getmusicbee.com

Support => Questions => Topic started by: hamlet35 on June 12, 2024, 02:30:35 PM

Title: Disc Duration
Post by: hamlet35 on June 12, 2024, 02:30:35 PM
Good morning all!

I am trying to create a virtual tag for Disc Duration - I need this for multiple disc sets. On my Main Table I want to show something like this:

Disc 1 of 2  46:00
Tracks
Disc 2 of 2  35:00

Right now I have the album duration in there, but would like to get Disc Duration and not album duration.  I tried doing some research, but couldn't find anything.
Title: Re: Disc Duration
Post by: Mayibongwe on June 12, 2024, 05:40:20 PM
Someone else might know of a condensed formula, but here it is in four virtual tags:

v1 Duration converted to seconds   =   $Add($Mul($Split(<Time>,:,1),60),$Split(<Time>,:,2))
v2 Unique Album Disc   =   <Disc#><Album><Album Artist>
v3 Total Duration per Disc   =   $Sum(<v1>,<v2>)
v4 Combined Disc Duration   =   $Split($Div(<v3>,60),",",1):$Sub(<v3>,$Mul($Split($Div(<v3>,60),",",1),60))
Title: Re: Disc Duration
Post by: hamlet35 on June 12, 2024, 06:15:21 PM
This was a great start and I thank you so much. I think I now have a formatting issue.
In this part of the code from part 4: $Split($Div(<v3>,60),",",1):$Sub(<v3>,$Mul($Split($Div(<v3>,60),",",1),60)), is there a way to get the results in the format of 56:09 for discs that are less than an hour and 1:15: 00 for above an hour or even in the format of 00:00:00 (hour, minute, seconds)
Title: Re: Disc Duration
Post by: Mayibongwe on June 12, 2024, 06:28:24 PM
is there a way to get the results in the format of 56:09 for discs that are less than an hour and 1:15: 00 for above an hour or even in the format of 00:00:00 (hour, minute, seconds)
It is possible, but to be honest, I'm not up for that task this evening - sorry.
See if you can play around with this formula below to get it to do what you want. You just need to insert the seconds in v3 in here:

Just wondering if it's possible to also split hours and days? Or I guess just hours would make the most sense, no need for days.
....
I think I finally got it!

Code
$Split($Div($Mul($Add($Mul($Pad($Split(<Time>,:,1),2),60),$Split(<Time>,:,2)),<Play Count>),3600),.,1) hours $Mod($Split($Div($Mul($Add($Mul($Pad($Split(<Time>,:,1),2),60),$Split(<Time>,:,2)),<Play Count>),60),.,1),60) minutes $Mod($Mul($Add($Mul($Pad($Split(<Time>,:,1),2),60),$Split(<Time>,:,2)),<Play Count>),60) seconds
Title: Re: Disc Duration
Post by: karbock on June 12, 2024, 07:04:44 PM
A new v4 formula to distinguish between discs longer/shorter than one hour.
It is also shorter, thanks to the use of modulos and downward roundings.

You'll need to have the Additional Tagging & Reporting Tools (https://getmusicbee.com/addons/plugins/49/additional-tagging-amp-reporting-tools/) plugin installed (for $ge and $RoundDown).

Code
$If($ge(<v3>,3600),$RoundDown($Div(<v3>,3600),0)":",)$Pad($RoundDown($Div($Mod(<v3>,3600),60),0),2)":"$Pad($Mod(<v3>,60),2)

Or, if you prefer the ... h ... min ... s format:
Code
$If($ge(<v3>,3600),$RoundDown($Div(<v3>,3600),0)" h ",)$RoundDown($Div($Mod(<v3>,3600),60),0)" min "$Mod(<v3>,60)" s"
Title: Re: Disc Duration
Post by: hamlet35 on June 12, 2024, 07:15:57 PM
This: $If($ge(<v3>,3600),$RoundDown($Div(<v3>,3600),0)" h ",)$RoundDown($Div($Mod(<v3>,3600),60),0)" min "$Mod(<v3>,60)" s"

did the trick!  Thanks for everyone's help!
Title: Re: Disc Duration
Post by: karbock on June 12, 2024, 07:20:37 PM
You're welcome!

NOTE:
Since the value in <Time> is an approximation (the milliseconds are dropped),
<v3> will never be accurate to the second.
But there is no workaround.
Title: Re: Disc Duration
Post by: hiccup on June 15, 2024, 06:42:31 AM
Building upon the great solutions that Mayibongwe and Karbock have already provided, thanks to Boroda it is now possible to accomplish this with three virtual tags instead of four, but more importantly, much simpler formulas.
It requires the latest version of the Additional Tagging & Reporting Tools (https://getmusicbee.com/forum/index.php?topic=3833.msg20793#msg20793) plugin (v8.2.8932)
(see here (https://getmusicbee.com/forum/index.php?topic=3833.msg224569#msg224569) for a link to the first version that has this new functionality)

It (probably?) also requires MusicBee v3.6

These are the three virtual tags:

1.
Seconds
$Seconds(<Time>)

2.
Disc tracks
<Album><Album Artist><Disc#>

3.
Disc duration
$DurationFromSeconds($Sum(<Seconds>,<Disc tracks>))

#1 and #2 being necessary to make #3 work
#3 being the one that you will be using for displaying disc duration
 
Title: Re: Disc Duration
Post by: Zak on June 15, 2024, 10:34:12 AM
I'm not going to install the plugin to test it, but it looks like the $Sum function will accept an expression as the first argument, but not the second.

So it might be possible to do this:

Code
$DurationFromSeconds($Sum($Seconds(<Time>),<Disc tracks>))
Which will only require two virtual tags instead of three.
Title: Re: Disc Duration
Post by: hiccup on June 15, 2024, 11:44:16 AM
Code
$DurationFromSeconds($Sum($Seconds(<Time>),<Disc tracks>))
Which will only require two virtual tags instead of three.
Nope, doesn't work.
There is some limitation on nesting with regards to the $Sum function.