@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.mjs
CHANGED
|
@@ -4069,9 +4069,9 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
4069
4069
|
for (const [trackId, trackCanvases] of canvasesByTrack) {
|
|
4070
4070
|
try {
|
|
4071
4071
|
const tiers = classifyViewport(trackCanvases, viewport);
|
|
4072
|
-
await this.renderTier(tiers.viewport, generation, viewport);
|
|
4072
|
+
const viewportDrawn = await this.renderTier(tiers.viewport, generation, viewport);
|
|
4073
4073
|
if (this.generation !== generation || this.disposed) return;
|
|
4074
|
-
if (!this.readyDispatched.has(trackId)) {
|
|
4074
|
+
if (viewportDrawn && !this.readyDispatched.has(trackId)) {
|
|
4075
4075
|
this.readyDispatched.add(trackId);
|
|
4076
4076
|
this.dispatchEvent(
|
|
4077
4077
|
new CustomEvent("viewport-ready", { detail: { trackId, generation } })
|
|
@@ -4083,7 +4083,7 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
4083
4083
|
} catch (err) {
|
|
4084
4084
|
if (this.generation !== generation || this.disposed) return;
|
|
4085
4085
|
if (err instanceof SpectrogramAbortError) {
|
|
4086
|
-
|
|
4086
|
+
continue;
|
|
4087
4087
|
}
|
|
4088
4088
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
4089
4089
|
console.warn(
|
|
@@ -4097,34 +4097,47 @@ var SpectrogramOrchestrator = class extends EventTarget {
|
|
|
4097
4097
|
}
|
|
4098
4098
|
}
|
|
4099
4099
|
}
|
|
4100
|
+
/** Renders the tier's groups; false when a group waits for a render already scheduled. */
|
|
4100
4101
|
async renderTier(canvases, generation, viewport) {
|
|
4101
|
-
|
|
4102
|
+
let drawn = true;
|
|
4103
|
+
if (canvases.length === 0) return drawn;
|
|
4102
4104
|
const groups = groupRenderableChunks(canvases);
|
|
4103
4105
|
for (const group of groups) {
|
|
4104
|
-
if (this.generation !== generation || this.disposed) return;
|
|
4105
|
-
await this.renderGroup(group, generation, viewport);
|
|
4106
|
+
if (this.generation !== generation || this.disposed) return drawn;
|
|
4107
|
+
if (!await this.renderGroup(group, generation, viewport)) drawn = false;
|
|
4106
4108
|
}
|
|
4109
|
+
return drawn;
|
|
4107
4110
|
}
|
|
4111
|
+
/**
|
|
4112
|
+
* Renders one group. Returns false when its computation was dropped and
|
|
4113
|
+
* another pass is queued (registerClip queues one for a clip registered again
|
|
4114
|
+
* mid-computation that still has canvases, #928): that pass draws it. True
|
|
4115
|
+
* otherwise, also when there is nothing to draw or nothing will draw it.
|
|
4116
|
+
*/
|
|
4108
4117
|
async renderGroup(group, generation, viewport) {
|
|
4109
|
-
if (group.length === 0) return;
|
|
4118
|
+
if (group.length === 0) return true;
|
|
4110
4119
|
const first = group[0];
|
|
4111
4120
|
const clip = this.clips.get(first.clipId);
|
|
4112
4121
|
if (!clip) {
|
|
4113
4122
|
console.warn(
|
|
4114
4123
|
"[dawcore-spectrogram] renderGroup: no clip audio for " + first.clipId + " (canvas " + first.canvasId + ") \u2014 canvas will stay black until registerClip is called"
|
|
4115
4124
|
);
|
|
4116
|
-
return;
|
|
4125
|
+
return true;
|
|
4117
4126
|
}
|
|
4118
4127
|
try {
|
|
4119
4128
|
await this.renderGroupOnce(group, generation, viewport, clip);
|
|
4129
|
+
return true;
|
|
4120
4130
|
} catch (err) {
|
|
4121
4131
|
if (this.generation !== generation || this.disposed) throw err;
|
|
4132
|
+
if (err instanceof SpectrogramAbortError) {
|
|
4133
|
+
return !this.renderQueued;
|
|
4134
|
+
}
|
|
4122
4135
|
if (err instanceof Error && err.message.includes("cache-miss")) {
|
|
4123
4136
|
console.warn(
|
|
4124
4137
|
"[dawcore-spectrogram] FFT cache entry evicted between compute and render \u2014 retrying group once"
|
|
4125
4138
|
);
|
|
4126
4139
|
await this.renderGroupOnce(group, generation, viewport, clip);
|
|
4127
|
-
return;
|
|
4140
|
+
return true;
|
|
4128
4141
|
}
|
|
4129
4142
|
throw err;
|
|
4130
4143
|
}
|