Read access violation using AudioSampleBuffer::getWritePointer()

Not sure what this error really means or how memory management works at all, I’ve just been playing with some DSP algorithms and ran into this problem. The issue is in the process() function of a delay class I wrote, which works fine when used normally but when trying to use it inside a chorus class (to make the chorus effect) it throws this exception. Anyway if you have any advice that would be much appreciated.

    //get a pointer to the circular buffer
	float* buff = m_buffer.getWritePointer(0);

	//read the input, xn, from the incoming sample
	float xn = in;

	//read the output, yn, from the circular buffer at the read position
	float yn1 = buff[m_indexRead1];
	float yn2 = buff[m_indexRead2];

The exception happens at the float yn1 = buff[m_indexRead1]; line.

obviously m_indexRead1is out of the index range, use a debugger and look which value it has

Ok I guess that’s the problem, think I was feeding some negative numbers in there :man_facepalming:

Secondary question:
How do you use the Visual Studio debugger when debugging a VST inside a host?

Thanks!

In the plugin project properties set the executable (command) to use when debugging :

F5 will then launch the debugger and the host.

I suggest using the JUCE Plugin Host for initial development.

Rail

Pro tip: if it happened once, it will happen again. Add this line before:

jassert (m_indexRead1 >= 0);

That way it will stop in debug mode exactly at the right point, not just crashing eventually…