On Fri, 2005-12-30 at 17:36 -0500, Ross Vandegrift wrote: > On Fri, Dec 30, 2005 at 12:45:48PM +1000, Adam Nielsen wrote: > > I've always wondered about this. Fair enough that two cards would play > > back sound at slightly different speeds, but why can't you just drop a > > sample or two every few milliseconds or so, to keep the sound roughly in > > sync? > > How do you know how much to slew the playback by? > > Say I have two sound cards in my box. Each sound card has an > independent crystal that generates a clock for timekeeping. The > crystals are rated to resonate at some fixed frequency, but there will > always be a margain of error. Even two "identical" parts from the > same manufacturer will produce different errors in their clock. > > At first, the issue isn't a big deal, since the difference may be > small. But as time ticks by, many small differences begin to add up > to bigger and bigger difference. This type of error is called drift. > > In addition, a crystal is a physical process, and so occasionally > there are abberant ticks. This causes sudden loss of time tracking. > This type of error is called jitter. > > The two together are a deadly combination. You need some way of > mitigating both to keep stuff in sync. One way is to use some > out-of-band data to slave one card to the other card's timesource. > Lots of pro gear does this with word clock, spdif links, and the like. > > You can solve the problem for your PC's internal clock with NTP. > Moreover, if you're interested in timekeeping issues like this, the > NTP research papers are an amazing source of a huge amount of > information on this kind of stuff. >
LDAS (the low delay audio streamer) does something similar - it has to compensate for the drift between two machines clocks' that exchange audio over the network but you could apply the algorithm to two cards on one box. It uses the ALSA API and is believed to accomplish this with the lowest achievable latency. http://www.q2s.ntnu.no/~asbjs/ldas/ldas.html Lee ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user