Page 1 of 1

Bandslimited synthesis - get number of harmonics

Posted: Wed Nov 08, 2017 8:59 am
by Lyberta

Re: Bandslimited synthesis - get number of harmonics

Posted: Wed Nov 08, 2017 3:41 pm
by sadko4u
It wouldn't be so funny if it wasn't really so sad.
The answer is in your code copy-paste.
Obviously, the highest harmonic number is numharmonics.

Re: Bandslimited synthesis - get number of harmonics

Posted: Wed Nov 08, 2017 4:35 pm
by Lyberta
It is so funny that you can't even read:
Here's what I've come up with intuition
I wrote this code myself. I just don't know if numharmonics is correct.

Re: Bandslimited synthesis - get number of harmonics

Posted: Wed Nov 08, 2017 5:39 pm
by ssj71
freq*n gives you the frequency of the nth harmonic. as long as its below nyquist (samplerate/2) then you are fine. So your equation for nharmonics is correct. I didn't really look at the rest of it.

Re: Bandslimited synthesis - get number of harmonics

Posted: Wed Nov 08, 2017 6:43 pm
by CrocoDuck
I just had a look at it quickly. Hope I am not too tired to figure out maths...

Pulse Wave:

It does look like the pulse wave is a sum of tones whose frequency grows as nf, where f is the fundamental and n = 1,2,3,....

So, if we call N the maximum allowed number of harmonics: Nf < fs / 2 <=> N < fs / 2f = harmonics order limit.

Where fs is the sample rate.

Triangle Wave:

This time the harmonic's frequencies goes like (2n + 1)f, hence:

(2N + 1)f < fs / 2 <=> N < (fs / 2f - 1) / 2 = harmonics order limit.

Sawtooth Wave:

As the Pulse Wave.

Re: Bandslimited synthesis - get number of harmonics

Posted: Thu Nov 09, 2017 4:24 am
by Lyberta
Alright, so my code was correct, phew.