Re: Outputting same sound source to multiple cardssimultaneously

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since the output from the two cards do not actually need to be in sync (the output is in different rooms and I take it these are not recording rooms) then can you not just feed the two cards from separate streams and just resync/restart the stream either at silence or between songs by draining the buffer? That way you just feed each device at the rate at which it wants to accept data.

If you really wanted to do this from a single open file descriptor then you could monitor the available buffer space on each device and have one device attempt to track the buffer occupancy of the other. I would advise resampling over sample insertion/removal because even at very low rate differences the action would be repetitive and sample drop/insertion then becomes very noticable. Resampling would introduce a little but of wow/flutter into one of the streams as its tries to maintain the same rate as the monitored stream, but hey, that can sound good at low rates - it would be like a set of tape heads. The reason you cannot directly implement such a solution is that every soundcard believes it is running at exactly 44100Hz (or 48kHz or whatever you configure), and they cannot tell you what their true running rate is.

To be honest, the other option would be to just dump a block of samples if you had overruns on a device (or repeat a block if you had underruns which is perhaps easier to detect). If you had, say, 64KB of buffer space then the proposed delta from your calculation below gives you about 70 excess samples per seconds, so you would have a sound similar to a 'tick' on a CD every 20 minutes, something that is iritating at worst.

Anyway, there is no 'canned code' that will do this for you, so you might have to get your compiler out and write the program yourself, so good luck, audio device programming is a pain in the butt.

Regards,

Nick.

From: "reuben firmin" <reuben.firmin@xxxxxxxxx>
Reply-To: A list for linux audio users <linux-audio-user@xxxxxxxxxxxxxxxxxx>
To: "Sampo Savolainen" <v2@xxxxxx>
CC: A list for linux audio users <linux-audio-user@xxxxxxxxxxxxxxxxxx>
Subject: Re: Outputting same sound source to multiple cardssimultaneously
Date: Wed, 10 Jan 2007 08:38:15 -0800

On 1/10/07, Sampo Savolainen <v2@xxxxxx> wrote:


Example: Just after 10 seconds, the 1st card in my example will be
emitting
sample 441010 (44101 * 10), and the other card will be emitting sample
440300 (44030 * 10). This means that if the original audio has been
recorded
at exactly 44100, the cards are already 0.016 seconds apart from
eachother!
(44030 is an example of a really crappy clock chip on a card, but it's not
unheard of)


OK, so what is the workaround? Couldn't the card that is behind be made to
catch up between songs? Couldn't every 1000th sample be dropped on the
crappier card? Etc. In any case, in your example, the cards would be about 1
second out of sync for every 20 minutes of play time. In my use case, this
really does not matter, as, again, the speakers are in different rooms. If
the software can be made to cope (which it surely should be made to, if the
problem is as prevalent as you describe) then afaic there is no problem.

Let me re-iterate: Without syncing the soundcards, this /will/ happen. This
is not a legend or some far-fetched possibility that people speak of but
which really never affects real life.


I touched on this above. So how do I sync the cards? Is there a specific
method to do this with alsa?

Just imagine two wall-clocks. Can you really expect them to keep the exact
same time over years of continuous running without anyone re-setting them?


If they were hardware being run by the same software on the same PC then,
yes, I would expect them to (be made to) stay in sync, regardless of their
mechanical quirks.

Cheers
Reuben

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux