admsyn / ofxAudioUnit

An openFrameworks addon which makes it easy to work with Audio Units on OSX and iOS
MIT License
120 stars 24 forks source link

Connecting multichannel input to taps #24

Open jasonlevine opened 9 years ago

jasonlevine commented 9 years ago

Hi Adam,

I'm trying to connect the inputs from an instance of ofxAudioUnitInput set to a multichannel device to multiple taps. The goal is to have the samples from each live input in realtime.

When i try this: input.connectTo(*taps[i], 0, i); I get an error: No matching member function for call to 'connectTo'

However this is the only member function: ofxAudioUnit& connectTo(ofxAudioUnit &otherUnit, int destinationBus = 0, int sourceBus = 0); using ofxAudioUnit::connectTo; // for connectTo(ofxAudioUnitTap&)

So how would I go about connecting my ofxAudioUnitInput to multiple ofxAudioUnitTaps?

jasonlevine commented 9 years ago

trying to hack a ofxAudioUnitDSPNode& ofxAudioUnitInput::connectTo(ofxAudioUnitDSPNode &destination, int destinationBus, int sourceBus) function together, when I noticed that the current connectTo function for ofxAudioUnitInput doesn't appear to make use of the sourceBus parameter:

// ----------------------------------------------------------
ofxAudioUnit& ofxAudioUnitInput::connectTo(ofxAudioUnit &otherUnit, int destinationBus, int sourceBus)
// ----------------------------------------------------------
{
    AudioStreamBasicDescription ASBD;
    UInt32 ASBDSize = sizeof(ASBD);

    OFXAU_PRINT(AudioUnitGetProperty(otherUnit,
                                     kAudioUnitProperty_StreamFormat,
                                     kAudioUnitScope_Input,
                                     destinationBus,
                                     &ASBD,
                                     &ASBDSize),
                "getting hardware input destination's format");

    OFXAU_PRINT(AudioUnitSetProperty(*_unit,
                                     kAudioUnitProperty_StreamFormat,
                                     kAudioUnitScope_Output,
                                     1,
                                     &ASBD,
                                     sizeof(ASBD)),
                "setting hardware input's output format");

    AURenderCallbackStruct callback = {PullCallback, &_impl->ctx};
    otherUnit.setRenderCallback(callback, destinationBus);
    return otherUnit;
}

is ofxAudioInput set up for devices with multiple inputs?

admsyn commented 9 years ago

Hey Jason, it's been long enough since I wrote this that I don't really know the answers off hand. Here's some thoughts though:

Let me know how it goes