From c1699f5e1cc97826d6a26c0b097f48b269da36cc Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Wed, 22 Nov 2023 11:42:18 -0500 Subject: [PATCH] display mic level --- src/components/timer.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/timer.vue b/src/components/timer.vue index de3e4e3..8209bf0 100644 --- a/src/components/timer.vue +++ b/src/components/timer.vue @@ -39,7 +39,8 @@ manualSeconds:0, analyser:null, secondsToSubtract:0, - micThreshold:0 + micThreshold:0, + micLevel:0 } }, methods: { @@ -77,9 +78,9 @@ const array = new Uint8Array(this.analyser.frequencyBinCount); this.analyser.getByteFrequencyData(array); const arraySum = array.reduce((a, value) => a + value, 0); - const micLevel = arraySum / array.length; + this.micLevel = arraySum / array.length; - if(micLevel < this.micThreshold){ + if(this.micLevel < this.micThreshold){ this.secondsToSubtract++; } @@ -142,7 +143,7 @@ {{formatTime(totalSeconds)}} - Mic Threshold: + Mic Threshold (current level: {{Math.round(micLevel)}}):