Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting multichannel input to taps #24

Open
jasonlevine opened this issue Jun 18, 2015 · 2 comments
Open

Connecting multichannel input to taps #24

jasonlevine opened this issue Jun 18, 2015 · 2 comments

Comments

@jasonlevine
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Owner

admsyn commented Jun 18, 2015

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:

  • the missing source bus param may be a bug, but I think the input will only ever have one source bus. Note that a bus is not the same as a channel, so you can have (for example) 5.1 channel audio on one bus. I think the source bus param is just there to keep the API consistent with other units which may actually have multiple busses
  • related, do you actually need multiple taps, or is it fine to have one tap taking all the channels?
  • the ofxAudioUnitInput is a bit of a special case, since it dumps everything into a circular buffer and has stuff pulled from there (instead of directly hooking it up to downstream units)
  • you can use the AUSplitter to create a copy of the input, giving you two busses to work with. This'll get real awkward if you want a bunch of busses though

Let me know how it goes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants