Handmade Hero»Forums»Code
2 posts
WaveFormat Quick Question
Edited by chelges1 on Reason: Initial post
Just a quick question about WaveFormat and its relation to win32_sound_output. I'm confused why WaveFormat.wBitsPerSample is set to 16 when in SoundOutput BitsPerSample is set to 32 (or sizeof(int16)*2). Microsoft Docs indicated the wBitsPerSample has to be either 8 or 16 when using WAVE_FORMAT_PCM, but I was wondering if there might be another reason that relates to the usage of bits within the SoundOutput?
Mārtiņš Možeiko
2198 posts / 1 project
WaveFormat Quick Question
Edited by Mārtiņš Možeiko on
If by SoundOutput you mean win32_sound_output structure, then it does not have BitsPerSample. It has BytesPerSample. sizeof(int16)*2 = 2*2 = 4. 4 bytes per sample - 2 for left channel, 2 for right channel. That's just how Casey decided to measure needed bytes for sound. In that place by "sample" he means "all the pieces of memory needed for all the channels".