AudioSampleBuffer operator=


#1

Hi to all,
I need to keep a copy of the input AudioSampleBuffer of the VST plugin, so the editor can draw a waveform preview.

So I instanciate an AudioSampleBuffer in the prepareToPlay method:

void MyFilter::prepareToPlay (double sampleRate, int samplesPerBlock)
{
  ...
  deleteAndZero(m_pLastInputBuffer);
  m_pLastInputBuffer = new AudioSampleBuffer(m_nInputs, samplesPerBlock);
  ...
}

In the proceccBlock callback I do as follows:

void MyFilter::processBlock (const AudioSampleBuffer& input, 
                              AudioSampleBuffer& output,
                              const bool accumulateOutput,
                              MidiBuffer& /*midiMessages*/)
{
  m_pLastInputBuffer->clear();
  *m_pLastInputBuffer = input;
  ...
}

The plugin crashes in the memcpy call inside the copy constructor code.
I’ve notified that input.allocatedData is NULL.


#2

ooh - yes, there seems to be a bug in operator=

Sorry about that, I’ve checked in a fixed version now. Thanks for spotting it!


#3

Thanx Jules for the fix


#4