The first harmonic is the fundamental...
If you mean the second harmonic or first overtone then you mean an octave.
The usual analog way of adding an octave is to rectify the signal -- which adds much more than just the first overtone but that plus filtering it about all you can do in analog.
There are other options but -- as I understand things -- none are simple.
Here some code that rectifies (take the absolute value), removes the DC offset and expands back to full range.
- Code: Select all
out = 2 * abs(in) - 1;
A lowpass will remove some
of the other overtones this will add.
Yeap, I was talking about the second harmonic, Sometime I'm stuck with the musician theory where the second acoustic harmonic is the first musical one. Big Sorry!
I'm not afraid (yet) to enter into complicated low level coding, after all, I'm doing this for as a "final project" in my place of study; so I'm already prepare to take the hard path, It's just that somethings are managed in a different way in SW, so It's very possible that I will be posting a lot of stuff here
I will take a look of your code and tried. Thanks!
martinvicanek wrote:Hey distante,
to get the amplitude of a signal you would use an envelope follower, which is basically a rectifier followed by a lowpass. Look at the stock module, there is a codeblock inside which you can examine.
Frequency or pitch extraction is a bit more tricky. If your signal is single-pitched with a dominant fundamental, then the zero crossing method is most efficient. Search for "zero crossing" on the forum, Trog has posted a ready-to-use module. There are alternatives based on autocorrelation, where you compare the original signal with a delayed version. If you can find a delay time where the signal essentially folds back on itself, that will give you the (inverse) frequency. These methods are more CPU demanding than zero crossing however they may perform better on signals with rich spectral content.
Hope that helps!
In the end I want to run a real time vst (as in insert in a DAW) with this "harmonic generator" in a channel with some musical content , so I supposed that the delay stuff isn't the best option (I need to read it first). I will look for zero crossing and mess with the stock module thanks!
I hope what I want to do is possible with SW, If not I will need to change my project request