Background music

  • #1, by dimmarkThursday, 18. April 2013, 12:18 8 years ago
    Hallo,

    I would like to add background music which will be the same for some scenes and won't be restatred when then player enters in a new scene.

    Is there any way to do that?

    Thanks for your help

    Newbie

    1 Posts


  • #2, by afrlmeThursday, 18. April 2013, 12:43 8 years ago
    you just have to tick the "continue music from the previous scene" check box, in the scene properties tab.

    Imperator

    6842 Posts

  • #3, by gustySaturday, 20. April 2013, 05:37 8 years ago
    And is it possible to make a volume of the music based on the distance? Let say there is a guitarist on the street (one big scrolling scene) and he is playing the guitar. When player stands right in front of him, then the music volume is 100%, but when he starts walking away from the guitarist along the street, then the music volume fading away... and player keeps walking off and music is weaker and weaker... 80%.. 70%.. Do you know what I mean? Is it possible to do so in the Visionaire?

    Forum Fan

    159 Posts

  • #4, by afrlmeSaturday, 20. April 2013, 13:22 8 years ago
    yes with Lua Script & mainLoop event handler & then some code to check character position vs object position, which you then have to calculate (somehow) into a percentage.

    I have been working on a dynamic footstep script which defines footstep volume & walk speed based on characters current scale & audio balance based on characters x position on a screen; but this can only really be done in the next release of Visionaire Studio where you have access to the audio Lua commands; amongst other things.

    P.S: I may, at some point add some examples of what can be done with the new
    Lua audio commands for the next release, to the new documentation wiki; stuff like audio panning, fade in/out, executing functions based on current playtime of a sound file etc.

    Imperator

    6842 Posts

  • #5, by gustySaturday, 20. April 2013, 17:08 8 years ago
    Thanks for comment AFRLme, do you have an idea when next release of Visionaire will be out?

    Forum Fan

    159 Posts

  • #6, by afrlmeSaturday, 20. April 2013, 17:14 8 years ago
    nope, sorry - not as yet.
    David & Alex are still busy working on things.

    * I will upload an exported demo of what the script does that I've been working on in a little while - just making a few final touches to the script & project file.

    Imperator

    6842 Posts

  • #7, by gustySaturday, 20. April 2013, 17:17 8 years ago
    OK, thanks man! Looking forward to try your demo.

    Forum Fan

    159 Posts

  • #8, by afrlmeSunday, 21. April 2013, 17:06 8 years ago
    And is it possible to make a volume of the music based on the distance? Let say there is a guitarist on the street (one big scrolling scene) and he is playing the guitar. When player stands right in front of him, then the music volume is 100%, but when he starts walking away from the guitarist along the street, then the music volume fading away... and player keeps walking off and music is weaker and weaker... 80%.. 70%.. Do you know what I mean? Is it possible to do so in the Visionaire?


    Ok so I have written a new script which plays sounds from the character with the volume based on character scale size (plus/minus a small random value. to add dynamic feel) & audio balance is based on current x position of character in the current camera view point (what you can currently see)

    --[[
    Character sound & property functions (v1.0)
    Written by AFRLme
    -- * --
    label@alternatingfrequencies.com, aim/skype: AFRLme
    --]]

    function playCharSound(char, sound)
    local tbl = {} -- create an empty table
    tbl["_temporary_"] = "" -- set table as temporary
    tbl["character"] = getObject("Characters[" .. char .. "]") -- store current character
    tbl["character_size"] = tbl["character"]:getInt(VCharacterSize) -- get linked characters current scale
    tbl["character_pos"] = tbl["character"]:getPoint(VCharacterPosition).x -- get linked characters current x pos
    tbl["random_val"] = math.random(-5, 5) -- for adding/subtracting from sound volume (dynamic reasons)
    tbl["volume"] = tbl["character_size"] + tbl["random_val"] -- adds or subtracts random value from volume level
    tbl["screen_center"] = (game:getPoint(VGameWindowResolution).x / 2) + game:getPoint(VGameScrollPosition).x -- find current scene center x pos
    -- * check if position of character to screen center to determine if audio balance % should be a positive or negative value
    if tbl["character_pos"] < tbl["screen_center"] then tbl["balance"] = - ((tbl["screen_center"] - tbl["character_pos"]) / (game:getPoint(VGameWindowResolution).x / 2) * 100) end -- inverse balance %
    if tbl["character_pos"] >= tbl["screen_center"] then tbl["balance"] = ((tbl["character_pos"] - tbl["screen_center"]) / (game:getPoint(VGameWindowResolution).x / 2) * 100) end -- positive balance %
    -- * break * --
    startSound(tblSounds[sound][1], {flags=1, volume=tbl["volume"], balance=tbl["balance"]})
    -- * debug * --
    --print("character name: " .. char .. ", size: " .. tbl["character_size"] .. ", x pos: " .. tbl["character_pos"])
    --print("volume: " .. tbl["volume"] .. ", original volume: " .. tbl["character_size"] .. ", random value: " .. tbl["random_val"])
    --print("screen center: " .. tbl["screen_center"])
    --print("balance: " .. tbl["balance"] .. "\n")
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28

    you need to create a table containing sounds for this to work & it works by executing a script > playCharSound("character_name", "sound_name")
    this won't work in the current version obviously but I thought I would share.

    What you are asking for is somewhat more complicated because we have to take into consideration both the characters x & y position from the object to calculate the volume percentage (%) & as of yet, I have no clue how to calculate this, because I really hate math & I am not very good at it. (it would have to be done with the mainLoop event handler too)

    I wonder if it would be possible to hard code it into the engine itself & have it as an option (will have to ask David later - if I remember)

    * edit: bloody emoticons (no idea why they are being added to the code box itself)

    Imperator

    6842 Posts

  • #9, by esmeraldaTuesday, 23. April 2013, 17:57 8 years ago
    A possible workaround could be to create some action areas in the scene (spaced along the scene) with an action setting the volume at 90%, 80%...
    Just an idea - haven't tried it yet

    Great Poster

    389 Posts

  • #10, by gustyTuesday, 23. April 2013, 18:00 8 years ago
    It sounds like an elegant solution in its theory, I'll definitely try that.

    Forum Fan

    159 Posts

  • #11, by afrlmeTuesday, 23. April 2013, 18:13 8 years ago
    it is possible, the way Esmeralda mentioned - a bit more effort involved & somewhat less accurate but very do-able smile

    Imperator

    6842 Posts

Write post