Which API should I use for playing audio on Windows?

audio-player, c++, windows

Solution

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 `waveOut` functions 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. `PlaySound` essentially provides a nice wrapper around this.

Problem

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

Original source