Add odd/even harmonics to a signal through distortion


I’ve searched for answered for 3 hours and I can’t find clear resources on this topic.

I am trying to implement a distortion/saturation effect in JUCE. For that, I’d like to implement an algorithm that could produce the same results than in this article:

Do you know how I could do that? I’m not sure that’s something that could be done directly with the WaveShaper class, since we need to analyze frequencies with a FFT first (but I’m maybe wrong) and then boost only odd or even harmonics. I’m lacking experience in audio engineering yet.

Thanks for your help :slight_smile:


I’d check out a graphing tool like desmos to play with algorithms in a cool visual way. Even harmonics can be made with a simple y = x^2, and odd with y = x^3. This holds true as you keep raising the power, odds stay odd, evens stay even.

Thanks, that’s a great news because I was really afraid of FFT implementations & performances issues. Actually, I need to understand how it is possible to add odd/even harmonics without determining the fondamental with an FFT, because it is dependent on the fondamental I guess?

I will write Python scripts to try different functions and prototype something simple with numpy before implementing anything with JUCE.

I don’t think it’s possible to accurately discern which are even and odd harmonics of a signal

For example, a saw wave can contain all the harmonics, but it could also be the same wave with twice the frequency with the even harmonics removed. And what if the sound is inharmonic? What about the noise? Those overtones will be intermediate.

If it was a synth waveform generator it would be very easy with additive synthesis, but as an effect, I think adding harmonics to a signal will produce misplaced beeps and artifacts. But it’s just an opinion, I’ll follow the thread to see if you can achieve it and show us the results

Thanks for the answer.

I found a repo of a JUCE plugin that does what I want: GitHub - spensbot/crispy: An Audio Saturation Plugin (VST/AU) made with JUCE

Unfortunatly, the author does not provide the saturation algorithm… I think it’s in a separate module. The README is interesting because he says he removes artifacts with oversampling.

I think the algorithm is in the stm-juce-modules repository (/stm_dsp/processors/stm_Saturation.h)

I found it thanks!

Now I need to understand how to integrate it :smiley: