From c6d110adcb755cd94b4fabdeb8cc66b51f7af728 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 22 Feb 2018 19:23:36 +0000 Subject: [PATCH] add noise --- src/components/Main.vue | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/components/Main.vue b/src/components/Main.vue index 739fc57..d27c18a 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -35,6 +35,14 @@
+ +
+ + + +
+
+

{{ preset.charAt(0).toUpperCase() + preset.slice(1) }} Waves

{{ presets[preset].description }}

@@ -52,9 +60,12 @@ export default { data () { return { started: false, + startedNoise: false, merge: null, leftCh: null, rightCh: null, + noise: null, + noiseVolume: -20, waveform: 'sine', preset: null, presets: { @@ -155,9 +166,12 @@ export default { init: function () { this.merge = new Tone.Merge().toMaster() this.leftCh = new Tone.Oscillator().connect(this.merge.left) - this.rightCh = new Tone.Oscillator().connect(this.merge.right) this.leftCh.frequency.value = 440 + this.rightCh = new Tone.Oscillator().connect(this.merge.right) this.rightCh.frequency.value = 430 + this.noise = new Tone.Noise().toMaster() + this.noise.type = 'brown' + this.noise.volume.value = -20 // = 50 % }, start: function () { this.leftCh.start() @@ -168,6 +182,14 @@ export default { this.leftCh.stop() this.rightCh.stop() this.started = false + }, + startNoise: function () { + this.noise.start() + this.startedNoise = true + }, + stopNoise: function () { + this.noise.stop() + this.startedNoise = false } }, watch: { @@ -179,6 +201,9 @@ export default { this.waveform = this.presets[this.preset].waveform this.leftCh.frequency.value = this.presets[this.preset].left this.rightCh.frequency.value = this.presets[this.preset].right + }, + noiseVolume: function () { + this.noise.volume.value = this.noiseVolume } } } @@ -222,7 +247,15 @@ input { height: 1.867em; } -.basic { +.basic, .advanced { margin-bottom: 0.5em; } + +input.noise-volume { + margin: 0; +} + +button.noise-volume { + padding: 0 3px; +}