Re: Midi sysex request in new thread
Re: Midi sysex request in new thread
- Subject: Re: Midi sysex request in new thread
- From: Pete Gontier <email@hidden>
- Date: Fri, 17 Dec 2004 09:48:12 -0800
circa 12/15/04 4:42 AM, "Peter Karlsson" <email@hidden> wrote:
> When I click a button, the code under that button starts a new thread. In that
> thread I send a midi sysex request message to one of my synthesizers. In my
> MyReadProc I increase a counter every time I receive a sysex midi byte. This
> counter is checked for in a while loop in my new thread. And when the counter
> have reached the size of the sysex message the while loop is finished and the
> thread exits. That's the idea but... It does not work so good. I get
> [MIDISportLike] sending full buffer messages so it seems that my way of doing
> this consumes a lot of cpu power. Can someone please help me to solve this?
> Maybe there is a much better way? I must find a way to stop my code executing
> until the sysex message is finished. That's the whole problem.
I am not an expert on multi-threaded CoreMIDI client programming, but I did
write the driver in question. It sounds like you are trying to receive a
large sysex message. The driver is trying to avoid sending you every byte as
it's received from USB (actually, they arrive in chunks of 1 to 12, but
that's neither here nor there). It's accumulating bytes into a non-small
buffer (say for the sake of discussion it's 256 bytes long because I can't
remember). When the message ends OR the buffer fills, then the driver sends
the buffer up to CoreMIDI. In theory, this is supposed to reduce overhead,
because my assumption is that you can't really do anything with a partial
sysex message anyway, and packing each byte into a Mach message that gets
shipped across at least two process barriers didn't seem like a good idea
for throughput. Despite all this, your concern is that too much CPU is being
consumed. So my questions are along the lines of: Is CoreMIDI delivering to
you little bitty chunks of message? Might that be because you're only asking
for little bitty chunks?
--
Pete Gontier
http://www.m-audio.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden