@blibliki/engine 0.3.2 → 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 -98
- package/dist/index.d.ts +45 -98
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/Engine.ts +54 -24
- 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 -1
- 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,28 +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 class Time {
|
|
7
|
-
private value;
|
|
8
|
-
private _notation?;
|
|
9
|
-
private _number?;
|
|
10
|
-
constructor(value: TTime);
|
|
11
|
-
add(value: TTime): Time;
|
|
12
|
-
subtrack(value: TTime): Time;
|
|
13
|
-
isBefore(value: TTime): boolean;
|
|
14
|
-
isAfter(value: TTime): boolean;
|
|
15
|
-
isEqual(value: TTime): boolean;
|
|
16
|
-
toNotation(): BarsBeatsSixteenths;
|
|
17
|
-
toNumber(): number;
|
|
18
|
-
private get transport();
|
|
19
|
-
}
|
|
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';
|
|
20
7
|
|
|
21
8
|
type INote = {
|
|
22
9
|
name: string;
|
|
23
10
|
octave: number;
|
|
24
11
|
frequency: number;
|
|
25
|
-
duration?:
|
|
12
|
+
duration?: Seconds;
|
|
26
13
|
velocity?: number;
|
|
27
14
|
};
|
|
28
15
|
declare class Note implements INote {
|
|
@@ -30,7 +17,7 @@ declare class Note implements INote {
|
|
|
30
17
|
name: string;
|
|
31
18
|
octave: number;
|
|
32
19
|
velocity: number;
|
|
33
|
-
duration?:
|
|
20
|
+
duration?: Seconds;
|
|
34
21
|
static fromFrequency(frequency: number): Note;
|
|
35
22
|
static fromEvent(message: Message): Note;
|
|
36
23
|
static notes(octave?: number): Note[];
|
|
@@ -55,11 +42,11 @@ declare enum MidiEventType {
|
|
|
55
42
|
declare class MidiEvent {
|
|
56
43
|
note?: Note;
|
|
57
44
|
voiceNo?: number;
|
|
58
|
-
readonly triggeredAt:
|
|
45
|
+
readonly triggeredAt: ContextTime;
|
|
59
46
|
private message;
|
|
60
|
-
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn
|
|
61
|
-
static fromCC(cc: number, value: number, triggeredAt
|
|
62
|
-
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);
|
|
63
50
|
get type(): MidiEventType;
|
|
64
51
|
get isNote(): boolean;
|
|
65
52
|
defineNotes(): void;
|
|
@@ -84,8 +71,9 @@ declare class MidiDevice implements IMidiDevice {
|
|
|
84
71
|
id: string;
|
|
85
72
|
name: string;
|
|
86
73
|
eventListerCallbacks: EventListerCallback[];
|
|
74
|
+
private context;
|
|
87
75
|
private input;
|
|
88
|
-
constructor(input: Input);
|
|
76
|
+
constructor(input: Input, context: Context);
|
|
89
77
|
get state(): MidiPortState;
|
|
90
78
|
connect(): void;
|
|
91
79
|
disconnect(): void;
|
|
@@ -104,7 +92,8 @@ declare class ComputerKeyboardInput implements IMidiInput {
|
|
|
104
92
|
name: string;
|
|
105
93
|
state: MidiPortState;
|
|
106
94
|
eventListerCallbacks: EventListerCallback[];
|
|
107
|
-
|
|
95
|
+
private context;
|
|
96
|
+
constructor(context: Context);
|
|
108
97
|
addEventListener(callback: EventListerCallback): void;
|
|
109
98
|
removeEventListener(callback: EventListerCallback): void;
|
|
110
99
|
serialize(): {
|
|
@@ -158,42 +147,6 @@ declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements
|
|
|
158
147
|
findIOByVoice(voice: number): AudioOutput;
|
|
159
148
|
}
|
|
160
149
|
|
|
161
|
-
declare enum TransportState {
|
|
162
|
-
playing = "playing",
|
|
163
|
-
stopped = "stopped",
|
|
164
|
-
paused = "paused"
|
|
165
|
-
}
|
|
166
|
-
type TPlaybackCallback = (actionAt: TTime) => void;
|
|
167
|
-
type TransportProps = {
|
|
168
|
-
onStart?: TPlaybackCallback;
|
|
169
|
-
onStop?: TPlaybackCallback;
|
|
170
|
-
};
|
|
171
|
-
declare class Transport {
|
|
172
|
-
bpm: number;
|
|
173
|
-
timeSignature: [number, number];
|
|
174
|
-
loopStart: TTime;
|
|
175
|
-
loopEnd?: TTime;
|
|
176
|
-
state: TransportState;
|
|
177
|
-
offset: TTime;
|
|
178
|
-
private startTime;
|
|
179
|
-
private onStart;
|
|
180
|
-
private onStop;
|
|
181
|
-
private scheduler;
|
|
182
|
-
constructor(props: TransportProps);
|
|
183
|
-
start({ offset, actionAt, }: {
|
|
184
|
-
offset?: TTime;
|
|
185
|
-
actionAt?: TTime;
|
|
186
|
-
}): TTime | undefined;
|
|
187
|
-
stop({ actionAt: actionAt }: {
|
|
188
|
-
actionAt?: TTime;
|
|
189
|
-
}): TTime | undefined;
|
|
190
|
-
pause({ actionAt: actionAt }: {
|
|
191
|
-
actionAt?: TTime;
|
|
192
|
-
}): TTime | undefined;
|
|
193
|
-
get playhead(): Time;
|
|
194
|
-
private validateFutureTime;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
150
|
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
198
151
|
voices: number;
|
|
199
152
|
};
|
|
@@ -223,8 +176,8 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
223
176
|
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
224
177
|
get voices(): number;
|
|
225
178
|
set voices(value: number);
|
|
226
|
-
start(time:
|
|
227
|
-
stop(time:
|
|
179
|
+
start(time: ContextTime): void;
|
|
180
|
+
stop(time: ContextTime): void;
|
|
228
181
|
serialize(): IPolyModuleSerialize<T>;
|
|
229
182
|
plug({ audioModule, from, to, }: {
|
|
230
183
|
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
@@ -243,7 +196,7 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
243
196
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
244
197
|
private adjustNumberOfModules;
|
|
245
198
|
protected get engine(): Engine;
|
|
246
|
-
protected get context():
|
|
199
|
+
protected get context(): _blibliki_utils.Context;
|
|
247
200
|
}
|
|
248
201
|
|
|
249
202
|
type MidiInputProps = IOProps & {
|
|
@@ -312,7 +265,7 @@ type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
|
312
265
|
outputs: IIOSerialize[];
|
|
313
266
|
};
|
|
314
267
|
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
315
|
-
audioNodeConstructor?: (context:
|
|
268
|
+
audioNodeConstructor?: (context: Context) => AudioNode;
|
|
316
269
|
};
|
|
317
270
|
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
318
271
|
id: string;
|
|
@@ -337,10 +290,10 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
337
290
|
}): void;
|
|
338
291
|
protected rePlugAll(callback?: () => void): void;
|
|
339
292
|
protected unPlugAll(): void;
|
|
340
|
-
start(_time:
|
|
341
|
-
stop(_time:
|
|
342
|
-
triggerAttack(note: Note, _triggeredAt:
|
|
343
|
-
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;
|
|
344
297
|
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
345
298
|
protected triggerPropsUpdate(): void;
|
|
346
299
|
dispose(): void;
|
|
@@ -350,7 +303,7 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
350
303
|
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
351
304
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
352
305
|
protected get engine(): Engine;
|
|
353
|
-
protected get context():
|
|
306
|
+
protected get context(): Context;
|
|
354
307
|
}
|
|
355
308
|
|
|
356
309
|
type IPlug = {
|
|
@@ -380,11 +333,13 @@ declare class MidiDeviceManager {
|
|
|
380
333
|
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
381
334
|
private initialized;
|
|
382
335
|
private listeners;
|
|
383
|
-
|
|
336
|
+
private context;
|
|
337
|
+
constructor(context: Context);
|
|
384
338
|
initialize(): Promise<void>;
|
|
385
339
|
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
386
340
|
addListener(callback: ListenerCallback): void;
|
|
387
341
|
private initializeDevices;
|
|
342
|
+
private addComputerKeyboard;
|
|
388
343
|
private listenChanges;
|
|
389
344
|
}
|
|
390
345
|
|
|
@@ -417,13 +372,11 @@ type PropSchema<T> = {
|
|
|
417
372
|
[K in keyof T]: PropDefinition<T[K]>;
|
|
418
373
|
};
|
|
419
374
|
|
|
420
|
-
type IAnyAudioContext = AudioContext | OfflineAudioContext;
|
|
421
|
-
|
|
422
375
|
type IVoiceSchedulerProps = EmptyObject;
|
|
423
376
|
declare class Voice extends Module<ModuleType.VoiceScheduler> {
|
|
424
377
|
audioNode: undefined;
|
|
425
378
|
activeNote: string | null;
|
|
426
|
-
triggeredAt:
|
|
379
|
+
triggeredAt: ContextTime;
|
|
427
380
|
constructor(engineId: string, params: ICreateModule<ModuleType.VoiceScheduler>);
|
|
428
381
|
midiTriggered: (midiEvent: MidiEvent) => void;
|
|
429
382
|
}
|
|
@@ -456,9 +409,9 @@ declare class Constant extends Module<ModuleType.Constant> {
|
|
|
456
409
|
isStated: boolean;
|
|
457
410
|
constructor(engineId: string, params: ICreateModule<ModuleType.Constant>);
|
|
458
411
|
protected onSetValue(value: IConstantProps["value"]): void;
|
|
459
|
-
start(time:
|
|
460
|
-
stop(time:
|
|
461
|
-
triggerAttack: (note: Note, triggeredAt:
|
|
412
|
+
start(time: ContextTime): void;
|
|
413
|
+
stop(time: ContextTime): void;
|
|
414
|
+
triggerAttack: (note: Note, triggeredAt: ContextTime) => void;
|
|
462
415
|
triggerRelease: () => void;
|
|
463
416
|
}
|
|
464
417
|
|
|
@@ -554,8 +507,8 @@ type IOscillatorProps = {
|
|
|
554
507
|
};
|
|
555
508
|
declare class Oscillator extends PolyModule<ModuleType.Oscillator> {
|
|
556
509
|
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Oscillator>);
|
|
557
|
-
start(time:
|
|
558
|
-
stop(time:
|
|
510
|
+
start(time: ContextTime): void;
|
|
511
|
+
stop(time: ContextTime): void;
|
|
559
512
|
private registerInputs;
|
|
560
513
|
}
|
|
561
514
|
|
|
@@ -578,7 +531,6 @@ declare class Scale extends Module<ModuleType.Scale> {
|
|
|
578
531
|
type IStepSequencer = IModule<ModuleType.StepSequencer>;
|
|
579
532
|
type ISequence = {
|
|
580
533
|
active: boolean;
|
|
581
|
-
time: BarsBeatsSixteenths;
|
|
582
534
|
duration: string;
|
|
583
535
|
notes: INote[];
|
|
584
536
|
};
|
|
@@ -601,8 +553,8 @@ declare class VirtualMidi extends Module<ModuleType.VirtualMidi> {
|
|
|
601
553
|
midiOutput: MidiOutput;
|
|
602
554
|
constructor(engineId: string, params: ICreateModule<ModuleType.VirtualMidi>);
|
|
603
555
|
sendMidi(midiEvent: MidiEvent): void;
|
|
604
|
-
triggerAttack: (note: Note, triggerAttack:
|
|
605
|
-
triggerRelease: (note: Note, triggerAttack:
|
|
556
|
+
triggerAttack: (note: Note, triggerAttack: ContextTime) => void;
|
|
557
|
+
triggerRelease: (note: Note, triggerAttack: ContextTime) => void;
|
|
606
558
|
private registerInputs;
|
|
607
559
|
private registerOutputs;
|
|
608
560
|
}
|
|
@@ -721,16 +673,16 @@ declare class Engine {
|
|
|
721
673
|
private static _currentId;
|
|
722
674
|
private propsUpdateCallbacks;
|
|
723
675
|
readonly id: string;
|
|
724
|
-
context:
|
|
676
|
+
context: Context;
|
|
725
677
|
isInitialized: boolean;
|
|
726
678
|
routes: Routes;
|
|
727
|
-
transport: Transport
|
|
679
|
+
transport: Transport<TransportEvent>;
|
|
728
680
|
modules: Map<string, ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping]>;
|
|
729
681
|
midiDeviceManager: MidiDeviceManager;
|
|
730
682
|
static getById(id: string): Engine;
|
|
731
683
|
static get current(): Engine;
|
|
732
|
-
constructor(context:
|
|
733
|
-
get state(): TransportState;
|
|
684
|
+
constructor(context: Context);
|
|
685
|
+
get state(): _blibliki_transport.TransportState;
|
|
734
686
|
initialize(): Promise<void>;
|
|
735
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>;
|
|
736
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>;
|
|
@@ -738,18 +690,13 @@ declare class Engine {
|
|
|
738
690
|
addRoute(props: ICreateRoute): IRoute;
|
|
739
691
|
removeRoute(id: string): void;
|
|
740
692
|
validRoute(props: Optional<IRoute, "id">): boolean;
|
|
741
|
-
start(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}): void;
|
|
745
|
-
stop(props?: {
|
|
746
|
-
actionAt?: TTime;
|
|
747
|
-
}): void;
|
|
748
|
-
pause(props?: {
|
|
749
|
-
actionAt?: TTime;
|
|
750
|
-
}): void;
|
|
693
|
+
start(): Promise<void>;
|
|
694
|
+
stop(): void;
|
|
695
|
+
pause(): void;
|
|
751
696
|
get bpm(): number;
|
|
752
697
|
set bpm(value: number);
|
|
698
|
+
get timeSignature(): TimeSignature;
|
|
699
|
+
set timeSignature(value: TimeSignature);
|
|
753
700
|
resume(): Promise<void>;
|
|
754
701
|
dispose(): void;
|
|
755
702
|
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
@@ -762,4 +709,4 @@ declare class Engine {
|
|
|
762
709
|
private onStop;
|
|
763
710
|
}
|
|
764
711
|
|
|
765
|
-
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,28 +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 class Time {
|
|
7
|
-
private value;
|
|
8
|
-
private _notation?;
|
|
9
|
-
private _number?;
|
|
10
|
-
constructor(value: TTime);
|
|
11
|
-
add(value: TTime): Time;
|
|
12
|
-
subtrack(value: TTime): Time;
|
|
13
|
-
isBefore(value: TTime): boolean;
|
|
14
|
-
isAfter(value: TTime): boolean;
|
|
15
|
-
isEqual(value: TTime): boolean;
|
|
16
|
-
toNotation(): BarsBeatsSixteenths;
|
|
17
|
-
toNumber(): number;
|
|
18
|
-
private get transport();
|
|
19
|
-
}
|
|
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';
|
|
20
7
|
|
|
21
8
|
type INote = {
|
|
22
9
|
name: string;
|
|
23
10
|
octave: number;
|
|
24
11
|
frequency: number;
|
|
25
|
-
duration?:
|
|
12
|
+
duration?: Seconds;
|
|
26
13
|
velocity?: number;
|
|
27
14
|
};
|
|
28
15
|
declare class Note implements INote {
|
|
@@ -30,7 +17,7 @@ declare class Note implements INote {
|
|
|
30
17
|
name: string;
|
|
31
18
|
octave: number;
|
|
32
19
|
velocity: number;
|
|
33
|
-
duration?:
|
|
20
|
+
duration?: Seconds;
|
|
34
21
|
static fromFrequency(frequency: number): Note;
|
|
35
22
|
static fromEvent(message: Message): Note;
|
|
36
23
|
static notes(octave?: number): Note[];
|
|
@@ -55,11 +42,11 @@ declare enum MidiEventType {
|
|
|
55
42
|
declare class MidiEvent {
|
|
56
43
|
note?: Note;
|
|
57
44
|
voiceNo?: number;
|
|
58
|
-
readonly triggeredAt:
|
|
45
|
+
readonly triggeredAt: ContextTime;
|
|
59
46
|
private message;
|
|
60
|
-
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn
|
|
61
|
-
static fromCC(cc: number, value: number, triggeredAt
|
|
62
|
-
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);
|
|
63
50
|
get type(): MidiEventType;
|
|
64
51
|
get isNote(): boolean;
|
|
65
52
|
defineNotes(): void;
|
|
@@ -84,8 +71,9 @@ declare class MidiDevice implements IMidiDevice {
|
|
|
84
71
|
id: string;
|
|
85
72
|
name: string;
|
|
86
73
|
eventListerCallbacks: EventListerCallback[];
|
|
74
|
+
private context;
|
|
87
75
|
private input;
|
|
88
|
-
constructor(input: Input);
|
|
76
|
+
constructor(input: Input, context: Context);
|
|
89
77
|
get state(): MidiPortState;
|
|
90
78
|
connect(): void;
|
|
91
79
|
disconnect(): void;
|
|
@@ -104,7 +92,8 @@ declare class ComputerKeyboardInput implements IMidiInput {
|
|
|
104
92
|
name: string;
|
|
105
93
|
state: MidiPortState;
|
|
106
94
|
eventListerCallbacks: EventListerCallback[];
|
|
107
|
-
|
|
95
|
+
private context;
|
|
96
|
+
constructor(context: Context);
|
|
108
97
|
addEventListener(callback: EventListerCallback): void;
|
|
109
98
|
removeEventListener(callback: EventListerCallback): void;
|
|
110
99
|
serialize(): {
|
|
@@ -158,42 +147,6 @@ declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements
|
|
|
158
147
|
findIOByVoice(voice: number): AudioOutput;
|
|
159
148
|
}
|
|
160
149
|
|
|
161
|
-
declare enum TransportState {
|
|
162
|
-
playing = "playing",
|
|
163
|
-
stopped = "stopped",
|
|
164
|
-
paused = "paused"
|
|
165
|
-
}
|
|
166
|
-
type TPlaybackCallback = (actionAt: TTime) => void;
|
|
167
|
-
type TransportProps = {
|
|
168
|
-
onStart?: TPlaybackCallback;
|
|
169
|
-
onStop?: TPlaybackCallback;
|
|
170
|
-
};
|
|
171
|
-
declare class Transport {
|
|
172
|
-
bpm: number;
|
|
173
|
-
timeSignature: [number, number];
|
|
174
|
-
loopStart: TTime;
|
|
175
|
-
loopEnd?: TTime;
|
|
176
|
-
state: TransportState;
|
|
177
|
-
offset: TTime;
|
|
178
|
-
private startTime;
|
|
179
|
-
private onStart;
|
|
180
|
-
private onStop;
|
|
181
|
-
private scheduler;
|
|
182
|
-
constructor(props: TransportProps);
|
|
183
|
-
start({ offset, actionAt, }: {
|
|
184
|
-
offset?: TTime;
|
|
185
|
-
actionAt?: TTime;
|
|
186
|
-
}): TTime | undefined;
|
|
187
|
-
stop({ actionAt: actionAt }: {
|
|
188
|
-
actionAt?: TTime;
|
|
189
|
-
}): TTime | undefined;
|
|
190
|
-
pause({ actionAt: actionAt }: {
|
|
191
|
-
actionAt?: TTime;
|
|
192
|
-
}): TTime | undefined;
|
|
193
|
-
get playhead(): Time;
|
|
194
|
-
private validateFutureTime;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
150
|
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
198
151
|
voices: number;
|
|
199
152
|
};
|
|
@@ -223,8 +176,8 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
223
176
|
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
224
177
|
get voices(): number;
|
|
225
178
|
set voices(value: number);
|
|
226
|
-
start(time:
|
|
227
|
-
stop(time:
|
|
179
|
+
start(time: ContextTime): void;
|
|
180
|
+
stop(time: ContextTime): void;
|
|
228
181
|
serialize(): IPolyModuleSerialize<T>;
|
|
229
182
|
plug({ audioModule, from, to, }: {
|
|
230
183
|
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
@@ -243,7 +196,7 @@ declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T
|
|
|
243
196
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
244
197
|
private adjustNumberOfModules;
|
|
245
198
|
protected get engine(): Engine;
|
|
246
|
-
protected get context():
|
|
199
|
+
protected get context(): _blibliki_utils.Context;
|
|
247
200
|
}
|
|
248
201
|
|
|
249
202
|
type MidiInputProps = IOProps & {
|
|
@@ -312,7 +265,7 @@ type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
|
312
265
|
outputs: IIOSerialize[];
|
|
313
266
|
};
|
|
314
267
|
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
315
|
-
audioNodeConstructor?: (context:
|
|
268
|
+
audioNodeConstructor?: (context: Context) => AudioNode;
|
|
316
269
|
};
|
|
317
270
|
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
318
271
|
id: string;
|
|
@@ -337,10 +290,10 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
337
290
|
}): void;
|
|
338
291
|
protected rePlugAll(callback?: () => void): void;
|
|
339
292
|
protected unPlugAll(): void;
|
|
340
|
-
start(_time:
|
|
341
|
-
stop(_time:
|
|
342
|
-
triggerAttack(note: Note, _triggeredAt:
|
|
343
|
-
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;
|
|
344
297
|
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
345
298
|
protected triggerPropsUpdate(): void;
|
|
346
299
|
dispose(): void;
|
|
@@ -350,7 +303,7 @@ declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
|
350
303
|
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
351
304
|
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
352
305
|
protected get engine(): Engine;
|
|
353
|
-
protected get context():
|
|
306
|
+
protected get context(): Context;
|
|
354
307
|
}
|
|
355
308
|
|
|
356
309
|
type IPlug = {
|
|
@@ -380,11 +333,13 @@ declare class MidiDeviceManager {
|
|
|
380
333
|
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
381
334
|
private initialized;
|
|
382
335
|
private listeners;
|
|
383
|
-
|
|
336
|
+
private context;
|
|
337
|
+
constructor(context: Context);
|
|
384
338
|
initialize(): Promise<void>;
|
|
385
339
|
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
386
340
|
addListener(callback: ListenerCallback): void;
|
|
387
341
|
private initializeDevices;
|
|
342
|
+
private addComputerKeyboard;
|
|
388
343
|
private listenChanges;
|
|
389
344
|
}
|
|
390
345
|
|
|
@@ -417,13 +372,11 @@ type PropSchema<T> = {
|
|
|
417
372
|
[K in keyof T]: PropDefinition<T[K]>;
|
|
418
373
|
};
|
|
419
374
|
|
|
420
|
-
type IAnyAudioContext = AudioContext | OfflineAudioContext;
|
|
421
|
-
|
|
422
375
|
type IVoiceSchedulerProps = EmptyObject;
|
|
423
376
|
declare class Voice extends Module<ModuleType.VoiceScheduler> {
|
|
424
377
|
audioNode: undefined;
|
|
425
378
|
activeNote: string | null;
|
|
426
|
-
triggeredAt:
|
|
379
|
+
triggeredAt: ContextTime;
|
|
427
380
|
constructor(engineId: string, params: ICreateModule<ModuleType.VoiceScheduler>);
|
|
428
381
|
midiTriggered: (midiEvent: MidiEvent) => void;
|
|
429
382
|
}
|
|
@@ -456,9 +409,9 @@ declare class Constant extends Module<ModuleType.Constant> {
|
|
|
456
409
|
isStated: boolean;
|
|
457
410
|
constructor(engineId: string, params: ICreateModule<ModuleType.Constant>);
|
|
458
411
|
protected onSetValue(value: IConstantProps["value"]): void;
|
|
459
|
-
start(time:
|
|
460
|
-
stop(time:
|
|
461
|
-
triggerAttack: (note: Note, triggeredAt:
|
|
412
|
+
start(time: ContextTime): void;
|
|
413
|
+
stop(time: ContextTime): void;
|
|
414
|
+
triggerAttack: (note: Note, triggeredAt: ContextTime) => void;
|
|
462
415
|
triggerRelease: () => void;
|
|
463
416
|
}
|
|
464
417
|
|
|
@@ -554,8 +507,8 @@ type IOscillatorProps = {
|
|
|
554
507
|
};
|
|
555
508
|
declare class Oscillator extends PolyModule<ModuleType.Oscillator> {
|
|
556
509
|
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Oscillator>);
|
|
557
|
-
start(time:
|
|
558
|
-
stop(time:
|
|
510
|
+
start(time: ContextTime): void;
|
|
511
|
+
stop(time: ContextTime): void;
|
|
559
512
|
private registerInputs;
|
|
560
513
|
}
|
|
561
514
|
|
|
@@ -578,7 +531,6 @@ declare class Scale extends Module<ModuleType.Scale> {
|
|
|
578
531
|
type IStepSequencer = IModule<ModuleType.StepSequencer>;
|
|
579
532
|
type ISequence = {
|
|
580
533
|
active: boolean;
|
|
581
|
-
time: BarsBeatsSixteenths;
|
|
582
534
|
duration: string;
|
|
583
535
|
notes: INote[];
|
|
584
536
|
};
|
|
@@ -601,8 +553,8 @@ declare class VirtualMidi extends Module<ModuleType.VirtualMidi> {
|
|
|
601
553
|
midiOutput: MidiOutput;
|
|
602
554
|
constructor(engineId: string, params: ICreateModule<ModuleType.VirtualMidi>);
|
|
603
555
|
sendMidi(midiEvent: MidiEvent): void;
|
|
604
|
-
triggerAttack: (note: Note, triggerAttack:
|
|
605
|
-
triggerRelease: (note: Note, triggerAttack:
|
|
556
|
+
triggerAttack: (note: Note, triggerAttack: ContextTime) => void;
|
|
557
|
+
triggerRelease: (note: Note, triggerAttack: ContextTime) => void;
|
|
606
558
|
private registerInputs;
|
|
607
559
|
private registerOutputs;
|
|
608
560
|
}
|
|
@@ -721,16 +673,16 @@ declare class Engine {
|
|
|
721
673
|
private static _currentId;
|
|
722
674
|
private propsUpdateCallbacks;
|
|
723
675
|
readonly id: string;
|
|
724
|
-
context:
|
|
676
|
+
context: Context;
|
|
725
677
|
isInitialized: boolean;
|
|
726
678
|
routes: Routes;
|
|
727
|
-
transport: Transport
|
|
679
|
+
transport: Transport<TransportEvent>;
|
|
728
680
|
modules: Map<string, ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping]>;
|
|
729
681
|
midiDeviceManager: MidiDeviceManager;
|
|
730
682
|
static getById(id: string): Engine;
|
|
731
683
|
static get current(): Engine;
|
|
732
|
-
constructor(context:
|
|
733
|
-
get state(): TransportState;
|
|
684
|
+
constructor(context: Context);
|
|
685
|
+
get state(): _blibliki_transport.TransportState;
|
|
734
686
|
initialize(): Promise<void>;
|
|
735
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>;
|
|
736
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>;
|
|
@@ -738,18 +690,13 @@ declare class Engine {
|
|
|
738
690
|
addRoute(props: ICreateRoute): IRoute;
|
|
739
691
|
removeRoute(id: string): void;
|
|
740
692
|
validRoute(props: Optional<IRoute, "id">): boolean;
|
|
741
|
-
start(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}): void;
|
|
745
|
-
stop(props?: {
|
|
746
|
-
actionAt?: TTime;
|
|
747
|
-
}): void;
|
|
748
|
-
pause(props?: {
|
|
749
|
-
actionAt?: TTime;
|
|
750
|
-
}): void;
|
|
693
|
+
start(): Promise<void>;
|
|
694
|
+
stop(): void;
|
|
695
|
+
pause(): void;
|
|
751
696
|
get bpm(): number;
|
|
752
697
|
set bpm(value: number);
|
|
698
|
+
get timeSignature(): TimeSignature;
|
|
699
|
+
set timeSignature(value: TimeSignature);
|
|
753
700
|
resume(): Promise<void>;
|
|
754
701
|
dispose(): void;
|
|
755
702
|
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
@@ -762,4 +709,4 @@ declare class Engine {
|
|
|
762
709
|
private onStop;
|
|
763
710
|
}
|
|
764
711
|
|
|
765
|
-
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 };
|