@dawcore/components 0.0.23 → 0.0.24
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 +155 -16
- package/dist/index.d.mts +248 -1
- package/dist/index.d.ts +248 -1
- package/dist/index.js +1269 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1266 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -7
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,87 @@ declare global {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/** Range/display metadata for one effect parameter. */
|
|
50
|
+
interface EffectParamDef {
|
|
51
|
+
min: number;
|
|
52
|
+
max: number;
|
|
53
|
+
step?: number;
|
|
54
|
+
/** 's', 'ms', 'Hz', 'dB', '%' … */
|
|
55
|
+
unit?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A live, wired effect. `input`/`output` are the chain attachment points
|
|
59
|
+
* (the same node for single-node effects). `applyParams` updates AudioParams
|
|
60
|
+
* in place — the chain never rebuilds for parameter changes.
|
|
61
|
+
*/
|
|
62
|
+
interface EffectInstance {
|
|
63
|
+
input: AudioNode;
|
|
64
|
+
output: AudioNode;
|
|
65
|
+
applyParams: (params: Record<string, number>) => void;
|
|
66
|
+
dispose?: () => void;
|
|
67
|
+
/** Serializable snapshot of plugin-internal state (WAM getState). */
|
|
68
|
+
getState?: () => Promise<unknown>;
|
|
69
|
+
/** Builds the plugin's own GUI element (WAM createGui). GUI lifecycle is
|
|
70
|
+
* independent of audio — hiding/destroying a GUI never stops processing. */
|
|
71
|
+
createGui?: () => Promise<HTMLElement>;
|
|
72
|
+
/** Releases a GUI element previously built by `createGui` (WAM destroyGui). */
|
|
73
|
+
destroyGui?: (gui: HTMLElement) => void;
|
|
74
|
+
/** Parameter metadata for the generic fallback panel (WAM getParameterInfo). */
|
|
75
|
+
getParameterInfo?: () => Promise<unknown>;
|
|
76
|
+
}
|
|
77
|
+
/** A registered effect type. `create` must work on any BaseAudioContext so
|
|
78
|
+
* the same definitions serve offline rendering. */
|
|
79
|
+
interface EffectDefinition {
|
|
80
|
+
label: string;
|
|
81
|
+
category: string;
|
|
82
|
+
defaults: Record<string, number>;
|
|
83
|
+
params: Record<string, EffectParamDef>;
|
|
84
|
+
/** Name of the wet/dry param, when the effect has one. Bypass zeroes it
|
|
85
|
+
* (storing the original); effects without one are bypassed by
|
|
86
|
+
* disconnection. */
|
|
87
|
+
wetParam?: string;
|
|
88
|
+
create: (audioContext: BaseAudioContext, params: Record<string, number>) => EffectInstance;
|
|
89
|
+
}
|
|
90
|
+
/** Public, serializable view of one chain entry. */
|
|
91
|
+
interface EffectState {
|
|
92
|
+
id: string;
|
|
93
|
+
kind: string;
|
|
94
|
+
type: string;
|
|
95
|
+
params: Record<string, number>;
|
|
96
|
+
bypassed: boolean;
|
|
97
|
+
url?: string;
|
|
98
|
+
/** Present on Faust entries: the DSP source this effect was compiled from. */
|
|
99
|
+
source?: {
|
|
100
|
+
faust: string;
|
|
101
|
+
};
|
|
102
|
+
label?: string;
|
|
103
|
+
error?: string;
|
|
104
|
+
}
|
|
105
|
+
/** Persisted form of a chain — see README for the consumer contract. */
|
|
106
|
+
type SerializedEffectEntry = {
|
|
107
|
+
kind: 'native';
|
|
108
|
+
type: string;
|
|
109
|
+
params: Record<string, number>;
|
|
110
|
+
bypassed: boolean;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'wam';
|
|
113
|
+
/** Module URL for url-loaded plugins. Absent for Faust entries. */
|
|
114
|
+
url?: string;
|
|
115
|
+
bypassed: boolean;
|
|
116
|
+
state?: unknown;
|
|
117
|
+
/** Faust DSP source — restore recompiles in-browser via @dawcore/faust
|
|
118
|
+
* instead of fetching a URL. */
|
|
119
|
+
faustDsp?: string;
|
|
120
|
+
/** Name the Faust entry was compiled under (restores the same label). */
|
|
121
|
+
faustName?: string;
|
|
122
|
+
};
|
|
123
|
+
/** Result of creating an effect via the registry. */
|
|
124
|
+
interface CreatedEffect {
|
|
125
|
+
instance: EffectInstance;
|
|
126
|
+
params: Record<string, number>;
|
|
127
|
+
wetParam?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
49
130
|
declare class DawTrackElement extends LitElement {
|
|
50
131
|
src: string;
|
|
51
132
|
name: string;
|
|
@@ -59,6 +140,35 @@ declare class DawTrackElement extends LitElement {
|
|
|
59
140
|
spectrogramConfig: SpectrogramConfig | null;
|
|
60
141
|
readonly trackId: `${string}-${string}-${string}-${string}-${string}`;
|
|
61
142
|
createRenderRoot(): this;
|
|
143
|
+
addEffect(type: string, params?: Record<string, number>): string;
|
|
144
|
+
/** Load a WAM plugin (via the optional @dawcore/wam peer) into this track's chain. */
|
|
145
|
+
addWamPlugin(url: string, initialState?: unknown): Promise<string>;
|
|
146
|
+
/**
|
|
147
|
+
* Compile Faust DSP source in the browser (via the optional @dawcore/faust
|
|
148
|
+
* peer) and add the resulting WAM to this track's chain. Compile errors
|
|
149
|
+
* keep their Faust line/column diagnostics and leave the chain untouched.
|
|
150
|
+
*/
|
|
151
|
+
addFaustEffect(dspCode: string, options?: {
|
|
152
|
+
name?: string;
|
|
153
|
+
}): Promise<string>;
|
|
154
|
+
/** Snapshot this track's chain in its persisted form (see dawcore README). */
|
|
155
|
+
getEffectsState(): Promise<SerializedEffectEntry[]>;
|
|
156
|
+
/** Replace this track's chain with a persisted snapshot. */
|
|
157
|
+
setEffectsState(entries: SerializedEffectEntry[]): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Open (lazily creating) the GUI for one of this track's effects into a
|
|
160
|
+
* consumer-provided container. Closing hides without interrupting audio;
|
|
161
|
+
* the element is cached for reopen. See <daw-editor>.openEffectGui.
|
|
162
|
+
*/
|
|
163
|
+
openEffectGui(effectId: string, container: HTMLElement): Promise<HTMLElement>;
|
|
164
|
+
/** Hide an effect's GUI (cached for reopen — never destroys). */
|
|
165
|
+
closeEffectGui(effectId: string): void;
|
|
166
|
+
removeEffect(effectId: string): void;
|
|
167
|
+
setEffectParams(effectId: string, params: Record<string, number>): void;
|
|
168
|
+
setEffectBypassed(effectId: string, bypassed: boolean): void;
|
|
169
|
+
moveEffect(effectId: string, newIndex: number): void;
|
|
170
|
+
get effects(): EffectState[];
|
|
171
|
+
private _effectsEditor;
|
|
62
172
|
connectedCallback(): void;
|
|
63
173
|
private _hasRendered;
|
|
64
174
|
updated(changed: PropertyValues): void;
|
|
@@ -826,6 +936,45 @@ interface DawSpectrogramErrorDetail {
|
|
|
826
936
|
generation: number;
|
|
827
937
|
error: Error;
|
|
828
938
|
}
|
|
939
|
+
interface DawEffectAddDetail {
|
|
940
|
+
effectId: string;
|
|
941
|
+
kind: string;
|
|
942
|
+
type: string;
|
|
943
|
+
params: Record<string, number>;
|
|
944
|
+
index: number;
|
|
945
|
+
/** Plugin source URL (kind 'wam', url-loaded). */
|
|
946
|
+
url?: string;
|
|
947
|
+
/** Faust DSP source (kind 'wam', compiled in-browser via @dawcore/faust). */
|
|
948
|
+
source?: {
|
|
949
|
+
faust: string;
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
interface DawEffectRemoveDetail {
|
|
953
|
+
effectId: string;
|
|
954
|
+
}
|
|
955
|
+
interface DawEffectChangeDetail {
|
|
956
|
+
effectId: string;
|
|
957
|
+
params: Record<string, number>;
|
|
958
|
+
}
|
|
959
|
+
interface DawEffectBypassDetail {
|
|
960
|
+
effectId: string;
|
|
961
|
+
bypassed: boolean;
|
|
962
|
+
}
|
|
963
|
+
interface DawEffectReorderDetail {
|
|
964
|
+
effectId: string;
|
|
965
|
+
fromIndex: number;
|
|
966
|
+
toIndex: number;
|
|
967
|
+
}
|
|
968
|
+
interface DawEffectErrorDetail {
|
|
969
|
+
effectId: string;
|
|
970
|
+
/** Plugin source URL (absent for Faust entries, which have no URL). */
|
|
971
|
+
url?: string;
|
|
972
|
+
/** Faust DSP source of the failed entry, when applicable. */
|
|
973
|
+
source?: {
|
|
974
|
+
faust: string;
|
|
975
|
+
};
|
|
976
|
+
message: string;
|
|
977
|
+
}
|
|
829
978
|
interface DawEventMap {
|
|
830
979
|
'daw-selection': CustomEvent<DawSelectionDetail>;
|
|
831
980
|
'daw-seek': CustomEvent<DawSeekDetail>;
|
|
@@ -855,6 +1004,12 @@ interface DawEventMap {
|
|
|
855
1004
|
'daw-clip-split': CustomEvent<DawClipSplitDetail>;
|
|
856
1005
|
'daw-spectrogram-ready': CustomEvent<DawSpectrogramReadyDetail>;
|
|
857
1006
|
'daw-spectrogram-error': CustomEvent<DawSpectrogramErrorDetail>;
|
|
1007
|
+
'daw-effect-add': CustomEvent<DawEffectAddDetail>;
|
|
1008
|
+
'daw-effect-remove': CustomEvent<DawEffectRemoveDetail>;
|
|
1009
|
+
'daw-effect-change': CustomEvent<DawEffectChangeDetail>;
|
|
1010
|
+
'daw-effect-bypass': CustomEvent<DawEffectBypassDetail>;
|
|
1011
|
+
'daw-effect-reorder': CustomEvent<DawEffectReorderDetail>;
|
|
1012
|
+
'daw-effect-error': CustomEvent<DawEffectErrorDetail>;
|
|
858
1013
|
}
|
|
859
1014
|
type DawEvent<K extends keyof DawEventMap> = DawEventMap[K];
|
|
860
1015
|
interface LoadFilesResult {
|
|
@@ -887,6 +1042,42 @@ interface MidiLoaderHost {
|
|
|
887
1042
|
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
888
1043
|
}
|
|
889
1044
|
|
|
1045
|
+
interface ExportOptions {
|
|
1046
|
+
/** Default: the host's sample rate. */
|
|
1047
|
+
sampleRate?: number;
|
|
1048
|
+
/** Window start in seconds. Default: 0. */
|
|
1049
|
+
startTime?: number;
|
|
1050
|
+
/** Window length in seconds. Default: host duration minus startTime. */
|
|
1051
|
+
duration?: number;
|
|
1052
|
+
/** Default: 2 (stereo). */
|
|
1053
|
+
channels?: 1 | 2;
|
|
1054
|
+
}
|
|
1055
|
+
interface ExportClip {
|
|
1056
|
+
startSample: number;
|
|
1057
|
+
durationSamples: number;
|
|
1058
|
+
offsetSamples: number;
|
|
1059
|
+
sampleRate: number;
|
|
1060
|
+
gain?: number;
|
|
1061
|
+
audioBuffer?: AudioBuffer;
|
|
1062
|
+
}
|
|
1063
|
+
interface ExportTrack {
|
|
1064
|
+
id: string;
|
|
1065
|
+
volume: number;
|
|
1066
|
+
pan: number;
|
|
1067
|
+
muted: boolean;
|
|
1068
|
+
soloed: boolean;
|
|
1069
|
+
clips: ExportClip[];
|
|
1070
|
+
}
|
|
1071
|
+
/** What the editor provides to the export pipeline. */
|
|
1072
|
+
interface ExportAudioHost {
|
|
1073
|
+
effectiveSampleRate: number;
|
|
1074
|
+
/** Natural session duration in seconds. */
|
|
1075
|
+
duration: number;
|
|
1076
|
+
tracks: ExportTrack[];
|
|
1077
|
+
getMasterEffectsState(): Promise<SerializedEffectEntry[]>;
|
|
1078
|
+
getTrackEffectsState(trackId: string): Promise<SerializedEffectEntry[]>;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
890
1081
|
declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
891
1082
|
get samplesPerPixel(): number;
|
|
892
1083
|
set samplesPerPixel(value: number);
|
|
@@ -989,6 +1180,57 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
989
1180
|
set adapter(value: PlayoutAdapter | null);
|
|
990
1181
|
get adapter(): PlayoutAdapter | null;
|
|
991
1182
|
private _externalAdapter;
|
|
1183
|
+
private _effectsManager;
|
|
1184
|
+
private get _effects();
|
|
1185
|
+
/** Master effects chain — inserted between the master bus and the destination. */
|
|
1186
|
+
addEffect(type: string, params?: Record<string, number>): string;
|
|
1187
|
+
removeEffect(effectId: string): void;
|
|
1188
|
+
setEffectParams(effectId: string, params: Record<string, number>): void;
|
|
1189
|
+
setEffectBypassed(effectId: string, bypassed: boolean): void;
|
|
1190
|
+
moveEffect(effectId: string, newIndex: number): void;
|
|
1191
|
+
get effects(): EffectState[];
|
|
1192
|
+
/** Load a WAM plugin (via the optional @dawcore/wam peer) into the master chain. */
|
|
1193
|
+
addWamPlugin(url: string, initialState?: unknown): Promise<string>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Compile Faust DSP source in the browser (via the optional @dawcore/faust
|
|
1196
|
+
* peer) and add the resulting WAM to the master chain. Compile errors keep
|
|
1197
|
+
* their Faust line/column diagnostics and leave the chain untouched.
|
|
1198
|
+
*/
|
|
1199
|
+
addFaustEffect(dspCode: string, options?: {
|
|
1200
|
+
name?: string;
|
|
1201
|
+
}): Promise<string>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Open (lazily creating) the GUI for a master-chain effect into a
|
|
1204
|
+
* consumer-provided container. WAM plugins mount their own GUI; plugins
|
|
1205
|
+
* without one — and native effects — get the generic parameter panel from
|
|
1206
|
+
* @dawcore/wam. The element is cached: closeEffectGui hides it without
|
|
1207
|
+
* interrupting audio, reopening remounts the same element.
|
|
1208
|
+
*/
|
|
1209
|
+
openEffectGui(effectId: string, container: HTMLElement): Promise<HTMLElement>;
|
|
1210
|
+
/** Hide a master-chain effect's GUI (cached for reopen — never destroys). */
|
|
1211
|
+
closeEffectGui(effectId: string): void;
|
|
1212
|
+
/** Snapshot the master chain in its persisted form (see dawcore README). */
|
|
1213
|
+
getEffectsState(): Promise<SerializedEffectEntry[]>;
|
|
1214
|
+
/** Replace the master chain with a persisted snapshot. */
|
|
1215
|
+
setEffectsState(entries: SerializedEffectEntry[]): Promise<void>;
|
|
1216
|
+
/**
|
|
1217
|
+
* Render the session offline through all effect chains (per-track +
|
|
1218
|
+
* master), including WAM plugins (re-instantiated on the offline context
|
|
1219
|
+
* with their live state). Returns the rendered AudioBuffer.
|
|
1220
|
+
*/
|
|
1221
|
+
exportAudio(options?: ExportOptions): Promise<AudioBuffer>;
|
|
1222
|
+
/** Internal — <daw-track> effects API delegates here (dawcore-internal contract). */
|
|
1223
|
+
_trackAddEffect(trackId: string, target: EventTarget, type: string, params?: Record<string, number>): string;
|
|
1224
|
+
_trackEffectOp(trackId: string, target: EventTarget, op: 'remove' | 'setParams' | 'setBypassed' | 'move', effectId: string, arg?: any): void;
|
|
1225
|
+
_trackEffects(trackId: string): EffectState[];
|
|
1226
|
+
_trackAddWamPlugin(trackId: string, target: EventTarget, url: string, initialState?: unknown): Promise<string>;
|
|
1227
|
+
_trackAddFaustEffect(trackId: string, target: EventTarget, dspCode: string, options?: {
|
|
1228
|
+
name?: string;
|
|
1229
|
+
}): Promise<string>;
|
|
1230
|
+
_trackOpenEffectGui(trackId: string, target: EventTarget, effectId: string, container: HTMLElement): Promise<HTMLElement>;
|
|
1231
|
+
_trackCloseEffectGui(_trackId: string, effectId: string): void;
|
|
1232
|
+
_trackGetEffectsState(trackId: string): Promise<SerializedEffectEntry[]>;
|
|
1233
|
+
_trackSetEffectsState(trackId: string, target: EventTarget, entries: SerializedEffectEntry[]): Promise<void>;
|
|
992
1234
|
get audioContext(): AudioContext;
|
|
993
1235
|
_engine: PlaylistEngine | null;
|
|
994
1236
|
private _warnedMissingTicksToSeconds;
|
|
@@ -1496,4 +1738,9 @@ interface SplitHost {
|
|
|
1496
1738
|
*/
|
|
1497
1739
|
declare function splitAtPlayhead(host: SplitHost): boolean;
|
|
1498
1740
|
|
|
1499
|
-
|
|
1741
|
+
declare function registerEffect(type: string, definition: EffectDefinition): void;
|
|
1742
|
+
/** A copy — mutating the returned map does not affect the registry. */
|
|
1743
|
+
declare function getEffectDefinitions(): Map<string, EffectDefinition>;
|
|
1744
|
+
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
|
|
1745
|
+
|
|
1746
|
+
export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, type PlaybackShortcutMap, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type UndoShortcutMap, type WaveformSegment, createEffectInstance, getEffectDefinitions, isDomClip, registerEffect, splitAtPlayhead };
|