[MPlayer-dev-eng] First shot at surround on multiple soundcards
Anders Johansson
ajh at watri.uwa.edu.au
Fri Nov 22 02:11:34 CET 2002
Hi Kevin,
>
> Hi all,
>
> I made a first (bad) shot at playing >2 sound streams using different
> sound cards. It took me a while to get it to play at all, till I found out
> that I need to respect to smaller frag size of the ISA card. Yes, it even
> runs with an ISA card ;)
>
You will get a problem with the clocks: The sample rate is not
synchronized between the two cards, so over time the two playback
buffers will contain different amount of free space (it might take a
few minutes if you are unlucky). There are two ways to solve this
problem (neither good):
1. Buy two identical sound cards and remove the oscillator from one of
them and solder wires from the other one for the clock. Alternatively
buy sound cards that can take external clock (these are expensive
though).
2. Monitor the two buffers and calculate the difference in sample rate
and duplicate samples for the slower card. This solution is not great
either cause it will make the delay differ in time which screws up the
surround experience a bit. This can however be solved by combining
resampling and fractional delay. This will remove the problem but is
requires a lot of processing (fractional delay requires a Lagrange-
network to sound good).
> It seems that it runs in sync. When I play the same data on both channels,
> it runs. But my C is too bad, so I cannot separate the streams when I
> request more than 2. Here is my (horrible) hack to try this:
>
> tempbuf = data;
>
> for (temp=0; temp<len/4; temp++)
> {
> sndbuf1[temp*2]=tempbuf[temp*4];
> sndbuf1[temp*2+1]=tempbuf[temp*4+1];
> sndbuf2[temp*2]=tempbuf[temp*4+2];
> sndbuf2[temp*2+1]=tempbuf[temp*4+3];
> }
>
> All I get is static on the secondary card and the sound of the movie on
> the first card, but with clicking and real slow. If anybody could help me
> with separating the streams into two stereo streams they're welcome.
The problem might be that sndbufX is a char* it should depend on bps
(bytes per sample). Also you need to specify -channels 4 on the
commandline.
> Ok, I'm off to bed, its way after 4:00 am %)
>
> Cheers,
>
> Kevin
>
Good luck,
//Anders
More information about the MPlayer-dev-eng
mailing list