It is currently December 6th, 2022, 3:48 pm

Help with Audio reactive png, not bitmap?

Get help with creating, editing & fixing problems with skins
User avatar
AveryNightshade
Posts: 5
Joined: October 11th, 2022, 2:27 pm
Location: Australia

Help with Audio reactive png, not bitmap?

Post by AveryNightshade »

Heyo!
Real new to coding and rainmeter in general, so I've just been trying to put an audio-reactive image (like bongo cat https://www.reddit.com/r/Rainmeter/comments/kjfxe5/bongocat_suite_20_light_dark_festive_themes/) together using pngs instead of bitmap images? I'm also trying to activate a gif when I double click but I'm confused about the location insertion, and general line of code (I've been pretty much copy and pasting from other bits of code, like https://visualskins.com/skin/desktop-dokis). Aim is to basically have a pngtuber working off of the nowplaying.dll instead of microphone.

Here are the pngs btw if you want to see (created using a picrew) + confetti images
@Resources.zip
Anyways, this is currently what I have, I know it's very broken:

Code: Select all


[Rainmeter]
Update=1000

[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=Spotify

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=0
RMSGain=75

[MeasureR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L,R
Type=RMS

[CatL]
Meter=Bitmap
MeasureName=MeasureL, Measure R
ImageName=#@#AlwynTalk.png

[ImageNumberCalc]
Measure=Calc
Formula=Counter %  22 + 1
Substitute=".00000":""

[MeterActionClick]
Meter=Image
ImageName=#@#AlwynQuiet.png
PreserveAspectRatio=1
LeftMouseDoubleClickAction=[!SetOption "Resources/Confetti" ImageName "[ImageNumberCalc].png"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]

[Alwyn]
Meter=Image
MeasureName=MeasureL,MeasureR
ImageName=#@#AlwynQuiet.png
DynamicVariables=1

[MeterAction]
Meter=Image
ImageName=#@#AlwynQs.png
PreserveAspectRatio=1
MouseOverAction=[!SetOption #CURRENTSECTION# ImageName "#@#AlwynAction.png"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageName "#@#AlwynQuiet.png"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 14766
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Audio reactive png, not bitmap?

Post by balala »

AveryNightshade wrote: October 11th, 2022, 2:46 pm I'm also trying to activate a gif when I double click but I'm confused about the location insertion, and general line of code
The !SetOption bang used in the LeftMouseDoubleClickAction option of the [MeterActionClick] meter is wrong. Such a !SetOption bang requires the following parameters:
  • The name of the section on which you'd like to dynamically modify an option. In your case this is the mistakenly used parameter. Resources/Confetti should be a name of a section (either of the current skin, or another activated skin in worst case). What I think is that you've tried to add here the path of the images. But even if you tried this, in the path you don't have a folder called Resources, but one called @Resources (the @ is not optional). And one more: even if you write correctly the name of the folder, this is not the place where to add this name and we are never referring to the @Resources folder by its name, but by the #@# variable (as you did in the ImageName option of the [MeterAction] meter, for instance).
  • The name of the option withing the section added in the previous parameter (this is probably right).
  • The value you'd like to set for the previously named option of the previously named section. If this is correct depends, you either have to set the name by including the path (#@#Confetti\[*ImageNumberCalc*].png) or add an ImagePath option to the Image meter and set only the name of file. See that in first case I escaped the [*ImageNumberCalc*] measure name.
  • If you want to set an option to a section which is not part of the current skin (in which you set it), a fourth parameter is the name of the config containing the skin in which you want to make the setting.
For instance this is a working option on the [MeterActionClick] meter:

Code: Select all

[MeterActionClick]
...
LeftMouseDoubleClickAction=[!SetOption #CURRENTSECTION# ImageName "#@#Confetti\[*ImageNumberCalc*].png"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
DynamicVariables=1
Note that I added a DynamicVariables=1 option as well, this being required by the fact that a section variable ([ImageNumberCalc]) is used in the LeftMouseDoubleClickAction option.
AveryNightshade wrote: October 11th, 2022, 2:46 pm (I've been pretty much copy and pasting from other bits of code,
This is not a problem, we all do the same all the time.
User avatar
AveryNightshade
Posts: 5
Joined: October 11th, 2022, 2:27 pm
Location: Australia

Re: Help with Audio reactive png, not bitmap?

Post by AveryNightshade »

balala wrote: October 11th, 2022, 6:29 pm Such a !SetOption bang requires the following parameters
Thanks for the help! It also helped me figure out the confetti aspect to a degree.
(Got caught up with uni so wasn't able to work on it for a bit.)

As a follow on, I'm having difficulty with the [MeasureAudio] aspect. My coding doesn't appear to differentiate at all between sound and no sound.
When I put

Code: Select all

[Rainmeter]
Update=90

[Base]
Meter=Image
ImageName=#@#AlwynQs.png

[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=Spotify

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=0
RMSGain=75

[MeasureL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS

[MeasureR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS
Specifically this part:

Code: Select all

[AlwynT]
Meter=Image
MeasureName=MeasureL, MeasureR
ImageName=#@#AlwynTs.png
Dynamic Variables=1
It doesn't perform the action if it is only MeasureL, but with MeasureR it is stuck on the new image?

Thanks again for your help before! It was a really thorough explanation.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4885
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Help with Audio reactive png, not bitmap?

Post by eclectic-tech »

Let's start by correcting some syntax errors in your code and simplifying the code to produce an Alwyn image that reacts to sound and shows confetti when double-clicked.

Here is working code, save it with a unique name in the same folder as your original code.

Code: Select all

[Rainmeter]
Update=50
LeftMouseDoubleClickAction=[!ToggleMeasure ImageNumberCalc][!ToggleMeter Confetti]

[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=Spotify
PlayerType=Title

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=0
RMSGain=75
IfCondition=(MeasureAudio>0.5)
IfTrueAction=[!SetOption MeterAlwyn ImageName "#@#AlwynAction.png"]
IfFalseAction=[!SetOption MeterAlwyn ImageName "#@#AlwynQuiet.png"]

[ImageNumberCalc]
Measure=Calc
Formula=Counter %  22 + 1
Substitute=".00000":""
DynamicVariables=1
Disabled=1

[MeterAlwyn]
Meter=Image
X=R
ImageName=#@#AlwynQuiet.png
PreserveAspectRatio=1

[Confetti]
Meter=Image
X=r
ImageName=#@#Confetti\[ImageNumberCalc].png
PreserveAspectRatio=1
DynamicVariables=1
Hidden=1
I removed all unused measures, added DynamicVariables=1 to the sections that need to respond to changes.
It will show 1 Alwyn 'quiet' image when loaded and no sound is playing.
When you play sound and the level is above 0.5, the image will change to Alwyn 'action'.
When you double-click on the image, the confetti calc measure and image meter will be toggled into action.

You are not using the [MeasurePlayer] in this code, but I added the PLAYERTYPE=Title to eliminate error messages in the log.
BTW, using the rainmeter log willl help you find errors in your code...
User avatar
balala
Rainmeter Sage
Posts: 14766
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Audio reactive png, not bitmap?

Post by balala »

AveryNightshade wrote: November 12th, 2022, 1:37 pm As a follow on, I'm having difficulty with the [MeasureAudio] aspect. My coding doesn't appear to differentiate at all between sound and no sound.
When I put

Code: Select all

[Rainmeter]
Update=90

[Base]
Meter=Image
ImageName=#@#AlwynQs.png

[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=Spotify

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=0
RMSGain=75

[MeasureL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS

[MeasureR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS
Specifically this part:

Code: Select all

[AlwynT]
Meter=Image
MeasureName=MeasureL, MeasureR
ImageName=#@#AlwynTs.png
Dynamic Variables=1
It doesn't perform the action if it is only MeasureL, but with MeasureR it is stuck on the new image?
I assume eclectic-tech's solution is a proper one, however I have to add a few details related to the above code, which he didn't touch:
  • If using a MeasureName option on an Image meter (in fact on any kind of meter), you can enter one single measure name. That's why the MeasureName=MeasureL, MeasureR option of the [AlwynT] meter as it is, is not working. The meter doesn't show up anything. The option can be either MeasureName=MeasureL or MeasureName=MeasureR, but by no means both.
  • The DynamicVariables=1 option, used on the same [AlwynT] meter should have no space. Accordingly Dynamic Variables=1 doesn't work.
  • The [MeasurePlayer] measure doesn't return anything, not having a PlayerType option. This option has no default value, the measure which doesn't have it returns nothing. As you can see eclectic-tech has also added a PlayerType=Title option.
  • This is definitely not a problem, especially not one to prevent the measure or skin working, however NowPlaying even if a while ago has been a plugin measure, it's not anymore. In meantime it has been converted to an internal measure and should be treated accordingly. So, recommend replacing the Measure=Plugin and Plugin=NowPlaying.dll options pair with Measure=NowPlaying. For backward compatibility reasons the plugin approach does still work, but the new syntax should be used.
User avatar
AveryNightshade
Posts: 5
Joined: October 11th, 2022, 2:27 pm
Location: Australia

Re: Help with Audio reactive png, not bitmap?

Post by AveryNightshade »

Back again! :')

Image

Thanks for clearing everything up for me! I seemed to miss a lot of stuff when I went through the Rainmeter Documentation last time.
I did do a couple of small changes like ordering for confetti and the images (as well as cleaning folder locations) and added a range for the audio reactions.

However

I'm trying to also do a mouse-over action that pauses the audio reaction, changes the image while hovering, and then resumes the audio reaction process upon leaving. Checked the log this time and it isn't picking anything up. Am I referring to a section wrongly? Or is to do with the bang? And is there any other method that I can use to check before coming over here? :')

Code: Select all

[Rainmeter]
Update=50
LeftMouseDoubleClickAction=[!ToggleMeasure ImageNumberCalc][!ToggleMeter Confetti]
MouseOverAction=[!PauseMeasure MeasurePlayer][!ToggleMeter Cursor]

[Cursor]
Meter=Image
AntiAlias=1
PreserveAspectRatio=1
DynamicVariables=1
MouseOverAction=[!SetOption Cursor ImageName "#@#CharacterImages\Character1\AlwynA.png"][!Redraw]
MouseLeaveAction=[!UnpauseMeasure MeasurePlayer][!Redraw]
Hidden=1 

[MeasurePlayer]
Measure=NowPlaying
PlayerName=Spotify
PlayerType=Title

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=0
RMSGain=75
IfCondition=(MeasureAudio=1)
IfTrueAction=[!SetOption MeterAlwyn ImageName "#@#CharacterImages\Character1\AlwynY.png"]
IfCondition2=(MeasureAudio>0.5) && (MeasureAudio<1)
IfTrueAction2=[!SetOption MeterAlwyn ImageName "#@#CharacterImages\Character1\AlwynT.png"]
IfCondition3=(MeasureAudio<=0.5)
IfTrueAction3=[!SetOption MeterAlwyn ImageName "#@#CharacterImages\Character1\AlwynQ.png"]
OnUpdateAction=[!UpdateMeter MeterAlwyn][!Redraw]

[ImageNumberCalc]
Measure=Calc
Formula=Counter %  22 + 1
Substitute=".00000":""
DynamicVariables=1
Disabled=1

[Confetti]
Meter=Image
ImageName=#@#Confetti\[ImageNumberCalc].png
PreserveAspectRatio=1
DynamicVariables=1
Hidden=1 
X=R

[MeterAlwyn]
Meter=Image
ImageName=#@#CharacterImages\Character1\AlwynQ.png
PreserveAspectRatio=1
X=r
Hopefully I won't be back again too quickly! Thanks (again) for your help, it's been really positive for me as a complete beginner :D
User avatar
balala
Rainmeter Sage
Posts: 14766
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Audio reactive png, not bitmap?

Post by balala »

AveryNightshade wrote: November 13th, 2022, 12:05 pm Thanks for clearing everything up for me! I seemed to miss a lot of stuff when I went through the Rainmeter Documentation last time.
If you were referring to me too, I'm glad if succeeded making you to understand something.
AveryNightshade wrote: November 13th, 2022, 12:05 pm I'm trying to also do a mouse-over action that pauses the audio, changes the image, and then resumes the process. Checked the log this time and it isn't picking anything up. Am I referring to a section wrongly? Or is to do with the bang? And is there any other method that I can use to check before coming over here? :')
Not sure what you mean by "pause the audio". Do you want to pause the playback, mute the system or anything else? Sorry but I'm not sure.
AveryNightshade wrote: November 13th, 2022, 12:05 pm Hopefully I won't be back again too quickly! Thanks (again) for your help, it's been really positive for me as a complete beginner :D
Why? Finally, coming back and asking whenever you have question is what for this forum has been created.

And additionally, a few questions I have to add to the last posted code:
  • When you're hovering the mouse over the skin the [MeasurePlayer] measure is paused by the [!PauseMeasure MeasurePlayer] bang of the MouseOverAction option of the [Rainmeter] section. Then this measure is supposed to be unpaused when you're leaving the [Cursor] meter. But what if you hovered the mouse over the skin, but not over the [Cursor] meter as well? In this case the measure remains paused. Is this alright, this is what you wanted to do?
  • Setting a new image to an Image meter then redrawing the skin makes not too much sense. The meter should be updated, otherwise the redrawing is completely useless. So in the MouseOverAction option of the [Cursor] meter a [!UpdateMeter "Cursor"] bang should be added between the !SetOption and !Redraw: MouseOverAction=[!SetOption Cursor ImageName "#@#CharacterImages\Character1\AlwynA.png"][!UpdateMeter "Cursor"][!Redraw]. This way when the image is set by the !SetOption bang, the meter is immediately updated then the skin redrawn, which lets you to immediately see the change.
  • Updating the [MeterAlwyn] meter on every update of the [MeasureAudio] measure (done by the OnUpdateAction option of the measure) doesn1t seem to be a good idea. In fact the meter is automatically updated on every update cycle, why to update it once more, with a bang? What seems a much better idea is to update it whenever the IfCondition changes. This can be done either by replacing the OnUpdateAction with an OnChangeAction, but an even better procedure is to remove the OnUpdateAction and add the !UpdateMeter and !Redraw bangs to the end of each IfTrueAction options:

    Code: Select all

    [MeasureAudio]
    Measure=Plugin
    Plugin=AudioLevel
    Port=Output
    RMSAttack=100
    RMSDecay=0
    RMSGain=75
    IfCondition=(MeasureAudio=1)
    IfTrueAction=[!SetOption MeterAlwyn ImageName "#@#CharacterImages\Character1\AlwynY.png"][!UpdateMeter "MeterAlwyn"][!Redraw]
    IfCondition2=(MeasureAudio>0.5) && (MeasureAudio<1)
    IfTrueAction2=[!SetOption MeterAlwyn ImageName "#@#CharacterImages\Character1\AlwynT.png"][!UpdateMeter "MeterAlwyn"][!Redraw]
    IfCondition3=(MeasureAudio<=0.5)
    IfTrueAction3=[!SetOption MeterAlwyn ImageName "#@#CharacterImages\Character1\AlwynQ.png"][!UpdateMeter "MeterAlwyn"][!Redraw]
User avatar
AveryNightshade
Posts: 5
Joined: October 11th, 2022, 2:27 pm
Location: Australia

Re: Help with Audio reactive png, not bitmap?

Post by AveryNightshade »

Not sure what you mean by "pause the audio".
Forgot to reread before I posted! I meant to say the audio reaction.
But what if you hovered the mouse over the skin, but not over the [Cursor] meter as well? In this case the measure remains paused. Is this alright, this is what you wanted to do?
I'm not quite sure what you mean by this however. How do the two relate? And what do I need to change in order for the former measure to resume and begin the audio reaction again? As you said,
Then this measure is supposed to be unpaused when you're leaving the [Cursor] meter.
Learning so much from you but I am also trying to get to the point where I can figure this stuff out on my own, hence hoping I don't have to come back too soon! Thanks again though in the meantime! :D
User avatar
balala
Rainmeter Sage
Posts: 14766
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Audio reactive png, not bitmap?

Post by balala »

AveryNightshade wrote: November 14th, 2022, 1:23 am I'm not quite sure what you mean by this however. How do the two relate? And what do I need to change in order for the former measure to resume and begin the audio reaction again? As you said,
I meant that when you're hovering the mouse over the skin, the [MeasurePlayer] measure is paused by the [!PauseMeasure MeasurePlayer] bang of the MouseOverAction option of the [Rainmeter] section. The same measure is unpaused when you're leaving the [Cursor] meter, this meter having the [!UnpauseMeasure MeasurePlayer] bang in its MouseLeaveAction option. I asked if this is for sure what you wanted to do, because if you're hovering the mouse over the skin, but not over the [Cursor] meter, the measure gets paused. However, when you leave the skin, it is not unpaused, because since the mouse has not been hovered over the [Cursor] meter, the MouseLeaveAction of this meter is not executed, the measure remaining paused.
Possible, however usually a measure is unpaused when we're leaving the meter or skin which paused it before. Again: this is perfectly valid and possible but might indicate a small inadvertence.
AveryNightshade wrote: November 14th, 2022, 1:23 am Learning so much from you but I am also trying to get to the point where I can figure this stuff out on my own, hence hoping I don't have to come back too soon! Thanks again though in the meantime! :D
Feel free to do so, if you want. Also feel free to come back if any new question arises. We're (me definitely am) open to reply to them, if needed...
User avatar
AveryNightshade
Posts: 5
Joined: October 11th, 2022, 2:27 pm
Location: Australia

Re: Help with Audio reactive png, not bitmap?

Post by AveryNightshade »

Meant to put [MeasureAudio] not [MeasurePlayer]. Didn't need the [Cursor] section in the end.

Finished it though! Thanks again balala and eclectic-tech for all your help+explanations!

I've posted it on devianart here: https://www.deviantart.com/melodyrosemary/art/DesktopBuddies-v1-0-937197612 and also uploaded it here.
DesktopBuddies.zip
Here's the code for the people coming across this page!:

Code: Select all

[Rainmeter]
Update=50
LeftMouseDoubleClickAction=[!ToggleMeasure ImageNumberCalc][!ToggleMeter Confetti]
MouseOverAction=[!PauseMeasure MeasureAudio][!SetOption MeterPICREW ImageName "#@#CharacterImages\Character1\PICREWA.png"][!Redraw]
MouseLeaveAction=[!UnpauseMeasure MeasureAudio][!SetOption MeterPICREW ImageName "#@#CharacterImages\Character1\PICREWQ.png"][!Redraw]

[MeasurePlayer]
Measure=NowPlaying
PlayerName=Spotify
PlayerType=Title

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=0
RMSGain=75
IfCondition=(MeasureAudio=1)
IfTrueAction=[!SetOption MeterPICREW ImageName "#@#CharacterImages\Character1\PICREWY.png"][!UpdateMeter "MeterPICREW"][!Redraw]
IfCondition2=(MeasureAudio>0.5) && (MeasureAudio<1)
IfTrueAction2=[!SetOption MeterPICREW ImageName "#@#CharacterImages\Character1\PICREWT.png"][!UpdateMeter "MeterPICREW"][!Redraw]
IfCondition3=(MeasureAudio<=0.5)
IfTrueAction3=[!SetOption MeterPICREW ImageName "#@#CharacterImages\Character1\PICREWQ.png"][!UpdateMeter "MeterPICREW"][!Redraw]

[ImageNumberCalc]
Measure=Calc
Formula=Counter %  22 + 1
Substitute=".00000":""
DynamicVariables=1
Disabled=1

[Confetti]
Meter=Image
ImageName=#@#Confetti\[ImageNumberCalc].png
PreserveAspectRatio=1
DynamicVariables=1
Hidden=1 
X=R

[MeterPICREW]
Meter=Image
ImageName=#@#CharacterImages\Character1\PICREWQ.png
PreserveAspectRatio=1
W=300
X=r
You do not have the required permissions to view the files attached to this post.