Search code examples
signal-processingfftd

N step fft in D language


I am using fft function from std.numeric

Complex!double[] resultfft = fft(timeDomainAmplitudeVal);

The parameter timeDomainAmplitudeVal is audio amplitude data. Sample rate 44100 hz and there is 131072(2^16) samples

I am seeing that resultfft has the same size as timeDomainAmplitudeVal(131072) which does not fits my project(also makes no sense) . I need to be able to divide FFT to N equally spaced frequencies. And I need this N to be defined by me .

Is there anyway to implement this with std.numeric.fft or can you have any advices for fft library?

Ps: I will be glad to hear if some DSP libraries exist also


Solution

  • That's just how Fourier transforms work in the practical number-crunching world. Give S samples of signal, get S amplitudes. (Ignoring issues with complex numbers and symmetries.)

    If you want N amplitudes, you'll have to interpolate the S-points amplitudes you get from FFT. Your biggest decision is to choose between linear, cubic, truncated sinc, etc.

    Altnernative: resample the original audio signal to have your desired N samples in the same overall time interval. Then FFT it.