Permalink
Browse files

Make FFT, IFFT work with empty inputs

  • Loading branch information...
oampo committed Feb 15, 2012
1 parent ec38a00 commit d1daa4394ec3a12bd4bb2ebdb7d0610248813f85
Showing with 8 additions and 0 deletions.
  1. +4 −0 src/dsp/FFT.js
  2. +4 −0 src/dsp/IFFT.js
View
@@ -42,6 +42,10 @@ FFT.prototype.generate = function() {
var input = this.inputs[0];
var output = this.outputs[0];
+ if (input.samples.length == 0) {
+ return;
+ }
+
this.buffer[this.readWriteIndex] = input.samples[0];
output.samples[0] = [this.realBuffer[this.readWriteIndex],
this.imaginaryBuffer[this.readWriteIndex]];
View
@@ -46,6 +46,10 @@ IFFT.prototype.generate = function() {
var input = this.inputs[0];
var output = this.outputs[0];
+ if (!input.samples.length) {
+ return;
+ }
+
var values = input.samples[0];
this.realBuffer[this.readWriteIndex] = values[0];
this.imaginaryBuffer[this.readWriteIndex] = values[1];

0 comments on commit d1daa43

Please sign in to comment.