Skip to content

Commit

Permalink
Change the fftSize on the fly!
Browse files Browse the repository at this point in the history
Added a function that allows users to be able to change the bin size/fftSize.
  • Loading branch information
TheBrenny authored Jun 11, 2017
1 parent cede0fd commit 6de0770
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/fft.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,17 @@ define(function (require) {
}
this.analyser.smoothingTimeConstant = s;
};

/**
* Changes the length of the resulting array, the bin size and in turn the fftSize of the analyser.
*
* @method setBins
* @param {Number} bins Must be a power of two between 16 and 1024.
*/
p5.FFT.prototype.setBins = function(b) {
this.bins = b;
this.analyser.fftSize = b * 2;
}

p5.FFT.prototype.dispose = function() {
// remove reference from soundArray
Expand Down Expand Up @@ -621,4 +632,4 @@ define(function (require) {
};


});
});

0 comments on commit 6de0770

Please sign in to comment.