There are many ways of playing sounds on Windows. Which are the differences, advantages and disavantages of each method?
I know there are at least 5 methods:
- 1991 WinMM.dll/mmsys.dll PlaySound
- 1995 MCIWnd (as suggested by @casablanca)
- 1996 DirectSound
- 1998 WaveOut
- 1999 ASIO
- 1999 Windows Media Player ActiveX control?
- 2005 WASAPI (which is used by XAudio2 – as suggested by @Han)
- 2007 XAudio2
Really depends on what you want to do. For most common scenarios, I’ve found that the MCIWnd functions work well: they’re really easy to use and can play any format for which a codec is installed.
DirectSound is somewhat more difficult to use but gives you much more control over the output; it lets you add special effects and simulate 3D positioning.
The
waveOutfunctions are the lowest level API you can get to and they are a kind of double-edged sword: you get to control exactly what goes out to the speakers, but they accept only raw waveform data, which means you are responsible for all decoding and post-processing of input data.PlaySoundessentially provides a nice wrapper around this.