Web installer and editor (GitHub Pages)

This commit is contained in:
isod89 committed 2026-10-04 11:17:24 -04:00
1 parent a3f9fd04c8
commit 8a5b3154b5
8 files changed
+4547 -4

No files matched your search

+4 -4
View File
@@ -1,4 +1,4 @@
<p align="center"><img src="assets/logo/sloop-logo.png" alt="SLOOP" width="420"></p>
<p align="center"><img src="assets/logo/sloop-logo.png" alt="SLOOP" width="420"></p>
<p align="center"><b>A hip-hop beat machine firmware for the M-VAVE FM-1.</b><br>
Free and open source (GPL-3.0), based on <a href="https://github.com/hugelton/Felucca">Felucca</a>.</p>
@@ -27,9 +27,9 @@ SLOOP turns the FM-1 into a four-track beat machine you play live: three synths
## Install
1. Get the `.fwsc` of the latest [release](../../releases), or build it (below).
2. On Windows, double-click **`INSTALL-SLOOP.bat`**: it builds the firmware and opens the installer in the browser.
3. Connect the FM-1 by USB (a data cable, no hub), open the installer in **Chrome or Edge**, press **INSTALL** and wait for *Done*.
**From the browser:** open **[the SLOOP installer](https://isod89.github.io/sloop-fm1/)** in **Chrome or Edge**, connect the FM-1 by USB (a data cable, no hub), press **INSTALL** and wait for *Done*. Nothing to download or compile. The [web editor](https://isod89.github.io/sloop-fm1/webapp/editor/) works the same way.
Other ways: the `.fwsc` of each [release](../../releases) with `python tools/fm1_install.py sloop-2.0.fwsc` (needs `pip install mido python-rtmidi`), or build it yourself and run `INSTALL-SLOOP.bat` (Windows).
Going back: M-VAVE's own updater (M-UPGRADE) and the official FM-1 firmware. If an install is cut off, the FM-1 stays in update mode: press Install again and it finishes.
View File
Whitespace-only changes.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
<!doctype html><meta charset="utf-8"><title>SLOOP</title><meta http-equiv="refresh" content="0; url=webapp/installer/"><a href="webapp/installer/">SLOOP installer</a>
+23
View File
@@ -0,0 +1,23 @@
Fukiai icon font (fukiai.ttf), used by the Felucca web editor.
MIT License
Copyright (c) 2026 Hügelton Instruments
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file not shown.
File diff suppressed because it is too large. Load diff
+475
View File
@@ -0,0 +1,475 @@
<!doctype html>
<!-- SPDX-License-Identifier: GPL-3.0-only
Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SLOOP installer</title>
<style>
:root { --bg: #000; --fg: #f2f2f2; --dim: #8a8a92; --tile: #16161a; --line: #2a2a30;
--blue: #287cff; --green: #1ecc70; --yellow: #ffc618; --orange: #ff621a; --red: #ff2c34; }
:root[data-theme="light"] { --bg: #f4f4f2; --fg: #111; --dim: #666; --tile: #e6e6e2; --line: #d0d0cc; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
font: 15px/1.6 "Helvetica Neue", -apple-system, BlinkMacSystemFont, Arial, sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: 32px 16px 48px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo svg { display: block; width: 220px; height: auto; }
.logo rect:first-child { fill: transparent; }
.lang { font-size: 12px; color: var(--dim); cursor: pointer; text-decoration: underline; background: none;
border: 0; padding: 0; text-transform: lowercase; }
.strip { display: flex; height: 4px; margin: 20px 0 24px; }
.strip i { flex: 1; } .strip i:nth-child(1) { background: var(--blue); } .strip i:nth-child(2) { background: var(--green); }
.strip i:nth-child(3) { background: var(--yellow); } .strip i:nth-child(4) { background: var(--orange); }
h1 { font-size: 13px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin: 0 0 8px; }
.lead { font-size: 20px; line-height: 1.35; margin: 0 0 24px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 28px; }
.tile { background: var(--tile); padding: 10px 10px 12px; border-top: 3px solid var(--c); min-height: 92px; }
.tile b { display: block; font-size: 22px; font-weight: 600; color: var(--c); line-height: 1.1; }
.tile span { display: block; font-size: 12px; color: var(--dim); text-transform: lowercase; margin-top: 4px; }
p { margin: 0 0 14px; }
button#go { font: 600 15px/1 inherit; font-family: inherit; background: var(--orange); color: #000; border: 0;
padding: 16px 0; width: 100%; cursor: pointer; letter-spacing: .08em; text-transform: uppercase; }
button#go:disabled { background: var(--tile); color: var(--dim); cursor: default; }
#status { margin-top: 14px; min-height: 1.6em; font-variant-numeric: tabular-nums; }
.small { color: var(--dim); font-size: 12.5px; }
.small a, a { color: inherit; }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin-top: 16px; border: 0; background: var(--tile); }
progress::-webkit-progress-bar { background: var(--tile); }
progress::-webkit-progress-value { background: var(--orange); }
progress::-moz-progress-bar { background: var(--orange); }
pre { color: var(--dim); font-size: 11px; white-space: pre-wrap; margin-top: 12px; max-height: 160px; overflow: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0 18px; }
.ed { display: inline-block; margin: 8px 0 0; padding: 10px 14px; background: var(--tile); text-decoration: none; }
@media (max-width: 420px) { .tiles { grid-template-columns: repeat(2, 1fr); } .logo svg { width: 170px; } }
</style>
</head>
<body>
<main>
<div class="top"><div class="logo"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 260" width="760" height="260" role="img" aria-label="SLOOP">
<rect width="760" height="260" fill="#000"/>
<path d="M59.29 200.71 A100.00 100.00 0 1 1 200.71 200.71" fill="none" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
<rect x="95.00" y="46.00" width="10" height="136.00" rx="5" fill="#F2F2F2"/>
<polygon points="111.00,50.00 111.00,50.00 131.34,75.00 111.00,75.00" fill="#287CFF"/>
<polygon points="111.00,81.00 136.22,81.00 156.56,106.00 111.00,106.00" fill="#1ECC70"/>
<polygon points="111.00,112.00 161.44,112.00 181.78,137.00 111.00,137.00" fill="#FFC618"/>
<polygon points="111.00,143.00 186.66,143.00 207.00,168.00 111.00,168.00" fill="#FF621A"/>
<rect x="66.00" y="192.00" width="128" height="12" rx="6" fill="#F2F2F2"/>
<path d="M290.88 130.00 A14.88 15.00 0 1 1 304.37 108.66" fill="none" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
<path d="M290.88 130.00 A14.88 15.00 0 1 1 277.39 151.34" fill="none" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
<line x1="337.76" y1="68.00" x2="337.76" y2="160.00" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
<circle cx="399.76" cy="130.00" r="30.00" fill="none" stroke="#F2F2F2" stroke-width="12"/>
<circle cx="489.76" cy="130.00" r="30.00" fill="none" stroke="#F2F2F2" stroke-width="12"/>
<circle cx="579.76" cy="130.00" r="30.00" fill="none" stroke="#F2F2F2" stroke-width="12"/>
<line x1="549.76" y1="130.00" x2="549.76" y2="196.00" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
</svg>
</div><button class="lang" id="lang"></button></div>
<div class="strip"><i></i><i></i><i></i><i></i></div>
<h1>Firmware for the M-VAVE FM-1</h1>
<p class="lead">Hip-hop on the FM-1: four tracks to play live — three synths and a drum machine — 54 sounds from 808s to Rhodes, 34 drum kits, 16 punch-in effects. No factory patterns, nothing to load: everything you hear, you play.</p>
<div class="tiles">
<div class="tile" style="--c: var(--blue)"><b>54</b><span>sounds: 808, rhodes, horns</span></div>
<div class="tile" style="--c: var(--green)"><b>34</b><span>drum kits, 808 to chiptune</span></div>
<div class="tile" style="--c: var(--yellow)"><b>16</b><span>punch-in fx: hold fx + key</span></div>
<div class="tile" style="--c: var(--orange)"><b>rec</b><span>no click: the loop follows you</span></div>
</div>
<p data-t="intro"></p>
<p data-t="warn"></p>
<p><button id="go" disabled data-t="install"></button></p>
<progress id="bar" max="100" value="0"></progress>
<p id="status"></p>
<pre id="log"></pre>
<a class="ed" href="../editor/" data-t="editor"></a>
<hr>
<p class="small" data-t="direct"></p>
<p class="small" data-t="beta"></p>
<p class="small"><span data-t="brick"></span>
<a href="https://github.com/kurogedelic/FM-1-transporter" target="_blank" rel="noopener">FM-1-transporter</a></p>
<p class="small" data-t="back"></p>
<p class="small"><a href="https://www.m-vave.com/download" target="_blank" rel="noopener">www.m-vave.com/download</a></p>
<p class="small">SLOOP is based on Felucca by Leo Kuroshita (@kurogedelic), <a href="https://hugelton.com" target="_blank" rel="noopener">Hügelton Instruments</a>.
Hold OCT− alone while switching on for USB rescue.<br>
Font: Terminus (Dimitar Toshkov Zhekov, SIL OFL 1.1). Samples: Versilian Studios VSCO-2 Community Edition and VCSL (CC0 1.0), and the Hügelton Sample Pack (© Hügelton Instruments, not CC0).<br>
M-VAVE and FM-1 are trademarks of their respective owners; SLOOP is not affiliated with them.<br>
<span data-t="license"></span> <a href="https://github.com/hugelton/Felucca" target="_blank" rel="noopener">github.com/hugelton/Felucca</a></p>
</main>
<script type="module">
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
//
// FM-1 .fwsc packages in the browser: the package identity and the image the
// device reads during an update.
const BLOCKS = 20, BLK = 0x30, KEEP = 0x2F;
// the package identity ("FM-1_904"): one marker byte after each of the first 20 blocks
function productOf(fwsc) {
if (fwsc.length < BLOCKS * BLK) throw new Error("not an FM-1 package (too short)");
let s = "";
for (let i = 0; i < BLOCKS; i++) {
const m = fwsc[i * BLK + KEEP];
if (m !== 0x7D) s += String.fromCharCode((m - i - 1) & 0xFF);
}
return s;
}
// the image the device addresses during an update: the .fwsc without the 20 marker bytes
function logicalImage(fwsc) {
const out = new Uint8Array(fwsc.length - BLOCKS);
for (let i = 0; i < BLOCKS; i++) out.set(fwsc.subarray(i * BLK, i * BLK + KEEP), i * KEEP);
out.set(fwsc.subarray(BLOCKS * BLK), BLOCKS * KEEP);
return out;
}
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
//
// The FM-1 USB-MIDI update protocol (M-UPGRADE compatible) over WebMIDI.
// Step 1: the running firmware reads parts of the package and stages the update
// loader. Step 2: the loader reads the whole image and writes it. In both steps
// the device sends cmd 0x30 read requests on the logical image and we answer.
const HS_QUERY = [0xF0, 0x00, 0x32, 0x45, 0x00, 0x00, 0x00, 0x40, 0x7F, 0xF7];
const UPGRADE = [0xF0, 0x22, 0x24, 0x35, 0x7F, 0xF7];
const MAXDATA = 512;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const IS_OTA = (id) => /^ota-/i.test(id.model);
// the update loader of SLOOP / Felucca packages ("ota-FM-1_9XX"). A device left in the update mode of another
// firmware (the stock updater's loader) is never written: its loader may lay the image out differently.
const OUR_LOADER = (id) => /^ota-FM-1_9\d\d$/i.test(id.text);
// errors carry a code the pages translate: notfound, model, stopped, noloader, lost, noreturn,
// mismatch (detail: the identity the device reports), badreq, foreign (detail: the loader's identity)
function fail(code, msg, detail = "") { const e = new Error(msg); e.code = code; e.detail = detail; return e; }
function pack7(data) {
const out = []; let acc = 0, nb = 0;
for (const b of data) {
acc |= b << nb; nb += 8;
while (nb >= 7) { out.push(acc & 0x7F); acc >>>= 7; nb -= 7; }
}
if (nb) out.push(acc & 0x7F);
return out;
}
function unpack7(s) {
const out = []; let acc = 0, nb = 0;
for (const b of s) {
acc |= (b & 0x7F) << nb; nb += 7;
while (nb >= 8) { out.push(acc & 0xFF); acc >>>= 8; nb -= 8; }
}
return out;
}
function response(addr, data, fl = 0) {
const len = data.length;
const body = [0x00, 0x59, 0x30, (len + 8) & 0xFF, ((len + 8) >> 8) & 0xFF, 0, fl,
addr & 0xFF, (addr >>> 8) & 0xFF, (addr >>> 16) & 0xFF, (addr >>> 24) & 0xFF,
len & 0xFF, (len >> 8) & 0xFF, 0, ...data];
let s = 0;
for (let i = 6; i < body.length; i++) s += body[i];
body.push(~s & 0xFF);
return [0xF0, ...pack7(body), 0xF7];
}
function parseRequest(pkt) {
if (pkt[0] !== 0xF0 || pkt[pkt.length - 1] !== 0xF7) return null;
const u = unpack7(pkt.slice(1, -1));
if (u.length !== 15 || u[0] !== 0 || u[1] !== 0x59 || u[2] !== 0x30) return null;
let s = 0;
for (let i = 6; i < 14; i++) s += u[i];
if ((~s & 0xFF) !== u[14]) return null;
return { fl: u[6], addr: (u[7] | (u[8] << 8) | (u[9] << 16) | (u[10] << 24)) >>> 0, len: u[11] | (u[12] << 8) | (u[13] << 16) };
}
function parseIdentity(pkt) {
const d = unpack7(pkt.slice(1, -1));
if (d.length !== 34 || d[0] !== 0 || d[1] !== 0x59 || d[2] !== 0x11) return null;
const txt = String.fromCharCode(...d.slice(6, 33)).replace(/\0+$/, "");
const m = /^([^_]+)_(\d+)$/.exec(txt);
return m ? { text: txt, model: m[1], version: parseInt(m[2], 10) } : null;
}
// one MIDI in/out pair with a SysEx queue
class Link {
constructor(input, output) {
this.input = input; this.output = output; this.q = []; this.waiter = null;
input.onmidimessage = (ev) => {
if (ev.data[0] !== 0xF0) return;
this.q.push(Array.from(ev.data));
if (this.waiter) { const w = this.waiter; this.waiter = null; w(); }
};
}
get lost() { return this.input.state === "disconnected" || this.output.state === "disconnected"; }
// false when the port is gone (unplugged): WebMIDI throws on a disconnected output
send(bytes) {
try { this.output.send(bytes); return true; } catch (_) { return false; }
}
drain() { this.q.length = 0; }
async read(ms) {
if (!this.q.length) {
let tm;
await Promise.race([new Promise((r) => { this.waiter = r; }), new Promise((r) => { tm = setTimeout(r, ms); })]);
clearTimeout(tm);
this.waiter = null;
}
return this.q.shift() || null;
}
close() { this.input.onmidimessage = null; }
}
async function handshake(link, tries = 3) {
link.drain();
for (let t = 0; t < tries; t++) {
if (!link.send(HS_QUERY)) return null;
const end = Date.now() + 1000;
while (Date.now() < end) {
const p = await link.read(end - Date.now());
if (!p) break;
const id = parseIdentity(p);
if (id) return id;
}
}
return null;
}
class Updater {
constructor(access, log) {
this.access = access;
this.log = log || (() => {});
}
// every in/out pair with the same port name that answers the handshake
async find(filter) {
const outs = [...this.access.outputs.values()];
for (const input of this.access.inputs.values()) {
if (input.state === "disconnected") continue;
if (!/fm-1|felucca|ota|composite|sinco|usb-midi/i.test(input.name || "")) continue; // never probe other gear
const output = outs.find((o) => o.name === input.name) || (outs.length === 1 ? outs[0] : null);
if (!output) continue;
try { await input.open(); await output.open(); } catch (_) { continue; }
const link = new Link(input, output);
const id = await handshake(link, 2);
if (id && (!filter || filter(id))) return { link, id, name: input.name };
link.close();
}
return null;
}
async waitFor(filter, ms) {
const end = Date.now() + ms;
while (Date.now() < end) {
const dev = await this.find(filter);
if (dev) return dev;
await sleep(1000);
}
return null;
}
// serve read requests until the device asks for one of the finish addresses; stops early
// when the port disappears (lost: true) instead of waiting out idleMs
async serve(link, image, finishAddr, idleMs, onProgress) {
let served = 0, last = Date.now();
for (;;) {
const pkt = await link.read(1000);
if (!pkt) {
if (link.lost) return { served, finished: false, lost: true };
if (Date.now() - last > idleMs) return { served, finished: false };
continue;
}
const r = parseRequest(pkt);
if (!r) continue;
last = Date.now();
if (r.addr === 0xE0000000 || r.addr === 0xF0000000) {
link.send(response(r.addr, [...new TextEncoder().encode("success"), 0]));
if (r.addr === finishAddr) return { served, finished: true };
continue;
}
if (r.len > MAXDATA || r.addr + r.len > image.length) throw fail("badreq", `bad request ${r.addr.toString(16)}+${r.len}`);
await sleep(10);
if (!link.send(response(r.addr, Array.from(image.subarray(r.addr, r.addr + r.len)), r.fl))) {
return { served, finished: false, lost: true };
}
served++;
if (onProgress) onProgress(served, r.addr);
}
}
// full install: running firmware -> loader -> new firmware
async install(image, product, onStep) {
const step = onStep || (() => {});
const dev = await this.find((id) => !IS_OTA(id));
if (!dev) throw fail("notfound", "FM-1 not found (USB cable, and no other app using it?)");
const [model] = product.split("_");
if (dev.id.model !== model) { dev.link.close(); throw fail("model", `the device is ${dev.id.text}, the package is for ${product}`); }
step("start", dev.id.text);
dev.link.send(UPGRADE);
await sleep(2000);
const s1 = await this.serve(dev.link, image, 0xE0000000, 8000, (n) => step("verify", n));
dev.link.close();
if (!s1.finished) throw fail(s1.lost ? "lost" : "stopped", `the device ${s1.lost ? "was disconnected" : "stopped"} after ${s1.served} requests: nothing was written`);
step("loader");
await sleep(3000);
const ota = await this.waitFor(IS_OTA, 30000);
if (!ota) throw fail("noloader", "the update loader did not appear. Replug the USB cable and press Install again: the device stays in update mode until it is finished.");
const s2 = await this.write(ota, image, step);
if (!s2.finished) throw fail(s2.lost ? "lost" : "stopped", `the loader ${s2.lost ? "was disconnected" : "stopped"} after ${s2.served} requests. Replug and press Install again to resume.`);
step("reboot");
await sleep(3000);
const back = await this.waitFor((id) => !IS_OTA(id), 40000);
if (!back) throw fail("noreturn", "the device did not come back: power-cycle it");
back.link.close();
if (back.id.text !== product) throw fail("mismatch", `installed, but the device reports ${back.id.text}`, back.id.text);
step("done", back.id.text);
return back.id.text;
}
// step 2 with the loader found by find()/waitFor()
async write(ota, image, step) {
ota.link.send(UPGRADE);
await sleep(2000);
const s2 = await this.serve(ota.link, image, 0xF0000000, 180000, (n) => step("write", n));
ota.link.close();
return s2;
}
// resume: the device is already in update mode (loader) -> true when the write finished
async resume(image, onStep) {
const ota = await this.find(IS_OTA);
if (!ota) return false;
if (!OUR_LOADER(ota.id)) {
ota.link.close();
throw fail("foreign", `the FM-1 is in the update mode of another firmware (${ota.id.text}): finish that update with its own updater`, ota.id.text);
}
return (await this.write(ota, image, onStep || (() => {}))).finished;
}
}
const $ = (id) => document.getElementById(id);
const TEXT = {
ja: {
intro: "FM-1 を USB で接続してください。(Chrome か Edge で使えます)",
warn: "書き込み中は USB を抜かないでください。",
install: "インストール", other: "English",
editor: "エディタ(インストール後、パソコンから音色やシーケンスを編集)",
direct: "USB ケーブルはパソコンに直接つないでください。Probe や Transporter などの機材は不要です。",
brick: "万一インストールに失敗して起動しなくなった場合は、復旧に Transporter が必要です:",
beta: "これはベータ版で、不安定な場合があります。このカスタムファームウェアを使ったことで FM-1 が壊れたり不具合が起きたりしても、作者は一切の責任を負いません。自己責任でお使いください。",
back: "公式ファームウェアに戻すには、M-VAVE 公式のアップデーター M-UPGRADE(Downloads → PC Software → M-UPGRADE)と公式ファームウェア(PC Firmware → FM-1 V15)が必要です。",
nomidi: "このブラウザでは使えません。Chrome か Edge で開いてください。", loadfail: "読み込めませんでした: ",
start: "開始します", verify: "確認中", loader: "書き込みモードに切り替え中", write: "書き込み中",
reboot: "再起動中", done: "完了しました", stopped: "途中で止まりました。USB を挿し直してもう一度押してください。",
error: "エラー: ",
denied: "MIDI(SysEx)の使用が許可されませんでした。アドレスバーのサイト設定で MIDI を許可して、もう一度押してください。",
notfound: "FM-1 が見つかりません。USB ケーブル(データ通信用か)を確かめ、MIDI を使う他のアプリを閉じてから、もう一度押してください。",
model: "接続されている機器は FM-1 ではありません。",
lost: "USB の接続が切れました。挿し直してもう一度押してください。",
noloader: "書き込みモードの FM-1 が見つかりません。USB を挿し直してもう一度押してください(終わるまで書き込みモードのままです)。",
noreturn: "FM-1 が戻ってきません。電源を入れ直してください。",
mismatch: "書き込みは終わりましたが、FM-1 が別のバージョンを報告しています: ",
foreign: "FM-1 は別のファームウェアの書き込みモードです。そのアップデーター(M-UPGRADE)で書き込みを終えてから、もう一度インストールしてください: ",
badpkg: "インストールするファイルが壊れています。ページを再読み込みしてください。",
leave: "書き込み中です。ページを閉じないでください。",
license: "GPL-3.0、無保証。ソース:",
},
en: {
intro: "Connect the FM-1 by USB. (Works in Chrome or Edge.)",
warn: "Do not unplug the USB cable while writing.",
install: "Install", other: "日本語",
editor: "Editor (after installing: edit sounds and sequences from the computer)",
direct: "Connect the USB cable directly to the computer. No probe or Transporter is needed.",
brick: "If an install fails and the FM-1 no longer starts, recovering it needs a Transporter:",
beta: "This is a beta and may be unstable. The author accepts no responsibility if your FM-1 is damaged or misbehaves because of this custom firmware. Use it at your own risk.",
back: "To go back to the official firmware you need M-VAVE's official updater, M-UPGRADE (Downloads → PC Software → M-UPGRADE), and the official firmware (PC Firmware → FM-1 V15).",
nomidi: "This browser cannot do it. Open the page in Chrome or Edge.", loadfail: "Could not load: ",
start: "Starting", verify: "Verifying", loader: "Switching to update mode", write: "Writing",
reboot: "Restarting", done: "Done", stopped: "Stopped. Replug the USB cable and press Install again.",
error: "Error: ",
denied: "MIDI (SysEx) access was not allowed. Allow MIDI in the site settings (address bar) and press Install again.",
notfound: "FM-1 not found. Check the USB cable (a data cable), close other apps that use MIDI, and press Install again.",
model: "The connected device is not an FM-1.",
lost: "The USB connection was lost. Replug it and press Install again.",
noloader: "The FM-1 in update mode was not found. Replug the USB cable and press Install again (it stays in update mode until it is finished).",
noreturn: "The FM-1 did not come back. Power-cycle it.",
mismatch: "Written, but the FM-1 reports another version: ",
foreign: "The FM-1 is in the update mode of another firmware. Finish that update with its own updater (M-UPGRADE), then press Install again: ",
badpkg: "The file to install is damaged. Reload the page.",
leave: "Writing. Do not close the page.",
license: "GPL-3.0, no warranty. Source:",
},
};
let lang = (navigator.language || "en").toLowerCase().startsWith("ja") ? "ja" : "en";
const t = (k) => TEXT[lang][k];
let lastKey = null, lastArg = "";
function applyLang() {
document.documentElement.lang = lang;
document.querySelectorAll("[data-t]").forEach((e) => { e.textContent = t(e.dataset.t); });
$("lang").textContent = t("other");
if (lastKey) $("status").textContent = t(lastKey) + lastArg;
}
$("lang").addEventListener("click", () => { lang = lang === "ja" ? "en" : "ja"; applyLang(); });
applyLang();
const sayK = (k, arg = "") => { lastKey = k; lastArg = arg; $("status").textContent = t(k) + arg; };
const say = (txt) => { lastKey = null; $("status").textContent = txt; };
const log = (t) => { $("log").textContent += t + "\n"; };
let image = null;
const meta = {"version": "2.0", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.0.fwsc", "sha256": "dbafa1eec6940ba4fd1597dd5b1be38f0ddf2e7cf26529ebd2fbaa71625a6617"};
let writing = false;
window.addEventListener("beforeunload", (e) => { if (writing) { e.preventDefault(); e.returnValue = t("leave"); } });
(async () => {
if (!navigator.requestMIDIAccess) { sayK("nomidi"); return; }
try {
const r = await fetch(meta.pkg);
if (!r.ok) throw new Error(`${meta.pkg}: HTTP ${r.status}`);
const pkg = new Uint8Array(await r.arrayBuffer());
if (productOf(pkg) !== meta.product) { sayK("badpkg"); return; }
if (meta.sha256 && self.crypto && crypto.subtle) { /* a damaged download is never offered (the loader checks its CRC too) */
const h = [...new Uint8Array(await crypto.subtle.digest("SHA-256", pkg))].map((b) => b.toString(16).padStart(2, "0")).join("");
if (h !== meta.sha256) { sayK("badpkg"); log(`sha256 ${h}, expected ${meta.sha256}`); return; }
}
image = logicalImage(pkg);
say(`SLOOP ${meta.version}`);
$("go").disabled = false;
} catch (e) { sayK("loadfail", e.message); }
})();
$("go").addEventListener("click", async () => {
$("go").disabled = true;
let midi;
try { midi = await navigator.requestMIDIAccess({ sysex: true }); }
catch (e) { sayK("denied"); $("go").disabled = false; return; }
writing = true;
try {
const up = new Updater(midi, log);
const total = 74 + 1179; /* reads: step 1, step 2 (head + app area, SLOOP 2.0 loader) */
const step = (k, a) => {
log(`${k} ${a ?? ""}`);
if (k === "start") sayK("start");
if (k === "verify") { sayK("verify"); $("bar").value = (a / total) * 100; }
if (k === "loader") sayK("loader");
if (k === "write") { sayK("write"); $("bar").value = ((74 + a) / total) * 100; }
if (k === "reboot") sayK("reboot");
if (k === "done") { $("bar").value = 100; sayK("done"); }
};
const ota = await up.find((id) => /^ota-/i.test(id.model));
if (ota) {
ota.link.close();
sayK((await up.resume(image, step)) ? "done" : "stopped");
} else {
await up.install(image, meta.product, step);
}
} catch (e) {
if (e && e.code && TEXT[lang][e.code]) sayK(e.code, e.detail || "");
else sayK("error", e && e.message);
log(String(e && e.stack || e));
}
writing = false;
$("go").disabled = false;
});
</script>
</body>
</html>