IPB

Welcome Guest ( Log In | Register )

> foobar2000 Tech Support Forum Rules

Please read foobar2000 Tech Support Forum Rules before posting and comply with all the points.
Failure to provide all the information pointed out in the above document in your post is considered wasting other people's time and in extreme cases will lead to your topic getting locked without a reply.


See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Display samplerate/bitspersample for FLAC only?
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: 244
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: 244
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: 5141
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

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: 17th April 2014 - 14:42