From 8f6fb424ca300b5052986864b847e413f2af7aaa Mon Sep 17 00:00:00 2001 From: Dusan Cervenka Date: Sat, 12 Jan 2019 10:15:50 +0100 Subject: [PATCH] Support of process function. --- stft.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stft.js b/stft.js index aca9e5f..bf6bc16 100644 --- a/stft.js +++ b/stft.js @@ -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) @@ -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)); }); }