We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8354b82 commit 3184a44Copy full SHA for 3184a44
src/board/microphone.ts
@@ -37,15 +37,11 @@ export class Microphone {
37
38
initialize(soundLevelCallback: (v: number) => void) {
39
this.soundLevel.onchange = (prev: number, curr: number) => {
40
- if (
41
- prev > this.soundLevel.lowThreshold &&
42
- curr <= this.soundLevel.lowThreshold
43
- ) {
+ const low = this.soundLevel.lowThreshold!;
+ const high = this.soundLevel.highThreshold!;
+ if (prev > low && curr <= low) {
44
soundLevelCallback(convertSoundEventStringToNumber("low"));
45
- } else if (
46
- prev < this.soundLevel.highThreshold &&
47
- curr >= this.soundLevel.highThreshold
48
+ } else if (prev < high && curr >= high!) {
49
soundLevelCallback(convertSoundEventStringToNumber("high"));
50
}
51
};
0 commit comments