Skip to content

Commit

Permalink
tmp: try max power for volume calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ianprime0509 committed Jan 4, 2024
1 parent 166de27 commit c993d3b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit c993d3b

Please sign in to comment.