diff --git a/src/components/Noise.vue b/src/components/Noise.vue index 6d05936..4e5159d 100644 --- a/src/components/Noise.vue +++ b/src/components/Noise.vue @@ -109,6 +109,7 @@ + + + + + + @@ -147,6 +182,7 @@ !isNaN(parseInt(value, 10)) || 'Invalid number', negative: value => (!isNaN(parseInt(value, 10)) && value <= 0) || "Can't be greater than 0" @@ -27,6 +32,7 @@ export default { this.noise = new Noise() this.filter = new Filter() this.tremolo = new Tremolo() + this.lfo = new LFO() }, methods: { playNoise () { @@ -48,6 +54,11 @@ export default { this.noise = new Noise({ volume: this.noiseVolume, type: this.noiseColor }).connect(this.filter) } + if (this.isFilterCutoffLFOEnabled) { + this.lfo = new LFO({ frequency: this.filterCutoffLFOFrequency, min: this.filterCutoffLFORange[0], max: this.filterCutoffLFORange[1] }) + this.lfo.connect(this.filter.frequency).start() + } + if (this.isTimerEnabled) { this.noise.sync().start(0).stop(this.noiseDuration) Transport.loopEnd = this.noiseDuration @@ -83,6 +94,12 @@ export default { updateFrequencyCutoff () { this.filter.set({ frequency: this.frequencyCutoff }) }, + updateFilterCutoffLFOFrequency () { + this.lfo.set({ frequency: this.filterCutoffLFOFrequency }) + }, + updateFilterCutoffLFORange () { + this.lfo.set({ min: this.filterCutoffLFORange[0], max: this.filterCutoffLFORange[1] }) + }, updateTremoloFrequency () { this.tremolo.set({ frequency: this.tremoloFrequency }) }, @@ -98,9 +115,16 @@ export default { } else if (!this.isFilterEnabled && this.isTremoloEnabled) { this.tremolo = new Tremolo({ frequency: this.tremoloFrequency, depth: this.tremoloDepth }).toDestination().start() this.noise.connect(this.tremolo) - } else if (this.isFilterEnabled && !this.isTremoloEnabled) { + } else if (this.isFilterEnabled && !this.isFilterCutoffLFOEnabled && !this.isTremoloEnabled) { this.filter = new Filter(this.frequencyCutoff, this.filterType).toDestination() this.noise.connect(this.filter) + this.lfo.disconnect() + this.lfo.stop() + } else if (this.isFilterEnabled && this.isFilterCutoffLFOEnabled && !this.isTremoloEnabled) { + this.filter = new Filter(this.frequencyCutoff, this.filterType).toDestination() + this.noise.connect(this.filter) + this.lfo = new LFO({ frequency: this.filterCutoffLFOFrequency, min: this.filterCutoffLFORange[0], max: this.filterCutoffLFORange[1] }) + this.lfo.connect(this.filter.frequency).start() } else { this.tremolo = new Tremolo({ frequency: this.tremoloFrequency, depth: this.tremoloDepth }).toDestination().start() this.filter = new Filter(this.frequencyCutoff, this.filterType).connect(this.tremolo)