@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.
@@ -1,192 +0,0 @@
1
- import IONode, {
2
- IOType,
3
- IIONode,
4
- plugCompatibleIO,
5
- unPlugCompatibleIO,
6
- } from "./Node";
7
- import Module, { Connectable, PolyModule } from "../Module";
8
- import { AnyObject } from "../../types";
9
- import { AnyInput, AnyOuput } from ".";
10
-
11
- export interface IForwardInput extends IIONode {
12
- ioType: IOType.ForwardInput;
13
- }
14
- export interface IForwardOutput extends IIONode {
15
- ioType: IOType.ForwardOutput;
16
- }
17
-
18
- export class ForwardInput extends IONode implements IForwardInput {
19
- declare plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
20
- declare ioType: IOType.ForwardInput;
21
- declare connections: ForwardOutput[];
22
-
23
- constructor(
24
- plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>,
25
- props: IForwardInput
26
- ) {
27
- super(plugableModule, props);
28
- this.checkNameValidity();
29
- }
30
-
31
- get subInputs() {
32
- return this.plugableModule.audioModules.map((am) => {
33
- const input = am.inputs.findByName(this.name);
34
- if (!input) throw Error(`Could not forward input ${this.name}`);
35
-
36
- return input;
37
- });
38
- }
39
-
40
- get subModules() {
41
- return this.plugableModule.audioModules;
42
- }
43
-
44
- subModule(voiceNo: number) {
45
- const mod = this.subModules.find((m) => m.voiceNo === voiceNo);
46
- if (!mod) throw Error(`Submodule with voiceNo ${voiceNo} not found`);
47
-
48
- return mod;
49
- }
50
-
51
- subInput(voiceNo: number) {
52
- const input = this.subModule(voiceNo).inputs.findByName(this.name);
53
- if (!input) throw Error(`Could not forward input ${this.name}`);
54
-
55
- return input;
56
- }
57
-
58
- plug(io: AnyOuput, plugOther: boolean = true) {
59
- super.plug(io, plugOther);
60
- if (!plugOther && io instanceof ForwardOutput) return;
61
-
62
- if (io instanceof ForwardOutput) {
63
- this.subModules.forEach((am) => {
64
- const input = am.inputs.findByName(this.name);
65
- if (!input) throw Error(`Could not forward input ${this.name}`);
66
-
67
- const output = io.subOutput(am.voiceNo as number);
68
- plugCompatibleIO(input, output);
69
- });
70
- } else {
71
- this.subInputs.forEach((input) => plugCompatibleIO(input, io));
72
- }
73
- }
74
-
75
- unPlug(io: AnyOuput, plugOther: boolean = true) {
76
- super.unPlug(io, plugOther);
77
- if (!plugOther && io instanceof ForwardOutput) return;
78
-
79
- if (io instanceof ForwardOutput) {
80
- this.subModules.forEach((am) => {
81
- const input = am.inputs.findByName(this.name);
82
- if (!input) throw Error(`Could not forward input ${this.name}`);
83
-
84
- const output = io.subOutput(am.voiceNo as number);
85
- unPlugCompatibleIO(input, output);
86
- });
87
- } else {
88
- this.subInputs.forEach((input) => unPlugCompatibleIO(input, io));
89
- }
90
- }
91
-
92
- unPlugAll() {
93
- IONode.unPlugAll(this);
94
- }
95
-
96
- private checkNameValidity() {
97
- const input = this.plugableModule.audioModules[0].inputs.findByName(
98
- this.name
99
- );
100
-
101
- if (!input) throw Error("You should forward to existing input");
102
- }
103
- }
104
-
105
- export class ForwardOutput extends IONode implements IForwardOutput {
106
- declare plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
107
- declare ioType: IOType.ForwardOutput;
108
- declare connections: ForwardInput[];
109
-
110
- constructor(
111
- plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>,
112
- props: IForwardOutput
113
- ) {
114
- super(plugableModule, props);
115
- this.checkNameValidity();
116
- }
117
-
118
- get subOutputs() {
119
- return this.subModules.map((am) => {
120
- const output = am.outputs.findByName(this.name);
121
- if (!output) throw Error(`Could not forward input ${this.name}`);
122
-
123
- return output;
124
- });
125
- }
126
-
127
- get subModules() {
128
- return this.plugableModule.audioModules;
129
- }
130
-
131
- subModule(voiceNo: number) {
132
- const mod = this.subModules.find((m) => m.voiceNo === voiceNo);
133
- if (!mod) throw Error(`Submodule with voiceNo ${voiceNo} not found`);
134
-
135
- return mod;
136
- }
137
-
138
- subOutput(voiceNo: number) {
139
- const output = this.subModule(voiceNo).outputs.findByName(this.name);
140
- if (!output) throw Error(`Could not forward input ${this.name}`);
141
-
142
- return output;
143
- }
144
-
145
- plug(io: AnyInput, plugOther: boolean = true) {
146
- super.plug(io, plugOther);
147
- if (!plugOther && io instanceof ForwardInput) return;
148
-
149
- if (io instanceof ForwardInput) {
150
- this.subModules.forEach((am) => {
151
- const output = am.outputs.findByName(this.name);
152
- if (!output) throw Error(`Could not forward output ${this.name}`);
153
-
154
- const input = io.subInput(am.voiceNo as number);
155
-
156
- plugCompatibleIO(input, output);
157
- });
158
- } else {
159
- this.subOutputs.forEach((output) => plugCompatibleIO(io, output));
160
- }
161
- }
162
-
163
- unPlug(io: AnyInput, plugOther: boolean = true) {
164
- super.unPlug(io, plugOther);
165
- if (!plugOther && io instanceof ForwardInput) return;
166
-
167
- if (io instanceof ForwardInput) {
168
- this.subModules.forEach((am) => {
169
- const output = am.outputs.findByName(this.name);
170
- if (!output) throw Error(`Could not forward output ${this.name}`);
171
-
172
- const input = io.subInput(am.voiceNo as number);
173
-
174
- unPlugCompatibleIO(input, output);
175
- });
176
- } else {
177
- this.subOutputs.forEach((output) => unPlugCompatibleIO(io, output));
178
- }
179
- }
180
-
181
- unPlugAll() {
182
- IONode.unPlugAll(this);
183
- }
184
-
185
- private checkNameValidity() {
186
- const output = this.plugableModule.audioModules[0].outputs.findByName(
187
- this.name
188
- );
189
-
190
- if (!output) throw Error("You should forward to existing output");
191
- }
192
- }