Closed for Company Meetings: Between September 18 (5pm PDT) and September 22 (12pm PDT), Support and Sales requests *will be delayed*. Only time-sensitive issues will be addressed during that time. Thanks for your patience.

Oct 22 2009 | 8:49 pm

Hi there, i'm currently trying to figure out the workings on FFT and how i can use it to get the frequency of a signal (music/adc)

I'm well aware of the presence of objects like fiddler. However i'm here to learn something in the process. Could someone be so kind to point out a few friendly tips how to accomplish this, for the moment i don't really see how i can use the fft/ifft components to generate any data that i can use to sort with.

I do know that i have to get out phase speed and the wavelength
do be able to get out the frequency in a wave, is this the way todo this?

Any help is appriciated, if you do have a patch doing something like this, that would also be highly appriciated.

Kind Regards Hiam

- Oct 22 2009 | 8:59 pmHiam wrote on Thu, 22 October 2009 22:49Hi there, I'm currently trying to figure out the workings on FFT and how i can use it to get the frequency of a signal (music/adc)I'm well aware of the presence of objects like fiddler. However I'm here to learn something in the process. Could someone be so kind to point out a few friendly tips how to accomplish this, for the moment i don't really see how i can use the fft/ifft components to generate any data that i can use to sort with.Any help is appreciated, if you do have a patch doing something like this, that would also be highly appreciated.Kind Regards HiamHi,Since your goal is about learning, I suggest to read these tutorials by Stephan M. Bernsee. And especially, the tutorial called "The DFT "à Pied": Mastering The Fourier Transform in One Day".HTH, Philippe
- Oct 26 2009 | 2:42 amHiam wrote on Thu, 22 October 2009 13:49Hi there, i'm currently trying to figure out the workings on FFT and how i can use it to get the frequency of a signal (music/adc)Once you've gotten into the frequency domain (with fft) then you look for peaks in the spectrum. In a simple case, you could find one big peak at the fundamental frequency. Usually, there are a bunch of peaks; hopefully they are partials in an harmonic spectrum. I think fiddle compares the analyzed peaks to and idea harmonic spectrum and tries to find the best fit. There are academic papers out there, and the source code is available. This is a good starting point:D. Gerhard. Pitch Extraction and Fundamental Frequency: History and Current Techniques, technical report, Dept. of Computer Science, University of Regina, 2003.mz
- Oct 27 2009 | 10:18 pmI've read through the guide you posted PhiDjee, thanks a bunch for that!Now i've switched over to practics here in Max.using pfft, fftin, dspstateI'm successfully getting out near correct Frequency out of a cycle. However, that faultyness can be very very bad if you try to for instance harmonise for instance a instrument of some sort.Im currently using the formula: Centrer Frequency(27) * Bin index which has the highest valueSo if the bin index 33 has the highest valueit will be for example 27 * 33 = 891hZ I get the center frequency from Samplerate / FFT Size(2048)The faultyness varies all from 30 to 0, and the higher FFT Size, obviously the more accurate result. However that won't really work good, since if you use a higher FFT Size you can't handle higher frequency well.I also made some extended calculations based on Hop-Size and Pi to be able to make even sophisticated math equations.Is there any way to take out the values more accuratly?
- Oct 27 2009 | 11:23 pmYou might try looking at the bins around the highest and taking a weighted average.ie, if bin 100 is the highest, then ((freq_of_bin99*amp_of_bin99)+(freq_of_bin100*amp_of_bin100)+(freq_of_bin101*amp_of_bin101))/(amp_of_bin99+amp_of_bin100+amp_of_bin101)Or, go looking for the second partial and use it to refine the fundamental.mz
- Oct 28 2009 | 10:31 amI tried the suggestion above, however the value outputted is actually worse than the Bin index * Center frequency. And i can't really use it to round of the bin index * center frequency either, cause it's kind of random.For instance here is one example: I have a cycle generating the frequency: 556HzMy patch figures bin index 52 has the highest peak. My center Frequency is 10.76 (because im using 4096 as FFT Size)52 * 10.76 = 559,52 Which is almost the correct answer.Using the suggested weighted average formula i get:Bin Index 51 | 52 | 53 ----------------------------------- AMP:68.19 | 90.61 | 6.880 FRQ:545 | 556 | 566.766 ---------------------------------- Summed Total AMP & FRQ: 51: 37163,55 52: 50379,16 53: 3899,35008Sum: 91442,06008Using the weighted avarage formula: 91442,06008 / 165,68 = 551,9197....As the bin * center frequency = 559,52Hz and the weighted avarage = 551.91HzI get a diffrence of 8 and in this particial case i could divide 8 by 2 to get a correct frequency, however that does not apply all the time sadfully. And at diffrent frequencies the bin * center freq is lower than the weighted avarage which also does make it hard to make a good estimate.I did discover something else allthough.Let's say I have the chosen input frequency 556Hz.My Patch notices a peak at bin index 52.Then i take out the Amplitude,Frequency value from 51,52,53And i find that that value one of those bin indexes has the right value each time, and i do mean, THE correct value.However i can't really seem to find a pattern which i can use to see which of them is the right each diffrent input frequency.Thanks for all your help, much appriciated!
- Oct 28 2009 | 6:57 pmhi to get the correct frequency from a detected peak in the freq spectrum, using frame to frame phase differences is the most precise method in my experience. you calculate the so called 'true frequency' by monitoring the phase advance of the selected bin from frame to frame. if the input freq falls on the center of a bin, the phase difference is 0. if it is not quite on the bin freq, phase differences start to grow (in either direction), growing faster the further the input freq deviates from the bin freq. from this you can calculate 'how far' the actual frequency is from the bin freq. see the attachment. hth, volker.
- Oct 29 2009 | 3:34 pmThanks a bunch Volker for pointing that out, i'd never come up with that alone. I now have working example utlizing your technique and it works like a charm!I'd also like to give thanks to you other guys for giving me hints and idea's how to solve this question!Kind RegardsHiam
- Feb 04 2010 | 11:50 pmhello maxers,volker, can i ask you to resend your attachment, please?regards, p.
- Feb 07 2010 | 9:49 amthe forum, how i love it - can't handle attachments anymore. things are getting better and better, he?think it was this one. take care, these are two patches. first copy and safe the pfft patch, then the main patch. hth, volker./* save as "true_pfft.mxb" *//* and the main patch */