mackron / dr_libs

Audio decoding libraries for C/C++, each in a single source file.
Other
1.26k stars 206 forks source link

Writing 24-bit WAV files #168

Closed colugomusic closed 3 years ago

colugomusic commented 3 years ago

Hello,

am I correct that it is not currently possible to write 24-bit WAV data using this library?

colugomusic commented 3 years ago

I think I'm wrong after digging through miniaudio, it appears the relevant data conversion utilities are in there instead, which makes sense. I assumed it would be a part of dr_libs. In this case I want the mapcm*_to_s24 functions.

I assume this will pack the 24-bit values tightly into a byte buffer (instead of doing what some other libraries do where 24-bit values are packed into the last 3 bytes of a 32-bit int). So I will need to allocate a buffer of (3 num_channels num_frames) bytes?

mackron commented 3 years ago

Yes, that's correct. When you initialize the drwav object make sure you use 24 for the bits per sample, and then write tightly packed 24-bit data with drwav_write_pcm_frames().

colugomusic commented 3 years ago

It works beautifully, thanks!