dev-audioprocessing/pages/onboarding.vue

136 lines
3.9 KiB
Vue
Raw Permalink Normal View History

2022-12-20 22:17:12 +00:00
<template>
<div>
2023-01-05 20:15:48 +00:00
<video-background
2023-01-27 03:33:29 +00:00
src="/video/bg-video.mp4"
2023-01-05 20:15:48 +00:00
style=" height: 100vh;"
2023-06-11 19:20:39 +00:00
poster="/images/poster.png"
2023-01-05 20:15:48 +00:00
>
2023-02-03 09:27:36 +00:00
<div class="container-fluid pt-3">
2023-06-11 19:20:39 +00:00
2022-12-20 22:25:31 +00:00
<div class="row">
2023-02-03 09:27:36 +00:00
<div class="col-12 col-lg-3 text-center text-sm-start">
2023-01-05 20:15:48 +00:00
<nuxt-link class="navbar-brand" to="/">
<img src="/svglogo.svg" height="35" class="img " alt="imae">
</nuxt-link>
2022-12-20 22:25:31 +00:00
</div>
2023-06-11 19:20:39 +00:00
<div class="col-12 text-center d-flex justify-content-center col-lg-12 pt-1">
<div class="progress mx-auto mt-2 " style="width: 50%;height: 12px">
<div class="progress-bar bar" style="transition: 0.1s !important;" :style="{width:bar_width+'%'}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
2022-12-20 22:25:31 +00:00
</div>
2023-06-11 19:20:39 +00:00
<div class="col-12 pt-3">
<h6 class="text-muted text-center">{{t("We are analyzing your background noise...")}} </h6>
</div>
2022-12-20 22:25:31 +00:00
</div>
2022-12-20 23:01:19 +00:00
2022-12-20 22:25:31 +00:00
<NuxtPage page-key="child" />
2022-12-23 14:42:30 +00:00
2023-06-11 19:20:39 +00:00
<div class="row pt-5 mt-0 mt-sm-4 " style="position: fixed;bottom: 0px;left: 0;right: 0">
<div class="col-12 text-center pt-5 mt-3 pb-2 mb-2" >
2023-06-11 20:22:41 +00:00
<NuxtLink class="btn btn-warning px-2 mx-1" exact-active-class="px-4 mx-2" :to="localePath('/onboarding/selectinput')"></NuxtLink>
2023-06-11 19:20:39 +00:00
<NuxtLink class="btn btn-warning px-2" exact-active-class="px-4 mx-2" :to="localePath('/onboarding')"></NuxtLink>
<NuxtLink class="btn btn-warning px-2 mx-2" exact-active-class="px-4 mx-2" :to="localePath('/onboarding/onboarding2')"></NuxtLink>
2023-06-11 19:20:39 +00:00
<NuxtLink class="btn btn-warning px-2 " exact-active-class="px-4 mx-2" :to="localePath('/onboarding/onboarding3')"></NuxtLink>
<NuxtLink class="btn btn-warning px-2 mx-2" exact-active-class="px-4 mx-2" :to="localePath('/onboarding/onboarding4')"></NuxtLink>
<h6 class="text-muted text-center pt-3">You can customize your selection later</h6>
</div>
</div>
2022-12-20 22:25:31 +00:00
</div>
2023-01-05 20:15:48 +00:00
</video-background>
2022-12-20 22:17:12 +00:00
</div>
</template>
2022-12-20 22:25:31 +00:00
2022-12-20 23:01:19 +00:00
<script>
2023-01-01 18:33:52 +00:00
import {useCounterStore} from '@/stores/counter';
import {mapState,mapActions} from "pinia";
2022-12-20 23:01:19 +00:00
export default {
2023-06-11 19:20:39 +00:00
setup() {
const {t} = useI18n()
const localePath = useLocalePath()
return {
t,
localePath,
}
},
computed: {
...mapState(useCounterStore, ['count'])
},
2023-01-01 18:33:52 +00:00
methods:{
...mapActions(useCounterStore,['increment']),
2023-06-11 19:20:39 +00:00
...mapActions(useCounterStore,['decrement']),
updateMeter(){
requestAnimationFrame(this.updateMeter);
this.analyser.getByteFrequencyData(this.dataArray);
var rms = this.getRMS(this.dataArray);
var level = 20 * Math.log10(rms / 128);
level = Math.max(0, Math.min(100, level + 100));
// bar.style.width = level + '%';
this.bar_width=level;
},
getRMS(dataArray) {
var rms = 0;
for (var i = 0; i < dataArray.length; i++) {
rms += dataArray[i] * dataArray[i];
}
rms /= dataArray.length;
rms = Math.sqrt(rms);
return rms;
}
2023-01-01 18:33:52 +00:00
},
2023-06-11 19:20:39 +00:00
mounted() {
navigator.mediaDevices.getUserMedia({audio: true})
.then((stream)=> {
var audioCtx = new AudioContext();
var source = audioCtx.createMediaStreamSource(stream);
this.analyser = audioCtx.createAnalyser();
source.connect(this.analyser);
this.analyser.fftSize = 2048;
var bufferLength = this.analyser.frequencyBinCount;
this.dataArray = new Uint8Array(bufferLength);
this.updateMeter();
})
.catch(function(err) {
console.log('Error accessing microphone', err);
});
},
2022-12-20 23:01:19 +00:00
data(){
return{
bar_val:25,
2023-06-11 19:20:39 +00:00
bar_width:0,
analyser:null,
dataArray:null,
2022-12-20 23:01:19 +00:00
}
}
2022-12-20 22:25:31 +00:00
}
</script>
2023-01-05 20:15:48 +00:00
<style >
2022-12-20 22:25:31 +00:00
.bar{
2023-03-07 04:28:32 +00:00
background-color: #e9c046 !important;
2022-12-20 22:17:12 +00:00
}
2023-01-05 20:15:48 +00:00
.checklabel{
2023-03-12 15:21:34 +00:00
background-color: white !important;
width: 150px ;
height: 134px ;
2023-01-05 20:15:48 +00:00
}
2023-06-11 19:20:39 +00:00
.px-4{
transition: 1s;
}
</style>