fixup! extend existing effects from Effect

This commit is contained in:
Michael "Z" Goddard 2018-06-05 14:42:46 -04:00
parent 5b8f0fce65
commit 618239654f
No known key found for this signature in database
GPG key ID: 762CD40DD5349872
2 changed files with 15 additions and 13 deletions

View file

@ -26,8 +26,8 @@ class AudioPlayer {
// Chain the effects and player together with the audio engine.
// outputNode -> "pitchEffect" -> panEffect -> audioEngine.input
panEffect.connect(this.audioEngine.inputNode);
pitchEffect.connect(panEffect.inputNode);
panEffect.connect(this.audioEngine);
pitchEffect.connect(panEffect);
// reset effects to their default parameters
this.clearEffects();
@ -137,8 +137,12 @@ class AudioPlayer {
this.outputNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME);
}
connect (node) {
this.outputNode.connect(node);
/**
* Connnect this player's output to another audio node
* @param {object} target - target whose node to should be connected
*/
connect (target) {
this.outputNode.connect(target.getInputNode());
}
/**

View file

@ -89,8 +89,8 @@ class Effect {
// Connect or disconnect from the graph if this now applies or no longer
// applies an effect.
if (this._isPatch !== _isPatch && this.targetNode !== null) {
this.connect(this.targetNode);
if (this._isPatch !== _isPatch && this.target !== null) {
this.connect(this.target);
}
}
@ -117,18 +117,16 @@ class Effect {
return;
}
const targetNode = target.getInputNode();
let nextNode = targetNode;
let nextTarget = target;
if (this._isPatch) {
nextNode = this.inputNode;
this.outputNode.connect(targetNode);
nextTarget = this;
this.outputNode.connect(target.getInputNode());
}
if (this.lastEffect === null) {
this.audioPlayer.connect(nextNode);
this.audioPlayer.connect(nextTarget);
} else {
this.lastEffect.connect(nextNode);
this.lastEffect.connect(nextTarget);
}
}