Login / Register 0 items | $0.00 New @ KVR
joshb
KVRist
 
74 posts since 13 Apr, 2016

Postby joshb; Fri Aug 10, 2018 11:31 am Harmonic analysis

I'm looking to chart the harmonic content of several instruments and not sure the easiest way to go about it.

I saw this in a publication and it's pretty close to what I'm looking for:

chart.jpg


I believe they used Matlab to generate it, but I'm completely clueless when it comes to Matlab. Can anyone help me out? Thank you.
You do not have the required permissions to view the files attached to this post.
juha_p
KVRist
 
457 posts since 21 Feb, 2006, from FI

Postby juha_p; Mon Aug 13, 2018 12:31 am Re: Harmonic analysis

Do you have link to the page you borrowed that image from (they might explain something there)?
joshb
KVRist
 
74 posts since 13 Apr, 2016

Postby joshb; Mon Aug 13, 2018 6:50 am Re: Harmonic analysis

I looked through the paper...it only said that it was written in Matlab.
User avatar
aciddose
KVRAF
 
11914 posts since 7 Dec, 2004

Postby aciddose; Mon Aug 13, 2018 7:22 am Re: Harmonic analysis

This is basically a narrow filter.

One problem with narrow "high Q" filters is that they oscillate/ring for a long period of time which means your measurement is not accurate over time. They attack very quickly but decay very slowly.

One solution to this problem is to create a high Q filter at the maximum possible frequency. For example you might be running at 96 kHz, so you can probably create a narrow band-pass filter at ~40kHz.

The decay is related to Q and frequency such that at twice the frequency you get twice the rate of decay.

Normally the problem would be most obvious in low frequencies such as 1st, 2nd, 3rd harmonic of 100 Hz for example. (100, 200, 300.)

If you were able to "transpose" those frequencies up to 40kHz, 40/0.1 = 400 times, you'd get 400 times the rate of decay! This means if the decay of your high Q filter is 100 ms at 100 Hz, it'll be 100 / 400 = 250 uS at 40kHz.

As it turns out, you can transpose a frequency by computing the sum&difference of a sine modulator. In order to get 100 to 40000 we need to add 39900 Hz. The difference frequency would be at 39800 Hz which is only 200 Hz away. So the effect of this method is reduced accuracy in amplitude at low frequencies rather than in time. This can be compensated by using a steep "high Q" filter.

We also need to look out for components of the carrier that may produce alias frequencies. For example given 48000 Hz nyquist and a modulator at 39900 Hz, we can only cope with a signal up to 8100 Hz before aliasing appears. This is okay though as we can apply a high order low-pass filter before sum & difference modulation to significantly reduce the level of other frequencies. We can use an ideally steep filter for this purpose such as a Butterworth or Chebyshev type II.

Then it's simply a matter of measuring the amplitude of the band-pass filter. Since you don't need to sweep the coefficients it makes the filters rather cheap. You can also sweep the coefficients to produce a full spectrum analysis rather than a measurement of a specific frequency.

This implementation has different trade-offs than a Fourier-transform based method which also suffers from modulation artifacts due to the need to window the signal, but most importantly suffers significantly from poor time resolution where time & frequency resolution are not independent but rather mutually exclusive.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
User avatar
Music Engineer
KVRAF
 
3764 posts since 8 Mar, 2004, from Berlin, Germany

Postby Music Engineer; Mon Aug 13, 2018 10:16 am Re: Harmonic analysis

i don't have it, so i can't comment on how good it is, but from the description, this:

https://www.amazon.com/Welshs-Synthesiz ... 003XRZST0/

seems to be exactly what you are looking for

edit: oops - wait no. you didn't ask for where to find such charts but how to do them...anyway, i'll leave that here because it may be useful to someone anyway
Image
joshb
KVRist
 
74 posts since 13 Apr, 2016

Postby joshb; Mon Aug 13, 2018 1:46 pm Re: Harmonic analysis

aciddose wrote:This implementation has different trade-offs than a Fourier-transform based method which also suffers from modulation artifacts due to the need to window the signal, but most importantly suffers significantly from poor time resolution where time & frequency resolution are not independent but rather mutually exclusive.


This is interesting. I'd started playing around (in C++) with a utility that would do an FFT, then find the bucket with the closest frequency to each harmonic and measure that over time, but I also started to think about doing something similar but with a bandpass filter for each frequency and measure that over time. I just wasn't sure which would be more accurate or why. I believe the graph I attached was done with an DFT in Matlab...again, not sure about the accuracy of that either.
mystran
KVRAF
 
4952 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Mon Aug 13, 2018 3:10 pm Re: Harmonic analysis

It's worth keeping in mind that ANY time-frequency analysis methods always have to trade-off between time-accuracy and frequency-accuracy. Unfortunately you can't really ever have both, because of how the duality works mathematically.

As aciddose notes, using band-pass filters can potentially give you a better trade-off than what you get with the FFT.. but ultimately it's still a trade-off, just a different one.
Image <- plugins | forum

Moderator: Moderators (Main)

Return to DSP and Plug-in Development