Skip to content

Commit 3184a44

Browse files
TypeScript fixes. (#39)
1 parent 8354b82 commit 3184a44

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/board/microphone.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@ export class Microphone {
3737

3838
initialize(soundLevelCallback: (v: number) => void) {
3939
this.soundLevel.onchange = (prev: number, curr: number) => {
40-
if (
41-
prev > this.soundLevel.lowThreshold &&
42-
curr <= this.soundLevel.lowThreshold
43-
) {
40+
const low = this.soundLevel.lowThreshold!;
41+
const high = this.soundLevel.highThreshold!;
42+
if (prev > low && curr <= low) {
4443
soundLevelCallback(convertSoundEventStringToNumber("low"));
45-
} else if (
46-
prev < this.soundLevel.highThreshold &&
47-
curr >= this.soundLevel.highThreshold
48-
) {
44+
} else if (prev < high && curr >= high!) {
4945
soundLevelCallback(convertSoundEventStringToNumber("high"));
5046
}
5147
};

0 commit comments

Comments
 (0)