View amplitude value of specific frequency
Hello, I'm looking for a way to find out the amplitude of a given frequency. For example, if I have a recording of a word and I play it and want to view the amplitude of 1000hz as a float. I want to do this for multiple frequencies but figure once I can do one frequency I could do them all. Has anyone done something like this before? Does anyone have any ideas? Thanks!
The good old way to do this is the "vocoder" way: feed your signal to bandpass filter with a center frequency of 1000Hz, and look at the amplitude getting out of there (with meter~, avg~, peakamp~, etc.) Choose your Q depending on the bandwidth you want, depending on the source/application/etc. Check out the Max vocoder example if you have not seen it.
Another way is to use a FFT analysis. No bandwidth per se, but a frequency bin width that depends on your FFT size. Check the two FFT Max tutorials to get started...
Best,
Thanks for your idea's Jean-Francois, the first way was the way I was initially trying. I was thinking of trying to leave the signal unaltered, maybe just leaving Q at zero. But without the focus of a higher Q level I am worried that if another frequency is louder than the frequency I am trying to read my output in peakamp~ (the object I was trying) won't be accurate with regards to the frequency I am investigating. I do want to look more into the FFT analysis, I started reading it quickly and it seemed at first that what you are analyzing is bunch of divisions of the overall audio spectrum, and not a specific frequency? Like say 50 divisions (frequency bins) between 20hz and 20000hz, or am I way off base? I will look into it more regardless
it seemed at first that what you are analyzing is bunch of divisions of the overall audio spectrum, and not a specific frequency?
Well yes that is what you are doing and each bin has a specific center frequency. You can massage the parameters of the FFt to give you a bin right at your desired frequency if you want.
Yes, the FFT algorithm gives you the amount of energy present in a number of frequency bins. The frequency bin has a finite width (in Hz), which is equal to the sampling rate divided by the FFT size. For instance, at 44.1 kHz, with a FFT size of 2048, the frequency bins are around 20 Hz wide.
About the passband filter option, if you want a very low bandwidth, that is a very high Q (not Q at zero).
In a way, it is impossible to analyze the one and only 1000Hz frequency: you would need an infinite amount of time. I'm afraid you will have to compromise with your infinitely precise objective, and accept a non-null bandwidth...
You can massage the parameters of the FFt to give you a bin right at your desired frequency if you want.
Ok, I want to perform an FFT analysis that gives me a bin at exactly 1000Hz.
1000Hz being the center frequency of that bin.
How would you do that???
- Luigi
Your bins are centered around k * sample-rate/FFT-size, with k=0 to (FFT-size/2 -1)
With a sampling rate of 44100 Hz, a FFT size of 2048, you get the space [0-22050Hz] split in 1024 bins, the first of which is centered around 0, the second around 22050/1024 = 21.5Hz, and the next ones are the multiples of 21.5Hz.
To get a bin precisely centered around 1000Hz, you need the bin width to be a divider of 1000.
So, you need FFT-size*1000/sample-rate to be an integer number.
And your FFT size is a power of two.
Won't work with a sample rate multiple of 3 (i.e. 48000Hz and multiples, or 44100 and multiples).
Will work with a sample rate of 8000Hz or 16000Hz!
Thank you Jean-Francois. That was exactly my point...
Since most audio software including Max/MSP are limited to a sample rate of 44100Hz/48000Hz and multiples, I find it impossible to get a bin centered at exactly 1000Hz in Max, no matter how you massage the parameters of the FFT.
Indeed, massage or no massage...
you can try looking into goertzel filters. here is an implementation for osx http://vboehm.net/downloads/
but coming back to the original question: there will be *very* little energy in one specific frequency component of a spoken word.
Hi.
Just to elaborate a bit further:
if you don't need your analysis to be performed in strict real-time, you can transpose the sound so as to move the original 1kHz to the center of a bin.
For example, the 23rd bin of an FFT with a window size of 1024 at a 44kHz sampling rate will be centered at ~990.52. If you pitch-shift your original sound by a factor of 0.99052 (which you can do with almost no latency, and I'm not talking of fancy pitch shifting algorithms, but just a slightly slowed-down playback of an audio buffer), there you go — the energy of the original 1kHz just moved to 990.52 Hz, that is, at the center of the FFT bin!
On the other hand, if you only need an estimation of the amount of energy in a few frequency bands, frankly I'd go with a bank of band-pass filters (see fffb~) and envelope followers.
Hope this helps,
aa
So many tricks we find when exploring a topic a little deeply! Nice (although I'm still not sure what Andrew Sblendorio is really after).
at exactly 1000 Hz ... impossible with fft.