Re: AUMIDIController Virtual Destination
Re: AUMIDIController Virtual Destination
- Subject: Re: AUMIDIController Virtual Destination
- From: Doug Wyatt <email@hidden>
- Date: Fri, 11 Jul 2003 14:22:01 -0700
Dan,
On Thursday, Jul 10, 2003, at 15:56 US/Pacific, Dan Callaway wrote:
I am having some trouble configuring an AUMIDIController. My app
sends large
groups of MIDI packets at a time, relying on MIDIServer to schedule
delivery.
To date, my MIDISend call has directed output to a hardware MIDI port,
which
works well. I want to allow playback through the stock DLS
MusicDevice, so I
am trying to:
1) Create an AUMIDIController
2) Link this AUMIDIController to the stock DLS
3) Set up the AUMIDIController as a CoreMIDI virtual destination
The AUMIDIController documentation states that an AUMIDIController can
be set
up as a virtual destination, but I can't find any further
documentation on
this.
All you have to do is pass a non-null CFStringRef with the name of the
virtual destination to AUMIDIControllerCreate, and CoreMIDI does create
a virtual destination with that name. I just did a sanity check to test
this and it works ... (see test code below)
When I create the AUMIDIController, FindNextComponent does 'see' it,
I don't understand -- AUMIDIController creates a virtual destination,
which will show up in the list returned by MIDIGetNumberOfDestinations
/ MIDIGetDestination. It doesn't create any components or component
instances.
but I can't get it to react to MIDISend. Furthermore, all the sample
code in
the list archive concerning AUMIDIController takes the approach of
setting up
a MIDI Source and then using MIDIReceived() to route packets to the
AUMIDIController. To take advantage of the MIDIServer scheduler,
though, I'd
like to set up the AUMIDIController as a virtual destination, so that
it is
interchangeable with hardware ports.
Is this possible?
With my program below running, I then ran another little command-line
tool that plays a MIDI file to a destination specified by name, using
MIDISend(). It worked fine.
I wonder what are you doing differently?
Doug
==============================================
#include <CoreAudio/CoreAudio.h>
#include <AudioToolbox/AUMIDIController.h>
#include <AudioToolbox/AUGraph.h>
#include <unistd.h>
#include "Debugging++.h"
#undef kComponentSignatureString
#define kComponentSignatureString "AUMIDIControllerTest2"
#define USE_VIRTUAL_DEST 1
void AUMIDIControllerTest2()
{
AUGraph theGraph;
RequireNoErr(NewAUGraph(&theGraph));
AUNode outputNode, synthNode;
ComponentDescription desc;
desc.componentType = kAudioUnitComponentType;
desc.componentSubType = kAudioUnitSubType_Output;
desc.componentManufacturer = kAudioUnitID_DefaultOutput;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
RequireNoErr(AUGraphNewNode(theGraph, &desc, 0, NULL, &outputNode));
desc.componentSubType = kAudioUnitSubType_MusicDevice;
desc.componentManufacturer = kAudioUnitID_DLSSynth;
RequireNoErr(AUGraphNewNode(theGraph, &desc, 0, NULL, &synthNode));
RequireNoErr(AUGraphConnectNodeInput( theGraph,
synthNode, 0,
outputNode, 0 ));
RequireNoErr(AUGraphOpen(theGraph));
RequireNoErr(AUGraphInitialize(theGraph));
AudioUnit theSynth, theOutput;
RequireNoErr(AUGraphGetNodeInfo(theGraph, synthNode, NULL, NULL, NULL,
&theSynth));
RequireNoErr(AUGraphGetNodeInfo(theGraph, outputNode, NULL, NULL,
NULL, &theOutput));
AUMIDIControllerRef ctlr;
CFStringRef virtDestName = USE_VIRTUAL_DEST ? CFSTR("aumidictl") :
NULL;
RequireNoErr(AUMIDIControllerCreate(virtDestName, &ctlr));
RequireNoErr(AUMIDIControllerMapChannelToAU(ctlr, -1, theSynth, 0,
true));
RequireNoErr(AUGraphStart(theGraph));
#if !USE_VIRTUAL_DEST
MIDIEndpointRef endpt = MIDIGetSource(0);
printf("asking for input from MIDI source lX\n", long(endpt));
RequireNoErr(AUMIDIControllerConnectSource(ctlr, endpt));
#endif
CFRunLoopRun();
}
int main(int argc, const char *argv[])
{
AUMIDIControllerTest2();
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.