• 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 processing question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIDI processing question


  • Subject: Re: MIDI processing question
  • From: Kurt Revis <email@hidden>
  • Date: Fri, 2 Apr 2004 01:34:20 -0800

On Friday, April 2, 2004, at 12:15 AM, Bob Lang wrote:

This is the first time I've ever bothered looking at the time
stamps, and now I realise I'm confused: What exactly does the time
stamp mean? It's a huge number and I can't find anywhere in the
documentation to explain it (apart from a reference to *absolute*
time and I'm sure Einstein exploded that notion).

If you are worried about relativistic effects when doing audio, I'm afraid you're on your own :)

The computer continually increments a hardware time counter while it runs. On older G3/G4 hardware this runs at something like 1/4 the bus speed; I don't know if it is different for the G5. In any case, it's a convenient, stable, and high-resolution source of timing information, so just about all time-related functionality in the system (from the OS scheduler on up) is based on it. This includes CoreAudio and CoreMIDI.

(Search for "PowerPC Time Base Register" if you really want to know more.)

Normally you don't care about the actual timestamp values. You can use the functions in <CoreAudio/HostTime.h> to convert values between HostTime units and nanoseconds, as necessary. Otherwise, you can just assume that the current host time is steadily increasing. (If you're really good you'll worry about the clock rolling over -- but if I'm doing the math right, that should take several thousand years to happen.)

For MIDI packets received by hardware, the timestamp should indicate the time that the MIDI data was received by the computer (or perhaps by the interface hardware itself, if that's possible). There was some discussion on this list a while back about whether the timestamp reflects the time the first byte of the packet is received, or the last byte; check the archives if you need to know at that level of detail (odds are you don't).

If you're sending MIDI data, you should provide a timestamp indicating when you would like the data to be sent by the computer. CoreMIDI will try its best to send it at that time. Or, if you set the timestamp to 0, CoreMIDI will send the data immediately.

It takes around 1mS to send one midi message, so midi time stamps
don't need to be any more accurate than that, yet the number seems
to be ticking at sub micro-second intervals - complete overkill.

It's perhaps overkill, but it is handy to deal with both audio and MIDI using the same time base.

--
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: MIDI processing question (From: "Bob Lang" <email@hidden>)

  • Prev by Date: Re: MIDI processing question
  • Next by Date: Re: Audio threads scheduling
  • Previous by thread: Re: MIDI processing question
  • Next by thread: Re: MIDI processing question
  • Index(es):
    • Date
    • Thread