mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -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.
|
||||
// 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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue