Discussion:
stereo channel splitting
Philipp Kraus
2012-08-09 09:03:18 UTC
Permalink
Hello,

I read with
alcCaptureSamples(m_device, (ALCvoid*)(&l_buffer[i]), l_samplesread);
data into a vector (blocking call till the vector stores vector.size()
samples).

On mono signals everything works fine and now I would like to add
stereo support.
I have found, that the i-th sample in the vector is the left channel
and the (i+1)-th sample
the right channel. Is this correct?

So if I have read my vector how can I seperate the left / right
channel. Can I used a alc function
or should I split it manually?
I think on a manual splitting I need a "(sample not read of the buffer
before + position) % 2" are for the left channel.

Thanks

Phil
Chris Robinson
2012-08-10 03:26:34 UTC
Permalink
On mono signals everything works fine and now I would like to add stereo
support.
I have found, that the i-th sample in the vector is the left channel and
the (i+1)-th sample
the right channel. Is this correct?
The samples are interlaced and alternate between left and right, yes. 0
is left, 1 is right, 2 if left, 3 is right, etc.
So if I have read my vector how can I seperate the left / right channel.
Separate in what way? Do you just need to address the channels
individually, or do you actually need to deinterlace the samples (so
left and right go into separate buffers)? If you just need to address
the channels individually, you can do:

l_buffer[(sample*2) + 0]; // left
l_buffer[(sample*2) + 1]; // right

to read the left and right channels of the given sample.

Continue reading on narkive:
Loading...