From 7d24304b46a1cad9f6492a7c68084aaf973710a5 Mon Sep 17 00:00:00 2001 From: Talon Date: Fri, 5 Nov 2021 14:43:18 +0100 Subject: [PATCH] Fix some fading problems --- src/framework/resonator/index.js | 1 + src/framework/resonator/sources/audio-source.js | 2 +- src/framework/resonator/sources/streaming-source.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/framework/resonator/index.js b/src/framework/resonator/index.js index 0bade61..62577e7 100644 --- a/src/framework/resonator/index.js +++ b/src/framework/resonator/index.js @@ -44,6 +44,7 @@ export default class Resonator { stream(path, type = SourceType.MasterSource) { const element = new Audio(path); element.crossOrigin = 'anonymous'; + element.volume = 1; const source = new StreamingSource(this.graph, this.scene, this.context, element, type); return source; } diff --git a/src/framework/resonator/sources/audio-source.js b/src/framework/resonator/sources/audio-source.js index 5452771..2828713 100644 --- a/src/framework/resonator/sources/audio-source.js +++ b/src/framework/resonator/sources/audio-source.js @@ -140,7 +140,7 @@ export default class AudioSource { if (!this.node) { this.play(); } - this.gain.gain.setValueAtTime(0, this.context.getContext().currentTime); + this.gain.gain.setValueAtTime(0.0001, this.context.getContext().currentTime); this.gain.gain.exponentialRampToValueAtTime(this.volume, this.context.getContext().currentTime + time); } } diff --git a/src/framework/resonator/sources/streaming-source.js b/src/framework/resonator/sources/streaming-source.js index 16eb241..39e02c1 100644 --- a/src/framework/resonator/sources/streaming-source.js +++ b/src/framework/resonator/sources/streaming-source.js @@ -84,7 +84,7 @@ export class StreamingSource { if (!this.node) { this.play(); } - this.gain.gain.setValueAtTime(0, this.context.getContext().currentTime); + this.gain.gain.setValueAtTime(0.0001, this.context.getContext().currentTime); this.gain.gain.exponentialRampToValueAtTime(this.getVolume(), this.context.getContext().currentTime + time); } fadeOut(time) {