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

查看:23
本文介绍了我应该使用哪个 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天全站免登陆