All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: alsa-devel@alsa-project.org
Subject: Re: Can ALSA MIDI use timestamps for precise timing?
Date: Mon, 28 Aug 2017 11:11:56 +0200	[thread overview]
Message-ID: <bde97703-2954-78ce-4128-4a8596c8042c@ladisch.de> (raw)
In-Reply-To: <fdc3abae-84b8-d94c-991d-cdd30c4d9f64@cs.cmu.edu>

Roger Dannenberg wrote:
>     PortMIDI wants to send MIDI messages at precise times according to
> arbitrary clocks. In Audacity, the important clock to synchronize to is
> the audio sample clock.

What is the API that PortMIDI wants to offer?  And does any OS actually
offer this?

The ALSA sequencer relies on interrupts for the clock.  It would be
possible to use a PCM device as interrupt source, but there is only one
interrupt after each period, so this would have horrible jitter.

> There's absolute timing, but the docs say that's relative to when you
> start the queue, but when exactly is that?

When you start the queue, i.e., when you send the SND_SEQ_EVENT_START
message or call snd_seq_start_queue().

> if you send with relative time and you get unscheduled just as you are
> executing the write call, you'll be late.

That could also happen with any other call.

> The problem becomes precise timing of queue creation doesn't it?

You could measure the offset between the queue's clock and the actual
clock.

> And there's no timestamp provided for when to start.

You could schedule the start event, but that would require another
queue ...  ;-)


Regards,
Clemens

      reply	other threads:[~2017-08-28  9:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 17:51 Can ALSA MIDI use timestamps for precise timing? Roger Dannenberg
2017-08-28  9:11 ` Clemens Ladisch [this message]

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=bde97703-2954-78ce-4128-4a8596c8042c@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    /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.