@blibliki/engine 0.3.6 → 0.3.8
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +189 -213
- package/dist/index.d.ts +189 -213
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Engine.ts +52 -2
- package/src/core/Route.ts +14 -2
- package/src/core/midi/MidiDeviceManager.ts +4 -0
- package/src/core/module/Module.ts +0 -38
- package/src/core/module/PolyModule.ts +1 -6
- package/src/index.ts +1 -1
- package/src/modules/MidiSelector.ts +29 -9
- package/src/modules/Oscillator.ts +6 -7
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { Context, Optional, EmptyObject } from '@blibliki/utils';
|
|
|
3
3
|
export { Context } from '@blibliki/utils';
|
|
4
4
|
import { Message, Input } from 'webmidi';
|
|
5
5
|
import * as _blibliki_transport from '@blibliki/transport';
|
|
6
|
-
import { Seconds, ContextTime, Transport, TransportEvent, TimeSignature } from '@blibliki/transport';
|
|
6
|
+
import { Seconds, ContextTime, Transport, TransportEvent, BPM, TimeSignature } from '@blibliki/transport';
|
|
7
7
|
export { Position, TimeSignature, TransportState } from '@blibliki/transport';
|
|
8
8
|
|
|
9
9
|
type INote = {
|
|
@@ -109,6 +109,65 @@ declare class ComputerKeyboardInput implements IMidiInput {
|
|
|
109
109
|
private extractNote;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
type MidiInputProps = IOProps & {
|
|
113
|
+
ioType: IOType.MidiInput;
|
|
114
|
+
onMidiEvent: (event: MidiEvent) => void;
|
|
115
|
+
};
|
|
116
|
+
type MidiOutputProps = IOProps & {
|
|
117
|
+
ioType: IOType.MidiOutput;
|
|
118
|
+
};
|
|
119
|
+
declare class MidiInput extends IO<MidiOutput> implements MidiInputProps {
|
|
120
|
+
ioType: IOType.MidiInput;
|
|
121
|
+
onMidiEvent: MidiInputProps["onMidiEvent"];
|
|
122
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: MidiInputProps);
|
|
123
|
+
}
|
|
124
|
+
declare class MidiOutput extends IO<MidiInput> implements MidiOutputProps {
|
|
125
|
+
ioType: IOType.MidiOutput;
|
|
126
|
+
onMidiEvent: (event: MidiEvent) => void;
|
|
127
|
+
private get midiConnections();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type IOProps = {
|
|
131
|
+
name: string;
|
|
132
|
+
ioType: IOType;
|
|
133
|
+
};
|
|
134
|
+
type IIOSerialize = IOProps & {
|
|
135
|
+
id: string;
|
|
136
|
+
moduleId: string;
|
|
137
|
+
};
|
|
138
|
+
declare enum IOType {
|
|
139
|
+
AudioInput = "audioInput",
|
|
140
|
+
AudioOutput = "audioOutput",
|
|
141
|
+
PolyAudioInput = "polyAudioInput",
|
|
142
|
+
PolyAudioOutput = "polyAudioOutput",
|
|
143
|
+
MidiOutput = "midiOutput",
|
|
144
|
+
MidiInput = "midiInput"
|
|
145
|
+
}
|
|
146
|
+
type IIO = {
|
|
147
|
+
id: string;
|
|
148
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
149
|
+
} & IOProps;
|
|
150
|
+
declare abstract class Base implements IIO {
|
|
151
|
+
id: string;
|
|
152
|
+
ioType: IOType;
|
|
153
|
+
name: string;
|
|
154
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
155
|
+
connections: Base[];
|
|
156
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: IOProps);
|
|
157
|
+
plug(io: Base, plugOther?: boolean): void;
|
|
158
|
+
unPlug(io: Base, plugOther?: boolean): void;
|
|
159
|
+
rePlugAll(callback?: () => void): void;
|
|
160
|
+
unPlugAll(): void;
|
|
161
|
+
isAudio(): this is AudioInput | AudioOutput | PolyAudioInput | PolyAudioOutput;
|
|
162
|
+
isMidi(): this is MidiInput | MidiOutput;
|
|
163
|
+
serialize(): IIOSerialize;
|
|
164
|
+
}
|
|
165
|
+
declare abstract class IO<Connection extends Base> extends Base {
|
|
166
|
+
connections: Connection[];
|
|
167
|
+
plug(io: Connection, plugOther?: boolean): void;
|
|
168
|
+
unPlug(io: Connection, plugOther?: boolean): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
112
171
|
type AudioInputProps = IOProps & {
|
|
113
172
|
ioType: IOType.AudioInput;
|
|
114
173
|
getAudioNode: () => AudioNode | AudioParam | AudioDestinationNode;
|
|
@@ -151,79 +210,6 @@ declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements
|
|
|
151
210
|
findIOByVoice(voice: number): AudioOutput;
|
|
152
211
|
}
|
|
153
212
|
|
|
154
|
-
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
155
|
-
voices: number;
|
|
156
|
-
};
|
|
157
|
-
type IPolyModuleSerialize<T extends ModuleType> = IPolyModule<T> & {
|
|
158
|
-
inputs: IIOSerialize[];
|
|
159
|
-
outputs: IIOSerialize[];
|
|
160
|
-
};
|
|
161
|
-
type IPolyModuleConstructor<T extends ModuleType> = Optional<IPolyModule<T>, "id"> & {
|
|
162
|
-
monoModuleConstructor: (engineId: string, params: IModuleConstructor<T>) => Module<T>;
|
|
163
|
-
};
|
|
164
|
-
declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T> {
|
|
165
|
-
id: string;
|
|
166
|
-
engineId: string;
|
|
167
|
-
moduleType: T;
|
|
168
|
-
audioModules: Module<T>[];
|
|
169
|
-
inputs: InputCollection;
|
|
170
|
-
outputs: OutputCollection;
|
|
171
|
-
protected monoModuleConstructor: IPolyModuleConstructor<T>["monoModuleConstructor"];
|
|
172
|
-
protected _props: ModuleTypeToPropsMapping[T];
|
|
173
|
-
protected superInitialized: boolean;
|
|
174
|
-
private _voices;
|
|
175
|
-
private _name;
|
|
176
|
-
private pendingUIUpdates;
|
|
177
|
-
constructor(engineId: string, params: IPolyModuleConstructor<T>);
|
|
178
|
-
get name(): string;
|
|
179
|
-
set name(value: string);
|
|
180
|
-
get props(): ModuleTypeToPropsMapping[T];
|
|
181
|
-
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
182
|
-
get voices(): number;
|
|
183
|
-
set voices(value: number);
|
|
184
|
-
start(time: ContextTime): void;
|
|
185
|
-
stop(time: ContextTime): void;
|
|
186
|
-
serialize(): IPolyModuleSerialize<T>;
|
|
187
|
-
plug({ audioModule, from, to, }: {
|
|
188
|
-
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
189
|
-
from: string;
|
|
190
|
-
to: string;
|
|
191
|
-
}): void;
|
|
192
|
-
rePlugAll(callback?: () => void): void;
|
|
193
|
-
protected unPlugAll(): void;
|
|
194
|
-
dispose(): void;
|
|
195
|
-
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
196
|
-
triggerPropsUpdate: () => void;
|
|
197
|
-
private sheduleTriggerUpdate;
|
|
198
|
-
findVoice(voiceNo: number): Module<T>;
|
|
199
|
-
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
200
|
-
protected registerAudioInput(props: Omit<PolyAudioInputProps, "ioType">): PolyAudioInput;
|
|
201
|
-
protected registerAudioOutput(props: Omit<PolyAudioOutputProps, "ioType">): PolyAudioOutput;
|
|
202
|
-
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
203
|
-
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
204
|
-
private adjustNumberOfModules;
|
|
205
|
-
protected get engine(): Engine;
|
|
206
|
-
protected get context(): _blibliki_utils.Context;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
type MidiInputProps = IOProps & {
|
|
210
|
-
ioType: IOType.MidiInput;
|
|
211
|
-
onMidiEvent: (event: MidiEvent) => void;
|
|
212
|
-
};
|
|
213
|
-
type MidiOutputProps = IOProps & {
|
|
214
|
-
ioType: IOType.MidiOutput;
|
|
215
|
-
};
|
|
216
|
-
declare class MidiInput extends IO<MidiOutput> implements MidiInputProps {
|
|
217
|
-
ioType: IOType.MidiInput;
|
|
218
|
-
onMidiEvent: MidiInputProps["onMidiEvent"];
|
|
219
|
-
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: MidiInputProps);
|
|
220
|
-
}
|
|
221
|
-
declare class MidiOutput extends IO<MidiInput> implements MidiOutputProps {
|
|
222
|
-
ioType: IOType.MidiOutput;
|
|
223
|
-
onMidiEvent: (event: MidiEvent) => void;
|
|
224
|
-
private get midiConnections();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
213
|
declare enum CollectionType {
|
|
228
214
|
Input = "Input",
|
|
229
215
|
Output = "Output"
|
|
@@ -260,138 +246,58 @@ declare class OutputCollection extends IOCollection<CollectionType.Output> {
|
|
|
260
246
|
constructor(module: Module<ModuleType> | PolyModule<ModuleType>);
|
|
261
247
|
}
|
|
262
248
|
|
|
263
|
-
type
|
|
264
|
-
|
|
265
|
-
name: string;
|
|
266
|
-
voiceNo: number;
|
|
267
|
-
moduleType: T;
|
|
268
|
-
props: ModuleTypeToPropsMapping[T];
|
|
249
|
+
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
250
|
+
voices: number;
|
|
269
251
|
};
|
|
270
|
-
type
|
|
252
|
+
type IPolyModuleSerialize<T extends ModuleType> = IPolyModule<T> & {
|
|
271
253
|
inputs: IIOSerialize[];
|
|
272
254
|
outputs: IIOSerialize[];
|
|
273
255
|
};
|
|
274
|
-
type
|
|
275
|
-
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Helper type for type-safe property lifecycle hooks.
|
|
279
|
-
*
|
|
280
|
-
* Hooks are completely optional - only define the ones you need.
|
|
281
|
-
* Use explicit type annotation for automatic type inference.
|
|
282
|
-
*
|
|
283
|
-
* @example
|
|
284
|
-
* ```typescript
|
|
285
|
-
* export type IGainProps = {
|
|
286
|
-
* gain: number;
|
|
287
|
-
* muted: boolean;
|
|
288
|
-
* };
|
|
289
|
-
*
|
|
290
|
-
* export class MonoGain extends Module<ModuleType.Gain> {
|
|
291
|
-
* // ✅ Define only the hooks you need with type annotation
|
|
292
|
-
* // value type is automatically inferred as number!
|
|
293
|
-
* onSetGain: SetterHooks<IGainProps>["onSetGain"] = (value) => {
|
|
294
|
-
* this.audioNode.gain.value = value;
|
|
295
|
-
* return value; // optional: return modified value
|
|
296
|
-
* };
|
|
297
|
-
*
|
|
298
|
-
* // ✅ onAfterSet is called after prop is set
|
|
299
|
-
* onAfterSetMuted: SetterHooks<IGainProps>["onAfterSetMuted"] = (value) => {
|
|
300
|
-
* if (value) this.audioNode.gain.value = 0;
|
|
301
|
-
* };
|
|
302
|
-
*
|
|
303
|
-
* // ✅ You can omit hooks you don't need - they're optional!
|
|
304
|
-
* // No need to define onSetMuted if you don't need it
|
|
305
|
-
*
|
|
306
|
-
* // ❌ This would cause a type error:
|
|
307
|
-
* // onSetGain: SetterHooks<IGainProps>["onSetGain"] = (value: string) => value;
|
|
308
|
-
* // ^^^^^^ Error!
|
|
309
|
-
* }
|
|
310
|
-
* ```
|
|
311
|
-
*/
|
|
312
|
-
type SetterHooks<P> = {
|
|
313
|
-
[K in keyof P as `onSet${Capitalize<string & K>}`]: (value: P[K]) => P[K];
|
|
314
|
-
} & {
|
|
315
|
-
[K in keyof P as `onAfterSet${Capitalize<string & K>}`]: (value: P[K]) => void;
|
|
256
|
+
type IPolyModuleConstructor<T extends ModuleType> = Optional<IPolyModule<T>, "id"> & {
|
|
257
|
+
monoModuleConstructor: (engineId: string, params: IModuleConstructor<T>) => Module<T>;
|
|
316
258
|
};
|
|
317
|
-
declare abstract class
|
|
259
|
+
declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T> {
|
|
318
260
|
id: string;
|
|
319
261
|
engineId: string;
|
|
320
|
-
name: string;
|
|
321
262
|
moduleType: T;
|
|
322
|
-
|
|
323
|
-
audioNode: AudioNode | undefined;
|
|
263
|
+
audioModules: Module<T>[];
|
|
324
264
|
inputs: InputCollection;
|
|
325
265
|
outputs: OutputCollection;
|
|
266
|
+
protected monoModuleConstructor: IPolyModuleConstructor<T>["monoModuleConstructor"];
|
|
326
267
|
protected _props: ModuleTypeToPropsMapping[T];
|
|
327
|
-
|
|
328
|
-
|
|
268
|
+
private _voices;
|
|
269
|
+
private _name;
|
|
329
270
|
private pendingUIUpdates;
|
|
330
|
-
constructor(engineId: string, params:
|
|
271
|
+
constructor(engineId: string, params: IPolyModuleConstructor<T>);
|
|
272
|
+
get name(): string;
|
|
273
|
+
set name(value: string);
|
|
331
274
|
get props(): ModuleTypeToPropsMapping[T];
|
|
332
275
|
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
333
|
-
|
|
334
|
-
|
|
276
|
+
get voices(): number;
|
|
277
|
+
set voices(value: number);
|
|
278
|
+
start(time: ContextTime): void;
|
|
279
|
+
stop(time: ContextTime): void;
|
|
280
|
+
serialize(): IPolyModuleSerialize<T>;
|
|
335
281
|
plug({ audioModule, from, to, }: {
|
|
336
|
-
audioModule:
|
|
282
|
+
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
337
283
|
from: string;
|
|
338
284
|
to: string;
|
|
339
285
|
}): void;
|
|
340
|
-
|
|
286
|
+
rePlugAll(callback?: () => void): void;
|
|
341
287
|
protected unPlugAll(): void;
|
|
342
|
-
|
|
343
|
-
stop(_time: ContextTime): void;
|
|
344
|
-
triggerAttack(note: Note, _triggeredAt: ContextTime): void;
|
|
345
|
-
triggerRelease(note: Note, _triggeredAt: ContextTime): void;
|
|
346
|
-
handleCC(_event: MidiEvent, _triggeredAt: ContextTime): void;
|
|
288
|
+
dispose(): void;
|
|
347
289
|
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
348
290
|
triggerPropsUpdate: () => void;
|
|
349
291
|
private sheduleTriggerUpdate;
|
|
350
|
-
|
|
292
|
+
findVoice(voiceNo: number): Module<T>;
|
|
351
293
|
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
352
|
-
protected registerAudioInput(props: Omit<
|
|
353
|
-
protected registerAudioOutput(props: Omit<
|
|
294
|
+
protected registerAudioInput(props: Omit<PolyAudioInputProps, "ioType">): PolyAudioInput;
|
|
295
|
+
protected registerAudioOutput(props: Omit<PolyAudioOutputProps, "ioType">): PolyAudioOutput;
|
|
354
296
|
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
355
297
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
298
|
+
private adjustNumberOfModules;
|
|
356
299
|
protected get engine(): Engine;
|
|
357
|
-
protected get context(): Context;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
type IPlug = {
|
|
361
|
-
moduleId: string;
|
|
362
|
-
ioName: string;
|
|
363
|
-
};
|
|
364
|
-
type IRoute = {
|
|
365
|
-
id: string;
|
|
366
|
-
source: IPlug;
|
|
367
|
-
destination: IPlug;
|
|
368
|
-
};
|
|
369
|
-
declare class Routes {
|
|
370
|
-
engine: Engine;
|
|
371
|
-
routes: Map<string, IRoute>;
|
|
372
|
-
constructor(engine: Engine);
|
|
373
|
-
addRoute(props: Optional<IRoute, "id">): IRoute;
|
|
374
|
-
removeRoute(id: string): void;
|
|
375
|
-
clear(): void;
|
|
376
|
-
private plug;
|
|
377
|
-
private unPlug;
|
|
378
|
-
private find;
|
|
379
|
-
private getIOs;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
type ListenerCallback = (device: MidiDevice) => void;
|
|
383
|
-
declare class MidiDeviceManager {
|
|
384
|
-
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
385
|
-
private initialized;
|
|
386
|
-
private listeners;
|
|
387
|
-
private context;
|
|
388
|
-
constructor(context: Context);
|
|
389
|
-
initialize(): Promise<void>;
|
|
390
|
-
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
391
|
-
addListener(callback: ListenerCallback): void;
|
|
392
|
-
private initializeDevices;
|
|
393
|
-
private addComputerKeyboard;
|
|
394
|
-
private listenChanges;
|
|
300
|
+
protected get context(): _blibliki_utils.Context;
|
|
395
301
|
}
|
|
396
302
|
|
|
397
303
|
type BasePropType = {
|
|
@@ -605,6 +511,7 @@ declare class MidiMapper extends Module<ModuleType.MidiMapper> implements MidiMa
|
|
|
605
511
|
|
|
606
512
|
type IMidiSelectorProps = {
|
|
607
513
|
selectedId: string | undefined | null;
|
|
514
|
+
selectedName: string | undefined | null;
|
|
608
515
|
};
|
|
609
516
|
declare class MidiSelector extends Module<ModuleType.MidiSelector> implements Pick<SetterHooks<IMidiSelectorProps>, "onSetSelectedId"> {
|
|
610
517
|
audioNode: undefined;
|
|
@@ -755,45 +662,105 @@ type ModuleParams = {
|
|
|
755
662
|
[K in ModuleType]: K extends ModuleType.Oscillator | ModuleType.Gain | ModuleType.Envelope | ModuleType.Filter | ModuleType.StereoPanner | ModuleType.VoiceScheduler ? IPolyModuleConstructor<K> : ICreateModule<K>;
|
|
756
663
|
}[ModuleType];
|
|
757
664
|
|
|
758
|
-
type
|
|
665
|
+
type IModule<T extends ModuleType> = {
|
|
666
|
+
id: string;
|
|
759
667
|
name: string;
|
|
760
|
-
|
|
668
|
+
voiceNo: number;
|
|
669
|
+
moduleType: T;
|
|
670
|
+
props: ModuleTypeToPropsMapping[T];
|
|
761
671
|
};
|
|
762
|
-
type
|
|
672
|
+
type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
673
|
+
inputs: IIOSerialize[];
|
|
674
|
+
outputs: IIOSerialize[];
|
|
675
|
+
};
|
|
676
|
+
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
677
|
+
audioNodeConstructor?: (context: Context) => AudioNode;
|
|
678
|
+
};
|
|
679
|
+
type SetterHooks<P> = {
|
|
680
|
+
[K in keyof P as `onSet${Capitalize<string & K>}`]: (value: P[K]) => P[K];
|
|
681
|
+
} & {
|
|
682
|
+
[K in keyof P as `onAfterSet${Capitalize<string & K>}`]: (value: P[K]) => void;
|
|
683
|
+
};
|
|
684
|
+
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
763
685
|
id: string;
|
|
686
|
+
engineId: string;
|
|
687
|
+
name: string;
|
|
688
|
+
moduleType: T;
|
|
689
|
+
voiceNo: number;
|
|
690
|
+
audioNode: AudioNode | undefined;
|
|
691
|
+
inputs: InputCollection;
|
|
692
|
+
outputs: OutputCollection;
|
|
693
|
+
protected _props: ModuleTypeToPropsMapping[T];
|
|
694
|
+
protected activeNotes: Note[];
|
|
695
|
+
private pendingUIUpdates;
|
|
696
|
+
constructor(engineId: string, params: IModuleConstructor<T>);
|
|
697
|
+
get props(): ModuleTypeToPropsMapping[T];
|
|
698
|
+
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
699
|
+
private callPropHook;
|
|
700
|
+
serialize(): IModuleSerialize<T>;
|
|
701
|
+
plug({ audioModule, from, to, }: {
|
|
702
|
+
audioModule: AnyModule;
|
|
703
|
+
from: string;
|
|
704
|
+
to: string;
|
|
705
|
+
}): void;
|
|
706
|
+
protected rePlugAll(callback?: () => void): void;
|
|
707
|
+
protected unPlugAll(): void;
|
|
708
|
+
start(_time: ContextTime): void;
|
|
709
|
+
stop(_time: ContextTime): void;
|
|
710
|
+
triggerAttack(note: Note, _triggeredAt: ContextTime): void;
|
|
711
|
+
triggerRelease(note: Note, _triggeredAt: ContextTime): void;
|
|
712
|
+
handleCC(_event: MidiEvent, _triggeredAt: ContextTime): void;
|
|
713
|
+
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
714
|
+
triggerPropsUpdate: () => void;
|
|
715
|
+
private sheduleTriggerUpdate;
|
|
716
|
+
dispose(): void;
|
|
717
|
+
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
718
|
+
protected registerAudioInput(props: Omit<AudioInputProps, "ioType">): AudioInput;
|
|
719
|
+
protected registerAudioOutput(props: Omit<AudioOutputProps, "ioType">): AudioOutput;
|
|
720
|
+
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
721
|
+
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
722
|
+
protected get engine(): Engine;
|
|
723
|
+
protected get context(): Context;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
type IPlug = {
|
|
764
727
|
moduleId: string;
|
|
728
|
+
ioName: string;
|
|
765
729
|
};
|
|
766
|
-
|
|
767
|
-
AudioInput = "audioInput",
|
|
768
|
-
AudioOutput = "audioOutput",
|
|
769
|
-
PolyAudioInput = "polyAudioInput",
|
|
770
|
-
PolyAudioOutput = "polyAudioOutput",
|
|
771
|
-
MidiOutput = "midiOutput",
|
|
772
|
-
MidiInput = "midiInput"
|
|
773
|
-
}
|
|
774
|
-
type IIO = {
|
|
775
|
-
id: string;
|
|
776
|
-
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
777
|
-
} & IOProps;
|
|
778
|
-
declare abstract class Base implements IIO {
|
|
730
|
+
type IRoute = {
|
|
779
731
|
id: string;
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
serialize():
|
|
732
|
+
source: IPlug;
|
|
733
|
+
destination: IPlug;
|
|
734
|
+
};
|
|
735
|
+
declare class Routes {
|
|
736
|
+
engine: Engine;
|
|
737
|
+
routes: Map<string, IRoute>;
|
|
738
|
+
constructor(engine: Engine);
|
|
739
|
+
addRoute(props: Optional<IRoute, "id">): IRoute;
|
|
740
|
+
removeRoute(id: string): void;
|
|
741
|
+
clear(): void;
|
|
742
|
+
replug(): void;
|
|
743
|
+
serialize(): IRoute[];
|
|
744
|
+
private plug;
|
|
745
|
+
private unPlug;
|
|
746
|
+
private find;
|
|
747
|
+
private getIOs;
|
|
792
748
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
749
|
+
|
|
750
|
+
type ListenerCallback = (device: MidiDevice) => void;
|
|
751
|
+
declare class MidiDeviceManager {
|
|
752
|
+
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
753
|
+
private initialized;
|
|
754
|
+
private listeners;
|
|
755
|
+
private context;
|
|
756
|
+
constructor(context: Context);
|
|
757
|
+
initialize(): Promise<void>;
|
|
758
|
+
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
759
|
+
findByName(name: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
760
|
+
addListener(callback: ListenerCallback): void;
|
|
761
|
+
private initializeDevices;
|
|
762
|
+
private addComputerKeyboard;
|
|
763
|
+
private listenChanges;
|
|
797
764
|
}
|
|
798
765
|
|
|
799
766
|
type IUpdateModule<T extends ModuleType> = {
|
|
@@ -804,6 +771,12 @@ type IUpdateModule<T extends ModuleType> = {
|
|
|
804
771
|
};
|
|
805
772
|
};
|
|
806
773
|
type ICreateRoute = Optional<IRoute, "id">;
|
|
774
|
+
interface IEngineSerialize {
|
|
775
|
+
bpm: BPM;
|
|
776
|
+
timeSignature: TimeSignature;
|
|
777
|
+
modules: (IModuleSerialize<ModuleType> | IPolyModuleSerialize<ModuleType>)[];
|
|
778
|
+
routes: IRoute[];
|
|
779
|
+
}
|
|
807
780
|
declare class Engine {
|
|
808
781
|
private static _engines;
|
|
809
782
|
private static _currentId;
|
|
@@ -817,6 +790,7 @@ declare class Engine {
|
|
|
817
790
|
midiDeviceManager: MidiDeviceManager;
|
|
818
791
|
static getById(id: string): Engine;
|
|
819
792
|
static get current(): Engine;
|
|
793
|
+
static load(data: IEngineSerialize): Promise<Engine>;
|
|
820
794
|
constructor(context: Context);
|
|
821
795
|
get state(): _blibliki_transport.TransportState;
|
|
822
796
|
initialize(): Promise<void>;
|
|
@@ -835,9 +809,11 @@ declare class Engine {
|
|
|
835
809
|
set timeSignature(value: TimeSignature);
|
|
836
810
|
resume(): Promise<void>;
|
|
837
811
|
dispose(): void;
|
|
812
|
+
serialize(): IEngineSerialize;
|
|
838
813
|
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
839
814
|
findIO(moduleId: string, ioName: string, type: "input" | "output"): Base;
|
|
840
815
|
findMidiDevice(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
816
|
+
findMidiDeviceByName(name: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
841
817
|
onPropsUpdate(callback: <T extends ModuleType>(params: IModule<T> | IPolyModule<T>) => void): void;
|
|
842
818
|
_triggerPropsUpdate<T extends ModuleType>(params: IModule<T> | IPolyModule<T>): void;
|
|
843
819
|
triggerVirtualMidi(id: string, noteName: string, type: "noteOn" | "noteOff"): void;
|
|
@@ -845,4 +821,4 @@ declare class Engine {
|
|
|
845
821
|
private onStop;
|
|
846
822
|
}
|
|
847
823
|
|
|
848
|
-
export { type ArrayProp, type BooleanProp, Engine, type EnumProp, type ICreateModule, type ICreateRoute, type IGain, type IIOSerialize, type IMaster, type IMidiDevice, type IMidiMapper, type IMidiMapperProps, type IModule, type IModuleSerialize, type INote, type IOscillator, type IPolyModuleSerialize, type IRoute, type ISequence, type IStepSequencer, type IStepSequencerProps, type IUpdateModule, MidiDevice, type MidiMapping, MidiMappingMode, MidiPortState, type ModuleParams, type ModulePropSchema, ModuleType, type ModuleTypeToPropsMapping, Note, type NumberProp, OscillatorWave, type PropSchema, type StringProp, moduleSchemas };
|
|
824
|
+
export { type ArrayProp, type BooleanProp, Engine, type EnumProp, type ICreateModule, type ICreateRoute, type IEngineSerialize, type IGain, type IIOSerialize, type IMaster, type IMidiDevice, type IMidiMapper, type IMidiMapperProps, type IModule, type IModuleSerialize, type INote, type IOscillator, type IPolyModuleSerialize, type IRoute, type ISequence, type IStepSequencer, type IStepSequencerProps, type IUpdateModule, MidiDevice, type MidiMapping, MidiMappingMode, MidiPortState, type ModuleParams, type ModulePropSchema, ModuleType, type ModuleTypeToPropsMapping, Note, type NumberProp, OscillatorWave, type PropSchema, type StringProp, moduleSchemas };
|