Fading between two background music files

  • #1, by andiliddellThursday, 29. January 2015, 01:05 10 years ago
    IS there any way to get a smooth fade/mix from one background music to another without an abrupt change?

    Can the tween lua engine be used to fade one sfx down as another is faded up?

    Any help would be much appreciated

    Forum Fan

    178 Posts

  • #2, by afrlmeThursday, 29. January 2015, 01:50 10 years ago
    Yes Lua can be used to control sounds but not ones directly linked to the editor (far as I know). You can start, stop, pause, control balance, volume & current play-time position of a sound started via Lua script.

    Please see here for a list of player functions. There are multiple functions listed on that page that are to do with sound. Each of the pages should contain an example.


    7278 Posts

  • #3, by andiliddellThursday, 29. January 2015, 14:25 10 years ago
    All understood, it's just the lack of a structured explanation of the syntax for me:

    Immediately setting Sfxvolume, musicvolume, global volume is no bother using something like:
    setSoundProperty(soundId, {flags=1, volume=20})

    Setting up a variable to a soundID and assigning a local file is also fine, it's the syntax for accessing these system variables in a larger function call like startTween that has always stumped me. to allow me to set this property over time so it incrementally fades the music.

    I understand how the tween statement is put together, (I used Greensock tween engine for AS3 for years) but it's the syntax to access the correct parameter of globalVolume or music Volume I can't find an example of.

    --Initially I set up a soundID var and get the local path to it, and start it playing:
    local soundId = startSound('vispath:assets/audio/music/valley.ogg')

    So the basic tween function takes any variable and tweens it over a set time with an easing:
    startTween("varstring", var, tweentothis, overthistime, easeQuadInOut)

    I need to plug in my local var soundID into this function, but its actually the "volume" parameter of the sound variable I want to tween over time, and I cannot find any syntax examples of this.. something like...??
    startTween("soundId", soundId.VOLUME, 20, 3000, easeQuadInOut)

    Can you give me any pointers on how to access a parameter of the sound object within a tween call, Ill be fine with the rest of it?

    Hope This makes sense razz

    Forum Fan

    178 Posts