Hi, this is my first post. I’m pretty new to JUCE, but I at least thought I was more comfortable with programming and c++ to have this much trouble. I am learning to write VST plugins.
I am writing a simple delay effect, in order to learn, stepping up the complexity a bit at a time. I managed to get a delay-effect working (without anything user-changable, and pretty much all parameters hard-coded), once i finally figured out that i was sending data from both channels to the same place.
Now i have started from scratch, using my own class for processing the delay-effect instead. The problem is that I get the same noise or distortion as when i was sending both channels through the same processing unit, but I really don’t think I am doing that still. I suspect I am doing something obviously wrong (since it is still really simple), so any pointers is very appreciated.
This is the code that is added to the processBlock. First the delay and then a volume-control.
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float* channelData = buffer.getWritePointer (channel);
delayBlock [channel].process(channelData, buffer.getNumSamples());
for(int sample = 0; sample < buffer.getNumSamples(); ++sample)
{
channelData[sample] = channelData[sample] * outGainFactor;
}
}
This is the class i wrote for the delay processing.:
DelayModule::DelayModule()
{
for (int i = 0; i < bufferSize; ++i)
{
delayBuffer [i] = 0;
}
readHead = 100;
writeHead = 0;
}
void DelayModule::process (float* channelData, int numSamples)
{
for (int sample = 0; sample < numSamples; ++sample) //write samples to buffer
{
delayBuffer [writeHead] = channelData[sample];
writeHead = (++writeHead) % bufferSize;
}
for (int sample = 0; sample < numSamples; ++sample) //write processed audio back to channel
{
channelData[sample] = channelData [sample] + delayBuffer[readHead];
readHead = (++readHead) % bufferSize;
}
}
Thanks!