Files
JIANT/web/studio/smk37/index.html
T

147 lines
11 KiB
HTML

<!doctype html><html lang="es"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>JIANT · Instalador SMK-37</title>
<style>
:root{color-scheme:dark;font:17px/1.55 system-ui;background:#131215;color:#f6f2ec}
body{max-width:700px;margin:5vh auto;padding:24px}h1{line-height:1.1;font-size:clamp(2rem,7vw,3.5rem);margin:.15em 0 .4em}
a{color:#ffc084}small{color:#ffc084}section{border-top:1px solid #686168;margin-top:24px;padding-top:18px}
button{font:inherit;font-weight:650;padding:10px 18px;margin:8px 8px 8px 0;border:0;border-radius:5px;background:#ffc084;color:#171012}
button:disabled{background:#38343a;color:#aaa}label{display:block;margin:15px 0}pre{white-space:pre-wrap;overflow-wrap:anywhere;font:14px/1.5 monospace}
</style><body><small>JIANT FM</small><h1>Instalador SMK-37</h1>
<p>JIANT FM V10.8.48 para M-VAVE SMK-37 Pro y Elite: desde el firmware de fábrica v016 o actualizando un JIANT ya instalado. Distribución estilo Rhythmer: las 37 teclas con escalas y acordes, pads PLAY/STEPS, faders con bancos LEVEL/PAN/REVERB/DELAY, ruedas, pedal y MIDI OUT por el jack (<a href="https://github.com/juanjiant-bit/JIANT/blob/0d353032fea9cf8f4fa805221d2401915e71e5d7/docs/SMK37.md" target="_blank" rel="noopener">controles</a>). Sin Bluetooth en el SMK. Conectá únicamente el teclado a probar por USB de datos y cerrá el editor, el DAW y el actualizador de M-VAVE.</p>
<p>La instalación reemplaza el firmware. Tené a mano el firmware oficial de tu modelo (abajo). Los proyectos y ajustes de esta versión de JIANT se pierden al apagar.</p>
<section><button id="detect">Detectar teclado</button><output id="device" aria-live="polite"></output>
<label><input type="checkbox" id="accept" disabled> Quiero instalar JIANT en el teclado detectado.</label>
<button id="install" disabled>Instalar JIANT</button><p id="status" role="status">La detección solo consulta la identidad MIDI.</p>
<p id="stock" hidden><a href="https://www.m-vave.com/download" target="_blank" rel="noopener">Descargas oficiales de M-VAVE</a> · Elegí M-UPGRADE y el firmware SMK-37 PRO V016.</p>
</section><section id="stocksec"><h2 style="margin:.2em 0">Volver al firmware oficial de M-VAVE</h2>
<p>Para volver al firmware de fábrica, o pasar de V015 a V016: bajá el archivo oficial de <b>tu</b> modelo desde M-VAVE, soltalo acá e instalalo. JIANT no guarda nada en la flash del SMK (solo en RAM), así que la calibración y el mapa de teclas de fábrica siguen intactos.</p>
<p>Descargas oficiales (servidor de M-VAVE): <a id="dlpro" download>SMK-37 Pro V016</a> · <a id="dlelite" download>SMK-37 Elite V016</a> · <a href="https://www.m-vave.com/download" target="_blank" rel="noopener">página de descargas de M-VAVE</a></p>
<label id="sdrop" style="display:block;border:1px dashed #686168;border-radius:6px;padding:16px;cursor:pointer"><input type="file" id="sfile" accept=".fwsc" hidden><span id="sdroptext">Soltá acá el .fwsc oficial, o tocá para elegirlo</span></label>
<p id="sinfo" role="status"></p>
<label><input type="checkbox" id="saccept" disabled> Quiero instalar este firmware oficial en el teclado conectado.</label>
<button id="sinstall" disabled>Instalar firmware oficial</button></section>
<section><details><summary>Registro de la sesión</summary><pre id="log"></pre></details></section><small><a href="https://github.com/juanjiant-bit/JIANT/tree/0d353032fea9cf8f4fa805221d2401915e71e5d7">Código y licencias del firmware</a></small>
<script type="module">
import {Updater} from './fm1ota.js';
import {productOf, logicalImage, sha256hex} from './fm1pkg.js';
const images = {
"SMK-37 Pro": {file:"felucca-smk37-pro.fwsc", sha:"0a161a65cfc3dbb30d576c7f804eccf53bc470a995a09692d74ceddd03ab73d5"},
"SMK-37 Elite": {file:"felucca-smk37-elite.fwsc", sha:"d0f7d50e5cbe1c2325270f6fc570026704122612f19cdc8716f1839ea6d12ef5"}
};
const get = id => document.getElementById(id);
const detect = get('detect'), accept = get('accept'), install = get('install');
let selection, busy = false;
const log = s => { get('log').textContent += s + '\n'; };
const status = s => { get('status').textContent = s; log(s); };
const midi = () => navigator.requestMIDIAccess({sysex:true});
function classify(text) {
const match = /^(ota-)?(SMK-37 (?:Elite|Pro))_(\d+)$/.exec(text);
if (!match) return null;
const [, loader, model, version] = match;
// the stock firmware (V016), JIANT already on it (9xx: an update) or JIANT's update loader (ota-…_900)
if (loader ? version !== '900' : version !== '016' && !/^9\d\d$/.test(version)) return null;
return {model, loader: Boolean(loader), id:text, jiant: !loader && version !== '016'};
}
async function imageFor(model) {
const p = images[model];
const response = await fetch(p.file);
if (!response.ok) throw Error('No se pudo descargar el firmware de ' + model);
const bytes = new Uint8Array(await response.arrayBuffer());
if (await sha256hex(bytes) !== p.sha || !productOf(bytes).startsWith(model + '_9'))
throw Error('El paquete integrado no pasó la verificación.');
return {image: logicalImage(bytes), product: productOf(bytes)};
}
async function run(task) {
if (busy) return;
busy = true; detect.disabled = accept.disabled = install.disabled = true;
try { await task(); } catch (e) { selection = null; status('Se detuvo el proceso. ' + e.message); }
finally { busy = false; detect.disabled = false; accept.disabled = !selection; install.disabled = !selection || !accept.checked; if (typeof slock === 'function') slock(); }
}
function updater(access) { return new Updater(access, log, {refresh:midi}); }
detect.onclick = () => run(async () => {
selection = null; accept.checked = false; get('device').textContent = ''; get('stock').hidden = true;
if (!navigator.requestMIDIAccess) throw Error('Abrí el HTML en Chrome o Edge de escritorio con Web MIDI.');
status('Consultando el teclado…');
const up = updater(await midi());
const dev = await up.find(null, {tries:2});
if (!dev) throw Error('Sin respuesta de identidad. Revisá el cable USB, el permiso MIDI y las otras aplicaciones.');
dev.link.close();
get('device').textContent = dev.id.text;
if (dev.id.text === 'SMK-37 Pro_015') {
get('stock').hidden = false;
status('Tu Pro tiene V015. Actualizá primero a V016 con M-UPGRADE y volvé a detectar el teclado.');
return;
}
const target = classify(dev.id.text);
if (!target) throw Error('Teclado no compatible: ' + dev.id.text);
await imageFor(target.model);
selection = target;
install.textContent = target.loader ? 'Reanudar escritura' : target.jiant ? 'Actualizar JIANT' : 'Instalar JIANT';
status('Paquete verificado para ' + target.model + '.');
});
accept.onchange = () => { install.disabled = busy || !selection || !accept.checked; };
install.onclick = () => run(async () => {
const target = selection;
if (!target || !accept.checked) return;
const {image, product} = await imageFor(target.model);
const up = updater(await midi());
const step = (s, value) => {
if (s === 'write' || s === 'verify') {
get('status').textContent = (s === 'write' ? 'Escribiendo' : 'Comprobando') + ' · petición ' + value;
} else status(({start:'Iniciando actualización',loader:'Esperando el cargador de ' + target.model,
reboot:'Esperando el reinicio',done:'Identidad confirmada tras el reinicio'})[s] + (value ? ' · ' + value : ''));
};
selection = null; accept.checked = false;
if (target.loader) {
if (!await up.resume(image, step, product, target.id)) throw Error('El cargador no completó la transferencia.');
} else await up.install(image, product, step); // (the loader says _900 whatever the package's _9xx: found by model)
status('Instalación verificada por USB. Probá pantalla, audio, teclas y pads.');
});
/* back to M-VAVE's firmware: a package the user downloaded from M-VAVE (never shipped here), read by smkstock.js
(the 36-block layout, its CRCs, an SMK-37 Pro / Elite identity with a stock version), written as any install */
import {identifyStockPackage, STOCK_URLS} from './smkstock.js';
get('dlpro').href = STOCK_URLS['SMK-37 Pro']; get('dlelite').href = STOCK_URLS['SMK-37 Elite'];
let stockPkg = null;
const sinfo = s => { get('sinfo').textContent = s; log(s); };
const slock = () => { get('saccept').disabled = busy || !stockPkg; get('sinstall').disabled = busy || !stockPkg || !get('saccept').checked; };
async function stockFile(file) {
if (!file || busy) return;
stockPkg = null; get('saccept').checked = false; get('sdroptext').textContent = file.name;
try {
stockPkg = await identifyStockPackage(new Uint8Array(await file.arrayBuffer()));
sinfo('Firmware oficial de M-VAVE: ' + stockPkg.name + ' V' + stockPkg.version + (stockPkg.known ? ' (versión conocida).' : ' (estructura verificada).') +
' Conectá el teclado de ese modelo e instalalo.');
} catch (e) {
sinfo({ours:'Es un firmware de la comunidad, no el oficial: para JIANT usá el instalador de arriba.',
damaged:'El archivo está dañado: bajalo de nuevo de M-VAVE y soltalo sin cambios.'}[e.code] ||
'No es un firmware oficial de M-VAVE para el SMK-37 Pro o Elite.');
}
slock();
}
get('sfile').onchange = e => stockFile(e.target.files[0]);
const sdrop = get('sdrop');
sdrop.addEventListener('dragover', e => e.preventDefault());
sdrop.addEventListener('drop', e => { e.preventDefault(); stockFile(e.dataTransfer.files[0]); });
get('saccept').onchange = slock;
get('sinstall').onclick = () => run(async () => {
const k = stockPkg;
if (!k || !get('saccept').checked) return;
get('saccept').checked = false;
if (!navigator.requestMIDIAccess) throw Error('Abrí la página en Chrome o Edge de escritorio con Web MIDI.');
const up = updater(await midi());
const step = (s, value) => {
if (s === 'write' || s === 'verify') get('status').textContent = (s === 'write' ? 'Escribiendo' : 'Comprobando') + ' · petición ' + value;
else status(({start:'Iniciando actualización', loader:'Esperando el cargador de ' + k.name, reboot:'Esperando el reinicio',
done:'Identidad confirmada tras el reinicio'})[s] + (value ? ' · ' + value : ''));
};
const ota = await up.find(id => /^ota-/i.test(id.model), {tries:1});
if (ota) { // already in update mode: the official package finishes it
ota.link.close();
if (!await up.resume(k.image, step, k.product)) throw Error('El cargador no completó la transferencia. Reconectá el USB y volvé a instalar.');
} else await up.install(k.image, k.product, step); // (the device's model must be the package's: checked there)
status('Listo: el teclado tiene el firmware oficial ' + k.product + '. M-UPGRADE vuelve a funcionar si lo necesitás.');
});
slock();
window.addEventListener('beforeunload', e => { if (busy) { e.preventDefault(); e.returnValue = ''; } });
</script></body></html>