Fix glitch when fading in sounds
parent
9e95b4c202
commit
576debf261
|
@ -131,18 +131,18 @@ export default class AudioSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fadeOut(time) {
|
fadeOut(time) {
|
||||||
|
this.gain.gain.setValueAtTime(this.getVolume(), this.context.getContext().currentTime);
|
||||||
if (!this.node) {
|
if (!this.node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.gain.gain.setValueAtTime(this.getVolume(), this.context.getContext().currentTime);
|
|
||||||
this.gain.gain.exponentialRampToValueAtTime(0.0001, this.context.getContext().currentTime + time);
|
this.gain.gain.exponentialRampToValueAtTime(0.0001, this.context.getContext().currentTime + time);
|
||||||
setTimeout(() => this.stop(), time * 1000);
|
setTimeout(() => this.stop(), time * 1000);
|
||||||
}
|
}
|
||||||
fadeIn(time) {
|
fadeIn(time) {
|
||||||
|
this.gain.gain.setValueAtTime(0.0001, this.context.getContext().currentTime);
|
||||||
if (!this.node) {
|
if (!this.node) {
|
||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,17 +82,17 @@ export class StreamingSource {
|
||||||
this.element.loop = true;
|
this.element.loop = true;
|
||||||
}
|
}
|
||||||
fadeIn(time) {
|
fadeIn(time) {
|
||||||
|
this.gain.gain.setValueAtTime(0.0001, this.context.getContext().currentTime);
|
||||||
if (!this.node) {
|
if (!this.node) {
|
||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
this.gain.gain.setValueAtTime(this.getVolume(), this.context.getContext().currentTime);
|
||||||
if (!this.node) {
|
if (!this.node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.gain.gain.setValueAtTime(this.getVolume(), this.context.getContext().currentTime);
|
|
||||||
this.gain.gain.exponentialRampToValueAtTime(0.0001, this.context.getContext().currentTime + time);
|
this.gain.gain.exponentialRampToValueAtTime(0.0001, this.context.getContext().currentTime + time);
|
||||||
setTimeout(() => this.stop(), time * 1000);
|
setTimeout(() => this.stop(), time * 1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue