How to implement global sound & music volume?

edited December 2015 in Help request
I'm trying to implement separate sound and music turn On/Off buttons. My intention is to implement this globally, so I don't have to check these settings separately all around the code and the ini. What is the best way to do this?

I'm currently inclined to add a handler for orxSOUND_EVENT_START events, and adjust the volume of the sound (multiply by 0 or 1 based on the relevant setting). Is this efficient? Will it still be playing the sound with 0 volume? Will there be any audible glitches? Is there any better way?



  • edited December 2015
    When this is in, it should rather be easy to do.

    At the moment, in Little Cells, I do what you suggested: I turn the sounds/musics volumes down to 0 when muted and back to what they should be when not muted. There shouldn't be any audible glitches (at least we don't have any) and we also use the orxSOUND_EVENT_START for that purpose. When a player switches a toggle, we just go over all the sounds/musics that are currently existing and update their volume accordingly.

    We have a couple of additional properties to handle things like unmute-able sounds or to handle more than just sounds vs musics, but those are really details that don't matter.
  • edited December 2015
    Thanks, so I should go ahead with what I planned. Just out of curiosity, how do you unmute existing sounds, you've lost their volume information when you multiplied by 0 after all? I'm thinking of doing some external book keeping, but I suspect you have something smarter in mind :)
  • edited December 2015
    I'm afraid not, I do the tracking on the side as well. :)
Sign In or Register to comment.