diff --git a/src/components/Noise.vue b/src/components/Noise.vue
index db7ada3..af80730 100644
--- a/src/components/Noise.vue
+++ b/src/components/Noise.vue
@@ -17,35 +17,62 @@
-
- Start
-
+
+ Playback
+
+
+
+
+ Start
+
+
+
+ Stop
+
+
+
+
-
- Stop
-
-
+
+ Noise Settings
+
-
-
-
+
+
-
-
+
+
+
+
@@ -58,25 +85,39 @@
name: "Noise",
data: () => ({
- isDisabled: false,
+ startDisabled: false,
noiseDuration: 4,
+ timeRemaining: 0,
noiseColorOptions: ["pink", "white", "brown"],
- noiseColor: "pink"
+ noiseColor: "pink",
+ noiseVolume: -10
}),
created() {
+ this.noise = new Noise()
},
methods: {
handleStart() {
- this.isDisabled = true
+ this.startDisabled = true
Transport.cancel()
- this.noise = new Noise({volume: -10, type: this.noiseColor}).toDestination()
+ this.noise = new Noise({volume: this.noiseVolume, type: this.noiseColor}).toDestination()
this.noise.sync().start(0).stop(this.noiseDuration)
Transport.start()
Transport.loopEnd = this.noiseDuration
+ this.transportInterval = setInterval(() => this.stopTransport(), this.noiseDuration * 1000 + 100)
+
+ this.timeRemaining = this.noiseDuration
+ this.timeRemainingInterval = setInterval(() => this.timer(), 1000)
},
- handleStop() {
+ stopTransport() {
+ clearInterval(this.transportInterval)
Transport.stop()
- this.isDisabled = false
+ this.startDisabled = false
+
+ clearInterval(this.timeRemainingInterval)
+ this.timeRemaining = 0
+ },
+ timer() {
+ this.timeRemaining -= 1
}
},
}