Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Creating (a single) harmonic

DSP related issues, mathematics, processing and techniques

Creating (a single) harmonic

Postby Rocko » Mon Jun 02, 2014 3:57 pm

Hi,

I'm looking into creating 'single higher harmonics' - no real value for this, just playing around :D

Background
The customary method for creating higher harmonics, is Chebyshev polynomials which is extremely handy, but it creates a 'pair' of harmonics for the higher ones, not just a single one...
Let me explain by an example...

Example
Let's assume I'm trying to create a 'third harmonic' only (general case, it could be the 'fifth harmonic' only as well) -
so that if the input is 'pure sine wave' at 100 Hz, the output would be a single, clean 300Hz.

I came across this extremely informational thread (on SM forum) - discussing the 'Chebyshev polynomials':
http://www.synthmaker.co.uk/forum/viewtopic.php?f=12&t=10265&st=0&sk=t&sd=a&hilit=chebyshev+polynomials&start=15
wikipedia:
http://en.wikipedia.org/wiki/Chebyshev_polynomials

Which is great, however I can not prodcue a 'clean' 3rd harmonic with it.
Here is why...

Assuming this code for third harmonic:

Code: Select all
streamin x;
streamout H;

//Define variables
float x2,x3;
//Define variables for harmonics
float H;

//supportive calculation
x2=x*x;
x3=x2*x;

//3rd harmonic (x3 the original frequency)
//This is based on chebyshev as shown in wikipedia
H = 8*x3-4*x;


the 'H' harmonic calculation obviously includes 'x' which is the original input. Looking at the output of 'H2' only on a 'spectrum analyzer' shows the harmonic with the original sine wave, while I'm interested in the harmonic only.

My question is how can I can I make the 'H' harmonic appear on 'spectrum analyzer' 'solo' without any other harmonics.
Is it possible?

Thanks,
Rocko
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: Creating (a single) harmonic

Postby tester » Mon Jun 02, 2014 5:12 pm

Maybe there are other ways, depends on applications.
Is the signal slow/fixed or fast/flowing across the spectra?
How many harmonics do you wish to follow?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Creating (a single) harmonic

Postby KG_is_back » Mon Jun 02, 2014 5:42 pm

You're doing it wrong... you must use Chebyshev polynomial of first kind - not of second.
So 4x^3-3x instead of 8x^3-4x

Also note, that input signal must be sinus in range <1,-1> otherwise you'll get just distorted sinus with fundamental frequency still present.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Creating (a single) harmonic

Postby Rocko » Tue Jun 03, 2014 9:04 am

Thanks for the answers...

tester wrote:Maybe there are other ways, depends on applications.
Is the signal slow/fixed or fast/flowing across the spectra?
How many harmonics do you wish to follow?


Well, it is a theoretical question, so let's assume the simplest case in which the input is a constant sine wave at 100 Hz, (-6) DbFS, never changing.
I would like the output to be 300 Hz (2nd harmonic) only. It could be 4th, 5th or other of course...

How is this doable?

Regarding "KG's" answer... well, the sine wave is limited to [-1:1] values only.
Please notice that the question is more theory related more than specific implementation.
One can notice that the Chebyshev formula's for higher harmonics include those for the lower harmonics (iterative), so it seems to me that this mechanism, can not produce a single clean high harmonic (like 3rd, 5th, etc.).

Please notice, first kind (similar in build to second kind):

T_0(x) = 1
T_1(x) = x
T_2(x) = 2x^2 - 1
T_3(x) = 4x^3 - 3x
T_4(x) = 8x^4 - 8x^2 + 1
T_5(x) = 16x^5 - 20x^3 + 5x
T_6(x) = 32x^6 - 48x^4 + 18x^2 - 1
T_7(x) = 64x^7 - 112x^5 + 56x^3 - 7x,
T_8(x) = 128x^8 - 256x^6 + 160x^4 - 32x^2 + 1
T_9(x) = 256x^9 - 576x^7 + 432x^5 - 120x^3 + 9x. ,
T_{10}(x) = 512x^{10} - 1280x^8 + 1120x^6 - 400x^4 + 50x^2-1.
T_{11}(x) = 1024x^{11} - 2816x^9 + 2816x^7 - 1232x^5 +220x^3 - 11x.


T_3 actaully include T_1 with a different gain, so it is bound to create the same harmonics as T_1. Isn't it?

Is this correct? If so, is there a way to create single high harmonics?
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: Creating (a single) harmonic

Postby tester » Tue Jun 03, 2014 9:12 am

Basically, as a non-programmer - I would use pitch tracking made by Martin, to find the fundamental = H1 (and maybe I would limit the H1 range with some LP filter, to track only H1), and then I would use graph and FFT graph prims, to get the spectra in green. Having H1, I can calculate where is it in spectra (indexes; at 16k resolution - this is max in stock FS prims), and then I can calculate other parts of the spectra (with some +/- tolerance), where harmonics are. Then I would calculate max values in these parts of the spectra, to get the amplitudes of my harmonics. And then - I can use individual harmonics on the display, the ones I desire.

Limitation of this method - pitch of the fundamental must be relatively stable versus amount of harmonics I can track relatively accurately.

Voice tracking?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Creating (a single) harmonic

Postby Rocko » Tue Jun 03, 2014 9:33 am

Here is another weird behavior of 'Chebyshev polynomials'...

Let's say I input the suggested signal (100Hz, pure sine wave, (-6 DbFS)) to create the first harmonic [200Hz].
The output is a clean 200 Hz as expected.

Now, if I cascade this 200Hz input to another 'chebyshev polynomial' module and output the first harmonic, the output is... 200Hz and 400Hz...
If I input a 200Hz to the second 'chebyshev polynomial' module only - the output is the expected 400Hz.

How does the system 'know' that in the first case, the sine wave is not original??
Attachments
Dual_Harmonizer.osm
(3.61 KiB) Downloaded 1317 times
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: Creating (a single) harmonic

Postby KG_is_back » Tue Jun 03, 2014 10:50 am

Rocko wrote:T_3 actaully include T_1 with a different gain, so it is bound to create the same harmonics as T_1. Isn't it?


Wrong! You are using polynomials to waveshape a signal. There is very little obvious logic in relation between what the formula contains and which harmonics it will create.
Chebyshev polynomials have a property that if you waveshape cosine it will output higher freqiency cosine. However the input must be pure cosine (ranging exactly <-1,1> normalized ... so -6dBFS will not work as that is <-0.5,0.5>).
Rocko wrote:Here is another weird behavior of 'Chebyshev polynomials'...

Let's say I input the suggested signal (100Hz, pure sine wave, (-6 DbFS)) to create the first harmonic [200Hz].
The output is a clean 200 Hz as expected.

Now, if I cascade this 200Hz input to another 'chebyshev polynomial' module and output the first harmonic, the output is... 200Hz and 400Hz...
If I input a 200Hz to the second 'chebyshev polynomial' module only - the output is the expected 400Hz.

How does the system 'know' that in the first case, the sine wave is not original??


Nothing weird on that really... connect it to a oscilloscope and you'll notice what you do wrong straight away. In case of first Ch. if you enter input that is ranging lower than <-1,1> your output will be a cosine with DC offset (which is hard to notice in spectum analyzers). So to the second you are inputing a cosine with very little gain and big DC offset = the output will not be pure cosine.

Here a schematic to show you what I'm talking about. a sine oscillator with a gain knob inputed to the chebysevs you posted and connected to oscilloscope. Notice how the waveshape changes in every stage (original sine, first pass through chebysev, second pass) with the gain. Chebysevs produce expected (pure sine) output only when gain is 1 thus 0dBFS.
Attachments
Dual_Harmonizer.osm
(126.52 KiB) Downloaded 1325 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Creating (a single) harmonic

Postby Rocko » Tue Jun 03, 2014 11:33 am

Hi,

Hey - thanks for the clear explanation... I thought it should be limited to [-1,1], not exactly at that value...
This makes things much clearer.

so, going back to 'real world' cases... is there an efficient 'mathematical' way to create single high harmonics, like x3 times higher frequency, for an input of constant frequency (let's say 100Hz) and changing amplitude (limited to maximum [1])?

I find all this very interesting...

Rocko
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: Creating (a single) harmonic

Postby KG_is_back » Tue Jun 03, 2014 12:39 pm

Rocko wrote:Hi,

Hey - thanks for the clear explanation... I thought it should be limited to [-1,1], not exactly at that value...
This makes things much clearer.

so, going back to 'real world' cases... is there an efficient 'mathematical' way to create single high harmonics, like x3 times higher frequency, for an input of constant frequency (let's say 100Hz) and changing amplitude (limited to maximum [1])?

I find all this very interesting...

Rocko


You may hard-compress the signal, preform the frequency shift and apply envelope from the original. However chebyshevs seem to be very sensitive to imperfections of the input sinus wave. And my hardlimiter introduces a lot of it unfortunately. You may cascade it with a bandpass/lowpass filter
Attachments
harmonizer sine.fsm
(52.85 KiB) Downloaded 1351 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia


Return to DSP

Who is online

Users browsing this forum: No registered users and 64 guests