jam/test/test-fft.js

16 lines
384 B
JavaScript
Raw Normal View History

2024-08-27 00:15:36 +02:00
var FFT = numerics.fft;
var signal = [1,0,1,0];
var phasors = FFT.fft(signal);
log(phasors);
var frequencies = FFT.fftFreq(phasors, 8000), // Sample rate and coef is just used for length, and frequency step
magnitudes = FFT.fftMag(phasors);
var both = frequencies.map(function (f, ix) {
return {frequency: f, magnitude: magnitudes[ix]};
});
log(inspect(both));