@blibliki/engine 0.3.7 → 0.3.9
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 +218 -215
- package/dist/index.d.ts +218 -215
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/Engine.ts +52 -2
- package/src/core/Note/index.ts +1 -1
- package/src/core/Route.ts +14 -2
- package/src/core/midi/Message.ts +46 -0
- package/src/core/midi/MidiDevice.ts +22 -12
- package/src/core/midi/MidiDeviceManager.ts +68 -36
- package/src/core/midi/MidiEvent.ts +1 -1
- package/src/core/midi/jzz.types.ts +51 -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
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import * as _blibliki_utils from '@blibliki/utils';
|
|
2
2
|
import { Context, Optional, EmptyObject } from '@blibliki/utils';
|
|
3
3
|
export { Context } from '@blibliki/utils';
|
|
4
|
-
import { Message, Input } from 'webmidi';
|
|
5
4
|
import * as _blibliki_transport from '@blibliki/transport';
|
|
6
|
-
import { Seconds, ContextTime, Transport, TransportEvent, TimeSignature } from '@blibliki/transport';
|
|
5
|
+
import { Seconds, ContextTime, Transport, TransportEvent, BPM, TimeSignature } from '@blibliki/transport';
|
|
7
6
|
export { Position, TimeSignature, TransportState } from '@blibliki/transport';
|
|
8
7
|
|
|
8
|
+
interface JZZMidiMessage extends Array<number> {
|
|
9
|
+
slice(): number[];
|
|
10
|
+
}
|
|
11
|
+
interface JZZPort {
|
|
12
|
+
connect(callback: (msg: JZZMidiMessage) => void): JZZPort;
|
|
13
|
+
close(): void;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Simple wrapper around MIDI message data (Uint8Array)
|
|
19
|
+
* Replaces the webmidi Message class with native Web MIDI API data
|
|
20
|
+
*/
|
|
21
|
+
declare class Message {
|
|
22
|
+
readonly data: Uint8Array;
|
|
23
|
+
constructor(data: Uint8Array);
|
|
24
|
+
/**
|
|
25
|
+
* Returns the data bytes (excluding the status byte)
|
|
26
|
+
*/
|
|
27
|
+
get dataBytes(): number[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns the MIDI message type based on the status byte
|
|
30
|
+
*/
|
|
31
|
+
get type(): string;
|
|
32
|
+
}
|
|
33
|
+
|
|
9
34
|
type INote = {
|
|
10
35
|
name: string;
|
|
11
36
|
octave: number;
|
|
@@ -77,7 +102,8 @@ declare class MidiDevice implements IMidiDevice {
|
|
|
77
102
|
eventListerCallbacks: EventListerCallback[];
|
|
78
103
|
private context;
|
|
79
104
|
private input;
|
|
80
|
-
|
|
105
|
+
private _state;
|
|
106
|
+
constructor(input: JZZPort, id: string, name: string, context: Context);
|
|
81
107
|
get state(): MidiPortState;
|
|
82
108
|
connect(): void;
|
|
83
109
|
disconnect(): void;
|
|
@@ -109,6 +135,65 @@ declare class ComputerKeyboardInput implements IMidiInput {
|
|
|
109
135
|
private extractNote;
|
|
110
136
|
}
|
|
111
137
|
|
|
138
|
+
type MidiInputProps = IOProps & {
|
|
139
|
+
ioType: IOType.MidiInput;
|
|
140
|
+
onMidiEvent: (event: MidiEvent) => void;
|
|
141
|
+
};
|
|
142
|
+
type MidiOutputProps = IOProps & {
|
|
143
|
+
ioType: IOType.MidiOutput;
|
|
144
|
+
};
|
|
145
|
+
declare class MidiInput extends IO<MidiOutput> implements MidiInputProps {
|
|
146
|
+
ioType: IOType.MidiInput;
|
|
147
|
+
onMidiEvent: MidiInputProps["onMidiEvent"];
|
|
148
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: MidiInputProps);
|
|
149
|
+
}
|
|
150
|
+
declare class MidiOutput extends IO<MidiInput> implements MidiOutputProps {
|
|
151
|
+
ioType: IOType.MidiOutput;
|
|
152
|
+
onMidiEvent: (event: MidiEvent) => void;
|
|
153
|
+
private get midiConnections();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type IOProps = {
|
|
157
|
+
name: string;
|
|
158
|
+
ioType: IOType;
|
|
159
|
+
};
|
|
160
|
+
type IIOSerialize = IOProps & {
|
|
161
|
+
id: string;
|
|
162
|
+
moduleId: string;
|
|
163
|
+
};
|
|
164
|
+
declare enum IOType {
|
|
165
|
+
AudioInput = "audioInput",
|
|
166
|
+
AudioOutput = "audioOutput",
|
|
167
|
+
PolyAudioInput = "polyAudioInput",
|
|
168
|
+
PolyAudioOutput = "polyAudioOutput",
|
|
169
|
+
MidiOutput = "midiOutput",
|
|
170
|
+
MidiInput = "midiInput"
|
|
171
|
+
}
|
|
172
|
+
type IIO = {
|
|
173
|
+
id: string;
|
|
174
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
175
|
+
} & IOProps;
|
|
176
|
+
declare abstract class Base implements IIO {
|
|
177
|
+
id: string;
|
|
178
|
+
ioType: IOType;
|
|
179
|
+
name: string;
|
|
180
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
181
|
+
connections: Base[];
|
|
182
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: IOProps);
|
|
183
|
+
plug(io: Base, plugOther?: boolean): void;
|
|
184
|
+
unPlug(io: Base, plugOther?: boolean): void;
|
|
185
|
+
rePlugAll(callback?: () => void): void;
|
|
186
|
+
unPlugAll(): void;
|
|
187
|
+
isAudio(): this is AudioInput | AudioOutput | PolyAudioInput | PolyAudioOutput;
|
|
188
|
+
isMidi(): this is MidiInput | MidiOutput;
|
|
189
|
+
serialize(): IIOSerialize;
|
|
190
|
+
}
|
|
191
|
+
declare abstract class IO<Connection extends Base> extends Base {
|
|
192
|
+
connections: Connection[];
|
|
193
|
+
plug(io: Connection, plugOther?: boolean): void;
|
|
194
|
+
unPlug(io: Connection, plugOther?: boolean): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
112
197
|
type AudioInputProps = IOProps & {
|
|
113
198
|
ioType: IOType.AudioInput;
|
|
114
199
|
getAudioNode: () => AudioNode | AudioParam | AudioDestinationNode;
|
|
@@ -151,79 +236,6 @@ declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements
|
|
|
151
236
|
findIOByVoice(voice: number): AudioOutput;
|
|
152
237
|
}
|
|
153
238
|
|
|
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
239
|
declare enum CollectionType {
|
|
228
240
|
Input = "Input",
|
|
229
241
|
Output = "Output"
|
|
@@ -260,138 +272,58 @@ declare class OutputCollection extends IOCollection<CollectionType.Output> {
|
|
|
260
272
|
constructor(module: Module<ModuleType> | PolyModule<ModuleType>);
|
|
261
273
|
}
|
|
262
274
|
|
|
263
|
-
type
|
|
264
|
-
|
|
265
|
-
name: string;
|
|
266
|
-
voiceNo: number;
|
|
267
|
-
moduleType: T;
|
|
268
|
-
props: ModuleTypeToPropsMapping[T];
|
|
275
|
+
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
276
|
+
voices: number;
|
|
269
277
|
};
|
|
270
|
-
type
|
|
278
|
+
type IPolyModuleSerialize<T extends ModuleType> = IPolyModule<T> & {
|
|
271
279
|
inputs: IIOSerialize[];
|
|
272
280
|
outputs: IIOSerialize[];
|
|
273
281
|
};
|
|
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;
|
|
282
|
+
type IPolyModuleConstructor<T extends ModuleType> = Optional<IPolyModule<T>, "id"> & {
|
|
283
|
+
monoModuleConstructor: (engineId: string, params: IModuleConstructor<T>) => Module<T>;
|
|
316
284
|
};
|
|
317
|
-
declare abstract class
|
|
285
|
+
declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T> {
|
|
318
286
|
id: string;
|
|
319
287
|
engineId: string;
|
|
320
|
-
name: string;
|
|
321
288
|
moduleType: T;
|
|
322
|
-
|
|
323
|
-
audioNode: AudioNode | undefined;
|
|
289
|
+
audioModules: Module<T>[];
|
|
324
290
|
inputs: InputCollection;
|
|
325
291
|
outputs: OutputCollection;
|
|
292
|
+
protected monoModuleConstructor: IPolyModuleConstructor<T>["monoModuleConstructor"];
|
|
326
293
|
protected _props: ModuleTypeToPropsMapping[T];
|
|
327
|
-
|
|
328
|
-
|
|
294
|
+
private _voices;
|
|
295
|
+
private _name;
|
|
329
296
|
private pendingUIUpdates;
|
|
330
|
-
constructor(engineId: string, params:
|
|
297
|
+
constructor(engineId: string, params: IPolyModuleConstructor<T>);
|
|
298
|
+
get name(): string;
|
|
299
|
+
set name(value: string);
|
|
331
300
|
get props(): ModuleTypeToPropsMapping[T];
|
|
332
301
|
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
333
|
-
|
|
334
|
-
|
|
302
|
+
get voices(): number;
|
|
303
|
+
set voices(value: number);
|
|
304
|
+
start(time: ContextTime): void;
|
|
305
|
+
stop(time: ContextTime): void;
|
|
306
|
+
serialize(): IPolyModuleSerialize<T>;
|
|
335
307
|
plug({ audioModule, from, to, }: {
|
|
336
|
-
audioModule:
|
|
308
|
+
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
337
309
|
from: string;
|
|
338
310
|
to: string;
|
|
339
311
|
}): void;
|
|
340
|
-
|
|
312
|
+
rePlugAll(callback?: () => void): void;
|
|
341
313
|
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;
|
|
314
|
+
dispose(): void;
|
|
347
315
|
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
348
316
|
triggerPropsUpdate: () => void;
|
|
349
317
|
private sheduleTriggerUpdate;
|
|
350
|
-
|
|
318
|
+
findVoice(voiceNo: number): Module<T>;
|
|
351
319
|
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
352
|
-
protected registerAudioInput(props: Omit<
|
|
353
|
-
protected registerAudioOutput(props: Omit<
|
|
320
|
+
protected registerAudioInput(props: Omit<PolyAudioInputProps, "ioType">): PolyAudioInput;
|
|
321
|
+
protected registerAudioOutput(props: Omit<PolyAudioOutputProps, "ioType">): PolyAudioOutput;
|
|
354
322
|
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
355
323
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
324
|
+
private adjustNumberOfModules;
|
|
356
325
|
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;
|
|
326
|
+
protected get context(): _blibliki_utils.Context;
|
|
395
327
|
}
|
|
396
328
|
|
|
397
329
|
type BasePropType = {
|
|
@@ -605,6 +537,7 @@ declare class MidiMapper extends Module<ModuleType.MidiMapper> implements MidiMa
|
|
|
605
537
|
|
|
606
538
|
type IMidiSelectorProps = {
|
|
607
539
|
selectedId: string | undefined | null;
|
|
540
|
+
selectedName: string | undefined | null;
|
|
608
541
|
};
|
|
609
542
|
declare class MidiSelector extends Module<ModuleType.MidiSelector> implements Pick<SetterHooks<IMidiSelectorProps>, "onSetSelectedId"> {
|
|
610
543
|
audioNode: undefined;
|
|
@@ -755,45 +688,106 @@ type ModuleParams = {
|
|
|
755
688
|
[K in ModuleType]: K extends ModuleType.Oscillator | ModuleType.Gain | ModuleType.Envelope | ModuleType.Filter | ModuleType.StereoPanner | ModuleType.VoiceScheduler ? IPolyModuleConstructor<K> : ICreateModule<K>;
|
|
756
689
|
}[ModuleType];
|
|
757
690
|
|
|
758
|
-
type
|
|
691
|
+
type IModule<T extends ModuleType> = {
|
|
692
|
+
id: string;
|
|
759
693
|
name: string;
|
|
760
|
-
|
|
694
|
+
voiceNo: number;
|
|
695
|
+
moduleType: T;
|
|
696
|
+
props: ModuleTypeToPropsMapping[T];
|
|
761
697
|
};
|
|
762
|
-
type
|
|
698
|
+
type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
699
|
+
inputs: IIOSerialize[];
|
|
700
|
+
outputs: IIOSerialize[];
|
|
701
|
+
};
|
|
702
|
+
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
703
|
+
audioNodeConstructor?: (context: Context) => AudioNode;
|
|
704
|
+
};
|
|
705
|
+
type SetterHooks<P> = {
|
|
706
|
+
[K in keyof P as `onSet${Capitalize<string & K>}`]: (value: P[K]) => P[K];
|
|
707
|
+
} & {
|
|
708
|
+
[K in keyof P as `onAfterSet${Capitalize<string & K>}`]: (value: P[K]) => void;
|
|
709
|
+
};
|
|
710
|
+
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
763
711
|
id: string;
|
|
712
|
+
engineId: string;
|
|
713
|
+
name: string;
|
|
714
|
+
moduleType: T;
|
|
715
|
+
voiceNo: number;
|
|
716
|
+
audioNode: AudioNode | undefined;
|
|
717
|
+
inputs: InputCollection;
|
|
718
|
+
outputs: OutputCollection;
|
|
719
|
+
protected _props: ModuleTypeToPropsMapping[T];
|
|
720
|
+
protected activeNotes: Note[];
|
|
721
|
+
private pendingUIUpdates;
|
|
722
|
+
constructor(engineId: string, params: IModuleConstructor<T>);
|
|
723
|
+
get props(): ModuleTypeToPropsMapping[T];
|
|
724
|
+
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
725
|
+
private callPropHook;
|
|
726
|
+
serialize(): IModuleSerialize<T>;
|
|
727
|
+
plug({ audioModule, from, to, }: {
|
|
728
|
+
audioModule: AnyModule;
|
|
729
|
+
from: string;
|
|
730
|
+
to: string;
|
|
731
|
+
}): void;
|
|
732
|
+
protected rePlugAll(callback?: () => void): void;
|
|
733
|
+
protected unPlugAll(): void;
|
|
734
|
+
start(_time: ContextTime): void;
|
|
735
|
+
stop(_time: ContextTime): void;
|
|
736
|
+
triggerAttack(note: Note, _triggeredAt: ContextTime): void;
|
|
737
|
+
triggerRelease(note: Note, _triggeredAt: ContextTime): void;
|
|
738
|
+
handleCC(_event: MidiEvent, _triggeredAt: ContextTime): void;
|
|
739
|
+
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
740
|
+
triggerPropsUpdate: () => void;
|
|
741
|
+
private sheduleTriggerUpdate;
|
|
742
|
+
dispose(): void;
|
|
743
|
+
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
744
|
+
protected registerAudioInput(props: Omit<AudioInputProps, "ioType">): AudioInput;
|
|
745
|
+
protected registerAudioOutput(props: Omit<AudioOutputProps, "ioType">): AudioOutput;
|
|
746
|
+
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
747
|
+
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
748
|
+
protected get engine(): Engine;
|
|
749
|
+
protected get context(): Context;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
type IPlug = {
|
|
764
753
|
moduleId: string;
|
|
754
|
+
ioName: string;
|
|
765
755
|
};
|
|
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 {
|
|
756
|
+
type IRoute = {
|
|
779
757
|
id: string;
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
serialize():
|
|
758
|
+
source: IPlug;
|
|
759
|
+
destination: IPlug;
|
|
760
|
+
};
|
|
761
|
+
declare class Routes {
|
|
762
|
+
engine: Engine;
|
|
763
|
+
routes: Map<string, IRoute>;
|
|
764
|
+
constructor(engine: Engine);
|
|
765
|
+
addRoute(props: Optional<IRoute, "id">): IRoute;
|
|
766
|
+
removeRoute(id: string): void;
|
|
767
|
+
clear(): void;
|
|
768
|
+
replug(): void;
|
|
769
|
+
serialize(): IRoute[];
|
|
770
|
+
private plug;
|
|
771
|
+
private unPlug;
|
|
772
|
+
private find;
|
|
773
|
+
private getIOs;
|
|
792
774
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
775
|
+
|
|
776
|
+
type ListenerCallback = (device: MidiDevice) => void;
|
|
777
|
+
declare class MidiDeviceManager {
|
|
778
|
+
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
779
|
+
private initialized;
|
|
780
|
+
private listeners;
|
|
781
|
+
private context;
|
|
782
|
+
private jzz;
|
|
783
|
+
constructor(context: Context);
|
|
784
|
+
initialize(): Promise<void>;
|
|
785
|
+
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
786
|
+
findByName(name: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
787
|
+
addListener(callback: ListenerCallback): void;
|
|
788
|
+
private initializeDevices;
|
|
789
|
+
private addComputerKeyboard;
|
|
790
|
+
private listenChanges;
|
|
797
791
|
}
|
|
798
792
|
|
|
799
793
|
type IUpdateModule<T extends ModuleType> = {
|
|
@@ -804,6 +798,12 @@ type IUpdateModule<T extends ModuleType> = {
|
|
|
804
798
|
};
|
|
805
799
|
};
|
|
806
800
|
type ICreateRoute = Optional<IRoute, "id">;
|
|
801
|
+
interface IEngineSerialize {
|
|
802
|
+
bpm: BPM;
|
|
803
|
+
timeSignature: TimeSignature;
|
|
804
|
+
modules: (IModuleSerialize<ModuleType> | IPolyModuleSerialize<ModuleType>)[];
|
|
805
|
+
routes: IRoute[];
|
|
806
|
+
}
|
|
807
807
|
declare class Engine {
|
|
808
808
|
private static _engines;
|
|
809
809
|
private static _currentId;
|
|
@@ -817,6 +817,7 @@ declare class Engine {
|
|
|
817
817
|
midiDeviceManager: MidiDeviceManager;
|
|
818
818
|
static getById(id: string): Engine;
|
|
819
819
|
static get current(): Engine;
|
|
820
|
+
static load(data: IEngineSerialize): Promise<Engine>;
|
|
820
821
|
constructor(context: Context);
|
|
821
822
|
get state(): _blibliki_transport.TransportState;
|
|
822
823
|
initialize(): Promise<void>;
|
|
@@ -835,9 +836,11 @@ declare class Engine {
|
|
|
835
836
|
set timeSignature(value: TimeSignature);
|
|
836
837
|
resume(): Promise<void>;
|
|
837
838
|
dispose(): void;
|
|
839
|
+
serialize(): IEngineSerialize;
|
|
838
840
|
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
839
841
|
findIO(moduleId: string, ioName: string, type: "input" | "output"): Base;
|
|
840
842
|
findMidiDevice(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
843
|
+
findMidiDeviceByName(name: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
841
844
|
onPropsUpdate(callback: <T extends ModuleType>(params: IModule<T> | IPolyModule<T>) => void): void;
|
|
842
845
|
_triggerPropsUpdate<T extends ModuleType>(params: IModule<T> | IPolyModule<T>): void;
|
|
843
846
|
triggerVirtualMidi(id: string, noteName: string, type: "noteOn" | "noteOff"): void;
|
|
@@ -845,4 +848,4 @@ declare class Engine {
|
|
|
845
848
|
private onStop;
|
|
846
849
|
}
|
|
847
850
|
|
|
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 };
|
|
851
|
+
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 };
|