在 Mac C++ 中播放任何格式的 .wav 数据; 程序,类似于win32 PlaySound
我有 .wav 文件已存储在中央数据库中。 我需要用 Mac C++ 代码来播放它们。 .wav 文件有许多不同的格式 - 其中一些格式相当古老 - 例如 4 位。
我使用 AudioHardware 接口获得了适用于主要格式的代码。 但是,只有当音频单元接受 .wav 中的采样率时,这些才有效。
我需要类似于 win32 PlaySound 的东西,我只需给它包含 .wav 文件的缓冲区,它就会执行必要的转换。
我需要同步或异步播放。
我在阅读苹果开发者文档时迷失了方向——有很多不同的级别,而且概述真的很差! 我应该查看音频队列吗? 音频文件? 快时?
预先感谢您的任何指点!
I have .wav files that have been stored in a central database. I need to play them in Mac C++ code. The .wav files have lots of different formats - some of them are quite old - for example 4bit.
I got code using AudioHardware interfaces to work for the main formats. But, these work only if the sample rate in the .wav is accepted by the audio unit.
I need something similar to win32 PlaySound where I just give it the buffer containing the .wav file, and it performs the necessary conversions.
I need the playback to occur either synchronously, or asynchronously.
I get lost trying to read the apple developer docs - there are so many different levels, and the overviews are really poor! Should I be looking at Audio Queue? Audio File? QuickTime?
Thanks in advance for any pointers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在 10.5 中进行开发,那么 AudioQueues 就是您想要的 API。 它们并不像单个函数那么简单,但它们确实提供了相当全面的高级 API 来播放各种声音文件。
音频队列编程指南详细介绍了使用它进行播放的详细示例,并涵盖了您需要提供的功能和结构。
我无法保证此示例的质量,但它确实显示了一个用于播放背景音乐的简单 Obj-C 包装器,这应该足以让您越过文档墙。
祝你好运!
I you are developing in 10.5, then AudioQueues are the API you want. They aren't as easy as a single function, but they do provide a fairly comprehensive high level API for playing all kinds of sound files.
The Audio Queue Programming Guide goes through a detailed example of using it for playback, and covers the functions and structures you will need to provide.
I can't vouch for the quality of this sample, but it does show a simple Obj-C wrapper for playing background music that should be enough to get you past the documentation wall.
Good luck!