[linux-audio-dev] Re: [Alsa-devel] Forcing an absolute timestamp for every midi event.

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] Re: [Alsa-devel] Forcing an absolute timestamp for every midi event.
From: Martijn Sipkema (msipkema_AT_sipkema-digital.com)
Date: Sun Aug 18 2002 - 23:12:52 EEST


> Hi! I wanted to ask, how about forcing
> an absolute timestamp for _every_ midi event?
> I think this would be great for softsynths,
> so they dont need to work with root/schedfifo/lowlatency
> to have a decent timing. Not allways you are willing
> to process midi at the lowest latency possible.
> I say because you dont really need all that if you
> sequence in the computer and control softsynths and maybe
> some external device.
> This way, the softsynth gets the event with the timestamp,
> gets the current time, substracts the audio delay (latency) to that
> and just mixes internally in smaller blocks processing each
> event in the right time.

I'm not sure what you mean, but below is what I think would be the
best approach for audio/MIDI I/O.

----

UST = unadjusted system time MSC = media stream count

see also:

http://www.lurkertech.com/lg/time/intro.html

(synchronous) Audio I/O API - Callback based. - All buffers in a callback are of the same size. - All frames with a particular MSC occur at the same time. (I don't think OpenML requires this, EASI does have this with its 'position') - The audio callback provides an MSC value for every buffer corresponding to the first frame in the buffer. - The (constant) latency (in frames) between an input and an output can be seen from the difference between their MSC values. - The audio callback provides an UST value for every input buffer corresponding to the end of that buffer/start of the next buffer. - The UST value for the start/end of an output buffer can be estimated.

MIDI I/O API - MIDI messages are received with a UST stamp. - Timestamps are measured at the start of the message on the wire. - MIDI messages are either sent immediately or scheduled to UST. - MIDI messages must have monotonically increasing timestamps if scheduled.

For a software synthesizer the MIDI messages received at some UST can be mapped to a corresponding MSC value and then rendered at a constant offset from this MSC, most likely the audio I/O latency (the audio I/O latency may not be the same for all inputs/outputs, also since MIDI messages always arrive late a small extra latency should be introduced in this case by increasing the MIDI message's UST by a constant value in order to compensate for the MIDI interface and scheduling latency so they arrive a little early instead of late in order to reduce jitter with MIDI messages arriving near buffer bounderies). MIDI -> audio output latency would then be slightly higher (say 2ms, noting that transmitting a note-on message already takes 3*320usec) then audio I/O latency.

--martijn


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sun Aug 18 2002 - 22:15:00 EEST