mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
connection tests and channel property tests
This commit is contained in:
parent
cc18de471d
commit
8c2979fe8a
1 changed files with 99 additions and 138 deletions
|
@ -1,4 +1,7 @@
|
|||
import { expect } from "chai";
|
||||
import { Merge } from "Tone/component";
|
||||
import { Split } from "Tone/component/channel/Split";
|
||||
import { Oscillator } from "Tone/source";
|
||||
import { Gain } from "./Gain";
|
||||
|
||||
describe("ToneAudioNode", () => {
|
||||
|
@ -43,62 +46,41 @@ describe("ToneAudioNode", () => {
|
|||
node.dispose();
|
||||
});
|
||||
|
||||
// it("reports its inputs and outputs", () => {
|
||||
// const node0 = new ToneAudioNode({
|
||||
// numberOfInputs : 3,
|
||||
// numberOfOutputs : 2,
|
||||
// });
|
||||
// expect(node0.numberOfInputs).to.equal(3);
|
||||
// expect(node0.numberOfOutputs).to.equal(2);
|
||||
// node0.dispose();
|
||||
it("reports its inputs and outputs", () => {
|
||||
const node0 = new Merge({
|
||||
channels: 4,
|
||||
});
|
||||
expect(node0.numberOfInputs).to.equal(4);
|
||||
expect(node0.numberOfOutputs).to.equal(1);
|
||||
node0.dispose();
|
||||
|
||||
// const node1 = new ToneAudioNode({
|
||||
// numberOfInputs : 0,
|
||||
// numberOfOutputs : 1,
|
||||
// });
|
||||
// expect(node1.numberOfInputs).to.equal(0);
|
||||
// expect(node1.numberOfOutputs).to.equal(1);
|
||||
// node1.dispose();
|
||||
const node1 = new Split(4);
|
||||
expect(node1.numberOfInputs).to.equal(1);
|
||||
expect(node1.numberOfOutputs).to.equal(4);
|
||||
node1.dispose();
|
||||
|
||||
// const node2 = new ToneAudioNode({
|
||||
// numberOfInputs : 1,
|
||||
// numberOfOutputs : 0,
|
||||
// });
|
||||
// expect(node2.numberOfInputs).to.equal(1);
|
||||
// expect(node2.numberOfOutputs).to.equal(0);
|
||||
// node2.dispose();
|
||||
// });
|
||||
const node2 = new Oscillator();
|
||||
expect(node2.numberOfInputs).to.equal(0);
|
||||
expect(node2.numberOfOutputs).to.equal(1);
|
||||
node2.dispose();
|
||||
});
|
||||
|
||||
// it("is able to get and set the channelCount, channelCountMode and channelInterpretation", () => {
|
||||
// const node0 = new ToneAudioNode({
|
||||
// channelCount : 4,
|
||||
// numberOfInputs: 1,
|
||||
// numberOfOutputs: 1,
|
||||
// });
|
||||
// expect(node0.channelCount).to.equal(4);
|
||||
// node0.channelCount = 1;
|
||||
// expect(node0.channelCount).to.equal(1);
|
||||
// node0.dispose();
|
||||
it("is able to get and set the channelCount, channelCountMode and channelInterpretation", () => {
|
||||
const gainNode = new Gain();
|
||||
|
||||
// const node1 = new ToneAudioNode({
|
||||
// numberOfInputs : 1,
|
||||
// numberOfOutputs : 2,
|
||||
// });
|
||||
// expect(node1.channelCountMode).to.equal("max");
|
||||
// node1.channelCountMode = "explicit";
|
||||
// expect(node1.channelCountMode).to.equal("explicit");
|
||||
// node1.dispose();
|
||||
expect(gainNode.channelCount).to.equal(2);
|
||||
gainNode.channelCount = 1;
|
||||
expect(gainNode.channelCount).to.equal(1);
|
||||
|
||||
// const node2 = new ToneAudioNode({
|
||||
// channelInterpretation : "speakers",
|
||||
// numberOfInputs : 2,
|
||||
// numberOfOutputs : 0,
|
||||
// });
|
||||
// expect(node2.channelInterpretation).to.equal("speakers");
|
||||
// node2.channelInterpretation = "discrete";
|
||||
// expect(node2.channelInterpretation).to.equal("discrete");
|
||||
// node2.dispose();
|
||||
// });
|
||||
expect(gainNode.channelInterpretation).to.equal("speakers");
|
||||
gainNode.channelInterpretation = "discrete";
|
||||
expect(gainNode.channelInterpretation).to.equal("discrete");
|
||||
|
||||
expect(gainNode.channelCountMode).to.equal("max");
|
||||
gainNode.channelCountMode = "clamped-max";
|
||||
expect(gainNode.channelCountMode).to.equal("clamped-max");
|
||||
gainNode.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
context("methods", () => {
|
||||
|
@ -113,6 +95,7 @@ describe("ToneAudioNode", () => {
|
|||
const nodeB = new Gain();
|
||||
nodeA.connect(nodeB);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
it("disconnect()", () => {
|
||||
|
@ -121,113 +104,91 @@ describe("ToneAudioNode", () => {
|
|||
nodeA.connect(nodeB);
|
||||
nodeA.disconnect(nodeB);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
it("fan()", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
nodeA.fan(nodeB);
|
||||
const nodeC = new Gain();
|
||||
nodeA.fan(nodeB, nodeC);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
nodeC.dispose();
|
||||
});
|
||||
|
||||
it("chain()", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
nodeA.chain(nodeB);
|
||||
const nodeC = new Gain();
|
||||
nodeA.chain(nodeB, nodeC);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
nodeC.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
// context("connections", () => {
|
||||
// it("can connect with args", () => {
|
||||
// const nodeA = new ToneAudioNode({
|
||||
// numberOfOutputs : 1,
|
||||
// });
|
||||
// const nodeB = new ToneAudioNode({
|
||||
// numberOfInputs: 1,
|
||||
// });
|
||||
// nodeA.connect(nodeB, 0, 0);
|
||||
// nodeA.dispose();
|
||||
// nodeB.dispose();
|
||||
// });
|
||||
context("connections", () => {
|
||||
it("can connect with args", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
nodeA.connect(nodeB, 0, 0);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
// it("can connect with no args", () => {
|
||||
// const nodeA = new ToneAudioNode({
|
||||
// numberOfOutputs: 1,
|
||||
// });
|
||||
// const nodeB = new ToneAudioNode({
|
||||
// numberOfInputs: 1,
|
||||
// });
|
||||
// nodeA.connect(nodeB);
|
||||
// nodeA.dispose();
|
||||
// nodeB.dispose();
|
||||
// });
|
||||
it("can connect with no args", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
nodeA.connect(nodeB);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
// it("can connect with one arg", () => {
|
||||
// const nodeA = new ToneAudioNode({
|
||||
// numberOfOutputs: 2,
|
||||
// });
|
||||
// const nodeB = new ToneAudioNode({
|
||||
// numberOfInputs: 1,
|
||||
// });
|
||||
// nodeA.connect(nodeB, 1);
|
||||
// nodeA.dispose();
|
||||
// nodeB.dispose();
|
||||
// });
|
||||
it("can connect with one arg", () => {
|
||||
const nodeA = new Split(2);
|
||||
const nodeB = new Gain();
|
||||
nodeA.connect(nodeB, 1);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
// it("Tone nodes can disconnect from everything with no args", () => {
|
||||
// const nodeA = new ToneAudioNode({
|
||||
// numberOfOutputs: 1,
|
||||
// });
|
||||
// const nodeB = new ToneAudioNode({
|
||||
// numberOfInputs: 1,
|
||||
// });
|
||||
// nodeA.connect(nodeB);
|
||||
// nodeA.disconnect();
|
||||
// nodeA.dispose();
|
||||
// nodeB.dispose();
|
||||
// });
|
||||
it("Tone nodes can disconnect from everything with no args", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
nodeA.connect(nodeB);
|
||||
nodeA.disconnect();
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
// it("Tone nodes can disconnect from a specific node", () => {
|
||||
// const nodeA = new ToneAudioNode({
|
||||
// numberOfOutputs: 1,
|
||||
// });
|
||||
// const nodeB = new ToneAudioNode({
|
||||
// numberOfInputs: 1,
|
||||
// });
|
||||
// nodeA.connect(nodeB);
|
||||
// nodeA.disconnect(nodeB);
|
||||
// nodeA.dispose();
|
||||
// nodeB.dispose();
|
||||
// });
|
||||
it("Tone nodes can disconnect from a specific node", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
nodeA.connect(nodeB);
|
||||
nodeA.disconnect(nodeB);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
// it("Tone nodes can disconnect from a specific node and input/output", () => {
|
||||
// const nodeA = new ToneAudioNode({
|
||||
// numberOfOutputs: 2,
|
||||
// });
|
||||
// const nodeB = new ToneAudioNode({
|
||||
// numberOfInputs: 2,
|
||||
// });
|
||||
// nodeA.connect(nodeB, 1, 1);
|
||||
// nodeA.disconnect(nodeB, 1, 1);
|
||||
// nodeA.dispose();
|
||||
// nodeB.dispose();
|
||||
// });
|
||||
it("Tone nodes can disconnect from a specific node and input/output", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Merge();
|
||||
nodeA.connect(nodeB, 0, 1);
|
||||
nodeA.disconnect(nodeB, 0, 1);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
|
||||
// it("throws an error if they are not connected", () => {
|
||||
// // const nodeA = new ToneAudioNode({
|
||||
// // numberOfOutputs: 2,
|
||||
// // });
|
||||
// // const nodeB = new ToneAudioNode({
|
||||
// // numberOfInputs: 2,
|
||||
// // });
|
||||
// // nodeA.connect(nodeB, 1, 1);
|
||||
// // expect(() => {
|
||||
// // nodeA.disconnect(nodeB, 10, 0);
|
||||
// // }).throws(Error);
|
||||
// // nodeA.dispose();
|
||||
// // nodeB.dispose();
|
||||
// });
|
||||
// });
|
||||
it("throws an error if they are not connected", () => {
|
||||
const nodeA = new Gain();
|
||||
const nodeB = new Gain();
|
||||
expect(() => {
|
||||
nodeA.disconnect(nodeB);
|
||||
}).throws(Error);
|
||||
nodeA.dispose();
|
||||
nodeB.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue