HydrogenAudio

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: JacksonGrey on 2009-02-05 12:05:17

Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: JacksonGrey on 2009-02-05 12:05:17
Hey everyone, I'm new to the forum. I've been using Foobar for quite a while now, but only recently have I started customising it (using the default UI).

I have a number of sound recordings kept in 24bit/96000Hz quality, as well as recordings in the more mainstream 16bit/44100Hz format. In the playlist view, I have created a column which displays the %samplerate% and %bitrate%, but I'm unsure how I make one which states whether the bit depth is 16bit of 24bit. It is my understanding that there is no tag for this present in FLAC or ID3v2, so does anyone know of a workaround?

At the moment, I'm contemplating making a custom tag that I format to list 16, 24 etc... But obviously I'd prefer a solution which doesn't rely on even more tagging! 

Furthermore, the samplerate is currently formatted as:

Code: [Select]
%samplerate% Hz

But ideally, I'd like the sample rate to be shown in KHz. Does anyone know what I enter under 'pattern' to divide the sample rate by 1000, so that it would display, for instance, 44.1 instead of 44100?

Thank you for any help you can give!
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: smkk on 2009-02-05 12:39:21
Welcome to the forum. 
This should be what you're looking for, might need to delete some parts of the string which you don't need:
http://www.hydrogenaudio.org/forums/index....st&p=578248 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=64799&view=findpost&p=578248)
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: ojdo on 2009-02-05 13:51:03
And here the link the the Title Formatting Reference (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Title_Formatting_Reference): So $info(bitrate) and $info(bitspersample) will work.

Code: [Select]
$div(%samplerate%,1000).$right($div(%samplerate%,100),1) kHz
will show the sampling rate in kHz.
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: smkk on 2009-02-05 15:55:39
^ will display "96.0 kHz" for 96 kHz files.

Code: [Select]
$div(%samplerate%,1000)$replace($insert($right($div(%samplerate%,100),1),.,0),.0,) kHz

removes the .0

Buktore's solution is shorter and more elegant though:
Code: [Select]
$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,) kHz
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: JacksonGrey on 2009-02-05 21:20:15
That's great, thanks a lot for the kHz workaround!

I tried removing sections of the code from the bit depth thread, but it seems it will only display the depth for lossless formats. Does anyone know of a way for it to show the bit depth for lossy formats as well? If there isn't one, I think I'll make it so it shows 16 by default, seeing as that seems to be what the lossy formats tend to be kept in. I tried doing that below, but it doesn't seem to work for anything but mp3 and wma:

Code: [Select]
$if($stricmp($info(encoding),lossless),$info(bitspersample),$if($stricmp($info(codec),mp3),16))$if($stricmp($info(codec),wma),16))$if($stricmp($info(codec),aac),16))$if($stricmp($info(codec),mpc),16))$if($stricmp($info(codec),ogg),16)) bit


Ideally, I'd let to work out a way of it showing 16 IF it doesn't have a lossy bit depth value. This is so that I can keep WMA Lossless as well as regular WMA / V2, which would of course both be given 16 under the above code.
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: lvqcl on 2009-02-05 22:25:58
Does anyone know of a way for it to show the bit depth for lossy formats as well?

Lossy formats doesn't have bit depth because they doesn't store sample values.

Ideally, I'd let to work out a way of it showing 16 IF it doesn't have a lossy bit depth value.


Code: [Select]
$if2($info(bitspersample),16) bit

Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: JacksonGrey on 2009-02-05 23:25:41
Fantastic, thanks ever so much!

Just on a side note, I'm trying to create a new 'Playing' column with the arrow, but without the 'Playing' text. This is so I can make the column narrower without any text getting shortened to, say "Pla...". Does anyone know what the arrow's code is? I looked on the title formatting reference page, but I can only make it 0 or 1 for playing. I'm assuming the arrow feature must be based on this?

Thanks for any help you can give.
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: tedgo on 2009-02-06 00:44:21
As far as i know the playing arrow is an icon and not based on titleformatting (but i don't know well, i use columns ui).
There is a character you could use instead but it is very, very small...
$char(9658)
Since i don't believe that default ui allows different font sizes in the playlist i fear this wouldn't help you much...
Title: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: PeterMac on 2015-01-08 03:34:54
^ will display "96.0 kHz" for 96 kHz files.

Code: [Select]
$div(%samplerate%,1000)$replace($insert($right($div(%samplerate%,100),1),.,0),.0,) kHz

removes the .0

Buktore's solution is shorter and more elegant though:
Code: [Select]
$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,) kHz

Buktore's solution is bad, try to play DSD native files and it shows wrong kHz 282.24 kHz instead 2822.4kHz, first code is correct.
Title: Re: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: bennettisawesome on 2020-01-06 05:35:51
Hi, I know it has been a long time since the last posts/replies for this, but I was hoping someone who helped write these scripts/sorting scripts would possibly be able to adapt the
Code: [Select]
$div(%samplerate%,1000)$replace($insert($right($div(%samplerate%,100),1),.,0),.0,) kHz
to work the same as it does there, but also convert DSD64 (and higher DSD as well like 128, 256, 512, etc.) sample rates from 2822400 Hz to not 2822.4 kHz like it does currently, but instead 2.8 MHz (nothing would change with the script's original functionality of changing a sample rate of something like 96000 Hz to 96 kHz, just adding to/changing the functionality of how it converts DSD sample rates I guess?).

This is something which I have been trying to do for a bit and could not figure out, so hopefully someone from here can help me with it.

Thanks in advance



Edit: Explained better
Title: Re: Bit Depth Column? Also, 44100 -> 44.1 in Column View?
Post by: anamorphic on 2020-01-07 02:32:08
^ Just add some zeros to the division -

Code: [Select]
$ifgreater($len(%samplerate%),6,$div(%samplerate%,1000000)$replace($insert($right($div(%samplerate%,100000),1),.,0),.0,) MHz,$div(%samplerate%,1000)$replace($insert($right($div(%samplerate%,100),1),.,0),.0,) kHz)

It can probably be refined but seems to work...