Re: Stuck MIDI notes
Re: Stuck MIDI notes
- Subject: Re: Stuck MIDI notes
- From: Herbie Robinson <email@hidden>
- Date: Thu, 31 Oct 2002 18:42:07 -0500
At 7:45 AM -0500 10/31/02, Robert Grant wrote:
Thanks for your pointers guys. They look perfect. I guess I thought that such
a common function as walking the packet would be provided in CoreMIDI.
It would require more state to parse MIDI messages within the
packets. It would be nice to have a more general parser; although,
that might be a bit much for a set of C macros. Some kind of C++
inline would do nicely.
There is 10 or 12 bytes of overhead for each packet (mostly the 8
byte time stamp); so, the overhead of putting a single MIDI message
in each packet would be a bit much. The data is stored into packets
in a way that hides some of the more nasty parsing issues (like
running status and real time messages coming in the middle of
everything else).
At 5:18 AM -0800 10/31/02, Kurt Revis wrote:
On Thursday, October 31, 2002, at 04:34 AM, Philippe Wicker wrote:
Have a look in XFramework/Model/XMIDIClient.cpp, there is a method
called NextMIDIEvent. This method contains code that allow to walk
through a MIDIPacket event by event. It may not be exactly what you
need (it could be useful to get at return the length of the event),
but it is surely a good starting point.
Yes--that code implements the basics correctly. Note that this code
doesn't handle realtime messages properly, though. The unofficial
"MIDI spec" floating around the net says
MIDI allows a RealTime message to be sent at any time, even
interspersed within some other MIDI message. For example, a
RealTime message could be sent inbetween the two data bytes of a
Note On message.
but this code doesn't handle that case.
The Core MIDI packets aren't as loose as a MIDI stream in the wild.
In particular, running status is not allowed and SysEx messages are
supposed to be in a packet by themselves. This is all documented in
the headers where the structures are declared. There was a bug in
the core MIDI routine for building packets; so, in reality, one could
see regular messages come after SysEx message in the same buffer (but
not before or between, AFIK).
(Unless CoreMIDI rewrites MIDI data to move realtime messages out of
other messages... but that's pretty unlikely. I sure don't think it
did when I wrote my parser more than a year ago.)
Providers of messages (drivers, etc) are required to create packets
with no intermingling. The easiest way to do this is to use packet
building routine that Core MIDI provides.
--
-*****************************************
**
http://www.curbside-recording.com/ **
******************************************
_______________________________________________
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.