PDA

View Full Version : AudioQueue - changing sample rate?




neil.b
Dec 11, 2008, 02:13 PM
I've been playing around with the AudioQueue stuff for a few days and it's all working fine.
I was trying to build a low-latency playback system by making the streaming buffers the same size as the audio file and pre-loading the buffers (which works fine) but I've hit a snag.

I've been trying to get the streaming to work at different sample rates so that I can play back the same sample at different pitches. I managed to do it by modifying the sample rate in the AudioStreamBasicDescription structure but in order to actually make the stream playback at the new rate it seems you have to create a new output, reload the audio file into the buffers and re-enqueue the output queue before starting playback again, otherwise the sample rate change has no effect.

There is a method to set queue properties; AudoQueueSetProperty() but unfortunately the sample rate Property (kAudioQueueDeviceProperty_SampleRate) is read-only :(

Can anyone suggest a way to achieve this with AudioQueue or do I need to move over to OpenAL?

Thanks,

Neil



firewood
Dec 12, 2008, 09:00 AM
Try looking up multirate signal processing in a DSP textbook.

.

neil.b
Dec 12, 2008, 12:50 PM
Bit over the top for the iPhone, no?

:)

firewood
Dec 12, 2008, 07:23 PM
Over the top? Not at all. The ARM CPU in the iPhone can easily create and mix many channels of multi-rate synthesized and DSP filtered audio. Why do you think they added all those MAC and VFP instructions?

.

neil.b
Dec 13, 2008, 03:44 AM
OK, what I should've said is "A bit over the top to have to learn about and write DSP code, considering I just want to play an audio file at different pitches".

:)