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

Loading…
Cancel
Save