It is currently March 27th, 2023, 10:41 am

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

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

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

Post by Bekarfel »

May I try to explain my formula? I believe it's quite simple, but I could have a poor perspective on the formula
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: 5038
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 »

Yes, your thoughts on developing a formula are welcomed.

In use, I don't think there is an issue with your acceleration formula; I believe the "ballistic" reaction is due to how it is applied.

You add the acceleration to your audiolevel to get the initial value, but then on the next update, if the audiolevel is still higher, you take that sum (accleration AND audiolevel) and add acceleration and audiolevel again, effectively doubling the result. I think that is why we was seeing values up to 15 to 20 times the actual audiolevel.

There are several ways to get a slowly diminishing peak bar, and I would like to see you succeed in this idea. :thumbup:
Bekarfel
Posts: 215
Joined: May 16th, 2012, 5:38 am

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

Post by Bekarfel »

The formula basically compares the current audio level (MeasureL) with the previous peak level (MeasureL_Peak) and adjusts the acceleration (MeasureL_Accel) accordingly. If the current audio level is higher than the previous peak level plus some threshold, then the formula sets the acceleration to be equal to the difference between them. If the current audio level is lower than that threshold, then the formula subtracts a constant gravity value from the acceleration. I've made a google doc simulator of this function to maybe help understand how it functions. You can edit the values in the MeasureL column to see its response. https://docs.google.com/spreadsheets/d/1vX-LFLPIm7NqsGekEeooVlopRXKG63XuhTuAd5pn6qQ/edit?usp=sharing
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: 5038
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 »

Sorry for the delay getting back here...

I had a chance to look at this and as far as I can tell, the cause for the "ballistic" reaction is due to your conditional statement nesting confusing Rainmeter.

If I bracket your nested tests with parenthesis, then the acceleration behaves as expected.

I changed the Formula for acceleration (this is for left) to:

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 = Clamp(MeasureL_Accel + MeasureL_Peak,0,1)
I did added a Clamp on [MeasureL_Peak] to prevent it from going negative, which would allow the peak bar to go below the current audio level.

This eliminates pinning the peak (unless you increase the RMSGain), but it may also not show enough of a reaction for your desired effect.
gravity.gif
Full code

Code: Select all

[Rainmeter]
Update=15
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
Gain=2.5

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=300
RMSDecay=300
RMSGain=#Gain#

[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"]
MiddleMouseUpAction=[!SetOption MeterL MeasureName "MeasureL_Peak"][!SetOption MeterR MeasureName "MeasureR_Peak"]

[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

[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 = Clamp(MeasureL_Accel + MeasureL_Peak,0,1)

[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 =  Clamp(MeasureR_Accel + MeasureR_Peak,0,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

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

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

Post by Bekarfel »

That change works perfectly for the peak pinning. Thank you so much for your help Eclectic. I'll have to keep in mind the parentheses are required in nested conditionals. For reference, here's my peak with your fixes applied, and I think it works great! that first peak hit doesn't pin any more, and I went through the entire song and didn't get any peaks pinned to the top.
I've had a think about how to address the perceived unresponsiveness of the meter, and one thing I've noticed is that the AudioLevel meter doesn't always update every frame. My google doc simulation is influenced by small reductions in MeasureL, I think this is a result of some error in the threshold to determine if the peak is going to clip the Measure. I'm not sure what to do about AudioLevel or the apparent bug in my math, so I doubled the update time, doubled gravity, and it looks like this
Peak Performance.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: 5038
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 »

That looks much better to me! :D I really like the motion you achieve with this acceleration/gravity method. :thumbup:

Tweaking the acceleration formula and skin variables should get you closer to the animation effect you are looking for...
I'll probably play with those to see if a better response can be achieved, but you have it working pretty well. :great:
Bekarfel
Posts: 215
Joined: May 16th, 2012, 5:38 am

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

Post by Bekarfel »

I made some changes to the formula to give it more of the effect that I wanted, especially where it was getting pinned at the top it behaves more realistically now. Let me know what you think. The meter on the left is the new one, meter on the right is the original
Peak pong.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: 5038
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: March 3rd, 2023, 1:45 am I made some changes to the formula to give it more of the effect that I wanted, especially where it was getting pinned at the top it behaves more realistically now. Let me know what you think. The meter on the left is the new one, meter on the right is the original {clip Image}
The left looks a bit more responsive. :great: It would be interesting to see your formula changes or the skin code... :Whistle
Bekarfel
Posts: 215
Joined: May 16th, 2012, 5:38 am

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

Post by Bekarfel »

Well, ya see, the first thing I did was to hard lock Rainmeter, as is tradition. :bow: Next I remembered, aha! parentheses! and rewrote the -MeasureL_Accel * 0.75 which crashes Rainmeter as (0 - MeasureL_Accel) * 0.75. This went into the sections that define the peak range limits: where 1.0 <= MeasureL_Peak, and where MeasureL_Peak <= MeasureL.

Formula = (1.0 <= MeasureL_Peak ? (0 - MeasureL_Accel) * 0.75 : (MeasureL >= MeasureL_Peak + ( MeasureL >= MeasureL_Peak ? MeasureL - MeasureL_Peak : MeasureL_Accel - #Gravity# ) ? Max(MeasureL - MeasureL_Peak,(0 - MeasureL_Accel) * 0.75) : MeasureL_Accel - #Gravity#))
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: 5038
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 »

8-) Thanks!