Adding harmonics

Hello. New member looking into making a plugin. Does Juce have any existing methods to add harmonics to a signal for use as a plugin in protools or logic. The goal is to add specific harmonics and set the amplitude of each harmonic added with a knob or slider and save the preset. There is no other goal for my first experiment other than this.

Is there a resource to hire a consultant to discuss the idea and viability of my goal and assist making a prototype?

Thanks.

You would most likely want to look into making some kind of waveshaping function, possibly polynomial waveshaping?

As an example of you had a 100hz sine wave going into the plugin and you changed the sine wave to 200hz that would give you the second harmonic. 300hz gives you the 3rd. Then have a way to adjust the volume of each harmonic individually. Ideally achieve at least 800hz out of 100hz fundamental. Granted this is for illustration. You don’t want what is coming in the plugin but the math works the same for whatever comes in. I could give another analogy of pitch shifting 100hz up 1 octave.

So you want to pitch shift the plugin’s input to each desired harmonic?

Or do you want to take the input signal & adjust the relative amplitudes of the frequency bins corresponding to each of these harmonic bands…?

1 Like

I want to input any signal and have control over which harmonics are added as well as amplitude of which are added. I don’t know if pitch shifting is how people are making plugins that add harmonics, but the end result is that on all that I test with using sine waves as the fundamental the effect is x2, x3 etc. the photo shows a 100hz sine wave going through a UAD plugin that adds harmonics. So you see 200 300 400 500 600 sine waves added by the plugin. I want separate control of what’s added.

I hope this helps explain. I know electronics and coding for microprocessors but not fluent C++

1 Like

This is not archieved by pitchshifting. You apply nonlinear processing to the signal.

You want to turn Waveform (a) into Waveform (b)

image

Maybe check chapter 19 of Will Pirkles “Designing Audio Effect Plugins in C++: For AAX, AU, and VST3 with DSP Theory” to understand the concept

have control over which harmonics are added as well as amplitude of which are added.

should be possible

1 Like

Thanks for the reference. I’ll check it out.

Does anyone on here offer hourly zoom? I’d like to get a quick overview and prefer to have someone walk me through the basics and run and example, build, run on protools to see the flow.

the basics are just this:
for each sample:
sample = tanh(sample);

experiment with different waveshaping functions to find out how they affect the harmonics. beware that this process (distortion) can add aliasing and intermodulation if some harmonics are above nyquist. but honestly don’t fiddle with that before getting the basic functionality done, because it’s a lot

Thanks. Generally speaking you cannot selectively add specific harmonics with a distortion or saturation Method, which is why I am experimenting with pitch shifting. With pitch shifting I can replicate a specific harmonic since a harmonic is a multiple of the original sound. X2 x3 etc. When you square a wave off you inherently produce lots of odd harmonics. If you simulate tubes you add a degree of even and odd. If you use asynchronous voltage offsets up or down you can produce even or odd. But you cannot add a specific harmonic. Since I have simulated what I want to accomplish using pitch shifters in series My first task is to learn how to create a pitch shift function. When I can shift a sound +12 semi or 1 octave then I will find out out to put 2-5 of them in series to achieve around 10 octaves. Next have a separate knob to set the level for each shifter. I’m not suggesting wave shaping won’t work so I’m open to testing that. Ideally find someone that can spend some time on zoom. I know Xojo very well and other coding platforms.

1 Like
1 Like

yeah, I thought you meant pitch shifting :slightly_smiling_face:

the thing is, if you duplicate + pitch-shift your original signal to each new desired frequency for each harmonic you want to add, you’ll end up with a composite output signal that’s more like a “choir” of the original sound, rather than a signal recognizable as only the original input with extra frequencies added.

To illustrate this point, the process of “take input signal & shift it to a bunch of desired fundamental frequencies” is exactly how Jacob Collier’s vocal harmonizer works: Hide and Seek - Jacob Collier [Live at House] - YouTube

Notice how the output sound definitely has the characteristics of a “choir” of voices, rather than sounding like Jacob’s voice with more frequencies added.

if pitch shifting is what you want, I may be able to help you, since I’ve done quite a bit of research in this area.

But I dunno if that’s really what you’re going for.

Thanks. Pitch shift sounds good on pure sine waves but not good on anything else. But it was a good way to show the idea of separate harmonic control. So it won’t work. I don’t know if the idea is achievable as I’ve never seen it done to separate out a harmonic. Ideas welcome! I’d be happy to pay for a bit of advice to get started.

Do you mean that pitch shifting things other than sine waves doesn’t achieve your desired result, or that the quality is too low?

Because it’s certainly possible to develop robust, higher-quality pitch shifting algorithms that are better at maintaining the timbre of the original signal.

But if pitch shifting is simply not achieving your desired result, then waveshaping is probably the way to go.

Thanks for the stack ex link. I don’t know enough to understand it but maybe someone can help me that understands if it has promise.

Pitch shifting anything other than pure sine waves sounds bad In terms of faking harmonics. I tried it just now in vocals and it’s bad. You are transposing 1 octave just for the second harmonic

right. but what pitch shifter are you using? chances are, it’s just not a high-enough-quality pitch shifting algorithm.

What I’m trying to figure out is, if you had a pitch shifter that’s super high quality, like at the level of Jacob Collier’s harmonizer, that could perfectly reproduce the input sound at the desired frequencies, would that be what you want?

Because that is possible. But it would give you a choir-like sound, because you’re recreating the entire sound at each new pitch. So I’m trying to figure out if that’s what you want or not.

I tried autotune with no formant. Also tried little alter boy but found out it adds tons a of harmonics even when doing nothing.

I wouldn’t say choir is the goal. However when you add a second harmonic, it is a doubling of the original frequencies. 1 octave up. pitch shifting 1 octave isn’t the same result somehow.

OK, that’s what I was trying to figure out. It sounds like you’ll want some sort of waveshaping function, unfortuantely that’s not really my area of expertise.

This is because your original signal contains an entire spectral envelope – fundamental frequency, whatever harmonics are already present, and probably some noise content – and a pitch shifter shifts this entire signal. So pitch shifting up one octave will reproduce the original fundamental, and the original harmonics present, and the original noise content all up one octave.

It could be possible to isolate just the original fundamental frequency before pitch shifting, which would give you more of a “pure” shifted frequency.

The issue here is that a “harmonic” naturally produced by an acoustic instrument is not an exact copy of the fundamental frequency at a different pitch, it’s more of an acoustic resonance that produces additional frequencies, but also has an auditory effect on the fundamental frequency itself.

It’s possible waveshaping is the answer. You could also look into physical modeling synthesis, to model the ways that an acoustic signal would resonate with its harmonics… ¯_(ツ)_/¯