Skip to content

Commit eccc0a3

Browse files
meiamsomecvalenzuela
authored andcommitted
Bugfix: PitchDetection returning the wrong pitch (#187)
When converted to the current syntax, the operation was the wrong way around. See https://github.com/marl/crepe/blob/gh-pages/crepe.js#L141 for the original.
1 parent db3dd16 commit eccc0a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PitchDetection/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class PitchDetection {
7979
const productSum = products.dataSync().reduce((a, b) => a + b, 0);
8080
const weightSum = weights.dataSync().reduce((a, b) => a + b, 0);
8181
const predictedCent = productSum / weightSum;
82-
const predictedHz = 10 * ((predictedCent / 1200.0) ** 2);
82+
const predictedHz = 10 * (2 ** (predictedCent / 1200.0));
8383

8484
const frequency = (confidence > 0.5) ? predictedHz : null;
8585
this.frequency = frequency;

0 commit comments

Comments
 (0)