AudioQueue - changing sample rate?

Discussion in 'iOS Programming' started by neil.b, Dec 11, 2008.

  1. macrumors member

    neil.b

    Joined:
    Nov 20, 2008
    #1
    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
     
  2. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    Try looking up multirate signal processing in a DSP textbook.

    .
     
  3. thread starter macrumors member

    neil.b

    Joined:
    Nov 20, 2008
  4. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #4
    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?

    .
     
  5. thread starter macrumors member

    neil.b

    Joined:
    Nov 20, 2008
    #5
    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".

    :)
     

Share This Page