Studio: Analysis, the exact state of the FM-1 or the emulator in one file (each track's engine, preset, level and every parameter by name and value, what differs from its default; the globals and effects; the steps; the song; the generator) and, from the emulator, how it sounds (8 s of stems: level, peak, crest, sustain, clipped samples, eight octave bands, per track and mixed); JSON to download, a summary to copy. Radio: a piece of its own first (RADIO on had nothing to play)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVqsRnhKjiABTzc6Ety3dd
This commit is contained in:
Claude committed 2026-11-26 11:44:22 +00:00
1 parent ec30b83f44
commit 6b07c4ec92
6 files changed
+216 -6

No files matched your search

+1 -1
View File
@@ -238,7 +238,7 @@ jobs:
# (studio) JIANT Studio: install, edit, the screen, the emulator and recording for JIANT FM and JIANT BYTE in one
# page (web/studio; it shows JIANT BYTE's tools from /JIANT-BYTE/, the same origin)
mkdir -p build/pages/studio
cp web/studio/index.html web/studio/studio.js web/studio/studio-lib.js web/studio/daw.js web/studio/recorder-worklet.js web/studio/learn.js web/studio/wavetable.js web/studio/radio-vis.js web/studio/learn-fm.json web/studio/learn-byte.json web/studio/live-fm.json web/studio/live-byte.json web/fm1backup.js build/pages/studio/
cp web/studio/index.html web/studio/studio.js web/studio/studio-lib.js web/studio/daw.js web/studio/recorder-worklet.js web/studio/learn.js web/studio/wavetable.js web/studio/radio-vis.js web/studio/analysis.js web/studio/learn-fm.json web/studio/learn-byte.json web/studio/live-fm.json web/studio/live-byte.json web/fm1backup.js build/pages/studio/
cp -r web/studio/img build/pages/studio/img
# (studio) FM-1 Rescue's builder and base firmware for Studio's Rescue tab; its own page at rescue/
mkdir -p build/pages/studio/rescue/base build/pages/rescue
+135
View File
@@ -0,0 +1,135 @@
/* JIANT Studio's Analysis: the device's (or the emulator's) exact state and, from the emulator, how it sounds, in one
* file to hand to someone (or to Claude): INFO, the tracks (TRACK 27; each one's parameters by TRACK_DUMP 29, named by
* DESC with that track selected for a moment, the selection put back), the globals (DUMP 4, DESC scope 1), the steps
* (TRACK_STEP 30), the song (SONG 33), the generator (jiantEmu.gen), and the audio (jiantEmu.tap: each track's level,
* peak, crest, how long it sustains, eight octave bands). capture() -> an object; text() -> a summary to paste */
const v14 = (a, i) => (a[i] | (a[i + 1] << 7)) - 8192;
function str(a, i) { let s = ""; while (i < a.length && a[i]) s += String.fromCharCode(a[i++]); return [s, i + 1]; }
function info(a) {
let i = 0, version; [version, i] = str(a, 0);
const o = { version, nengines: a[i], pcount: a[i + 1], gcount: a[i + 2], nstep: a[i + 3], pe0: a[i + 4], engines: [] }; i += 5;
for (let k = 0; k < o.nengines; k++) { let s; [s, i] = str(a, i); o.engines.push(s); }
o.ntrk = i < a.length ? a[i] : 0;
return o;
}
function desc(a) {
const o = { fmt: a[2], min: v14(a, 3), max: v14(a, 5), def: v14(a, 7) };
let i = 9; [o.label, i] = str(a, i); [o.unit, i] = str(a, i); o.names = [];
if (o.fmt === 8) for (let k = 0; k <= o.max - o.min && k < 32 && i < a.length; k++) { let n; [n, i] = str(a, i); o.names.push(n); }
return o;
}
const named = (d, v) => {
if (!d) return { v };
const o = { label: d.label || "?", v };
if (d.names && d.names.length) o.name = d.names[v - d.min];
if (d.unit) o.unit = d.unit;
if (v !== d.def) o.def = d.names && d.names.length ? d.names[d.def - d.min] ?? d.def : d.def;
o.range = [d.min, d.max];
return o;
};
/* req(cmd, args, timeout, match) -> the reply's bytes; opts { steps, audio: tap fn or null, secs, gen }; say(text, frac) */
export async function capture(req, opts = {}, say = () => {}) {
const out = { kind: "jiant-analysis", made: new Date().toISOString(), source: opts.source || "", note: "values are the device's raw ones; name = the enum's name; def = the default when the value differs" };
say("INFO", 0);
const I = info(await req(1, [], 900)); out.firmware = I.version; out.engines = I.engines;
const T = await req(27, [], 900), sel = T[0], ntrk = T[1], tracks = [];
for (let t = 0; t < ntrk; t++) { const b = 2 + t * 6; tracks.push({ track: t + 1, engine: I.engines[T[b]] || T[b], preset: T[b + 1] + 1, level: v14(T, b + 2), mute: !!T[b + 4] }); }
out.selected = sel + 1;
const common = []; // the common parameters' names (any track)
for (let id = 0; id < I.pe0; id++) { say(`DESC ${id + 1}/${I.pcount}`, id / I.pcount * .4); try { common[id] = desc(await req(5, [0, id], 800)); } catch (_) {} }
try {
for (let t = 0; t < ntrk; t++) {
say(`T${t + 1}`, .4 + t / ntrk * .3);
await req(27, [t], 900); // this track for a moment: its engine's names
const eng = [];
for (let id = I.pe0; id < I.pcount; id++) { try { eng[id] = desc(await req(5, [0, id], 800)); } catch (_) {} }
const D = await req(29, [t], 900), p = {};
for (let id = 0; id < I.pcount; id++) { const v = v14(D, 3 + id * 2), d = id < I.pe0 ? common[id] : eng[id]; if (d && d.label && d.label !== "-") p[`${id}`] = named(d, v); }
tracks[t].params = p;
}
} finally { try { await req(27, [sel], 900); } catch (_) {} } // the selection back
out.tracks = tracks;
say("GLOBAL", .72);
const G = await req(4, [], 1500), g = {};
for (let id = 0; id < I.gcount; id++) { try { const d = desc(await req(5, [1, id], 800)); if (d.label && d.label !== "-") g[`${id}`] = named(d, v14(G, 2 + (I.pcount + id) * 2)); } catch (_) {} }
out.globals = g;
try { const S = await req(33, [0], 900); out.song = { count: S[2], playing: !!S[3], row: S[4], rows: Array.from({ length: S[2] }, (_, k) => ({ slot: "ABCD"[S[6 + k * 2]] || S[6 + k * 2], repeat: S[7 + k * 2] })) }; } catch (_) {}
if (opts.steps) {
for (let t = 0; t < ntrk; t++) {
say(`STEPS T${t + 1}`, .78 + t / ntrk * .1);
const st = [];
for (let i = 0; i < Math.min(64, I.nstep); i++) {
try { const a = await req(30, [t, i], 800, (r) => r[0] === t && r[1] === i); if (a[2]) st.push({ step: i + 1, n: a[2], notes: a.slice(3, 3 + a[2]), time: a[7], flags: a[8], vel: a[9] }); } catch (_) { break; }
}
tracks[t].steps = st;
}
}
if (opts.gen) { try { const r = await opts.gen(); if (r) out.generator = r; } catch (_) {} }
if (opts.audio) { say("AUDIO", .9); out.audio = await listen(opts.audio, opts.secs || 8, (f) => say(`AUDIO ${Math.round(f * 100)} %`, .9 + f * .1)); }
say("", 1);
return out;
}
/* the emulator's stems for a few seconds: per track and their sum, level / peak (dBFS), crest, sustain (the share of
time above -40 dBFS), clipped samples, eight octave bands (dB, relative to the loudest) */
const BANDS = [63, 125, 250, 500, 1000, 2000, 4000, 8000];
function listen(tap, secs, prog) {
return new Promise((res) => {
const sr = 44100, n = 7, acc = Array.from({ length: n }, () => ({ sq: 0, peak: 0, cnt: 0, clip: 0, loud: 0, win: 0, wsq: 0, bands: BANDS.map((f) => ({ ...bp(f, sr), z1: 0, z2: 0, e: 0 })) }));
let got = 0;
const stop = tap((m) => {
if (!m.planes) return;
const L = m.planes[0].length;
for (let k = 0; k < L; k++) {
let mix = 0;
for (let c = 0; c <= n; c++) {
const x = c < 6 ? m.planes[c][k] : c === 6 ? mix + (m.planes[6] ? m.planes[6][k] : 0) : 0;
if (c < 6) mix += x;
if (c === 7) break;
const A = acc[c], ax = Math.abs(x);
A.sq += x * x; A.cnt++; if (ax > A.peak) A.peak = ax; if (ax > .99) A.clip++;
A.wsq += x * x; if (++A.win === 441) { if (A.wsq / 441 > 1e-4) A.loud++; A.win = 0; A.wsq = 0; }
for (const B of A.bands) { const y = B.b0 * x + B.z1; B.z1 = B.b1 * x - B.a1 * y + B.z2; B.z2 = B.b2 * x - B.a2 * y; B.e += y * y; }
}
}
got += L; prog(Math.min(1, got / (sr * secs)));
if (got >= sr * secs) { stop && stop(); res(summary()); }
});
if (!stop) res(null);
const db = (v) => v > 1e-9 ? +(20 * Math.log10(v)).toFixed(1) : -120;
function summary() {
const names = ["T1", "T2", "T3", "T4", "T5", "T6", "MIX"];
const o = { seconds: secs, rate: sr, bands_hz: BANDS, note: "the stems as USB STEMS sends them, before the master: a peak above 0 dBFS is headroom the master then limits; MIX = the six tracks plus the effects' return", tracks: {} };
acc.forEach((A, c) => {
const rms = Math.sqrt(A.sq / Math.max(1, A.cnt)), emax = Math.max(...A.bands.map((B) => B.e), 1e-12);
o.tracks[names[c]] = rms < 1e-5 ? { silent: true } : { rms_dbfs: db(rms), peak_dbfs: db(A.peak), crest_db: +(db(A.peak) - db(rms)).toFixed(1),
sustain_pct: Math.round(A.loud / Math.max(1, A.cnt / 441) * 100), clipped: A.clip, bands_db: A.bands.map((B) => +(10 * Math.log10(Math.max(B.e, 1e-12) / emax)).toFixed(1)) };
});
return o;
}
});
}
function bp(f, sr) { // RBJ band-pass, an octave wide
const w = 2 * Math.PI * f / sr, al = Math.sin(w) * Math.sinh(Math.LN2 / 2 * 1 * w / Math.sin(w)), a0 = 1 + al;
return { b0: al / a0, b1: 0, b2: -al / a0, a1: -2 * Math.cos(w) / a0, a2: (1 - al) / a0 };
}
/* a summary to paste: the firmware, each track (engine, preset, level, the parameters away from their default), the
globals away from theirs, the song, the generator, the audio */
export function text(o) {
const L = [`JIANT ANALYSIS · ${o.firmware} · ${o.source} · ${o.made}`, ""];
const pv = (p) => `${p.label}=${p.name ?? p.v}${p.unit ? p.unit : ""}${p.def != null ? ` (def ${p.def})` : ""}`;
for (const t of o.tracks || []) {
L.push(`T${t.track} ${t.engine} preset ${t.preset} level ${t.level}${t.mute ? " MUTED" : ""}${t.track === o.selected ? " [selected]" : ""}`);
const ch = Object.values(t.params || {}).filter((p) => p.def != null);
L.push(` changed: ${ch.length ? ch.map(pv).join(", ") : "(all at default)"}`);
if (t.steps) L.push(` steps with notes: ${t.steps.length}${t.steps.length ? " · " + t.steps.slice(0, 16).map((s) => `${s.step}:${s.notes.join("/")}`).join(" ") : ""}`);
}
const gc = Object.values(o.globals || {}).filter((p) => p.def != null);
L.push("", `GLOBAL changed: ${gc.length ? gc.map(pv).join(", ") : "(all at default)"}`);
if (o.song) L.push(`SONG ${o.song.count} rows${o.song.playing ? ", playing" : ""}: ${o.song.rows.map((r) => `${r.slot}x${r.repeat}`).join(" ")}`);
if (o.generator) L.push(`GENERATOR ${JSON.stringify(o.generator)}`);
if (o.audio) {
L.push("", `AUDIO ${o.audio.seconds} s (bands ${o.audio.bands_hz.join(" ")} Hz, dB from the loudest)`);
for (const [k, a] of Object.entries(o.audio.tracks)) L.push(a.silent ? ` ${k} silent` : ` ${k} rms ${a.rms_dbfs} peak ${a.peak_dbfs} crest ${a.crest_db} sustain ${a.sustain_pct}% clipped ${a.clipped} bands ${a.bands_db.join(" ")}`);
}
return L.join("\n");
}
+8
View File
@@ -153,6 +153,14 @@ try {
/^c[0-9a-f]{24}$/.test(b0.client) && posts[0].h.apikey && posts[1].b.seed !== b0.seed && /: 2/.test(count) && parts0 === 9 && noParts && posts[1].b.parts === 0,
`radio: ${now}, 👍 and 👎 posted (${posts.map((p) => p.b.vote).join(" ")}, a 409 taken), ⏭ nothing; parts 9 (a 400 sent again without it), none chosen 0 after 4 s; "${count}"`);
}
/* analysis: the simulated FM-1's six tracks, their parameters by name, steps, the song, in a summary */
{
const q = await page("?mock=1#an", { width: 1280, height: 900 });
await q.click("#ango"); await q.waitForTimeout(12000);
const txt = await q.textContent("#anpre");
ok(/T1 ANALOG preset 1/.test(txt) && /CUT=90 \(def 64\)/.test(txt) && /steps with notes: 16/.test(txt) && /SONG 2 rows: Ax1 Bx2/.test(txt) && (await q.textContent("#anstat")) === "Done.",
`analysis: 6 tracks, parameters by name, steps and the song in the summary (${txt.split("\n").length} lines)`);
}
/* rescue: the published JIANT FM and JieLi's loader fetched and checked, a board's fm1-rescue.uf2 made */
{
const ctx = await b.newContext({ viewport: { width: 1280, height: 900 }, acceptDownloads: true });
+18
View File
@@ -308,6 +308,7 @@
body.radiodock #v-emu .framebox iframe { height: 52vh; min-height: 300px; }
body.radiodock .rdstage { height: 70vh; margin: 0; }
}
.anpre { margin: 0; max-height: 60vh; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; color: var(--fg); }
.wtframes { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 8px 0; }
.wtframes canvas { width: 100%; aspect-ratio: 1; background: var(--field); border-radius: var(--radius-s); cursor: pointer; }
.wtframes canvas.on { outline: 2px solid var(--accent); }
@@ -512,6 +513,7 @@
<button data-go="rec" data-t="vRec"></button>
<button data-go="proj" data-t="vProj"></button>
<button data-go="wt" data-t="vWt"></button>
<button data-go="an" data-t="vAn"></button>
<button data-go="learn" data-t="vLearn"></button>
<button data-go="docs" data-t="vDocs"></button>
<button data-go="rescue" data-t="vRescue"></button>
@@ -662,6 +664,22 @@
</div>
</section>
<!-- ======================================================================================= analysis -->
<section class="view" id="v-an" hidden>
<div class="viewhead"><div><p class="eyebrow" data-t="vAn"></p><h1 data-t="anTitle"></h1></div>
<div class="emuctl"><button class="btn" id="ango" type="button" data-t="anGo"></button></div></div>
<p class="lead" data-t="anLead"></p>
<div class="wtsend"><label class="chk"><input type="checkbox" id="ansteps" checked> <span data-t="anSteps"></span></label>
<label class="chk"><input type="checkbox" id="anaudio" checked> <span data-t="anAudio"></span></label></div>
<p class="dim" id="anwho"></p>
<p class="projstat" id="anstat" role="status"></p>
<div class="bkprog" id="anprog" hidden><i id="anbar"></i></div>
<div class="card" id="anout" hidden>
<div class="emuctl" style="margin-bottom:10px"><button class="btn" id="anjson" type="button" data-t="anJson"></button><button class="btn ghost" id="ancopy" type="button" data-t="anCopy"></button></div>
<pre class="anpre" id="anpre"></pre>
</div>
</section>
<!-- ======================================================================================= radio (votes) -->
<section class="view" id="v-radio" hidden>
<div class="rdstage" id="rdstage">
+52 -3
View File
@@ -12,12 +12,14 @@ import { scrDecode, scrEncode, wavFile, zipStored, midiFile, SCR } from "./studi
import { Daw } from "./daw.js";
import { Player, anim } from "./learn.js";
import { Ecosystem, Levels } from "./radio-vis.js";
import { capture as anCapture, text as anText } from "./analysis.js";
import { makeTable, toI16, pack as wtPack, unpack as wtUnpack, parseInfo as parseWtInfo, render as wtRender, wav as wtWav, WT, FRAMES, LEN, CHUNKS } from "./wavetable.js";
import { captureBackup, restoreBackup, readBackup, songsNotRestored, BACKUP_IDS, bkU32, bkR32, bkCrc, bkPack, bkUnpack } from "./fm1backup.js";
const $ = (id) => document.getElementById(id);
const QS = new URLSearchParams(location.search);
const MOCK = QS.get("mock") === "1";
let mockSel = 0; // (the simulated FM-1's selected track)
/* ------------------------------------------------------------------------------------------------- the words */
const TEXT = {
@@ -71,6 +73,10 @@ const TEXT = {
rsSafe: "Solo se escribe la zona del firmware (0x4000–0x92FFF), sector por sector, cada uno releído y comparado; la cabecera de arranque y tus datos no se tocan. Sin firmware dentro, la placa queda como un FM-1 Transporter común. Basado en FM-1 Transporter (Hügelton Instruments), MvaveFM1Unbricker (Quixotic7), jl-uboot-tool (kagaimiq) y la guía de GoodPerson42. Usalo con la batería cargada y bajo tu responsabilidad: todavía no se probó en un FM-1 real.",
rdLiked: "¿Qué te gustó? (opcional)", rdDisliked: "¿Qué no te gustó? (opcional)", rdNext: "Siguiente", rdpDrums: "Batería", rdpBass: "Bajo", rdpChords: "Acordes", rdpLead: "Lead", rdpArp: "Arp", rdpSound: "Sonido/mezcla",
rdStarting: "Prendiendo…", rdEmuOn: "Prendiendo el emulador…",
vAn: "Análisis", anTitle: "Análisis: los datos exactos", anLead: "Lee del FM-1 o del emulador todo lo que tiene: cada pista con su motor, preset, nivel y cada parámetro con su nombre y valor (y cuáles cambiaron), los globales y los efectos, los pasos, la canción y el generador. Con el emulador escucha además unos segundos: nivel, picos, cuánto sostiene cada pista y su espectro. Bajá el archivo o copiá el resumen y pasalo tal cual.",
anGo: "Analizar", anSteps: "Incluir los pasos", anAudio: "Escuchar 8 s del emulador", anFrom: "De: %s (elige la pista de a una un instante y vuelve a la tuya)", anNoDev: "Conectá el FM-1 o prendé el emulador.",
anDone: "Listo.", anFail: "No se pudo leer todo", anJson: "Bajar el archivo (JSON)", anCopy: "Copiar el resumen", anCopied: "Resumen copiado.", anNoCopy: "No se pudo copiar: seleccioná el texto.",
tourV_anT: "Análisis", tourV_an: "Los datos exactos del equipo o del emulador en un archivo, para mandar cuando algo suena raro.", tourV_anH: "Con el emulador también mide cómo suena cada pista.",
vRadio: "Radio", rdTitle: "Votá las piezas del generador", rdLead: "Piezas nuevas del generador, una tras otra, y un ecosistema que vive de la música: cada pista mueve a sus seres. Decí si te gusta cada pieza; con tus votos el generador mejora. Subí el volumen.",
rdStart: "Empezar", rdStop: "Parar", rdGenre: "Género", rdMood: "MOOD", rdSeed: "semilla", rdThanks: "Votos: %n · ¡gracias!",
rdNoEmu: "No se pudo prender el emulador: probá de nuevo, o prendelo en la pestaña Emulador.", rdOld: "El emulador publicado todavía no tiene RADIO para esta página: llega con su próxima versión.",
@@ -241,6 +247,10 @@ const TEXT = {
rsSafe: "Only the firmware area (0x4000–0x92FFF) is written, sector by sector, each read back and compared; the boot head and your data are not touched. Without a firmware inside, the board is a plain FM-1 Transporter. Built on FM-1 Transporter (Hügelton Instruments), MvaveFM1Unbricker (Quixotic7), jl-uboot-tool (kagaimiq) and GoodPerson42's guide. Use it with a charged battery and at your own risk: it has not been tried on a real FM-1 yet.",
rdLiked: "What did you like? (optional)", rdDisliked: "What didn't you like? (optional)", rdNext: "Next", rdpDrums: "Drums", rdpBass: "Bass", rdpChords: "Chords", rdpLead: "Lead", rdpArp: "Arp", rdpSound: "Sound/mix",
rdStarting: "Starting…", rdEmuOn: "Switching the emulator on…",
vAn: "Analysis", anTitle: "Analysis: the exact data", anLead: "Reads everything the FM-1 or the emulator holds: each track with its engine, preset, level and every parameter by name and value (and which ones changed), the globals and effects, the steps, the song and the generator. From the emulator it also listens for a few seconds: level, peaks, how long each track sustains and its spectrum. Download the file or copy the summary and pass it on as it is.",
anGo: "Analyze", anSteps: "Include the steps", anAudio: "Listen to 8 s of the emulator", anFrom: "From: %s (selects each track for an instant and goes back to yours)", anNoDev: "Connect the FM-1 or switch the emulator on.",
anDone: "Done.", anFail: "Not everything could be read", anJson: "Download the file (JSON)", anCopy: "Copy the summary", anCopied: "Summary copied.", anNoCopy: "Could not copy: select the text.",
tourV_anT: "Analysis", tourV_an: "The device's or the emulator's exact data in a file, to send when something sounds wrong.", tourV_anH: "From the emulator it also measures how each track sounds.",
vRadio: "Radio", rdTitle: "Vote on the generator's pieces", rdLead: "New pieces from the generator, one after another, and an ecosystem that lives on the music: each track moves its beings. Say whether you like each piece; your votes make the generator better. Turn the volume up.",
rdStart: "Start", rdStop: "Stop", rdGenre: "Genre", rdMood: "MOOD", rdSeed: "seed", rdThanks: "Votes: %n · thank you!",
rdNoEmu: "The emulator could not be switched on: try again, or switch it on in the Emulator tab.", rdOld: "The published emulator does not have RADIO for this page yet: it comes with its next version.",
@@ -535,7 +545,7 @@ try {
window.navShow = () => { const b = nv.querySelector('[aria-current="page"]'); if (b) nv.scrollTo({ left: b.offsetLeft - (nv.clientWidth - b.offsetWidth) / 2, behavior: "smooth" }); edges(); };
setTimeout(edges, 50);
}
const VIEWS = ["home", "install", "editor", "screen", "emu", "rec", "proj", "wt", "radio", "learn", "docs", "rescue", "ports"];
const VIEWS = ["home", "install", "editor", "screen", "emu", "rec", "proj", "wt", "radio", "an", "learn", "docs", "rescue", "ports"];
function go(view, push = true) {
if (!VIEWS.includes(view)) view = "home";
state.view = view;
@@ -1541,6 +1551,7 @@ async function rdStart() {
const r = await G.gen(0, 1, true);
if (!r.ok) { rdSay(t("rdOld")); return; }
rd.on = true;
await G.gen(1, 0); // a piece of its own first (RADIO on has nothing yet to play)
await G.gen(4, 1);
clearInterval(rd.timer); rd.timer = setInterval(rdPoll, 1000);
rdFeed();
@@ -1590,6 +1601,38 @@ $("rdfull").onclick = () => { const st = $("rdstage"); document.fullscreenElemen
$("rdup").onclick = () => rdAsk(1); $("rddown").onclick = () => rdAsk(-1); $("rdskip").onclick = () => { rd.pending = null; rdNext(); }; $("rdnext").onclick = () => rdNext();
$("rdgenre").onchange = async () => { const G = rdGen(); if (G) { await G.gen(2, +$("rdgenre").value); await G.gen(1, 0); await rdPoll(); } };
$("rdmood").onchange = async () => { const G = rdGen(); if (G) { await G.gen(3, +$("rdmood").value); await rdPoll(); } };
/* ------------------------------------------------------------------------------------------------- analysis */
/* the exact state (and, from the emulator, how it sounds) in one file to hand over (analysis.js) */
const an = { data: null, busy: false };
const anSay = (x) => { $("anstat").textContent = x; };
function renderAn() {
if (!$("ango")) return;
const L = projLink(), emu = emuApi();
$("anwho").textContent = L ? t("anFrom").replace("%s", L.name) : t("anNoDev");
$("ango").disabled = !L || an.busy; $("anaudio").disabled = !emu; if (!emu) $("anaudio").checked = false;
$("anout").hidden = !an.data;
}
$("ango").onclick = async () => {
const L = projLink(); if (!L || an.busy) return;
an.busy = true; an.data = null; renderAn(); $("anprog").hidden = false;
const e = emuApi();
try {
an.data = await anCapture((c, a, to, m) => L.link.request(c, a, to, m), {
source: L.name, steps: $("ansteps").checked,
audio: $("anaudio").checked && e ? (f) => e.tap(f) : null, secs: 8,
gen: e && e.gen ? async () => { const r = await e.gen(null, 0, true); const i = rdInfo(r && r.info); return i ? { radio: !!i[0], genre: i[1] >= 0 && r.genres ? r.genres[i[1]] : i[1], seed: i[2], mood: i[3], energy: i[4], form: RD_FORMS[i[5]], piece: i[6] } : null; } : null,
}, (x, f) => { anSay(x); $("anbar").style.width = `${Math.round(f * 100)}%`; });
$("anpre").textContent = anText(an.data); anSay(t("anDone"));
} catch (err) { anSay(t("anFail") + (err && err.message ? ` (${err.message})` : "")); }
an.busy = false; $("anprog").hidden = true; renderAn();
};
$("anjson").onclick = () => {
if (!an.data) return;
const a = document.createElement("a"), stamp = an.data.made.replace(/[:.]/g, "-").slice(0, 19);
a.href = URL.createObjectURL(new Blob([JSON.stringify(an.data, null, 1)], { type: "application/json" }));
a.download = `jiant-analysis-${state.fw}-${(an.data.firmware || "").replace(/\s+/g, "_")}-${stamp}.json`; a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 4000);
};
$("ancopy").onclick = async () => { try { await navigator.clipboard.writeText($("anpre").textContent); anSay(t("anCopied")); } catch (_) { anSay(t("anNoCopy")); } };
/* ------------------------------------------------------------------------------------------- how it works */
/* each firmware's ideas (learn-fm.json, learn-byte.json): sectors (the concept, the engines, the sequencers, the
* effects, the modulators, the generators, the songs), each item its statement, how it works, where it is on the
@@ -1717,7 +1760,7 @@ const TOUR = [
{ k: "Target", sel: "#targetseg" },
{ k: "Dev", sel: "#devchip", view: "home" },
{ k: "Find", sel: "#find", view: "home" },
...["install", "editor", "screen", "emu", "rec", "proj", "wt", "radio", "learn", "docs", "rescue", "ports"].map((v) => ({ k: "V_" + v, sel: `nav.views [data-go="${v}"]` })),
...["install", "editor", "screen", "emu", "rec", "proj", "wt", "radio", "an", "learn", "docs", "rescue", "ports"].map((v) => ({ k: "V_" + v, sel: `nav.views [data-go="${v}"]` })),
{ k: "Lang", sel: "#lang" },
{ k: "End", sel: "#tourbtn" },
];
@@ -2193,6 +2236,7 @@ function render() {
if (state.view === "ports") renderPorts();
if (state.view === "proj") renderProj();
if (state.view === "wt") renderWtDev();
if (state.view === "an") renderAn();
if (state.view === "radio" || rd.vis) renderRadio();
document.querySelector('nav.views [data-go="wt"]').hidden = state.fw !== "byte";
if (state.view === "learn") renderLearn();
@@ -2328,7 +2372,12 @@ function mockAccess() {
}, 250); }
deliver(frame(22, [f.a[0] ? 31 : 0])); return;
}
if (f.cmd === 4) { deliver(frame(4, [0, 0])); return; } // DUMP (the engine and preset are all the guide reads)
const e14 = (v) => [(v + 8192) & 127, (v + 8192) >> 7];
if (f.cmd === 4) { deliver(frame(4, [0, 0, ...Array.from({ length: 140 }, (_, i) => e14(i % 7 ? 64 : 0)).flat()])); return; } // DUMP: the engine, the preset, 100 + 40 values
if (f.cmd === 27) { if (f.a.length) mockSel = f.a[0]; deliver(frame(27, [mockSel, 6, ...[0, 2, 3, 4, 0, 5].flatMap((en, t) => [en, t, ...e14(100), t === 5 ? 1 : 0, 0])])); return; } // TRACK
if (f.cmd === 29) { deliver(frame(29, [f.a[0], 0, f.a[0], ...Array.from({ length: 100 }, (_, i) => e14(i === 3 ? 90 : 64)).flat()])); return; } // TRACK_DUMP
if (f.cmd === 30) { const [t, i] = f.a, on = i % 4 === 0; deliver(frame(30, [t, i, on ? 1 : 0, on ? 36 + t : 0, 0, 0, 0, 2, 0, 100])); return; } // TRACK_STEP
if (f.cmd === 33) { deliver(frame(33, [0, 0, 2, 0, 0, 0, 0, 1, 1, 2])); return; } // SONG: A x1, B x2
if (f.cmd === 5) { // DESC: CUT on any id
const s = (x) => [...x].map((c) => c.charCodeAt(0)).concat(0), e = (v) => [(v + 8192) & 127, (v + 8192) >> 7];
deliver(frame(5, [f.a[0], f.a[1], 0, ...e(0), ...e(127), ...e(64), ...s("CUT"), ...s("")])); return;
+2 -2
View File
@@ -67,8 +67,8 @@ const miss = [...used].filter((k) => !(k in TEXT.es) || !(k in TEXT.en));
const odd = Object.keys(TEXT.es).filter((k) => !(k in TEXT.en)).concat(Object.keys(TEXT.en).filter((k) => !(k in TEXT.es)));
ok(!miss.length && !odd.length, `every word in Spanish and English (${used.size} used${miss.length ? "; missing " + miss : ""}${odd.length ? "; one language only " + odd : ""})`);
const views = [...page.matchAll(/<button data-go="(\w+)" data-t="v\w+"[^>]*>/g)].map((m) => m[1]);
ok(eq(views, ["radio", "home", "install", "editor", "screen", "emu", "rec", "proj", "wt", "learn", "docs", "rescue", "ports"]) && views.every((v) => page.includes(`id="v-${v}"`)) &&
/const VIEWS = \["home", "install", "editor", "screen", "emu", "rec", "proj", "wt", "radio", "learn", "docs", "rescue", "ports"\]/.test(js), `thirteen views, a section each (${views.join(" ")})`);
ok(eq(views, ["radio", "home", "install", "editor", "screen", "emu", "rec", "proj", "wt", "an", "learn", "docs", "rescue", "ports"]) && views.every((v) => page.includes(`id="v-${v}"`)) &&
/const VIEWS = \["home", "install", "editor", "screen", "emu", "rec", "proj", "wt", "radio", "an", "learn", "docs", "rescue", "ports"\]/.test(js), `fourteen views, a section each (${views.join(" ")})`);
/* other devices: every card's words, and its links (the emulator's panels exist in devices.html) */
const devices = readFileSync(join(HERE, "..", "emu", "devices.html"), "utf8");
const portKeys = [...js.matchAll(/\b(p[A-Z]\w+|st[A-Z]\w*|port[A-Z]\w+)"/g)].map((m) => m[1]).filter((k) => !/^(portlist|pic)$/.test(k));