Volume control for different types of sound.

  • #1, by dos4gwFriday, 29. July 2016, 23:20 8 years ago
    Hi there. Just wondering if there was a way to designate some sound effects as a certain type, and then set up volume controls for the two different types of sounds. For instance, if I wanted a slider for both "Sound Effects" and also "Ambient Sounds" in the game menu.

    Could it be done?

    Newbie

    69 Posts


  • #2, by afrlmeSaturday, 30. July 2016, 01:14 8 years ago
    There's only music, voice, sounds, movies & global for in-editor sounds. You could do that for sounds played via Lua script though. Maybe play the ambient ones via that. You'd have to specify the default value that you want to play the sound at then calculate the actual percentage based on the volume percentage set in the menu.

    Some decent Lua tables would sort that out... mind you, you need to create tables for sound paths anyway if you decide to use the openAL sound engine via Lua script...
    var = "vispath:sounds/sound001.ogg" -- variable
    

    or...
    sndz = {}
    sndz["_temporary_"] = "" -- set it as temporary so as not to store data in save files
    
    sndz["ambient"] =
    {
      {path = "vispath:sounds/ambient/amb01.ogg" vol = 100, bal = 50, loop = true}
      {path = "vispath:sounds/ambient/amb02.ogg" vol = 55, bal = 25, loop = false}
      {...}
    }
    


    play sound...
    -- play sound in table index 1 with custom parameters...
    startSound(sndz["ambient"][1].path, {flags=1, volume=sndz["ambient"][1].vol, balance=sndz["ambient"][1].bal, loop=sndz["ambient"][1].loop})
    
    -- quickly play a sound with default settings...
    startSound(sndz["ambient"][1].path)
    

    Imperator

    7278 Posts

  • #3, by dos4gwSaturday, 30. July 2016, 02:26 8 years ago
    Wow, thanks! smile I'll look into setting this up.

    Newbie

    69 Posts

  • #4, by afrlmeSaturday, 30. July 2016, 02:36 8 years ago
    No problem mate. These links might be of use to you if you want to play / control sounds with Lua script...

    https://wiki.visionaire-tracker.net/wiki/StartSound_(CMS)
    https://wiki.visionaire-tracker.net/wiki/GetSoundId_(CMS)
    https://wiki.visionaire-tracker.net/wiki/GetSoundProperty_(CMS)

    https://wiki.visionaire-tracker.net/wiki/StopSound
    https://wiki.visionaire-tracker.net/wiki/SetSoundProperty
    https://wiki.visionaire-tracker.net/wiki/ToggleSoundPause

    P.S: sorry... I never got round to creating custom pages for each of the sound functions, so the last 3 links I posted are ones that were generated by VS itself. The syntax examples on some of the generated pages is not always that easy to understand which is why I started typing my own versions up by hand ages back.

    Imperator

    7278 Posts