@dawcore/components 0.0.25 → 0.0.27
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/dist/index.d.mts +46 -12
- package/dist/index.d.ts +46 -12
- package/dist/index.js +104 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -203,11 +203,11 @@ var DawTrackElement = class extends LitElement2 {
|
|
|
203
203
|
}
|
|
204
204
|
// --- Effects API (delegates to the owning <daw-editor>) ---
|
|
205
205
|
addEffect(type, params) {
|
|
206
|
-
return this._effectsEditor().
|
|
206
|
+
return this._effectsEditor().addTrackEffect(this.trackId, type, params);
|
|
207
207
|
}
|
|
208
208
|
/** Load a WAM plugin (via the optional @dawcore/wam peer) into this track's chain. */
|
|
209
209
|
addWamPlugin(url, initialState) {
|
|
210
|
-
return this._effectsEditor().
|
|
210
|
+
return this._effectsEditor().addTrackWamPlugin(this.trackId, url, initialState);
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* Compile Faust DSP source in the browser (via the optional @dawcore/faust
|
|
@@ -215,16 +215,16 @@ var DawTrackElement = class extends LitElement2 {
|
|
|
215
215
|
* keep their Faust line/column diagnostics and leave the chain untouched.
|
|
216
216
|
*/
|
|
217
217
|
addFaustEffect(dspCode, options) {
|
|
218
|
-
return this._effectsEditor().
|
|
218
|
+
return this._effectsEditor().addTrackFaustEffect(this.trackId, dspCode, options);
|
|
219
219
|
}
|
|
220
220
|
/** Snapshot this track's chain in its persisted form (see dawcore README). */
|
|
221
221
|
getEffectsState() {
|
|
222
222
|
const editor = this.closest("daw-editor");
|
|
223
|
-
return editor?.
|
|
223
|
+
return editor?.getTrackEffectsState(this.trackId) ?? Promise.resolve([]);
|
|
224
224
|
}
|
|
225
225
|
/** Replace this track's chain with a persisted snapshot. */
|
|
226
226
|
setEffectsState(entries) {
|
|
227
|
-
return this._effectsEditor().
|
|
227
|
+
return this._effectsEditor().setTrackEffectsState(this.trackId, entries);
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
230
|
* Open (lazily creating) the GUI for one of this track's effects into a
|
|
@@ -232,27 +232,27 @@ var DawTrackElement = class extends LitElement2 {
|
|
|
232
232
|
* the element is cached for reopen. See <daw-editor>.openEffectGui.
|
|
233
233
|
*/
|
|
234
234
|
openEffectGui(effectId, container) {
|
|
235
|
-
return this._effectsEditor().
|
|
235
|
+
return this._effectsEditor().openTrackEffectGui(this.trackId, effectId, container);
|
|
236
236
|
}
|
|
237
237
|
/** Hide an effect's GUI (cached for reopen — never destroys). */
|
|
238
238
|
closeEffectGui(effectId) {
|
|
239
|
-
this._effectsEditor().
|
|
239
|
+
this._effectsEditor().closeTrackEffectGui(this.trackId, effectId);
|
|
240
240
|
}
|
|
241
241
|
removeEffect(effectId) {
|
|
242
|
-
this._effectsEditor().
|
|
242
|
+
this._effectsEditor().removeTrackEffect(this.trackId, effectId);
|
|
243
243
|
}
|
|
244
244
|
setEffectParams(effectId, params) {
|
|
245
|
-
this._effectsEditor().
|
|
245
|
+
this._effectsEditor().setTrackEffectParams(this.trackId, effectId, params);
|
|
246
246
|
}
|
|
247
247
|
setEffectBypassed(effectId, bypassed) {
|
|
248
|
-
this._effectsEditor().
|
|
248
|
+
this._effectsEditor().setTrackEffectBypassed(this.trackId, effectId, bypassed);
|
|
249
249
|
}
|
|
250
250
|
moveEffect(effectId, newIndex) {
|
|
251
|
-
this._effectsEditor().
|
|
251
|
+
this._effectsEditor().moveTrackEffect(this.trackId, effectId, newIndex);
|
|
252
252
|
}
|
|
253
253
|
get effects() {
|
|
254
254
|
const editor = this.closest("daw-editor");
|
|
255
|
-
return editor?.
|
|
255
|
+
return editor?.trackEffects(this.trackId) ?? [];
|
|
256
256
|
}
|
|
257
257
|
_effectsEditor() {
|
|
258
258
|
const editor = this.closest("daw-editor");
|
|
@@ -2708,7 +2708,12 @@ var AudioResumeController = class {
|
|
|
2708
2708
|
};
|
|
2709
2709
|
|
|
2710
2710
|
// src/controllers/recording-controller.ts
|
|
2711
|
-
import {
|
|
2711
|
+
import {
|
|
2712
|
+
appendPeaks,
|
|
2713
|
+
concatenateAudioData,
|
|
2714
|
+
createAudioBuffer,
|
|
2715
|
+
resolveRecordingOffsetSamples
|
|
2716
|
+
} from "@waveform-playlist/core";
|
|
2712
2717
|
var RecordingController = class {
|
|
2713
2718
|
constructor(host) {
|
|
2714
2719
|
this._sessions = /* @__PURE__ */ new Map();
|
|
@@ -2771,8 +2776,12 @@ var RecordingController = class {
|
|
|
2771
2776
|
}
|
|
2772
2777
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
2773
2778
|
const startSample = options.startSample ?? Math.floor(this._host._currentTime * this._host.effectiveSampleRate);
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2779
|
+
const latencySamples = resolveRecordingOffsetSamples({
|
|
2780
|
+
overrideSeconds: options.latencyOffset,
|
|
2781
|
+
outputLatency: rawCtx.outputLatency ?? 0,
|
|
2782
|
+
lookAhead: 0,
|
|
2783
|
+
sampleRate: rawCtx.sampleRate
|
|
2784
|
+
});
|
|
2776
2785
|
const source = this._host.createMediaStreamSource ? this._host.createMediaStreamSource(stream) : rawCtx.createMediaStreamSource(stream);
|
|
2777
2786
|
const workletNode = this._host.createAudioWorkletNode ? this._host.createAudioWorkletNode("recording-processor", {
|
|
2778
2787
|
channelCount,
|
|
@@ -6064,38 +6073,92 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
6064
6073
|
duration: this._duration,
|
|
6065
6074
|
tracks: [...this._engineTracks.values()],
|
|
6066
6075
|
getMasterEffectsState: () => this.getEffectsState(),
|
|
6067
|
-
getTrackEffectsState: (trackId) => this.
|
|
6076
|
+
getTrackEffectsState: (trackId) => this.getTrackEffectsState(trackId)
|
|
6068
6077
|
},
|
|
6069
6078
|
options
|
|
6070
6079
|
);
|
|
6071
6080
|
}
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6081
|
+
// --- Per-track effects API (public, keyed by trackId) ---
|
|
6082
|
+
// Mirrors the master-chain methods above and the <daw-track> element methods,
|
|
6083
|
+
// but addresses a track by id so element-less tracks (drag-dropped, or
|
|
6084
|
+
// programmatic tracks the consumer doesn't hold an element for) can carry
|
|
6085
|
+
// their own insert chain. Effect events dispatch from the track's <daw-track>
|
|
6086
|
+
// element when one exists, else from the editor (see _trackEventTarget).
|
|
6087
|
+
/** Add a native registry effect to a track's chain. */
|
|
6088
|
+
addTrackEffect(trackId, type, params) {
|
|
6089
|
+
return this._effects.addTrackEffect(trackId, this._trackEventTarget(trackId), type, params);
|
|
6090
|
+
}
|
|
6091
|
+
/** Snapshot of a track's effect chain (empty array for an unknown track). */
|
|
6092
|
+
trackEffects(trackId) {
|
|
6093
|
+
return this._effectsManager?.trackEffects(trackId) ?? [];
|
|
6075
6094
|
}
|
|
6076
|
-
|
|
6077
|
-
this._effects.trackOp(trackId,
|
|
6095
|
+
removeTrackEffect(trackId, effectId) {
|
|
6096
|
+
this._effects.trackOp(trackId, this._trackEventTarget(trackId), "remove", effectId);
|
|
6078
6097
|
}
|
|
6079
|
-
|
|
6080
|
-
|
|
6098
|
+
setTrackEffectParams(trackId, effectId, params) {
|
|
6099
|
+
this._effects.trackOp(trackId, this._trackEventTarget(trackId), "setParams", effectId, params);
|
|
6081
6100
|
}
|
|
6082
|
-
|
|
6083
|
-
|
|
6101
|
+
setTrackEffectBypassed(trackId, effectId, bypassed) {
|
|
6102
|
+
this._effects.trackOp(
|
|
6103
|
+
trackId,
|
|
6104
|
+
this._trackEventTarget(trackId),
|
|
6105
|
+
"setBypassed",
|
|
6106
|
+
effectId,
|
|
6107
|
+
bypassed
|
|
6108
|
+
);
|
|
6084
6109
|
}
|
|
6085
|
-
|
|
6086
|
-
|
|
6110
|
+
moveTrackEffect(trackId, effectId, newIndex) {
|
|
6111
|
+
this._effects.trackOp(trackId, this._trackEventTarget(trackId), "move", effectId, newIndex);
|
|
6087
6112
|
}
|
|
6088
|
-
|
|
6089
|
-
|
|
6113
|
+
/** Load a WAM plugin (via the optional @dawcore/wam peer) into a track's chain. */
|
|
6114
|
+
addTrackWamPlugin(trackId, url, initialState) {
|
|
6115
|
+
return this._effects.addTrackWamPlugin(
|
|
6116
|
+
trackId,
|
|
6117
|
+
this._trackEventTarget(trackId),
|
|
6118
|
+
url,
|
|
6119
|
+
initialState
|
|
6120
|
+
);
|
|
6121
|
+
}
|
|
6122
|
+
/** Compile Faust DSP (via the optional @dawcore/faust peer) into a track's chain. */
|
|
6123
|
+
addTrackFaustEffect(trackId, dspCode, options) {
|
|
6124
|
+
return this._effects.addTrackFaustEffect(
|
|
6125
|
+
trackId,
|
|
6126
|
+
this._trackEventTarget(trackId),
|
|
6127
|
+
dspCode,
|
|
6128
|
+
options
|
|
6129
|
+
);
|
|
6090
6130
|
}
|
|
6091
|
-
|
|
6131
|
+
/** Open (lazily creating) the GUI for a track-chain effect into a container. */
|
|
6132
|
+
openTrackEffectGui(trackId, effectId, container) {
|
|
6133
|
+
return this._effects.openTrackEffectGui(
|
|
6134
|
+
trackId,
|
|
6135
|
+
this._trackEventTarget(trackId),
|
|
6136
|
+
effectId,
|
|
6137
|
+
container
|
|
6138
|
+
);
|
|
6139
|
+
}
|
|
6140
|
+
/** Hide a track-chain effect's GUI (cached for reopen — never destroys). */
|
|
6141
|
+
closeTrackEffectGui(_trackId, effectId) {
|
|
6092
6142
|
this._effects.closeEffectGui(effectId);
|
|
6093
6143
|
}
|
|
6094
|
-
|
|
6144
|
+
/** Snapshot a track's chain in its persisted form (see dawcore README). */
|
|
6145
|
+
getTrackEffectsState(trackId) {
|
|
6095
6146
|
return this._effectsManager?.getTrackEffectsState(trackId) ?? Promise.resolve([]);
|
|
6096
6147
|
}
|
|
6097
|
-
|
|
6098
|
-
|
|
6148
|
+
/** Replace a track's chain from a persisted snapshot. */
|
|
6149
|
+
setTrackEffectsState(trackId, entries) {
|
|
6150
|
+
return this._effects.setTrackEffectsState(trackId, this._trackEventTarget(trackId), entries);
|
|
6151
|
+
}
|
|
6152
|
+
/**
|
|
6153
|
+
* Event-dispatch source for a per-track effect op: the track's `<daw-track>`
|
|
6154
|
+
* element when one exists (so `daw-effect-*` bubble from it exactly as the
|
|
6155
|
+
* element-method path does), else the editor itself for element-less tracks
|
|
6156
|
+
* (drag-dropped / programmatic). Reads the `_trackElements` index the editor
|
|
6157
|
+
* already maintains across the track connect/remove lifecycle — O(1), and the
|
|
6158
|
+
* same resolution `removeTrack` uses — rather than re-querying the DOM per op.
|
|
6159
|
+
*/
|
|
6160
|
+
_trackEventTarget(trackId) {
|
|
6161
|
+
return this._trackElements.get(trackId) ?? this;
|
|
6099
6162
|
}
|
|
6100
6163
|
get audioContext() {
|
|
6101
6164
|
if (!this._externalAdapter) {
|
|
@@ -6206,7 +6269,10 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
6206
6269
|
this._selectedTrackId = trackId;
|
|
6207
6270
|
}
|
|
6208
6271
|
get tracks() {
|
|
6209
|
-
return [...this._tracks.
|
|
6272
|
+
return [...this._tracks.entries()].map(([trackId, descriptor]) => ({
|
|
6273
|
+
trackId,
|
|
6274
|
+
...descriptor
|
|
6275
|
+
}));
|
|
6210
6276
|
}
|
|
6211
6277
|
get selectedTrackId() {
|
|
6212
6278
|
return this._selectedTrackId;
|
|
@@ -6344,6 +6410,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
6344
6410
|
}
|
|
6345
6411
|
}
|
|
6346
6412
|
_onTrackRemoved(trackId) {
|
|
6413
|
+
const existed = this._tracks.has(trackId);
|
|
6347
6414
|
this._trackElements.delete(trackId);
|
|
6348
6415
|
this._effectsManager?.disposeTrackChain(trackId);
|
|
6349
6416
|
const removedTrack = this._engineTracks.get(trackId);
|
|
@@ -6373,6 +6440,15 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
6373
6440
|
this._currentTime = 0;
|
|
6374
6441
|
this._stopPlayhead();
|
|
6375
6442
|
}
|
|
6443
|
+
if (existed && this.isConnected) {
|
|
6444
|
+
this.dispatchEvent(
|
|
6445
|
+
new CustomEvent("daw-track-removed", {
|
|
6446
|
+
bubbles: true,
|
|
6447
|
+
composed: true,
|
|
6448
|
+
detail: { trackId }
|
|
6449
|
+
})
|
|
6450
|
+
);
|
|
6451
|
+
}
|
|
6376
6452
|
}
|
|
6377
6453
|
/** Drop the controller when no spectrogram tracks remain. */
|
|
6378
6454
|
_disposeSpectrogramControllerIfEmpty() {
|