Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions stft.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class STFT{
return this.fft.inverse(this.fft.real, this.fft.imag);
}

analyze(buffer, processFunc, maxHops = 100000) {
analyze(buffer, processFunc = this.magnitude, maxHops = 100000) {
this.processFunc = processFunc
let frames = new Array();
let arrayHops = Math.floor(
(buffer.length - this.fftSize) / parseFloat(this.hopSize)
Expand All @@ -87,7 +88,7 @@ class STFT{
let windowed = this.window.process(buffer.slice(start, end));
this.processSegment(windowed,
(real, imag) => {
let mag = this.magnitude(real, imag);
let mag = this.processFunc(real, imag);
frames.push(mag.slice(0, size));
});
}
Expand Down