• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MIDISend buffersize?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIDISend buffersize?


  • Subject: Re: MIDISend buffersize?
  • From: Kurt Revis <email@hidden>
  • Date: Sun, 2 Feb 2003 11:37:32 -0800

On Sunday, February 2, 2003, at 04:30 AM, Herbie Robinson wrote:

I have just managed to record and play back midi bytes with my microseq (not much more at the moment).

I am using MIDISend to play back my notes. But how big is the buffer? I mean, how much midi can I send to the system for future delivery? Is there a way to check when the buffer is full or when it's time to send more midi?

You should queue ahead by a certain amount of time. That would be determined by the scheduling parameters for the thread doing the sending and kMIDIPropertyAdvanceScheduleTimeMuSec for the device you are sending to (probably, the scheduling parameters for the thread would be influenced by kMIDIPropertyAdvanceScheduleTimeMuSec...).

I agree that that's the right way to do it. But it helps to know that if you're just hacking around, there's no need to be so careful. You can send MIDI packets with timestamps many seconds in the future, and the MIDIServer will handle it correctly. Same with sending a whole lot of data all at once. If there is a fixed buffer for scheduled events in the MIDIServer, I haven't encountered it yet.

(Also, if you specify a timestamp which is already in the past, the MIDIServer will send the packet immediately, not drop it.)

In a quality app, though, it would be best to even out the CPU load and memory usage over time, by only queuing up a reasonable amount of data, scheduled for a reasonable amount of time. What's "reasonable" is open to debate.

As for knowing "when it's time to send more MIDI", that is entirely up to your application. If you're writing a sequencer, for instance, you need to keep track of which events have been sent, which events remain to be sent, and when they need to be sent. You would have your code wake up periodically, find out the current time, figure out what needs to be sent, send it, and go back to sleep. Since the MIDIServer is good at doing high-precision timing, you don't have to worry about timing as much: you could wake up once per second (for instance), but your MIDI events would still be sent with much more accurate timing.

I'm glossing over a lot of details, but that's the basic idea.

--
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.

References: 
 >Re: MIDISend buffersize? (From: Herbie Robinson <email@hidden>)

  • Prev by Date: Why my view can't get some Carbon Events?
  • Next by Date: AudioConverter woes
  • Previous by thread: Re: MIDISend buffersize?
  • Next by thread: Why my view can't get some Carbon Events?
  • Index(es):
    • Date
    • Thread