Reputation: 51
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!
Upvotes: 2
Views: 2788
Reputation: 1985
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!
Upvotes: 2