result of FFT

Ferhat Kurtulmuş aferust at gmail.com
Wed Jul 9 09:39:43 UTC 2025


On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote:
> 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

I have not been doing DSP stuff since [2018]. I am not sure how 
DTMF is similar to a regular sound signal, but I remember a few 
things from sound signals. The FFT result is symmetrical, so you 
probably only need to take the first 2048 of 4096. A Spectrogram 
would be useful to visualize the components [2]. If this is not 
the issue, sorry and please ignore this.

1: https://en.wikipedia.org/wiki/Spectrogram
2: 
https://medium.com/@adler7210/manually-decoding-dtmf-through-spectrogram-562e4b0b99c3

2018: Kurtulmuş, F., Öztüfekçi, S., & Kavdır, İ. (2018). 
Classification of chestnuts according to moisture levels using 
impact sound analysis and machine learning. Journal of Food 
Measurement and Characterization, 12(4), 2819-2834.


More information about the Digitalmars-d-learn mailing list