Multiple Taps on AVAudioInputNode?

I'm searching for the best way to directly or indirectly create multiple taps on one AVAudioInputNode. I'm making an app with a conversational interface, and for architecture purposes it'd be useful to have one tap that deals with visualizing input audio and another that actually sends input audio to the speech recognizer. My attempts to do this are as follows, neither of which seem to work:


1) Install multiple taps on AVAudioInputNode:
It seems AVAudioInputNode only has one output bus, so you can't simply call installTap twice with different bus arguments.


2). Create two other AVAudioNodes, connect them downstream from the input nodes, and install taps on those.

It seems like you can't create actual instances of AVAudioNode or AVAudioIONode, since they're really just base classes for other nodes. I've tried using AVAudioUnitEQ for this purpose but that doesn't work either.


Any thoughts about my approach here? Not sure if I'm thinking about this the wrong way or if I'm just missing something obvious.

Replies

Have you had a look at the AVAEMixerSample code at https://developer.apple.com/library/archive/samplecode/AVAEMixerSample/Introduction/Intro.html?


Specifically, around line 252 of https://developer.apple.com/library/archive/samplecode/AVAEMixerSample/Listings/AVAEMixerSample_AudioEngine_m.html


    // fan out the sampler to mixer input 1 and distortion effect
    NSArray<AVAudioConnectionPoint *> *destinationNodes = [NSArray arrayWithObjects:[[AVAudioConnectionPoint alloc] initWithNode:_engine.mainMixerNode bus:1], [[AVAudioConnectionPoint alloc] initWithNode:_distortion bus:0], nil];
    
    [_engine connect:_sampler toConnectionPoints:destinationNodes fromBus:0 format:stereoFormat];


I would try that method to do one of the following:


  • Attach multiple mixers to the input node and attach the taps to those
  • Attach a single mixer to the input node, and then attach additional mixer nodes to the single mixer, and install the taps on them
  • Attach multiple AVAudioSinkNodes to the input node or an attached mixer (this is a new feature of iOS 13)