It is currently March 28th, 2024, 11:43 am

Change audio visualizer based on volume output

Get help with creating, editing & fixing problems with skins
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Change audio visualizer based on volume output

Post by JamX »

Hello everybody.

I have an audio visualizer based on radian_vibrance_visualizer_1.3 skin.
This skin uses Lua to generate the .ini files for the visualizer lines.
I have tweaked it a bit to suite my skin but one thing I can not get it to work.

The line length of the visualizer is related to the volume .
The line length can be set with the "amplifier" variable

When I change the volume (which I measure) I want the variable "Amplifier" to increase or decrease so I have more or less the same line length independent of the volume

I use this code:

Code: Select all

[Metadata]
Author=FreezingClouds
Name=Radian Vibrance Visualizer
Version=1.3

[Rainmeter]
Update=40

[Variables]
Pad=#CURRENTPATH#@Resources\
@include=#Pad#Vibrance\VibranceVariables.inc


[MSLine]
LineWidth=#BarWidth#
Solid=#BubbleMode#
AntiAlias=1

[MSTip]
LineLength=(#BarWidth#/2)
Solid=1
AntiAlias=1
Hidden=#BubbleMode#

[MeasureVolume]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Volume
Substitute="":"N/A"
;IfConditionMode=1
IfCondition=MeasureVolume > 80
IfTrueAction= [!SetVariable  "Amplifier" "1"]
IfCondition2=(MeasureVolume = 80) && (MeasureVolume >60)
IfTrueAction2=[!SetVariable  "Amplifier" "2"]
IfCondition3=(MeasureVolume = 60) && (MeasureVolume >40)
IfTrueAction3=[!SetVariable  "Amplifier" "3"]
IfCondition4=(MeasureVolume = 40) && (MeasureVolume >20)
IfTrueAction4=[!SetVariable  "Amplifier" "4"]
dynamicvariables=1

[VibranceScript]
Measure=Script
ScriptFile=#Pad#Vibrance\Vibrance.lua
OutFile=#Pad#Vibrance\Lines.inc

[ScriptRefresher]
Measure=Script
ScriptFile=#Pad#Vibrance\Refresher.lua
Refreshed=0
UpdateDivider=-1

[AudioExtractor]
Measure=Plugin
Plugin=AudioLevel
FFTSize=#FFTSize#
FFTOverlap=128
FFTAttack=80
FFTDecay=80
Bands=(Clamp(#Bars#,2,360))
FreqMin=100
FreqMax=12000
Sensitivity=#Sensitivity#
@include=#Pad#Vibrance\Lines.inc

[Progress/Bounds]
Meter=Roundline
X=735
Y=390
W=(2*#BarHeight#+#CoverSize#+200)
H=(2*#BarHeight#+#CoverSize#+200)
AntiAlias=1

I see the variable "Amplifier" change when I change the volume in the log file within Rainmeter so that part is working
I think somehow I must call the Vibrance Lua script when "Amplifier" variable changes to generate NEW .ini files with the changed "Amplifier" variable when I change the volume but I do not know how.

Here is the skin file:
Vibranci_.rmskin
(59.19 KiB) Downloaded 38 times


All help is appreciated
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: Change audio visualizer based on volume output

Post by JamX »

I have changed part of the code to:

Code: Select all

[MeasureVolume]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Volume
Substitute="":"N/A"

IfCondition= ((MeasureVolume = 100) && (MeasureVolume >80))
IfTrueAction= [!SetVariable  "Sensitivity" "25"]
IfCondition2=((MeasureVolume = 80) && (MeasureVolume >60))
IfTrueAction2=[!SetVariable  "Sensitivity" "30"]
IfCondition3=((MeasureVolume = 60) && (MeasureVolume >40))
IfTrueAction3=[!SetVariable  "Sensitivity" "40"]
IfCondition4=((MeasureVolume =40)  && (MeasureVolume >20))
IfTrueAction4=[!SetVariable  "Sensitivity" "60"]
IfCondition5=((MeasureVolume  = 20)  && (MeasureVolume >0))
IfTrueAction5=[!SetVariable  "Sensitivity" "80"]
IfCondition6=(MeasureVolume  = 0)
IfTrueAction6=[!SetVariable  "Sensitivity" "90"]

OnChangeAction=[!WriteKeyValue Variables Sensitivity #Sensitivity# "#Pad#Vibrance\VibranceVariables.inc"][!Refresh ]
dynamicvariables=1
But when I now change the volume the "sensitivity" variable value written to the VibranceVariables.inc file is always one instance to low or to high (late) depending if I go Up or Down in volume.
In rainmeter logging all is fine and working but the written variable is wrong.

Strange
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change audio visualizer based on volume output

Post by balala »

JamX wrote: January 13th, 2021, 10:09 pm I have changed part of the code to:
There is a mistake in the above IfConditions. For instance IfCondition is true ONLY when [MeasureVolume] is exactly 100, because you've used equality: IfCondition= ((MeasureVolume = 100) && (MeasureVolume >80)). Replace all those equalities in the first condition of all IfCondition options (at least from 1 to 5), like this: IfCondition= ((MeasureVolume <= 100) && (MeasureVolume > 80)).
Not sure this fixes the issue, but it has to be done.
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: Change audio visualizer based on volume output

Post by JamX »

Hello Balala,

I have made the changes you suggested but the result is the same since I make volume changes in +/- 20% increments.

Code: Select all

[MeasureVolume]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Volume
Substitute="":"N/A"

IfCondition= ((MeasureVolume <= 100) && (MeasureVolume >80))
IfTrueAction= [!SetVariable  "Sensitivity" "25"]
IfCondition2=((MeasureVolume <= 80) && (MeasureVolume >60))
IfTrueAction2=[!SetVariable  "Sensitivity" "30"]
IfCondition3=((MeasureVolume <= 60) && (MeasureVolume >40))
IfTrueAction3=[!SetVariable  "Sensitivity" "40"]
IfCondition4=((MeasureVolume <=40)  && (MeasureVolume >20))
IfTrueAction4=[!SetVariable  "Sensitivity" "60"]
IfCondition5=((MeasureVolume  <= 20)  && (MeasureVolume >0))
IfTrueAction5=[!SetVariable  "Sensitivity" "80"]
IfCondition6=(MeasureVolume  = 0)
IfTrueAction6=[!SetVariable  "Sensitivity" "90"]

OnChangeAction=[!WriteKeyValue Variables Sensitivity #Sensitivity# "#Pad#Vibrance\VibranceVariables.inc"][!Refresh ]
dynamicvariables=1
Here is a video you you can see what's happening:
example.mp4
(1.49 MiB) Downloaded 29 times
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: Change audio visualizer based on volume output

Post by JamX »

When I do this:

Code: Select all

MeasureVolume]
 Measure=Plugin
 Plugin=WebNowPlaying
 PlayerType=Volume
 Substitute="":"N/A"
 
IfCondition= ((MeasureVolume >80))
IfTrueAction= [!WriteKeyValue Variables Sensitivity 35 "#Pad#Vibrance\VibranceVariables.inc"]
IfCondition2=((MeasureVolume <= 80) && (MeasureVolume >60))
IfTrueAction2=[!WriteKeyValue Variables Sensitivity 42 "#Pad#Vibrance\VibranceVariables.inc"]
IfCondition3=((MeasureVolume <= 60) && (MeasureVolume >40))
IfTrueAction3=[!WriteKeyValue Variables Sensitivity 52 "#Pad#Vibrance\VibranceVariables.inc"]
IfCondition4=((MeasureVolume <=40)  && (MeasureVolume >20))
IfTrueAction4=[!WriteKeyValue Variables Sensitivity 65 "#Pad#Vibrance\VibranceVariables.inc"]
IfCondition5=((MeasureVolume  <= 20))
IfTrueAction5=[!WriteKeyValue Variables Sensitivity 85 "#Pad#Vibrance\VibranceVariables.inc"]

OnChangeAction=[!Refresh ]
it is working.

Strange that with the option where I use !SetVariable it is not working properly.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change audio visualizer based on volume output

Post by balala »

JamX wrote: January 14th, 2021, 5:45 pm Strange that with the option where I use !SetVariable it is not working properly.
Make sure you've added a DynamicVariables=1 option to the measure / meter where you've used the Sensitivity variable (when working with the !SetVariable bang).
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: Change audio visualizer based on volume output

Post by JamX »

Is was using the dynamicvariables=1 command in the previous coding but even that did not help.

With the latest (working) code I delete it because there it is not needed.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change audio visualizer based on volume output

Post by balala »

JamX wrote: January 14th, 2021, 6:42 pm With the latest (working) code I delete it because there it is not needed.
Yep, it's not, however I'd think more times before using that solution, because it refreshes the skin every time you're changing the volume and such an approach has to be treated sceptical: https://forum.rainmeter.net/viewtopic.php?f=5&t=22739&p=119966&p119966#p119966
Please post the whole and actual code of your skin, to can take a look, even if it has been posted before, because you've update it, if I'm not mistaken, so I'd like to have the entire code.
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: Change audio visualizer based on volume output

Post by JamX »

I attached the Spotify player and equalizer code
The skin uses the webnowplaying plugin and spicetify to make it work but you'll probably know.

Player_and_Vibrance_.rmskin
(1.36 MiB) Downloaded 42 times
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: Change audio visualizer based on volume output

Post by JamX »

balala wrote: January 14th, 2021, 7:06 pm Yep, it's not, however I'd think more times before using that solution, because it refreshes the skin every time you're changing the volume and such an approach has to be treated sceptical: https://forum.rainmeter.net/viewtopic.php?f=5&t=22739&p=119966&p119966#p119966
Please post the whole and actual code of your skin, to can take a look, even if it has been posted before, because you've update it, if I'm not mistaken, so I'd like to have the entire code.
I need the !Refresh bang because the Lua scrips needs to be "refreshed" to generate new Lines.inc file for new sensitivity variable setting.
I have not found an other way to call the lua scrips after the volume/sensitivity changes.

Maybe you know.
Post Reply