Is there a $log()? |
This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.
See also: Hydrogenaudio Terms of Service.
![]() ![]() |
Is there a $log()? |
Feb 24 2013, 20:51
Post
#1
|
|
|
Group: Members Posts: 2 Joined: 24-February 13 Member No.: 106858 |
I checked the "Foobar2000:Title Formatting Reference" for the logarithm function, but it is not supported. Does anyone know of a simple workaround? I want to use it for a "View" in the "Album List" to view by duration. For example, it could group files by durations of [n to 2*n) seconds -- 0 to 1 minute, 1 to 2 minutes, 2 to 4 minutes, 4 to 8 minutes, and so on. (I realize that one could implement division with several $if statements, but that is complicated and does not scale).
Thanks! |
|
|
|
Feb 24 2013, 22:45
Post
#2
|
|
![]() Group: FB2K Moderator (Donating) Posts: 4219 Joined: 24-February 03 Member No.: 5153 |
No, there are no exponential or logarithm functions. Note that all title formatting functions operate on integers only.
However, you can compute $floor($log10(x)) for a natural number x, even though neither a $floor nor a $log10 function actually exists. For this you have to compute the number of digits of the number which can be done with the $len function. Here is an example that applies this to the track length in minutes: CODE $puts(L,$len($div(%length_seconds%,60))) 1$repeat(0,$sub($get(L),1)) to $add(1$repeat(9,$sub($get(L),1)),1) minutes This displays things like "10 to 20 minutes" or "1 to 2 minutes". Note that it will display the latter even for tracks shorter than 1 minute. For maximum flexibility you have to resort to an $if cascade. Like you said this does not scale, but on the other hand you can choose the intervals freely. For example: CODE $ifgreater(%length_seconds%,599,
10 minutes or longer, $ifgreater(%length_seconds%,179, 3 to 10 minutes, $ifgreater(%length_seconds%,59, 1 to 3 minutes, 0 to 1 minute ))) This post has been edited by foosion: Feb 24 2013, 22:47 -------------------- http://foosion.foobar2000.org/ - my components for foobar2000
|
|
|
|
Feb 25 2013, 02:04
Post
#3
|
|
|
Group: Members Posts: 2 Joined: 24-February 13 Member No.: 106858 |
Thanks for the reply, foosion. I ended up going with your latter suggestion. In case anyone else would benefit,
CODE $ifgreater(%length%,3,$ifgreater(%length%,5,$ifgreater(%length%,10,$ifgreater(%length%,15,$ifgreater(%length%,30,$ifgreater(%length%,60,60:00 +,30:00 - 60:00),15:00 - 30:00),10:00 - 15:00),5:00 - 10:00),3:00 - 5:00),0:00 - 3:00)|$filename(%path%)
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 20th May 2013 - 03:06 |