Random Music with Visionaire?

  • #10, by afrlmeTuesday, 03. March 2015, 14:59 9 years ago
    hmm? If you trigger set random value between x & y then it should change to another value, although there is a chance that it will return the same value. The larger the difference the less chance there will be of getting the same number again.

    You can also use Lua script to set a random number to a value too...
    Values["test"].Int = math.random(10) -- this would set a random value between 1 & 10 to value 'test'
    


    Feel free to combine scripting & action parts. It's entirely possible because of the execute a script action parts or the call script action parts.

    A loop? for?

    Imperator

    7278 Posts


  • #11, by MortoAllegroTuesday, 03. March 2015, 16:02 9 years ago
    i'll try to create an Action that goes in loop because, when a song is finished,i want the action part to choose a new one or stay silent for an amount of time and then reload a song.

    this is why, in my case i have 3 possibility. Two are songs, one are a pause for (60 90 80..ecc seconds)

    What i want to obtain in the end, is to have 2 or 3 songs that during the game are played randomly...i don't want them to being related to a single scene.
    obvious i also add a possibility in my loop that one of the choice is to play nothing.

    i don't know if i'll able to doing it..
    but,this is the plan..

    i'm working on an horror adventure game. and play short random music for me is a good way to obtain the right ambience..

    i'll try to combine scripting & action parts as you suggest..

    thanks a lot



    Newbie

    44 Posts

  • #12, by afrlmeTuesday, 03. March 2015, 16:25 9 years ago
    Does it matter when the sounds / music are triggered? or is the idea to have it select a random sound & play at random intervals?

    You can actually link values in Visionaire Studio to the pause action part which means if you use the set random value action part on a value that is linked to a pause action part that you can then use it to generate a dynamic delay time. I often employ that method for many things I do, as I'm a big fan of dynamic content.

    Quick note: I believe there is also an action part which can be used to pause the action list by making it wait until a linked sound has stopped playing so in effect you could create a dynamic loop like so... (action parts)
    set random value 'delay_music' between 5000 and 120000 -- would create random value between 5 seconds & 120 seconds (I used milliseconds)
    set  random value 'select_music' between 1 and 3
    pause for 'delay_music' milliseconds
    if value 'select_music' is 1
     play sound 'music_1'
     wait until sound 'music_1' is finished
     jump to action part #1
    end if
    if value 'select_music' is 2
     play sound 'music_2'
     wait until sound 'music_2' is finished
     jump to action part #1
    end if
    if value 'select_music' is 3
     play sound 'music_3'
     wait until sound 'music_3' is finished
     jump to action part #1
    end if
    

    ...I'm sure you get the idea? What I've done above is create a loop that automatically generates a random pause time & then randomly picks which audio file to play, which is then started by running an if query to see which value was generated. From there it waits until that sound is finished & then it loops back to the beginning of the action.

    The problem with using sounds is that they won't continue over into the next scene if the scene changes while a sound is playing. The problem with assigning an audio file as the background music is that it will loop indefinitely. The sounds method could also be recreated using Lua script, but you would have to use some other method of when to trigger new sounds as there's no wait until sound ends function for Lua script other than checking the current playtime of a playing sound against it's final playtime or checking if its id exists in the sound table.

    P.S: sorry for my large replies. I tend to ramble a little bit, as it's hard to try to explain things in detail in only a few short sentences.

    Imperator

    7278 Posts

  • #13, by MortoAllegroWednesday, 04. March 2015, 11:34 9 years ago
    thank you for all the effort you put on this post.
    i notice that sound doesn't live through scene, and if i'll change instead background music is it reproduced in loop indefinitely as you say..

    Recreated the sounds method using Lua script, i think is it to hard for my current knowledge..

    maybe i have to use visionaire in a more simple way for now..
    however i'll try to figure it out in the future 'cause i'm a big fan of dynamic event too.

    i hope They are working on an audio system much more flexible, because as i know now, is impossible to have more than one music for background, and we have to use soundPlay that does not goes through scene. in my case is it a problem because i have music background and a rain effect on my scene that i won't have it restart when player goes through scene.

    'couse for the rain i have to use play sound,when i change scene i have the rain sound fade out and than fade in effect, because it restart during the change scene.
    ^^

    however it's not a big deal ^^

    Newbie

    44 Posts

  • #14, by afrlmeWednesday, 04. March 2015, 16:25 9 years ago
    You could consider merging your bg sounds into the same audio file?

    Yes I believe Simon plans on overhauling the sound system for a future update. The idea is also to add some modulation effects that can be applied to sounds / channels such as reverb, filter cutoff, echo, delay etc. I have no idea when he will get around to it though as the dev team are currently busy with the upcoming bug fix release, which is mostly bug & optimization fixes, but it does have some new minor features which are quite useful.

    Imperator

    7278 Posts

  • #15, by MortoAllegroFriday, 06. March 2015, 09:45 9 years ago
    if i'll merge rain with bg music, there is a possibility that Player on the general option menu, wants to deactivate only the music for play only with sounds effects and speech, in this case even the Rain effects goes away with the bg music.

    i think i'll have to coexisting with my rain fade in/out through the scenes.

    ^^

    Newbie

    44 Posts