ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.62k stars 809 forks source link

bug with sound.position issue on imported .mp3s: Conductor Volume game #5019

Open zumbasana opened 3 years ago

zumbasana commented 3 years ago

Hello to the Ruffle team, Adrian17 on discord asked me to post our issues here. We are happy to post our AS2 code, .swfs, and test!

GAME ONLINE: game: https://goclassical.org/kids/opera/volume.htm And .swf and .fla and .swd attached. VolumeGame2021.zip

PROBLEM: No Audio and game doesn't display 4 little volume slider controls below conductor and game does not move forward to play. The .swd debugger says the .mp3s loaded... -- WORKS when "test movie" from Macromeda Flash Professional 8 authoring app. -- NOT WORKING when playing same exported .sfw on desktop (runs Macromedia Flash Player 8). -- NOT WORKING in html page with Ruffle on server: https://goclassical.org/kids/opera/volume.htm

EXPECTED BEHAVIOR: there's 4 little volume slider controls below conductor, setting volume for the 4 imported .mp3s: they should display and allow user to drag up-and-down, setting volume. At end of mp3s, triggers 2 buttons (repeat and continue) to display.

ISSUE: Adrian17 wrote on Discord #help: " I think we have volume control working, but not the more advanced sound features (like sound.position)" I can confirm that yes this game does use sound1.position, sound2.position, etc.

Thank you!

zumbasana commented 3 years ago

AS2 code from first frame of game (this is a 1-frame game):

//stop(); preloader_mc.bar_mc._xscale = 0; // play_btn.onRollOver = function(){ this.gotoAndPlay("over"); } play_btn.onRollOut = function(){ this.gotoAndPlay("up"); } play_btn.onRelease = function(){ this.gotoAndPlay("down"); _root.play(); } replay_btn.onRollOver = function(){ this.gotoAndPlay("over"); } replay_btn.onRollOut = function(){ this.gotoAndPlay("up"); } replay_btn.onRelease = function(){ this.gotoAndPlay("down"); _root.game_mc.loadMovie("VolumeGame2021.swf"); this._visible = false; /sound1.start(0,0); sound2.start((sound1.position/1000),0); sound3.start((sound1.position/1000),0); sound4.start((sound1.position/1000),0); sound1.setVolume(volume1); sound2.setVolume(volume2); sound3.setVolume(volume3); sound4.setVolume(volume4); play_btn._visible = false; replay_btn._visible = false;/ } play_btn._visible = false; replay_btn._visible = false; // var test1:Boolean = false; var test2:Boolean = false; var test3:Boolean = false; var test4:Boolean = false; // var sound1:Sound = new Sound(); sound1.loadSound("volume_winds.mp3", false); var sound2:Sound = new Sound(); sound2.loadSound("volume_brass.mp3", false); var sound3:Sound = new Sound(); sound3.loadSound("volume_percussion.mp3", false); var sound4:Sound = new Sound(); sound4.loadSound("volume_strings.mp3", false); //

// sound1.onLoad = function() { test1 = true; trace("Sound1 ready ..."); message_txt.text ="Sound1 ready ..."; }; sound2.onLoad = function() { test2 = true; trace("Sound2 ready ..."); message_txt.text ="Sound2 ready ..."; }; sound3.onLoad = function() { test3 = true; trace("Sound3 ready ..."); message_txt.text ="Sound3 ready ..."; }; sound4.onLoad = function() { test4 = true; trace("Sound4 ready ..."); message_txt.text ="Sound4 ready ..."; }; // slave1_mc.onEnterFrame = function() { preloader_mc.message_txt.text = ("Loading:"+Math.floor((sound1.getBytesLoaded()+sound2.getBytesLoaded()+sound3.getBytesLoaded()+sound4.getBytesLoaded() )/(sound1.getBytesTotal()+sound2.getBytesTotal()+sound3.getBytesTotal()+sound4.getBytesTotal())100)+"%"); preloader_mc.bar_mc._xscale = ((sound1.getBytesLoaded()+sound2.getBytesLoaded()+sound3.getBytesLoaded()+sound4.getBytesLoaded() )/(sound1.getBytesTotal()+sound2.getBytesTotal()+sound3.getBytesTotal()+sound4.getBytesTotal())100); if (test1 == true && test2 == true && test3 == true && test4 == true) { sound1.start(0,0); sound2.start((sound1.position/1000),0); sound3.start((sound1.position/1000),0); sound4.start((sound1.position/1000),0); sound1.setVolume(80); sound2.setVolume(80); sound3.setVolume(80); sound4.setVolume(80); trace("playing ..."); preloader_mc._visible = false; slave1_mc.onEnterFrame = undefined; } }; // slide1_mc.onPress = function(){ this.startDrag(false,this._x, 520, this._x, 615); windIcon_mc.gotoAndStop("down"); conductor_mc.gotoAndStop("winds"); } slide1_mc.onRelease = function(){ stopDrag(); windIcon_mc.gotoAndStop("up"); } slide1_mc.onReleaseOutside = function(){ stopDrag(); windIcon_mc.gotoAndStop("up"); } slide2_mc.onPress = function(){ this.startDrag(false,this._x, 520, this._x, 615); brassIcon_mc.gotoAndStop("down"); conductor_mc.gotoAndStop("brass"); } slide2_mc.onRelease = function(){ stopDrag(); brassIcon_mc.gotoAndStop("up"); } slide2_mc.onReleaseOutside = function(){ stopDrag(); brassIcon_mc.gotoAndStop("up"); } slide3_mc.onPress = function(){ this.startDrag(false,this._x, 520, this._x, 615); percIcon_mc.gotoAndStop("down"); conductor_mc.gotoAndStop("perc"); } slide3_mc.onRelease = function(){ stopDrag(); percIcon_mc.gotoAndStop("up"); } slide3_mc.onReleaseOutside = function(){ stopDrag(); percIcon_mc.gotoAndStop("up"); } slide4_mc.onPress = function(){ this.startDrag(false,this._x, 520, this._x, 615); stringIcon_mc.gotoAndStop("down"); conductor_mc.gotoAndStop("strings"); } slide4_mc.onRelease = function(){ stopDrag(); stringIcon_mc.gotoAndStop("up"); } slide4_mc.onReleaseOutside = function(){ stopDrag(); stringIcon_mc.gotoAndStop("up"); } // var slide1Y = 520; var difference1 = 0; var volume1 = 100; var volume1a = 100; // slave2_mc.onEnterFrame = function(){ difference1 = (slide1Y - slide1_mc._y); volume1 += (difference1); winds_mc._alpha = volume1; sound1.setVolume(volume1); slide1Y = slide1_mc._y; difference1 = 0; volume1a = Math.floor(volume1); } // var slide2Y = 520; var difference2 = 0; var volume2 = 100; var volume2a = 100; // slave3_mc.onEnterFrame = function(){ difference2 = (slide2Y - slide2_mc._y); volume2 += (difference2); brass_mc._alpha = volume2; sound2.setVolume(volume2); slide2Y = slide2_mc._y; difference2 = 0; volume2a = Math.floor(volume2); } // var slide3Y = 520; var difference3 = 0; var volume3 = 100; var volume3a = 100; // slave4_mc.onEnterFrame = function(){ difference3 = (slide3Y - slide3_mc._y); volume3 += (difference3); percussion_mc._alpha = volume3; sound3.setVolume(volume3); slide3Y = slide3_mc._y; difference3 = 0; volume3a = Math.floor(volume3); } // var slide4Y = 520; var difference4 = 0; var volume4 = 100; volume4a = 100; // slave5_mc.onEnterFrame = function(){ difference4 = (slide4Y - slide4_mc._y); volume4 += (difference4); strings_mc._alpha = volume4; sound4.setVolume(volume4); slide4Y = slide4_mc._y; difference4 = 0; volume4a = Math.floor(volume4); } sound1.onSoundComplete = function(){ play_btn._visible = true; replay_btn._visible = true;

} stop();


Ann Zumwinkle

ousia commented 3 years ago

@zumbasana, many thanks for reporting the issue.

sound.position() has been reported as not implemented already in issue #340 and PR #4273 will implement it.

Just in case it helps.

zumbasana commented 3 years ago

Thank you very much Ousia/Herschel for bumping this issue up, and I'm available to assist with testing anytime!

zumbasana commented 3 years ago

Hello @Herschel and team! Thanks much for working on audio-mixer issues in the new Pull Request here: https://github.com/ruffle-rs/ruffle/pull/5231 which seems related to our audio sound.position issue. Quick update from me: I installed the most recent Ruffle download: view-source:https://goclassical.org/ruffle/ruffle.js but our volume game still hangs up when getting to sound.position: https://goclassical.org/kids/opera/volume.htm another of our games relies on sound.position heavily and no sound plays at all: https://goclassical.org/kids/brahms/brahms-game Thank you for any advice!

zumbasana commented 3 years ago

Hi @Herschel and team, This might also help; here is code from another game module of ours, Brahms in Vienna, that also utilizes audio sound .mp3 imports.

GAME ONLINE: https://goclassical.org/kids/brahms/brahms-game

and .swf and .fla attached. base-AZ2021.zip

-- NOT WORKING in HTML page with today's recent version of Ruffle on server (link above) -- WORKS when "test movie" exported from Flash Professional 8.

And here is pertinent AS2 code from the third and fourth AS2-coded frames:

stop(); // var congrats:Sound = new Sound(); congrats.loadSound("https://goclassical.org/kids/brahms/sound/dialog_congrats.mp3",false); var brahms1:Sound = new Sound(); brahms1.loadSound("https://goclassical.org/kids/brahms/sound/Brahms_1.mp3",false); var ferd3:Sound = new Sound(); ferd3.loadSound("https://goclassical.org/kids/brahms/sound/Ferdinand_3.mp3",false); var brahms2:Sound = new Sound(); brahms2.loadSound("https://goclassical.org/kids/brahms/sound/Brahms_2.mp3",false); var muhlfeld1:Sound = new Sound(); muhlfeld1.loadSound("https://goclassical.org/kids/brahms/sound/Muhlfeld_1.mp3",false); var ferd4:Sound = new Sound(); ferd4.loadSound("https://goclassical.org/kids/brahms/sound/Ferdinand_4.mp3",false); var muhlfeld2:Sound = new Sound(); muhlfeld2.loadSound("https://goclassical.org/kids/brahms/sound/Muhlfeld_2.mp3",false); var klimt1:Sound = new Sound(); klimt1.loadSound("https://goclassical.org/kids/brahms/sound/Klimt_2.mp3",false); var ferd5a:Sound = new Sound(); ferd5a.loadSound("https://goclassical.org/kids/brahms/sound/Ferdinand_5a.mp3",false); var hausmann1:Sound = new Sound(); hausmann1.loadSound("https://goclassical.org/kids/brahms/sound/Hausmann_1.mp3",false); var ferd5b:Sound = new Sound(); ferd5b.loadSound("https://goclassical.org/kids/brahms/sound/Ferdinand_5b.mp3",false); var hausmann2:Sound = new Sound(); hausmann2.loadSound("https://goclassical.org/kids/brahms/sound/Hausmann_2.mp3",false); var klimt2:Sound = new Sound(); klimt2.loadSound("https://goclassical.org/kids/brahms/sound/Klimt_3.mp3",false); //set the above to Stop when you want this. Declare Variables: desiredTotal is the amount of the total in percent that you want loaded var percent = 0; var finalBytes = 0; var now = 0; var desiredTotal = 1 var totalSound = (congrats.getBytesTotal()+brahms1.getBytesTotal()+ferd3.getBytesTotal()+brahms2.getBytesTotal()+muhlfeld1.getBytesTotal()+ferd4.getBytesTotal()+muhlfeld2.getBytesTotal()+klimt1.getBytesTotal()+ferd5a.getBytesTotal()+hausmann1.getBytesTotal()+ferd5b.getBytesTotal()+hausmann2.getBytesTotal()+klimt2.getBytesTotal()); //------------------------------------ display_txt.text = "loading sounds"; divide_txt.text = "xxx/xxx kb"; bar_mc._xscale = 0; //------------------------------------ loadSound = function () { now = (congrats.getBytesLoaded()+brahms1.getBytesLoaded()+ferd3.getBytesLoaded()+brahms2.getBytesLoaded()+muhlfeld1.getBytesLoaded()+ferd4.getBytesLoaded()+muhlfeld2.getBytesLoaded()+klimt1.getBytesLoaded()+ferd5a.getBytesLoaded()+hausmann1.getBytesLoaded()+ferd5b.getBytesLoaded()+hausmann2.getBytesLoaded()+klimt2.getBytesLoaded()); finalBytes = totalSound; percent = Math.floor((now/finalBytes)*100); if (percent<100) { bar_mc._xscale = percent; display_txt.text = "loading: "+percent+" %"; divide_txt.text = (Math.floor(now/1000))+" / "+(Math.floor(finalBytes/1000))+" kb"; }else { bar_mc._xscale = 100; display_txt.text = "loading complete 100%"; slave1_mc.onEnterFrame = undefined; play(); } }; //------------------------------------ slave1_mc.onEnterFrame = function() { trace(percent); loadSound(); };

var cue_sound:Sound = new Sound(); cue_sound.loadSound("https://goclassical.org/kids/brahms/sound/cue_01_op25.mp3", true); cue_sound.setVolume(50); cue_sound.onSoundComplete = function(){ cue_sound.start(0,1); }

Thanks guys very much!

Herschel commented 3 years ago

Adding here for reference: https://github.com/ruffle-rs/ruffle/pull/5482#issuecomment-944993256

midgleyc commented 3 years ago

Think this is waiting on Sound.loadSound (non-streaming version).

Ref #273.

n0samu commented 2 years ago

Since #6738 was merged the sound is now working. Strangely, only the leftmost volume slider seems to be working though - the others have no effect. And the "Again" and "Next" buttons aren't working.

Lord-McSweeney commented 1 year ago

There's still some sound lag, but all the sliders work now.

n0samu commented 1 year ago

@Lord-McSweeney I don't think so. Open the webpage with a Flash-enabled browser and drag the 3 sliders on the right all the way down, leaving only the leftmost slider turned up. Hear how different that sounds? Now try the same thing in Ruffle. It has no effect, even with the latest Ruffle version.