AudioSampleBuffer is a second-class citizen

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 (

  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.

+1, and then we don’t need AudioSourceChannelInfo anymore!
the same request -->

[quote=“chkn”]+1, and then we don’t need AudioSourceChannelInfo anymore!
the same request -->[/quote]

Oh yeah…I see what you mean, you pointed out the exact same problem.

It seems Jules has added the constructor which takes a sample offset, hooray!