gcardozo Posted August 28, 2017 Share Posted August 28, 2017 Hi, I have a folder with 23MB of sounds (including music), all of them are in .ogg format because I need to support really old browsers. When loading those sounds, memory usage goes up to 900MB. If I comment the lines below, it stays about 90MB. What am I doing wrong? Controller.numMusic = 5; //Load music: for (var i = 0; i < Controller.numMusic; i++) { let soundName:string = "music" + i; this.game.load.audio(soundName, "assets/audios/music/" + soundName + ".ogg"); } this.game.load.audio("menu", "assets/audios/music/menu.ogg"); this.game.load.audio(ESounds.ACERTOU, "assets/audios/" + ESounds.ACERTOU + ".ogg"); this.game.load.audio(ESounds.ERROU, "assets/audios/" + ESounds.ERROU + ".ogg"); this.game.load.audio(ESounds.ANDANDO, "assets/audios/" + ESounds.ANDANDO + ".ogg"); this.game.load.audio(ESounds.CAINDO, "assets/audios/" + ESounds.CAINDO + ".ogg"); this.game.load.audio(ESounds.CLICK_BT, "assets/audios/" + ESounds.CLICK_BT + ".ogg"); this.game.load.audio(ESounds.CLICK_RUN, "assets/audios/" + ESounds.CLICK_RUN + ".ogg"); this.game.load.audio(ESounds.GRAB_ARTIFACT, "assets/audios/" + ESounds.GRAB_ARTIFACT + ".ogg"); this.game.load.audio(ESounds.PUT_ARTIFACT_ALTAR, "assets/audios/" + ESounds.PUT_ARTIFACT_ALTAR + ".ogg"); this.game.load.audio(ESounds.BREAK_ARTIFACT, "assets/audios/" + ESounds.BREAK_ARTIFACT + ".ogg"); Link to comment Share on other sites More sharing options...
samme Posted August 28, 2017 Share Posted August 28, 2017 I think the browser just needs to decode and store a lot of audio. Link to comment Share on other sites More sharing options...
gcardozo Posted August 28, 2017 Author Share Posted August 28, 2017 @samme is there any work around to improve it? Link to comment Share on other sites More sharing options...
samme Posted August 28, 2017 Share Posted August 28, 2017 Use shorter sounds or load fewer sounds at a time, I guess. Link to comment Share on other sites More sharing options...
samid737 Posted August 29, 2017 Share Posted August 29, 2017 Don't think your doing it wrong it's alot of audio. I would combine all music to one /two audio files, all fx to a single file and use audio sprites to mark each sound. If your game works with different states, carefully manage loading and unloading in each state. Link to comment Share on other sites More sharing options...
gcardozo Posted September 1, 2017 Author Share Posted September 1, 2017 @samid737 do you know how much memory is usually saved by combining all audios into one audio sprite instead of using several Phaser.Sound? Link to comment Share on other sites More sharing options...
samid737 Posted September 2, 2017 Share Posted September 2, 2017 I have no clue, it will still depend on final filesize come to think of it. For my own game the music was pretty repetitive, so I would chop the unncessary and have an intro and chorus part and loop those two using markers. the music went from 800kB to 100kB, but it depends on what kind of music you have if this will work or not. Link to comment Share on other sites More sharing options...
samme Posted September 2, 2017 Share Posted September 2, 2017 I don't think it's unusual that the memory use is larger than the size of the compressed audio files. The browser needs to decode them before it can play them. I'd guess the music accounts for most of that. Link to comment Share on other sites More sharing options...
fitness23 Posted September 13, 2017 Share Posted September 13, 2017 It's best practice to stage loading files. 23mb is a lot to load right from the outset. Try only loading sounds just before the scene where they are to be used. Then after that scene clear the cache before you load the new ones needed for the next scene. gcardozo 1 Link to comment Share on other sites More sharing options...
Recommended Posts