2

I'm trying to change the output format of a AVAudioMixerNode so that it outputs mono audio at a lower samplerate instead of the default format. Do I have to subclass the AVAudioMixerNode class and override the outputFormatForBus function to do that, or is there some other way?

Nilesh
  • 701
  • 5
  • 14
rodskagg
  • 3,827
  • 4
  • 27
  • 46

1 Answers1

2

Check out the docs for AVAudioEngine for this method:

- (void)connect:(AVAudioNode *)node1 
             to:(AVAudioNode *)node2
         format:(AVAudioFormat *)format

Note the format parameter:

If not NULL, the format of the source audio node’s output bus is set to this AVAudioFormat object. In all cases, the format of the destination audio node’s input bus is set to match that of the source audio node’s output bus.

Specify the mono, lower-sample-rate AVAudioFormat whenever the AVAudioMixerNode output bus gets connected.

Mark
  • 333
  • 2
  • 12
  • 1
    do you have any idea about my question? https://stackoverflow.com/q/53959379/1517943 – Daedelus Dec 29 '18 at 06:27
  • AVAudioMixerNode downsampling works, as described in this answer, from 48k to 24k and 16k. However downsampling from 48k to 8k causes "kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=512, mMaxFramesPerSlice=320". Environment: macOS 11.7, Xcode 13.2.1, Target macOS10.15 – helioz Feb 03 '23 at 00:05