- cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
+ cwt->sample_rate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
+ bps = a[34] + ((unsigned)a[35] << 8);
+ if (bps != 8 && bps != 16) {
+ PARA_WARNING_LOG("%u bps not supported, assuming 16\n", bps);
+ bps = 16;
+ }
+ /*
+ * 8-bit samples are stored as unsigned bytes, ranging from 0 to 255.
+ * 16-bit samples are stored as 2's-complement signed integers, ranging
+ * from -32768 to 32767.
+ */
+ if (bps == 8)
+ cwt->sample_format = SF_U8;
+ else
+ cwt->sample_format = (a[3] == 'F')? SF_S16_LE : SF_S16_BE;
+ PARA_NOTICE_LOG("%dHz, %s, %s\n", cwt->sample_rate,
+ cwt->channels == 1? "mono" : "stereo",
+ sample_formats[cwt->sample_format]);