Author Topic: Different info in panel displays based on genre or other tag information  (Read 2125 times)

Maxo

  • Newbie
  • *
  • Posts: 6
Apologies if this has been asked before, it's been a bit hard finding a specific answer here.  

A little background first, I have a big library that's split into different sections, specifically Video Game Music, Film / Series Scoring, Classical, and Everything Else.  I use Album Cover display for all of these with drop down panels.

I'm curious if, using virtual tags, I can have different tags displayed in the header based on which category these albums fall under.  

For example, for my video game music collection, I'm currently displaying the tags, "Developer" "Console" "Original Album" and "Sound Team" (3 of 4 of which are custom tags, btw).  I have a virtual tag that combines Developer and Console since all albums in the library include them, while Original Album & Sound Team are only featured for selections that include these fields.

However, if I flip over to my other playlists with any material without these fields, I have pretty much no remaining space in the panel preferences to display other fields like "Genre" or "Publisher" or anything else, since they're all being taken up by tags that only pertain to other parts of my library.

Is there a possible $if function that would help set up conditions that would change the displayed fields based on which category the files in question fall under?  For example, something like $If(<Album Library>="1" etc etc.

Any tailored info on this would be helpful.  I'm finding that combining tags in a virtual tag is a bit too cumbersome to account for what I'd like to display in 4 or more different ways while still keeping it looking visually clean and uniform between all my categories.

EDIT:
What I'd love is something like (explaining in layman's terms)
if Album Library is 1, output Publisher - Genre
if Album Library is 2, output Developer - Console - Sound Team - Original Album
if Album Library is 3, output Comment - Publisher
if Album Library is 4, output Work - Original Year

I should also mention that I'd like the output to display nothing if the field is empty, rather than "Unknown _____".  I know that requires the $Trim and $IfNull functions.
Last Edit: June 01, 2025, 10:36:06 PM by Maxo

hiccup

  • Hero Member
  • *****
  • Posts: 9109
Is there a possible $if function that would help set up conditions that would change the displayed fields based on which category the files in question fall under?  For example, something like $If(<Category>="VGM" etc etc.
Yes, the $If function is available for that.
See the MusicBee functions for virtual tags cheatsheet.

But you will need to create your own custom and/or virtual tags for what you consider to be a category, since <Category> is an already existing internal MusicBee tag.
(music/audiobook/podcast, etc.)
Last Edit: June 01, 2025, 08:14:05 PM by hiccup

Maxo

  • Newbie
  • *
  • Posts: 6
Yes, the $If function is available for that.
See the MusicBee functions for virtual tags cheatsheet.

But you will need to create your own custom and/or virtual tags for what you consider to be a category, since <Category> is an already existing internal MusicBee tag.
(music/audiobook/podcast, etc.)

Awesome, this is very helpful!  Thanks so much for the quick reply.  I actually have a separate tag I'm gonna use for these categories called "Album Library" with values from say, 1-4 referencing each category I'm describing here.  I found a reference for a $if true/false function.. I'm not too great with coding in this way, how would I set up a function with more than just a binary output?

hiccup

  • Hero Member
  • *****
  • Posts: 9109
I'm not too great with coding in this way, how would I set up a function with more than just a binary output?
IF is binary by design.
When 'true' it will do A, if it is not true it will do B.
You can also nest several IF statements to refine the output further.

If you can specify in more detail what you want A and B to do, I'm sure you will get some useful replies and more specific suggestions or solutions.
Or, do a forum search and take a look at some posted virtual tags and try to learn from those.
(it's more rewarding ;-)

Maxo

  • Newbie
  • *
  • Posts: 6
If you can specify in more detail what you want A and B to do, I'm sure you will get some useful replies and more specific suggestions or solutions.
Or, do a forum search and take a look at some posted virtual tags and try to learn from those.
(it's more rewarding ;-)

Well, I'll do both!

What I'd love is something like (explaining in layman's terms)
if Album Library is 1, output Publisher - Genre
if Album Library is 2, output Developer - Console - Sound Team - Original Album
if Album Library is 3, output Comment - Publisher
if Album Library is 4, output Work - Original Year

I should also mention that I'd like the output to display nothing if the field is empty, rather than "Unknown _____".  I know that requires the $Trim and $IfNull functions.

Pickles7853

  • Full Member
  • ***
  • Posts: 151
I'll jump in.  I have some time to kill this morning.
What I recommend, for anyone new to programming, is to write them out as separate macros and then combine them later.
Funny enough with your explanation of what you wanted you already provided it.

Macro1: $IsNull(<Album Library>,,Macro2)
Macro2: $If(<Album Library>=1,<Publisher> - <Genre>,Macro3)
Macro3: $If(<Album Library>=2,<Developer> - <Console> - <Sound Team> - <Original Album>,Macro4)
Macro4: $If(<Album Library>=3,<Comment> - <Publisher>,Macro5)
Macro5: $If(<Album Library>=4,<Work> - <Original Year>,)

First check if <Album Library> is null.  If so output nothing.  This takes care of the "unknown" problem.  As you can see, highlighted in red, the false portion of each statement leads down to the next macro.  This way all the different cases are checked.  This is called nesting and is how you can arrange a binary output into a multiple output format.

From here you just have to combine them into the single statement it should be.  For this step I prefer to work backwards.  Cut-n-paste all of Macro5 into Macro4 at the appropriate spot and work your way up the chain until you are done.

$IsNull(<Album Library>,,$If(<Album Library>=1,<Publisher> - <Genre>,$If(<Album Library>=2,<Developer> - <Console> - <Sound Team> - <Original Album>,$If(<Album Library>=3,<Comment> - <Publisher>,$If(<Album Library>=4,<Work> - <Original Year>,)))))

This would be the final product.  Call it something useful like TrackInfo and save it.  Now you can add this to your header and remove all the other fields this handles.  Hopefully I explained how to do this in a manner that will allow you to make any needed changes.

Maxo

  • Newbie
  • *
  • Posts: 6
I'll jump in.  I have some time to kill this morning.
What I recommend, for anyone new to programming, is to write them out as separate macros and then combine them later.
Funny enough with your explanation of what you wanted you already provided it.

Macro1: $IsNull(<Album Library>,,Macro2)
Macro2: $If(<Album Library>=1,<Publisher> - <Genre>,Macro3)
Macro3: $If(<Album Library>=2,<Developer> - <Console> - <Sound Team> - <Original Album>,Macro4)
Macro4: $If(<Album Library>=3,<Comment> - <Publisher>,Macro5)
Macro5: $If(<Album Library>=4,<Work> - <Original Year>,)

First check if <Album Library> is null.  If so output nothing.  This takes care of the "unknown" problem.  As you can see, highlighted in red, the false portion of each statement leads down to the next macro.  This way all the different cases are checked.  This is called nesting and is how you can arrange a binary output into a multiple output format.

From here you just have to combine them into the single statement it should be.  For this step I prefer to work backwards.  Cut-n-paste all of Macro5 into Macro4 at the appropriate spot and work your way up the chain until you are done.

$IsNull(<Album Library>,,$If(<Album Library>=1,<Publisher> - <Genre>,$If(<Album Library>=2,<Developer> - <Console> - <Sound Team> - <Original Album>,$If(<Album Library>=3,<Comment> - <Publisher>,$If(<Album Library>=4,<Work> - <Original Year>,)))))

This would be the final product.  Call it something useful like TrackInfo and save it.  Now you can add this to your header and remove all the other fields this handles.  Hopefully I explained how to do this in a manner that will allow you to make any needed changes.

This is incredibly helpful and works super well.  I really appreciate you taking the time to lay this out for me!

One small caveat though, in regard to the $IfNull function, I'm not so much concerned about whether or not the macros in question would display with "Unknown" if the Album Library field is empty, and am more concerned with the fields included *within* the macro returning empty fields as "Unknown".. and of course the formatting of the result in question.  

For example, if I have an album in Album Library = 2 that doesn't include fields like Original Album or Sound Team, with this code it would return, say:
"HAL Laboratory - Super Nintendo - Unknown Sound Team - Unknown Original Album"
If I want to make the unknowns in these specific fields vanish, alongside the displayed text preceding them: " - ", how would I need to amend $IfNull for these macros?  
Again, I want to make sure that the end result doesn't look like:
"HAL Laboratory - Super Nintendo -  - "
and instead, would look like:
"HAL Laboratory - Super Nintendo"
Thank you so much again!
Last Edit: June 02, 2025, 06:57:15 PM by Maxo

tjinc

  • Sr. Member
  • ****
  • Posts: 826
Well that's actually quite a challenge you laid out there - mainly due to all the possible permutations of fields being empty or not.
So, while Pickles7853 is working on that  ::) :

Reading your first post, it looks like you are displaying these different 'sections' of your library using playlists (which is a perfectly valid way of doing so).
If this is correct you might like to look at what you can do using Custom Views.

You currently have several standard views (Tracks, Album and Tracks, Artists...) but you can create your own Custom Views and use different ones for different playlists. These are entirely independent of each other - just make sure you take notice of the 'tip' on the page I linked.

I am suggesting this as I think that it may give you even more flexibility over how each 'section' (i.e. playlist) is displayed.
Don't get me wrong, at times virtual tags are invaluable and it is well worth gaining some sort of understanding of these whether you end up using them here or not.

Pickles7853

  • Full Member
  • ***
  • Posts: 151
Sorry!  I was snoozing on my couch.  8)

Oh... each individual field...
Yeah that is a pain.  But you just have to work through the logic.

Macro2: $If(<Album Library>=1,<Publisher> - <Genre>,Macro3)
$IsNull(<Publisher>,,$IsNull(<Genre>,," - "))

So for the dash, the logic here is simple.  You only need a dash is there is a value for both <Publisher> and <Genre>.
If either of them is missing the dash is not needed.
For these smaller macros it isn't all that bad.  The larger one needs more attention.

Macro3: $If(<Album Library>=2,<Developer> - <Console> - <Sound Team> - <Original Album>,Macro4)
1st dash: $IsNull(<Developer>,,$IsNull(<Console><Sound Team><Original Album>,," - "))
2nd dash: $IsNull(<Console>,,$IsNull(<Sound Team><Original Album>,," - "))
3rd dash: $IsNull(<Sound Team>,,$IsNull(<Original Album>,," - "))

The first dash can only appear if <Developer> is not null and all the other fields after it are not empty.
The same logic applies for each dash after the first.

After taking out the dashes in the original macros and replacing them with the appropriate code it becomes:

$IsNull(<Album Library>,,$If(<Album Library>=1,<Publisher>$IsNull(<Publisher>,,$IsNull(<Genre>,," - "))<Genre>,$If(<Album Library>=2,<Developer>$IsNull(<Developer>,,$IsNull(<Console><Sound Team><Original Album>,," - "))<Console>$IsNull(<Console>,,$IsNull(<Sound Team><Original Album>,," - "))<Sound Team>$IsNull(<Sound Team>,,$IsNull(<Original Album>,," - "))<Original Album>,$If(<Album Library>=3,<Comment>$IsNull(<Comment>,,$IsNull(<Publisher>,," - "))<Publisher>,$If(<Album Library>=4,<Work>$IsNull(<Work>,,$IsNull(<Original Year>,," - "))<Original Year>,)))))

Hope I did not fat finger something in there and it works out of the preverbal box.  :-X

tjinc

  • Sr. Member
  • ****
  • Posts: 826
I don't think it is quite that straightforward:

Take the example where:
   <Album Library>=1
   <Publisher>=""
   <Genre>="Rock"


Your first IF statement:
  $If(<Album Library>=1,<Publisher>$IsNull(<Publisher>,,$IsNull(<Genre>,," - "))<Genre>
will output:
   Unknown PublisherRock

You still need to wrap the fields <Publisher> and <Genre> in IsNull functions so that they are not output as Unknown.

Pickles7853

  • Full Member
  • ***
  • Posts: 151
Puuh... yeah I missed that.  Thanks for pointing it out.
This should correct that and assuming my logic works out it might work lol.

$IsNull(<Album Library>,,$If(<Album Library>=1,$IsNull(<Publisher>,,<Publisher>)$IsNull(<Publisher>,,$IsNull(<Genre>,," - "))$IsNull(<Genre>,,<Genre>),$If(<Album Library>=2,$IsNull(<Developer>,,<Developer>)$IsNull(<Developer>,,$IsNull(<Console><Sound Team><Original Album>,," - "))$IsNull(<Console>,,<Console>)$IsNull(<Console>,,$IsNull(<Sound Team><Original Album>,," - "))$IsNull(<Sound Team>,,<Sound Team>)$IsNull(<Sound Team>,,$IsNull(<Original Album>,," - "))$IsNull(<Original Album>,,<Original Album>),$If(<Album Library>=3,$IsNull(<Comment>,,<Comment>)$IsNull(<Comment>,,$IsNull(<Publisher>,," - "))$IsNull(<Publisher>,,<Publisher>),$If(<Album Library>=4,$IsNull(<Work>,,<Work>)$IsNull(<Work>,,$IsNull(<Original Year>,," - "))$IsNull(<Original Year>,,<Original Year>),)))))

tjinc

  • Sr. Member
  • ****
  • Posts: 826
Yes, I think that should do it.
It has become something of a behemoth, so I hope it hasn't put @Maxo off at all.

And I have to thank you @Pickles7853 - it had never occurred to me that you could wrap multiple fields in a single IsNull function. This is a useful trick to remember (and certainly made the solution to this problem less complex).

Pickles7853

  • Full Member
  • ***
  • Posts: 151
Quote
And I have to thank you @Pickles7853 - it had never occurred to me that you could wrap multiple fields in a single IsNull function. This is a useful trick to remember (and certainly made the solution to this problem less complex).

No need to thank me because I stole it from somewhere.  I *think* it was from hiccup.  It has been long enough now that I cannot remember though.
But I agree.  It is very useful in certain circumstances.

tjinc

  • Sr. Member
  • ****
  • Posts: 826
And another way of coming at this (in case anyone is interested - it tweaked my curiosity):

Code
$RxReplace($RxReplace($If(<Album Library>=1,<Publisher> - <Genre>,$If(<Album Library>=2,<Developer> - <Console> - <Sound Team> - <Original Album>,$If(<Album Library>=3,<Comment> - <Publisher>,$If(<Album Library>=4,<Work> - <Original Year>,)))),"Unknown.+? - |Unknown.+$","")," - $","")
Somewhat shorter using some witchy RegEx stuff to remove the 'Unknown' fields and superfluous characters from Pickles7853's original virtual tag code.
(I would say that my RegEx is at 'novice' standard so there is most likely a better way.)

hiccup

  • Hero Member
  • *****
  • Posts: 9109
Ah! A puzzle ;-)

Here's an additional and slightly different approach.
The idea behind it is to make it as easy as possible to maintain and modify things.

First, the four Album Library tags from the startpost each get their own individul virtual tag.

Like this:




Then create a virtual tag like this:
(I named it Library output in the screenshot)

Code
$Trim($RxReplace($RxReplace($RxReplace($RxReplace($If(<Album Library>=1,<AlbLib1>,$If(<Album Library>=2,<AlbLib2>,$If(<Album Library>=3,<AlbLib3>,$If(<Album Library>=4,<AlbLib4>,)))),"((?<!\w\s)Unknown.*?(?=\s-\s|$))",""),"(-\s{1,}){1,}","- "),"\s{1,}"," "),"(^\s*-\s*|\s*-\s*$)"," "))
I think this should work. (I haven't been able to test it fully)

Now if you want to change any of the four 'AlbLib' tags, just change the tags that it contains.

edit
Updated to accommodate for album and song titles such as 'An Unknown…', 'The Unknown…' etc.
Last Edit: June 04, 2025, 03:41:34 PM by hiccup