|
|
|
@ -39,7 +39,8 @@
|
|
|
|
manualSeconds:0,
|
|
|
|
manualSeconds:0,
|
|
|
|
analyser:null,
|
|
|
|
analyser:null,
|
|
|
|
secondsToSubtract:0,
|
|
|
|
secondsToSubtract:0,
|
|
|
|
micThreshold:0
|
|
|
|
micThreshold:0,
|
|
|
|
|
|
|
|
micLevel:0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
@ -77,9 +78,9 @@
|
|
|
|
const array = new Uint8Array(this.analyser.frequencyBinCount);
|
|
|
|
const array = new Uint8Array(this.analyser.frequencyBinCount);
|
|
|
|
this.analyser.getByteFrequencyData(array);
|
|
|
|
this.analyser.getByteFrequencyData(array);
|
|
|
|
const arraySum = array.reduce((a, value) => a + value, 0);
|
|
|
|
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++;
|
|
|
|
this.secondsToSubtract++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -142,7 +143,7 @@
|
|
|
|
<em>
|
|
|
|
<em>
|
|
|
|
{{formatTime(totalSeconds)}}
|
|
|
|
{{formatTime(totalSeconds)}}
|
|
|
|
</em>
|
|
|
|
</em>
|
|
|
|
Mic Threshold: <input type="number" v-model="micThreshold"/>
|
|
|
|
Mic Threshold (current level: {{Math.round(micLevel)}}): <input type="number" v-model="micThreshold"/>
|
|
|
|
<button :disabled="running" @click="start">Start</button>
|
|
|
|
<button :disabled="running" @click="start">Start</button>
|
|
|
|
<button :disabled="!running" @click="stop">Stop</button>
|
|
|
|
<button :disabled="!running" @click="stop">Stop</button>
|
|
|
|
<button :disabled="running || totalSeconds === 0" @click="reset">Reset</button>
|
|
|
|
<button :disabled="running || totalSeconds === 0" @click="reset">Reset</button>
|
|
|
|
|