Bandslimited synthesis - get number of harmonics

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

Bandslimited synthesis - get number of harmonics

Post by Lyberta »

User avatar
sadko4u
Established Member
Posts: 986
Joined: Mon Sep 28, 2015 9:03 pm
Has thanked: 2 times
Been thanked: 359 times

Re: Bandslimited synthesis - get number of harmonics

Post 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.
LSP (Linux Studio Plugins) Developer and Maintainer.
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

Re: Bandslimited synthesis - get number of harmonics

Post 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.
ssj71
Established Member
Posts: 1294
Joined: Tue Sep 25, 2012 6:36 pm
Has thanked: 1 time

Re: Bandslimited synthesis - get number of harmonics

Post 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.
_ssj71

music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Bandslimited synthesis - get number of harmonics

Post 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.
Lyberta
Established Member
Posts: 681
Joined: Sat Nov 01, 2014 8:15 pm
Location: The Internet
Been thanked: 1 time

Re: Bandslimited synthesis - get number of harmonics

Post by Lyberta »

Alright, so my code was correct, phew.
Post Reply