How to get codec/audio info from a file?

Started by rgomez,

rgomez

Hello,

I need to get the following info from the audio files my app handles:
  - codec
  - sample rate
  - bit rate
  - bit depth
  - number of audio channels

Is there a way to get this info from BASS?

I know I can get the number of channels and sample rate with BASS_ChannelGetInfo. I am not sure if the bit depth (depending on the flags set?, 8, 16 or 32, but I don't know if those refer to the channel setup, rather than the audio file itself). The codec I can try with the filename extension, although I know that in a lot of cases it's only the container format, not the codec.The bit rate I can also calculate from the duration and the file size. I know that a lot of codecs have VBR, but something like that would be enough for my users.

So, even if I have some ways to get the info "manually" I wonder if there is some function that could provide this info already?

Thanks!

MB_SOFT

for the codec i use the ctype member of BASS_CHANNELINFO and the original bitrate i get it from BASS_ChannelGetAttribute(handle, BASS_ATTRIB_BITRATE,bitrate)

sample rate and audio channels you get it from BASS_CHANNELINFO

the codec bit depth i think is the only missing info

Ian @ un4seen

The file's bit depth is in the BASS_CHANNELINFO "origres" member. Note that'll usually be 0 for lossy formats (eg. MP3/OGG/AAC), as they don't have a defined bit depth.