It is currently September 8th, 2024, 12:10 am

Audio Peak Level not dropping

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Audio Peak Level not dropping

Post by Yincognito »

sl23 wrote: July 10th, 2024, 10:01 pmSo it's like a shorthand IfCondition? [...] I mean, I get it in principal, but how this is achieved I can't figure out where to start.
Yincognito wrote: July 10th, 2024, 10:47 pmI might think about it in the following days, if I'm in the mood.
Well, the mood finally arrived, and it turned out that the matter was as simple as a few nested conditionals, no pausing, no additional time measure. This behaves both similar and slightly different than the previous code - make sure you read and understand the explanation if you want to work with this... ;-)

The code:

Code: Select all

[Variables]
Update=25
HoldTime=0
HoldMost=1000
FallStep=0.01

[Rainmeter]
Update=#Update#
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=128,128,128,255

---Measures---

[Rmsq]
Measure=Plugin
Plugin=AudioLevel

[Peak]
Measure=Plugin
Plugin=AudioLevel
Parent=Rmsq
Type=Peak

[Hold]
Measure=Calc
Formula=(Rmsq>Hold-#FallStep#*(#HoldTime#>#HoldMost#?1:0)?Rmsq:(#HoldTime#>#HoldMost#?Hold-#FallStep#:Hold))
OnUpdateAction=[!SetVariable HoldTime ([Hold]=[Rmsq]?0:#HoldTime#+#Update#)]
DynamicVariables=1

---Meters---

[Result]
Meter=String
FontFace=Consolas
MeasureName =Rmsq
MeasureName2=Hold
MeasureName3=Peak
NumOfDecimals=5
Text=Rmsq = %1#CRLF#Hold = %2#CRLF#Peak = %3
DynamicVariables=1

[Visual]
Meter=Shape
X=5R
Y=0r
Shape =Rectangle 0, 0,        150 ,48 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 128,128,128,255
Shape2=Rectangle 0, 0,([Rmsq]*150),16 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 255,  0,  0,255
Shape3=Rectangle 0,16,([Hold]*150),16 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color   0,255,  0,255
Shape4=Rectangle 0,32,([Peak]*150),16 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color   0,  0,255,255
DynamicVariables=1
The preview:
Desktop_2024_07_12_00_24_39_714.gif
The variables:
- Update is the time interval in ms between updates
- HoldTime is the time counter in ms
- HoldMost is the maximum time interval in ms that Hold will keep its value
- FallStep is how fast Hold will decrease each update after HoldMost ms have passed

The measures:
- Rmsq is the standard RMS value (red color)
- Hold is the value we're interested in (green color)
- Peak is the standard Peak value (blue color)

The process:
1) we either make Hold to be Rmsq, if the latter is greater than the former - this can happen either:
- before or during the HoldMost interval, in which case we compare Rmsq with Hold normally, since Hold doesn't change otherwise
- after the HoldMost interval has passed, in which case we compare Rmsq with Hold-FallStep, since we're going to subtract FallStep from Hold later on
2) or otherwise, if Rmsq is not greater than Hold - we can safely replicate the keep and fall effect from the spectrum analyzer GIF earlier:
- decrease Hold by FallStep each update, if the HoldMost interval has passed, to gradually drop Hold as desired
- keep Hold the same, if the HoldMost interval has not yet passed, to make Hold stick for better observation
3) finally, on each Hold update - we:
- reset HoldTime to 0, if Hold is equal to Rmsq i.e. we either started, ended, or got out of the keep and decrease interval for Hold according to the 1) point
- increase HoldTime by Update, if otherwise i.e. we're during the keep and decrease interval for Hold and we need to count time

The notes:
- you'll have to duplicate and use HoldTime and Hold under different names (and optionally HoldMost and / or FallStep, if you want different keep intervals and / or decrease speeds) for every instance/value you want to make a "Hold" value for
- if curious, this keep and decrease technique can easily be applied to the standard Peak instead, by replacing all 3 occurrences of Rmsq in Hold with Peak (which is why I placed Hold after Peak in the code, despite their order in the meters)
- as in the previous code, the Peak measure is entirely optional, unless of course you want to see it keep and decrease instead of the RMS value



Hopefully everything is clear and solved now and we can close this chapter - if this is still not what you want, then this is where my help ends in this case. Next time, you'll be the one to figure it all out - seriously. :D

EDIT: Optionally, if you want to shorten the code (at the expense of having the inherent measure benefits), you could even transform the Hold measure into a Hold variable and put it all in the OnUpdateAction of the standard measure you want to "keep and decrease" (Rmsq case illustrated below, similar approach for the standard Peak measure), once you use the [#Hold] nested syntax for the Hold variable in the 2nd bang, e.g.:

Code: Select all

[Variables]
Update=25
HoldTime=0
HoldMost=1000
FallStep=0.01
Hold=0

[Rainmeter]
Update=#Update#
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=128,128,128,255

---Measures---

[Rmsq]
Measure=Plugin
Plugin=AudioLevel
OnUpdateAction=[!SetVariable Hold ([Rmsq]>#Hold#-#FallStep#*(#HoldTime#>#HoldMost#?1:0)?[Rmsq]:(#HoldTime#>#HoldMost#?#Hold#-#FallStep#:#Hold#))][!SetVariable HoldTime ([#Hold]=[Rmsq]?0:#HoldTime#+#Update#)]
DynamicVariables=1

---Meters---

[Result]
Meter=String
FontFace=Consolas
MeasureName =Rmsq
NumOfDecimals=5
Text=Rmsq = %1#CRLF#Hold = #Hold#
DynamicVariables=1

[Visual]
Meter=Shape
X=5R
Y=0r
Shape =Rectangle 0, 0,        150 ,32 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 128,128,128,255
Shape2=Rectangle 0, 0,([Rmsq]*150),16 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 255,  0,  0,255
Shape3=Rectangle 0,16,(#Hold#*150),16 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color   0,255,  0,255
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1600
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Audio Peak Level not dropping

Post by sl23 »

That's brilliant, thank you so much. :thumbup:
I'll take a look at it properly later. :rosegift:

I have already implemented the last code, and set it up for measuring peaks instead of RMS, works perfect. Looking forward to getting this one working in place of it though! Thanks :thumbup:
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Audio Peak Level not dropping

Post by Yincognito »

sl23 wrote: July 12th, 2024, 9:30 am That's brilliant, thank you so much. :thumbup:
You're welcome, glad to help. ;-)

Now, since I solved this, thought about building myself a lil' band skin for the unlikely moment when my skins will get bigger... 8-)
Desktop_2024_07_12_12_41_25_241.gif
Looks almost like this one, isn't it? Except I didn't have the patience to make 70+ bands. :D
sl23 wrote: July 7th, 2024, 8:43 pm Made a Gif to make it easier to see :)
Image
Easier to see on the high frequencies. The Peaks go up as soon as they are 'hit' by the volume bar under it, then stay there for 1000ms, as that's the setting I made for it, then drops to the level of the next reading given by where the volume bar is at.
sl23 wrote: July 12th, 2024, 9:30 amand set it up for measuring peaks instead of RMS, works perfect
Yep, it works with them too. Me, I prefer the RMS, it behaves just like the sample GIF you posted. :lol:

By the way, not sure if you checked it, if it works properly and is flexible enough, or if it has a hold setting for peaks, but while trying to replicate the Winamp spectrum analyzer, I found this plugin by rxtd:
https://forum.rainmeter.net/viewtopic.php?t=31091

I edited my previous post with an optional more compact approach that uses a single measure at the end.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1600
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Audio Peak Level not dropping

Post by sl23 »

Excellent! :thumbup: :D
Looks great. I'm all for compressing the code where possible. I'm so impressed by your shape meter approach that I've adopted it into all my skins where I can. It's reduced so much so far. I'm really stuck on trying to figure out why it isn't working on drives bar at the moment. But that's another story! :Whistle :sly:

Really like what you've done with that spectrum analyser. Perhaps you could make it 48 pixels high set Z pos to stay topmost and stick it on the taskbar. :D
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Audio Peak Level not dropping

Post by Yincognito »

Using a shape meter might be compact, but if hundreds of shapes are added to it, it does take a bit of CPU. But then, so do other choices, just slightly less.

Yeah, the spectrum analyzer is just a replica of your gif, which I liked and represented my model / objective in this case. I know what you mean with sticking it on the taskbar, but my skins are on the opposite side of the screen (the bottom of the screen is inconvenient as it conflicts with other full screen apps like video players and such and their display / controls), and my taskbar is 30px not 48, lol. That being said, I like the end result too, it helped a lot with having a positive mood to tackle this final stage of the project. :D

By the way, do you - or anyone else, for that matter - happen to know the AudioLevel settings to make the spectrum analyzer like the Winamp / Foobar one? Cause the bands and their distribution are not that similar... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1600
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Audio Peak Level not dropping

Post by sl23 »

More CPU? :o lol That's ok, my CPU rarely goes above 1%! :D

Oh yeah Win10 taskbar is smaller! It's been a few years since then, ah the memories! :x :rofl:

What exactly do you need? Would the settings screenshot help?
Btw, that first gif of foobar was from Foobar v1 which was 32bit. Foobar v2 was made for both 32/64bit. I chose to go with 64bit so all my plugins had to be upgraded. A few weren't available hence why the second gif has a different analyser graphic display. I prefer the old one, which isn't updated anymore. But the newer one is being developed, slowly!
sshot-004.png
Hope that helps. :D
You do not have the required permissions to view the files attached to this post.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Audio Peak Level not dropping

Post by Yincognito »

sl23 wrote: July 12th, 2024, 9:10 pm Hope that helps. :D
It does, at least the FFT Size, since the others are not expressed in the same "units" as inAudioLevel. Thanks! :thumbup:
In the audio skin from my suite, I use:

Code: Select all

[MS_AudioLevel_Output]
Group=AudioLevelGroup | OutputGroup
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=15
RMSDecay=250
RMSGain=1.5
FFTSize=4096
FFTOverlap=2048
FFTAttack=150
FFTDecay=300
Bands=24
FreqMin=20
FreqMax=24000
Sensitivity=25
That seems to somewhat resemble the Winamp / Foobar spectrum analyzer, but I would have been interested in how exactly these settings relate to the number of bands, what is the frequency interval displayed in those players, and how to set these to resemble the spectrum analyzer in those players as much as possible (ideally, identical). For example, in the spectrum analyzer with the "hold" values I showcased above, I have some trouble making the "form" of the bars look like in the player. Obviously, I now have 100 such bars, so I guess that plays a part as well. :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1600
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Audio Peak Level not dropping

Post by sl23 »

It's the least I can do after everything you've done for me! Glad to be able to help if I can.

I'm off PC now so will help tomorrow.

I think it's based on keyboard frequencies so the key A4=440Hz. As the keyboard frequencies can be shown or hidden.

Iirc, the interval can be user specified, sort of. Not quite sure at present. Although long time since I set that up. It may even be automated depending on window width. In fact, I think it is. So, wider the window, more bands are shown. I'll double check tomorrow when I get time.

100 bars! :jawdrop
57686174 77696C6C 6265 77696C6C 6265
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5502
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Audio Peak Level not dropping

Post by eclectic-tech »

Yincognito wrote: July 12th, 2024, 10:26 pm It does, at least the FFT Size, since the others are not expressed in the same "units" as inAudioLevel. Thanks! :thumbup:
In the audio skin from my suite, I use:

Code: Select all

[MS_AudioLevel_Output]
Group=AudioLevelGroup | OutputGroup
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=15
RMSDecay=250
RMSGain=1.5
FFTSize=4096
FFTOverlap=2048
FFTAttack=150
FFTDecay=300
Bands=24
FreqMin=20
FreqMax=24000
Sensitivity=25
That seems to somewhat resemble the Winamp / Foobar spectrum analyzer, but I would have been interested in how exactly these settings relate to the number of bands, what is the frequency interval displayed in those players, and how to set these to resemble the spectrum analyzer in those players as much as possible (ideally, identical). For example, in the spectrum analyzer with the "hold" values I showcased above, I have some trouble making the "form" of the bars look like in the player. Obviously, I now have 100 such bars, so I guess that plays a part as well. :???:


When using FFT you do not need the RMS or Peak calculated by the plugin (unless you plan on using them outside of the spectrum analyzer). I would disable RMS and Peak as described in the AudioLevel docs; set the Gain for each to 1 and the related attack and decay to zero. The RMS settings will control the attack and decay; I usually leave the RMSGain at 1. The "gain" for FFT display is controlled by the "Sensitivity" setting; I usually leave it at default 30 and let the end user change it if needed.

The number of defined bands will be used to display the frequencies available based on the range you set. The precision is based on the FFTSize (higher values yield more accurate displays but also use more CPU).
I usually set the frequency range to a low of 50 Hz~16000 Hz which covers the common human hearing range. I would recommend not using Band0 as it is not properly calculated in this plugin (see 3rd party "AudioAnalyzer" plugin for "Comparison to AudioLevel"); I calculate Band0 but do not use it in the display.

You can see the Frequency for each Band by creating child measures of the Type=BandFreq to see the frequency of each band; I have not had success when trying to use this and actually I do not care that much about the actual frequency because the entire frequency range will be displayed based on the number of defined Bands.

To display the 'peak' for each FFT, I usually create a separate measure to control that meter; I believe you could use your solution for RMS peak to control the display (the hold time and drop time) of each FFT peak meter.

Hope this helps.

EDIT: Corrected info on RMS settings
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Audio Peak Level not dropping

Post by Yincognito »

sl23 wrote: July 12th, 2024, 10:49 pm I think it's based on keyboard frequencies so the key A4=440Hz. As the keyboard frequencies can be shown or hidden.

Iirc, the interval can be user specified, sort of. Not quite sure at present. Although long time since I set that up. It may even be automated depending on window width. In fact, I think it is. So, wider the window, more bands are shown. I'll double check tomorrow when I get time.

100 bars! :jawdrop
Oh, I see, that clarifies things a bit indeed. Take your time, is not urgent, it's just something I always wondered, instead of making (even an educated) guess. Appreciate the help! :rosegift:

Yeah, with 100 bars there are actually 200 ShapeN= options in the meter - one for the RMS and one for the Hold (plus the gradient lines for each of them, so around 400 lines in total in the meter). It takes around 10% of my CPU at 25 ms Update, but then it's much easier to comment out something you already have, than adding 2 corresponding measures and 4 lines in the meter each time you need another bar, lol.

P.S. I have my own technique of simplifying mass editing in Notepad++: I repeatedly add the 0 to 9 stuff via copy paste and then simply regex replace to add the relevant indexes for the next set of 10 by inserting 1, 2, 3, and so on in front of the 0..9 in a "semi-automated" manner. It takes some time, but I make my job easier as well, so it's not as much effort as it could be for a strictly manual approach.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth