@dawcore/spectrogram 0.0.9-next.4 → 0.0.9-next.5
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 +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -0
- package/dist/index.mjs.map +1 -1
- package/dist/orchestrator/index.d.mts +9 -0
- package/dist/orchestrator/index.mjs +9 -0
- package/dist/orchestrator/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -178,6 +178,15 @@ interface SpectrogramWorkerApi {
|
|
|
178
178
|
unregisterCanvas(canvasId: string): void;
|
|
179
179
|
registerAudioData(clipId: string, channelDataArrays: Float32Array[], sampleRate: number): void;
|
|
180
180
|
unregisterAudioData(clipId: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* The ids whose audio is registered now: registered and not unregistered
|
|
183
|
+
* since. An id is whatever the caller registered the audio under (a clip id,
|
|
184
|
+
* or a key per AudioBuffer, as the React provider uses). Empty once
|
|
185
|
+
* terminated; a register after that is ignored. A new array on every call.
|
|
186
|
+
* A caller that pre-registers audio asks this instead of keeping its own
|
|
187
|
+
* list, which would outlive a terminated worker (#821).
|
|
188
|
+
*/
|
|
189
|
+
registeredAudioClipIds(): string[];
|
|
181
190
|
terminate(): void;
|
|
182
191
|
}
|
|
183
192
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -178,6 +178,15 @@ interface SpectrogramWorkerApi {
|
|
|
178
178
|
unregisterCanvas(canvasId: string): void;
|
|
179
179
|
registerAudioData(clipId: string, channelDataArrays: Float32Array[], sampleRate: number): void;
|
|
180
180
|
unregisterAudioData(clipId: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* The ids whose audio is registered now: registered and not unregistered
|
|
183
|
+
* since. An id is whatever the caller registered the audio under (a clip id,
|
|
184
|
+
* or a key per AudioBuffer, as the React provider uses). Empty once
|
|
185
|
+
* terminated; a register after that is ignored. A new array on every call.
|
|
186
|
+
* A caller that pre-registers audio asks this instead of keeping its own
|
|
187
|
+
* list, which would outlive a terminated worker (#821).
|
|
188
|
+
*/
|
|
189
|
+
registeredAudioClipIds(): string[];
|
|
181
190
|
terminate(): void;
|
|
182
191
|
}
|
|
183
192
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3607,6 +3607,7 @@ function createSpectrogramWorker(worker) {
|
|
|
3607
3607
|
worker.postMessage({ type: "unregister-canvas", canvasId });
|
|
3608
3608
|
},
|
|
3609
3609
|
registerAudioData(clipId, channelDataArrays, sampleRate) {
|
|
3610
|
+
if (terminated) return;
|
|
3610
3611
|
const transferableArrays = channelDataArrays.map((arr) => arr.slice());
|
|
3611
3612
|
const transferables = transferableArrays.map((arr) => arr.buffer);
|
|
3612
3613
|
worker.postMessage(
|
|
@@ -3616,11 +3617,16 @@ function createSpectrogramWorker(worker) {
|
|
|
3616
3617
|
registeredClipIds.add(clipId);
|
|
3617
3618
|
},
|
|
3618
3619
|
unregisterAudioData(clipId) {
|
|
3620
|
+
if (terminated) return;
|
|
3619
3621
|
worker.postMessage({ type: "unregister-audio-data", clipId });
|
|
3620
3622
|
registeredClipIds.delete(clipId);
|
|
3621
3623
|
},
|
|
3624
|
+
registeredAudioClipIds() {
|
|
3625
|
+
return [...registeredClipIds];
|
|
3626
|
+
},
|
|
3622
3627
|
terminate() {
|
|
3623
3628
|
terminated = true;
|
|
3629
|
+
registeredClipIds.clear();
|
|
3624
3630
|
worker.terminate();
|
|
3625
3631
|
for (const [, entry] of pending) {
|
|
3626
3632
|
entry.reject(new Error("Worker terminated"));
|
|
@@ -3779,6 +3785,9 @@ function createSpectrogramWorkerPool(createWorker, poolSize = defaultPoolSize())
|
|
|
3779
3785
|
w.unregisterAudioData(clipId);
|
|
3780
3786
|
}
|
|
3781
3787
|
},
|
|
3788
|
+
registeredAudioClipIds() {
|
|
3789
|
+
return [...registeredAudio.keys()];
|
|
3790
|
+
},
|
|
3782
3791
|
terminate() {
|
|
3783
3792
|
terminated = true;
|
|
3784
3793
|
registeredAudio.clear();
|