@dawcore/spectrogram 0.0.9-next.6 → 0.0.9-next.8
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 +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -9
- package/dist/index.mjs.map +1 -1
- package/dist/orchestrator/index.d.mts +9 -2
- package/dist/orchestrator/index.mjs +22 -9
- package/dist/orchestrator/index.mjs.map +1 -1
- package/dist/worker/spectrogram.worker.mjs +85 -54
- package/dist/worker/spectrogram.worker.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -125,7 +125,8 @@ declare function computePaddedFftRange({ chunks, fftSize, offsetSamples, duratio
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* Error thrown when a spectrogram computation is aborted
|
|
128
|
+
* Error thrown when a spectrogram computation is aborted: its generation was
|
|
129
|
+
* superseded, or its clip's audio was replaced or unregistered while it ran (#928).
|
|
129
130
|
* Use `instanceof SpectrogramAbortError` instead of string matching on error messages.
|
|
130
131
|
*/
|
|
131
132
|
declare class SpectrogramAbortError extends Error {
|
|
@@ -340,8 +341,15 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
340
341
|
protected scheduleRender(): void;
|
|
341
342
|
protected runRenderLoop(): Promise<void>;
|
|
342
343
|
protected runRender(generation: number): Promise<void>;
|
|
343
|
-
|
|
344
|
-
protected
|
|
344
|
+
/** Renders the tier's groups; false when a group waits for a render already scheduled. */
|
|
345
|
+
protected renderTier(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<boolean>;
|
|
346
|
+
/**
|
|
347
|
+
* Renders one group. Returns false when its computation was dropped and
|
|
348
|
+
* another pass is queued (registerClip queues one for a clip registered again
|
|
349
|
+
* mid-computation that still has canvases, #928): that pass draws it. True
|
|
350
|
+
* otherwise, also when there is nothing to draw or nothing will draw it.
|
|
351
|
+
*/
|
|
352
|
+
protected renderGroup(group: CanvasEntry[], generation: number, viewport: ViewportState): Promise<boolean>;
|
|
345
353
|
protected renderGroupOnce(group: CanvasEntry[], generation: number, viewport: ViewportState, clip: ClipEntry): Promise<void>;
|
|
346
354
|
protected renderRemainingViaIdle(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
347
355
|
protected yieldUntilIdle(): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -125,7 +125,8 @@ declare function computePaddedFftRange({ chunks, fftSize, offsetSamples, duratio
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* Error thrown when a spectrogram computation is aborted
|
|
128
|
+
* Error thrown when a spectrogram computation is aborted: its generation was
|
|
129
|
+
* superseded, or its clip's audio was replaced or unregistered while it ran (#928).
|
|
129
130
|
* Use `instanceof SpectrogramAbortError` instead of string matching on error messages.
|
|
130
131
|
*/
|
|
131
132
|
declare class SpectrogramAbortError extends Error {
|
|
@@ -340,8 +341,15 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
340
341
|
protected scheduleRender(): void;
|
|
341
342
|
protected runRenderLoop(): Promise<void>;
|
|
342
343
|
protected runRender(generation: number): Promise<void>;
|
|
343
|
-
|
|
344
|
-
protected
|
|
344
|
+
/** Renders the tier's groups; false when a group waits for a render already scheduled. */
|
|
345
|
+
protected renderTier(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<boolean>;
|
|
346
|
+
/**
|
|
347
|
+
* Renders one group. Returns false when its computation was dropped and
|
|
348
|
+
* another pass is queued (registerClip queues one for a clip registered again
|
|
349
|
+
* mid-computation that still has canvases, #928): that pass draws it. True
|
|
350
|
+
* otherwise, also when there is nothing to draw or nothing will draw it.
|
|
351
|
+
*/
|
|
352
|
+
protected renderGroup(group: CanvasEntry[], generation: number, viewport: ViewportState): Promise<boolean>;
|
|
345
353
|
protected renderGroupOnce(group: CanvasEntry[], generation: number, viewport: ViewportState, clip: ClipEntry): Promise<void>;
|
|
346
354
|
protected renderRemainingViaIdle(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
347
355
|
protected yieldUntilIdle(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -4115,9 +4115,9 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
4115
4115
|
for (const [trackId, trackCanvases] of canvasesByTrack) {
|
|
4116
4116
|
try {
|
|
4117
4117
|
const tiers = classifyViewport(trackCanvases, viewport);
|
|
4118
|
-
await this.renderTier(tiers.viewport, generation, viewport);
|
|
4118
|
+
const viewportDrawn = await this.renderTier(tiers.viewport, generation, viewport);
|
|
4119
4119
|
if (this.generation !== generation || this.disposed) return;
|
|
4120
|
-
if (!this.readyDispatched.has(trackId)) {
|
|
4120
|
+
if (viewportDrawn && !this.readyDispatched.has(trackId)) {
|
|
4121
4121
|
this.readyDispatched.add(trackId);
|
|
4122
4122
|
this.dispatchEvent(
|
|
4123
4123
|
new CustomEvent("viewport-ready", { detail: { trackId, generation } })
|
|
@@ -4129,7 +4129,7 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
4129
4129
|
} catch (err) {
|
|
4130
4130
|
if (this.generation !== generation || this.disposed) return;
|
|
4131
4131
|
if (err instanceof SpectrogramAbortError) {
|
|
4132
|
-
|
|
4132
|
+
continue;
|
|
4133
4133
|
}
|
|
4134
4134
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
4135
4135
|
console.warn(
|
|
@@ -4143,34 +4143,47 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
4143
4143
|
}
|
|
4144
4144
|
}
|
|
4145
4145
|
}
|
|
4146
|
+
/** Renders the tier's groups; false when a group waits for a render already scheduled. */
|
|
4146
4147
|
async renderTier(canvases, generation, viewport) {
|
|
4147
|
-
|
|
4148
|
+
let drawn = true;
|
|
4149
|
+
if (canvases.length === 0) return drawn;
|
|
4148
4150
|
const groups = groupRenderableChunks(canvases);
|
|
4149
4151
|
for (const group of groups) {
|
|
4150
|
-
if (this.generation !== generation || this.disposed) return;
|
|
4151
|
-
await this.renderGroup(group, generation, viewport);
|
|
4152
|
+
if (this.generation !== generation || this.disposed) return drawn;
|
|
4153
|
+
if (!await this.renderGroup(group, generation, viewport)) drawn = false;
|
|
4152
4154
|
}
|
|
4155
|
+
return drawn;
|
|
4153
4156
|
}
|
|
4157
|
+
/**
|
|
4158
|
+
* Renders one group. Returns false when its computation was dropped and
|
|
4159
|
+
* another pass is queued (registerClip queues one for a clip registered again
|
|
4160
|
+
* mid-computation that still has canvases, #928): that pass draws it. True
|
|
4161
|
+
* otherwise, also when there is nothing to draw or nothing will draw it.
|
|
4162
|
+
*/
|
|
4154
4163
|
async renderGroup(group, generation, viewport) {
|
|
4155
|
-
if (group.length === 0) return;
|
|
4164
|
+
if (group.length === 0) return true;
|
|
4156
4165
|
const first = group[0];
|
|
4157
4166
|
const clip = this.clips.get(first.clipId);
|
|
4158
4167
|
if (!clip) {
|
|
4159
4168
|
console.warn(
|
|
4160
4169
|
"[dawcore-spectrogram] renderGroup: no clip audio for " + first.clipId + " (canvas " + first.canvasId + ") \u2014 canvas will stay black until registerClip is called"
|
|
4161
4170
|
);
|
|
4162
|
-
return;
|
|
4171
|
+
return true;
|
|
4163
4172
|
}
|
|
4164
4173
|
try {
|
|
4165
4174
|
await this.renderGroupOnce(group, generation, viewport, clip);
|
|
4175
|
+
return true;
|
|
4166
4176
|
} catch (err) {
|
|
4167
4177
|
if (this.generation !== generation || this.disposed) throw err;
|
|
4178
|
+
if (err instanceof SpectrogramAbortError) {
|
|
4179
|
+
return !this.renderQueued;
|
|
4180
|
+
}
|
|
4168
4181
|
if (err instanceof Error && err.message.includes("cache-miss")) {
|
|
4169
4182
|
console.warn(
|
|
4170
4183
|
"[dawcore-spectrogram] FFT cache entry evicted between compute and render \u2014 retrying group once"
|
|
4171
4184
|
);
|
|
4172
4185
|
await this.renderGroupOnce(group, generation, viewport, clip);
|
|
4173
|
-
return;
|
|
4186
|
+
return true;
|
|
4174
4187
|
}
|
|
4175
4188
|
throw err;
|
|
4176
4189
|
}
|