Creating an audio plugin. getReadPointer returns null pointer?


I was getting started with some of the examples on writing a audio plugin. My problem is that when I call buffer.getReadPointer in my processBlock, it returns a null value.

Here is the code.

void FishTankAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
	const int totalNumInputChannels  = getTotalNumInputChannels();
	const int totalNumOutputChannels = getTotalNumOutputChannels();
	// If it ever becomes the point that there are more ouputs then inputs,
	// Then regenerate this file, and see what they did for that sitch :)
	// This is the place where you'd normally do the guts of your plugin's
	// audio processing...
	// Set up variables
	//AudioSampleBuffer mainInputOutput = busArrangement.getBusBuffer(buffer, true, 0);
	float sr = m_sampleRate;
	for (int chan = 0; chan < buffer.getNumChannels(); chan++)
		for (int samp = 0; chan < buffer.getNumChannels(); samp++)
			// Test values
			float testReadPointer = buffer.getReadPointer(chan)[samp];
			float testValue = calculate(buffer.getReadPointer(chan)[samp]);
			// Actual code.
			buffer.getWritePointer(chan)[samp] = calculate(buffer.getReadPointer(chan)[samp]);

Does anything appear to be abnormal, or could there be a problem elsewhere? Thanks!

…Ahem… Polite cough… :slight_smile:

Well that is an embarrassing mistake. Even after fixing the loop the value I get for testReadPointer is 0.000 according to my debugger.

Can you post your fixed code again?

…looks like the expected behaviour to me, if there is silence on the channel… what did you expect?