我应该使用哪个API在Windows上播放音频? [英] Which API should I use for playing audio on Windows?
问题描述
有许多方法可以在Windows上播放声音.每种方法的区别,优点和缺点是什么?
There are many ways of playing sounds on Windows. Which are the differences, advantages and disavantages of each method?
我知道至少有5种方法:
I know there are at least 5 methods:
- 1991 WinMM.dll/mmsys.dll PlaySound
- 1995年MCIWnd(由@casablanca建议)
- 1996 DirectSound
- 1998 WaveOut
- 1999年ASIO
- 1999 Windows Media Player ActiveX控件?
- 2005 WASAPI (其中由XAudio2使用-如@Han所建议)
- 2007 XAudio2
- 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
推荐答案
确实取决于您要执行的操作.对于大多数常见情况,我发现 MCIWnd 功能运作良好:它们确实非常易于使用,并且可以播放已安装编解码器的任何格式.
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有点难以使用,但可以让您更好地控制输出.它使您可以添加特殊效果并模拟3D定位.
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.
waveOut
函数是您可以获得的最低级别的API,它们是一把双刃剑:您可以精确控制扬声器的输出,但它们仅接受原始波形数据,这意味着您负责输入数据的所有解码和后处理. PlaySound
基本上提供了一个不错的包装器这个.
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.
这篇关于我应该使用哪个API在Windows上播放音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!