S06 Simple FFT using js lib

Content outdated

We are in the process of migrating all content to impulse version 2.0.

In this example, we tried a simple fft using an external library (http://nayuki.eigenstate.org/page/free-small-fft-in-multiple-languages). The source signal length was 100us, so the output domain was set to 10khz.

// input: an array of all input signals
// in0: primary input of type ISamplePointer,IReadableSamples
// in1..: additional inputs of type ISamplePointer,IReadableSamples
// out: output signal of type IFloatSamplesWriter

// T = 100us
// -> df = 10kHz (configure above)
var real = []; var imag = []; 
var count = in0.getCount()-1;
// extract samples into array
for (var i=0;i<1024;i++){ 
	real[i] = in0.floatValueAt(i/1024*count);
	imag[i] = 0.0;
// do fft 
var result = transform(real,imag);
// write result into out; each i represent 10kHz
for (var i=0;i<real.length/2;i++){
 * Free FFT and convolution (JavaScript)
 * Copyright (c) 2014 Nayuki Minase
 * http://nayuki.eigenstate.org/page/free-small-fft-in-multiple-languages
 * (MIT License)
About Signal Scripts Java reference for scripts



technical software and tooling


Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.