From df25b5600b1b38e885944aca531a126700dac981 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 11 Sep 2021 21:40:08 -0400 Subject: [PATCH] Add toggles to each source --- package-lock.json | 5 +++++ package.json | 1 + src/App.vue | 1 + src/audio.ts | 14 ++++++++++++++ src/components/VoreAudio.vue | 18 +++++++++++++----- src/components/sources/SourceNode.vue | 19 +++++++++++++++++-- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ad3d7e..f7d5724 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2423,6 +2423,11 @@ "wnumb": "^1.2.0" } }, + "@vueform/toggle": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@vueform/toggle/-/toggle-2.0.1.tgz", + "integrity": "sha512-Hx26jK+hJUndP4zUBXdScYnTlDwXhkRl+sPW1srkOHqImAcyV2932LzavZQIqK1MhBBukKt+X0wkR5cJL7duYw==" + }, "@webassemblyjs/ast": { "version": "1.9.0", "resolved": "https://registry.nlark.com/@webassemblyjs/ast/download/@webassemblyjs/ast-1.9.0.tgz?cache=0&sync_timestamp=1625473420080&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40webassemblyjs%2Fast%2Fdownload%2F%40webassemblyjs%2Fast-1.9.0.tgz", diff --git a/package.json b/package.json index a032f7c..55a50cb 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "@vueform/slider": "^2.0.5", + "@vueform/toggle": "^2.0.1", "core-js": "^3.6.5", "postcss": "^8.3.6", "reflect-metadata": "^0.1.13", diff --git a/src/App.vue b/src/App.vue index 166d412..a44fbab 100644 --- a/src/App.vue +++ b/src/App.vue @@ -32,3 +32,4 @@ body { + diff --git a/src/audio.ts b/src/audio.ts index e52b1cf..26415f6 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -41,6 +41,20 @@ export abstract class Source extends Node { protected sounds: Array = []; public gain: GainNode; public output: GainNode; + public _active = true; + + get active(): boolean { + return this._active; + } + + set active(value: boolean) { + this._active = value; + + this.output.gain.linearRampToValueAtTime( + value ? 1.0 : 0.0, + context.currentTime + 0.5 + ); + } @exposedNumber("Volume", 0, 1) public volume = 1; diff --git a/src/components/VoreAudio.vue b/src/components/VoreAudio.vue index 2f39b99..fb39ab6 100644 --- a/src/components/VoreAudio.vue +++ b/src/components/VoreAudio.vue @@ -9,10 +9,7 @@
Many sounds by Jit!
- - - - +
source.tick(100), 100); + source.active = false; + this.sources.push(source); } @@ -103,6 +102,8 @@ export default class VoreAudio extends Vue { console.log(source); setInterval(() => source.tick(100), 100); + source.active = false; + this.sources.push(source); } @@ -131,7 +132,7 @@ export default class VoreAudio extends Vue { source.loadSound("gurgles/gurgle (21).ogg"); source.output.connect(this.context.destination); source.start(); - source.gain.gain.value = 0.5; + source.volume = 0.5; console.log(source); setInterval(() => source.tick(100), 100); @@ -142,6 +143,13 @@ export default class VoreAudio extends Vue { clearCache(); } + start(): void { + this.startGlorps(); + this.startGurgles(); + this.startDigestion(); + this.startBurps(); + } + mounted(): void { this.context = setup(); } diff --git a/src/components/sources/SourceNode.vue b/src/components/sources/SourceNode.vue index e69514f..0eefa69 100644 --- a/src/components/sources/SourceNode.vue +++ b/src/components/sources/SourceNode.vue @@ -1,5 +1,6 @@