1

I'm writing an app that should mix several sounds from disk and save resulting file to disk. I'm trying to use Audio Units. I used Apple's MixerHost as a base for my app. It has Multichannel mixer connected to Remote I/O. When I'm trying to add render callback to remote IO I've got error -10861 "The attempted connection between two nodes cannot be made." when call AUGraphConnectNodeInput(...). What I'm doing wrong? What's the right way to mix and record file to disk?

callback stub:

static OSStatus saveToDiskRenderCallback(void *inRefCon,
                                     AudioUnitRenderActionFlags *ioActionFlags,
                                     const AudioTimeStamp *inTimeStamp,
                                     UInt32 inBusNumber,
                                     UInt32 inNumberFrames,
                                     AudioBufferList *ioData) 
{
    return noErr;
}

adding callback to Remote I/O Unit:

    AURenderCallbackStruct saveToDiskCallbackStruct;
saveToDiskCallbackStruct.inputProc = &saveToDiskRenderCallback;


result = AUGraphSetNodeInputCallback (
                                      processingGraph,
                                      iONode,
                                      0,
                                      &saveToDiskCallbackStruct
                                      );    

error here:

    result = AUGraphConnectNodeInput (
             processingGraph,
             mixerNode,         // source node
             0,                 // source node output bus number
             iONode,            // destination node
             0                  // desintation node input bus number
         );
Seify
  • 312
  • 2
  • 10

1 Answers1

4

You are confused on how audio units works.

The node input callback (as set by AUGraphSetNodeInputCallback) and the node input connection (as set by AUGraphConnectNodeInput) are both on the same input side of your remote IO unit. It looks you believe that the input callback will be the output of your graph. This is wrong.

AUGraph offers two paths to feed the input of an AudioUnit:

  • Either from another upstream node (AUGraphConnectNodeInput)
  • or from a custom callback (AUGraphSetNodeInputCallback),

So you can't set them both simulatenously, it has no meaning.

Now two possibilities

1) Real time monitoring

This is not what you describe but this is the easier to get from where you are. So I assume you want to listen to the mix on the Remote I/O while it is being processed (in real time). Then Read this

2) offline rendering

If you don't plan to listen in real time (which is what I understood first from your description), then the remote IO has nothing to do here since its purpose is to talk to a physical output. Then read that. It replaces the remote I/O unit with a Generic Output Unit. Be careful that the graph is not run in the same way.

Community
  • 1
  • 1
Frédéric DJ
  • 337
  • 2
  • 7