@dawcore/spectrogram 0.0.3 → 0.0.4
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 +50 -6
- package/dist/index.d.mts +96 -1
- package/dist/index.d.ts +96 -1
- package/dist/index.js +223 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +224 -51
- package/dist/index.mjs.map +1 -1
- package/dist/orchestrator/index.d.mts +51 -1
- package/dist/orchestrator/index.mjs +193 -51
- package/dist/orchestrator/index.mjs.map +1 -1
- package/dist/worker/spectrogram.worker.mjs +111 -37
- package/dist/worker/spectrogram.worker.mjs.map +1 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -1,14 +1,58 @@
|
|
|
1
1
|
# @dawcore/spectrogram
|
|
2
2
|
|
|
3
|
-
Framework-agnostic spectrogram computation,
|
|
3
|
+
Framework-agnostic spectrogram computation, Web Worker, and viewport-aware rendering orchestrator for the dawcore family.
|
|
4
4
|
|
|
5
|
-
Used by `@dawcore/components` (the Lit web component layer) and `@waveform-playlist/spectrogram` (the React Provider).
|
|
5
|
+
Used by `@dawcore/components` (the Lit web component layer, behind `<daw-track render-mode="spectrogram">`) and `@waveform-playlist/spectrogram` (the React Provider).
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @dawcore/spectrogram
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
No peer dependencies. If you use `@dawcore/components`, you don't install this directly — it's a regular dependency of that package.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { computeSpectrogram, getColorMap } from '@dawcore/spectrogram';
|
|
19
|
+
|
|
20
|
+
// Pure, synchronous FFT — magnitudes per time/frequency bin
|
|
21
|
+
const data = computeSpectrogram(audioBuffer, { fftSize: 2048 });
|
|
22
|
+
const lut = getColorMap('magma');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For rendering inside an app, use the worker and orchestrator instead of blocking the main thread:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { SpectrogramOrchestrator } from '@dawcore/spectrogram/orchestrator';
|
|
29
|
+
|
|
30
|
+
const orchestrator = new SpectrogramOrchestrator({
|
|
31
|
+
workerFactory: () =>
|
|
32
|
+
new Worker(new URL('@dawcore/spectrogram/worker/spectrogram.worker', import.meta.url), {
|
|
33
|
+
type: 'module',
|
|
34
|
+
}),
|
|
35
|
+
config: { fftSize: 2048 },
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
orchestrator.registerClip(/* audio data */);
|
|
39
|
+
orchestrator.registerCanvas(/* OffscreenCanvas + metadata */);
|
|
40
|
+
orchestrator.setViewport(/* visible range */);
|
|
41
|
+
orchestrator.addEventListener('viewport-ready', (e) => console.log(e));
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The orchestrator renders in three tiers (visible viewport first, then a 25% overscan buffer, then the rest during idle time), aborts stale work when the viewport, config, or color map changes, and groups contiguous chunks so non-adjacent regions never trigger one oversized FFT.
|
|
45
|
+
|
|
46
|
+
## Entry Points
|
|
47
|
+
|
|
48
|
+
- `@dawcore/spectrogram` — `computeSpectrogram`, `computeSpectrogramMono`, `getColorMap`, `getFrequencyScale`, worker factories (`createSpectrogramWorker`, `createSpectrogramWorkerPool`, `SpectrogramAbortError`), and the orchestrator re-exports
|
|
49
|
+
- `@dawcore/spectrogram/worker/spectrogram.worker` — the Worker module URL target (resolve with `new URL(..., import.meta.url)`)
|
|
50
|
+
- `@dawcore/spectrogram/orchestrator` — `SpectrogramOrchestrator` and helpers (`classifyViewport`, `groupContiguousChunks`, `ColorLUTCache`) without the computation/worker graph, for consumers with their own FFT pipeline
|
|
51
|
+
|
|
52
|
+
## Examples & Documentation
|
|
53
|
+
|
|
54
|
+
- [`examples/dawcore-native/spectrogram.html`](https://github.com/naomiaro/waveform-playlist/tree/main/examples/dawcore-native) — spectrogram tracks in `<daw-editor>` (`pnpm example:dawcore-native`)
|
|
55
|
+
- Guides: [naomiaro.github.io/waveform-playlist](https://naomiaro.github.io/waveform-playlist/)
|
|
12
56
|
|
|
13
57
|
## License
|
|
14
58
|
|
package/dist/index.d.mts
CHANGED
|
@@ -47,6 +47,51 @@ type FrequencyScaleName = 'linear' | 'logarithmic' | 'mel' | 'bark' | 'erb';
|
|
|
47
47
|
*/
|
|
48
48
|
declare function getFrequencyScale(name: FrequencyScaleName): (f: number, minF: number, maxF: number) => number;
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Pure geometry for mapping rendered pixel columns to FFT frames.
|
|
52
|
+
*/
|
|
53
|
+
interface PixelColumnToFrameParams {
|
|
54
|
+
/** Clip-relative pixel column (chunk pixel offset + x within the canvas). */
|
|
55
|
+
pixelX: number;
|
|
56
|
+
samplesPerPixel: number;
|
|
57
|
+
/** The clip's start position within its audio file (AudioClip.offsetSamples). */
|
|
58
|
+
clipOffsetSamples: number;
|
|
59
|
+
/** File-absolute sample position where the cached FFT data begins. */
|
|
60
|
+
fftStartSample: number;
|
|
61
|
+
hopSize: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The file sample displayed at clip-relative pixel x is
|
|
65
|
+
* `clipOffsetSamples + x * samplesPerPixel`; the FFT frame holding it starts
|
|
66
|
+
* at `fftStartSample + frame * hopSize`. Omitting `clipOffsetSamples` (the
|
|
67
|
+
* pre-#554 behavior) shifts every trimmed clip's display by its offset.
|
|
68
|
+
*/
|
|
69
|
+
declare function pixelColumnToFrame(params: PixelColumnToFrameParams): number;
|
|
70
|
+
interface PixelRowToBinParams {
|
|
71
|
+
/** Vertical position, bottom-up: `1 - y / canvasHeight` ∈ (0, 1]. */
|
|
72
|
+
normalizedY: number;
|
|
73
|
+
frequencyBinCount: number;
|
|
74
|
+
sampleRate: number;
|
|
75
|
+
minFrequency: number;
|
|
76
|
+
/** Resolved maximum frequency (> 0); callers default 0 → sampleRate / 2. */
|
|
77
|
+
maxFrequency: number;
|
|
78
|
+
/** Frequency scale mapping (Hz, minF, maxF) → [0, 1]. */
|
|
79
|
+
scaleFn: (f: number, minF: number, maxF: number) => number;
|
|
80
|
+
/** Linear scale uses a direct O(1) mapping instead of the binary search. */
|
|
81
|
+
isLinear: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Map a canvas row to the FFT bin displayed there.
|
|
85
|
+
*
|
|
86
|
+
* Linear: direct inversion of the scale — `freq = minF + normalizedY·(maxF −
|
|
87
|
+
* minF)` — so the configured frequency range is honored exactly like the
|
|
88
|
+
* non-linear scales (pre-#557 the linear fast path always spanned 0..Nyquist).
|
|
89
|
+
* Non-linear: binary search for the first bin whose scaled frequency reaches
|
|
90
|
+
* `normalizedY`. Both paths clamp to the last bin so the top row
|
|
91
|
+
* (normalizedY === 1) never falls out of range.
|
|
92
|
+
*/
|
|
93
|
+
declare function pixelRowToBin(params: PixelRowToBinParams): number;
|
|
94
|
+
|
|
50
95
|
/**
|
|
51
96
|
* Error thrown when a spectrogram computation is aborted due to a generation change.
|
|
52
97
|
* Use `instanceof SpectrogramAbortError` instead of string matching on error messages.
|
|
@@ -90,6 +135,12 @@ interface SpectrogramWorkerApi {
|
|
|
90
135
|
cacheKey: string;
|
|
91
136
|
}>;
|
|
92
137
|
renderChunks(params: SpectrogramWorkerRenderChunksParams, generation?: number): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Cancel in-flight work from generations OLDER than `generation`.
|
|
140
|
+
* Pass the NEW (current) generation after bumping — the worker treats work
|
|
141
|
+
* as stale iff `workGeneration < latestAbortedGeneration`, so passing the
|
|
142
|
+
* previous generation cancels nothing (#555).
|
|
143
|
+
*/
|
|
93
144
|
abortGeneration(generation: number): void;
|
|
94
145
|
registerCanvas(canvasId: string, canvas: OffscreenCanvas): void;
|
|
95
146
|
unregisterCanvas(canvasId: string): void;
|
|
@@ -169,6 +220,13 @@ interface CanvasRegistration {
|
|
|
169
220
|
readonly trackId: string;
|
|
170
221
|
readonly channelIndex: number;
|
|
171
222
|
readonly chunkIndex: number;
|
|
223
|
+
/**
|
|
224
|
+
* TIMELINE-absolute pixel where this chunk starts. Layout contract: every
|
|
225
|
+
* canvas of a clip must satisfy
|
|
226
|
+
* `globalPixelOffset === clipOriginPx + chunkIndex * MAX_CANVAS_WIDTH` —
|
|
227
|
+
* renderGroup's clip-relative sample math depends on it (#554), and
|
|
228
|
+
* registerCanvas warns when a registration violates it.
|
|
229
|
+
*/
|
|
172
230
|
readonly globalPixelOffset: number;
|
|
173
231
|
readonly widthPx: number;
|
|
174
232
|
readonly heightPx: number;
|
|
@@ -202,6 +260,11 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
202
260
|
protected colorLUT: ColorLUTCache;
|
|
203
261
|
protected disposed: boolean;
|
|
204
262
|
protected renderInFlight: boolean;
|
|
263
|
+
protected renderQueued: boolean;
|
|
264
|
+
protected clipOrigins: Map<string, {
|
|
265
|
+
originPx: number;
|
|
266
|
+
canvasCount: number;
|
|
267
|
+
}>;
|
|
205
268
|
protected readyDispatched: Set<string>;
|
|
206
269
|
constructor(opts: SpectrogramOrchestratorOptions);
|
|
207
270
|
registerClip(reg: ClipRegistration): void;
|
|
@@ -212,11 +275,27 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
212
275
|
setConfig(config: SpectrogramConfig): void;
|
|
213
276
|
setColorMap(colorMap: ColorMapValue): void;
|
|
214
277
|
setDevicePixelRatio(dpr: number): void;
|
|
278
|
+
/**
|
|
279
|
+
* Start a new render generation and cancel in-flight work from older ones.
|
|
280
|
+
*
|
|
281
|
+
* The worker treats work as stale iff `generation < latestGeneration`, so
|
|
282
|
+
* the abort message must carry the NEW generation — passing the previous
|
|
283
|
+
* one leaves its in-flight FFTs running to completion (#555).
|
|
284
|
+
*/
|
|
285
|
+
protected bumpGenerationAndAbortStale(): void;
|
|
215
286
|
dispose(): void;
|
|
287
|
+
/**
|
|
288
|
+
* Coalesce render requests: `renderInFlight` is held for the WHOLE async
|
|
289
|
+
* render, not just until the microtask fires — a request arriving
|
|
290
|
+
* mid-render (e.g. a late registerCanvas) queues one follow-up run instead
|
|
291
|
+
* of starting a concurrent runRender for the same generation (#558).
|
|
292
|
+
*/
|
|
216
293
|
protected scheduleRender(): void;
|
|
294
|
+
protected runRenderLoop(): Promise<void>;
|
|
217
295
|
protected runRender(generation: number): Promise<void>;
|
|
218
296
|
protected renderTier(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
219
297
|
protected renderGroup(group: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
298
|
+
protected renderGroupOnce(group: CanvasEntry[], generation: number, viewport: ViewportState, clip: ClipEntry): Promise<void>;
|
|
220
299
|
protected renderRemainingViaIdle(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
221
300
|
protected yieldUntilIdle(): Promise<void>;
|
|
222
301
|
}
|
|
@@ -236,6 +315,10 @@ interface ViewportReadyDetail {
|
|
|
236
315
|
interface ChunkLike {
|
|
237
316
|
chunkIndex: number;
|
|
238
317
|
}
|
|
318
|
+
interface RenderableChunkLike extends ChunkLike {
|
|
319
|
+
clipId: string;
|
|
320
|
+
channelIndex: number;
|
|
321
|
+
}
|
|
239
322
|
/**
|
|
240
323
|
* Group a list of chunks into runs of contiguous chunk indices.
|
|
241
324
|
*
|
|
@@ -247,5 +330,17 @@ interface ChunkLike {
|
|
|
247
330
|
* two smaller FFTs (10–11, 14–15) totaling ~32K frames.
|
|
248
331
|
*/
|
|
249
332
|
declare function groupContiguousChunks<T extends ChunkLike>(chunks: T[]): T[][];
|
|
333
|
+
/**
|
|
334
|
+
* Group render canvases into runs of contiguous chunk indices, partitioned by
|
|
335
|
+
* `(clipId, channelIndex)` first.
|
|
336
|
+
*
|
|
337
|
+
* A track's canvases span multiple channels (one <daw-spectrogram> per channel,
|
|
338
|
+
* chunk indices shared) and multiple clips (chunk indices restart at 0 per
|
|
339
|
+
* clip). Grouping by chunk index alone interleaves them — e.g. stereo
|
|
340
|
+
* [ch0k0, ch1k0, ch0k1, ch1k1] yields the mixed group [ch1k0, ch0k1], which
|
|
341
|
+
* renderGroup then routes to a single channel's worker with a single clip's
|
|
342
|
+
* FFT data (issue #553).
|
|
343
|
+
*/
|
|
344
|
+
declare function groupRenderableChunks<T extends RenderableChunkLike>(chunks: T[]): T[][];
|
|
250
345
|
|
|
251
|
-
export { type CanvasMeta, type CanvasRegistration, type ChunkLike, type ClassifiedTiers, type ClipRegistration, ColorLUTCache, type FrequencyScaleName, SpectrogramAbortError, SpectrogramOrchestrator, type SpectrogramOrchestratorOptions, type SpectrogramWorkerApi, type SpectrogramWorkerFFTParams, type SpectrogramWorkerRenderChunksParams, type ViewportBounds, type ViewportReadyDetail, type ViewportState, classifyViewport, computeSpectrogram, computeSpectrogramMono, createSpectrogramWorker, createSpectrogramWorkerPool, getColorMap, getFrequencyScale, groupContiguousChunks };
|
|
346
|
+
export { type CanvasMeta, type CanvasRegistration, type ChunkLike, type ClassifiedTiers, type ClipRegistration, ColorLUTCache, type FrequencyScaleName, type PixelColumnToFrameParams, type PixelRowToBinParams, type RenderableChunkLike, SpectrogramAbortError, SpectrogramOrchestrator, type SpectrogramOrchestratorOptions, type SpectrogramWorkerApi, type SpectrogramWorkerFFTParams, type SpectrogramWorkerRenderChunksParams, type ViewportBounds, type ViewportReadyDetail, type ViewportState, classifyViewport, computeSpectrogram, computeSpectrogramMono, createSpectrogramWorker, createSpectrogramWorkerPool, getColorMap, getFrequencyScale, groupContiguousChunks, groupRenderableChunks, pixelColumnToFrame, pixelRowToBin };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,51 @@ type FrequencyScaleName = 'linear' | 'logarithmic' | 'mel' | 'bark' | 'erb';
|
|
|
47
47
|
*/
|
|
48
48
|
declare function getFrequencyScale(name: FrequencyScaleName): (f: number, minF: number, maxF: number) => number;
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Pure geometry for mapping rendered pixel columns to FFT frames.
|
|
52
|
+
*/
|
|
53
|
+
interface PixelColumnToFrameParams {
|
|
54
|
+
/** Clip-relative pixel column (chunk pixel offset + x within the canvas). */
|
|
55
|
+
pixelX: number;
|
|
56
|
+
samplesPerPixel: number;
|
|
57
|
+
/** The clip's start position within its audio file (AudioClip.offsetSamples). */
|
|
58
|
+
clipOffsetSamples: number;
|
|
59
|
+
/** File-absolute sample position where the cached FFT data begins. */
|
|
60
|
+
fftStartSample: number;
|
|
61
|
+
hopSize: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The file sample displayed at clip-relative pixel x is
|
|
65
|
+
* `clipOffsetSamples + x * samplesPerPixel`; the FFT frame holding it starts
|
|
66
|
+
* at `fftStartSample + frame * hopSize`. Omitting `clipOffsetSamples` (the
|
|
67
|
+
* pre-#554 behavior) shifts every trimmed clip's display by its offset.
|
|
68
|
+
*/
|
|
69
|
+
declare function pixelColumnToFrame(params: PixelColumnToFrameParams): number;
|
|
70
|
+
interface PixelRowToBinParams {
|
|
71
|
+
/** Vertical position, bottom-up: `1 - y / canvasHeight` ∈ (0, 1]. */
|
|
72
|
+
normalizedY: number;
|
|
73
|
+
frequencyBinCount: number;
|
|
74
|
+
sampleRate: number;
|
|
75
|
+
minFrequency: number;
|
|
76
|
+
/** Resolved maximum frequency (> 0); callers default 0 → sampleRate / 2. */
|
|
77
|
+
maxFrequency: number;
|
|
78
|
+
/** Frequency scale mapping (Hz, minF, maxF) → [0, 1]. */
|
|
79
|
+
scaleFn: (f: number, minF: number, maxF: number) => number;
|
|
80
|
+
/** Linear scale uses a direct O(1) mapping instead of the binary search. */
|
|
81
|
+
isLinear: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Map a canvas row to the FFT bin displayed there.
|
|
85
|
+
*
|
|
86
|
+
* Linear: direct inversion of the scale — `freq = minF + normalizedY·(maxF −
|
|
87
|
+
* minF)` — so the configured frequency range is honored exactly like the
|
|
88
|
+
* non-linear scales (pre-#557 the linear fast path always spanned 0..Nyquist).
|
|
89
|
+
* Non-linear: binary search for the first bin whose scaled frequency reaches
|
|
90
|
+
* `normalizedY`. Both paths clamp to the last bin so the top row
|
|
91
|
+
* (normalizedY === 1) never falls out of range.
|
|
92
|
+
*/
|
|
93
|
+
declare function pixelRowToBin(params: PixelRowToBinParams): number;
|
|
94
|
+
|
|
50
95
|
/**
|
|
51
96
|
* Error thrown when a spectrogram computation is aborted due to a generation change.
|
|
52
97
|
* Use `instanceof SpectrogramAbortError` instead of string matching on error messages.
|
|
@@ -90,6 +135,12 @@ interface SpectrogramWorkerApi {
|
|
|
90
135
|
cacheKey: string;
|
|
91
136
|
}>;
|
|
92
137
|
renderChunks(params: SpectrogramWorkerRenderChunksParams, generation?: number): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Cancel in-flight work from generations OLDER than `generation`.
|
|
140
|
+
* Pass the NEW (current) generation after bumping — the worker treats work
|
|
141
|
+
* as stale iff `workGeneration < latestAbortedGeneration`, so passing the
|
|
142
|
+
* previous generation cancels nothing (#555).
|
|
143
|
+
*/
|
|
93
144
|
abortGeneration(generation: number): void;
|
|
94
145
|
registerCanvas(canvasId: string, canvas: OffscreenCanvas): void;
|
|
95
146
|
unregisterCanvas(canvasId: string): void;
|
|
@@ -169,6 +220,13 @@ interface CanvasRegistration {
|
|
|
169
220
|
readonly trackId: string;
|
|
170
221
|
readonly channelIndex: number;
|
|
171
222
|
readonly chunkIndex: number;
|
|
223
|
+
/**
|
|
224
|
+
* TIMELINE-absolute pixel where this chunk starts. Layout contract: every
|
|
225
|
+
* canvas of a clip must satisfy
|
|
226
|
+
* `globalPixelOffset === clipOriginPx + chunkIndex * MAX_CANVAS_WIDTH` —
|
|
227
|
+
* renderGroup's clip-relative sample math depends on it (#554), and
|
|
228
|
+
* registerCanvas warns when a registration violates it.
|
|
229
|
+
*/
|
|
172
230
|
readonly globalPixelOffset: number;
|
|
173
231
|
readonly widthPx: number;
|
|
174
232
|
readonly heightPx: number;
|
|
@@ -202,6 +260,11 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
202
260
|
protected colorLUT: ColorLUTCache;
|
|
203
261
|
protected disposed: boolean;
|
|
204
262
|
protected renderInFlight: boolean;
|
|
263
|
+
protected renderQueued: boolean;
|
|
264
|
+
protected clipOrigins: Map<string, {
|
|
265
|
+
originPx: number;
|
|
266
|
+
canvasCount: number;
|
|
267
|
+
}>;
|
|
205
268
|
protected readyDispatched: Set<string>;
|
|
206
269
|
constructor(opts: SpectrogramOrchestratorOptions);
|
|
207
270
|
registerClip(reg: ClipRegistration): void;
|
|
@@ -212,11 +275,27 @@ declare class SpectrogramOrchestrator extends EventTarget {
|
|
|
212
275
|
setConfig(config: SpectrogramConfig): void;
|
|
213
276
|
setColorMap(colorMap: ColorMapValue): void;
|
|
214
277
|
setDevicePixelRatio(dpr: number): void;
|
|
278
|
+
/**
|
|
279
|
+
* Start a new render generation and cancel in-flight work from older ones.
|
|
280
|
+
*
|
|
281
|
+
* The worker treats work as stale iff `generation < latestGeneration`, so
|
|
282
|
+
* the abort message must carry the NEW generation — passing the previous
|
|
283
|
+
* one leaves its in-flight FFTs running to completion (#555).
|
|
284
|
+
*/
|
|
285
|
+
protected bumpGenerationAndAbortStale(): void;
|
|
215
286
|
dispose(): void;
|
|
287
|
+
/**
|
|
288
|
+
* Coalesce render requests: `renderInFlight` is held for the WHOLE async
|
|
289
|
+
* render, not just until the microtask fires — a request arriving
|
|
290
|
+
* mid-render (e.g. a late registerCanvas) queues one follow-up run instead
|
|
291
|
+
* of starting a concurrent runRender for the same generation (#558).
|
|
292
|
+
*/
|
|
216
293
|
protected scheduleRender(): void;
|
|
294
|
+
protected runRenderLoop(): Promise<void>;
|
|
217
295
|
protected runRender(generation: number): Promise<void>;
|
|
218
296
|
protected renderTier(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
219
297
|
protected renderGroup(group: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
298
|
+
protected renderGroupOnce(group: CanvasEntry[], generation: number, viewport: ViewportState, clip: ClipEntry): Promise<void>;
|
|
220
299
|
protected renderRemainingViaIdle(canvases: CanvasEntry[], generation: number, viewport: ViewportState): Promise<void>;
|
|
221
300
|
protected yieldUntilIdle(): Promise<void>;
|
|
222
301
|
}
|
|
@@ -236,6 +315,10 @@ interface ViewportReadyDetail {
|
|
|
236
315
|
interface ChunkLike {
|
|
237
316
|
chunkIndex: number;
|
|
238
317
|
}
|
|
318
|
+
interface RenderableChunkLike extends ChunkLike {
|
|
319
|
+
clipId: string;
|
|
320
|
+
channelIndex: number;
|
|
321
|
+
}
|
|
239
322
|
/**
|
|
240
323
|
* Group a list of chunks into runs of contiguous chunk indices.
|
|
241
324
|
*
|
|
@@ -247,5 +330,17 @@ interface ChunkLike {
|
|
|
247
330
|
* two smaller FFTs (10–11, 14–15) totaling ~32K frames.
|
|
248
331
|
*/
|
|
249
332
|
declare function groupContiguousChunks<T extends ChunkLike>(chunks: T[]): T[][];
|
|
333
|
+
/**
|
|
334
|
+
* Group render canvases into runs of contiguous chunk indices, partitioned by
|
|
335
|
+
* `(clipId, channelIndex)` first.
|
|
336
|
+
*
|
|
337
|
+
* A track's canvases span multiple channels (one <daw-spectrogram> per channel,
|
|
338
|
+
* chunk indices shared) and multiple clips (chunk indices restart at 0 per
|
|
339
|
+
* clip). Grouping by chunk index alone interleaves them — e.g. stereo
|
|
340
|
+
* [ch0k0, ch1k0, ch0k1, ch1k1] yields the mixed group [ch1k0, ch0k1], which
|
|
341
|
+
* renderGroup then routes to a single channel's worker with a single clip's
|
|
342
|
+
* FFT data (issue #553).
|
|
343
|
+
*/
|
|
344
|
+
declare function groupRenderableChunks<T extends RenderableChunkLike>(chunks: T[]): T[][];
|
|
250
345
|
|
|
251
|
-
export { type CanvasMeta, type CanvasRegistration, type ChunkLike, type ClassifiedTiers, type ClipRegistration, ColorLUTCache, type FrequencyScaleName, SpectrogramAbortError, SpectrogramOrchestrator, type SpectrogramOrchestratorOptions, type SpectrogramWorkerApi, type SpectrogramWorkerFFTParams, type SpectrogramWorkerRenderChunksParams, type ViewportBounds, type ViewportReadyDetail, type ViewportState, classifyViewport, computeSpectrogram, computeSpectrogramMono, createSpectrogramWorker, createSpectrogramWorkerPool, getColorMap, getFrequencyScale, groupContiguousChunks };
|
|
346
|
+
export { type CanvasMeta, type CanvasRegistration, type ChunkLike, type ClassifiedTiers, type ClipRegistration, ColorLUTCache, type FrequencyScaleName, type PixelColumnToFrameParams, type PixelRowToBinParams, type RenderableChunkLike, SpectrogramAbortError, SpectrogramOrchestrator, type SpectrogramOrchestratorOptions, type SpectrogramWorkerApi, type SpectrogramWorkerFFTParams, type SpectrogramWorkerRenderChunksParams, type ViewportBounds, type ViewportReadyDetail, type ViewportState, classifyViewport, computeSpectrogram, computeSpectrogramMono, createSpectrogramWorker, createSpectrogramWorkerPool, getColorMap, getFrequencyScale, groupContiguousChunks, groupRenderableChunks, pixelColumnToFrame, pixelRowToBin };
|