It is currently May 14th, 2024, 12:50 pm

Change Shape Colour Based On MusicBee Genre

Get help with creating, editing & fixing problems with skins
User avatar
e__j
Posts: 2
Joined: April 28th, 2024, 2:38 pm

Change Shape Colour Based On MusicBee Genre

Post by e__j »

Hello.

I have been playing around with Rainmeter for the past few days and have tried to learn a few things and decided to make a skin based on the Anjunabeats videos.

I have used the Monstercat Visualizer to help create the skin and I have all of the genres I want set up in that skin, but I am stuck on how to incorporate the colour change based on genre into a new skin.

I have used the MeterShape to create the bar up the top and the left side and would like those to change with the genre just like the meter. I have used some of the code from the Monstercat Visualizer to help with this, but everything I have tried doesn't work. The closest I have come is the colours changing, but not to the assigned colours that I have listed.

Here is the code. Is there anything painfully obvious I am missing? Any help is appreciated. I understand the objects like #House# and #EDM# will need to be changed, but I haven't updated them yet as nothing else works currently.

Code: Select all

[Rainmeter]
Group=Anjunabeats
Update=10
BackgroundMode=2
AccurateText=1
DynamicWindowSize=1
DynamicVariables=1
SolidColor=0,0,0,1

[Measures]
[MeasurePlayer]
Measure=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Title
Substitute="":"N\A"

[MeasureArtist]
Measure=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=Artist
Substitute="":"N\A"

[MeasureState]
Measure=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=State
Substitute="0":"Play","1":"Pause","2":"Play"

[MeasureAlbum]
Measure=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Album
Substitute="":"N\A"

[MeasureGenre]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Genre
; You can add your own genres here.
; Use | as dividier and replace spaces with \s (otherwise it won't work)
; Electro
IfMatch=Electro\sHouse|Big\sRoom\sHouse|Melbourne\sBounce|Fidget\sHouse
IfMatchAction=[!SetVariable GenreColor "#Electro#"]
; Electronic/EDM
IfMatch2=Intro|Outro|Interlude|Spoken\sWord|Novelty|Comedy|Recordings|Instrumental
IfMatchAction2=[!SetVariable GenreColor "#EDM#"]
; House
IfMatch3=Ambient\sHouse|Funky\sHouse|Deep\sTech|Progressive\sHouse|Future\sHouse
IfMatchAction3=[!SetVariable GenreColor "#House#"]
; Drum & Bass
IfMatch4=Drum\s&\sBass
IfMatchAction4=[!SetVariable GenreColor "#DnB#"]
; Dubstep
IfMatch5=Dubstep
IfMatchAction5=[!SetVariable GenreColor "#Dubstep#"]
; Here is an example for an custom genre. Colors need to be rgb(a) values.
IfMatch13=Mashup|Mash\sUp
IfMatchAction13=[!SetVariable GenreColor "192,255,99"]
Substitute="CalcColor":"#Color#"
OnChangeAction=[!UpdateMeasure "CalcColors"]
Disabled=1
DynamicVariables=1

[Meter]
[MeterShape]
Meter=Shape
Shape=Rectangle 43,0,1920,50 | Extend MySharedModifiers
Shape2=Rectangle 43,0,50,1080 | Extend MySharedModifiers
MySharedModifiers=Fill Color [CalcColors] | StrokeWidth 0
DynamicVariables=1

[GenreColor]
Meter=Bar
MeasureName=MeasureGenre
MeterStyle=[MeasureGenre]
Disabled=1
UpdateDivider=50
DynamicVariables=1

[ScriptRefresher]
Measure=Script
ScriptFile=#@#scripts\Refresher.lua
UpdateDivider=-1
Refreshed=0
User avatar
balala
Rainmeter Sage
Posts: 16217
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Shape Colour Based On MusicBee Genre

Post by balala »

e__j wrote: April 28th, 2024, 5:28 pm Here is the code. Is there anything painfully obvious I am missing?
You set different values for the GenreColor variable through the IfMatchActionX options of the [MeasureGenre] measure and here I have two remarks:
  • The values set to the GenreColor variable (#Electro#, #EDM#, #House#, #DnB#" and #Dubstep#) are not defined, at least not in the posted code. Hope you have them defined somewhere, however if they are not, you can't use the set GenreColor variable.
  • If those variables are defined, you get some real color codes for the GenreColor variable. But this variable is not used in the code. I assume you should want to use it in the Fill Color parameter of the MySharedModifiers option of the [Meter] meter. In this option you have so far the [CalcColors] measure, which probably should return a color code, but this measure is not present in the code. So replace it with the set up GenreColor variable: MySharedModifiers=Fill Color #GenreColor# | StrokeWidth 0.
User avatar
e__j
Posts: 2
Joined: April 28th, 2024, 2:38 pm

Re: Change Shape Colour Based On MusicBee Genre

Post by e__j »

balala wrote: April 28th, 2024, 6:05 pm You set different values for the GenreColor variable through the IfMatchActionX options of the [MeasureGenre] measure and here I have two remarks:
  • The values set to the GenreColor variable (#Electro#, #EDM#, #House#, #DnB#" and #Dubstep#) are not defined, at least not in the posted code. Hope you have them defined somewhere, however if they are not, you can't use the set GenreColor variable.
  • If those variables are defined, you get some real color codes for the GenreColor variable. But this variable is not used in the code. I assume you should want to use it in the Fill Color parameter of the MySharedModifiers option of the [Meter] meter. In this option you have so far the [CalcColors] measure, which probably should return a color code, but this measure is not present in the code. So replace it with the set up GenreColor variable: MySharedModifiers=Fill Color #GenreColor# | StrokeWidth 0.
I did have an additional 20 or so colours set up with properly defined RGBA codes, I just deleted them to reduce some of the monotony of IfMatch when reading. I have replaced the #EDM# etc. codes now with defined values.

I have replaced the [CalcColors] measure with [GenreColor] now in the [Measure] and the [Meter] and I still cannot get it to work. I would assume that I have written the [GenreColor] variable wrong near the bottom of the code, but I am very new to learning Rainmeter and code in general so I am unsure where I am going wrong.

I did manage to get the colours changing previously, but there were only 3 colours and they were incorrectly defined.

Here is the code I am have now. I have again left out many of the IfMatch actions as I have quite a few in the code.

Code: Select all

[Rainmeter]
Group=Anjunabeats
Update=10
BackgroundMode=2
AccurateText=1
DynamicWindowSize=1
DynamicVariables=1
SolidColor=0,0,0,0

[Measures]
[MeasurePlayer]
Measure=NowPlaying
PlayerName=#PlayerName#
PlayerType=Title
Substitute="":"N\A"

[MeasureArtist]
Measure=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=Artist
Substitute="":"N\A"

[MeasureState]
Measure=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=State
Substitute="0":"Play","1":"Pause","2":"Play"

[MeasureAlbum]
Measure=NowPlaying
PlayerName=#PlayerName#
PlayerType=Album
Substitute="":"N\A"

[MeasureGenre]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Genre
; Electro
IfMatch=Electro\sHouse|Big\sRoom\sHouse|Melbourne\sBounce|Fidget\sHouse [!SetVariable GenreColor "230,206,0"]
IfMatchAction=[!SetVariable GenreColor "230,206,0"]
; Electronic/EDM
IfMatch2=Spoken\sWord|Novelty|Comedy|
IfMatchAction2=[!SetVariable GenreColor "193,193,193"]
; House
IfMatch3=Ambient\sHouse|Funky\sHouse|Deep\sTech|Progressive\sHouse|Future\sHouse|Hard\sHouse|Speed\sHouse|Microhouse|Tech\sHouse|Deep\sHouse|Organic\sHouse|Bass\sHouse|Garage\sHouse|Festival\sHouse|G-House|Afro\sHouse|Acid\sHouse|Hip\sHouse
IfMatchAction3=[!SetVariable GenreColor "234,140,6"]
; Drum & Bass
IfMatch4=Drum\s&\sBass
IfMatchAction4=[!SetVariable GenreColor "242,25,4"]
; Dubstep
IfMatch5=Dubstep
IfMatchAction5=[!SetVariable GenreColor "141,4,225"]
; Drumstep
IfMatch6=Drumstep|Halftime
IfMatchAction6=[!SetVariable GenreColor "243,33,136"]
; Glitch Hop
IfMatch7=Glitch\sHop|Moombahcore|Moombahton|Midtempo\sBass
IfMatchAction7=[!SetVariable GenreColor "11,151,87"]
; Trap
IfMatch8=Trap|Hip-Hop|Drift\sPhonk|Detroit\sElectro
IfMatchAction8=[!SetVariable GenreColor "140,15,39"]
; Trance
IfMatch9=Progressive\sTrance|Acid\sTrance|Electro\sTrance|Psy-Trance|Hard\sTrance|Uplifting\sTrance|Vocal\sTrance|Big\sRoom\sTrance|Tech\sTrance|Future\sRave|Acid\sTrance
IfMatchAction9=[!SetVariable GenreColor "0,126,231"]
; Hard Dance
IfMatch10=Hard\sDance|Hardcore\sEDM|Breakcore|Hardstyle
IfMatchAction10=[!SetVariable GenreColor "1,151,0"]
; Nu Disco/Indie Dance
IfMatch11=Electropop|Nu-disco|Synthpop|Synthwave|Disco|Indietronica|Electro-disco
IfMatchAction11=[!SetVariable GenreColor "28,171,179"]
; Future Bass
IfMatch12=Future\sBass
IfMatchAction12=[!SetVariable GenreColor "154,152,252"]
; Breaks
IfMatch13=Progressive\sBreaks|Breaks|Big\sBeat
IfMatchAction13=[!SetVariable GenreColor "18,132,101"]
; Industrial
IfMatch14=Industrial|Dark\sAmbient|Post-industrial|Electro-industrial
IfMatchAction14=[!SetVariable GenreColor "40,40,40"]
; UK Garage
IfMatch15=Speed\sGarage|2-step|Future\sGarage|Bassline|UK\sJackin
IfMatchAction15=[!SetVariable GenreColor "191,127,255"]
; Experimental
IfMatch16=Experimental|Drone|Improvisation|Noise|Power\sElectronics|Avant-prog
IfMatchAction16=[!SetVariable GenreColor "78,18,48"]
; Techno
IfMatch17=Techno|Ambient\sTechno|Peak\sTime\sTechno|Melodic\sTechno|Hard\sTechno|Industrial\sTechno|Minimal\sTechno|Dub\sTechno|Acid\sTechno
IfMatchAction17=[!SetVariable GenreColor "42,63,215"]
; Soundtrack
IfMatch18=Soundtrack
IfMatchAction18=[!SetVariable GenreColor "233,36,239"]
; Jazz
IfMatch19=Jazz|Jazz\sFusion|Swing
IfMatchAction19=[!SetVariable GenreColor "135,206,250"]
; Downtempo
IfMatch20=Downtempo|Trip\sHop|Progressive\sElectronic|Folktronica
IfMatchAction20=[!SetVariable GenreColor "146,222,104"]
; Leftfield Bass
IfMatch21=IDM|Wonky|Leftfield\sBass|Jungle\sTerror|Jersey\sClub|Juke\s/\sFootwork
IfMatchAction21=[!SetVariable GenreColor "70,89,107"]
; Folk
IfMatch22=Singer-Songwriter|Contemporary\sFolk|Progressive\sFolk|Neofolk|Regional\sFolk|World|Waltz|Acoustic|Classical|Chamber\sMusic|Opera
IfMatchAction22=[!SetVariable GenreColor "201,151,0"]
; Hardcore Punk
IfMatch23=Hardcore\sPunk|Metalcore|Mathcore|Post-hardcore|Melodic\sHardcore|Deathcore|Grindcore
IfMatchAction23=[!SetVariable GenreColor "103,78,167"]
; Punk
IfMatch24=Punk\sRock|Emo|Pop\sPunk|Post-punk|Darkwave
IfMatchAction24=[!SetVariable GenreColor "97,0,97"]
; Metal
IfMatch25=Drone\sMetal|Deathgrind|Progressive\sMetal|Thrash\sMetal|Death\sMetal|Black\sMetal|Groove\sMetal|Sludge\sMetal|Post-metal|Doom\sMetal|Speed\sMetal|Heavy\sMetal|Alternative\sMetal|Avant-garde\sMetal
IfMatchAction25=[!SetVariable GenreColor "216,57,0"]
; Rock
IfMatch26=Hard\sRock|Krautrock|Folk\sRock|Alternative\sRock|Post-rock|Jazz\sRock|Progressive\sRock|Art\sRock|Math\sRock|Gothic\sRock|Blues\sRock|Noise\sRock|Indie\sRock|Pop\sRock|Electronic\sRock|New\sWave
IfMatchAction26=[!SetVariable GenreColor "0,103,150"]
; Psychedelia
IfMatch27=Psychedelic\sRock|Psychedelic\sFolk|Neo-Psychedelia
IfMatchAction27=[!SetVariable GenreColor "185,78,72"]
; Ambient
IfMatch28=Ambient
IfMatchAction28=[!SetVariable GenreColor "240,180,181"]
; Pop
IfMatch29=Pop|R&B
IfMatchAction29=[!SetVariable GenreColor "255,127,182"]
Substitute="GenreColor":"#Color#"
OnChangeAction=[!UpdateMeasure "GenreColor"]
Disabled=1
DynamicVariables=1

[Meter]
[MeterShape]
Meter=Shape
Shape=Rectangle 43,0,1920,50 | Extend MySharedModifiers
Shape2=Rectangle 43,0,50,1080 | Extend MySharedModifiers
MySharedModifiers=Fill Color #GenreColor# | StrokeWidth 0
DynamicVariables=1

[Variables]
[GenreColor]
Meter=Bar
MeasureName=MeasureGenre
MeterStyle=[MeasureGenre]
Disabled=1
UpdateDivider=50
DynamicVariables=1

[ScriptRefresher]
Measure=Script
ScriptFile=#@#scripts\Refresher.lua
UpdateDivider=-1
Refreshed=0
User avatar
balala
Rainmeter Sage
Posts: 16217
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Shape Colour Based On MusicBee Genre

Post by balala »

e__j wrote: April 28th, 2024, 7:32 pm I have replaced the [CalcColors] measure with [GenreColor] now in the [Measure] and the [Meter]
No, in fact you've replaced the [CalcColors] measure name by the #GenreColor# variable, because #GenreColor# (written this way) is a variable. [GenreColor] is a meter (a Bar meter, to be precise), but you can't use a meter in this context, doesn't make sense, you can use just a measure. But it's alright as you did, GenreColor is indeed a variable and has to be used as a variable (#GenreColor#).
But what you mean by [Measure]? The skin has a [Meter] named meter, but there is no measure called [Measure]. There is a [Measures] measure, but not a [Measure]. Additionally the only place where you've used the GenreColor variable is the MySharedModifiers option of the [Meter] meter.
e__j wrote: April 28th, 2024, 7:32 pm and I still cannot get it to work. I would assume that I have written the [GenreColor] variable wrong near the bottom of the code, but I am very new to learning Rainmeter and code in general so I am unsure where I am going wrong.
As I see it now, you can't get it working because the [MeasureGenre] measure is disabled (having a Disabled=1 option). Try removing this option and check again, to see if it starts working. Does it?
However even if it starts working, there are few other inadvertences in the code, which should have to be fixed. For instance:
  • You can't define a meter style through a measure. You've used such an option (incorrectly written) onto the [GenreColor] measure (MeterStyle=[MeasureGenre]). The correct form of such an option is with no brackets: MeterStyle=MeasureGenre, but such in a case, MeasureGenre should be a style section, not at all a measure.
  • You can't disable a meter. You added a Disabled=1 option to the [GenreColor] meter, but a Disabled=1 option makes sense only on measures. Measures can be disabled, while meters can be hidden.
Did you get working the color setting by enabling the [MeasureGenre] measure? Does the color setting work now?
If it doesn't, add the following very simple meter to the end of the code. This way, when you refresh the skin, you get a small black rectangle in the upper left corner of your skin, showing the value set for the GenreColor variable. Is its value correctly set?

Code: Select all

[MeterGenreColor]
Meter=STRING
X=10
Y=10
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#GenreColor#
DynamicVariables=1