AudioBlock Constructor bug?

Hi there,
I think this jassert is wrong in the AudioBlock constructor:

AudioBlock (AudioBuffer<SampleType>& buffer, size_t startSampleIndex) noexcept
    : channels (buffer.getArrayOfWritePointers()),
      numChannels (static_cast<ChannelCountType> (buffer.getNumChannels())),
      startSample (startSampleIndex),
      numSamples (static_cast<size_t> (buffer.getNumSamples()) - startSampleIndex)
{
    jassert (startSample < numSamples);
}

Let’s assume I’ve got an AudioBuffer of size 8 and I want to construct an AudioBlock which reads starting from sample 6. numSamples would be 2, which is correct. However the jassert will throw an exception - is that on purpose? Why? I think it should be:

jassert(numSamples > 0);

This has been fixed on the develop branch here.

1 Like