声音处理:我应该使用 DirectSound 还是直接使用 Win32 API?

发布于 2024-07-13 15:30:23 字数 407 浏览 11 评论 0原文

我正在制作一个应用程序,我将:

  • 从麦克风录制并对输入进行一些实时处理
  • 播放 MP3 文件(一首常规歌曲),但实时操作输出
  • 我时不时地需要播放其他声音也在这首歌上,但我想我可以通过简单地添加缓冲区来做到这一点。

简而言之,我需要有用于录制和播放的循环缓冲区,并且我需要每 20 毫秒左右向输出缓冲区“馈送”即将播放的新数据。

我一直在研究 DirectSound,它似乎没有多大帮助。 输出缓冲区的读取和写入看起来与 Win32 非常相似,唯一有帮助的地方是在主歌曲上播放“附加声音”。

我应该使用 DirectSound,还是应该直接使用原始 Windows API?
DirectSound 能为我做些什么吗?

提前致谢!

I'm making an application where I will:

  • Record from the microphone and do some realtime processing on the input
  • Play an MP3 file (a regular song), but manipulating the output in realtime
  • Every now and then I'll need to play additional sounds over this song too, but I guess I can do that by simply adding the buffers.

In short, I need to have circular buffers for both recording and playing, and I need to be "feeding" the output buffer every 20 ms or so with the new data that is just about to be played.

I've been looking at DirectSound, and it doesn't seem to help a lot. The reading and writing to the output buffers seem very similar to Win32, the only place where it seems it'd help is in playing the "additional sounds" over the main song.

Should I use DirectSound, or should I go straight to raw Windows APIs?
Is DirectSound going to do anything for me?

Thanks in Advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一枫情书 2024-07-20 15:30:23

Directsound API 为您提供更好的实时控制。 它们也是 Windows 中支持的使用声音的方式。 我的印象是 win32 api 已被废弃,但我对此可能是错的。

这个问题与您的问题很接近

https://stackoverflow.com/ questions/314522/what-is-the-best-c-sound-api-for-windows

DirectSound 是 Windows 上最好的音频抽象层吗?

最后但并非最不重要的一点是,这是微软所说的 http://msdn.microsoft.com/en-us/library/dd370784(VS.85).aspx< /a>

The Directsound API's give you better realtime control. They are also the supported way to use sound in Windows. I was under the impression that the win32 api's were depracated, but I could be wrong on this.

This question is close to yours

https://stackoverflow.com/questions/314522/what-is-the-best-c-sound-api-for-windows

also

Is DirectSound the best audio abstraction layer for Windows?

last but not least, this is what microsoft has to say http://msdn.microsoft.com/en-us/library/dd370784(VS.85).aspx

谈情不如逗狗 2024-07-20 15:30:23

两者都不? :)

故事是 DirectSound 是 waveOut 的替代品,但 DirectSound 在 Vista 中作为已弃用的 API 加入了 DirectInput 并被替换为 WASAPI。 DirectSound 和waveOut 是在Vista 中的用户空间WASAPI 之上实现的。 在 XP 上,waveOut 和 DirectSound 提供相同的内核级 Mixer API。

为了整合所有这些接口,请查看 OpenAL 之类的接口,它是一个与 OpenGL 一样得到良好支持的音频标准。

Neither? :)

The story is that DirectSound is the replacement for waveOut, but DirectSound joined DirectInput as deprecated APIs in Vista and is replaced with WASAPI. DirectSound and waveOut are implemented on top of the User-Space WASAPI in Vista. On XP, waveOut and DirectSound feed to the same kernel level Mixer API.

To consolidate all of these interfaces take a look at something like OpenAL, it's a well supported audio standard along the same lines as OpenGL.

心奴独伤 2024-07-20 15:30:23

听起来您对延迟非常敏感。 看看 ASIO 可能会有所帮助

It sounds like you're going to be quite sensitive to latency. It might pay to look at ASIO

国际总奸 2024-07-20 15:30:23

我找到了 Harmony Central - 音频编程。 另请阅读 w:DirectSound

Windows Vista 具有完全
基于重写的音频堆栈
通用音频架构。 因为
的架构变化
重新设计的音频堆栈,直接路径
从 DirectSound 到音频驱动程序
不存在。

因为 Xbox 360 和 Microsoft
Windows 集成,微软
积极推动开发者迁移
同等 Xbox 的新应用程序
音频 API,例如 XAudio 和 XACT。

OpenAL 看起来很有前途。

I found Harmony Central - Audio Programming. Also read w:DirectSound.

Windows Vista features a completely
re-written audio stack based on the
Universal Audio Architecture. Because
of the architectural changes in the
redesigned audio stack, a direct path
from DirectSound to the audio drivers
does not exist.

Because of Xbox 360 and Microsoft
Windows integration, Microsoft is
actively pushing developers to migrate
new applications to equivalent Xbox
audio APIs such as XAudio and XACT.

OpenAL looks promising.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文