2

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!

4

1 回答 1

2

我你在 10.5 中开发,那么 AudioQueues 就是你想要的 API。它们不像单个函数那么简单,但它们确实为播放各种声音文件提供了相当全面的高级 API。

音频队列编程指南详细介绍了使用它进行播放的示例,并涵盖了您需要提供的功能和结构。

我不能保证这个示例的质量,但它确实显示了一个简单的 Obj-C 包装器,用于播放背景音乐,应该足以让您通过文档墙。

祝你好运!

于 2009-08-10T22:12:38.437 回答