I've tried fixing this by checking if 1 is less than or equal to peak and if it is then the acceleration should be 0 - my gravitational constant, but that doesn't seem to prevent the peak from rising above 1.
I've included the skin itself as an attachment to this post, but the main measures are
Code: Select all
[Variables]
Gravity = 0.00327
[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
[MeasureL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS
[MeasureL_Accel]
Measure = Calc
Formula = 1.0 <= MeasureL_Peak ? 0 - #Gravity# : MeasureL >= MeasureL_Peak + ( MeasureL >= MeasureL_Peak ? MeasureL - MeasureL_Peak : MeasureL_Accel - #Gravity# ) ? MeasureL - MeasureL_Peak : MeasureL_Accel - #Gravity#
[MeasureL_Peak]
Measure = Calc
Formula = MeasureL_Accel + MeasureL_Peak
MeasureL_Accel creates an acceleration value for the peak by this code
MeasureL >= MeasureL_Peak + ( //Check if sound is greater than peak + what the current acceleration would be if it were applied
MeasureL >= MeasureL_Peak ? // If the sound level is greater than or equal to the peak
MeasureL - MeasureL_Peak : // then return the difference between the sound level and the peak, this creates an upward impulse for the peak
MeasureL_Accel - #Gravity# // otherwise return this value minus the gravitational constant, this provides a decelerating value
) ?
MeasureL - MeasureL_Peak :
MeasureL_Accel - #Gravity#
MeasureL_Peak simply adds the acceleration value to itself so when the acceleration is positive it moves upward, and when acceleration is negative it moves downward.
Using Clamp in the peak formula would prevent the peak from reaching crazy levels, but it doesn't prevent acceleration from pinning peak to the top of the meter. I've tried using clamp in the acceleration formula like
Formula = Clamp(MeasureL >= MeasureL_Peak + ( MeasureL >= MeasureL_Peak ? MeasureL - MeasureL_Peak : MeasureL_Accel - #Gravity# ) ? MeasureL - MeasureL_Peak : MeasureL_Accel - #Gravity#,-10,1-MeasureL_Peak) to make the limit of the acceleration the difference between 1 and the peak, with the intention of when peak is at 1 the acceleration clamp is at 0, but that still seems to pin the peak with peak at 1 and acceleration a positive value.