settings menu - play sound based on current slider

  • #1, by sebastianMonday, 20. March 2017, 22:35 7 years ago
    hello fellas,

    recently im redesigning my settings menu and now i came to the point where i added sound sliders for all 5 different sound types:

    music
    sounds
    speech
    movies
    global

    when releasing the slider i want to play a sound file based off the value of the currently changed sound type.

    So when clicking or releasing the slider the following happens:

    music slider - no sound needed. Background music changes instantly, so you hear that it gets quiter/louder
    sounds slider - play a sound with play sound action part
    speech slider - display a narration text with " " as text an a linked sound
    movies slider - ???
    global slider - ???

    What do i need to play to get the sounds of the two last sliders played with the correct volume? 
    I can't just use a play sound action part on the other sliders, because when e.g. i set the sound volume to "0" i cant hear the sound on the other sliders...

    I found a lua player function (startsound) which has volume flag in it. But does it take the normal sounds as a channel or is this individual?

    Any suggestions how i achive the sound playback correctly? 


    kind regards
    Sebastian






    Thread Captain

    2346 Posts


  • #2, by afrlmeTuesday, 21. March 2017, 00:28 7 years ago
    Play sound with action part or Lua script openAL function at 100% volume - remember that 100% volume is only 100% of current global sound volume. If you want to use Lua script then you need to make sure you store sound files inside of a global table.
    sndz = {}
    
    sndz["footsteps"] = 
    {
    "vispath:sounds/footstep_1.ogg",
    "vispath:sounds/footstep_2.ogg"
    }
    
    sndz["random_fx"] =
    {
    "vispath:sounds/bang.ogg",
    "vispath:sounds/glass_breaking.ogg"
    }

    Then you could start a sound like so...
    startSound(sndz["random_fx"][2], {flags=1, volume=100}) -- play glass breaking sound fx


    Speech, just use a blank display or narration text with background ticked.

    P.S: I wouldn't bother with global or movie volume levels. Just leave them at 100% or for movie base it on either sound or speech volume.

    Imperator

    7278 Posts

  • #3, by sebastianTuesday, 21. March 2017, 08:13 7 years ago
    remember that 100% volume is only 100% of current global sound volume. 
    yeah and thats my problem here razz
    I need something independant. 

    I guess i will go and delete the movie + global slider then if there is no other way around. 

    Thread Captain

    2346 Posts

  • #4, by afrlmeTuesday, 21. March 2017, 11:19 7 years ago
    Global is the master volume for all volume levels. If you set that to say 70% then play a sound fx at 100% then it will actually be playing at 70%. If you play the sound at less than 100% then it would be whatever volume level percentage you specified of 70%. This is why I don't use global as it just complicates things.

    P.S: Lua openAL sound player volume is based on sound volume channel. I was also under the impression that it was independent from VS volume channels, but I found out that wasn't the case when I did a bit of freelance for Midnight at the Celestial Palace. I ended up having to redo the bit that played the sounds. The challenge was to do with having an additional volume slider for setting volume for the musical song parts of the game. If Lua sound engine isn't independent then how to have custom volume for it? In the end I opted for creating a value/variable to store the current speech volume value into then using narration text (background) to play the song parts & temporarily updating speech volume to the song volume. It was crude but it worked.

    Imperator

    7278 Posts