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