Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

Trigger animations and actions by song position

  • #1, by Lebostein 9 years ago Zitieren
    For example a guitar player. He should move his arm fast at fast song parts and slow at slow song parts. Or he should speak the song text at specific song positions. How I can do that? How I can trigger animations or actions at specific song positions?

    Thanks!
  • #2, by afrlme 9 years ago Zitieren
    For example a guitar player. He should move his arm fast at fast song parts and slow at slow song parts. Or he should speak the song text at specific song positions. How I can do that? How I can trigger animations or actions at specific song positions?

    Thanks!
    One of two ways I guess...

    1. by using the pause action parts to control when to play a specific kind of animation or force which frames of an animation should be looped with the AnimationFirstFrame & AnimationLastFrame data structure fields.
    -- force animation "example" to loop between frames 3 to 5
    ActiveAnimations["example"].AnimationFirstFrame = 3
    ActiveAnimations["example"].AnimationLastFrame = 5


    2. Optionally you could play the song with Lua script via the openAL player & then use a mainLoop to query the current playback position (offset) to start an animation or call an action. It's probably closer to what you are asking, but a lot more complicated than the action part method & it's possible that the mainLoop could miss the range window if the queried values are too small.

    3. Actually, yes I know I said 1 of 2 ways but I just thought of another solution that might work as I don't think sounds fade in/out when you play them, so what you could do is chop up the song into parts, then you play one & then start the animation or action associated with it & then add a wait until sound "x" has finished playing then immediately play the next sound & so on.

    Whichever way you go about it will require a bit of hard work & some patience.

    Good luck. wink
  • #3, by Lebostein 9 years ago Zitieren
    Thanks for the hints. It is possible to examine the song position of the current music (in milliseconds for example) directly? Or other way: can I set the song position of the current music? I have programmed with FMOD long time ago an there was functions like SetPosition() and GetPosition() for music streams... Maybe there are similar things in the Visionaire music system.
  • #4, by sebastian 9 years ago Zitieren
    yes. via lua and the getSoundProperty function:

  • #5, by Lebostein 9 years ago Zitieren
    Ah! Now I have all the things I need. Thanks!
  • #6, by afrlme 9 years ago Zitieren
    Quick note: I recommend querying a range rather than a single specific time value as the time between each loop with the mainLoop event handler varies on each loop so in theory it's entirely possible that you could miss such a narrow window.

    By range, I mean something like: >= 1000 & < 1500.
    local sndID = getSoundId("vispath:sounds/example.ogg")
    local sndOffset = getSoundProperty(sndID, "offset")
    
    if sndOffset >= 1000 and sndOffset < 1500 then
     startAction("Actions[action 1]")
    elseif sndOffset >= 1500 and sndOffset < 2000 then
     startAction(Scenes["x"].SceneActions["action 2"])
    end


    The safest approach would be the third option I mentioned, but using a Lua script approach would probably save a lot of time overall.

    * edit: code blocks seem to be automatically adding in ; for some reason.