0

Inside my iOS 8.0. App I need to apply some custom audio processing on (non-realtime) audio playback. Typically, the audio comes from a device-local audio file.

Currently, I use MTAudioProcessingTap on a AVMutableAudioMix. Inside the process callback I then call my processing code. In certain cases this processing code may produce more samples than the amount of samples being passed in and I wonder what's the best way to handle this (think time stretching effect for example)

The process callback takes an incoming CMItemCount *numberFramesOut argument that signals the amount of outgoing frames. For in-place processing where the amount of incoming frames and outgoing frames is identical this is no problem. In the case where my processing generates more samples I need a way to get the playback going until my output buffers are emptied.

Is MTAudioProcessingTap the right choice here anyway?

gabelkonus
  • 466
  • 1
  • 4
  • 13

2 Answers2

1

MTAudioProcessingTap does not support changing the number of samples between the input and the output (to skip silences for instance).

You will need a custom audio unit graph for this.

Daniel Broad
  • 2,512
  • 18
  • 14
0

A circular buffer/fifo is one of the most common methods to intermediate between different producer and consumer rates, as long as the long term rate is the same. If long term, you plan on producing more samples than are played, you may need to occasionally temporarily stop producing samples, while still playing, in order not to fill up all of the buffer or the systems memory.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • sure. But how to do this with MTAudioProcessingTap? How do I ensure that the process callback gets called until my fifo is emptied? – gabelkonus Oct 26 '15 at 09:07