I am almost done my second of three major synths, but I have encountered a quirk I can’t understand.
I am using the JUCE synthesiser class. I have a distortion module which is essentially just an oversampled tanh/atan function. I can run this on a per sample basis in SynthVoice.h (my synth voice for polyphonic distortion). I can also run this in PluginProcessor.cpp without any quirks using a function like this to render blocks:
void renderNextBlockMono(AudioBuffer<float>& bufferIn)
{
float* chanbuf = bufferIn.getWritePointer(0);
for (int j = 0; j < bufferIn.getNumSamples(); ++j)
{
chanbuf[j] = getNextSample(chanbuf[j]);
for (int i = 1; i < bufferIn.getNumChannels(); ++i)
{
float* chanbufcopy = bufferIn.getWritePointer(i);
chanbufcopy[j] = chanbuf[j];
}
}
}
Where getnextsample runs the distortion on each sample.
However, when I move the same function to the Synthesiser area, it starts acting very strangely. If I feed it 0 velocity signals that don’t make noise in any other part of the synthesiser, it crackles in response. As if it is receiving MIDI values somehow into it directly.
I have confirmed this isn’t just an amplification of crackling occurring somewhere else in the project, because as I said it doesn’t do this even with the same distortion placed in other places.
So I’m wondering if there’s something about the audio buffer in the Synthesiser area that would be causing me problems. Does it have some other type of data like MIDI somehow in there as well at this level that would need to be stripped out?
This is my “SynthesiserInherited” relevant function:
class SynthesiserInherited
: public Synthesiser,
public AudioProcessorValueTreeState::Listener
{
public:
....
//BLOCK BASED PROCESSING OF VOICES
void renderVoices(AudioBuffer<float>& outputAudio,
int startSample, int numSamples) override
{
//BASE
Synthesiser::renderVoices(outputAudio, startSample, numSamples);
//MONOCOMP
if (monoCompOnOff) {
monoComp.render(outputAudio, startSample, numSamples);
}
//DISTORTION
if (monoDistOnOff) {
monoDistortion.renderNextBlockMono(outputAudio);
}
//DELAY
if (delayOnOff) {
monoDelay.renderNextBlockMono(outputAudio, delayTime, delayFeedback, delayPrePostMix, delayDWMix);
}
How on earth could MIDI data be getting into the monoDistortion here to trigger crackling? It seems very much to be coming from there because if I turn off the monoDistortion, no matter how much I apply distortion in other levels of the project (or turn up the volume), there is no such similar crackling.
I am using a midi guitar and if I just tap on the keys it makes 0 velocity “notes” that are causing this monoDistortion to crackle. But there is absolutely no sound made by the synth if I do the same thing with monoDistortion off, even with the volume as high as possible, or with the same distortion applied in other areas.
Is this crazy or what?
Thanks for any help.