Click here to Skip to main content
15,920,217 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCreateFile and binary files Pin
Cannibal1-Sep-03 8:36
Cannibal1-Sep-03 8:36 
GeneralRe: CreateFile and binary files Pin
Stefan Pedersen1-Sep-03 10:30
Stefan Pedersen1-Sep-03 10:30 
GeneralFFT for dummies Pin
Steve Messer1-Sep-03 8:14
Steve Messer1-Sep-03 8:14 
GeneralRe: FFT for dummies Pin
Joaquín M López Muñoz1-Sep-03 11:16
Joaquín M López Muñoz1-Sep-03 11:16 
GeneralRe: FFT for dummies Pin
Anonymous1-Sep-03 11:50
Anonymous1-Sep-03 11:50 
GeneralRe: FFT for dummies Pin
mr20031-Sep-03 13:27
mr20031-Sep-03 13:27 
GeneralRe: FFT for dummies Pin
Steve Messer1-Sep-03 21:26
Steve Messer1-Sep-03 21:26 
GeneralRe: FFT for dummies Pin
Joaquín M López Muñoz1-Sep-03 22:14
Joaquín M López Muñoz1-Sep-03 22:14 
1) With the sample rates you used in your example are you implying that the sample rate should be base 2.

No. In the example the sampling rate f2 is 48,000, which certainly is not a power of 2. What should be a a power of two is the size of the chunks passed to the FFT routine --some FFT libraries do not impose this restriction, but even so there're efficiency advantages in doing it that way.

2) So, if I want to display lets say 64 bars(samples??) to represent the sound starting from 20hz to 20,000kHz how does this work? Do I just select the frequencies that I want from the fft calculation?

Not exactly, you've got to do some postprocessing in order to get something with physical meaning. Let's do the planning:

1. As your maximum frequency is 20 kHz then fs must be at least 40 kHz. It is a good idea to have it a little higher to reduce the aliasing, so 48 kHz seems a good choice --plus, many sound formats come sampled at this very frequency. So, your maximum frequency is 24 kHz and you want 20 Hz resolution. This gives 48,000/20 = 2400 for the size of the chunks. If your FFT routine accepts this size, you're done. If not, then choose the next power of 2 (4096).

2. as you already know, FFT outputs values in the [-fs,fs), range, so it is giving you results for negative frequencies. Also, FFT values are complex numbers, with imaginary as well as real part. This has little physical meaning, so most spectrum analyzers display the energy of the signal as a function of frequency, which is more easily understandable by a human user. So, if we write X(f) for the FFT at frequency f, the energy of the function is
E<sub>X</sub>(f) = |X(f)|<sup>2</sup> + |X(-f)|<sup>2</sup>
where |·| is the complex absolute value function (also called modulus). This operation "folds" the negative frequencies into the positive axis, so you only have now positive frequencies and real values (energies), which is fine.

3. Finally, the frequency bands you want to display are not evenly spaced, but they follow an exponential distribution from 20 Hz to 20 kHz. This is fine, as it models the perception system of the human ear. But the FFT gives evenly spaced frequency values (or energies, if you applied the transformation above). To transform from what you've got to the exponential bands, just group the energy points in frequency bands around the frequencies of interest (higher frequencies will get more points) and sum their energies for each band.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: FFT for dummies Pin
Steve Messer2-Sep-03 6:21
Steve Messer2-Sep-03 6:21 
GeneralRe: FFT for dummies Pin
Joaquín M López Muñoz2-Sep-03 7:02
Joaquín M López Muñoz2-Sep-03 7:02 
GeneralRe: FFT for dummies Pin
Steve Messer2-Sep-03 7:58
Steve Messer2-Sep-03 7:58 
Questionhow to hide the view of MDI program at startup Pin
mr20031-Sep-03 8:06
mr20031-Sep-03 8:06 
AnswerRe: how to hide the view of MDI program at startup Pin
KaЯl1-Sep-03 10:45
KaЯl1-Sep-03 10:45 
GeneralRe: how to hide the view of MDI program at startup Pin
mr20032-Sep-03 8:07
mr20032-Sep-03 8:07 
GeneralRe: how to hide the view of MDI program at startup Pin
KaЯl2-Sep-03 8:29
KaЯl2-Sep-03 8:29 
Questionhow to hide the view of MDI program Pin
Anonymous1-Sep-03 8:05
Anonymous1-Sep-03 8:05 
QuestionHow to fit a bitmap into a CStatic control Pin
tico_tech1-Sep-03 7:38
tico_tech1-Sep-03 7:38 
AnswerRe: How to fit a bitmap into a CStatic control Pin
Anonymous1-Sep-03 10:46
Anonymous1-Sep-03 10:46 
GeneralAnybody please help with linked list implementation Pin
digiman20031-Sep-03 6:02
digiman20031-Sep-03 6:02 
GeneralRe: Anybody please help with linked list implementation Pin
DViggiano1-Sep-03 7:11
DViggiano1-Sep-03 7:11 
GeneralOnPaint problem Pin
YaronNir1-Sep-03 5:59
YaronNir1-Sep-03 5:59 
GeneralRe: OnPaint problem Pin
Stefan Pedersen1-Sep-03 10:34
Stefan Pedersen1-Sep-03 10:34 
GeneralRe: OnPaint problem Pin
YaronNir2-Sep-03 4:08
YaronNir2-Sep-03 4:08 
GeneralRe: OnPaint problem Pin
Neville Franks1-Sep-03 10:47
Neville Franks1-Sep-03 10:47 
GeneralRe: OnPaint problem Pin
YaronNir2-Sep-03 4:08
YaronNir2-Sep-03 4:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.