diff --git a/index.js b/index.js index 2cc935d..931aef3 100644 --- a/index.js +++ b/index.js @@ -437,11 +437,15 @@ export class PitchDetector { */ _belowMinimumVolume(input) { if (this._minVolumeAbsolute === 0) return false; - let sum = 0; + // let sum = 0; + // for (let i = 0; i < input.length; i++) { + // sum += Math.abs(input[i]); + // } + // return sum / input.length < this._minVolumeAbsolute; for (let i = 0; i < input.length; i++) { - sum += Math.abs(input[i]); + if (Math.abs(input[i]) > this._minVolumeAbsolute) return false; } - return sum / input.length < this._minVolumeAbsolute; + return true; } /**