@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
|
@@ -194,8 +194,15 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
194
194
|
protected scheduleRender(): void;
|
|
195
195
|
protected runRenderLoop(): Promise<void>;
|
|
196
196
|
protected runRender(generation: number): Promise<void>;
|
|
197
|
-
|
|
198
|
-
protected
|
|
197
|
+
/** Renders the tier's groups; false when a group waits for a render already scheduled. */
|
|
198
|
+
protected renderTier(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<boolean>;
|
|
199
|
+
/**
|
|
200
|
+
* Renders one group. Returns false when its computation was dropped and
|
|
201
|
+
* another pass is queued (registerClip queues one for a clip registered again
|
|
202
|
+
* mid-computation that still has canvases, #928): that pass draws it. True
|
|
203
|
+
* otherwise, also when there is nothing to draw or nothing will draw it.
|
|
204
|
+
*/
|
|
205
|
+
protected renderGroup(group: CanvasEntry[], generation: number, viewport: ViewportState): Promise<boolean>;
|
|
199
206
|
protected renderGroupOnce(group: CanvasEntry[], generation: number, viewport: ViewportState, clip: ClipEntry): Promise<void>;
|
|
200
207
|
protected renderRemainingViaIdle(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
201
208
|
protected yieldUntilIdle(): Promise<void>;
|
|
@@ -3793,9 +3793,9 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
3793
3793
|
for (const [trackId, trackCanvases] of canvasesByTrack) {
|
|
3794
3794
|
try {
|
|
3795
3795
|
const tiers = classifyViewport(trackCanvases, viewport);
|
|
3796
|
-
await this.renderTier(tiers.viewport, generation, viewport);
|
|
3796
|
+
const viewportDrawn = await this.renderTier(tiers.viewport, generation, viewport);
|
|
3797
3797
|
if (this.generation !== generation || this.disposed) return;
|
|
3798
|
-
if (!this.readyDispatched.has(trackId)) {
|
|
3798
|
+
if (viewportDrawn && !this.readyDispatched.has(trackId)) {
|
|
3799
3799
|
this.readyDispatched.add(trackId);
|
|
3800
3800
|
this.dispatchEvent(
|
|
3801
3801
|
new CustomEvent("viewport-ready", { detail: { trackId, generation } })
|
|
@@ -3807,7 +3807,7 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
3807
3807
|
} catch (err) {
|
|
3808
3808
|
if (this.generation !== generation || this.disposed) return;
|
|
3809
3809
|
if (err instanceof SpectrogramAbortError) {
|
|
3810
|
-
|
|
3810
|
+
continue;
|
|
3811
3811
|
}
|
|
3812
3812
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
3813
3813
|
console.warn(
|
|
@@ -3821,34 +3821,47 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
3821
3821
|
}
|
|
3822
3822
|
}
|
|
3823
3823
|
}
|
|
3824
|
+
/** Renders the tier's groups; false when a group waits for a render already scheduled. */
|
|
3824
3825
|
async renderTier(canvases, generation, viewport) {
|
|
3825
|
-
|
|
3826
|
+
let drawn = true;
|
|
3827
|
+
if (canvases.length === 0) return drawn;
|
|
3826
3828
|
const groups = groupRenderableChunks(canvases);
|
|
3827
3829
|
for (const group of groups) {
|
|
3828
|
-
if (this.generation !== generation || this.disposed) return;
|
|
3829
|
-
await this.renderGroup(group, generation, viewport);
|
|
3830
|
+
if (this.generation !== generation || this.disposed) return drawn;
|
|
3831
|
+
if (!await this.renderGroup(group, generation, viewport)) drawn = false;
|
|
3830
3832
|
}
|
|
3833
|
+
return drawn;
|
|
3831
3834
|
}
|
|
3835
|
+
/**
|
|
3836
|
+
* Renders one group. Returns false when its computation was dropped and
|
|
3837
|
+
* another pass is queued (registerClip queues one for a clip registered again
|
|
3838
|
+
* mid-computation that still has canvases, #928): that pass draws it. True
|
|
3839
|
+
* otherwise, also when there is nothing to draw or nothing will draw it.
|
|
3840
|
+
*/
|
|
3832
3841
|
async renderGroup(group, generation, viewport) {
|
|
3833
|
-
if (group.length === 0) return;
|
|
3842
|
+
if (group.length === 0) return true;
|
|
3834
3843
|
const first = group[0];
|
|
3835
3844
|
const clip = this.clips.get(first.clipId);
|
|
3836
3845
|
if (!clip) {
|
|
3837
3846
|
console.warn(
|
|
3838
3847
|
"[dawcore-spectrogram] renderGroup: no clip audio for " + first.clipId + " (canvas " + first.canvasId + ") \u2014 canvas will stay black until registerClip is called"
|
|
3839
3848
|
);
|
|
3840
|
-
return;
|
|
3849
|
+
return true;
|
|
3841
3850
|
}
|
|
3842
3851
|
try {
|
|
3843
3852
|
await this.renderGroupOnce(group, generation, viewport, clip);
|
|
3853
|
+
return true;
|
|
3844
3854
|
} catch (err) {
|
|
3845
3855
|
if (this.generation !== generation || this.disposed) throw err;
|
|
3856
|
+
if (err instanceof SpectrogramAbortError) {
|
|
3857
|
+
return !this.renderQueued;
|
|
3858
|
+
}
|
|
3846
3859
|
if (err instanceof Error && err.message.includes("cache-miss")) {
|
|
3847
3860
|
console.warn(
|
|
3848
3861
|
"[dawcore-spectrogram] FFT cache entry evicted between compute and render \u2014 retrying group once"
|
|
3849
3862
|
);
|
|
3850
3863
|
await this.renderGroupOnce(group, generation, viewport, clip);
|
|
3851
|
-
return;
|
|
3864
|
+
return true;
|
|
3852
3865
|
}
|
|
3853
3866
|
throw err;
|
|
3854
3867
|
}
|