light green when timer is running but mic threshold not exceeded

mic_level
Matthew Huntington 2 years ago
parent c1699f5e1c
commit 3752ce25d4

@ -40,7 +40,8 @@
analyser:null, analyser:null,
secondsToSubtract:0, secondsToSubtract:0,
micThreshold:0, micThreshold:0,
micLevel:0 micLevel:0,
micThresholdExceeded:false
} }
}, },
methods: { methods: {
@ -80,8 +81,11 @@
const arraySum = array.reduce((a, value) => a + value, 0); const arraySum = array.reduce((a, value) => a + value, 0);
this.micLevel = arraySum / array.length; this.micLevel = arraySum / array.length;
if(this.micLevel < this.micThreshold){ if(this.micLevel > this.micThreshold){
this.micThresholdExceeded = true;
} else {
this.secondsToSubtract++; this.secondsToSubtract++;
this.micThresholdExceeded = false;
} }
this.totalSeconds = getAccumulatedSeconds(Date.now(), this.startTime) - this.secondsToSubtract + this.savedPreviousSeconds; this.totalSeconds = getAccumulatedSeconds(Date.now(), this.startTime) - this.secondsToSubtract + this.savedPreviousSeconds;
@ -139,7 +143,7 @@
<template> <template>
<h2>Timer</h2> <h2>Timer</h2>
<div :class="{running:running}"> <div :class="{running:running, micThresholdExceeded:micThresholdExceeded}">
<em> <em>
{{formatTime(totalSeconds)}} {{formatTime(totalSeconds)}}
</em> </em>
@ -185,8 +189,13 @@ label, [type="submit"] {
} }
.running { .running {
background:lightgreen;
}
.running.micThresholdExceeded {
background:green; background:green;
} }
button, em { button, em {
margin: 1em 0; margin: 1em 0;
display:block; display:block;

Loading…
Cancel
Save