c++audiowasapi

Microsoft WASAPI - Do different audio formats need different data in the buffer, for the same wave


Lets say I want to play a sine wave using WASAPI.

Will the data I enter into the AudioClient buffer always just be samples between -1 and 1, or will it be different between PCM and IEEE_Float Formats, and other formats for that matter.

Thanks.

Right now i'm just using 1 to -1, but i want to know whether or not i need to write my buffer input code different for each format.


Solution

  • MEDIASUBTYPE_IEEE_FLOAT / WAVE_FORMAT_IEEE_FLOAT audio types operate with floating point values in [-1, +1] range.

    MEDIASUBTYPE_PCM / WAVE_FORMAT_PCM has integer values,

    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.

    You will also find good references here: How to handle asymmetry of WAV data?.