Add Noise and Transport components

This commit is contained in:
KevinNThomas
2021-07-17 22:30:40 -07:00
parent 22f9d5f118
commit ad9cb7a6f8
4 changed files with 103 additions and 3 deletions

49
src/components/Noise.vue Normal file
View File

@@ -0,0 +1,49 @@
<template>
<v-container>
<v-row class="text-center">
<v-col cols="12">
<v-btn
:disabled="isDisabled"
@click="handleStart"
>
Start
</v-btn>
</v-col>
<v-col cols="12">
<v-btn
@click="handleStop"
>
Stop
</v-btn>
</v-col>
</v-row>
</v-container>
</template>
<script>
import { Noise, Transport } from "tone";
export default {
name: 'Noise',
data: () => ({
isDisabled: false
}),
created() {
this.noise = new Noise({volume: -10, type: "brown"}).toDestination()
},
methods: {
handleStart() {
this.isDisabled = true
Transport.scheduleOnce((time) => {
this.noise.start(time).stop(time + 2)
})
Transport.start()
},
handleStop() {
Transport.stop()
this.isDisabled = false
}
},
}
</script>