mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 11:33:09 +00:00
Add failing tests for fanIn
This commit is contained in:
parent
8b0004ff00
commit
fdcbea3714
2 changed files with 34 additions and 1 deletions
|
@ -3,7 +3,7 @@ import { Merge } from "Tone/component";
|
|||
import { Split } from "Tone/component/channel/Split";
|
||||
import { Oscillator } from "Tone/source";
|
||||
import { Gain } from "./Gain";
|
||||
import { connect, disconnect } from "./ToneAudioNode";
|
||||
import { connect, disconnect, fanIn } from "./ToneAudioNode";
|
||||
import { PassAudio } from "test/helper/PassAudio";
|
||||
import { Offline } from "test/helper/Offline";
|
||||
|
||||
|
@ -218,6 +218,16 @@ describe("ToneAudioNode", () => {
|
|||
disconnect(input);
|
||||
}, false);
|
||||
});
|
||||
|
||||
it("can fan in multiple nodes to a destination", async () => {
|
||||
return PassAudio(input => {
|
||||
const input0 = new Gain();
|
||||
const input1 = new Gain();
|
||||
const input2 = new Gain();
|
||||
const output = new Gain();
|
||||
fanIn(output, input0, input1, input2);
|
||||
});
|
||||
});
|
||||
|
||||
it("can connect one channel to another", () => {
|
||||
return PassAudio(input => {
|
||||
|
@ -320,6 +330,15 @@ describe("ToneAudioNode", () => {
|
|||
disconnect(gain, output);
|
||||
});
|
||||
});
|
||||
|
||||
it("can fan in multiple nodes to a destination", async () => {
|
||||
const output = new Gain();
|
||||
const input0 = new Gain();
|
||||
const input1 = new Gain();
|
||||
const input2 = new Gain();
|
||||
fanIn(output, input0, input1, input2);
|
||||
expect(output.numberOfInputs).to.equal(3);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -257,6 +257,7 @@ export abstract class ToneAudioNode<Options extends ToneAudioNodeOptions = ToneA
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dispose and disconnect
|
||||
*/
|
||||
|
@ -376,3 +377,16 @@ export function disconnect(
|
|||
srcNode.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* connect the output of this node to the rest of the nodes in parallel.
|
||||
* @example
|
||||
* const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
|
||||
* const player1 = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
|
||||
* const filter = new Tone.Filter("G5").toDestination();
|
||||
* // connect nodes to a common destination
|
||||
* fanIn(filter, player, player1);
|
||||
*/
|
||||
export function fanIn(dstNode: InputNode, ...srcNodes: OutputNode[]): void {
|
||||
srcNodes.forEach(srcNode => connect(srcNode, dstNode));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue