April 18th, 2013, 06:05 AM
Create new array, the fast way
I have a buffer of binary data (void*) of known length in bytes.
This buffer contains a chunk of audio data, stereo samples which are interleaved. So the buffer of audio data is essentially of the form -
[L R L R L R ...]
Where L is a left sample, and R is a right sample.
This audio data is placed in a circular buffer as raw binary data at the producer end, and re-interpreted as Signed Integer of 32 Bit at the Consumer end.
I would like to add some extra information to my initial buffer at the producer end. Essentially I would like to add an additional 'channel', though this will essentially be timing information.
So my buffer will become -
[L R X L R X L R X ...]
Where X is the timing information.
I have used an initial for-loop, to iterate over the buffer and populate a new array with the data. However it is too slow for real-time audio work.
Is there a fast way to create a new array from an existing array i.e to perform the following quickly -
[L R L R L R ...] -> [L R X L R X L R X ...]
Thanks for any tips!
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.