MATLAB - Missing fundamental from an FFT [closed]
Asked Answered
G

4

10

I am currently working on my fourth year project (computer science) which involves the automatic transcription of music -> sheet music. I am doing it in Matlab at the moment but will have to be converted to java at some stage.

My problem: I have my program returning the correct notes for pure sine tones, I have now encountered a problem when it comes to the retrieval of the fundamental frequency from a note played by a natural instrument. With certain notes, the peak representing the fundamental of the note seems to be missing entirely. For example when I play a G3 note from garageband, it is shown as a G4, as only the 1st, 3rd, 5th and 7th harmonics are appearing in my plot. I tried to add the image but as this is my first post it wouldn't allow me. Any pointers in the right direction would be greatly appreciated.

Genni answered 19/11, 2010 at 16:58 Comment(6)
Bummer about the image. It would help a lot to see what you're seeing.Pairs
The 1st harmonic is the fundamental. Are you sure that's what you mean?Hildredhildreth
Yes I'm sure that it isn't giving me the fundamental, the first peak it is giving me is at 392Hz, where as I am giving it a G3 which is at 196Hz. I also created a site for my project, I made a blog post here that has the title image set to be my plot, hopefully this will help: csserver.ucd.ie/~djones/Project_Site/Blog/Entries/2010/11/…Genni
Are you sure you trust GarageBand then? It sure looks like you've got a note at 392 with harmonics. Maybe the instrument you chose is automatically transposed up by an octave?Pairs
Yes I was thinking that it might be something to do with the way garageband synthesizes the notes, I may try and record some notes on my own instruments and test them out. I fed my program a 3 note sequence of C3 - E3 - G3, the C and G have their highest peaks second, where as the E has it first. All are missing the fundamental of the actual note though, so that returns a C4 - E4 - G4. I am just going to have to try make sure my instruments are tuned exactly. If you have any other ideas what it could possibly be that would be great. Also if there are any other plots you want, just let me knowGenni
Harmonic Series in musical instruments [Pitch Detection Algorithms, Harmonic Product Spectrum ](cnx.org/content/m11714/latest)Runesmith
F
17

This is not unusual. It's very common for the fundamental to be missing, or nearly so, for male voices, big string instruments, and many other pitched sound sources.

That makes using an FFT peak result alone extremely poor at determining musical notes from actual musical instruments, as opposed to sinewave function generators. That's because pitch is different from peak spectral frequency. Pitch is a psycho-acoustic perceptual phenomena. So that's what you need to read up on. There are tons of research papers on the subject.

So you need to look at a completely different set of algorithms. Try cepstrums (cepstral analysis), harmonic product spectrums, autocorrelation and similar (AMDF, ASDF, etc. lags), RAPT (Robust Algorithm for Pitch Tracking), YAAPT, etc.

ADDED: I wrote up a more detailed explanation of pitched sounds with missing fundamentals in a blog post.

Fastigium answered 20/11, 2010 at 5:4 Comment(2)
Thanks for that, how easy are some of these algorithms to implement? I am already 2 months into my project so this is a massive blow to my progress if I have to change that.Genni
Excellent answer! The choice of the right algorithm will depend on one more thing, do you pretend to transcript monophonic music? Or you want to write poliphonic music as well?Amative
G
1

It isn't unusual for the fundamental frequency of a musical instrument note to be attenuated relative to the harmonics (also known as overtones), and in some cases the fundamental frequency magnitude may be well below the magnitude of the overtones.

Take a look at this frequency/magnitude plot of a real bassoon (not a synthesized bassoon) playing a G3 note. Observe the attenuated fundamental (196.39 Hz) relative to the first harmonic. But also observe that all the integer-multiple harmonics are visible upto the 10th harmonic. Actually, many more harmonics are present, but they aren't visible on this linear magnitude plot.

BassoonG3frequencyMagnitude

In your case, the additional fact that your G3 musical note's spectrum is showing only the 1st, 3rd, 5th and 7th harmonics suggests that something is wrong. Your test sound appears to be synthesized, so the problem could be with the way the sound was synthesized.

The spectra of real musical instruments typically show the fundamental frequency and many integer-multiple harmonics such as 1, 2, 3 and so on, as seen above. And the harmonics typically extend well above 6KHz for most notes played on most instruments.

Take a look at this frequency/decibel_magnitude plot of a real bassoon (not a synthesized bassoon) playing a G3 note. Observe that a total of 37 integer-multiple harmonics are present, until they dissappear at the noise floor near -104 dB.

BassoonG3frequencyDecibelMagnitude

You can listen to this bassoon sample and see its spectrum here: Bassoon musical instrument spectrum

Also read this detailed post on analytical approaches to autonomous musical transcription

Grooms answered 8/2, 2013 at 21:20 Comment(0)
S
0

Have you tried running it through a spectrogram (function spectrogram in MATLAB) to identify what is happening?

I don't know what algorithms you use, without that information, we can't say what is going wrong. What alarms me is that your second third harmonic (second peak in the plot) is much larger than your second harmonic (first peak in the plot).

Are you sure you have all the sampling right: i.e. your DFT only has frequencies up to half the sampling frequency (both positive and negative frequency range)? Also: how do you suppress any transient part of your signal?

Schade answered 19/11, 2010 at 23:10 Comment(1)
"Are you sure you have all the sampling right: i.e. your DFT only has frequencies up to half the sampling frequency (both positive and negative frequency range)?" When I plot the frequency bins vs. the power, I have a number of peaks at both the beginning of the range, but I also have some peaks at the end of the range, i was only taking the first set of peaks into account, are you saying then that there is something I need to the peaks at both ends to get the accurate value for f0? If someone could vote me up so that I have 10 rep, then I can post picsGenni
U
0

The fact that you see peaks at 2f, 4f, 6f and 8f strongly implies that either your input data is actually an octave above what you think it is, or that you're misinterpreting the frequency scale of your results. If you were just missing the fundamental frequency, you'd see 3f, 5f and 7f as well.

Suggestions:

  • Plot your input data before you FT it. You should be able to eyeball the frequency of the dominant term.
  • Listen to the note produced by garageband. Is it above or below middle C?
  • Check that you understand where the values on the frequency scale on your plot came from.
Uniformity answered 21/11, 2010 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.