Hi everyone!
I feel rather stupid asking this, but:
I’m trying to implement a very simple sine oscillator (not caring about performance or aliasing yet), and I’m stumbling on a problem:
As you can see, it isn’t a continous sine wave.
My guess it has something to do with the buffer ‘resetting’, and my sine wave starting again from naught.
My code (in processBlock):
void GirafficSynthAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples());
//float* samplesL = buffer.getWritePointer(0); //float* samplesR = buffer.getWritePointer(1);
float samplerate = getSampleRate();
const int numSamples = buffer.getNumSamples();
for (int i = 0; i < numSamples; ++i) { buffer.setSample(0, i, sinf((2 * float_Pi / samplerate) * frequency * i)); buffer.setSample(1, i, sinf((2 * float_Pi / samplerate) * frequency * i)); }
}
Does anyone have some input on this? I’ve googled a ton already without much succes.