views:

343

answers:

2

I want to playback an mp3 rather than an uncompressed file using RemoteIO / AudioUnit. Using uncompressed files obviously uses far too much disk space (30MB vs 3MB for mp3).

Is this even possible? If so, can you provide a little code headstart?

Thanks a million.

A: 

Same question here. Any help?

Brian Rice
I am using Audio Queues instead and it's working ok for what I need, but I'd still like to know if it's possible to get compressed playback using the lowest level api possible.
CJ Hanson
A: 

How low-level do you want to go? You could use the AudioHardware API:

err = AudioDeviceAddIOProc(deviceID, ioProc, self);

and in your ioProc fill the buffers yourself, listen for hardware changes, and deal with real-time threading and a lot of other low-level stuff.

I'm assuming you're already decoding the mp3 data with AudioConverter and know how to do that.

lucius
I will look into AudioConverter, it may be what I'm after. My question isn't about using AudioUnits in itself, as I can already do the low level stuff fine with wav, but I would like to use MP3. Thank you :)
CJ Hanson
For converting MP3s, I suggest using the Extended Audio File Services. Use `ExtAudioFileOpenURL` to open the file, and then you can use `ExtAudioFileGetProperty` to get the file length and data format and other info. Then use `ExtAudioFileSetProperty` to set the output format to PCM data, so when you call `ExtAudioFileRead` in your loop, it returns uncompressed data.
lucius