• 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: MIDI timer resolution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIDI timer resolution


  • Subject: Re: MIDI timer resolution
  • From: Kurt Revis <email@hidden>
  • Date: Thu, 15 Aug 2002 10:40:50 -0700

There is an issue I would like to know in detail about before I buy the machine: How exact is QT's MIDI timing in Mac OS X ? I need a resolution of at least 1ms, ie. my program should be notified on the exact millisecond. The timing should also be exact when there is heavy cpu or kernel load. I have read about QT's MIDI functions at developer.apple.com and have found functions dealing with clock components, but no information about how exact the timer resolution can be.

From my point of view, you are mixing up at least three things here which are really somewhat separate. So I'll try to answer your question and explain the differences.

1. MIDI timing on Mac OS X

Using CoreMIDI on Mac OS X, all MIDI events which go in and out of a program have a timestamp. The CoreMIDI system contains a scheduler which is responsible for sending the events on time (with the help of the driver). All your program needs to do is to give the events to CoreMIDI some amount of time in advance of when they should really be sent. (You can read the property kMIDIPropertyAdvanceScheduleTimeMuSec of an endpoint to find out how early that is.)

You may also provide a timestamp of zero, which means "send this immediately". Of course, then you are responsible for all timing issues.

The advantages of the CoreMIDI system are:
* All programs on the system get really good timing
* The timing is consistent across applications
* Devices which need data ahead of time (like modern multiport devices) work transparently
* Only one process in the system needs to go to the effort to get high-resolution timers

So, in many cases, your program doesn't *need* really high-resolution timers. For example, a sequencer could wake up every 100ms or so, process the MIDI events for a block of time, tell CoreMIDI to send them, and go back to sleep. Waking up that often is not difficult, and still gives a responsive user interface.


2. QuickTime (QT)

QuickTime has some functionality for dealing with MIDI, but it's more focused on the playback and synthesis side of things (as I understand it). You don't need to use it to write MIDI programs on OS X. It's probably best avoided until you are more familiar with how CoreMIDI works.

If you really were interested only in QuickTime, I apologize... I am assuming that you read about QuickTime and got off the track. If you are interested in getting good timing, there are probably better ways to do it than by using QuickTime.


3. Using (high-resolution) timers in your program

Instead of going through all of this again, please just check the archives of this list. Particularly these threads:
"setting up independent timing thread", July 12
"CoreMIDI question", April 28
"More thread scheduling observations", May 4

There should be enough to get started on, but please ask if you have more detailed questions.

--
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: 
 >MIDI timer resolution (From: Sven Thoennissen <email@hidden>)

  • Prev by Date: Re: MIDI timer resolution
  • Next by Date: Re: inOutputTime accuracy?
  • Previous by thread: Re: MIDI timer resolution
  • Next by thread: When should takeTimeStamp() be called?
  • Index(es):
    • Date
    • Thread