Register
Handmade Hero»Forums»Code»WaveOut Sound API
11 posts
WaveOut Sound API
1 day, 4 hours ago Edited by Bits Please on May 23, 2020, 5:41 p.m. Reason: Initial post
Greetings, everyone.

I'm want to write the equivalent code for constructing and playing a sine wave that Casey wrote on episode 9 but using the WaveOut API, and since I'm dealing with a very old API, there's not much information about it. So I was wondering if any of you guys have dealt with this API before and could shed some light as to how exactly it works, its pros and cons over other sound API's and how do I succeed in my mission.

Thanks!
Mārtiņš Možeiko
2072 posts / 1 project
WaveOut Sound API
1 day, 1 hour ago Edited by Mārtiņš Možeiko on May 23, 2020, 8:33 p.m.
MSDN has reasonable documentation about how to use waveOut API: https://docs.microsoft.com/en-us/...s/win32/multimedia/waveform-audio
The older is the API, the better it is documented in MSDN.

There is not really much to do with waveOut functions - first you open device with waveOutOpen, then prepare data blocks to submit with waveOutPrepareHeader, and write them with waveOutWrite, then use waveOutUnprepareHeader to "free" the blocks. That's it. There are different mechanisms to be notified when when block finished playing - callback, event, thread/window messages, polling - all covered in MSDN docs.

Advantages of using waveOut? You can run on Windows 95/98 or XP without installing any redists.
Disadvantages - very large latency compared to other audio API's. If you are playing music or video file - no problem, but for fast games, this can be problematic.