Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Display samplerate/bitspersample for FLAC only? (Read 8753 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Display samplerate/bitspersample for FLAC only?

I've been trying to configure a column that, when showing a FLAC file, will look something like this: FLAC 16/44.1 or FLAC 24/192. I can't seem to get it right though.

This is what I've come up with: $info(codec) $info(bitspersample)/$div($info(samplerate),1000)

However, first of all, I want it to exclude MP3 files, so that only MP3 is shown. Also, I want it to display the decimal in 44.1. $div($info(samplerate),1000) only shows 44.

Can it be done? I would really appreciate some help.

Display samplerate/bitspersample for FLAC only?

Reply #1
Code: [Select]
$if($stricmp(%codec%,flac),%codec% $info(bitspersample)/$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,),%codec%)


You might try this instead since it work with all lossless files.

Code: [Select]
$if($stricmp($info(encoding),lossless),%codec% $info(bitspersample)/$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,),%codec%)


My code seem to be overkill.. anyone have better solution, please go ahead.

Display samplerate/bitspersample for FLAC only?

Reply #2
Amazing! Worked perfectly.

Many, many thanks.

Display samplerate/bitspersample for FLAC only?

Reply #3
Ok, one more question. If I also want MP3 files to show as MP3 VBR or MP3 CBR ($info(codec) $info(codec_profile)), then how would the code look?

Sorry to bother like this, but the whole titleformatting business feels like brainsurgery when you want something a little more advanced.

Display samplerate/bitspersample for FLAC only?

Reply #4
That would be as easy as this:
Code: [Select]
$if($stricmp($info(encoding),lossless),
%codec% $info(bitspersample)/$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,),
$if($stricmp($info(codec),mp3),$info(codec) $info(codec_profile)))

Display samplerate/bitspersample for FLAC only?

Reply #5
Works beautifully. Thanks.

Display samplerate/bitspersample for FLAC only?

Reply #6
I made it a little bit simpler.

Code: [Select]
%codec%$if($stricmp(%__encoding%,lossless), %__bitspersample%/$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,),[ %__codec_profile%])


@Nemphael

Your code will not show anything if it isn't MP3 and not lossless, I don't think that's desirable.

Display samplerate/bitspersample for FLAC only?

Reply #7
I made it a little bit simpler.
Your code will not show anything if it isn't MP3 and not lossless, I don't think that's desirable.

I do know that, but in his post Th0m asked for MP3 (only), which he stated once (or thrice, if you look at it).

Display samplerate/bitspersample for FLAC only?

Reply #8
MP3 is the only lossy codec I use, so that's why I wrote that way. Thanks for the more versatile code though.

Display samplerate/bitspersample for FLAC only?

Reply #9
Just for the record, here's a more complete version, based on my own working version with some buktore optimizations. Try it on your prefs / Default UI / Status bar :

Code: [Select]
%codec%[ %codec_profile%] %bitrate% kbps$if($stricmp(%__encoding%,lossless),' ('$div($mul(%bitrate%,100),$mul(%__channels%,%__bitspersample%,$div(%samplerate%,1000)))'% of original)',)'   |   '[%__bitspersample% bits / ]$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,) kHz / $caps(%channels%)


e.g. "MP3 VBR V2 173 kbps  |  44.1 kHz / Stereo"
e.g. "FLAC 1020 kbps (72% of original)  |  16 bits / 44.1 kHz / Stereo"
e.g. "FLAC 2642 kbps (57% of original)  |  24 bits / 96 kHz / Stereo"
e.g. "FLAC 4501 kbps (65% of original)  |  24 bits / 48 kHz / 6 ch"

Oh, one more thing : I don't understand the difference between %codec_profile% and buktore's %__codec_profile%. I've tried both on my collection, and they all give exactly the same results. So I've ended using the shorter one.

Display samplerate/bitspersample for FLAC only?

Reply #10
Found your codes while searching for "bitspersample" and I really wanna say a big thank you for sorting me out. After some testing finally I choosed " buktore's " variant, works just great! Also used the same code for my album list view in media library, thus sorting out my media in Codec / Codec Profile / Bits per sample / Samplerate, which actually even was a bigger help for me! So thank u again guys!

Also wanna ask "foorious" what I need to change in his code so it leaves out the "xxxx kbps (xx% of original)" bit, since that bit is a little too much info for me.


If anyone wold like to try for album list viem here's what I use : %codec%$if($stricmp(%__encoding%,lossless), %__bitspersample%/$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,),[ %__codec_profile%]) %channels% | %<artist>%|%date% - %album%|[[%discnumber%.]%tracknumber%. ][%track artist% - ]%title%

Hopefully that helps someone else    And oh, FB2K RULES!

 

Display samplerate/bitspersample for FLAC only?

Reply #11
Also wanna ask "foorious"
I guess you didn’t notice the bit under foorious’s name that says “Banned”.

Quote
what I need to change in his code so it leaves out the "xxxx kbps (xx% of original)" bit, since that bit is a little too much info for me.
Using simple logic, we can identify which bit of code is doing that:
Code: [Select]
$if($stricmp(%__encoding%,lossless),' ('$div($mul(%bitrate%,100),$mul(%__channels%,%__bitspersample%,$div(%samplerate%,1000)))'% of original)',)
After removing it:
Code: [Select]
%codec%[ %codec_profile%] %bitrate% kbps'   |   '[%__bitspersample% bits / ]$replace($trim($insert($pad_right($div(%samplerate%,100),4),.,3)),.0,) kHz / $caps(%channels%)

If you are unsure about title-formatting in general, perhaps you have not yet seen this and would find it useful: http://wiki.hydrogenaudio.org/index.php?ti...tting_Reference

Edit: The above only removes the bracketed proportion. If you want to remove the bitrate altogether, needless to say, just take out “ %bitrate% kbps”.

Display samplerate/bitspersample for FLAC only?

Reply #12
Does anyone know how I can integrate this code into my current setup, such that it only displays "bitdepth/samplerate" when applied to FLAC 24/96 and 24/88?
Instead of looking at my library and seeing a lot of [FLAC], id like to see [FLAC] [FLAC 24/88] or [FLAC 24/96], since these are the three formats of FLAC that I have.

this snippet is from my current Album View code:

Code: [Select]
 $if($stricmp(FLAC,%codec%),' - [FLAC]',$if($stricmp(CBR,%codec_profile%),' - [C-'%bitrate%']',$if($stricmp(VBR V2,%codec_profile%),' - [V2]',$if($stricmp(VBR V0,%codec_profile%),' - [V0]',$if($stricmp(VBR V1,%codec_profile%),' - [V1]',$if($stricmp(AAC,%codec%),' - [AAC]',' - ['%codec_profile%']'))))))


the above code gives me results like:

xxxxxxxxxxxx - [C-320]
xxxxxxxxxxxx - [V0]
xxxxxxxxxxxx - [V2]
xxxxxxxxxxxx - [FLAC]

so, im just trying to keep this same setup, but also be able to differentiate between the 3 types of FLAC i mentioned above. So I would like to have FLAC albums like this:

xxxxxxxxxxxx - [FLAC 24/96]
xxxxxxxxxxxx - [FLAC 24/88]
xxxxxxxxxxxx - [FLAC]

(the plain [FLAC] implies 16/44 type, so i dont need to have it listed. in other words, if it just says [FLAC], I know that it is 16/44. This is actually the hard part. If i didnt want to do this, I could just use a basic $if($stricmp(%codec_profile%, lossless), .....  and then apply the bitdepth/samplerate code to all lossless types. but i dont want the bitdepth/samplerate code to be applied if the file is 16/44

Ive messed with the code in this thread for several hours. ive tried using $and function, all sorts of combinations of $if functions, but i cant figure out how to do it. any help would be greatly appreciated!
Thanks

Display samplerate/bitspersample for FLAC only?

Reply #13
Try this:

Code: [Select]
$if($and($stricmp(FLAC,%codec%),$greater(%__bitspersample%,16),$greater(%samplerate%,44100)),' - [FLAC '%__bitspersample%/$div(%samplerate%,1000)']',
$if($stricmp(FLAC,%codec%),' - [FLAC]',
$if($stricmp(CBR,%codec_profile%),' - [C-'%bitrate%']',
$if($stricmp(VBR V2,%codec_profile%),' - [V2]',
$if($stricmp(VBR V0,%codec_profile%),' - [V0]',
$if($stricmp(VBR V1,%codec_profile%),' - [V1]',
$if($stricmp(AAC,%codec%),' - [AAC]',
' - ['%codec_profile%']')))))))


It's easier to just insert what you want than incorporate another's code.

Display samplerate/bitspersample for FLAC only?

Reply #14
Try this:

Code: [Select]
$if($and($stricmp(FLAC,%codec%),$greater(%__bitspersample%,16),$greater(%samplerate%,44100)),' - [FLAC '%__bitspersample%/$div(%samplerate%,1000)']',
$if($stricmp(FLAC,%codec%),' - [FLAC]',
$if($stricmp(CBR,%codec_profile%),' - [C-'%bitrate%']',
$if($stricmp(VBR V2,%codec_profile%),' - [V2]',
$if($stricmp(VBR V0,%codec_profile%),' - [V0]',
$if($stricmp(VBR V1,%codec_profile%),' - [V1]',
$if($stricmp(AAC,%codec%),' - [AAC]',
' - ['%codec_profile%']')))))))


It's easier to just insert what you want than incorporate another's code.


ok, i will give this a shot right now! thank you for the reply, i do appreciate it. I agree it's easier to do what you want, but im still learning and, while the title formatting wiki page is very useful at times, it doesnt provide many examples of how to use things like the $and operator. I will study this code you gave me so i can try to make sense of how you utilized the various functions, the syntax, etc.
Thanks again. I will report back when I try it out
-----------------------------------------------------------------------
EDIT: First of all, this works amazing, so thank you for that. I also noticed how you used line breaks in your code and how everything is nice and organized, with most lines beginning with an $if function. I use np++ and have custom syntax highlighting that i tweaked myself, but having the code written/organized like this makes it a lot easier to read.. for some reason i always thought it had to be one long string all on a single line:)
The only question I have is about the two leading underscores that you use for the %__bitspersample% -- ive seen this before, earlier in this thread. however, ive never seen it outside of this thread. and when i look up the 'bitspersample' field on the wiki, it just has it listed as %bitspersample% without any underscores. I tried it without the underscores and does not work. so i wonder, is the wiki wrong, or is there some circumstances that require you to modify the "base" field with underscores?
Thanks again!

Display samplerate/bitspersample for FLAC only?

Reply #15
Quote
%bitspersample%


are you sure you saw this? you can use $info(bitspersample) as described here... http://wiki.hydrogenaudio.org/index.php?ti...4info.28name.29

you'll see there how it mentions how you can use double underscores (%__bitspersample%) instead of the $info function.

you might be confused with %bitrate% and %__bitrate% which both work. %bitrate% will display a dynamic bitrate in VBR files whereas %__bitrate% will always display a fixed bitrate (average for the whole file)

Display samplerate/bitspersample for FLAC only?

Reply #16
Quote
%bitspersample%


are you sure you saw this? you can use $info(bitspersample) as described here... http://wiki.hydrogenaudio.org/index.php?ti...4info.28name.29

you'll see there how it mentions how you can use double underscores (%__bitspersample%) instead of the $info function.

you might be confused with %bitrate% and %__bitrate% which both work. %bitrate% will display a dynamic bitrate in VBR files whereas %__bitrate% will always display a fixed bitrate (average for the whole file)



yeah im sure i saw that. the code reads:

Code: [Select]
$greater(%__bitspersample%,16)


but i see what youre saying now.. I was confused about the purpose/meaning of the double underscore.. i think it makes sense now. I appreciate the help