forked from abh1nash/ace-daw
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathInstrumentEngine.ts
More file actions
34 lines (28 loc) · 1.25 KB
/
InstrumentEngine.ts
File metadata and controls
34 lines (28 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Unified interface for all instrument engines (subtractive synth, sampler, FM).
*
* Every instrument engine implementation must conform to this interface so that
* playback, recording, and automation code can operate on any instrument kind
* without branching on the concrete type.
*/
export interface InstrumentEngine {
/** Trigger note-on for a track (for live playing / recording). */
noteOn(trackId: string, pitch: number, velocity: number): void;
/** Trigger note-off for a track. */
noteOff(trackId: string, pitch: number): void;
/** Play a note with a fixed duration (for sequenced playback). */
triggerAttackRelease(trackId: string, pitch: number, duration: number, velocity: number): void;
/**
* Set an engine-specific parameter by name.
*
* This is a generic escape hatch for automation and preset changes.
* Implementations may ignore unknown parameter names.
*/
setParameter(trackId: string, name: string, value: number | string | boolean): void;
/** Release all currently sounding notes across every track. */
releaseAll(): void;
/** Tear down resources associated with a single track. */
removeTrack(trackId: string): void;
/** Dispose the entire engine and release all resources. */
dispose(): void;
}