It is currently April 23rd, 2024, 11:10 am

Peak on a ballistic trajectory sticks at the top of the meter

Get help with creating, editing & fixing problems with skins
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Peak on a ballistic trajectory sticks at the top of the meter

Post by Bekarfel »

Hello, I'm stealing jsmorley's SoundLevelMeter skin and modifying it so that it has ballistic peak meters. I think I've got the ballistic acceleration part correct. My problem is when the sound is particularly energetic the peak will stick at the top of the meter as the value goes above 1.
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
Someone asked if I had tried the clamp function, but I don't believe that will fix this issue.
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.
You do not have the required permissions to view the files attached to this post.
moshi wrote:there are many Rainmeter skins that aren't really useful, so let's add another one.
jsmorley wrote:I have good news and bad news.
First the bad news. [...] We would be happy to have this happen and would love to work with anyone who is feeling ambitious.
Now the good news.
I lied, there isn't any good news...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by eclectic-tech »

By resetting the AudioLevel default values for RMS and Peak, then adjusting the Gain values seems to keep your formulas within limits.
I tried different gain values but settled on 2.0 for the RMS and 3.0 for Peak. They may peak sometimes but will fall back fairly quick.

I did not disect your acceleration formula since these changes seem to help.

Code: Select all

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=300
RMSDecay=300
RMSGain=2.0
PeakAttack=50
PeakDecay=2500
PeakGain=3.0
Sensitivity=35

peak.gif
You do not have the required permissions to view the files attached to this post.
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by Bekarfel »

I appreciate the input, but smoothing the meter so the peak doesn't bounce off the meter doesn't address the issue of the peak sticking to the ceiling, and defeats the effect I am going for. I did take your advice into consideration and set new meter values which gave a better effect, here's a screen capture of your values on the left meter, and my new updated values on the right
Peak Meter Examples.gif
But my original issue of the peak sticking at the top of the meter still exists.
You do not have the required permissions to view the files attached to this post.
moshi wrote:there are many Rainmeter skins that aren't really useful, so let's add another one.
jsmorley wrote:I have good news and bad news.
First the bad news. [...] We would be happy to have this happen and would love to work with anyone who is feeling ambitious.
Now the good news.
I lied, there isn't any good news...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by eclectic-tech »

To prevent "pinning" at the top of your scale, add MinValue and MaxValue to the [MeasureL_Peak] and [MeasureR_Peak] measures and set the MaxValue to slightly more than '1', since your acceleration is setting a value beyond 100%.

Code: Select all

...

[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
MinValue=0
MaxValue=1.25

[MeasureR_Accel]
Measure = Calc
Formula =  (1.0 <= MeasureR_Peak ? 0 - #Gravity# : (MeasureR >= MeasureR_Peak + ( MeasureR >= MeasureR_Peak ? MeasureR - MeasureR_Peak : MeasureR_Accel - #Gravity# ) ? MeasureR - MeasureR_Peak : MeasureR_Accel - #Gravity#))

[MeasureR_Peak]
Measure = Calc
Formula = MeasureR_Accel + MeasureR_Peak
MinValue=0
MaxValue=1.25

...
I do not know what 'effect' you are trying to achieve, and we may be having completely different ideas.
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by Bekarfel »

Here is the original effect I'm trying to achieve, this screen capture is not Rainmeter:
Real Player.gif
I'm trying to modify it so that when the peak hits the top it doesn't stay there, but falls back immediately, like
Peak ideal operation.gif
I tried what you suggested, setting MaxValue to 1.25 and it looks like it sinks the peak into the meter.
Peak Test 2.gif
You do not have the required permissions to view the files attached to this post.
moshi wrote:there are many Rainmeter skins that aren't really useful, so let's add another one.
jsmorley wrote:I have good news and bad news.
First the bad news. [...] We would be happy to have this happen and would love to work with anyone who is feeling ambitious.
Now the good news.
I lied, there isn't any good news...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by eclectic-tech »

Add measures for the 'Peak' values and display those to show as the separate bars. Play with the attack and decay of both RMS and PEAK to get the reactions you want. Basically, a longer decay causing those bars to remain higher longer.

Code: Select all

[Rainmeter]
Update=16
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=SoundLevel
Author=JSMorley
Version=August 16, 2014
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=BitMap Demonstration of new AudioLevel Plugin from dgrace||Left click to test channels||Latest version of the plugin is available at:|http://rainmeter.net/forum/viewtopic.php?p=101823#p101823

[Variables]
; Gravity = 0.00327

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=300
RMSDecay=300
RMSGain=1.0
PeakAttack=50
PeakDecay=1000
PeakGain=1.0
Sensitivity=35

[MeasureL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS

[MeasureLPeak]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=Peak

[MeasureR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS

[MeasureRPeak]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=Peak

[MeterBack]
Meter=Image
W=52
H=425
SolidColor=47,47,47,255
UpdateDivider=-1
LeftMouseUpAction=[Play "#@#Sounds\AudioTest.wav"]

[MeterL]
Meter=BitMap
MeasureName=MeasureL
X=5
Y=5
BitMapImage=#@#Images\LevelBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterR]
Meter=BitMap
MeasureName=MeasureR
X=3R
Y=5
BitMapImage=#@#Images\LevelBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterPeakL]
Meter=BitMap
MeasureName=MeasureLPeak
X=5
Y=5
BitMapImage=#@#Images\PeakBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterPeakR]
Meter=BitMap
MeasureName=MeasureRPeak
X=3R
Y=5
BitMapImage=#@#Images\PeakBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterLText]
Meter=String
X=12
Y=1R
FontFace=Trebuchet MS
FontSize=8
FontColor=200,200,200,255
AntiAlias=1
Text=L
UpdateDivider=-1

[MeterRText]
Meter=String
X=35
Y=0r
FontFace=Trebuchet MS
FontSize=8
FontColor=200,200,200,255
AntiAlias=1
Text=R
UpdateDivider=-1

Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by Bekarfel »

You're suggesting my peak be completely tethered to the audio output, but that doesn't make sense to me at all. To be honest, I don't think you understand the effect I'm trying to achieve, or I don't understand how you believe what you are suggesting will achieve the effect. I'd like a second opinion on what I could do to prevent the peak pinning.
moshi wrote:there are many Rainmeter skins that aren't really useful, so let's add another one.
jsmorley wrote:I have good news and bad news.
First the bad news. [...] We would be happy to have this happen and would love to work with anyone who is feeling ambitious.
Now the good news.
I lied, there isn't any good news...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by eclectic-tech »

Bekarfel wrote: February 25th, 2023, 6:27 am You're suggesting my peak be completely tethered to the audio output, but that doesn't make sense to me at all. To be honest, I don't think you understand the effect I'm trying to achieve, or I don't understand how you believe what you are suggesting will achieve the effect. I'd like a second opinion on what I could do to prevent the peak pinning.
Here my second opinion (and last)... simply add a second AudioLevel parent measure and set the RMSDecay to 2-3 times the default value. Then use that measure as the parent to display the "floating" peaks.

Code: Select all

[Rainmeter]
Update=16
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=SoundLevel
Author=JSMorley
Version=August 16, 2014
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=BitMap Demonstration of new AudioLevel Plugin from dgrace||Left click to test channels||Latest version of the plugin is available at:|http://rainmeter.net/forum/viewtopic.php?p=101823#p101823

[Variables]

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output

[MeasureAudioDelay]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSDecay=900

[MeasureL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS

[MeasureR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS

[MeasureLDelay]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioDelay
Channel=L
Type=RMS

[MeasureRDelay]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioDelay
Channel=R
Type=RMS

[MeterBack]
Meter=Image
W=52
H=425
SolidColor=47,47,47,255
UpdateDivider=-1
LeftMouseUpAction=[Play "#@#Sounds\AudioTest.wav"]

[MeterL]
Meter=BitMap
MeasureName=MeasureL
X=5
Y=5
BitMapImage=#@#Images\LevelBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterR]
Meter=BitMap
MeasureName=MeasureR
X=3R
Y=5
BitMapImage=#@#Images\LevelBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterPeakL]
Meter=BitMap
MeasureName=MeasureLDelay
X=5
Y=5
BitMapImage=#@#Images\PeakBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterPeakR]
Meter=BitMap
MeasureName=MeasureRDelay
X=3R
Y=5
BitMapImage=#@#Images\PeakBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterLText]
Meter=String
X=12
Y=1R
FontFace=Trebuchet MS
FontSize=8
FontColor=200,200,200,255
AntiAlias=1
Text=L
UpdateDivider=-1

[MeterRText]
Meter=String
X=35
Y=0r
FontFace=Trebuchet MS
FontSize=8
FontColor=200,200,200,255
AntiAlias=1
Text=R
UpdateDivider=-1

Why not use the options already available in the plugin over an external formula?
We can agree to disagree. :rosegift:
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by Bekarfel »

eclectic-tech wrote: February 25th, 2023, 2:26 pmWhy not use the options already available in the plugin over an external formula?
We can agree to disagree. :rosegift:
When I use the options in the audiolevel plugin, the resulting dynamic is based solely on the audiolevel plugin. No matter how much attack, decay, or gain set in the plugin, fundamentally the movement of the target meter is based on the audio going to the plugin. My concept peak is disconnected from the audio level, the only thing the audio level does is provide an impulse to the peak to give it animation.
In my original effect the only dependence on the audio level is when the peak meets the bar. At any other time the only thing it is doing is accelerating downward.
moshi wrote:there are many Rainmeter skins that aren't really useful, so let's add another one.
jsmorley wrote:I have good news and bad news.
First the bad news. [...] We would be happy to have this happen and would love to work with anyone who is feeling ambitious.
Now the good news.
I lied, there isn't any good news...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Peak on a ballistic trajectory sticks at the top of the meter

Post by eclectic-tech »

I can be single-minded sometimes, so sorry for not addressing your original question about pinned bars...

Acceleration/Deacceleration are a result of a change in values over a time period.

I can't follow your formulas but for me a simpler possibility is to use a second set of measures to get the average change over a time and compare those to the current level to set the acceleration/deacceleration value and clamp the minimum value to the current measure value.

Something like this:

Code: Select all

; Acceleration/Deacceleration is the change in value over a time period
; Use the Update rate for the skin as the time and comparing the current level to the running average determines the speed and direction of change

[Rainmeter]
Update=#Updater#
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=SoundLevel
Author=JSMorley;Bekarfel;Eclectic Tech
Version=August 16, 2014
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=BitMap Demonstration of new AudioLevel Plugin from dgrace||Left click to test channels||Latest version of the plugin is available at:|http://rainmeter.net/forum/viewtopic.php?p=101823#p101823

[Variables]
Updater=32

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSGain=2

[MeasureL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS

[MeasureR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS

[MeterBack]
Meter=Image
W=52
H=425
SolidColor=47,47,47,255
UpdateDivider=-1
LeftMouseUpAction=[Play "#@#Sounds\AudioTest.wav"]

[MeterL]
Meter=BitMap
MeasureName=MeasureL
X=5
Y=5
BitMapImage=#@#Images\LevelBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

[MeterR]
Meter=BitMap
MeasureName=MeasureR
X=3R
Y=5
BitMapImage=#@#Images\LevelBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1

; Get average left sound level
[MeasureL2]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS
AverageSize=#Updater#

; Get average right sound level
[MeasureR2]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS
AverageSize=#Updater#

; Compare current left to average left to determine Acceleration ~ Deacceleration
[MeasureL_Accel]
Measure = Calc
Formula=MeasureL>=MeasureL2? ((MeasureL-MeasureL2)) : (-(MeasureL2-MeasureL))

; Set left accel ~ deaccel clamped at current level
[MeasureL_Peak]
Measure = Calc
Formula = Clamp(MeasureL_Accel + MeasureL,MeasureL,1)

; Compare current right to average right to determine Acceleration ~ Deacceleration.
[MeasureR_Accel]
Measure = Calc
Formula=MeasureR>=MeasureR2? ((MeasureR-MeasureR2)) : (-(MeasureR2-MeasureR))

; Set right accel ~ deaccel clamped at current level
[MeasureR_Peak]
Measure = Calc
Formula = Clamp(MeasureR_Accel + MeasureR,MeasureR,1)

[MeterPeakL]
Meter=BitMap
MeasureName=MeasureL_Peak
X=5
Y=5
BitMapImage=#@#Images\PeakBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1;

[MeterPeakR]
Meter=BitMap
MeasureName=MeasureR_Peak
X=3R
Y=5
BitMapImage=#@#Images\PeakBitmapLarge.png
BitMapFrames=101
BitmapZeroFrame=1;

[MeterLText]
Meter=String
X=12
Y=1R
FontFace=Trebuchet MS
FontSize=8
FontColor=200,200,200,255
AntiAlias=1
Text=L
UpdateDivider=-1

[MeterRText]
Meter=String
X=35
Y=0r
FontFace=Trebuchet MS
FontSize=8
FontColor=200,200,200,255
AntiAlias=1
Text=R
UpdateDivider=-1

I only change the RMSGain value to set average sounds near the center of the bar display.