我应该使用哪个API在Windows上播放音频? [英] Which API should I use for playing audio on Windows?

查看:360
本文介绍了我应该使用哪个API在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:

  1. 1991 WinMM.dll/mmsys.dll PlaySound
  2. 1995年MCIWnd(由@casablanca建议)
  3. 1996 DirectSound
  4. 1998 WaveOut
  5. 1999年ASIO
  6. 1999 Windows Media Player ActiveX控件?
  7. 2005 WASAPI (其中由XAudio2使用-如@Han所建议)
  8. 2007 XAudio2
  1. 1991 WinMM.dll/mmsys.dll PlaySound
  2. 1995 MCIWnd (as suggested by @casablanca)
  3. 1996 DirectSound
  4. 1998 WaveOut
  5. 1999 ASIO
  6. 1999 Windows Media Player ActiveX control?
  7. 2005 WASAPI (which is used by XAudio2 - as suggested by @Han)
  8. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆