[openbeos-midi] Re: Greetings!

  • From: Owen Smith <ods94538@xxxxxxxxx>
  • To: openbeos-midi@xxxxxxxxxxxxx
  • Date: Sat, 19 Oct 2002 11:01:04 -0700 (PDT)

Hello Martijn,

These are good questions, and unfortunately my memory
is too hazy to give you really concrete answers. But
here's my two bits' worth:

> The callbacks for receiving MIDI are only called
when > the data is sent atomically IIRC. Thus sending
system > exclusive data in several packets does not
result in
> the callback function for sysex being called. I
never > was able to figure out how to handle this, so
if you
> happen to know I'd love to hear it :).

What do you mean, "sending sys ex data in several
packets does not result in the callback function being
called?" What exactly is your code doing?

> I've been thinking about doing a "midi kit" for UNIX
> (as in POSIX compliant) and I would use message
> queues for IPC but then I won't be able to handle
> arbitrarily large sysex messages. I'm not sure BeOS
> ports are able to handle messages of any size,
> probably not. I'm not sure how well the midi2 kit
> handles very large sysex dumps and how error
handling
> is done.

Two suggestions:

1) There's nothing I can think of that's stopping you
from marshalling a big sysex dump, behind the scenes,
into smaller messages, transmitting them over the
pipe, and zipping them back together at the end. Ports
should hand you the packets in the order it received
them, so no sequencing issues should pop up, and this
happens behind the user's back so he sees it as an
atomic transaction.

2) If you're really dealing with that much data, then
shared memory is appropriate so you can avoid copying
the data.

Also: you may know better than I, but in MIDI isn't it
better if you split up the sysex data into more
manageable chunks ahead of time? If other instruments
are on the same MIDI port as your super-mega-sampler,
then one big MIDI message to that sampler is going to
starve all other instruments on the same bus from any
time-sensitive MIDI events they were hoping to
receive. I'm trying to remember what the MIDI protocol
for this was, but I'd have to go look it up somewhere.

> Another thing about the midi2 kit is the handling of
> timestamps. Are timestamps supposed to be
> monotonically increasing?

From a single source, yes.

> two kinds of stamps exist. The one where the
> message is late and the stamp indicates when it
> was received (e.g. on a physical input). And the one
> where the stamp is in the future indicating when it
> is to be transmitted (e.g. on a physical output).

In the Media Kit, absolutely! In the MIDI Kit, there
was no such distinction. I don't recall how captured
MIDI events were stamped (test it yourself!), but most
stamps were of the "future" variety. Actually, most of
the code I wrote sent everything "now," so the stamps
were basically irrelevant--the events got performed as
soon as they were received!

> There is nothing in the articles on how timestamps
> are to be used, but in practice they should be time
> ordered, i.e. the application that outputs MIDI
> should schedule the messages itself. Should it send
> them just ahead of time? or late?

I don't think the MIDI Kit did much handling of
timestamps at all, It's possible that timestamps
weren't actually looked at until they got all the way
to the output driver--and it might very well be that
some drivers just ignored those values and sent
everything immediately (yuck!). Your application
should ideally send events ahead of time by the amount
of time indicated by the latency of the producer (see
below).

> Also a software synthesizer might want to receive
> MIDI ahead of time when getting input from a
> sequencer so latency can be avoided in that case. I
> don't think the midi2 kit supports this, but maybe
it
> could.

Yes, midi2 supports latency, but AFAIK it's up to the
programmer to check the latency value for a particular
endpoint and make sure the data goes out that much
time before something should be performed. The
question is whether you can send it out significantly
*before* the time that latency dictates and still get
meaningful results. One way to find out, really!

-- O

__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

Other related posts: