All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Christopher Arndt <chris.arndt@web.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: pyalsa: synchronizing queue with MIDI clock events
Date: Tue, 21 Jul 2009 15:32:32 +0200	[thread overview]
Message-ID: <4A65C370.3030205@ladisch.de> (raw)
In-Reply-To: <4A607468.7010300@web.de>

Christopher Arndt wrote:
> Now to synchronize the queue tempo to incoming MIDI clock events, to be
> able implement synchronized delays or arpeggiators,  I use the method in
> the code shown below. This works ok, but I notice that the measured BPM
> oscillates +-1 BPM around the value displayed by the clock source (my
> synth's sequencer) if I measure/average only a few (~10) ticks or do not
>  round the result to an integer value.
> 
> Is this the right approach? What is a sensible number of ticks to take
> into account for measurement?

Large enough that you get a stable average, but small enough that you
can detect actual changes.

> Should I use another reference timer than Python's time.time() function?

That timer probably has a high enough resolution, but you measure the
time when your code is executed, which may be later then when the
event was actually received.

You can tell ALSA to timestamp all events that are received; just call
the snd_seq_port_info_set_timestamping() function and set a queue that
is running, then you'll get the queue's current time in each event.
This isn't implemented in pyalsa, but you can set this for a specific
connection with the queue, time_update, and time_real parameters of the
connect_ports function.

> Is pyalsa generally suitable for this kind of application even on
> older/weaker hardware (e.g. a NSLU2)?

The biggest problem is probably scheduling delays, so I guess using
Python instead of C should not add any noticeable delay.


Best regards,
Clemens

  parent reply	other threads:[~2009-07-21 13:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-17 12:54 pyalsa: synchronizing queue with MIDI clock events Christopher Arndt
2009-07-20 12:31 ` Christopher Arndt
2009-07-21 13:32 ` Clemens Ladisch [this message]
2009-07-21 16:20   ` Christopher Arndt
2009-07-31 18:26     ` pyalsa: SeqEvent.time strangeness (Was: synchronizing queue with MIDI clock events) Christopher Arndt
2009-08-02 15:42       ` Christopher Arndt
2009-08-03 11:55       ` Clemens Ladisch
2009-08-03 12:21         ` pyalsa: SeqEvent.time strangeness Christopher Arndt
2009-08-04  9:45           ` Clemens Ladisch
2009-08-04 11:10             ` Christopher Arndt
2009-08-04 13:03               ` Clemens Ladisch
2009-08-05 13:18                 ` [PATCH] alsa-python: Add support for setuptools Christopher Arndt
2009-08-05 13:30                   ` Clemens Ladisch

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=4A65C370.3030205@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=chris.arndt@web.de \
    /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.