mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-09 06:12:20 -05:00
fixup! extend existing effects from Effect
This commit is contained in:
parent
5b8f0fce65
commit
618239654f
2 changed files with 15 additions and 13 deletions
|
@ -26,8 +26,8 @@ class AudioPlayer {
|
||||||
|
|
||||||
// Chain the effects and player together with the audio engine.
|
// Chain the effects and player together with the audio engine.
|
||||||
// outputNode -> "pitchEffect" -> panEffect -> audioEngine.input
|
// outputNode -> "pitchEffect" -> panEffect -> audioEngine.input
|
||||||
panEffect.connect(this.audioEngine.inputNode);
|
panEffect.connect(this.audioEngine);
|
||||||
pitchEffect.connect(panEffect.inputNode);
|
pitchEffect.connect(panEffect);
|
||||||
|
|
||||||
// reset effects to their default parameters
|
// reset effects to their default parameters
|
||||||
this.clearEffects();
|
this.clearEffects();
|
||||||
|
@ -137,8 +137,12 @@ class AudioPlayer {
|
||||||
this.outputNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME);
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -89,8 +89,8 @@ class Effect {
|
||||||
|
|
||||||
// Connect or disconnect from the graph if this now applies or no longer
|
// Connect or disconnect from the graph if this now applies or no longer
|
||||||
// applies an effect.
|
// applies an effect.
|
||||||
if (this._isPatch !== _isPatch && this.targetNode !== null) {
|
if (this._isPatch !== _isPatch && this.target !== null) {
|
||||||
this.connect(this.targetNode);
|
this.connect(this.target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,18 +117,16 @@ class Effect {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetNode = target.getInputNode();
|
let nextTarget = target;
|
||||||
|
|
||||||
let nextNode = targetNode;
|
|
||||||
if (this._isPatch) {
|
if (this._isPatch) {
|
||||||
nextNode = this.inputNode;
|
nextTarget = this;
|
||||||
this.outputNode.connect(targetNode);
|
this.outputNode.connect(target.getInputNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lastEffect === null) {
|
if (this.lastEffect === null) {
|
||||||
this.audioPlayer.connect(nextNode);
|
this.audioPlayer.connect(nextTarget);
|
||||||
} else {
|
} else {
|
||||||
this.lastEffect.connect(nextNode);
|
this.lastEffect.connect(nextTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue