Managing audio files

n my project I will have a lot of sound files.
Should I clean the buffer from these unused sounds?
If so, how can I do it?
I will be grateful for every hint.

1 Like

tons of really good docs on this…

https://www.google.com/search?q=babylonjs+sound&oq=babylonjs+sound&aqs=chrome..69i57.5563j0j7&sourceid=chrome&ie=UTF-8

thats where id look first : )

In addition we load our sound on delay (in a separate module lazy loaded):

/*********************************-CREATE-SOUNDS-******************************/
var createSonicz = function( ){ //
    nx.sonic.track1=new BABYLON.Sound("bg1","./sonic/nxBoomCore2cc0.mp3",nx.scene,null,{loop:false,autoplay:true, volume:0.04});
    nx.sonic.blip2= new BABYLON.Sound("blipIn1","./sonic/nxBlip2b.mp3", nx.scene, null, { loop: false, autoplay: false });
    BABYLON.Engine.audioEngine.setGlobalVolume(0.8); //0.02 is on the quiet side.
    nx.sonic.loaded=1;
    setTimeout(function(){
    	nx.sonic.theme1= new BABYLON.Sound("theme1","./sonic/nxTheme1.ogg", nx.scene, null, { loop: true, autoplay: false });
    },3000)
}
createSonicz();

We see sound is pretty heavy. we do not yet clean up unused sounds.

Probably better ways to delay sound (upcoming). We are light for PWA

1 Like

I was wondering this as well for particle systems.
I think it may be better to allocate early on what I need, and modify existing systems as I go.