Sign in to follow this  
Jompe_71

Handling Music option [on/off]

Recommended Posts

Jompe_71    166

Hi,

 

How do you "usually" handle to option in a game to toggle music on/off. Do you load/unload the sounds or do you load all sounds on startup and just toggle the volume between mute/unmute to save load time and potential lag?

 

// Jonas 

Share this post


Link to post
Share on other sites
Khatharr    8812
Well, if the sound is off during loading and then the user turns it on what will you do?

You should probably be streaming your music unless you're using a midi-style format, which is trivial to load.

To turn music on or off just make the update function for the music processing conditional.

Share this post


Link to post
Share on other sites
freeworld    341
Ths s how. Would do it. And Im pretty sure several tripple a games. Play do it this way. When sound is turned off they just shut down the audio module. Then when sou d is turned back on. They juat allow the sound kodule to do what it does. This ofcourse cause a delay from the point you turned music on to the point music starts playing.... but nicely uandled sfreaming should cut off that delay.

Basically if sound is turned off... you dont need to load sounds I to memory... not like the resources are beng used. Then when sound is turned back on. Load/stream the reaourcea back I. Till tbey are good enough to play.

Realze nothing in pogramming a game is ever going to be perfect... just like a carpenter good programmers make hacks look and act li ke perfection... its not always perfect under the hood.

From my phone. Sorry for the bad spelling.

Share this post


Link to post
Share on other sites
cr88192    1570

Well, if the sound is off during loading and then the user turns it on what will you do?

You should probably be streaming your music unless you're using a midi-style format, which is trivial to load.

To turn music on or off just make the update function for the music processing conditional.

FWIW:
in my engine, the music playback (if actually used) is basically just a normal mixer channel, which plays back without attenuation (it is basically equivalent to an unattenuated ambient noise being emitted from the "worldspawn" entity, so is basically under server control).

otherwise IIRC there is a flag to indicate to the server to multiply the channel volume with the client's BGM volume setting prior to mixing.

given the way the mixer is implemented, if the channel mix volume is 0 (for normal streams, this would often be due to attenuation), the mixer will skip processing them (it still may update the sample position, but wont mix any samples).

if/when to load sounds involves some tradeoffs though (in my case though, they are mostly just demand-loaded on first use, as this was fairly straightforward, though both precaching and also load-when-audible are also possible options). Edited by cr88192

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this