Diagnosing introduction of noise in signal

Hi, I am working on a soft/hard clipper plugin, it is almost finished but today I was doing some testing and found that my clippers process() method was introducing a lot of noise. The test I did consisted simply of feeding a low level sign into my plugin (around -30 to -40dB) and then turning the gain back up. This produced some very horrible artefacts/noise and they dissapear when I remove “clipper.process()” from the process block.
Here is the code inside the Clipper process method:

void Clipper::process(juce::dsp::AudioBlock<float> buffer) {
    //a look up table that holds the waveshaper, it has 8192 data points.
    auto waveshaper = shaper.getWaveShaper();
    for (int c = 0; c < buffer.getNumChannels(); c++)
    {
        auto channelData = buffer.getChannelPointer(c);
        for (int n = 0; n < buffer.getNumSamples(); n++)
        {
            //normalise the current sample
            float sample = channelData[n] / threshold;
            //calculate index from sample (the index of the waveshaper represents an input of 0.0f to 2.0f) an input value of 1 indicates the threshold
            int index = std::floor(std::abs(sample) * 0.5f * static_cast<float>(shaperSize));
            //clamp index
            int lookup = juce::jmin(index, shaperSize - 1);
            //un-normalise and apply sign
            channelData[n] = threshold * (waveshaper[lookup] * ((sample > 0) - (sample < 0)));
        }
    }
}

The reason for normalising is that for low values of threshold, the waveshaper would hold a small number of data points for its linear region (I hope that makes sense). I am very confused, however, where noise is introduced in the signal. Could I be losing precision somewhere? What strategies to people have for finding/reducing noise?
Would love to know peoples thoughts.
Cheers

Causal look makes me think maybe you are needing to interpolate here? The integer lookup in a waveshaper[] is suspicious?

Ah yes i feel a bit silly really.
Interpolation is pretty darn good .

1 Like