Chorus Clipping noise

Hi everyone, I am trying to write my own Chorus class, and it is a month now that I am stuck on some wired glitchy clipping noise each time I do my sample processing. In the following example I used my own delayline class that is working just right, but i think something is wrong, something in the LFO calculation just is breaking everything…


float processSample(const int channel, const float inputSample)
    {
        m_currentPhase += m_phaseIncrement;
        m_currentPhase = std::fmod(m_currentPhase, juce::MathConstants<float>::twoPi);
        m_oscTime[channel] = std::sin(m_currentPhase + channel * juce::MathConstants<float>::halfPi) * currentDelayMod() / 2 + m_centreDelay;
        
//        DBG("channl::" << channel);
//        DBG("test::" << m_oscTime[channel]);
        const float delaySamples = DelayLine::timeToSamples(m_oscTime[channel], m_sampleRate);
        m_delayLine[channel].setDelay(delaySamples);
        float outputSample = m_delayLine[channel].processSample(channel, inputSample);
        return outputSample;
    }

I am trying to learn, maybe is not the best code, but I’m pretty proud of it because it has been made without any external help, it means a lot to me. I wouldn’t be asking any help if I didn’t even tried to understand the error, but i think is something bigger than me… Thanks in advance to anyone that can help!

it might have something to do with the fact that you move forward with the increment value in both channels. you use the channel value to add a phase offset to channel 1, which is probably a good stereo effect, but the increment should not increase for each channel i think

I’m not sure if there’s enough code to figure it out. One thing I sometimes do when the audio is not right is record it with Audacity or my DAW and inspect the waveform, to gather information on the anomaly, which often helps point out what’s going on. You’re looking for patterns of weird behavior, often patterns of suddenly vertical lines, but if it’s clipping, you’re looking for clipped tops of waves. Since it occurs only sometimes, finding the pattern of when it occurs is important.

1 Like