It is currently April 19th, 2024, 1:10 pm

How to hide visualizer when there's no audio playing

Get help with creating, editing & fixing problems with skins
rina
Posts: 6
Joined: March 18th, 2020, 3:03 pm

How to hide visualizer when there's no audio playing

Post by rina »

Hello! I'd like to hide the audio visualizer when there's no audio playing. I don't know much about coding so I don't know how to do that. Any help would be greatly appreciated!

the visualizer i'm using is this one: https://www.deviantart.com/hiphopium/art/Lasix-761401403
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide visualizer when there's no audio playing

Post by balala »

rina wrote: March 18th, 2020, 3:23 pm I'd like to hide the audio visualizer when there's no audio playing. I don't know much about coding so I don't know how to do that.
Add the following options to the [MeasureAudio] measure of your code:

Code: Select all

[MeasureAudio]
...
IfCondition=([#CURRENTSECTION#]=0)
IfTrueAction=[!HideFade]
IfFalseAction=[!ShowFade]
DynamicVariables=1
Don't replace or remove none of the existing options, just add these.
rina
Posts: 6
Joined: March 18th, 2020, 3:03 pm

Re: How to hide visualizer when there's no audio playing

Post by rina »

balala wrote: March 18th, 2020, 5:00 pm

Code: Select all

[MeasureAudio]
...
IfCondition=([#CURRENTSECTION#]=0)
IfTrueAction=[!HideFade][!SetOption Uptime FontColor "255,0,0"]
IfFalseAction=[!ShowFade][!SetOption Uptime FontColor "0,255,0"]
DynamicVariables=1
It worked perfectly, thank you so much!
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide visualizer when there's no audio playing

Post by balala »

rina wrote: March 18th, 2020, 5:30 pm It worked perfectly, thank you so much!
Glad to help.
If you are wondering what you did, here is a short explanation: the IfCondition checks if the value returned by the measure is zero. If it is, there is no sound and such in a case, the !HadeFade bang used into the IfTrueAction option of the same measure hides the skin. Note that although not visible, the skin is still loaded and eats some resources. If on the other hand the measure returns a not-zero value (practically a larger value), the !ShowMeter bang used into the IfFalseAction option shows (the still running) skin.

Take care, when I posted my reply, I accidentally added two !SetOption bangs into both option, IfTrueAction and IfFalseAction. I many times use such bangs to check the result and I also have added a String meter, named [Uptime] (which I copied from an old skin and didn't modify its name), to can see the results. I should had to remove these !SetOption bangs before posting the reply, but as usually I again forgot to do this. Get rid of them please because otherwise the [MeasureAudio] measure will give error messages in the log. I edited my previous reply, check it as well.
Sorry for my usual inattention... :?
rinaa
Posts: 1
Joined: March 18th, 2020, 9:37 pm

Re: How to hide visualizer when there's no audio playing

Post by rinaa »

balala wrote: March 18th, 2020, 5:46 pm Glad to help.
If you are wondering what you did, here is a short explanation: the IfCondition checks if the value returned by the measure is zero. If it is, there is no sound and such in a case, the !HadeFade bang used into the IfTrueAction option of the same measure hides the skin. Note that although not visible, the skin is still loaded and eats some resources. If on the other hand the measure returns a not-zero value (practically a larger value), the !ShowMeter bang used into the IfFalseAction option shows (the still running) skin.

Take care, when I posted my reply, I accidentally added two !SetOption bangs into both option, IfTrueAction and IfFalseAction. I many times use such bangs to check the result and I also have added a String meter, named [Uptime] (which I copied from an old skin and didn't modify its name), to can see the results. I should had to remove these !SetOption bangs before posting the reply, but as usually I again forgot to do this. Get rid of them please because otherwise the [MeasureAudio] measure will give error messages in the log. I edited my previous reply, check it as well.
Sorry for my usual inattention... :?
Hey, it's still me! Had to create a second account because I couldn't reply to you or PM you, it kept showing me an error message that "the submitted form was invalid". When I tried to log out of my account, it also didn't let me log out, got an error message saying "you were not logged out, as the request did not match your session"... so I cleared all browsing data to force it to log out. And then... I couldn't log back in either. I have no idea what happened to that account but oh well... maybe i'd be able to log in again if I just waited for a while, but I didn't feel like waiting ^^"

Anyways-- Thank you for explaining how it works! It makes perfect sense. and I just replaced the code!

I noticed a weird bug though, the visualizer doesn't always fade out as intended. It's invisible at first, fades in and becomes visible when I play audio as it is supposed to, but sometimes it stays visible instead of fading out when I pause the audio. Dunno what's going on :???:
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How to hide visualizer when there's no audio playing

Post by eclectic-tech »

I would consider actually deactivating/activating the visualizer config when your media player is not active along with hiding/showing the visualizer when the sound is muted. I recommend this approach because visualizers are notorious CPU hogs and hiding them does not reduce the lag they can cause to your system, only deactivating them does.

You need to create a measure that checks the Process for your media player and deactivates/activates the visualizer config. I will use WinAmp as an example, your media player process may be different, but it will be the executable file that starts your player.

Code: Select all

[MeasureProcess]
Measure=Plugin
Plugin=Process
ProcessName=WinAmp.exe
; Value will be '1' when the process is running, '-1' when it is not running
IfCondition=([MeasureProcess]=-1)
IfTrueAction=[!DeactivateConfig "Lasix\Visualizer"]
UpdateDivider=66
As for your intermittent response to hide/show when paused, I would try to change balala's code to:

Code: Select all

IfCondition=([#CURRENTSECTION#]<=0.00001)
IfTrueAction=[!HideFade]
IfFalseAction=[!ShowFade]
IfConditionMode=1
DynamicVariables=1
The audiolevel plugin responds to all system sounds, so the visualizer will try to hide/show when any program generates sound... that is another reason to add a Process measure so the visualizer only loads when your player is active.

Edit: I was in a hurry again! :oops: Thanks balala!
There are several ways to use the Process measure, if the measure is added to the visualizer skin code, it only needs one action, the "IfTrueAction". Added an update divider so it checks about once per second (Visualizer skins update every ~16 ms).

Alternately, you could created a new skin, have it loaded first, and use the Process measure to activate/deactivate the visualizer when your media player is running.

Code: Select all

[MeasureProcess]
Measure=Plugin
Plugin=Process
ProcessName=WinAmp.exe
; Value will be '1' when the process is running, '-1' when it is not running
IfCondition=([MeasureProcess]=-1)
IfTrueAction=[!DeactivateConfig "Lasix\Visualizer"]
IfFalseAction=[!ActivateConfig "Lasix\Visualizer" "Visualizer.ini"]

[MeterDummy]
Meter=String
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide visualizer when there's no audio playing

Post by balala »

rinaa wrote: March 18th, 2020, 9:50 pm Hey, it's still me! Had to create a second account because I couldn't reply to you or PM you, it kept showing me an error message that "the submitted form was invalid". When I tried to log out of my account, it also didn't let me log out, got an error message saying "you were not logged out, as the request did not match your session"... so I cleared all browsing data to force it to log out. And then... I couldn't log back in either. I have no idea what happened to that account but oh well... maybe i'd be able to log in again if I just waited for a while, but I didn't feel like waiting ^^"
I suppose you're using IE, right? I also am using at least sometimes it (yep, I know many people will say now I am stupid if using this browser, but I usually have not too much problems with it, but since I got used with it, so as said at least from time to time I am still using it) and encountered such problems as well over time. If you can, try it with another browser.
rinaa wrote: March 18th, 2020, 9:50 pm Anyways-- Thank you for explaining how it works! It makes perfect sense. and I just replaced the code!
Glad to help. :thumbup:
rinaa wrote: March 18th, 2020, 9:50 pm I noticed a weird bug though, the visualizer doesn't always fade out as intended. It's invisible at first, fades in and becomes visible when I play audio as it is supposed to, but sometimes it stays visible instead of fading out when I pause the audio. Dunno what's going on :???:
First please take a look to eclectic-tech's reply above and let us know if it does help.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide visualizer when there's no audio playing

Post by balala »

eclectic-tech wrote: March 19th, 2020, 2:38 am

Code: Select all

[MeasureProcess]
...
IfTrueAction=[!ActivateConfig "Lasix\Visualizer' "Visualizer.ini"]
Note a small mistake in the above code. As you can see in the config name parameter, a double quote is replaced by a single quote ([!ActivateConfig "Lasix\Visualizer' "Visualizer.ini"]). Please edit your post and fix this, because this way the !ActivateConfig bang doesn't work.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to hide visualizer when there's no audio playing

Post by Yincognito »

balala wrote: March 19th, 2020, 8:10 am I suppose you're using IE, right? I also am using at least sometimes it (yep, I know many people will say now I am stupid if using this browser, but I usually have not too much problems with it, but since I got used with it, so as said at least from time to time I am still using it) and encountered such problems as well over time. If you can, try it with another browser.
Yeah, but these problems appear to happen more often lately, and it's annoying. I think the administrators / devs should take a look at it, if it persists. And no, it doesn't happen just in IE, but also in Chrome (and I bet it happens in Edge and Firefox as well).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide visualizer when there's no audio playing

Post by balala »

Yincognito wrote: March 19th, 2020, 9:28 am And no, it doesn't happen just in IE, but also in Chrome (and I bet it happens in Edge and Firefox as well).
Well in Edge it didn't happened to me so far, but if you say, obviously it probably may happen. Don't know...