supersonic-scsynth 0.6.0 → 0.6.2
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/supersonic.js +16 -8
- package/dist/wasm/manifest.json +3 -3
- package/dist/wasm/scsynth-nrt.wasm +0 -0
- package/package.json +1 -1
package/dist/supersonic.js
CHANGED
|
@@ -2384,21 +2384,21 @@ var SuperSonic = class _SuperSonic {
|
|
|
2384
2384
|
try {
|
|
2385
2385
|
const response = await fetch(manifestUrl);
|
|
2386
2386
|
if (!response.ok) {
|
|
2387
|
-
console.warn(`[SuperSonic] WASM manifest not found (${response.status}), using default`);
|
|
2388
2387
|
return;
|
|
2389
2388
|
}
|
|
2390
2389
|
const manifest = await response.json();
|
|
2391
2390
|
this.config.wasmUrl = this.config.wasmBaseURL + manifest.wasmFile;
|
|
2392
2391
|
console.log(`[SuperSonic] WASM: ${manifest.wasmFile} (${manifest.buildId}, git: ${manifest.gitHash})`);
|
|
2393
2392
|
} catch (error) {
|
|
2394
|
-
console.warn("[SuperSonic] Failed to load WASM manifest, using default");
|
|
2395
2393
|
}
|
|
2396
2394
|
}
|
|
2397
2395
|
/**
|
|
2398
2396
|
* Load WASM binary from network
|
|
2399
2397
|
*/
|
|
2400
2398
|
async #loadWasm() {
|
|
2401
|
-
|
|
2399
|
+
if (this.config.development) {
|
|
2400
|
+
await this.#loadWasmManifest();
|
|
2401
|
+
}
|
|
2402
2402
|
const wasmResponse = await fetch(this.config.wasmUrl);
|
|
2403
2403
|
if (!wasmResponse.ok) {
|
|
2404
2404
|
throw new Error(`Failed to load WASM: ${wasmResponse.status} ${wasmResponse.statusText}`);
|
|
@@ -2541,7 +2541,7 @@ var SuperSonic = class _SuperSonic {
|
|
|
2541
2541
|
const timeout = setTimeout(() => {
|
|
2542
2542
|
reject(new Error("AudioWorklet initialization timeout"));
|
|
2543
2543
|
}, 5e3);
|
|
2544
|
-
const messageHandler = (event) => {
|
|
2544
|
+
const messageHandler = async (event) => {
|
|
2545
2545
|
if (event.data.type === "debug") {
|
|
2546
2546
|
return;
|
|
2547
2547
|
}
|
|
@@ -2564,8 +2564,8 @@ var SuperSonic = class _SuperSonic {
|
|
|
2564
2564
|
if (event.data.bufferConstants !== void 0) {
|
|
2565
2565
|
console.log("[SuperSonic] Received bufferConstants from worklet");
|
|
2566
2566
|
this.#bufferConstants = event.data.bufferConstants;
|
|
2567
|
-
console.log("[SuperSonic] Initializing NTP timing");
|
|
2568
|
-
this.initializeNTPTiming();
|
|
2567
|
+
console.log("[SuperSonic] Initializing NTP timing (waiting for audio to flow)...");
|
|
2568
|
+
await this.initializeNTPTiming();
|
|
2569
2569
|
this.#startDriftOffsetTimer();
|
|
2570
2570
|
} else {
|
|
2571
2571
|
console.warn("[SuperSonic] Warning: bufferConstants not provided by worklet");
|
|
@@ -3106,13 +3106,21 @@ var SuperSonic = class _SuperSonic {
|
|
|
3106
3106
|
/**
|
|
3107
3107
|
* Initialize NTP timing (write-once)
|
|
3108
3108
|
* Sets the NTP start time when AudioContext started
|
|
3109
|
+
* Blocks until audio is actually flowing (contextTime > 0)
|
|
3109
3110
|
* @private
|
|
3110
3111
|
*/
|
|
3111
|
-
initializeNTPTiming() {
|
|
3112
|
+
async initializeNTPTiming() {
|
|
3112
3113
|
if (!this.#bufferConstants || !this.#audioContext) {
|
|
3113
3114
|
return;
|
|
3114
3115
|
}
|
|
3115
|
-
|
|
3116
|
+
let timestamp;
|
|
3117
|
+
while (true) {
|
|
3118
|
+
timestamp = this.#audioContext.getOutputTimestamp();
|
|
3119
|
+
if (timestamp.contextTime > 0) {
|
|
3120
|
+
break;
|
|
3121
|
+
}
|
|
3122
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
3123
|
+
}
|
|
3116
3124
|
const perfTimeMs = performance.timeOrigin + timestamp.performanceTime;
|
|
3117
3125
|
const currentNTP = perfTimeMs / 1e3 + NTP_EPOCH_OFFSET;
|
|
3118
3126
|
const ntpStartTime = currentNTP - timestamp.contextTime;
|
package/dist/wasm/manifest.json
CHANGED
|
Binary file
|
package/package.json
CHANGED