@blibliki/engine 0.3.3 → 0.3.5
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/README.md +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -103
- package/dist/index.d.ts +46 -103
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/Engine.ts +45 -30
- package/src/core/Note/index.ts +3 -3
- package/src/core/index.ts +0 -3
- package/src/core/midi/ComputerKeyboardDevice.ts +9 -2
- package/src/core/midi/MidiDevice.ts +5 -3
- package/src/core/midi/MidiDeviceManager.ts +14 -5
- package/src/core/midi/MidiEvent.ts +10 -6
- package/src/core/module/Module.ts +7 -8
- package/src/core/module/PolyModule.ts +3 -3
- package/src/core/module/VoiceScheduler.ts +3 -3
- package/src/index.ts +6 -3
- package/src/modules/BiquadFilter.ts +4 -4
- package/src/modules/Constant.ts +12 -11
- package/src/modules/Envelope.ts +16 -21
- package/src/modules/Filter.ts +3 -2
- package/src/modules/Gain.ts +4 -3
- package/src/modules/Inspector.ts +4 -3
- package/src/modules/Master.ts +3 -4
- package/src/modules/Oscillator.ts +18 -21
- package/src/modules/Scale.ts +3 -2
- package/src/modules/StepSequencer.ts +1 -2
- package/src/modules/VirtualMidi.ts +3 -3
- package/src/processors/index.ts +7 -11
- package/src/core/Timing/Scheduler.ts +0 -37
- package/src/core/Timing/Time.ts +0 -103
- package/src/core/Timing/Transport.ts +0 -104
- package/src/core/Timing/index.ts +0 -16
package/dist/index.d.cts
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
+
import * as _blibliki_utils from '@blibliki/utils';
|
|
2
|
+
import { Context, Optional, EmptyObject } from '@blibliki/utils';
|
|
3
|
+
export { Context } from '@blibliki/utils';
|
|
1
4
|
import { Message, Input } from 'webmidi';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type TTime = number | BarsBeatsSixteenths | Time;
|
|
6
|
-
declare const t: (value?: TTime) => Time;
|
|
7
|
-
declare const nt: (value?: TTime) => number;
|
|
8
|
-
declare class Time {
|
|
9
|
-
private value;
|
|
10
|
-
private _notation?;
|
|
11
|
-
private _number?;
|
|
12
|
-
constructor(value: TTime);
|
|
13
|
-
add(value: TTime): Time;
|
|
14
|
-
subtrack(value: TTime): Time;
|
|
15
|
-
isBefore(value: TTime): boolean;
|
|
16
|
-
isAfter(value: TTime): boolean;
|
|
17
|
-
isEqual(value: TTime): boolean;
|
|
18
|
-
toNotation(): BarsBeatsSixteenths;
|
|
19
|
-
toNumber(): number;
|
|
20
|
-
private get transport();
|
|
21
|
-
}
|
|
5
|
+
import * as _blibliki_transport from '@blibliki/transport';
|
|
6
|
+
import { Seconds, ContextTime, Transport, TransportEvent, TimeSignature } from '@blibliki/transport';
|
|
7
|
+
export { Position, TimeSignature, TransportState } from '@blibliki/transport';
|
|
22
8
|
|
|
23
9
|
type INote = {
|
|
24
10
|
name: string;
|
|
25
11
|
octave: number;
|
|
26
12
|
frequency: number;
|
|
27
|
-
duration?:
|
|
13
|
+
duration?: Seconds;
|
|
28
14
|
velocity?: number;
|
|
29
15
|
};
|
|
30
16
|
declare class Note implements INote {
|
|
@@ -32,7 +18,7 @@ declare class Note implements INote {
|
|
|
32
18
|
name: string;
|
|
33
19
|
octave: number;
|
|
34
20
|
velocity: number;
|
|
35
|
-
duration?:
|
|
21
|
+
duration?: Seconds;
|
|
36
22
|
static fromFrequency(frequency: number): Note;
|
|
37
23
|
static fromEvent(message: Message): Note;
|
|
38
24
|
static notes(octave?: number): Note[];
|
|
@@ -57,11 +43,11 @@ declare enum MidiEventType {
|
|
|
57
43
|
declare class MidiEvent {
|
|
58
44
|
note?: Note;
|
|
59
45
|
voiceNo?: number;
|
|
60
|
-
readonly triggeredAt:
|
|
46
|
+
readonly triggeredAt: ContextTime;
|
|
61
47
|
private message;
|
|
62
|
-
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn
|
|
63
|
-
static fromCC(cc: number, value: number, triggeredAt
|
|
64
|
-
constructor(message: Message, triggeredAt
|
|
48
|
+
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn: boolean | undefined, triggeredAt: ContextTime): MidiEvent;
|
|
49
|
+
static fromCC(cc: number, value: number, triggeredAt: ContextTime): MidiEvent;
|
|
50
|
+
constructor(message: Message, triggeredAt: ContextTime);
|
|
65
51
|
get type(): MidiEventType;
|
|
66
52
|
get isNote(): boolean;
|
|
67
53
|
defineNotes(): void;
|
|
@@ -86,8 +72,9 @@ declare class MidiDevice implements IMidiDevice {
|
|
|
86
72
|
id: string;
|
|
87
73
|
name: string;
|
|
88
74
|
eventListerCallbacks: EventListerCallback[];
|
|
75
|
+
private context;
|
|
89
76
|
private input;
|
|
90
|
-
constructor(input: Input);
|
|
77
|
+
constructor(input: Input, context: Context);
|
|
91
78
|
get state(): MidiPortState;
|
|
92
79
|
connect(): void;
|
|
93
80
|
disconnect(): void;
|
|
@@ -106,7 +93,8 @@ declare class ComputerKeyboardInput implements IMidiInput {
|
|
|
106
93
|
name: string;
|
|
107
94
|
state: MidiPortState;
|
|
108
95
|
eventListerCallbacks: EventListerCallback[];
|
|
109
|
-
|
|
96
|
+
private context;
|
|
97
|
+
constructor(context: Context);
|
|
110
98
|
addEventListener(callback: EventListerCallback): void;
|
|
111
99
|
removeEventListener(callback: EventListerCallback): void;
|
|
112
100
|
serialize(): {
|
|
@@ -160,42 +148,6 @@ declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements
|
|
|
160
148
|
findIOByVoice(voice: number): AudioOutput;
|
|
161
149
|
}
|
|
162
150
|
|
|
163
|
-
declare enum TransportState {
|
|
164
|
-
playing = "playing",
|
|
165
|
-
stopped = "stopped",
|
|
166
|
-
paused = "paused"
|
|
167
|
-
}
|
|
168
|
-
type TPlaybackCallback = (actionAt: TTime) => void;
|
|
169
|
-
type TransportProps = {
|
|
170
|
-
onStart?: TPlaybackCallback;
|
|
171
|
-
onStop?: TPlaybackCallback;
|
|
172
|
-
};
|
|
173
|
-
declare class Transport {
|
|
174
|
-
bpm: number;
|
|
175
|
-
timeSignature: [number, number];
|
|
176
|
-
loopStart: TTime;
|
|
177
|
-
loopEnd?: TTime;
|
|
178
|
-
state: TransportState;
|
|
179
|
-
offset: TTime;
|
|
180
|
-
private startTime;
|
|
181
|
-
private onStart;
|
|
182
|
-
private onStop;
|
|
183
|
-
private scheduler;
|
|
184
|
-
constructor(props: TransportProps);
|
|
185
|
-
start({ offset, actionAt, }: {
|
|
186
|
-
offset?: TTime;
|
|
187
|
-
actionAt?: TTime;
|
|
188
|
-
}): TTime | undefined;
|
|
189
|
-
stop({ actionAt: actionAt }: {
|
|
190
|
-
actionAt?: TTime;
|
|
191
|
-
}): TTime | undefined;
|
|
192
|
-
pause({ actionAt: actionAt }: {
|
|
193
|
-
actionAt?: TTime;
|
|
194
|
-
}): TTime | undefined;
|
|
195
|
-
get playhead(): Time;
|
|
196
|
-
private validateFutureTime;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
151
|
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
200
152
|
voices: number;
|
|
201
153
|
};
|
|
@@ -225,8 +177,8 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
225
177
|
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
226
178
|
get voices(): number;
|
|
227
179
|
set voices(value: number);
|
|
228
|
-
start(time:
|
|
229
|
-
stop(time:
|
|
180
|
+
start(time: ContextTime): void;
|
|
181
|
+
stop(time: ContextTime): void;
|
|
230
182
|
serialize(): IPolyModuleSerialize<T>;
|
|
231
183
|
plug({ audioModule, from, to, }: {
|
|
232
184
|
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
@@ -245,7 +197,7 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
245
197
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
246
198
|
private adjustNumberOfModules;
|
|
247
199
|
protected get engine(): Engine;
|
|
248
|
-
protected get context():
|
|
200
|
+
protected get context(): _blibliki_utils.Context;
|
|
249
201
|
}
|
|
250
202
|
|
|
251
203
|
type MidiInputProps = IOProps & {
|
|
@@ -314,7 +266,7 @@ type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
|
314
266
|
outputs: IIOSerialize[];
|
|
315
267
|
};
|
|
316
268
|
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
317
|
-
audioNodeConstructor?: (context:
|
|
269
|
+
audioNodeConstructor?: (context: Context) => AudioNode;
|
|
318
270
|
};
|
|
319
271
|
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
320
272
|
id: string;
|
|
@@ -339,10 +291,10 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
339
291
|
}): void;
|
|
340
292
|
protected rePlugAll(callback?: () => void): void;
|
|
341
293
|
protected unPlugAll(): void;
|
|
342
|
-
start(_time:
|
|
343
|
-
stop(_time:
|
|
344
|
-
triggerAttack(note: Note, _triggeredAt:
|
|
345
|
-
triggerRelease(note: Note, _triggeredAt:
|
|
294
|
+
start(_time: ContextTime): void;
|
|
295
|
+
stop(_time: ContextTime): void;
|
|
296
|
+
triggerAttack(note: Note, _triggeredAt: ContextTime): void;
|
|
297
|
+
triggerRelease(note: Note, _triggeredAt: ContextTime): void;
|
|
346
298
|
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
347
299
|
protected triggerPropsUpdate(): void;
|
|
348
300
|
dispose(): void;
|
|
@@ -352,7 +304,7 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
352
304
|
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
353
305
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
354
306
|
protected get engine(): Engine;
|
|
355
|
-
protected get context():
|
|
307
|
+
protected get context(): Context;
|
|
356
308
|
}
|
|
357
309
|
|
|
358
310
|
type IPlug = {
|
|
@@ -382,11 +334,13 @@ declare class MidiDeviceManager {
|
|
|
382
334
|
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
383
335
|
private initialized;
|
|
384
336
|
private listeners;
|
|
385
|
-
|
|
337
|
+
private context;
|
|
338
|
+
constructor(context: Context);
|
|
386
339
|
initialize(): Promise<void>;
|
|
387
340
|
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
388
341
|
addListener(callback: ListenerCallback): void;
|
|
389
342
|
private initializeDevices;
|
|
343
|
+
private addComputerKeyboard;
|
|
390
344
|
private listenChanges;
|
|
391
345
|
}
|
|
392
346
|
|
|
@@ -419,13 +373,11 @@ type PropSchema<T> = {
|
|
|
419
373
|
[K in keyof T]: PropDefinition<T[K]>;
|
|
420
374
|
};
|
|
421
375
|
|
|
422
|
-
type IAnyAudioContext = AudioContext | OfflineAudioContext;
|
|
423
|
-
|
|
424
376
|
type IVoiceSchedulerProps = EmptyObject;
|
|
425
377
|
declare class Voice extends Module<ModuleType.VoiceScheduler> {
|
|
426
378
|
audioNode: undefined;
|
|
427
379
|
activeNote: string | null;
|
|
428
|
-
triggeredAt:
|
|
380
|
+
triggeredAt: ContextTime;
|
|
429
381
|
constructor(engineId: string, params: ICreateModule<ModuleType.VoiceScheduler>);
|
|
430
382
|
midiTriggered: (midiEvent: MidiEvent) => void;
|
|
431
383
|
}
|
|
@@ -458,9 +410,9 @@ declare class Constant extends Module<ModuleType.Constant> {
|
|
|
458
410
|
isStated: boolean;
|
|
459
411
|
constructor(engineId: string, params: ICreateModule<ModuleType.Constant>);
|
|
460
412
|
protected onSetValue(value: IConstantProps["value"]): void;
|
|
461
|
-
start(time:
|
|
462
|
-
stop(time:
|
|
463
|
-
triggerAttack: (note: Note, triggeredAt:
|
|
413
|
+
start(time: ContextTime): void;
|
|
414
|
+
stop(time: ContextTime): void;
|
|
415
|
+
triggerAttack: (note: Note, triggeredAt: ContextTime) => void;
|
|
464
416
|
triggerRelease: () => void;
|
|
465
417
|
}
|
|
466
418
|
|
|
@@ -556,8 +508,8 @@ type IOscillatorProps = {
|
|
|
556
508
|
};
|
|
557
509
|
declare class Oscillator extends PolyModule<ModuleType.Oscillator> {
|
|
558
510
|
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Oscillator>);
|
|
559
|
-
start(time:
|
|
560
|
-
stop(time:
|
|
511
|
+
start(time: ContextTime): void;
|
|
512
|
+
stop(time: ContextTime): void;
|
|
561
513
|
private registerInputs;
|
|
562
514
|
}
|
|
563
515
|
|
|
@@ -580,7 +532,6 @@ declare class Scale extends Module<ModuleType.Scale> {
|
|
|
580
532
|
type IStepSequencer = IModule<ModuleType.StepSequencer>;
|
|
581
533
|
type ISequence = {
|
|
582
534
|
active: boolean;
|
|
583
|
-
time: BarsBeatsSixteenths;
|
|
584
535
|
duration: string;
|
|
585
536
|
notes: INote[];
|
|
586
537
|
};
|
|
@@ -603,8 +554,8 @@ declare class VirtualMidi extends Module<ModuleType.VirtualMidi> {
|
|
|
603
554
|
midiOutput: MidiOutput;
|
|
604
555
|
constructor(engineId: string, params: ICreateModule<ModuleType.VirtualMidi>);
|
|
605
556
|
sendMidi(midiEvent: MidiEvent): void;
|
|
606
|
-
triggerAttack: (note: Note, triggerAttack:
|
|
607
|
-
triggerRelease: (note: Note, triggerAttack:
|
|
557
|
+
triggerAttack: (note: Note, triggerAttack: ContextTime) => void;
|
|
558
|
+
triggerRelease: (note: Note, triggerAttack: ContextTime) => void;
|
|
608
559
|
private registerInputs;
|
|
609
560
|
private registerOutputs;
|
|
610
561
|
}
|
|
@@ -723,16 +674,16 @@ declare class Engine {
|
|
|
723
674
|
private static _currentId;
|
|
724
675
|
private propsUpdateCallbacks;
|
|
725
676
|
readonly id: string;
|
|
726
|
-
context:
|
|
677
|
+
context: Context;
|
|
727
678
|
isInitialized: boolean;
|
|
728
679
|
routes: Routes;
|
|
729
|
-
transport: Transport
|
|
680
|
+
transport: Transport<TransportEvent>;
|
|
730
681
|
modules: Map<string, ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping]>;
|
|
731
682
|
midiDeviceManager: MidiDeviceManager;
|
|
732
683
|
static getById(id: string): Engine;
|
|
733
684
|
static get current(): Engine;
|
|
734
|
-
constructor(context:
|
|
735
|
-
get state(): TransportState;
|
|
685
|
+
constructor(context: Context);
|
|
686
|
+
get state(): _blibliki_transport.TransportState;
|
|
736
687
|
initialize(): Promise<void>;
|
|
737
688
|
addModule<T extends ModuleType>(params: ICreateModule<T>): IModuleSerialize<ModuleType.Scale> | IPolyModuleSerialize<ModuleType.VoiceScheduler> | IPolyModuleSerialize<ModuleType.Gain> | IPolyModuleSerialize<ModuleType.Oscillator> | IPolyModuleSerialize<ModuleType.Envelope> | IPolyModuleSerialize<ModuleType.Filter> | IPolyModuleSerialize<ModuleType.BiquadFilter> | IModuleSerialize<ModuleType.Master> | IModuleSerialize<ModuleType.MidiSelector> | IModuleSerialize<ModuleType.Inspector> | IModuleSerialize<ModuleType.Constant> | IModuleSerialize<ModuleType.VirtualMidi> | IModuleSerialize<ModuleType.StepSequencer>;
|
|
738
689
|
updateModule<T extends ModuleType>(params: IUpdateModule<T>): IModuleSerialize<ModuleType.Scale> | IPolyModuleSerialize<ModuleType.VoiceScheduler> | IPolyModuleSerialize<ModuleType.Gain> | IPolyModuleSerialize<ModuleType.Oscillator> | IPolyModuleSerialize<ModuleType.Envelope> | IPolyModuleSerialize<ModuleType.Filter> | IPolyModuleSerialize<ModuleType.BiquadFilter> | IModuleSerialize<ModuleType.Master> | IModuleSerialize<ModuleType.MidiSelector> | IModuleSerialize<ModuleType.Inspector> | IModuleSerialize<ModuleType.Constant> | IModuleSerialize<ModuleType.VirtualMidi> | IModuleSerialize<ModuleType.StepSequencer>;
|
|
@@ -740,21 +691,13 @@ declare class Engine {
|
|
|
740
691
|
addRoute(props: ICreateRoute): IRoute;
|
|
741
692
|
removeRoute(id: string): void;
|
|
742
693
|
validRoute(props: Optional<IRoute, "id">): boolean;
|
|
743
|
-
start(
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}): Promise<void>;
|
|
747
|
-
stop(props?: {
|
|
748
|
-
actionAt?: TTime;
|
|
749
|
-
}): void;
|
|
750
|
-
pause(props?: {
|
|
751
|
-
actionAt?: TTime;
|
|
752
|
-
}): void;
|
|
694
|
+
start(): Promise<void>;
|
|
695
|
+
stop(): void;
|
|
696
|
+
pause(): void;
|
|
753
697
|
get bpm(): number;
|
|
754
698
|
set bpm(value: number);
|
|
755
|
-
get timeSignature():
|
|
756
|
-
set timeSignature(value:
|
|
757
|
-
get playhead(): Time;
|
|
699
|
+
get timeSignature(): TimeSignature;
|
|
700
|
+
set timeSignature(value: TimeSignature);
|
|
758
701
|
resume(): Promise<void>;
|
|
759
702
|
dispose(): void;
|
|
760
703
|
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
@@ -767,4 +710,4 @@ declare class Engine {
|
|
|
767
710
|
private onStop;
|
|
768
711
|
}
|
|
769
712
|
|
|
770
|
-
export { type ArrayProp, type BooleanProp, Engine, type EnumProp, type ICreateModule, type ICreateRoute, type IGain, type IIOSerialize, type IMaster, type IMidiDevice, type IModule, type IModuleSerialize, type INote, type IOscillator, type IPolyModuleSerialize, type IRoute, type ISequence, type IStepSequencer, type IStepSequencerProps, type IUpdateModule, MidiDevice, MidiPortState, type ModuleParams, ModuleType, type ModuleTypeToPropsMapping, Note, type NumberProp, OscillatorWave, type PropDefinition, type PropSchema, type StringProp,
|
|
713
|
+
export { type ArrayProp, type BooleanProp, Engine, type EnumProp, type ICreateModule, type ICreateRoute, type IGain, type IIOSerialize, type IMaster, type IMidiDevice, type IModule, type IModuleSerialize, type INote, type IOscillator, type IPolyModuleSerialize, type IRoute, type ISequence, type IStepSequencer, type IStepSequencerProps, type IUpdateModule, MidiDevice, MidiPortState, type ModuleParams, ModuleType, type ModuleTypeToPropsMapping, Note, type NumberProp, OscillatorWave, type PropDefinition, type PropSchema, type StringProp, moduleSchemas };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
+
import * as _blibliki_utils from '@blibliki/utils';
|
|
2
|
+
import { Context, Optional, EmptyObject } from '@blibliki/utils';
|
|
3
|
+
export { Context } from '@blibliki/utils';
|
|
1
4
|
import { Message, Input } from 'webmidi';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type TTime = number | BarsBeatsSixteenths | Time;
|
|
6
|
-
declare const t: (value?: TTime) => Time;
|
|
7
|
-
declare const nt: (value?: TTime) => number;
|
|
8
|
-
declare class Time {
|
|
9
|
-
private value;
|
|
10
|
-
private _notation?;
|
|
11
|
-
private _number?;
|
|
12
|
-
constructor(value: TTime);
|
|
13
|
-
add(value: TTime): Time;
|
|
14
|
-
subtrack(value: TTime): Time;
|
|
15
|
-
isBefore(value: TTime): boolean;
|
|
16
|
-
isAfter(value: TTime): boolean;
|
|
17
|
-
isEqual(value: TTime): boolean;
|
|
18
|
-
toNotation(): BarsBeatsSixteenths;
|
|
19
|
-
toNumber(): number;
|
|
20
|
-
private get transport();
|
|
21
|
-
}
|
|
5
|
+
import * as _blibliki_transport from '@blibliki/transport';
|
|
6
|
+
import { Seconds, ContextTime, Transport, TransportEvent, TimeSignature } from '@blibliki/transport';
|
|
7
|
+
export { Position, TimeSignature, TransportState } from '@blibliki/transport';
|
|
22
8
|
|
|
23
9
|
type INote = {
|
|
24
10
|
name: string;
|
|
25
11
|
octave: number;
|
|
26
12
|
frequency: number;
|
|
27
|
-
duration?:
|
|
13
|
+
duration?: Seconds;
|
|
28
14
|
velocity?: number;
|
|
29
15
|
};
|
|
30
16
|
declare class Note implements INote {
|
|
@@ -32,7 +18,7 @@ declare class Note implements INote {
|
|
|
32
18
|
name: string;
|
|
33
19
|
octave: number;
|
|
34
20
|
velocity: number;
|
|
35
|
-
duration?:
|
|
21
|
+
duration?: Seconds;
|
|
36
22
|
static fromFrequency(frequency: number): Note;
|
|
37
23
|
static fromEvent(message: Message): Note;
|
|
38
24
|
static notes(octave?: number): Note[];
|
|
@@ -57,11 +43,11 @@ declare enum MidiEventType {
|
|
|
57
43
|
declare class MidiEvent {
|
|
58
44
|
note?: Note;
|
|
59
45
|
voiceNo?: number;
|
|
60
|
-
readonly triggeredAt:
|
|
46
|
+
readonly triggeredAt: ContextTime;
|
|
61
47
|
private message;
|
|
62
|
-
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn
|
|
63
|
-
static fromCC(cc: number, value: number, triggeredAt
|
|
64
|
-
constructor(message: Message, triggeredAt
|
|
48
|
+
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn: boolean | undefined, triggeredAt: ContextTime): MidiEvent;
|
|
49
|
+
static fromCC(cc: number, value: number, triggeredAt: ContextTime): MidiEvent;
|
|
50
|
+
constructor(message: Message, triggeredAt: ContextTime);
|
|
65
51
|
get type(): MidiEventType;
|
|
66
52
|
get isNote(): boolean;
|
|
67
53
|
defineNotes(): void;
|
|
@@ -86,8 +72,9 @@ declare class MidiDevice implements IMidiDevice {
|
|
|
86
72
|
id: string;
|
|
87
73
|
name: string;
|
|
88
74
|
eventListerCallbacks: EventListerCallback[];
|
|
75
|
+
private context;
|
|
89
76
|
private input;
|
|
90
|
-
constructor(input: Input);
|
|
77
|
+
constructor(input: Input, context: Context);
|
|
91
78
|
get state(): MidiPortState;
|
|
92
79
|
connect(): void;
|
|
93
80
|
disconnect(): void;
|
|
@@ -106,7 +93,8 @@ declare class ComputerKeyboardInput implements IMidiInput {
|
|
|
106
93
|
name: string;
|
|
107
94
|
state: MidiPortState;
|
|
108
95
|
eventListerCallbacks: EventListerCallback[];
|
|
109
|
-
|
|
96
|
+
private context;
|
|
97
|
+
constructor(context: Context);
|
|
110
98
|
addEventListener(callback: EventListerCallback): void;
|
|
111
99
|
removeEventListener(callback: EventListerCallback): void;
|
|
112
100
|
serialize(): {
|
|
@@ -160,42 +148,6 @@ declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements
|
|
|
160
148
|
findIOByVoice(voice: number): AudioOutput;
|
|
161
149
|
}
|
|
162
150
|
|
|
163
|
-
declare enum TransportState {
|
|
164
|
-
playing = "playing",
|
|
165
|
-
stopped = "stopped",
|
|
166
|
-
paused = "paused"
|
|
167
|
-
}
|
|
168
|
-
type TPlaybackCallback = (actionAt: TTime) => void;
|
|
169
|
-
type TransportProps = {
|
|
170
|
-
onStart?: TPlaybackCallback;
|
|
171
|
-
onStop?: TPlaybackCallback;
|
|
172
|
-
};
|
|
173
|
-
declare class Transport {
|
|
174
|
-
bpm: number;
|
|
175
|
-
timeSignature: [number, number];
|
|
176
|
-
loopStart: TTime;
|
|
177
|
-
loopEnd?: TTime;
|
|
178
|
-
state: TransportState;
|
|
179
|
-
offset: TTime;
|
|
180
|
-
private startTime;
|
|
181
|
-
private onStart;
|
|
182
|
-
private onStop;
|
|
183
|
-
private scheduler;
|
|
184
|
-
constructor(props: TransportProps);
|
|
185
|
-
start({ offset, actionAt, }: {
|
|
186
|
-
offset?: TTime;
|
|
187
|
-
actionAt?: TTime;
|
|
188
|
-
}): TTime | undefined;
|
|
189
|
-
stop({ actionAt: actionAt }: {
|
|
190
|
-
actionAt?: TTime;
|
|
191
|
-
}): TTime | undefined;
|
|
192
|
-
pause({ actionAt: actionAt }: {
|
|
193
|
-
actionAt?: TTime;
|
|
194
|
-
}): TTime | undefined;
|
|
195
|
-
get playhead(): Time;
|
|
196
|
-
private validateFutureTime;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
151
|
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
200
152
|
voices: number;
|
|
201
153
|
};
|
|
@@ -225,8 +177,8 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
225
177
|
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
226
178
|
get voices(): number;
|
|
227
179
|
set voices(value: number);
|
|
228
|
-
start(time:
|
|
229
|
-
stop(time:
|
|
180
|
+
start(time: ContextTime): void;
|
|
181
|
+
stop(time: ContextTime): void;
|
|
230
182
|
serialize(): IPolyModuleSerialize<T>;
|
|
231
183
|
plug({ audioModule, from, to, }: {
|
|
232
184
|
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
@@ -245,7 +197,7 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
245
197
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
246
198
|
private adjustNumberOfModules;
|
|
247
199
|
protected get engine(): Engine;
|
|
248
|
-
protected get context():
|
|
200
|
+
protected get context(): _blibliki_utils.Context;
|
|
249
201
|
}
|
|
250
202
|
|
|
251
203
|
type MidiInputProps = IOProps & {
|
|
@@ -314,7 +266,7 @@ type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
|
314
266
|
outputs: IIOSerialize[];
|
|
315
267
|
};
|
|
316
268
|
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
317
|
-
audioNodeConstructor?: (context:
|
|
269
|
+
audioNodeConstructor?: (context: Context) => AudioNode;
|
|
318
270
|
};
|
|
319
271
|
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
320
272
|
id: string;
|
|
@@ -339,10 +291,10 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
339
291
|
}): void;
|
|
340
292
|
protected rePlugAll(callback?: () => void): void;
|
|
341
293
|
protected unPlugAll(): void;
|
|
342
|
-
start(_time:
|
|
343
|
-
stop(_time:
|
|
344
|
-
triggerAttack(note: Note, _triggeredAt:
|
|
345
|
-
triggerRelease(note: Note, _triggeredAt:
|
|
294
|
+
start(_time: ContextTime): void;
|
|
295
|
+
stop(_time: ContextTime): void;
|
|
296
|
+
triggerAttack(note: Note, _triggeredAt: ContextTime): void;
|
|
297
|
+
triggerRelease(note: Note, _triggeredAt: ContextTime): void;
|
|
346
298
|
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
347
299
|
protected triggerPropsUpdate(): void;
|
|
348
300
|
dispose(): void;
|
|
@@ -352,7 +304,7 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
352
304
|
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
353
305
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
354
306
|
protected get engine(): Engine;
|
|
355
|
-
protected get context():
|
|
307
|
+
protected get context(): Context;
|
|
356
308
|
}
|
|
357
309
|
|
|
358
310
|
type IPlug = {
|
|
@@ -382,11 +334,13 @@ declare class MidiDeviceManager {
|
|
|
382
334
|
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
383
335
|
private initialized;
|
|
384
336
|
private listeners;
|
|
385
|
-
|
|
337
|
+
private context;
|
|
338
|
+
constructor(context: Context);
|
|
386
339
|
initialize(): Promise<void>;
|
|
387
340
|
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
388
341
|
addListener(callback: ListenerCallback): void;
|
|
389
342
|
private initializeDevices;
|
|
343
|
+
private addComputerKeyboard;
|
|
390
344
|
private listenChanges;
|
|
391
345
|
}
|
|
392
346
|
|
|
@@ -419,13 +373,11 @@ type PropSchema<T> = {
|
|
|
419
373
|
[K in keyof T]: PropDefinition<T[K]>;
|
|
420
374
|
};
|
|
421
375
|
|
|
422
|
-
type IAnyAudioContext = AudioContext | OfflineAudioContext;
|
|
423
|
-
|
|
424
376
|
type IVoiceSchedulerProps = EmptyObject;
|
|
425
377
|
declare class Voice extends Module<ModuleType.VoiceScheduler> {
|
|
426
378
|
audioNode: undefined;
|
|
427
379
|
activeNote: string | null;
|
|
428
|
-
triggeredAt:
|
|
380
|
+
triggeredAt: ContextTime;
|
|
429
381
|
constructor(engineId: string, params: ICreateModule<ModuleType.VoiceScheduler>);
|
|
430
382
|
midiTriggered: (midiEvent: MidiEvent) => void;
|
|
431
383
|
}
|
|
@@ -458,9 +410,9 @@ declare class Constant extends Module<ModuleType.Constant> {
|
|
|
458
410
|
isStated: boolean;
|
|
459
411
|
constructor(engineId: string, params: ICreateModule<ModuleType.Constant>);
|
|
460
412
|
protected onSetValue(value: IConstantProps["value"]): void;
|
|
461
|
-
start(time:
|
|
462
|
-
stop(time:
|
|
463
|
-
triggerAttack: (note: Note, triggeredAt:
|
|
413
|
+
start(time: ContextTime): void;
|
|
414
|
+
stop(time: ContextTime): void;
|
|
415
|
+
triggerAttack: (note: Note, triggeredAt: ContextTime) => void;
|
|
464
416
|
triggerRelease: () => void;
|
|
465
417
|
}
|
|
466
418
|
|
|
@@ -556,8 +508,8 @@ type IOscillatorProps = {
|
|
|
556
508
|
};
|
|
557
509
|
declare class Oscillator extends PolyModule<ModuleType.Oscillator> {
|
|
558
510
|
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Oscillator>);
|
|
559
|
-
start(time:
|
|
560
|
-
stop(time:
|
|
511
|
+
start(time: ContextTime): void;
|
|
512
|
+
stop(time: ContextTime): void;
|
|
561
513
|
private registerInputs;
|
|
562
514
|
}
|
|
563
515
|
|
|
@@ -580,7 +532,6 @@ declare class Scale extends Module<ModuleType.Scale> {
|
|
|
580
532
|
type IStepSequencer = IModule<ModuleType.StepSequencer>;
|
|
581
533
|
type ISequence = {
|
|
582
534
|
active: boolean;
|
|
583
|
-
time: BarsBeatsSixteenths;
|
|
584
535
|
duration: string;
|
|
585
536
|
notes: INote[];
|
|
586
537
|
};
|
|
@@ -603,8 +554,8 @@ declare class VirtualMidi extends Module<ModuleType.VirtualMidi> {
|
|
|
603
554
|
midiOutput: MidiOutput;
|
|
604
555
|
constructor(engineId: string, params: ICreateModule<ModuleType.VirtualMidi>);
|
|
605
556
|
sendMidi(midiEvent: MidiEvent): void;
|
|
606
|
-
triggerAttack: (note: Note, triggerAttack:
|
|
607
|
-
triggerRelease: (note: Note, triggerAttack:
|
|
557
|
+
triggerAttack: (note: Note, triggerAttack: ContextTime) => void;
|
|
558
|
+
triggerRelease: (note: Note, triggerAttack: ContextTime) => void;
|
|
608
559
|
private registerInputs;
|
|
609
560
|
private registerOutputs;
|
|
610
561
|
}
|
|
@@ -723,16 +674,16 @@ declare class Engine {
|
|
|
723
674
|
private static _currentId;
|
|
724
675
|
private propsUpdateCallbacks;
|
|
725
676
|
readonly id: string;
|
|
726
|
-
context:
|
|
677
|
+
context: Context;
|
|
727
678
|
isInitialized: boolean;
|
|
728
679
|
routes: Routes;
|
|
729
|
-
transport: Transport
|
|
680
|
+
transport: Transport<TransportEvent>;
|
|
730
681
|
modules: Map<string, ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping]>;
|
|
731
682
|
midiDeviceManager: MidiDeviceManager;
|
|
732
683
|
static getById(id: string): Engine;
|
|
733
684
|
static get current(): Engine;
|
|
734
|
-
constructor(context:
|
|
735
|
-
get state(): TransportState;
|
|
685
|
+
constructor(context: Context);
|
|
686
|
+
get state(): _blibliki_transport.TransportState;
|
|
736
687
|
initialize(): Promise<void>;
|
|
737
688
|
addModule<T extends ModuleType>(params: ICreateModule<T>): IModuleSerialize<ModuleType.Scale> | IPolyModuleSerialize<ModuleType.VoiceScheduler> | IPolyModuleSerialize<ModuleType.Gain> | IPolyModuleSerialize<ModuleType.Oscillator> | IPolyModuleSerialize<ModuleType.Envelope> | IPolyModuleSerialize<ModuleType.Filter> | IPolyModuleSerialize<ModuleType.BiquadFilter> | IModuleSerialize<ModuleType.Master> | IModuleSerialize<ModuleType.MidiSelector> | IModuleSerialize<ModuleType.Inspector> | IModuleSerialize<ModuleType.Constant> | IModuleSerialize<ModuleType.VirtualMidi> | IModuleSerialize<ModuleType.StepSequencer>;
|
|
738
689
|
updateModule<T extends ModuleType>(params: IUpdateModule<T>): IModuleSerialize<ModuleType.Scale> | IPolyModuleSerialize<ModuleType.VoiceScheduler> | IPolyModuleSerialize<ModuleType.Gain> | IPolyModuleSerialize<ModuleType.Oscillator> | IPolyModuleSerialize<ModuleType.Envelope> | IPolyModuleSerialize<ModuleType.Filter> | IPolyModuleSerialize<ModuleType.BiquadFilter> | IModuleSerialize<ModuleType.Master> | IModuleSerialize<ModuleType.MidiSelector> | IModuleSerialize<ModuleType.Inspector> | IModuleSerialize<ModuleType.Constant> | IModuleSerialize<ModuleType.VirtualMidi> | IModuleSerialize<ModuleType.StepSequencer>;
|
|
@@ -740,21 +691,13 @@ declare class Engine {
|
|
|
740
691
|
addRoute(props: ICreateRoute): IRoute;
|
|
741
692
|
removeRoute(id: string): void;
|
|
742
693
|
validRoute(props: Optional<IRoute, "id">): boolean;
|
|
743
|
-
start(
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}): Promise<void>;
|
|
747
|
-
stop(props?: {
|
|
748
|
-
actionAt?: TTime;
|
|
749
|
-
}): void;
|
|
750
|
-
pause(props?: {
|
|
751
|
-
actionAt?: TTime;
|
|
752
|
-
}): void;
|
|
694
|
+
start(): Promise<void>;
|
|
695
|
+
stop(): void;
|
|
696
|
+
pause(): void;
|
|
753
697
|
get bpm(): number;
|
|
754
698
|
set bpm(value: number);
|
|
755
|
-
get timeSignature():
|
|
756
|
-
set timeSignature(value:
|
|
757
|
-
get playhead(): Time;
|
|
699
|
+
get timeSignature(): TimeSignature;
|
|
700
|
+
set timeSignature(value: TimeSignature);
|
|
758
701
|
resume(): Promise<void>;
|
|
759
702
|
dispose(): void;
|
|
760
703
|
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
@@ -767,4 +710,4 @@ declare class Engine {
|
|
|
767
710
|
private onStop;
|
|
768
711
|
}
|
|
769
712
|
|
|
770
|
-
export { type ArrayProp, type BooleanProp, Engine, type EnumProp, type ICreateModule, type ICreateRoute, type IGain, type IIOSerialize, type IMaster, type IMidiDevice, type IModule, type IModuleSerialize, type INote, type IOscillator, type IPolyModuleSerialize, type IRoute, type ISequence, type IStepSequencer, type IStepSequencerProps, type IUpdateModule, MidiDevice, MidiPortState, type ModuleParams, ModuleType, type ModuleTypeToPropsMapping, Note, type NumberProp, OscillatorWave, type PropDefinition, type PropSchema, type StringProp,
|
|
713
|
+
export { type ArrayProp, type BooleanProp, Engine, type EnumProp, type ICreateModule, type ICreateRoute, type IGain, type IIOSerialize, type IMaster, type IMidiDevice, type IModule, type IModuleSerialize, type INote, type IOscillator, type IPolyModuleSerialize, type IRoute, type ISequence, type IStepSequencer, type IStepSequencerProps, type IUpdateModule, MidiDevice, MidiPortState, type ModuleParams, ModuleType, type ModuleTypeToPropsMapping, Note, type NumberProp, OscillatorWave, type PropDefinition, type PropSchema, type StringProp, moduleSchemas };
|