Constant DC output on plugin (resolved)


#1

Hi all, this is most likely a fundamental misunderstanding or some stupid random mistake I’ve made somewhere as I’m pretty new to JUCE and plugin development in general.

So my problem is that I’ve made a simple distortion plugin using the projucer template for audio plugins and it seems to function ok (audio in, audio out, some distortion). However, there is a constant output wether audio is running through or not of a non-audible signal passing through the plugin that is being processed like a DC offset.

This also causes an audible click to be heard on adding the plugin and switching it on and off. Also a “clicking” like sound is heard on adjusting the sliders on the GUI.

I’ve included my code from the main processing block below and I am unsure wether the issue stems from using both an input and output pointer, or wether its the processing itself that I have attempted.

    for (auto channel = 0; channel < totalNumOutputChannels; ++channel){
    auto* channelData = buffer.getWritePointer (channel);
    auto* InputData = buffer.getReadPointer(channel);
    
    for (int currentSample = 0; currentSample < buffer.getNumSamples(); ++currentSample)
    {
        //Do processing
        //try chebychev 2x^2 - 1
        channelData[currentSample] = ((LevelValue * ((InputData[currentSample]))
                                      + (LevelValue * DistortionValue * (2 * pow(InputData[currentSample], 2) - 1))))/2;
    }
}

Any feedback will be most appreciated!


#2

Can you elaborate a little bit about what you tried? There’s a certain art of how to ask for help on the internet and people are more likely to help you if you ask well.

Some problems here is that your code example is partial. Where does LevelValue or DistortionValue come from?

Another issue is that things in the code needlessly make it hard to spot the issue. What’s ((InputData[currentSample]))? Was it supposed to be InputData[currentSample]?


#3

Apologies for the messy code, I should of cleared it up a little bit before posting.
Level Value and DistortionValue are values declared elsewhere to take parameters from the GUI.

So I’ve realised my fundamental flaw in processing the audio. Turns out that leaving the -1 on the end has led to a constant stream of offset values being output if there is nothing passing through my plugin, hence the clicking and inaudible levels being passed through!


#4

I believe the issue is with this part of your equation: (2 * pow(InputData[currentSample], 2) - 1).

Even if your input data is 0 you will end up with a value as 2 * 0^2 - 1 = -1.

channelData[currentSample ]= (levelValue * distortionValue * -1 )/ 2

You will therefore always get a signal unless levelValue and/or distortionValue are equal to 0. I have taken out (levelValue* inputData[currentSample]) as I am assuming a 0 value for currentSample in this case.

EDIT: Sorry have just seen your last post that you found the issue