mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 04:44:33 +01:00
- Emulator view: the panel fitted to its frame (all of it in sight), a Full screen button (the browser's own, else the frame over the page on iPhone), refitted in portrait and landscape. - devices.html: the MPC Sample back to the unit's proportions (its screen at its size in the top band) and the SMK-37's 1.54" screen to scale; each screen larger beside the panel (bigScreen). Studio's frame for them grows to the page, no scrolling inside. - tools/gen_manual_html.py: the manuals in JIANT's look (Michroma, the heat, the HUD cards, a manuals bar, the contents following the reading), and a page for each port's doc: SMK-37, MPC Sample, the MPC plugin and ports, the VST3/AU/LV2 plugin, each with its shot. - Other devices: each port's shots (the SMK-37 and MPC panels running, the plugin's three editor pages), a tap opens them large; the Manual links go to the HTML manuals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVqsRnhKjiABTzc6Ety3dd
1121 lines
80 KiB
JavaScript
1121 lines
80 KiB
JavaScript
// SPDX-License-Identifier: GPL-3.0-only
|
||
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)
|
||
// JIANT Studio (index.html): one page for JIANT FM and JIANT BYTE. What it does itself: finds the FM-1 and says which
|
||
// firmware it runs (INFO: BYTE's engines include MATH), shows its screen big (78 SCREEN / 79 SCREEN_DATA, as the editor's
|
||
// mirror) or the emulator's, and records audio (the FM-1's USB audio: stereo, or the 8 channels of USB > STEMS; or the
|
||
// emulator's output) and MIDI. The installer, the editor and the emulator are the sites' own pages in frames (one origin:
|
||
// /JIANT/ and /JIANT-BYTE/ on juanjiant-bit.github.io), dressed in the firmware's look.
|
||
// Install safety: the BroadcastChannel "jiant-midi" (as every MIDI page of both sites): while an installer writes, this
|
||
// page lets the FM-1 go (link closed, screen off) and says "released"; the editor and the emulator in the frames do the
|
||
// same on their own.
|
||
import { scrDecode, scrEncode, wavFile, zipStored, midiFile, SCR } from "./studio-lib.js";
|
||
import { Daw } from "./daw.js";
|
||
|
||
const $ = (id) => document.getElementById(id);
|
||
const QS = new URLSearchParams(location.search);
|
||
const MOCK = QS.get("mock") === "1";
|
||
|
||
/* ------------------------------------------------------------------------------------------------- the words */
|
||
const TEXT = {
|
||
es: {
|
||
other: "English", vPorts: "Otros aparatos", vHome: "Inicio", vInstall: "Instalar", vEditor: "Editor", vScreen: "Pantalla", vEmu: "Emulador", vRec: "Grabar",
|
||
tFm1: "FM-1", tEmu: "Emulador", target: "Destino",
|
||
eyebrow: "Un firmware libre para la M-VAVE FM-1",
|
||
leadFm: "Síntesis, secuencias, mutación y escena en vivo. Instalalo, editalo, mirá su pantalla en grande y grabá, todo desde acá.",
|
||
leadByte: "Bytebeat y floatbeat: cada sonido, batería y animación es una fórmula del tiempo. Instalalo, editalo y grabá desde acá.",
|
||
needBrowser: "Chrome o Edge", needCable: "Un cable USB de datos", needPhone: "Celular Android con USB-C (OTG)",
|
||
s1Title: "Conectá la FM-1", s1Text: "Enchufala directo a esta computadora o celular, sin hub, y prendela. Cuando el navegador pida usar dispositivos MIDI, elegí Permitir.",
|
||
find: "Buscar FM-1", forget: "Soltar la FM-1",
|
||
s2Title: "Instalá o actualizá", s2Text: "Elegí el firmware. Antes de escribir, el instalador hace un backup y todas las demás herramientas sueltan la FM-1 solas.",
|
||
fmPitch: "Seis pistas vivas, once motores, secuenciador de 64 pasos, canciones, generador y efectos.",
|
||
bytePitch: "Fórmulas como voces: MATH, WAVE y DRUM-X con fórmulas. LIFE: las pistas se escuchan entre sí.",
|
||
s3Title: "Usala", s3Text: "Todo con la misma conexión. Arriba elegís si trabajás con la FM-1 por USB o con el emulador.",
|
||
toolEditor: "Sonidos, pasos, pistas, proyectos y backups desde la computadora.",
|
||
toolScreen: "La pantalla de la FM-1 en grande, a pantalla completa en el celular.",
|
||
toolEmu: "La FM-1 en el navegador, con sonido. Tocala con un teclado MIDI.",
|
||
toolRec: "Master o stems en WAV, y lo que tocaste en MIDI.",
|
||
hSafeQ: "¿Es seguro tener el editor o el emulador abiertos mientras instalo?",
|
||
hSafeA: "Sí. Cuando el instalador empieza a escribir, avisa a todas las pestañas y marcos de JIANT FM y JIANT BYTE: el editor se desconecta, la pantalla se apaga y el emulador deja de escuchar MIDI, y el instalador espera a que cada uno confirme antes de mandar el primer byte. Nadie se vuelve a conectar hasta que termina. Cerrá otros programas de música que usen la FM-1 (un DAW, otro editor): esos no se enteran.",
|
||
hStopQ: "Si la instalación se cortó", hStopA: "La FM-1 queda en modo actualización: volvé a enchufarla (o prendela) en esta misma página y la instalación sigue desde donde quedó.",
|
||
hDeadQ: "Si la FM-1 no arranca", hDeadA: "Abrí Instalar: el instalador la encuentra en modo actualización y la recupera. Si ni así responde, hace falta un FM-1-transporter (está explicado en el instalador).",
|
||
hPhoneQ: "¿Funciona en el celular?", hPhoneA: "En Android con Chrome, enchufando la FM-1 al USB-C del teléfono (un cable o adaptador OTG). En iPhone no: Safari no tiene Web MIDI.",
|
||
devNone: "sin FM-1", devLooking: "buscando…", devGone: "FM-1 desconectada", devBusy: "instalando en otra pestaña", devMock: "(simulada)",
|
||
found: "Encontrada: ", foundNot: "No aparece ninguna FM-1 con JIANT. Si tiene otro firmware o el oficial, instalá JIANT FM o JIANT BYTE desde el paso 2.",
|
||
noMidi: "Este navegador no tiene Web MIDI: usá Chrome o Edge (en iPhone no hay).", denied: "El navegador no dio permiso para MIDI.",
|
||
nowBusy: "Un instalador está escribiendo: la FM-1 quedó libre para él.",
|
||
instTitleFm: "JIANT FM", instTitleByte: "JIANT BYTE",
|
||
instSafe: "Mientras el instalador escribe, el editor, la pantalla y el emulador de esta página (y de otras pestañas) sueltan la FM-1 y esperan. No desenchufes ni apagues la FM-1 hasta que termine.",
|
||
edTarget: "Destino: ", edEmuNote: "Editando el emulador: el editor habla con la FM-1 del navegador (pestaña Emulador). Prendelo ahí primero.",
|
||
scrTitle: "La pantalla, en grande", scrStart: "Mostrar", scrStop: "Detener", scrFull: "Pantalla completa", scrExitFull: "Salir",
|
||
scrSharp: "Píxeles nítidos", scrWaitFm1: "Conectá la FM-1 (Inicio) y tocá Mostrar.", scrWaitEmu: "Prendé el emulador en la pestaña Emulador y tocá Mostrar.",
|
||
scrNo: "Este firmware no tiene espejo de pantalla: actualizá JIANT FM o JIANT BYTE.",
|
||
scrNoFw: "Tu FM-1 tiene %s, que todavía no trae el espejo de pantalla: llega con la próxima versión del firmware. Mientras tanto, elegí Emulador arriba y mirá la pantalla del emulador.",
|
||
scrNoShort: "sin espejo de pantalla (llega en la próxima versión)",
|
||
scrHelpFm1: "La FM-1 manda solo lo que cambia: una pantalla quieta no cuesta nada. Mientras se ve acá, la interfaz de la FM-1 puede ir un poco más lenta en páginas muy animadas; el sonido no cambia.",
|
||
scrHelpEmu: "La pantalla del emulador, cuadro a cuadro.",
|
||
scrOrient: "La pantalla de la FM-1 es cuadrada (240 × 240). En vertical ocupa todo el ancho; en horizontal, todo el alto, con los controles al costado. A pantalla completa queda centrada y lo más grande posible en las dos posiciones: girá el celular como te quede cómodo.",
|
||
scrRate: " KB/s", scrFps: " cuadros/s", scrWaiting: "esperando la imagen…",
|
||
emuMidi: "MIDI que toca el emulador", emuMidiAll: "Todas las entradas", emuMidiNone: "Ninguna", emuMidiOff: "(prendé el emulador)",
|
||
recTitle: "Grabar", recAudio: "Audio", recInput: "Entrada", recStart: "Grabar", recStop: "Detener",
|
||
recProfile: "Modo USB de la FM-1 (MENU › SYSTEM › USB)", profAuto: "Detectar por los canales que llegan",
|
||
profMaster: "AUDIO · STEREO · IN+OUT: el master (2 canales)", profStems: "STEMS: 8 canales (T1–T6, FX L R)",
|
||
profStemsIn: "STEMS+IN: 10 canales (T1–T6, FX L R, VOX, DRY)",
|
||
profHelp_auto: "Studio mira cuántos canales llegan y los nombra: 2 el master, 8 STEMS, 10 STEMS+IN. Después de cambiar el modo en la FM-1, desenchufala y enchufala.",
|
||
profHelp_master: "En la FM-1: MENU › SYSTEM › USB › AUDIO (o STEREO, o IN+OUT) y reenchufá. Llega el master estéreo, como suena.",
|
||
profHelp_stems: "En la FM-1: MENU › SYSTEM › USB › STEMS y reenchufá. Cada pista en mono antes del master (sin limitador ni MASTER) y la vuelta de efectos en estéreo: su suma es la mezcla. USB LEVEL en −6 dB o menos deja margen.",
|
||
profHelp_stemsin: "En la FM-1: MENU › SYSTEM › USB › STEMS+IN y reenchufá. Como STEMS más dos canales de voz: VOX (la voz como la mezcló la última pista) y DRY (la voz como llegó); lo que suena en este dispositivo entra a la FM-1 como voz.",
|
||
recMonitor: "Probar entrada", recMonitorStop: "Cerrar entrada", recPlay: "▶ Escuchar la toma", recPlayStop: "■ Parar",
|
||
recDawEmpty: "Tocá Probar entrada: aparece un carril por cada canal que llega, con su nivel. Grabar dibuja cada pista mientras suena.",
|
||
recFewerLong: "Llegan %got canales y el modo de la FM-1 manda %need. Chrome en Android entrega como mucho 2 (son T1 y T2, o el master): el navegador no puede leer el audio USB de otra forma (protege las interfaces de audio). Para los stems en vivo: Chrome o Edge en una computadora (Mac, Windows o Linux), o la app JIANT Probe en el celular; o los stems de una canción desde un backup (abajo), exactos y sin límite.",
|
||
laneTrack: "pista, mono", lane_L: "master izquierdo", lane_R: "master derecho", lane_FXL: "efectos, izquierda", lane_FXR: "efectos, derecha",
|
||
lane_VOX: "la voz mezclada", lane_DRY: "la voz como llegó", recMute: "Silenciar", recSolo: "Solo",
|
||
stWhat: "Qué", stLive: "La sección que suena (8 compases)", stGo: "Stems desde la FM-1", stFile: "…o desde un backup",
|
||
stReading: "Leyendo el backup de la FM-1… ", stRender: "Armando los stems: ", stDone: "Listo: las pistas están arriba.", stNeedDev: "Conectá la FM-1 (Inicio) o elegí un archivo de backup.",
|
||
recSaved: "Toma guardada: está abajo, en Tomas.",
|
||
recSrcFm1: "La FM-1 por USB es una entrada de audio: estéreo (USB > AUDIO), u 8 canales en USB > STEMS (las 6 pistas y los efectos por separado). Elegila acá.",
|
||
recSrcEmu: "Graba la salida del emulador (prendelo en la pestaña Emulador).",
|
||
recNoDev: "No hay entradas de audio (dale permiso al micrófono para verlas).", recAsk: "Pedir permiso de audio",
|
||
recMidi: "MIDI", recMidiHelp: "Mientras grabás, también se guarda lo que entra por MIDI: lo que tocás en la FM-1 (MENU > MIDI OUT) o en un teclado.",
|
||
recMidiIn: "Entrada MIDI", recMidiNone: "(ninguna)",
|
||
recStems: "Stems de una canción", recStemsHelp: "Exactos y sin límite de canales, también en el celular: Studio lee la canción de la FM-1 por USB (o un archivo de backup) y la toca en el emulador una vez por pista. Cada pista en su WAV, alineadas al sample.",
|
||
recStemsGo: "Abrir el emulador",
|
||
recTakes: "Tomas", recNone: "Todavía no grabaste nada.", recWav: "WAV master", recStemsZip: "Stems (ZIP)", recMid: "MIDI",
|
||
recChannels: " canales", recNotes: " notas",
|
||
portsTitle: "JIANT FM en otros aparatos",
|
||
portsLead: "El mismo firmware, de las mismas fuentes, en otras máquinas: una canción suena igual en todas. En las CPU grandes suma los motores SAMPLE y GRAIN, DRUM-X con samples y 8 voces por pista. Todos gratis y GPL-3.0; algunos todavía buscan quién los pruebe.",
|
||
shotSmk: "el panel del SMK-37 con JIANT en el emulador", shotMpc: "la MPC Sample con JIANT en el emulador",
|
||
shotDaw: "el editor del plugin: pantalla en vivo y pistas", shotDawSound: "el editor del plugin: el sonido",
|
||
shotDawSamples: "el editor del plugin: el explorador de samples", portsManuals: "Manuales",
|
||
portsHow: "Cómo funcionan", portTry: "Probar en el navegador", portDownload: "Descargar", portManual: "Manual", portInstall: "Cómo instalar",
|
||
portSource: "Código", portBuild: "Compilar", portSoon: "Instalador: próximamente",
|
||
stOk: "funciona", stPreview: "preview: buscamos testers", stDev: "en desarrollo", stCi: "compilado en CI",
|
||
pSmkTitle: "M-VAVE SMK-37 Pro / Elite", pSmkText: "JIANT directo en el chip del SMK-37 (el mismo AC791N que la FM-1): 37 teclas, 16 pads RGB, 8 encoders y 4 faders como panel. Usa el mismo editor web.",
|
||
pSmk1: "Pads con color por pista", pSmk2: "El mismo editor y los mismos sonidos que la FM-1",
|
||
pMpcTitle: "Akai MPC Sample", pMpcText: "JIANT como el instrumento entero de la MPC Sample: su pantalla, sus pads, botones y perillas como el panel de la FM-1, arrancando desde la microSD.",
|
||
pMpc1: "SAMPLE, GRAIN y DRUM-X con samples", pMpc2: "16 slots de samples de 60 s, grabación desde la entrada",
|
||
pPlugMpcTitle: "Plugin para MPC", pPlugMpcText: "JIANT FM como instrumento dentro de las MPC standalone (MPC OS 3.10.1 o más nuevo) y de hosts VST2 de escritorio.",
|
||
pPlugMpc1: "ARM32, ARM64 y escritorio", pPlugMpc2: "Pasa el simulador de host del SDK; falta probarlo en una MPC",
|
||
pDawTitle: "VST3 · AU · LV2 · app", pDawText: "Para tu DAW o el iPad (AUM, GarageBand, Logic, Cubasis…), con un editor hecho para DAW: la pantalla en vivo, las seis pistas, los presets y parámetros de cada sonido, y un navegador de samples con arrastrar y soltar.",
|
||
pDaw1: "Hasta 8 JIANT en una sesión, cada uno el suyo", pDaw2: "La app standalone responde al editor web (con un cable MIDI virtual)",
|
||
pDaw3: "VST3 (macOS, Windows, Linux), AU y AUv3 (macOS, iPadOS), LV2 (Linux), standalone",
|
||
foot: "JIANT Studio, de Juan Jiant",
|
||
},
|
||
en: {
|
||
other: "Español", vPorts: "Other devices", vHome: "Home", vInstall: "Install", vEditor: "Editor", vScreen: "Screen", vEmu: "Emulator", vRec: "Record",
|
||
tFm1: "FM-1", tEmu: "Emulator", target: "Target",
|
||
eyebrow: "A free firmware for the M-VAVE FM-1",
|
||
leadFm: "Synthesis, sequencing, mutation and performance. Install it, edit it, see its screen big and record, all from here.",
|
||
leadByte: "Bytebeat and floatbeat: every sound, drum and animation is a formula of time. Install it, edit it and record from here.",
|
||
needBrowser: "Chrome or Edge", needCable: "A USB data cable", needPhone: "Android phone with USB-C (OTG)",
|
||
s1Title: "Connect the FM-1", s1Text: "Plug it straight into this computer or phone, without a hub, and switch it on. When the browser asks to use MIDI devices, choose Allow.",
|
||
find: "Find FM-1", forget: "Let the FM-1 go",
|
||
s2Title: "Install or update", s2Text: "Pick the firmware. Before writing, the installer makes a backup and every other tool lets the FM-1 go by itself.",
|
||
fmPitch: "Six living tracks, eleven engines, a 64-step sequencer, songs, a generator and effects.",
|
||
bytePitch: "Formulas as voices: MATH, WAVE and DRUM-X with formulas. LIFE: the tracks hear each other.",
|
||
s3Title: "Use it", s3Text: "All over one connection. Up top you choose the FM-1 over USB or the emulator.",
|
||
toolEditor: "Sounds, steps, tracks, projects and backups from the computer.",
|
||
toolScreen: "The FM-1's screen big, full screen on a phone.",
|
||
toolEmu: "The FM-1 in the browser, with sound. Play it from a MIDI keyboard.",
|
||
toolRec: "Master or stems as WAV, and what you played as MIDI.",
|
||
hSafeQ: "Is it safe to keep the editor or the emulator open while installing?",
|
||
hSafeA: "Yes. When the installer starts writing it tells every JIANT FM and JIANT BYTE tab and frame: the editor disconnects, the screen stops and the emulator stops listening to MIDI, and the installer waits until each one confirms before the first byte goes out. Nothing reconnects until it has finished. Close other music software using the FM-1 (a DAW, another editor): those are not told.",
|
||
hStopQ: "If an installation stopped", hStopA: "The FM-1 stays in update mode: plug it back in (or switch it on) on this same page and the install carries on where it stopped.",
|
||
hDeadQ: "If the FM-1 won't start", hDeadA: "Open Install: the installer finds it in update mode and recovers it. If it still does not answer, an FM-1-transporter is needed (explained in the installer).",
|
||
hPhoneQ: "Does it work on a phone?", hPhoneA: "On Android with Chrome, with the FM-1 plugged into the phone's USB-C (an OTG cable or adapter). Not on iPhone: Safari has no Web MIDI.",
|
||
devNone: "no FM-1", devLooking: "looking…", devGone: "FM-1 unplugged", devBusy: "installing in another tab", devMock: "(simulated)",
|
||
found: "Found: ", foundNot: "No FM-1 with JIANT answers. If it runs other or official firmware, install JIANT FM or JIANT BYTE in step 2.",
|
||
noMidi: "This browser has no Web MIDI: use Chrome or Edge (none on iPhone).", denied: "The browser did not allow MIDI.",
|
||
nowBusy: "An installer is writing: the FM-1 was let go for it.",
|
||
instTitleFm: "JIANT FM", instTitleByte: "JIANT BYTE",
|
||
instSafe: "While the installer writes, the editor, the screen and the emulator on this page (and in other tabs) let the FM-1 go and wait. Do not unplug or switch off the FM-1 until it has finished.",
|
||
edTarget: "Target: ", edEmuNote: "Editing the emulator: the editor talks to the FM-1 in the browser (Emulator tab). Switch it on there first.",
|
||
scrTitle: "The screen, big", scrStart: "Show", scrStop: "Stop", scrFull: "Full screen", scrExitFull: "Exit",
|
||
scrSharp: "Sharp pixels", scrWaitFm1: "Connect the FM-1 (Home) and press Show.", scrWaitEmu: "Switch the emulator on in the Emulator tab and press Show.",
|
||
scrNo: "This firmware has no screen mirror: update JIANT FM or JIANT BYTE.",
|
||
scrNoFw: "Your FM-1 runs %s, which has no screen mirror yet: it comes with the next firmware release. Meanwhile pick Emulator up top and see the emulator's screen.",
|
||
scrNoShort: "no screen mirror (comes in the next release)",
|
||
scrHelpFm1: "The FM-1 sends only what changes: a screen at rest costs nothing. While it shows here the FM-1's UI may run a little slower on very animated pages; the sound does not change.",
|
||
scrHelpEmu: "The emulator's screen, frame by frame.",
|
||
scrOrient: "The FM-1's screen is square (240 × 240). In portrait it fills the width; in landscape, the height, with the controls beside it. Full screen keeps it centred and as big as it gets either way: turn the phone as you like.",
|
||
scrRate: " KB/s", scrFps: " frames/s", scrWaiting: "waiting for the picture…",
|
||
emuMidi: "MIDI that plays the emulator", emuMidiAll: "Every input", emuMidiNone: "None", emuMidiOff: "(switch the emulator on)",
|
||
recTitle: "Record", recAudio: "Audio", recInput: "Input", recStart: "Record", recStop: "Stop",
|
||
recProfile: "The FM-1's USB mode (MENU › SYSTEM › USB)", profAuto: "Detect by the channels that come in",
|
||
profMaster: "AUDIO · STEREO · IN+OUT: the master (2 channels)", profStems: "STEMS: 8 channels (T1–T6, FX L R)",
|
||
profStemsIn: "STEMS+IN: 10 channels (T1–T6, FX L R, VOX, DRY)",
|
||
profHelp_auto: "Studio counts the channels that come in and names them: 2 the master, 8 STEMS, 10 STEMS+IN. After changing the mode on the FM-1, unplug it and plug it in again.",
|
||
profHelp_master: "On the FM-1: MENU › SYSTEM › USB › AUDIO (or STEREO, or IN+OUT), then plug it in again. The stereo master comes in, as it sounds.",
|
||
profHelp_stems: "On the FM-1: MENU › SYSTEM › USB › STEMS, then plug it in again. Each track mono before the master (no limiter, no MASTER knob) and the effects' return in stereo: their sum is the mix. USB LEVEL at −6 dB or lower leaves headroom.",
|
||
profHelp_stemsin: "On the FM-1: MENU › SYSTEM › USB › STEMS+IN, then plug it in again. STEMS plus two voice channels: VOX (the voice as the last track mixed it) and DRY (the voice as it came); what this device plays goes into the FM-1 as the voice.",
|
||
recMonitor: "Test the input", recMonitorStop: "Close the input", recPlay: "▶ Play the take", recPlayStop: "■ Stop",
|
||
recDawEmpty: "Press Test the input: a lane shows for each channel that comes in, with its level. Record draws each track as it plays.",
|
||
recFewerLong: "%got channels come in and the FM-1's mode sends %need. Chrome on Android hands over at most 2 (T1 and T2, or the master): a web page cannot read USB audio any other way (browsers protect audio interfaces). For live stems: Chrome or Edge on a computer (Mac, Windows or Linux), or the JIANT Probe app on the phone; or a song's stems from a backup (below), exact and unlimited.",
|
||
laneTrack: "track, mono", lane_L: "master left", lane_R: "master right", lane_FXL: "effects, left", lane_FXR: "effects, right",
|
||
lane_VOX: "the voice as mixed", lane_DRY: "the voice as it came", recMute: "Mute", recSolo: "Solo",
|
||
stWhat: "What", stLive: "The section playing (8 bars)", stGo: "Stems from the FM-1", stFile: "…or from a backup",
|
||
stReading: "Reading the FM-1's backup… ", stRender: "Making the stems: ", stDone: "Done: the tracks are above.", stNeedDev: "Connect the FM-1 (Home) or pick a backup file.",
|
||
recSaved: "Take saved: it is below, under Takes.",
|
||
recSrcFm1: "The FM-1 over USB is an audio input: stereo (USB > AUDIO), or 8 channels in USB > STEMS (the 6 tracks and the effects apart). Pick it here.",
|
||
recSrcEmu: "Records the emulator's output (switch it on in the Emulator tab).",
|
||
recNoDev: "No audio inputs (allow the microphone to list them).", recAsk: "Ask for audio permission",
|
||
recMidi: "MIDI", recMidiHelp: "While recording, what comes in over MIDI is kept too: what you play on the FM-1 (MENU > MIDI OUT) or on a keyboard.",
|
||
recMidiIn: "MIDI input", recMidiNone: "(none)",
|
||
recStems: "A song's stems", recStemsHelp: "Exact and with no channel limit, on a phone too: Studio reads the song from the FM-1 over USB (or a backup file) and plays it in the emulator once a track. Each track its own WAV, sample-aligned.",
|
||
recStemsGo: "Open the emulator",
|
||
recTakes: "Takes", recNone: "Nothing recorded yet.", recWav: "WAV master", recStemsZip: "Stems (ZIP)", recMid: "MIDI",
|
||
recChannels: " channels", recNotes: " notes",
|
||
portsTitle: "JIANT FM on other devices",
|
||
portsLead: "The same firmware from the same sources on other machines: a song sounds the same on every one. On the bigger CPUs it adds the SAMPLE and GRAIN engines, DRUM-X with samples and 8 voices a track. All free and GPL-3.0; some are still looking for testers.",
|
||
shotSmk: "the SMK-37's panel running JIANT in the emulator", shotMpc: "the MPC Sample running JIANT in the emulator",
|
||
shotDaw: "the plugin's editor: the live screen and tracks", shotDawSound: "the plugin's editor: the sound",
|
||
shotDawSamples: "the plugin's editor: the sample browser", portsManuals: "Manuals",
|
||
portsHow: "How they work", portTry: "Try it in the browser", portDownload: "Download", portManual: "Manual", portInstall: "How to install",
|
||
portSource: "Source", portBuild: "Build", portSoon: "Installer: coming",
|
||
stOk: "works", stPreview: "preview: testers wanted", stDev: "in development", stCi: "built by CI",
|
||
pSmkTitle: "M-VAVE SMK-37 Pro / Elite", pSmkText: "JIANT bare metal on the SMK-37's chip (the FM-1's AC791N): 37 keys, 16 RGB pads, 8 encoders and 4 faders as its panel. The same web editor.",
|
||
pSmk1: "Pads lit in each track's colour", pSmk2: "The FM-1's editor and sounds",
|
||
pMpcTitle: "Akai MPC Sample", pMpcText: "JIANT as the MPC Sample's whole instrument: its screen, its pads, buttons and knobs as the FM-1's panel, started from the microSD card.",
|
||
pMpc1: "SAMPLE, GRAIN and DRUM-X with samples", pMpc2: "16 sample slots of 60 s, recording from the input",
|
||
pPlugMpcTitle: "MPC plugin", pPlugMpcText: "JIANT FM as an instrument inside the MPC standalones (MPC OS 3.10.1 or newer) and desktop VST2 hosts.",
|
||
pPlugMpc1: "ARM32, ARM64 and desktop", pPlugMpc2: "Passes the SDK's host simulator; not yet tried on an MPC",
|
||
pDawTitle: "VST3 · AU · LV2 · app", pDawText: "For your DAW or the iPad (AUM, GarageBand, Logic, Cubasis…), with an editor made for a DAW: the live screen, the six tracks, each sound's presets and parameters, and a sample browser with drag and drop.",
|
||
pDaw1: "Up to 8 JIANTs in one session, each its own", pDaw2: "The standalone app answers the web editor (through a virtual MIDI cable)",
|
||
pDaw3: "VST3 (macOS, Windows, Linux), AU and AUv3 (macOS, iPadOS), LV2 (Linux), standalone",
|
||
foot: "JIANT Studio, by Juan Jiant",
|
||
},
|
||
};
|
||
let lang = (() => { try { const l = localStorage.getItem("jiant.studio.lang"); if (TEXT[l]) return l; } catch (_) {} return /^es/i.test(navigator.language || "") ? "es" : "en"; })();
|
||
const t = (k) => TEXT[lang][k] ?? TEXT.en[k] ?? k;
|
||
function applyLang() {
|
||
document.documentElement.lang = lang;
|
||
document.querySelectorAll("[data-t]").forEach((e) => { e.textContent = t(e.dataset.t); });
|
||
document.querySelectorAll("[data-t-label]").forEach((e) => e.setAttribute("aria-label", t(e.dataset.tLabel)));
|
||
$("lang").textContent = t("other");
|
||
render();
|
||
}
|
||
$("lang").addEventListener("click", () => { lang = lang === "es" ? "en" : "es"; try { localStorage.setItem("jiant.studio.lang", lang); } catch (_) {} applyLang(); });
|
||
|
||
/* ------------------------------------------------------------------------------------- where the tools live */
|
||
/* The sites: /JIANT/ (JIANT FM) and /JIANT-BYTE/ (JIANT BYTE) under one origin; this page is /JIANT/studio/. Anywhere else
|
||
* (a copy on disk) the tools come from the published sites (then they cannot hear this page: another origin). */
|
||
const ROOT = (() => { const m = location.pathname.match(/^(.*?)\/JIANT\//); return location.protocol.startsWith("http") && m ? m[1] : null; })();
|
||
const SITE = ROOT !== null ? `${ROOT}/` : "https://juanjiant-bit.github.io/";
|
||
const TOOLS = {
|
||
fm: { base: `${SITE}JIANT/`, installer: "webapp/installer/", editor: "webapp/editor/", emu: "emu/" },
|
||
byte: { base: `${SITE}JIANT-BYTE/`, installer: "webapp/installer/", editor: "webapp/editor/", emu: "emu/" },
|
||
};
|
||
const toolUrl = (fw, tool, q = "") => TOOLS[fw].base + TOOLS[fw][tool] + q;
|
||
|
||
/* ------------------------------------------------------------------------------------------------ the state */
|
||
const state = {
|
||
view: "home", fw: QS.get("fw") === "byte" ? "byte" : "fm", target: QS.get("target") === "emu" ? "emu" : "fm1",
|
||
dev: null, // {link, input, output, version, kind ("fm" | "byte"), engines}
|
||
looking: false, busy: false, // busy: an installer writes (jiant-midi)
|
||
found: "", // the last result line
|
||
};
|
||
try { const f = localStorage.getItem("jiant.studio.fw"); if (!QS.get("fw") && (f === "fm" || f === "byte")) state.fw = f; } catch (_) {}
|
||
|
||
/* ------------------------------------------------------------------------------------- the USB link (SysEx) */
|
||
const HDR = [0x7D, 0x46, 0x4C];
|
||
const CMD = { INFO: 1, PING: 25, SCREEN: 78, SCREEN_DATA: 79 };
|
||
const frame = (cmd, args = []) => [0xF0, ...HDR, cmd & 0x7F, ...args, 0xF7];
|
||
function unframe(d) {
|
||
if (!d || d.length < 6 || d[0] !== 0xF0 || d[d.length - 1] !== 0xF7 || d[1] !== HDR[0] || d[2] !== HDR[1] || d[3] !== HDR[2]) return null;
|
||
return { cmd: d[4], a: Array.from(d.subarray ? d.subarray(5, d.length - 1) : d.slice(5, -1)) };
|
||
}
|
||
/* one request at a time, each matched by its command (the device answers in order); pushes (79) to onPush */
|
||
class Link {
|
||
constructor(output, onPush) { this.output = output; this.onPush = onPush; this.q = []; this.cur = null; this.lastSent = 0; this.closed = false; }
|
||
request(cmd, args = [], timeout = 600) {
|
||
if (this.closed) return Promise.reject(new Error("closed"));
|
||
return new Promise((res, rej) => { this.q.push({ cmd, args, res, rej, timeout }); this.pump(); });
|
||
}
|
||
pump() {
|
||
if (this.cur || !this.q.length || this.closed) return;
|
||
const c = this.cur = this.q.shift();
|
||
try { this.output.send(frame(c.cmd, c.args)); this.lastSent = Date.now(); } catch (e) { this.finish(null, e); return; }
|
||
c.timer = setTimeout(() => this.finish(null, new Error("timeout")), c.timeout);
|
||
}
|
||
finish(a, err) {
|
||
const c = this.cur;
|
||
if (!c) return;
|
||
clearTimeout(c.timer); this.cur = null;
|
||
if (err) c.rej(err); else c.res(a);
|
||
this.pump();
|
||
}
|
||
receive(data) {
|
||
const f = unframe(data);
|
||
if (!f) return;
|
||
if (f.cmd === CMD.SCREEN_DATA) { this.onPush(f); return; }
|
||
if (this.cur && f.cmd === this.cur.cmd && (f.cmd !== CMD.SCREEN || f.a[0] === this.cur.args[0])) this.finish(f.a);
|
||
}
|
||
close() { this.closed = true; for (const c of [this.cur, ...this.q].filter(Boolean)) { clearTimeout(c.timer); c.rej(new Error("closed")); } this.cur = null; this.q = []; }
|
||
}
|
||
/* INFO: version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then the engines' names. JIANT BYTE's include MATH */
|
||
function parseInfo(a) {
|
||
let i = 0;
|
||
const str = () => { let s = ""; while (i < a.length && a[i]) s += String.fromCharCode(a[i++]); i++; return s; };
|
||
const version = str(), n = a[i]; i += 5;
|
||
const engines = [];
|
||
for (let k = 0; k < n && i < a.length; k++) engines.push(str());
|
||
/* JIANT BYTE names itself ("JIANT BYTE v0.16"); JIANT FM does not ("JIANT V10.8.24"). (Not by its engines: JIANT FM has
|
||
MATH too since V10.8.21) */
|
||
return { version, engines, kind: /\bBYTE\b/i.test(version) ? "byte" : "fm", jiant: /^(JIANT|FELUCCA)\b/i.test(version) };
|
||
}
|
||
const PORT_RE = /felucca|jiant|skiff|fm[ _-]*1|smk[ _-]*37|m[ _-]*vave|cuvave|composite|sinco|usb[ _-]*midi|usb audio/i;
|
||
let access = null;
|
||
async function midiAccess() {
|
||
if (access) return access;
|
||
if (MOCK) return (access = mockAccess());
|
||
if (!navigator.requestMIDIAccess) throw Object.assign(new Error("nomidi"), { code: "noMidi" });
|
||
try { access = await navigator.requestMIDIAccess({ sysex: true }); }
|
||
catch (e) { throw Object.assign(new Error("denied"), { code: "denied" }); }
|
||
access.onstatechange = (e) => {
|
||
const p = e.port;
|
||
if (state.dev && p && p.state === "disconnected" && (p.id === state.dev.input.id || p.id === state.dev.output.id)) { letGo(); state.found = t("devGone"); render(); }
|
||
renderMidiInputs();
|
||
};
|
||
return access;
|
||
}
|
||
async function find() {
|
||
if (state.looking || state.busy) return;
|
||
state.looking = true; state.found = ""; render();
|
||
try {
|
||
const acc = await midiAccess();
|
||
const live = (m) => [...m.values()].filter((p) => p.state !== "disconnected");
|
||
let ins = live(acc.inputs).filter((p) => PORT_RE.test(p.name || "")), outs = live(acc.outputs).filter((p) => PORT_RE.test(p.name || ""));
|
||
if (!ins.length || !outs.length) { ins = live(acc.inputs); outs = live(acc.outputs); }
|
||
const pairs = ins.flatMap((input) => outs.map((output) => ({ input, output, s: input.name === output.name ? 1 : 0 }))).sort((x, y) => y.s - x.s);
|
||
for (const { input, output } of pairs) {
|
||
const link = new Link(output, onScreenData);
|
||
input.onmidimessage = (e) => link.receive(e.data);
|
||
try {
|
||
const info = parseInfo(await link.request(CMD.INFO, [], 900));
|
||
if (!info.jiant) throw new Error("not JIANT");
|
||
letGo();
|
||
/* does it mirror its screen? (78 SCREEN, op 0: firmware before the mirror sends no reply) */
|
||
let screen = null; // (null: it did not say; Show tries anyway)
|
||
for (let k = 0; k < 2 && screen === null; k++) {
|
||
try { const a = await link.request(CMD.SCREEN, [0], 1200); screen = a[1] === 0; } catch (_) {}
|
||
}
|
||
state.dev = { link, input, output, ...info, screen };
|
||
if (state.fw !== info.kind) setFw(info.kind);
|
||
state.found = t("found") + `${devName(state.dev)}${MOCK ? " " + t("devMock") : ""}` + (state.dev.screen === false ? " · " + t("scrNoShort") : "");
|
||
return;
|
||
} catch (_) { link.close(); input.onmidimessage = null; }
|
||
}
|
||
state.found = t("foundNot");
|
||
} catch (e) { state.found = t(e.code || "foundNot"); }
|
||
finally { state.looking = false; render(); }
|
||
}
|
||
/* "JIANT BYTE v0.16", "JIANT FM V10.8.21": the firmware's name once (its INFO says "JIANT BYTE v0.16" or "JIANT V10.8.21") */
|
||
const devName = (d) => `${d.kind === "byte" ? "JIANT BYTE" : "JIANT FM"} ${d.version.replace(/^(JIANT|FELUCCA)\s+/i, "").replace(/^(BYTE|FM)\s+/i, "")}`;
|
||
function letGo() {
|
||
const d = state.dev;
|
||
if (!d) return;
|
||
screenStop(false);
|
||
d.link.close();
|
||
d.input.onmidimessage = midiTap; // (the recorder keeps listening to what the FM-1 plays)
|
||
state.dev = null;
|
||
}
|
||
$("find").addEventListener("click", find);
|
||
$("forget").addEventListener("click", () => { letGo(); state.found = ""; render(); });
|
||
|
||
/* -------------------------------------------------------------------- install safety: the jiant-midi channel */
|
||
let busyUntil = 0, busyTimer = 0;
|
||
try {
|
||
const bc = new BroadcastChannel("jiant-midi");
|
||
bc.onmessage = (e) => {
|
||
const m = e.data || {};
|
||
if (m.type === "who") bc.postMessage({ type: "studio", connected: !!state.dev });
|
||
if (m.type !== "installer") return;
|
||
clearTimeout(busyTimer);
|
||
if (m.busy) {
|
||
busyUntil = Date.now() + 60000; state.busy = true;
|
||
letGo(); monitorStop();
|
||
state.found = t("nowBusy");
|
||
bc.postMessage({ type: "released", who: "studio" });
|
||
busyTimer = setTimeout(() => { state.busy = false; render(); }, 60000);
|
||
} else { state.busy = false; busyUntil = 0; }
|
||
render();
|
||
};
|
||
} catch (_) {}
|
||
|
||
/* ------------------------------------------------------------------------------------- views, firmware, target */
|
||
const VIEWS = ["home", "install", "editor", "screen", "emu", "rec", "ports"];
|
||
function go(view, push = true) {
|
||
if (!VIEWS.includes(view)) view = "home";
|
||
state.view = view;
|
||
for (const v of VIEWS) $("v-" + v).hidden = v !== view;
|
||
if (push) history.replaceState(null, "", location.pathname + location.search + "#" + view);
|
||
showFrames();
|
||
render();
|
||
window.scrollTo({ top: 0 });
|
||
}
|
||
document.addEventListener("click", (e) => {
|
||
const g = e.target.closest("[data-go]");
|
||
if (g) { e.preventDefault(); go(g.dataset.go); return; }
|
||
const f = e.target.closest("[data-fw]");
|
||
if (f) { setFw(f.dataset.fw); return; }
|
||
const i = e.target.closest("[data-install]");
|
||
if (i) { setFw(i.dataset.install); go("install"); return; }
|
||
const tg = e.target.closest("[data-target]");
|
||
if (tg) { setTarget(tg.dataset.target); }
|
||
});
|
||
function setFw(fw) {
|
||
if (fw !== "fm" && fw !== "byte") return;
|
||
const changed = fw !== state.fw;
|
||
state.fw = fw;
|
||
try { localStorage.setItem("jiant.studio.fw", fw); } catch (_) {}
|
||
document.documentElement.dataset.skin = fw;
|
||
document.querySelector('meta[name="theme-color"]').content = fw === "byte" ? "#000000" : "#050409";
|
||
if (changed) for (const k of Object.keys(frames)) frames[k].fw = null; // the tools of the other firmware: loaded anew
|
||
showFrames();
|
||
render();
|
||
}
|
||
function setTarget(target) {
|
||
state.target = target === "emu" ? "emu" : "fm1";
|
||
if (frames.editor.fw) frames.editor.fw = null; // the editor anew, for the other target
|
||
screenStop(false);
|
||
showFrames();
|
||
render();
|
||
}
|
||
|
||
/* ------------------------------------------------------------------------- the tools in frames, in our look */
|
||
const frames = {
|
||
install: { el: $("f-install"), fw: null, tool: "installer" },
|
||
editor: { el: $("f-editor"), fw: null, tool: "editor" },
|
||
emu: { el: $("f-emu"), fw: null, tool: "emu" },
|
||
};
|
||
const VIEW_FRAME = { install: "install", editor: "editor", emu: "emu" };
|
||
function showFrames() {
|
||
const k = VIEW_FRAME[state.view];
|
||
// the emulator stays loaded once it was (it keeps playing; the screen and the recorder read it)
|
||
if (k) loadFrame(k);
|
||
if (state.view === "screen" && state.target === "emu") loadFrame("emu");
|
||
}
|
||
function loadFrame(k) {
|
||
const f = frames[k];
|
||
if (f.fw === state.fw && f.el.src) return;
|
||
f.fw = state.fw;
|
||
const q = k === "editor" && state.target === "emu" ? "?emu=1" : MOCK && k === "editor" ? "?mock=1" : "";
|
||
f.el.src = toolUrl(state.fw, f.tool, q);
|
||
}
|
||
for (const [k, f] of Object.entries(frames)) f.el.addEventListener("load", () => { dress(f.el); if (k === "editor") editorLoaded(); });
|
||
/* the firmware's look inside a tool's frame (same origin only): its colour tokens and type, over the page's own */
|
||
const DRESS = {
|
||
fm: `:root,:root:not([data-theme="light"]){--bg:#050409;--fg:#efe6c8;--dim:#a39bb6;--line:rgba(239,230,200,.18)}
|
||
body{background:#050409;color:#efe6c8;font-family:"Instrument Sans",system-ui,sans-serif}`,
|
||
byte: `:root,:root:not([data-theme="light"]){--bg:#000;--fg:#f2f0f7;--dim:#9d94b8;--line:rgba(167,123,255,.35);
|
||
--jiant-panel:#0b0912;--jiant-field:#05040a;--jiant-cyan:#a77bff;--jiant-yellow:#ffb21a;--jiant-mag:#ff3b3b;--jiant-orange:#ff7a1a;
|
||
--jiant-display:"Silkscreen",monospace;--jiant-body:"IBM Plex Mono",monospace;--jiant-mono:"VT323",monospace;
|
||
--jiant-heat:linear-gradient(90deg,#ff3b3b,#ff7a1a 40%,#ffb21a 60%,#a77bff)}
|
||
body{background:#000;color:#f2f0f7;font-family:"IBM Plex Mono",monospace}
|
||
h1,h2,.jiant-wordmark{font-family:"Silkscreen",monospace}`,
|
||
};
|
||
/* inside Studio a tool's own wordmark, links to the other tools, support line and footer are Studio's already */
|
||
const EMBEDDED = `h1.jiant-wordmark,.jiant-wordmark,p.kofi,.kofi,body>main>footer,body>footer,main>p.dim:first-of-type{display:none!important}
|
||
main{padding-top:8px!important} a{color:inherit}`;
|
||
function dress(iframe) {
|
||
try {
|
||
const d = iframe.contentDocument;
|
||
if (!d || !d.head) return;
|
||
let s = d.getElementById("studio-skin");
|
||
if (!s) {
|
||
s = d.createElement("style"); s.id = "studio-skin"; d.head.append(s);
|
||
const l = d.createElement("link"); l.rel = "stylesheet";
|
||
l.href = "https://fonts.googleapis.com/css2?family=Michroma&family=IBM+Plex+Mono:wght@400;500;600&family=Instrument+Sans:wght@400;500;600&family=Silkscreen&family=VT323&display=swap";
|
||
d.head.append(l);
|
||
}
|
||
s.textContent = DRESS[state.fw] + EMBEDDED;
|
||
d.documentElement.dataset.skin = state.fw; // (the editor's own design layer, editor.html #jiant-skin: the firmware's look)
|
||
} catch (_) { /* another origin: its own look */ }
|
||
}
|
||
function editorLoaded() {
|
||
// the FM-1 found here, or the emulator running: the editor (just loaded, so not connected) connects at once, as its own
|
||
// button would
|
||
if (state.busy || (state.target === "fm1" ? !state.dev : !emuOn())) return;
|
||
try { const b = frames.editor.el.contentDocument.getElementById("connect"); if (b && !b.disabled) b.click(); } catch (_) {}
|
||
}
|
||
|
||
/* ------------------------------------------------------------------------------------------------ the screen */
|
||
const scr = { on: false, src: null, ctx: $("scr").getContext("2d"), img: null, lut: null, fb: new Uint16Array(SCR.W * SCR.H),
|
||
dirty: null, raf: 0, timer: 0, bytes: 0, frames: 0, t0: 0, rate: 0, fps: 0, got: false, lock: null, copy: 0 };
|
||
scr.img = scr.ctx.createImageData(SCR.W, SCR.H);
|
||
scr.lut = (() => { const l = new Uint32Array(65536); for (let c = 0; c < 65536; c++) l[c] = 0xFF000000 | ((c & 31) * 255 / 31 | 0) << 16 | (((c >> 5) & 63) * 255 / 63 | 0) << 8 | (((c >> 11) & 31) * 255 / 31 | 0); return l; })();
|
||
function onScreenData(f) {
|
||
if (!scr.on || scr.src !== "fm1") return;
|
||
const box = scrDecode(f.a, scr.fb);
|
||
if (!box) return;
|
||
scr.bytes += f.a.length + 6;
|
||
if (!scr.got) { scr.got = true; $("scrwait").hidden = true; } // (the first picture: the waiting line goes)
|
||
const d = scr.dirty;
|
||
scr.dirty = !d ? box : { x: Math.min(d.x, box.x), y: Math.min(d.y, box.y),
|
||
w: Math.max(d.x + d.w, box.x + box.w) - Math.min(d.x, box.x), h: Math.max(d.y + d.h, box.y + box.h) - Math.min(d.y, box.y) };
|
||
if (!scr.raf) scr.raf = requestAnimationFrame(paint);
|
||
}
|
||
function paint() {
|
||
scr.raf = 0;
|
||
const d = scr.dirty;
|
||
if (!d) return;
|
||
scr.dirty = null; scr.frames++;
|
||
const px = new Uint32Array(scr.img.data.buffer);
|
||
for (let y = d.y; y < d.y + d.h; y++) for (let i = y * SCR.W + d.x, e = i + d.w; i < e; i++) px[i] = scr.lut[scr.fb[i]];
|
||
scr.ctx.putImageData(scr.img, 0, 0, d.x, d.y, d.w, d.h);
|
||
}
|
||
function emuCanvas() {
|
||
try { return frames.emu.el.contentDocument && frames.emu.el.contentDocument.getElementById("screen"); } catch (_) { return null; }
|
||
}
|
||
async function screenStart() {
|
||
if (scr.on) return;
|
||
scr.src = state.target; scr.got = false; scr.bytes = 0; scr.frames = 0; scr.t0 = Date.now();
|
||
scr.fb.fill(0); scr.ctx.fillStyle = "#000"; scr.ctx.fillRect(0, 0, SCR.W, SCR.H);
|
||
if (scr.src === "emu") {
|
||
loadFrame("emu");
|
||
scr.on = true;
|
||
const step = () => {
|
||
if (!scr.on) return;
|
||
const c = emuCanvas();
|
||
if (c && c.width) { scr.ctx.drawImage(c, 0, 0, SCR.W, SCR.H); if (!scr.got) { scr.got = true; $("scrwait").hidden = true; } scr.frames++; }
|
||
scr.copy = requestAnimationFrame(step);
|
||
};
|
||
step();
|
||
} else {
|
||
const d = state.dev;
|
||
if (!d) { render(); return; }
|
||
scr.on = true;
|
||
try {
|
||
const a = await d.link.request(CMD.SCREEN, [1]);
|
||
if (a[1] || !a[2]) { scr.on = false; $("scrstat").textContent = t("scrNo"); render(); return; }
|
||
} catch (e) { scr.on = false; $("scrstat").textContent = t("scrNo"); render(); return; }
|
||
clearInterval(scr.timer);
|
||
scr.timer = setInterval(async () => {
|
||
if (!scr.on || !state.dev || document.hidden) return;
|
||
try { const a = await state.dev.link.request(CMD.SCREEN, [2]); if (scr.on && !a[2]) await state.dev.link.request(CMD.SCREEN, [1]); } catch (_) {}
|
||
}, 1000);
|
||
}
|
||
wake();
|
||
render();
|
||
}
|
||
function screenStop(tell = true) {
|
||
if (!scr.on) return;
|
||
scr.on = false;
|
||
clearInterval(scr.timer); cancelAnimationFrame(scr.copy);
|
||
if (tell && scr.src === "fm1" && state.dev) state.dev.link.request(CMD.SCREEN, [4]).catch(() => {});
|
||
if (scr.lock) { scr.lock.release().catch(() => {}); scr.lock = null; }
|
||
render();
|
||
}
|
||
async function wake() {
|
||
try { if (scr.on && !scr.lock && navigator.wakeLock && !document.hidden) { scr.lock = await navigator.wakeLock.request("screen"); scr.lock.addEventListener("release", () => { scr.lock = null; }); } } catch (_) {}
|
||
}
|
||
document.addEventListener("visibilitychange", () => {
|
||
if (document.hidden || !scr.on) return;
|
||
wake();
|
||
if (scr.src === "fm1" && state.dev) state.dev.link.request(CMD.SCREEN, [3]).catch(() => {}); // (it may have stopped meanwhile)
|
||
});
|
||
setInterval(() => {
|
||
if (!scr.on) return;
|
||
const dt = (Date.now() - scr.t0) / 1000;
|
||
if (dt >= 1) { scr.rate = scr.bytes / dt; scr.fps = scr.frames / dt; scr.bytes = 0; scr.frames = 0; scr.t0 = Date.now(); }
|
||
if (state.view === "screen") $("scrstat").textContent = !scr.got ? t("scrWaiting") :
|
||
scr.src === "fm1" ? `${(scr.rate / 1024).toFixed(1)}${t("scrRate")} · ${scr.fps.toFixed(0)}${t("scrFps")}` : `${scr.fps.toFixed(0)}${t("scrFps")}`;
|
||
}, 500);
|
||
|
||
const fullscreen = () => {
|
||
const s = $("stage");
|
||
if (document.fullscreenElement || document.webkitFullscreenElement) (document.exitFullscreen || document.webkitExitFullscreen).call(document);
|
||
else (s.requestFullscreen || s.webkitRequestFullscreen).call(s)?.catch?.(() => {});
|
||
};
|
||
/* Show: the screen on, and full screen at once (the same tap: browsers allow full screen only from one); Exit leaves full
|
||
* screen with the picture still here, Stop ends it */
|
||
$("scrgo").addEventListener("click", () => {
|
||
if (scr.on) { screenStop(); return; }
|
||
if (state.target === "emu" || (state.dev && state.dev.screen === true)) fullscreen(); // (unsure: the page first, Full screen after) // (only a picture that will come goes full screen)
|
||
screenStart();
|
||
});
|
||
$("scrfull").addEventListener("click", async () => { if (!scr.on) await screenStart(); fullscreen(); });
|
||
$("fsexit").addEventListener("click", fullscreen);
|
||
const sharp = () => {
|
||
const on = $("stage").classList.toggle("smooth") === false;
|
||
$("scrsharp").setAttribute("aria-pressed", String(on));
|
||
try { localStorage.setItem("jiant.studio.smooth", on ? "0" : "1"); } catch (_) {}
|
||
};
|
||
$("scrsharp").addEventListener("click", sharp); $("fssharp").addEventListener("click", sharp);
|
||
try { if (localStorage.getItem("jiant.studio.smooth") === "1") { $("stage").classList.add("smooth"); $("scrsharp").setAttribute("aria-pressed", "false"); } } catch (_) {}
|
||
let fade = 0;
|
||
const showBar = () => { $("fsbar").classList.remove("faded"); clearTimeout(fade); fade = setTimeout(() => $("fsbar").classList.add("faded"), 2500); };
|
||
$("stage").addEventListener("pointerdown", showBar);
|
||
document.addEventListener("fullscreenchange", () => { if (document.fullscreenElement) showBar(); });
|
||
if (QS.has("screen")) { state.view = "screen"; }
|
||
|
||
/* ------------------------------------------------------------------------------------------------ recording */
|
||
/* JIANT's USB audio profiles (MENU > SYSTEM > USB, then unplug and plug again): what each sends to the computer or the
|
||
* phone, channel by channel (docs/MANUAL.md "Stems", "USB audio in", "Stems with a voice"; android/README.md) */
|
||
const PROFILES = {
|
||
master: { ch: 2, lanes: [["L", 0, -1], ["R", 0, 1]] },
|
||
stems: { ch: 8, lanes: [["T1", 1], ["T2", 2], ["T3", 3], ["T4", 4], ["T5", 5], ["T6", 6], ["FX L", 7, -1], ["FX R", 7, 1]] },
|
||
stemsin: { ch: 10, lanes: [["T1", 1], ["T2", 2], ["T3", 3], ["T4", 4], ["T5", 5], ["T6", 6], ["FX L", 7, -1], ["FX R", 7, 1], ["VOX", 8], ["DRY", 9]] },
|
||
};
|
||
const LANE_COLORS = { fm: ["#efe6c8", "#9d97ff", "#d39bff", "#ff9fd2", "#ff9a8a", "#ffc07a", "#fff3a8", "#3fe0e6", "#7be0a8", "#a39bb6"],
|
||
byte: ["#f2f0f7", "#ff7a1a", "#a77bff", "#ff3b3b", "#6bc8ff", "#ffd23f", "#f2f0f7", "#ff6fae", "#6bff9e", "#9d94b8"] };
|
||
const rec = { on: false, mon: false, stream: null, ac: null, node: null, chunks: [], ch: 2, rate: 44100, t0: 0, midi: [], takes: [], clock: 0,
|
||
profile: "master", engines: [] };
|
||
const daw = new Daw($("daw"), { get mute() { return t("recMute"); }, get solo() { return t("recSolo"); } });
|
||
const profileOf = (ch) => { const p = $("recprof").value; return p !== "auto" ? p : ch >= 10 ? "stemsin" : ch >= 8 ? "stems" : "master"; };
|
||
/* the six tracks' engines, for the lanes' names (27 TRACK: selected, NTRK, then per track engine, preset, level v14,
|
||
mute, armed) */
|
||
async function trackNames() {
|
||
const d = state.dev;
|
||
if (!d || state.target !== "fm1") return [];
|
||
try {
|
||
const a = await d.link.request(27, [], 600), n = a[1] | 0;
|
||
return Array.from({ length: n }, (_, k) => d.engines[a[2 + k * 6]] || "");
|
||
} catch (_) { return []; }
|
||
}
|
||
function lanesFor(profile, ch) {
|
||
const P = PROFILES[profile], col = LANE_COLORS[state.fw];
|
||
const lanes = P.lanes.slice(0, Math.max(ch, 1)).map(([name, c, pan], i) => {
|
||
const e = /^T\d$/.test(name) ? rec.engines[+name[1] - 1] : "", eng = e && e !== "-" ? e : "";
|
||
return { name: eng ? `${name} · ${eng}` : name, sub: /^T\d$/.test(name) ? t("laneTrack") : t("lane_" + name.replace(" ", "")), color: col[c] || col[0], pan: pan || 0 };
|
||
});
|
||
for (let i = lanes.length; i < ch; i++) lanes.push({ name: `CH ${i + 1}`, sub: "", color: col[9], pan: 0 });
|
||
return lanes;
|
||
}
|
||
function profileHelp() {
|
||
const p = $("recprof").value;
|
||
$("profhelp").textContent = state.target === "emu" ? t("recSrcEmu") : t("profHelp_" + p);
|
||
}
|
||
$("recprof").addEventListener("change", () => { profileHelp(); if (rec.mon && !rec.on) monitorStop(); });
|
||
/* the input open and shown in the lanes (levels only) until Record, which keeps what comes in */
|
||
async function monitorStart() {
|
||
if (rec.mon || state.busy) return true;
|
||
let stream;
|
||
const want = PROFILES[$("recprof").value === "auto" ? "stemsin" : $("recprof").value].ch;
|
||
try {
|
||
if (state.target === "emu") {
|
||
const w = frames.emu.el.contentWindow;
|
||
stream = w && w.jiantEmu && w.jiantEmu.stream && w.jiantEmu.stream();
|
||
if (!stream) { $("recstat").textContent = t("recSrcEmu"); return false; }
|
||
} else {
|
||
const id = $("recdev").value;
|
||
if (MOCK && id === "mock-stems") stream = "mock";
|
||
else {
|
||
if (!id || id === "ask") { await renderAudioInputs(true); return false; }
|
||
const base = { deviceId: { exact: id }, echoCancellation: false, noiseSuppression: false, autoGainControl: false, sampleRate: { ideal: 44100 } };
|
||
try { stream = await navigator.mediaDevices.getUserMedia({ audio: { ...base, channelCount: want > 2 ? { min: 2, ideal: want } : { exact: 2 } } }); }
|
||
catch (_) { stream = await navigator.mediaDevices.getUserMedia({ audio: { ...base, channelCount: { ideal: want } } }); }
|
||
}
|
||
}
|
||
} catch (e) { $("recstat").textContent = e.message; return false; }
|
||
const ac = new AudioContext({ latencyHint: "playback" });
|
||
const src = stream === "mock" ? mockStems(ac) : ac.createMediaStreamSource(stream);
|
||
const ch = stream === "mock" ? 10 : Math.max(1, Math.min(16, stream.getAudioTracks()[0]?.getSettings?.().channelCount || src.channelCount || 2));
|
||
await ac.audioWorklet.addModule("recorder-worklet.js");
|
||
const node = new AudioWorkletNode(ac, "studio-recorder", { numberOfInputs: 1, numberOfOutputs: 0, channelCount: ch, channelCountMode: "explicit", channelInterpretation: "discrete" });
|
||
src.connect(node);
|
||
rec.engines = await trackNames();
|
||
const profile = state.target === "emu" ? "master" : profileOf(ch);
|
||
Object.assign(rec, { mon: true, stream, ac, node, ch, rate: ac.sampleRate, profile });
|
||
daw.setLanes(lanesFor(profile, ch));
|
||
node.port.onmessage = (e) => {
|
||
const c = e.data.chunk;
|
||
if (!c) return;
|
||
if (rec.on) { rec.chunks.push(c); daw.live(c, rec.rate); }
|
||
else daw.meters(c.map((p) => { let m = 0; for (let i = 0; i < p.length; i += 8) { const v = Math.abs(p[i]); if (v > m) m = v; } return m; }));
|
||
};
|
||
const need = PROFILES[profile].ch, got = ch;
|
||
$("recstat").textContent = `${got}${t("recChannels")} · ${rec.rate} Hz`;
|
||
const warn = $("recwarn");
|
||
warn.hidden = !(state.target !== "emu" && (got < need || ($("recprof").value !== "auto" && got < PROFILES[$("recprof").value].ch)));
|
||
warn.textContent = t("recFewerLong").replace("%got", got).replace("%need", PROFILES[$("recprof").value === "auto" ? profile : $("recprof").value].ch);
|
||
render();
|
||
return true;
|
||
}
|
||
function monitorStop() {
|
||
if (!rec.mon) return;
|
||
if (rec.on) recStop();
|
||
rec.mon = false;
|
||
if (state.target !== "emu" && rec.stream !== "mock") rec.stream.getTracks().forEach((x) => x.stop());
|
||
rec.ac.close().catch(() => {});
|
||
render();
|
||
}
|
||
$("recmon").addEventListener("click", () => (rec.mon ? monitorStop() : monitorStart()));
|
||
async function recStart() {
|
||
if (rec.on || state.busy) return;
|
||
if (!rec.mon && !(await monitorStart())) return;
|
||
daw.stop();
|
||
daw.setLanes(lanesFor(rec.profile, rec.ch));
|
||
Object.assign(rec, { on: true, chunks: [], t0: performance.now(), midi: [] });
|
||
const mid = $("midisrc").value;
|
||
if (mid && access) {
|
||
const inp = access.inputs.get(mid);
|
||
if (inp) {
|
||
midiTapInput = inp;
|
||
if (state.dev && state.dev.input.id === inp.id) { const prev = inp.onmidimessage; inp.onmidimessage = (e) => { midiTap(e); prev && prev(e); }; }
|
||
else inp.addEventListener("midimessage", midiTap);
|
||
}
|
||
}
|
||
rec.clock = setInterval(() => {
|
||
const s = Math.floor((performance.now() - rec.t0) / 1000);
|
||
$("recclock").textContent = `${String(Math.floor(s / 60)).padStart(2, "0")}:${String(s % 60).padStart(2, "0")}`;
|
||
}, 200);
|
||
render();
|
||
}
|
||
function recStop() {
|
||
if (!rec.on) return;
|
||
rec.on = false;
|
||
clearInterval(rec.clock);
|
||
try { rec.node.port.postMessage("flush"); } catch (_) {}
|
||
setTimeout(() => {
|
||
if (midiTapInput) { midiTapInput.removeEventListener("midimessage", midiTap); midiTapInput = null; }
|
||
const take = makeTake();
|
||
if (take) daw.show(take.planes, rec.rate);
|
||
$("recclock").textContent = "00:00";
|
||
$("recstat").textContent = t("recSaved");
|
||
render();
|
||
}, 200); // (the worklet's last chunk)
|
||
}
|
||
$("recgo").addEventListener("click", () => (rec.on ? recStop() : recStart()));
|
||
$("recplay").addEventListener("click", () => (daw.playing ? daw.stop() : daw.play()));
|
||
daw.onState = () => render();
|
||
/* ---- a song's stems from a backup (the FM-1's, read over USB, or a file): the emulator's own renderer (emu/stems.js,
|
||
in a Worker) plays it once a track; the result shown in the lanes as a take */
|
||
async function stemsFrom(archiveOrNull) {
|
||
const base = TOOLS[state.fw].base + "emu/", say = (x) => { $("ststat").textContent = x; };
|
||
try {
|
||
const BK = await import(base + "fm1backup.js");
|
||
let archive = archiveOrNull;
|
||
if (!archive) {
|
||
const d = state.dev;
|
||
if (!d || state.busy) { say(t("stNeedDev")); return; }
|
||
archive = await BK.captureBackup((r, o) => d.link.request(r[0], r[1], (o && o.timeout) || 2000), d.version,
|
||
(done, total) => say(t("stReading") + Math.round(done / Math.max(1, total) * 100) + " %"));
|
||
}
|
||
const backup = BK.readBackup(archive), wasm = await (await fetch(base + "felucca.wasm")).arrayBuffer();
|
||
const v = $("stsong").value, opts = v === "live" ? { mode: "live", bars: 8 } : { mode: "song", song: +v };
|
||
const out = await new Promise((res, rej) => {
|
||
const w = new Worker(base + "stems.js", { type: "module" });
|
||
w.onmessage = (e) => { const m = e.data; if (m.type === "progress") say(t("stRender") + `${m.step} / ${m.steps}`); else { w.terminate(); m.type === "done" ? res(m) : rej(new Error(m.message)); } };
|
||
w.onerror = (e) => { w.terminate(); rej(new Error(e.message || "stems")); };
|
||
w.postMessage({ wasm, backup, opts }, [wasm]);
|
||
});
|
||
const files = unzipStored(new Uint8Array(out.zip)), col = LANE_COLORS[state.fw], planes = [], lanes = [];
|
||
for (const f of files) {
|
||
const { l, r, rate } = readWav(f.data), m = new Float32Array(l.length);
|
||
for (let i = 0; i < l.length; i++) m[i] = (l[i] + r[i]) * 0.5;
|
||
const k = /^T(\d)/.exec(f.name), n = k ? +k[1] : 0;
|
||
planes.push(m); lanes.push({ name: f.name.replace(".wav", ""), sub: k ? t("laneTrack").replace(", mono", "") : "MIX", color: k ? col[n] : col[0], pan: 0 });
|
||
rec.rate = rate;
|
||
}
|
||
const name = `${state.fw === "byte" ? "JIANT-BYTE" : "JIANT-FM"}-${v === "live" ? "live" : "song" + (+v + 1)}-stems`;
|
||
const take = { name, secs: out.seconds, planes, files: [{ label: t("recStemsZip"), name: name + ".zip", blob: new Blob([out.zip], { type: "application/zip" }) },
|
||
...files.map((f) => ({ label: f.name.replace(".wav", ""), name: `${name}-${f.name}`, blob: new Blob([f.data], { type: "audio/wav" }), small: true }))] };
|
||
rec.takes.unshift(take);
|
||
daw.setLanes(lanes); daw.show(planes, rec.rate);
|
||
say(t("stDone"));
|
||
render();
|
||
} catch (e) { say(String(e.message || e)); }
|
||
}
|
||
$("stgo").addEventListener("click", () => stemsFrom(null));
|
||
$("stfile").addEventListener("change", async () => { const f = $("stfile").files[0]; if (f) stemsFrom(JSON.parse(await f.text())); $("stfile").value = ""; });
|
||
/* the renderer's ZIP is stored (no compression) and its WAVs 16-bit stereo: read back without a library */
|
||
function unzipStored(z) {
|
||
const out = [], dv = new DataView(z.buffer, z.byteOffset, z.byteLength);
|
||
for (let o = 0; o + 30 <= z.length && dv.getUint32(o, true) === 0x04034B50;) {
|
||
const size = dv.getUint32(o + 18, true), nl = dv.getUint16(o + 26, true), xl = dv.getUint16(o + 28, true);
|
||
const name = new TextDecoder().decode(z.subarray(o + 30, o + 30 + nl)), start = o + 30 + nl + xl;
|
||
out.push({ name, data: z.slice(start, start + size) }); o = start + size;
|
||
}
|
||
return out;
|
||
}
|
||
function readWav(b) {
|
||
const dv = new DataView(b.buffer, b.byteOffset, b.byteLength), ch = dv.getUint16(22, true), rate = dv.getUint32(24, true);
|
||
let o = 12; while (o + 8 <= b.length && String.fromCharCode(...b.subarray(o, o + 4)) !== "data") o += 8 + dv.getUint32(o + 4, true);
|
||
const n = Math.floor(dv.getUint32(o + 4, true) / (2 * ch)), l = new Float32Array(n), r = new Float32Array(n);
|
||
for (let i = 0, p = o + 8; i < n; i++, p += 2 * ch) { l[i] = dv.getInt16(p, true) / 32768; r[i] = ch > 1 ? dv.getInt16(p + 2, true) / 32768 : l[i]; }
|
||
return { l, r, rate };
|
||
}
|
||
|
||
function makeTake() {
|
||
const n = rec.chunks.reduce((s, c) => s + c[0].length, 0);
|
||
if (!n && !rec.midi.length) return null;
|
||
const ch = rec.ch, planes = Array.from({ length: ch }, () => new Float32Array(n));
|
||
let o = 0;
|
||
for (const c of rec.chunks) { for (let k = 0; k < ch; k++) planes[k].set(c[k] || c[0], o); o += c[0].length; }
|
||
const stamp = new Date().toISOString().replace(/[:T]/g, "-").slice(0, 19);
|
||
const name = `${state.fw === "byte" ? "JIANT-BYTE" : "JIANT-FM"}-${state.target === "emu" ? "emu" : "fm1"}-${stamp}`;
|
||
const take = { name, secs: n / rec.rate, files: [], planes };
|
||
const lanes = lanesFor(rec.profile, ch);
|
||
if (n) {
|
||
if (rec.profile !== "master" && ch >= 8) { // STEMS / STEMS+IN: each track, the effects, the voice; their sum
|
||
const sum = [new Float32Array(n), new Float32Array(n)];
|
||
for (let i = 0; i < n; i++) {
|
||
let c = 0; for (let k = 0; k < 6; k++) c += planes[k][i] * 0.5;
|
||
if (ch >= 10) c += planes[8][i] * 0.5; // (VOX: the voice as the track mixed it, not in its stem)
|
||
sum[0][i] = c + planes[6][i]; sum[1][i] = c + planes[7][i];
|
||
}
|
||
const file = (l) => l.name.replace(/[^A-Za-z0-9]+/g, "-").replace(/-+$/, "");
|
||
const entries = [];
|
||
for (let k = 0; k < Math.min(6, ch); k++) entries.push({ name: `${name}/${file(lanes[k])}.wav`, data: wavFile([planes[k]], rec.rate) });
|
||
entries.push({ name: `${name}/FX.wav`, data: wavFile([planes[6], planes[7]], rec.rate) });
|
||
if (ch >= 10) { entries.push({ name: `${name}/VOX.wav`, data: wavFile([planes[8]], rec.rate) }); entries.push({ name: `${name}/DRY.wav`, data: wavFile([planes[9]], rec.rate) }); }
|
||
entries.push({ name: `${name}/MIX.wav`, data: wavFile(sum, rec.rate) });
|
||
take.files.push({ label: t("recStemsZip"), name: `${name}-stems.zip`, blob: new Blob([zipStored(entries)], { type: "application/zip" }) });
|
||
take.files.push({ label: t("recWav"), name: `${name}.wav`, blob: new Blob([wavFile(sum, rec.rate)], { type: "audio/wav" }) });
|
||
for (const e of entries.slice(0, -1)) take.files.push({ label: e.name.split("/")[1].replace(".wav", ""), name: e.name.replace("/", "-"), blob: new Blob([e.data], { type: "audio/wav" }), small: true });
|
||
} else {
|
||
take.files.push({ label: t("recWav"), name: `${name}.wav`, blob: new Blob([wavFile(planes.slice(0, 2), rec.rate)], { type: "audio/wav" }) });
|
||
}
|
||
}
|
||
if (rec.midi.length) {
|
||
take.files.push({ label: `${t("recMid")} (${rec.midi.filter((m) => (m.data[0] & 0xF0) === 0x90 && m.data[2]).length}${t("recNotes")})`, name: `${name}.mid`,
|
||
blob: new Blob([midiFile(rec.midi)], { type: "audio/midi" }) });
|
||
}
|
||
rec.takes.unshift(take);
|
||
rec.chunks = [];
|
||
return take;
|
||
}
|
||
let midiTapInput = null;
|
||
function midiTap(e) {
|
||
const d = e.data;
|
||
if (!rec.on || !d || !d.length || d[0] < 0x80 || d[0] >= 0xF0) return;
|
||
rec.midi.push({ t: performance.now() - rec.t0, data: Array.from(d) });
|
||
}
|
||
async function renderAudioInputs(ask = false) {
|
||
const sel = $("recdev"), was = sel.value;
|
||
if (state.target === "emu") { sel.replaceChildren(new Option(t("tEmu"), "emu")); sel.disabled = true; return; }
|
||
if (rec.mon) return; // (the input in use stays as it is)
|
||
sel.disabled = false;
|
||
try {
|
||
if (ask) (await navigator.mediaDevices.getUserMedia({ audio: true })).getTracks().forEach((x) => x.stop());
|
||
const ins = (await navigator.mediaDevices.enumerateDevices()).filter((d) => d.kind === "audioinput");
|
||
const opts = ins.map((d, i) => new Option(d.label || `${t("recInput")} ${i + 1}`, d.deviceId));
|
||
if (!opts.length || !ins.some((d) => d.label)) opts.push(new Option(t("recAsk"), "ask"));
|
||
if (MOCK) opts.unshift(new Option("JIANT FM (simulated: STEMS+IN, 10 ch)", "mock-stems"));
|
||
sel.replaceChildren(...opts);
|
||
const fm1 = MOCK ? { deviceId: "mock-stems" } : ins.find((d) => /fm-?1|jiant|felucca|m-?vave/i.test(d.label));
|
||
sel.value = [...sel.options].some((o) => o.value === was) ? was : fm1 ? fm1.deviceId : sel.options[0].value;
|
||
} catch (_) { sel.replaceChildren(new Option(t("recNoDev"), "")); }
|
||
}
|
||
$("recdev").addEventListener("change", () => { if ($("recdev").value === "ask") renderAudioInputs(true); });
|
||
function renderMidiInputs() {
|
||
const sel = $("midisrc"), was = sel.value;
|
||
const ins = access ? [...access.inputs.values()].filter((p) => p.state !== "disconnected") : [];
|
||
sel.replaceChildren(new Option(t("recMidiNone"), ""), ...ins.map((p) => new Option(p.name || p.id, p.id)));
|
||
const fm1 = ins.find((p) => PORT_RE.test(p.name || ""));
|
||
sel.value = [...sel.options].some((o) => o.value === was) ? was : fm1 ? fm1.id : "";
|
||
}
|
||
$("midisrc").addEventListener("focus", async () => { if (!access && !MOCK) { try { await midiAccess(); } catch (_) {} renderMidiInputs(); } });
|
||
function renderTakes() {
|
||
const box = $("takes");
|
||
if (!rec.takes.length) { box.replaceChildren(Object.assign(document.createElement("p"), { className: "small dim", textContent: t("recNone") })); return; }
|
||
box.replaceChildren(...rec.takes.map((tk) => {
|
||
const row = document.createElement("div"); row.className = "take";
|
||
const nm = document.createElement("span"); nm.className = "name"; nm.textContent = `${tk.name} · ${tk.secs.toFixed(1)} s`;
|
||
row.append(nm, ...tk.files.map((f) => {
|
||
const a = document.createElement("a"); a.className = "btn ghost"; a.textContent = f.label; a.download = f.name;
|
||
a.href = f.url || (f.url = URL.createObjectURL(f.blob)); return a;
|
||
}));
|
||
return row;
|
||
}));
|
||
}
|
||
|
||
/* -------------------------------------------------------------------------------------------- other devices */
|
||
/* JIANT FM's ports (ports/README.md): each one's state, what it is, and its links: the emulator (emu/devices.html, the
|
||
* same origin: shown here in a frame), the download (the releases), its manual. The words are TEXT's (p<Name>...) */
|
||
const GH = "https://github.com/juanjiant-bit/JIANT/blob/main/", RELEASES = "https://github.com/juanjiant-bit/JIANT/releases";
|
||
const MAN = "../docs/guide/"; // the manuals in HTML (tools/gen_manual_html.py), this site's
|
||
const OUTLINE = { // a device's outline where there is no picture (the pads, the keys)
|
||
smk: '<svg viewBox="0 0 320 120" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="312" height="112" rx="10"/><rect x="16" y="14" width="44" height="34" rx="3"/>' +
|
||
Array.from({ length: 8 }, (_, i) => `<rect x="${72 + i * 26}" y="16" width="20" height="13" rx="2"/><rect x="${72 + i * 26}" y="34" width="20" height="13" rx="2"/>`).join("") +
|
||
Array.from({ length: 22 }, (_, i) => `<rect x="${16 + i * 13.3}" y="62" width="11" height="46" rx="2"/>`).join("") + "</svg>",
|
||
mpc: '<svg viewBox="0 0 240 150" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="232" height="142" rx="12"/><rect x="16" y="16" width="86" height="54" rx="4"/>' +
|
||
Array.from({ length: 16 }, (_, i) => `<rect x="${118 + (i % 4) * 28}" y="${16 + Math.floor(i / 4) * 31}" width="24" height="27" rx="4"/>`).join("") +
|
||
'<circle cx="30" cy="96" r="10"/><circle cx="60" cy="96" r="10"/><circle cx="90" cy="96" r="10"/><rect x="18" y="118" width="84" height="8" rx="4"/></svg>',
|
||
plug: '<svg viewBox="0 0 240 150" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="232" height="142" rx="8"/><path d="M4 26h232"/><circle cx="16" cy="15" r="3"/><circle cx="28" cy="15" r="3"/>' +
|
||
'<rect x="18" y="40" width="60" height="92" rx="3"/><rect x="88" y="40" width="64" height="64" rx="3"/><circle cx="178" cy="54" r="12"/><circle cx="210" cy="54" r="12"/><rect x="164" y="80" width="60" height="52" rx="3"/></svg>',
|
||
};
|
||
const PORTS = [
|
||
// shots: the port running (its emulator's panel in the browser, the plugin's editor), the first one on the card
|
||
{ id: "smk37", name: "pSmkTitle", text: "pSmkText", points: ["pSmk1", "pSmk2"], state: ["stDev", "soon"], pic: OUTLINE.smk,
|
||
shots: [["img/smk37.webp", "shotSmk"]],
|
||
links: [["portTry", "#try:smk37"], ["portManual", MAN + "smk37.html"], ["portBuild", GH + "docs/SMK37.md"], ["portSoon", null]] },
|
||
{ id: "mpc", name: "pMpcTitle", text: "pMpcText", points: ["pMpc1", "pMpc2"], state: ["stPreview", "soon"], pic: OUTLINE.mpc,
|
||
shots: [["img/mpc.webp", "shotMpc"]], whole: true, // (the unit stands upright: all of it shown)
|
||
links: [["portTry", "#try:mpc"], ["portManual", MAN + "mpc-sample.html"], ["portDownload", RELEASES], ["portInstall", MAN + "mpc-sample.html#release"]] },
|
||
{ id: "mpcplug", name: "pPlugMpcTitle", text: "pPlugMpcText", points: ["pPlugMpc1", "pPlugMpc2"], state: ["stPreview", "soon"], pic: OUTLINE.mpc,
|
||
links: [["portDownload", RELEASES], ["portManual", MAN + "ports.html#the-mpc-plugin"], ["portSource", "https://github.com/juanjiant-bit/JIANT/tree/main/ports/mpc-plugin"]] },
|
||
{ id: "daw", name: "pDawTitle", text: "pDawText", points: ["pDaw1", "pDaw2", "pDaw3"], state: ["stCi", "ok"],
|
||
shots: [["img/plugin.webp", "shotDaw"], ["img/plugin-sound.webp", "shotDawSound"], ["img/plugin-samples.webp", "shotDawSamples"]],
|
||
links: [["portDownload", RELEASES], ["portManual", MAN + "plugin.html"], ["portSource", "https://github.com/juanjiant-bit/JIANT/tree/main/ports/juce-plugin"]] },
|
||
];
|
||
function renderPorts() {
|
||
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
|
||
$("portlist").replaceChildren(...PORTS.map((p) => {
|
||
const card = el("article", "card port");
|
||
const pic = el("div", "pic");
|
||
let thumbs = null;
|
||
if (p.shots) {
|
||
// the shot (a tap: larger), and under it a thumbnail each when there are more
|
||
const im = new Image(); im.loading = "lazy"; if (p.whole) im.style.objectFit = "contain";
|
||
const show = (k) => { im.src = p.shots[k][0]; im.alt = t(p.shots[k][1]); pic.dataset.k = k;
|
||
if (thumbs) [...thumbs.children].forEach((b, i) => b.setAttribute("aria-pressed", String(i === k))); };
|
||
const open = el("button", "picopen"); open.type = "button"; open.append(im);
|
||
open.addEventListener("click", () => openShot(p, +pic.dataset.k || 0));
|
||
pic.append(open);
|
||
if (p.shots.length > 1) {
|
||
thumbs = el("div", "thumbs");
|
||
thumbs.append(...p.shots.map(([src, cap], k) => {
|
||
const b = el("button"); b.type = "button"; b.title = t(cap);
|
||
const ti = new Image(); ti.src = src; ti.alt = ""; ti.loading = "lazy"; b.append(ti);
|
||
b.addEventListener("click", () => show(k));
|
||
return b;
|
||
}));
|
||
}
|
||
show(0);
|
||
} else { pic.innerHTML = p.pic; pic.setAttribute("aria-hidden", "true"); }
|
||
const meta = el("div", "meta"); meta.append(el("span", "state " + p.state[1], t(p.state[0])));
|
||
const ul = el("ul"); ul.append(...p.points.map((k) => el("li", null, t(k))));
|
||
const links = el("div", "links");
|
||
links.append(...p.links.map(([k, href], i) => {
|
||
if (!href) return el("span", "btn ghost na", t(k));
|
||
const a = el("a", "btn" + (i ? " ghost" : ""), t(k)); a.href = href;
|
||
if (href.startsWith("#try:")) a.addEventListener("click", (e) => { e.preventDefault(); tryDevice(href.slice(5), t(p.name)); });
|
||
else { a.target = "_blank"; a.rel = "noopener"; }
|
||
return a;
|
||
}));
|
||
card.append(pic, ...(thumbs ? [thumbs] : []), el("h2", null, t(p.name)), meta, el("p", null, t(p.text)), ul, links);
|
||
return card;
|
||
}));
|
||
}
|
||
/* a port's shots, large: a dialog, its caption, ← → between them */
|
||
function openShot(p, k) {
|
||
const dlg = $("shotdlg"), img = $("shotimg"), cap = $("shotcap");
|
||
const show = () => { img.src = p.shots[k][0]; img.alt = t(p.shots[k][1]); cap.textContent = `${t(p.name)} · ${t(p.shots[k][1])}`;
|
||
$("shotprev").hidden = $("shotnext").hidden = p.shots.length < 2; };
|
||
dlg._step = (d) => { k = (k + d + p.shots.length) % p.shots.length; show(); };
|
||
show();
|
||
dlg.showModal();
|
||
}
|
||
$("shotprev").addEventListener("click", () => $("shotdlg")._step(-1));
|
||
$("shotnext").addEventListener("click", () => $("shotdlg")._step(1));
|
||
$("shotclose").addEventListener("click", () => $("shotdlg").close());
|
||
$("shotdlg").addEventListener("click", (e) => { if (e.target === $("shotdlg")) $("shotdlg").close(); });
|
||
$("shotdlg").addEventListener("keydown", (e) => { if (e.key === "ArrowLeft") $("shotdlg")._step(-1); else if (e.key === "ArrowRight") $("shotdlg")._step(1); });
|
||
/* the device's emulator (the JIANT FM site's emu/devices.html, its panel picked by the hash) in the frame below */
|
||
function tryDevice(dev, name) {
|
||
const f = $("f-devices"), url = `${TOOLS.fm.base}emu/devices.html#${dev}`;
|
||
$("devtry").hidden = false; $("devtrytitle").textContent = `${t("portTry")} · ${name}`;
|
||
if (f.src !== new URL(url, location.href).href) f.src = url;
|
||
$("devtry").scrollIntoView({ behavior: "smooth", block: "start" });
|
||
}
|
||
$("f-devices").addEventListener("load", () => {
|
||
const f = $("f-devices");
|
||
dress(f);
|
||
try { // inside Studio: straight to the devices and their panel (its own bar, title, plugins note and footer are Studio's)
|
||
const d = f.contentDocument, st = d.createElement("style");
|
||
st.textContent = "main>header.top,main>section:first-of-type,section.plugins,main>footer,body>footer{display:none!important}";
|
||
d.head.append(st);
|
||
// the frame as tall as the page in it: the whole device and its screen larger, no scrolling inside
|
||
const fit = () => { f.style.height = `${Math.max(480, Math.ceil(d.body.getBoundingClientRect().bottom + f.contentWindow.scrollY) + 16)}px`; };
|
||
new f.contentWindow.ResizeObserver(fit).observe(d.body); fit();
|
||
} catch (_) {}
|
||
});
|
||
$("devtryclose").addEventListener("click", () => { $("devtry").hidden = true; $("f-devices").src = "about:blank"; });
|
||
|
||
/* ------------------------------------------------------------------------------------------- the whole page */
|
||
function render() {
|
||
const d = state.dev, fwName = state.fw === "byte" ? "BYTE" : "FM";
|
||
$("brandfw").textContent = fwName; $("herofw").textContent = fwName;
|
||
$("herolead").textContent = t(state.fw === "byte" ? "leadByte" : "leadFm");
|
||
document.querySelectorAll("[data-fw]").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.fw === state.fw)));
|
||
document.querySelectorAll("[data-install]").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.install === state.fw)));
|
||
document.querySelectorAll("[data-target]").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.target === state.target)));
|
||
document.querySelectorAll("nav.views button").forEach((b) => b.setAttribute("aria-current", b.dataset.go === state.view ? "page" : "false"));
|
||
// the device chip
|
||
const dot = $("devdot");
|
||
dot.className = "dot" + (state.busy ? " warn" : d ? " ok" : "");
|
||
$("devtext").textContent = state.busy ? t("devBusy") : state.looking ? t("devLooking") :
|
||
d ? devName(d) : t("devNone");
|
||
$("find").disabled = state.looking || state.busy; $("forget").hidden = !d;
|
||
$("findres").textContent = state.found;
|
||
$("step1").classList.toggle("now", !d); $("step3").classList.toggle("now", !!d);
|
||
// install
|
||
$("insttitle").textContent = t(state.fw === "byte" ? "instTitleByte" : "instTitleFm");
|
||
// editor
|
||
$("edtitle").textContent = state.fw === "byte" ? "JIANT BYTE" : "JIANT FM";
|
||
$("edtarget").textContent = t("edTarget") + t(state.target === "emu" ? "tEmu" : "tFm1");
|
||
$("ednote").hidden = state.target !== "emu"; $("ednote").textContent = t("edEmuNote");
|
||
// emulator
|
||
$("emutitle").textContent = state.fw === "byte" ? "JIANT BYTE" : "JIANT FM";
|
||
// screen
|
||
$("scrgo").textContent = t(scr.on ? "scrStop" : "scrStart");
|
||
const noMirror = state.target === "fm1" && d && d.screen === false;
|
||
$("scrgo").disabled = state.busy || (!scr.on && state.target === "fm1" && (!d || noMirror));
|
||
$("scrfull").disabled = noMirror;
|
||
$("scrwait").hidden = scr.on && scr.got;
|
||
$("scrwait").textContent = scr.on ? t("scrWaiting") : noMirror ? t("scrNoFw").replace("%s", devName(d)) :
|
||
t(state.target === "emu" ? "scrWaitEmu" : "scrWaitFm1");
|
||
$("scrhelp").textContent = t(state.target === "emu" ? "scrHelpEmu" : "scrHelpFm1");
|
||
$("scr").setAttribute("aria-label", t("scrTitle"));
|
||
if (!scr.on && state.view !== "screen") $("scrstat").textContent = "";
|
||
$("scrfull").hidden = !(document.fullscreenEnabled || document.webkitFullscreenEnabled);
|
||
// record
|
||
$("recgo").textContent = t(rec.on ? "recStop" : "recStart");
|
||
$("recgo").classList.toggle("recording", rec.on);
|
||
$("recgo").disabled = state.busy;
|
||
$("recmon").textContent = t(rec.mon ? "recMonitorStop" : "recMonitor");
|
||
$("recmon").disabled = rec.on || state.busy;
|
||
$("recplay").textContent = t(daw.playing ? "recPlayStop" : "recPlay");
|
||
$("recplay").disabled = rec.on || !daw.planes;
|
||
$("recprof").disabled = rec.mon || state.target === "emu";
|
||
if (state.view === "rec") profileHelp();
|
||
if (state.view === "rec" && !rec.on) { renderAudioInputs(); renderMidiInputs(); }
|
||
renderTakes();
|
||
if (state.view === "ports") renderPorts();
|
||
}
|
||
|
||
/* ------------------------------------------------- the editor and the emulator joined (target: Emulator) */
|
||
/* A MIDIAccess-like pair of ports for the editor's frame (editor.html ?emu=1): what the editor sends goes to the emulator's
|
||
* own editor handler (emu/index.html jiantEmu.sysex -> worklet.js -> editor-api.h), its replies and pushes come back */
|
||
function emuMidi() {
|
||
const emu = () => { try { return frames.emu.el.contentWindow.jiantEmu; } catch (_) { return null; } };
|
||
loadFrame("emu");
|
||
const input = { id: "emu-in", name: "JIANT (emulator)", type: "input", state: "connected", manufacturer: "JIANT", onmidimessage: null,
|
||
_l: new Set(), addEventListener(_, f) { this._l.add(f); }, removeEventListener(_, f) { this._l.delete(f); },
|
||
open() { return Promise.resolve(this); }, close() { return Promise.resolve(this); } };
|
||
let off = null;
|
||
const hook = () => {
|
||
const e = emu();
|
||
if (!e || off) return;
|
||
off = e.listen((bytes) => { const ev = { data: Uint8Array.from(bytes) }; input.onmidimessage && input.onmidimessage(ev); input._l.forEach((f) => f(ev)); });
|
||
};
|
||
const output = { id: "emu-out", name: "JIANT (emulator)", type: "output", state: "connected", manufacturer: "JIANT",
|
||
open() { return Promise.resolve(this); }, close() { return Promise.resolve(this); },
|
||
send(d) { hook(); const e = emu(); if (e && e.on()) e.sysex(Array.from(d)); } };
|
||
hook();
|
||
return { inputs: new Map([[input.id, input]]), outputs: new Map([[output.id, output]]), onstatechange: null, sysexEnabled: true };
|
||
}
|
||
/* which MIDI inputs play the emulator (emu/index.html jiantEmu.midiInput): every one, none, or one port */
|
||
function renderEmuMidi() {
|
||
const sel = $("emumidi");
|
||
let e = null;
|
||
try { e = frames.emu.el.contentWindow.jiantEmu; } catch (_) {}
|
||
if (!e || !e.on()) { sel.replaceChildren(new Option(t("emuMidiOff"), "")); sel.disabled = true; return; }
|
||
sel.disabled = false;
|
||
sel.replaceChildren(new Option(t("emuMidiAll"), "all"), new Option(t("emuMidiNone"), "none"), ...e.midiInputs().map((p) => new Option(p.name, p.id)));
|
||
sel.value = e.midiInput();
|
||
}
|
||
$("emumidi").addEventListener("change", () => { try { frames.emu.el.contentWindow.jiantEmu.midiInput($("emumidi").value); } catch (_) {} });
|
||
$("emumidi").addEventListener("pointerdown", renderEmuMidi);
|
||
setInterval(() => { if (state.view === "emu" && document.activeElement !== $("emumidi")) renderEmuMidi(); }, 1500);
|
||
/* the emulator's whole panel in its frame: the device as wide as the frame lets it be with all of it in sight (its own
|
||
* page makes it as wide as the page, taller than the frame); refitted on any resize, in or out of full screen */
|
||
function fitEmu() {
|
||
try {
|
||
const w = frames.emu.el.contentWindow, d = w.document, dev = d.getElementById("device");
|
||
if (!dev) return;
|
||
const ar = (dev.style.aspectRatio || "1000 / 624").split("/").map(Number), r = ar[0] / ar[1];
|
||
const main = dev.parentElement, cs = w.getComputedStyle(main);
|
||
const padX = parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight);
|
||
const top = dev.getBoundingClientRect().top + w.scrollY;
|
||
const h = Math.max(240, w.innerHeight - top - 12), wid = Math.min(main.clientWidth - padX, h * r);
|
||
main.style.maxWidth = "none";
|
||
Object.assign(dev.style, { width: `${Math.floor(wid)}px`, marginLeft: "auto", marginRight: "auto" });
|
||
} catch (_) {}
|
||
}
|
||
frames.emu.el.addEventListener("load", () => {
|
||
fitEmu();
|
||
try {
|
||
const w = frames.emu.el.contentWindow;
|
||
w.addEventListener("resize", fitEmu);
|
||
// (its layout, wide or tall, rebuilt: the aspect changes)
|
||
new w.MutationObserver(fitEmu).observe(w.document.getElementById("device"), { attributes: true, attributeFilter: ["style"] });
|
||
} catch (_) {}
|
||
});
|
||
/* full screen: the browser's own (the frame's box) where it has it; else (iPhone) the box over the whole page */
|
||
const emuFullOn = () => $("emubox").classList.contains("max") || document.fullscreenElement === $("emubox") || document.webkitFullscreenElement === $("emubox");
|
||
function emuFull(on) {
|
||
const b = $("emubox");
|
||
if (on) {
|
||
loadFrame("emu");
|
||
const req = b.requestFullscreen || b.webkitRequestFullscreen;
|
||
const p = req ? req.call(b) : null;
|
||
if (p && p.catch) p.catch(() => b.classList.add("max")); else if (!req) b.classList.add("max");
|
||
} else {
|
||
b.classList.remove("max");
|
||
if (document.fullscreenElement || document.webkitFullscreenElement) (document.exitFullscreen || document.webkitExitFullscreen).call(document);
|
||
}
|
||
setTimeout(fitEmu, 300);
|
||
}
|
||
$("emufull").addEventListener("click", () => emuFull(!emuFullOn()));
|
||
$("emuexit").addEventListener("click", () => emuFull(false));
|
||
document.addEventListener("keydown", (e) => { if (e.key === "Escape" && $("emubox").classList.contains("max")) emuFull(false); });
|
||
const emuOn = () => { try { const e = frames.emu.el.contentWindow.jiantEmu; return !!(e && e.on()); } catch (_) { return false; } };
|
||
|
||
/* ?mock=1: STEMS+IN's 10 channels made up (each its own pitch and pulse), in the recorder's own context: a node */
|
||
function mockStems(ac) {
|
||
const merge = ac.createChannelMerger(10);
|
||
for (let k = 0; k < 10; k++) {
|
||
const o = ac.createOscillator(), g = ac.createGain(), lfo = ac.createOscillator(), lg = ac.createGain();
|
||
o.type = ["square", "sawtooth", "triangle", "sine"][k % 4]; o.frequency.value = 55 * (k + 2);
|
||
lfo.frequency.value = 0.7 + k * 0.45; lg.gain.value = 0.18; g.gain.value = 0.2;
|
||
lfo.connect(lg).connect(g.gain); o.connect(g).connect(merge, 0, k); o.start(); lfo.start();
|
||
}
|
||
return merge;
|
||
}
|
||
|
||
/* ------------------------------------------------------------------------------- ?mock=1: a simulated FM-1 */
|
||
function mockAccess() {
|
||
const fb = new Uint16Array(SCR.W * SCR.H), rgb = (r, g, b) => (r >> 3) << 11 | (g >> 2) << 5 | b >> 3;
|
||
const rect = (x, y, w, h, c) => { for (let j = y; j < y + h; j++) fb.fill(c, j * SCR.W + x, j * SCR.W + x + w); };
|
||
const kind = QS.get("fw") === "byte" ? "byte" : "fm";
|
||
let on = false, last = 0, step = 0, tick = 0;
|
||
const input = { id: "mock-in", name: "JIANT", type: "input", state: "connected", onmidimessage: null,
|
||
_l: new Set(), addEventListener(_, f) { this._l.add(f); }, removeEventListener(_, f) { this._l.delete(f); } };
|
||
const deliver = (bytes) => setTimeout(() => { const ev = { data: Uint8Array.from(bytes) }; input.onmidimessage && input.onmidimessage(ev); input._l.forEach((f) => f(ev)); }, 2);
|
||
const draw = () => {
|
||
const bg = kind === "byte" ? rgb(0, 0, 0) : rgb(20, 18, 28), acc = kind === "byte" ? rgb(167, 123, 255) : rgb(236, 110, 80);
|
||
rect(0, 0, 240, 240, bg); rect(0, 0, 240, 24, rgb(40, 36, 52)); rect(8, 8, 70, 8, rgb(230, 230, 230)); rect(196, 8, 36, 8, acc);
|
||
rect(8, 34, 52, 44, acc); rect(64, 34, 52, 44, rgb(60, 56, 80)); rect(120, 34, 52, 44, rgb(60, 56, 80)); rect(176, 34, 56, 44, rgb(60, 56, 80));
|
||
for (let i = 0; i < 120; i++) fb[(120 + Math.round(30 * Math.sin(i / 9))) * 240 + 60 + i] = acc;
|
||
};
|
||
const output = { id: "mock-out", name: "JIANT", type: "output", state: "connected", send(d) {
|
||
const f = unframe(Uint8Array.from(d));
|
||
if (!f) return;
|
||
last = Date.now();
|
||
if (f.cmd === CMD.INFO) {
|
||
const s = (x) => [...x].map((c) => c.charCodeAt(0)).concat(0);
|
||
const eng = kind === "byte" ? ["ANALOG", "-", "PHASE", "MATH", "WAVE", "DRUM"] : ["ANALOG", "-", "PHASE", "MATH", "DRUM", "FM6"]; // (FM has MATH too)
|
||
deliver(frame(CMD.INFO, [...s(kind === "byte" ? (QS.has("nomirror") ? "JIANT BYTE v0.16" : "JIANT BYTE v0.17") : "JIANT V10.8.24"), eng.length, 100, 40, 64, 10, ...eng.flatMap(s)]));
|
||
} else if (f.cmd === 27) { // TRACK: six tracks, their engines (indexes into INFO's list)
|
||
deliver(frame(27, [0, 6, ...[4, 0, 2, 3, 5, 1].flatMap((e) => [e, 0, 0, 64, 0, 0])]));
|
||
} else if (f.cmd === CMD.SCREEN && !QS.has("nomirror")) { // (?nomirror: firmware from before the mirror: no reply)
|
||
const op = f.a[0] | 0;
|
||
if (op === 1 || (op === 3 && on)) { on = true; draw(); for (const a of scrEncode(fb, 0, 0, 240, 240)) deliver(frame(CMD.SCREEN_DATA, a)); }
|
||
if (op === 4) on = false;
|
||
deliver(frame(CMD.SCREEN, [op, 0, on ? 1 : 0, 240 & 127, 240 >> 7, 240 & 127, 240 >> 7]));
|
||
}
|
||
} };
|
||
setInterval(() => { // the playhead's row moving, and a note now and then
|
||
if (on && Date.now() - last < 4000) {
|
||
const y = 200, row = fb.subarray(y * 240, (y + 12) * 240);
|
||
row.fill(rgb(20, 18, 28)); for (let j = 0; j < 12; j++) row.fill(rgb(255, 210, 63), j * 240 + 8 + (step % 16) * 14, j * 240 + 20 + (step % 16) * 14);
|
||
step++;
|
||
for (const a of scrEncode(fb.subarray(y * 240), 0, y, 240, 12)) deliver(frame(CMD.SCREEN_DATA, a));
|
||
} else on = false;
|
||
if (++tick % 4 === 0) { const n = 48 + (tick % 12); deliver([0x90, n, 100]); setTimeout(() => deliver([0x80, n, 0]), 200); }
|
||
}, 125);
|
||
return { inputs: new Map([[input.id, input]]), outputs: new Map([[output.id, output]]), onstatechange: null, sysexEnabled: true };
|
||
}
|
||
|
||
/* ------------------------------------------------------------------------------------------------- the start */
|
||
document.documentElement.dataset.skin = state.fw;
|
||
const fromHash = (location.hash || "").replace(/^#/, "").split("?")[0];
|
||
applyLang();
|
||
go(QS.get("view") || (VIEWS.includes(fromHash) ? fromHash : state.view), false);
|
||
window.addEventListener("hashchange", () => { const h = location.hash.replace(/^#/, ""); if (VIEWS.includes(h) && h !== state.view) go(h, false); });
|
||
if (MOCK || QS.has("screen")) find().then(() => { if (QS.has("screen") && state.dev) { screenStart(); } });
|
||
/* (for the tests) */
|
||
window.jiantStudio = { emuMidi, state, find, letGo, screenStart, screenStop, recStart, recStop, setFw, setTarget, go, rec, scr };
|