Consider the declaration of AudioSourceChannelInfo:
struct JUCE_API AudioSourceChannelInfo
{
AudioSampleBuffer* buffer;
int startSample;
int numSamples;
};
There is no convenient way to construct an AudioSampleBuffer that points only to the data described by the AudioSourceChannelInfo. What is missing, is the following constructor for AudioSampleBuffer:
AudioSampleBuffer (
float** dataToReferTo,
int numChannels,
int startSample,
int numSamples) throw();
If we had this constructor we could do this:
void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
AudioSampleBuffer destBuffer (
bufferToFill->buffer->getArrayOfChannels(),
bufferToFill->buffer->getNumChannels(),
bufferToFill->startSample,
bufferToFill->numSamples);
int samplesToWrite; // calculate this
// advance destBuffer
destBuffer = AudioSampleBuffer (destBuffer->getArrayofChannels(), destBuffer->getNumChannels(), samplesToWrite,
destBuffer->getNumSamples() - samplesToWrite);
// ...
}
Or, for clarity, we could have this constructor
AudioSampleBuffer (const AudioSampleBuffer& other, int startSample);
Now to advance destBuffer we need only do
destBuffer = AudioSampleBuffer (destBuffer, samplesToWrite);
If we want to overengineer it we could provide operator + (int deltaSamples) and so on and so forth.
