It is currently June 24th, 2024, 1:14 am

Adding variable background music to preexsisting code

Get help with creating, editing & fixing problems with skins
StarAnimates
Posts: 2
Joined: May 22nd, 2024, 1:52 am

Adding variable background music to preexsisting code

Post by StarAnimates »

So i recently installed rainmeter just so I could have this wonderfully made skin!

https://github.com/lezzthanthree/Needy-Streamer-Overload

I wanted to see if it would maybe be possible though, to add an option to one of the windows to be able to play audio based on the characters sprites (which change based on settings that you set her emotions as)

I do not know how this coding works, but I know i'd need to detect some kind of variable for it to play different audios at "moods", as well as consistently play the audio over everything else. (preferably able to toggle on and off)

Does anyone have any idea how something like this would work?
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adding variable background music to preexsisting code

Post by Yincognito »

StarAnimates wrote: May 22nd, 2024, 1:56 am I wanted to see if it would maybe be possible though, to add an option to one of the windows to be able to play audio based on the characters sprites (which change based on settings that you set her emotions as)
Depending on what those character sprites are (Image meters or other types of meter), how they change (typically in some action options from a measure or meter), and what kind of audio files you're thinking of (for example, .wav or .mp3 files), this should be possible.

So, once you identify where in the code those character sprites change, you can:
- if it's about .wav files, add to that corresponding action option the desired [Play...] bangs, see:
https://docs.rainmeter.net/manual/bangs/#Application
- if it's about .mp3 files and you use a supported player that can start minimized and play some file from the command line, add a bang like:

Code: Select all

["FullPathToYourPlayerHere" "FullPathToYourAudioFileHere"]
to run it and play that file, or, alternatively, command a RunCommand measure to "Run" and do the same, optionally in a hidden state:
https://docs.rainmeter.net/manual/plugins/runcommand/
and afterwards control the play via some NowPlaying measures:
https://docs.rainmeter.net/manual/measures/nowplaying/
or, if using a web based player, via some WebNowPlaying measures (this is what one of the skins in that package does too):
https://forum.rainmeter.net/viewtopic.php?t=26619

Don't worry about just beginning with Rainmeter, things might be easier than you expect, especially if you're looking for something simple (like using .wav files is).

P.S. You can even add a LeftMouseUpAction option to one of your meters and do the testing there, until you get familiar with the approach and implement it in the place in the code where those sprites change.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16325
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Adding variable background music to preexsisting code

Post by balala »

StarAnimates wrote: May 22nd, 2024, 1:56 am Does anyone have any idea how something like this would work?
No, because your question is extremely vague formulated. I think Yincognito agrees this, at least based on his reply. We (me at least definitelay) have no idea what would you like to achieve. For first I think by windows you meant one of the skins included in the linked package. Am I right? If I am, to which skin would you like to add the feature? And what do you mean by "based on the characters sprites"?
So details are absolutely needed in order to can help you.
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adding variable background music to preexsisting code

Post by Yincognito »

balala wrote: May 22nd, 2024, 6:37 pmI think Yincognito agrees this, at least based on his reply.
Yes, I do agree with the question being vague - hence covering all possibilities in my reply, and letting the OP identify the what, where and how parts that are not clear (yet). As I said other times, the help is as good as the relevant details in the question are. But yeah, having less details than needed is a common (and normal) mistake when starting with Rainmeter - folks initially think that skins are fixed functions of Rainmeter, when in reality each skin has a high degree of independence from the Rainmeter program itself, with only the "Rainmeter customized" .ini syntax and its particular "sections" connecting them.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
StarAnimates
Posts: 2
Joined: May 22nd, 2024, 1:52 am

Re: Adding variable background music to preexsisting code

Post by StarAnimates »

Yincognito wrote: May 22nd, 2024, 8:41 pm Yes, I do agree with the question being vague - hence covering all possibilities in my reply, and letting the OP identify the what, where and how parts that are not clear (yet). As I said other times, the help is as good as the relevant details in the question are. But yeah, having less details than needed is a common (and normal) mistake when starting with Rainmeter - folks initially think that skins are fixed functions of Rainmeter, when in reality each skin has a high degree of independence from the Rainmeter program itself, with only the "Rainmeter customized" .ini syntax and its particular "sections" connecting them.
I'd like to apologize for my vagueness! I'm totally new to this and had no idea how to word it.
It's like to add it to a file called 'Ame.inc'
This file is just a screen that resembles a webcam window, with a couple buttons allowing you to change her (the characters) mood, her activity, and close the tab.
The character runs through various character sprites, which is defined by a variable

Code: Select all

[Variables]
SpritePath=#@#\Images\Ame\sprites\[Stress]\[Affection]\[Darkness]\[Variation]

Code: Select all

; ===== Ame Animation ===== 

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 20
DynamicVariables=1
AntiAlias=0

[VariationRandomizer]
Measure=Calc
Formula=Random
LowBound=0
HighBound=1
UpdateRandom=1
UpdateDivider=#VarRand#
DynamicVariables=1

[Variation]
Measure=Calc
Formula=[VariationRandomizer]
DynamicVariables=1

[Ame]
Meter=IMAGE
MeasureName=ImageNumberCalc
DynamicVariables=1
X=8
Y=42
Path=#SpritePath#
W=#Width#
AntiAlias=1
What I am hoping to do is have a toggle on/off button on the Ame.inc window that would play a looping .wav file that follows this [Stress]\[Affection]\[Darkness]\[Variation] system that the sprites follow.

Please let me know if there's any details I am missing, again I am completely new to Rainmeter and do not know all the correct terminology
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adding variable background music to preexsisting code

Post by Yincognito »

StarAnimates wrote: May 22nd, 2024, 9:39 pm I'd like to apologize for my vagueness! I'm totally new to this and had no idea how to word it.
It's like to add it to a file called 'Ame.inc'
This file is just a screen that resembles a webcam window, with a couple buttons allowing you to change her (the characters) mood, her activity, and close the tab.
The character runs through various character sprites, which is defined by a variable

Code: Select all

[Variables]
SpritePath=#@#\Images\Ame\sprites\[Stress]\[Affection]\[Darkness]\[Variation]

Code: Select all

; ===== Ame Animation ===== 

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 20
DynamicVariables=1
AntiAlias=0

[VariationRandomizer]
Measure=Calc
Formula=Random
LowBound=0
HighBound=1
UpdateRandom=1
UpdateDivider=#VarRand#
DynamicVariables=1

[Variation]
Measure=Calc
Formula=[VariationRandomizer]
DynamicVariables=1

[Ame]
Meter=IMAGE
MeasureName=ImageNumberCalc
DynamicVariables=1
X=8
Y=42
Path=#SpritePath#
W=#Width#
AntiAlias=1
What I am hoping to do is have a toggle on/off button on the Ame.inc window that would play a looping .wav file that follows this [Stress]\[Affection]\[Darkness]\[Variation] system that the sprites follow.

Please let me know if there's any details I am missing, again I am completely new to Rainmeter and do not know all the correct terminology
Alright, that's much better, thanks! Well, based strictly on your description (which I'm not 100% sure it's actually what you want, but anyway), you could add this before the SpritePath line in the [Variables] section of Ame.inc:

Code: Select all

WavIndex=0
Wav0=[PlayStop]
Wav1=[PlayLoop "#@#\Audio\Ame\[Stress]\[Affection]\[Darkness]\[Variation]\File.wav"]
and this before the [Close] meter in Ame.inc:

Code: Select all

[Wav]
Meter=IMAGE
X=0
Y=0
ImageName=#@#Images\button_wav.png
LeftMouseUpAction=[!SetVariable WavIndex (1-[#WavIndex])][!UpdateMeter Wav][#Wav[#WavIndex]]
assuming that:
- you replicate the system's subfolder structure at https://github.com/lezzthanthree/Needy-Streamer-Overload/blob/master/%40Resources/Images/Ame/sprites/Folder%20Arrangement.txt (bar the \sprites\ part, obviously) in ...\@Resources\Audio\Ame folder and place a corresponding File.wav file in each of those subfolders
- you set the X and Y of the meter according to your preference and available space in the skin
- you create a properly sized ...\@Resources\Images\button_wav.png image file to act as your button

That being said, the above is untested as I'm on my phone, so it might not work at first or completely. If so, you could try using [&Stress] or even [&*Stress*] and similar for the rest in your Wav1 variable, or let us know of any other issue that might arise along the way.

P.S. Other than that, a skin typically has an .ini extension and not an .inc one, but then I didn't bother to check or test the said skin or figure out precisely the author's structure.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth