@blibliki/engine 0.1.27 → 0.3.2
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 +252 -76
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +765 -0
- package/dist/index.d.ts +765 -0
- package/dist/index.js +2 -19484
- package/dist/index.js.map +1 -0
- package/package.json +19 -28
- package/src/Engine.ts +158 -177
- package/src/core/IO/AudioIO.ts +72 -0
- package/src/core/IO/Base.ts +118 -0
- package/src/core/IO/Collection.ts +123 -47
- package/src/core/IO/MidiIO.ts +43 -0
- package/src/core/IO/PolyAudioIO.ts +115 -0
- package/src/core/IO/index.ts +7 -61
- package/src/core/Note/frequencyTable.ts +144 -144
- package/src/core/Note/index.ts +49 -59
- package/src/core/Route.ts +79 -0
- package/src/core/Timing/Scheduler.ts +37 -0
- package/src/core/Timing/Time.ts +103 -0
- package/src/core/Timing/Transport.ts +104 -0
- package/src/core/Timing/index.ts +16 -0
- package/src/core/index.ts +36 -0
- package/src/core/midi/{ComputerKeyboardInput.ts → ComputerKeyboardDevice.ts} +31 -11
- package/src/core/midi/MidiDevice.ts +38 -31
- package/src/core/midi/MidiDeviceManager.ts +54 -55
- package/src/core/midi/MidiEvent.ts +36 -60
- package/src/core/module/Module.ts +233 -0
- package/src/core/module/PolyModule.ts +246 -0
- package/src/core/module/VoiceScheduler.ts +121 -0
- package/src/core/module/index.ts +3 -0
- package/src/core/schema.ts +41 -0
- package/src/index.ts +31 -9
- package/src/modules/BiquadFilter.ts +162 -0
- package/src/modules/Constant.ts +72 -0
- package/src/modules/Envelope.ts +178 -0
- package/src/modules/Filter.ts +109 -104
- package/src/modules/Gain.ts +78 -0
- package/src/modules/Inspector.ts +59 -0
- package/src/modules/Master.ts +18 -21
- package/src/modules/MidiSelector.ts +50 -50
- package/src/modules/Oscillator.ts +203 -158
- package/src/modules/Scale.ts +79 -0
- package/src/modules/StepSequencer.ts +61 -0
- package/src/modules/VirtualMidi.ts +33 -49
- package/src/modules/index.ts +159 -74
- package/src/nodePolyfill.ts +25 -0
- package/src/processors/filter-processor.ts +82 -0
- package/src/processors/index.ts +28 -0
- package/src/processors/scale-processor.ts +81 -0
- package/dist/index.umd.cjs +0 -227
- package/dist/src/Engine.d.ts +0 -83
- package/dist/src/core/IO/AudioNode.d.ts +0 -36
- package/dist/src/core/IO/Collection.d.ts +0 -14
- package/dist/src/core/IO/ForwardNode/Base.d.ts +0 -19
- package/dist/src/core/IO/ForwardNode/index.d.ts +0 -28
- package/dist/src/core/IO/MidiNode.d.ts +0 -31
- package/dist/src/core/IO/Node.d.ts +0 -41
- package/dist/src/core/IO/index.d.ts +0 -22
- package/dist/src/core/Module/MonoModule.d.ts +0 -68
- package/dist/src/core/Module/PolyModule.d.ts +0 -62
- package/dist/src/core/Module/index.d.ts +0 -7
- package/dist/src/core/Note/frequencyTable.d.ts +0 -4
- package/dist/src/core/Note/index.d.ts +0 -28
- package/dist/src/core/midi/ComputerKeyboardInput.d.ts +0 -12
- package/dist/src/core/midi/MidiDevice.d.ts +0 -30
- package/dist/src/core/midi/MidiDeviceManager.d.ts +0 -15
- package/dist/src/core/midi/MidiEvent.d.ts +0 -22
- package/dist/src/core/midi/index.d.ts +0 -5
- package/dist/src/index.d.ts +0 -9
- package/dist/src/main.d.ts +0 -0
- package/dist/src/modules/BitCrusher.d.ts +0 -17
- package/dist/src/modules/Delay.d.ts +0 -20
- package/dist/src/modules/Distortion.d.ts +0 -17
- package/dist/src/modules/Effect.d.ts +0 -20
- package/dist/src/modules/Envelope/AmpEnvelope.d.ts +0 -19
- package/dist/src/modules/Envelope/Base.d.ts +0 -67
- package/dist/src/modules/Envelope/FreqEnvelope.d.ts +0 -26
- package/dist/src/modules/Envelope/index.d.ts +0 -3
- package/dist/src/modules/Filter.d.ts +0 -43
- package/dist/src/modules/LFO.d.ts +0 -45
- package/dist/src/modules/Master.d.ts +0 -12
- package/dist/src/modules/MidiSelector.d.ts +0 -22
- package/dist/src/modules/Oscillator.d.ts +0 -56
- package/dist/src/modules/Reverb.d.ts +0 -20
- package/dist/src/modules/Sequencer.d.ts +0 -43
- package/dist/src/modules/VirtualMidi.d.ts +0 -33
- package/dist/src/modules/VoiceScheduler.d.ts +0 -45
- package/dist/src/modules/Volume.d.ts +0 -27
- package/dist/src/modules/index.d.ts +0 -18
- package/dist/src/routes.d.ts +0 -19
- package/dist/src/types.d.ts +0 -5
- package/dist/src/utils.d.ts +0 -1
- package/dist/test/MockingModules.d.ts +0 -22
- package/dist/test/Module/Oscillator.test.d.ts +0 -1
- package/dist/test/core/IO.test.d.ts +0 -1
- package/src/core/IO/AudioNode.ts +0 -82
- package/src/core/IO/ForwardNode/Base.ts +0 -99
- package/src/core/IO/ForwardNode/index.ts +0 -60
- package/src/core/IO/MidiNode.ts +0 -67
- package/src/core/IO/Node.ts +0 -118
- package/src/core/Module/MonoModule.ts +0 -219
- package/src/core/Module/PolyModule.ts +0 -218
- package/src/core/Module/index.ts +0 -15
- package/src/core/midi/index.ts +0 -5
- package/src/main.ts +0 -1
- package/src/modules/BitCrusher.ts +0 -45
- package/src/modules/Delay.ts +0 -53
- package/src/modules/Distortion.ts +0 -45
- package/src/modules/Effect.ts +0 -46
- package/src/modules/Envelope/AmpEnvelope.ts +0 -23
- package/src/modules/Envelope/Base.ts +0 -176
- package/src/modules/Envelope/FreqEnvelope.ts +0 -64
- package/src/modules/Envelope/index.ts +0 -3
- package/src/modules/LFO.ts +0 -149
- package/src/modules/Reverb.ts +0 -53
- package/src/modules/Sequencer.ts +0 -178
- package/src/modules/VoiceScheduler.ts +0 -145
- package/src/modules/Volume.ts +0 -72
- package/src/routes.ts +0 -49
- package/src/types.ts +0 -3
- package/src/utils.ts +0 -18
- package/src/vite-env.d.ts +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
import { Message, Input } from 'webmidi';
|
|
2
|
+
import { Optional, EmptyObject } from '@blibliki/utils';
|
|
3
|
+
|
|
4
|
+
type BarsBeatsSixteenths = `${number}:${number}:${number}`;
|
|
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
|
+
}
|
|
20
|
+
|
|
21
|
+
type INote = {
|
|
22
|
+
name: string;
|
|
23
|
+
octave: number;
|
|
24
|
+
frequency: number;
|
|
25
|
+
duration?: TTime;
|
|
26
|
+
velocity?: number;
|
|
27
|
+
};
|
|
28
|
+
declare class Note implements INote {
|
|
29
|
+
static _notes: Note[];
|
|
30
|
+
name: string;
|
|
31
|
+
octave: number;
|
|
32
|
+
velocity: number;
|
|
33
|
+
duration?: TTime;
|
|
34
|
+
static fromFrequency(frequency: number): Note;
|
|
35
|
+
static fromEvent(message: Message): Note;
|
|
36
|
+
static notes(octave?: number): Note[];
|
|
37
|
+
constructor(note: Omit<INote, "frequency"> | string);
|
|
38
|
+
get isSemi(): boolean;
|
|
39
|
+
get fullName(): string;
|
|
40
|
+
get frequency(): number;
|
|
41
|
+
midiData(noteOn?: boolean): Uint8Array;
|
|
42
|
+
get midiNumber(): number;
|
|
43
|
+
get noteIndex(): number;
|
|
44
|
+
valueOf(): string;
|
|
45
|
+
serialize(): INote;
|
|
46
|
+
private fromString;
|
|
47
|
+
private fromProps;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare enum MidiEventType {
|
|
51
|
+
noteOn = "noteon",
|
|
52
|
+
noteOff = "noteoff",
|
|
53
|
+
cc = "cc"
|
|
54
|
+
}
|
|
55
|
+
declare class MidiEvent {
|
|
56
|
+
note?: Note;
|
|
57
|
+
voiceNo?: number;
|
|
58
|
+
readonly triggeredAt: TTime;
|
|
59
|
+
private message;
|
|
60
|
+
static fromNote(noteName: string | Note | Omit<INote, "frequency">, noteOn?: boolean, triggeredAt?: TTime): MidiEvent;
|
|
61
|
+
static fromCC(cc: number, value: number, triggeredAt?: TTime): MidiEvent;
|
|
62
|
+
constructor(message: Message, triggeredAt?: TTime);
|
|
63
|
+
get type(): MidiEventType;
|
|
64
|
+
get isNote(): boolean;
|
|
65
|
+
defineNotes(): void;
|
|
66
|
+
get rawMessage(): Message;
|
|
67
|
+
clone(voiceNo?: number): MidiEvent;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare enum MidiPortState {
|
|
71
|
+
connected = "connected",
|
|
72
|
+
disconnected = "disconnected"
|
|
73
|
+
}
|
|
74
|
+
type IMidiDevice = {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
state: MidiPortState;
|
|
78
|
+
};
|
|
79
|
+
type IMidiInput = IMidiDevice & {
|
|
80
|
+
eventListerCallbacks: EventListerCallback[];
|
|
81
|
+
};
|
|
82
|
+
type EventListerCallback = (event: MidiEvent) => void;
|
|
83
|
+
declare class MidiDevice implements IMidiDevice {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
eventListerCallbacks: EventListerCallback[];
|
|
87
|
+
private input;
|
|
88
|
+
constructor(input: Input);
|
|
89
|
+
get state(): MidiPortState;
|
|
90
|
+
connect(): void;
|
|
91
|
+
disconnect(): void;
|
|
92
|
+
serialize(): {
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
state: MidiPortState;
|
|
96
|
+
};
|
|
97
|
+
addEventListener(callback: EventListerCallback): void;
|
|
98
|
+
removeEventListener(callback: EventListerCallback): void;
|
|
99
|
+
private processEvent;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare class ComputerKeyboardInput implements IMidiInput {
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
state: MidiPortState;
|
|
106
|
+
eventListerCallbacks: EventListerCallback[];
|
|
107
|
+
constructor();
|
|
108
|
+
addEventListener(callback: EventListerCallback): void;
|
|
109
|
+
removeEventListener(callback: EventListerCallback): void;
|
|
110
|
+
serialize(): {
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
state: MidiPortState;
|
|
114
|
+
};
|
|
115
|
+
onKeyTrigger: (noteOn: boolean) => (event: KeyboardEvent) => void;
|
|
116
|
+
private extractNote;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type AudioInputProps = IOProps & {
|
|
120
|
+
ioType: IOType.AudioInput;
|
|
121
|
+
getAudioNode: () => AudioNode | AudioParam | AudioDestinationNode;
|
|
122
|
+
};
|
|
123
|
+
type AudioOutputProps = IOProps & {
|
|
124
|
+
ioType: IOType.AudioOutput;
|
|
125
|
+
getAudioNode: () => AudioNode;
|
|
126
|
+
};
|
|
127
|
+
declare class AudioInput extends IO<AudioOutput | PolyAudioOutput> implements AudioInputProps {
|
|
128
|
+
ioType: IOType.AudioInput;
|
|
129
|
+
getAudioNode: AudioInputProps["getAudioNode"];
|
|
130
|
+
constructor(module: Module<ModuleType>, props: AudioInputProps);
|
|
131
|
+
}
|
|
132
|
+
declare class AudioOutput extends IO<AudioInput | PolyAudioInput> implements AudioOutputProps {
|
|
133
|
+
ioType: IOType.AudioOutput;
|
|
134
|
+
getAudioNode: AudioOutputProps["getAudioNode"];
|
|
135
|
+
constructor(module: Module<ModuleType>, props: AudioOutputProps);
|
|
136
|
+
plug(io: AudioInput | PolyAudioInput, plugOther?: boolean): void;
|
|
137
|
+
unPlug(io: AudioInput | PolyAudioInput, plugOther?: boolean): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type PolyAudioInputProps = IOProps & {
|
|
141
|
+
ioType: IOType.PolyAudioInput;
|
|
142
|
+
};
|
|
143
|
+
type PolyAudioOutputProps = IOProps & {
|
|
144
|
+
ioType: IOType.PolyAudioOutput;
|
|
145
|
+
};
|
|
146
|
+
declare class PolyAudioInput extends IO<PolyAudioOutput | AudioOutput> implements PolyAudioInputProps {
|
|
147
|
+
ioType: IOType.PolyAudioInput;
|
|
148
|
+
module: PolyModule<ModuleType>;
|
|
149
|
+
plug(io: PolyAudioOutput | AudioOutput, plugOther?: boolean): void;
|
|
150
|
+
unPlug(io: PolyAudioOutput | AudioOutput, plugOther?: boolean): void;
|
|
151
|
+
findIOByVoice(voice: number): AudioInput;
|
|
152
|
+
}
|
|
153
|
+
declare class PolyAudioOutput extends IO<PolyAudioInput | AudioInput> implements PolyAudioOutputProps {
|
|
154
|
+
ioType: IOType.PolyAudioOutput;
|
|
155
|
+
module: PolyModule<ModuleType>;
|
|
156
|
+
plug(io: PolyAudioInput | AudioInput, plugOther?: boolean): void;
|
|
157
|
+
unPlug(io: PolyAudioInput | AudioInput, plugOther?: boolean): void;
|
|
158
|
+
findIOByVoice(voice: number): AudioOutput;
|
|
159
|
+
}
|
|
160
|
+
|
|
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
|
+
type IPolyModule<T extends ModuleType> = Omit<IModule<T>, "voiceNo"> & {
|
|
198
|
+
voices: number;
|
|
199
|
+
};
|
|
200
|
+
type IPolyModuleSerialize<T extends ModuleType> = IPolyModule<T> & {
|
|
201
|
+
inputs: IIOSerialize[];
|
|
202
|
+
outputs: IIOSerialize[];
|
|
203
|
+
};
|
|
204
|
+
type IPolyModuleConstructor<T extends ModuleType> = Optional<IPolyModule<T>, "id"> & {
|
|
205
|
+
monoModuleConstructor: (engineId: string, params: IModuleConstructor<T>) => Module<T>;
|
|
206
|
+
};
|
|
207
|
+
declare abstract class PolyModule<T extends ModuleType> implements IPolyModule<T> {
|
|
208
|
+
id: string;
|
|
209
|
+
engineId: string;
|
|
210
|
+
moduleType: T;
|
|
211
|
+
audioModules: Module<T>[];
|
|
212
|
+
inputs: InputCollection;
|
|
213
|
+
outputs: OutputCollection;
|
|
214
|
+
protected monoModuleConstructor: IPolyModuleConstructor<T>["monoModuleConstructor"];
|
|
215
|
+
protected _props: ModuleTypeToPropsMapping[T];
|
|
216
|
+
protected superInitialized: boolean;
|
|
217
|
+
private _voices;
|
|
218
|
+
private _name;
|
|
219
|
+
constructor(engineId: string, params: IPolyModuleConstructor<T>);
|
|
220
|
+
get name(): string;
|
|
221
|
+
set name(value: string);
|
|
222
|
+
get props(): ModuleTypeToPropsMapping[T];
|
|
223
|
+
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
224
|
+
get voices(): number;
|
|
225
|
+
set voices(value: number);
|
|
226
|
+
start(time: TTime): void;
|
|
227
|
+
stop(time: TTime): void;
|
|
228
|
+
serialize(): IPolyModuleSerialize<T>;
|
|
229
|
+
plug({ audioModule, from, to, }: {
|
|
230
|
+
audioModule: Module<ModuleType> | PolyModule<ModuleType>;
|
|
231
|
+
from: string;
|
|
232
|
+
to: string;
|
|
233
|
+
}): void;
|
|
234
|
+
rePlugAll(callback?: () => void): void;
|
|
235
|
+
protected unPlugAll(): void;
|
|
236
|
+
dispose(): void;
|
|
237
|
+
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
238
|
+
findVoice(voiceNo: number): Module<T>;
|
|
239
|
+
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
240
|
+
protected registerAudioInput(props: Omit<PolyAudioInputProps, "ioType">): PolyAudioInput;
|
|
241
|
+
protected registerAudioOutput(props: Omit<PolyAudioOutputProps, "ioType">): PolyAudioOutput;
|
|
242
|
+
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
243
|
+
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
244
|
+
private adjustNumberOfModules;
|
|
245
|
+
protected get engine(): Engine;
|
|
246
|
+
protected get context(): IAnyAudioContext;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
type MidiInputProps = IOProps & {
|
|
250
|
+
ioType: IOType.MidiInput;
|
|
251
|
+
onMidiEvent: (event: MidiEvent) => void;
|
|
252
|
+
};
|
|
253
|
+
type MidiOutputProps = IOProps & {
|
|
254
|
+
ioType: IOType.MidiOutput;
|
|
255
|
+
};
|
|
256
|
+
declare class MidiInput extends IO<MidiOutput> implements MidiInputProps {
|
|
257
|
+
ioType: IOType.MidiInput;
|
|
258
|
+
onMidiEvent: MidiInputProps["onMidiEvent"];
|
|
259
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: MidiInputProps);
|
|
260
|
+
}
|
|
261
|
+
declare class MidiOutput extends IO<MidiInput> implements MidiOutputProps {
|
|
262
|
+
ioType: IOType.MidiOutput;
|
|
263
|
+
onMidiEvent: (event: MidiEvent) => void;
|
|
264
|
+
private get midiConnections();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare enum CollectionType {
|
|
268
|
+
Input = "Input",
|
|
269
|
+
Output = "Output"
|
|
270
|
+
}
|
|
271
|
+
type IMappedIOProps = {
|
|
272
|
+
[CollectionType.Input]: AudioInputProps | PolyAudioInputProps | MidiInputProps;
|
|
273
|
+
[CollectionType.Output]: AudioOutputProps | PolyAudioOutputProps | MidiOutputProps;
|
|
274
|
+
};
|
|
275
|
+
type IIOTypeTOClass = {
|
|
276
|
+
[IOType.AudioInput]: AudioInput;
|
|
277
|
+
[IOType.AudioOutput]: AudioOutput;
|
|
278
|
+
[IOType.PolyAudioInput]: PolyAudioInput;
|
|
279
|
+
[IOType.PolyAudioOutput]: PolyAudioOutput;
|
|
280
|
+
[IOType.MidiInput]: MidiInput;
|
|
281
|
+
[IOType.MidiOutput]: MidiOutput;
|
|
282
|
+
};
|
|
283
|
+
declare abstract class IOCollection<T extends CollectionType> {
|
|
284
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
285
|
+
collection: Base[];
|
|
286
|
+
collectionType: T;
|
|
287
|
+
constructor(collectionType: T, module: Module<ModuleType> | PolyModule<ModuleType>);
|
|
288
|
+
add<TT extends IMappedIOProps[T]>(props: TT): IIOTypeTOClass[TT["ioType"]];
|
|
289
|
+
unPlugAll(): void;
|
|
290
|
+
rePlugAll(callback?: () => void): void;
|
|
291
|
+
find(id: string): Base;
|
|
292
|
+
findByName(name: string): Base;
|
|
293
|
+
serialize(): IIOSerialize[];
|
|
294
|
+
private validateUniqName;
|
|
295
|
+
}
|
|
296
|
+
declare class InputCollection extends IOCollection<CollectionType.Input> {
|
|
297
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>);
|
|
298
|
+
}
|
|
299
|
+
declare class OutputCollection extends IOCollection<CollectionType.Output> {
|
|
300
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
type IModule<T extends ModuleType> = {
|
|
304
|
+
id: string;
|
|
305
|
+
name: string;
|
|
306
|
+
voiceNo: number;
|
|
307
|
+
moduleType: T;
|
|
308
|
+
props: ModuleTypeToPropsMapping[T];
|
|
309
|
+
};
|
|
310
|
+
type IModuleSerialize<T extends ModuleType> = IModule<T> & {
|
|
311
|
+
inputs: IIOSerialize[];
|
|
312
|
+
outputs: IIOSerialize[];
|
|
313
|
+
};
|
|
314
|
+
type IModuleConstructor<T extends ModuleType> = Optional<IModule<T>, "id" | "voiceNo"> & {
|
|
315
|
+
audioNodeConstructor?: (context: IAnyAudioContext) => AudioNode;
|
|
316
|
+
};
|
|
317
|
+
declare abstract class Module<T extends ModuleType> implements IModule<T> {
|
|
318
|
+
id: string;
|
|
319
|
+
engineId: string;
|
|
320
|
+
name: string;
|
|
321
|
+
moduleType: T;
|
|
322
|
+
voiceNo: number;
|
|
323
|
+
audioNode: AudioNode | undefined;
|
|
324
|
+
inputs: InputCollection;
|
|
325
|
+
outputs: OutputCollection;
|
|
326
|
+
protected _props: ModuleTypeToPropsMapping[T];
|
|
327
|
+
protected superInitialized: boolean;
|
|
328
|
+
protected activeNotes: Note[];
|
|
329
|
+
constructor(engineId: string, params: IModuleConstructor<T>);
|
|
330
|
+
get props(): ModuleTypeToPropsMapping[T];
|
|
331
|
+
set props(value: Partial<ModuleTypeToPropsMapping[T]>);
|
|
332
|
+
serialize(): IModuleSerialize<T>;
|
|
333
|
+
plug({ audioModule, from, to, }: {
|
|
334
|
+
audioModule: AnyModule;
|
|
335
|
+
from: string;
|
|
336
|
+
to: string;
|
|
337
|
+
}): void;
|
|
338
|
+
protected rePlugAll(callback?: () => void): void;
|
|
339
|
+
protected unPlugAll(): void;
|
|
340
|
+
start(_time: TTime): void;
|
|
341
|
+
stop(_time: TTime): void;
|
|
342
|
+
triggerAttack(note: Note, _triggeredAt: TTime): void;
|
|
343
|
+
triggerRelease(note: Note, _triggeredAt: TTime): void;
|
|
344
|
+
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
345
|
+
protected triggerPropsUpdate(): void;
|
|
346
|
+
dispose(): void;
|
|
347
|
+
protected registerDefaultIOs(value?: "both" | "in" | "out"): void;
|
|
348
|
+
protected registerAudioInput(props: Omit<AudioInputProps, "ioType">): AudioInput;
|
|
349
|
+
protected registerAudioOutput(props: Omit<AudioOutputProps, "ioType">): AudioOutput;
|
|
350
|
+
protected registerMidiInput(props: Omit<MidiInputProps, "ioType">): MidiInput;
|
|
351
|
+
protected registerMidiOutput(props: Omit<MidiOutputProps, "ioType">): MidiOutput;
|
|
352
|
+
protected get engine(): Engine;
|
|
353
|
+
protected get context(): IAnyAudioContext;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
type IPlug = {
|
|
357
|
+
moduleId: string;
|
|
358
|
+
ioName: string;
|
|
359
|
+
};
|
|
360
|
+
type IRoute = {
|
|
361
|
+
id: string;
|
|
362
|
+
source: IPlug;
|
|
363
|
+
destination: IPlug;
|
|
364
|
+
};
|
|
365
|
+
declare class Routes {
|
|
366
|
+
engine: Engine;
|
|
367
|
+
routes: Map<string, IRoute>;
|
|
368
|
+
constructor(engine: Engine);
|
|
369
|
+
addRoute(props: Optional<IRoute, "id">): IRoute;
|
|
370
|
+
removeRoute(id: string): void;
|
|
371
|
+
clear(): void;
|
|
372
|
+
private plug;
|
|
373
|
+
private unPlug;
|
|
374
|
+
private find;
|
|
375
|
+
private getIOs;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
type ListenerCallback = (device: MidiDevice) => void;
|
|
379
|
+
declare class MidiDeviceManager {
|
|
380
|
+
devices: Map<string, MidiDevice | ComputerKeyboardInput>;
|
|
381
|
+
private initialized;
|
|
382
|
+
private listeners;
|
|
383
|
+
constructor();
|
|
384
|
+
initialize(): Promise<void>;
|
|
385
|
+
find(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
386
|
+
addListener(callback: ListenerCallback): void;
|
|
387
|
+
private initializeDevices;
|
|
388
|
+
private listenChanges;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
type BasePropType = {
|
|
392
|
+
label?: string;
|
|
393
|
+
description?: string;
|
|
394
|
+
};
|
|
395
|
+
type NumberProp = BasePropType & {
|
|
396
|
+
kind: "number";
|
|
397
|
+
min?: number;
|
|
398
|
+
max?: number;
|
|
399
|
+
step?: number;
|
|
400
|
+
};
|
|
401
|
+
type EnumProp<T extends string | number> = BasePropType & {
|
|
402
|
+
kind: "enum";
|
|
403
|
+
options: T[];
|
|
404
|
+
};
|
|
405
|
+
type StringProp = BasePropType & {
|
|
406
|
+
kind: "string";
|
|
407
|
+
pattern?: RegExp;
|
|
408
|
+
};
|
|
409
|
+
type BooleanProp = BasePropType & {
|
|
410
|
+
kind: "boolean";
|
|
411
|
+
};
|
|
412
|
+
type ArrayProp = BasePropType & {
|
|
413
|
+
kind: "array";
|
|
414
|
+
};
|
|
415
|
+
type PropDefinition<T> = T extends number ? NumberProp | EnumProp<number> : T extends boolean ? BooleanProp : T extends string ? StringProp | EnumProp<string> : T extends (string | number)[] ? ArrayProp : never;
|
|
416
|
+
type PropSchema<T> = {
|
|
417
|
+
[K in keyof T]: PropDefinition<T[K]>;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
type IAnyAudioContext = AudioContext | OfflineAudioContext;
|
|
421
|
+
|
|
422
|
+
type IVoiceSchedulerProps = EmptyObject;
|
|
423
|
+
declare class Voice extends Module<ModuleType.VoiceScheduler> {
|
|
424
|
+
audioNode: undefined;
|
|
425
|
+
activeNote: string | null;
|
|
426
|
+
triggeredAt: TTime;
|
|
427
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.VoiceScheduler>);
|
|
428
|
+
midiTriggered: (midiEvent: MidiEvent) => void;
|
|
429
|
+
}
|
|
430
|
+
declare class VoiceScheduler extends PolyModule<ModuleType.VoiceScheduler> {
|
|
431
|
+
audioModules: Voice[];
|
|
432
|
+
midiOutput: MidiOutput;
|
|
433
|
+
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.VoiceScheduler>);
|
|
434
|
+
onMidiEvent: (midiEvent: MidiEvent) => void;
|
|
435
|
+
private findFreeVoice;
|
|
436
|
+
private registerInputs;
|
|
437
|
+
private registerOutputs;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
type IBiquadFilterProps = {
|
|
441
|
+
cutoff: number;
|
|
442
|
+
envelopeAmount: number;
|
|
443
|
+
type: BiquadFilterType;
|
|
444
|
+
Q: number;
|
|
445
|
+
};
|
|
446
|
+
declare class BiquadFilter extends PolyModule<ModuleType.BiquadFilter> {
|
|
447
|
+
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.BiquadFilter>);
|
|
448
|
+
private registerInputs;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
type IConstantProps = {
|
|
452
|
+
value: number;
|
|
453
|
+
};
|
|
454
|
+
declare class Constant extends Module<ModuleType.Constant> {
|
|
455
|
+
audioNode: ConstantSourceNode;
|
|
456
|
+
isStated: boolean;
|
|
457
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.Constant>);
|
|
458
|
+
protected onSetValue(value: IConstantProps["value"]): void;
|
|
459
|
+
start(time: TTime): void;
|
|
460
|
+
stop(time: TTime): void;
|
|
461
|
+
triggerAttack: (note: Note, triggeredAt: TTime) => void;
|
|
462
|
+
triggerRelease: () => void;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
type IEnvelopeProps = {
|
|
466
|
+
attack: number;
|
|
467
|
+
decay: number;
|
|
468
|
+
sustain: number;
|
|
469
|
+
release: number;
|
|
470
|
+
};
|
|
471
|
+
declare class Envelope extends PolyModule<ModuleType.Envelope> {
|
|
472
|
+
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Envelope>);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
type IFilterProps = {
|
|
476
|
+
cutoff: number;
|
|
477
|
+
envelopeAmount: number;
|
|
478
|
+
resonance: number;
|
|
479
|
+
};
|
|
480
|
+
declare class Filter extends PolyModule<ModuleType.Filter> {
|
|
481
|
+
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Filter>);
|
|
482
|
+
private registerInputs;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
type IGain = IModule<ModuleType.Gain>;
|
|
486
|
+
type IGainProps = {
|
|
487
|
+
gain: number;
|
|
488
|
+
};
|
|
489
|
+
declare class Gain extends PolyModule<ModuleType.Gain> {
|
|
490
|
+
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Gain>);
|
|
491
|
+
private registerAdditionalInputs;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
type IInspectorProps = {
|
|
495
|
+
fftSize: number;
|
|
496
|
+
};
|
|
497
|
+
declare class Inspector extends Module<ModuleType.Inspector> {
|
|
498
|
+
audioNode: AnalyserNode;
|
|
499
|
+
private _buffer?;
|
|
500
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.Inspector>);
|
|
501
|
+
protected onSetFftSize(value: number): void;
|
|
502
|
+
get buffer(): Float32Array<ArrayBuffer>;
|
|
503
|
+
getValue(): number;
|
|
504
|
+
getValues(): Float32Array;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
type IMaster = IModule<ModuleType.Master>;
|
|
508
|
+
type IMasterProps = EmptyObject;
|
|
509
|
+
declare class Master extends Module<ModuleType.Master> {
|
|
510
|
+
audioNode: AudioDestinationNode;
|
|
511
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.Master>);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
type IMidiSelectorProps = {
|
|
515
|
+
selectedId: string | undefined | null;
|
|
516
|
+
};
|
|
517
|
+
declare class MidiSelector extends Module<ModuleType.MidiSelector> {
|
|
518
|
+
audioNode: undefined;
|
|
519
|
+
midiOutput: MidiOutput;
|
|
520
|
+
_forwardMidiEvent?: (midiEvent: MidiEvent) => void;
|
|
521
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.MidiSelector>);
|
|
522
|
+
protected onSetSelectedId(value: string | null): void;
|
|
523
|
+
private get forwardMidiEvent();
|
|
524
|
+
private addEventListener;
|
|
525
|
+
private removeEventListener;
|
|
526
|
+
private registerOutputs;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
type IOscillator = IModule<ModuleType.Oscillator>;
|
|
530
|
+
declare enum OscillatorWave {
|
|
531
|
+
sine = "sine",
|
|
532
|
+
triangle = "triangle",
|
|
533
|
+
square = "square",
|
|
534
|
+
sawtooth = "sawtooth"
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Props for the Oscillator module.
|
|
538
|
+
*
|
|
539
|
+
* @property wave - Waveform shape of the oscillator.
|
|
540
|
+
* One of: "sine", "square", "sawtooth", "triangle", or "custom".
|
|
541
|
+
* @property frequency - Base frequency in Hz (e.g. 440 for A4).
|
|
542
|
+
* @property fine - Fine tuning factor in the range [-1, 1], where ±1 represents ±1 semitone.
|
|
543
|
+
* @property coarse - Coarse tuning factor in the range [-1, 1], scaled to ±12 semitones.
|
|
544
|
+
* @property octave - Octave transposition value (e.g. +1 for one octave up, -2 for two octaves down).
|
|
545
|
+
* @property lowGain - Whether to gain reduction (-18dB). When false, oscillator runs at full gain.
|
|
546
|
+
*/
|
|
547
|
+
type IOscillatorProps = {
|
|
548
|
+
wave: OscillatorWave;
|
|
549
|
+
frequency: number;
|
|
550
|
+
fine: number;
|
|
551
|
+
coarse: number;
|
|
552
|
+
octave: number;
|
|
553
|
+
lowGain: boolean;
|
|
554
|
+
};
|
|
555
|
+
declare class Oscillator extends PolyModule<ModuleType.Oscillator> {
|
|
556
|
+
constructor(engineId: string, params: IPolyModuleConstructor<ModuleType.Oscillator>);
|
|
557
|
+
start(time: TTime): void;
|
|
558
|
+
stop(time: TTime): void;
|
|
559
|
+
private registerInputs;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
type IScaleProps = {
|
|
563
|
+
min: number;
|
|
564
|
+
max: number;
|
|
565
|
+
current: number;
|
|
566
|
+
};
|
|
567
|
+
declare class Scale extends Module<ModuleType.Scale> {
|
|
568
|
+
audioNode: AudioWorkletNode;
|
|
569
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.Scale>);
|
|
570
|
+
get current(): AudioParam;
|
|
571
|
+
get min(): AudioParam;
|
|
572
|
+
get max(): AudioParam;
|
|
573
|
+
protected onSetMin(value: number): void;
|
|
574
|
+
protected onSetMax(value: number): void;
|
|
575
|
+
protected onSetCurrent(value: number): void;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
type IStepSequencer = IModule<ModuleType.StepSequencer>;
|
|
579
|
+
type ISequence = {
|
|
580
|
+
active: boolean;
|
|
581
|
+
time: BarsBeatsSixteenths;
|
|
582
|
+
duration: string;
|
|
583
|
+
notes: INote[];
|
|
584
|
+
};
|
|
585
|
+
type IStepSequencerProps = {
|
|
586
|
+
bars: number;
|
|
587
|
+
steps: number;
|
|
588
|
+
sequences: ISequence[][];
|
|
589
|
+
};
|
|
590
|
+
declare class StepSequencer extends Module<ModuleType.StepSequencer> {
|
|
591
|
+
audioNode: undefined;
|
|
592
|
+
midiOutput: MidiOutput;
|
|
593
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.StepSequencer>);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
type IVirtualMidiProps = {
|
|
597
|
+
activeNotes: string[];
|
|
598
|
+
};
|
|
599
|
+
declare class VirtualMidi extends Module<ModuleType.VirtualMidi> {
|
|
600
|
+
audioNode: undefined;
|
|
601
|
+
midiOutput: MidiOutput;
|
|
602
|
+
constructor(engineId: string, params: ICreateModule<ModuleType.VirtualMidi>);
|
|
603
|
+
sendMidi(midiEvent: MidiEvent): void;
|
|
604
|
+
triggerAttack: (note: Note, triggerAttack: TTime) => void;
|
|
605
|
+
triggerRelease: (note: Note, triggerAttack: TTime) => void;
|
|
606
|
+
private registerInputs;
|
|
607
|
+
private registerOutputs;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
declare enum ModuleType {
|
|
611
|
+
Master = "Master",
|
|
612
|
+
Oscillator = "Oscillator",
|
|
613
|
+
Gain = "Gain",
|
|
614
|
+
MidiSelector = "MidiSelector",
|
|
615
|
+
Envelope = "Envelope",
|
|
616
|
+
Filter = "Filter",
|
|
617
|
+
BiquadFilter = "BiquadFilter",
|
|
618
|
+
Scale = "Scale",
|
|
619
|
+
Inspector = "Inspector",
|
|
620
|
+
Constant = "Constant",
|
|
621
|
+
VirtualMidi = "VirtualMidi",
|
|
622
|
+
StepSequencer = "StepSequencer",
|
|
623
|
+
VoiceScheduler = "VoiceScheduler"
|
|
624
|
+
}
|
|
625
|
+
type ModuleTypeToPropsMapping = {
|
|
626
|
+
[ModuleType.Oscillator]: IOscillatorProps;
|
|
627
|
+
[ModuleType.Gain]: IGainProps;
|
|
628
|
+
[ModuleType.Master]: IMasterProps;
|
|
629
|
+
[ModuleType.MidiSelector]: IMidiSelectorProps;
|
|
630
|
+
[ModuleType.Envelope]: IEnvelopeProps;
|
|
631
|
+
[ModuleType.Filter]: IFilterProps;
|
|
632
|
+
[ModuleType.BiquadFilter]: IBiquadFilterProps;
|
|
633
|
+
[ModuleType.Scale]: IScaleProps;
|
|
634
|
+
[ModuleType.Inspector]: IInspectorProps;
|
|
635
|
+
[ModuleType.Constant]: IConstantProps;
|
|
636
|
+
[ModuleType.VirtualMidi]: IVirtualMidiProps;
|
|
637
|
+
[ModuleType.StepSequencer]: IStepSequencerProps;
|
|
638
|
+
[ModuleType.VoiceScheduler]: IVoiceSchedulerProps;
|
|
639
|
+
};
|
|
640
|
+
type ModuleTypeToModuleMapping = {
|
|
641
|
+
[ModuleType.Oscillator]: Oscillator;
|
|
642
|
+
[ModuleType.Gain]: Gain;
|
|
643
|
+
[ModuleType.Master]: Master;
|
|
644
|
+
[ModuleType.MidiSelector]: MidiSelector;
|
|
645
|
+
[ModuleType.Envelope]: Envelope;
|
|
646
|
+
[ModuleType.Filter]: Filter;
|
|
647
|
+
[ModuleType.BiquadFilter]: BiquadFilter;
|
|
648
|
+
[ModuleType.Scale]: Scale;
|
|
649
|
+
[ModuleType.Inspector]: Inspector;
|
|
650
|
+
[ModuleType.Constant]: Constant;
|
|
651
|
+
[ModuleType.VirtualMidi]: VirtualMidi;
|
|
652
|
+
[ModuleType.StepSequencer]: StepSequencer;
|
|
653
|
+
[ModuleType.VoiceScheduler]: VoiceScheduler;
|
|
654
|
+
};
|
|
655
|
+
declare const moduleSchemas: {
|
|
656
|
+
[K in ModuleType]: PropSchema<Partial<ModuleTypeToPropsMapping[K]>>;
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
type AnyModule = Module<ModuleType>;
|
|
660
|
+
type ICreateModule<T extends ModuleType> = {
|
|
661
|
+
id?: string;
|
|
662
|
+
name: string;
|
|
663
|
+
moduleType: T;
|
|
664
|
+
props: Partial<ModuleTypeToPropsMapping[T]>;
|
|
665
|
+
};
|
|
666
|
+
type ModuleParams = {
|
|
667
|
+
[K in ModuleType]: K extends ModuleType.Oscillator | ModuleType.Gain | ModuleType.Envelope | ModuleType.Filter | ModuleType.BiquadFilter | ModuleType.VoiceScheduler ? IPolyModuleConstructor<K> : ICreateModule<K>;
|
|
668
|
+
}[ModuleType];
|
|
669
|
+
|
|
670
|
+
type IOProps = {
|
|
671
|
+
name: string;
|
|
672
|
+
ioType: IOType;
|
|
673
|
+
};
|
|
674
|
+
type IIOSerialize = IOProps & {
|
|
675
|
+
id: string;
|
|
676
|
+
moduleId: string;
|
|
677
|
+
};
|
|
678
|
+
declare enum IOType {
|
|
679
|
+
AudioInput = "audioInput",
|
|
680
|
+
AudioOutput = "audioOutput",
|
|
681
|
+
PolyAudioInput = "polyAudioInput",
|
|
682
|
+
PolyAudioOutput = "polyAudioOutput",
|
|
683
|
+
MidiOutput = "midiOutput",
|
|
684
|
+
MidiInput = "midiInput"
|
|
685
|
+
}
|
|
686
|
+
type IIO = {
|
|
687
|
+
id: string;
|
|
688
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
689
|
+
} & IOProps;
|
|
690
|
+
declare abstract class Base implements IIO {
|
|
691
|
+
id: string;
|
|
692
|
+
ioType: IOType;
|
|
693
|
+
name: string;
|
|
694
|
+
module: Module<ModuleType> | PolyModule<ModuleType>;
|
|
695
|
+
connections: Base[];
|
|
696
|
+
constructor(module: Module<ModuleType> | PolyModule<ModuleType>, props: IOProps);
|
|
697
|
+
plug(io: Base, plugOther?: boolean): void;
|
|
698
|
+
unPlug(io: Base, plugOther?: boolean): void;
|
|
699
|
+
rePlugAll(callback?: () => void): void;
|
|
700
|
+
unPlugAll(): void;
|
|
701
|
+
isAudio(): this is AudioInput | AudioOutput | PolyAudioInput | PolyAudioOutput;
|
|
702
|
+
isMidi(): this is MidiInput | MidiOutput;
|
|
703
|
+
serialize(): IIOSerialize;
|
|
704
|
+
}
|
|
705
|
+
declare abstract class IO<Connection extends Base> extends Base {
|
|
706
|
+
connections: Connection[];
|
|
707
|
+
plug(io: Connection, plugOther?: boolean): void;
|
|
708
|
+
unPlug(io: Connection, plugOther?: boolean): void;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
type IUpdateModule<T extends ModuleType> = {
|
|
712
|
+
id: string;
|
|
713
|
+
moduleType: T;
|
|
714
|
+
changes: Partial<Omit<ICreateModule<T>, "id" | "moduleType" | "voice">> & {
|
|
715
|
+
voices?: number;
|
|
716
|
+
};
|
|
717
|
+
};
|
|
718
|
+
type ICreateRoute = Optional<IRoute, "id">;
|
|
719
|
+
declare class Engine {
|
|
720
|
+
private static _engines;
|
|
721
|
+
private static _currentId;
|
|
722
|
+
private propsUpdateCallbacks;
|
|
723
|
+
readonly id: string;
|
|
724
|
+
context: IAnyAudioContext;
|
|
725
|
+
isInitialized: boolean;
|
|
726
|
+
routes: Routes;
|
|
727
|
+
transport: Transport;
|
|
728
|
+
modules: Map<string, ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping]>;
|
|
729
|
+
midiDeviceManager: MidiDeviceManager;
|
|
730
|
+
static getById(id: string): Engine;
|
|
731
|
+
static get current(): Engine;
|
|
732
|
+
constructor(context: IAnyAudioContext);
|
|
733
|
+
get state(): TransportState;
|
|
734
|
+
initialize(): Promise<void>;
|
|
735
|
+
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
|
+
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>;
|
|
737
|
+
removeModule(id: string): void;
|
|
738
|
+
addRoute(props: ICreateRoute): IRoute;
|
|
739
|
+
removeRoute(id: string): void;
|
|
740
|
+
validRoute(props: Optional<IRoute, "id">): boolean;
|
|
741
|
+
start(props?: {
|
|
742
|
+
offset?: TTime;
|
|
743
|
+
actionAt?: TTime;
|
|
744
|
+
}): void;
|
|
745
|
+
stop(props?: {
|
|
746
|
+
actionAt?: TTime;
|
|
747
|
+
}): void;
|
|
748
|
+
pause(props?: {
|
|
749
|
+
actionAt?: TTime;
|
|
750
|
+
}): void;
|
|
751
|
+
get bpm(): number;
|
|
752
|
+
set bpm(value: number);
|
|
753
|
+
resume(): Promise<void>;
|
|
754
|
+
dispose(): void;
|
|
755
|
+
findModule(id: string): ModuleTypeToModuleMapping[keyof ModuleTypeToModuleMapping];
|
|
756
|
+
findIO(moduleId: string, ioName: string, type: "input" | "output"): Base;
|
|
757
|
+
findMidiDevice(id: string): MidiDevice | ComputerKeyboardInput | undefined;
|
|
758
|
+
onPropsUpdate(callback: <T extends ModuleType>(params: IModule<T>) => void): void;
|
|
759
|
+
_triggerPropsUpdate<T extends ModuleType>(params: IModule<T>): void;
|
|
760
|
+
triggerVirtualMidi(id: string, noteName: string, type: "noteOn" | "noteOff"): void;
|
|
761
|
+
private onStart;
|
|
762
|
+
private onStop;
|
|
763
|
+
}
|
|
764
|
+
|
|
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, TransportState, moduleSchemas };
|