Hi everyone,
I am currently developing a synth that has its processing part coded in Faust (you don’t need to understand Faust to help me ). The plugin consist of 9 oscillators, each having some basic parameters (like : gain, pan, active/notActive, waveform type, etc…) and several effects (like : distortion, compression, etc… ). The Faust part has already been coded, which means I have a cpp file that contains a class representing a single oscillator.
What I do for the moment, is that I create 9 instances of the class, I compute the sound that each oscillator make and then I add them up. Like so :
void FAUST::processBlock(juce::AudioBuffer<float>& buffer, int totalNumOutputChannels)
{
juce::ScopedNoDenormals noDenormals;
int numSamples = buffer.getNumSamples();
float** o1 = osc11Faust.processBlock(numSamples);
float** o2 = osc12Faust.processBlock(numSamples);
...
float** o9 = osc33Faust.processBlock(numSamples);
for (int channel = 0; channel < totalNumOutputChannels; ++channel)
{
for(int i=0; i<buffer.getNumSamples(); i++)
{
*buffer.getWritePointer(channel,i) = o1[channel][i] + o2[channel][i]; + o3[channel][i]
+ o4[channel][i] + o5[channel][i] + o6[channel][i]
+ o7[channel][i] + o8[channel][i] + o9[channel][i];
}
}
}
The issue is that there is a super annoying clicking at the start of a chord when I press more than 2 notes at the same time. Since the results of the different oscillators are independent, I though it would be a good idea to make them run on different threads. I’ve looked at the juce::Thread class and what I’ve come to understand from that is that I should make all the oscijFaust
objects inherit from Thread and put the function processBlock(int numSamples)
in the run function. But then how can I know when each process has finished? And how can I share the float**
between all the threads?
I am also interested in knowing if the threads are actually going the help me get rid of the clicking. If someone has another idea of how I could do I would very much appreciate.
Romain.