[music-dsp] fx architecture: Interleaved or flat samples..

robert bristow-johnson rbj at audioimagination.com
Wed Oct 20 01:13:50 EDT 2010


On Oct 19, 2010, at 4:49 PM, Nils Pipenbrinck wrote:

>  I wonder in which order you keep your sample buffers in memory?
>
> Do you usually work with a single buffer containing the samples of all
> channels interleaved (e.g. how the data usually gets delivered from  
> the
> codec) or do you split the buffers and work on a 'per channel basis?
>
> Any pros/cons/ideas about that?


i can't think of any pros to leaving the samples interleaved for  
processing.

i always try to write algorithms in a context where many samples (in a  
sample "block" or "chunk") is processed at a time for each component  
(delays, filters, non-linear, etc.).  these blocks can be as small as  
4 or 8 samples or as large as, i dunno, 1024 samples (or larger, but  
then delay becomes noticeable).  this processing code is either  
interrupted by the codec interrupt request (that inputs and outputs a  
single sample to the codec or whatever) or there may be (like in the  
SHArC) a DMA of some kind.  that interrupt routine is expecting the  
samples to be interleaved in the I/O buffer.

but the task of de-interleaving the I/O buffer to the sample blocks  
(and re-interleaving back out) is not wasted code.  it has to be  
swapped anyway (at the beginning and ending of a sample block period)  
so that the processing code inside can be completely unaware of and  
independent of where in the I/O buffer the codec interrupt I/O pointer  
is.  as long as you're moving samples in and out of the buffer, you  
may as well de-interleave going in and re-interleave going out as well  
as scale the input and scale (and mix with the dry input) the output  
as the samples are being passed around.

then the code for the processing components (you know, the little  
delays and filters and whatever else is in your "secret sauce") is  
always working on a single signal channel and need not worry about  
whether or not it's interleaved (because it never is) and what the  
interleaving "stride" is.

--

r b-j                  rbj at audioimagination.com

"Imagination is more important than knowledge."






More information about the music-dsp mailing list