@blibliki/engine 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blibliki/engine",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/main.cjs.js",
6
6
  "module": "dist/main.esm.js",
package/src/Engine.ts CHANGED
@@ -120,7 +120,7 @@ class Engine {
120
120
  if (audioModule instanceof PolyModule && numberOfVoices)
121
121
  audioModule.numberOfVoices = numberOfVoices;
122
122
 
123
- //if (numberOfVoices) this.updateRoutes();
123
+ if (numberOfVoices) this.updateRoutes();
124
124
 
125
125
  return audioModule.serialize();
126
126
  }
@@ -134,6 +134,7 @@ class Engine {
134
134
  }
135
135
 
136
136
  addRoute(props: Optional<RouteInterface, "id">) {
137
+ if (!this.validRoute(props)) throw Error("Invalid route, incompatible IOs");
137
138
  const route = createRoute(props);
138
139
  const newRoutes = { ...this.routes, [route.id]: route };
139
140
 
@@ -143,6 +144,18 @@ class Engine {
143
144
  return route;
144
145
  }
145
146
 
147
+ validRoute(props: Optional<RouteInterface, "id">): boolean {
148
+ const { sourceId, sourceIOId, destinationId, destinationIOId } = props;
149
+
150
+ const output = this.findById(sourceId).outputs.find(sourceIOId);
151
+ const input = this.findById(destinationId).inputs.find(destinationIOId);
152
+
153
+ return (
154
+ !!(output?.isMidi && input?.isMidi) ||
155
+ !!(output?.isAudio && input?.isAudio)
156
+ );
157
+ }
158
+
146
159
  removeRoute(id: string) {
147
160
  delete this.routes[id];
148
161
  this.updateRoutes();
@@ -2,7 +2,8 @@ import { InputNode } from "tone";
2
2
  import IONode, { IOType, IIONode } from "./Node";
3
3
  import MonoModule, { Connectable } from "../Module/index";
4
4
  import { AnyObject } from "../../types";
5
- import { ForwardInput, ForwardOutput } from "./ForwardNode";
5
+ import { ForwardAudioInput } from "./ForwardNode";
6
+ import { AnyAudioInput, AnyAudioOuput } from ".";
6
7
 
7
8
  export type AudioIO = AudioInput | AudioOutput;
8
9
 
@@ -31,11 +32,11 @@ export class AudioInput extends IONode implements IAudioInput {
31
32
  this.internalModule = props.internalModule;
32
33
  }
33
34
 
34
- plug(io: AudioOutput | ForwardOutput, plugOther: boolean = true) {
35
+ plug(io: AnyAudioOuput, plugOther: boolean = true) {
35
36
  super.plug(io, plugOther);
36
37
  }
37
38
 
38
- unPlug(io: AudioOutput | ForwardOutput, plugOther: boolean = true) {
39
+ unPlug(io: AnyAudioOuput, plugOther: boolean = true) {
39
40
  super.unPlug(io, plugOther);
40
41
  }
41
42
 
@@ -57,16 +58,16 @@ export class AudioOutput extends IONode implements IAudioOutput {
57
58
  this.internalModule = props.internalModule;
58
59
  }
59
60
 
60
- plug(io: AudioInput | ForwardInput, plugOther: boolean = true) {
61
+ plug(io: AnyAudioInput, plugOther: boolean = true) {
61
62
  super.plug(io, plugOther);
62
- if (io instanceof ForwardInput) return;
63
+ if (io instanceof ForwardAudioInput) return;
63
64
 
64
65
  this.internalModule.connect(io.internalModule);
65
66
  }
66
67
 
67
- unPlug(io: AudioInput | ForwardInput, plugOther: boolean = true) {
68
+ unPlug(io: AnyAudioInput, plugOther: boolean = true) {
68
69
  super.unPlug(io, plugOther);
69
- if (io instanceof ForwardInput) return;
70
+ if (io instanceof ForwardAudioInput) return;
70
71
 
71
72
  try {
72
73
  this.internalModule.disconnect(io.internalModule);
@@ -3,7 +3,7 @@ import IO, { IOType } from "./Node";
3
3
  import { AudioInput, AudioOutput } from "./AudioNode";
4
4
  import { MidiInput, MidiOutput } from "./MidiNode";
5
5
  import { IAnyIO } from ".";
6
- import { ForwardInput, ForwardOutput } from "./ForwardNode";
6
+ import { ForwardAudioInput, ForwardAudioOutput } from "./ForwardNode";
7
7
 
8
8
  export default class IOCollection<AnyIO extends IO> {
9
9
  plugableModule: AudioModule;
@@ -30,25 +30,25 @@ export default class IOCollection<AnyIO extends IO> {
30
30
 
31
31
  io = new AudioOutput(this.plugableModule, props);
32
32
  break;
33
- case IOType.ForwardInput:
33
+ case IOType.MidiInput:
34
+ io = new MidiInput(this.plugableModule, props);
35
+ break;
36
+ case IOType.MidiOutput:
37
+ io = new MidiOutput(this.plugableModule, props);
38
+ break;
39
+ case IOType.ForwardAudioInput:
34
40
  if (this.plugableModule instanceof MonoModule) {
35
41
  throw Error("MonoModule is not supported");
36
42
  }
37
43
 
38
- io = new ForwardInput(this.plugableModule, props);
44
+ io = new ForwardAudioInput(this.plugableModule, props);
39
45
  break;
40
- case IOType.ForwardOutput:
46
+ case IOType.ForwardAudioOutput:
41
47
  if (this.plugableModule instanceof MonoModule) {
42
48
  throw Error("MonoModule is not supported");
43
49
  }
44
50
 
45
- io = new ForwardOutput(this.plugableModule, props);
46
- break;
47
- case IOType.MidiInput:
48
- io = new MidiInput(this.plugableModule, props);
49
- break;
50
- case IOType.MidiOutput:
51
- io = new MidiOutput(this.plugableModule, props);
51
+ io = new ForwardAudioOutput(this.plugableModule, props);
52
52
  break;
53
53
  default:
54
54
  throw Error("Unknown IOType");
@@ -0,0 +1,99 @@
1
+ import IONode, { IIONode, plugCompatibleIO, unPlugCompatibleIO } from "../Node";
2
+
3
+ import Module, { Connectable, PolyModule } from "../../Module";
4
+ import { AnyObject } from "../../../types";
5
+ import { AnyIO, ForwardAudioInput, ForwardAudioOutput } from "..";
6
+
7
+ export default class ForwardBaseNode extends IONode {
8
+ declare plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
9
+
10
+ constructor(
11
+ plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>,
12
+ props: IIONode
13
+ ) {
14
+ super(plugableModule, props);
15
+ this.checkNameValidity();
16
+ }
17
+
18
+ get voices() {
19
+ return this.subModules.length;
20
+ }
21
+
22
+ get subModules() {
23
+ return this.plugableModule.audioModules;
24
+ }
25
+
26
+ subModule(voiceNo: number) {
27
+ const adjustedVoiceNo = voiceNo % this.voices;
28
+ const mod = this.subModules.find((m) => m.voiceNo === adjustedVoiceNo);
29
+ if (!mod) throw Error(`Submodule with voiceNo ${voiceNo} not found`);
30
+
31
+ return mod;
32
+ }
33
+
34
+ get subIOs() {
35
+ const ios: IONode[] = [];
36
+
37
+ for (let voice = 0; voice < this.voices; voice++) {
38
+ ios.push(this.subIO(voice));
39
+ }
40
+
41
+ return ios;
42
+ }
43
+
44
+ subIO(voiceNo: number) {
45
+ const ios = this.ioType.includes("Input")
46
+ ? this.subModule(voiceNo).inputs
47
+ : this.subModule(voiceNo).outputs;
48
+
49
+ const io = ios.findByName(this.name);
50
+ if (!io) throw Error(`Could not forward io ${this.name}`);
51
+
52
+ return io;
53
+ }
54
+
55
+ plug(io: AnyIO, plugOther: boolean = true) {
56
+ this.plugUnplug(io, plugOther, true);
57
+ }
58
+
59
+ unPlug(io: AnyIO, plugOther: boolean = true) {
60
+ this.plugUnplug(io, plugOther, false);
61
+ }
62
+
63
+ unPlugAll() {
64
+ IONode.unPlugAll(this);
65
+ }
66
+
67
+ private plugUnplug(io: AnyIO, plugOther: boolean, isPlug: boolean) {
68
+ isPlug ? super.plug(io, plugOther) : super.unPlug(io, plugOther);
69
+ if (
70
+ !plugOther &&
71
+ (io instanceof ForwardAudioOutput || io instanceof ForwardAudioInput)
72
+ )
73
+ return;
74
+
75
+ const plugCallback = isPlug ? plugCompatibleIO : unPlugCompatibleIO;
76
+
77
+ if (io instanceof ForwardAudioOutput || io instanceof ForwardAudioInput) {
78
+ const maxVoices = Math.max(this.voices, io.voices);
79
+
80
+ for (let voice = 0; voice < maxVoices; voice++) {
81
+ const thisIO = this.subIO(voice);
82
+ const otherIO = io.subIO(voice);
83
+
84
+ plugCallback(thisIO, otherIO);
85
+ }
86
+ } else {
87
+ for (let voice = 0; voice < this.voices; voice++) {
88
+ const thisIO = this.subIO(voice);
89
+ plugCallback(thisIO, io);
90
+ }
91
+ }
92
+ }
93
+
94
+ private checkNameValidity() {
95
+ const io = this.subIO(0);
96
+
97
+ if (!io) throw Error("You should forward to existing input");
98
+ }
99
+ }
@@ -0,0 +1,60 @@
1
+ import { IOType, IIONode } from "../Node";
2
+ import Module, { Connectable, PolyModule } from "../../Module";
3
+ import { AnyObject } from "../../../types";
4
+ import { AnyAudioInput, AnyAudioOuput, AnyInput, AnyOuput } from "..";
5
+ import ForwardBaseNode from "./Base";
6
+
7
+ export interface IForwardAudioInput extends IIONode {
8
+ ioType: IOType.ForwardAudioInput;
9
+ }
10
+ export interface IForwardAudioOutput extends IIONode {
11
+ ioType: IOType.ForwardAudioOutput;
12
+ }
13
+
14
+ export class ForwardAudioInput
15
+ extends ForwardBaseNode
16
+ implements IForwardAudioInput
17
+ {
18
+ declare plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
19
+ declare ioType: IOType.ForwardAudioInput;
20
+ declare connections: AnyAudioOuput[];
21
+
22
+ constructor(
23
+ plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>,
24
+ props: IForwardAudioInput
25
+ ) {
26
+ super(plugableModule, props);
27
+ }
28
+
29
+ plug(io: AnyOuput, plugOther: boolean = true) {
30
+ super.plug(io, plugOther);
31
+ }
32
+
33
+ unPlug(io: AnyOuput, plugOther: boolean = true) {
34
+ super.unPlug(io, plugOther);
35
+ }
36
+ }
37
+
38
+ export class ForwardAudioOutput
39
+ extends ForwardBaseNode
40
+ implements IForwardAudioOutput
41
+ {
42
+ declare plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
43
+ declare ioType: IOType.ForwardAudioOutput;
44
+ declare connections: AnyAudioInput[];
45
+
46
+ constructor(
47
+ plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>,
48
+ props: IForwardAudioOutput
49
+ ) {
50
+ super(plugableModule, props);
51
+ }
52
+
53
+ plug(io: AnyInput, plugOther: boolean = true) {
54
+ super.plug(io, plugOther);
55
+ }
56
+
57
+ unPlug(io: AnyInput, plugOther: boolean = true) {
58
+ super.unPlug(io, plugOther);
59
+ }
60
+ }
@@ -1,6 +1,6 @@
1
+ import { AnyMidiInput, AnyMidiOuput } from ".";
1
2
  import { AudioModule } from "../Module";
2
3
  import { MidiEvent } from "../midi";
3
- import { ForwardInput, ForwardOutput } from "./ForwardNode";
4
4
  import IONode, { IOType, IIONode } from "./Node";
5
5
 
6
6
  export interface IMidiInput extends IIONode {
@@ -22,11 +22,11 @@ export class MidiInput extends IONode implements IMidiInput {
22
22
  this.onMidiEvent = props.onMidiEvent;
23
23
  }
24
24
 
25
- plug(io: MidiOutput | ForwardOutput, plugOther: boolean = true) {
25
+ plug(io: AnyMidiOuput, plugOther: boolean = true) {
26
26
  super.plug(io, plugOther);
27
27
  }
28
28
 
29
- unPlug(io: MidiOutput | ForwardOutput, plugOther: boolean = true) {
29
+ unPlug(io: AnyMidiOuput, plugOther: boolean = true) {
30
30
  super.unPlug(io, plugOther);
31
31
  }
32
32
 
@@ -43,11 +43,11 @@ export class MidiOutput extends IONode implements IMidiOutput {
43
43
  super(plugableModule, props);
44
44
  }
45
45
 
46
- plug(io: MidiInput | ForwardInput, plugOther: boolean = true) {
46
+ plug(io: AnyMidiInput, plugOther: boolean = true) {
47
47
  super.plug(io, plugOther);
48
48
  }
49
49
 
50
- unPlug(io: MidiInput | ForwardOutput, plugOther: boolean = true) {
50
+ unPlug(io: AnyMidiInput, plugOther: boolean = true) {
51
51
  super.unPlug(io, plugOther);
52
52
  }
53
53
 
@@ -1,14 +1,5 @@
1
1
  import { AudioModule } from "../Module";
2
- import {
3
- AnyInput,
4
- AnyOuput,
5
- AudioInput,
6
- AudioOutput,
7
- ForwardInput,
8
- ForwardOutput,
9
- MidiInput,
10
- MidiOutput,
11
- } from ".";
2
+ import { AnyIO } from ".";
12
3
  import { deterministicId } from "../../utils";
13
4
 
14
5
  export interface IIONode {
@@ -29,48 +20,42 @@ export enum IOType {
29
20
  AudioOutput = "audioOutput",
30
21
  MidiInput = "midiInput",
31
22
  MidiOutput = "midiOutput",
32
- ForwardInput = "forwardInput",
33
- ForwardOutput = "forwardOutput",
23
+ ForwardAudioInput = "forwardAudioInput",
24
+ ForwardAudioOutput = "forwardAudioOutput",
34
25
  }
35
26
 
36
- export function plugCompatibleIO(input: AnyInput, output: AnyOuput) {
37
- if (input instanceof AudioInput && output instanceof AudioOutput) {
38
- input.plug(output);
39
- } else if (input instanceof MidiInput && output instanceof MidiOutput) {
40
- input.plug(output);
41
- } else if (input instanceof ForwardInput && output instanceof ForwardOutput) {
42
- input.plug(output);
43
- } else if (input instanceof ForwardInput && output instanceof MidiOutput) {
44
- input.plug(output);
45
- } else if (input instanceof ForwardInput && output instanceof AudioOutput) {
46
- input.plug(output);
47
- } else if (input instanceof AudioInput && output instanceof ForwardOutput) {
48
- input.plug(output);
49
- } else if (input instanceof MidiInput && output instanceof ForwardOutput) {
50
- input.plug(output);
51
- } else {
52
- throw Error("Input and output type is not compatible");
53
- }
27
+ const AudioIO = [
28
+ IOType.AudioInput,
29
+ IOType.AudioOutput,
30
+ IOType.ForwardAudioInput,
31
+ IOType.ForwardAudioOutput,
32
+ ];
33
+
34
+ const MidiIO = [IOType.MidiInput, IOType.MidiOutput];
35
+
36
+ const IOInputs = [
37
+ IOType.AudioInput,
38
+ IOType.MidiInput,
39
+ IOType.ForwardAudioInput,
40
+ ];
41
+ const IOOutputs = [
42
+ IOType.AudioOutput,
43
+ IOType.MidiOutput,
44
+ IOType.ForwardAudioOutput,
45
+ ];
46
+
47
+ export function plugCompatibleIO(io1: AnyIO, io2: AnyIO): void {
48
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
+ // @ts-ignore
50
+ io1.plug(io2);
54
51
  }
55
52
 
56
- export function unPlugCompatibleIO(input: AnyInput, output: AnyOuput) {
57
- if (input instanceof AudioInput && output instanceof AudioOutput) {
58
- input.unPlug(output);
59
- } else if (input instanceof MidiInput && output instanceof MidiOutput) {
60
- input.unPlug(output);
61
- } else if (input instanceof ForwardInput && output instanceof ForwardOutput) {
62
- input.unPlug(output);
63
- } else if (input instanceof ForwardInput && output instanceof MidiOutput) {
64
- input.unPlug(output);
65
- } else if (input instanceof ForwardInput && output instanceof AudioOutput) {
66
- input.unPlug(output);
67
- } else if (input instanceof AudioInput && output instanceof ForwardOutput) {
68
- input.unPlug(output);
69
- } else if (input instanceof MidiInput && output instanceof ForwardOutput) {
70
- input.unPlug(output);
71
- } else {
72
- throw Error("Input and output type is not compatible");
73
- }
53
+ export function unPlugCompatibleIO(io1: AnyIO, io2: AnyIO) {
54
+ if (!io1.connections.some((io) => io.id === io2.id)) return;
55
+
56
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
+ // @ts-ignore
58
+ io1.unPlug(io2);
74
59
  }
75
60
 
76
61
  export default abstract class IONode implements IIONode {
@@ -103,6 +88,22 @@ export default abstract class IONode implements IIONode {
103
88
  if (plugOther) io.unPlug(this, false);
104
89
  }
105
90
 
91
+ get isInput() {
92
+ return IOInputs.indexOf(this.ioType) > -1;
93
+ }
94
+
95
+ get isOutput() {
96
+ return IOOutputs.indexOf(this.ioType) > -1;
97
+ }
98
+
99
+ get isAudio() {
100
+ return AudioIO.indexOf(this.ioType) > -1;
101
+ }
102
+
103
+ get isMidi() {
104
+ return MidiIO.indexOf(this.ioType) > -1;
105
+ }
106
+
106
107
  abstract unPlugAll(): void;
107
108
 
108
109
  serialize(): IIOSerialize {
@@ -8,17 +8,27 @@ import {
8
8
  } from "./AudioNode";
9
9
  import { IMidiInput, IMidiOutput, MidiInput, MidiOutput } from "./MidiNode";
10
10
  import {
11
- ForwardInput,
12
- ForwardOutput,
13
- IForwardInput,
14
- IForwardOutput,
11
+ ForwardAudioInput,
12
+ ForwardAudioOutput,
13
+ IForwardAudioInput,
14
+ IForwardAudioOutput,
15
15
  } from "./ForwardNode";
16
16
 
17
- type AnyInput = AudioInput | MidiInput | ForwardInput;
18
- type AnyOuput = AudioOutput | MidiOutput | ForwardOutput;
19
- type IAnyInput = IAudioInput | IMidiInput | IForwardInput;
20
- type IAnyOutput = IAudioOutput | IMidiOutput | IForwardOutput;
21
- type IAnyIO = IAnyInput | IAnyOutput | IForwardOutput;
17
+ type AnyAudioInput = AudioInput | ForwardAudioInput;
18
+ type AnyMidiInput = MidiInput;
19
+ type AnyAudioOuput = AudioOutput | ForwardAudioOutput;
20
+ type AnyMidiOuput = MidiOutput;
21
+ type AnyInput = AnyAudioInput | AnyMidiInput;
22
+ type AnyOuput = AnyAudioOuput | AnyMidiOuput;
23
+ type AnyIO = AnyInput | AnyOuput;
24
+
25
+ type IAnyAudioInput = IAudioInput | IForwardAudioInput;
26
+ type IAnyMidiInput = IMidiInput;
27
+ type IAnyAudioOuput = IAudioOutput | IForwardAudioOutput;
28
+ type IAnyMidiOuput = IMidiOutput;
29
+ type IAnyInput = IAnyAudioInput | IAnyMidiInput;
30
+ type IAnyOutput = IAnyAudioOuput | IAnyMidiOuput;
31
+ type IAnyIO = IAnyInput | IAnyOutput;
22
32
 
23
33
  export {
24
34
  IOCollection,
@@ -27,8 +37,8 @@ export {
27
37
  AudioOutput,
28
38
  MidiInput,
29
39
  MidiOutput,
30
- ForwardInput,
31
- ForwardOutput,
40
+ ForwardAudioInput,
41
+ ForwardAudioOutput,
32
42
  };
33
43
  export type {
34
44
  IAnyIO,
@@ -37,11 +47,16 @@ export type {
37
47
  IAudioOutput,
38
48
  IMidiInput,
39
49
  IMidiOutput,
40
- IForwardInput,
41
- IForwardOutput,
50
+ IForwardAudioInput,
51
+ IForwardAudioOutput,
42
52
  IAnyInput,
43
53
  IAnyOutput,
44
54
  IIOSerialize,
55
+ AnyAudioInput,
56
+ AnyMidiInput,
57
+ AnyAudioOuput,
58
+ AnyMidiOuput,
45
59
  AnyInput,
46
60
  AnyOuput,
61
+ AnyIO,
47
62
  };
@@ -3,19 +3,23 @@ import { v4 as uuidv4 } from "uuid";
3
3
  import Module, { Connectable } from "./MonoModule";
4
4
  import {
5
5
  IOCollection,
6
- ForwardInput,
7
- ForwardOutput,
8
6
  IOType,
9
7
  IMidiInput,
10
8
  IMidiOutput,
11
- IForwardInput,
12
- IForwardOutput,
13
9
  MidiOutput,
14
10
  MidiInput,
11
+ AnyInput,
12
+ AnyOuput,
13
+ ForwardAudioInput,
15
14
  } from "../IO";
16
15
  import { AudioModule } from "./index";
17
16
  import { plugCompatibleIO } from "../IO/Node";
18
17
  import { deterministicId } from "../../utils";
18
+ import {
19
+ ForwardAudioOutput,
20
+ IForwardAudioInput,
21
+ IForwardAudioOutput,
22
+ } from "../IO/ForwardNode";
19
23
 
20
24
  interface PolyModuleInterface<MonoAudioModule, PropsInterface> {
21
25
  id?: string;
@@ -43,8 +47,8 @@ export default abstract class PolyModule<
43
47
  }) => MonoAudioModule;
44
48
  _name: string;
45
49
  audioModules: MonoAudioModule[];
46
- inputs: IOCollection<ForwardInput | MidiInput>;
47
- outputs: IOCollection<ForwardOutput | MidiOutput>;
50
+ inputs: IOCollection<AnyInput>;
51
+ outputs: IOCollection<AnyOuput>;
48
52
  private _numberOfVoices: number;
49
53
 
50
54
  constructor(params: PolyModuleInterface<MonoAudioModule, PropsInterface>) {
@@ -58,8 +62,8 @@ export default abstract class PolyModule<
58
62
  Object.assign(this, basicProps);
59
63
 
60
64
  this.numberOfVoices = params.numberOfVoices || 1;
61
- this.inputs = new IOCollection<ForwardInput>(this);
62
- this.outputs = new IOCollection<ForwardOutput>(this);
65
+ this.inputs = new IOCollection<AnyInput>(this);
66
+ this.outputs = new IOCollection<AnyOuput>(this);
63
67
 
64
68
  Object.assign(this, { props: extraProps });
65
69
  }
@@ -147,14 +151,16 @@ export default abstract class PolyModule<
147
151
  return this.audioModules.find((m) => m.voiceNo === voiceNo);
148
152
  }
149
153
 
150
- protected registerInput(props: Omit<IForwardInput, "ioType">): ForwardInput {
151
- return this.inputs.add({ ...props, ioType: IOType.ForwardInput });
154
+ protected registerForwardAudioInput(
155
+ props: Omit<IForwardAudioInput, "ioType">
156
+ ): ForwardAudioInput {
157
+ return this.inputs.add({ ...props, ioType: IOType.ForwardAudioInput });
152
158
  }
153
159
 
154
- protected registerOutput(
155
- props: Omit<IForwardOutput, "ioType">
156
- ): ForwardOutput {
157
- return this.outputs.add({ ...props, ioType: IOType.ForwardOutput });
160
+ protected registerForwardAudioOutput(
161
+ props: Omit<IForwardAudioOutput, "ioType">
162
+ ): ForwardAudioOutput {
163
+ return this.outputs.add({ ...props, ioType: IOType.ForwardAudioOutput });
158
164
  }
159
165
 
160
166
  protected registerMidiInput(props: Omit<IMidiInput, "ioType">): MidiInput {
@@ -166,11 +172,15 @@ export default abstract class PolyModule<
166
172
  }
167
173
 
168
174
  protected registerBasicOutputs() {
169
- this.registerOutput({ name: "output" });
175
+ this.registerForwardAudioOutput({ name: "output" });
170
176
  }
171
177
 
172
178
  protected registerBasicInputs() {
173
- this.registerInput({ name: "input" });
179
+ this.registerForwardAudioInput({ name: "input" });
180
+ this.registerMidiIn();
181
+ }
182
+
183
+ protected registerMidiIn() {
174
184
  this.registerMidiInput({
175
185
  name: "midi in",
176
186
  onMidiEvent: this.onMidiEvent,
@@ -34,7 +34,7 @@ class MonoFilter extends Module<InternalFilter, FilterInterface> {
34
34
  props: { ...InitialProps, ...props },
35
35
  });
36
36
 
37
- this._cutoff = new Add(this.cutoff);
37
+ this._cutoff = new Add();
38
38
  this._cutoff.connect(this.internalModule.frequency);
39
39
 
40
40
  this._amount = new Multiply();
@@ -143,6 +143,6 @@ export default class Filter extends PolyModule<MonoFilter, FilterInterface> {
143
143
 
144
144
  private registerOutputs() {
145
145
  this.registerBasicOutputs();
146
- this.registerInput({ name: "cutoff" });
146
+ this.registerForwardAudioInput({ name: "cutoff" });
147
147
  }
148
148
  }
@@ -110,7 +110,6 @@ class MonoLFO extends Module<LFOInternal, LFOInterface> implements Startable {
110
110
  };
111
111
 
112
112
  private registerInputs() {
113
- this.registerDefaultMidiInput();
114
113
  this.registerAudioInput({
115
114
  name: "amount",
116
115
  internalModule: this.internalModule.amplitude,
@@ -136,8 +135,8 @@ export default class LFO extends PolyModule<MonoLFO, LFOInterface> {
136
135
  });
137
136
 
138
137
  this.registerBasicOutputs();
139
- this.registerInput({ name: "midi in" });
140
- this.registerInput({ name: "amount" });
138
+ this.registerMidiIn();
139
+ this.registerForwardAudioInput({ name: "amount" });
141
140
  }
142
141
 
143
142
  start(time: number) {
@@ -171,7 +171,6 @@ class MonoOscillator
171
171
  }
172
172
 
173
173
  private registerInputs() {
174
- this.registerDefaultMidiInput();
175
174
  this.registerAudioInput({
176
175
  name: "fine",
177
176
  internalModule: this.fineSingal,
@@ -200,8 +199,8 @@ export default class Oscillator extends PolyModule<
200
199
  });
201
200
 
202
201
  this.registerBasicOutputs();
203
- this.registerInput({ name: "midi in" });
204
- this.registerInput({ name: "fine" });
202
+ this.registerMidiIn();
203
+ this.registerForwardAudioInput({ name: "fine" });
205
204
  }
206
205
 
207
206
  start(time: number) {