Author Topic: Get bitrate from a file  (Read 215 times)

Dennis

  • Posts: 16
Get bitrate from a file
« on: 13 Aug '17 - 13:32 »
Hi everyone,

i'm trying to get the bitrate value of a flac/mp3 file using bass.net, but i can't get it to work.

' When a channel is playing:
Dim Bitrate As Integer = Bass.BASS_ChannelGetAttribute(BASS_Channel, BASSAttribute.BASS_ATTRIB_BITRATE, 0)

' When i check a stream:
Dim stream As Integer = Bass.BASS_StreamCreateFile(path, 0, 0, BASSFlag.BASS_DEFAULT)
Dim Bitrate As Integer = Bass.BASS_ChannelGetAttribute(stream, BASSAttribute.BASS_ATTRIB_BITRATE, 0)

Both give me a result of -1 :(

I get that the first one isn't working, because in the documentation it states it can only be used by HSTREAM.

Can anyone point me in the right direction?

Kind regards,
Dennis

Chris

  • Posts: 1810
Re: Get bitrate from a file
« Reply #1 on: 13 Aug '17 - 15:53 »
I`m not a Net Developer but that should be

Code: [Select]
Dim FBitrate As Single = 0F
If Bass.BASS_ChannelGetAttribute(stream, BASSAttribute.BASS_ATTRIB_BITRATE, FBitrate) Then ........
Quote
Dim Bitrate As Integer = Bass.BASS_ChannelGetAttribute(stream, BASSAttribute.BASS_ATTRIB_BITRATE, 0)
the Return of BASS_ChannelGetAttribute is a bool not a int

Dennis

  • Posts: 16
Re: Get bitrate from a file
« Reply #2 on: 13 Aug '17 - 18:29 »
Hi Chris,

That helps and explains the -1 (false) :)

I think i have to code something myself to extract the bitrate from an audio file,
because i don't know any other command in Bass that deals with the bitrate.

Thank You for the reply!

Kind regards,
Dennis

saga

  • Posts: 2183
Re: Get bitrate from a file
« Reply #3 on: 13 Aug '17 - 23:41 »
Quote
I think i have to code something myself to extract the bitrate from an audio file,
because i don't know any other command in Bass that deals with the bitrate.
Check the first code snippet from Chris' post again - the last parameter is a reference to a Single, and if you don't pass 0 there but a variable instead, you actually get the value you want in that variable.

Dennis

  • Posts: 16
Re: Get bitrate from a file
« Reply #4 on: 14 Aug '17 - 20:21 »
Thanks Saga and Chris, i've got it working now.
It was very late and i was coding over 10 hours :)

Thanks for the help!

Kind regards,
Dennis