mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Does miniaudio support encoding PCM sample data into ADPCM sample data? #814

Closed sinkinben closed 9 months ago

sinkinben commented 9 months ago

I have noticed that there are two APIs:

MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut);
MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut);

Miniaudio can decode the ADPCM sample data.

But in this piece of code:

MA_PRIVATE ma_bool32 ma_dr_wav_preinit_write(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_bool32 isSequential, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks)
{
    if (pWav == NULL || onWrite == NULL) {
        return MA_FALSE;
    }
    if (!isSequential && onSeek == NULL) {
        return MA_FALSE;
    }
    if (pFormat->format == MA_DR_WAVE_FORMAT_EXTENSIBLE) {
        return MA_FALSE;
    }
    if (pFormat->format == MA_DR_WAVE_FORMAT_ADPCM || pFormat->format == MA_DR_WAVE_FORMAT_DVI_ADPCM) {
        return MA_FALSE;
    }
    // ... more code here
}

It seems that it rejects the ADPCM tag. I want to make a confirmation about this question.

Many thanks.

mackron commented 9 months ago

No, WAV encoding does not support any kind of compression. Only raw PCM is supported.