forked from external-repos/noisedash
Reset start button when noise ends, add remaining time display
This commit is contained in:
@@ -17,35 +17,62 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
|
<h2 class="headline font-weight-bold mb-5">
|
||||||
|
Playback
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<v-row justify="center">
|
||||||
<v-btn
|
<v-btn
|
||||||
:disabled="isDisabled"
|
:disabled="startDisabled"
|
||||||
|
class="mx-3"
|
||||||
@click="handleStart"
|
@click="handleStart"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="12">
|
|
||||||
<v-btn
|
<v-btn
|
||||||
@click="handleStop"
|
class="mx-3"
|
||||||
|
@click="stopTransport"
|
||||||
>
|
>
|
||||||
Stop
|
Stop
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|
||||||
|
<v-text-field
|
||||||
|
v-model="timeRemaining"
|
||||||
|
class="mx-3"
|
||||||
|
:value="timeRemaining"
|
||||||
|
label="Time Remaining"
|
||||||
|
filled
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
|
<h2 class="headline font-weight-bold mb-5">
|
||||||
|
Noise Settings
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<v-row justify="center">
|
||||||
|
<v-text-field
|
||||||
|
v-model="noiseVolume"
|
||||||
|
label="Volume"
|
||||||
|
class="mx-3"
|
||||||
|
/>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="noiseDuration"
|
v-model="noiseDuration"
|
||||||
label="Seconds"
|
label="Seconds"
|
||||||
|
class="mx-3"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="12">
|
|
||||||
<v-select
|
<v-select
|
||||||
v-model="noiseColor"
|
v-model="noiseColor"
|
||||||
:items="noiseColorOptions"
|
:items="noiseColorOptions"
|
||||||
label="Noise Color"
|
label="Noise Color"
|
||||||
|
class="mx-3"
|
||||||
/>
|
/>
|
||||||
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
@@ -58,25 +85,39 @@
|
|||||||
name: "Noise",
|
name: "Noise",
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
isDisabled: false,
|
startDisabled: false,
|
||||||
noiseDuration: 4,
|
noiseDuration: 4,
|
||||||
|
timeRemaining: 0,
|
||||||
noiseColorOptions: ["pink", "white", "brown"],
|
noiseColorOptions: ["pink", "white", "brown"],
|
||||||
noiseColor: "pink"
|
noiseColor: "pink",
|
||||||
|
noiseVolume: -10
|
||||||
}),
|
}),
|
||||||
created() {
|
created() {
|
||||||
|
this.noise = new Noise()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleStart() {
|
handleStart() {
|
||||||
this.isDisabled = true
|
this.startDisabled = true
|
||||||
Transport.cancel()
|
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)
|
this.noise.sync().start(0).stop(this.noiseDuration)
|
||||||
Transport.start()
|
Transport.start()
|
||||||
Transport.loopEnd = this.noiseDuration
|
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()
|
Transport.stop()
|
||||||
this.isDisabled = false
|
this.startDisabled = false
|
||||||
|
|
||||||
|
clearInterval(this.timeRemainingInterval)
|
||||||
|
this.timeRemaining = 0
|
||||||
|
},
|
||||||
|
timer() {
|
||||||
|
this.timeRemaining -= 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user