Update magentaRT_rt_tester.html
Browse files- magentaRT_rt_tester.html +52 -1
magentaRT_rt_tester.html
CHANGED
|
@@ -98,6 +98,11 @@
|
|
| 98 |
<label>WebSocket URL</label>
|
| 99 |
<input id="wsUrl" type="text" value="wss://thecollabagepatch-magenta-retry.hf.space/ws/jam" />
|
| 100 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
<div class="col-12 controls">
|
| 102 |
<button id="btnStart" class="btn">Start</button>
|
| 103 |
<button id="btnStop" class="btn" disabled>Stop</button>
|
|
@@ -133,6 +138,11 @@
|
|
| 133 |
<input id="rngVol" type="range" min="0" max="1" step="0.01" value="1" />
|
| 134 |
<input id="numVol" type="number" min="0" max="1" step="0.01" value="1" />
|
| 135 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
<div class="sep"></div>
|
| 137 |
<button id="btnUpdate" class="btn">Send Update Now</button>
|
| 138 |
</div>
|
|
@@ -256,6 +266,12 @@
|
|
| 256 |
const rngC4 = $("rngC4"), numC4 = $("numC4");
|
| 257 |
const rngC5 = $("rngC5"), numC5 = $("numC5");
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
const XFADE_MS = 40; // crossfade length
|
| 260 |
|
| 261 |
let pending = []; // decoded AudioBuffers waiting to be scheduled
|
|
@@ -497,8 +513,36 @@ async function scheduleWavBytes(arrayBuffer) {
|
|
| 497 |
linkRangeNumber(rngC3, numC3);
|
| 498 |
linkRangeNumber(rngC4, numC4);
|
| 499 |
linkRangeNumber(rngC5, numC5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
|
| 501 |
-
|
| 502 |
// --- Dynamic Styles UI ---
|
| 503 |
const styleRows = document.getElementById("styleRows");
|
| 504 |
const btnAddStyle = document.getElementById("btnAddStyle");
|
|
@@ -578,6 +622,8 @@ async function scheduleWavBytes(arrayBuffer) {
|
|
| 578 |
style_weights: styleWeightsCSV(),
|
| 579 |
use_current_mix_as_style: !!chkUseMixStyle.checked,
|
| 580 |
|
|
|
|
|
|
|
| 581 |
mean: parsefloatSafe(numMean?.value, 1.0),
|
| 582 |
centroid_weights: centroidWeightsCSV(),
|
| 583 |
};
|
|
@@ -625,6 +671,11 @@ async function scheduleWavBytes(arrayBuffer) {
|
|
| 625 |
},
|
| 626 |
};
|
| 627 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 628 |
ws.send(JSON.stringify(msg));
|
| 629 |
log("→ start " + JSON.stringify(msg), "ok");
|
| 630 |
nextTime = ctx.currentTime + 0.12;
|
|
|
|
| 98 |
<label>WebSocket URL</label>
|
| 99 |
<input id="wsUrl" type="text" value="wss://thecollabagepatch-magenta-retry.hf.space/ws/jam" />
|
| 100 |
</div>
|
| 101 |
+
<div class="col-12">
|
| 102 |
+
<label>Initial Loop Audio (optional)</label>
|
| 103 |
+
<input id="loopFile" type="file" accept="audio/*" />
|
| 104 |
+
<span id="loopStatus" class="small"></span>
|
| 105 |
+
</div>
|
| 106 |
<div class="col-12 controls">
|
| 107 |
<button id="btnStart" class="btn">Start</button>
|
| 108 |
<button id="btnStop" class="btn" disabled>Stop</button>
|
|
|
|
| 138 |
<input id="rngVol" type="range" min="0" max="1" step="0.01" value="1" />
|
| 139 |
<input id="numVol" type="number" min="0" max="1" step="0.01" value="1" />
|
| 140 |
</div>
|
| 141 |
+
<div class="range-row">
|
| 142 |
+
<label>Loop weight</label>
|
| 143 |
+
<input id="rngLoopWeight" type="range" min="0.0" max="2.0" step="0.01" value="1.0" />
|
| 144 |
+
<input id="numLoopWeight" type="number" min="0.0" max="2.0" step="0.01" value="1.0" />
|
| 145 |
+
</div>
|
| 146 |
<div class="sep"></div>
|
| 147 |
<button id="btnUpdate" class="btn">Send Update Now</button>
|
| 148 |
</div>
|
|
|
|
| 266 |
const rngC4 = $("rngC4"), numC4 = $("numC4");
|
| 267 |
const rngC5 = $("rngC5"), numC5 = $("numC5");
|
| 268 |
|
| 269 |
+
const loopFile = $("loopFile");
|
| 270 |
+
const loopStatus = $("loopStatus");
|
| 271 |
+
const rngLoopWeight = $("rngLoopWeight");
|
| 272 |
+
const numLoopWeight = $("numLoopWeight");
|
| 273 |
+
let uploadedLoopB64 = null; // stores base64 of uploaded file
|
| 274 |
+
|
| 275 |
const XFADE_MS = 40; // crossfade length
|
| 276 |
|
| 277 |
let pending = []; // decoded AudioBuffers waiting to be scheduled
|
|
|
|
| 513 |
linkRangeNumber(rngC3, numC3);
|
| 514 |
linkRangeNumber(rngC4, numC4);
|
| 515 |
linkRangeNumber(rngC5, numC5);
|
| 516 |
+
linkRangeNumber(rngLoopWeight, numLoopWeight);
|
| 517 |
+
|
| 518 |
+
// File upload handler
|
| 519 |
+
loopFile.addEventListener("change", async (e) => {
|
| 520 |
+
const file = e.target.files[0];
|
| 521 |
+
if (!file) {
|
| 522 |
+
uploadedLoopB64 = null;
|
| 523 |
+
loopStatus.textContent = "";
|
| 524 |
+
return;
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
try {
|
| 528 |
+
loopStatus.textContent = "encoding...";
|
| 529 |
+
const arrayBuffer = await file.arrayBuffer();
|
| 530 |
+
const bytes = new Uint8Array(arrayBuffer);
|
| 531 |
+
let binary = '';
|
| 532 |
+
for (let i = 0; i < bytes.byteLength; i++) {
|
| 533 |
+
binary += String.fromCharCode(bytes[i]);
|
| 534 |
+
}
|
| 535 |
+
uploadedLoopB64 = btoa(binary);
|
| 536 |
+
loopStatus.textContent = `✓ ${file.name} (${(arrayBuffer.byteLength / 1024).toFixed(1)} KB)`;
|
| 537 |
+
loopStatus.className = "small ok";
|
| 538 |
+
} catch (e) {
|
| 539 |
+
uploadedLoopB64 = null;
|
| 540 |
+
loopStatus.textContent = "✗ encoding failed: " + e.message;
|
| 541 |
+
loopStatus.className = "small err";
|
| 542 |
+
}
|
| 543 |
+
});
|
| 544 |
+
|
| 545 |
|
|
|
|
| 546 |
// --- Dynamic Styles UI ---
|
| 547 |
const styleRows = document.getElementById("styleRows");
|
| 548 |
const btnAddStyle = document.getElementById("btnAddStyle");
|
|
|
|
| 622 |
style_weights: styleWeightsCSV(),
|
| 623 |
use_current_mix_as_style: !!chkUseMixStyle.checked,
|
| 624 |
|
| 625 |
+
loop_weight: parsefloatSafe(numLoopWeight?.value, 1.0),
|
| 626 |
+
|
| 627 |
mean: parsefloatSafe(numMean?.value, 1.0),
|
| 628 |
centroid_weights: centroidWeightsCSV(),
|
| 629 |
};
|
|
|
|
| 671 |
},
|
| 672 |
};
|
| 673 |
|
| 674 |
+
// Add loop audio if uploaded
|
| 675 |
+
if (uploadedLoopB64) {
|
| 676 |
+
msg.loop_audio_b64 = uploadedLoopB64;
|
| 677 |
+
}
|
| 678 |
+
|
| 679 |
ws.send(JSON.stringify(msg));
|
| 680 |
log("→ start " + JSON.stringify(msg), "ok");
|
| 681 |
nextTime = ctx.currentTime + 0.12;
|