[linux-audio-dev] synching soundcards Was: MTC, SMPTE, etc.

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

Subject: [linux-audio-dev] synching soundcards Was: MTC, SMPTE, etc.
From: Benno Senoner (sbenno_AT_gardena.net)
Date: Sat Jul 22 2000 - 14:01:37 EEST


My two cents on the sync issue:

it is possible to sync (not at sample level but so that you do not
get 1sec drift after a few minutes) two soundcards
in pure software if you do it then do it using an adaptive algorithm and never
assume thatthe drift will remain constant.

Take one card as reference eg the Hammerfall connected to
a very accurate wordclock source
 (BTW: how accurateit the internal timing source ?)

Then at each iteration read let's say 128 samples from both cards.
now measure the hw capture / playback ptr position of the slave card:
if it begins to drift (compared to the previous iteration), and you notice
that the card is too fast in producing data , then downsample the data.
At some point there will be an iteration where a fragment gets fetched
from the Hammerfall but TWO fragments on the slave card.
This additional queued up fragment will slowly be eaten by the
resampling routine (or sample-skipping routine) during the next iterations.

The case "slave-card is to slow" is similar, at some point you would
read one fragment from the hammerfall but NO fragments from the slave
card. The resampling buffer would still have a fragment worth of samples left to
send to the output. (which have to be queued in advance)

The necessary condition is that the slave card needs to support at least
3 fragments , in order to provide the necessary buffering.
(if we want to keep the audio processing code single-threaded
which is almost mandatory for low-latency operation)

Basically the algorithm adapts itself after every fragment so even if you
heat up your soundblaster with a hairdresser which migth cause clockdrifts,
the code would notice it and react to the changed frequency drifts.

Notice in the above algorithm works even if you set all soundcards to slaves
and take a precise clock source as timing base.
(then every PCM stream would be resampled).

You CAN use an audio card as interrupt source (for let's say MIDI events) AND
still get good audio output timing , provided that you sync it up to the precise
clock source.

I was wondering if there is windows software available which can sync together
two soundcards in software.
( can Cubase, Logic , Cakewalk do this ?)
 
I think that the above stuff is a kludge and only suitable for the amateur
wanting to get out the most of his toy-soundcards.
(With big problems for the audio software developer :-) )

The pro should definitively go with soundcards which can be synched with
an external wordclock source.

perfect timing, full efficiency and easy life for us poor audio software
developers.
:-))

Benno.

On Sat, 22 Jul 2000, Paul Winkler wrote:
> Paul Barton-Davis wrote:
> >
> > >> Note, interestingly, how bad this is for the idea of using audio
> > >> devices as a timer for, say, the ALSA sequencer ...
> > >
> > >Well, only if you use one audio device for your timer and another
> > >for audio at the same time.
> >
> > I don't think so! What we know is that 44,100 samples at a nominal
> > rate of 44.1kHz is *not* guaranteed to correspond to 1 second of
> > elapsed time. If you build a timer around this (e.g. the ALSA lowlevel
> > timer interface), and then use it for sequencing, its not accurate.
> >
> > Obviously, this is all about "within a tolerance of X usecs".
>
> Right. And if it's within close enough tolerance that recording an
> audio stream sounds OK, then recording a midi stream will sound
> equally OK (or equally bad!).
>
> I believe that even a cheap soundcard with a bad timer could provide
> a good enough timing reference to satisfy nearly all MIDI musicians,
> but not good enough to assume it will stay in sync with another
> soundcard. For example, with my two soundcards that had 1/4 sec. of
> difference after 60 seconds, that's an 0.4% difference in soundcard
> sampling rates. If you have a MIDI sequencer running 0.4% too fast,
> that means that when you expect a tempo of 100 bpm you'll actually
> get 100.4 bpm. I haven't actually tried it, but I think I'd be very
> impressed with anyone who could reliably tell the difference between
> 100 and 100.4 bpm in a double-blind test. BUT, start playing two
> parts simultaneously at 100 and 100.4 bpm and *anyone* will know
> something's wrong pretty soon.
>
> So, I think running a sequencer from the soundcard clock will
> probably be very satisfactory until you try to use a different
> soundcard for something else at the same time.
>
>
> ................. paul winkler ..................
> sslinkP arts: music, sound, illustration, design, etc.
> web page: http://www.ulster.net/~abigoo
> A member of ARMS: http://www.reacharms.com
> or http://www.mp3.com/arms


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

This archive was generated by hypermail 2b28 : Sat Jul 22 2000 - 14:14:10 EEST