All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martijn Sipkema" <msipkema@sipkema-digital.com>
To: Juan Linietsky <coding@reduz.com.ar>,
	alsa-devel@alsa-project.org, linux-audio-dev@music.columbia.edu
Subject: Re: Forcing an absolute timestamp for every midi event.
Date: Sun, 18 Aug 2002 21:12:52 +0100	[thread overview]
Message-ID: <000c01c246f3$bfed4370$0400a8c0@martijn> (raw)
In-Reply-To: 20020818055740.2af8e3e7.coding@reduz.com.ar

> 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





-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

  parent reply	other threads:[~2002-08-18 19:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-18  8:57 Forcing an absolute timestamp for every midi event Juan Linietsky
2002-08-18 10:08 ` Patrick Shirkey
2002-08-18 12:48 ` Frank van de Pol
2002-08-18 22:17   ` Juan Linietsky
2002-08-19 15:47     ` Takashi Iwai
2002-08-18 20:12 ` Martijn Sipkema [this message]
2002-08-18 21:18   ` [linux-audio-dev] " Frank van de Pol
2002-08-19  6:43     ` Martijn Sipkema
2002-08-19  7:52       ` Jaroslav Kysela
2002-08-18 22:58   ` Juan Linietsky
2002-08-19  6:41     ` Martijn Sipkema
2002-08-19  8:07       ` Juan Linietsky
2002-08-19 12:39         ` Martijn Sipkema
2002-08-19 13:01           ` aside - alsa-docs Patrick Shirkey
2002-08-20 21:11           ` Forcing an absolute timestamp for every midi event Frank van de Pol
2002-08-21  1:10             ` Martijn Sipkema

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000c01c246f3$bfed4370$0400a8c0@martijn' \
    --to=msipkema@sipkema-digital.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=coding@reduz.com.ar \
    --cc=linux-audio-dev@music.columbia.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.