result of FFT
Matthew
monkeytonk115 at gmail.com
Tue Jul 8 18:11:27 UTC 2025
Hi,
I'm writing a program where I'm trying to decode DTMF tones. I
already completed the wave file decoder and I know I'm supposed
to use an FFT to transform the samples from time domain to
frequency domain but I'm stuck on determining which of the DTMF
frequencies are present.
Consider the following, the input is the sound wave samples as an
array of floats between -1 and +1.
```D
void decode_sound(float[] samples)
{
import std.numeric;
import std.math;
import std.complex;
import std.algorithm;
size_t fft_size = 4096;
auto f = new Fft(fft_size);
foreach(ch; samples.chunks(fft_size))
{
auto res = f.fft(ch);
// res is an array of 4096 complex numbers
}
}
```
I can't figure out how the 4096 results of the FFT relate to the
frequencies in the input.
I tried taking the magnitude of each element, I tried taking just
the real or imaginary parts. I plotted them but the graph
doesn't look how I'm expecting.
What do the 4096 resulting complex numbers represent?
How should I use the result to check whether the 1209Hz, 1336Hz,
1477Hz, or 1633Hz tones are present in that part of the sound?
Thanks,
Matthew
More information about the Digitalmars-d-learn
mailing list