Author Topic: Read File Bits Per Sample  (Read 200 times)

Hanuman

  • Posts: 89
Read File Bits Per Sample
« on: 23 Sep '22 - 16:50 »
I'm encoding audio files and then re-opening it to check the bits per sample (8, 16, 24 or 32).

I call ChannelGetInfo, look at Resolution property, which returns Byte, Short or Float. (doesn't allow me to know if it's 24-bit?)

I'm finding that using BASS_ENCODE_FP_8BIT or BASS_ENCODE_FP_16BIT flags create a stream that returns Byte and Short respectively.

For 24-bit and 32-bit, however, the new stream returns only Short!

How can I detect when the source bits per sample is 24bit or 32bit?

Ian @ un4seen

  • Administrator
  • Posts: 24738
Re: Read File Bits Per Sample
« Reply #1 on: 23 Sep '22 - 18:02 »
You can get the file's resolution from BASS_ChannelGetInfo (see the "origres" value). Note that to benefit from the extra quality of 24/32-bit files, you will need to set the BASS_SAMPLE_FLOAT flag on the stream. The stream will otherwise be limited to 16-bit.

Hanuman

  • Posts: 89
Re: Read File Bits Per Sample
« Reply #2 on: 23 Sep '22 - 18:13 »
Ah right, although I use the Float flag when encoding, I wasn't setting that flag when trying to read it back!

It works now, but for 32-bit float WAV, "origres" returns 65568 instead of 32.