Simple question about getting a basic frequency spectrum
Hi, I am a little confused with fourier-transforms, math not being my specialty. In essence all I am trying to do is take 1 second samples of an audio file and print out coordinates as follows: - amplitude at 80Hz, amplitude at 200Hz, amplitude at 1000Hz I have set up a file connecting: SndBuf buf => dac; buf => FFT fft => blackhole; And now I assume that I set the fft.size to 1024 samples (for a 44k 16bit audio file) and then upchuck that every 1024 samples. Most likely my error is there... But now I don't know how to get at the correct output. I have a ton of polar values but I don't really know what any of them correspond to. Some sample values: "time: 0:5000.0000" : (string) %(0.0140,-0.9985*pi) %(0.0004,-0.6629*pi) %(0.0001,-0.4812*pi) %(0.0001,-0.4412*pi) %(0.0001,-0.7007*pi) %(0.0001,-0.7549*pi) %(0.0001,-0.5928*pi) %(0.0000,0.7277*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) "time: 0:6000.0000" : (string) %(0.0189,0.0008*pi) %(0.0003,0.4507*pi) %(0.0001,0.2899*pi) %(0.0001,0.2122*pi) %(0.0001,0.3072*pi) %(0.0000,0.5483*pi) %(0.0001,0.1053*pi) %(0.0000,0.2292*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) "time: 0:7000.0000" : (string) %(0.0148,0.9997*pi) %(0.0002,0.4662*pi) %(0.0002,0.1996*pi) %(0.0001,0.4250*pi) %(0.0001,0.2651*pi) %(0.0001,0.4396*pi) %(0.0000,0.9036*pi) %(0.0001,0.4967*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) Can someone help? I bet this is actually pretty simple I just can't seem to figure it out. I understand the notion of polar coordinates and know how I can convert them to Cartesian. But what I am not understanding is where I find out what the actual frequencies that are being sampled are... Thanks - J -- ---- vomc8one@gmail.com ----
Hello v bar
Just an approximation, I suggest a good book or internet resource.
The polars you have are the magnitud (amp) and phase of each band of
frequencies. The bands of frequencies you have are defined by the ratio
between the sampling rate the windows size, that ratio is the analysis
frequency. In this case, the analysis frequency is 44100 / 1024 =
43.06640625. Then you have windowssize / 2 = 512 harmonically related bands
starting from 43.066 and... I strongly suggest a good reading, sorry I don't
have nothing at hand right now.
Best
Lucas
2010/3/5 v bar
Hi,
I am a little confused with fourier-transforms, math not being my specialty.
In essence all I am trying to do is take 1 second samples of an audio file and print out coordinates as follows:
- amplitude at 80Hz, amplitude at 200Hz, amplitude at 1000Hz
I have set up a file connecting:
SndBuf buf => dac; buf => FFT fft => blackhole;
And now I assume that I set the fft.size to 1024 samples (for a 44k 16bit audio file) and then upchuck that every 1024 samples.
Most likely my error is there...
But now I don't know how to get at the correct output.
I have a ton of polar values but I don't really know what any of them correspond to.
Some sample values:
"time: 0:5000.0000" : (string) %(0.0140,-0.9985*pi) %(0.0004,-0.6629*pi) %(0.0001,-0.4812*pi) %(0.0001,-0.4412*pi) %(0.0001,-0.7007*pi) %(0.0001,-0.7549*pi) %(0.0001,-0.5928*pi) %(0.0000,0.7277*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) "time: 0:6000.0000" : (string) %(0.0189,0.0008*pi) %(0.0003,0.4507*pi) %(0.0001,0.2899*pi) %(0.0001,0.2122*pi) %(0.0001,0.3072*pi) %(0.0000,0.5483*pi) %(0.0001,0.1053*pi) %(0.0000,0.2292*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) "time: 0:7000.0000" : (string) %(0.0148,0.9997*pi) %(0.0002,0.4662*pi) %(0.0002,0.1996*pi) %(0.0001,0.4250*pi) %(0.0001,0.2651*pi) %(0.0001,0.4396*pi) %(0.0000,0.9036*pi) %(0.0001,0.4967*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi)
Can someone help? I bet this is actually pretty simple I just can't seem to figure it out. I understand the notion of polar coordinates and know how I can convert them to Cartesian. But what I am not understanding is where I find out what the actual frequencies that are being sampled are...
Thanks - J
-- ---- vomc8one@gmail.com ---- _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
http://www.dspguide.com/ch8.htm
I need to read it too.
2010/3/5 Lucas Samaruga
Hello v bar
Just an approximation, I suggest a good book or internet resource. The polars you have are the magnitud (amp) and phase of each band of frequencies. The bands of frequencies you have are defined by the ratio between the sampling rate the windows size, that ratio is the analysis frequency. In this case, the analysis frequency is 44100 / 1024 = 43.06640625. Then you have windowssize / 2 = 512 harmonically related bands starting from 43.066 and... I strongly suggest a good reading, sorry I don't have nothing at hand right now.
Best Lucas
2010/3/5 v bar
Hi,
I am a little confused with fourier-transforms, math not being my specialty.
In essence all I am trying to do is take 1 second samples of an audio file and print out coordinates as follows:
- amplitude at 80Hz, amplitude at 200Hz, amplitude at 1000Hz
I have set up a file connecting:
SndBuf buf => dac; buf => FFT fft => blackhole;
And now I assume that I set the fft.size to 1024 samples (for a 44k 16bit audio file) and then upchuck that every 1024 samples.
Most likely my error is there...
But now I don't know how to get at the correct output.
I have a ton of polar values but I don't really know what any of them correspond to.
Some sample values:
"time: 0:5000.0000" : (string) %(0.0140,-0.9985*pi) %(0.0004,-0.6629*pi) %(0.0001,-0.4812*pi) %(0.0001,-0.4412*pi) %(0.0001,-0.7007*pi) %(0.0001,-0.7549*pi) %(0.0001,-0.5928*pi) %(0.0000,0.7277*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) "time: 0:6000.0000" : (string) %(0.0189,0.0008*pi) %(0.0003,0.4507*pi) %(0.0001,0.2899*pi) %(0.0001,0.2122*pi) %(0.0001,0.3072*pi) %(0.0000,0.5483*pi) %(0.0001,0.1053*pi) %(0.0000,0.2292*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) "time: 0:7000.0000" : (string) %(0.0148,0.9997*pi) %(0.0002,0.4662*pi) %(0.0002,0.1996*pi) %(0.0001,0.4250*pi) %(0.0001,0.2651*pi) %(0.0001,0.4396*pi) %(0.0000,0.9036*pi) %(0.0001,0.4967*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi) %(0.0000,0.0000*pi)
Can someone help? I bet this is actually pretty simple I just can't seem to figure it out. I understand the notion of polar coordinates and know how I can convert them to Cartesian. But what I am not understanding is where I find out what the actual frequencies that are being sampled are...
Thanks - J
-- ---- vomc8one@gmail.com ---- _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Bins are spaced sample_frequency/fft_size hz apart. And you take the magnitude of the polar coordinates: sqrt(i*i+r*r) to calculate the magnitude of the signal. The resulting magnitiude isbetween zero and 1 (for in-range signales), and you would convert db2a to get a db value. For signal power, as opposed to magnitude, you multiply by two (or don't take the square root).
You'll need to multiple the samples in the input with a window function in order to get sensible values. See http://en.wikipedia.org/wiki/Window_function#Hamming_window
Hamming, or Hann window functions would be good choices. Without a window function, all you'll get is the frequency of the step response at the start and end of the FFT frame - which is terribly useful.
From: chuck-users-bounces@lists.cs.princeton.edu [mailto:chuck-users-bounces@lists.cs.princeton.edu] On Behalf Of Lucas Samaruga
Sent: Thursday, March 04, 2010 10:30 PM
To: ChucK Users Mailing List
Subject: Re: [chuck-users] Simple question about getting a basic frequency spectrum
Hello v bar
Just an approximation, I suggest a good book or internet resource.
The polars you have are the magnitud (amp) and phase of each band of frequencies. The bands of frequencies you have are defined by the ratio between the sampling rate the windows size, that ratio is the analysis frequency. In this case, the analysis frequency is 44100 / 1024 = 43.06640625. Then you have windowssize / 2 = 512 harmonically related bands starting from 43.066 and... I strongly suggest a good reading, sorry I don't have nothing at hand right now.
Best
Lucas
2010/3/5 v bar
On 5 March 2010 04:05, v bar
Hi,
I am a little confused with fourier-transforms, math not being my specialty.
Depending on the way that you learn best you could go over the formal math (beware that this is serious university level stuff) or you could look at the relevant examples in the directory of examples that came with your ChucK install and poke around in those, seeing how changes affect them. There is also the reference pages for the analysis stuff. If I were you I'd read up on the general theory of *what* happens but leave the details of the *how* be, being happy that others implemented it for you. Then I'd do some poking around, read the same stuff again as by then it will make more sense, poke some more and see how far you can get in making it do your bidding. The theory behind it all is heavy stuff but working with this in practice need not be all that hard, especially as there are working examples that do fun stuff ready made for you. Good luck! Kas.
participants (4)
-
Kassen
-
Lucas Samaruga
-
Robin Davies
-
v bar