It is currently March 28th, 2024, 12:47 pm

Audio visualiser - Change BarColor based on value

Get help with creating, editing & fixing problems with skins
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

Audio visualiser - Change BarColor based on value

Post by DigitalEssence »

Hi,

I've built myself a simple audio volume display using:

Code: Select all

[MeasureAudioOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=10
RMSGain=10
IfCondition=MeasureAudioOutput > 50
IfTrueAction=[!SetOption MeterAudioOutput] BarColor 255,0,0,255]
IfFalseAction=[!SetOption MeterAudioOutput] BarColor 255,255,255,255]
DynamicVariables=1

[MeterAudioOutput]
Meter=BAR
MeasureName=MeasureAudioOutput
X=0
Y=0
W=25
H=200
And I was hoping to be able to get the bar colour to change depending on the level but it is just showing as green (I assume that's the default colour when it can't find any colour) so it's not picking up either True or False actions.

I've tried changing the IfCondition to:

IfCondition=(([MeasureAudioOutput]/[MeasureAudioOutput:MaxValue]) * 100) > 50 but to no avail.

I've also tried the following code from one of my previous fan speed checks to warn me if a fan fell below minimum speeds:

Code: Select all

IfCondition=MeasureAudioOutput > 20
IfTrueAction=[!SetOption MeterAudioOutput BarColor 255,0,0,255]
IfCondition2=MeasureAudioOutput < 20
IfTrueAction2=[!SetOption MeterAudioOutput BarColor #BarColor#]
OnUpdateAction=[!UpdateMeter MeterAudioOutput][!Redraw]
And that didn't work either.

My String output is displaying the value going over the level required to trigger.

Code: Select all

[MeterAudioLevel]
Meter=STRING
MeterStyle=styleTitle
MeasureName=MeasureAudioOutput
X=0
Y=0
W=290
H=14
Text=LEVEL %1%
Percentual=1
So I'm guessing its something to do with the value being output differently, as per this previous ticket of mine.

https://forum.rainmeter.net/viewtopic.php?f=5&t=25508
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Audio visualiser - Change BarColor based on value

Post by eclectic-tech »

You have a "]" in your IfConditions that prevent them from working... but you also need to understand what the measure is returning for values.

The AudioLevel plugin returns values from 0~1. It will never be more than 1, so your IfCondition will never be true.
The typo prevents the IfFalse from setting it to 'white'.

Your string meter will return 0~100 percent based on the measure values from 0~1 and Percentual=1, so 50% in your string meter is actually 0.5 in the audio measure.

IfConditions are always dynamic, so you shouldn't need DynamicVariables=1

Try this code:

Code: Select all

[MeasureAudioOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=10
RMSGain=10
IfCondition=MeasureAudioOutput > 0.5
IfTrueAction=[!SetOption MeterAudioOutput BarColor "255,0,0,255"]
IfFalseAction=[!SetOption MeterAudioOutput BarColor "255,255,255,255"]
; DynamicVariables=1

[MeterAudioOutput]
Meter=BAR
MeasureName=MeasureAudioOutput
X=0
Y=0
W=25
H=200
BarColor=255,255,255,255
There are many ways to color the bar using audio.
You could do it right in the meter using BarColor=(255-([MeasureAudioOutput]*255)),255,(255-([MeasureAudioOutput]*255)) and add DynamicVariables=1. This will reduce the Red & Blue colors as the audio gets louder.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Audio visualiser - Change BarColor based on value

Post by balala »

On the IfTrueAction and IfFalseAction options of the [MeasureAudioOutput] measure you have some unnecessary brackets: IfTrueAction=[!SetOption MeterAudioOutput[color=#FF0000]][/color] BarColor "255,0,0,255"] respectively IfFalseAction=[!SetOption MeterAudioOutput[color=#FF0000]][/color] BarColor "255,255,255,255"].
Also don't forget that even if a color code is composed by three or four numbers, it's a string and would be a good idea to include them between quotation marks (as I did above).

EDIT: Sorry eclectic-tech, you beat me again!
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Audio visualiser - Change BarColor based on value

Post by eclectic-tech »

@balala
But too late to save you some typing! :p :D :welcome:
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

Re: Audio visualiser - Change BarColor based on value

Post by DigitalEssence »

Thank you.

Can't believe I missed that ] I checked it over so many times.

I also missed the 0 > 1 level for audio plugin. Duly noted.

And that code you pasted at the end is very very nice. Thank you. Going to play with that.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Audio visualiser - Change BarColor based on value

Post by eclectic-tech »

Have Fun!

Always glad to help. :)
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

Re: Audio visualiser - Change BarColor based on value

Post by DigitalEssence »

Oh,

I am having soo much fun with your BarColor trick.

it's garish but it's clever.

Code: Select all

BarColor=(255-([MeasureAudioOutput]*255)),([MeasureAudioOutput]*255)-255),0
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Audio visualiser - Change BarColor based on value

Post by eclectic-tech »

Glad to hear... If you want to see how crazy it can get... look at my Versa skin! {Shameless self-promotion!} :rolmfao:
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

Re: Audio visualiser - Change BarColor based on value

Post by DigitalEssence »

Wow. That' some pretty clever shizz going on there...

I'm a subtle chap so ended up going for: BarColor=255,255,255,([MeasureAudioRaw0]*255)

Quick question. I've got 63 of these things and had to add them in manually as each Meter BarColor needs to measure it's own levels.

Is there an alternative way of doing this? Perhaps scripting it to create all 63 meters rather than wearing my poor fingers to the bone. I've considered using reg expr in text editor but would prefer to be able to script this plugin.

https://www.screencast.com/t/FcdxXiEgF
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Audio visualiser - Change BarColor based on value

Post by eclectic-tech »

DigitalEssence wrote:Wow. That' some pretty clever shizz going on there...

I'm a subtle chap so ended up going for: BarColor=255,255,255,([MeasureAudioRaw0]*255)

Quick question. I've got 63 of these things and had to add them in manually as each Meter BarColor needs to measure it's own levels.

Is there an alternative way of doing this? Perhaps scripting it to create all 63 meters rather than wearing my poor fingers to the bone. I've considered using reg expr in text editor but would prefer to be able to script this plugin.

https://www.screencast.com/t/FcdxXiEgF
Monstercat (as well as Frost and others) use 'Factory'' and 'Refresher' scripts to write the METERS on the fly, but have all the possible MEASURES hard coded. This script is used in many visualizers and is available to use (credit to the @author "Malody Hoe / GitHub: madhoe / Twitter: maddhoexD" would be good to add to your code).

By looking at those skins, I think you will be able to save manually creating meters and then Show/Hide them.

Good Luck!
Post Reply