Re: CoreMidi and Virtual EndPoints
Re: CoreMidi and Virtual EndPoints
- Subject: Re: CoreMidi and Virtual EndPoints
- From: Philippe Wicker <email@hidden>
- Date: Tue, 14 Jan 2003 22:31:32 +0100
On Tuesday, January 14, 2003, at 07:27 PM, Pierre-Olivier Latour wrote:
>
Hi there,
>
>
There's something I would like to understand about virtual endpoints:
>
>
If a MIDI software does not connect directly to the hardware device
>
(say a
>
GM hardware synthesizer), but creates a MIDI virtual endpoint: other
>
applications will see it and offer the user to use it as a MIDI input,
>
so
>
that's OK.
>
>
But how can the user connect this virtual device and a hardware device
>
together? Under OS 9 and MIDI Manager, there was a program for that
>
where
>
you could see all devices (virtual and physical) and establish
>
connections
>
between them. Apparently, virtual endpoints do not appear in the
>
"Audio MIDI
>
Setup" application. So how do you do virtual MIDI routing inside the
>
computer?
>
Hi,
Follows a summary of (what I have understood of) the way MIDI endpoints
work.
RECEIVING MIDI EVENTS
To receive MIDI events you may choose between two methods (or both if
you like): with the 1st method, you choose the source of MIDI events,
with the 2nd method, you tell to the outside world "you can send me
MIDI events at this "address" (endpoint)".
1st method:
- get the list of available source endpoints in the system (you may use
MIDIGetSource for a static approach, and/or manage the messages passed
to the MIDINotifyProc for a dynamic approach). Endpoints associated to
MIDI input devices (ie devices with a MIDI driver installed) will be
obtained by MIDIGetSource. Others endpoints will be obtained by this
same call if they have been created before you call MIDIGetSource.
Otherwise you need to manage the notification messages to get them "on
the fly" (well, at least that's how I do it).
- choose the endpoint you wish to receive MIDI events from (some GUI
stuff here).
- create a MIDIInputPort (MIDIInputPortCreate)
- connect the endpoint you have just chosen to this port
(MIDIPortConnectSource).
When this is done, you should be able to receive MIDI events in your
MIDIProc callback (this callback is one of the parameters to
MIDIInputPortCreate).
2nd method:
- "export" a virtual destination endpoint (call MIDIDestinationCreate),
that's all!
When this is done, you should be able to receive MIDI events in your
MIDIProc callback. As far as I know, the callback may be the same if
you choose to implement both methods.
SENDING MIDI EVENTS
Here again 2 methods. With the 1st method, you choose who will receive
your MIDI events. With the 2nd method, you send MIDI events to the
outside world and everyone interested can grab them.
1st method:
- get the list of available destination endpoints in the system (use
MIDIGetDestination for a static approach, and/or manage the messages
passed to the MIDINotifyProc for a dynamic approach). Endpoints
associated to MIDI output devices (ie devices with a MIDI driver
installed) will be obtained by MIDIGetDestination. Others endpoints
will be obtained by this same call if they have been created before
you call MIDIGetDestination. Otherwise you need to manage the
notification messages to get them "on the fly" (again, this is at least
how I do it).
- choose the endpoint you wish to send MIDI events to (some GUI stuff
here).
- create a MIDIOutputPort (MIDIOutputPortCreate)
- call MIDISend. This call takes as parameters the output port you've
created, the endpoint ref you've chosen, and a list of the MIDI events
you want to send. Additionally (and this is a great feature), MIDISend
schedules the events in the time. If you send events with a time stamp
sometime in the future, they will be delivered to the destination at
the time specified in the time stamp. Really cool.
2nd method:
- create a virtual source (call MIDISourceCreate),
- call MIDIReceived. It sends a list of event through this source.
PUTTING THINGS TOGETHER
At the application level (as far as MIDI communication is concerned)
you don't need to deal with physical devices. Everything appears as
endpoints, wether those endpoints are associated with physical devices,
or associated with virtual sources or destinations does not really
matter. The routing of MIDI events is done inside your application by
any one of the methods described above. And the routing at the system
level is the result (the combination) of the routing chosen (by the
user(s) at the end) in each MIDI application running at the same time.
Apple "Audio MIDI Setup" Application shows you devices. In my case for
instance, it shows a device called Unity (the software sampler from
Bitheadz) and another device called UM-1 (USB MIDI interface from
Edirol). Unity cannot be connected to any other device because it is a
"pure" virtual device that do not communicate with the world outside
the machine. On the contrary, I can connect the UM-1 to external
devices (eg a Sond Canvas, or a hardware sampler). This is possible
because UM-1 is a physical device designed to send or receive MIDI
to/from the outside of the machine.
Hope this is clear enough.
Philippe Wicker
email@hidden
_______________________________________________
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.