IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Display samplerate/bitspersample for FLAC only?, [Support is not for how-to questions]
th0m
post Jul 19 2008, 19:34
Post #1





Group: Members
Posts: 22
Joined: 19-July 08
Member No.: 56012



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.
Go to the top of the page
+Quote Post
buktore
post Jul 19 2008, 20:26
Post #2





Group: Members
Posts: 506
Joined: 24-November 06
Member No.: 38011



CODE
$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
$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.

This post has been edited by buktore: Jul 19 2008, 20:31
Go to the top of the page
+Quote Post
th0m
post Jul 19 2008, 20:52
Post #3





Group: Members
Posts: 22
Joined: 19-July 08
Member No.: 56012



Amazing! Worked perfectly.

Many, many thanks.
Go to the top of the page
+Quote Post
th0m
post Jul 19 2008, 21:54
Post #4





Group: Members
Posts: 22
Joined: 19-July 08
Member No.: 56012



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.
Go to the top of the page
+Quote Post
Nemphael
post Jul 19 2008, 22:35
Post #5





Group: Members
Posts: 245
Joined: 19-March 07
Member No.: 41623



That would be as easy as this:
CODE
$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)))


This post has been edited by Nemphael: Jul 19 2008, 22:38
Go to the top of the page
+Quote Post
th0m
post Jul 19 2008, 23:02
Post #6





Group: Members
Posts: 22
Joined: 19-July 08
Member No.: 56012



Works beautifully. Thanks.
Go to the top of the page
+Quote Post
buktore
post Jul 19 2008, 23:08
Post #7





Group: Members
Posts: 506
Joined: 24-November 06
Member No.: 38011



I made it a little bit simpler.

CODE
%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.

This post has been edited by buktore: Jul 19 2008, 23:11
Go to the top of the page
+Quote Post
Nemphael
post Jul 19 2008, 23:30
Post #8





Group: Members
Posts: 245
Joined: 19-March 07
Member No.: 41623



QUOTE (buktore @ Jul 20 2008, 00:08) *
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).
Go to the top of the page
+Quote Post
th0m
post Jul 20 2008, 00:24
Post #9





Group: Members
Posts: 22
Joined: 19-July 08
Member No.: 56012



MP3 is the only lossy codec I use, so that's why I wrote that way. Thanks for the more versatile code though.
Go to the top of the page
+Quote Post
foorious
post Aug 9 2008, 10:44
Post #10


troll / ban evasion


Group: Banned
Posts: 244
Joined: 22-April 08
Member No.: 52991



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
%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.
Go to the top of the page
+Quote Post
goddog
post Apr 1 2013, 17:13
Post #11





Group: Members
Posts: 2
Joined: 1-April 13
Member No.: 107477



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 smile.gif And oh, FB2K RULES!

This post has been edited by goddog: Apr 1 2013, 17:28
Go to the top of the page
+Quote Post
db1989
post Apr 1 2013, 17:43
Post #12





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



QUOTE (goddog @ Apr 1 2013, 17:13) *
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
$if($stricmp(%__encoding%,lossless),' ('$div($mul(%bitrate%,100),$mul(%__channels%,%__bitspersample%,$div(%samplerate%,1000)))'% of original)',)
After removing it:
CODE
%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”.

This post has been edited by db1989: Apr 1 2013, 19:52
Go to the top of the page
+Quote Post
alwayswrming
post May 17 2014, 14:57
Post #13





Group: Members
Posts: 20
Joined: 28-March 14
Member No.: 115199



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
$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
Go to the top of the page
+Quote Post
BenB
post May 17 2014, 20:08
Post #14





Group: Members
Posts: 767
Joined: 17-April 12
Member No.: 98921



Try this:

CODE
$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.

This post has been edited by BenB: May 17 2014, 20:10
Go to the top of the page
+Quote Post
alwayswrming
post May 19 2014, 02:54
Post #15





Group: Members
Posts: 20
Joined: 28-March 14
Member No.: 115199



QUOTE (BenB @ May 17 2014, 21:08) *
Try this:

CODE
$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 smile.gif
-----------------------------------------------------------------------
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!

This post has been edited by alwayswrming: May 19 2014, 03:04
Go to the top of the page
+Quote Post
marc2003
post May 19 2014, 06:09
Post #16





Group: Members
Posts: 4774
Joined: 27-January 05
From: England
Member No.: 19379



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)
Go to the top of the page
+Quote Post
alwayswrming
post Jun 5 2014, 00:37
Post #17





Group: Members
Posts: 20
Joined: 28-March 14
Member No.: 115199



QUOTE (marc2003 @ May 19 2014, 07:09) *
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
$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
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 27th November 2014 - 22:00