Fix some fading problems

master
Talon 2021-11-05 14:43:18 +01:00
parent c5a4167846
commit 7d24304b46
3 changed files with 3 additions and 2 deletions

View File

@ -44,6 +44,7 @@ export default class Resonator {
stream(path, type = SourceType.MasterSource) { stream(path, type = SourceType.MasterSource) {
const element = new Audio(path); const element = new Audio(path);
element.crossOrigin = 'anonymous'; element.crossOrigin = 'anonymous';
element.volume = 1;
const source = new StreamingSource(this.graph, this.scene, this.context, element, type); const source = new StreamingSource(this.graph, this.scene, this.context, element, type);
return source; return source;
} }

View File

@ -140,7 +140,7 @@ export default class AudioSource {
if (!this.node) { if (!this.node) {
this.play(); 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); this.gain.gain.exponentialRampToValueAtTime(this.volume, this.context.getContext().currentTime + time);
} }
} }

View File

@ -84,7 +84,7 @@ export class StreamingSource {
if (!this.node) { if (!this.node) {
this.play(); 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); this.gain.gain.exponentialRampToValueAtTime(this.getVolume(), this.context.getContext().currentTime + time);
} }
fadeOut(time) { fadeOut(time) {