[linux-audio-dev] De-interleaving

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

Subject: [linux-audio-dev] De-interleaving
From: Paul Winkler (pw_lists_AT_slinkp.com)
Date: Thu Jun 13 2002 - 23:42:55 EEST


Something's odd here...
I'm trying to de-interleave the stereo output from sfront
into discrete channel buffers suitable for jack. Everything's
fine when number of channels = 1; but when it's 2, it seems
that I get the left channel in both outputs. I've confirmed
that the left and right outputs are different when running
with oss audio output instead of jack.

I have a buffer called tempbuf, which contains nframes channel-interleaved
sample frames. Call it tempbuf. e.g.:

long nframes;
long nsamples = nframes * ASYS_OCHAN;
/* ASYS_OCHAN is the number of channels */

float* tempbuf = (float*) calloc(nsamples, sizeof(float));

next, I set up an array of buffers into which I want to put
the deinterleaved output:

float* obuf[ASYS_OCHAN];

for(i=0; i < ASYS_OCHAN; i++) {
        obuf[i] = (float*) calloc(nframes, sizeof(float));
        /* actually I use jack_port_get_buffer() instead of calloc... */
        /* and actually there are various typedefs in use, not float */
}

That's all fine, as far as I can tell. Now here's the de-interleaving
code:

for(i=0; i < nsamples; i++) {
        obuf[i % ASYS_OCHAN][i / ASYS_OCHAN] = tempbuf[i];
}

The effect this *should* have (when ASYS_OCHAN = 2):

obuf[0][0] = tempbuf[0]
obuf[1][0] = tempbuf[1]
obuf[0][1] = tempbuf[2]
obuf[1][1] = tempbuf[3]
obuf[0][2] = tempbuf[4]
obuf[1][2] = tempbuf[5]
...

... but I'm hearing the left output on both channels.
Have I made some silly mistake in the de-interleaving?
Any other ideas on what I could've done wrong?
Complete actual code attached if anyone wants to see more
context...

-- 

Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"



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

This archive was generated by hypermail 2b28 : Fri Jun 14 2002 - 00:07:47 EEST