Re: MIDI TimeCode generator
Re: MIDI TimeCode generator
- Subject: Re: MIDI TimeCode generator
- From: Kurt Revis <email@hidden>
- Date: Sun, 18 Aug 2002 15:13:06 -0700
On Sunday, August 18, 2002, at 02:47 PM, Peter Krajcik wrote:
Now, I'm a little bit disoriented:
- Virtual destination in my app seems to be a "port" where other
application
can send data - it is a MIDI in of my app.
- Virtual source in my app seems to be a "port" from where other
application
can recieve data - it is a MIDI output of my app.
Yes.
If this is a true, why I need to use MIDIReceived() if I need to send
out
data to my "virtual output port" -> my Virtual source ?
Normally MIDI sources are owned by a driver, and are related to actual
hardware. The driver for that hardware calls MIDIReceived() when it gets
MIDI data from the hardware.
The signal flow is the same for virtual sources, even though there is no
actual hardware involved. So I think the CoreMIDI engineers decided
that they could just use MIDIReceived() in exactly the same way.
The problem is that the situation isn't *exactly* the same, because
hardware drivers just want to set the timestamp of the events and pass
them on as soon as possible, but applications with virtual sources
actually want the events to be scheduled to be sent in the future.
(That is: hardware drivers will set the events' timestamps to some time
in the past, but applications will generally set the events' timestamps
to some time in the future. The current behavior--passing on the events
immediately--is correct for the first case, but not the second case.)
I think I just need to call MIDISend(port, myVirtualSource, packetlist);
You can try it, but I'm pretty sure it won't work.
See the comments in MIDIServices.h:
"After creating a virtual source, use MIDIReceived to transmit MIDI
messages from your virtual source to any clients connected to the
virtual source."
"Clients which have created virtual sources, using MIDISourceCreate,
should call this function [MIDIReceived] when the source is generating
MIDI."
Did you mean that recieving application needs to call MIDIRecieved()
from my
VirtualSource
No.
How to make an accurate timing of MIDI data via
virtual source ?
Basically, you need to implement the same kind of scheduler that the
MIDIServer has internally. This is pretty tricky to do correctly. You
need a high-priority thread (probably with the time-constraint policy
set) to get good timing. Please check the archives of this list--we've
gone over it a few times.
(What is logic in that: destination uses TimeStamps and
source doesn't. Should be symmetrical Ithink.)
I agree, and I've brought up the issue on the list before. Doug Wyatt
gave me the impression that this behavior may be changed in the future,
but as far as I know it's still asymmetrical in 10.2.
--
Kurt Revis
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.