Graphics

 View Only
  • 1.  Smooth Animation Based on Variable Distance

    Posted 11-04-2018 01:37
    Hi folks,

    I have a decibel meter which is hooked up to a microphone in our arena. Long story short, I've animated this meter to fill according to how loud the crowd is. It works, but the animation is choppy.
    I've set an animation controller to 100 frames , starting on 0 and ending on 100 to relate to the percentage of how much the decibel meter is filled.

    The decibel software is limited to updating once every 500ms, so is there a way to make the animation always take 15 frames (500ms) to complete when the start and stop point are different?
    I've included my code here because my explanation isn't the best. Please let me know if you have any suggestions.


    OnSetText:

    dim meter1 as xpTextObject
    dim meter2 as xpTextObject
    dim BarUp as xpAnimController
    dim divisor as integer
    dim minus as integer

    scene.GetObjectByName("DB1", meter1)
    scene.GetObjectByName("DB2", meter2)
    scene.GetAnimControllerByName("BAR UP", BarUp)

    divisor = 40
    minus = 60

    meter1.text = (self.text - minus) / divisor

    if meter1.text > meter2.text then
    BarUp.PlayRange(meter2.text * 100, meter1.text * 100)
    else if meter1.text < meter2.text then
    BarUp.PlayRange(meter2.text * 100, meter1.text * 100)
    end if

    meter2.text = meter1.text


  • 2.  RE: Smooth Animation Based on Variable Distance

    Posted 11-04-2018 09:43
    Hello Wes ,
    you can adjust the speed of your anim controller to match the duration of 500ms.
    BarUp.speed = Math.abs( CDbl(meter2.text * 100) - CDbl(meter1.text * 100) ) * constantfactorValue

    constantfactorValue will depend on your framerate and the total duration of your anim controller

    Also , to avoid jitter if the value is not updated exactly every 500ms , don't use the previous stored value, but use the current position of the animation instead
    BarUp.PlayRange(BarUp.Position, meter1.text * 100)


    Let's try this kind of script :

    dim BarUp as xpAnimController
    dim divisor as double
    dim minus as double

    if scene.GetAnimControllerByName("BAR UP", BarUp) then

    divisor = 40
    minus = 60

    Dim posCurrent as double ' current position in the animation
    Dim posToReach as double ' position to reach
    Dim constantfactorValue as double

    constantfactorValue = 1 ' value to compute to match the constant duration

    posCurrent = BarUp.position
    posToReach = (CDbl(Text) - minus) / divisor * 100
    BarUp.speed = Math.abs( posToReach - posCurrent ) * constantfactorValue ' speed adjust
    BarUp.PlayRange(posCurrent, posToReach)


    end if


    Hope it helps
    #XPression


  • 3.  RE: Smooth Animation Based on Variable Distance

    Posted 11-07-2018 18:15
    I'd love to get more information on your decibel meter integration. What meter are you using?
    #XPression


  • 4.  RE: Smooth Animation Based on Variable Distance

    Posted 11-08-2018 22:51
    Thanks for your responses folks. I won't be back in the control room for a couple weeks
    I'll try your suggestion and get the info on the decibel meter. Stay tuned.
    #XPression


  • 5.  RE: Smooth Animation Based on Variable Distance

    Posted 11-24-2018 22:13
    Amignon, your code looks promising but we are having an issue with the decibel meter not outputting any values (first time since it was installed four years ago!). Unfortunately I'll have to try it later.

    Cam, the software is called LAMA from lama-audio.net. It looks as though the microphone is just plugged into the mic input on a Mac Pro.
    #XPression


  • 6.  RE: Smooth Animation Based on Variable Distance

    Posted 11-25-2018 02:05
    I'm going to follow this one too.

    #XPression


  • 7.  RE: Smooth Animation Based on Variable Distance

    Posted 12-22-2018 03:31
    Ok folks I finally got this working... and the code is much simpler than I originally had.

    dim meter1 as xpTextObject
    dim meter2 as xpTextObject
    dim BarUp as xpAnimController
    dim divisor as integer
    dim minus as integer
    dim constantFactorValue as double

    scene.GetObjectByName("DB1", meter1)
    scene.GetObjectByName("DB2", meter2)
    scene.GetAnimControllerByName("BAR UP", BarUp)

    divisor = 40
    minus = 60
    constantFactorValue = 0.07 'speed adjustment value

    meter1.text = (self.text - minus) / divisor

    BarUp.speed = Math.abs(meter2.text * 100 - meter1.text * 100) * constantFactorValue
    BarUp.PlayRange(meter2.text * 100, meter1.text * 100)

    meter2.text = meter1.text


    I got rid of the "if statement" after I realized both conditions resulted in the same outcome. Feel free to use this as you wish. Let me know if you have any comments or questions about this!
    This works because my source is always being updated every 500ms. If your refresh rate is variable, you would have to use something else.
    #XPression