Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Handling Music option [on/off]


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Jompe_71   Members   -  Reputation: 155

Like
0Likes
Like

Posted 11 March 2013 - 07:12 AM

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 



Sponsor:

#2 bollµ   Members   -  Reputation: 354

Like
1Likes
Like

Posted 11 March 2013 - 11:30 AM

AFAIK, you just set the output volume to zero, and disable any sound processing,


a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)


#3 Khatharr   Crossbones+   -  Reputation: 3037

Like
0Likes
Like

Posted 11 March 2013 - 08:45 PM

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.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#4 freeworld   Members   -  Reputation: 329

Like
0Likes
Like

Posted 12 March 2013 - 12:12 AM

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.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.

#5 BGB   Crossbones+   -  Reputation: 1554

Like
1Likes
Like

Posted 13 March 2013 - 03:34 AM

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, 13 March 2013 - 03:35 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS