getmusicbee.com

Support => Tips and Tricks => Topic started by: redwing on March 30, 2013, 06:55:42 PM

Title: Useful virtual tag formulas
Post by: redwing on March 30, 2013, 06:55:42 PM
I thought it would be useful if users share virtual tag formulas designed to perform a special task. Keep in mind though that long and complicated virtual tag formulas consume lots of system resources and slow down MB. So use them for one-time task only if you think they could give quite a system load. Feel free to add any virtual tag formulas to this thread if you think they could be useful to other users.

---------------
How to Create a Virtual Tag

1. Go to Edit> Preferences> Tags (1)> Define New Tags.
2. Enter a label and formula in one of the boxes in the lower half of the dialog.
3. Now you can add the field to main panel or use the field for "group by" or "sort by".
Title: Re: Useful virtual tag formulas
Post by: redwing on March 31, 2013, 08:30:50 PM
Custom AZ Bar Using Vertical Column Browser

AZ bar is useful but it responds only to sort column which feels sometimes cumbersome. To avoid this, you can create your own custom AZ bar using a virtual tag and vertical column browser. It also filters to the selection.

1. Create a virtual tag as follows:

(1) For general use: AZ = $Group($Sort(<Artist>),1)

(2) If you have classical music tracks and want them grouped by composer rather than by artist:
AZ = $If(<Genre>="Classical",$Group($Sort(<Composer>),1),$Group($Sort(<Artist>),1))

(3) If you want to group artists by their last name, then use this instead:
Last = $Group($RSplit($First(<Artist>)," ",1),1)

It populates the first letter of the last word in artist field value. And if multiple artists are tagged, it takes the first artist's last name.
Also you can replace <Artist> field with <Composer> if you want to group composers by last name.

2. Configure column browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

3. When you want to return to full list after filtered to a subset , click on "all" at the top or the selected node in left navigator.

(http://i.imgur.com/Bk3OwAq.png)
Title: Re: Useful virtual tag formulas
Post by: redwing on March 31, 2013, 08:40:08 PM
How to Sort Tracks by Title in "Letters-Numbers-Symbols" order

1. Create a virtual tag with the following formula.

Code
$If($IsMatch(<Title>,"^[a-zA-Z]")="T",1<Title>,$If($IsMatch(<Title>,"^[0-9]")="T",2<Title>,3<Title>))
2. You can either create a custom sorting set using that virtual tag and sort by that field or just add the virtual tag to the main panel and sort by it. Also you can create the same sorting virtual tags for <Artist> and <Album> if you just replace <Title> with those fields using the formula above.
3. To use "ignore words" option, replace "<field>" with "$Sort(<field>)". So for "<Title>", use "$Sort(<Title>)" instead.

Note: Originally posted here (https://getmusicbee.com/forum/index.php?topic=22386.msg131589#msg131589)
Title: Re: Useful virtual tag formulas
Post by: frn_747 on March 31, 2013, 08:57:19 PM
One question, redwing...
Your solution is very interesting but a screenshot could be nice to see how it looks afterwards:
2. Configure track browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

Would you please?
Title: Re: Useful virtual tag formulas
Post by: redwing on March 31, 2013, 09:18:36 PM
One question, redwing...
Your solution is very interesting but a screenshot could be nice to see how it looks afterwards:
2. Configure track browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

Would you please?

I did. Thanks for your interest.
Title: Re: Useful virtual tag formulas
Post by: redwing on March 31, 2013, 10:28:16 PM
How to Display <First Artist> only

This is a pretty simple one, but if you're not familiar to virtual tag functions it might not be apparent at first glance.
If you have lots of multiple artist tracks and do not use album artist field, then artist field won't look good due to the lengthy chained artist names. This could be a problem for grouping by the field or displaying it on player scroll.

Create a virtual field as follows:

FA = $Sort($First(<Artist>))

Now use the field as if it's album artist field.
Title: Re: Useful virtual tag formulas
Post by: Steven on April 01, 2013, 08:24:22 AM
Keep in mind though that long and complicated virtual tag formulas consume lots of system resources and slow down MB. So use them for one-time task only if you think they could give quite a system load.
to expand on this - if you are only displaying a virtual field then there is very little overhead. Its only when you use the virtual field for sorting, grouping (which includes the library explorer and track browser) or as filtering criteria that is potentially becomes more expensive if you have a lot of files
Title: Re: Useful virtual tag formulas
Post by: redwing on April 01, 2013, 09:38:47 AM
Keep in mind though that long and complicated virtual tag formulas consume lots of system resources and slow down MB. So use them for one-time task only if you think they could give quite a system load.
to expand on this - if you are only displaying a virtual field then there is very little overhead. Its only when you use the virtual field for sorting, grouping (which includes the library explorer and track browser) or as filtering criteria that is potentially becomes more expensive if you have a lot of files

Thanks for the clarification! That corresponds to my experience with complicated virtual tags.
Title: Re: Useful virtual tag formulas
Post by: redwing on April 25, 2013, 07:18:22 AM
How to Group Tracks by <Album Artist (Album)> format

(http://i.imgur.com/4FRZ39I.png)

Create a virtual field as follows (of course, you can edit the format as you like)
 
AA_Album = $Sort(<Album Artist>) (<Album>)

Then right click on column header, click Group by, and select "AA_Album" field under virtual field.
Title: Re: Useful virtual tag formulas
Post by: redwing on April 25, 2013, 04:39:34 PM
How to State "contain" and "does not contain" in Virtual Tags

[Added]

This post is now obsolete since new functions were added for this purpose.

i've added these search functions:
$Contains(<field>, search-text)
$IsMatch(<field>, regex-pattern)

[Original Post]

You can define a rule with "contain" or "does not contain" condition for auto-playlists.  You can do the same for a field with virtual tags, and use it for various purposes.

The key is to combine $If and $Replace function.
Let's say you want to display "Rock" in a virtual field if a track contains a word "rock" in <Genre> tag; if not, display "Pop".

Pop_or_Rock = $If($Replace(<Genre>,rock,)=<Genre>,"Pop","Rock")

This can be used independently like the example above, but could be more useful when used as a condition for another virtual tag (See next post).
Title: Re: Useful virtual tag formulas
Post by: redwing on April 25, 2013, 05:15:24 PM
How to Define <Ensemble> field for Classical Music Tracks

Because MB uses <Display Artist> field values for <Artist> field in main library and virtual tags, it's a good idea to keep a consistent format for Display Artist field to use it for various purposes.
I'm using a semicolon between multiple artists, so it is easy to display artist value in a specific position.
For most classical pieces, ensemble is placed in the second position in multiple artist field next to conductor.
Then the formula would be like this:

Ensemble = $Split(<Artist>,";",2)

But for concertos, ensemble is in the third artist, following soloist and conductor. I am using <Grouping> field for sub-genres for classical music which contains "Piano Concerto," "Violin Concerto", etc.
So the field should display third artist when <Grouping> filed contains "Concerto", otherwise second artist.

Ensemble = $If($Replace(<Grouping>,Concerto,)=<Grouping>,$Split(<Artist>,";",2),$Split(<Artist>,";",3))

(http://i.imgur.com/VxbmRR4.png)
Title: Re: Useful virtual tag formulas
Post by: redwing on October 15, 2013, 07:43:02 PM
How to Identify Files with Extremely Lengthy Path

First have a look at this post:

one of the recurring problems reported is long generated filenames based from tags that exceed the windows limits:
260 chars for total length, 247 for the directory path (I realise that windows can support longer filenames, but that API is not available from .NET and i dont think its well supported in windows)

what i propose to do is where a tag exceeds 70 chars in length, MB will use the first 64 chars and append a unique 6 char string
c:\music\01234567890123456789012345678901234567890123456789012345678901234567890123456789\file.mp3
becomes
c:\music\0123456789012345678901234567890123456789012345678901234567890123~B998CD\file.mp3

i appreciate you could still theoretically get a file that has say 4 large tags in the path\filename that exceed the limits.

If anyone has concerns about this approach let me know as i plan to include the change in the next update. It wont apply to existing files, only to files as they next get organised in MB eg. auto-organise is enabled and you edit a tag, files added to an auto-organised library, manual re-org etc

the file organiser now displays a warning.
Additionally i improved the algorithm so it only shortens the filenames when it absolutely has to

So MB helps the user to take care of the issue, but the best way would be you handle extremely lengthy tags first that are used in your file-naming template before such a problem arises. Hence the question is how to identify those tracks? There may be some other ways, but the recently implemented $IsMatch function would be probably the simplest one to use and modify.

Lengthy_Path = $If($IsMatch(<Path><Filename>,"^.{201,}$")="T",">200",)

This would return ">200" for any tracks with full path name (path + filename + file extension) exceeding 200 characters; otherwise null.

Also you can check whether the above-mentioned MB handling is already in action with any of your tracks by using the following virtual tag:

Lengthy_Tag = $If($Contains(<Path><Filename>,~)="T","Y",)

This would return "Y" for any tracks with its path containing "~"character; otherwise null.
Title: Re: Useful virtual tag formulas
Post by: redwing on October 25, 2013, 10:24:55 AM
How to Create a Virtual <Folder> tag

If you frequently access and play files from their folders, MB's Computer node in left navigator might not offer desirable functionality for navigating and quick-accessing different folders. Then you might want to use a virtual field starting with the folder name you'd like to populate.

If you have a folder structure starting with E:\Music\Adele,
 
Folder = $Split(<Path>,\,3)

This would return "Adele\..." value for each track. So replace the number 3 with any number depending on your folder structure.
If you have different folder structure according to genre, etc., you can modify the formula above using $If syntax.

Now you can add this "Folder" virtual field to library explorer, column browser, or main panel for easier browsing. The difference between this and using the tag (in this case "Artist" tag) is that this directs to the corresponding folder instead of a group of tracks corresponding to the tag value. 
Title: Re: Useful virtual tag formulas
Post by: blau on October 25, 2013, 05:49:42 PM
Hello redwing,

I would like to ask if is it possible to add a virtual tag to open an external file, for example a .txt file.
I'm a complete newbie at this, tho modifying your last How to Create a Virtual <Folder> tag to:
<Path>adele.txt  i get E:\Music\Adele\adele.txt but clicking (or double clicking) on it just do nothing (that I can see).

...Perhaps I'm over-complicating myself and there is another option I'm no aware of in MB that do the same

Any hint will be much appreciated
Thanks
Title: Re: Useful virtual tag formulas
Post by: redwing on October 25, 2013, 06:04:27 PM
Hello redwing,

I would like to ask if is it possible to add a virtual tag to open an external file, for example a .txt file.
I'm a complete newbie at this, tho modifying your last How to Create a Virtual <Folder> tag to:
<Path>adele.txt  i get E:\Music\Adele\adele.txt but clicking (or double clicking) on it just do nothing (that I can see).

...Perhaps I'm over-complicating myself and there is another option I'm no aware of in MB that do the same

Any hint will be much appreciated
Thanks

No, it doesn't mean the actual file. That means just displaying <Path> plus some words you typed in, and it will show the same thing for any file (each file's path plus the same filename you typed in). For one thing, MB can't display files other than file types playable with it. For another, virtual tag is sort of tag just like Title or Artist, so it can't be used for such purpose.
Title: Re: Useful virtual tag formulas
Post by: blau on October 25, 2013, 06:10:34 PM
Thanks for the explanation.
Title: Re: Useful virtual tag formulas
Post by: redwing on October 28, 2013, 01:21:29 PM
How to Populate "Filename Only" Field

Currently <Filename> field returns filename plus file extension. Here's how to populate filename only with virtual tags.

Filename only = $Replace(<Filename>,.<.Ext>,)
Title: Re: Useful virtual tag formulas
Post by: redwing on February 07, 2014, 10:44:30 AM
How to Remove Last Backslash of <path>

  $Replace(<Path>*,\*,)

However, it's expandable to a more general formula, let's say you'd like to remove the last 5 characters of any field. First you have to choose a character (or a combination of more than one) that will never be part of that field in the same order, in the following example I use "qqq" instead of the "*":
   $Replace(<Anyfield>qqq,$Right(<Anyfield>,5)qqq,)
Title: Re: Useful virtual tag formulas
Post by: Deping on February 07, 2014, 07:46:51 PM
Using <Random #> returns "Unknown Random #" ?
Title: Re: Useful virtual tag formulas
Post by: psychoadept on February 07, 2014, 10:12:42 PM
Using <Random #> returns "Unknown Random #" ?

This is a known bug.  Search in the Bug Reports forum to comment on it.
Title: Re: Useful virtual tag formulas
Post by: redwing on February 26, 2014, 07:22:34 AM
How to Identify Duplicate Filenames in an Auto-organized Library

When you have your library auto-organized, what happens if some files in the same folder get exactly the same filename according to your naming template? In that case MB appends underscore plus counter to the filename to distinguish each file from others. e.g.: "1-08 Right as Rain_1.mp3"
Thus you might, once in a while, want to check if there are any duplicate filenames in your auto-organized library. After identifying those, you could edit your template or delete duplicate files depending on the situation.

Duplicate Filename = $If($Left($Right(<Filename>,6),1)="_",Y,)

Duplicate Filename = $If($Left($Right($Replace(<Filename>,.<.Ext>,),2),1)="_",Y,)

will assign "Y" value to the files in filename ending underscore plus a single digit number.
Title: Re: Useful virtual tag formulas
Post by: psychoadept on February 26, 2014, 02:16:00 PM
That's a good idea!  You'd have to do 7 digits for FLAC files, though.
Title: Re: Useful virtual tag formulas
Post by: redwing on February 26, 2014, 02:32:45 PM
Good point! I edited the formula above to make it working with any kind of file extension. Thanks for reporting!
Title: Re: Useful virtual tag formulas
Post by: callimi on March 14, 2014, 09:37:58 PM
How to Create a Virtual <Folder> tag

If you frequently access and play files from their folders, MB's Computer node in left navigator might not offer desirable functionality for navigating and quick-accessing different folders. Then you might want to use a virtual field starting with the folder name you'd like to populate.

If you have a folder structure starting with E:\Music\Adele,
 
Folder = $Replace(<Path>,$Left(<Path>,9),)

This would return "Adele\..." value for each track. So replace the number 9 with any number depending on your folder structure.
If you have different folder structure according to genre, etc., you can modify the formula above using $If syntax.

Now you can add this "Folder" virtual field to library explorer, track browser, or main panel for easier browsing. The difference between this and using the tag (in this case "Artist" tag) is that this directs to the corresponding folder instead of a group of tracks corresponding to the tag value.  

How to Create a "real" Virtual <Folder> tag

stating from your idea, i managed to create a virtual tag that give me the name of folder where my music file is located (wherever the file is, up to 8 levels)
That mean, If you have a music file located in  E:\Music\Goodmusic\ToShare\Arstist -Album\Mytitle.mp3
this tag will give you "Arstist -Album"
 
For doing so i create  8 virtual tags  and call the last one (I.e. Virtual9) : 

Virtual2 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,1),<Chemin>)
Virtual3 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,2),<Chemin>)
Virtual4 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,3),<Chemin>)
Virtual5 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,4'),<Chemin>)
Virtual6 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,5),<Chemin>)
Virtual7 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,6),<Chemin>)
Virtual8 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,7),<Chemin>)
Virtual9 = $IsNull(<Virtual8>,$IsNull(<Virtual7>,$IsNull(<Virtual6>,$IsNull(<Virtual5>,$IsNull(<Virtual4>,$IsNull(<Virtual3>,<Virtual2>,<Virtual3>),<Virtual4>),<Virtual5>),<Virtual6>),<Virtual7>),<Virtual8>)


Now you can add this "Real Folder" virtual field to library explorer, track browser, or main panel for easier browsing..


PS: do not hesitate to comment this post is you find a better way to do it !
Title: Re: Useful virtual tag formulas
Post by: redwing on March 20, 2014, 04:51:44 PM
How to Convert Date Format

If you want to convert date like "20110318" to "18/03/2011" format, use this:

Date Convert = $Date($Left(<Year>,4)/$Left($Right(<Year>,4),2)/$Right(<Year>,2),dd/MM/yyyy)

for changing to "03/18/2011" format, use this:

Date Convert = $Date($Left(<Year>,4)/$Left($Right(<Year>,4),2)/$Right(<Year>,2),MM/dd/yyyy)

Now you could copy the virtual tag values to date tag to convert the date format.
Title: Re: Useful virtual tag formulas
Post by: redwing on March 23, 2014, 04:21:42 PM
Easier Navigation with Artists on Thumbnail Browser

The biggest pain with using Thumbnail Browser is that it doesn't support AZ jump bar. Though you can type first letter and jump to those artists, it's not as convenient as it appears because you first have to select an item on Thumbnail Browser to take focus before typing. The better solution is to use a custom AZ jump bar with vertical Column Browser as posted before:

Custom AZ bar using vertical column browser

AZ bar is useful but it responds only to sort column which feels sometimes cumbersome. To avoid this, you can create your own custom AZ bar using a virtual tag and vertical column browser. It also filters to the selection.

1. Create a virtual tag as follows:
(1) For general use: AZ = $Group($Sort(<Artist>),1)
(2) If you have classical music tracks and want them grouped by composer rather than by artist:
AZ = $If(<Genre>="Classical",$Group($Sort(<Composer>),1),$Group($Sort(<Artist>),1))

Note: you can replace <Artist> with <Album Artist> or any other field in accordance with your tagging scheme.

2. Configure column browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

3. When you want to return to full list after filtered to a subset , click on "all" at the top or the selected node in left navigator.

The same virtual tag can be used to easily navigate through a long list of artists in Thumbnail Browser.

AZ = $Group($Sort(<Artist>),1)

If using a first letter of artist like A, B, C... still lists too many artists, you can divide each letter into two groups like Aa, Ao, Ba, Bo,...

AaZo = $Group($Sort(<Artist>),1)$If($IsMatch($Right($Left($Sort(<Artist>),2),1),[a-n])="T",a,o)

will return "Ea" for Elton John and "Eo" for Eric Clapton.


(http://i.imgur.com/AiXOOe6.png)


Let's try one more step. For some letters where only a few artists are listed, you might not want divide them into two groups because if the AZ bar is too long then you have to scroll it up and down as well.

Custom AaZo = $Group($Sort(<Artist>),1)$If($IsMatch($Group($Sort(<Artist>),1),[gioqu-z])="T",,$If($IsMatch($Right($Left($Sort(<Artist>),2),1),[a-n])="T",a,o))

will not divide into two groups for first letters specified in [gioqu-z] part, which means "g", "i", "o", "q", "u", "v", "w", "x", "y", and "z".
Title: Re: Useful virtual tag formulas
Post by: redwing on April 03, 2014, 03:35:56 AM
How to Extract All <Featuring Artist> from Title

The following virtual tag returns all featuring artists specified in title.

Code
$RxReplace($RSplit($Split(<Title>,feat.,2),")",2),",|\s&",";")

Song Title
=> returns nothing

Song Title (feat. BBB)
=> BBB

Song Title (feat. BBB & CCC)
=> BBB; CCC

Song Title (feat. BBB, CCC & DDD)
=> BBB; CCC; DDD

Song Title (feat. BBB, CCC, DDD & EEE)
=> BBB; CCC; DDD; EEE

If you want, you can copy this virtual tag value to <Artists: Guest> field, using "Copy guest artists from <tag 1>" preset with Additional Tagging Tools plugin.
Title: Re: Useful virtual tag formulas
Post by: redwing on April 06, 2014, 03:19:39 AM
How to Convert "Composer" to <Last name, First name> format

This virtual tag converts composer name to "last name, first name" format as follows (thanks to the newly implemented $RSplit function, it's now much simpler with no word count limit):

Anonymous => Anonymous
Johaness Brahms => Brahms, Johaness
Ludwig van Beethoven => Beethoven, Ludwig van
Carl Maria von Weber => Weber, Carl Maria von

Sort-Composer = $IsNull(<Composer>,,$If($Contains(<Composer>," ")="F",<Composer>,$RSplit(<Composer>," ",1)", "$Replace(<Composer>*,$RSplit(<Composer>," ",1)*,)))

Note: You could also use ASR preset for the same purpose.
Title: Re: Useful virtual tag formulas
Post by: redwing on September 07, 2014, 07:18:23 AM
How to Identify Artists with Multiple Albums in the Same Year

I'm trying to do a search of artists that released multiple albums in the same year, and exclude everything else. How would one do that?

The quote above came from quite an old post (with no responses), but I've been wresting with the same issue for some time partly to enhance my file organization template. Anyway, I came to the conclusion that this kind of task can't be done without having "Album Count" field implemented.
Within the current functionality, the best solution I could think of is:

- Create a virtual tag "Multi-album" = $IsNull(<Year (yyyy)>,,$Sort(<Album Artist>)-<Year (yyyy)>)
- Add the field to library explorer category
- Set "sort by" option of the category to "Album"
- Tick "Show Count" option
- Now browse the field list and try to find items with a number greater than 1.

(http://i.imgur.com/Mxg9sdh.png)

If there was "Album Count" field available, you could have a neat auto-playlist of only those tracks without having to browse all album artists.
Title: Re: Useful virtual tag formulas
Post by: redwing on May 28, 2015, 01:43:45 AM
How to Group Auto-calculated Album Rating

If you have the option "auto-calculate album rating" ticked under Preference> Tags (1), MB auto-calculates <Album Rating> as an average of track rating in the album. To display the number(0-100), you need to create a virtual field and add it to the main panel.

Album Score = <Album Rating>

You can also group the album rating using another virtual tag:

1. Go to Preferences> Layout (1)> Configure Fields
2. Find the virtual tag you created for album rating ("Album Score" in this case) and change its data type from "String" to "Number"
3. Define another virtual field "Album Range" using the following formula (note that this formula should use your own virtual tag label, "Album Score" in this case):

$If(<Album Score>=-1,"No Rating",$If(<Album Score>>10,$If(<Album Score>>20,$If(<Album Score>>30,$If(<Album Score>>40,$If(<Album Score>>50,$If(<Album Score>>60,$If(<Album Score>>70,$If(<Album Score>>80,$If(<Album Score>>90,91-100,81-90),71-80),61-70),51-60),41-50),31-40),21-30),11-20),0-10))

4. Add "Album Range" to column browser for grouping album rating.
Title: Re: Useful virtual tag formulas
Post by: redwing on March 04, 2016, 01:07:37 PM
How to Display Web Lyrics for Playing Track

For v2.5
You can add custom web links to Playing Tracks panel (either tab or bar at the bottom). The nice thing is it updates when playing track changes.
 
For v3
Custom web links can be configured in configuration dialog of Track Information element. And they can be run either from track info element or now playing tab/bar via context menu. If you have web browser plugin installed, the web content will be displayed inside MB.

Genius.com
http://genius.com/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Artist>,/,-),the,)-$Split(<Title>,"(",1)," ",-),',),?,),&,and),",",),!,),.,)-lyrics

Musixmatch.com
https://www.musixmatch.com/lyrics/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Artist>,/,-)," ",-)/$Replace($Split(<Title>,(,1)," ",-),',),.,),?,),!,),&,),',)

MetroLyrics.com
http://metrolyrics.com/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Split(<title>,"(",1)-lyrics-$Replace($Replace(<Artist>,/,),the,)," ",-),',),?,),&,and),",",),!,),.,)

Note: It should work for most songs with standard artist names and song titles, but could fail for some in which cases you will need to edit the generated query manually or use the site's search function.
Title: Re: Useful virtual tag formulas
Post by: redwing on March 17, 2016, 03:26:55 PM
How to Identify Tracks with a Cue Sheet File

To identify tracks with a cue sheet file, you can use the following virtual tag using MB's internal tag <FileCueSheet>:

Cue = $IsNull(<FileCueSheet>,,<FileCueSheet>)

If you add the "CUE" field to the main panel, the column will show the entire content of the cue sheet just like when using Edit Cuesheet button on Tag Editor.
 
Then create an auto-playlist using the rule of "CUE" field "has a value".
The auto-playlist will only contain tracks with a cue sheet.

Also you can make file extension column of tracks with a cuesheet file displayed in the main panel as something like "flac/cue" with the following virtual tag:

$IsNull(<FileCueSheet>,<.Ext>,<.Ext>/cue)
Title: Re: Useful virtual tag formulas
Post by: thesket on April 26, 2016, 09:38:41 AM
Oh my god, redwing, thank you for those custom web links.

I've been trying for hours to figure out how to do this; tried using virtual tags, and got it to work for some cases but not all. Your solution is much more elegant. Actually I didn't realize you could use functions in the custom web links section.

I wasn't able to fully wrap my head around your logic, but was able to reverse-engineer them enough to at least get Ultimate-Guitar tabs and chords working.

Thanks, you're brilliant.
Title: Re: Useful virtual tag formulas
Post by: redwing on April 26, 2016, 09:59:15 AM
Oh my god, redwing, thank you for those custom web links.

I've been trying for hours to figure out how to do this; tried using virtual tags, and got it to work for some cases but not all. Your solution is much more elegant. Actually I didn't realize you could use functions in the custom web links section.

I wasn't able to fully wrap my head around your logic, but was able to reverse-engineer them enough to at least get Ultimate-Guitar tabs and chords working.

Thanks, you're brilliant.

That's great! Feel free to post the web link formula you've come up with so that others can benefit from your work.
Title: Re: Useful virtual tag formulas
Post by: thesket on April 26, 2016, 10:19:36 AM
Sure thing! If you ever have time and feel like explaining exactly how this logic works, I'd appreciate it lol. There are so many replaces, parameters and parentheses that it's hard to follow.
Here's the UG web link I got from modifying yours:

UG Chords
https://tabs.ultimate-guitar.com/traesmusicbee/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Artist>,/,-)," ",_)/$Replace($Split(<Title>,(,1)," ",_),',),.,),?,),!,),&,),',)_crd.htm

UG Tab
https://tabs.ultimate-guitar.com/traesmusicbee/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Artist>,/,-)," ",_)/$Replace($Split(<Title>,(,1)," ",_),',),.,),?,),!,),&,),',)_tab.htm

(and)

UG Search
https://www.ultimate-guitar.com/search.php?search_type=title&order=&value=<Title>+<Artist>
Title: Re: Useful virtual tag formulas
Post by: Iasc on April 26, 2016, 10:42:20 AM
Sure thing! If you ever have time and feel like explaining exactly how this logic works, I'd appreciate it lol. There are so many replaces, parameters and parentheses that it's hard to follow.
Here's the UG web link I got from modifying yours:

UG Chords
https://tabs.ultimate-guitar.com/traesmusicbee/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Artist>,/,-)," ",_)/$Replace($Split(<Title>,(,1)," ",_),',),.,),?,),!,),&,),',)_crd.htm

UG Tab
https://tabs.ultimate-guitar.com/traesmusicbee/$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Artist>,/,-)," ",_)/$Replace($Split(<Title>,(,1)," ",_),',),.,),?,),!,),&,),',)_tab.htm

(and)

UG Search
https://www.ultimate-guitar.com/search.php?search_type=title&order=&value=<Title>+<Artist>

I will definitely use these. Thanks thesket.
Title: Re: Useful virtual tag formulas
Post by: redwing on April 26, 2016, 01:00:44 PM
Sure thing! If you ever have time and feel like explaining exactly how this logic works, I'd appreciate it lol. There are so many replaces, parameters and parentheses that it's hard to follow.

Thanks for sharing them! Sure, I'll try to find time to write a short guide.
Title: Re: Useful virtual tag formulas
Post by: Abers86 on August 12, 2016, 03:53:09 PM
Not sure if anyone might be interested in this very short virtual tag formula to easily display whether a track is in a specified playlist. I have a 'Phone' playlist, unsurprisingly used for syncing music with my phone. Since it has hundreds of tracks and I regularly add / remove albums it's hard to keep track of what's in it or not. I was getting more and more annoyed when sending tracks to the playlist to be notified that they would be duplicates as they were already in it. This little formula fixed that issue:

$If(<Playlist>="Phone","  ?"," ")

Now if a track is in the specified playlist I have a tick displayed after all the other fields.

Edit: Quick question - would it be possible to create a checkbox similar to the one that can enable or disable whether a file is synced / played but instead that when ticked adds a track to a specified playlist and when unticked removes it?
Title: Re: Useful virtual tag formulas
Post by: psychoadept on August 12, 2016, 05:25:07 PM
Edit: Quick question - would it be possible to create a checkbox similar to the one that can enable or disable whether a file is synced / played but instead that when ticked adds a track to a specified playlist and when unticked removes it?

You can use the tick box as a criteria for auto playlists.  So you can just use that to keep track of which tracks are included.
Title: Re: Useful virtual tag formulas
Post by: Abers86 on August 12, 2016, 06:13:55 PM
You can use the tick box as a criteria for auto playlists.  So you can just use that to keep track of which tracks are included.

Thanks for the reply. Huh, I always thought the built-in tick box if unticked meant that tracks would be skipped during playback. Double checked and that's not the case. Does the field then have no intrinsic purpose / effect unless the user specifies one for it in playlists etc?
Title: Re: Useful virtual tag formulas
Post by: psychoadept on August 12, 2016, 07:21:29 PM
It can also be used to select tracks in groups, ie all checked or all unchecked, flee editing our whatever.  But just ticking a track doesn't have any effect that I'm aware of.

To prevent a track from playing, you can ban it I the tag editor or click the space to the left of it in the playing tracks list (makes a - appear)
Title: Re: Useful virtual tag formulas
Post by: Abers86 on August 12, 2016, 09:20:01 PM
Magic thanks. Fortunately my formula was handy to quickly tick all those that were in my existing playlist. Only issue I am having with using the 'ticked' special field is that you can't display it in the compact view - or I am just being glaikit. Not the end of the world but tad annoying.
Title: Re: Useful virtual tag formulas
Post by: psychoadept on August 12, 2016, 09:40:11 PM
You can always make a wishlist request.  :)
Title: Re: Useful virtual tag formulas
Post by: redwing on November 29, 2017, 04:38:49 PM
More Informative Track Properties Display

Track information panel has an option to show track properties for playing/selected track. Very useful but it has some limitations. I have lots of ALAC files but it only shows them as "m4a", which is not quite helpful if you also have lots of AAC files that are using the same MPEG-4 container format. Another info that I'd like to see is whether it's a file with a cue sheet.

So now I am using the following formula for the track info panel in place of the in-built track properties option.

Code
$IsNull(<FileCueSheet>,$Replace($Split(<Kind>," ",1),MPEG,MP3),$Replace($Split(<Kind>," ",1),MPEG,MP3)" (cue)") <Bitrate> / <Sample Rate> (<Channels>)
(https://i.imgur.com/GHyn7Ih.png)
Title: Re: Useful virtual tag formulas
Post by: redwing on February 02, 2018, 08:53:22 PM
How to Display and Sort Tracks by Clipping Gain

If you run volume analysis, it can optionally show in its result window which tracks will clip when the current ReplayGain values are applied and how much gain reduction is required to avoid clipping. The problem is there's no way to save or export those figures. Thanks to Additional Tagging Tools plugin's support for various math functions, now it's possible to instantly display those figures as a virtual tag and you can sort tracks by it (or save it as a custom tag to files) to find out which tracks will likely to clip while playing with ReplayGain on.

(https://i.imgur.com/K4ff6Pl.png)

Needless to say, this assumes you have already run volume analysis on your tracks. Without existing ReplayGain tags, these virtual tags won't work at all.

First, you need to map album peak and track peak tag to custom tags to access their values as MB doesn't support this natively.
Go to Preferences> Tags (1)> Define new tags and enter the following in identifier box and press tab to populate it in other boxes.

Code
REPLAYGAIN_ALBUM_PEAK
Code
REPLAYGAIN_TRACK_PEAK

(https://i.imgur.com/yVN8ldV.png)

Save and close the dialog and return to Tags (1) panel.

In custom tags configuration setting, create two custom tags "Album Peak" and "Track Peak" and select the pre-defined tag code REPLAYGAIN_ALBUM_PEAK and REPLAYGAIN_TRACK_PEAK using dropdown button.

(https://i.imgur.com/tPHvJ62.png)

Save the dialog, now you will see MB rescans all files in your library. When it's done, confirm Album Peak and Track Peak tags are properly mapped by adding those columns to the main panel.

Now you need to define two virtual tags that will show the clipping gain. As stated earlier, these virtual tags require latest version (2018-02-03 or later) of Additional Tagging Tools plugin (https://getmusicbee.com/addons/plugins/49/additional-tagging-and-reporting-tools/) installed and enabled. Without the plugin, this won't work.

Clip (album)
Code
$IsNull(<Album Peak>,,$If($Add($Mul(20,$Lg(<Album Peak>)),$Split(<Album Gain>," ",1))<0.00,,$Round($Add($Mul(20,$Lg(<Album Peak>)),$Split(<Album Gain>," ",1)),2)))
Clip (track)
Code
$IsNull(<Track Peak>,,$If($Add($Mul(20,$Lg(<Track Peak>)),$Split(<Track Gain>," ",1))<0.00,,$Round($Add($Mul(20,$Lg(<Track Peak>)),$Split(<Track Gain>," ",1)),2)))
Now you can sort albums/tracks by the clipping gain and identify tracks that would most likely to clip while playing. This will allow you to test which tracks are most audibly clip and what means are mostly effective to avoid clipping.
Title: Re: Useful virtual tag formulas
Post by: redwing on February 02, 2018, 09:12:59 PM
How to Bulk-adjust Target Loudness Level of RG tags without Re-analyzing Tracks

When you want to adjust target loudness level of existing ReplayGain tags, you don't have to re-analyze tracks using the slider, which will take considerable amount of time. Instead you could create a virtual tag that shows the adjusted values and then bulk copy them to the existing ReplayGain tags.

These virtual tags require latest version (2018-02-03 or later) of Additional Tagging Tools plugin (https://getmusicbee.com/addons/plugins/49/additional-tagging-and-reporting-tools/) installed and enabled.

For instance, if you want to lower 7 dB for all your ReplayGain tags then use the following virtual tags, which will have the exactly same effect as re-analyzing tracks using the slider:

New Album Gain
Code
$IsNull(<Album Gain>,,$Sub($Split(<Album Gain>," ",1),7)" dB")
New Track Gain
Code
$IsNull(<Track Gain>,,$Sub($Split(<Track Gain>," ",1),7)" dB")
Then you can use "copy tag" command of Additional Tagging Tools plugin to bulk copy the virtual tags to the RG tags.

(Personally I don't take this approach to tackle the clipping issue but it seems many people prefer this way)

Note on sorting of negative numbers in virtual tags:

To sort negative numbers correctly in virtual tags, you need to change the virtual tag's type to "number" in configure fields setting. But if the numbers are appended by some characters (like "dB" in this case), they won't sort correctly even if it's set to numeral type. If you really want to sort them correctly then create another virtual tag just for sorting purpose without appending any characters to the number.
Title: Re: Useful virtual tag formulas
Post by: redwing on February 05, 2018, 10:44:48 AM
How to Check Filename Length

Now it's easy to check the length of filename (+paths) if you install latest version (2018-02-05 or later) of Additional Tagging Tools plugin (https://getmusicbee.com/addons/plugins/49/additional-tagging-and-reporting-tools/).
Use the following formula to create a virtual tag.

Length
Code
$Len(<URL>)
Then add the field to the main panel or create an auto-playlist using the field. To make the field sorting correctly you need to change the virtual field's type to "Number" in Configure Fields setting.
Title: Re: Useful virtual tag formulas
Post by: redwing on February 08, 2018, 01:53:33 AM
How to Create "Filename Only" Field

Sometimes you want to use just filename in a template, but currently <Filename> field returns filename plus file extension.
Now this can be easily achieved if you install latest version (2018-02-06 or later) of Additional Tagging Tools plugin (https://getmusicbee.com/addons/plugins/49/additional-tagging-and-reporting-tools/).

Create a virtual tag called <Name> with the following formula.
Code
$Name(<Filename>)
Then you can put just <Name> in a template when you want to use filename without extension.
Title: Re: Useful virtual tag formulas
Post by: redwing on February 08, 2018, 02:17:38 AM
Play count per 100 days

A highest play count doesn't necessarily mean that you liked the song most in your library. You also need to take into account how many days each track has stayed in your library since tracks you had imported earlier are likely to have played more times than recently imported ones.
Now you can calculate this kind of figures if you install latest version (2018-02-15 or later) of Additional Tagging Tools plugin.
Create a virtual tag with the following formula:

Play count per 100 days
Code
$Round($Mul($Div(<Play Count>,$NumberOfDays($Now(),<Date Added>)),100),1)
The reason it's using per 100 days rather than per day is simply to avoid small numbers. If you have rather big (or small) play counts, adjust the formula accordingly. To sort the field correctly, you need to change the virtual field's type to "Number" in Configure Fields setting.
Title: Re: Useful virtual tag formulas
Post by: Freddy Barker on February 08, 2018, 11:26:13 AM
Quote
Now you can calculate this kind of figures if you install latest version (2018-02-06 or later) of Additional Tagging Tools plugin

@redwing

Does all of that awesomeness now mean I can show "Last played was NNN days ago" now?

Kind regards: Freddy  ;)
Title: Re: Useful virtual tag formulas
Post by: redwing on February 08, 2018, 11:46:20 AM
I can show "Last played was NNN days ago" now?

Yes, use this:

$If(<Last Played>="Unknown",,$RoundDown($NumberOfDays(<Last Played>),0))

I'll ask boroda74 to return integers with the $NumberOfDays function, then you could remove $RoundDown part (I'll edit the formula if it's fixed).
And if you have further questions, please use Questions forum.

--------

<edit>
Code
$If(<Last Played>="Unknown",,$NumberOfDays($Now(),<Last Played>))
Title: Re: Useful virtual tag formulas
Post by: Freddy Barker on February 08, 2018, 06:54:32 PM
I can show "Last played was NNN days ago"?

Yes, use this:
Code
$If(<Last Played>="Unknown",,$RoundDown($NumberOfDays(<Last Played>),0))
I'll ask boroda74 to return integers with the $NumberOfDays function, then you could remove $RoundDown part

Wow! ;)
I was assuming that the Tagging Tool Plugin would need some configuring but it worked like a dream by just installing it!
As usual - excellent work and quick fix! 
Thanks @boroda74 for the Plugin and thanks @redwing for the Code - I would never had figured it out on my own!

Best Regards: Freddy
Title: Re: Useful virtual tag formulas
Post by: doodlepapers on June 21, 2018, 03:06:31 AM
How to Identify Tracks with a Cue Sheet File

To identify tracks with a cue sheet file, you can use the following virtual tag using MB's internal tag <FileCueSheet>:

Cue = $IsNull(<FileCueSheet>,,<FileCueSheet>)

If you add the "CUE" field to the main panel, the column will show the entire content of the cue sheet just like when using Edit Cuesheet button on Tag Editor.
 
Then create an auto-playlist using the rule of "CUE" field "has a value".
The auto-playlist will only contain tracks with a cue sheet.

Also you can make file extension column of tracks with a cuesheet file displayed in the main panel as something like "flac/cue" with the following virtual tag:

$IsNull(<FileCueSheet>,<.Ext>,<.Ext>/cue)


Does this still work?

When I add the virtual track to track details and then sort, they show up fine.

But when added to an auto playlist, all tracks in my library show up, and not just the ones with .cue.
Title: Re: Useful virtual tag formulas
Post by: redwing on June 21, 2018, 05:03:50 AM
Then check what the virtual field shows for tracks with no cuesheet in your auto-playlist.
Make sure you didn't include "Cue =" part too to the formula.
Title: Re: Useful virtual tag formulas
Post by: redwing on July 18, 2018, 01:07:15 AM
How to find albums with the same value for both album gain and track gain

Sometimes you forget to re-run volume analysis for a single FLAC (or APE) file album after splitting them to individual tracks. Then the album gets left with the same album/track gain for every track in it. Because they already have the both RG tags, they get excluded even if you select the entire library (unless you tick the tickbox again for all selected tracks to re-run it for every selected album).

Create a virtual tag with the following formula:
 
Code
$IsNull(<Album Gain><Track Gain>,,$If($Split(<Album Gain>," ",1)=$Split(<Track Gain>," ",1),$Split(<Album Gain>," ",1),))
And use "that virtual tag" "has a value" rule for either an auto-playlist or highlighting rule.
Then it will show all tracks that have the exactly same value for both album and track gain. Some tracks could have the same values at random. So ignore such a single track in an album and try to find albums with full of such tracks.

And this code is for locating tracks with no RG tags or with track gain tags only:
Code
$IsNull(<Album Gain>,$IsNull(<Track Gain>,,T),T+A)
For this tag, if you use "that virtual tag" "has no value" rule, it will show tracks with no RG tags.
And "that virtual tag" "is" "T" rule will list tracks with track gain tags only.
Title: Re: Useful virtual tag formulas
Post by: redwing on September 27, 2018, 11:20:14 PM
How to display the number of values tagged for a multi-value tag

I'd like to share tangotoynb's contributions: see the original thread https://getmusicbee.com/forum/index.php?topic=26688.0

This code will display the number of values tagged for a multi-value tag like Artist or Genre.

Code
$Add($Len($RxReplace(<Artist>,"[^;]","")),1)
And note that you need to have Additional Tagging Tools plugin (http://musicbee.wikia.com/wiki/Additional_Tagging_and_Reporting_Tools#Links) installed to use those additional functions in your virtual tags.
Title: Re: Useful virtual tag formulas
Post by: redwing on November 11, 2018, 03:12:29 PM
How to Add All <Featuring Artist> to Title

This is an opposite task to a previous post "How to Extract All <Featuring Artist> from Title" (https://getmusicbee.com/forum/index.php?topic=9317.msg75544#msg75544).

When you have multiple artists tagged, the following code will generate a virtual tag that adds all featuring artists after title.

Code
<Title>$If($First(<Artist>)=<Artists>,," (feat. "$If($Split(<Artists>,;,2)=$RSplit(<Artists>,;,1),$RSplit(<Artists>,;,1),$Replace($RxReplace(<Artists>,"^[^;]+;\s*(.*);\s*([^;]+)$","$1 & $2"),;,","))")")
e.g. multiple artists "AAA; BBB; CCC; DDD; EEE" > Song Title (feat. BBB, CCC, DDD & EEE)