Help - Search - Members - Calendar
Full Version: Sampling rate in kilohertz (kHz)?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Support - (fb2k)
pianoman
Having the sampling rate in kHz is a MUST for me, as it just saves me the trouble of from reading long numbers (like 44100).
I've scripted a very ugly hack for this, but I'm not very happy with it:

$insert($div(%samplerate%,100),'.',$sub($len(%samplerate%),3)) kHz

Left to say ... it works! tongue.gif

But I'd rather have a $frac() function to get the fractional part right of the point.
(You did note that $div() does an INTEGER division, didn't you? wink.gif)
pianoman
bumped...

anyone else with a better solution?
Yotsuya
This is what I use, though to be honest it isnt really all that different than what you are doing:
CODE
$if2($div(%samplerate%,1000)$ifequal($div($mod(%samplerate%,1000),100),0,,.$div($mod(%samplerate%,1000),100))KHz,)

I think it handles the right side of the decimal a bit better than just replicating the last 3 digits.
nawhead
QUOTE(Yotsuya @ Aug 8 2007, 23:56) *

This is what I use, though to be honest it isnt really all that different than what you are doing:
CODE
$if2($div(%samplerate%,1000)$ifequal($div($mod(%samplerate%,1000),100),0,,.$div($mod(%samplerate%,1000),100))KHz,)

I think it handles the right side of the decimal a bit better than just replicating the last 3 digits.


I'm rusty on my programming logic, but what does the $if2 operation do?

This seems to work fine:
CODE
$div(%samplerate%,1000)
$ifequal($div($mod(%samplerate%,1000),100),0,,'.'$div($mod(%samplerate%,1000),100))
' kHz '
pianoman
Thanks, using this now! smile.gif

QUOTE(nawhead @ Sep 3 2007, 17:44) *

I'm rusty on my programming logic, but what does the $if2 operation do?


Read The F..ine Manual. laugh.gif

$if2() is a shorthand for $if (X, X, Y), i. e. if X is present, execute X; if X is not present, execute Y.
Normally, $if() takes 3 different parameters.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.