3

I've got several usb audio input devices connected and I want to select more than 1 of them to connect to the mixer. The way I understand it, it will not be able to use AVAudioInputNode for this purpose.

I could accomplish this by using AVFoundation to read samples from each device and then schedule them to a player but it seems to me that this might be easier done with AVAudioUnit. Unfortunately, I have not been able to make that work.

AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_HALOutput;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;

[AVAudioUnit
    instantiateWithComponentDescription:desc
                                options:kAudioComponentInstantiation_LoadInProcess
                      completionHandler:^(AVAudioUnit *xx, NSError *error) {

                        AudioUnitSetProperty(xx.audioUnit, kAudioOutputUnitProperty_CurrentDevice,
                                             kAudioUnitScope_Global, 0, &inputDeviceID, sizeof(inputDeviceID));

                        [_engine attachNode:xx];
                        AVAudioMixerNode *mixer = [_engine mainMixerNode];
                        [_engine connect:xx to:mixer format:[xx outputFormatForBus:0]];
                      }];

[central] 54: ERROR: >avae> AVAudioEngineGraph.mm:1235: AddNode: required condition is false: inImpl != nil && !IsIONode(inAVNode)

Any suggestions would be appreciated.

lagnat
  • 483
  • 3
  • 11

0 Answers0