Bad Access when setting sample rate - Synth

I am trying to create a synth. There is a Bad Access Error pointing to this peice of code below where the sample rate is set to sr,

sr = 44100 set in a function just above.

void OscillatorBase::setSampleRate (float sr)
    sampleRate = sr;
    setFrequency (frequency); //just to update the phaseInc

In the audio class, an instance of the oscillator base class is called like so:

Atomic<OscillatorBase*> oscillatorBasePtr;

Along with the error, this is shown as:

this OscillatorBase * NULL 0x0000000000000000

I believe it’s an issue with the way the classes are communicating. I have the correct #includes in place etc. Any input is much appreciated.


Apparently you never assign a new instance of the oscillator into the pointer? It’s impossible to say anything more based on the information you have provided so far.

This line assigns a new instance within the audio .cpp file

oscillatorBasePtr = new SinOscillator;

OscillatorBase is a base from which SinOscillator inherits. OscillatorbasePtr is an instance of a SinOscillator.