Author Topic: More Functions for Template Editor  (Read 1425 times)

MayorQwert

  • Jr. Member
  • **
  • Posts: 51
There's a few things I've noticed are missing from template editor that would further expand on functionality.

1) A random number function. Something like $Rand(lower,upper). Outputted values could be used with the <, >, or =, operators in some cases.
I've had at to improvise in my case with very convoluted code involving date modified to make a "pseudo-random" display for some projects I'm working on in MusicBee

2) Better implementation of >,<,= operators. It seems like it doesn't work properly for larger integers, I get odd behavior when you get to multiple digit numbers. It would be nice if it worked properly for all integers as well as negative numbers and timestamps (in the #:## form).

3) Arithmetic functions (i.e. add, subtract, multiply, divide) and the ability to use them with tags that are set to be numbers (and maybe even times!). So for example being able to manually divide the album rating to have it display on a 1-5 scale.

If functions were to be used, the following could be contenders:

$Mult(A,B,decimals) (A * B) if decimals = 0, output is #, if decimals is 3, output is #.###, etc.
$Div(A,B,decimals) (A/B)
$Add(A,B) (A+B)
$Sub(A,B) (A-B)

So for the album rating example, let's say you want a string to say "The Album rating is 4.7."  in track info. Currently, album rating is an integer between 0 and 100.

So if you were to type this string out in the current template editor it would be:

"The Album rating is "<Album Rating>"."
Which would print: "The Album Rating is 94."

With a Div function, you would write it as:

"The Album Rating is "$Div(<Album Rating>,20,1)"."
Which would print: "The Album Rating is 4.7.

There's other benefits, too. Like if you can use it with time variables and do division of a mm:ss formatted track length by the full album length to get a percentage of how much the track is out of the full album, or even if you could do something like take the album length in minutes and divide it by the number of tracks to get the average length per track, for example.

4) A tag to go along with "Album Played" that can denote the number of tracks played from the track's album. So if you have played 3 / 11 of the tracks in the library it will display a "3". This could be used with the $Div function to then give you the percentage of an album played.

So:
"Percent of Album Played: "$Mult($Div(<Album Played Tracks>, <Album Track Count>,5),100,1)"%"

If:
<Album Played Tracks> = 3, <Album Track Count> = 11
$Div(<Album Played Tracks>,<Album Track Count>,5) = 0.27273
$Mult(0.27273,100,1) = 27.3

With string elements, outputted text is:
"Percent of Album Played: 27.3%"
Last Edit: February 15, 2021, 05:48:26 PM by MayorQwert

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
You should check out the additional tagging and supporting tools plugin. I know it has math functions, I'm not sure what else there might be.
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

MayorQwert

  • Jr. Member
  • **
  • Posts: 51
You should check out the additional tagging and supporting tools plugin. I know it has math functions, I'm not sure what else there might be.
I'll certainly have a look to see if it has some of what I'm searching for, thanks for the suggestion.

MayorQwert

  • Jr. Member
  • **
  • Posts: 51
Just found "Additional tagging and reporting tools" plugin, and looks to have what I'm looking for! Though I do wish it had the option for number of decimals built into the function (it has rounding function though, at least!).

Another gripe is the current implementation of that plugin doesn't display the functions in the functions list. Not sure if that can be done or not but something official would be great. :)

I can hopefully make this work for the time being at least.  ;)
Last Edit: February 15, 2021, 10:38:18 PM by MayorQwert