mirror of
https://github.com/isod89/sloop-fm1.git
synced 2026-12-06 12:54:21 +01:00
11558 lines
840 KiB
HTML
11558 lines
840 KiB
HTML
<!doctype html>
|
||
<!-- SPDX-License-Identifier: GPL-3.0-only
|
||
Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments -->
|
||
<!-- Felucca web editor. One file, no libraries. Protocol: EDITOR_PROTOCOL.md.
|
||
Add ?mock=1 to the URL to use a built-in simulated device. -->
|
||
<html lang="ja">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>SLOOP Editor</title>
|
||
<!--PWA--><link rel="manifest" href="../sloop.webmanifest"><meta name="theme-color" content="#000000"><link rel="icon" href="../icon-192.png"><!--/PWA-->
|
||
<style>
|
||
/* SLOOP 2.4 editor: the FM-1's screen on a big display. Black, the four track colours, the device's own
|
||
Terminus pixel font (tools/gen_webfont.py, inlined: the editor also runs from file://), 16 px and 32 px only
|
||
so every pixel stays sharp. The accent (--trk) is the selected track's colour, as the curves on the device.
|
||
Fukiai: Hügelton Instruments' icon font (MIT, FUKIAI-LICENSE.txt); icons stay hidden until it has loaded. */
|
||
@font-face { font-family: "SLOOP Terminus"; src: /*SLOOP-FONT*/url(data:font/ttf;base64,AAEAAAAKAIAAAwAgT1MvMr126a8AAAEoAAAAYGNtYXDGt7jUAAAFGAAAAdxnbHlmpb0cuwAACoQAAQ5OaGVhZC7ukVYAAACsAAAANmhoZWEFAgECAAAA5AAAACRobXR4OIAzQAAAAYgAAAOObG9jYbJFbUYAAAb0AAADjm1heHACBwECAAABCAAAACBuYW1lYDwbZwABGNQAAAHjcG9zdEfFXqIAARq4AAAOTAABAAAAAQAAwEBbKl8PPPUAAwQAAAAAAObrpy8AAAAA5uunLwAA/wACAAMAAAAAAwACAAAAAAAAAAEAAAMA/wAAAAIAAAAAAAIAAAEAAAAAAAAAAAAAAAAAAAABAAEAAAHGAQAAQAAAAAAAAgAAAAAAAAAAAAA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jVEOAV1MjVEOQV1MjYzQQV1MjYzQgV1MjYzQwV1MjY0MAV1MjY0MgV1MjY2MAV1MjY2MwV1MjY2NQV1MjY2NgV1MjY2QQV1MjY2Qg==)/*SLOOP-FONT*/ format("truetype"); font-display: block; }
|
||
@font-face { font-family: "Fukiai"; src: url("fukiai.ttf") format("truetype"); font-display: block; unicode-range: U+EA00-EB09; }
|
||
:root {
|
||
--bg: #000; --s1: #0b0b0e; --s2: #1a1a1e; --s3: #36363c; --line: #232329; --dim: #76767e; --fg2: #c4c4cc; --fg: #f2f2f2;
|
||
--red: #ff2c34; --t1: #287cff; --t2: #1ecc70; --t3: #ffc618; --t4: #ff621a; --trk: var(--t1);
|
||
--font: "SLOOP Terminus", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
|
||
color-scheme: dark;
|
||
}
|
||
* { box-sizing: border-box; }
|
||
html { background: var(--bg); }
|
||
body { margin: 0; background: var(--bg); color: var(--fg2); font: 16px/20px var(--font); -webkit-font-smoothing: none;
|
||
font-smooth: never; text-rendering: optimizeSpeed; font-variant-numeric: tabular-nums; }
|
||
a { color: inherit; }
|
||
h1, h2, h3 { font-weight: 400; margin: 0; font-size: 16px; line-height: 20px; }
|
||
::selection { background: var(--trk); color: #000; }
|
||
[hidden] { display: none !important; }
|
||
.dim { color: var(--dim); }
|
||
.ic { font-family: "Fukiai"; font-style: normal; font-weight: 400; font-synthesis: none; line-height: 1; margin-right: .4em;
|
||
-webkit-font-smoothing: antialiased; }
|
||
html:not(.fk) .ic { display: none; }
|
||
|
||
/* ---- controls ---- */
|
||
button { font: inherit; color: var(--fg); background: var(--s2); border: 0; padding: 6px 12px; cursor: pointer;
|
||
white-space: nowrap; text-transform: lowercase; }
|
||
button:hover:not(:disabled) { background: var(--s3); }
|
||
button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--trk); outline-offset: 1px; }
|
||
button:disabled { color: var(--s3); background: var(--s1); cursor: default; }
|
||
button.pri { background: var(--trk); color: #000; }
|
||
button.pri:hover:not(:disabled) { background: var(--fg); }
|
||
button.pri:disabled { background: var(--s2); color: var(--s3); }
|
||
button.warn:hover:not(:disabled) { background: var(--red); color: #000; }
|
||
select, input[type=text], input[type=number], input[type=search] {
|
||
font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--s3); padding: 3px 6px; border-radius: 0; min-width: 0; }
|
||
select { appearance: none; padding-right: 22px; cursor: pointer;
|
||
background: var(--bg) linear-gradient(45deg, transparent 50%, var(--dim) 50%) no-repeat calc(100% - 9px) 55% / 5px 5px,
|
||
linear-gradient(-45deg, transparent 50%, var(--dim) 50%) no-repeat calc(100% - 4px) 55% / 5px 5px; }
|
||
select[size], select[multiple] { background: var(--bg); padding: 0; }
|
||
select option { background: var(--bg); color: var(--fg); }
|
||
select[size] option { padding: 2px 8px; }
|
||
select[size] option:checked { background: var(--trk); color: #000; }
|
||
input[type=search] { padding-left: 8px; }
|
||
input::placeholder { color: var(--s3); }
|
||
input[type=checkbox] { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--dim); background: var(--bg);
|
||
vertical-align: -3px; cursor: pointer; display: inline-grid; place-content: center; }
|
||
input[type=checkbox]:checked { background: var(--trk); border-color: var(--trk); }
|
||
input[type=checkbox]:checked::after { content: ""; width: 8px; height: 8px; background: #000; }
|
||
/* a slider: a thin bar filled to the value (--p, set by the editor), a small white handle; no native chrome */
|
||
input[type=range] { appearance: none; -webkit-appearance: none; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer; }
|
||
input[type=range]::-webkit-slider-runnable-track { height: 4px;
|
||
background: linear-gradient(90deg, var(--s3) var(--a, 0%), var(--c, var(--trk)) var(--a, 0%), var(--c, var(--trk)) var(--p, 0%), var(--s3) var(--p, 0%)); }
|
||
input[type=range]::-moz-range-track { height: 4px;
|
||
background: linear-gradient(90deg, var(--s3) var(--a, 0%), var(--c, var(--trk)) var(--a, 0%), var(--c, var(--trk)) var(--p, 0%), var(--s3) var(--p, 0%)); }
|
||
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 6px; height: 14px; margin-top: -5px; background: var(--fg); border: 0; border-radius: 0; }
|
||
input[type=range]::-moz-range-thumb { width: 6px; height: 14px; background: var(--fg); border: 0; border-radius: 0; }
|
||
input[type=range]:disabled { opacity: .3; }
|
||
progress { appearance: none; -webkit-appearance: none; height: 6px; border: 0; background: var(--s3); vertical-align: middle; }
|
||
progress::-webkit-progress-bar { background: var(--s3); }
|
||
progress::-webkit-progress-value { background: var(--trk); }
|
||
progress::-moz-progress-bar { background: var(--trk); }
|
||
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
|
||
.bar .grow { flex: 1; }
|
||
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; }
|
||
.seg button, button.tog { background: var(--s2); color: var(--dim); }
|
||
.seg button[aria-pressed="true"], button.tog[aria-pressed="true"] { background: var(--trk); color: #000; }
|
||
.seg.ids button { text-transform: none; }
|
||
button:disabled .ic { opacity: .5; }
|
||
label { white-space: nowrap; }
|
||
table { border-collapse: collapse; }
|
||
th { font-weight: 400; color: var(--dim); text-align: left; padding: 0 12px 4px 0; text-transform: lowercase; }
|
||
td { padding: 2px 12px 2px 0; }
|
||
td.i { color: var(--dim); text-align: right; }
|
||
|
||
/* ---- the frame: the side bar (logo, pages, the device), the page ---- */
|
||
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
|
||
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px; padding: 20px 16px;
|
||
border-right: 1px solid var(--line); overflow-y: auto; }
|
||
.brand { display: flex; align-items: flex-end; gap: 10px; color: var(--fg); text-decoration: none; }
|
||
.brand svg { width: 132px; height: auto; display: block; }
|
||
.brand span { color: var(--dim); text-transform: lowercase; padding-bottom: 2px; }
|
||
.tabs { display: flex; flex-direction: column; gap: 2px; }
|
||
.tabs .navh { color: var(--s3); margin: 14px 0 4px 12px; text-transform: lowercase; }
|
||
.tabs .navh:first-child { margin-top: 0; }
|
||
.tabs button { background: none; color: var(--dim); text-align: left; padding: 6px 12px; border-left: 4px solid transparent; }
|
||
.tabs button:hover { color: var(--fg); background: var(--s1); }
|
||
.tabs button[aria-selected="true"] { color: var(--fg); background: var(--s2); border-left-color: var(--trk); }
|
||
.devcard { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
|
||
.devline { display: flex; align-items: center; gap: 8px; color: var(--fg); }
|
||
.led { width: 10px; height: 10px; background: var(--s3); flex: none; }
|
||
.led.on { background: var(--t2); box-shadow: 0 0 8px var(--t2); }
|
||
.led.busy { background: var(--t3); }
|
||
#version { color: var(--fg2); overflow-wrap: anywhere; }
|
||
#live, #mock { color: var(--dim); }
|
||
#connect { width: 100%; }
|
||
.preview { border-bottom: 1px solid var(--line); padding: 16px 0; margin-bottom: 16px; }
|
||
.preview > * { max-width: 848px; }
|
||
.preview-toolbar, .preview-instrument, .preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
|
||
.preview-transport, .preview-volume, .preview-output, .preview-octaves { display: flex; align-items: center; gap: 8px; }
|
||
.preview-transport { flex-wrap: wrap; }
|
||
.preview-transport button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
|
||
.preview svg { width: 16px; height: 16px; flex: none; fill: currentColor; }
|
||
.preview-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg2); }
|
||
#preview-disclosure { color: var(--dim); background: none; padding: 4px 0; text-transform: none; }
|
||
#preview-disclosure:hover { color: var(--fg); }
|
||
.preview[data-expanded="false"] .preview-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; }
|
||
#preview-enable { color: var(--fg2); background: none; border: 1px solid var(--s3); }
|
||
#preview-enable[aria-pressed="true"] { border-color: var(--trk); color: var(--fg); }
|
||
#preview-enable:disabled { color: var(--dim); border-color: var(--line); }
|
||
#preview-play { min-width: 112px; color: var(--trk); border: 1px solid var(--trk); }
|
||
#preview-play:disabled { color: var(--dim); border-color: var(--line); }
|
||
#preview-play[aria-pressed="true"] { background: var(--trk); color: #000; }
|
||
.preview-volume { flex-wrap: wrap; }
|
||
.preview-volume label { display: flex; align-items: center; gap: 8px; }
|
||
#preview-volume { width: 112px; }
|
||
#preview-volume-value { min-width: 4ch; text-align: right; color: var(--fg); }
|
||
.preview-output { color: var(--dim); border-left: 1px solid var(--line); padding-left: 12px; }
|
||
#preview-meter { appearance: none; width: 64px; height: 8px; border: 0; background: var(--s2); }
|
||
#preview-meter::-webkit-meter-bar { border: 0; border-radius: 0; background: var(--s2); height: 8px; }
|
||
#preview-meter::-webkit-meter-optimum-value { background: var(--t2); }
|
||
#preview-meter::-moz-meter-bar { background: var(--t2); }
|
||
.preview-instrument { margin: 12px 0 8px; }
|
||
.preview-instrument-actions { display: flex; align-items: center; gap: 12px; }
|
||
#preview-fold { background: none; padding: 4px 0; color: var(--dim); text-decoration: underline; }
|
||
#preview-fold:hover { color: var(--fg); }
|
||
#preview-sound { color: var(--dim); margin-left: 8px; }
|
||
#preview-instrument { color: var(--fg); }
|
||
#preview-octave { min-width: 5ch; text-align: center; }
|
||
.preview-octaves button { width: 32px; height: 32px; padding: 0; }
|
||
.preview-keys { position: relative; width: 100%; }
|
||
.preview-keys button { touch-action: none; user-select: none; text-transform: none; padding: 8px; }
|
||
.preview-keys kbd { font: inherit; color: var(--dim); }
|
||
.preview-keys.piano { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; height: 96px; }
|
||
.piano .white-key { height: 96px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; align-items: center; background: var(--fg2); color: var(--bg); border-bottom: 3px solid var(--dim); }
|
||
.piano .white-key:hover:not(:disabled) { background: var(--fg); }
|
||
.piano .white-key kbd { color: var(--s3); }
|
||
.piano .black-key { position: absolute; z-index: 1; left: calc(var(--key) * 12.5% - 3.75%); width: 7.5%; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; background: var(--s1); color: var(--fg); border: 1px solid var(--s3); border-bottom-width: 3px; padding: 4px; }
|
||
.preview-keys.pads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; max-width: 480px; }
|
||
.pads button { min-width: 0; height: 48px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; border: 1px solid var(--s3); white-space: normal; text-align: left; line-height: 16px; }
|
||
.pads button kbd { border: 1px solid var(--s3); min-width: 20px; text-align: center; }
|
||
.preview-keys button[aria-pressed="true"], .preview-keys button[aria-pressed="true"]:hover { background: var(--trk); color: #000; border-color: var(--trk); }
|
||
.preview-keys button[aria-pressed="true"] kbd { color: #000; }
|
||
.preview-keys button:disabled { background: var(--s2); color: var(--dim); border-color: var(--line); }
|
||
.preview-footer { margin-top: 12px; color: var(--dim); align-items: baseline; }
|
||
.preview-footer .preview-help { white-space: nowrap; }
|
||
#preview-status[data-error="true"] { color: var(--red); }
|
||
.preview-footer kbd { font: inherit; color: var(--fg2); border: 1px solid var(--s3); padding: 0 4px; }
|
||
.preview-sequence { grid-column: 1 / 3; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
|
||
.preview-seq-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 8px; }
|
||
.preview-seq-head > span { margin-right: auto; }
|
||
.preview-seq-head label { color: var(--dim); }
|
||
#preview-edit { background: none; color: var(--dim); text-decoration: underline; padding: 0; }
|
||
#preview-edit:hover { color: var(--fg); }
|
||
.preview-seq-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 8px; margin-top: 4px; }
|
||
.preview-seq-label { min-width: 0; }
|
||
.preview-seq-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 4px; }
|
||
.preview-seq-tools select { width: 64px; min-width: 0; padding: 0 4px; height: 24px; }
|
||
.preview-seq-tools button { padding: 0; width: 24px; height: 24px; }
|
||
.preview-seq-pages { color: var(--dim); font-size: 12px; white-space: nowrap; }
|
||
.preview-seq-row > .preview-seq-steps { align-self: center; }
|
||
.preview-seq-drums { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 4px; }
|
||
.preview-seq-drumhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
|
||
.preview-seq-drumhead > .seq-all-drums { padding: 0; background: none; color: var(--dim); text-decoration: underline; margin-left: auto; }
|
||
.seq-drum-toggle { padding: 0; max-width: 100%; white-space: normal; background: none; color: var(--c); text-align: left; text-transform: none; }
|
||
.seq-drum-toggle:hover:not(:disabled) { background: none; color: var(--fg); }
|
||
.seq-drum-toggle:focus-visible { outline: 1px solid var(--c); outline-offset: 2px; }
|
||
.seq-drum-brief.on { color: var(--c); }
|
||
.preview-seq-lane { color: var(--fg2); align-self: center; padding-left: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
.preview-seq-numbers { color: var(--dim); text-align: center; font-size: 12px; }
|
||
.preview-seq-track { display: flex; align-items: center; gap: 4px; padding: 0; min-width: 0; width: 100%; height: 28px; color: var(--c); background: none; text-align: left; text-transform: none; }
|
||
.preview-seq-track[aria-pressed="true"] { background: var(--s2); }
|
||
.preview-seq-track .seq-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--fg2); }
|
||
.preview-seq-track .seq-no { width: 24px; flex: none; text-align: center; }
|
||
.preview-seq-track .seq-position { flex: none; margin-left: auto; color: var(--dim); padding-right: 4px; font-size: 12px; white-space: nowrap; }
|
||
.preview-seq-steps { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 2px; }
|
||
.preview-seq-cell { display: flex; align-items: center; justify-content: center; height: 28px; padding: 0; border: 1px solid var(--line); background: var(--s1); color: var(--dim); overflow: hidden; }
|
||
.preview-seq-cell:hover:not(:disabled) { border-color: var(--c); background: var(--s3); }
|
||
.preview-seq-cell:focus-visible { outline: 2px solid var(--c); outline-offset: 1px; }
|
||
.preview-seq-cell.on { background: var(--s2); color: var(--c); border-color: var(--s3); }
|
||
.preview-seq-cell.bar-start { border-left-color: var(--s3); }
|
||
.preview-seq-cell.is-current { color: var(--c); border-color: var(--c); }
|
||
.preview-seq-cell.on.is-current { background: var(--c); color: #000; }
|
||
.preview-seq-cell.unused { visibility: hidden; }
|
||
.preview-seq-row.is-muted .preview-seq-steps { opacity: .4; }
|
||
.preview-seq-cell .seq-hit { display: none; width: 4px; height: 12px; background: currentColor; }
|
||
.preview-seq-legend { color: var(--dim); margin: 6px 0 0; }
|
||
#preview-note-dialog { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--s3); padding: 20px; width: 520px; max-width: calc(100vw - 32px); }
|
||
#preview-note-dialog::backdrop { background: var(--bg); opacity: .7; }
|
||
#preview-note-title { font-size: 16px; line-height: 24px; margin: 0 0 16px; color: var(--c); }
|
||
.preview-note-chord { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
|
||
.preview-note-chord button { padding: 4px 8px; }
|
||
.preview-note-chord button[aria-pressed="true"] { color: var(--bg); background: var(--c); }
|
||
.preview-note-picker-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
|
||
#preview-note-value { color: var(--c); }
|
||
.preview-note-octave { display: flex; align-items: center; gap: 8px; }
|
||
.preview-note-octave button { padding: 0; width: 32px; height: 32px; }
|
||
.preview-note-piano.preview-keys.piano { grid-template-columns: repeat(7, minmax(0, 1fr)); height: 120px; }
|
||
.preview-note-piano .white-key { height: 120px; }
|
||
.preview-note-piano .black-key { left: calc(var(--key) * 14.285714% - 4.3%); width: 8.6%; height: 72px; padding: 4px 0; }
|
||
.preview-note-listen { display: flex; align-items: center; gap: 8px; color: var(--dim); margin-top: 12px; }
|
||
.preview-note-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
|
||
@media (min-width: 1100px) {
|
||
.preview[data-instrument="drums"][data-expanded="true"] { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 344px); column-gap: 24px; }
|
||
.preview[data-instrument="drums"][data-expanded="true"] .preview-instrument { grid-column: 1; grid-row: 1; margin-top: 0; }
|
||
.preview[data-instrument="drums"][data-expanded="true"] .preview-keys { grid-column: 1; grid-row: 2; }
|
||
.preview[data-instrument="drums"][data-expanded="true"] .preview-toolbar { grid-column: 2; grid-row: 1 / 3; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 16px; }
|
||
.preview[data-instrument="drums"][data-expanded="true"] .preview-volume { flex-direction: column; align-items: flex-start; gap: 12px; }
|
||
.preview[data-instrument="drums"][data-expanded="true"] .preview-output { border: 0; padding-left: 0; }
|
||
.preview[data-instrument="drums"][data-expanded="true"] .preview-footer { grid-column: 1 / 3; }
|
||
}
|
||
@media (max-width: 1150px) {
|
||
.preview-volume { width: 100%; justify-content: space-between; }
|
||
}
|
||
@media (max-width: 680px) {
|
||
.preview[data-expanded="false"] .preview-toolbar { grid-template-columns: 1fr auto; gap: 8px; }
|
||
.preview[data-expanded="false"] .preview-summary { grid-column: 1 / 3; grid-row: 2; }
|
||
.preview-toolbar { align-items: flex-start; }
|
||
.preview-volume { width: 100%; justify-content: space-between; }
|
||
.preview-keys.pads { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
||
.pads button { height: 64px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 4px; }
|
||
.preview-footer { gap: 4px; }
|
||
.preview-seq-row { grid-template-columns: 72px minmax(0, 1fr); gap: 4px; }
|
||
.preview-seq-tools { flex-wrap: wrap; }
|
||
.preview-seq-tools select { width: 72px; }
|
||
.preview-seq-lane { padding-left: 0; font-size: 12px; }
|
||
.preview-seq-track { gap: 0; }
|
||
.preview-seq-track .seq-name { display: none; }
|
||
.preview-seq-note { display: none; }
|
||
.preview-seq-cell.on .seq-hit { display: block; }
|
||
}
|
||
.devcard .links { display: flex; justify-content: space-between; gap: 8px; }
|
||
.lang { background: none; color: var(--dim); padding: 0; text-decoration: underline; text-transform: none; }
|
||
.lang:hover:not(:disabled) { background: none; color: var(--fg); }
|
||
|
||
.main { min-width: 0; padding: 0 32px 32px; }
|
||
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 20px 0 12px; border-bottom: 1px solid var(--line); }
|
||
.titlebar { display: flex; align-items: flex-end; gap: 16px; min-height: 32px; }
|
||
#pagetitle { font-size: 32px; line-height: 32px; color: var(--trk); text-transform: uppercase; white-space: nowrap; flex: none; }
|
||
#status { margin-left: auto; color: var(--dim); text-align: right; min-height: 20px; overflow-wrap: anywhere; max-width: 70%;
|
||
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||
#status.err { color: var(--red); }
|
||
.trackbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
|
||
.trackbar > .dim { text-transform: lowercase; margin-right: 4px; }
|
||
#trackbtns { gap: 8px; }
|
||
#trackbtns button { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 0; background: var(--s1); color: var(--fg2);
|
||
text-transform: none; min-width: 150px; max-width: 240px; overflow: hidden; }
|
||
#trackbtns button .no { width: 32px; height: 32px; display: grid; place-content: center; background: var(--s2); color: var(--c); font-size: 16px; flex: none; }
|
||
#trackbtns button .nm { overflow: hidden; text-overflow: ellipsis; }
|
||
#trackbtns button[aria-pressed="true"] { background: var(--s2); color: var(--fg); box-shadow: inset 0 -2px var(--c); }
|
||
#trackbtns button[aria-pressed="true"] .no { background: var(--c); color: #000; }
|
||
.hint { margin: 32px 0; color: var(--dim); }
|
||
.panel { padding-top: 20px; }
|
||
footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--s3); }
|
||
footer a { color: var(--dim); }
|
||
|
||
/* ---- cards and the parameter pages (the device's 4 knobs a page, one colour per knob) ---- */
|
||
.card { background: var(--s1); border: 1px solid var(--line); padding: 14px 16px 16px; margin: 0 0 16px; min-width: 0; }
|
||
.card > h2, .group > h2 { color: var(--fg); text-transform: uppercase; margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
|
||
font-size: 32px; line-height: 32px; }
|
||
.card > h2 .ic, .group > h2 .ic { font-size: 20px; }
|
||
.card > h2 .sub, .group > h2 .sub { color: var(--dim); text-transform: lowercase; margin-left: auto; font-size: 16px; line-height: 16px; }
|
||
.card > p.dim { margin: 0 0 12px; }
|
||
.groups + .card { margin-top: 16px; }
|
||
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 16px; align-items: start; }
|
||
.groups { columns: 2 520px; column-gap: 16px; }
|
||
.group { background: var(--s1); border: 1px solid var(--line); padding: 14px 16px 12px; min-width: 0; break-inside: avoid; margin: 0 0 16px; }
|
||
.group h3 { color: var(--dim); text-transform: uppercase; margin: 10px 0 6px; display: flex; align-items: center; }
|
||
.group h2 + h3 { margin-top: 0; }
|
||
.knobs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
|
||
/* 2.5: the DRUM SYNTH page */
|
||
/* 2.7: the Theme page */
|
||
.thwrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin: 8px 0; }
|
||
#thprev { width: 360px; max-width: 100%; aspect-ratio: 1; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
|
||
.thside { flex: 1; min-width: 260px; }
|
||
.thside h3 { margin: 10px 0 4px; font-size: 13px; }
|
||
.thcols { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
|
||
.thcols label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
|
||
.thcols input[type=color] { width: 100%; height: 34px; padding: 0; border-radius: 4px; cursor: pointer; }
|
||
#p-theme .thbad { outline: 3px solid var(--red); outline-offset: 1px; }
|
||
#p-theme .bad { color: var(--red); }
|
||
#thcode, #thpaste { flex: 1; min-width: 16em; font-family: ui-monospace, monospace; font-size: 12px; }
|
||
.dslanes { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin: 6px 0 10px; }
|
||
.dslanes button { --c: var(--t4); padding: 8px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||
.dslanes button[aria-pressed=true] { background: var(--c); border-color: var(--c); color: #000; }
|
||
.dsrng { display: inline-flex; align-items: center; gap: 6px; }
|
||
.dsrng input[type=range] { width: 110px; --c: var(--t4); }
|
||
#dsgroups .knob { --c: var(--t4); }
|
||
.knob { --c: var(--t1); position: relative; padding: 8px 10px 10px; min-width: 0; border-left: 1px solid var(--line);
|
||
display: flex; flex-direction: column; gap: 4px; }
|
||
.knob:first-child { border-left: 0; padding-left: 0; }
|
||
.knobs > .knob:nth-child(4n + 2) { --c: var(--t2); }
|
||
.knobs > .knob:nth-child(4n + 3) { --c: var(--t3); }
|
||
.knobs > .knob:nth-child(4n + 4) { --c: var(--t4); }
|
||
.knob .kl { color: var(--c); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
.knob .v { color: var(--fg); font-size: 32px; line-height: 32px; white-space: nowrap; overflow: hidden; cursor: ns-resize;
|
||
user-select: none; touch-action: none; }
|
||
.knob .v small { font-size: 16px; line-height: 16px; color: var(--dim); margin-left: 4px; }
|
||
.knob .v.long { font-size: 16px; line-height: 32px; }
|
||
.knob select { width: 100%; color: var(--fg); border-color: var(--s3); font-size: 16px; }
|
||
.knob.enum .v { display: none; }
|
||
.knob.enum select { margin-top: 6px; height: 34px; color: var(--c); border-color: var(--line); background-color: var(--s2); }
|
||
.knob.pushed .v, .knob.pushed select { color: var(--trk); }
|
||
/* wave choices: a page-drawn picker so the options carry an icon (Chrome 135+); native menus get words only */
|
||
@supports (appearance: base-select) {
|
||
select.wave, select.wave::picker(select) { appearance: base-select; }
|
||
select.wave > button { font: inherit; background: none; color: inherit; padding: 0; text-align: start; text-transform: none; }
|
||
select.wave::picker(select) { border: 1px solid var(--s3); background: var(--bg); color: var(--fg); padding: 0; }
|
||
select.wave option { padding: 2px 8px; min-block-size: 0; }
|
||
select.wave option:checked { color: var(--trk); }
|
||
select.wave option:hover, select.wave option:focus-visible { background: var(--trk); color: #000; }
|
||
select.wave option::checkmark { display: none; }
|
||
}
|
||
|
||
/* ---- sound: the engine and its presets ---- */
|
||
.browser { display: grid; grid-template-columns: 200px minmax(220px, 360px) 1fr; gap: 16px; align-items: start; }
|
||
.browser .fld { display: flex; flex-direction: column; gap: 6px; color: var(--dim); text-transform: lowercase; }
|
||
.browser select:not([size]) { width: 100%; }
|
||
.browser select[size] { width: 100%; height: 200px; }
|
||
.browser .acts { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding-top: 26px; }
|
||
.browser .acts .bar { margin: 0; }
|
||
#engine { height: 34px; }
|
||
|
||
/* ---- sequencer: the steps as the device's tiles, the drum lanes ---- */
|
||
.grid { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; margin: 8px 0 16px; }
|
||
.grid button { background: var(--s2); color: var(--dim); padding: 4px 5px; min-width: 0; height: 58px; display: flex; flex-direction: column;
|
||
justify-content: space-between; text-align: left; overflow: hidden; text-transform: none; }
|
||
.grid button:hover:not(:disabled) { background: var(--s3); }
|
||
.grid button .n { color: var(--s3); }
|
||
.grid button.beat .n { color: var(--dim); }
|
||
.grid button .x { overflow: hidden; overflow-wrap: anywhere; color: var(--fg2); line-height: 16px; max-height: 32px; }
|
||
.grid button.on { background: var(--trk); }
|
||
.grid button.on .n, .grid button.on .x { color: #000; }
|
||
.grid button.acc { box-shadow: inset 0 3px var(--fg); }
|
||
.grid button.tie { background: repeating-linear-gradient(-45deg, var(--s2) 0 6px, var(--s3) 6px 8px); }
|
||
.grid button.lk .n::after { content: " \25AA"; }
|
||
.grid button.fc1 .n::before { content: "F "; }
|
||
.grid button.fc2 .n::before { content: "\00d7 "; }
|
||
.grid button.sel { outline: 2px solid var(--fg); outline-offset: 1px; }
|
||
.stepdetail { margin: 0 0 16px; padding: 12px 0 0; border-top: 1px solid var(--line); }
|
||
.stepdetail .bar > * { margin-right: 8px; }
|
||
.stepdetail input[type=number] { width: 70px; }
|
||
.stepcols { columns: 520px; column-gap: 32px; }
|
||
.stepcols table { break-inside: avoid; margin-bottom: 12px; }
|
||
#steps input[type=text] { width: 140px; }
|
||
#steps input[type=number] { width: 60px; }
|
||
#steps .bad { border-color: var(--red); color: var(--red); }
|
||
#steps tr.off td { color: var(--s3); }
|
||
#steps tr.hl td { background: var(--s2); }
|
||
/* ---- 2.5: LEN at hand, the piano roll, the MIDI preview, the song order ---- */
|
||
.seqtools input[type=number] { width: 64px; text-align: center; }
|
||
.seqtools .sq { min-width: 34px; padding: 0 8px; }
|
||
.seqtools > * { margin-right: 6px; }
|
||
.rollbox { overflow-x: auto; margin: 8px 0; border: 1px solid var(--line); }
|
||
.rollbox canvas { display: block; touch-action: none; }
|
||
.midiprev { border: 1px solid var(--line); padding: 12px; margin: 8px 0 16px; }
|
||
.midiprev ul { margin: 6px 0; padding-left: 20px; }
|
||
.midiprev ul.warn li { color: var(--t3); }
|
||
table.song td, table.song th { padding: 4px 8px; text-align: left; }
|
||
table.song input[type=number] { width: 64px; }
|
||
table.song td.acts button { min-width: 34px; padding: 0 6px; margin-right: 4px; }
|
||
table.song tr.bad td { color: var(--red); }
|
||
#p-song .bad { color: var(--red); }
|
||
details.more { margin-top: 8px; }
|
||
details.more > summary { cursor: pointer; color: var(--dim); text-transform: lowercase; list-style: none; padding: 6px 0; }
|
||
details.more > summary::before { content: "\25B8 "; }
|
||
details.more[open] > summary::before { content: "\25BE "; }
|
||
.dgrid { display: grid; gap: 2px; margin: 8px 0 16px; overflow-x: auto; }
|
||
.dgrid .ln { color: var(--fg2); white-space: nowrap; padding-right: 10px; align-self: center; text-transform: lowercase; }
|
||
.dgrid .hd { color: var(--dim); }
|
||
.dgrid .gap { grid-column: 1 / -1; height: 12px; }
|
||
.dgrid button { background: var(--s2); color: #000; padding: 0; min-width: 18px; height: 22px; line-height: 22px; text-align: center; }
|
||
.dgrid button.beat { background: var(--s3); }
|
||
.dgrid button:hover { outline: 1px solid var(--dim); }
|
||
.dgrid button.on { background: var(--t4); }
|
||
.dgrid button.on.l1 { background: color-mix(in srgb, var(--t4) 35%, var(--s2)); }
|
||
.dgrid button.on.l2 { background: color-mix(in srgb, var(--t4) 65%, var(--s2)); }
|
||
.dgrid button.on.l3 { background: var(--fg); }
|
||
|
||
/* ---- mixer: the device's TRACKS strips ---- */
|
||
.mixer { display: grid; grid-template-columns: repeat(4, minmax(0, 170px)); gap: 12px; margin: 4px 0 12px; }
|
||
.strip { --c: var(--t1); background: var(--bg); border: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column;
|
||
align-items: center; gap: 8px; min-width: 0; }
|
||
.strip.sel { border-color: var(--c); }
|
||
.strip button.num { width: 48px; height: 48px; font-size: 32px; padding: 0; background: var(--s2); color: var(--c); }
|
||
.strip.sel button.num { background: var(--c); color: #000; }
|
||
.strip .snd { width: 100%; text-align: center; color: var(--fg); overflow-wrap: anywhere; min-height: 40px; }
|
||
.strip .rec, .strip .solo { color: var(--s3); text-transform: lowercase; }
|
||
.strip .rec.on { color: #000; background: var(--red); padding: 0 6px; }
|
||
.strip .rec:not(.on) .ic { visibility: hidden; }
|
||
.strip .solo { visibility: hidden; }
|
||
.strip .solo.on { visibility: visible; color: #000; background: var(--fg); padding: 0 6px; }
|
||
.strip input.fader { writing-mode: vertical-lr; direction: rtl; width: 32px; height: 180px; }
|
||
.strip input.fader::-webkit-slider-runnable-track { width: 6px; height: 100%; background: linear-gradient(0deg, var(--c) var(--p, 0%), var(--s3) var(--p, 0%)); }
|
||
.strip input.fader::-moz-range-track { width: 6px; background: linear-gradient(0deg, var(--c) var(--p, 0%), var(--s3) var(--p, 0%)); }
|
||
.strip input.fader::-webkit-slider-thumb { width: 18px; height: 8px; margin-top: 0; margin-left: -6px; }
|
||
.strip input.fader::-moz-range-thumb { width: 18px; height: 8px; }
|
||
.strip .lv { color: var(--fg); font-size: 32px; line-height: 32px; }
|
||
.strip .v { white-space: nowrap; }
|
||
.strip .pan { width: 100%; }
|
||
.strip.muted .fader, .strip.muted .lv { opacity: .35; }
|
||
.strip button { width: 100%; }
|
||
.strip button.tog[aria-pressed="true"] { background: var(--c); color: #000; }
|
||
.strip button.selb:disabled { background: none; color: var(--c); }
|
||
|
||
/* ---- library and the device bank ---- */
|
||
.libcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
|
||
.libcols > .card { margin: 0; }
|
||
.libcols .bar input[type=search] { flex: 1 1 140px; }
|
||
.list { height: 360px; overflow: auto; border: 1px solid var(--line); background: var(--bg); resize: vertical; }
|
||
.list table { width: 100%; table-layout: fixed; }
|
||
.list th { position: sticky; top: 0; background: var(--s1); padding: 4px 8px; }
|
||
.list td { padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg2); }
|
||
.list tr[data-id]:hover td, .list tr[data-slot]:hover td { background: var(--s2); }
|
||
.list tr[data-id], .list tr[data-slot] { cursor: pointer; }
|
||
.list tr.sel td, .list tr.sel:hover td { background: var(--trk); color: #000; }
|
||
.list tr.empty td { color: var(--s3); }
|
||
.list tr.over td { outline: 1px dashed var(--trk); outline-offset: -1px; }
|
||
.list.over { outline: 1px solid var(--trk); }
|
||
.list .none { padding: 12px; color: var(--dim); }
|
||
.list col.n { width: 52px; } .list col.e { width: 96px; } .list col.d { width: 110px; }
|
||
|
||
/* ---- samples: CHOP and the user slots ---- */
|
||
.smp { background: var(--s1); border: 1px solid var(--line); padding: 14px 16px; margin: 0 0 16px; }
|
||
.smp.over { outline: 2px dashed var(--trk); outline-offset: -2px; }
|
||
.smp .head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 8px; }
|
||
.smp .head b { font-weight: 400; color: var(--fg); min-width: 48px; }
|
||
.smp > .head:first-child b { font-size: 32px; line-height: 32px; color: var(--trk); }
|
||
.smp progress { width: 180px; }
|
||
.smp table { margin: 8px 0 0; }
|
||
.smp input.name { width: 110px; text-transform: uppercase; }
|
||
.smp input.root { width: 60px; }
|
||
.smp .bad { color: var(--red); }
|
||
.chop canvas.wave { display: block; width: 100%; height: 150px; margin: 8px 0; background: var(--bg); border: 1px solid var(--line);
|
||
cursor: default; touch-action: none; }
|
||
.chop .sep { width: 12px; }
|
||
.chop input.num { width: 70px; }
|
||
.chop input[type=range] { width: 110px; }
|
||
.chop button.tap { min-width: 80px; }
|
||
.chop .chops { display: flex; flex-wrap: wrap; gap: 3px; margin: 8px 0; }
|
||
.chop .chip { display: inline-flex; align-items: center; gap: 4px; background: var(--s2); color: var(--fg2); padding: 3px 8px; cursor: pointer;
|
||
user-select: none; text-transform: none; }
|
||
.chop .chip.on { background: var(--trk); color: #000; }
|
||
.chop .chip.off { color: var(--s3); text-decoration: line-through; }
|
||
.chop input.len { width: 180px; }
|
||
.chop .selrow[hidden] { display: none; }
|
||
|
||
/* ---- drum kit: 16 pads, one per drum lane, as the white keys ---- */
|
||
.kithead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; align-items: end; }
|
||
.kitmeter { display: flex; align-items: center; gap: 10px; }
|
||
.kitmeter progress { width: 220px; height: 8px; }
|
||
.kitmeter.over progress::-webkit-progress-value { background: var(--red); }
|
||
.kitmeter.over span { color: var(--red); }
|
||
.pads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
|
||
.pad { --c: var(--t4); background: var(--bg); border: 1px solid var(--line); padding: 10px; min-width: 0; display: flex; flex-direction: column;
|
||
gap: 6px; position: relative; min-height: 170px; }
|
||
.pad.over { outline: 2px dashed var(--c); outline-offset: -2px; }
|
||
.pad .ph { display: flex; align-items: baseline; gap: 8px; }
|
||
.pad .ph b { font-weight: 400; color: var(--c); text-transform: uppercase; }
|
||
.pad .ph .key { color: var(--s3); margin-left: auto; }
|
||
.pad canvas { width: 100%; height: 48px; display: block; background: var(--s1); cursor: pointer; }
|
||
.pad .fn { color: var(--fg2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
.pad .empty { flex: 1; display: grid; place-content: center; color: var(--s3); text-align: center; cursor: pointer; border: 1px dashed var(--s3); }
|
||
.pad .empty:hover { color: var(--fg2); border-color: var(--dim); }
|
||
.pad .row3 { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; color: var(--dim); }
|
||
.pad .row3 .val { color: var(--fg2); min-width: 64px; text-align: right; }
|
||
.pad .acts { display: flex; gap: 4px; }
|
||
.pad .acts button { padding: 3px 8px; }
|
||
.pad.playing canvas { outline: 1px solid var(--c); }
|
||
.kstep { border-top: 1px solid var(--line); padding: 16px 0 4px; margin-top: 8px; }
|
||
.kstep > h3 { display: flex; align-items: center; gap: 12px; color: var(--fg); text-transform: uppercase; margin: 0 0 10px; }
|
||
.kstep > h3 .num { width: 32px; height: 32px; display: grid; place-content: center; background: var(--trk); color: #000; font-size: 32px; line-height: 32px; }
|
||
.dest { display: grid; grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; }
|
||
.dest button { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; background: var(--bg);
|
||
border: 1px solid var(--s3); text-transform: none; white-space: normal; text-align: left; min-height: 92px; }
|
||
.dest button b { font-weight: 400; font-size: 32px; line-height: 32px; color: var(--fg); }
|
||
.dest button .cap { color: var(--dim); }
|
||
.dest button .now { color: var(--s3); overflow-wrap: anywhere; }
|
||
.dest button.full .now { color: var(--fg2); }
|
||
.dest button.big { border-color: var(--t4); }
|
||
.dest button.big b { color: var(--t4); }
|
||
.dest button[aria-checked="true"] { background: var(--s2); border-color: var(--trk); box-shadow: inset 0 0 0 1px var(--trk); }
|
||
.dest button[aria-checked="true"] b { color: var(--trk); }
|
||
.dest button:disabled { opacity: .35; }
|
||
.destnote { color: var(--fg2); margin: 0 0 10px; }
|
||
.destnote .warn, .warn-t { color: var(--t3); }
|
||
|
||
/* ---- samples: the slots, files or CHOP, send ---- */
|
||
.dest.slots4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
||
.dest.slots4 button progress { width: 100%; height: 4px; }
|
||
.modes { margin: 0 0 10px; }
|
||
.modes button { padding: 8px 16px; text-transform: none; }
|
||
.modes button[aria-selected="true"] { background: var(--trk); color: #000; }
|
||
.modehelp { color: var(--fg2); margin: 0 0 12px; max-width: 980px; }
|
||
.modehelp p { margin: 0 0 4px; }
|
||
.modehelp p:first-child { color: var(--fg); }
|
||
.dropzone { border: 1px dashed var(--s3); padding: 28px 16px; display: grid; place-items: center; gap: 6px; cursor: pointer;
|
||
text-align: center; margin: 0 0 12px; background: var(--bg); }
|
||
.dropzone b { font-weight: 400; color: var(--fg); }
|
||
.dropzone:hover, .dropzone.over { border-color: var(--trk); }
|
||
.dropzone.over { outline: 2px dashed var(--trk); outline-offset: -2px; }
|
||
canvas.keymap { display: block; width: 100%; height: 44px; margin: 8px 0 12px; }
|
||
.flist { display: grid; gap: 2px; margin: 0 0 8px; }
|
||
.frow { --c: var(--t1); display: grid; grid-template-columns: 40px minmax(0, 1fr) 80px 120px 80px 120px 150px 40px; gap: 8px; align-items: center;
|
||
background: var(--bg); padding: 4px 8px; border-left: 4px solid var(--c); }
|
||
.frow.fhead { background: none; border-left-color: transparent; color: var(--dim); text-transform: lowercase; }
|
||
.frow .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
|
||
.frow input.root { width: 72px; }
|
||
.frow button { padding: 3px 0; }
|
||
.frow .gain { display: grid; grid-template-columns: 1fr 52px; gap: 6px; align-items: center; }
|
||
.frow .gain .val { color: var(--fg2); text-align: right; }
|
||
.frow select { width: 100%; min-width: 0; }
|
||
.floopbox { display: grid; gap: 2px; }
|
||
.floop { --c: var(--t1); display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; background: var(--bg); padding: 6px 8px 8px 48px;
|
||
border-left: 4px solid var(--c); }
|
||
.floop canvas.loopwave { display: block; width: 100%; height: 48px; }
|
||
.floop .lpt { display: grid; grid-template-columns: 90px minmax(0, 1fr) 64px; gap: 8px; align-items: center; }
|
||
.floop .lpt .val { color: var(--fg2); text-align: right; }
|
||
.pane .smp.chop { border: 0; padding: 0; margin: 0; background: none; }
|
||
.seg button.trk[aria-pressed], .seg button.trk { color: var(--c); }
|
||
.seg button.trk:hover:not(:disabled) { background: var(--c); color: #000; }
|
||
.seg button.trk:disabled { color: var(--s3); }
|
||
/* ---- projects, settings ---- */
|
||
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
|
||
.slot { background: var(--bg); border: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
||
.slot b { font-weight: 400; font-size: 32px; line-height: 32px; color: var(--fg); }
|
||
.slot .st { color: var(--dim); text-transform: lowercase; }
|
||
.slot.used .st { color: var(--t2); }
|
||
.slot .bar { margin: 0; }
|
||
#sysinfo th { padding-right: 24px; }
|
||
#sysinfo td { color: var(--fg); }
|
||
.fm6ops { overflow-x: auto; }
|
||
.fm6list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; margin: 6px 0 10px; }
|
||
.fm6v { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
||
.fm6v button { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: none; }
|
||
.fm6v .dim { width: 2.6em; }
|
||
#fm6panel.drop { outline: 2px dashed var(--trk); outline-offset: -6px; }
|
||
.fm6ops td, .fm6ops th { padding: 1px 3px; }
|
||
input.fm6n { width: 3.6em; padding: 2px 3px; }
|
||
#fm6panel h3 { margin: 16px 0 6px; color: var(--dim); text-transform: uppercase; }
|
||
|
||
/* ---- narrow screens: the side bar becomes a top bar ---- */
|
||
@media (max-width: 860px) {
|
||
.app { grid-template-columns: minmax(0, 1fr); }
|
||
.side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px;
|
||
border-right: 0; border-bottom: 1px solid var(--line); }
|
||
.brand svg { width: 96px; }
|
||
.tabs { flex-direction: row; overflow-x: auto; order: 3; width: 100%; }
|
||
.tabs .navh { display: none; }
|
||
.tabs button { border-left: 0; border-bottom: 3px solid transparent; }
|
||
.tabs button[aria-selected="true"] { border-bottom-color: var(--trk); }
|
||
.devcard { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
|
||
#connect { width: auto; }
|
||
.main { padding: 0 16px 24px; }
|
||
.top { position: static; }
|
||
.browser { grid-template-columns: 1fr; }
|
||
.browser .acts { padding-top: 0; }
|
||
.grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
|
||
.mixer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||
.pads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||
.knobs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||
.dslanes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
||
.knobs > .knob:nth-child(2n + 1) { border-left: 0; padding-left: 0; }
|
||
.kithead { grid-template-columns: 1fr; }
|
||
.dest, .dest.slots4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||
.frow { grid-template-columns: 28px minmax(0, 1fr) 72px 32px; gap: 6px; } /* ▶ file note ×, then loop and gain */
|
||
.frow input.root { width: 100%; }
|
||
.frow > :nth-child(6) { grid-column: 2; grid-row: 2; }
|
||
.frow > :nth-child(7) { grid-column: 3 / 5; grid-row: 2; }
|
||
.frow > :nth-child(8) { grid-column: 4; grid-row: 1; }
|
||
.floop { padding-left: 8px; }
|
||
.floop .lpt { grid-template-columns: 80px minmax(0, 1fr) 56px; }
|
||
.frow > :nth-child(4), .frow > :nth-child(5) { display: none; }
|
||
.dest button.big { grid-column: 1 / -1; }
|
||
}
|
||
/* ---- 2.7: the LIVE page (the FM-1 under the hands: transport, sections, mixer, effects, keys) ---- */
|
||
#lv { --c: var(--trk); }
|
||
#lv .lvcard { margin-bottom: 12px; }
|
||
#lv .lvcard > h2, #lv .lvhead h2 { color: var(--fg); text-transform: uppercase; font-size: 16px; line-height: 20px; margin: 0 0 10px; }
|
||
#lv .lvhead h2 { margin: 0; }
|
||
#lv .lvhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-bottom: 10px; }
|
||
#lv .lvhint { margin: 8px 0 0; }
|
||
#lv button { touch-action: manipulation; }
|
||
.lvneeds { color: var(--t3); border: 1px solid var(--t3); padding: 8px 12px; margin: 0 0 12px; }
|
||
.lvgrp { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||
.lvtrans { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
|
||
html.lvfocus .lvtrans { position: sticky; top: 0; z-index: 4; }
|
||
.lvright { margin-left: auto; }
|
||
.lvbig { font-size: 32px; line-height: 32px; min-width: 132px; height: 64px; padding: 0 16px; }
|
||
.lvplay { background: var(--s2); color: var(--t2); border: 2px solid var(--t2); }
|
||
.lvplay.on { background: var(--t2); color: #000; }
|
||
.lvrec { height: 64px; min-width: 96px; color: var(--red); border: 2px solid var(--red); background: var(--s2); }
|
||
.lvrec.on { background: var(--red); color: #000; }
|
||
.lvrec.wait { animation: lvblink .5s steps(1) infinite; }
|
||
.lvundo { display: flex; flex-direction: column; gap: 2px; }
|
||
.lvundo button { padding: 4px 10px; }
|
||
.lvpos { display: grid; gap: 2px; min-width: 128px; }
|
||
.lvpos b { font-size: 32px; line-height: 32px; color: var(--fg); font-weight: 400; }
|
||
.lvbeat { display: flex; gap: 4px; }
|
||
.lvbeat i { width: 14px; height: 6px; background: var(--s3); }
|
||
.lvbeat i.on { background: var(--fg); }
|
||
.lvfill { display: grid; height: 64px; min-width: 88px; place-content: center; text-align: center; border: 2px solid var(--s3); color: var(--t3); background: var(--s2); touch-action: none; }
|
||
.lvfill small { color: var(--dim); }
|
||
.lvfill.on, .lvfill.act { background: var(--t3); color: #000; }
|
||
.lvfill.on small, .lvfill.act small { color: #000; }
|
||
.lvcpu { min-width: 6ch; }
|
||
@keyframes lvblink { 50% { opacity: .35; } }
|
||
/* a knob: drag up / down (Shift: fine), the wheel, the arrow keys; double-click: its default */
|
||
.lk { display: grid; justify-items: center; gap: 0; width: 64px; cursor: ns-resize; touch-action: none; user-select: none; -webkit-user-select: none; }
|
||
.lk svg { width: 48px; height: 48px; display: block; }
|
||
.lk .kb { fill: none; stroke: var(--s3); stroke-width: 4; }
|
||
.lk .kf { fill: none; stroke: var(--c, var(--trk)); stroke-width: 4; }
|
||
.lk .kl { color: var(--dim); text-transform: lowercase; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
|
||
.lk .kv { color: var(--fg); white-space: nowrap; }
|
||
.lk.drag .kv, .lk:focus-visible .kv { color: var(--c, var(--trk)); }
|
||
.lvtrans .lk { width: 76px; }
|
||
.lvbpm { width: 80px; }
|
||
.lvbpm svg { width: 64px; height: 64px; }
|
||
.lvbpm .kv { font-size: 32px; line-height: 32px; }
|
||
/* sections A..D */
|
||
.lvsecrow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
|
||
.lvsec { height: 84px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 8px 12px;
|
||
border: 2px solid var(--c); background: var(--bg); color: var(--fg); text-transform: none; }
|
||
.lvsec b { font-size: 32px; line-height: 32px; font-weight: 400; color: var(--c); }
|
||
.lvsec small { color: var(--dim); text-transform: lowercase; }
|
||
.lvsec.cur { background: var(--c); }
|
||
.lvsec.cur b, .lvsec.cur small { color: #000; }
|
||
.lvsec.next { animation: lvblink .5s steps(1) infinite; }
|
||
.lvsec.empty { border-color: var(--s3); }
|
||
.lvsec.empty b { color: var(--s3); }
|
||
.lvstorerow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 10px 0 0; }
|
||
.lvstorerow span { margin-right: 6px; }
|
||
.lvstore { padding: 2px 10px; }
|
||
/* mixer, master fx, effects */
|
||
.lvcols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0 12px; align-items: start; }
|
||
.lvknobs { display: flex; flex-wrap: wrap; gap: 8px 12px; }
|
||
.lvstrips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
|
||
.lstrip { background: var(--bg); border: 1px solid var(--line); border-top: 4px solid var(--c); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
|
||
.lstrip.target { border-color: var(--c); }
|
||
.lstrip.muted .lsbody { opacity: .4; }
|
||
.lstrip.rec .lsnum { background: var(--red); }
|
||
.lshead { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
||
.lsnum { background: var(--c); color: #000; padding: 0 6px; flex: none; }
|
||
.lsname { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
.lssnd { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px; }
|
||
.lssound { width: 100%; color: var(--fg); }
|
||
.lsnav { padding: 3px 8px; }
|
||
.lsprog { height: 3px; background: var(--s2); }
|
||
.lsprog i { display: block; height: 100%; width: 0; background: var(--c); }
|
||
.lsbody { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 6px; align-items: start; }
|
||
.lsknobs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 0; justify-items: center; }
|
||
.lstrip .lk { width: 100%; min-width: 0; }
|
||
.lstrip .lk .kl { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
|
||
.lstrip .lk svg { width: 40px; height: 40px; }
|
||
.lsbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
|
||
.lsbtns .lssel { grid-column: 1 / 3; }
|
||
#lv .lsbtns button { padding: 8px 4px; }
|
||
#lv .lsmute[aria-pressed="true"] { background: var(--red); color: #000; }
|
||
#lv .lssolo[aria-pressed="true"] { background: var(--fg); color: #000; }
|
||
#lv .lssel[aria-pressed="true"] { background: var(--c); color: #000; }
|
||
/* a fader: drag, a click on its track, the wheel, the keys; the track's meter beside it */
|
||
.lfd { display: flex; gap: 4px; height: 216px; cursor: ns-resize; touch-action: none; user-select: none; -webkit-user-select: none; }
|
||
.lfd .ft { position: relative; width: 22px; background: var(--s2); }
|
||
.lfd .ff { position: absolute; left: 0; right: 0; bottom: 0; background: var(--c); opacity: .85; }
|
||
.lfd .fc { position: absolute; left: -3px; right: -3px; height: 6px; background: var(--fg); }
|
||
.lfd .fm { position: relative; width: 6px; background: var(--s2); }
|
||
.lfd .fm i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--t2); transition: height 80ms linear; }
|
||
.lfd:focus-visible .fc { background: var(--c); }
|
||
.lvfxg { margin-top: 10px; }
|
||
.lvfxg > .dim { display: block; margin-bottom: 4px; text-transform: lowercase; }
|
||
.lvfxpads { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; }
|
||
.lvfx { height: 56px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; padding: 6px 8px;
|
||
white-space: normal; text-align: left; text-transform: none; border: 1px solid var(--s3); background: var(--bg); color: var(--fg); touch-action: none; }
|
||
.lvfx b { font-weight: 400; }
|
||
.lvfx kbd { font: inherit; color: var(--dim); }
|
||
#lv .lvfx.on, #lv .lvfx.act { background: var(--t4); border-color: var(--t4); color: #000; }
|
||
#lv .lvfx.on kbd, #lv .lvfx.act kbd { color: #000; }
|
||
/* the keys: two octaves and a C; the drum track: 16 pads */
|
||
.lvplaybox .seg button { min-width: 36px; }
|
||
#lv .lvplaybox .seg button[aria-pressed="true"] { background: var(--trk); color: #000; }
|
||
.lvoct { min-width: 9ch; text-align: center; color: var(--fg); }
|
||
.lvplaybox input[type=range] { width: 120px; }
|
||
.lvchan { color: var(--red); margin: 0 0 8px; }
|
||
.lvkeys { position: relative; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 2px; height: 168px; touch-action: none; }
|
||
.lvkeys .wk { height: 168px; background: var(--fg2); border: 0; border-bottom: 4px solid var(--dim); padding: 0 0 8px; display: flex; align-items: flex-end; justify-content: center; color: var(--s3); touch-action: none; }
|
||
.lvkeys .wk:hover { background: var(--fg); }
|
||
.lvkeys .bk { position: absolute; top: 0; z-index: 1; height: 100px; width: calc(100% / 15 * .62); left: calc((var(--x) + 1) * 100% / 15 - 100% / 15 * .31);
|
||
background: #000; border: 1px solid var(--s3); padding: 0 0 6px; display: flex; align-items: flex-end; justify-content: center; color: var(--dim); touch-action: none; }
|
||
.lvkeys .bk:hover { background: var(--s2); }
|
||
.lvkeys kbd { font: inherit; }
|
||
#lv .lvkeys .wk.on, #lv .lvkeys .bk.on { background: var(--trk); color: #000; }
|
||
.lvpads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; max-width: 760px; }
|
||
.lvpad { height: 76px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; padding: 8px 10px;
|
||
border: 1px solid var(--s3); background: var(--bg); color: var(--fg); text-transform: none; touch-action: none; }
|
||
.lvpad b { font-weight: 400; }
|
||
.lvpad kbd { font: inherit; color: var(--dim); }
|
||
#lv .lvpad.on { background: var(--t4); border-color: var(--t4); color: #000; }
|
||
#lv .lvpad.on kbd { color: #000; }
|
||
.lvkeyshelp { margin: 4px 0 0; }
|
||
/* the playlist */
|
||
.lvpl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: pl; }
|
||
.lvpl li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; counter-increment: pl; }
|
||
.lvplgo { display: grid; grid-template-columns: 2.5ch minmax(0, 1fr) auto; align-items: center; gap: 8px; text-align: left; text-transform: none;
|
||
background: var(--bg); border: 1px solid var(--s3); color: var(--fg); padding: 8px 10px; }
|
||
.lvplgo::before { content: counter(pl); color: var(--dim); }
|
||
.lvplgo b { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
.lvplgo small { color: var(--dim); }
|
||
.lvpl li.cur .lvplgo { border-color: var(--t2); box-shadow: inset 4px 0 var(--t2); }
|
||
.lvpl li.at .lvplgo { animation: lvblink .5s steps(1) infinite; }
|
||
.lvplact { display: flex; gap: 2px; }
|
||
.lvplact button { padding: 4px 8px; }
|
||
.lvplbar { margin: 10px 0 0; }
|
||
/* ---- LIVE pro: scenes, the PERFORM card, the steps, MIDI learn, the stage tools ---- */
|
||
.lvscnrow { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
|
||
.lvscn { position: relative; height: 72px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 6px 8px;
|
||
border: 2px solid var(--t1); background: var(--bg); color: var(--fg); text-transform: none; overflow: hidden; }
|
||
.lvscn b { font-size: 24px; line-height: 24px; font-weight: 400; color: var(--t1); }
|
||
.lvscn small { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
|
||
.lvscn kbd { position: absolute; right: 6px; top: 6px; font: inherit; color: var(--dim); }
|
||
.lvscn.empty { border-color: var(--s3); }
|
||
.lvscn.empty b { color: var(--s3); }
|
||
.lvscn.cur { background: linear-gradient(90deg, var(--t1) var(--m, 100%), var(--bg) var(--m, 100%)); }
|
||
.lvscn.cur b, .lvscn.cur small, .lvscn.cur kbd { color: #000; }
|
||
.lvscn.store { border-style: dashed; border-color: var(--red); }
|
||
.lvxrow { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; margin-top: 10px; }
|
||
.lvxf { width: 100%; }
|
||
.lvperf { --c: var(--trk); border-top: 4px solid var(--c); }
|
||
.lvperftrk { color: var(--c); }
|
||
.lvptabs { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }
|
||
.lvptab { padding: 4px 10px; }
|
||
#lv .lvptab[aria-selected="true"] { background: var(--c); color: #000; }
|
||
.lvxgrp { margin-top: 8px; }
|
||
.lvxgrp > .dim { display: block; margin-bottom: 2px; text-transform: lowercase; }
|
||
.lvxsel { display: grid; gap: 2px; min-width: 96px; align-self: center; }
|
||
.lvperf .lvknobs { align-items: center; }
|
||
.lvxsel .dim { text-transform: lowercase; }
|
||
.lvgrid { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; overflow-x: auto; }
|
||
.lvgr { display: grid; grid-template-columns: repeat(16, minmax(28px, 1fr)); gap: 2px; }
|
||
.lvgrid.drum .lvgr { grid-template-columns: 9ch repeat(16, minmax(22px, 1fr)); }
|
||
.lvgl { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: center; }
|
||
.lvgc { height: 34px; padding: 0; border: 1px solid var(--s3); background: var(--bg); color: var(--fg); font-size: inherit; text-transform: none; }
|
||
.lvgrid.drum .lvgc { height: 22px; }
|
||
.lvgc.beat { border-left-color: var(--dim); }
|
||
#lv .lvgc.on { background: var(--c); color: #000; border-color: var(--c); }
|
||
.lvgc.out { opacity: .3; }
|
||
.lvgc.ph { box-shadow: inset 0 0 0 2px var(--fg); }
|
||
.lvgc.fillonly { border-bottom: 3px solid var(--t3); }
|
||
.lvgc.nofill { border-bottom: 3px solid var(--red); }
|
||
.lsfav { margin-left: auto; padding: 0 6px; color: var(--t3); background: none; border: 0; }
|
||
.lvtools { flex-basis: 100%; }
|
||
.lvclock { display: grid; text-align: left; background: none; border: 0; padding: 0 8px 0 0; text-transform: none; }
|
||
.lvclock b { font-size: 24px; line-height: 24px; font-weight: 400; color: var(--fg); }
|
||
.lvrecset { --lv: 0%; background: linear-gradient(90deg, var(--s3) var(--lv), var(--s2) var(--lv)); border: 2px solid var(--red); color: var(--red); }
|
||
.lvrecset.on { color: var(--fg); animation: lvblink 1s steps(1) infinite; }
|
||
.lvlearnbar { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
||
.lvlearnbar:not(:has(.lvlearnmsg:not([hidden]))) { display: none; }
|
||
.lvlearnmsg { color: var(--t3); }
|
||
#lv .lvlearnbtn[aria-pressed="true"] { background: var(--t3); color: #000; }
|
||
#lv.learn [data-lvm] { outline: 1px dashed var(--t3); outline-offset: 1px; }
|
||
#lv.learn .lvmapped { outline: 2px solid var(--t2); }
|
||
#lv.learn .lvlearnat { outline: 3px solid var(--t3); }
|
||
#lv.locked .lvcard { pointer-events: none; }
|
||
#lv.locked .lvcard > * { opacity: .85; }
|
||
#lv.locked .lvlockbtn { pointer-events: auto; opacity: 1; }
|
||
#lv .lvlockbtn[aria-pressed="true"] { background: var(--red); color: #000; }
|
||
.lvcue { margin: 0 0 8px; }
|
||
.lvcue p { margin: 0 0 2px; }
|
||
.lvcue p:first-child b { font-size: 20px; color: var(--t2); font-weight: 400; }
|
||
@media (max-width: 760px) {
|
||
.lvscnrow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
||
.lvxrow { grid-template-columns: auto minmax(0, 1fr) auto; }
|
||
.lvxrow > .dim, .lvxrow > b { display: none; }
|
||
}
|
||
/* a page a newcomer can read: each card's line and "?", the first steps, the essentials view */
|
||
.lvsub { display: flex; align-items: center; gap: 8px; margin: -4px 0 10px; color: var(--dim); }
|
||
.lvtrans > .lvsub, .lvtrans > .lvhelp { flex-basis: 100%; margin: 0; }
|
||
.lvq { min-width: 28px; height: 24px; padding: 0 6px; border: 1px solid var(--s3); color: var(--fg); background: var(--bg); }
|
||
#lv .lvq[aria-expanded="true"] { background: var(--t3); border-color: var(--t3); color: #000; }
|
||
.lvhelp { border-left: 3px solid var(--t3); background: var(--s2); padding: 8px 12px; margin: 0 0 10px; }
|
||
.lvhelp p { margin: 0 0 6px; }
|
||
.lvhelp p:last-child { margin: 0; }
|
||
.lvguide { border: 1px solid var(--t3); }
|
||
.lvsteps { margin: 0 0 8px; padding-left: 22px; display: grid; gap: 6px; }
|
||
.lvguidebtn { margin: 0 0 12px; }
|
||
.lvtabsub { margin: 0 0 4px; }
|
||
#lv.simple .lvadv { display: none !important; }
|
||
#lv.nopro .lvxpro { display: none !important; }
|
||
.lvthrow { height: 48px; min-width: 96px; border: 1px solid var(--t1); color: var(--t1); background: var(--bg); touch-action: none; }
|
||
#lv .lvthrow.on, #lv .lvthrow.act { background: var(--t1); color: #000; }
|
||
.lvchainlist { color: var(--fg); min-width: 10ch; padding: 0 6px; }
|
||
.lvchainlist.run { color: var(--t2); }
|
||
.lvpattools { margin: 6px 0 0; }
|
||
.lvkeys.roll .wk, .lvpads.roll .lvpad { box-shadow: inset 0 -4px var(--t3); }
|
||
.lvkeys.erase .wk, .lvpads.erase .lvpad { box-shadow: inset 0 -4px var(--red); }
|
||
.lvrollrate .lvxsel { min-width: 80px; }
|
||
/* (2.7) the drum track on the Sound page */
|
||
#drumpanel { --c: var(--t4); }
|
||
.dprow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin: 10px 0; }
|
||
.dpkit { min-width: 220px; }
|
||
.dpkitsel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px; }
|
||
.dppads { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
|
||
.dpcell { border: 1px solid var(--s3); padding: 6px; display: grid; gap: 4px; }
|
||
.dpcell.tweaked { border-color: var(--t4); }
|
||
.dppad { text-align: left; text-transform: none; touch-action: none; }
|
||
#drumpanel .dppad.on { background: var(--t4); color: #000; }
|
||
.dpk { display: flex; justify-content: space-around; }
|
||
.dpk .lk { width: 56px; }
|
||
.dpk .lk svg { width: 40px; height: 40px; }
|
||
.lk.dpoff { opacity: .35; pointer-events: none; }
|
||
/* full screen: the page alone */
|
||
html.lvfocus .app { grid-template-columns: minmax(0, 1fr); }
|
||
html.lvfocus .side, html.lvfocus .top, html.lvfocus #hint, html.lvfocus #preview { display: none !important; }
|
||
html.lvfocus .main { padding: 12px 16px 16px; }
|
||
html.lvfocus .panel { padding-top: 0; }
|
||
@media (max-width: 1180px) {
|
||
.lvcols { grid-template-columns: minmax(0, 1fr); }
|
||
}
|
||
@media (max-width: 760px) {
|
||
.lvtrans { gap: 10px 16px; position: static; }
|
||
.lvright { margin-left: 0; }
|
||
.lvbig { min-width: 96px; height: 56px; }
|
||
.lvstrips { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
|
||
.lstrip { flex: 0 0 168px; scroll-snap-align: start; }
|
||
.lvsec { height: 68px; }
|
||
.lvkeys, .lvkeys .wk { height: 136px; }
|
||
.lvkeys .bk { height: 80px; }
|
||
.lvkeys kbd, .lvpad kbd, .lvfx kbd, .lvkeyshelp { display: none; }
|
||
.lvpad { height: 64px; }
|
||
.lvfxpads { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="app">
|
||
<aside class="side">
|
||
<a class="brand" href="#sound" aria-label="SLOOP">
|
||
<svg viewBox="44 24 572 186" role="img" aria-hidden="true">
|
||
<path d="M59.29 200.71 A100.00 100.00 0 1 1 200.71 200.71" fill="none" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
|
||
<rect x="95" y="46" width="10" height="136" rx="5" fill="#F2F2F2"/>
|
||
<polygon points="111,50 111,50 131.34,75 111,75" fill="#287CFF"/>
|
||
<polygon points="111,81 136.22,81 156.56,106 111,106" fill="#1ECC70"/>
|
||
<polygon points="111,112 161.44,112 181.78,137 111,137" fill="#FFC618"/>
|
||
<polygon points="111,143 186.66,143 207,168 111,168" fill="#FF621A"/>
|
||
<rect x="66" y="192" width="128" height="12" rx="6" fill="#F2F2F2"/>
|
||
<path d="M290.88 130 A14.88 15 0 1 1 304.37 108.66" fill="none" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
|
||
<path d="M290.88 130 A14.88 15 0 1 1 277.39 151.34" fill="none" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
|
||
<line x1="337.76" y1="68" x2="337.76" y2="160" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
|
||
<circle cx="399.76" cy="130" r="30" fill="none" stroke="#F2F2F2" stroke-width="12"/>
|
||
<circle cx="489.76" cy="130" r="30" fill="none" stroke="#F2F2F2" stroke-width="12"/>
|
||
<circle cx="579.76" cy="130" r="30" fill="none" stroke="#F2F2F2" stroke-width="12"/>
|
||
<line x1="549.76" y1="130" x2="549.76" y2="196" stroke="#F2F2F2" stroke-width="12" stroke-linecap="round"/>
|
||
</svg>
|
||
<span>editor</span>
|
||
</a>
|
||
<nav class="tabs" id="tabs" role="tablist" aria-orientation="vertical">
|
||
<div class="navh" data-t="navTrack"></div>
|
||
<button role="tab" data-tab="live" data-t="tabLive" data-ic="note_eight"></button>
|
||
<button role="tab" data-tab="sound" data-t="sound" data-ic="symbol_audio"></button>
|
||
<button role="tab" data-tab="sequencer" data-t="tabSeq" data-ic="symbol_grid"></button>
|
||
<button role="tab" data-tab="tracks" data-t="tabTracks" data-ic="ui_slider_vertical"></button>
|
||
<button role="tab" data-tab="song" data-t="tabSong" data-ic="control_arrow_loop"></button>
|
||
<div class="navh" data-t="navSounds"></div>
|
||
<button role="tab" data-tab="library" data-t="library" data-ic="symbol_books"></button>
|
||
<button role="tab" data-tab="samples" data-t="samples" data-ic="symbol_waves"></button>
|
||
<button role="tab" data-tab="kits" data-t="tabKits" data-ic="symbol_drum"></button>
|
||
<button role="tab" data-tab="drumsynth" data-t="tabDrumSynth" data-ic="symbol_waves"></button>
|
||
<div class="navh" data-t="navDevice"></div>
|
||
<button role="tab" data-tab="projects" data-t="projects" data-ic="symbol_folder"></button>
|
||
<button role="tab" data-tab="settings" data-t="tabSettings" data-ic="symbol_cog"></button>
|
||
<button role="tab" data-tab="theme" data-t="tabTheme" data-ic="ui_knob"></button>
|
||
</nav>
|
||
<div class="devcard">
|
||
<div class="devline"><span class="led" id="led"></span><span data-t="fm1"></span></div>
|
||
<span id="version"></span>
|
||
<span id="live"></span>
|
||
<span id="mock" hidden data-t="mock"></span>
|
||
<button id="connect" class="pri" data-t="connect" data-ic="port_usb_c"></button>
|
||
<div class="links"><a class="dim" href="../installer/" data-t="installer"></a><button class="lang" id="lang"></button></div>
|
||
<button id="install" class="pri" data-t="install" hidden></button>
|
||
<!--DL--><a class="dim" id="offline" href="sloop-editor.html" download="sloop-editor.html" data-t="offline"></a><!--/DL-->
|
||
</div>
|
||
</aside>
|
||
|
||
<main class="main">
|
||
<header class="top">
|
||
<div class="titlebar"><h1 id="pagetitle"></h1><div id="status" role="status" aria-live="polite"></div></div>
|
||
<div class="trackbar" id="trackbar" hidden><span class="dim" data-t="track"></span><span class="seg" id="trackbtns" role="group"></span></div>
|
||
</header>
|
||
<p class="hint" id="hint" hidden></p>
|
||
<section class="preview" id="preview" aria-label="Local audio preview" hidden>
|
||
<div class="preview-toolbar">
|
||
<div class="preview-transport">
|
||
<button id="preview-enable" aria-pressed="false"></button>
|
||
<button id="preview-play" aria-pressed="false" disabled></button>
|
||
<button id="preview-stop" disabled></button>
|
||
</div>
|
||
<span class="preview-summary" id="preview-summary"></span>
|
||
<button id="preview-disclosure" aria-expanded="false" aria-controls="preview-instrument-panel preview-keys preview-footer preview-sequence preview-volume-panel"></button>
|
||
<div class="preview-volume" id="preview-volume-panel">
|
||
<label><span data-t="previewVolume"></span> <input id="preview-volume" type="range" min="0" max="100" value="50"> <output id="preview-volume-value" for="preview-volume">50%</output></label>
|
||
<div class="preview-output"><span data-t="previewOutput"></span><meter id="preview-meter" min="0" max="1" value="0" aria-label="Local audio output level"></meter></div>
|
||
</div>
|
||
</div>
|
||
<div class="preview-instrument" id="preview-instrument-panel">
|
||
<div><span id="preview-instrument"></span><span id="preview-sound"></span></div>
|
||
<div class="preview-instrument-actions">
|
||
<div class="preview-octaves" id="preview-octaves">
|
||
<button id="preview-down" aria-label="Octave down">−</button>
|
||
<span id="preview-octave">C4–C5</span>
|
||
<button id="preview-up" aria-label="Octave up">+</button>
|
||
</div>
|
||
<button id="preview-fold" aria-expanded="true" aria-controls="preview-keys"></button>
|
||
</div>
|
||
</div>
|
||
<div class="preview-keys" id="preview-keys"></div>
|
||
<div class="preview-footer" id="preview-footer">
|
||
<span id="preview-status" role="status" aria-live="polite"></span>
|
||
<span class="preview-help"><kbd>Space</kbd> <span data-t="previewShortcut"></span></span>
|
||
</div>
|
||
<div class="preview-sequence" id="preview-sequence" hidden>
|
||
<div class="preview-seq-head"><span data-t="previewSequence"></span><label><input type="checkbox" id="preview-follow" checked> <span data-t="previewFollow"></span></label><button id="preview-edit" data-t="previewEdit"></button></div>
|
||
<div id="preview-sequence-rows"></div>
|
||
<p class="preview-seq-legend" data-t="previewSequenceHint"></p>
|
||
</div>
|
||
</section>
|
||
|
||
<!-- 2.7: LIVE, the FM-1 under the hands (built by the script: lvBuild) -->
|
||
<section class="panel" id="p-live" data-tab="live" data-dev hidden>
|
||
<div id="lv"></div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-sound" data-tab="sound" data-dev hidden>
|
||
<div class="card">
|
||
<div class="browser" id="browser">
|
||
<label class="fld"><span data-t="engine"></span><select id="engine"></select></label>
|
||
<label class="fld"><span data-t="presets"></span><select id="preset" size="10"></select></label>
|
||
<div class="acts">
|
||
<p class="bar"><button id="init" class="warn" data-t="initSound"></button>
|
||
<button id="factlib" data-t="factoryToLib" data-ic="symbol_books"></button></p>
|
||
<p class="bar"><button id="savefile" data-t="saveFile" data-ic="symbol_download"></button>
|
||
<button id="loadfile" data-t="loadFile" data-ic="symbol_upload"></button>
|
||
<input type="file" id="file" accept=".json,application/json" hidden></p>
|
||
<p class="dim" id="ctlhelp"><span data-t="ctlHelp"></span> <span data-t="ctlDrag"></span></p>
|
||
</div>
|
||
</div>
|
||
<p class="dim" id="drumnote" data-t="drumNote" hidden></p>
|
||
</div>
|
||
<!-- (2.7) the drum track's sound: what the FM-1's DRUMS screen sets (the kit page, the SOUND page) -->
|
||
<div class="card" id="drumpanel" hidden></div>
|
||
<div class="groups" id="groups"></div>
|
||
<!-- the FM6 engine's patch (firmware protocol v9): only while the selected track plays FM6 -->
|
||
<div class="card" id="fm6panel" hidden>
|
||
<h2 data-t="fm6Title" data-ic="ui_knob"></h2>
|
||
<p class="dim" data-t="fm6Help"></p>
|
||
<p class="bar"><button id="fm6read" data-t="fm6ReadBtn"></button> <button id="fm6send" class="pri" data-t="fm6SendBtn"></button>
|
||
<label><input type="checkbox" id="fm6live"> <span data-t="fm6Live"></span></label></p>
|
||
<p class="bar"><label><span data-t="fm6Slot"></span> <select id="fm6slot"></select></label>
|
||
<button id="fm6load" data-t="load"></button> <button id="fm6store" data-t="fm6StoreBtn"></button>
|
||
<button id="fm6erase" class="warn" data-t="erase"></button></p>
|
||
<p class="bar"><button id="fm6import" data-t="fm6Import" data-ic="symbol_upload"></button>
|
||
<input type="file" id="fm6file" accept=".syx,.SYX,.bin,application/octet-stream" hidden>
|
||
<button id="fm6export" data-t="fm6Export" data-ic="symbol_download"></button>
|
||
<button id="fm6bankexp" data-t="fm6BankExport" data-ic="symbol_download"></button>
|
||
<button id="fm6init" data-t="fm6Init"></button> <span class="dim" data-t="fm6Drop"></span></p>
|
||
<div id="fm6imported"></div>
|
||
<h3 data-t="fm6Voice"></h3>
|
||
<div id="fm6voice"></div>
|
||
<h3 data-t="fm6Ops"></h3>
|
||
<div id="fm6ops"></div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-sequencer" data-tab="sequencer" data-dev hidden>
|
||
<div class="groups" id="seqgroups"></div>
|
||
<div class="card" id="steps">
|
||
<h2><span data-t="steps" data-ic="note_eight"></span><span class="sub" id="steplen"></span></h2>
|
||
<p class="bar"><button id="reloadsteps" data-t="reload" data-ic="control_arrow_loop"></button>
|
||
<button id="clearseq" class="warn" data-t="clearSeq" data-ic="symbol_trash"></button>
|
||
<span class="dim" id="noteshelp"></span></p>
|
||
<p class="bar seqtools"><span data-t="lenLabel"></span>
|
||
<button type="button" id="lenminus" class="sq">−</button><input id="lenval" type="number" min="1" max="64"><button type="button" id="lenplus" class="sq">+</button>
|
||
<span class="seg" id="viewseg"><button type="button" data-v="grid" data-t="viewGrid"></button><button type="button" data-v="roll" data-t="viewRoll"></button></span>
|
||
<button type="button" id="midiexp" data-t="midiExport" data-ic="symbol_download"></button>
|
||
<button type="button" id="midiimp" data-t="midiImportBtn" data-ic="symbol_upload"></button>
|
||
<input id="midifile" type="file" accept=".mid,.midi,audio/midi" hidden></p>
|
||
<div class="midiprev" id="midiprev" hidden></div>
|
||
<div class="bar" id="drumbar" hidden></div>
|
||
<div class="dgrid" id="drumgrid" hidden></div>
|
||
<div class="grid" id="stepgrid"></div>
|
||
<div class="roll" id="roll" hidden>
|
||
<p class="bar"><span class="dim" data-t="rollLen"></span> <span class="seg" id="rolllen"></span>
|
||
<button type="button" id="rolldown" data-t="rollDown"></button> <span class="dim" id="rollrange"></span> <button type="button" id="rollup" data-t="rollUp"></button></p>
|
||
<div class="rollbox"><canvas id="rollcv"></canvas></div>
|
||
<p class="dim" data-t="rollHelp"></p>
|
||
</div>
|
||
<div class="stepdetail" id="stepdetail" hidden></div>
|
||
<details class="more" id="steplist"><summary data-t="stepList"></summary>
|
||
<div class="stepcols" id="steptables"></div></details>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-tracks" data-tab="tracks" data-dev hidden>
|
||
<div class="card">
|
||
<h2 data-t="mixer" data-ic="ui_slider_vertical"></h2>
|
||
<div class="mixer" id="mixer"></div>
|
||
<p class="dim" data-t="mixHelp"></p>
|
||
</div>
|
||
</section>
|
||
|
||
<!-- works without a device too (the device bank shows while connected) -->
|
||
<section class="panel" id="p-song" data-tab="song" data-dev hidden>
|
||
<div class="card">
|
||
<h2 data-t="songTitle" data-ic="control_arrow_loop"></h2>
|
||
<p class="dim" data-t="songHelp"></p>
|
||
<p class="bad" id="songerr" hidden></p>
|
||
<div id="songbody" hidden>
|
||
<table class="song"><thead><tr><th>#</th><th data-t="songSection"></th><th data-t="songBars"></th><th data-t="songTimes"></th><th></th></tr></thead>
|
||
<tbody id="songrows"></tbody></table>
|
||
<p class="bad" id="songempty" data-t="songEmpty" hidden></p>
|
||
<p class="bar"><button type="button" id="songadd" data-t="songAdd"></button> <span class="dim" id="songsum"></span></p>
|
||
<p class="bar"><span data-t="songLoop"></span> <span class="seg" id="songloop"><button type="button" data-v="0" data-t="songLoopOff"></button><button type="button" data-v="1" data-t="songLoopOn"></button></span></p>
|
||
<p class="bar"><button type="button" id="songread" data-t="songRead" data-ic="control_arrow_loop"></button>
|
||
<button type="button" id="songsend" data-t="songSend" data-ic="symbol_upload"></button></p>
|
||
<p class="bar"><button type="button" id="songexp" data-t="sfSave" data-ic="symbol_download"></button>
|
||
<button type="button" id="songimp" data-t="sfLoad" data-ic="symbol_upload"></button></p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-library" data-tab="library" hidden>
|
||
<div class="libcols" id="libsec">
|
||
<div class="card" id="libpane">
|
||
<h2 data-t="library" data-ic="symbol_books"></h2>
|
||
<div class="bar">
|
||
<input type="search" id="libq" spellcheck="false">
|
||
<select id="libeng"></select>
|
||
<select id="libtag"></select>
|
||
<select id="libsort"></select>
|
||
</div>
|
||
<div class="list" id="liblist"></div>
|
||
<p class="bar" style="margin-top:10px">
|
||
<button id="libaud" class="pri" data-t="audition" data-ic="symbol_audio"></button>
|
||
<button id="libput" data-t="toSlot" data-ic="symbol_upload"></button>
|
||
<button id="libren" data-t="rename"></button>
|
||
<button id="libtags" data-t="tags"></button>
|
||
<button id="libdup" data-t="duplicate"></button>
|
||
<button id="libdel" class="warn" data-t="delete" data-ic="symbol_trash"></button>
|
||
<button id="libexp1" data-t="exportPatch" data-ic="symbol_download"></button>
|
||
</p>
|
||
<p class="bar">
|
||
<button id="libsave" data-t="saveToLib" data-ic="port_disk"></button>
|
||
<button id="libimport" data-t="import" data-ic="symbol_upload"></button>
|
||
<button id="libexport" data-t="exportLib" data-ic="symbol_download"></button>
|
||
<input type="file" id="libfile" accept=".json,application/json" multiple hidden>
|
||
<span class="dim" id="libcount"></span>
|
||
</p>
|
||
</div>
|
||
<div class="card">
|
||
<h2 data-t="bank" data-ic="port_disk"></h2>
|
||
<p class="dim" id="bankhint"></p>
|
||
<div id="bankpane" hidden>
|
||
<div class="bar"><b id="bankhead" class="dim"></b></div>
|
||
<div class="list" id="banklist"></div>
|
||
<p class="bar" style="margin-top:10px">
|
||
<button id="bkload" class="pri" data-t="bankLoad" data-ic="symbol_folder_open"></button>
|
||
<button id="bkstore" data-t="bankStore" data-ic="port_disk"></button>
|
||
<button id="bkget" data-t="bankGet" data-ic="symbol_download"></button>
|
||
<button id="bkerase" class="warn" data-t="erase" data-ic="symbol_trash"></button>
|
||
</p>
|
||
<p class="bar">
|
||
<button id="bkrefresh" data-t="reload" data-ic="control_arrow_loop"></button>
|
||
<button id="bkexport" data-t="exportBank" data-ic="symbol_download"></button>
|
||
<span class="dim" data-t="dndHelp"></span>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-samples" data-tab="samples" data-dev hidden>
|
||
<!-- built by renderSamples: what the slots are, then 1 the slot, 2 the sound (files or CHOP), 3 send and play it -->
|
||
<div id="smpslots"></div>
|
||
<div class="smp chop" id="chop" hidden></div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-kits" data-tab="kits" data-dev hidden>
|
||
<div id="kit"></div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-drumsynth" data-tab="drumsynth" data-dev hidden>
|
||
<div class="card">
|
||
<h2 data-t="dsTitle" data-ic="symbol_waves"></h2>
|
||
<p class="dim" data-t="dsHelp"></p>
|
||
<p class="bad" id="dsold" data-t="dsOld" hidden></p>
|
||
<div id="dsbody" hidden>
|
||
<p class="bar"><span class="seg" id="dsk"><button type="button" data-v="0">SYN1</button><button type="button" data-v="1">SYN2</button><button type="button" data-v="2">SYN3</button><button type="button" data-v="3">SYN4</button></span>
|
||
<span data-t="name"></span> <input id="dsname" type="text" maxlength="8" size="9" spellcheck="false">
|
||
<span class="dim" id="dsstate"></span></p>
|
||
<p class="bar"><span data-t="dsFrom"></span> <select id="dsfrom"></select> <button type="button" id="dscopy" data-t="dsCopy"></button>
|
||
<span class="dsrng"><span data-t="dsBits"></span> <input id="dsbits" type="range" min="0" max="15" step="1"> <span class="dim" id="dsbitsv"></span></span>
|
||
<span class="dsrng"><span data-t="dsHoldS"></span> <input id="dssh" type="range" min="1" max="16" step="1"> <span class="dim" id="dsshv"></span></span></p>
|
||
<p class="bar"><button type="button" id="dsstore" data-t="dsStore" data-ic="symbol_upload"></button>
|
||
<button type="button" id="dsuse" data-t="dsUse" data-ic="symbol_drum"></button>
|
||
<button type="button" id="dssave" data-t="dsSave" data-ic="symbol_download"></button>
|
||
<button type="button" id="dsopen" data-t="dsOpen" data-ic="symbol_folder_open"></button>
|
||
<input id="dsfile" type="file" accept=".json,application/json" hidden></p>
|
||
<div class="dslanes" id="dslanes"></div>
|
||
<p class="bar"><button type="button" id="dsplay" class="pri" data-t="dsPlay" data-ic="symbol_audio"></button>
|
||
<label><input type="checkbox" id="dsauto" checked> <span data-t="dsAuto"></span></label>
|
||
<span class="dim" id="dslane" style="margin-left:auto"></span></p>
|
||
</div>
|
||
</div>
|
||
<div class="groups" id="dsgroups"></div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-projects" data-tab="projects" data-dev hidden>
|
||
<div class="card">
|
||
<h2 data-t="projects" data-ic="symbol_folder"></h2>
|
||
<p class="dim" data-t="projHelp"></p>
|
||
<div class="slots" id="slots"></div>
|
||
</div>
|
||
<div class="card" id="bkgroup" hidden>
|
||
<h2 data-t="bkTitle" data-ic="port_disk"></h2>
|
||
<p class="dim" data-t="bkHelp"></p>
|
||
<p class="bar"><button id="bk-save" class="pri" data-t="bkSave"></button> <button id="bk-load" data-t="bkLoad"></button>
|
||
<input id="bk-file" type="file" accept=".json,application/json" hidden></p>
|
||
<progress id="bk-prog" max="1" value="0" hidden></progress>
|
||
</div>
|
||
<!-- 2.7: a song as one file (the LIVE page's playlist plays them) -->
|
||
<div class="card" id="sfgroup" hidden>
|
||
<h2 data-t="sfTitle" data-ic="control_arrow_loop"></h2>
|
||
<p class="dim" data-t="sfHelp"></p>
|
||
<p class="bar"><button id="sf-save" class="pri" data-t="sfSave" data-ic="symbol_download"></button> <button id="sf-load" data-t="sfLoad" data-ic="symbol_upload"></button>
|
||
<input id="sf-file" type="file" accept=".sloopsong,.json,application/json" hidden></p>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-settings" data-tab="settings" data-dev hidden>
|
||
<div class="groups" id="setgroups"></div>
|
||
<div class="card">
|
||
<h2 data-t="system" data-ic="symbol_cog"></h2>
|
||
<table id="sysinfo"></table>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="panel" id="p-theme" data-tab="theme" hidden>
|
||
<div class="card">
|
||
<h2 data-t="thTitle" data-ic="ui_knob"></h2>
|
||
<p class="dim" data-t="thHelp"></p>
|
||
<div class="thwrap">
|
||
<canvas id="thprev" width="240" height="240" role="img" aria-label="FM-1 screen"></canvas>
|
||
<div class="thside">
|
||
<p class="bar"><span data-t="thStart"></span> <select id="thfrom"></select>
|
||
<span data-t="name"></span> <input id="thname" type="text" maxlength="8" size="9" spellcheck="false"></p>
|
||
<h3 data-t="thScreen"></h3>
|
||
<div class="thcols" id="thscreen"></div>
|
||
<p class="bar"><span data-t="thBg"></span> <input type="color" id="thbg" value="#000000"> <button type="button" id="thbgblack" data-t="thBlack"></button>
|
||
<button type="button" id="thinvert" data-t="thInvert"></button></p>
|
||
<p class="bar"><span data-t="thAcc"></span> <input type="color" id="thacc" value="#ffffff"> <span class="dim" data-t="thAccHelp"></span></p>
|
||
<p class="bar"><span data-t="thRampFrom"></span> <input type="color" id="thbase" value="#38c85c"> <button type="button" id="thramp" data-t="thRamp"></button></p>
|
||
<h3 data-t="thTracks"></h3>
|
||
<div class="thcols" id="thtracks"></div>
|
||
</div>
|
||
</div>
|
||
<p class="bar"><button type="button" id="thsend" class="pri" data-t="thSend" data-ic="symbol_upload"></button>
|
||
<button type="button" id="thread" data-t="thRead" data-ic="symbol_download"></button>
|
||
<button type="button" id="thremove" data-t="thRemove" data-ic="symbol_trash"></button>
|
||
<span class="dim" id="thstate"></span></p>
|
||
<p class="bar" id="thdarkbar" hidden><span class="bad" id="thdark"></span> <button type="button" id="thfix" data-t="thFix"></button></p>
|
||
<p class="dim" id="thnodev" data-t="thNoDev" hidden></p>
|
||
<p class="bad" id="thold" data-t="thOld" hidden></p>
|
||
</div>
|
||
<div class="card">
|
||
<h2 data-t="thShare"></h2>
|
||
<p class="dim" data-t="thShareHelp"></p>
|
||
<p class="bar"><input id="thcode" type="text" readonly spellcheck="false"> <button type="button" id="thcopy" data-t="thCopy"></button></p>
|
||
<p class="bar"><input id="thpaste" type="text" spellcheck="false"> <button type="button" id="thapply" data-t="thApply"></button></p>
|
||
</div>
|
||
</section>
|
||
|
||
<footer>SLOOP, based on Felucca by Leo Kuroshita (@kurogedelic), <a href="https://hugelton.com" target="_blank" rel="noopener">Hügelton Instruments</a>. GPL-3.0.<br>
|
||
<span data-t="foot"></span> M-VAVE and FM-1 are trademarks of their respective owners.<br>
|
||
<a href="FUKIAI-LICENSE.txt" data-t="iconsCredit"></a> · <span data-t="fontCredit"></span></footer>
|
||
</main>
|
||
</div>
|
||
<dialog id="preview-note-dialog" aria-labelledby="preview-note-title">
|
||
<form id="preview-note-form">
|
||
<h2 id="preview-note-title"></h2>
|
||
<div id="preview-note-fields"></div>
|
||
<div class="preview-note-picker-head">
|
||
<span><span data-t="notes"></span> · <output id="preview-note-value" aria-live="polite"></output></span>
|
||
<div class="preview-note-octave"><button type="button" id="preview-note-down">−</button><span id="preview-note-octave"></span><button type="button" id="preview-note-up">+</button></div>
|
||
</div>
|
||
<div id="preview-note-piano" class="preview-keys piano preview-note-piano" role="group"></div>
|
||
<label class="preview-note-listen"><input type="checkbox" id="preview-note-listen" checked> <span data-t="previewListen"></span></label>
|
||
<p class="dim" data-t="previewNoteDialogHint"></p>
|
||
<div class="preview-note-actions"><button type="button" id="preview-note-cancel" data-t="previewCancel"></button><button type="submit" id="preview-note-apply" class="pri" data-t="previewApply"></button></div>
|
||
</form>
|
||
</dialog>
|
||
<script>
|
||
"use strict";
|
||
/*PROTO-BEGIN*/
|
||
/* ---------------------------------------------------------------- protocol --- */
|
||
const HDR = [0x7D, 0x46, 0x4C];
|
||
const CMD = { INFO: 1, GET: 2, SET: 3, DUMP: 4, DESC: 5, STEP_GET: 6, STEP_SET: 7, PRESET: 8, PROJECT: 9, NAMES: 10,
|
||
SMP_BEGIN: 11, SMP_WRITE: 12, SMP_END: 13, SMP_ERASE: 14, SMP_INFO: 15,
|
||
UP_LIST: 16, UP_GET: 17, UP_PUT: 18, UP_STORE: 19, UP_LOAD: 20, UP_ERASE: 21,
|
||
WATCH: 22, CHANGED: 23, RELOAD: 24, PING: 25, STEP_CHANGED: 26,
|
||
TRACK: 27, TRACK_MIX: 28, TRACK_DUMP: 29, TRACK_STEP: 30,
|
||
TRACK_PARAM: 31, TRACK_CHANGED: 32,
|
||
DRUM_STEP: 33,
|
||
BK_LIST: 34, BK_GET: 35, BK_PUT: 36, /* v6: backup / restore */
|
||
LOCK_GET: 37, LOCK_SET: 38, MICRO_GET: 39, MICRO_SET: 40, /* v7 (SLOOP 2.4): parameter locks, nudges */
|
||
FILL_GET: 41, FILL_SET: 42, /* v8 (SLOOP 2.4): the steps' fill conditions */
|
||
FM6_GET: 68, FM6_PUT: 69, FM6_LIST: 70, FM6_ERASE: 71, /* v9 (SLOOP 2.4): the FM6 engine's patches (Felucca 1.0's numbers) */
|
||
DSYN_LIST: 72, DSYN_GET: 73, DSYN_PUT: 74, DSYN_STORE: 75, DSYN_PLAY: 76, /* v10 (SLOOP 2.5): the SYN drum kits */
|
||
LIVE: 77 }; /* v12 (SLOOP 2.7): the LIVE page (firmware editor_live.c) */
|
||
/* v12: LIVE ops (firmware editor_live.c) and the layers its keys reach (seq.c LY_*: 5 SEL, 6 GLO, 7 SAVE) */
|
||
const LIVE = { STATE: 0, PLAY: 1, KEY: 2, FX: 3, REC: 4, UNDO: 5, LY_KEY: 5, LY_MIX: 6, LY_SONG: 7, NFX: 27,
|
||
/* (2.7) the page's own (editor_live.c 6..12): ROLL and ERASE while held, the pattern's tools, a chain of sections, THROW,
|
||
the master level, a drum sound's TUNE / DECAY; a state with them is 50 bytes (s.pro) */
|
||
ROLL: 6, ERASE: 7, PATTERN: 8, CHAIN: 9, THROW: 10, MASTER: 11, DRUM_TW: 12, CHAIN_MAX: 8,
|
||
/* the 27 punch-in effects (punch.c PUNCH_NAME): 16 on the white keys, 11 on the black keys */
|
||
FX_NAMES: ["LOOP 4", "LOOP 8", "LOOP 16", "LOOP 32", "STUTTER", "REVERSE", "STOP", "HALF", "LOW", "HIGH", "PHONE", "CRUSH",
|
||
"ALIAS", "GATE", "ECHO", "WOBBLE", "KILL LOW", "KILL MID", "KILL HIGH", "REWIND", "OCT UP", "FLANGER", "AUTO-PAN", "FREEZE",
|
||
"LOOP 8T", "MONO", "FADE OUT"],
|
||
/* the GLO keys (ui_layers.c layer_key): 1..4 mute, 5..8 solo, 9 fill while held, 10 fill next bar, 16 tap tempo;
|
||
the SAVE keys: 1..4 play A..D, 5..8 store into A..D, 13 loop / song, 14 SONG REC */
|
||
MUTE: 0, SOLO: 4, FILL: 8, FILL_BAR: 9, TAP: 15, SEC: 0, STORE: 4, SONG: 12, SONG_REC: 13 };
|
||
/* ---- LIVE pro (editor only: the 2.7 firmware as it is, every value through TRACK_MIX / TRACK_PARAM / SET).
|
||
Scenes: what a track and the master sound like, kept in the browser, recalled at once or morphed over bars, or mixed
|
||
with the A / B crossfader. Ids: core.h P_* and G_* (2.7: P_E0 = 63). cont: values that glide in a morph; the others
|
||
(switches, lists) change at its start. A track's engine values (E0..E7) come back only onto the same engine */
|
||
const LVX = {
|
||
/* per track: pan, filter, sends, drive, the sound's FLT PIT SHP, the envelope, glide, LFO, the INSERT, the arp */
|
||
TP: [39, 50, 36, 35, 34, 33, 5, 6, 7, 1, 2, 3, 4, 38, 9, 13, 14, 15, 16, 53, 54, 55, 56, 57, 17, 18, 19, 20, 21, 23, 24],
|
||
TP_STEP: [53, 17, 18, 19, 23, 24], /* INSERT TYPE, arp MODE RATE OCT HOLD ORD: switched, not glided */
|
||
/* the master: FILT DUST DUCK, the drums' REV DLY, the delay (TIME is a list), the reverb, the chorus, TEXTURE, SWING */
|
||
GP: [29, 27, 28, 26, 32, 4, 5, 6, 7, 8, 9, 10, 11, 37, 38, 39, 40, 41, 42, 43, 1],
|
||
GP_STEP: [4, 37, 41, 42, 43],
|
||
BPM: 0, E0: 63, NE: 8, NSCENE: 8, MORPH_BARS: [0, 1, 2, 4, 8, 16],
|
||
/* a scene from the page's values: tracks [{level, mute, engine, preset, p: {id: v}, e: [8]}], g: {id: v}, bpm */
|
||
capture(tracks, g, opt = {}) {
|
||
return {
|
||
v: 1,
|
||
tracks: tracks.map((o) => ({
|
||
level: o.level ?? 0, mute: o.mute ? 1 : 0, engine: o.engine ?? 0, preset: o.preset ?? 0, kit: o.kit ?? null,
|
||
p: Object.fromEntries(LVX.TP.filter((id) => o.p && o.p[id] != null).map((id) => [id, o.p[id]])),
|
||
e: Array.from({ length: LVX.NE }, (_, k) => (o.p && o.p[LVX.E0 + k] != null ? o.p[LVX.E0 + k] : null)),
|
||
})),
|
||
g: Object.fromEntries(LVX.GP.filter((id) => g[id] != null).map((id) => [id, g[id]])),
|
||
bpm: g[LVX.BPM] ?? null,
|
||
sounds: !!opt.sounds, tempo: !!opt.tempo,
|
||
};
|
||
},
|
||
/* the values f (0..1) of the way from a to b: glided ones in between (rounded), switched ones b's as soon as f > 0.
|
||
-> {tracks: [{level, mute, p: {id: v}, e: [] | null}], g: {id: v}} (only what both scenes have) */
|
||
mix(a, b, f) {
|
||
f = Math.max(0, Math.min(1, f));
|
||
const lerp = (x, y) => Math.round(x + (y - x) * f), sw = (x, y) => (f > 0 ? y : x);
|
||
const out = { tracks: [], g: {} };
|
||
const n = Math.min(a.tracks.length, b.tracks.length);
|
||
for (let i = 0; i < n; i++) {
|
||
const ta = a.tracks[i], tb = b.tracks[i], p = {};
|
||
for (const id of LVX.TP) {
|
||
if (ta.p[id] == null || tb.p[id] == null) continue;
|
||
p[id] = LVX.TP_STEP.includes(id) ? sw(ta.p[id], tb.p[id]) : lerp(ta.p[id], tb.p[id]);
|
||
}
|
||
const sameEngine = ta.engine === tb.engine;
|
||
out.tracks.push({ level: lerp(ta.level, tb.level), mute: f >= 1 ? tb.mute : f > 0 ? (ta.mute && tb.mute ? 1 : 0) : ta.mute, p,
|
||
e: sameEngine ? ta.e.map((x, k) => (x == null || tb.e[k] == null ? null : lerp(x, tb.e[k]))) : null });
|
||
}
|
||
for (const id of LVX.GP) {
|
||
if (a.g[id] == null || b.g[id] == null) continue;
|
||
out.g[id] = LVX.GP_STEP.includes(id) ? sw(a.g[id], b.g[id]) : lerp(a.g[id], b.g[id]);
|
||
}
|
||
return out;
|
||
},
|
||
/* a morph's length in ms: bars of 4 beats at bpm (0 bars: at once) */
|
||
morphMs: (bars, bpm) => (bars > 0 ? Math.round(bars * 4 * 60000 / Math.max(20, bpm || 120)) : 0),
|
||
/* MIDI learn: an incoming message -> {key, kind: "cc" | "note", value 0..1, on} (key: "cc:ch:num" / "note:ch:num");
|
||
null for what cannot drive a control (clock, SysEx, aftertouch...) */
|
||
midiKey(d) {
|
||
if (!d || d.length < 3) return null;
|
||
const st = d[0] & 0xF0, ch = d[0] & 15;
|
||
if (st === 0xB0) return { key: `cc:${ch}:${d[1]}`, kind: "cc", value: d[2] / 127, on: d[2] >= 64, raw: d[2] };
|
||
if (st === 0x90 && d[2] > 0) return { key: `note:${ch}:${d[1]}`, kind: "note", value: d[2] / 127, on: true, raw: d[2] };
|
||
if (st === 0x80 || (st === 0x90 && d[2] === 0)) return { key: `note:${ch}:${d[1]}`, kind: "note", value: 0, on: false, raw: 0 };
|
||
return null;
|
||
},
|
||
/* a control's value from a learned message: a knob / fader takes the CC's (or the note's velocity) as min..max */
|
||
midiValue: (m, min, max) => Math.round(min + m.value * (max - min)),
|
||
/* a WAV file (16-bit PCM, interleaved) from Int16Array chunks */
|
||
wav(chunks, rate, ch = 2) {
|
||
const n = chunks.reduce((s, c) => s + c.length, 0), buf = new ArrayBuffer(44 + 2 * n), v = new DataView(buf);
|
||
const str = (o, s) => { for (let i = 0; i < s.length; i++) v.setUint8(o + i, s.charCodeAt(i)); };
|
||
str(0, "RIFF"); v.setUint32(4, 36 + 2 * n, true); str(8, "WAVE"); str(12, "fmt ");
|
||
v.setUint32(16, 16, true); v.setUint16(20, 1, true); v.setUint16(22, ch, true); v.setUint32(24, rate, true);
|
||
v.setUint32(28, rate * ch * 2, true); v.setUint16(32, ch * 2, true); v.setUint16(34, 16, true);
|
||
str(36, "data"); v.setUint32(40, 2 * n, true);
|
||
let o = 44;
|
||
for (const c of chunks) { new Int16Array(buf, o, c.length).set(c); o += 2 * c.length; }
|
||
return new Uint8Array(buf);
|
||
},
|
||
/* float samples (-1..1) to 16 bits */
|
||
pcm16(f) { const o = new Int16Array(f.length); for (let i = 0; i < f.length; i++) { const x = Math.max(-1, Math.min(1, f[i])); o[i] = x < 0 ? x * 32768 : x * 32767; } return o; },
|
||
/* the set timer / a duration as m:ss or h:mm:ss */
|
||
clock(ms) { const s = Math.max(0, Math.floor(ms / 1000)), h = Math.floor(s / 3600), m = Math.floor(s / 60) % 60, x = String(s % 60).padStart(2, "0");
|
||
return h ? `${h}:${String(m).padStart(2, "0")}:${x}` : `${m}:${x}`; },
|
||
};
|
||
/* v7: the parameters a step can lock (firmware seq.c p_lockable: the sound, not the sequencer / arp / key / voice
|
||
mode); ids as core.h: LEVEL .. LFO dests, GATE, the sends, GLIDE, PAN, DETUNE, the SLICER, FILTER, the engine's 8;
|
||
from 2.6 (pe0 63) also the INSERT's A B C and MIX (54..57). pe0: the device's (the newest when none) */
|
||
const lockable = (id, pe0 = typeof dev !== "undefined" && dev && dev.info ? dev.info.pe0 : 63) => id <= 16 || id === 32 || (id >= 33 && id <= 36) || id === 38 || id === 39
|
||
|| id === 44 || (id >= 45 && id <= 48) || id === 50 || (pe0 >= 63 && id >= 54 && id <= 57) || (id >= pe0 && id <= pe0 + 7);
|
||
const MICRO = { MIN: -32, MAX: 31 }; /* a step's nudge in 1/64 of a step (- early, + late), sent + 64 */
|
||
/* v8: a step's fill condition (firmware core.h FC_*): 0 normal, 1 plays only during a fill, 2 silent during one; 2 bits a
|
||
step, 4 steps a byte (step i: byte i >> 2, bits 2 (i & 3)..), the 16 bytes sent pack7 */
|
||
const FC = { NORM: 0, FILL: 1, NOFILL: 2, NAMES: ["normal", "fill only", "no fill"] };
|
||
const fillGet = (bytes, i) => ((bytes[i >> 2] || 0) >> (2 * (i & 3))) & 3;
|
||
const fillSet = (bytes, i, c) => { bytes[i >> 2] = (bytes[i >> 2] & ~(3 << (2 * (i & 3)))) | ((c & 3) << (2 * (i & 3))); };
|
||
/* frames the device sends on its own (while WATCH is on); never replies */
|
||
const PUSH = new Set([CMD.CHANGED, CMD.RELOAD, CMD.STEP_CHANGED, CMD.TRACK_CHANGED]);
|
||
/* user preset bank: name 1..12 printable ASCII, a 16-step pattern of (note, flags 1 acc 2 slide 4 tie) */
|
||
const UP = { NAME_MAX: 12, PAT: 16, LIST_MAX: 16 };
|
||
const F = { INT: 0, PCT: 1, BIPCT: 2, TIME: 3, LFOHZ: 4, CUTOFF: 5, DB: 6, SEMI: 7, ENUM: 8, BPM: 9, NOTE: 10, ONOFF: 11, OCT: 12, STEPS: 13,
|
||
SWING: 14, FILT: 15 };
|
||
/* v5 (SLOOP 2.0): the drum track's 16 sounds (firmware drums.c LANE_NOTE / LANE_NAME), one per white key
|
||
F3..G5; a hit has a level (NORM, GHOST, SOFT, HARD: OCT- / OCT+ held on the device) and a ratchet x1..x4 */
|
||
const DRUM_LANES = [[36, "KICK"], [35, "KICK 2"], [38, "SNARE"], [39, "CLAP"], [42, "HAT"], [46, "OPEN HAT"], [44, "PEDAL"], [37, "RIM"],
|
||
[40, "SNARE 2"], [43, "LOW TOM"], [48, "HI TOM"], [49, "CRASH"], [51, "RIDE"], [70, "SHAKER"], [63, "CONGA"], [56, "COWBELL"]];
|
||
const LV_NAMES = ["NORM", "GHOST", "SOFT", "HARD"];
|
||
const LV_ORDER = [1, 2, 0, 3]; /* by loudness: GHOST SOFT NORM HARD (as the device's LEVEL knob) */
|
||
/* an empty drum step: no lane on */
|
||
const emptyDrum = () => ({ on: 0, lvl: new Array(16).fill(0), rat: new Array(16).fill(0) });
|
||
|
||
const v14enc = (v) => { const u = Math.max(-8192, Math.min(8191, Math.round(v))) + 8192; return [u & 0x7F, (u >> 7) & 0x7F]; };
|
||
const v14dec = (lo, hi) => (lo | (hi << 7)) - 8192;
|
||
function strEnc(s) { const a = []; for (const c of String(s)) a.push(c.charCodeAt(0) & 0x7F); a.push(0); return a; }
|
||
|
||
/* only ever builds F0 7D 46 4C ... F7 */
|
||
function frame(cmd, args = []) {
|
||
for (const b of args) if (!(Number.isInteger(b) && b >= 0 && b <= 0x7F)) throw new Error("bad data byte " + b);
|
||
return [0xF0, ...HDR, cmd & 0x7F, ...args, 0xF7];
|
||
}
|
||
/* -> {cmd, a} or null when it is not an editor frame */
|
||
function unframe(d) {
|
||
if (!d || d.length < 6 || d[0] !== 0xF0 || d[d.length - 1] !== 0xF7) return null;
|
||
if (d[1] !== HDR[0] || d[2] !== HDR[1] || d[3] !== HDR[2]) return null;
|
||
return { cmd: d[4], a: Array.from(d.slice(5, d.length - 1)) };
|
||
}
|
||
|
||
class Reader {
|
||
constructor(a) { this.a = a; this.i = 0; }
|
||
b() { if (this.i >= this.a.length) throw new Error("short reply"); return this.a[this.i++]; }
|
||
v() { const lo = this.b(); return v14dec(lo, this.b()); }
|
||
s() { let s = ""; for (;;) { const c = this.b(); if (!c) return s; s += String.fromCharCode(c); } }
|
||
}
|
||
|
||
/* v5 steps end with level / ratchet (2 bits per note, 7-bit bytes: lvl, hi (bit 0 lvl, bit 1 rat), rat) */
|
||
function stepExt(r, a, o) {
|
||
if (r.i + 3 <= a.length) {
|
||
const lo = r.b(), hi = r.b(), rt = r.b();
|
||
o.lvl = lo | ((hi & 1) << 7);
|
||
o.rat = rt | (((hi >> 1) & 1) << 7);
|
||
}
|
||
return o;
|
||
}
|
||
|
||
const parse = {
|
||
[CMD.INFO](a) {
|
||
const r = new Reader(a);
|
||
const o = { version: r.s(), nengines: r.b(), pcount: r.b(), gcount: r.b(), nstep: r.b(), pe0: r.b(), engines: [] };
|
||
for (let i = 0; i < o.nengines; i++) o.engines.push(r.s());
|
||
o.ntrk = r.i < a.length ? r.b() : 0; /* v3: tracks (0 = older firmware, one instrument) */
|
||
o.proto = r.i < a.length ? r.b() : 0; /* v5: the protocol version (0 = older firmware) */
|
||
return o;
|
||
},
|
||
[CMD.GET](a) { const r = new Reader(a); return { scope: r.b(), id: r.b(), value: r.v() }; },
|
||
[CMD.SET](a) { return parse[CMD.GET](a); },
|
||
/* needs the counts from INFO */
|
||
[CMD.DUMP](a, info) {
|
||
const r = new Reader(a);
|
||
const o = { engine: r.b(), preset: r.b(), p: [], g: [] };
|
||
for (let i = 0; i < info.pcount; i++) o.p.push(r.v());
|
||
for (let i = 0; i < info.gcount; i++) o.g.push(r.v());
|
||
return o;
|
||
},
|
||
[CMD.DESC](a) {
|
||
const r = new Reader(a);
|
||
const o = { scope: r.b(), id: r.b(), fmt: r.b(), min: r.v(), max: r.v(), def: r.v(), label: r.s(), unit: r.s(), names: [] };
|
||
if (o.fmt === F.ENUM) for (let i = 0; i <= o.max - o.min && i < 64 && r.i < a.length; i++) o.names.push(r.s());
|
||
return o;
|
||
},
|
||
[CMD.STEP_GET](a) {
|
||
const r = new Reader(a);
|
||
const o = { index: r.b(), n: r.b(), notes: [r.b(), r.b(), r.b(), r.b()], time: r.b(), flags: r.b(), vel: r.b() };
|
||
return stepExt(r, a, o);
|
||
},
|
||
[CMD.STEP_SET](a) { return parse[CMD.STEP_GET](a); },
|
||
[CMD.PRESET](a) { const r = new Reader(a); return { engine: r.b(), preset: r.b() }; },
|
||
[CMD.PROJECT](a) { const r = new Reader(a); return { op: r.b(), slot: r.b(), used: r.b(), busy: a.length > 3 && a[3] === 1 }; },
|
||
[CMD.NAMES](a) {
|
||
const r = new Reader(a);
|
||
const o = { engine: r.b(), names: [] };
|
||
const n = r.b();
|
||
for (let i = 0; i < n; i++) o.names.push(r.s());
|
||
o.titles = [];
|
||
try { o.titles.push(r.s(), r.s()); } catch (e) { o.titles = []; } /* older firmware: no page titles */
|
||
return o;
|
||
},
|
||
[CMD.SMP_BEGIN](a) { const r = new Reader(a); return { slot: r.b(), rc: r.b() }; },
|
||
[CMD.SMP_WRITE](a) { const r = new Reader(a); return { slot: r.b(), offset: r.b() | (r.b() << 7) | (r.b() << 14), rc: r.b() }; },
|
||
[CMD.SMP_END](a) { return parse[CMD.SMP_BEGIN](a); },
|
||
[CMD.SMP_ERASE](a) { return parse[CMD.SMP_BEGIN](a); },
|
||
[CMD.SMP_INFO](a) {
|
||
const r = new Reader(a);
|
||
const o = { nslots: r.b(), slotKiB: r.b(), slots: [] };
|
||
for (let i = 0; i < o.nslots; i++) o.slots.push({ zones: r.b(), name: r.s(), kib: r.b() });
|
||
return o;
|
||
},
|
||
[CMD.UP_LIST](a) {
|
||
const r = new Reader(a);
|
||
const o = { start: r.b(), count: r.b(), total: r.b(), slots: [] };
|
||
for (let i = 0; i < o.count; i++) o.slots.push({ slot: o.start + i, used: r.b(), engine: r.b(), name: r.s() });
|
||
return o;
|
||
},
|
||
/* needs P_COUNT from INFO */
|
||
[CMD.UP_GET](a, info) {
|
||
const r = new Reader(a);
|
||
const o = { slot: r.b(), used: r.b(), engine: r.b(), name: r.s(), p: [], pattern: [] };
|
||
for (let i = 0; i < info.pcount; i++) o.p.push(r.v());
|
||
for (let i = 0; i < UP.PAT; i++) o.pattern.push([r.b(), r.b()]);
|
||
return o;
|
||
},
|
||
[CMD.UP_PUT](a) { return parse[CMD.SMP_BEGIN](a); },
|
||
[CMD.UP_STORE](a) { return parse[CMD.SMP_BEGIN](a); },
|
||
[CMD.UP_LOAD](a) { return parse[CMD.SMP_BEGIN](a); },
|
||
[CMD.UP_ERASE](a) { return parse[CMD.SMP_BEGIN](a); },
|
||
[CMD.WATCH](a) { return { on: new Reader(a).b() }; },
|
||
[CMD.CHANGED](a) { return parse[CMD.GET](a); },
|
||
[CMD.RELOAD](a) { const r = new Reader(a); return { engine: r.b(), preset: r.b(), track: r.i < a.length ? r.b() : 0 }; },
|
||
[CMD.PING](a) { return {}; },
|
||
[CMD.STEP_CHANGED](a) { const r = new Reader(a); return { index: r.b(), track: r.i < a.length ? r.b() : 0 }; },
|
||
/* v3: tracks. engine === NENGINES: the drum track */
|
||
[CMD.TRACK](a) {
|
||
const r = new Reader(a);
|
||
const o = { sel: r.b(), ntrk: r.b(), tracks: [] };
|
||
for (let i = 0; i < o.ntrk; i++) o.tracks.push({ engine: r.b(), preset: r.b(), level: r.v(), mute: r.b(), armed: r.b() });
|
||
o.solo = r.i < a.length ? r.b() : 0; /* v5: the tracks soloed (bit per track) */
|
||
return o;
|
||
},
|
||
[CMD.TRACK_MIX](a) { const r = new Reader(a); return { track: r.b(), level: r.v(), mute: r.b() }; },
|
||
/* v12: the live state (firmware editor_live.c): per track its step, its length and its meter (8 log2 |peak|: 48 = -54 dB,
|
||
128 = +6 dB, 0 = silent) */
|
||
[CMD.LIVE](a) {
|
||
const r = new Reader(a);
|
||
const op = r.b(), f = r.b(), f2 = r.b();
|
||
const o = { op, playing: !!(f & 1), asked: !!(f & 2), songMode: !!(f & 4), songRuns: !!(f & 8), fillNow: !!(f & 16),
|
||
fillBar: !!(f & 32), songRec: !!(f & 64), recWait: !!(f2 & 1), canUndo: !!(f2 & 2), canRedo: !!(f2 & 4), freeTake: !!(f2 & 8),
|
||
bpm: r.v(), sec: r.b() - 1, next: r.b() - 1, chainN: r.b(), chainI: r.b(), mutes: r.b(), solo: r.b(), rec: r.b(),
|
||
sel: r.b(), fx: r.b() - 1, cpu: r.b(), songAt: r.b(), songLen: r.b(), songBar: r.b(), songBars: r.b(), ready: r.b(), tracks: [] };
|
||
for (let k = 0; k < 4 && r.i + 3 <= a.length; k++) o.tracks.push({ step: r.b(), len: r.b(), meter: r.b() });
|
||
if (r.i + 18 <= a.length) { /* (2.7, ops 6..12) the master, the THROWs, the drum sounds' TUNE / DECAY */
|
||
const m = r.b();
|
||
o.pro = true; o.master = m ? m - 1 : -1; o.throws = r.b();
|
||
o.dtw = Array.from({ length: 16 }, () => { const v = r.b(); return { tune: (v & 15) - 8, dec: ((v >> 4) & 7) - 4 }; });
|
||
}
|
||
return o;
|
||
},
|
||
[CMD.TRACK_DUMP](a, info) {
|
||
const r = new Reader(a);
|
||
const o = { track: r.b(), engine: r.b(), preset: r.b(), p: [] };
|
||
for (let i = 0; i < info.pcount; i++) o.p.push(r.v());
|
||
return o;
|
||
},
|
||
[CMD.TRACK_STEP](a) {
|
||
const r = new Reader(a);
|
||
return stepExt(r, a, { track: r.b(), index: r.b(), n: r.b(), notes: [r.b(), r.b(), r.b(), r.b()], time: r.b(), flags: r.b(), vel: r.b() });
|
||
},
|
||
/* v6: backup. LIST: rc, then per object id, length, CRC-32 (5 x 7 bit each) */
|
||
[CMD.BK_LIST](a) {
|
||
const r = new Reader(a), rc = r.b(), n = r.b(), items = [];
|
||
for (let i = 0; i < n; i++) items.push({ id: r.b(), len: u35dec(r), crc: u35dec(r) >>> 0 });
|
||
return { rc, items };
|
||
},
|
||
[CMD.BK_GET](a) {
|
||
const r = new Reader(a), id = r.b(), rc = r.b(), off = u35dec(r), count = r.b() | (r.b() << 7);
|
||
return { id, rc, off, count, data: unpack7(a.slice(r.i)) };
|
||
},
|
||
[CMD.BK_PUT](a) { const r = new Reader(a); return { op: r.b(), id: r.b(), rc: r.b() }; },
|
||
/* v5: the drum track's step: the lanes on (16 bits), their levels and ratchets (2 bits each) */
|
||
[CMD.DRUM_STEP](a) {
|
||
const r = new Reader(a);
|
||
const o = { index: r.b(), on: r.b() | (r.b() << 7) | ((r.b() & 3) << 14), lvl: [], rat: [] };
|
||
let lv = 0, rt = 0;
|
||
for (let k = 0; k < 5; k++) lv += r.b() * 2 ** (7 * k);
|
||
for (let k = 0; k < 5; k++) rt += r.b() * 2 ** (7 * k);
|
||
for (let l = 0; l < 16; l++) {
|
||
const on = (o.on >> l) & 1;
|
||
o.lvl.push(on ? Math.floor(lv / 4 ** l) % 4 : 0);
|
||
o.rat.push(on ? Math.floor(rt / 4 ** l) % 4 : 0);
|
||
}
|
||
return o;
|
||
},
|
||
/* v4: a parameter of any track (the selection stays), and its push for a track that is not selected */
|
||
[CMD.TRACK_PARAM](a) { const r = new Reader(a); return { track: r.b(), id: r.b(), value: r.v() }; },
|
||
[CMD.TRACK_CHANGED](a) { return parse[CMD.TRACK_PARAM](a); },
|
||
/* v7: a track's parameter locks: n x {step, param, value}; a set: rc (0 ok, 1 arguments, 2 not lockable, 3 full) */
|
||
[CMD.LOCK_GET](a) {
|
||
const r = new Reader(a), o = { track: r.b(), locks: [] }, n = r.b();
|
||
for (let i = 0; i < n; i++) o.locks.push({ step: r.b(), param: r.b(), value: r.v() });
|
||
return o;
|
||
},
|
||
[CMD.LOCK_SET](a) { const r = new Reader(a); const o = { track: r.b(), step: r.b(), param: r.b(), rc: r.b(), has: r.b() }; o.value = r.v(); if (!o.has) o.value = null; return o; },
|
||
/* v7: a track's nudges (NSTEP bytes, each + 64) */
|
||
[CMD.MICRO_GET](a) { const r = new Reader(a), o = { track: r.b(), micro: [] }; while (r.i < a.length) o.micro.push(r.b() - 64); return o; },
|
||
[CMD.MICRO_SET](a) { const r = new Reader(a); return { track: r.b(), step: r.b(), micro: r.b() - 64 }; },
|
||
/* v8: a track's fill conditions (16 bytes, pack7; 3 reads as normal) and a set */
|
||
[CMD.FILL_GET](a) { const r = new Reader(a), o = { track: r.b() }; o.fill = Array.from(unpack7(a.slice(r.i))).slice(0, 16); while (o.fill.length < 16) o.fill.push(0); return o; },
|
||
[CMD.FILL_SET](a) { const r = new Reader(a); return { track: r.b(), step: r.b(), cond: r.b() % 3 }; },
|
||
/* v9 FM6 patches: target 0 a track (0..2), 1 a bank slot, 2 a factory patch; packed: the 128-byte record */
|
||
[CMD.FM6_GET](a) { return { target: a[0], index: a[1], rc: a[2], packed: a[2] ? null : a.slice(3, 3 + 128) }; },
|
||
[CMD.FM6_PUT](a) { return { target: a[0], index: a[1], rc: a[2] }; },
|
||
[CMD.FM6_LIST](a) {
|
||
const r = new Reader(a), o = { factory: r.b(), bank: r.b(), slots: [] };
|
||
for (let i = 0; i < o.factory + o.bank; i++) { const used = r.b(); o.slots.push({ used, name: used ? r.s() : (r.b(), "") }); }
|
||
return o;
|
||
},
|
||
[CMD.FM6_ERASE](a) { return { index: a[0], rc: a[1] }; },
|
||
/* v10: the SYN drum kits (editor_dsyn.c) */
|
||
[CMD.DSYN_LIST](a) {
|
||
const r = new Reader(a), o = { factory: r.b(), user: r.b(), stored: !!r.b(), names: [], kits: [] };
|
||
for (let i = 0; i < o.factory; i++) o.names.push(r.s());
|
||
for (let i = 0; i < o.user; i++) o.kits.push({ name: r.s(), src: r.b() });
|
||
return o;
|
||
},
|
||
[CMD.DSYN_GET](a) {
|
||
const r = new Reader(a), o = { which: r.b(), rc: r.b() };
|
||
if (o.rc) return o;
|
||
o.name = r.s();
|
||
const d = unpack7(a.slice(r.i));
|
||
o.crush = d[0]; o.src = d[1];
|
||
o.sounds = Array.from({ length: DSYN.LANES }, (_, l) => d.slice(2 + l * DSYN.SIZE, 2 + (l + 1) * DSYN.SIZE));
|
||
if (d.length < 2 + DSYN.LANES * DSYN.SIZE) o.rc = 2;
|
||
return o;
|
||
},
|
||
[CMD.DSYN_PUT](a) { return { k: a[0], part: a[1], rc: a[2] }; },
|
||
[CMD.DSYN_STORE](a) { return { rc: a[0] }; },
|
||
[CMD.DSYN_PLAY](a) { return { k: a[0], lane: a[1], rc: a[2] }; },
|
||
};
|
||
|
||
/* a name the device accepts: printable ASCII, 1..12 characters */
|
||
function upName(s) { return String(s ?? "").replace(/[^\x20-\x7E]/g, "").trim().slice(0, UP.NAME_MAX) || "PATCH"; }
|
||
|
||
const req = {
|
||
info: () => [CMD.INFO, []],
|
||
get: (scope, id) => [CMD.GET, [scope, id]],
|
||
set: (scope, id, v) => [CMD.SET, [scope, id, ...v14enc(v)]],
|
||
dump: () => [CMD.DUMP, []],
|
||
desc: (scope, id) => [CMD.DESC, [scope, id]],
|
||
stepGet: (i) => [CMD.STEP_GET, [i]],
|
||
stepSet: (i, st) => {
|
||
const n = Math.max(0, Math.min(4, st.n | 0));
|
||
const notes = [0, 1, 2, 3].map((k) => (st.notes[k] | 0) & 0x7F);
|
||
const ext = st.lvl == null && st.rat == null ? [] /* v5: level / ratchet kept (older firmware ignores them) */
|
||
: [(st.lvl | 0) & 0x7F, (((st.lvl | 0) >> 7) & 1) | ((((st.rat | 0) >> 7) & 1) << 1), (st.rat | 0) & 0x7F];
|
||
return [CMD.STEP_SET, [i, n, ...notes, Math.max(0, Math.min(2, st.time | 0)), st.flags & 3, (st.vel | 0) & 0x7F, ...ext]];
|
||
},
|
||
/* v5: get (d == null) or set the drum track's step i: {on: 16 bits, lvl[16], rat[16]} */
|
||
drumStep: (i, d) => {
|
||
if (!d) return [CMD.DRUM_STEP, [i & 0x7F]];
|
||
let lv = 0, rt = 0;
|
||
for (let l = 0; l < 16; l++) if ((d.on >> l) & 1) { lv += ((d.lvl[l] | 0) & 3) * 4 ** l; rt += ((d.rat[l] | 0) & 3) * 4 ** l; }
|
||
const g7 = (x, n) => Array.from({ length: n }, (_, k) => Math.floor(x / 2 ** (7 * k)) & 0x7F);
|
||
return [CMD.DRUM_STEP, [i & 0x7F, ...g7(d.on & 0xFFFF, 3), ...g7(lv, 5), ...g7(rt, 5)]];
|
||
},
|
||
preset: (e, p) => [CMD.PRESET, [e & 0x7F, p & 0x7F]],
|
||
project: (op, slot) => { if (![0, 1, 2].includes(op)) throw new Error("bad PROJECT op"); return [CMD.PROJECT, [op, slot & 3]]; }, /* 0 load, 1 save, 2 query */
|
||
names: (e) => [CMD.NAMES, [e & 0x7F]],
|
||
smpBegin: (s) => [CMD.SMP_BEGIN, [s & 0x7F]],
|
||
smpWrite: (s, off, bytes) => [CMD.SMP_WRITE, [s & 0x7F, off & 0x7F, (off >> 7) & 0x7F, (off >> 14) & 0x7F, ...pack7(bytes)]],
|
||
smpEnd: (s, hdr) => [CMD.SMP_END, [s & 0x7F, ...pack7(hdr)]],
|
||
smpErase: (s) => [CMD.SMP_ERASE, [s & 0x7F]],
|
||
smpInfo: () => [CMD.SMP_INFO, []],
|
||
upList: (start, count) => [CMD.UP_LIST, [start & 0x7F, Math.max(1, Math.min(UP.LIST_MAX, count | 0))]],
|
||
upGet: (s) => [CMD.UP_GET, [s & 0x7F]],
|
||
/* patch: {engine, name, p: P_COUNT values, pattern: 16 x [note, flags]} */
|
||
upPut: (s, pt) => [CMD.UP_PUT, [s & 0x7F, pt.engine & 0x7F, ...strEnc(upName(pt.name)), ...pt.p.flatMap((v) => v14enc(v ?? 0)),
|
||
...Array.from({ length: UP.PAT }, (_, i) => { const x = (pt.pattern || [])[i] || [0, 0]; return [x[0] & 0x7F, x[1] & 7]; }).flat()]],
|
||
upStore: (s, name) => [CMD.UP_STORE, [s & 0x7F, ...strEnc(name ? upName(name) : "")]], /* "": the device names it ("ANALOG 07") */
|
||
upLoad: (s) => [CMD.UP_LOAD, [s & 0x7F]],
|
||
upErase: (s) => [CMD.UP_ERASE, [s & 0x7F]],
|
||
/* on: 1 = pushes; 3 = also TRACK_CHANGED (v4 firmware answers 3, older firmware 1) */
|
||
watch: (on) => [CMD.WATCH, [on === 3 ? 3 : on ? 1 : 0]],
|
||
ping: () => [CMD.PING, []],
|
||
/* v3: tracks 0..3 (3 = drums) */
|
||
track: (sel) => [CMD.TRACK, sel == null ? [] : [sel & 0x7F]],
|
||
trackMix: (tr, level, mute) => [CMD.TRACK_MIX, level == null ? [tr & 0x7F] : [tr & 0x7F, ...v14enc(level), mute ? 1 : 0]],
|
||
trackDump: (tr) => [CMD.TRACK_DUMP, [tr & 0x7F]],
|
||
trackStep: (tr, i, st) => [CMD.TRACK_STEP, st ? [tr & 0x7F, ...req.stepSet(i, st)[1]] : [tr & 0x7F, i & 0x7F]],
|
||
/* v4: get (v == null) or set parameter id (P_*) of track tr, clamped as SET */
|
||
trackParam: (tr, id, v) => [CMD.TRACK_PARAM, v == null ? [tr & 0x7F, id & 0x7F] : [tr & 0x7F, id & 0x7F, ...v14enc(v)]],
|
||
/* v6: backup / restore */
|
||
bkList: () => [CMD.BK_LIST, []],
|
||
bkGet: (id, off, n) => [CMD.BK_GET, [id & 0x7F, ...u35enc(off), n & 0x7F, (n >> 7) & 0x7F]],
|
||
bkBegin: (id, len, crc) => [CMD.BK_PUT, [0, id & 0x7F, ...u35enc(len), ...u35enc(crc)]],
|
||
bkData: (id, off, bytes) => [CMD.BK_PUT, [1, id & 0x7F, ...u35enc(off), ...pack7(bytes)]],
|
||
bkCommit: (id) => [CMD.BK_PUT, [2, id & 0x7F]],
|
||
bkAbort: (id) => [CMD.BK_PUT, [3, id & 0x7F]],
|
||
/* v7: the locks of a track; set (v a number) or delete (v == null) the lock of (step, param) */
|
||
lockGet: (tr) => [CMD.LOCK_GET, [tr & 0x7F]],
|
||
lockSet: (tr, step, param, v) => [CMD.LOCK_SET, v == null ? [tr & 0x7F, step & 0x7F, param & 0x7F] : [tr & 0x7F, step & 0x7F, param & 0x7F, ...v14enc(v)]],
|
||
/* v7: the nudges of a track; set one (m: MICRO.MIN..MAX, sent + 64) */
|
||
microGet: (tr) => [CMD.MICRO_GET, [tr & 0x7F]],
|
||
microSet: (tr, step, m) => [CMD.MICRO_SET, [tr & 0x7F, step & 0x7F, (Math.max(MICRO.MIN, Math.min(MICRO.MAX, Math.round(m))) + 64) & 0x7F]],
|
||
/* v8: the fill conditions of a track; set one (c: FC.NORM / FILL / NOFILL) */
|
||
fillGet: (tr) => [CMD.FILL_GET, [tr & 0x7F]],
|
||
fillSet: (tr, step, c) => [CMD.FILL_SET, [tr & 0x7F, step & 0x7F, (c % 3) & 0x7F]],
|
||
/* v9: FM6 patches (firmware proto >= 9) */
|
||
fm6Get: (target, i) => [CMD.FM6_GET, [target & 0x7F, i & 0x7F]],
|
||
fm6Put: (target, i, packed) => [CMD.FM6_PUT, [target & 0x7F, i & 0x7F, ...Array.from(packed, (x) => x & 0x7F)]],
|
||
fm6List: () => [CMD.FM6_LIST, []],
|
||
fm6Erase: (i) => [CMD.FM6_ERASE, [i & 0x7F]],
|
||
/* v10: the SYN drum kits (firmware proto >= 10). which: a factory kit 0.., or DSYN.USER + k */
|
||
dsynList: () => [CMD.DSYN_LIST, []],
|
||
dsynGet: (which) => [CMD.DSYN_GET, [which & 0x7F]],
|
||
dsynSound: (k, lane, bytes22) => [CMD.DSYN_PUT, [k & 0x7F, lane & 0x7F, ...pack7(bytes22)]],
|
||
dsynHead: (k, name, crush, src) => [CMD.DSYN_PUT, [k & 0x7F, 16, ...pack7(Uint8Array.from([...DSYN.name8(name), crush & 255, src & 255]))]],
|
||
dsynCopy: (k, src) => [CMD.DSYN_PUT, [k & 0x7F, 17, ...pack7(Uint8Array.of(src & 255))]],
|
||
dsynStore: () => [CMD.DSYN_STORE, []],
|
||
dsynPlay: (k, lane, vel = 110) => [CMD.DSYN_PLAY, [k & 0x7F, lane & 0x7F, Math.max(1, Math.min(127, vel | 0))]],
|
||
/* v12: LIVE op [, args]: every reply is the live state (parse[CMD.LIVE]) */
|
||
live: (op, ...args) => [CMD.LIVE, [op & 0x7F, ...(args.length ? args : [0]).map((x) => x & 0x7F)]],
|
||
};
|
||
|
||
/* which reply belongs to which request (the device echoes these) */
|
||
function replyMatches(cmd, args, a) {
|
||
switch (cmd) {
|
||
case CMD.GET: case CMD.SET: case CMD.DESC: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.STEP_GET: case CMD.STEP_SET: case CMD.NAMES:
|
||
case CMD.SMP_BEGIN: case CMD.SMP_END: case CMD.SMP_ERASE: return a[0] === args[0];
|
||
case CMD.SMP_WRITE: return a[0] === args[0] && a[1] === args[1] && a[2] === args[2] && a[3] === args[3];
|
||
case CMD.PROJECT: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.UP_LIST: case CMD.UP_GET: case CMD.UP_PUT: case CMD.UP_STORE: case CMD.UP_LOAD: case CMD.UP_ERASE:
|
||
case CMD.TRACK_MIX: case CMD.TRACK_DUMP: case CMD.DRUM_STEP: return a[0] === args[0];
|
||
case CMD.WATCH: return (a[0] & 1) === (args[0] & 1); /* bit 1: v4 firmware only */
|
||
case CMD.TRACK_STEP: case CMD.TRACK_PARAM: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.BK_GET: return a[0] === args[0] && [0, 1, 2, 3, 4].every((k) => a[2 + k] === args[1 + k]);
|
||
case CMD.BK_PUT: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.LOCK_GET: case CMD.MICRO_GET: case CMD.FILL_GET: return a[0] === args[0];
|
||
case CMD.LOCK_SET: return a[0] === args[0] && a[1] === args[1] && a[2] === args[2];
|
||
case CMD.MICRO_SET: case CMD.FILL_SET: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.FM6_GET: case CMD.FM6_PUT: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.FM6_ERASE: return a[0] === args[0];
|
||
case CMD.DSYN_GET: return a[0] === args[0];
|
||
case CMD.DSYN_PUT: case CMD.DSYN_PLAY: return a[0] === args[0] && a[1] === args[1];
|
||
case CMD.LIVE: return a[0] === args[0];
|
||
default: return true;
|
||
}
|
||
}
|
||
|
||
/* strict request/response: one frame in flight, the rest queued. Push frames (CHANGED, RELOAD,
|
||
STEP_CHANGED) can come at any time, also between a request and its reply: they go to onPush. */
|
||
class Link {
|
||
constructor(send, opts = {}) {
|
||
this.sendRaw = send;
|
||
this.q = [];
|
||
this.cur = null;
|
||
this.closed = false;
|
||
this.lastSent = 0; /* Date.now() of the last frame sent (WATCH keep-alive) */
|
||
this.timeout = opts.timeout || 300;
|
||
this.onUnknown = opts.onUnknown || (() => {});
|
||
this.onTimeout = opts.onTimeout || (() => {});
|
||
this.onPush = opts.onPush || (() => {});
|
||
this.onGap = opts.onGap || (() => {}); /* (ms) nothing was sent for that long (WATCH may have ended) */
|
||
}
|
||
get idle() { return !this.cur && !this.q.length; }
|
||
hasQueued(key) { return this.q.some((r) => r.key === key); }
|
||
/* r = [cmd, args]; opt: {timeout, retries, key (coalesce queued requests: the latest args win), front,
|
||
quiet (a timeout is expected: no onTimeout)} */
|
||
request(r, opt = {}) {
|
||
if (this.closed) return Promise.reject(new Error("closed"));
|
||
const [cmd, args] = r;
|
||
if (opt.key) {
|
||
const old = this.q.find((x) => x.key === opt.key);
|
||
if (old) { old.cmd = cmd; old.args = args; return old.promise; }
|
||
}
|
||
let res, rej;
|
||
const promise = new Promise((a, b) => { res = a; rej = b; });
|
||
const item = { cmd, args, key: opt.key, res, rej, promise, quiet: !!opt.quiet,
|
||
timeout: opt.timeout || this.timeout, retries: opt.retries ?? 1 };
|
||
if (opt.front) this.q.unshift(item); else this.q.push(item);
|
||
this.pump();
|
||
return promise;
|
||
}
|
||
pump() {
|
||
if (this.cur || this.closed || !this.q.length) return;
|
||
this.cur = this.q.shift();
|
||
this.fire();
|
||
}
|
||
fire() {
|
||
const c = this.cur;
|
||
const now = Date.now();
|
||
if (this.lastSent && now - this.lastSent > 2500) this.onGap(now - this.lastSent);
|
||
this.lastSent = now;
|
||
try { this.sendRaw(frame(c.cmd, c.args)); } catch (e) { this.finish(null, e); return; }
|
||
c.timer = setTimeout(() => {
|
||
if (this.cur !== c) return;
|
||
if (c.retries-- > 0) { this.fire(); return; }
|
||
if (!c.quiet) this.onTimeout(c.cmd);
|
||
this.finish(null, new Error("timeout (cmd " + c.cmd + ")"));
|
||
}, c.timeout);
|
||
}
|
||
finish(val, err) {
|
||
const c = this.cur;
|
||
if (!c) return;
|
||
clearTimeout(c.timer);
|
||
this.cur = null;
|
||
if (err) c.rej(err); else c.res(val);
|
||
this.pump();
|
||
}
|
||
/* raw incoming MIDI bytes */
|
||
receive(data) {
|
||
const f = unframe(data);
|
||
if (!f) return; /* not ours (notes, clock, other SysEx) */
|
||
if (PUSH.has(f.cmd)) { this.onPush(f); return; }
|
||
const c = this.cur;
|
||
if (!c || f.cmd !== c.cmd || !replyMatches(c.cmd, c.args, f.a)) { this.onUnknown(f); return; }
|
||
this.finish(f.a);
|
||
}
|
||
close() {
|
||
this.closed = true;
|
||
const all = (this.cur ? [this.cur] : []).concat(this.q);
|
||
if (this.cur) clearTimeout(this.cur.timer);
|
||
this.cur = null;
|
||
this.q = [];
|
||
for (const r of all) r.rej(new Error("closed"));
|
||
}
|
||
}
|
||
|
||
/* ------------------------------------------------------------- formatting --- */
|
||
const NOTE_NAMES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
||
const noteName = (n) => NOTE_NAMES[n % 12] + (Math.floor(n / 12) - 1); /* 60 = C4 */
|
||
/* GM drum notes (35..81) by short names, for the drum track's steps */
|
||
const GM_DRUM = { 35: "KICK2", 36: "KICK", 37: "RIM", 38: "SNARE", 39: "CLAP", 40: "SNARE2", 41: "LTOM2", 42: "CHH", 43: "LTOM",
|
||
44: "PHH", 45: "MTOM2", 46: "OHH", 47: "MTOM", 48: "HTOM2", 49: "CRASH", 50: "HTOM", 51: "RIDE", 52: "CHINA", 53: "BELL",
|
||
54: "TAMB", 55: "SPLASH", 56: "COWBELL", 57: "CRASH2", 58: "VIBRA", 59: "RIDE2", 60: "HBONGO", 61: "LBONGO", 62: "MCONGA",
|
||
63: "HCONGA", 64: "LCONGA", 65: "HTIMB", 66: "LTIMB", 67: "HAGOGO", 68: "LAGOGO", 69: "CABASA", 70: "MARACA", 71: "SWHIS",
|
||
72: "LWHIS", 73: "SGUIRO", 74: "LGUIRO", 75: "CLAVES", 76: "HWOOD", 77: "LWOOD", 78: "MCUICA", 79: "OCUICA", 80: "MTRI", 81: "OTRI" };
|
||
const GM_DRUM_BY_NAME = Object.fromEntries(Object.entries(GM_DRUM).map(([n, s]) => [s, +n]));
|
||
const drumName = (n) => GM_DRUM[n] || String(n);
|
||
/* a note token: a number, a note name (C4, F#3, Bb2) or a GM drum name (KICK, CHH) */
|
||
function parseNote(tok) {
|
||
const dn = GM_DRUM_BY_NAME[tok.toUpperCase()];
|
||
if (dn != null) return dn;
|
||
if (/^\d+$/.test(tok)) { const n = +tok; return n <= 127 ? n : null; }
|
||
const m = /^([A-Ga-g])([#b]?)(-?\d)$/.exec(tok);
|
||
if (!m) return null;
|
||
const base = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 }[m[1].toUpperCase()];
|
||
const n = base + (m[2] === "#" ? 1 : m[2] === "b" ? -1 : 0) + (parseInt(m[3], 10) + 1) * 12;
|
||
return n >= 0 && n <= 127 ? n : null;
|
||
}
|
||
/* "C4 E4 G4" -> [60, 64, 67]; null on a bad token or more than 4 notes */
|
||
function parseNotes(s) {
|
||
const t = s.trim().split(/[\s,]+/).filter(Boolean);
|
||
if (t.length > 4) return null;
|
||
const out = t.map(parseNote);
|
||
return out.includes(null) ? null : out;
|
||
}
|
||
|
||
/* close to the device's param_format (params.c), tables from tools/gen_tables.py */
|
||
function fmtValue(d, v) {
|
||
const sign = (x) => (x > 0 ? "+" + x : String(x));
|
||
switch (d.fmt) {
|
||
case F.PCT: return [String(d.max > 0 ? Math.trunc((v * 100 + Math.trunc(d.max / 2)) / d.max) : v), "%"];
|
||
case F.SWING: return [String(Math.max(0, Math.min(100, v))), ""]; /* 0 straight .. 100 the most (as the FM-1, 2.5) */
|
||
case F.FILT: return !v ? ["OFF", ""] : v < 0 ? ["LP" + Math.trunc((-v * 100 + 32) / 64), "%"] : ["HP" + Math.trunc((v * 100 + 31) / 63), "%"];
|
||
case F.BIPCT: return [sign(Math.trunc(v * 100 / 64)), "%"];
|
||
case F.TIME: {
|
||
const ms10 = Math.round(10 * Math.pow(10000, (v & 127) / 127));
|
||
if (ms10 < 100) return [(ms10 / 10).toFixed(1), "ms"];
|
||
if (ms10 < 10000) return [String(Math.round(ms10 / 10)), "ms"];
|
||
return [(ms10 / 10000).toFixed(2), "s"];
|
||
}
|
||
case F.LFOHZ: { const h = 0.05 * Math.pow(800, (v & 127) / 127); return [h < 10 ? h.toFixed(2) : h.toFixed(1), "Hz"]; }
|
||
case F.CUTOFF: { const h = 30 * Math.pow(16000 / 30, (v & 127) / 127); return h < 1000 ? [String(Math.round(h)), "Hz"] : [(h / 1000).toFixed(1), "kHz"]; }
|
||
case F.DB: return v <= 0 ? ["OFF", ""] : [((v - 112) / 2).toFixed(1), "dB"];
|
||
case F.SEMI: return [sign(v), "st"];
|
||
case F.ENUM: return [d.names[v - d.min] ?? String(v), d.unit || ""];
|
||
case F.BPM: return [String(v), "BPM"];
|
||
case F.NOTE: return [NOTE_NAMES[((v % 12) + 12) % 12], ""];
|
||
case F.ONOFF: return [v ? "ON" : "OFF", ""];
|
||
case F.STEPS: return [String(v), "STEP"];
|
||
default: return [d.names && d.names[v - d.min] != null ? d.names[v - d.min] : String(v), d.unit || ""];
|
||
}
|
||
}
|
||
|
||
/* ---------------------------------------------------------- user samples --- */
|
||
/* A port of tools/sampleio.py (read_any_wav, resample, to_int16, ima_encode, user_slot),
|
||
byte for byte: web/test_web.mjs compares them. */
|
||
const SMP = { SLOT_SIZE: 0x14000, DATA_OFF: 512, RATE: 22050, HDR_LEN: 32 + 16 * 28, MAX_ZONES: 16 };
|
||
SMP.MAX_DATA = SMP.SLOT_SIZE - SMP.DATA_OFF;
|
||
|
||
/* groups of up to 7 bytes, each preceded by their top bits */
|
||
function pack7(b) {
|
||
const out = [];
|
||
for (let i = 0; i < b.length; i += 7) {
|
||
const g = Array.from(b.slice(i, i + 7));
|
||
out.push(g.reduce((m, x, j) => m | (((x >> 7) & 1) << j), 0));
|
||
for (const x of g) out.push(x & 0x7F);
|
||
}
|
||
return out;
|
||
}
|
||
function unpack7(a) {
|
||
const out = [];
|
||
for (let i = 0; i < a.length; i += 8) {
|
||
const top = a[i];
|
||
for (let j = 0; j < 7 && i + 1 + j < a.length; j++) out.push(a[i + 1 + j] | (((top >> j) & 1) << 7));
|
||
}
|
||
return Uint8Array.from(out);
|
||
}
|
||
|
||
const CRC_TABLE = (() => {
|
||
const t = new Uint32Array(256);
|
||
for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xEDB88320 ^ (c >>> 1) : c >>> 1; t[n] = c >>> 0; }
|
||
return t;
|
||
})();
|
||
function crc32(b) { let c = 0xFFFFFFFF; for (let i = 0; i < b.length; i++) c = CRC_TABLE[(c ^ b[i]) & 0xFF] ^ (c >>> 8); return (c ^ 0xFFFFFFFF) >>> 0; }
|
||
|
||
const IMA_STEP = [7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88,
|
||
97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
|
||
724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660,
|
||
4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818,
|
||
18500, 20350, 22385, 24623, 27086, 29794, 32767];
|
||
const IMA_IDX = [-1, -1, -1, -1, 2, 4, 6, 8];
|
||
/* IMA ADPCM, 4 bit, low nibble first, from predictor 0 / index 0 -> {data, pred, idx} (state at loopStart) */
|
||
function imaEncode(s, loopStart = 0) {
|
||
let pred = 0, idx = 0, atLoop = [0, 0];
|
||
const nib = new Uint8Array(s.length + (s.length & 1));
|
||
for (let n = 0; n < s.length; n++) {
|
||
if (n === loopStart) atLoop = [pred, idx];
|
||
const step = IMA_STEP[idx];
|
||
let diff = s[n] - pred, code = 0;
|
||
if (diff < 0) { code = 8; diff = -diff; }
|
||
let vd = step >> 3;
|
||
if (diff >= step) { code |= 4; diff -= step; vd += step; }
|
||
if (diff >= step >> 1) { code |= 2; diff -= step >> 1; vd += step >> 1; }
|
||
if (diff >= step >> 2) { code |= 1; vd += step >> 2; }
|
||
pred = Math.max(-32768, Math.min(32767, code & 8 ? pred - vd : pred + vd));
|
||
idx = Math.max(0, Math.min(88, idx + IMA_IDX[code & 7]));
|
||
nib[n] = code;
|
||
}
|
||
const out = new Uint8Array(nib.length >> 1);
|
||
for (let k = 0; k < nib.length; k += 2) out[k >> 1] = nib[k] | (nib[k + 1] << 4);
|
||
return { data: out, pred: atLoop[0], idx: atLoop[1] };
|
||
}
|
||
|
||
/* WAV: PCM 8/16/24/32 or float, any channel count, mixed to mono -> {sr, x} (gen_samples.read_any_wav) */
|
||
function parseWav(buf) {
|
||
const d = new Uint8Array(buf), v = new DataView(d.buffer, d.byteOffset, d.byteLength);
|
||
const id = (i) => String.fromCharCode(d[i], d[i + 1], d[i + 2], d[i + 3]);
|
||
if (d.length < 12 || id(0) !== "RIFF" || id(8) !== "WAVE") throw new Error("not a WAV file");
|
||
let i = 12, fmt = null, data = null, loop = null;
|
||
while (i + 8 <= d.length) {
|
||
const cid = id(i), n = v.getUint32(i + 4, true);
|
||
if (cid === "fmt ") {
|
||
let tag = v.getUint16(i + 8, true);
|
||
const ch = v.getUint16(i + 10, true), sr = v.getUint32(i + 12, true), bits = v.getUint16(i + 22, true);
|
||
if (tag === 0xFFFE) tag = v.getUint16(i + 32, true);
|
||
fmt = { tag, ch, sr, bits };
|
||
} else if (cid === "data") {
|
||
data = [i + 8, Math.min(d.length, i + 8 + n)];
|
||
} else if (cid === "smpl" && n >= 60 && i + 8 + 60 <= d.length && v.getUint32(i + 8 + 28, true)) {
|
||
loop = [v.getUint32(i + 8 + 44, true), v.getUint32(i + 8 + 48, true)]; /* (2.7) its first loop, in frames */
|
||
}
|
||
i += 8 + n + (n & 1);
|
||
}
|
||
if (!fmt || !data) throw new Error("WAV without fmt/data");
|
||
const { tag, ch, sr, bits } = fmt, bps = bits >> 3, frame = bps * ch;
|
||
if (!(tag === 1 || tag === 3) || !bps || !ch) throw new Error("unsupported WAV format");
|
||
const nfr = Math.floor((data[1] - data[0]) / frame), x = new Float64Array(nfr);
|
||
for (let f = 0; f < nfr; f++) {
|
||
let acc = 0;
|
||
for (let c = 0; c < ch; c++) {
|
||
const o = data[0] + f * frame + c * bps;
|
||
let s;
|
||
if (tag === 3) s = bps === 4 ? v.getFloat32(o, true) : v.getFloat64(o, true);
|
||
else if (bps === 2) s = v.getInt16(o, true) / 32768;
|
||
else if (bps === 3) s = (((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) << 8) >> 8) / 8388608;
|
||
else if (bps === 4) s = v.getInt32(o, true) / 2147483648;
|
||
else s = (d[o] - 128) / 128;
|
||
acc += s;
|
||
}
|
||
x[f] = acc / ch;
|
||
}
|
||
return { sr, x, loop };
|
||
}
|
||
|
||
/* gen_samples.resample: moving average over the ratio, then linear interpolation */
|
||
function resample(x, sr, to) {
|
||
if (sr === to) return Array.from(x);
|
||
if (sr > to) {
|
||
const k = Math.max(1, pyRound(sr / to));
|
||
if (k > 1) {
|
||
const y = new Array(x.length);
|
||
for (let i = 0; i < x.length; i++) { let s = 0; for (let j = i; j < Math.min(x.length, i + k); j++) s += x[j]; y[i] = s / k; }
|
||
x = y;
|
||
}
|
||
}
|
||
const step = sr / to, out = [];
|
||
let p = 0;
|
||
while (p < x.length - 1) { const i = Math.floor(p), f = p - i; out.push(x[i] * (1 - f) + x[i + 1] * f); p += step; }
|
||
return out;
|
||
}
|
||
function pyRound(v) { const f = Math.floor(v), r = v - f; return r > 0.5 ? f + 1 : r < 0.5 ? f : (f % 2 ? f + 1 : f); }
|
||
|
||
/* mono float -> int16, peak normalised to 30000 */
|
||
function normalize(x) {
|
||
let pk = 1e-9;
|
||
for (const v of x) pk = Math.max(pk, Math.abs(v));
|
||
return Int16Array.from(x, (v) => Math.max(-32768, Math.min(32767, Math.trunc(v / pk * 30000))));
|
||
}
|
||
|
||
/* SLOOP 2.6: how loud a sound is heard, in dB: K-weighted (ITU-R BS.1770, the ear's curve: the lows count less, the
|
||
presence more), the mean square over 100 ms windows, the loudest window (a hit is heard by its loudest moment, not
|
||
by its average with the silence after; a click shorter than a window counts over the whole window, as the ear does) */
|
||
function loudDb(s, sr = SMP.RATE) {
|
||
const bq = (G, Q, fc, shelf) => { /* the two stages' coefficients at this rate (pyloudnorm's) */
|
||
const A = Math.pow(10, G / 40), w = 2 * Math.PI * fc / sr, c = Math.cos(w), al = Math.sin(w) / (2 * Q), r = 2 * Math.sqrt(A) * al;
|
||
const k = shelf
|
||
? [A * ((A + 1) + (A - 1) * c + r), -2 * A * ((A - 1) + (A + 1) * c), A * ((A + 1) + (A - 1) * c - r),
|
||
(A + 1) - (A - 1) * c + r, 2 * ((A - 1) - (A + 1) * c), (A + 1) - (A - 1) * c - r]
|
||
: [(1 + c) / 2, -(1 + c), (1 + c) / 2, 1 + al, -2 * c, 1 - al];
|
||
return k.map((v) => v / k[3]);
|
||
};
|
||
const st = [bq(3.99984385397, 0.7071752369554193, 1681.9744509555319, true), bq(0, 0.5003270373253953, 38.13547087613982, false)];
|
||
const y = new Float64Array(s.length);
|
||
for (let i = 0; i < s.length; i++) y[i] = s[i] / 32768;
|
||
for (const [b0, b1, b2, , a1, a2] of st) {
|
||
let x1 = 0, x2 = 0, y1 = 0, y2 = 0;
|
||
for (let i = 0; i < y.length; i++) { const x = y[i], v = b0 * x + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2; x2 = x1; x1 = x; y2 = y1; y1 = v; y[i] = v; }
|
||
}
|
||
const W = Math.round(sr * 0.1), hop = Math.max(1, W >> 2);
|
||
let best = 1e-12;
|
||
for (let a = 0; a < Math.max(1, y.length - W + hop); a += hop) {
|
||
let e = 0;
|
||
for (let i = a; i < Math.min(y.length, a + W); i++) e += y[i] * y[i];
|
||
best = Math.max(best, e / W);
|
||
}
|
||
return 10 * Math.log10(best) - 0.691;
|
||
}
|
||
/* gains (dB, -24..0) that bring sounds to the same heard level: the louder ones turned down to the quietest (every
|
||
sound comes in peak-normalised, so turning up would clip); null entries stay null */
|
||
const LEVEL_MIN = -24;
|
||
function matchGains(sounds) {
|
||
const L = sounds.map((x) => (x ? loudDb(x) : null)), q = L.filter((v) => v != null);
|
||
if (!q.length) return L;
|
||
const target = Math.max(Math.min(...q), Math.max(...q) + LEVEL_MIN);
|
||
return L.map((v) => (v == null ? null : Math.max(LEVEL_MIN, Math.min(0, Math.round(target - v)))));
|
||
}
|
||
/* a sound with its gain (dB, 0 = as it came) */
|
||
function withGain(s, db) {
|
||
if (!db) return s;
|
||
const g = Math.pow(10, Math.max(LEVEL_MIN, Math.min(0, db)) / 20);
|
||
return Int16Array.from(s, (v) => Math.round(v * g));
|
||
}
|
||
|
||
/* root from a file name like "piano_C4" or "F#3" (C4 = 60), else 60 (sampleio.note_from_name) */
|
||
function rootFromName(name) {
|
||
const m = /(?<![A-Za-z])([A-G])([#b]?)(-?\d)(?!\d)/.exec(name);
|
||
if (!m) return 60;
|
||
const n = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 }[m[1]] + (m[2] === "#" ? 1 : m[2] === "b" ? -1 : 0) + (parseInt(m[3], 10) + 1) * 12;
|
||
return Math.max(0, Math.min(127, n));
|
||
}
|
||
|
||
/* 2.7: a file's loop (the Samples page): 0 ONE SHOT; 1 LOOP, the whole file again while the key is held, let go it ends
|
||
its round; 2 LOOP+TAIL, the start, then [ls, le] again while held, let go the rest to the end. Both are the zone's
|
||
looped = 2 (SMP_LOOP_HELD, firmware eng_sample.c; SLOOP 2.6 loops them until the release ends the note) */
|
||
const LOOP = {
|
||
NAMES: ["ONE SHOT", "LOOP", "LOOP+TAIL"], MIN: 64, SNAP: 512,
|
||
/* the loop's [ls, le] of a file of n samples */
|
||
range(z) {
|
||
const n = z.s.length;
|
||
if (z.loop === 1 || n < 2 * LOOP.MIN) return [0, n - 1];
|
||
const ls = Math.max(0, Math.min(n - LOOP.MIN - 1, Math.round(z.ls ?? 0)));
|
||
return [ls, Math.max(ls + LOOP.MIN - 1, Math.min(n - 1, Math.round(z.le ?? n - 1)))];
|
||
},
|
||
/* the nearest rising zero crossing to i (s[i - 1] < 0 <= s[i]), within SNAP samples, else i */
|
||
snap(s, i) {
|
||
for (let d = 0; d <= LOOP.SNAP; d++)
|
||
for (const j of d ? [i - d, i + d] : [i])
|
||
if (j >= 1 && j < s.length && s[j - 1] < 0 && s[j] >= 0) return j;
|
||
return i;
|
||
},
|
||
/* start and end points snapped: the loop starts on a crossing and its last sample is just before one, so the jump
|
||
back lands where the wave was going anyway (no click) */
|
||
snapRange(s, ls, le) {
|
||
const n = s.length, a = Math.max(0, Math.min(n - LOOP.MIN - 1, LOOP.snap(s, ls)));
|
||
let b = LOOP.snap(s, le + 1) - 1;
|
||
if (b < a + LOOP.MIN - 1 || b > n - 1) b = Math.max(a + LOOP.MIN - 1, Math.min(n - 1, le));
|
||
return [a, b];
|
||
},
|
||
};
|
||
|
||
/* zones: [{s: Int16Array (22050 Hz), root, lo?, hi?, loop?, ls?, le?}] -> {hdr (480 B), data, zones} (sampleio.user_slot) */
|
||
function buildSlot(name, zonesIn) {
|
||
const zones = [], parts = [];
|
||
let len = 0;
|
||
for (const z of zonesIn) {
|
||
const [ls, le] = z.loop ? LOOP.range(z) : [0, z.s.length - 1];
|
||
const e = imaEncode(z.s, ls); /* (the decoder's state at the loop start) */
|
||
zones.push({ off: len, n: z.s.length, ls, le, looped: z.loop ? 2 : 0, root: z.root, lo: z.lo ?? null, hi: z.hi ?? null,
|
||
pred: e.pred, idx: e.idx });
|
||
parts.push(e.data);
|
||
len += e.data.length;
|
||
}
|
||
const data = new Uint8Array(len);
|
||
let o = 0;
|
||
for (const p of parts) { data.set(p, o); o += p.length; }
|
||
if (len > SMP.MAX_DATA) throw new Error(`too long: ${len} B (max ${SMP.MAX_DATA} B)`);
|
||
if (!zones.length || zones.length > SMP.MAX_ZONES) throw new Error("1..16 files per slot");
|
||
zones.sort((a, b) => a.root - b.root);
|
||
zones.forEach((z, j) => {
|
||
if (z.lo == null) {
|
||
z.lo = j === 0 ? 0 : Math.floor((zones[j - 1].root + z.root) / 2) + 1;
|
||
z.hi = j === zones.length - 1 ? 127 : Math.floor((z.root + zones[j + 1].root) / 2);
|
||
}
|
||
});
|
||
const hdr = new Uint8Array(SMP.HDR_LEN), v = new DataView(hdr.buffer);
|
||
v.setUint32(0, 0x504D5346, true);
|
||
v.setUint16(4, 1, true);
|
||
hdr[6] = zones.length;
|
||
const nm = String(name).toUpperCase().replace(/[^\x20-\x7E]/g, "").slice(0, 8);
|
||
for (let i = 0; i < nm.length; i++) hdr[8 + i] = nm.charCodeAt(i);
|
||
v.setUint32(16, len, true);
|
||
v.setUint32(20, crc32(data), true);
|
||
const rate = pyRound(SMP.RATE / 44100 * 65536);
|
||
zones.forEach((z, j) => {
|
||
const b = 32 + j * 28;
|
||
[z.off, z.n, z.ls, z.le, rate].forEach((x, k) => v.setUint32(b + k * 4, x >>> 0, true));
|
||
v.setInt16(b + 20, z.root * 16, true);
|
||
v.setInt16(b + 22, z.pred, true);
|
||
hdr[b + 24] = z.idx; hdr[b + 25] = z.lo; hdr[b + 26] = z.hi; hdr[b + 27] = z.looped || 0;
|
||
});
|
||
return { hdr, data, zones };
|
||
}
|
||
|
||
/* ------------------------------------------------------------------- chop --- */
|
||
/* Chopping a recording into a slot (the CHOP block of the samples tab). All at SMP.RATE, positions
|
||
in samples. These are pure: test_web.mjs runs them. */
|
||
const CHOP = { HOP: 128, MAX: 16, FADE_IN: 22, FADE_OUT: 132, PRE: 32 }; /* 5.8 ms frames; fades 1 / 6 ms; start 1.5 ms early */
|
||
|
||
/* onset novelty per frame: the rise of the log energy of the signal's first difference (the attack
|
||
of a hit, not its body), over the louder of the two frames before */
|
||
function chopNovelty(x) {
|
||
const H = CHOP.HOP, F = Math.ceil(x.length / H), L = new Float64Array(F), P = new Float64Array(F), nov = new Float64Array(F);
|
||
let top = 1e-12, ptop = 1e-12;
|
||
for (let f = 0; f < F; f++) {
|
||
let e = 0, p = 0;
|
||
for (let i = f * H, n = Math.min(x.length, i + H); i < n; i++) { const d = x[i] - (i ? x[i - 1] : 0); e += d * d; p += x[i] * x[i]; }
|
||
L[f] = e;
|
||
P[f] = p;
|
||
if (e > top) top = e;
|
||
if (p > ptop) ptop = p;
|
||
}
|
||
for (let f = 0; f < F; f++) { L[f] = Math.log10(L[f] / top + 1e-9); P[f] = Math.log10(P[f] / ptop + 1e-9); } /* 0 = the loudest */
|
||
for (let f = 0; f < F; f++) {
|
||
const before = Math.max(f ? L[f - 1] : -9, f > 1 ? L[f - 2] : -9);
|
||
nov[f] = L[f] > -3.5 ? Math.max(0, L[f] - before) : 0; /* (under -35 dB: no hit) */
|
||
}
|
||
nov.level = P; /* (log10 power, 0 = the loudest frame) */
|
||
return nov;
|
||
}
|
||
|
||
/* the first sample of the hit in frame f: where the signal first reaches 30 % of its peak over the
|
||
frames f-1..f+2, then PRE samples earlier (the attack is kept whole) */
|
||
function chopAttack(x, f) {
|
||
const H = CHOP.HOP, a = Math.max(0, (f - 1) * H), b = Math.min(x.length, (f + 3) * H);
|
||
let pk = 0;
|
||
for (let i = a; i < b; i++) pk = Math.max(pk, Math.abs(x[i]));
|
||
for (let i = a; i < b; i++) if (Math.abs(x[i]) >= 0.3 * pk) return Math.max(0, i - CHOP.PRE);
|
||
return a;
|
||
}
|
||
|
||
/* hits: sens 1 (only the hardest and loudest) .. 10 (every small one); at least 60 ms apart. A hit is a
|
||
sharp rise (nov over thr) to a level (its loudest frame within 3) over the gate */
|
||
function chopHits(x, nov, sens) {
|
||
const k = Math.max(1, Math.min(10, sens)), thr = 0.15 + (10 - k) * 0.08, gate = -(0.5 + k * 0.35);
|
||
const gap = Math.round(0.06 * SMP.RATE / CHOP.HOP), L = nov.level;
|
||
const out = [];
|
||
let last = -1e9;
|
||
for (let f = 0; f < nov.length - 1; f++) { /* (a hit on the very first frame counts too) */
|
||
if (nov[f] < thr || (f && nov[f] < nov[f - 1]) || nov[f] < nov[f + 1]) continue;
|
||
if (L && Math.max(L[f], L[Math.min(L.length - 1, f + 1)], L[Math.min(L.length - 1, f + 2)]) < gate) continue;
|
||
if (f - last < gap) {
|
||
if (out.length && nov[f] > nov[last]) { out[out.length - 1] = chopAttack(x, f); last = f; }
|
||
continue;
|
||
}
|
||
out.push(chopAttack(x, f));
|
||
last = f;
|
||
}
|
||
return out;
|
||
}
|
||
|
||
/* a tap at pos (as heard) moved to the hit it meant: the strongest attack within +-win s, if any */
|
||
function chopSnap(x, nov, pos, win = 0.05) {
|
||
const H = CHOP.HOP, w = Math.round(win * SMP.RATE / H), c = Math.round(pos / H);
|
||
let best = -1, bv = 0.12;
|
||
for (let f = Math.max(1, c - w); f <= Math.min(nov.length - 1, c + w); f++) if (nov[f] > bv) { bv = nov[f]; best = f; }
|
||
return best < 0 ? Math.max(0, Math.min(x.length - 1, Math.round(pos))) : chopAttack(x, best);
|
||
}
|
||
|
||
/* markers every `beats` beats at bpm from start to end */
|
||
function chopGrid(start, end, bpm, beats) {
|
||
const step = SMP.RATE * 60 / bpm * beats, out = [];
|
||
for (let p = start; p < end - step * 0.25 && out.length < 64; p += step) out.push(Math.round(p));
|
||
return out;
|
||
}
|
||
|
||
/* n equal parts of start..end */
|
||
function chopEqual(start, end, n) {
|
||
return Array.from({ length: n }, (_, i) => Math.round(start + (end - start) * i / n));
|
||
}
|
||
|
||
/* the chops of sorted markers: each to the next marker (the last to the end), cut at maxLen samples
|
||
when maxLen > 0 -> [{start, end, i, off, full}] (all of them; the slot takes CHOP.MAX).
|
||
opt[i] (optional) = {off: left out of the slot, len: its own length in samples, over maxLen};
|
||
a chop is never longer than up to the next marker (`full`) */
|
||
function chopList(marks, total, maxLen = 0, opt = null) {
|
||
return marks.map((m, i) => {
|
||
const full = Math.max(m + 1, i + 1 < marks.length ? marks[i + 1] : total), o = (opt && opt[i]) || {};
|
||
let e = full;
|
||
if (o.len > 0) e = Math.min(e, m + o.len);
|
||
else if (maxLen > 0) e = Math.min(e, m + maxLen);
|
||
return { start: m, end: Math.max(m + 1, e), i, off: !!o.off, full };
|
||
});
|
||
}
|
||
|
||
/* the chops the slot gets: mode 0 the kept ones, the first CHOP.MAX of them; mode 1 the chop `sel` */
|
||
function chopPick(chops, mode = 0, sel = 0) {
|
||
if (mode === 1) return chops.length ? [chops[Math.max(0, Math.min(chops.length - 1, sel))]] : [];
|
||
return chops.filter((c) => !c.off).slice(0, CHOP.MAX);
|
||
}
|
||
|
||
/* the longest common length L (samples) so the chops, each cut at L, fit in room; Infinity if they fit */
|
||
function chopFit(chops, room) {
|
||
const len = chops.map((c) => c.end - c.start), sum = (L) => len.reduce((a, n) => a + Math.min(n, L), 0);
|
||
if (sum(Infinity) <= room) return Infinity;
|
||
let lo = 0, hi = Math.max(...len);
|
||
while (lo < hi) { const L = (lo + hi + 1) >> 1; if (sum(L) <= room) lo = L; else hi = L - 1; }
|
||
return lo;
|
||
}
|
||
|
||
/* chops -> slot zones {s (Int16Array, one gain for all: their levels are kept), root, lo, hi, fname}.
|
||
mode 0: the kept chops (chopPick), one key each from key0 (each key plays its chop at its own speed,
|
||
the keys between are silent); mode 1: the chop `sel` alone over the whole keyboard, at its own speed
|
||
on key0. The file names keep the chop's own number. */
|
||
function chopZones(x, chops, key0, mode = 0, sel = 0) {
|
||
const use = chopPick(chops, mode, sel);
|
||
let pk = 1e-9;
|
||
for (const c of use) for (let i = c.start; i < c.end; i++) pk = Math.max(pk, Math.abs(x[i]));
|
||
return use.map((c, j) => {
|
||
const n = c.end - c.start, s = new Int16Array(n), fi = Math.min(CHOP.FADE_IN, n >> 2), fo = Math.min(CHOP.FADE_OUT, n >> 2);
|
||
for (let i = 0; i < n; i++) {
|
||
let g = 1;
|
||
if (i < fi) g = i / fi;
|
||
if (i >= n - fo) g = Math.min(g, (n - i) / fo);
|
||
s[i] = Math.max(-32768, Math.min(32767, Math.trunc(x[c.start + i] / pk * 30000 * g)));
|
||
}
|
||
const key = Math.min(127, key0 + (mode === 1 ? 0 : j));
|
||
return { s, root: key, lo: mode === 1 ? 0 : key, hi: mode === 1 ? 127 : key,
|
||
fname: `CHOP${String((c.i != null ? c.i : mode === 1 ? sel : j) + 1).padStart(2, "0")}_${NOTE_NAMES[key % 12]}${Math.floor(key / 12) - 1}.wav` };
|
||
});
|
||
}
|
||
|
||
/* a mono 16-bit WAV at SMP.RATE */
|
||
function wavFile(s) {
|
||
const b = new Uint8Array(44 + s.length * 2), v = new DataView(b.buffer);
|
||
const str = (o, t) => { for (let i = 0; i < t.length; i++) b[o + i] = t.charCodeAt(i); };
|
||
str(0, "RIFF"); v.setUint32(4, 36 + s.length * 2, true); str(8, "WAVEfmt "); v.setUint32(16, 16, true);
|
||
v.setUint16(20, 1, true); v.setUint16(22, 1, true); v.setUint32(24, SMP.RATE, true); v.setUint32(28, SMP.RATE * 2, true);
|
||
v.setUint16(32, 2, true); v.setUint16(34, 16, true); str(36, "data"); v.setUint32(40, s.length * 2, true);
|
||
for (let i = 0; i < s.length; i++) v.setInt16(44 + i * 2, s[i], true);
|
||
return b;
|
||
}
|
||
|
||
/* files [{name, data: Uint8Array}] -> a ZIP (stored, no compression) */
|
||
function zipStore(files) {
|
||
const parts = [], dir = [];
|
||
let off = 0;
|
||
for (const f of files) {
|
||
const nm = new TextEncoder().encode(f.name), crc = crc32(f.data), h = new Uint8Array(30 + nm.length), v = new DataView(h.buffer);
|
||
v.setUint32(0, 0x04034B50, true); v.setUint16(4, 20, true); v.setUint32(14, crc, true);
|
||
v.setUint32(18, f.data.length, true); v.setUint32(22, f.data.length, true); v.setUint16(26, nm.length, true); h.set(nm, 30);
|
||
const c = new Uint8Array(46 + nm.length), w = new DataView(c.buffer);
|
||
w.setUint32(0, 0x02014B50, true); w.setUint16(4, 20, true); w.setUint16(6, 20, true); w.setUint32(16, crc, true);
|
||
w.setUint32(20, f.data.length, true); w.setUint32(24, f.data.length, true); w.setUint16(28, nm.length, true);
|
||
w.setUint32(42, off, true); c.set(nm, 46);
|
||
parts.push(h, f.data);
|
||
dir.push(c);
|
||
off += h.length + f.data.length;
|
||
}
|
||
const size = dir.reduce((a, c) => a + c.length, 0), end = new Uint8Array(22), e = new DataView(end.buffer);
|
||
e.setUint32(0, 0x06054B50, true); e.setUint16(8, files.length, true); e.setUint16(10, files.length, true);
|
||
e.setUint32(12, size, true); e.setUint32(16, off, true);
|
||
const out = new Uint8Array(off + size + 22);
|
||
let o = 0;
|
||
for (const p of [...parts, ...dir, end]) { out.set(p, o); o += p.length; }
|
||
return out;
|
||
}
|
||
|
||
/* -------------------------------------------------------------- librarian --- */
|
||
/* A patch (library entry, user preset):
|
||
{name, engine (index), engineName, p: [P_COUNT values by parameter id, null = unknown],
|
||
pattern: 16 x [note 0..127 (0 rest), flags 1 accent | 2 slide | 4 tie] or null, tags: [], created, modified}
|
||
|
||
Library / bank / single-patch file (JSON):
|
||
{
|
||
"format": "felucca-library", "version": 1,
|
||
"kind": "library" | "bank" | "patch",
|
||
"firmware": "FELUCCA 0.5 ...", device version string when exported ("" if unknown)
|
||
"pCount": 57, "pE0": 49, P_COUNT and the first engine parameter id
|
||
"paramLabels": ["LVL", "ATK", ...], one key per parameter id: the DESC label, "#2", "#3" appended to
|
||
a repeated label (PIT, PIT#2), and "E0".."E7" for the engine
|
||
parameters (their labels depend on the engine)
|
||
"engines": ["ANALOG", ...], engine names by index
|
||
"exported": "2026-10-03T12:00:00.000Z",
|
||
"patches": [{ "name", "engine", "engineName", "params": [pCount numbers or null],
|
||
"pattern": [[note, flags] x 16] or null, "tags": [...], "created", "modified",
|
||
"slot": n (bank files only, 0-based) }]
|
||
}
|
||
Reading maps every parameter by its key, so a firmware with other ids (or more parameters) still gets
|
||
the right values; parameters the file does not have are null (left at the engine default). Engines are
|
||
matched by name. The old single-sound file ("felucca-patch" version 1, "Save to file") is read too. */
|
||
const LIB = { FORMAT: "felucca-library", VERSION: 1 };
|
||
|
||
/* parameter keys by id from the instrument DESCs */
|
||
function paramKeys(pdesc, pe0, pcount) {
|
||
const seen = {}, out = [];
|
||
for (let i = 0; i < pcount; i++) {
|
||
if (i >= pe0) { out.push("E" + (i - pe0)); continue; }
|
||
const l = (pdesc[i] && pdesc[i].label) || "P" + i;
|
||
seen[l] = (seen[l] || 0) + 1;
|
||
out.push(seen[l] > 1 ? `${l}#${seen[l]}` : l);
|
||
}
|
||
return out;
|
||
}
|
||
const sameKeys = (a, b) => !!a && !!b && a.length === b.length && a.every((k, i) => k === b[i]);
|
||
/* values by fromKeys -> values by toKeys (null where the source has no such key) */
|
||
function remapParams(p, fromKeys, toKeys) {
|
||
if (!fromKeys || !toKeys || sameKeys(fromKeys, toKeys)) return p.slice();
|
||
const at = new Map(fromKeys.map((k, i) => [k, i]));
|
||
return toKeys.map((k) => (at.has(k) ? p[at.get(k)] ?? null : null));
|
||
}
|
||
|
||
/* one pattern step as the firmware keeps it (up_pat_norm): a tie has no note, a rest no flags */
|
||
const patNorm = (n, f) => (f & 4 ? [0, 4] : [n & 0x7F, n ? f & 3 : 0]);
|
||
/* sequencer steps (STEP_GET objects) -> 16-step pattern, as the firmware's UP_STORE does (up_pat_from):
|
||
the first note of a NOTE step, flag 4 for a TIE step */
|
||
function patternFromSteps(steps) {
|
||
return Array.from({ length: UP.PAT }, (_, i) => {
|
||
const s = steps[i];
|
||
if (!s) return [0, 0];
|
||
return patNorm(s.time === 0 && s.n ? s.notes[0] : 0, s.time === 1 ? 4 : s.flags);
|
||
});
|
||
}
|
||
/* pattern -> 16 STEP_SET objects, as the firmware loads one (load_pat16; velocity 96) */
|
||
function stepsFromPattern(pat) {
|
||
return Array.from({ length: UP.PAT }, (_, i) => {
|
||
const [n, f] = (pat && pat[i]) || [0, 0];
|
||
return { n: n ? 1 : 0, notes: [n & 0x7F, 0, 0, 0], time: f & 4 ? 1 : n ? 0 : 2, flags: n ? f & 3 : 0, vel: n ? 96 : 0 };
|
||
});
|
||
}
|
||
const patternUsed = (pat) => !!pat && pat.some((x) => x && x[0]);
|
||
|
||
function cleanPatch(pt) {
|
||
const now = new Date().toISOString();
|
||
const pat = Array.isArray(pt.pattern) && pt.pattern.length
|
||
? Array.from({ length: UP.PAT }, (_, i) => { const x = pt.pattern[i]; return Array.isArray(x) ? patNorm(x[0] | 0, x[1] | 0) : [0, 0]; })
|
||
: null;
|
||
const o = {
|
||
name: String(pt.name ?? "PATCH").slice(0, 32) || "PATCH",
|
||
engine: pt.engine | 0, engineName: String(pt.engineName ?? ""),
|
||
p: Array.from(pt.p || pt.params || [], (v) => (Number.isFinite(v) ? Math.round(v) : null)),
|
||
pattern: patternUsed(pat) ? pat : null,
|
||
tags: Array.isArray(pt.tags) ? [...new Set(pt.tags.map((x) => String(x).trim()).filter(Boolean))] : [],
|
||
created: pt.created || now, modified: pt.modified || pt.created || now,
|
||
};
|
||
if (Number.isInteger(pt.slot)) o.slot = pt.slot;
|
||
return o;
|
||
}
|
||
|
||
/* ctx: {keys, engines, firmware, pe0} of the library (the device's when connected) */
|
||
function libraryFile(kind, patches, ctx) {
|
||
return {
|
||
format: LIB.FORMAT, version: LIB.VERSION, kind, firmware: ctx.firmware || "",
|
||
pCount: ctx.keys ? ctx.keys.length : 0, pE0: ctx.pe0 ?? null, paramLabels: ctx.keys || [], engines: ctx.engines || [],
|
||
exported: new Date().toISOString(),
|
||
patches: patches.map((x) => {
|
||
const c = cleanPatch(x);
|
||
const o = { name: c.name, engine: c.engine, engineName: c.engineName || (ctx.engines || [])[c.engine] || "",
|
||
params: c.p, pattern: c.pattern, tags: c.tags, created: c.created, modified: c.modified };
|
||
if (Number.isInteger(x.slot)) o.slot = x.slot;
|
||
return o;
|
||
}),
|
||
};
|
||
}
|
||
/* a sound's values (p, the device or file layout: the common parameters, then the engine's 8 from pe0) in another
|
||
layout of n values, as the firmware maps user presets (up_params): new common parameters come just before the
|
||
engine's, so the common ones by position, the engine's 8 by their own place; what the source lacks is null */
|
||
function patchByCount(p, pe0, n) {
|
||
const src = Number.isInteger(pe0) && pe0 >= 0 && pe0 + 8 <= p.length ? pe0 : p.length - 8;
|
||
if (!(n > 8) || src < 0 || (p.length === n && src === n - 8)) return p.slice(0, n);
|
||
const out = new Array(n).fill(null);
|
||
for (let i = 0; i < Math.min(src, n - 8); i++) out[i] = p[i];
|
||
for (let k = 0; k < 8; k++) out[n - 8 + k] = p[src + k] ?? null;
|
||
return out;
|
||
}
|
||
|
||
/* -> {patches, skipped, keys (the file's, for a library that has none yet)}; throws on a file it cannot read */
|
||
function readLibraryFile(obj, ctx) {
|
||
if (!obj || typeof obj !== "object") throw new Error("not JSON");
|
||
const engIndex = (name, idx, fileEngines) => {
|
||
const nm = name || (fileEngines || [])[idx];
|
||
if (ctx.engines && ctx.engines.length) {
|
||
if (nm) return ctx.engines.indexOf(nm);
|
||
return idx < ctx.engines.length ? idx : -1;
|
||
}
|
||
return idx;
|
||
};
|
||
if (obj.format === "felucca-patch") { /* "Save to file": the whole current sound */
|
||
if (!Array.isArray(obj.p) || !Number.isInteger(obj.engine)) throw new Error("felucca-patch without engine / p");
|
||
const e = engIndex(obj.engineName, obj.engine);
|
||
if (e < 0) return { patches: [], skipped: 1, keys: null };
|
||
return { patches: [cleanPatch({ name: obj.presetName || obj.engineName || "PATCH", engine: e, engineName: obj.engineName,
|
||
p: ctx.keys ? patchByCount(obj.p, obj.pE0, ctx.keys.length) : obj.p.slice(), pattern: Array.isArray(obj.steps) ? patternFromSteps(obj.steps) : null, tags: ["file"] })],
|
||
skipped: 0, keys: null };
|
||
}
|
||
if (obj.format !== LIB.FORMAT) throw new Error("unknown format");
|
||
if (!(obj.version >= 1)) throw new Error("version");
|
||
if (!Array.isArray(obj.patches)) throw new Error("no patches");
|
||
const fileKeys = Array.isArray(obj.paramLabels) && obj.paramLabels.length ? obj.paramLabels.map(String) : null;
|
||
const out = [];
|
||
let skipped = 0;
|
||
for (const x of obj.patches) {
|
||
if (!x || !Array.isArray(x.params)) { skipped++; continue; }
|
||
const e = engIndex(x.engineName, x.engine | 0, obj.engines);
|
||
if (e < 0) { skipped++; continue; }
|
||
const p = remapParams(x.params, fileKeys, ctx.keys);
|
||
out.push(cleanPatch({ ...x, engine: e, engineName: (ctx.engines || [])[e] || x.engineName || (obj.engines || [])[x.engine], p }));
|
||
}
|
||
return { patches: out, skipped, keys: fileKeys };
|
||
}
|
||
|
||
/* device side; rq(r, opt) -> reply args (Link.request), info from INFO */
|
||
const FLASH_OPT = { timeout: 2500, retries: 0 };
|
||
const bank = {
|
||
async list(rq) {
|
||
const first = parse[CMD.UP_LIST](await rq(req.upList(0, UP.LIST_MAX)));
|
||
const slots = first.slots.slice();
|
||
while (slots.length < first.total) {
|
||
const r = parse[CMD.UP_LIST](await rq(req.upList(slots.length, Math.min(UP.LIST_MAX, first.total - slots.length))));
|
||
if (!r.count) break;
|
||
slots.push(...r.slots);
|
||
}
|
||
return { total: first.total, slots };
|
||
},
|
||
async get(rq, info, slot) { return parse[CMD.UP_GET](await rq(req.upGet(slot)), info); },
|
||
/* -> rc (0 ok) */
|
||
async put(rq, slot, pt) { return parse[CMD.UP_PUT](await rq(req.upPut(slot, pt), FLASH_OPT)).rc; },
|
||
async store(rq, slot, name) { return parse[CMD.UP_STORE](await rq(req.upStore(slot, name), FLASH_OPT)).rc; },
|
||
async load(rq, slot) { return parse[CMD.UP_LOAD](await rq(req.upLoad(slot), { timeout: 1000 })).rc; },
|
||
async erase(rq, slot) { return parse[CMD.UP_ERASE](await rq(req.upErase(slot), FLASH_OPT)).rc; },
|
||
};
|
||
|
||
/* the current sound: DUMP + the first 16 steps */
|
||
/* ---- v6: the complete backup (projects, sections, user presets, samples, settings) ---- */
|
||
function u35enc(v) { v >>>= 0; return [0, 1, 2, 3, 4].map((k) => Math.floor(v / 2 ** (7 * k)) & 0x7F); }
|
||
function u35dec(r) { let v = 0; for (let k = 0; k < 5; k++) v += r.b() * 2 ** (7 * k); return v >>> 0; }
|
||
const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||
function b64enc(b) {
|
||
let s = "";
|
||
for (let i = 0; i < b.length; i += 3) {
|
||
const n = (b[i] << 16) | ((b[i + 1] || 0) << 8) | (b[i + 2] || 0);
|
||
s += B64[(n >> 18) & 63] + B64[(n >> 12) & 63] + (i + 1 < b.length ? B64[(n >> 6) & 63] : "=") + (i + 2 < b.length ? B64[n & 63] : "=");
|
||
}
|
||
return s;
|
||
}
|
||
function b64dec(s) {
|
||
s = String(s).replace(/[^A-Za-z0-9+/]/g, "");
|
||
const out = new Uint8Array((s.length * 3) >> 2);
|
||
let o = 0, acc = 0, bits = 0;
|
||
for (const c of s) {
|
||
acc = ((acc << 6) | B64.indexOf(c)) & 0xFFFFFF;
|
||
bits += 6;
|
||
if (bits >= 8) { bits -= 8; out[o++] = (acc >> bits) & 255; }
|
||
}
|
||
return out.subarray(0, o);
|
||
}
|
||
/* object ids (firmware editor.c ED_BK_IDS): 0 the working project, 1 the settings, 2..5 projects A..D,
|
||
6..7 the user preset banks, 32..35 the sample slots USR1..4 (35, USR4: SLOOP 2.4) */
|
||
/* RESTORE: the objects in the order they are written back (banks first; 8 = the FM6 patch bank, firmware v9: a
|
||
file without it restores fine, a v8 device gets no object 8 sent; 9 = the SYN drum kits, firmware v10, likewise) */
|
||
const BK = { FORMAT: "sloop-backup", VERSION: 1, SAMPLES: [32, 33, 34, 35], RESTORE: [6, 7, 8, 9, 10, 11, 2, 3, 4, 5, 0, 1] }; /* 10: MIDI LEARN (2.6),
|
||
* 11: your theme (2.7, before the settings: they say whether it is shown) */
|
||
class BackupError extends Error { constructor(code, msg) { super(msg); this.code = code; } }
|
||
/* read everything; progress(done, total bytes) */
|
||
async function backupCapture(rq, info, progress = () => {}) {
|
||
const L = parse[CMD.BK_LIST](await rq(req.bkList(), { timeout: 5000, retries: 0 }));
|
||
if (L.rc) throw new BackupError("bkRc" + L.rc, `LIST rc ${L.rc}`);
|
||
const total = L.items.reduce((s, it) => s + it.len, 0), objects = [];
|
||
let done = 0;
|
||
for (const it of L.items) {
|
||
const data = new Uint8Array(it.len);
|
||
for (let off = 0; off < it.len; off += 256) {
|
||
const n = Math.min(256, it.len - off);
|
||
const g = parse[CMD.BK_GET](await rq(req.bkGet(it.id, off, n), { timeout: 1500, retries: 2 }));
|
||
if (g.rc) throw new BackupError(g.rc === 5 ? "bkStale" : "bkRead", `GET ${it.id}+${off} rc ${g.rc}`);
|
||
if (g.data.length !== n) throw new BackupError("bkRead", `GET ${it.id}+${off}: ${g.data.length} bytes`);
|
||
data.set(g.data, off);
|
||
done += n;
|
||
progress(done, total);
|
||
}
|
||
if (crc32(data) !== it.crc) throw new BackupError("bkStale", `object ${it.id}: CRC`);
|
||
objects.push({ id: it.id, len: it.len, crc: it.crc, data: b64enc(data) });
|
||
}
|
||
return { format: BK.FORMAT, version: BK.VERSION, firmware: info.version, date: new Date().toISOString(), objects };
|
||
}
|
||
/* a backup file -> {id: Uint8Array}; every object checked against its length and CRC */
|
||
function backupObjects(file) {
|
||
if (!file || file.format !== BK.FORMAT || !(file.version >= 1) || !Array.isArray(file.objects)) throw new BackupError("bkBad", "not a SLOOP backup");
|
||
const m = new Map();
|
||
for (const o of file.objects) {
|
||
const d = b64dec(o.data || "");
|
||
if (![...BK.RESTORE, ...BK.SAMPLES].includes(o.id) || d.length !== o.len || crc32(d) !== (o.crc >>> 0))
|
||
throw new BackupError("bkBad", `object ${o.id}: damaged`);
|
||
m.set(o.id, d);
|
||
}
|
||
if (!m.has(0) || !m.has(1)) throw new BackupError("bkBad", "incomplete backup");
|
||
return m;
|
||
}
|
||
/* write it back: banks, projects, the working project, the settings, then the samples */
|
||
/* the project format of a backup object ("FUN6" .. as stored, low byte first: 6 ..), 0 not a project */
|
||
const bkProjFormat = (d) => (d && d.length >= 4 && d[1] === 0x4E && d[2] === 0x55 && d[3] === 0x46 ? d[0] - 0x30 : 0);
|
||
/* the newest project format a device reads, from its INFO: 2.6 (71 parameters) 6, 2.4 .. 2.5 (61) 5, older 4 */
|
||
const bkDevFormat = (info) => (info.pcount >= 71 ? 6 : info.pcount >= 61 ? 5 : 4);
|
||
/* "SLOOP 2.6" -> true when at least maj.min.patch */
|
||
const bkFwAtLeast = (v, want) => {
|
||
const m = /(\d+)\.(\d+)(?:\.(\d+))?/.exec(String(v || ""));
|
||
if (!m) return false;
|
||
const a = [+m[1], +m[2], +(m[3] || 0)];
|
||
for (let i = 0; i < 3; i++) if (a[i] !== want[i]) return a[i] > want[i];
|
||
return true;
|
||
};
|
||
async function backupRestore(rq, file, progress = () => {}) {
|
||
const m = backupObjects(file);
|
||
/* (2.6) projects newer than the device reads (a 2.6 backup into 2.5): stop before anything is written (it stopped at
|
||
the first project, the preset banks already replaced) */
|
||
const info = parse[CMD.INFO](await rq(req.info(), { timeout: 1000, retries: 2 }));
|
||
const newest = Math.max(0, ...[0, 2, 3, 4, 5].filter((id) => m.has(id)).map((id) => bkProjFormat(m.get(id))));
|
||
if (newest > bkDevFormat(info)) throw new BackupError("bkNewer", `${file.firmware || "?"} > ${info.version}`);
|
||
/* (2.6) a backup of a 2.6 FM-1 without object 10 had the MIDI settings at their defaults (nothing learned, channels
|
||
1 2 3, drums 10, OTHER SEL, BEND 2): restored as such, not left as the device has them now */
|
||
if (!m.has(10) && bkFwAtLeast(file.firmware, [2, 5, 1])) {
|
||
const d = new Uint8Array(40);
|
||
d.set([1, 2, 3, 10, 2], 32);
|
||
m.set(10, d);
|
||
}
|
||
const total = [...m.values()].reduce((s, d) => s + d.length, 0) || 1;
|
||
let done = 0;
|
||
for (const id of BK.RESTORE) {
|
||
if (!m.has(id)) continue;
|
||
const d = m.get(id);
|
||
let r = parse[CMD.BK_PUT](await rq(req.bkBegin(id, d.length, crc32(d)), { timeout: 1500, retries: 1 }));
|
||
if ((r.rc === 1 || r.rc === 5) && (id === 8 || id === 9 || id === 10 || id === 11)) continue; /* a device without the FM6 bank (v8) /
|
||
* the SYN kits (v9) / MIDI LEARN (2.6): skipped (its BK_PUT answers
|
||
* an unknown id's begin with 5) */
|
||
if (r.rc) throw new BackupError("bkWrite", `begin ${id} rc ${r.rc}`);
|
||
for (let off = 0; off < d.length; off += 256) {
|
||
r = parse[CMD.BK_PUT](await rq(req.bkData(id, off, d.subarray(off, off + 256)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new BackupError("bkWrite", `data ${id}+${off} rc ${r.rc}`);
|
||
done += Math.min(256, d.length - off);
|
||
progress(done, total);
|
||
}
|
||
r = parse[CMD.BK_PUT](await rq(req.bkCommit(id), { timeout: 5000, retries: 0 }));
|
||
if (r.rc === 3) throw new BackupError("bkStop", "stop the song first");
|
||
if (r.rc) throw new BackupError("bkWrite", `commit ${id} rc ${r.rc}`);
|
||
}
|
||
for (const id of BK.SAMPLES) {
|
||
if (!m.has(id)) continue;
|
||
const d = m.get(id), k = id - 32;
|
||
if (!d.length) {
|
||
const e = parse[CMD.SMP_ERASE](await rq(req.smpErase(k), { timeout: 2500, retries: 0 }));
|
||
if (e.rc) throw new BackupError("bkWrite", `erase USR${k + 1} rc ${e.rc}`);
|
||
continue;
|
||
}
|
||
let r = parse[CMD.SMP_BEGIN](await rq(req.smpBegin(k), { timeout: 1000, retries: 0 }));
|
||
if (r.rc) throw new BackupError("bkWrite", `USR${k + 1} begin rc ${r.rc}`);
|
||
const data = d.subarray(SMP.DATA_OFF);
|
||
for (let off = 0; off < data.length; off += 256) {
|
||
const w = parse[CMD.SMP_WRITE](await rq(req.smpWrite(k, SMP.DATA_OFF + off, data.subarray(off, off + 256)), { timeout: 1000, retries: 1 }));
|
||
if (w.rc) throw new BackupError("bkWrite", `USR${k + 1} write rc ${w.rc}`);
|
||
done += Math.min(256, data.length - off);
|
||
progress(done, total);
|
||
}
|
||
r = parse[CMD.SMP_END](await rq(req.smpEnd(k, d.subarray(0, SMP.HDR_LEN)), { timeout: 2000, retries: 0 }));
|
||
if (r.rc) throw new BackupError("bkWrite", `USR${k + 1} end rc ${r.rc}`);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
/* 2.5 Store cartridge: packed patches into B1..Bn in one write. The bank (backup object 8) is read whole, slots
|
||
0..n-1 replaced, the others kept, and written back whole (BK_PUT, as a restore: one flash write, stopped only).
|
||
-> 0 written, 3 the song plays (nothing changed), "old" a device without object 8 (before v9) */
|
||
async function fm6CartWrite(rq, packs) {
|
||
if (!packs.length || packs.length > FM6.BANK_N) throw new Error(`bank: ${packs.length} voices`);
|
||
const L = parse[CMD.BK_LIST](await rq(req.bkList(), { timeout: 5000, retries: 0 }));
|
||
if (L.rc) throw new Error(`bank: LIST rc ${L.rc}`);
|
||
const it = L.items.find((x) => x.id === 8);
|
||
if (!it) return "old";
|
||
const cur = new Uint8Array(it.len);
|
||
for (let off = 0; off < it.len; off += 256) {
|
||
const nn = Math.min(256, it.len - off);
|
||
const g = parse[CMD.BK_GET](await rq(req.bkGet(8, off, nn), { timeout: 1500, retries: 2 }));
|
||
if (g.rc || g.data.length !== nn) throw new Error(`bank: GET rc ${g.rc}`);
|
||
cur.set(g.data, off);
|
||
}
|
||
const slots = FM6.bankUnobj(cur); /* a bank this page can't read is never overwritten */
|
||
if (!slots) throw new Error("bank: unknown format");
|
||
packs.forEach((pk, i) => { slots[i] = FM6.pack(FM6.unpack(pk)); }); /* every value in range, as fm6_bank_put */
|
||
const d = FM6.bankObj(slots);
|
||
let r = parse[CMD.BK_PUT](await rq(req.bkBegin(8, d.length, crc32(d)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new Error(`bank: begin rc ${r.rc}`);
|
||
for (let off = 0; off < d.length; off += 256) {
|
||
r = parse[CMD.BK_PUT](await rq(req.bkData(8, off, d.subarray(off, off + 256)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new Error(`bank: data rc ${r.rc}`);
|
||
}
|
||
r = parse[CMD.BK_PUT](await rq(req.bkCommit(8), { timeout: 5000, retries: 0 }));
|
||
if (r.rc === 3) return 3;
|
||
if (r.rc) throw new Error(`bank: commit rc ${r.rc}`);
|
||
return 0;
|
||
}
|
||
/* 2.5: a user preset that plays bank slot k (B(k+1)): engine FM6, the voice's name, every value at its default
|
||
(base: P_COUNT values; the macros neutral, so the patch plays as it is), PTCH (P_E7) = F count + k. A user preset
|
||
keeps PTCH, not the patch (a record has no room for 128 bytes): loading it loads B(k+1) */
|
||
function fm6CartPreset(info, base, nf, k, name) {
|
||
const p = Array.from({ length: info.pcount }, (_, i) => base[i] ?? 0);
|
||
p[info.pe0 + 7] = nf + k;
|
||
return { engine: info.engines.indexOf("FM6"), name: upName(name || `FM6 B${k + 1}`), p, pattern: [] };
|
||
}
|
||
/* the preset slots for n voices: from "free" = the first n free ones, from a slot s = s..s+n-1; null: no room */
|
||
function fm6CartSlots(list, n, from) {
|
||
if (from === "free") {
|
||
const f = list.slots.filter((x) => !x.used).map((x) => x.slot);
|
||
return f.length >= n ? f.slice(0, n) : null;
|
||
}
|
||
const s = from | 0;
|
||
return s >= 0 && s + n <= list.total ? Array.from({ length: n }, (_, i) => s + i) : null;
|
||
}
|
||
/* the presets after the bank (fm6CartWrite): one UP_PUT each -> 0, or the first rc (3: the song plays) */
|
||
async function fm6CartPresets(rq, puts) {
|
||
for (const { slot, pt } of puts) {
|
||
const rc = await bank.put(rq, slot, pt);
|
||
if (rc) return rc;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
async function capturePatch(rq, info, name) {
|
||
const dump = parse[CMD.DUMP](await rq(req.dump()), info);
|
||
const steps = [];
|
||
for (let i = 0; i < UP.PAT && i < info.nstep; i++) steps.push(parse[CMD.STEP_GET](await rq(req.stepGet(i))));
|
||
return { patch: cleanPatch({ name, engine: dump.engine, engineName: info.engines[dump.engine], p: dump.p, pattern: patternFromSteps(steps) }), dump, steps };
|
||
}
|
||
|
||
/* what loading a sound leaves alone (firmware ui.c param_kept): the mix (LEVEL, PAN, MUTE), the pattern
|
||
parameters (LEN, DIV, SWG, GATE) and the key the part plays in (ROOT, SCL, QNT; CHORD from SLOOP 2.0); the track FILTER (2.4) */
|
||
const keptIds = (info) => new Set([0, 25, 26, 27, 29, 30, 31, 32, 39, 40, ...(info.pe0 > 49 ? [49] : []), ...(info.pe0 > 50 ? [50] : []), ...(info.pe0 > 52 ? [51, 52] : [])]);
|
||
/* play a patch without writing flash, as UP_LOAD would load it: SET the engine (G_ENGSEL, engine defaults),
|
||
then every parameter of the sound that differs. Never the pattern (LIVE: a sound never changes the
|
||
sequence), the mix or the key. opt: {gEng: G_ENGSEL id, progress(i, n)} -> {wrote: false} */
|
||
async function auditionPatch(rq, info, pt, opt = {}) {
|
||
await rq(req.set(1, opt.gEng ?? 20, pt.engine));
|
||
const dump = parse[CMD.DUMP](await rq(req.dump()), info);
|
||
const n = Math.min(info.pcount, pt.p.length), kept = keptIds(info);
|
||
for (let i = 0; i < n; i++) {
|
||
const v = pt.p[i];
|
||
if (opt.progress) opt.progress(i, n);
|
||
if (v == null || kept.has(i) || v === dump.p[i]) continue;
|
||
await rq(req.set(0, i, v));
|
||
}
|
||
return { wrote: false };
|
||
}
|
||
|
||
/* WATCH on (asking for TRACK_CHANGED too): false when the firmware does not know it (older than protocol v2),
|
||
else 1, or 3 when it also has TRACK_PARAM / TRACK_CHANGED (protocol v4) */
|
||
async function startWatch(rq) {
|
||
try { const on = parse[CMD.WATCH](await rq(req.watch(3), { timeout: 300, retries: 1, quiet: true })).on; return on & 1 ? on & 3 : false; }
|
||
catch (e) { if (e.message === "closed") throw e; return false; }
|
||
}
|
||
|
||
/* ------------------------------------------------------------ mixer (v3) --- */
|
||
/* The TRACKS page in the editor: TRACK (engine, preset, level, mute, armed of all four) and TRACK_DUMP
|
||
of each track for its P_PAN. Level and mute go through TRACK_MIX (any track; the drum level is
|
||
G_DRLVL). Pan: TRACK_PARAM (v4, any track); with v3 firmware a plain SET, which reaches only the
|
||
selected track: another track is selected for it and the selection is put back (TRACK pushes no
|
||
RELOAD). ids: {pan: P_PAN id} */
|
||
const mixer = {
|
||
async read(rq, info, ids) {
|
||
const tr = parse[CMD.TRACK](await rq(req.track()));
|
||
for (let i = 0; i < tr.ntrk; i++) {
|
||
const d = parse[CMD.TRACK_DUMP](await rq(req.trackDump(i)), info);
|
||
tr.tracks[i].pan = ids.pan == null ? null : d.p[ids.pan];
|
||
tr.tracks[i].e0 = d.p[info.pe0]; /* the drum track: its kit */
|
||
}
|
||
return tr;
|
||
},
|
||
/* -> {track, level, mute} as the device has them now */
|
||
async setMix(rq, track, level, mute, opt) { return parse[CMD.TRACK_MIX](await rq(req.trackMix(track, level, mute), opt)); },
|
||
/* -> the pan value after clamping. v4: TRACK_PARAM, the selection stays */
|
||
async setPan(rq, track, sel, panId, v, v4) {
|
||
if (v4) return parse[CMD.TRACK_PARAM](await rq(req.trackParam(track, panId, v), { key: "pan:" + track })).value;
|
||
if (track === sel) return parse[CMD.SET](await rq(req.set(0, panId, v))).value;
|
||
await rq(req.track(track));
|
||
try { return parse[CMD.SET](await rq(req.set(0, panId, v))).value; }
|
||
finally { await rq(req.track(sel)).catch(() => {}); }
|
||
},
|
||
};
|
||
|
||
/* ---- (2.7) a song as one file: the loop playing (object 0), the sections A..D (2..5; an empty one is not in the
|
||
file) and their order on the SONG screen (the 36 bytes of the settings at 48, arranger.h arr_config_t). Loaded
|
||
onto an FM-1 (stopped: the commits answer 3 while it plays) every section is written, an empty one as 0 bytes, then
|
||
the loop, then the order into the device's own settings (its colours, calibration... kept). The LIVE page's
|
||
playlist is a list of these files */
|
||
const SONGF = { FORMAT: "sloop-song", VERSION: 1, SECS: [2, 3, 4, 5], ORDER_OFF: 48, ORDER_LEN: 36, PER3: 0x50455233 };
|
||
const songOrderOk = (b) => !!b && b.length >= SONGF.ORDER_OFF + SONGF.ORDER_LEN && ((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0) === SONGF.PER3;
|
||
/* one object, read whole after a LIST (the LIST's item: {id, len, crc}) */
|
||
async function bkReadObj(rq, it) {
|
||
const data = new Uint8Array(it.len);
|
||
for (let off = 0; off < it.len; off += 256) {
|
||
const n = Math.min(256, it.len - off);
|
||
const g = parse[CMD.BK_GET](await rq(req.bkGet(it.id, off, n), { timeout: 1500, retries: 2 }));
|
||
if (g.rc) throw new BackupError(g.rc === 5 ? "bkStale" : "bkRead", `GET ${it.id}+${off} rc ${g.rc}`);
|
||
if (g.data.length !== n) throw new BackupError("bkRead", `GET ${it.id}+${off}: ${g.data.length} bytes`);
|
||
data.set(g.data, off);
|
||
}
|
||
if (crc32(data) !== it.crc) throw new BackupError("bkStale", `object ${it.id}: CRC`);
|
||
return data;
|
||
}
|
||
/* one object written (0 bytes: an empty section) -> rc 0, or throws (bkStop: the song plays) */
|
||
async function bkWriteObj(rq, id, d, progress = () => {}) {
|
||
let r = parse[CMD.BK_PUT](await rq(req.bkBegin(id, d.length, crc32(d)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new BackupError("bkWrite", `begin ${id} rc ${r.rc}`);
|
||
for (let off = 0; off < d.length; off += 256) {
|
||
r = parse[CMD.BK_PUT](await rq(req.bkData(id, off, d.subarray(off, off + 256)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new BackupError("bkWrite", `data ${id}+${off} rc ${r.rc}`);
|
||
progress(Math.min(256, d.length - off));
|
||
}
|
||
r = parse[CMD.BK_PUT](await rq(req.bkCommit(id), { timeout: 5000, retries: 0 }));
|
||
if (r.rc === 3) throw new BackupError("bkStop", "stop the song first");
|
||
if (r.rc) throw new BackupError("bkWrite", `commit ${id} rc ${r.rc}`);
|
||
}
|
||
async function songCapture(rq, info, name, progress = () => {}) {
|
||
const L = parse[CMD.BK_LIST](await rq(req.bkList(), { timeout: 5000, retries: 0 }));
|
||
if (L.rc) throw new BackupError("bkRc" + L.rc, `LIST rc ${L.rc}`);
|
||
const items = L.items.filter((it) => it.id === 0 || it.id === 1 || (SONGF.SECS.includes(it.id) && it.len));
|
||
const total = items.reduce((s, it) => s + it.len, 0) || 1, objects = [];
|
||
let done = 0, order = null;
|
||
for (const it of items) {
|
||
const d = await bkReadObj(rq, it);
|
||
done += it.len;
|
||
progress(done, total);
|
||
if (it.id === 1) { if (songOrderOk(d)) order = d.slice(SONGF.ORDER_OFF, SONGF.ORDER_OFF + SONGF.ORDER_LEN); continue; }
|
||
objects.push({ id: it.id, len: it.len, crc: it.crc, data: b64enc(d) });
|
||
}
|
||
return { format: SONGF.FORMAT, version: SONGF.VERSION, name: String(name || "").slice(0, 40), firmware: info.version,
|
||
date: new Date().toISOString(), order: order ? b64enc(order) : null, objects };
|
||
}
|
||
/* a song file -> {objects: Map id -> bytes, order: bytes or null}; every object checked against its length and CRC */
|
||
function songObjects(file) {
|
||
if (!file || file.format !== SONGF.FORMAT || !(file.version >= 1) || !Array.isArray(file.objects)) throw new BackupError("songBadFile", "not a SLOOP song");
|
||
const m = new Map();
|
||
for (const o of file.objects) {
|
||
const d = b64dec(o.data || "");
|
||
if (!(o.id === 0 || SONGF.SECS.includes(o.id)) || d.length !== o.len || crc32(d) !== (o.crc >>> 0))
|
||
throw new BackupError("songBadFile", `object ${o.id}: damaged`);
|
||
m.set(o.id, d);
|
||
}
|
||
if (!m.has(0)) throw new BackupError("songBadFile", "no loop");
|
||
const order = file.order ? b64dec(file.order) : null;
|
||
if (order && order.length !== SONGF.ORDER_LEN) throw new BackupError("songBadFile", "order");
|
||
return { objects: m, order };
|
||
}
|
||
/* onto the FM-1 (stopped); progress(done, total bytes) */
|
||
async function songLoad(rq, file, progress = () => {}) {
|
||
const { objects: m, order } = songObjects(file);
|
||
const info = parse[CMD.INFO](await rq(req.info(), { timeout: 1000, retries: 2 }));
|
||
const newest = Math.max(0, ...[...m.values()].map(bkProjFormat));
|
||
if (newest > bkDevFormat(info)) throw new BackupError("bkNewer", `${file.firmware || "?"} > ${info.version}`);
|
||
const total = [...m.values()].reduce((s, d) => s + d.length, 0) || 1;
|
||
let done = 0;
|
||
const step = (n) => { done += n; progress(done, total); };
|
||
for (const id of SONGF.SECS) await bkWriteObj(rq, id, m.get(id) || new Uint8Array(0), step);
|
||
await bkWriteObj(rq, 0, m.get(0), step);
|
||
if (order) { /* the order, into the settings as the FM-1 has them */
|
||
const L = parse[CMD.BK_LIST](await rq(req.bkList(), { timeout: 5000, retries: 0 }));
|
||
const it = L.rc ? null : L.items.find((x) => x.id === 1);
|
||
if (!it) throw new BackupError("bkRead", `LIST rc ${L.rc}`);
|
||
const s = await bkReadObj(rq, it);
|
||
if (songOrderOk(s)) { s.set(order, SONGF.ORDER_OFF); await bkWriteObj(rq, 1, s); }
|
||
}
|
||
return true;
|
||
}
|
||
|
||
/* ------------------------------------------------------------ mock device --- */
|
||
/* Implements the protocol like firmware/src/editor.c, with tables copied from params.c
|
||
and the engine sources. Used with ?mock=1 (add &legacy=1 for a firmware without cmds 16..26).
|
||
opt: {legacy: no user bank / WATCH, v3: no TRACK_PARAM / TRACK_CHANGED (firmware 0.8),
|
||
auto: false = no simulated knobs (tests drive sim.*),
|
||
watchMs: how long WATCH lasts after the last request (3000), slots: user bank size (32)} */
|
||
/* ------------------------------------------------------------------- FM6 --- */
|
||
/* The FM6 engine's patches (eng_fm6.c, EDITOR_PROTOCOL.md "FM6 patches", firmware v9): the generic 6-operator voice.
|
||
voice: 155 bytes, 6 x 21 operator bytes (the sixth operator first, as the format has them), then 19 voice bytes
|
||
and a 10-character name. packed: the 128-byte record of a 32-voice bank (every byte 7-bit). SysEx files: a
|
||
single voice (F0 43 0n 00 01 1B, 155 bytes, checksum, F7: 163 bytes) or 32 packed voices (F0 43 0n 09 20 00,
|
||
4096 bytes, checksum, F7: 4104 bytes); raw 155 / 128 / 4096-byte files are read too, and damaged ones as far
|
||
as they go (parseSysex). */
|
||
const FM6 = (() => {
|
||
/* per operator byte: name, highest value; then the voice bytes */
|
||
const OP = [["R1", 99], ["R2", 99], ["R3", 99], ["R4", 99], ["L1", 99], ["L2", 99], ["L3", 99], ["L4", 99],
|
||
["BP", 99], ["LD", 99], ["RD", 99], ["LC", 3], ["RC", 3], ["RS", 7], ["AMS", 3], ["KVS", 7], ["OL", 99],
|
||
["MODE", 1], ["FC", 31], ["FF", 99], ["DET", 14]];
|
||
const VOICE = [["PR1", 99], ["PR2", 99], ["PR3", 99], ["PR4", 99], ["PL1", 99], ["PL2", 99], ["PL3", 99], ["PL4", 99],
|
||
["ALG", 31], ["FB", 7], ["OKS", 1], ["LFS", 99], ["LFD", 99], ["LPMD", 99], ["LAMD", 99], ["LKS", 1], ["LFW", 5],
|
||
["LPMS", 7], ["TRNSP", 48]];
|
||
const OPI = Object.fromEntries(OP.map(([n], i) => [n, i])), VI = Object.fromEntries(VOICE.map(([n], i) => [n, 126 + i]));
|
||
const NAME = 145, SIZE = 155, PACKED = 128;
|
||
const max = (i) => (i < 126 ? OP[i % 21][1] : i < NAME ? VOICE[i - 126][1] : 126);
|
||
/* byte i of operator n (1..6) */
|
||
const at = (n, field) => (6 - n) * 21 + OPI[field];
|
||
function sanitize(v) {
|
||
const o = Uint8Array.from(v.slice(0, SIZE));
|
||
for (let i = 0; i < SIZE; i++) o[i] = i >= NAME ? (o[i] < 32 || o[i] > 126 ? 32 : o[i]) : Math.min(o[i], max(i));
|
||
return o;
|
||
}
|
||
function unpack(b) { /* eng_fm6.c fm6_unpack */
|
||
const v = new Uint8Array(SIZE);
|
||
for (let k = 0; k < 6; k++) {
|
||
const o = k * 17, d = k * 21;
|
||
for (let i = 0; i < 11; i++) v[d + i] = b[o + i] & 127;
|
||
v[d + 11] = b[o + 11] & 3; v[d + 12] = b[o + 11] >> 2 & 3; v[d + 13] = b[o + 12] & 7; v[d + 20] = b[o + 12] >> 3 & 15;
|
||
v[d + 14] = b[o + 13] & 3; v[d + 15] = b[o + 13] >> 2 & 7; v[d + 16] = b[o + 14] & 127; v[d + 17] = b[o + 15] & 1;
|
||
v[d + 18] = b[o + 15] >> 1 & 31; v[d + 19] = b[o + 16] & 127;
|
||
}
|
||
for (let i = 0; i < 9; i++) v[126 + i] = b[102 + i] & 127;
|
||
v[134] &= 31; v[135] = b[111] & 7; v[136] = b[111] >> 3 & 1;
|
||
for (let i = 0; i < 4; i++) v[137 + i] = b[112 + i] & 127;
|
||
v[141] = b[116] & 1; v[142] = b[116] >> 1 & 7; v[143] = b[116] >> 4 & 7; v[144] = b[117] & 127;
|
||
for (let i = 0; i < 10; i++) v[NAME + i] = b[118 + i] & 127;
|
||
return sanitize(v);
|
||
}
|
||
function pack(v) { /* eng_fm6.c fm6_pack */
|
||
const b = new Array(PACKED).fill(0);
|
||
for (let k = 0; k < 6; k++) {
|
||
const o = k * 17, d = k * 21;
|
||
for (let i = 0; i < 11; i++) b[o + i] = v[d + i] & 127;
|
||
b[o + 11] = (v[d + 11] & 3) | (v[d + 12] & 3) << 2; b[o + 12] = (v[d + 13] & 7) | (v[d + 20] & 15) << 3;
|
||
b[o + 13] = (v[d + 14] & 3) | (v[d + 15] & 7) << 2; b[o + 14] = v[d + 16] & 127;
|
||
b[o + 15] = (v[d + 17] & 1) | (v[d + 18] & 31) << 1; b[o + 16] = v[d + 19] & 127;
|
||
}
|
||
for (let i = 0; i < 9; i++) b[102 + i] = v[126 + i] & 127;
|
||
b[110] &= 31; b[111] = (v[135] & 7) | (v[136] & 1) << 3;
|
||
for (let i = 0; i < 4; i++) b[112 + i] = v[137 + i] & 127;
|
||
b[116] = (v[141] & 1) | (v[142] & 7) << 1 | (v[143] & 7) << 4; b[117] = v[144] & 127;
|
||
for (let i = 0; i < 10; i++) b[118 + i] = v[NAME + i] & 127;
|
||
return b;
|
||
}
|
||
const name = (v) => String.fromCharCode(...v.slice(NAME, NAME + 10)).replace(/\s+$/, "");
|
||
function setName(v, s) {
|
||
const t = String(s).toUpperCase().replace(/[^\x20-\x7E]/g, " ").slice(0, 10).padEnd(10, " ");
|
||
for (let i = 0; i < 10; i++) v[NAME + i] = t.charCodeAt(i);
|
||
return v;
|
||
}
|
||
const checksum = (a) => (128 - (a.reduce((s, x) => s + x, 0) & 127)) & 127;
|
||
/* every voice in a file's bytes: [{name, v}] (after Felucca 1.0.3's editor: files cut short, banks with a bad
|
||
checksum, several banks or voices in one file, raw 4096-byte banks one after another are read); badSum: messages
|
||
whose checksum did not match (still read), short: messages cut short (their whole voices read), skipped / kinds:
|
||
the SysEx that were not 6-operator voices (4-op, another maker, universal...), sysex: the file held any */
|
||
function parseSysex(bytes) {
|
||
const d = Uint8Array.from(bytes), voices = [], kinds = [];
|
||
let badSum = 0, short = 0, skipped = 0;
|
||
const add = (v) => voices.push({ v, name: name(v) });
|
||
const kind = (k) => { skipped++; if (!kinds.includes(k)) kinds.push(k); };
|
||
const sysex = d.includes(0xF0);
|
||
if (d[0] !== 0xF0 && !sysex) { /* raw data: banks of 4096, one voice of 155 or packed 128 */
|
||
if (d.length && d.length % 4096 === 0) {
|
||
for (let o = 0; o < d.length; o += 128) add(unpack(d.subarray(o, o + 128)));
|
||
} else if (d.length === SIZE) add(sanitize(d));
|
||
else if (d.length === PACKED) add(unpack(d));
|
||
return { voices, badSum, short, skipped, kinds, sysex };
|
||
}
|
||
for (let i = 0; i < d.length; i++) {
|
||
if (d[i] !== 0xF0) continue;
|
||
const id = d[i + 1], st = d[i + 2], f = d[i + 3];
|
||
if (id === 0x43 && st !== undefined && (st & 0xF0) === 0 && (f === 0 || f === 9) && i + 6 <= d.length) {
|
||
const want = f === 0 ? SIZE : 4096, s0 = i + 6;
|
||
let e = s0;
|
||
while (e < d.length && e < s0 + want && d[e] < 0x80) e++;
|
||
const data = d.subarray(s0, e);
|
||
if (data.length < want) short++;
|
||
else if (e < d.length && d[e] < 0x80 && checksum(data) !== d[e]) badSum++;
|
||
if (f === 0) {
|
||
if (data.length >= NAME) { const v = new Uint8Array(SIZE); v.set(data); add(sanitize(v)); }
|
||
} else {
|
||
for (let o = 0; o + 118 <= data.length; o += 128) { /* whole voices, and one cut in its name (at 118) */
|
||
const pk = new Uint8Array(128); pk.set(data.subarray(o, o + 128)); add(unpack(pk));
|
||
}
|
||
}
|
||
i = e - 1; /* on to the next F0 (the checksum, F7, junk are passed over) */
|
||
continue;
|
||
}
|
||
if (id === 0x43) kind(f === 3 || f === 4 ? "fm4" : "other43");
|
||
else if (id === 0x7E || id === 0x7F) kind("universal");
|
||
else if (id !== undefined && id < 0x80) kind("maker:" + (id === 0 ? [0, d[i + 2], d[i + 3]] : [id])
|
||
.map((x) => (x ?? 0).toString(16).toUpperCase().padStart(2, "0")).join(" "));
|
||
}
|
||
return { voices, badSum, short, skipped, kinds, sysex };
|
||
}
|
||
function singleSysex(v, ch = 0) {
|
||
const data = Array.from(sanitize(v));
|
||
return Uint8Array.from([0xF0, 0x43, ch & 15, 0, 0x01, 0x1B, ...data, checksum(data), 0xF7]);
|
||
}
|
||
function bankSysex(voices, ch = 0) { /* up to 32 voices (155 bytes each), the rest the init voice */
|
||
const data = [];
|
||
for (let k = 0; k < 32; k++) data.push(...(voices[k] ? pack(voices[k]) : INIT_PK));
|
||
return Uint8Array.from([0xF0, 0x43, ch & 15, 9, 0x20, 0, ...data, checksum(data), 0xF7]);
|
||
}
|
||
/* the 32 algorithms (msfa's tables; fm6_core.c FM6_ALG): per operator, the sixth first */
|
||
const ALG = [[0xc1, 0x11, 0x11, 0x14, 0x01, 0x14], [0x01, 0x11, 0x11, 0x14, 0xc1, 0x14], [0xc1, 0x11, 0x14, 0x01, 0x11, 0x14],
|
||
[0xc1, 0x11, 0x94, 0x01, 0x11, 0x14], [0xc1, 0x14, 0x01, 0x14, 0x01, 0x14], [0xc1, 0x94, 0x01, 0x14, 0x01, 0x14],
|
||
[0xc1, 0x11, 0x05, 0x14, 0x01, 0x14], [0x01, 0x11, 0xc5, 0x14, 0x01, 0x14], [0x01, 0x11, 0x05, 0x14, 0xc1, 0x14],
|
||
[0x01, 0x05, 0x14, 0xc1, 0x11, 0x14], [0xc1, 0x05, 0x14, 0x01, 0x11, 0x14], [0x01, 0x05, 0x05, 0x14, 0xc1, 0x14],
|
||
[0xc1, 0x05, 0x05, 0x14, 0x01, 0x14], [0xc1, 0x05, 0x11, 0x14, 0x01, 0x14], [0x01, 0x05, 0x11, 0x14, 0xc1, 0x14],
|
||
[0xc1, 0x11, 0x02, 0x25, 0x05, 0x14], [0x01, 0x11, 0x02, 0x25, 0xc5, 0x14], [0x01, 0x11, 0x11, 0xc5, 0x05, 0x14],
|
||
[0xc1, 0x14, 0x14, 0x01, 0x11, 0x14], [0x01, 0x05, 0x14, 0xc1, 0x14, 0x14], [0x01, 0x14, 0x14, 0xc1, 0x14, 0x14],
|
||
[0xc1, 0x14, 0x14, 0x14, 0x01, 0x14], [0xc1, 0x14, 0x14, 0x01, 0x14, 0x04], [0xc1, 0x14, 0x14, 0x14, 0x04, 0x04],
|
||
[0xc1, 0x14, 0x14, 0x04, 0x04, 0x04], [0xc1, 0x05, 0x14, 0x01, 0x14, 0x04], [0x01, 0x05, 0x14, 0xc1, 0x14, 0x04],
|
||
[0x04, 0xc1, 0x11, 0x14, 0x01, 0x14], [0xc1, 0x14, 0x01, 0x14, 0x04, 0x04], [0x04, 0xc1, 0x11, 0x14, 0x04, 0x04],
|
||
[0xc1, 0x14, 0x04, 0x04, 0x04, 0x04], [0xc4, 0x04, 0x04, 0x04, 0x04, 0x04]];
|
||
/* operators 1..6 that are carriers (on the output bus), and the one with the feedback, of algorithm a (0..31) */
|
||
const carriers = (a) => [1, 2, 3, 4, 5, 6].filter((n) => !(ALG[a & 31][6 - n] & 3));
|
||
const feedbackOp = (a) => [1, 2, 3, 4, 5, 6].find((n) => (ALG[a & 31][6 - n] & 0xc0) === 0xc0);
|
||
/* an operator's frequency as text: x ratio, or Hz for a fixed one (msfa note osc_freq) */
|
||
function freqText(v, n) {
|
||
const fc = v[at(n, "FC")], ff = v[at(n, "FF")];
|
||
if (v[at(n, "MODE")]) return (10 ** ((fc & 3) + ff / 100)).toPrecision(4) + " Hz";
|
||
return "x" + ((fc ? fc : 0.5) * (1 + ff / 100)).toFixed(2);
|
||
}
|
||
const INIT_PK = [99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,99,2,0,99,99,99,99,50,50,50,50,0,8,35,0,0,0,49,24,73,78,73,84,32,86,79,73,67,69];
|
||
const FACTORY_PK = [
|
||
[95,40,30,60,99,80,0,0,39,0,0,0,56,12,52,2,0,95,30,20,60,99,90,0,0,39,0,0,0,48,4,78,2,0,97,62,40,60,99,60,0,0,39,0,0,0,59,24,68,28,0,95,20,20,50,99,95,0,0,39,0,0,0,66,8,90,2,0,95,50,35,78,99,75,0,0,39,0,0,0,59,28,58,2,0,96,25,25,67,99,75,0,0,39,0,0,0,59,8,98,2,0,99,99,99,99,50,50,50,50,4,11,34,33,0,0,41,24,84,73,78,69,32,69,80,32,32,32], /* TINE EP */
|
||
[99,60,40,45,99,50,0,0,39,0,0,0,56,0,60,2,0,99,60,40,45,99,50,0,0,39,0,0,0,40,0,78,10,40,99,50,30,40,99,60,0,0,39,0,0,0,56,12,70,10,0,99,45,30,40,99,70,0,0,39,0,0,0,72,4,84,4,38,99,35,25,35,99,70,0,0,39,0,0,0,56,12,78,6,50,99,40,25,35,99,80,0,0,39,0,0,0,56,4,96,2,0,99,99,99,99,50,50,50,50,4,8,35,0,0,0,1,24,71,76,65,83,83,32,66,69,76,76], /* BELL */
|
||
[99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,72,50,75,99,65,40,0,39,0,0,0,56,24,78,4,0,99,55,40,75,99,70,50,0,39,0,0,0,64,4,80,2,0,99,60,40,75,99,72,55,0,39,0,0,0,56,20,80,2,0,99,40,30,75,99,85,70,0,39,0,0,0,56,8,99,2,0,99,99,99,99,50,50,50,50,4,8,35,0,0,0,1,24,82,79,85,78,68,32,66,65,83,83], /* FM BASS */
|
||
[52,50,40,60,99,85,82,0,39,0,0,0,56,8,72,2,0,62,50,40,60,99,92,90,0,39,0,0,0,40,4,88,2,0,50,50,40,60,99,88,85,0,39,0,0,0,56,12,78,2,0,62,50,40,60,99,92,90,0,39,0,0,0,72,4,92,2,0,55,50,40,60,99,88,85,0,39,0,0,0,56,12,80,2,0,65,50,40,60,99,92,90,0,39,0,0,0,56,4,98,2,0,80,60,99,60,46,50,50,50,4,13,33,50,6,0,57,24,66,82,65,83,83,32,83,69,67,84], /* BRASS */
|
||
[35,30,40,40,85,90,85,0,39,0,0,0,56,0,50,2,0,38,30,40,40,99,95,90,0,39,0,0,0,56,0,80,4,0,30,25,40,40,80,90,85,0,39,0,0,0,56,4,55,4,0,40,30,40,40,99,95,90,0,39,0,0,0,80,0,92,2,0,35,30,40,40,85,90,80,0,39,0,0,0,56,4,60,2,0,40,30,40,40,99,95,90,0,39,0,0,0,40,0,92,2,0,99,99,99,99,50,50,50,50,4,10,30,60,4,0,41,24,83,79,70,84,32,80,65,68,32,32], /* PAD */
|
||
[99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,80,50,60,99,0,0,0,39,0,0,0,59,12,45,2,0,99,70,50,60,99,0,0,0,39,0,0,0,59,12,72,8,0,99,75,50,60,99,0,0,0,39,0,0,0,59,20,70,8,0,99,52,40,55,99,0,0,0,39,0,0,0,58,8,99,2,0,99,99,99,99,50,50,50,50,4,8,35,0,0,0,1,24,87,79,79,68,32,66,65,82,83,32], /* MARIMBA */
|
||
[99,99,99,85,99,99,99,0,39,0,0,0,56,0,72,2,50,99,99,99,85,99,99,99,0,39,0,0,0,56,0,78,8,0,99,99,99,85,99,99,99,0,39,0,0,0,56,0,76,6,0,99,99,99,85,99,99,99,0,39,0,0,0,56,0,86,4,0,99,99,99,85,99,99,99,0,39,0,0,0,56,0,84,0,0,99,99,99,85,99,99,99,0,39,0,0,0,56,0,90,2,0,99,99,99,99,50,50,50,50,31,8,60,0,3,0,57,24,68,82,65,87,66,65,82,83,32,32], /* ORGAN */
|
||
[99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,99,99,99,99,99,99,0,39,0,0,0,56,0,0,2,0,99,75,40,60,99,30,0,0,39,0,0,0,58,12,68,2,0,99,60,40,60,99,30,0,0,39,0,0,0,66,8,74,4,0,99,70,40,60,99,40,0,0,39,0,0,0,58,16,76,6,0,99,45,30,60,99,60,0,0,39,0,0,0,58,8,98,2,0,99,99,99,99,50,50,50,50,4,8,35,0,0,0,1,24,78,89,76,79,78,32,80,73,67,75], /* PLUCK */
|
||
];
|
||
/* backup object 8, the PTCH bank as the firmware stores it (fm6_bank.c fm6_bank_t, 3472 bytes): "FM6B", version 1,
|
||
27 slots, the used bits, 4 reserved, then 27 packed records (an empty slot: zeros). slots: [packed 128 | null] */
|
||
function bankObj(slots) {
|
||
const o = new Uint8Array(16 + 27 * PACKED);
|
||
let used = 0;
|
||
o.set([0x46, 0x4D, 0x36, 0x42, 1, 0, 27, 0]);
|
||
for (let k = 0; k < 27; k++) if (slots[k]) { o.set(Array.from(slots[k], (x) => x & 0x7F), 16 + k * PACKED); used |= 1 << k; }
|
||
o.set([used & 255, (used >> 8) & 255, (used >> 16) & 255, (used >>> 24) & 255], 8);
|
||
return o;
|
||
}
|
||
/* bytes -> [packed | null] x 27; an empty object (length 0): all empty; anything else: null (not a bank) */
|
||
function bankUnobj(b) {
|
||
if (!b || !b.length) return new Array(27).fill(null);
|
||
if (b.length !== 16 + 27 * PACKED || b[0] !== 0x46 || b[1] !== 0x4D || b[2] !== 0x36 || b[3] !== 0x42 || b[4] !== 1 || b[6] !== 27) return null;
|
||
const used = (b[8] | (b[9] << 8) | (b[10] << 16) | (b[11] << 24)) >>> 0;
|
||
if (used >>> 27 || b.subarray(16).some((x) => x > 127)) return null;
|
||
return Array.from({ length: 27 }, (_, k) => ((used >> k) & 1 ? b.slice(16 + k * PACKED, 16 + (k + 1) * PACKED) : null));
|
||
}
|
||
const init = () => unpack(INIT_PK);
|
||
const factory = (k) => unpack(FACTORY_PK[k]);
|
||
return { OP, VOICE, OPI, VI, NAME, SIZE, PACKED, max, at, sanitize, unpack, pack, name, setName, checksum, parseSysex,
|
||
singleSysex, bankSysex, ALG, carriers, feedbackOp, freqText, INIT_PK, FACTORY_PK, init, factory, bankObj, bankUnobj,
|
||
TARGET: { TRACK: 0, BANK: 1, FACTORY: 2 }, BANK_N: 27 };
|
||
})();
|
||
|
||
/* the mock's settings object: "PER3", the rest opaque, the song order A B C D, 4 bars each (arranger.h arr_defaults) */
|
||
function mockSettings() {
|
||
const b = Uint8Array.from({ length: 88 }, (_, i) => (i * 37 + 5) & 0xFF);
|
||
b.set([0x33, 0x52, 0x45, 0x50]);
|
||
return ARR.encode(b, { loop: false, entries: [0, 1, 2, 3].map((scene) => ({ scene, bars: 4 })) });
|
||
}
|
||
/* backup object 10 at its default: nothing learned, CH1-3 = 1 2 3, drums 10, OTHER SEL, BEND 2 (a 32 / 36-byte one: the
|
||
map, the map and the channels) */
|
||
const mlDefault = (b) => b.every((x, i) => i < 32 ? !x : i === 32 ? x === 1 : i === 33 ? x === 2 : i === 34 ? x === 3 : i === 35 ? x === 10 : i === 36 ? x === 2 : !x);
|
||
function makeMockDevice(opt = {}) {
|
||
const NONOFF = ["OFF", "ON"], NDIV = ["1/4", "1/8", "1/16", "1/32", "8T", "16T"], NGO = ["--", "GO"], NDASH = ["--"];
|
||
const NSDIV = [...NDIV, "1/2", "1BAR", "2BAR"], NDLY = [...NDIV, "1/8D", "1/16D", "1/4D"]; /* SLOOP 2.4: long steps, dotted delays */
|
||
const D = (label, fmt, min, max, def, names = null, unit = "") => ({ label, fmt, min, max, def, names, unit });
|
||
const E = (label, names, def) => D(label, F.ENUM, 0, names.length - 1, def, names);
|
||
const TP = [
|
||
D("LVL", F.DB, 0, 127, 104),
|
||
D("ATK", F.TIME, 0, 127, 10), D("DEC", F.TIME, 0, 127, 70), D("SUS", F.PCT, 0, 127, 90), D("REL", F.TIME, 0, 127, 60),
|
||
D("FLT", F.BIPCT, -64, 63, 0), D("PIT", F.BIPCT, -64, 63, 0), D("SHP", F.BIPCT, -64, 63, 0), D("FX", F.BIPCT, -64, 63, 0),
|
||
D("RATE", F.LFOHZ, 0, 127, 60), E("WAVE", ["SIN", "TRI", "SAW", "SQR", "S&H"], 0), D("PHS", F.INT, 0, 127, 0), D("FADE", F.TIME, 0, 127, 0),
|
||
D("PIT", F.BIPCT, -64, 63, 0), D("FLT", F.BIPCT, -64, 63, 0), D("SHP", F.BIPCT, -64, 63, 0), D("AMP", F.PCT, 0, 127, 0),
|
||
E("MODE", ["OFF", "UP", "DN", "UPDN", "RND", "ORD", "REPEAT", "DNUP", "UP+8", "CONV", "DIVG", "PINKY", "THUMB", "WALK", "CHORD"], 0), E("RATE", NDIV, 2), D("OCT", F.INT, 1, 4, 1), D("GATE", F.PCT, 1, 127, 64),
|
||
D("SWG", F.SWING, 0, 100, 0), D("PROB", F.PCT, 0, 127, 127), E("HOLD", NONOFF, 0), E("ORD", ["NOTE", "PLAY"], 0),
|
||
D("ROOT", F.NOTE, 0, 11, 0), E("SCL", ["CHR", "MAJ", "MIN", "DOR", "MIX", "PEN", "MPEN", "HARM", "PHRY", "LYD", "LOC", "MEL", "BLUES", "WHOLE", "DIMHW", "DIMWH"], 0), E("QNT", ["OFF", "SNAP", "WHITE"], 0), D("TRN", F.SEMI, -24, 24, 0),
|
||
D("LEN", F.STEPS, 1, 64, 16), E("DIV", NSDIV, 2), D("SWG", F.SWING, 0, 100, 0), D("GATE", F.PCT, 1, 127, 64),
|
||
D("DST", F.PCT, 0, 127, 0), D("CHO", F.PCT, 0, 127, 0), D("DLY", F.PCT, 0, 127, 0), D("REV", F.PCT, 0, 127, 0),
|
||
E("VCE", ["POLY", "MONO", "LEG", "UNI"], 0), D("GLD", F.TIME, 0, 127, 0), D("PAN", F.BIPCT, -64, 63, 0), E("MUTE", NONOFF, 0),
|
||
E("GLMOD", ["RATE", "TIME"], 0), E("PRIO", ["LAST", "LOW", "HIGH"], 0), E("ALLOC", ["ROT", "REUSE"], 0), D("DTUNE", F.INT, 0, 127, 40),
|
||
E("SLCR", ["OFF", "GATE", "STUT"], 0), D("PAT", F.INT, 1, 16, 1), E("RATE", ["1/8", "1/16", "1/32", "8T", "16T", "32T"], 1), D("DEPTH", F.PCT, 0, 127, 127),
|
||
E("CHORD", ["OFF", "TRIAD", "7TH", "9TH", "SUS4", "POWER"], 0),
|
||
D("FILT", F.FILT, -64, 63, 0), D("STRUM", F.INT, -60, 60, 0), E("VLEAD", NONOFF, 0),
|
||
/* SLOOP 2.6 (after Felucca 1.4 / 1.5): INSERT, ANALOG's filter TYPE, ENV SYNC, LFO 2 */
|
||
E("INSRT", ["OFF", "SOFT", "HARD", "FOLD", "FUZZ", "CRUSH", "PHASR", "FLANG", "CHOR"], 0),
|
||
D("INS A", F.PCT, 0, 127, 64), D("INS B", F.PCT, 0, 127, 96), D("INS C", F.PCT, 0, 127, 96), D("MIX", F.PCT, 0, 127, 127),
|
||
E("TYPE", ["LP", "BP", "HP"], 0), E("ESYNC", NONOFF, 0),
|
||
E("SYNC", ["OFF", "4BAR", "2BAR", "1BAR", "1/2", "1/4", "1/8", "8T", "1/16", "16T", "1/32"], 0),
|
||
E("TRIG", ["NOTE", "FREE"], 0), E("POL", ["BI", "UNI"], 0),
|
||
];
|
||
const GP = [
|
||
D("BPM", F.BPM, 40, 240, 90), D("SWING", F.SWING, 0, 100, 0), E("CLICK", ["OFF", "REC", "ON"], 0), D("TUNE", F.INT, -50, 50, 0),
|
||
E("TIME", NDLY, 1), D("FDBK", F.PCT, 0, 120, 60), D("COLR", F.PCT, 0, 127, 70), D("MIX", F.PCT, 0, 127, 90),
|
||
D("SIZE", F.PCT, 0, 127, 90), D("DAMP", F.PCT, 0, 127, 60), D("CRT", F.LFOHZ, 0, 127, 40), D("CDP", F.PCT, 0, 127, 60),
|
||
E("OUT", ["KEYS", "SEQ"], 0), E("SYNC", ["INT", "USB", "TRS"], 0), E("IN", ["NOTES", "CLOCK", ...Array.from({ length: 16 }, (_, k) => `CH ${k + 1}`)], 0), D("CPU", F.INT, 0, 0, 0),
|
||
D("SECT", F.INT, 1, 4, 1), E("NAME", NDASH, 0), E("LOAD", NGO, 0), E("SAVE", NGO, 0),
|
||
E("ENG", ["ANALOG", "DIGITAL", "PHASE", "LOFI", "SAMPLE", "VOICE", "TRIO", "WHEEL",
|
||
"GRAIN", "FM6", "PHYS", "NOISE"], 0), E("SET", NGO, 0),
|
||
E("CLRSQ", NGO, 0), E("INIT", NGO, 0),
|
||
E("CH4", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 10), D("LVL", F.INT, 0, 127, 100), D("REV", F.INT, 0, 127, 16),
|
||
D("DUST", F.PCT, 0, 127, 0), D("DUCK", F.PCT, 0, 127, 0), D("FILT", F.FILT, -64, 63, 0),
|
||
E("ROLL", ["1/8", "1/16", "1/32", "32T", "1/64"], 1), E("NEW", NGO, 0), D("DLY", F.INT, 0, 127, 0),
|
||
/* SLOOP 2.6: GLO > MIDI, each synth track's channel (OFF, 1..16) and the other channels (SEL / OFF) */
|
||
...[1, 2, 3].map((k) => E("CH" + k, ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], k)), E("OTHER", ["SEL", "OFF"], 0),
|
||
/* GLO > TEXTURE (2.6): the bed under the mix */
|
||
E("SRC", ["OFF", "VINYL", "TAPE", "RAIN", "WIND", "RADIO", "ROOM", "USR1", "USR2", "USR3", "USR4"], 0), D("LEVEL", F.PCT, 0, 127, 64),
|
||
D("TONE", F.FILT, -64, 63, 0), D("MOVE", F.PCT, 0, 127, 40),
|
||
E("RATE", ["1BAR", "2BAR", "4BAR", "8BAR", "16BAR"], 2), E("WHEN", ["PLAY", "ALWAYS"], 0), E("DUCK", NONOFF, 0),
|
||
D("BEND", F.SEMI, 1, 12, 2), /* GLO > MIDI 2 (2.6): the pitch bend's range */
|
||
E("FX CH", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 0), /* GLO > MIDI 3 (2.7): the punch-in FX */
|
||
E("DR MAP", ["GM", "1-16"], 0), /* GLO > MIDI 3 (2.7): MIDI notes -> drum sounds */
|
||
E("REMOTE", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 0), /* GLO > MIDI 3 (2.7): the buttons */
|
||
E("CLOCK", ["OFF", "OUT"], 0), /* GLO > MIDI 3 (2.7): MIDI clock, START / STOP out on USB */
|
||
D("FADE", F.INT, 0, 15, 0), /* GLO > MASTER 2 (2.7.2): the punch-in FX fade (punch.c) */
|
||
];
|
||
/* the drum track's P_E0: its kit (drums.c DRUM_KIT_NAMES; 5 = 808, the power-on kit) */
|
||
const KIT = E("KIT", ["ACOUSTIC", "DEEP", "TIGHT", "BRIGHT", "DUST", "808", "909", "606", "80S", "VINTAGE", "TRAP", "DRILL", "BOOMBAP", "LO-FI", "PHONK", "HOUSE", "D.HOUSE", "TECHNO", "MINIMAL", "ELECTRO", "DISCO", "GARAGE", "JUNGLE", "DUBSTEP", "DEMBOW", "AMAPIANO", "AFRO", "LATIN", "TRIBAL", "SYNTHWV", "CHIP", "ARCADE", "GLITCH", "INDUSTR", "HYPER", "AMBIENT", "JAZZ", "USR1", "USR2", "USR3", "USR4", "USR3+4", "SYN1", "SYN2", "SYN3", "SYN4"], 0);
|
||
/* a GM note -> its drum lane (drums.c LANE_OF_GM: 35..81) */
|
||
const LANE_OF_GM = [1, 0, 7, 2, 3, 8, 9, 4, 9, 6, 9, 5, 10, 10, 11, 10, 12, 11, 12, 13, 11, 15, 11, 13, 12, 14, 14, 14, 14, 14,
|
||
14, 14, 15, 15, 13, 13, 15, 15, 13, 13, 7, 7, 7, 14, 14, 15, 15];
|
||
const laneOf = (n) => (n < 35 ? 0 : n > 81 ? 13 : LANE_OF_GM[n - 35]);
|
||
const v5 = !opt.legacy && !opt.v3; /* SLOOP 2.0: steps with level / ratchet, DRUM_STEP, TRACK solo */
|
||
const mockProto = opt.noBackup ? 5 : opt.v7 ? 7 : opt.v8 ? 8 : opt.v9 ? 9 : opt.v10 ? 10 : opt.v11 ? 11 : 12; /* INFO's protocol */
|
||
/* the drum step as an old (v1..v4) step: its first 4 lanes as GM notes, ACC when one is hard (editor.c ed_dstep_old) */
|
||
const dOld = (d) => {
|
||
const notes = [];
|
||
let hard = 0;
|
||
for (let l = 0; l < 16 && notes.length < 4; l++) if ((d.on >> l) & 1) { notes.push(DRUM_LANES[l][0]); hard |= d.lvl[l] === 3; }
|
||
const n = notes.length;
|
||
return { n, notes: [...notes, 0, 0, 0, 0].slice(0, 4), time: n ? 0 : 2, flags: hard ? 1 : 0, vel: n ? 100 : 0, lvl: 0, rat: 0 };
|
||
};
|
||
/* an old step written into the drum track: its notes onto their lanes (ed_dstep_from_old) */
|
||
const dFromOld = (d, n, notes, time, flags) => {
|
||
Object.assign(d, emptyDrum());
|
||
if (time !== 0) return;
|
||
for (let i = 0; i < Math.min(4, n); i++) { const l = laneOf(notes[i] & 0x7F); d.on |= 1 << l; d.lvl[l] = flags & 1 ? 3 : 0; }
|
||
};
|
||
/* a step's bytes as STEP_GET sends them (v5: + lvl, hi, rat) */
|
||
const stepOut = (b, x) => {
|
||
b(x.n); x.notes.forEach(b); b(x.time); b(x.flags); b(x.vel);
|
||
if (v5) { b(x.lvl | 0); b((((x.lvl | 0) >> 7) & 1) | ((((x.rat | 0) >> 7) & 1) << 1)); b(x.rat | 0); }
|
||
};
|
||
/* a step written (n, 4 notes, time, flags, vel [, lvl, hi, rat]) */
|
||
const stepIn = (x, a) => {
|
||
x.n = Math.min(4, a[0]); x.notes = a.slice(1, 5); x.time = Math.min(2, a[5]); x.flags = a[6] & 3; x.vel = a[7];
|
||
x.lvl = a.length >= 11 ? (a[8] & 0x7F) | ((a[9] & 1) << 7) : 0;
|
||
x.rat = a.length >= 11 ? (a[10] & 0x7F) | (((a[9] >> 1) & 1) << 7) : 0;
|
||
};
|
||
const NONE = D("-", F.INT, 0, 0, 0);
|
||
const RATIO = [".5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14", "16"];
|
||
const P = (name, e, env = [10, 70, 90, 60], mono = 0, pat = 0) => ({ name, e, env, mono, pat });
|
||
const ENG = [
|
||
{ name: "ANALOG", titles: ["OSC", "FLT"], edit: [E("WAVE", ["SAW", "SQR", "TRI", "SIN", "PWM"], 0), D("DTN", F.INT, 0, 127, 10, null, "ct"), D("MIX", F.PCT, 0, 127, 64),
|
||
D("NOIS", F.PCT, 0, 127, 0), D("CUT", F.CUTOFF, 0, 127, 90), D("RES", F.PCT, 0, 127, 30), D("DRV", F.PCT, 0, 127, 0), D("KTR", F.PCT, 0, 127, 64)],
|
||
presets: [P("808 BOOM", [3, 0, 0, 0, 127, 0, 48, 0], [0, 112, 0, 52], 1), P("808 DIRTY", [3, 0, 0, 0, 96, 12, 118, 30], [0, 108, 0, 46], 1),
|
||
P("SUB BASS", [3, 0, 0, 0, 127, 0, 10, 0], [0, 60, 118, 24], 1), P("REESE", [0, 22, 64, 0, 56, 22, 36, 40], [0, 70, 118, 28], 1),
|
||
P("WOBBLE", [0, 9, 64, 0, 38, 72, 62, 30], [0, 64, 127, 22], 1, 1), P("FUNK BASS", [1, 6, 50, 0, 50, 30, 22, 64], [0, 55, 62, 20], 1),
|
||
P("G-FUNK LD", [2, 0, 0, 0, 92, 0, 10, 64], [6, 70, 112, 46], 1), P("TRAP PLUCK", [0, 8, 64, 0, 30, 35, 0, 64], [0, 58, 0, 45], 0),
|
||
P("SYN BRASS", [0, 10, 64, 0, 45, 20, 16, 64], [12, 70, 96, 35], 0), P("WARM PAD", [4, 12, 64, 6, 52, 8, 0, 32], [75, 90, 115, 90], 0),
|
||
P("DARK STR", [0, 18, 64, 0, 48, 6, 0, 32], [60, 90, 118, 85], 0), P("ATMOS PAD", [4, 25, 64, 20, 60, 15, 0, 32], [90, 100, 120, 100], 0),
|
||
P("PAN FLUTE", [2, 0, 0, 30, 70, 10, 0, 64], [14, 70, 110, 40], 1), P("FAT LEAD", [0, 8, 64, 0, 70, 30, 30, 64], [2, 70, 110, 30], 1), P("MONO BASS", [0, 4, 64, 0, 48, 36, 30, 64], [0, 60, 70, 20], 1)] },
|
||
{ name: "DIGITAL", titles: ["OPS", "MOD"], edit: [E("ALG", ["1", "2", "3", "4", "5", "6", "7", "8"], 0), E("R2", RATIO, 1), E("R3", RATIO, 1), E("R4", RATIO, 1),
|
||
D("IDX", F.PCT, 0, 127, 60), D("MDEC", F.TIME, 0, 127, 60), D("FB", F.PCT, 0, 127, 0), NONE],
|
||
presets: [P("RHODES", [4, 1, 1, 14, 26, 35, 0, 0], [0, 85, 35, 55], 0), P("DX RHODES", [4, 1, 1, 14, 85, 45, 0, 0], [0, 82, 40, 55], 0),
|
||
P("WURLI", [4, 1, 2, 3, 62, 35, 8, 0], [0, 75, 30, 45], 0), P("CLAV", [3, 1, 3, 5, 90, 25, 20, 0], [0, 50, 20, 18], 0),
|
||
P("TRAP BELL", [4, 8, 1, 4, 80, 70, 0, 0], [0, 92, 0, 70], 0), P("MUSIC BOX", [4, 4, 3, 9, 45, 75, 0, 0], [0, 90, 0, 75], 0),
|
||
P("MARIMBA", [4, 4, 1, 1, 60, 30, 0, 0], [0, 80, 0, 60], 0), P("FM BASS", [0, 1, 1, 1, 34, 40, 8, 0], [0, 60, 70, 25], 1),
|
||
P("STEEL DRUM", [4, 2, 2, 2, 45, 45, 0, 0], [0, 88, 0, 66], 0), P("GLOCKEN", [4, 5, 1, 8, 40, 60, 0, 0], [0, 95, 0, 85], 0), P("CELESTA", [4, 2, 1, 4, 30, 50, 0, 0], [0, 84, 0, 70], 0), P("XYLOPHONE", [4, 4, 3, 3, 70, 18, 0, 0], [0, 77, 0, 58], 0), P("HARP", [4, 1, 1, 2, 45, 30, 10, 0], [0, 92, 0, 80], 0), P("BASS GTR", [4, 1, 1, 2, 40, 30, 6, 0], [0, 76, 40, 22], 1)] },
|
||
{ name: "PHASE", titles: ["PHS", "LINE"], edit: [E("WAVE", ["SAW", "SQR", "PLS", "DSIN", "SPLS", "RSAW", "RTRI", "RTRP"], 0),
|
||
E("WAVE2", ["--", "SAW", "SQR", "PLS", "DSIN", "SPLS", "RSAW", "RTRI", "RTRP"], 0), D("DCW", F.PCT, 0, 127, 60), D("ENV", F.PCT, 0, 127, 64),
|
||
D("DTN", F.INT, 0, 127, 0, null, "ct"), E("LINE", ["MIX", "RING"], 0), D("SUB", F.PCT, 0, 127, 0), NONE],
|
||
presets: [P("CZ BASS", [5, 0, 28, 70, 0, 0, 40, 0], [0, 60, 50, 22], 1), P("SOFT KEYS", [3, 0, 40, 70, 0, 0, 0, 0], [0, 80, 20, 50], 0),
|
||
P("CZ STRING", [0, 4, 50, 40, 12, 0, 0, 0], [50, 90, 105, 75], 0), P("RESO PLUCK", [5, 0, 60, 60, 0, 0, 0, 0], [0, 70, 30, 60], 0, 1),
|
||
P("CZ BRASS", [0, 0, 30, 90, 0, 0, 0, 0], [8, 70, 90, 40], 0)] },
|
||
{ name: "LOFI", titles: ["CHIP", "MOTN"], edit: [E("CHIP", ["4BIT", "4B/2", "8BIT", "1BIT", "STEP"], 0), E("WAVE", ["PLS", "TRI", "SAW", "NOIS", "WRAM"], 0), D("DUTY", F.INT, 0, 127, 64),
|
||
D("CRSH", F.PCT, 0, 127, 0), D("SWP", F.PCT, 0, 127, 0), D("VIB", F.PCT, 0, 127, 0), E("ARP", ["OFF", "OCT", "MAJ", "MIN"], 0), D("TONE", F.PCT, 0, 127, 127)],
|
||
presets: [P("GAME LEAD", [0, 0, 32, 0, 0, 20, 0, 127], [0, 60, 90, 30], 1), P("GB BASS", [1, 1, 0, 0, 0, 0, 0, 90], [0, 50, 70, 20], 1),
|
||
P("8BIT ARP", [2, 0, 96, 0, 0, 0, 2, 110], [0, 60, 80, 40], 0)] },
|
||
{ name: "SAMPLE", titles: ["SET", "TONE"], edit: [E("SET", ["PIANO", "BASS", "VIBES", "HORNS", "STRGS", "FLUTE", "SCRCH", "PERC", "USR1", "USR2", "USR3", "USR4"], 0), D("TUNE", F.SEMI, -24, 24, 0), D("BITS", F.INT, 0, 127, 0),
|
||
E("LOOP", NONOFF, 1), D("CUT", F.INT, 0, 127, 127), NONE, D("DRV", F.PCT, 0, 127, 0), NONE],
|
||
presets: [P("DUSTY PNO", [0, 0, 20, 1, 104, 0, 14, 0], [0, 127, 127, 52], 0), P("UP BASS", [1, 0, 0, 1, 118, 0, 12, 0], [0, 127, 127, 26], 1),
|
||
P("VIBES", [2, 0, 0, 1, 127, 0, 0, 0], [0, 127, 127, 72], 0), P("HORN STAB", [3, 0, 0, 1, 120, 0, 20, 0], [0, 127, 127, 22], 0),
|
||
P("STRING STB", [4, 0, 0, 1, 122, 0, 10, 0], [0, 127, 127, 26], 0), P("LOFI FLUTE", [5, 0, 12, 1, 100, 0, 0, 0], [12, 80, 120, 60], 1),
|
||
P("SCRATCH", [6, 0, 0, 1, 127, 0, 8, 0], [0, 127, 127, 18], 0), P("GM KIT", [7, 0, 0, 0, 127, 0, 0, 0], [0, 127, 127, 60], 0),
|
||
P("LOFI KEYS", [0, 0, 45, 1, 78, 0, 30, 0], [0, 127, 110, 60], 0), P("DEEP BASS", [1, -12, 0, 1, 90, 0, 40, 0], [0, 127, 127, 30], 1)] },
|
||
{ name: "VOICE", titles: ["VOWL", "TONE"], edit: [D("VOWL", F.INT, 0, 127, 0), D("VOWL2", F.INT, 0, 127, 64), D("TALK", F.TIME, 0, 127, 0),
|
||
D("SHIFT", F.SEMI, -12, 12, 0), D("BUZZ", F.PCT, 0, 127, 64), D("BRTH", F.PCT, 0, 127, 10), D("Q", F.PCT, 0, 127, 64), D("RAND", F.PCT, 0, 127, 0)],
|
||
presets: [P("CHOIR AAH", [0, 0, 0, 0, 40, 22, 60, 0], [85, 90, 115, 95], 0), P("SOUL OOH", [110, 0, 0, 0, 30, 30, 55, 0], [70, 90, 115, 90], 0),
|
||
P("TALKBOX", [32, 95, 60, 0, 100, 4, 75, 0], [4, 70, 110, 40], 1), P("WOW BASS", [95, 0, 68, 0, 100, 0, 80, 0], [0, 70, 70, 30], 1),
|
||
P("HARMONICA", [64, 0, 0, 0, 127, 20, 70, 0], [4, 70, 115, 25], 1)] },
|
||
{ name: "TRIO", titles: ["OSC", "TONE"], edit: [E("WAVE", ["SAW3", "PLS3", "PPT", "SST", "TRI3", "S&T", "P&S", "P+N", "NOIS", "SYNC", "SYNCP", "SYNC3",
|
||
"RING", "RING3", "R+S", "R+SP"], 0), D("INT2", F.SEMI, -24, 24, 0), D("INT3", F.SEMI, -24, 24, -12), D("DTN", F.INT, 0, 50, 6, null, "ct"),
|
||
E("MODE", ["LP", "BP", "HP", "NOT"], 0), D("CUT", F.CUTOFF, 0, 127, 80), D("RES", F.PCT, 0, 127, 40), D("PW", F.PCT, 0, 127, 64)],
|
||
presets: [P("FAT BASS", [0, 0, -12, 9, 0, 62, 45, 64], [0, 62, 60, 25], 1), P("MIN STAB", [0, 3, 7, 6, 0, 80, 20, 64], [0, 50, 0, 30], 0),
|
||
P("MIN7 STAB", [3, 3, 10, 5, 0, 75, 15, 64], [0, 60, 20, 40], 0), P("SYNC LEAD", [9, 9, 0, 0, 0, 82, 30, 64], [2, 70, 100, 40], 1),
|
||
P("HOOVER", [0, 0, -12, 40, 0, 70, 20, 64], [10, 70, 110, 40], 1),
|
||
P("ACCORDION", [1, 0, 12, 14, 0, 92, 10, 40], [6, 70, 118, 24], 0), P("ENSEMBLE", [0, 12, 0, 10, 0, 85, 0, 64], [50, 90, 118, 80], 0), P("80S POLY", [0, 0, 12, 12, 0, 70, 30, 64], [2, 72, 70, 50], 0)] },
|
||
{ name: "WHEEL", titles: ["BARS", "TONE"], edit: [E("REG", ["FLUTE", "MELLO", "HOLLW", "SMOOT", "3BAR", "BLUES", "GOSPL", "ROCK",
|
||
"TOPS", "CLARI", "REED", "STRNG", "CHAPL", "BRITE", "BASS", "FULL"], 4), D("SUB", F.INT, -8, 8, 0), D("BODY", F.INT, -8, 8, 0), D("TOP", F.INT, -8, 8, 0),
|
||
E("PERC", ["OFF", "2ND", "3RD", "2SOFT", "3SOFT", "2SLOW", "3SLOW"], 0), D("CLICK", F.PCT, 0, 127, 40), D("DRV", F.PCT, 0, 127, 0), E("ROTR", ["OFF", "SLOW", "FAST"], 1)],
|
||
presets: [P("SOUL ORGAN", [3, 0, 0, 0, 0, 25, 10, 1], [0, 64, 127, 40], 0), P("GOSPEL", [6, 0, 0, 0, 1, 60, 40, 2], [0, 64, 127, 45], 0),
|
||
P("JAZZ ORGAN", [4, 0, 0, 0, 2, 50, 8, 1], [0, 64, 127, 40], 0), P("DIRTY B3", [5, 0, 0, 0, 0, 60, 90, 2], [0, 64, 127, 40], 0)] },
|
||
{ name: "GRAIN", titles: ["GRAN", "SPRY"], edit: [E("SRC", ["PIANO", "BASS", "VIBES", "HORNS", "STRGS", "FLUTE", "SCRCH", "PERC", "USR1", "USR2", "USR3", "USR4"], 0),
|
||
D("POS", F.PCT, 0, 127, 32), D("SIZE", F.PCT, 0, 127, 80), D("DENS", F.PCT, 0, 127, 80),
|
||
D("PTCH", F.SEMI, -24, 24, 0), D("SPRD", F.PCT, 0, 127, 30), D("RAND", F.PCT, 0, 127, 10), D("TONE", F.PCT, 0, 127, 127)],
|
||
presets: [P("LOFI CLOUD", [0, 45, 95, 85, 0, 35, 12, 80], [70, 90, 120, 90], 0), P("VIBE HAZE", [2, 30, 100, 90, 0, 25, 10, 90], [50, 100, 120, 95], 0),
|
||
P("FLUTE DUST", [5, 50, 108, 72, 0, 10, 10, 85], [50, 100, 127, 100], 0),
|
||
P("STR CLOUD", [4, 40, 100, 90, 0, 30, 12, 80], [70, 100, 120, 95], 0), P("SHIMMER", [0, 30, 90, 95, 12, 40, 15, 110], [60, 100, 120, 100], 0), P("DRONE", [3, 50, 115, 80, -12, 20, 20, 50], [90, 100, 127, 100], 0)] },
|
||
/* 9: FM6 (SLOOP 2.4, eng_fm6.c): the macros on top of the patch; ALG and PTCH are F_INT with names on the device */
|
||
{ name: "FM6", titles: ["OPS", "PATCH"], edit: [D("ALG", F.INT, 0, 32, 0), D("FB", F.INT, -7, 7, 0), D("MLVL", F.BIPCT, -64, 63, 0),
|
||
D("MRAT", F.INT, -16, 16, 0), D("MEG", F.BIPCT, -64, 63, 0), D("VMOD", F.INT, -7, 7, 0), D("DTUN", F.PCT, 0, 127, 0),
|
||
D("PTCH", F.INT, 0, FM6.FACTORY_PK.length + 27 - 1, 0)],
|
||
presets: [P("TINE EP", [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 127, 0], 0), P("GLASS BELL", [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 127, 0], 0),
|
||
P("ROUND BASS", [0, 0, 0, 0, 0, 0, 0, 2], [0, 0, 127, 0], 1), P("BRASS SECT", [0, 0, 0, 0, 0, 0, 0, 3], [0, 0, 127, 0], 0),
|
||
P("SOFT PAD", [0, 0, 0, 0, 0, 0, 30, 4], [0, 0, 127, 0], 0), P("WOOD BARS", [0, 0, 0, 0, 0, 0, 0, 5], [0, 0, 127, 0], 0),
|
||
P("DRAWBARS", [0, 0, 0, 0, 0, 0, 0, 6], [0, 0, 127, 0], 0), P("NYLON PICK", [0, 0, 0, 0, 0, 0, 0, 7], [0, 0, 127, 0], 0)] },
|
||
{ name: "PHYS", titles: ["BODY", "EXCT"], edit: [E("MODEL", ["MODAL", "STRNG", "MEMB", "SYMP"], 0), D("STRC", F.PCT, 0, 127, 64),
|
||
D("BRIT", F.PCT, 0, 127, 80), D("DAMP", F.PCT, 0, 127, 80), D("POS", F.PCT, 0, 127, 20), D("ACC", F.PCT, 0, 127, 90),
|
||
D("BOW", F.PCT, 0, 127, 0), D("EXC", F.PCT, 0, 127, 0)],
|
||
presets: [
|
||
P("BELL TREE", [0, 70, 100, 106, 12, 100, 0, 6], [0, 100, 127, 96], 0),
|
||
P("MODAL BAR", [0, 116, 38, 40, 24, 90, 0, 30], [0, 90, 127, 52], 0),
|
||
P("STR PLUCK", [1, 56, 72, 84, 40, 96, 0, 0], [0, 100, 127, 58], 0),
|
||
P("BOWED MTL", [0, 98, 70, 112, 10, 80, 90, 0], [60, 90, 127, 90], 0),
|
||
P("THUMB PNO", [0, 34, 16, 56, 100, 90, 0, 48], [0, 100, 127, 60], 0),
|
||
P("HAND DRUM", [2, 112, 76, 56, 44, 100, 14, 24], [0, 100, 127, 64], 0),
|
||
P("MEMB TOMS", [2, 0, 52, 40, 30, 100, 40, 30], [0, 100, 127, 70], 0),
|
||
P("SITAR", [3, 127, 80, 88, 64, 100, 92, 0], [0, 100, 127, 90], 0),
|
||
P("PHYS HARP", [3, 8, 62, 74, 60, 90, 0, 0], [0, 100, 127, 80], 0),
|
||
P("NYLON GTR", [1, 40, 50, 80, 30, 80, 0, 10], [0, 100, 127, 50], 0),
|
||
P("STEEL GTR", [1, 56, 85, 88, 22, 96, 0, 6], [0, 100, 127, 56], 0),
|
||
P("MUTED GTR", [1, 50, 40, 55, 30, 90, 0, 20], [0, 100, 127, 20], 0),
|
||
P("PLUCK BASS", [1, 60, 45, 74, 35, 100, 0, 8], [0, 100, 127, 30], 1),
|
||
P("KOTO", [1, 20, 70, 82, 15, 96, 0, 4], [0, 100, 127, 60], 0),
|
||
P("BANJO", [1, 70, 100, 60, 12, 110, 0, 12], [0, 100, 127, 40], 0),
|
||
P("CELLO BOW", [0, 34, 60, 110, 12, 70, 90, 0], [60, 90, 127, 70], 0),
|
||
P("TANPURA", [3, 0, 70, 120, 90, 80, 110, 0], [0, 100, 127, 100], 0),
|
||
P("CHIMES", [0, 70, 110, 118, 8, 110, 0, 4], [0, 100, 127, 100], 0),
|
||
P("BIG BELL", [0, 80, 90, 124, 16, 120, 0, 8], [0, 100, 127, 110], 0),
|
||
P("VIBRA BAR", [0, 116, 60, 100, 20, 80, 0, 10], [0, 100, 127, 70], 0),
|
||
P("GLASS BOWL", [0, 98, 90, 120, 6, 60, 70, 0], [70, 90, 127, 100], 0),
|
||
P("STEEL PAN", [0, 36, 80, 90, 30, 100, 0, 20], [0, 100, 127, 60], 0),
|
||
P("WOOD BLOCK", [0, 116, 30, 35, 40, 110, 0, 60], [0, 100, 127, 20], 0),
|
||
P("TABLA", [2, 120, 70, 70, 50, 110, 20, 30], [0, 100, 127, 50], 0),
|
||
P("CONGA", [2, 90, 60, 50, 40, 100, 8, 40], [0, 100, 127, 40], 0),
|
||
P("TIMPANI", [2, 10, 50, 100, 20, 110, 6, 10], [0, 100, 127, 90], 0)] },
|
||
{ name: "NOISE", titles: ["SRC", "MOVE"], edit: [E("MODE", ["ANLG", "DUST", "LFSR", "META"], 0), D("COLR", F.PCT, 0, 127, 64),
|
||
D("FREQ", F.CUTOFF, 0, 127, 80), D("RES", F.PCT, 0, 127, 30), D("TRK", F.PCT, 0, 127, 64), D("DENS", F.PCT, 0, 127, 0),
|
||
D("DRFT", F.PCT, 0, 127, 0), D("CRSH", F.PCT, 0, 127, 0)],
|
||
presets: [
|
||
P("WIND", [0, 64, 70, 100, 127, 0, 70, 0], [90, 90, 110, 90], 0),
|
||
P("RAIN", [1, 30, 88, 80, 64, 105, 40, 0], [10, 90, 127, 70], 0),
|
||
P("NZ ARCADE", [2, 0, 127, 0, 127, 112, 0, 84], [0, 80, 0, 50], 0),
|
||
P("NZ METAL", [3, 0, 100, 40, 100, 32, 0, 0], [0, 75, 40, 60], 0),
|
||
P("OCEAN", [0, 100, 50, 20, 0, 0, 110, 0], [100, 90, 127, 100], 0),
|
||
P("VINYL", [1, 0, 110, 10, 0, 70, 20, 0], [0, 64, 127, 40], 0),
|
||
P("HISS", [0, 0, 115, 0, 0, 0, 0, 0], [20, 64, 127, 40], 0),
|
||
P("RISER", [0, 30, 60, 110, 127, 0, 0, 0], [100, 90, 127, 60], 0),
|
||
P("NZ SNARE", [0, 20, 90, 30, 64, 0, 0, 0], [0, 60, 0, 44], 0),
|
||
P("BITCRUSH", [0, 40, 90, 40, 64, 0, 0, 100], [0, 70, 110, 40], 0),
|
||
P("RADIO", [2, 20, 70, 90, 64, 0, 60, 48], [10, 70, 120, 50], 0)] },
|
||
];
|
||
const FM6_E = ENG.findIndex((e) => e.name === "FM6"), FM6_BANK = 27, FM6_NPART = 3;
|
||
const v9 = !opt.legacy && !opt.v3 && !opt.noBackup && !opt.v7 && !opt.v8; /* SLOOP 2.4: FM6 patches */
|
||
const v10 = v9 && !opt.v9; /* SLOOP 2.5: the SYN drum kits */
|
||
const v11 = v10 && !opt.v10; /* SLOOP 2.7: your theme (backup object 11) */
|
||
/* demo patterns of the mock only (the LIVE firmware has no factory patterns: a preset never writes the
|
||
sequencer); used to seed the mock's user presets and track 1 as if they had been recorded */
|
||
const T_ = 4;
|
||
const PATTERNS = [
|
||
[[45, 45, 57, 45, 0, 48, 45, 55, 45, 0, 57, 52, 45, 48, 0, 50], [1, 0, 2, 0, 0, 0, 1, 2, 0, 0, 1, 0, 0, 2, 0, 1]],
|
||
[[0, 36, 0, 36, 0, 36, 0, 48, 0, 36, 0, 36, 0, 39, 0, 43], [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]],
|
||
[[60, 0, 67, 0, 72, 67, 0, 64, 62, 0, 69, 0, 74, 69, 0, 67], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]],
|
||
[[72, 0, 0, 74, 0, 0, 76, 0, 79, 0, 76, 0, 74, 0, 0, 0], [1, T_, 0, 2, T_, 0, 0, 0, 1, 0, 2, 0, 0, T_, T_, 0]],
|
||
[[60, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 55, 0, 0, 0], [0, T_, T_, T_, T_, T_, T_, 0, 0, T_, T_, 0, 0, T_, T_, 0]],
|
||
[[0, 0, 60, 0, 0, 63, 0, 0, 0, 0, 60, 0, 0, 65, 0, 63], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]],
|
||
[[72, 0, 0, 79, 0, 0, 84, 0, 0, 0, 76, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
|
||
[[36, 0, 0, 0, 0, 0, 0, 36, 0, 0, 34, 0, 0, 0, 0, 0], [1, T_, T_, T_, 0, 0, 0, 0, 0, 0, 0, T_, T_, T_, 0, 0]],
|
||
[[60, 61, 62, 67, 64, 65, 60, 69, 68, 70, 62, 67, 72, 72, 74, 64], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]],
|
||
[[60, 60, 61, 61, 62, 0, 63, 63, 64, 65, 65, 0, 66, 66, 66, 67], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]],
|
||
[[60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]],
|
||
];
|
||
const P_E0 = TP.length, P_COUNT = P_E0 + 8, G_COUNT = GP.length, NSTEP = 64, G_ENGSEL = 20, P_SLCR = 45, P_CHORD = 49;
|
||
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
|
||
/* four tracks (firmware v3); engine / preset / p / step below are the selected track's */
|
||
const NTRK = 4, TRK_DRUM = 3;
|
||
const newTrack = (i) => ({ engine: 0, preset: 0, drum: i === TRK_DRUM, fm6: FM6.INIT_PK.slice(), /* fm6: the FM6 patch (eng_fm6.c fm6_patch) */
|
||
p: TP.map((d) => d.def).concat(i === TRK_DRUM ? [5, 0, 0, 0, 0, 0, 0, 0] : new Array(8).fill(0)),
|
||
step: Array.from({ length: NSTEP }, () => ({ n: 0, notes: [0, 0, 0, 0], time: 2, flags: 0, vel: 0, lvl: 0, rat: 0 })),
|
||
dstep: i === TRK_DRUM ? Array.from({ length: NSTEP }, emptyDrum) : null,
|
||
micro: new Array(NSTEP).fill(0), locks: [], /* v7: nudges, parameter locks (at most NLOCK) */
|
||
fill: new Array(NSTEP / 4).fill(0) }); /* v8: fill conditions, 2 bits a step */
|
||
const NLOCK = 24;
|
||
const st = {
|
||
tracks: [0, 1, 2, 3].map(newTrack), sel: 0, rec: 0, solo: 0,
|
||
g: GP.map((d) => d.def),
|
||
slots: [null, null, null, null],
|
||
smp: [0, 1, 2, 3].map(() => ({ flash: new Uint8Array(SMP.SLOT_SIZE).fill(0xFF), zones: 0, name: "", len: 0, next: SMP.DATA_OFF })), /* USR1..4 (2.4: USR4) */
|
||
bank: new Array(opt.slots || 32).fill(null), /* user presets: {engine, name, p, pattern} */
|
||
fm6bank: new Array(FM6_BANK).fill(null), /* the FM6 patch bank (fm6_bank.c): packed records */
|
||
settings: mockSettings(), /* v6: the settings object (2.5: a PER3 with a song order) */
|
||
dsyn: null, dsynStored: null, dsynPlayed: [], /* v10: the SYN kits (RAM, flash), the auditions heard */
|
||
ml: null, /* 2.6: the MIDI LEARN map (seq.c ml_tab, 16 x 2 bytes), null: none */
|
||
bkSnap: null, bkPut: null,
|
||
watch: false, v4: false, lastReq: 0, playing: false,
|
||
/* v12 (LIVE): the transport's start, the sections (A..D: playing, asked for at a time), song mode, SONG REC, fills,
|
||
the punch-in effect, REC waiting for a note, undo (0 none, 1 undo, 2 redo), a store waiting for its second press,
|
||
the taps of TAP, the MIDI the editor played (notes) */
|
||
live: { t0: 0, sec: -1, next: -1, nextAt: 0, songMode: false, srec: 0, fillHeld: false, fillBar: false, fillAt: 0, fillTo: 0,
|
||
fx: -1, recWait: false, undo: 0, armed: -1, armedAt: 0, taps: [],
|
||
rolls: new Set(), erase: new Set(), pattern: [], chain: [], thr: 0, master: 0, dtw: new Array(16).fill(8 | 4 << 4) },
|
||
midiIn: [],
|
||
};
|
||
for (const k of ["engine", "preset", "p", "step"]) {
|
||
Object.defineProperty(st, k, { enumerable: false, get: () => st.tracks[st.sel][k], set: (v) => { st.tracks[st.sel][k] = v; } });
|
||
}
|
||
const drumSel = () => st.tracks[st.sel].drum;
|
||
const engOf = (t) => (t.drum ? ENG.length : t.engine); /* the engine byte: NENGINES = drums */
|
||
const watchMs = opt.watchMs || 3000;
|
||
const tdesc = (t, id) => (t.drum && id === P_E0 ? KIT : id >= P_E0 ? ENG[t.engine].edit[id - P_E0] : TP[id]);
|
||
const desc = (scope, id) => (scope === 0 && id < P_COUNT ? tdesc(st.tracks[st.sel], id) : scope === 1 && id < G_COUNT ? GP[id] : null);
|
||
const seqEmpty = () => st.step.every((s) => !s.n);
|
||
function loadPat16(pat) { /* ui.c load_pat16 */
|
||
const ps = stepsFromPattern(pat);
|
||
st.step.forEach((s, i) => Object.assign(s, i < 16 ? ps[i] : { n: 0, notes: [0, 0, 0, 0], time: 2, flags: 0, vel: 0 }));
|
||
st.p[29] = 16;
|
||
}
|
||
const loadPattern = (k) => loadPat16(PATTERNS[k][0].map((n, i) => [n, PATTERNS[k][1][i]]));
|
||
function applyPreset(pi, demo) { /* demo: seed the mock (never from a command) */
|
||
if (drumSel()) return;
|
||
const e = ENG[st.engine];
|
||
pi %= e.presets.length;
|
||
const pr = e.presets[pi];
|
||
st.preset = pi;
|
||
for (let i = 0; i < 8; i++) st.p[P_E0 + i] = pr.e[i];
|
||
[1, 2, 3, 4].forEach((id, k) => { st.p[id] = pr.env[k]; });
|
||
st.p[37] = pr.mono ? 2 : 0;
|
||
st.p[33] = 0; st.p[34] = 24; st.p[35] = 28; st.p[36] = 36;
|
||
for (let i = P_SLCR; i < P_CHORD; i++) st.p[i] = TP[i].def; /* a factory preset turns the SLICER off (CHORD stays: the key) */
|
||
if (demo && pr.pat && seqEmpty()) loadPattern(pr.pat - 1);
|
||
if (st.engine === FM6_E) fm6Slot(st.tracks[st.sel], st.p[P_E0 + 7]); /* eng_fm6.c fm6_track_loaded: the slot's patch */
|
||
}
|
||
/* PTCH value s -> the track's patch: F1..F8 the factory, B1..B27 the bank (empty: the init voice) */
|
||
function fm6Slot(t, s) {
|
||
const nf = FM6.FACTORY_PK.length;
|
||
t.fm6 = (s < nf ? FM6.FACTORY_PK[s] : st.fm6bank[s - nf] || FM6.INIT_PK).slice();
|
||
}
|
||
function setEngine(ei) {
|
||
if (drumSel()) return;
|
||
st.engine = ei % ENG.length;
|
||
for (let i = 0; i < 8; i++) st.p[P_E0 + i] = ENG[st.engine].edit[i].def;
|
||
applyPreset(0);
|
||
}
|
||
const fm6BankChanged = (k) => st.tracks.forEach((t) => { if (!t.drum && t.engine === FM6_E && t.p[P_E0 + 7] === FM6.FACTORY_PK.length + k) fm6Slot(t, t.p[P_E0 + 7]); });
|
||
const clearSteps = () => { st.step.forEach((s) => Object.assign(s, { n: 0, notes: [0, 0, 0, 0], time: 2, flags: 0, vel: 0, lvl: 0, rat: 0 })); st.tracks[st.sel].micro.fill(0); st.tracks[st.sel].locks.length = 0; st.tracks[st.sel].fill.fill(0); };
|
||
const snapshot = (name) => ({ engine: st.engine, name, p: st.p.slice(), pattern: patternFromSteps(st.step) });
|
||
/* a few user presets to start with */
|
||
[[0, 0, 0, "MY LEAD"], [1, 1, 1, "GLASS BELL"], [2, 2, 3, "PHASE RESO"], [5, 3, 2, "8BIT ARP"]].forEach(([slot, e, p, name]) => {
|
||
setEngine(e); clearSteps(); applyPreset(p, true);
|
||
st.bank[slot] = snapshot(name);
|
||
clearSteps();
|
||
});
|
||
[[1, 1, 5], [2, 3, 0]].forEach(([i, e, p]) => { st.sel = i; setEngine(e); applyPreset(p); clearSteps(); }); /* MUSIC BOX, GAME LEAD */
|
||
st.fm6bank[0] = FM6.pack(FM6.setName(FM6.factory(0), "MY TINES")); /* B1: a stored patch to look at */
|
||
/* a mix to look at: pads left, lead right, and a GM drum pattern on track 4 */
|
||
st.tracks[1].p[39] = -24; st.tracks[2].p[39] = 20; st.tracks[2].p[0] = 92; st.tracks[TRK_DRUM].p[39] = 0;
|
||
/* a boom bap beat on the 16 lanes: kick 0, snare 2, clap 3, hat 4, open hat 5; a ghost snare, a hat roll (x2) */
|
||
const KICK = 0, SNARE = 2, CLAP = 3, HAT = 4, OHAT = 5;
|
||
[[KICK, HAT], [HAT], [HAT], [HAT], [SNARE, HAT], [HAT], [HAT], [KICK, OHAT], [KICK, HAT], [HAT], [KICK], [HAT, SNARE], [SNARE, CLAP], [HAT], [HAT], [OHAT]]
|
||
.forEach((ls, i) => {
|
||
const d = st.tracks[TRK_DRUM].dstep[i];
|
||
for (const l of ls) d.on |= 1 << l;
|
||
if (i === 11) d.lvl[SNARE] = 1; /* GHOST */
|
||
if (i === 14) d.rat[HAT] = 1; /* x2 */
|
||
});
|
||
st.sel = 0;
|
||
setEngine(0);
|
||
clearSteps();
|
||
applyPreset(4, true); /* WOBBLE, a recorded-looking pattern on track 1 (mock only) */
|
||
const project = () => JSON.parse(JSON.stringify({ tracks: st.tracks, sel: st.sel, g: st.g }));
|
||
/* v10: a factory synthesised kit (DSYN_MOCK_KITS), SYN1..4 = copies of 808, 909, TRAP, TECHNO */
|
||
const dsynRaw = b64dec(DSYN_MOCK_KITS);
|
||
function dsynFactory(i) {
|
||
const at = i * (1 + DSYN.LANES * DSYN.SIZE);
|
||
return { name: DSYN_MOCK_NAMES[i], crush: dsynRaw[at], src: i,
|
||
sounds: Array.from({ length: DSYN.LANES }, (_, l) => dsynRaw.slice(at + 1 + l * DSYN.SIZE, at + 1 + (l + 1) * DSYN.SIZE)) };
|
||
}
|
||
function dsynKits() {
|
||
if (!st.dsyn) { st.dsyn = [0, 1, 5, 12].map(dsynFactory); st.dsynStored = DSYN.bankEncode(st.dsyn); }
|
||
return st.dsyn;
|
||
}
|
||
st.slots[0] = project();
|
||
|
||
function handle(cmd, a) {
|
||
const out = [];
|
||
const b = (x) => out.push(x & 0x7F), v = (x) => out.push(...v14enc(x)), s = (x) => out.push(...strEnc(x));
|
||
if (opt.legacy && cmd >= CMD.UP_LIST) return null;
|
||
if (opt.v3 && cmd >= CMD.TRACK_PARAM) return null;
|
||
if (opt.noBackup && cmd >= CMD.LOCK_GET) return null; /* (a v5 device: no locks either) */
|
||
if (opt.v7 && cmd >= CMD.FILL_GET) return null; /* (a v7 device: no fill conditions) */
|
||
if (!v9 && cmd >= CMD.FM6_GET) return null; /* (a v8 device: no FM6 patches) */
|
||
if (!v10 && cmd >= CMD.DSYN_LIST) return null; /* (a v9 device: no SYN kits) */
|
||
const NB = st.bank.length;
|
||
switch (cmd) {
|
||
case CMD.UP_LIST: {
|
||
if (a.length < 2) return null;
|
||
const start = a[0], n = Math.max(0, Math.min(a[1], UP.LIST_MAX, NB - start));
|
||
b(start); b(n); b(NB);
|
||
for (let i = start; i < start + n; i++) { const u = st.bank[i]; b(u ? 1 : 0); b(u ? u.engine : 0); s(u ? u.name : ""); }
|
||
break;
|
||
}
|
||
case CMD.UP_GET: {
|
||
if (a.length < 1 || a[0] >= NB) return null;
|
||
const u = st.bank[a[0]];
|
||
b(a[0]); b(u ? 1 : 0); b(u ? u.engine : 0); s(u ? u.name : "");
|
||
for (let i = 0; i < P_COUNT; i++) v(u ? u.p[i] : 0);
|
||
for (let i = 0; i < UP.PAT; i++) { const x = u ? u.pattern[i] : [0, 0]; b(x[0]); b(x[1]); }
|
||
break;
|
||
}
|
||
case CMD.UP_PUT: {
|
||
if (a.length < 3) return null;
|
||
const r = new Reader(a);
|
||
let rc = 0;
|
||
try {
|
||
const slot = r.b(), engine = r.b(), name = r.s(), p = [], pattern = [];
|
||
for (let i = 0; i < P_COUNT; i++) p.push(r.v());
|
||
for (let i = 0; i < UP.PAT; i++) pattern.push(patNorm(r.b(), r.b()));
|
||
if (slot >= NB || engine >= ENG.length || !name.length || name.length > UP.NAME_MAX || /[^\x20-\x7E]/.test(name)) rc = 1;
|
||
else if (st.playing) rc = 3; /* editor.c: no flash write while the song plays */
|
||
else {
|
||
const saved = st.engine; /* values clamped to the ranges of that engine */
|
||
st.engine = engine;
|
||
st.bank[slot] = { engine, name, p: p.map((x, i) => { const d = desc(0, i); return clamp(x, d.min, d.max); }), pattern };
|
||
st.engine = saved;
|
||
}
|
||
} catch (e) { rc = 1; }
|
||
b(a[0]); b(rc);
|
||
break;
|
||
}
|
||
case CMD.UP_STORE: {
|
||
if (a.length < 2) return null;
|
||
const name = new Reader(a.slice(1)).s();
|
||
const rc = a[0] >= NB || name.length > UP.NAME_MAX || drumSel() ? 1 : 0;
|
||
if (!rc) st.bank[a[0]] = snapshot(name || `${ENG[st.engine].name} ${String(a[0] + 1).padStart(2, "0")}`);
|
||
b(a[0]); b(rc);
|
||
break;
|
||
}
|
||
case CMD.UP_LOAD: {
|
||
if (a.length < 1) return null;
|
||
const u = drumSel() ? null : st.bank[a[0]];
|
||
if (u) { /* the sound; the mix, pattern and key parameters stay (param_kept) */
|
||
const KEPT = [0, 25, 26, 27, 29, 30, 31, 32, 39, 40, P_CHORD], mix = KEPT.map((i) => st.p[i]);
|
||
st.engine = u.engine; st.preset = 0; st.p = u.p.slice();
|
||
KEPT.forEach((i, k) => { st.p[i] = mix[k]; });
|
||
/* LIVE firmware: a user preset brings its sound only, never its pattern */
|
||
}
|
||
b(a[0]); b(u ? 0 : 1);
|
||
break;
|
||
}
|
||
case CMD.UP_ERASE:
|
||
if (a.length < 1) return null;
|
||
if (a[0] < NB) st.bank[a[0]] = null;
|
||
b(a[0]); b(a[0] < NB ? 0 : 1);
|
||
break;
|
||
case CMD.WATCH:
|
||
if (a.length < 1) return null;
|
||
st.watch = !!(a[0] & 1);
|
||
st.v4 = st.watch && !opt.v3 && !!(a[0] & 2); /* v4: TRACK_CHANGED pushes too */
|
||
b((st.watch ? 1 : 0) | (st.v4 ? 2 : 0));
|
||
break;
|
||
case CMD.PING:
|
||
b(0);
|
||
break;
|
||
case CMD.INFO:
|
||
s(opt.legacy ? "FELUCCA 0.4 BETA (MOCK)" : opt.v3 ? "FELUCCA 0.8 (MOCK)" : "FELUCCA SLOOP 2.6 (MOCK)"); b(ENG.length); b(P_COUNT); b(G_COUNT); b(NSTEP); b(P_E0);
|
||
ENG.forEach((e) => s(e.name));
|
||
if (!opt.legacy) b(NTRK);
|
||
if (v5) b(mockProto); /* v12: LIVE (2.7), v11: your theme (2.7) */ /* v10: SYN kits (v9: FM6 patches, v8: fill conditions, v7: nudges and locks, v6: backup) */
|
||
break;
|
||
case CMD.GET: case CMD.SET: {
|
||
if (a.length < 2) return null;
|
||
const d = desc(a[0], a[1]);
|
||
if (!d) return null;
|
||
const arr = a[0] ? st.g : st.p;
|
||
if (cmd === CMD.SET && a.length >= 4) {
|
||
if (a[0] === 1 && a[1] === G_ENGSEL) setEngine(clamp(v14dec(a[2], a[3]), 0, ENG.length - 1));
|
||
else if (d.max > d.min) arr[a[1]] = clamp(v14dec(a[2], a[3]), d.min, d.max);
|
||
if (!a[0] && a[1] === P_E0 + 7 && st.engine === FM6_E && !drumSel()) fm6Slot(st.tracks[st.sel], arr[a[1]]); /* PTCH (fm6_poll) */
|
||
}
|
||
b(a[0]); b(a[1]); v(arr[a[1]]);
|
||
break;
|
||
}
|
||
case CMD.DUMP:
|
||
b(engOf(st.tracks[st.sel])); b(st.preset); st.p.forEach(v); st.g.forEach(v);
|
||
break;
|
||
case CMD.TRACK:
|
||
if (a.length >= 1 && a[0] < NTRK) st.sel = a[0];
|
||
b(st.sel); b(NTRK);
|
||
st.tracks.forEach((t, i) => { b(engOf(t)); b(t.preset); v(i === TRK_DRUM ? st.g[25] : t.p[0]); b(t.p[40] ? 1 : 0); b((st.rec >> i) & 1); });
|
||
if (v5) b(st.solo & 15);
|
||
break;
|
||
case CMD.TRACK_MIX: {
|
||
if (a.length < 1 || a[0] >= NTRK) return null;
|
||
const t = st.tracks[a[0]], drum = a[0] === TRK_DRUM;
|
||
if (a.length >= 4) {
|
||
const lv = clamp(v14dec(a[1], a[2]), 0, 127);
|
||
if (drum) st.g[25] = lv; else t.p[0] = lv;
|
||
t.p[40] = a[3] ? 1 : 0;
|
||
}
|
||
b(a[0]); v(drum ? st.g[25] : t.p[0]); b(t.p[40] ? 1 : 0);
|
||
break;
|
||
}
|
||
case CMD.TRACK_DUMP: {
|
||
if (a.length < 1 || a[0] >= NTRK) return null;
|
||
const t = st.tracks[a[0]];
|
||
b(a[0]); b(engOf(t)); b(t.preset); t.p.forEach(v);
|
||
break;
|
||
}
|
||
case CMD.TRACK_PARAM: {
|
||
if (a.length < 2 || a[0] >= NTRK || a[1] >= P_COUNT) return null;
|
||
const t = st.tracks[a[0]], d = tdesc(t, a[1]);
|
||
if (a.length >= 4 && d.max > d.min) t.p[a[1]] = clamp(v14dec(a[2], a[3]), d.min, d.max);
|
||
if (a.length >= 4 && a[1] === P_E0 + 7 && !t.drum && t.engine === FM6_E) fm6Slot(t, t.p[a[1]]); /* PTCH (fm6_poll) */
|
||
b(a[0]); b(a[1]); v(t.p[a[1]]);
|
||
break;
|
||
}
|
||
case CMD.TRACK_STEP: {
|
||
if (a.length < 2 || a[0] >= NTRK || a[1] >= NSTEP) return null;
|
||
const t = st.tracks[a[0]];
|
||
if (t.drum) {
|
||
if (a.length >= 10) dFromOld(t.dstep[a[1]], a[2], a.slice(3, 7), a[7], a[8]);
|
||
b(a[0]); b(a[1]); stepOut(b, dOld(t.dstep[a[1]]));
|
||
break;
|
||
}
|
||
const x = t.step[a[1]];
|
||
if (a.length >= 10) stepIn(x, a.slice(2));
|
||
b(a[0]); b(a[1]); stepOut(b, x);
|
||
break;
|
||
}
|
||
/* v7: parameter locks and nudges (firmware editor.c ED_LOCK_* / ED_MICRO_*) */
|
||
case CMD.LOCK_GET: {
|
||
if (a.length < 1 || a[0] >= NTRK) return null;
|
||
const t = st.tracks[a[0]];
|
||
b(a[0]); b(t.locks.length);
|
||
for (const l of t.locks) { b(l.step); b(l.param); v(l.value); }
|
||
break;
|
||
}
|
||
case CMD.LOCK_SET: {
|
||
if (a.length < 3 || a[0] >= NTRK) return null;
|
||
const t = st.tracks[a[0]], step = a[1], param = a[2];
|
||
let rc = step >= NSTEP || param >= P_COUNT ? 1 : !lockable(param, P_E0) ? 2 : 0;
|
||
if (!rc) {
|
||
const k = t.locks.findIndex((l) => l.step === step && l.param === param);
|
||
if (a.length >= 5) {
|
||
const d = tdesc(t, param), val = clamp(v14dec(a[3], a[4]), d.min, d.max);
|
||
if (k >= 0) t.locks[k].value = val;
|
||
else if (t.locks.length < NLOCK) t.locks.push({ step, param, value: val });
|
||
else rc = 3;
|
||
} else if (k >= 0) t.locks.splice(k, 1);
|
||
}
|
||
const l = rc === 1 ? null : t.locks.find((x) => x.step === step && x.param === param);
|
||
b(a[0]); b(step); b(param); b(rc); b(l ? 1 : 0); v(l ? l.value : 0);
|
||
break;
|
||
}
|
||
case CMD.MICRO_GET: {
|
||
if (a.length < 1 || a[0] >= NTRK) return null;
|
||
b(a[0]); st.tracks[a[0]].micro.forEach((m) => b(m + 64));
|
||
break;
|
||
}
|
||
case CMD.MICRO_SET: {
|
||
if (a.length < 3 || a[0] >= NTRK || a[1] >= NSTEP) return null;
|
||
const t = st.tracks[a[0]];
|
||
t.micro[a[1]] = clamp(a[2] - 64, MICRO.MIN, MICRO.MAX);
|
||
b(a[0]); b(a[1]); b(t.micro[a[1]] + 64);
|
||
break;
|
||
}
|
||
/* v8: the fill conditions (firmware editor.c ED_FILL_*): 16 bytes pack7, as stored; a set of one step */
|
||
case CMD.FILL_GET: {
|
||
if (a.length < 1 || a[0] >= NTRK) return null;
|
||
b(a[0]); out.push(...pack7(Uint8Array.from(st.tracks[a[0]].fill)));
|
||
break;
|
||
}
|
||
case CMD.FILL_SET: {
|
||
if (a.length < 3 || a[0] >= NTRK || a[1] >= NSTEP) return null;
|
||
const t = st.tracks[a[0]];
|
||
fillSet(t.fill, a[1], a[2] % 3);
|
||
b(a[0]); b(a[1]); b(fillGet(t.fill, a[1]));
|
||
break;
|
||
}
|
||
case CMD.DRUM_STEP: { /* v5: index [, on 3 x 7 bits, lvl 5 x 7, rat 5 x 7] */
|
||
if (a.length < 1 || a[0] >= NSTEP) return null;
|
||
const d = st.tracks[TRK_DRUM].dstep[a[0]];
|
||
if (a.length >= 14) {
|
||
const g = (k, n) => a.slice(k, k + n).reduce((x, y, j) => x + y * 2 ** (7 * j), 0);
|
||
const on = g(1, 3) & 0xFFFF, lv = g(4, 5) % 2 ** 32, rt = g(9, 5) % 2 ** 32;
|
||
Object.assign(d, emptyDrum());
|
||
d.on = on;
|
||
for (let l = 0; l < 16; l++) if ((on >> l) & 1) { d.lvl[l] = Math.floor(lv / 4 ** l) % 4; d.rat[l] = Math.floor(rt / 4 ** l) % 4; }
|
||
}
|
||
out.push(...req.drumStep(a[0], d)[1]);
|
||
break;
|
||
}
|
||
case CMD.DESC: {
|
||
if (a.length < 2) return null;
|
||
const d = desc(a[0], a[1]);
|
||
if (!d) return null;
|
||
b(a[0]); b(a[1]); b(d.fmt); v(d.min); v(d.max); v(d.def); s(d.label); s(d.unit || "");
|
||
if (d.fmt === F.ENUM && d.names) for (let i = 0; i <= d.max - d.min && i < 64; i++) s(d.names[i]);
|
||
break;
|
||
}
|
||
case CMD.STEP_GET: case CMD.STEP_SET: {
|
||
if (a.length < 1 || a[0] >= NSTEP) return null;
|
||
if (drumSel()) {
|
||
const d = st.tracks[st.sel].dstep[a[0]];
|
||
if (cmd === CMD.STEP_SET && a.length >= 9) dFromOld(d, a[1], a.slice(2, 6), a[6], a[7]);
|
||
b(a[0]); stepOut(b, dOld(d));
|
||
break;
|
||
}
|
||
const x = st.step[a[0]];
|
||
if (cmd === CMD.STEP_SET && a.length >= 9) stepIn(x, a.slice(1));
|
||
b(a[0]); stepOut(b, x);
|
||
break;
|
||
}
|
||
case CMD.PRESET:
|
||
if (a.length < 2 || a[0] >= ENG.length) return null;
|
||
if (a[0] !== st.engine) setEngine(a[0]);
|
||
applyPreset(a[1]);
|
||
b(engOf(st.tracks[st.sel])); b(st.preset);
|
||
break;
|
||
case CMD.PROJECT: {
|
||
if (a.length < 2) return null;
|
||
const k = a[1] & 3;
|
||
if (a[0] > 2) return null;
|
||
if (a[0] === 1) st.slots[k] = project();
|
||
else if (a[0] === 0 && st.slots[k]) Object.assign(st, JSON.parse(JSON.stringify(st.slots[k])));
|
||
b(a[0]); b(k); b(st.slots[k] ? 1 : 0);
|
||
break;
|
||
}
|
||
case CMD.NAMES:
|
||
if (a.length < 1 || a[0] >= ENG.length) return null;
|
||
b(a[0]); b(ENG[a[0]].presets.length); ENG[a[0]].presets.forEach((p) => s(p.name));
|
||
ENG[a[0]].titles.forEach(s);
|
||
break;
|
||
/* user sample slots: the header is checked like the firmware's ed_smp_end() */
|
||
case CMD.SMP_BEGIN: case CMD.SMP_ERASE: {
|
||
if (a.length < 1 || a[0] >= st.smp.length) return null;
|
||
const u = st.smp[a[0]];
|
||
if (cmd === CMD.SMP_ERASE) u.flash.fill(0xFF); else u.flash.fill(0xFF, 0, 4096);
|
||
u.zones = 0; u.name = ""; u.len = 0; u.next = SMP.DATA_OFF;
|
||
b(a[0]); b(0);
|
||
break;
|
||
}
|
||
case CMD.SMP_WRITE: {
|
||
if (a.length < 5 || a[0] >= st.smp.length) return null;
|
||
const u = st.smp[a[0]], off = a[1] | (a[2] << 7) | (a[3] << 14), dat = unpack7(a.slice(4));
|
||
let rc = 0;
|
||
if (off < SMP.DATA_OFF || (off & 0xFF) || !dat.length || off + dat.length > SMP.SLOT_SIZE || dat.length > 256) rc = 1;
|
||
else {
|
||
if (!(off & 0xFFF)) u.flash.fill(0xFF, off, off + 4096);
|
||
u.flash.set(dat, off);
|
||
u.next = off + dat.length;
|
||
}
|
||
b(a[0]); b(off); b(off >> 7); b(off >> 14); b(rc);
|
||
break;
|
||
}
|
||
case CMD.SMP_END: {
|
||
if (a.length < 2 || a[0] >= st.smp.length) return null;
|
||
const u = st.smp[a[0]], hd = unpack7(a.slice(1)), dv = new DataView(hd.buffer);
|
||
let rc = 0;
|
||
if (hd.length < SMP.HDR_LEN || dv.getUint32(0, true) !== 0x504D5346 || dv.getUint16(4, true) !== 1) rc = 2;
|
||
else if (!hd[6] || hd[6] > 16) rc = 5;
|
||
else {
|
||
const len = dv.getUint32(16, true);
|
||
if (len > SMP.MAX_DATA) rc = 1;
|
||
else if (crc32(u.flash.subarray(SMP.DATA_OFF, SMP.DATA_OFF + len)) !== dv.getUint32(20, true)) rc = 3;
|
||
else {
|
||
u.flash.set(hd, 0);
|
||
u.zones = hd[6]; u.len = len;
|
||
u.name = String.fromCharCode(...hd.slice(8, 16)).replace(/\0.*$/, "");
|
||
}
|
||
}
|
||
b(a[0]); b(rc);
|
||
break;
|
||
}
|
||
/* v6 backup: the mock's objects are JSON bytes (projects, banks) and the raw sample slots */
|
||
case CMD.BK_LIST: {
|
||
if (opt.noBackup) return null;
|
||
const enc = (o) => Uint8Array.from(Array.from(JSON.stringify(o), (c) => c.charCodeAt(0) & 0x7F));
|
||
const bankOf = (h) => { const x = st.bank.slice(h * 16, h * 16 + 16); return x.some(Boolean) ? enc(x) : new Uint8Array(0); };
|
||
st.bkSnap = new Map([[0, enc(project())], [1, st.settings.slice()], ...[0, 1, 2, 3].map((k) => [2 + k, st.slots[k] ? enc(st.slots[k]) : new Uint8Array(0)]),
|
||
[6, bankOf(0)], [7, bankOf(1)], ...(v9 ? [[8, st.fm6bank.some(Boolean) ? FM6.bankObj(st.fm6bank) : new Uint8Array(0)]] : []),
|
||
...(v10 ? [[9, DSYN.bankEncode(dsynKits())]] : []),
|
||
...(v10 && st.ml && !mlDefault(st.ml) ? [[10, st.ml.slice()]] : []), /* MIDI LEARN (2.6): only when not the
|
||
* default (editor.c, project.c midi_part_default) */
|
||
...(v11 && st.theme ? [[11, st.theme.slice()]] : []), /* your theme (2.7): only when there is one */
|
||
...st.smp.map((_, k) => [32 + k, st.smp[k].zones ? st.smp[k].flash.slice(0, SMP.DATA_OFF + st.smp[k].len) : new Uint8Array(0)])]);
|
||
st.bkPut = null;
|
||
b(0); b(st.bkSnap.size);
|
||
for (const [id, d] of st.bkSnap) { b(id); out.push(...u35enc(d.length), ...u35enc(crc32(d))); }
|
||
break;
|
||
}
|
||
case CMD.BK_GET: {
|
||
if (opt.noBackup || a.length !== 8) return null;
|
||
const r = new Reader(a), id = r.b(), off = u35dec(r), n = r.b() | (r.b() << 7);
|
||
const d = st.bkSnap && st.bkSnap.get(id);
|
||
const rc = !d || !n || n > 256 || off + n > d.length ? 1 : st.bkPut && id === 0 ? 5 : 0;
|
||
b(id); b(rc); out.push(...u35enc(off)); b(rc ? 0 : n); b(rc ? 0 : n >> 7);
|
||
if (!rc) out.push(...pack7(d.subarray(off, off + n)));
|
||
break;
|
||
}
|
||
case CMD.BK_PUT: {
|
||
if (opt.noBackup || a.length < 2) return null;
|
||
const op = a[0], id = a[1], r = new Reader(a.slice(2));
|
||
let rc = 1;
|
||
if (op === 0 && a.length === 12 && [0, 1, 2, 3, 4, 5, 6, 7, ...(v9 ? [8] : []), ...(v10 ? [9, 10] : []), ...(v11 ? [11] : [])].includes(id)) {
|
||
const len = u35dec(r), crc = u35dec(r);
|
||
if ((id >= 2 || len) && len <= 1 << 20) { st.bkPut = { id, len, crc, pos: 0, buf: new Uint8Array(len) }; st.bkSnap = null; rc = 0; }
|
||
} else if (!st.bkPut || st.bkPut.id !== id) rc = 5;
|
||
else if (op === 1 && a.length >= 9) {
|
||
const off = u35dec(r), d = unpack7(a.slice(7));
|
||
if (off === st.bkPut.pos && d.length && d.length <= st.bkPut.len - off) { st.bkPut.buf.set(d, off); st.bkPut.pos += d.length; rc = 0; }
|
||
} else if (op === 2) {
|
||
const P = st.bkPut;
|
||
st.bkPut = null;
|
||
rc = P.pos !== P.len || crc32(P.buf) !== P.crc ? 2 : 0;
|
||
if (!rc) try {
|
||
const js = () => JSON.parse(Array.from(P.buf, (c) => String.fromCharCode(c)).join(""));
|
||
if (id === 1) { /* project.c settings_restore */
|
||
if (P.len !== st.settings.length || !ARR.ok(P.buf) || P.buf[ARR.OFF] > ARR.STEPS || P.buf[ARR.OFF + 1] > 1 || !ARR.valid(ARR.decode(P.buf))) throw 0;
|
||
if (st.playing && P.buf.subarray(ARR.OFF, ARR.OFF + ARR.SIZE).some((v, k) => v !== st.settings[ARR.OFF + k])) { rc = 3; }
|
||
else st.settings = P.buf.slice();
|
||
}
|
||
else if (id === 0) { const o = js(); st.tracks = o.tracks; st.sel = o.sel; st.g = o.g; }
|
||
else if (id <= 5) st.slots[id - 2] = P.len ? js() : null;
|
||
else if (id === 11) { /* your theme (2.7; editor.c: stopped only; 0 bytes: none) */
|
||
const th = P.len ? THEME.decode(P.buf) : null;
|
||
if (P.len && (!th || !THEME.readable(th))) throw 0;
|
||
if (st.playing) rc = 3;
|
||
else st.theme = P.len ? THEME.encode(th) : null; /* (kept as gfx.c keeps it: a THM1 as THM2) */
|
||
}
|
||
else if (id === 10) { /* the MIDI part (2.6; editor.c: stopped only): the LEARN
|
||
map (16 x 2 bytes), then GLO > MIDI's channels (4 bytes) */
|
||
if (P.len !== 32 && P.len !== 36 && P.len !== 40) throw 0;
|
||
if (st.playing) rc = 3;
|
||
else st.ml = P.buf.slice();
|
||
}
|
||
else if (id === 9) { /* the SYN kits (with the settings: stopped only) */
|
||
const k = DSYN.bankDecode(P.buf);
|
||
if (!k) throw 0;
|
||
if (st.playing) rc = 3;
|
||
else { st.dsyn = k.map((x) => ({ ...x, sounds: x.sounds.map((y) => DSYN.encode(DSYN.decode(y))) })); st.dsynStored = DSYN.bankEncode(st.dsyn); }
|
||
}
|
||
else if (id === 8) { /* the PTCH bank (fm6_bank_t; editor.c: stopped only) */
|
||
const x = FM6.bankUnobj(P.buf);
|
||
if (!x) throw 0;
|
||
if (st.playing) rc = 3;
|
||
else { st.fm6bank = x.map((pk) => (pk ? FM6.pack(FM6.unpack(pk)) : null)); st.fm6bank.forEach((_, i) => fm6BankChanged(i)); }
|
||
}
|
||
else { const x = P.len ? js() : new Array(16).fill(null); for (let i = 0; i < 16; i++) st.bank[(id - 6) * 16 + i] = x[i] || null; }
|
||
} catch (e) { rc = 2; }
|
||
} else if (op === 3) { st.bkPut = null; rc = 0; }
|
||
b(op); b(id); b(rc);
|
||
break;
|
||
}
|
||
case CMD.FM6_GET: case CMD.FM6_PUT: case CMD.FM6_LIST: case CMD.FM6_ERASE: { /* editor_fm6.c */
|
||
const nf = FM6.FACTORY_PK.length;
|
||
if (cmd === CMD.FM6_LIST) {
|
||
if (a.length) return null;
|
||
b(nf); b(FM6_BANK);
|
||
for (let i = 0; i < nf + FM6_BANK; i++) {
|
||
const pk = i < nf ? FM6.FACTORY_PK[i] : st.fm6bank[i - nf];
|
||
b(pk ? 1 : 0); if (pk) s(FM6.name(FM6.unpack(pk))); else b(0);
|
||
}
|
||
} else if (cmd === CMD.FM6_ERASE) {
|
||
const rc = a.length !== 1 || a[0] >= FM6_BANK ? 1 : st.playing ? 3 : 0;
|
||
if (!rc) { st.fm6bank[a[0]] = null; fm6BankChanged(a[0]); }
|
||
b(a.length ? a[0] : 127); b(rc);
|
||
} else if (cmd === CMD.FM6_GET) {
|
||
let rc = a.length !== 2 || a[0] > 2 ? 1 : 0, pk = null;
|
||
if (!rc && a[0] === 0) { if (a[1] < FM6_NPART) pk = st.tracks[a[1]].fm6; else rc = 1; }
|
||
else if (!rc && a[0] === 1) { if (a[1] < FM6_BANK) { pk = st.fm6bank[a[1]]; if (!pk) rc = 2; } else rc = 1; } /* 2: an empty slot */
|
||
else if (!rc) { if (a[1] < nf) pk = FM6.FACTORY_PK[a[1]]; else rc = 1; } /* 1: a bad index */
|
||
b(a.length ? a[0] : 127); b(a.length > 1 ? a[1] : 127); b(rc);
|
||
if (!rc) pk.forEach(b);
|
||
} else {
|
||
let rc = a.length !== 2 + FM6.PACKED ? 1 : 0;
|
||
const pk = rc ? null : FM6.pack(FM6.unpack(a.slice(2))); /* (every value into its range) */
|
||
if (!rc && a[0] === 0 && a[1] < FM6_NPART) st.tracks[a[1]].fm6 = pk;
|
||
else if (!rc && a[0] === 1 && a[1] < FM6_BANK) {
|
||
if (st.playing) rc = 3;
|
||
else { st.fm6bank[a[1]] = pk; fm6BankChanged(a[1]); }
|
||
} else rc = 1;
|
||
b(a.length ? a[0] : 127); b(a.length > 1 ? a[1] : 127); b(rc);
|
||
}
|
||
break;
|
||
}
|
||
case CMD.DSYN_LIST: case CMD.DSYN_GET: case CMD.DSYN_PUT: case CMD.DSYN_STORE: case CMD.DSYN_PLAY: { /* editor_dsyn.c */
|
||
const K = dsynKits(), nf = DSYN_MOCK_NAMES.length;
|
||
if (cmd === CMD.DSYN_LIST) {
|
||
if (a.length) return null;
|
||
b(nf); b(K.length); b(DSYN.bankEncode(K).every((x, i) => x === st.dsynStored[i]) ? 1 : 0);
|
||
DSYN_MOCK_NAMES.forEach(s);
|
||
K.forEach((k) => { s(k.name); b(k.src); });
|
||
} else if (cmd === CMD.DSYN_GET) {
|
||
const w = a.length === 1 ? a[0] : 127, k = w < nf ? dsynFactory(w) : w >= DSYN.USER && w < DSYN.USER + K.length ? K[w - DSYN.USER] : null;
|
||
b(w); b(k ? 0 : 1);
|
||
if (k) { s(k.name); pack7(Uint8Array.from([k.crush, k.src, ...k.sounds.flatMap((x) => Array.from(x))])).forEach(b); }
|
||
} else if (cmd === CMD.DSYN_PUT) {
|
||
const k = a.length >= 2 ? a[0] : 127, part = a.length >= 2 ? a[1] : 127, d = unpack7(a.slice(2));
|
||
let rc = 1;
|
||
if (k < K.length && part < DSYN.LANES && d.length === DSYN.SIZE) { K[k].sounds[part] = DSYN.encode(DSYN.decode(d)); rc = 0; }
|
||
else if (k < K.length && part === 16 && d.length === 10) {
|
||
K[k].name = String.fromCharCode(...d.subarray(0, 8)).replace(/\0.*$/, ""); K[k].crush = d[8]; K[k].src = d[9] % nf; rc = 0;
|
||
} else if (k < K.length && part === 17 && d.length === 1 && d[0] < nf) { K[k] = dsynFactory(d[0]); rc = 0; }
|
||
b(k); b(part); b(rc);
|
||
} else if (cmd === CMD.DSYN_STORE) {
|
||
if (a.length) return null;
|
||
const rc = st.playing ? 3 : 0;
|
||
if (!rc) st.dsynStored = DSYN.bankEncode(K);
|
||
b(rc);
|
||
} else {
|
||
const rc = a.length !== 3 || a[0] >= K.length || a[1] >= DSYN.LANES || !a[2] ? 1 : 0;
|
||
if (!rc) st.dsynPlayed.push({ k: a[0], lane: a[1], vel: a[2], sound: K[a[0]].sounds[a[1]].slice() });
|
||
b(a.length ? a[0] : 127); b(a.length > 1 ? a[1] : 127); b(rc);
|
||
}
|
||
break;
|
||
}
|
||
case CMD.SMP_INFO:
|
||
b(st.smp.length); b(SMP.SLOT_SIZE / 1024);
|
||
st.smp.forEach((u) => { b(u.zones); s(u.zones ? u.name : ""); b(u.zones ? Math.ceil(u.len / 1024) : 0); });
|
||
break;
|
||
case CMD.LIVE: { /* v12: firmware editor_live.c */
|
||
if (a.length < 1 || !v5 || mockProto < 12) return null;
|
||
liveOp(a);
|
||
liveState(b, v, a[0]);
|
||
break;
|
||
}
|
||
default:
|
||
return null;
|
||
}
|
||
return frame(cmd, out);
|
||
}
|
||
|
||
/* ---- v12: LIVE (firmware editor_live.c, the FM-1's own code for each control: ui_layers.c layer_key, rec_toggle) */
|
||
const barMs = () => 240000 / Math.max(40, st.g[0]);
|
||
const nextBar = () => st.live.t0 + Math.ceil((Date.now() - st.live.t0 + 1) / barMs()) * barMs();
|
||
const lenOf = (t) => Math.max(1, t.p[29] | 0);
|
||
function liveTick() { /* what the sequencer does on the bar */
|
||
const L = st.live, now = Date.now();
|
||
if (!st.playing) return;
|
||
if (L.next >= 0 && now >= L.nextAt) { L.sec = L.next; L.next = -1; }
|
||
if (L.fillBar && now >= L.fillAt) { L.fillBar = false; L.fillTo = L.fillAt + barMs(); }
|
||
}
|
||
function liveOp(a) {
|
||
const L = st.live, [op, x = 0, y = 0, z = 0] = a;
|
||
liveTick();
|
||
if (op === LIVE.PLAY) {
|
||
const play = x === 2 ? !st.playing : !!x;
|
||
if (play && !st.playing && !(L.songMode && !st.slots.some(Boolean))) { st.playing = true; L.t0 = Date.now(); }
|
||
else if (!play && st.playing) { st.playing = false; L.next = -1; L.fillBar = false; if (st.rec) st.rec = 0; }
|
||
} else if (op === LIVE.KEY && a.length >= 4 && x === LIVE.LY_MIX && y < 16) {
|
||
if (!z) { if (y === LIVE.FILL) L.fillHeld = false; return; }
|
||
if (y < 4) st.tracks[y].p[40] = st.tracks[y].p[40] ? 0 : 1;
|
||
else if (y < 8) st.solo ^= 1 << (y - 4);
|
||
else if (y === LIVE.FILL) L.fillHeld = true;
|
||
else if (y === LIVE.FILL_BAR) { L.fillBar = !L.fillBar; L.fillAt = nextBar(); }
|
||
else if (y === LIVE.TAP) { /* ui_layers.c tap_tempo: the last taps' mean, 40..240 */
|
||
const now = Date.now();
|
||
if (L.taps.length && now - L.taps[L.taps.length - 1] > 2000) L.taps = [];
|
||
L.taps.push(now);
|
||
if (L.taps.length > 4) L.taps.shift();
|
||
if (L.taps.length >= 2) st.g[0] = clamp(Math.round(60000 * (L.taps.length - 1) / (now - L.taps[0])), 40, 240);
|
||
}
|
||
} else if (op === LIVE.KEY && a.length >= 4 && x === LIVE.LY_SONG && y < 16 && z) {
|
||
if (y < 4) {
|
||
if (st.live.songMode && st.playing) return; /* (SONG PLAYS) */
|
||
if (!st.slots[y]) return; /* (EMPTY) */
|
||
if (st.playing) { L.next = y; L.nextAt = nextBar(); }
|
||
else { L.sec = y; L.next = -1; }
|
||
} else if (y < 8) {
|
||
const k = y - 4, now = Date.now();
|
||
if (st.slots[k] && !(L.armed === k && now - L.armedAt < 3000)) { L.armed = k; L.armedAt = now; return; }
|
||
L.armed = -1;
|
||
st.slots[k] = project();
|
||
L.sec = k;
|
||
} else if (y === LIVE.SONG) { if (!L.srec) L.songMode = !L.songMode; }
|
||
else if (y === LIVE.SONG_REC) {
|
||
if (L.srec) L.srec = 0;
|
||
else if (!(L.songMode && st.playing)) { L.songMode = false; L.srec = 1; }
|
||
}
|
||
} else if (op === LIVE.FX && a.length >= 3 && x < LIVE.NFX) {
|
||
if (y) L.fx = x; else if (L.fx === x) L.fx = -1;
|
||
} else if (op === LIVE.REC) { /* ui_studio.c rec_toggle */
|
||
if (L.ft) { L.ft = false; st.playing = true; L.t0 = Date.now(); return; } /* a free take: REC closes the loop */
|
||
if (st.playing && L.songMode) return;
|
||
if (st.rec || L.recWait) { st.rec = 0; L.recWait = false; return; }
|
||
L.songMode = false;
|
||
if (st.playing) { st.rec = 1 << st.sel; L.undo = 1; } else L.recWait = true;
|
||
} else if (op === LIVE.UNDO && a.length >= 2) {
|
||
if (x && L.undo === 2) L.undo = 1; else if (!x && L.undo === 1) L.undo = 2;
|
||
} else if ((op === LIVE.ROLL && a.length >= 5) || (op === LIVE.ERASE && a.length >= 4)) { /* (kept for the tests) */
|
||
const set = op === LIVE.ROLL ? L.rolls : L.erase, k = `${x}:${y}`, down = op === LIVE.ROLL ? a[4] : z;
|
||
if (down) set.add(k); else set.delete(k);
|
||
if (op === LIVE.ERASE && down && x === 3) st.tracks[3].dsteps?.forEach((d) => { if (d) d.on &= ~(1 << y); });
|
||
} else if (op === LIVE.PATTERN && a.length >= 4 && x < 4) {
|
||
const t = st.tracks[x], len = lenOf(t);
|
||
if (y === 1) t.p[29] = z ? Math.min(64, len * 2) : Math.max(1, len >> 1);
|
||
L.pattern.push([x, y, z]);
|
||
} else if (op === LIVE.CHAIN) {
|
||
L.chain = x && st.playing && a.length >= 1 + x ? a.slice(2, 2 + x).map((c) => c & 3) : [];
|
||
if (L.chain.length) { L.next = L.chain[0]; L.nextAt = nextBar(); }
|
||
} else if (op === LIVE.THROW) L.thr = x & 3;
|
||
else if (op === LIVE.MASTER) L.master = x >= 127 ? 0 : x + 1;
|
||
else if (op === LIVE.DRUM_TW && a.length >= 4) L.dtw[x & 15] = (Math.min(15, y) & 15) | ((Math.min(7, z) & 7) << 4);
|
||
}
|
||
function liveState(b, v, op) {
|
||
const L = st.live, now = Date.now(), el = now - L.t0, mutes = st.tracks.reduce((m, t, i) => m | (t.p[40] ? 1 << i : 0), 0);
|
||
liveTick();
|
||
b(op);
|
||
b((st.playing ? 1 : 0) | (L.songMode ? 4 : 0) | (L.songMode && st.playing ? 8 : 0) | (L.fillHeld || now < L.fillTo ? 16 : 0)
|
||
| (L.fillBar ? 32 : 0) | (L.srec ? 64 : 0));
|
||
b((L.recWait ? 1 : 0) | (L.undo === 1 ? 2 : 0) | (L.undo === 2 ? 4 : 0) | (L.ft ? 8 : 0));
|
||
v(st.g[0]); b(L.sec + 1); b(L.next + 1); b(L.chain.length >= 2 ? L.chain.length : 0); b(0); b(mutes); b(st.solo & 15); b(st.rec & 15); b(st.sel); b(L.fx + 1);
|
||
b(st.playing ? 18 + Math.round(Math.random() * 6) : 9);
|
||
b(0); b(4); b(0); b(4); /* (the song: entry 0 of 4, bar 0 of 4) */
|
||
b(st.slots.reduce((m, x, k) => m | (x ? 1 << k : 0), 0));
|
||
st.tracks.forEach((t, i) => {
|
||
const steps = st.playing ? Math.floor(el * st.g[0] / 15000) : 0, heard = st.playing && !t.p[40] && !(st.solo && !((st.solo >> i) & 1));
|
||
b(steps % lenOf(t)); b(lenOf(t)); b(heard ? 70 + Math.round(Math.random() * 40) : 0);
|
||
});
|
||
if (mockProto >= 12) { b(L.master); b(L.thr); L.dtw.forEach((x) => b(x)); } /* (2.7: 50 bytes) */
|
||
}
|
||
|
||
/* a WebMIDI-like access object: one input and one output named "Felucca" */
|
||
const input = { id: "mock-in", name: "Felucca", type: "input", state: "connected", onmidimessage: null };
|
||
let busy = false;
|
||
const output = {
|
||
id: "mock-out", name: "Felucca", type: "output", state: "connected",
|
||
send(data) {
|
||
if (data && data.length && data[0] !== 0xF0) { /* v12 (LIVE): a note, as a keyboard would play it */
|
||
st.midiIn.push(Array.from(data));
|
||
if (st.live.recWait && (data[0] & 0xF0) === 0x90 && data[2] && !st.slots.some(Boolean)) { st.live.recWait = false; st.live.ft = true; } /* an empty project: a free take */
|
||
if (st.midiIn.length > 64) st.midiIn.shift();
|
||
if (opt.onNote) opt.onNote(Array.from(data));
|
||
return;
|
||
}
|
||
const f = unframe(data);
|
||
if (!f) { console.error("mock: refused a frame that is not F0 7D 46 4C ... F7", data); return; }
|
||
if (busy) { console.warn("mock: frame dropped (device holds only one frame)", data); return; }
|
||
busy = true;
|
||
watching(); /* a lapsed WATCH ends before this request counts */
|
||
st.lastReq = Date.now();
|
||
const flash = [CMD.UP_PUT, CMD.UP_STORE, CMD.UP_ERASE].includes(f.cmd) && !opt.legacy;
|
||
setTimeout(() => {
|
||
busy = false;
|
||
const r = handle(f.cmd, f.a);
|
||
if (r && opt.onChange && [CMD.SET, CMD.STEP_SET, CMD.PRESET, CMD.PROJECT, CMD.UP_LOAD, CMD.TRACK,
|
||
CMD.TRACK_MIX, CMD.TRACK_PARAM, CMD.TRACK_STEP, CMD.DRUM_STEP, CMD.LOCK_SET, CMD.MICRO_SET,
|
||
CMD.FILL_SET, CMD.FM6_PUT, CMD.FM6_ERASE, CMD.DSYN_PUT, CMD.DSYN_PLAY, CMD.SMP_END,
|
||
CMD.SMP_ERASE, CMD.BK_PUT, CMD.LIVE].includes(f.cmd)) opt.onChange(f.cmd, f.a);
|
||
if (r && input.onmidimessage) input.onmidimessage({ data: Uint8Array.from(r) });
|
||
const ra = r ? r.slice(5, -1) : [];
|
||
if (r && ((f.cmd === CMD.SET && f.a[0] === 1 && f.a[1] === G_ENGSEL) || f.cmd === CMD.PRESET
|
||
|| (f.cmd === CMD.PROJECT && f.a[0] === 0 && ra[2]) || (f.cmd === CMD.UP_LOAD && !ra[1]))) reloadPush();
|
||
}, f.cmd === CMD.SMP_ERASE ? 900 : f.cmd === CMD.SMP_BEGIN ? 120 : flash ? 150 : f.cmd === CMD.SMP_WRITE ? 25 + Math.random() * 10 : 4 + Math.random() * 12);
|
||
},
|
||
};
|
||
/* WATCH ends by itself watchMs after the last request */
|
||
function watching() {
|
||
if (st.watch && Date.now() - st.lastReq > watchMs) st.watch = false;
|
||
return st.watch;
|
||
}
|
||
function push(cmd, args) {
|
||
if (!watching()) return false;
|
||
const fr = Uint8Array.from(frame(cmd, args));
|
||
setTimeout(() => { if (input.onmidimessage) input.onmidimessage({ data: fr }); }, 0);
|
||
return true;
|
||
}
|
||
const reloadPush = () => push(CMD.RELOAD, opt.legacy ? [st.engine, st.preset] : [engOf(st.tracks[st.sel]), st.preset, st.sel]);
|
||
/* things done on the device itself */
|
||
const sim = {
|
||
knob(id = [9, 33, 35, P_E0 + 4][Math.floor(Math.random() * 4)], dv = Math.random() < 0.5 ? -4 : 4) {
|
||
const d = desc(0, id);
|
||
st.p[id] = clamp(st.p[id] + dv, d.min, d.max);
|
||
push(CMD.CHANGED, [0, id, ...v14enc(st.p[id])]);
|
||
return { id, value: st.p[id] };
|
||
},
|
||
reload(pi = st.preset + 1) {
|
||
applyPreset(pi);
|
||
reloadPush();
|
||
return { engine: st.engine, preset: st.preset };
|
||
},
|
||
track(i = (st.sel + 1) % NTRK) { /* TRACKS page KNOB 1 */
|
||
st.sel = i;
|
||
reloadPush();
|
||
return i;
|
||
},
|
||
/* TRACKS page KNOB 2: the selected track's level (the drum track: G_DRLVL); pushes CHANGED */
|
||
level(v) {
|
||
const drum = st.sel === TRK_DRUM;
|
||
v = clamp(v, 0, 127);
|
||
if (drum) st.g[25] = v; else st.p[0] = v;
|
||
push(CMD.CHANGED, drum ? [1, 25, ...v14enc(v)] : [0, 0, ...v14enc(v)]);
|
||
return v;
|
||
},
|
||
mute(on = !st.p[40]) { st.p[40] = on ? 1 : 0; push(CMD.CHANGED, [0, 40, ...v14enc(st.p[40])]); return st.p[40]; },
|
||
/* a parameter of track i changed on the device: CHANGED for the selected track, else TRACK_CHANGED (v4 watch) */
|
||
param(i, id, val) {
|
||
const t = st.tracks[i], d = id >= P_E0 ? ENG[t.engine].edit[id - P_E0] : TP[id];
|
||
t.p[id] = clamp(val, d.min, d.max);
|
||
if (i === st.sel) push(CMD.CHANGED, [0, id, ...v14enc(t.p[id])]);
|
||
else if (st.v4) push(CMD.TRACK_CHANGED, [i, id, ...v14enc(t.p[id])]);
|
||
return t.p[id];
|
||
},
|
||
/* SEQ + a step held + KNOB 4 / PRESETS on the device: a nudge or a lock; the firmware pushes STEP_CHANGED for it */
|
||
nudge(i = 4, m = -8) { st.tracks[st.sel].micro[i] = clamp(m, MICRO.MIN, MICRO.MAX); push(CMD.STEP_CHANGED, [i, st.sel]); return i; },
|
||
/* SEQ + a step held + OCT+ on the device: its fill condition (v8); the same push */
|
||
fill(i = 4, c = 1) { fillSet(st.tracks[st.sel].fill, i, c); push(CMD.STEP_CHANGED, [i, st.sel]); return i; },
|
||
lock(i = 4, param = 33, val = 100) {
|
||
const t = st.tracks[st.sel], k = t.locks.findIndex((l) => l.step === i && l.param === param);
|
||
if (k >= 0) t.locks[k].value = val; else t.locks.push({ step: i, param, value: val });
|
||
push(CMD.STEP_CHANGED, [i, st.sel]);
|
||
return i;
|
||
},
|
||
/* PLAY / STOP on the device: flash writes (the FM6 bank) answer rc 3 while it plays */
|
||
play(on = !st.playing) { st.playing = !!on; return st.playing; },
|
||
/* REC on TRACKS: arm / disarm live recording of a track (no push: the editor reads TRACK) */
|
||
arm(i = st.sel) { st.rec ^= 1 << i; return (st.rec >> i) & 1; },
|
||
step(i = Math.floor(Math.random() * 16)) {
|
||
const x = st.step[i];
|
||
if (drumSel()) { const d = st.tracks[st.sel].dstep[i]; d.on ^= 1 << 4; d.lvl[4] = d.rat[4] = 0; } /* the hat lane */
|
||
else if (x.n) x.flags ^= 1;
|
||
else Object.assign(x, { n: 1, notes: [60 + Math.floor(Math.random() * 12), 0, 0, 0], time: 0, flags: 0, vel: 96 });
|
||
push(CMD.STEP_CHANGED, opt.legacy ? [i] : [i, st.sel]);
|
||
return i;
|
||
},
|
||
};
|
||
if (opt.auto !== false) st.rec = 1 << 2; /* the browser mock: track 3 armed, to show it */
|
||
const timers = opt.auto === false ? [] : [
|
||
setInterval(() => sim.knob(), 3000),
|
||
setInterval(() => sim.step(), 11000),
|
||
setInterval(() => sim.reload(), 27000),
|
||
setInterval(() => sim.param((st.sel + 1) % NTRK, 39, Math.round(Math.random() * 80) - 40), 13000), /* pan of another track */
|
||
];
|
||
return {
|
||
state: st, sim,
|
||
stop: () => timers.forEach(clearInterval),
|
||
access: { sysexEnabled: true, inputs: new Map([[input.id, input]]), outputs: new Map([[output.id, output]]), onstatechange: null },
|
||
};
|
||
}
|
||
/* A detached snapshot for the audio thread; flash is copied only after an upload or a new start. */
|
||
/* A compact sequencer click toggles a whole synth step, or just one drum lane.
|
||
Other drum hits, levels and ratchets are preserved. Never mutate the snapshot. */
|
||
function previewToggleStep(step, note) {
|
||
// REST silences a step in the real sequencer without erasing its pitches or expression.
|
||
if (step.time === 1) return { ...step, notes: step.notes.slice(), time: 2 };
|
||
if (step.n > 0) return { ...step, notes: step.notes.slice(), time: step.time === 0 ? 2 : 0 };
|
||
return previewSetStepNotes(step, [note]);
|
||
}
|
||
function previewSetStepNotes(step, notes) {
|
||
return { ...step, n: notes.length, notes: [...notes, 0, 0, 0, 0].slice(0, 4), time: 0, vel: step.vel || 100 };
|
||
}
|
||
function previewToggleDrum(step, lane) {
|
||
const d = { ...step, lvl: step.lvl.slice(), rat: step.rat.slice() };
|
||
d.on ^= 1 << lane; d.lvl[lane] = d.rat[lane] = 0;
|
||
return d;
|
||
}
|
||
function previewSnapshot(st, includeSamples = false) {
|
||
const state = JSON.parse(JSON.stringify({ tracks: st.tracks, g: st.g, sel: st.sel, solo: st.solo }));
|
||
if (includeSamples) state.samples = st.smp.map((s) => s.flash.slice());
|
||
if (st.dsyn) {
|
||
const bank = DSYN.bankEncode(st.dsyn);
|
||
state.kits = Array.from({ length: 4 }, (_, i) => bank.slice(8 + i * 364, 8 + (i + 1) * 364));
|
||
}
|
||
return state;
|
||
}
|
||
/* ------------------------------------------------------------ drum kit (2.4) --- */
|
||
/* The DRUM KIT page: a user slot whose zones are the drum track's 16 lanes (firmware drums.c, KIT USR1..USR3: a lane
|
||
plays the zone holding its GM note, at its own pitch). A pad: {s: Int16Array at SMP.RATE (normalised), fname,
|
||
tune: semitones -12..12, gain: dB -24..0, len: samples kept (0 = all)}; pads[l] for lane l, or null. */
|
||
const KIT = { TUNE: 12, GAIN_MIN: -24, FADE: Math.round(SMP.RATE * 0.004) };
|
||
/* a pad as it goes to the slot: tuned (played faster or slower, as a sampler does), cut, faded out, its gain */
|
||
function kitPad(p) {
|
||
let x = Array.from(p.s);
|
||
if (p.tune) x = resample(x, SMP.RATE * Math.pow(2, p.tune / 12), SMP.RATE);
|
||
const n = Math.max(1, Math.min(x.length, p.len > 0 ? Math.round(p.len) : x.length));
|
||
const g = Math.pow(10, Math.max(KIT.GAIN_MIN, Math.min(0, p.gain || 0)) / 20), out = new Int16Array(n);
|
||
const fade = n < x.length ? Math.min(KIT.FADE, n) : 0; /* a cut sound ends in 4 ms, not with a click */
|
||
for (let i = 0; i < n; i++) {
|
||
const f = fade && i >= n - fade ? (n - i) / fade : 1;
|
||
out[i] = Math.max(-32768, Math.min(32767, Math.round(x[i] * g * f)));
|
||
}
|
||
return out;
|
||
}
|
||
/* the slot's zones: one per pad, lo = hi = root = its lane's note */
|
||
function kitZones(pads) {
|
||
const zs = [];
|
||
pads.forEach((p, l) => { if (p) zs.push({ s: kitPad(p), root: DRUM_LANES[l][0], lo: DRUM_LANES[l][0], hi: DRUM_LANES[l][0], lane: l, fname: p.fname }); });
|
||
return zs;
|
||
}
|
||
/* the samples a pad keeps after tune and cut (no encode: for the meter while the knobs move) */
|
||
const kitLen = (p) => { const full = p.tune ? Math.floor((p.s.length - 1) / Math.pow(2, p.tune / 12)) : p.s.length; return Math.max(1, Math.min(full, p.len > 0 ? Math.round(p.len) : full)); };
|
||
const kitBytes = (pads) => pads.reduce((a, p) => a + (p ? (kitLen(p) + 1) >> 1 : 0), 0);
|
||
/* shorten the longest pads to fit `room` bytes (as CHOP's fit): their len, in samples. bins 2 (KIT USR3+4): the
|
||
room of two slots, no pad longer than one slot holds, and the pads must also share out (kitSplit) */
|
||
function kitFit(pads, room = SMP.MAX_DATA, bins = 1) {
|
||
if (bins > 1) {
|
||
let changed = false;
|
||
for (const p of pads) if (p && ((kitLen(p) + 1) >> 1) > room) { p.len = room * 2 - 1; changed = true; }
|
||
for (let r = room * 2; !kitSplit(pads, room) && r > 64; r = Math.floor(r * 0.98)) { kitFit(pads, r); changed = true; }
|
||
return changed;
|
||
}
|
||
const use = pads.map((p, l) => (p ? { l, n: kitLen(p) } : null)).filter(Boolean);
|
||
const sum = (L) => use.reduce((a, u) => a + ((Math.min(u.n, L) + 1) >> 1), 0);
|
||
if (sum(Infinity) <= room) return false;
|
||
let lo = 1, hi = Math.max(...use.map((u) => u.n));
|
||
while (lo < hi) { const L = (lo + hi + 1) >> 1; if (sum(L) <= room) lo = L; else hi = L - 1; }
|
||
for (const u of use) if (u.n > lo) pads[u.l].len = lo; /* (len counts the samples after the tune) */
|
||
return true;
|
||
}
|
||
/* KIT USR3+4: the pads shared out over two slots of `room` bytes each, every pad whole in one (the biggest first,
|
||
each into the emptier slot that takes it): [lanes of USR3, lanes of USR4], or null when they do not fit */
|
||
function kitSplit(pads, room = SMP.MAX_DATA) {
|
||
const items = pads.map((p, l) => (p ? { l, b: (kitLen(p) + 1) >> 1 } : null)).filter(Boolean).sort((a, b) => b.b - a.b || a.l - b.l);
|
||
const bins = [[], []], used = [0, 0];
|
||
for (const it of items) {
|
||
const order = used[0] <= used[1] ? [0, 1] : [1, 0];
|
||
const k = order.find((j) => used[j] + it.b <= room);
|
||
if (k == null) return null;
|
||
bins[k].push(it.l);
|
||
used[k] += it.b;
|
||
}
|
||
return bins.map((x) => x.sort((a, b) => a - b));
|
||
}
|
||
/* a file name -> the lane it most likely is (-1: none): "BD 808.wav" kick, "OH_01" open hat, "Low Tom" ... */
|
||
const KIT_WORDS = [
|
||
[5, /open|\boh\b|ophat|o ?hat/], [6, /pedal|\bph\b|foot/], [4, /clos|\bch\b|\bhh\b|hi ?hat|hihat|\bhat/],
|
||
[7, /\brim|\brs\b|side ?stick|stick/], [3, /clap|\bcp\b|\bclp\b|snap/], [1, /kick ?2|\bbd ?2|sub ?kick/],
|
||
[0, /kick|\bbd\b|bass ?drum|\bkik\b|\bkck\b/], [8, /snare ?2|\bsd ?2|snr ?2/], [2, /snare|\bsd\b|\bsnr\b/],
|
||
[10, /hi(gh)? ?tom|\bht\b|tom ?h|mid ?tom|\bmt\b|tom ?[23]\b/], [9, /lo(w)? ?tom|\blt\b|floor|tom ?l|tom ?1\b|\btom/],
|
||
[11, /crash|\bcr\b|\bcy\b|cymbal|splash|china/], [12, /ride|\brd\b/], [13, /shak|\bsh\b|maraca|cabasa|tamb|\bshk\b/],
|
||
[14, /conga|bongo|\bcg\b|\bperc|timbal|djembe/], [15, /cow ?bell|\bcb\b|bell|block|clave|agogo/]];
|
||
/* the lane to try next when a sound's lane is taken */
|
||
const KIT_ALT = { 0: 1, 1: 0, 2: 8, 8: 2, 3: 8, 4: 6, 6: 4, 5: 4, 7: 3, 9: 10, 10: 9, 11: 12, 12: 11, 13: 14, 14: 13, 15: 14 };
|
||
function kitLaneOf(name) {
|
||
const n = String(name).toLowerCase().replace(/\.[a-z0-9]{2,4}$/, "").replace(/[_\-.()\[\]]+/g, " ");
|
||
for (const [l, re] of KIT_WORDS) if (re.test(n)) return l;
|
||
return -1;
|
||
}
|
||
/* where a new sound goes: its lane, else that lane's alternative, else (or by name nothing) the first free lane */
|
||
function kitPlace(pads, name, want = -1) {
|
||
const l = want >= 0 ? want : kitLaneOf(name);
|
||
if (l >= 0 && !pads[l]) return l;
|
||
if (want >= 0) return want; /* (dropped on a pad: that pad) */
|
||
if (l >= 0 && !pads[KIT_ALT[l]]) return KIT_ALT[l];
|
||
const f = pads.findIndex((p) => !p);
|
||
return f >= 0 ? f : -1;
|
||
}
|
||
/* a ZIP's files [{name, data}] (stored or deflated: DecompressionStream) */
|
||
async function zipRead(bytes) {
|
||
const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes), v = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
||
let e = b.length - 22;
|
||
while (e >= 0 && v.getUint32(e, true) !== 0x06054B50) e--;
|
||
if (e < 0) throw new Error("not a zip");
|
||
const n = v.getUint16(e + 10, true), out = [];
|
||
let c = v.getUint32(e + 16, true);
|
||
for (let k = 0; k < n; k++) {
|
||
if (v.getUint32(c, true) !== 0x02014B50) throw new Error("bad zip directory");
|
||
const method = v.getUint16(c + 10, true), size = v.getUint32(c + 20, true), nl = v.getUint16(c + 28, true);
|
||
const xl = v.getUint16(c + 30, true), cl = v.getUint16(c + 32, true), off = v.getUint32(c + 42, true);
|
||
const name = new TextDecoder().decode(b.subarray(c + 46, c + 46 + nl));
|
||
const lo = off + 30 + v.getUint16(off + 26, true) + v.getUint16(off + 28, true), raw = b.subarray(lo, lo + size);
|
||
if (!name.endsWith("/")) {
|
||
if (method === 0) out.push({ name, data: raw.slice() });
|
||
else if (method === 8 && typeof DecompressionStream !== "undefined") {
|
||
const st = new Blob([raw]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
||
out.push({ name, data: new Uint8Array(await new Response(st).arrayBuffer()) });
|
||
} else throw new Error(`zip method ${method}`);
|
||
}
|
||
c += 46 + nl + xl + cl;
|
||
}
|
||
return out;
|
||
}
|
||
|
||
/* ------------------------------------------------ SLOOP 2.5: piano roll --- */
|
||
/* A synth track's steps as a piano roll. A NOTE step starts a chord (up to 4 notes, one length for all of
|
||
them: the device ties every note of a step), the TIE steps after it hold it, a REST is silence. These
|
||
functions never change their input: they return the steps to write, as a Map index -> new step. */
|
||
const ROLL = {
|
||
DIV_PER_BAR: [4, 8, 16, 32, 12, 24, 2, 1, 0.5], /* steps in a 4/4 bar for DIV (params.c N_SDIV) */
|
||
LENGTHS: [["whole", 1], ["half", 1 / 2], ["quarter", 1 / 4], ["eighth", 1 / 8], ["sixteenth", 1 / 16]],
|
||
/* a length (a fraction of a bar) in steps at DIV div: at least one step */
|
||
steps: (frac, div) => Math.max(1, Math.round((ROLL.DIV_PER_BAR[div] ?? 16) * frac)),
|
||
rest: () => ({ n: 0, notes: [0, 0, 0, 0], time: 2, flags: 0, vel: 0, lvl: 0, rat: 0 }),
|
||
tie: () => ({ n: 0, notes: [0, 0, 0, 0], time: 1, flags: 0, vel: 0, lvl: 0, rat: 0 }),
|
||
isNote: (s) => !!s && s.time === 0 && s.n > 0,
|
||
/* the chords: {at, dur, notes[], vel} for every NOTE step, dur = 1 + the TIE steps after it (within len) */
|
||
chords(steps, len) {
|
||
const out = [];
|
||
for (let i = 0; i < len; i++) {
|
||
const s = steps[i];
|
||
if (!ROLL.isNote(s)) continue;
|
||
let d = 1;
|
||
while (i + d < len && steps[i + d] && steps[i + d].time === 1) d++;
|
||
out.push({ at: i, dur: d, notes: s.notes.slice(0, s.n), vel: s.vel, flags: s.flags });
|
||
}
|
||
return out;
|
||
},
|
||
/* the chord sounding at step i (its NOTE step), or -1 */
|
||
owner(steps, i) {
|
||
for (let k = i; k >= 0; k--) {
|
||
const s = steps[k];
|
||
if (ROLL.isNote(s)) return k;
|
||
if (!s || s.time !== 1) return -1;
|
||
}
|
||
return -1;
|
||
},
|
||
/* the steps after a chord that ends at `end` and were holding it (TIE) become rests */
|
||
_cutTies(steps, len, end, out) {
|
||
for (let k = end; k < len && steps[k] && steps[k].time === 1 && !out.has(k); k++) out.set(k, ROLL.rest());
|
||
},
|
||
/* put note `pitch` at step `at` for `dur` steps. On a chord's first step: added to it (it keeps its length,
|
||
at most 4 notes). Inside a held chord: that chord ends there and a new one starts. Elsewhere: a new chord. */
|
||
place(steps, len, at, pitch, dur) {
|
||
const out = new Map(), s = steps[at];
|
||
if (at < 0 || at >= len) return out;
|
||
if (ROLL.isNote(s)) {
|
||
if (s.notes.slice(0, s.n).includes(pitch) || s.n >= 4) return out;
|
||
const notes = s.notes.slice(0, s.n).concat(pitch);
|
||
out.set(at, { ...s, n: notes.length, notes: notes.concat([0, 0, 0, 0]).slice(0, 4) });
|
||
return out;
|
||
}
|
||
out.set(at, { n: 1, notes: [pitch, 0, 0, 0], time: 0, flags: 0, vel: 96, lvl: 0, rat: 0 });
|
||
let k = 1;
|
||
for (; k < dur && at + k < len; k++) {
|
||
const x = steps[at + k];
|
||
if (ROLL.isNote(x)) break; /* the next chord: this one stops before it */
|
||
out.set(at + k, ROLL.tie());
|
||
}
|
||
ROLL._cutTies(steps, len, at + k, out); /* (inside a long chord: its rest is silence now) */
|
||
return out;
|
||
},
|
||
/* take note `pitch` off the chord starting at `at`; the last one leaves rests where the chord was */
|
||
remove(steps, len, at, pitch) {
|
||
const out = new Map(), s = steps[at];
|
||
if (!ROLL.isNote(s)) return out;
|
||
const notes = s.notes.slice(0, s.n).filter((n) => n !== pitch);
|
||
if (notes.length === s.n) return out;
|
||
if (notes.length) { out.set(at, { ...s, n: notes.length, notes: notes.concat([0, 0, 0, 0]).slice(0, 4) }); return out; }
|
||
out.set(at, ROLL.rest());
|
||
ROLL._cutTies(steps, len, at + 1, out);
|
||
return out;
|
||
},
|
||
/* the chord at `at` lasts `dur` steps: shorter, the steps it leaves become rests; longer, it ties over
|
||
the rests after it, up to the next chord */
|
||
resize(steps, len, at, dur) {
|
||
const out = new Map();
|
||
if (!ROLL.isNote(steps[at])) return out;
|
||
let cur = 1;
|
||
while (at + cur < len && steps[at + cur] && steps[at + cur].time === 1) cur++;
|
||
dur = Math.max(1, Math.min(dur, len - at));
|
||
if (dur < cur) for (let k = dur; k < cur; k++) out.set(at + k, ROLL.rest());
|
||
else for (let k = cur; k < dur; k++) { if (ROLL.isNote(steps[at + k])) break; out.set(at + k, ROLL.tie()); }
|
||
return out;
|
||
},
|
||
};
|
||
|
||
/* ------------------------------------------ SLOOP 2.5: Standard MIDI Files --- */
|
||
const SMF = {
|
||
PPQ: 96,
|
||
/* ticks of one step at DIV div (a quarter = ppq ticks) */
|
||
stepTicks: (div, ppq = SMF.PPQ) => Math.round(ppq * 4 / (ROLL.DIV_PER_BAR[div] ?? 16)),
|
||
vlq(n) { const a = [n & 0x7F]; while ((n >>= 7)) a.unshift(0x80 | (n & 0x7F)); return a; },
|
||
/* a format 0 file: notes [{t, dur, key, vel}] on channel ch (0..15), the tempo, a track name */
|
||
write(notes, { ppq = SMF.PPQ, bpm = 120, ch = 0, name = "" } = {}) {
|
||
const ev = [];
|
||
for (const n of notes) {
|
||
ev.push({ t: n.t, o: 1, b: [0x90 | ch, n.key & 0x7F, Math.max(1, Math.min(127, n.vel | 0))] });
|
||
ev.push({ t: n.t + Math.max(1, n.dur), o: 0, b: [0x80 | ch, n.key & 0x7F, 0] });
|
||
}
|
||
ev.sort((a, b) => a.t - b.t || a.o - b.o); /* (a note-off before a note-on at the same tick) */
|
||
const us = Math.round(60000000 / Math.max(1, bpm));
|
||
const nm = Array.from(String(name), (c) => c.charCodeAt(0) & 0x7F);
|
||
const tr = [0, 0xFF, 0x51, 3, (us >> 16) & 255, (us >> 8) & 255, us & 255, 0, 0xFF, 0x58, 4, 4, 2, 24, 8];
|
||
if (nm.length) tr.push(0, 0xFF, 0x03, ...SMF.vlq(nm.length), ...nm);
|
||
let last = 0;
|
||
for (const e of ev) { tr.push(...SMF.vlq(e.t - last), ...e.b); last = e.t; }
|
||
tr.push(0, 0xFF, 0x2F, 0);
|
||
const u32 = (n) => [(n >>> 24) & 255, (n >> 16) & 255, (n >> 8) & 255, n & 255];
|
||
return Uint8Array.from([0x4D, 0x54, 0x68, 0x64, ...u32(6), 0, 0, 0, 1, (ppq >> 8) & 255, ppq & 255,
|
||
0x4D, 0x54, 0x72, 0x6B, ...u32(tr.length), ...tr]);
|
||
},
|
||
/* -> {format, ppq, bpm, tracks: [{name, notes: [{t, dur, key, vel, ch}]}]}; throws on a non-MIDI file */
|
||
read(bytes) {
|
||
const d = bytes instanceof Uint8Array ? bytes : Uint8Array.from(bytes);
|
||
const str = (o) => String.fromCharCode(d[o], d[o + 1], d[o + 2], d[o + 3]);
|
||
const u32 = (o) => ((d[o] << 24) | (d[o + 1] << 16) | (d[o + 2] << 8) | d[o + 3]) >>> 0;
|
||
if (d.length < 14 || str(0) !== "MThd") throw new Error("not a MIDI file");
|
||
const format = (d[8] << 8) | d[9], ntrk = (d[10] << 8) | d[11], div = (d[12] << 8) | d[13];
|
||
if (div & 0x8000) throw new Error("SMPTE time is not supported");
|
||
let o = 8 + u32(4), bpm = 0;
|
||
const tracks = [];
|
||
for (let k = 0; k < ntrk && o + 8 <= d.length; k++) {
|
||
if (str(o) !== "MTrk") { o += 8 + u32(o + 4); k--; if (o >= d.length) break; continue; }
|
||
const end = Math.min(d.length, o + 8 + u32(o + 4));
|
||
let p = o + 8, t = 0, run = 0, name = "";
|
||
const on = new Map(), notes = [];
|
||
const vlq = () => { let n = 0, c; do { c = d[p++]; n = (n << 7) | (c & 0x7F); } while (c & 0x80 && p < end); return n; };
|
||
const off = (ch, key) => {
|
||
const q = on.get(ch * 128 + key);
|
||
if (q && q.length) { const n = q.shift(); n.dur = Math.max(1, t - n.t); notes.push(n); }
|
||
};
|
||
while (p < end) {
|
||
t += vlq();
|
||
let st = d[p];
|
||
if (st & 0x80) p++; else st = run;
|
||
if (st === 0xFF) {
|
||
const type = d[p++], len = vlq();
|
||
if (type === 0x51 && len === 3 && !bpm) bpm = 60000000 / ((d[p] << 16) | (d[p + 1] << 8) | d[p + 2]);
|
||
if (type === 0x03 && !name) name = String.fromCharCode(...d.subarray(p, p + len)).replace(/[^\x20-\x7E]/g, "");
|
||
p += len;
|
||
continue;
|
||
}
|
||
if (st === 0xF0 || st === 0xF7) { p += vlq(); continue; }
|
||
run = st;
|
||
const hi = st & 0xF0, ch = st & 15;
|
||
const a = d[p++], b = hi === 0xC0 || hi === 0xD0 ? 0 : d[p++];
|
||
if (hi === 0x90 && b) {
|
||
const q = on.get(ch * 128 + a) || [];
|
||
q.push({ t, dur: 0, key: a, vel: b, ch });
|
||
on.set(ch * 128 + a, q);
|
||
} else if (hi === 0x80 || (hi === 0x90 && !b)) off(ch, a);
|
||
}
|
||
for (const [k, q] of on) for (const n of q) { n.dur = Math.max(1, t - n.t); notes.push(n); } /* (no note-off: to the end) */
|
||
notes.sort((x, y) => x.t - y.t || x.key - y.key);
|
||
tracks.push({ name, notes });
|
||
o = end;
|
||
}
|
||
return { format, ppq: div || SMF.PPQ, bpm: Math.round(bpm || 120), tracks };
|
||
},
|
||
/* a synth track's steps -> notes (a chord's notes last its steps; the step's level as the device plays it) */
|
||
fromSteps(steps, len, div, ppq = SMF.PPQ) {
|
||
const tk = SMF.stepTicks(div, ppq), V = [0, 42, 72, 127], out = [];
|
||
for (const c of ROLL.chords(steps, len)) {
|
||
const s = steps[c.at], base = s.flags & 1 ? 127 : s.vel || 96;
|
||
c.notes.forEach((key, i) => {
|
||
const lv = (s.lvl >> (2 * i)) & 3;
|
||
out.push({ t: c.at * tk, dur: c.dur * tk - Math.max(1, tk >> 4), key, vel: lv ? V[lv] : base });
|
||
});
|
||
}
|
||
return out;
|
||
},
|
||
/* the drum track's steps -> GM notes on their lanes (a hit lasts a quarter of its step) */
|
||
fromDrums(dsteps, len, div, ppq = SMF.PPQ) {
|
||
const tk = SMF.stepTicks(div, ppq), V = [100, 42, 72, 127], out = [];
|
||
for (let i = 0; i < len; i++) {
|
||
const d = dsteps[i];
|
||
if (!d) continue;
|
||
for (let l = 0; l < 16; l++) if ((d.on >> l) & 1) out.push({ t: i * tk, dur: Math.max(1, tk >> 2), key: DRUM_LANES[l][0], vel: V[d.lvl[l] & 3] });
|
||
}
|
||
return out;
|
||
},
|
||
/* the GM drum note -> its lane (firmware drums.c LANE_OF_GM) */
|
||
LANE_OF_GM: [1, 0, 7, 2, 3, 8, 9, 4, 9, 6, 9, 5, 10, 10, 11, 10, 12, 11, 12, 13, 11, 15, 11, 13, 12, 14, 14, 14, 14, 14,
|
||
14, 14, 15, 15, 13, 13, 15, 15, 13, 13, 7, 7, 7, 14, 14, 15, 15],
|
||
laneOf: (key) => (key < 35 ? 0 : key > 81 ? 13 : SMF.LANE_OF_GM[key - 35]),
|
||
levelOf: (vel) => (vel < 56 ? 1 : vel < 88 ? 2 : vel < 116 ? 0 : 3), /* (drums.c vel_lvl: GHOST, SOFT, NORM, HARD) */
|
||
/* notes -> the steps of a track at DIV div, at most nstep. The report says what changed on the way:
|
||
{notes, steps, moved (off the grid by more than a quarter step), chordCut (notes over 4 on a step),
|
||
overlap (a chord cut short by the next one), dropped (past the last step), merged (on the same step)} */
|
||
toSteps(notes, ppq, div, nstep, drum = false) {
|
||
const tk = ppq * 4 / (ROLL.DIV_PER_BAR[div] ?? 16);
|
||
const rep = { notes: notes.length, steps: 0, moved: 0, chordCut: 0, overlap: 0, dropped: 0, merged: 0 };
|
||
const at = new Map();
|
||
for (const n of notes) {
|
||
const pos = n.t / tk, i = Math.round(pos);
|
||
if (Math.abs(pos - i) > 0.25) rep.moved++;
|
||
if (i >= nstep) { rep.dropped++; continue; }
|
||
if (!at.has(i)) at.set(i, []);
|
||
at.get(i).push({ ...n, end: Math.max(i + 1, Math.round((n.t + n.dur) / tk)) });
|
||
}
|
||
if (drum) {
|
||
const ds = Array.from({ length: nstep }, emptyDrum);
|
||
let last = -1;
|
||
for (const [i, list] of at) {
|
||
for (const n of list) {
|
||
const l = SMF.laneOf(n.key);
|
||
if ((ds[i].on >> l) & 1) { rep.merged++; continue; }
|
||
ds[i].on |= 1 << l;
|
||
ds[i].lvl[l] = SMF.levelOf(n.vel);
|
||
}
|
||
last = Math.max(last, i);
|
||
}
|
||
rep.steps = last + 1;
|
||
return { dsteps: ds, len: Math.max(1, last + 1), report: rep };
|
||
}
|
||
const steps = Array.from({ length: nstep }, ROLL.rest);
|
||
const starts = [...at.keys()].sort((a, b) => a - b);
|
||
let last = -1;
|
||
starts.forEach((i, k) => {
|
||
let list = at.get(i);
|
||
const keys = new Set();
|
||
list = list.filter((n) => (keys.has(n.key) ? (rep.merged++, false) : keys.add(n.key)));
|
||
if (list.length > 4) { rep.chordCut += list.length - 4; list = list.slice().sort((a, b) => b.vel - a.vel).slice(0, 4); }
|
||
list.sort((a, b) => a.key - b.key);
|
||
const vel = Math.max(...list.map((n) => n.vel));
|
||
let end = Math.min(nstep, Math.max(...list.map((n) => n.end)));
|
||
const next = k + 1 < starts.length ? starts[k + 1] : nstep;
|
||
if (end > next) { rep.overlap++; end = next; }
|
||
steps[i] = { n: list.length, notes: list.map((n) => n.key).concat([0, 0, 0, 0]).slice(0, 4), time: 0, flags: 0, vel, lvl: 0, rat: 0 };
|
||
for (let j = i + 1; j < end; j++) steps[j] = ROLL.tie();
|
||
last = Math.max(last, end - 1);
|
||
});
|
||
rep.steps = last + 1;
|
||
return { steps, len: Math.max(1, last + 1), report: rep };
|
||
},
|
||
};
|
||
|
||
/* ------------------------------------------- SLOOP 2.5: the song order --- */
|
||
/* The song order lives in the settings object (backup object 1, firmware project.c persist_t): bytes 48..83
|
||
are arranger.h arr_config_t: count, loop, 2 reserved, then 16 x {scene 0..3 = A..D, bars 1..64}. */
|
||
const ARR = {
|
||
OFF: 48, STEPS: 16, SIZE: 36, MAX_BARS: 64, MAGIC: 0x50455233,
|
||
ok: (b) => !!b && b.length >= ARR.OFF + ARR.SIZE && ((b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0) === ARR.MAGIC,
|
||
decode(b) {
|
||
const count = b[ARR.OFF], loop = b[ARR.OFF + 1], entries = [];
|
||
for (let i = 0; i < Math.min(count, ARR.STEPS); i++) entries.push({ scene: b[ARR.OFF + 4 + 2 * i], bars: b[ARR.OFF + 5 + 2 * i] });
|
||
return { loop: loop === 1, entries };
|
||
},
|
||
/* the settings bytes with this song order (the rest kept as it was) */
|
||
encode(b, song) {
|
||
const o = Uint8Array.from(b), e = song.entries;
|
||
o[ARR.OFF] = e.length; o[ARR.OFF + 1] = song.loop ? 1 : 0; o[ARR.OFF + 2] = o[ARR.OFF + 3] = 0;
|
||
for (let i = 0; i < ARR.STEPS; i++) {
|
||
o[ARR.OFF + 4 + 2 * i] = i < e.length ? e[i].scene : i % 4;
|
||
o[ARR.OFF + 5 + 2 * i] = i < e.length ? e[i].bars : 4;
|
||
}
|
||
return o;
|
||
},
|
||
/* arranger.h arr_valid: 1..16 entries, sections A..D, 1..64 bars */
|
||
valid: (song) => song.entries.length >= 1 && song.entries.length <= ARR.STEPS
|
||
&& song.entries.every((e) => e.scene >= 0 && e.scene < 4 && e.bars >= 1 && e.bars <= ARR.MAX_BARS),
|
||
/* entries -> rows {scene, bars, times}: the same section with the same bars in a row is one row played `times` */
|
||
group(entries) {
|
||
const rows = [];
|
||
for (const e of entries) {
|
||
const r = rows[rows.length - 1];
|
||
if (r && r.scene === e.scene && r.bars === e.bars) r.times++;
|
||
else rows.push({ scene: e.scene, bars: e.bars, times: 1 });
|
||
}
|
||
return rows;
|
||
},
|
||
expand: (rows) => rows.flatMap((r) => Array.from({ length: Math.max(1, r.times | 0) }, () => ({ scene: r.scene, bars: r.bars }))),
|
||
};
|
||
|
||
|
||
/* ------------------------------------- v10 (SLOOP 2.5): the SYN drum kits --- */
|
||
/* A synthesised drum sound is the firmware's dsnd_t (drum_synth.c, tools/gen_drumkits.py), 22 bytes in this order.
|
||
The tone (a wave with a falling pitch, a second partial), the click, the noise (white, the 808's six metallic
|
||
squares, both, a chip LFSR; the clap's bursts), a resonant filter, drive and level. A kit: 16 of them and its
|
||
crush (bits dropped in the low nibble, sample-and-hold - 1 in the high one). */
|
||
const DSYN = {
|
||
USER: 64, NUSER: 4, LANES: 16, SIZE: 22,
|
||
FIELDS: ["wave", "src", "pitch", "fine", "bend", "btime", "hold", "decay", "tlev", "t2", "t2lev", "click",
|
||
"nlev", "nhold", "ndec", "flt", "fcut", "fenv", "hpf", "chip", "drive", "level"],
|
||
/* the synthesised lanes (DS_MAP order) and the GM note each plays without an offset (drum_synth.c DS_LANE_NOTE) */
|
||
LANES_N: ["KICK", "SNARE", "CLAP", "HAT", "OPEN HAT", "LOW TOM", "HI TOM", "CRASH", "RIDE", "SHAKER", "CONGA", "RIM",
|
||
"COWBELL", "CLAVE", "KICK 2", "SNARE 2"],
|
||
LANE_NOTE: [36, 38, 39, 42, 46, 43, 48, 49, 51, 70, 63, 37, 56, 75, 35, 40],
|
||
WAVES: ["OFF", "SINE", "TRI", "SQUARE", "FM", "BELL"],
|
||
NOISES: ["OFF", "WHITE", "METAL", "CYM", "CHIP"],
|
||
FMODES: ["OFF", "LP", "BP", "HP"],
|
||
STEPS_PER_OCT: 127 / Math.log2(16000 / 30),
|
||
/* 22 bytes -> the values the page edits */
|
||
decode(b) {
|
||
const g = (k) => b[DSYN.FIELDS.indexOf(k)] & 255;
|
||
const f = g("flt"), src = g("src"), fe = g("fenv");
|
||
return { wave: g("wave"), noise: src & 15, clap: (src >> 4) & 1, pitch: g("pitch"), fine: g("fine"), bend: g("bend"),
|
||
btime: g("btime"), hold: g("hold"), decay: g("decay"), tlev: g("tlev"), t2: g("t2"), t2lev: g("t2lev"), click: g("click"),
|
||
nlev: g("nlev"), nhold: g("nhold"), ndec: g("ndec"), fmode: f & 3, fall: (f >> 2) & 1, res: f >> 3, fcut: g("fcut"),
|
||
fenv: fe > 127 ? fe - 256 : fe, hpf: g("hpf"), chip: g("chip"), drive: g("drive"), level: g("level") };
|
||
},
|
||
/* the values -> 22 bytes, into the ranges the firmware keeps (editor_dsyn.c dsu_fix_sound) */
|
||
encode(o) {
|
||
const c = (v, lo, hi) => Math.max(lo, Math.min(hi, Math.round(+v || 0)));
|
||
const v = { wave: c(o.wave, 0, 5), src: c(o.noise, 0, 4) | (o.clap ? 16 : 0), pitch: c(o.pitch, 0, 127), fine: c(o.fine, 0, 15),
|
||
bend: c(o.bend, 0, 96), btime: c(o.btime, 0, 127), hold: c(o.hold, 0, 255), decay: c(o.decay, 0, 127), tlev: c(o.tlev, 0, 127),
|
||
t2: c(o.t2, 0, 255), t2lev: c(o.t2lev, 0, 127), click: c(o.click, 0, 127), nlev: c(o.nlev, 0, 127), nhold: c(o.nhold, 0, 255),
|
||
ndec: c(o.ndec, 0, 127), flt: c(o.fmode, 0, 3) | (o.fall ? 4 : 0) | (c(o.res, 0, 31) << 3), fcut: c(o.fcut, 0, 127),
|
||
fenv: c(o.fenv, -128, 127) & 255, hpf: c(o.hpf, 0, 127), chip: c(o.chip, 0, 127), drive: c(o.drive, 0, 127), level: c(o.level, 0, 255) };
|
||
return Uint8Array.from(DSYN.FIELDS.map((k) => v[k]));
|
||
},
|
||
/* what the numbers mean (tools/gen_tables.py, gen_drumkits.py) */
|
||
hz: (note, fine = 0) => 440 * 2 ** ((note + fine / 16 - 69) / 12),
|
||
decayMs: (i) => 5 * 800 ** (i / 127),
|
||
cutHz: (i) => 30 * (16000 / 30) ** (i / 127),
|
||
db: (level) => (level - 128) / 4,
|
||
name8: (s) => { const b = new Uint8Array(8); String(s || "").replace(/[^\x20-\x7E]/g, "").slice(0, 8).split("").forEach((ch, i) => { b[i] = ch.charCodeAt(0); }); return b; },
|
||
/* a kit as a file: {format, version, name, crush, sounds: [22 numbers] x 16} */
|
||
FORMAT: "sloop-drumsynth",
|
||
toFile: (k) => ({ format: DSYN.FORMAT, version: 1, name: k.name, crush: k.crush, sounds: k.sounds.map((x) => Array.from(x)) }),
|
||
/* backup object 9: the firmware's dsu_bank_t ("DSU1", 1, 4, then per kit: name 8, crush, src, 2 reserved, 16 x 22) */
|
||
BANK_SIZE: 8 + 4 * 364,
|
||
bankEncode(kits) {
|
||
const o = new Uint8Array(DSYN.BANK_SIZE);
|
||
o.set([0x44, 0x53, 0x55, 0x31, 1, 0, 4, 0]);
|
||
kits.forEach((k, i) => {
|
||
const at = 8 + i * 364;
|
||
o.set(DSYN.name8(k.name), at); o[at + 8] = k.crush & 255; o[at + 9] = k.src & 255;
|
||
k.sounds.forEach((x, l) => o.set(x, at + 12 + l * DSYN.SIZE));
|
||
});
|
||
return o;
|
||
},
|
||
bankDecode(b) {
|
||
if (!b || b.length !== DSYN.BANK_SIZE || b[0] !== 0x44 || b[1] !== 0x53 || b[2] !== 0x55 || b[3] !== 0x31 || b[4] !== 1 || b[6] !== 4) return null;
|
||
return Array.from({ length: 4 }, (_, i) => {
|
||
const at = 8 + i * 364;
|
||
return { name: String.fromCharCode(...b.subarray(at, at + 8)).replace(/\0.*$/, ""), crush: b[at + 8], src: b[at + 9],
|
||
sounds: Array.from({ length: DSYN.LANES }, (_, l) => b.slice(at + 12 + l * DSYN.SIZE, at + 12 + (l + 1) * DSYN.SIZE)) };
|
||
});
|
||
},
|
||
fromFile(j) {
|
||
if (!j || j.format !== DSYN.FORMAT || !Array.isArray(j.sounds) || j.sounds.length !== DSYN.LANES
|
||
|| j.sounds.some((x) => !Array.isArray(x) || x.length !== DSYN.SIZE)) throw new Error("not a SLOOP drum synth kit");
|
||
return { name: String(j.name || "KIT").replace(/[^\x20-\x7E]/g, "").slice(0, 8), crush: (j.crush | 0) & 255,
|
||
sounds: j.sounds.map((x) => DSYN.encode(DSYN.decode(Uint8Array.from(x, (v) => v & 255)))) };
|
||
},
|
||
};
|
||
/* the device's 32 synthesised kits (build/gen/felucca_drumkits.h), for the mock: per kit its crush, then 16 x 22 */
|
||
const DSYN_MOCK_NAMES = ["808", "909", "606", "80S", "VINTAGE", "TRAP", "DRILL", "BOOMBAP", "LO-FI", "PHONK", "HOUSE", "D.HOUSE", "TECHNO", "MINIMAL", "ELECTRO", "DISCO", "GARAGE", "JUNGLE", "DUBSTEP", "DEMBOW", "AMAPIANO", "AFRO", "LATIN", "TRIBAL", "SYNTHWV", "CHIP", "ARCADE", "GLITCH", "INDUSTR", "HYPER", "AMBIENT", "JAZZ"];
|
||
const DSYN_MOCK_KITS = "AAEAHwYSJARhfAAADwAALAB/AAAAJIYBATYAAxQAPGA5XBZkAEMjUgAAAAB7ABErBgAaADkAAAAAegBJYkoAPQAAsQACNwwAGgA5AAAACnYAKGp0AG0AAM4AAjcMABoAOQAAAAByClJicwBsAAC4AQErAAYvBVR2MCgQEgAiGVUAAAAAfwEBMgAGLwVRdDAoEBIAIhlaAAAAAH0AAzcMABoAOQAAAABsBXA7ZgAAAAB/AAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGAGLkpvAAAAAIcBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFcBgAAABxcL0YoKAADZloAAAAAnQUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAcBRIvI298AAAIAAAsAH8AAAAkhwIBOwMEDQAyVDA8HmAAPEpoAAAAAJUAAQEgAB4kB1B8AAAmKAADGWcAAAAkigIBNgcHFQA7XDNGHnQASBtHAAAAFocAESsGABoAOQAAAAB8AE1qTABAAACrAAM5DAAaADkAAAAMcgAuQ3EAbgAArgADOQwAGgA5AAAAAG4KVkNwAG4AAJMBAS0ACigFT3YwJBYaACIZXQAAAACBAQE0AAooBUx0MCQWGgAiGWEAAAAAgAADOwMAGgA5AAAAAG4FcTNnAAAAAH4AAz4GABoAOQAAAA5sA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per control key: last = when the user last changed it (touched()), sent = the value last
|
||
requested. A value equal to the last request is skipped only while that request is still pending (queued or in
|
||
flight): it carries it already. Once answered, the device may hold something else under the same key (another track
|
||
or sound under the controls, a knob turned on the FM-1), so the same value is sent again (2.6: setting DIV 1/8 on
|
||
one track, then 1/8 on another, sent nothing the second time). clear(): another track / sound / device */
|
||
class SetGate {
|
||
constructor() { this.m = new Map(); }
|
||
get(k) { return this.m.get(k); }
|
||
user(k, v, pending, now) {
|
||
let st = this.m.get(k);
|
||
if (!st) this.m.set(k, (st = { last: 0, sent: null }));
|
||
st.last = now;
|
||
return !(pending && v === st.sent);
|
||
}
|
||
clear() { this.m.clear(); }
|
||
}
|
||
/* SLOOP 2.7 (protocol v11): your theme, backup object 11, the bytes of gfx.c theme_t: "THM1", name[8] (ASCII, 0-padded),
|
||
c[5] (the screen, faintest .. strongest: lines, dim, labels, secondary, values), trk[4] (the tracks' colours: 1, 2, 3,
|
||
drums), bg (the background; 0 black), hi (the accent: what is touched, the cursor, the play head), 0, CRC-32 of the
|
||
36 bytes before it ("THM2", 40 bytes); colours RGB565, low byte first. The first 2.7 beta's "THM1" (36 bytes, no hi,
|
||
its CRC at 32) still decodes, with a white accent (black on a light background), as the FM-1 takes it. The FM-1
|
||
refuses a theme whose strongest step or accent does not stand out from the background (gfx.c theme_check):
|
||
readable() / problems() say it first. A shared theme is its bytes in a line of text: "SLOOP-THEME-1:" + base64 */
|
||
const THEME = {
|
||
ID: 11, SIZE: 40, MAGIC: 0x324D4854, MAGIC1: 0x314D4854, PREFIX: "SLOOP-THEME-1:",
|
||
WHITE: [255, 255, 255], BLACK: [0, 0, 0],
|
||
/* the FM-1's own palettes (gfx.c PALETTES) and the tracks' colours (TE_COL_DEF), as RGB 0..255 */
|
||
BUILTIN: [
|
||
["GREEN", [[0, 40, 12], [0, 84, 30], [16, 140, 54], [56, 200, 92], [120, 255, 146]]],
|
||
["AMBER", [[60, 26, 0], [110, 50, 0], [170, 82, 0], [225, 120, 8], [255, 166, 40]]],
|
||
["CYAN", [[0, 30, 50], [0, 62, 96], [16, 112, 160], [56, 172, 222], [140, 222, 255]]],
|
||
["RED", [[52, 8, 8], [100, 18, 14], [170, 36, 26], [226, 64, 48], [255, 112, 92]]],
|
||
["MONO", [[40, 40, 40], [80, 80, 80], [130, 130, 130], [186, 186, 186], [226, 226, 226]]]],
|
||
TRACKS: [[40, 124, 255], [30, 204, 112], [255, 198, 24], [255, 98, 26]],
|
||
to565: ([r, g, b]) => ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3),
|
||
from565: (v) => [Math.round((((v >> 11) & 31) * 255) / 31), Math.round((((v >> 5) & 63) * 255) / 63), Math.round(((v & 31) * 255) / 31)],
|
||
/* as the FM-1 shows it: each colour through RGB565 */
|
||
shown: (rgb) => THEME.from565(THEME.to565(rgb)),
|
||
hex: (rgb) => "#" + rgb.map((x) => x.toString(16).padStart(2, "0")).join(""),
|
||
unhex: (h) => { const m = /^#?([0-9a-f]{6})$/i.exec(String(h).trim()); if (!m) return null; const n = parseInt(m[1], 16); return [n >> 16, (n >> 8) & 255, n & 255]; },
|
||
/* a name the FM-1 shows: printable ASCII, upper case (its menu font), 8 at most */
|
||
cleanName: (s) => String(s || "").toUpperCase().replace(/[^\x20-\x7E]/g, "").slice(0, 8),
|
||
/* the FM-1's test (theme_check): the brightest step one channel 96 or more apart from the background (after RGB565,
|
||
channels as x * 8, x * 4, x * 8) */
|
||
ch: (v) => [((v >> 11) & 31) * 8, ((v >> 5) & 63) * 4, (v & 31) * 8],
|
||
apart(c, bg) {
|
||
const a = THEME.ch(THEME.to565(c)), b = THEME.ch(THEME.to565(bg || [0, 0, 0]));
|
||
return a.some((x, k) => Math.abs(x - b[k]) >= 96);
|
||
},
|
||
hiOf: (t) => t.hi || THEME.WHITE,
|
||
/* what the FM-1 would refuse: the values (c[4]), the accent */
|
||
problems: (t) => ({ val: !THEME.apart(t.c[4], t.bg), acc: !THEME.apart(THEME.hiOf(t), t.bg) }),
|
||
readable(t) { const p = THEME.problems(t); return !p.val && !p.acc; },
|
||
light: (rgb) => 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2] > 127,
|
||
/* a colour moved toward black (light background) or white (dark) just enough to stand out */
|
||
push(c, bg) {
|
||
if (THEME.apart(c, bg)) return c.slice();
|
||
const to = THEME.light(bg || [0, 0, 0]) ? 0 : 255;
|
||
for (let f = 0.05; f < 1; f += 0.05) {
|
||
const y = c.map((x) => Math.round(x + (to - x) * f));
|
||
if (THEME.apart(y, bg)) return y;
|
||
}
|
||
return [to, to, to];
|
||
},
|
||
/* the same theme readable: the values and the accent pushed apart from the background */
|
||
fix: (t) => ({ ...t, c: t.c.map((x, k) => (k === 4 ? THEME.push(x, t.bg) : x.slice())), hi: THEME.push(THEME.hiOf(t), t.bg) }),
|
||
/* light <-> dark: the five steps the other way round (faint lines, strong values), a white or black background,
|
||
the accent the other way */
|
||
invert(t) {
|
||
const bg = THEME.light(t.bg || [0, 0, 0]) ? THEME.BLACK.slice() : THEME.WHITE.slice();
|
||
return THEME.fix({ ...t, c: t.c.slice().reverse().map((x) => x.slice()), bg, hi: THEME.light(bg) ? THEME.BLACK.slice() : THEME.WHITE.slice() });
|
||
},
|
||
encode(t) {
|
||
const d = new Uint8Array(THEME.SIZE), w = new DataView(d.buffer);
|
||
w.setUint32(0, THEME.MAGIC, true);
|
||
const nm = THEME.cleanName(t.name);
|
||
for (let i = 0; i < nm.length; i++) d[4 + i] = nm.charCodeAt(i);
|
||
t.c.forEach((c, k) => w.setUint16(12 + 2 * k, THEME.to565(c), true));
|
||
t.trk.forEach((c, k) => w.setUint16(22 + 2 * k, THEME.to565(c), true));
|
||
w.setUint16(30, THEME.to565(t.bg || [0, 0, 0]), true);
|
||
w.setUint16(32, THEME.to565(THEME.hiOf(t)), true);
|
||
w.setUint32(36, crc32(d.subarray(0, 36)), true);
|
||
return d;
|
||
},
|
||
decode(d) {
|
||
if (!d || (d.length !== THEME.SIZE && d.length !== 36)) return null;
|
||
const w = new DataView(d.buffer, d.byteOffset, d.length), v1 = d.length === 36;
|
||
if (v1 ? w.getUint32(0, true) !== THEME.MAGIC1 || w.getUint32(32, true) !== crc32(d.subarray(0, 32))
|
||
: w.getUint32(0, true) !== THEME.MAGIC || w.getUint32(36, true) !== crc32(d.subarray(0, 36))) return null;
|
||
let name = "";
|
||
for (let i = 4; i < 12 && d[i]; i++) { if (d[i] < 0x20 || d[i] > 0x7E) return null; name += String.fromCharCode(d[i]); }
|
||
return { name, c: [0, 1, 2, 3, 4].map((k) => THEME.from565(w.getUint16(12 + 2 * k, true))),
|
||
trk: [0, 1, 2, 3].map((k) => THEME.from565(w.getUint16(22 + 2 * k, true))), bg: THEME.from565(w.getUint16(30, true)),
|
||
hi: v1 ? (THEME.apart(THEME.WHITE, THEME.from565(w.getUint16(30, true))) ? THEME.WHITE.slice() : THEME.BLACK.slice())
|
||
: THEME.from565(w.getUint16(32, true)) };
|
||
},
|
||
code: (t) => THEME.PREFIX + b64enc(THEME.encode(t)),
|
||
fromCode(s) {
|
||
const m = /SLOOP-THEME-1:([A-Za-z0-9+/=]+)/.exec(String(s || ""));
|
||
if (!m) return null;
|
||
try { return THEME.decode(b64dec(m[1])); } catch (e) { return null; }
|
||
},
|
||
builtin: (i) => ({ name: THEME.BUILTIN[i][0], c: THEME.BUILTIN[i][1].map((x) => x.slice()), trk: THEME.TRACKS.map((x) => x.slice()), bg: [0, 0, 0], hi: [255, 255, 255] }),
|
||
/* five steps from one colour, as the FM-1's palettes go: dark to the colour, the last lighter toward white; on a light
|
||
background (bg given) the other way: faint (light) to strong (dark) */
|
||
ramp(rgb, bg) {
|
||
if (bg && THEME.light(bg))
|
||
return [0.8, 0.6, 0.35].map((f) => rgb.map((x) => Math.round(x + (255 - x) * f)))
|
||
.concat([rgb.slice(), rgb.map((x) => Math.round(x * 0.45))]);
|
||
return [0.2, 0.42, 0.7].map((f) => rgb.map((x) => Math.round(x * f)))
|
||
.concat([rgb.slice(), rgb.map((x) => Math.round(x + (255 - x) * 0.45))]);
|
||
},
|
||
};
|
||
/* the FM-1's MIDI ports. Every FM-1 firmware has the same USB IDs, so Windows and macOS often keep the port name of the
|
||
* first firmware they saw ("X0X FM-1", "USB-MIDI"…): the names the installer accepts (fm1ota.js FM1_PORT, the same
|
||
* list), as in/out pairs of one name, "Felucca" / "SLOOP" first, then FM-1, then the generic names. connect() keeps the
|
||
* first pair that answers INFO, so a generic name of other gear is tried and left */
|
||
const FM1_PORT = /fm-1|felucca|sloop|clipper|ota|composite|sinco|usb-midi/i;
|
||
function fm1Ports(access) {
|
||
const live = (p) => p.state !== "disconnected" && FM1_PORT.test(p.name || "");
|
||
const ins = [...access.inputs.values()].filter(live), outs = [...access.outputs.values()].filter(live);
|
||
const rank = (n) => (/felucca|sloop/i.test(n) ? 0 : /fm-1/i.test(n) ? 1 : 2);
|
||
const pairs = [];
|
||
for (const input of ins) {
|
||
const output = outs.find((o) => o.name === input.name) || (outs.length === 1 ? outs[0] : null);
|
||
if (output) pairs.push({ input, output });
|
||
}
|
||
return pairs.sort((a, b) => rank(a.input.name || "") - rank(b.input.name || ""));
|
||
}
|
||
/*PROTO-END*/
|
||
|
||
/* ===================================================================== UI === */
|
||
if (typeof document !== "undefined") (() => {
|
||
const $ = (id) => document.getElementById(id);
|
||
const el = (tag, attrs = {}, ...kids) => {
|
||
const e = document.createElement(tag);
|
||
for (const [k, v] of Object.entries(attrs)) {
|
||
if (k === "text") e.textContent = v;
|
||
else if (k === "ic") continue;
|
||
else if (k.startsWith("on")) e.addEventListener(k.slice(2), v);
|
||
else if (v !== false && v != null) e.setAttribute(k, v === true ? "" : v);
|
||
}
|
||
for (const k of kids) e.append(k);
|
||
if (attrs.ic) e.prepend(icon(attrs.ic));
|
||
return e;
|
||
};
|
||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||
|
||
/* ---------------------------------------------------------------- icons --- */
|
||
/* Fukiai glyphs by their names in hugelton-plugin-rules lib/include/hugelton/Glyphs.h */
|
||
const GLYPH = {
|
||
port_usb_c: 0xEA3F, symbol_audio: 0xEA40, symbol_download: 0xEAD4, symbol_upload: 0xEAD5,
|
||
symbol_folder: 0xEAB8, symbol_folder_open: 0xEAB9, port_disk: 0xEAB3, symbol_trash: 0xEAC1,
|
||
control_arrow_loop: 0xEAD6, note_eight: 0xEAEF, symbol_waves: 0xEAE6, function_env_adsr_exp: 0xEA12,
|
||
ui_knob: 0xEA70, symbol_keyboard: 0xEABC, symbol_effector: 0xEAB7, symbol_echo: 0xEAB5, symbol_spring: 0xEAD1,
|
||
symbol_tuning: 0xEAA7, control_arrow_up_down: 0xEACF, symbol_grid: 0xEABA, symbol_cog: 0xEA46, symbol_drum: 0xEA66,
|
||
function_filter_lpf_peak: 0xEAA0, ui_slider_vertical: 0xEA73, symbol_books: 0xEADC, control_rec_f: 0xEA09,
|
||
symbol_pan: 0xEA53, control_speaker_mute: 0xEAEB,
|
||
waveform_sine: 0xEA85, waveform_triangle_ac: 0xEA89, waveform_sawtooth_ac: 0xEA81, waveform_square: 0xEA87,
|
||
waveform_pulse_quarter: 0xEA7F, waveform_pulse_eighth: 0xEA7B, waveform_noise_step: 0xEA79,
|
||
waveform_noise_white: 0xEA7A, waveform_harmonic: 0xEAC5,
|
||
};
|
||
/* section headings (LAYOUT titles) and page titles */
|
||
const HEAD_IC = { ENV: "function_env_adsr_exp", LFO: "waveform_sine", EDIT: "ui_knob", VOICE: "symbol_keyboard",
|
||
FX: "symbol_effector", SEL: "symbol_tuning", ARP: "control_arrow_up_down", "SEQ PATTERN": "symbol_grid",
|
||
GLOBAL: "symbol_cog", MASTER: "ui_slider_vertical", DRUMS: "symbol_drum", INSTRUMENT: "symbol_keyboard" };
|
||
const PAGE_IC = { FLT: "function_filter_lpf_peak", FILT: "function_filter_lpf_peak", DLY: "symbol_echo", "REV/CHO": "symbol_spring", SLICER: "symbol_grid" };
|
||
/* WAVE / WAVE2 choices; phase-distortion shapes without a close glyph (SPLS, RSAW, RTRI, RTRP) get none */
|
||
const WAVE_IC = { SIN: "waveform_sine", TRI: "waveform_triangle_ac", SAW: "waveform_sawtooth_ac", SQR: "waveform_square",
|
||
PLS: "waveform_pulse_quarter", PWM: "waveform_pulse_eighth", "S&H": "waveform_noise_step", NOIS: "waveform_noise_white",
|
||
DSIN: "waveform_harmonic" };
|
||
/* options can hold an icon only where the browser draws the picker itself; a native menu would show a box */
|
||
const RICH_SELECT = typeof CSS !== "undefined" && CSS.supports && CSS.supports("appearance", "base-select");
|
||
function icon(name) { return el("span", { class: "ic", "aria-hidden": "true", text: String.fromCharCode(GLYPH[name]) }); }
|
||
function setLabel(e, txt) { e.replaceChildren(...(e.dataset.ic ? [icon(e.dataset.ic)] : []), txt); }
|
||
/* icons stay hidden (html:not(.fk)) until the face has loaded; on failure, or from file://, words only */
|
||
(async () => {
|
||
try {
|
||
const probe = "1em Fukiai", ch = String.fromCharCode(GLYPH.waveform_sine);
|
||
const faces = await document.fonts.load(probe, ch);
|
||
if (faces.length && faces.every((f) => f.status === "loaded") && document.fonts.check(probe, ch)) document.documentElement.classList.add("fk");
|
||
} catch (e) { /* no icons */ }
|
||
})();
|
||
|
||
const TEXT = {
|
||
ja: {
|
||
/* 2.7: the LIVE page */
|
||
sfTitle: "ソング", sfHelp: "ソングファイルには、再生中のループ、セクション A–D とその順番(SONG 画面)が入ります。曲ごとに1つ保存し、LIVE ページのプレイリストから順に演奏できます。読み込むと FM-1 の A–D とループが置き換わります(先に停止)。",
|
||
sfSave: "このソングを書き出す", sfLoad: "ソングファイルを読み込む", sfName: "ソングの名前", sfSaving: "ソングを書き出し中 ", sfSaved: "ソングを書き出しました:",
|
||
sfLoading: "ソングを読み込み中 ", sfLoaded: "ソングを読み込みました:", sfConfirm: "「{name}」を読み込みますか? FM-1 のセクション A–D とループが置き換わります。",
|
||
songBadFile: "SLOOP のソングファイルではありません", plTitle: "プレイリスト", plAdd: "ソングを追加", plSave: "リストを保存", plOpen: "リストを開く",
|
||
plNext: "次のソング", plAuto: "読み込んだら再生", plEmpty: "ソングを書き出して(ソングとセクション → このソングを書き出す)、ここに追加してください。",
|
||
plLoad: "読み込む", plUp: "上へ", plDown: "下へ", plRemove: "削除", plBadList: "SLOOP のプレイリストではありません",
|
||
tabLive: "LIVE", lvNeeds: "トランスポート・セクション・フィル・エフェクトには FM-1 の SLOOP 2.7 が必要です。ミキサーと鍵盤は使えます。",
|
||
lvPlay: "再生", lvStop: "停止", lvRec: "録音", lvRecArm: "録音待機", lvRecFree: "録音:ループ確定", lvUndo: "元に戻す", lvRedo: "やり直す", lvBpm: "BPM", lvTap: "タップ",
|
||
lvSwing: "スイング", lvBar: "小節", lvSong: "ソング", lvLoop: "ループ", lvSongRec: "ソング録音", lvFill: "フィル", lvFillHold: "押す間", lvFillBar: "次の小節フィル",
|
||
lvCpu: "CPU", lvFull: "全画面", lvFullOff: "全画面を終了", lvSections: "セクション", lvSecHint: "タップ:次の小節から再生(停止中はすぐに)。",
|
||
lvSecPlaying: "再生中", lvSecNext: "次", lvSecEmpty: "空", lvStore: "ループを保存", lvStoreAsk: "セクション {x} を今のループで置き換えますか?",
|
||
lvMixer: "ミキサー", lvMute: "ミュート", lvSolo: "ソロ", lvSel: "演奏", lvSelOn: "演奏中", lvLevel: "レベル", lvPan: "パン", lvFilter: "フィルター", lvRev: "リバーブ",
|
||
lvDly: "ディレイ", lvCho: "コーラス", lvDrive: "ドライブ", lvMaster: "マスター FX", lvDust: "ダスト", lvDuck: "ダック", lvSound: "音色", lvKit: "キット",
|
||
lvFx: "パンチイン・エフェクト", lvFxHint: "パッドを押している間(または Shift + キー)エフェクトがかかります。LATCH:タップでオン、もう一度でオフ。",
|
||
lvLatch: "ラッチ", lvFxLoops: "ループ・時間", lvFxTone: "フィルター・EQ", lvFxColour: "音色", lvFxMove: "動き",
|
||
lvKeys: "鍵盤", lvTrack: "トラック", lvOct: "オクターブ", lvVel: "ベロシティ", lvArp: "アルペジオ", lvHold: "ホールド", lvLvl: ["GHOST", "SOFT", "NORM", "HARD"],
|
||
lvNoChan: "このトラックはノートを受けません:GLO > MIDI にチャンネルがなく OTHER が OFF です。",
|
||
lvClock: "GLO > SYSTEM > IN = CLOCK:FM-1 はノートを無視します。ここから演奏するには IN を NOTES に。",
|
||
lvShortcuts: "Space 再生/停止 · 1–4 セクション · 5–8 ミュート · Shift+5–8 ソロ · 9 フィル(押す間)· 0 次の小節フィル · B タップ · C 録音 · N 次のソング · Z / X オクターブ · ← → トラック · A W S E D F T G Y H U J K O L P 演奏 · Shift + それらのキー:エフェクト · F1–F8 シーン(Shift:保存)· Esc 全オフ",
|
||
lvPanic: "全オフ", lvStored: "ループを保存:セクション ",
|
||
lvxHelpShow: "使い方", lvxViewAll: "表示:すべて", lvxViewSimple: "表示:基本",
|
||
lvxGuideTitle: "はじめてのライブ 5 ステップ", lvxGuideOk: "わかった",
|
||
lvxGuideSteps: ["再生(Space)を押す。FM-1 がループを再生し、小節.拍が進みます。",
|
||
"セクション A–D で曲を作る:好きなループで「ループを保存」の A を押し、ループを変えて B に保存…。A–D をタップすると次の小節で切り替わります。",
|
||
"フェーダー、ミュート、ソロでミックス。エフェクトパッド(LOOP 4、STOP、KILL LOW…)を押している間だけパンチインします。",
|
||
"シーンは「何が鳴るか」ではなく「どう鳴るか」を変えます:静かなミックスをシーン 1(フィルタ閉、リバーブ少)、大きいミックスをシーン 2 に保存し、1 と 2 をタップ。4 小節のモーフでゆっくり移ることも。",
|
||
"1 本のショーには:各ソングを書き出し(ソングとセクション → このソングを書き出す)プレイリストに追加、MIDI コントローラーを覚えさせ(MIDI ラーン)、本番前にロック、セットを録音。"],
|
||
lvxGuideFoot: "各カードの「?」が説明します。コントロールにマウスを置くと何をするか表示されます。「表示:基本」は上級カードを隠します。",
|
||
lvxSub_transport: "スタート、ストップ、録音、テンポ。",
|
||
lvxSub_sections: "何が鳴るか:ソングの 4 つのパート(ノート)。",
|
||
lvxSub_scenes: "どう鳴るか:ミックスとエフェクトのスナップショットをワンタップで。",
|
||
lvxSub_mixer: "トラックごと:音色、レベル、フィルタ、センド、ミュート、ソロ。",
|
||
lvxSub_keys: "「演奏」で選んだトラックを鍵盤で(ドラムは 16 パッド)。",
|
||
lvxSub_perform: "演奏中のトラックのすべてのノブを 4 つのタブで。",
|
||
lvxSub_fx: "パッドを押している間だけ鳴るエフェクト(FM-1 の FX + キー)。",
|
||
lvxSub_master: "ミックス全体に:DJ フィルタ、ローファイのダスト、キックのダッキング。",
|
||
lvxSub_playlist: "ソングを順番に、1 本のセットとして。",
|
||
lvxHelp_transport: "再生/停止:PLAY ボタンと同じ。録音:演奏中のトラックに録音(FM-1 の REC と同じ)。空のプロジェクトでは、もう一度押すとループが確定。元に戻す/やり直す:最後の録音や編集。\nBPM:ノブを上下にドラッグ(Shift で細かく)、またはタップ。SWING:まっすぐからシャッフルまで。カウンターは小節.拍、ソングモードではソングの位置。\nループ/ソング:ループ再生かソング(セクションの順)。ソング録音:演奏したセクションの順がソングになります。フィル(押す間)、次の小節フィル。\n全オフ:すべてのノートとエフェクトを止めます。全画面:ページのみ。\n2 段目:時計とセットの時間(タップでリセット)、セット録音(FM-1 の USB オーディオを WAV に)、MIDI ラーンとロック。",
|
||
lvxHelp_sections: "セクションはループ全体:4 トラックのパターン、音色、ミックス。ソングは A、B、C、D(例:A イントロ、B バース、C サビ、D ブレイク)。\n作り方:ループを鳴らし、「ループを保存」の文字を押します。使用中のセクションは確認してから上書き。\n切り替え:A–D をタップ(1–4 キー)。再生中は次の小節から(待つ間点滅)、停止中はすぐ。\nセクションは「何が鳴るか」(ノート)を変えます。ノートを変えずに「どう鳴るか」を変えるにはシーンを使います。\nチェーン:2 つ以上の文字(A B B C…)をタップしてチェーン再生。各セクションをその小節数鳴らして次へ、繰り返し(FM-1 の SAVE + 複数キーと同じ)。チェーン停止で 1 つのセクションに戻ります。",
|
||
lvxHelp_scenes: "シーンはノブの写真です:各トラックのレベル、ミュート、パン、フィルタ、センド、ドライブ、音色のノブ、エンベロープ、LFO、INSERT、アルペジオ、そしてマスターエフェクト。ノートには触れません。\n例:シーン 1「イントロ」=フィルタ閉、ドラム小さめ、リバーブ少;シーン 2「ドロップ」=全開。ループを鳴らして 1、ドロップで 2 をタップ。\n保存:ノブを決めて「保存」、シーンパッドを押す。ダブルクリックで名前。F1–F8 呼び出し、Shift+F1–F8 保存。\nモーフ:「すぐ」は即切替、1–16 小節はゆっくり移ります(ビルドアップ)。+音色:プリセットとキットも読み込み。+テンポ:BPM も。\nクロスフェーダー:2 つのシーン(A と B)を選び、手でスライド。",
|
||
lvxHelp_mixer: "トラックごとに 1 本(1–3 シンセ、D ドラム)。リストと ‹ › で音色(ドラムはキット)、☆ でお気に入り。\nフェーダーはレベル(横にメーター)、音色の下の細い線はパターンの位置。\nfilt:左ローパス(暗く)、右ハイパス(細く)。pan:左右。rev、dly、cho:リバーブ、ディレイ、コーラスへの量。drive:サチュレーション。\nミュート/ソロ:GLO + キーと同じ。演奏:下の鍵盤とパフォームがこのトラックに(FM-1 でも選択されるので REC で録音)。",
|
||
lvxHelp_keys: "鍵盤は「演奏」で選んだトラックを MIDI ノートで鳴らします:すぐ鳴り、REC で録音されます。\nパソコン:A W S E D F T G Y H U J K O L P が鍵盤、Z / X でオクターブ。ドラムは同じ文字が 16 パッド、強さは 4 段階(GHOST、SOFT、NORM、HARD)。\nベロシティ:強さ。アルペジオ:トラックのアルペジオモード。ホールド:離しても鳴り続けます。\n演奏/ロール/消去:鍵盤とパッドの動作。ロールは押している間ロールの速さで連打(ARP + キーと同じ)、REC 中は録音されます。消去は押している間そのノートやドラム音をパターンから消します:再生中は通ったステップ、停止中は全ステップ(EDIT + キーと同じ、アンドゥで戻せます)。",
|
||
lvxHelp_perform: "演奏中のトラックのすべてを、メニューなしで。\n音色:エンジンの値(FM-1 の EDIT ページ)、3 つのマクロ(FLT PIT SHP)、エンベロープとグライド、LFO。\nアルペジオ・キー:アルペジオ(モード、速さ、オクターブ、ゲート、スウィング、順序、ホールド)、キー(ルート、スケール、コード、トランスポーズ)——「全シンセトラック」で 3 つのシンセに送ります。\nインサート・バス:トラックの INSERT とフィルタ、共有のディレイ、リバーブ、コーラス、TEXTURE、メトロノーム。\nステップ:パターンのグリッド。タップでオン/オフ(新しいシンセステップは最後に弾いた音)、右クリックでフィル条件(黄:フィルのみ、赤:フィルなし)。LEN、DIV、SWG、GATE:長さ、速さ、スウィング、音の長さ。\nドラムの音色タブ:パッドを選び、チューン(半音)とディケイ(DRUMS の SOUND ページと同じ)。ステップタブのパターンボタン:全体を 1 ステップずらす、長さ ½ / ×2、トランスポーズ(各 1 回のアンドゥ)。",
|
||
lvxHelp_fx: "パンチインエフェクトはパッドを押している間(または Shift + 文字キー)だけ鳴り、離すと元通り。何も録音・変更されません。\nループ・タイム:直前の拍の繰り返し(LOOP 4…32)、スタッター、リバース、ストップ、半速、巻き戻し、フリーズ。フィルタ・EQ:ロー/ハイパス、帯域カット、電話。カラー:クラッシュ、エイリアス、オクターブ上、フランジャー、エコー。ムーブメント:ゲート、ワブル、オートパン、モノ、フェードアウト。\nラッチ:タップでオンのまま、もう一度(または別のエフェクト)でオフ。",
|
||
lvxHelp_master: "トラックの後、ミックス全体にかかります。\nフィルタ:DJ フィルタ(左暗く、右細く、中央オフ)。ダスト:ローファイ(ノイズ、揺れ、ざらつき)。ダック:キックが他のトラックを押し下げます(ポンピング)。\n音量:ここから FM-1 の音量。MASTER ノブを回すとノブに戻ります(ノブ:すぐ戻す)。リバーブスロー/エコースロー:押す間、全トラックがリバーブかディレイへ(FX + OCT- / OCT+ と同じ)、離すと戻ります。",
|
||
lvxHelp_playlist: "複数のソングのセット用。まず各ソングをファイルに:ソングとセクション → このソングを書き出す(ループ、A–D と順番)。\nソングを追加:ファイルをここへ。ソングをタップ(または次のソング、N キー):FM-1 が止まり、数秒で読み込み、「読み込んだら再生」で始まります。\n✎ でソングのテンポ(読み込み時に設定)とキュー(ステージ用メモ、再生中に表示、次のソングも)。\nリストを保存:ソング、シーン、MIDI 割り当てを 1 ファイルに。リストはこのブラウザにも残ります。",
|
||
lvxTabSub_sound: "トラックの音:エンジン、マクロ、エンベロープ、LFO。",
|
||
lvxTabSub_arp: "アルペジオとトラックのキー。",
|
||
lvxTabSub_fx: "トラックの INSERT とフィルタ、全トラック共有のエフェクト。",
|
||
lvxTabSub_steps: "パターン:ステップをタップでオン/オフ、右クリックでフィル条件。",
|
||
lvxTip_play: "再生/停止(Space)", lvxTip_rec: "演奏中のトラックに録音(C)。空のプロジェクト:もう一度でループ確定", lvxTip_undo: "最後の録音や編集を元に戻す/やり直す",
|
||
lvxTip_tap: "リズムに合わせてタップでテンポ(B)", lvxTip_bpm: "テンポ:上下にドラッグ、Shift で細かく、ダブルクリックで初期値", lvxTip_swing: "スウィング:まっすぐからシャッフルまで",
|
||
lvxTip_loop: "ループかソング(セクションの順)を再生", lvxTip_songrec: "演奏したセクションの順がソングになります",
|
||
lvxTip_fill: "押している間フィル(9)", lvxTip_fillbar: "次の小節をフィルに(0)", lvxTip_panic: "すべてのノートとエフェクトを止める(Esc)",
|
||
lvxTip_sec: "次の小節からこのセクション(1–4 キー)", lvxTip_storesec: "今のループをこのセクションに保存",
|
||
lvxTip_scene: "このシーンを呼び出す(F1–F8)。先に保存:今のノブを記憶。ダブルクリック:名前", lvxTip_store: "続けてシーンパッドを押すと今のノブを記憶",
|
||
lvxTip_morph: "シーンの来かた:すぐ、または 1–16 小節かけて", lvxTip_xf: "シーン A と B の間を手でスライド", lvxTip_ab: "クロスフェーダーが混ぜる 2 つのシーン",
|
||
lvxTip_wsounds: "シーンがプリセットとキットも記憶・読み込み", lvxTip_wtempo: "シーンが BPM も記憶・設定",
|
||
lvxTip_lvl: "トラックのレベル(横にメーター)", lvxTip_mute: "トラックをミュート(5–8)", lvxTip_solo: "このトラックだけ(Shift+5–8)",
|
||
lvxTip_sel: "鍵盤とパフォームがこのトラックに", lvxTip_snd: "前/次の音色(ドラム:キット)", lvxTip_fav: "お気に入り:すべての音色リストの先頭に(このブラウザ)",
|
||
lvxTip_pan: "左右", lvxTip_filt: "フィルタ:左ローパス(暗く)、右ハイパス(細く)、中央オフ", lvxTip_send: "このエフェクトへの量",
|
||
lvxTip_drive: "サチュレーション", lvxTip_macro: "音色のマクロ(FM-1 の FLT / PIT / SHP)", lvxTip_env: "エンベロープ:アタック、ディケイ、サステイン、リリース",
|
||
lvxTip_glide: "ノートからノートへのグライド", lvxTip_lfo: "LFO:速さと、ピッチ・フィルタ・形・レベルへの量",
|
||
lvxTip_ins: "トラックの INSERT エフェクト:種類、3 つの値、ドライ/ウェット", lvxTip_arp: "アルペジオ", lvxTip_hold: "離してもノートが鳴り続けます",
|
||
lvxTip_key: "キー:ルート、スケール、コード、トランスポーズ", lvxTip_len: "パターン:長さ、速さ(DIV)、スウィング、音の長さ(GATE)",
|
||
lvxTip_engine: "エンジンの値(FM-1 の EDIT ページと同じ)", lvxTip_mfilt: "ミックス全体の DJ フィルタ", lvxTip_dust: "ローファイ:ノイズ、揺れ、ざらつき",
|
||
lvxTip_duck: "キックが他のトラックを押し下げる(ポンピング)", lvxTip_bus: "共有のディレイ/リバーブ/コーラス", lvxTip_tex: "TEXTURE:背景の音(レコード、テープ、雨…)",
|
||
lvxTip_click: "メトロノーム", lvxTip_fx: "押している間エフェクト(Shift + 文字キー)", lvxTip_latch: "タップでエフェクトをオン、もう一度でオフ",
|
||
lvxTip_pad: "ドラムの音(文字キーでも)", lvxTip_next: "次のソングを読み込んで再生(N)",
|
||
lvxTip_recset: "セットを WAV で録音(FM-1 の USB オーディオ)", lvxTip_learn: "MIDI コントローラーを覚えさせる:コントロールをタップ、ノブを動かす",
|
||
lvxTip_lock: "誤タップを防ぐロック(長押しで解除)", lvxTip_clock: "時刻とセットの経過時間(タップでリセット)",
|
||
lvxTip_view: "基本:トランスポート、セクション、ミキサー、鍵盤、エフェクト。すべて:+シーン、パフォーム、プレイリスト、ステージツール",
|
||
lvxVolume: "音量", lvxKnob: "ノブ", lvxThrowRev: "リバーブスロー", lvxThrowEcho: "エコースロー", lvxChain: "チェーン",
|
||
lvxChainPlay: "チェーン再生", lvxChainStop: "チェーン停止", lvxChainClear: "チェーンをクリア", lvxChainEmpty: "2 つ以上の文字をタップ",
|
||
lvxChainStopped: "チェーンは FM-1 の再生中に動きます。先に再生を押してください。", lvxK_play: "演奏", lvxK_roll: "ロール", lvxK_erase: "消去",
|
||
lvxRollRate: "ロールの速さ", lvxPad: "パッド", lvxPadSound: "パッドの音", lvxTune: "チューン", lvxDecay: "ディケイ", lvxPattern: "パターン",
|
||
lvxShiftL: "◀ ずらす", lvxShiftR: "ずらす ▶", lvxHalf: "長さ ½", lvxDouble: "長さ ×2", lvxTrDown: "トランスポーズ −", lvxTrUp: "トランスポーズ +",
|
||
lvxTip_vol: "ここからマスター音量。FM-1 の MASTER ノブを回すとノブに戻ります", lvxTip_volknob: "FM-1 の MASTER ノブに戻す",
|
||
lvxTip_throw: "押す間:全トラックのセンドがリバーブ(rev)かディレイ(echo)に全開(FX + OCT- / OCT+ と同じ)",
|
||
lvxTip_chain: "このセクションをチェーンに追加", lvxTip_chainplay: "チェーン再生:各セクションをその小節数、繰り返し(SAVE + 複数キーと同じ)",
|
||
lvxTip_kmode: "鍵盤とパッドの動作:演奏、ロール(押す間の連打)、消去(EDIT + キーと同じ)",
|
||
lvxTip_pat: "このトラックのパターン全体:1 ステップずらす、長さ ½ / ×2、トランスポーズ(各 1 回のアンドゥ)",
|
||
lvxTip_padtw: "このパッドの TUNE(半音)と DECAY(DRUMS の SOUND ページと同じ)",
|
||
dpHelp: "ドラムトラックの音(FM-1 の DRUMS 画面と同じ):キット、レベルとエフェクト、各パッドの TUNE と DECAY(SOUND ページ)。パターンはシーケンサーで。",
|
||
dpPads: "パッド", dpHear: "押す間:このパッドを鳴らす", dpReset: "全パッドをキットのまま", dpResetAsk: "全パッドの TUNE と DECAY を 0(キットのまま)に戻しますか?",
|
||
dpPadsHelp: "パッドをタップで試聴。TUNE:−8 … +7 半音、DECAY:−4(短い)… +3(長い)、0 はキットのまま。どのキットでも、プロジェクトと各セクションに保存。",
|
||
dpNeeds: "各パッドの TUNE と DECAY には FM-1 の SLOOP 2.7 が必要です(このファームウェアにはありません)。",
|
||
lvxScenes: "シーン", lvxScene: "シーン", lvxStore: "保存", lvxStoreHere: "ここに保存", lvxReplace: "{x} を今の音で置き換えますか?",
|
||
lvxStored: "シーンを保存:", lvxRename: "シーン名", lvxMorph: "モーフ", lvxAtOnce: "すぐ", lvxBar: "小節", lvxBars: "小節",
|
||
lvxWithSounds: "+音色", lvxWithTempo: "+テンポ", lvxCross: "クロスフェーダー", lvxNoAB: "先にシーン A と B を保存してください(クロスフェーダー横の 2 つのリスト)。",
|
||
lvxScenesHint: "シーンはミックス、センド、フィルタ、各音色のノブ、INSERT、アルペジオ、マスターを記憶します(+音色:プリセットとキットも、+テンポ:BPM も)。タップ:呼び出し(モーフの小節数で)。保存→シーン:今の音を記憶。ダブルクリック:名前。F1–F8 呼び出し、Shift+F1–F8 保存。",
|
||
lvxPerform: "パフォーム", lvxTab_sound: "音色", lvxTab_arp: "アルペジオ・キー", lvxTab_fx: "インサート・バス", lvxTab_steps: "ステップ",
|
||
lvxEngine: "エンジン", lvxMacro: "マクロ", lvxEnv: "エンベロープ・グライド", lvxLfo: "LFO", lvxArp: "アルペジオ", lvxKey: "キー",
|
||
lvxKeyAll: "全シンセトラック", lvxIns: "インサート", lvxTrkFilt: "トラックフィルタ", lvxDelay: "ディレイ", lvxReverb: "リバーブ", lvxChorus: "コーラス",
|
||
lvxTexture: "テクスチャ", lvxClick: "メトロノーム", lvxPage: "ページ",
|
||
lvxDrumSound: "キット、レベル、センドはストリップに。各パッドの TUNE と DECAY は FM-1 で(DRUMS > SOUND)。",
|
||
lvxDrumArp: "ドラムトラックにアルペジオとキーはありません。シンセトラックを選んでください。",
|
||
lvxGridHint: "ステップをタップ:オン/オフ(新しいステップは最後に弾いた音)。右クリック:フィル条件(フィルのみ、フィルなし)。",
|
||
lvxGridDrumHint: "タップ:そのステップの音をオン/オフ。右クリック:ステップのフィル条件(フィルのみ、フィルなし)。",
|
||
lvxFavs: "お気に入り", lvxFavToggle: "お気に入り(このブラウザ)", lvxUserEmpty: "その USER プリセットは空です。",
|
||
lvxLearn: "MIDI ラーン", lvxLearnPick: "ページのコントロールをタップし、コントローラーのノブかパッドを動かします。右クリック:割り当てを解除。",
|
||
lvxLearnWait: "{x}:コントローラーのノブかパッドを動かしてください…", lvxLearned: "割り当て:", lvxLearnClear: "すべて解除",
|
||
lvxLearnClearAsk: "LIVE ページの MIDI 割り当てをすべて解除しますか?",
|
||
lvxLock: "ロック", lvxUnlock: "ロック中(長押し)", lvxSet: "セット", lvxSetReset: "セットの時間:タップでリセット",
|
||
lvxRecSet: "セット録音", lvxRecStop: "録音停止", lvxRecOn: "録音中:", lvxRecOther: "FM-1 の USB オーディオが見つかりません。録音元:",
|
||
lvxRecNo: "ここでは録音できません(ブラウザのマイク許可が必要):", lvxRecSaved: "セットを WAV で保存:",
|
||
lvxSongEdit: "テンポとキュー", lvxSongBpm: "読み込み時の BPM(空:ソングのまま)", lvxSongNote: "ステージ用のキュー(再生中に表示)",
|
||
lvxNext: "次:", lvxSceneEmpty: "このシーンは空です:ノブを決めて「保存」、このパッドを押してください。", lvxSetScenes: "このセットリストにはシーンと MIDI 割り当てがあります。使いますか(今のものと置き換え)?",
|
||
lsFilt: "フィルタ", lsPan: "パン", lsRev: "リバーブ", lsDly: "ディレイ", lsCho: "コーラス", lsDrv: "ドライブ",
|
||
previewShow: "試聴を表示", previewHide: "試聴を隠す", previewDisclosureHint: "鍵盤・シーケンス・試聴コントロールを開閉", previewStopped: "停止中", previewRunning: "ループ再生中", previewSequence: "現在のシーケンス", previewEdit: "詳細エディター", previewSequenceHint: "クリック:ステップ ON/OFF · ダブルクリック:音符を変更 · 新しい音符はトラック横または鍵盤で選択", previewDoubleClick: "ダブルクリックで音符を変更", previewNoteDialogHint: "鍵盤をクリックして音符を選び、適用でステップに保存。", previewListen: "クリックで試聴", previewOctaveDown: "前のオクターブ", previewOctaveUp: "次のオクターブ", previewChooseNote: "鍵盤で音符を選択", previewApply: "適用", previewCancel: "キャンセル", previewDeactivate: "無効", previewReactivate: "有効", previewFollow: "再生に追従", previewPrevSteps: "前のステップ", previewNextSteps: "次のステップ", previewNewNote: "追加する音符", previewAllDrums: "全16音を表示", previewFewerDrums: "表示を減らす", previewShowDrumGrid: "ドラムを展開", previewHideDrumGrid: "ドラムを閉じる", previewDrumHint: "ドラム:各行は音色、各列はステップ。クリックで打音を追加・削除。", previewAdd: "追加", previewRemove: "削除", previewMuted: "ミュート", previewStep: "ステップ", previewTie: "タイ", previewRest: "休符", previewAudioOn: "音声 ON", previewAudioOff: "音声 OFF", previewHideKeys: "鍵盤を隠す", previewShowKeys: "鍵盤を表示", previewHidePads: "パッドを隠す", previewShowPads: "パッドを表示", previewConnect: "モックに接続して開始", previewLocalConnect: "接続ボタンでローカルエディターを開きます。FM-1は不要です。", previewEnable: "音を有効にする", previewDisable: "音を無効にする", previewPlay: "ループ再生", previewPause: "ループ停止", previewStop: "停止", previewVolume: "音量", previewOutput: "出力", previewKeys: "鍵盤", previewDrums: "16 ドラムパッド", previewTouch: "クリックまたは表示のキーで演奏", previewShortcut: "再生/停止", previewHint: "再生または表示のキーでローカル試聴", previewSongHint: "現在のループのみ再生。SONGのセクション順序は含まれません。", previewReady: "ローカル音声 · 演奏できます", previewPlaying: "ローカル音声 · ループ再生中", previewLoading: "音声エンジンを読み込み中…",
|
||
other: "English", connect: "接続", disconnect: "切断", mock: "モック(実機なし)",
|
||
sound: "音色", engine: "エンジン", presets: "プリセット", initSound: "音色を初期化",
|
||
track: "トラック", drum: "ドラム",
|
||
saveFile: "ファイルに保存", loadFile: "ファイルを読み込む", projects: "ソングとセクション",
|
||
load: "読込", save: "保存", used: "使用中", empty: "空", unknown: "—",
|
||
steps: "ステップ", reload: "再読み込み", clearSeq: "シーケンスを消去",
|
||
notesHelp: "ノートは C4 E4 G4 のように入力(最大 4 音、C4 = 60)。",
|
||
notes: "ノート", time: "タイム", acc: "アクセント", slide: "スライド", vel: "ベロシティ",
|
||
foot: "Chrome か Edge で使えます。", iconsCredit: "アイコン: Fukiai(MIT)Hügelton Instruments",
|
||
nomidi: "このブラウザでは使えません。Chrome か Edge で開いてください。",
|
||
denied: "MIDI(SysEx)の使用が許可されませんでした。",
|
||
nodevice: "SLOOP が見つかりません。USB で接続して、もう一度押してください。",
|
||
connecting: "接続中", reading: "読み込み中 ", steploading: "ステップを読み込み中 ",
|
||
ready: "接続しました", disconnected: "切断されました", lost: "FM-1 が外されました",
|
||
noreply: "応答がありません", error: "エラー: ", busy: "処理中",
|
||
applying: "書き込み中 ", applied: "読み込みました", badfile: "ファイルを読み込めません: ",
|
||
savedSlot: "保存しました: スロット ", loadedSlot: "読み込みました: スロット ", emptySlot: "空のスロットです: ",
|
||
confirmSave: "今のループをセクション {n} にしまいますか?({n} の中身は置き換わります)", confirmLoad: "セクション {n} を今のループに読み込みますか? 今の音色とパターンは置き換わります。",
|
||
secSaved: "セクションに保存しました: ", secLoaded: "セクションを読み込みました: ", secEmpty: "空のセクションです: ",
|
||
confirmClear: "シーケンスを全部消しますか?", confirmInit: "音色を初期化しますか?",
|
||
samples: "サンプル", smpHelp: "WAV をドロップするか選んでください。1 スロットに 16 ファイルまで、モノ 22050 Hz の ADPCM で合計約 7 秒。SAMPLE エンジンの SET(または SLICE エンジンの SRC)で USR1〜USR4 を選ぶと鳴ります。ドラムキットは「ドラムキット」ページで。",
|
||
zones: "ゾーン", smpName: "名前", chooseFiles: "ファイルを選ぶ", upload: "書き込む", erase: "消去", clearList: "リストを消す",
|
||
file: "ファイル", root: "ルート", keys: "鍵盤", length: "長さ", remove: "外す",
|
||
chopOpen: "音を開く", chopHelp: "録音(WAV、MP3、AIFF…)を開くかドロップし、チョップを決めてスロットへ。1 キーに 1 チョップ。長い録音(7 秒以上)でも、使うチョップを選び長さを調整できます。",
|
||
chopDrop: "ここに録音をドロップ、またはクリック", chopPlay: "▶ 再生", chopStop: "■ 停止", chopTap: "TAP",
|
||
chopSnap: "アタックに吸着", chopClear: "マーカーを消去", chopHits: "アタック検出", chopSens: "感度",
|
||
chopGrid: "グリッド", chopEqual: "等分", chopKey: "最初のキー", chopModeKeys: "1 キーに 1 チョップ",
|
||
chopModeOne: "選択チョップを鍵盤全体に", chopMax: "最大長", chopTo: "送信先", chopZip: "WAV をダウンロード",
|
||
chopChops: "チョップ", chopTooLong: "スロットに入りません", chopTooMany: "(最大 16 チョップ。残りは使われません)",
|
||
chopLoaded: "読み込みました: ", chopSent: "チョップを書き込みました ",
|
||
chopSel: "チョップ", chopKeep: "使う", chopLen: "長さ", chopFull: "次のマーカーまで", chopAll: "すべて使う", chopNone: "すべて外す",
|
||
chopFit: "スロットに合わせる", chopKept: "使用", chopFitted: "長いチョップを短くしました: 最大 ",
|
||
chopOverHint: "— チョップを外すか、短くするか、「スロットに合わせる」を押してください",
|
||
chopKeepHint: "チェックを外したチョップはスロットにも WAV にも入りません。長い録音でも必要な部分だけ選べます。",
|
||
chopHint: "スペース: 再生中に TAP(停止中は再生/停止)· 1–9 0: 試聴 · ダブルクリック: 追加 · ドラッグ: 移動 · ← →: 微調整 · K: 使う/外す · 下のつまみ: 長さ · Del: 削除 · ホイール: ズーム",
|
||
smpTooBig: "大きすぎます", smpDecodeFail: "読み込めません: ", smpUploading: "書き込み中 USR", smpDone: "書き込みました USR",
|
||
smpFail: "サンプルの書き込みに失敗しました: ", smpErased: "消去しました USR",
|
||
confirmErase: "USR{n} を消去しますか?", confirmUpload: "USR{n} に書き込みますか? 今の内容は消えます。",
|
||
layout: "(ファームウェアのパラメーター数が想定と違うため、簡易表示にしています)",
|
||
ctlHelp: "スライダーはクリックしてからホイールか矢印キーで微調整(Shift で 10 ずつ)、ダブルクリックで初期値。",
|
||
live: "● リアルタイム", polling: "○ ポーリング(古いファームウェア)",
|
||
library: "ライブラリ", libSearch: "名前・タグで検索", allEngines: "全エンジン", allTags: "全タグ",
|
||
sortModified: "更新順", sortCreated: "作成順", sortName: "名前順", sortEngine: "エンジン順",
|
||
name: "名前", tagsCol: "タグ", date: "更新",
|
||
audition: "試聴", toSlot: "本体スロットへ", rename: "名前変更", tags: "タグ", duplicate: "複製", delete: "削除",
|
||
exportPatch: "書き出し", saveToLib: "今の音色をライブラリへ", import: "読み込み", exportLib: "ライブラリを書き出し",
|
||
factoryToLib: "ライブラリへコピー", libEmpty: "ライブラリは空です。「今の音色をライブラリへ」やファクトリープリセットのコピー、本体スロットからの取り込み、ファイルの読み込みで追加できます。",
|
||
noMatch: "該当なし", noLibDB: "(ブラウザに保存できません。再読み込みで消えます)",
|
||
bank: "本体のユーザープリセット", bankLoad: "読込", bankStore: "今の音色を保存", bankGet: "ライブラリへ",
|
||
exportBank: "バンクを書き出し", dndHelp: "ライブラリとスロットの間はドラッグでもコピーできます。",
|
||
confirmOverwrite: "スロット {n}({name})を上書きしますか?", confirmEraseSlot: "スロット {n}({name})を消去しますか?",
|
||
confirmDelete: "「{name}」をライブラリから削除しますか?",
|
||
promptName: "名前(本体では英数字 12 文字まで)", promptTags: "タグ(カンマ区切り)",
|
||
promptNameAuto: "名前(英数字 12 文字まで。空なら本体が自動で付けます)",
|
||
auditioning: "試聴の準備中 ", auditioned: "試聴中: ", auditionedPat: "試聴中(パターンも書き込みました): ",
|
||
savedLib: "ライブラリに保存しました: ", copiedLib: "ライブラリにコピーしました: ", imported: "読み込みました: ",
|
||
skippedN: " 件(読めないもの {n} 件)", patchesN: " 件",
|
||
putDone: "本体に書き込みました: スロット ", storedSlot: "本体に保存しました: スロット ", erasedSlot: "消去しました: スロット ",
|
||
loadedUser: "読み込みました: ", reloaded: "本体で音色が変わったので読み直しました", readingBank: "スロットを読み込み中",
|
||
badEngine: "このファームウェアにないエンジンです: ", flashFail: "書き込みに失敗しました(rc {rc})",
|
||
installer: "SLOOP インストーラー",
|
||
offline: "エディタをダウンロード(パソコンでオフライン用:Chrome / Edge で開く)",
|
||
install: "アプリとしてインストール(オフラインで使える・Android も)",
|
||
tabSeq: "シーケンサー", tabTracks: "トラック", tabSettings: "設定",
|
||
navTrack: "トラック", navSounds: "サウンド", navDevice: "本体", tabKits: "ドラムキット", fm1: "FM-1",
|
||
stepList: "ステップ一覧(音名を入力)", stepsOf: "{n} ステップ", fontCredit: "フォント: Terminus(SIL OFL 1.1)",
|
||
ctlDrag: "値を上下にドラッグでも変更できます。",
|
||
kitTitle: "ドラムキット", kitHelp: "ドラムトラック用に 16 の音を作ります(白鍵 1 つに 1 音)。3 ステップ: 音を入れる → 置き場所を選ぶ → FM-1 に送る。",
|
||
kitName: "名前", kitAdd: "ファイルを選ぶ", kitClear: "全部消す", kitFit: "スロットに収める",
|
||
kitSend: "{x} に書き込む", kitUse: "ドラムトラックで {x} を使う", kitZip: "ZIP で保存", kitOpen: "ZIP を開く",
|
||
kitUsed: "{s} 秒 / {t} 秒", kitOver: "入りません",
|
||
kitEmptyPad: "ここに WAV をドロップ\nまたはクリック", kitTune: "ピッチ", kitGain: "音量", kitLen: "長さ",
|
||
kitPlay: "試聴", kitRemove: "消す", kitNone: "まずパッドに音を入れてください。", kitSent: "キットを書き込みました: ",
|
||
kitUsing: "ドラムトラックの KIT: ", kitNoKit: "このファームウェアのドラムトラックには USR キットがありません(2.4 以降)。",
|
||
kitConfirm: "{x} を上書きしてこのキットを書き込みますか?", kitAssigned: "振り分けました: ",
|
||
kitFull: "16 パッドとも埋まっています", kitLoaded: "ZIP を読み込みました: ",
|
||
needDevice: "FM-1 を接続すると編集できます。", smpNone: "このファームウェアにはユーザーサンプルのスロットがありません。",
|
||
bankConnect: "FM-1 を接続すると本体のユーザープリセットも扱えます。", bankNone: "このファームウェアにはユーザープリセットがありません。",
|
||
drumNote: "ドラムトラックにはエンジンもプリセットもありません。レベル・パン・ミュートは「トラック」、キットとパターンは「シーケンサー」で。",
|
||
drumGridHelp: "クリック:ヒット/消去(同じレベルとロールなら)。Shift+クリック:ヒットを一段強く(GHOST・SOFT・NORM・HARD)。白鍵 F3〜G5 の 16 音。",
|
||
drumNoSound: "ドラムトラックにはサウンドがありません:トラック 1〜3 を選んでください。",
|
||
kit: "キット", hitLevel: "レベル", ratchet: "ロール", solo: "SOLO",
|
||
drumHelp: "ドラムは KICK SNARE CHH のように GM の名前か番号で入力(最大 4 音)。",
|
||
stepDetail: "ステップ", nudge: "ナッジ", locks: "パラメータロック", addLock: "+ ロック", noLock: "ロックなし",
|
||
fillCond: "フィル", fcNorm: "通常", fcFill: "フィル時のみ", fcNoFill: "フィル時は休み",
|
||
lockFull: "ロックは 1 トラック 24 個まで。", lockRefused: "このパラメータはロックできません。",
|
||
lockHelp: "ナッジ:ステップの長さの 1/64 単位で早め(−)/遅め(+)。ロック:そのステップだけパラメータの値を変え、次のステップで元に戻ります。フィル:「フィル時のみ」のステップは GLO + キー 9 を押している間(またはキー 10 で次の小節)だけ鳴り、「フィル時は休み」はその間だけ休みます(グリッドの F と ×)。本体では SEQ + ステップ長押し + KNOB 4(ナッジ)/PRESETS(ロック、ALGORITHM でパラメータ)/OCT+(フィル)。",
|
||
mixer: "ミキサー", mixHelp: "本体の TRACKS ページと同じ 4 トラック。フェーダーはレベル(ドラムは GLO > DRUMS LEVEL)。パンはどのトラックも選択を変えずに書き込みます(0.8 のファームウェアでは一瞬そのトラックを選びます)。REC は本体での録音待機の表示です。",
|
||
level: "レベル", pan: "パン", mute: "ミュート", rec: "REC", selectTrack: "選択", selectedTrack: "選択中",
|
||
projHelp: "FM-1 が持つのは 1 曲です: セクション A〜D(それぞれ 4 トラックのループ: 音色、パターン、テンポ、キー)と、その並び(ソングタブ)。「読込」はセクションを今のループに入れ、「保存」は今のループをセクションにしまいます。4 曲ではありません: 何曲も残すには、曲ごとに下のバックアップをファイルに保存し、使う曲を復元してください。",
|
||
bkTitle: "バックアップ", bkHelp: "FM-1 の中身をすべて 1 つのファイルに保存します: 今のループ、ソング(セクション A〜D とその並び)、ユーザープリセット、FM6 の音色バンク、サンプル USR1〜4、設定(色、キャリブレーション、ソング、ライト)。復元すると、本体はファイルの状態に戻ります(今の内容は上書きされます)。",
|
||
bkSave: "バックアップを保存", bkLoad: "ファイルから復元", bkSaving: "バックアップ中 ", bkSaved: "バックアップを保存しました",
|
||
bkRestoring: "復元中 ", bkRestored: "復元しました", bkConfirm: "FM-1 の今の内容をすべてこのバックアップで置き換えます。続けますか?",
|
||
bkBad: "SLOOP のバックアップファイルではないか、壊れています: ", bkStop: "FM-1 の再生を止めてから、もう一度復元してください。",
|
||
bkStale: "本体の内容が途中で変わりました。もう一度バックアップしてください: ", bkRead: "読み取りエラー: ", bkWrite: "書き込みエラー: ", bkRc4: "フラッシュがありません",
|
||
bkNewer: "新しい SLOOP のバックアップです。先に FM-1 をアップデートしてから復元してください(何も変更していません): ",
|
||
system: "システム", firmware: "ファームウェア", sync: "同期", tracksN: "トラック", stepsN: "ステップ数", enginesL: "エンジン",
|
||
smpSlots: "サンプルスロット", userBank: "ユーザープリセット", none: "なし",
|
||
fm6Title: "FM6 の音色(6 オペレーター)", fm6Help: "FM6 エンジンの音色をまるごと編集します。本体のノブ(EDIT の 8 つ)はこの音色の上にかかるマクロです。トラックへ送るとすぐ鳴り、PTCH を回すか別の音を読み込むまでそのトラックの音色になります(プロジェクトは PTCH だけを保存します)。バンク(B1〜B27)に保存すると PTCH で呼び出せます(本体を停止してから)。",
|
||
fm6ReadBtn: "トラックから読む", fm6SendBtn: "トラックへ送る", fm6Live: "編集しながら送る", fm6Slot: "スロット",
|
||
fm6StoreBtn: "バンクに保存", fm6Import: "SysEx を読み込む", fm6Export: "SysEx に書き出し", fm6BankExport: "バンクを SysEx に書き出し",
|
||
fm6Init: "初期音色", fm6Voice: "ボイス", fm6Ops: "オペレーター", fm6Carriers: "キャリア", fm6Feedback: "フィードバック",
|
||
fm6PitchEg: "ピッチ EG", fm6Freq: "周波数",
|
||
fm6Legend: "R1〜R4 / L1〜L4: EG のレートとレベル、BP LD RD LC RC: キーボードレベルスケーリング、RS: レートスケーリング、AMS: LFO 音量変調、KVS: ベロシティ、OL: 出力レベル、MODE: 比率 / 固定、FC FF: 周波数(粗・細)、DET: デチューン(7 が中央)。● はキャリア。",
|
||
fm6Drop: "(.syx をこのパネルにドロップしても読み込めます)",
|
||
fm6PickMany: "ファイルの音色: 名前を押すと編集へ。チェックした音色は「カートリッジを保存」で B1 から順にバンクへ。",
|
||
fm6CartTick: "バンクに入れる", fm6Cart: "カートリッジをバンクに保存({n} 音色 → {b})", fm6CartFirst: "最初の {n}", fm6CartNone: "なし",
|
||
fm6CartFull: "バンクは最大", fm6CartAsk: "{x} の {n} 音色を {b} に保存します(バンクの残りはそのまま)。よろしいですか?",
|
||
fm6CartOver: "そのうち {k} スロットは使用中で、置き換えられます。", fm6CartStop: "ソングを止めてから保存してください",
|
||
fm6CartDone: "バンクに保存しました:", fm6CartOld: "この FM-1 のファームウェアではできません(SLOOP 2.4 以降)",
|
||
fm6UpWhere: "ユーザープリセットにも追加(FM-1 の PRESETS / SELECT で名前から選べます):", fm6UpNone: "しない(PTCH で選ぶ)",
|
||
fm6UpFree: "する: 空きスロットに(空き {k})", fm6UpFrom: "する: {u} から",
|
||
fm6UpAsk: "ユーザープリセット {n} 個を {u} に作ります(各音色の名前で、FM6 の PTCH がそのスロットに)。",
|
||
fm6UpOver: "そのうち {k} 個は既存のユーザープリセットを置き換えます: {names}",
|
||
fm6UpNoRoom: "ユーザープリセットの空きが足りません。空き:", fm6UpPast: "U32 を超えます:",
|
||
fm6UpStop: "バンクは保存しました。ユーザープリセットはソングを止めてからもう一度", fm6UpDone: "バンクとユーザープリセットに保存しました:",
|
||
fm6Pick: "読み込んだファイルの音色(押すと編集へ):", fm6Picked: "編集中:", fm6Sent: "トラックへ送りました:", fm6Read: "トラックから読みました",
|
||
fm6Loaded: "読み込みました", fm6Factory: "F1〜F8 はファクトリー音色です。B1〜B27 を選んでください。", fm6BadSum: "チェックサム不一致あり",
|
||
fm6Short: "途中で切れたデータあり", fm6Skipped: "音色以外の {x} 件は無視",
|
||
fm6NoVoice: "6 オペレーター FM の音色が見つかりません(32 音色バンクか 1 音色の SysEx が必要です)",
|
||
fm6NotSysex: "SysEx ファイルではありません(6 オペレーター FM の 32 音色バンクか 1 音色の SysEx が必要です)",
|
||
fm6Is4op: "4 オペレーター FM の音色データです。FM6 は 6 オペレーターの音色だけ読み込めます",
|
||
fm6OtherBlocks: "6 オペレーターのファイル形式ですが、音色ではないデータ(パフォーマンスや補助データなど)だけでした",
|
||
fm6OtherMaker: "別のメーカーの SysEx です", fm6Universal: "音色ではない汎用 SysEx です",
|
||
fm6Exported: "バンクを書き出しました",
|
||
kitStep1: "音",
|
||
kitStep1Help: "WAV をパッドにドロップ、またはまとめて選ぶとファイル名で振り分けます(kick, bd, snare, hh, open, crash…)。波形をクリックで試聴。パッドごとにピッチ・音量・長さ。",
|
||
kitFitHelp: "長すぎるとき: 長い音(クラッシュ、オープンハット)を短くして収めます。",
|
||
kitStep2: "置き場所",
|
||
kitCapBig: "大きなキット · 約 15 秒",
|
||
kitCapOne: "約 7 秒",
|
||
kitNotePair: "{x}: キットを USR3 と USR4 の 2 スロットに分けて入れます(自動)。USR1 と USR2 は楽器(SAMPLE)用に空いたまま。",
|
||
kitNoteOne: "{x}: キット全体を 1 スロットに(約 7 秒)。他のスロットは楽器用に空いたまま。",
|
||
kitReplaces: "今の中身を置き換えます: {x}",
|
||
kitNo4: "このファームウェアには USR4 がありません(SLOOP 2.4 以降)。",
|
||
kitStep3: "FM-1 に送る",
|
||
kitWhereFM1: "FM-1 では: トラック 4(ドラム)→ KIT = {x}。保存したプロジェクトもこのキットを覚えています。",
|
||
smpIntro: "FM-1 に入れる自分の音。スロットは 4 つ(USR1〜USR4)、各約 7 秒。スロットには楽器(トラック 1〜3 の SAMPLE エンジンで鳴らす)か、ドラムキット(「ドラムキット」ページで作る)が入ります。",
|
||
smpStep1: "スロットを選ぶ",
|
||
smpStep2: "音を作る",
|
||
smpStep3: "FM-1 に送って鳴らす",
|
||
smpModeFiles: "ファイルから(1 ファイル = 1 音)",
|
||
smpModeChop: "録音を切り分ける(CHOP)",
|
||
smpFilesHelp: "楽器用: 各ファイルが自分の音程で鳴り、間の鍵盤は近いファイルを音程を変えて鳴らします。\nピアノ、ベース、パッド、声、数個のワンショットに。ファイル名に音名を入れる(PIANO_C4.wav)か、下で設定。1 スロット 16 ファイルまで、合計約 7 秒。",
|
||
smpChopHelp: "1 つの録音(ループ、ブレイク、フレーズ)を切って、1 キーに 1 片。\n① 録音を開くかドロップ ② 切る位置を決める: 再生中に TAP(スペースキー)、ヒット検出、グリッド、等分 ③ 要らない片のチェックを外し、長すぎたら短く ④ 下の 3 で送信。",
|
||
smpDrop: "WAV ファイルをここにドロップ",
|
||
smpDropHint: "またはクリックして選ぶ(複数可)",
|
||
smpKeymap: "鍵盤の割り当て",
|
||
smpNote: "音程",
|
||
matchLevels: "音量をそろえる", matchHelp: "聞こえる音量をそろえます(大きい音を下げる)。そのあと各音量で耳で調整できます。",
|
||
levelsMatched: "音量をそろえました。各音量で微調整できます。", smpGainHelp: "この音の音量(送るときにかかります)",
|
||
smpLoop: "ループ", smpLoopHelp: "ONE SHOT: 最後まで 1 回。LOOP: 鍵盤を押している間ファイル全体をくり返し、離すとその周を終えて止まる。LOOP+TAIL: 頭のあと、押している間ループ部分をくり返し、離すと残り(テール)を最後まで鳴らす。",
|
||
smpLoopStart: "ループ開始", smpLoopEnd: "ループ終了", smpLoopTail: "押している間ループ、離すとテール。点はゼロクロスに合わせます(クリック防止)。",
|
||
smpHoldPlay: "押し続けて試聴(ループ)、離すとテール",
|
||
smpNoteHelp: "このファイルが元の音程で鳴る鍵盤(C4 = 60)",
|
||
smpEraseSlot: "USR{n} を消去",
|
||
smpReplaces: "USR{n} には「{x}」が入っています: 送信すると置き換わります。",
|
||
smpSlotFree: "USR{n} は空です。",
|
||
smpKitHint: "(ドラムキット USR3+4 に使っているなら、ここに送るとキットの半分が消えます。)",
|
||
smpSendTo: "USR{n} に送る",
|
||
smpPlayOn: "このスロットを鳴らすトラック:",
|
||
smpWhere: "FM-1 では: シンセトラック、エンジン SAMPLE、SET = USR{n}(EDIT ページの KNOB 1)。上のボタンで自動設定。",
|
||
smpNoEngine: "このファームウェアでは自動設定できません: SAMPLE エンジンで SET = USR を選んでください。",
|
||
smpPlaying: "トラック",
|
||
smpFull: "1 スロット 16 ファイルまで",
|
||
chopSendBelow: "送信は下の 3 で。",
|
||
/* SLOOP 2.5: DRUM SYNTH */
|
||
tabDrumSynth: "ドラムシンセ", dsTitle: "ドラムシンセ",
|
||
dsHelp: "自分のシンセドラムキット SYN1〜SYN4(ドラムトラックの KIT の最後)。音を選び、値を変えると FM-1 ですぐ鳴ります。「FM-1 に保存」でフラッシュに残ります(ソングを止めて)。値をダブルクリック: 元のキットの値に戻す。",
|
||
dsOld: "この FM-1 のファームウェアにはドラムシンセがありません(SLOOP 2.5 以降)。",
|
||
dsFrom: "元のキット:", dsCopy: "コピー", dsBits: "CRUSH", dsHoldS: "S&H", dsOff: "OFF",
|
||
dsStore: "FM-1 に保存", dsUse: "ドラムトラックで使う", dsSave: "ファイルに保存", dsOpen: "ファイルを開く",
|
||
dsPlay: "鳴らす", dsAuto: "変えたら鳴らす",
|
||
dsTone: "トーン", dsNoise: "ノイズ", dsFilter: "フィルター", dsOut: "出力",
|
||
dsNotStored: "まだ保存していません", dsStored: "保存済み",
|
||
dsBad: "FM-1 が受け付けませんでした", dsCopyAsk: "{k} を {x} のコピーにします。よろしいですか?", dsCopied: "コピーしました:",
|
||
dsStop: "ソングを止めてから保存してください", dsFlash: "フラッシュに書けませんでした", dsSaved: "FM-1 に保存しました",
|
||
tabTheme: "テーマ", thTitle: "テーマ",
|
||
thHelp: "FM-1 の画面の色を自分で作れます。画面の 5 段階の色(薄い順)、背景、アクセント、4 つのトラックの色を選び、左のプレビューで確認して「FM-1 に送る」。変えるたびに送り直せます。FM-1 では MENU → COLOR の MONO の次に、つけた名前で出ます。白い背景なら「明 ↔ 暗」。",
|
||
thStart: "もとにする", thScreen: "画面(薄い → 濃い)", thTracks: "トラックの色",
|
||
thAcc: "アクセント", thAccHelp: "触っているもの、カーソル、再生位置", thInvert: "明 ↔ 暗", thFix: "読めるように直す",
|
||
thDarkAcc: "アクセントが背景と近すぎます。FM-1 が受け付けません(メニューのカーソルが見えなくなるため)。",
|
||
thDarkBoth: "値(5)とアクセントが背景と近すぎます。FM-1 が受け付けません(メニューが読めなくなるため)。",
|
||
thSendDark: "このままでは FM-1 が受け付けません:「読めるように直す」を押すか、色を変えてください",
|
||
thStSent: "FM-1 と同じ", thStNew: "変更あり:送ると FM-1 に出ます",
|
||
thC1: "線", thC2: "暗い", thC3: "ラベル", thC4: "サブ", thC5: "値", thT4: "ドラム",
|
||
thRampFrom: "1 色から 5 段階を作る", thRamp: "作る", thBg: "背景", thBlack: "黒に戻す",
|
||
thDark: "値(5)の色が背景と近すぎます。FM-1 が受け付けません(メニューが読めなくなるため)。",
|
||
thSend: "FM-1 に送る", thRead: "FM-1 から読む", thRemove: "FM-1 から消す",
|
||
thNoDev: "FM-1 をつなぐと送れます。つながなくても作って共有できます。",
|
||
thOld: "この FM-1 のファームウェアはテーマに対応していません(SLOOP 2.7 以降)。",
|
||
thShare: "共有", thShareHelp: "この 1 行がテーマのすべてです。コピーしてコメントやメッセージに貼れば、ほかの人が下に貼って使えます。",
|
||
thCopy: "コピー", thApply: "使う", thPasteHint: "SLOOP-THEME-1:… を貼る",
|
||
thSent: "FM-1 に送りました(MENU → COLOR)", thGot: "FM-1 のテーマを読みました", thNone: "FM-1 にテーマはありません",
|
||
thRemoved: "FM-1 からテーマを消しました", thStop: "ソングを止めてから送ってください", thRefused: "FM-1 が受け付けませんでした",
|
||
thCopied: "コピーしました", thBadCode: "テーマのコードではありません", thMine: "FM-1 のテーマ",
|
||
dsFileBad: "SLOOP のドラムシンセキットではありません", dsOpenAsk: "{x} を {k} に読み込みます。よろしいですか?", dsOpened: "読み込みました:",
|
||
/* SLOOP 2.5: length, piano roll, MIDI files, song */
|
||
lenLabel: "長さ(ステップ)", viewGrid: "グリッド", viewRoll: "ピアノロール",
|
||
midiExport: "MIDI 書き出し", midiImportBtn: "MIDI 読み込み",
|
||
rollLen: "音の長さ", rollUp: "オクターブ上", rollDown: "オクターブ下",
|
||
rollHelp: "空いた所をクリック: 選んだ長さの音を置く(同じ位置の音は和音に、最大 4 音)。音をクリック: 消す。音の右端をドラッグ: 長さを変える(タイ)。",
|
||
len_whole: "全音符", len_half: "2分", len_quarter: "4分", len_eighth: "8分", len_sixteenth: "16分",
|
||
midiEmpty: "このトラックには書き出す音がありません", midiSaved: "MIDI ファイルを保存しました。音の数: ",
|
||
midiPreview: "MIDI の読み込み", midiNoNotes: "このファイルには音がありません。", midiCancel: "やめる", midiTrack: "トラック",
|
||
midiSource: "読み込むトラック:", midiNotes: "{n} 音", midiGrid: "グリッド: このトラックの DIV({div})",
|
||
midiSteps: "{n} ステップ(最大 {max})",
|
||
midiMoved: "{n} 音がいちばん近いステップに移動します", midiChord: "{n} 音が入りません(1 ステップ 4 音まで、強い音を残す)",
|
||
midiOverlap: "{n} か所で、音が次の音の所で短くなります", midiMerged: "{n} 音が同じステップの同じ音と重なり、1 つになります",
|
||
midiDropped: "{n} 音が {max} ステップを越えるので入りません",
|
||
midiClean: "そのまま入ります。", midiHow: "音の長さはタイになり、各ステップの強さはその中でいちばん大きい velocity になります。",
|
||
midiHowDrum: "GM ドラムの音(36 キック、38 スネア、42 ハット…)がドラムのレーンに、強さが ghost〜hard のレベルに入ります。",
|
||
midiSetLen: "トラックの長さを {n} ステップにする", midiImport: "読み込む",
|
||
midiConfirm: "このトラックのパターンを置き換えます。よろしいですか?", midiDone: "読み込みました。音の数: ", midiBad: "MIDI ファイルを読めません: ",
|
||
tabSong: "ソング", songTitle: "ソング",
|
||
songHelp: "FM-1 の SONG 画面と同じもの: セクション A〜D(FM-1 の SAVE → SECTION)を並べ、それぞれ何小節鳴らすか。全部で 16 項目まで。PLAY はソングモード(SAVE + 13)で。",
|
||
songSection: "セクション", songBars: "小節", songTimes: "回数",
|
||
songEmpty: "空のスロットのセクションがあります: FM-1 で先に SAVE + 5〜8 で保存してください。",
|
||
songAdd: "追加", songSum: "{n} / {max} 項目、{bars} 小節", songLoop: "最後まで来たら:",
|
||
songLoopOff: "止まる", songLoopOn: "最初に戻る", songRead: "FM-1 から読む", songSend: "FM-1 に送る",
|
||
songUp: "上へ", songDown: "下へ", songDel: "削除",
|
||
songOld: "この FM-1 のファームウェアではソングを読めません(SLOOP 2.5 以降)。",
|
||
songBad: "このソングは送れません(16 項目、1〜64 小節まで)", songRefused: "ソングを止めてから送ってください",
|
||
songSent: "ソングを FM-1 に送りました",
|
||
},
|
||
en: {
|
||
/* 2.7: the LIVE page */
|
||
sfTitle: "Songs", sfHelp: "A song file holds the loop playing, the sections A–D and their order (the SONG screen). Keep one per song, and play them one after the other from the LIVE page's playlist. Loading one replaces A–D and the loop on the FM-1 (stop it first).",
|
||
sfSave: "Export this song", sfLoad: "Load a song file", sfName: "The song's name", sfSaving: "Exporting the song ", sfSaved: "Song exported: ",
|
||
sfLoading: "Loading the song ", sfLoaded: "Song loaded: ", sfConfirm: "Load \"{name}\"? The sections A–D and the loop on the FM-1 are replaced.",
|
||
songBadFile: "Not a SLOOP song file", plTitle: "playlist", plAdd: "add songs", plSave: "save the list", plOpen: "open a list",
|
||
plNext: "next song", plAuto: "play when loaded", plEmpty: "Export your songs (Song & sections → Export this song), then add them here.",
|
||
plLoad: "load", plUp: "up", plDown: "down", plRemove: "remove", plBadList: "Not a SLOOP playlist",
|
||
tabLive: "LIVE", lvNeeds: "Transport, sections, fills and effects need SLOOP 2.7 on the FM-1. The mixer and the keys work.",
|
||
lvPlay: "play", lvStop: "stop", lvRec: "rec", lvRecArm: "rec armed", lvRecFree: "rec: close loop", lvUndo: "undo", lvRedo: "redo", lvBpm: "BPM", lvTap: "tap",
|
||
lvSwing: "swing", lvBar: "bar", lvSong: "song", lvLoop: "loop", lvSongRec: "song rec", lvFill: "fill", lvFillHold: "hold", lvFillBar: "fill bar",
|
||
lvCpu: "CPU", lvFull: "full screen", lvFullOff: "exit full screen", lvSections: "sections", lvSecHint: "Tap: plays on the next bar (stopped: at once).",
|
||
lvSecPlaying: "playing", lvSecNext: "next", lvSecEmpty: "empty", lvStore: "save the loop into", lvStoreAsk: "Replace section {x} with the loop playing now?",
|
||
lvMixer: "mixer", lvMute: "mute", lvSolo: "solo", lvSel: "play", lvSelOn: "playing", lvLevel: "level", lvPan: "pan", lvFilter: "filter", lvRev: "reverb",
|
||
lvDly: "delay", lvCho: "chorus", lvDrive: "drive", lvMaster: "master fx", lvDust: "dust", lvDuck: "duck", lvSound: "sound", lvKit: "kit",
|
||
lvFx: "punch-in effects", lvFxHint: "Hold a pad (or Shift + a key): the effect plays while held. LATCH: a tap turns it on, another tap off.",
|
||
lvLatch: "latch", lvFxLoops: "loops & time", lvFxTone: "filter & EQ", lvFxColour: "colour", lvFxMove: "movement",
|
||
lvKeys: "keys", lvTrack: "track", lvOct: "octave", lvVel: "velocity", lvArp: "arp", lvHold: "hold", lvLvl: ["GHOST", "SOFT", "NORM", "HARD"],
|
||
lvNoChan: "The FM-1 does not take notes for this track: GLO > MIDI gives it no channel and OTHER is OFF.",
|
||
lvClock: "GLO > SYSTEM > IN = CLOCK: the FM-1 ignores notes. Set IN to NOTES to play from here.",
|
||
lvShortcuts: "Space play / stop · 1–4 sections · 5–8 mute · Shift+5–8 solo · 9 fill (hold) · 0 fill bar · B tap · C rec · N next song · Z / X octave · ← → track · keys A W S E D F T G Y H U J K O L P play · Shift + those keys: effects · F1–F8 scenes (Shift: store) · Esc all off",
|
||
lvPanic: "all off", lvStored: "Loop saved into section ",
|
||
lvxHelpShow: "how it works", lvxViewAll: "view: everything", lvxViewSimple: "view: essentials",
|
||
lvxGuideTitle: "first live in 5 steps", lvxGuideOk: "got it",
|
||
lvxGuideSteps: ["Press PLAY (or Space). The FM-1 plays its loop; the bar.beat counter moves.",
|
||
"Build your song with the sections A–D: play a loop you like, press A under “save the loop into”, change the loop, save it into B… Tap A, B, C or D: the FM-1 jumps there at the next bar.",
|
||
"Mix with the faders, mute and solo. Hold an effect pad (LOOP 4, STOP, KILL LOW…) for a punch-in that lasts while you hold it.",
|
||
"Scenes change how it sounds, not what plays: store a calm mix in scene 1 (filters closed, little reverb) and a big one in scene 2, then tap 1 and 2 — or choose a morph of 4 bars to glide from one to the other.",
|
||
"For a whole show: export each song (Song & sections → Export this song) and add them to the playlist, teach your MIDI controller the page (MIDI learn), lock the page before you go on, and record the set."],
|
||
lvxGuideFoot: "Every card has a “?” that explains it, and a mouse over a control says what it does. “view: essentials” hides the advanced cards.",
|
||
lvxSub_transport: "Start, stop, record and keep time.",
|
||
lvxSub_sections: "What plays: the four parts of your song (the notes).",
|
||
lvxSub_scenes: "How it sounds: snapshots of the mix and effects, recalled with one tap.",
|
||
lvxSub_mixer: "Each track: its sound, level, filter, sends, mute and solo.",
|
||
lvxSub_keys: "Play the track chosen with “play”: the keys, or the 16 pads for the drums.",
|
||
lvxSub_perform: "Every knob of the track you play, in four tabs.",
|
||
lvxSub_fx: "Effects that play while you hold the pad, like FX + a key on the FM-1.",
|
||
lvxSub_master: "On the whole mix: the DJ filter, the lo-fi dust, the kick's ducking.",
|
||
lvxSub_playlist: "Your songs, one after the other, for a whole set.",
|
||
lvxHelp_transport: "PLAY / STOP: as the PLAY button. REC: records into the track you play (as REC on the FM-1); in an empty project, REC again closes the loop. undo / redo: the last recording or edit.\nBPM: drag the knob up or down (Shift: fine), or tap TAP in time. SWING: from straight to shuffled. The counter shows bar.beat, and in song mode the part and bar of the song.\nloop / song: the loop playing, or the song (the sections in order). song rec: the order you play the sections becomes the song. FILL while held, FILL BAR: the next bar is a fill (the steps marked “fill only” play).\nall off: lets go of every note and effect. full screen: the page alone.\nThe second row: the clock and the set's time (tap it to start again), record set (a WAV of what the FM-1 plays, from its USB audio), MIDI learn and lock (see their tips).",
|
||
lvxHelp_sections: "A section is a whole loop: the four tracks' patterns, sounds and mix. A song is A, B, C, D — for example A intro, B verse, C chorus, D break.\nTo make one: play the loop you want, then under “save the loop into” press a letter. A used section asks before it is replaced.\nTo switch: tap A–D (or keys 1–4). Playing, the new section starts at the next bar (it blinks while it waits); stopped, at once.\nSections change WHAT plays (the notes). To change HOW it sounds without changing the notes, use the scenes.\nchain: tap two or more letters (A B B C…), then play chain: each section plays for its own bars, then the next, and the chain loops — as SAVE + several keys on the FM-1. stop chain goes back to one section.",
|
||
lvxHelp_scenes: "A scene is a photo of your knobs: each track's level, mute, pan, filter, sends, drive, sound knobs, envelope, LFO, INSERT and arp, and the master effects. It does not touch the notes.\nExample: scene 1 “intro” = filters closed, drums low, little reverb; scene 2 “drop” = everything open and loud. Play your loop, tap 1, then 2 at the drop: the FM-1 jumps from one sound to the other.\nTo store: set the knobs as you want them, press STORE, then a scene pad. Double-click a pad to name it. F1–F8 recall, Shift+F1–F8 store.\nmorph: “at once” jumps; 1–16 bars glides there slowly (a build-up). + sounds: the scene also loads its presets and kit. + tempo: it also sets the BPM.\nThe crossfader: pick two scenes (A and B) and slide between them by hand, like a DJ.",
|
||
lvxHelp_mixer: "One strip per track (1–3 synths, D drums). The list and ‹ › change the sound (the drums: the kit); ☆ makes it a favourite.\nThe fader is the level (its meter beside it); the thin bar under the sound is where the pattern is.\nfilt: left a low-pass (darker), right a high-pass (thinner). pan: left / right. rev, dly, cho: how much goes to the reverb, delay, chorus. drive: saturation.\nmute / solo: as GLO + key. play: the keys below and the PERFORM card follow this track (it is selected on the FM-1 too, so REC records it).",
|
||
lvxHelp_keys: "The keys play the track chosen with “play” (or the track buttons here), as real MIDI notes: they sound at once, and REC records them.\nOn the computer: A W S E D F T G Y H U J K O L P are the keys (white and black), Z / X change the octave. For the drums, the same letters are the 16 pads, with four strengths (GHOST, SOFT, NORM, HARD).\nvelocity: how hard the keys play. arp: the track's arpeggiator mode, hold: notes keep playing after you let go.\nplay / roll / erase: what the keys and pads do. roll repeats the note or drum sound while you hold it, at the roll rate (as ARP + key); playing with REC on, it is recorded. erase removes that note or drum sound from the pattern while you hold it: playing, the steps it passes; stopped, every step (as EDIT + key; undo brings it back).",
|
||
lvxHelp_perform: "Everything you can turn on the track you play, without menus.\nsound: the engine's own values (as the FM-1's EDIT page), the three macros (FLT PIT SHP), the envelope and glide, the LFO.\narp & key: the arpeggiator (mode, rate, octaves, gate, swing, order, hold); the key (root, scale, chord, transpose) — “every synth track” sends the key to all three synths.\ninsert & bus: the track's INSERT effect and filter; the shared delay, reverb, chorus, TEXTURE (a background bed) and the metronome.\nsteps: the pattern as a grid. Tap a step to turn it on or off (a new synth step plays the last note you played); right-click for its fill condition (yellow: only in a fill, red: never in a fill). LEN, DIV, SWG, GATE: the pattern's length, speed, swing and note length.\nThe drums' sound tab: pick a pad, then its tune (semitones) and decay, as the DRUMS screen's SOUND page. The steps tab's pattern buttons: shift the whole pattern a step, half or double its length, transpose it — each one undo.",
|
||
lvxHelp_fx: "Punch-in effects play only while you hold the pad (or Shift + a letter key), then the sound comes back exactly as it was: nothing is recorded or changed.\nloops & time: repeat the last beats (LOOP 4 … 32), stutter, reverse, stop, half speed, rewind, freeze. filter & EQ: low / high pass, kill a band, phone. colour: crush, alias, octave up, flanger, echo. movement: gate, wobble, auto-pan, mono, fade out.\nlatch: a tap turns the effect on and it stays; another tap (or another effect) turns it off.",
|
||
lvxHelp_master: "These act on the whole mix, after the tracks.\nfilter: a DJ filter (left darker, right thinner, middle off). dust: lo-fi — noise, wobble and grit. duck: the kick pushes the other tracks down (the “pumping” of dance music).\nvolume: the FM-1's level from here; turning its MASTER knob takes it back (knob: at once). rev throw / echo throw: hold for every track to pour into the reverb or the delay, as FX + OCT- / OCT+ — let go and it falls back.",
|
||
lvxHelp_playlist: "For a set of several songs. First, save each song as a file: Song & sections → Export this song (the loop, A–D and their order).\nadd songs: put the files here. Tap a song (or next song, key N): the FM-1 stops, loads it in a few seconds and, with “play when loaded”, starts.\n✎ gives a song its tempo (set when it loads) and a cue — a note for you on stage, shown while it plays, with the next song under it.\nsave the list: one file with the songs, your scenes and your MIDI mappings, to take to the gig. The list also stays in this browser.",
|
||
lvxTabSub_sound: "The sound of the track: the engine, the macros, the envelope, the LFO.",
|
||
lvxTabSub_arp: "The arpeggiator and the key the track plays in.",
|
||
lvxTabSub_fx: "The track's INSERT and filter, then the effects all tracks share.",
|
||
lvxTabSub_steps: "The pattern: tap a step on / off, right-click for its fill condition.",
|
||
lvxTip_play: "Play / stop (Space)", lvxTip_rec: "Record into the track you play (C). Empty project: REC again closes the loop", lvxTip_undo: "Undo / redo the last recording or edit",
|
||
lvxTip_tap: "Tap in time to set the tempo (B)", lvxTip_bpm: "Tempo: drag up / down, Shift for fine steps, double-click: default", lvxTip_swing: "Swing: from straight to shuffled",
|
||
lvxTip_loop: "Play the loop, or the song (the sections in order)", lvxTip_songrec: "The order you play the sections becomes the song",
|
||
lvxTip_fill: "A fill while you hold it (9)", lvxTip_fillbar: "The next bar is a fill (0)", lvxTip_panic: "Let go of every note and effect (Esc)",
|
||
lvxTip_sec: "Play this section from the next bar (keys 1–4)", lvxTip_storesec: "Save the loop playing now into this section",
|
||
lvxTip_scene: "Recall this scene (F1–F8). STORE first: keep the knobs as they are now. Double-click: rename", lvxTip_store: "Then tap a scene pad to keep the knobs as they are now",
|
||
lvxTip_morph: "How a scene comes: at once, or gliding over 1–16 bars", lvxTip_xf: "Slide between scene A and scene B by hand", lvxTip_ab: "The two scenes the crossfader mixes",
|
||
lvxTip_wsounds: "Scenes also keep and load the presets and the kit", lvxTip_wtempo: "Scenes also keep and set the BPM",
|
||
lvxTip_lvl: "The track's level (its meter beside it)", lvxTip_mute: "Mute the track (5–8)", lvxTip_solo: "Only this track (Shift+5–8)",
|
||
lvxTip_sel: "The keys and PERFORM play this track", lvxTip_snd: "The previous / next sound (drums: kit)", lvxTip_fav: "A favourite: at the top of every sound list (this browser)",
|
||
lvxTip_pan: "Left / right", lvxTip_filt: "Filter: left a low-pass (darker), right a high-pass (thinner), middle off", lvxTip_send: "How much goes to this effect",
|
||
lvxTip_drive: "Saturation", lvxTip_macro: "A macro of the sound (as the FM-1's FLT / PIT / SHP)", lvxTip_env: "The envelope: attack, decay, sustain, release",
|
||
lvxTip_glide: "Glide from one note to the next", lvxTip_lfo: "The LFO: its speed and how much it moves pitch, filter, shape, level",
|
||
lvxTip_ins: "The track's INSERT effect: its type, its three values and dry / wet", lvxTip_arp: "The arpeggiator", lvxTip_hold: "Notes keep playing after you let go",
|
||
lvxTip_key: "The key: root, scale, chord, transpose", lvxTip_len: "The pattern: length, speed (DIV), swing, note length (GATE)",
|
||
lvxTip_engine: "A value of the engine (as on the FM-1's EDIT page)", lvxTip_mfilt: "DJ filter on the whole mix", lvxTip_dust: "Lo-fi: noise, wobble, grit",
|
||
lvxTip_duck: "The kick pushes the other tracks down (pumping)", lvxTip_bus: "The shared delay / reverb / chorus", lvxTip_tex: "TEXTURE: a background bed (vinyl, tape, rain…)",
|
||
lvxTip_click: "The metronome", lvxTip_fx: "Hold: the effect plays while held (Shift + its letter)", lvxTip_latch: "A tap turns an effect on, another tap off",
|
||
lvxTip_pad: "A drum sound (the letter key plays it too)", lvxTip_next: "Load and play the next song (N)",
|
||
lvxTip_recset: "Record the set as a WAV (the FM-1's USB audio)", lvxTip_learn: "Teach the page your MIDI controller: tap a control, move a knob",
|
||
lvxTip_lock: "Lock the page against stray taps (hold to unlock)", lvxTip_clock: "The time, and how long the set has run (tap: start again)",
|
||
lvxTip_view: "Essentials: transport, sections, mixer, keys, effects. Everything: + scenes, PERFORM, playlist, stage tools",
|
||
lvxVolume: "volume", lvxKnob: "knob", lvxThrowRev: "rev throw", lvxThrowEcho: "echo throw", lvxChain: "chain",
|
||
lvxChainPlay: "play chain", lvxChainStop: "stop chain", lvxChainClear: "clear the chain", lvxChainEmpty: "tap 2+ letters",
|
||
lvxChainStopped: "A chain plays while the FM-1 plays: press PLAY first.", lvxK_play: "play", lvxK_roll: "roll", lvxK_erase: "erase",
|
||
lvxRollRate: "roll rate", lvxPad: "pad", lvxPadSound: "pad sound", lvxTune: "tune", lvxDecay: "decay", lvxPattern: "pattern",
|
||
lvxShiftL: "◀ shift", lvxShiftR: "shift ▶", lvxHalf: "½ length", lvxDouble: "×2 length", lvxTrDown: "transpose −", lvxTrUp: "transpose +",
|
||
lvxTip_vol: "The master level from here; turning the FM-1's MASTER knob takes it back", lvxTip_volknob: "Back to the FM-1's MASTER knob",
|
||
lvxTip_throw: "Hold: every track's send goes full into the reverb (rev) or the delay (echo), as FX + OCT- / OCT+",
|
||
lvxTip_chain: "Add this section to the chain", lvxTip_chainplay: "Play the chain: each section for its bars, looped (as SAVE + several keys)",
|
||
lvxTip_kmode: "What the keys and pads do: play, roll (note repeat while held) or erase (as EDIT + key)",
|
||
lvxTip_pat: "The whole pattern of this track: shift by a step, half / double its length, transpose (each one undo)",
|
||
lvxTip_padtw: "This pad's TUNE (semitones) and DECAY, as the DRUMS screen's SOUND page",
|
||
dpHelp: "The drum track's sound, as the FM-1's DRUMS screen: the kit, its level and effects, and each pad's TUNE and DECAY (its SOUND page). The pattern: Sequencer.",
|
||
dpPads: "pads", dpHear: "Hold: hear this pad", dpReset: "all pads as the kit", dpResetAsk: "Put every pad's TUNE and DECAY back to 0 (as the kit has them)?",
|
||
dpPadsHelp: "Tap a pad to hear it. TUNE: −8 … +7 semitones; DECAY: −4 (short) … +3 (long), 0 as the kit has it. Every kit, kept with the project and each section.",
|
||
dpNeeds: "Each pad's TUNE and DECAY need SLOOP 2.7 on the FM-1 (this firmware does not have them).",
|
||
lvxScenes: "scenes", lvxScene: "scene", lvxStore: "store", lvxStoreHere: "store here", lvxReplace: "Replace {x} with what plays now?",
|
||
lvxStored: "Scene stored: ", lvxRename: "Scene name", lvxMorph: "morph", lvxAtOnce: "at once", lvxBar: "bar", lvxBars: "bars",
|
||
lvxWithSounds: "+ sounds", lvxWithTempo: "+ tempo", lvxCross: "crossfader", lvxNoAB: "Store scenes A and B first (the two lists beside the crossfader).",
|
||
lvxScenesHint: "A scene keeps the mix, the sends, the filters, each sound's knobs, the INSERT, the arp and the master bus (+ sounds: the presets and kit too; + tempo: the BPM). Tap: recall (over the morph's bars). STORE then a scene: keep what plays now. Double-click: rename. F1–F8 recall, Shift+F1–F8 store.",
|
||
lvxPerform: "perform", lvxTab_sound: "sound", lvxTab_arp: "arp & key", lvxTab_fx: "insert & bus", lvxTab_steps: "steps",
|
||
lvxEngine: "engine", lvxMacro: "macros", lvxEnv: "envelope & glide", lvxLfo: "lfo", lvxArp: "arp", lvxKey: "key",
|
||
lvxKeyAll: "every synth track", lvxIns: "insert", lvxTrkFilt: "track filter", lvxDelay: "delay", lvxReverb: "reverb", lvxChorus: "chorus",
|
||
lvxTexture: "texture", lvxClick: "metronome", lvxPage: "page",
|
||
lvxDrumSound: "The kit, its level and sends are on the strip; each pad's TUNE and DECAY: on the FM-1 (DRUMS > SOUND).",
|
||
lvxDrumArp: "The drum track has no arp or key: pick a synth track.",
|
||
lvxGridHint: "Tap a step: on / off (a new step plays the last note you played). Right-click: its fill condition (fill only, no fill).",
|
||
lvxGridDrumHint: "Tap: the sound on that step, on / off. Right-click: the step's fill condition (fill only, no fill).",
|
||
lvxFavs: "favourites", lvxFavToggle: "favourite (this browser)", lvxUserEmpty: "That USER preset is empty.",
|
||
lvxLearn: "MIDI learn", lvxLearnPick: "Tap a control of the page, then move a knob or press a pad on your controller. Right-click a control: forget it.",
|
||
lvxLearnWait: "{x}: now move a knob or press a pad on the controller…", lvxLearned: "Learned: ", lvxLearnClear: "forget all",
|
||
lvxLearnClearAsk: "Forget every MIDI mapping of the LIVE page?",
|
||
lvxLock: "lock", lvxUnlock: "locked (hold)", lvxSet: "set", lvxSetReset: "the set's time: tap to start again",
|
||
lvxRecSet: "record set", lvxRecStop: "stop rec", lvxRecOn: "Recording from ", lvxRecOther: "The FM-1's USB audio was not found; recording from ",
|
||
lvxRecNo: "Recording is not possible here (the browser needs the microphone permission): ", lvxRecSaved: "Set saved as a WAV file: ",
|
||
lvxSongEdit: "tempo and cue", lvxSongBpm: "This song's BPM when it loads (empty: the song's own)", lvxSongNote: "A cue for the stage (shown when it plays)",
|
||
lvxNext: "next:", lvxSceneEmpty: "This scene is empty: set the knobs as you like, press STORE, then this pad.", lvxSetScenes: "This setlist has scenes and MIDI mappings: use them (they replace yours)?",
|
||
lsFilt: "filt", lsPan: "pan", lsRev: "rev", lsDly: "dly", lsCho: "cho", lsDrv: "drive",
|
||
previewShow: "Show preview", previewHide: "Hide preview", previewDisclosureHint: "Open or close the piano, sequence and listening controls", previewStopped: "Stopped", previewRunning: "Playing loop", previewSequence: "Current sequence", previewEdit: "Full editor", previewSequenceHint: "Click: enable / disable a step · double-click: change its note · new notes use the track selector or piano", previewDoubleClick: "Double-click to change notes", previewNoteDialogHint: "Click a piano key to choose the note. Apply saves it to this step.", previewListen: "Listen on click", previewOctaveDown: "Previous octave", previewOctaveUp: "Next octave", previewChooseNote: "Choose a note on the piano", previewApply: "Apply", previewCancel: "Cancel", previewDeactivate: "Disable", previewReactivate: "Enable", previewFollow: "Follow playback", previewPrevSteps: "Previous steps", previewNextSteps: "Next steps", previewNewNote: "New note", previewAllDrums: "Show all 16 sounds", previewFewerDrums: "Show fewer sounds", previewShowDrumGrid: "Show drum grid", previewHideDrumGrid: "Hide drum grid", previewDrumHint: "Drums = percussion. Each row is one sound; each column is a step. Click a cell to add or remove a hit.", previewAdd: "Add", previewRemove: "Remove", previewMuted: "Muted", previewStep: "Step", previewTie: "Tie", previewRest: "Rest", previewAudioOn: "Audio on", previewAudioOff: "Audio off", previewHideKeys: "Hide keys", previewShowKeys: "Show keys", previewHidePads: "Hide pads", previewShowPads: "Show pads", previewConnect: "Connect the mock device to start", previewLocalConnect: "Press Connect to open the local editor. No FM-1 is needed.", previewEnable: "Enable audio", previewDisable: "Disable audio", previewPlay: "Play loop", previewPause: "Stop loop", previewStop: "Stop", previewVolume: "Volume", previewOutput: "Output", previewKeys: "Keys", previewDrums: "16 drum pads", previewTouch: "Click or use the labeled keys", previewShortcut: "play/stop", previewHint: "Press Play or a labeled key to listen locally", previewSongHint: "Current loop only; Song section order is not included.", previewReady: "Local audio · ready to play", previewPlaying: "Local audio · playing loop", previewLoading: "Loading audio engine…",
|
||
other: "日本語", connect: "Connect", disconnect: "Disconnect", mock: "Mock device (no hardware)",
|
||
sound: "Sound", engine: "Engine", presets: "Presets", initSound: "Init sound",
|
||
track: "Track", drum: "Drums",
|
||
saveFile: "Save to file", loadFile: "Load file", projects: "Song & sections",
|
||
load: "Load", save: "Save", used: "used", empty: "empty", unknown: "—",
|
||
steps: "Steps", reload: "Reload", clearSeq: "Clear sequence",
|
||
notesHelp: "Enter notes like C4 E4 G4 (up to 4, C4 = 60).",
|
||
notes: "Notes", time: "Time", acc: "Accent", slide: "Slide", vel: "Velocity",
|
||
foot: "Works in Chrome or Edge.", iconsCredit: "Icons: Fukiai (MIT), Hügelton Instruments",
|
||
nomidi: "This browser cannot do it. Open the page in Chrome or Edge.",
|
||
denied: "MIDI (SysEx) access was not allowed.",
|
||
nodevice: "SLOOP not found. Connect the FM-1 by USB and press Connect again.",
|
||
connecting: "Connecting", reading: "Reading ", steploading: "Reading steps ",
|
||
ready: "Connected", disconnected: "Disconnected", lost: "The FM-1 was unplugged",
|
||
noreply: "No reply from the device", error: "Error: ", busy: "Busy",
|
||
applying: "Writing ", applied: "Loaded", badfile: "Cannot read the file: ",
|
||
savedSlot: "Saved to slot ", loadedSlot: "Loaded slot ", emptySlot: "Empty slot: ",
|
||
confirmSave: "Store the loop you are working on into section {n}? (what is in {n} is replaced)", confirmLoad: "Load section {n} into the loop you are working on? The current sounds and patterns are replaced.",
|
||
secSaved: "Saved into section ", secLoaded: "Loaded section ", secEmpty: "Empty section: ",
|
||
confirmClear: "Clear the whole sequence?", confirmInit: "Reset the sound to the engine defaults?",
|
||
samples: "Samples", smpHelp: "Drop or choose WAV files. Up to 16 files per slot, stored as mono 22050 Hz ADPCM (about 7 s in all). Select USR1–USR4 with SET on the SAMPLE engine (or SRC on the SLICE engine). Drum kits: the Drum kit page.",
|
||
zones: "zones", smpName: "Name", chooseFiles: "Choose files", upload: "Upload", erase: "Erase", clearList: "Clear list",
|
||
file: "File", root: "Root", keys: "Keys", length: "Length", remove: "Remove",
|
||
chopOpen: "Open a sound", chopHelp: "Open or drop a recording (WAV, MP3, AIFF…), mark the chops, send them to a slot: one chop per key. Any length: a recording longer than a slot (7 s) works, keep the chops you want and adjust them.",
|
||
chopDrop: "Drop a recording here, or click", chopPlay: "▶ Play", chopStop: "■ Stop", chopTap: "TAP",
|
||
chopSnap: "snap to the hit", chopClear: "Clear markers", chopHits: "Find hits", chopSens: "sensitivity",
|
||
chopGrid: "Grid", chopEqual: "Equal parts", chopKey: "First key", chopModeKeys: "one key per chop",
|
||
chopModeOne: "selected chop, whole keyboard", chopMax: "max length", chopTo: "Send to", chopZip: "Download WAVs",
|
||
chopChops: "chops", chopTooLong: "too long for a slot", chopTooMany: "(16 chops at most: the rest are left out)",
|
||
chopLoaded: "Loaded: ", chopSent: "Chops in ",
|
||
chopSel: "Chop", chopKeep: "keep", chopLen: "length", chopFull: "Up to the next marker", chopAll: "Keep all", chopNone: "Keep none",
|
||
chopFit: "Fit to slot", chopKept: "kept", chopFitted: "Long chops shortened to at most ",
|
||
chopOverHint: "— untick chops, shorten them, or press Fit to slot",
|
||
chopKeepHint: "Unticked chops go neither to the slot nor to the WAVs: from a long recording, keep only what you want.",
|
||
chopHint: "space: TAP while it plays (play/stop when stopped) · 1–9 0: listen · double-click: add · drag: move · ← →: nudge · K: keep / leave out · bottom handle: length · Del: remove · wheel: zoom",
|
||
smpTooBig: "too large", smpDecodeFail: "Cannot read: ", smpUploading: "Uploading USR", smpDone: "Uploaded USR",
|
||
smpFail: "Sample upload failed: ", smpErased: "Erased USR",
|
||
confirmErase: "Erase USR{n}?", confirmUpload: "Write to USR{n}? Its current contents will be replaced.",
|
||
layout: "(The firmware has a different parameter count; showing a plain list.)",
|
||
ctlHelp: "Sliders: click, then fine-tune with the wheel or arrow keys (Shift: steps of 10); double-click resets.",
|
||
live: "● Live", polling: "○ Polling (older firmware)",
|
||
library: "Library", libSearch: "Search name or tag", allEngines: "All engines", allTags: "All tags",
|
||
sortModified: "Recently changed", sortCreated: "Recently added", sortName: "Name", sortEngine: "Engine",
|
||
name: "Name", tagsCol: "Tags", date: "Changed",
|
||
audition: "Audition", toSlot: "To device slot", rename: "Rename", tags: "Tags", duplicate: "Duplicate", delete: "Delete",
|
||
exportPatch: "Export", saveToLib: "Save current sound", import: "Import", exportLib: "Export library",
|
||
factoryToLib: "Copy to library", libEmpty: "The library is empty. Add sounds with \"Save current sound\", by copying a factory preset or a device slot, or by importing a file.",
|
||
noMatch: "No match", noLibDB: "(this browser cannot store it: it is gone after a reload)",
|
||
bank: "User presets on the device", bankLoad: "Load", bankStore: "Store current sound", bankGet: "To library",
|
||
exportBank: "Export bank", dndHelp: "You can also drag between the library and the slots.",
|
||
confirmOverwrite: "Overwrite slot {n} ({name})?", confirmEraseSlot: "Erase slot {n} ({name})?",
|
||
confirmDelete: "Delete \"{name}\" from the library?",
|
||
promptName: "Name (the device keeps 12 ASCII characters)", promptTags: "Tags (comma separated)",
|
||
promptNameAuto: "Name (12 ASCII characters; empty: the device names it)",
|
||
auditioning: "Preparing audition ", auditioned: "Auditioning: ", auditionedPat: "Auditioning (pattern written too): ",
|
||
savedLib: "Saved to the library: ", copiedLib: "Copied to the library: ", imported: "Imported: ",
|
||
skippedN: " ({n} unreadable)", patchesN: " patches",
|
||
putDone: "Written to the device: slot ", storedSlot: "Stored on the device: slot ", erasedSlot: "Erased slot ",
|
||
loadedUser: "Loaded ", reloaded: "The sound changed on the device: read again", readingBank: "Reading the slots",
|
||
badEngine: "This firmware has no such engine: ", flashFail: "Write failed (rc {rc})",
|
||
installer: "SLOOP installer",
|
||
offline: "Download the editor (offline on a computer: open it in Chrome or Edge)",
|
||
install: "Install the app (works offline, Android too)",
|
||
tabSeq: "Sequencer", tabTracks: "Tracks", tabSettings: "Settings",
|
||
navTrack: "Track", navSounds: "Sounds", navDevice: "Device", tabKits: "Drum kit", fm1: "FM-1",
|
||
stepList: "Step list (type note names)", stepsOf: "{n} steps", fontCredit: "Font: Terminus (SIL OFL 1.1)",
|
||
ctlDrag: "You can also drag a value up or down.",
|
||
kitTitle: "Drum kit", kitHelp: "Build 16 sounds for the drum track, one per white key. Three steps: put your sounds on the pads, choose where the kit goes, send it to the FM-1.",
|
||
kitName: "Name", kitAdd: "Choose files", kitClear: "Clear all", kitFit: "Fit the slot",
|
||
kitSend: "Send to {x}", kitUse: "Use {x} on the drum track", kitZip: "Save as ZIP", kitOpen: "Open ZIP",
|
||
kitUsed: "{s} s of {t} s", kitOver: "too long",
|
||
kitEmptyPad: "Drop a WAV here\nor click", kitTune: "Pitch", kitGain: "Gain", kitLen: "Length",
|
||
kitPlay: "Play", kitRemove: "Remove", kitNone: "Put a sound on a pad first.", kitSent: "Kit sent to ",
|
||
kitUsing: "Drum track KIT: ", kitNoKit: "This firmware's drum track has no USR kits (SLOOP 2.4 and later).",
|
||
kitConfirm: "Replace {x} with this kit?", kitAssigned: "Sorted: ",
|
||
kitFull: "All 16 pads are taken", kitLoaded: "ZIP opened: ",
|
||
needDevice: "Connect the FM-1 to edit.", smpNone: "This firmware has no user sample slots.",
|
||
bankConnect: "Connect the FM-1 to see its user presets too.", bankNone: "This firmware has no user presets.",
|
||
drumNote: "The drum track has no engine or presets. Level, pan and mute: Tracks; the kit and the pattern: Sequencer.",
|
||
drumGridHelp: "Click: a hit / clear it (same level and roll). Shift+click: a hit one level louder (GHOST, SOFT, NORM, HARD). The 16 sounds of the white keys F3..G5.",
|
||
drumNoSound: "The drum track has no sound: select track 1, 2 or 3.",
|
||
kit: "Kit", hitLevel: "Level", ratchet: "Roll", solo: "SOLO",
|
||
drumHelp: "Enter drums by GM name or number, like KICK SNARE CHH (up to 4).",
|
||
stepDetail: "Step", nudge: "Nudge", locks: "Parameter locks", addLock: "+ lock", noLock: "no lock",
|
||
fillCond: "Fill", fcNorm: "normal", fcFill: "fill only", fcNoFill: "no fill",
|
||
lockFull: "A track holds 24 locks at most.", lockRefused: "This parameter cannot be locked.",
|
||
lockHelp: "Nudge: the step early (-) or late (+), in 1/64 of a step. A lock gives a parameter another value for this step only; the base comes back at the next one. Fill: a \"fill only\" step plays only while GLO + key 9 is held (or key 10 makes the next bar a fill), a \"no fill\" step is silent then (F and \u00d7 on the grid). On the device: SEQ + a step held + KNOB 4 (nudge) / PRESETS (the lock; ALGORITHM picks its parameter) / OCT+ (the fill condition).",
|
||
mixer: "Mixer", mixHelp: "The four tracks of the device's TRACKS page. The fader is the level (drums: GLO > DRUMS LEVEL). Pan is written to any track without changing the selection (firmware 0.8: by selecting it for a moment). REC shows a track armed for live recording on the device.",
|
||
level: "Level", pan: "Pan", mute: "Mute", rec: "REC", selectTrack: "Select", selectedTrack: "Selected",
|
||
projHelp: "The FM-1 holds one song: four sections A–D, each a loop of the four tracks (sounds, patterns, tempo, key), and the order they play in (the Song tab). Load puts a section into the loop you are working on; Save stores that loop into a section. They are not four songs: to keep several songs, save a Backup file per song (below) and restore the one you want.",
|
||
bkTitle: "Backup", bkHelp: "Everything on the FM-1 in one file: the loop you are working on, the song (its sections A–D and their order), the user presets, the FM6 patch bank, the samples USR1–USR4 and the settings (colours, calibration, the song, the lights). Restoring puts the FM-1 back as it was in the file (what is on it now is replaced).",
|
||
bkSave: "Save a backup", bkLoad: "Restore from a file", bkSaving: "Backing up ", bkSaved: "Backup saved",
|
||
bkRestoring: "Restoring ", bkRestored: "Restored", bkConfirm: "Replace everything on the FM-1 with this backup?",
|
||
bkBad: "Not a SLOOP backup, or damaged: ", bkStop: "Stop the FM-1 (PLAY), then restore again.",
|
||
bkStale: "The FM-1 changed during the backup; back up again: ", bkRead: "Read error: ", bkWrite: "Write error: ", bkRc4: "No flash",
|
||
bkNewer: "This backup comes from a newer SLOOP: update the FM-1 first, then restore. Nothing was changed: ",
|
||
system: "System", firmware: "Firmware", sync: "Sync", tracksN: "Tracks", stepsN: "Steps", enginesL: "Engines",
|
||
smpSlots: "Sample slots", userBank: "User presets", none: "none",
|
||
fm6Title: "FM6 patch (six operators)", fm6Help: "Edit the whole patch of the FM6 engine. The device's knobs (the eight EDIT values) are macros on top of it. Sent to a track it plays at once and stays that track's patch until PTCH turns or another sound loads (a project keeps PTCH only); stored in the bank (B1..B27) it is a PTCH value (stop the device first).",
|
||
fm6ReadBtn: "Read from track", fm6SendBtn: "Send to track", fm6Live: "Send while editing", fm6Slot: "Slot",
|
||
fm6StoreBtn: "Store in bank", fm6Import: "Import SysEx", fm6Export: "Export SysEx", fm6BankExport: "Export bank as SysEx",
|
||
fm6Init: "Init voice", fm6Voice: "Voice", fm6Ops: "Operators", fm6Carriers: "carriers", fm6Feedback: "feedback",
|
||
fm6PitchEg: "Pitch EG", fm6Freq: "Frequency",
|
||
fm6Legend: "R1..R4 / L1..L4: EG rates and levels; BP LD RD LC RC: keyboard level scaling; RS: rate scaling; AMS: LFO amplitude modulation; KVS: velocity; OL: output level; MODE: ratio / fixed; FC FF: coarse / fine frequency; DET: detune (7 = centre). ● = carrier.",
|
||
fm6Drop: "(or drop a .syx file on this panel)",
|
||
fm6PickMany: "Voices of the file: click a name to edit it. The ticked voices go to the bank in order from B1 with Store cartridge.",
|
||
fm6CartTick: "Put in the bank", fm6Cart: "Store cartridge in bank ({n} → {b})", fm6CartFirst: "First {n}", fm6CartNone: "None",
|
||
fm6CartFull: "The bank holds at most", fm6CartAsk: "Store {n} voice(s) of {x} in {b}? The rest of the bank stays as it is.",
|
||
fm6CartOver: "Slots already in use (their patch will be replaced): {k}.", fm6CartStop: "Stop the song first, then store",
|
||
fm6CartDone: "Stored in the bank:", fm6CartOld: "This FM-1's firmware cannot do it (SLOOP 2.4 or later)",
|
||
fm6UpWhere: "Also add them to the user presets (pick them by name with PRESETS / SELECT on the FM-1):", fm6UpNone: "No (pick them with PTCH)",
|
||
fm6UpFree: "Yes, in the free slots ({k} free)", fm6UpFrom: "Yes, from {u}",
|
||
fm6UpAsk: "Also {n} user preset(s) in {u}, named after the voices (FM6, PTCH on their slot).",
|
||
fm6UpOver: "User presets replaced ({k}): {names}",
|
||
fm6UpNoRoom: "Not enough free user presets. Free:", fm6UpPast: "That goes past U32:",
|
||
fm6UpStop: "The bank is stored; stop the song, then store again for the user presets", fm6UpDone: "Stored in the bank and the user presets:",
|
||
fm6Pick: "Voices of the imported file (click to edit):", fm6Picked: "Editing:", fm6Sent: "Sent to track", fm6Read: "Read from track",
|
||
fm6Loaded: "Loaded", fm6Factory: "F1..F8 are the factory patches: pick B1..B27.", fm6BadSum: "a checksum did not match",
|
||
fm6Short: "some data was cut short", fm6Skipped: "{x} non-voice blocks skipped",
|
||
fm6NoVoice: "No 6-operator FM voices found (expects a 32-voice bank or single-voice SysEx)",
|
||
fm6NotSysex: "Not a SysEx file (expects a 6-operator FM 32-voice bank or single-voice SysEx)",
|
||
fm6Is4op: "These are 4-operator FM voices: FM6 reads 6-operator voices only",
|
||
fm6OtherBlocks: "6-operator file format, but no voices (performance or supplement data only)",
|
||
fm6OtherMaker: "SysEx from another manufacturer", fm6Universal: "Universal SysEx, not voice data",
|
||
fm6Exported: "Bank exported",
|
||
kitStep1: "Your sounds",
|
||
kitStep1Help: "Drop a WAV on a pad, or choose several files: they are sorted onto the pads by name (kick, bd, snare, hh, open, crash…). Click a wave to hear it. Each pad has its pitch, gain and length.",
|
||
kitFitHelp: "Too long? Fit shortens the longest sounds (crashes, open hats) just enough.",
|
||
kitStep2: "Where it goes",
|
||
kitCapBig: "big kit · about 15 s",
|
||
kitCapOne: "about 7 s",
|
||
kitNotePair: "{x}: the kit is shared out over the two slots USR3 and USR4 by itself. USR1 and USR2 stay free for your instruments (SAMPLE).",
|
||
kitNoteOne: "{x}: the whole kit in one slot (about 7 s). The other slots stay free for instruments.",
|
||
kitReplaces: "It replaces what is there now: {x}",
|
||
kitNo4: "This firmware has no USR4 (SLOOP 2.4 and later).",
|
||
kitStep3: "Send it to the FM-1",
|
||
kitWhereFM1: "On the FM-1: track 4 (drums) → KIT = {x}. A project you save remembers the kit.",
|
||
smpIntro: "Your own sounds on the FM-1. Four slots (USR1–USR4) of about 7 s each. A slot holds an instrument, played by a synth track with the SAMPLE engine, or a drum kit (made on the Drum kit page).",
|
||
smpStep1: "Choose a slot",
|
||
smpStep2: "Make the sound",
|
||
smpStep3: "Send it and play it",
|
||
smpModeFiles: "From files (one note per file)",
|
||
smpModeChop: "Chop a recording",
|
||
smpFilesHelp: "For an instrument: each file plays at its own note, and the keys in between play the nearest file, pitched.\nGood for a piano, a bass, a pad, a voice, or a few one-shots. Put the note in the file name (PIANO_C4.wav) or set it below. Up to 16 files, about 7 s in all.",
|
||
smpChopHelp: "Cut one recording (a loop, a break, a phrase) into pieces, one per key.\n① Open or drop it. ② Mark the cuts: TAP while it plays (or the space bar), Find hits, Grid or Equal parts. ③ Untick the pieces you don't want, shorten them if it is too long. ④ Send it in step 3 below.",
|
||
smpDrop: "Drop WAV files here",
|
||
smpDropHint: "or click to choose them (several at once)",
|
||
smpKeymap: "Which keys play which file",
|
||
smpNote: "Note",
|
||
matchLevels: "Match levels", matchHelp: "Brings every sound to the same heard level (the loud ones turned down). Then fine-tune each Gain by ear.",
|
||
levelsMatched: "Levels matched. Fine-tune each Gain by ear.", smpGainHelp: "This sound's level (applied when it is sent)",
|
||
smpLoop: "Loop", smpLoopHelp: "ONE SHOT: plays once to the end. LOOP: the whole file again and again while the key is held; let go, it ends its round. LOOP+TAIL: the start, then the loop again and again while held; let go, the rest (the tail) to the end.",
|
||
smpLoopStart: "Loop start", smpLoopEnd: "Loop end", smpLoopTail: "Loops while the key is held, the tail when you let go. The points snap to a zero crossing (no click).",
|
||
smpHoldPlay: "Hold to hear the loop, let go for the tail",
|
||
smpNoteHelp: "The key that plays this file at its own pitch (C4 = 60)",
|
||
smpEraseSlot: "Erase USR{n}",
|
||
smpReplaces: "USR{n} holds “{x}”: sending replaces it.",
|
||
smpSlotFree: "USR{n} is empty.",
|
||
smpKitHint: "(If it is half of your USR3+4 drum kit, sending here replaces that half.)",
|
||
smpSendTo: "Send to USR{n}",
|
||
smpPlayOn: "Play this slot on:",
|
||
smpWhere: "On the FM-1: a synth track, engine SAMPLE, SET = USR{n} (KNOB 1 on the EDIT page). The buttons above set it for you.",
|
||
smpNoEngine: "This firmware cannot be set from here: choose SAMPLE and SET = USR on the track.",
|
||
smpPlaying: "Track",
|
||
smpFull: "A slot takes 16 files at most",
|
||
chopSendBelow: "Sending: step 3 below.",
|
||
/* SLOOP 2.5: DRUM SYNTH */
|
||
tabDrumSynth: "Drum synth", dsTitle: "Drum synth",
|
||
dsHelp: "Your own synthesised drum kits, SYN1 to SYN4 (the last kits of the drum track's KIT). Pick a sound, change its values: the FM-1 plays it at once. Store on the FM-1 keeps them in flash (stop the song first). Double-click a value: back to the kit it started from.",
|
||
dsOld: "This FM-1's firmware has no drum synth (SLOOP 2.5 or later).",
|
||
dsFrom: "Start from:", dsCopy: "Copy", dsBits: "CRUSH", dsHoldS: "S&H", dsOff: "OFF",
|
||
dsStore: "Store on the FM-1", dsUse: "Use on the drum track", dsSave: "Save file", dsOpen: "Open file",
|
||
dsPlay: "Play", dsAuto: "Play on change",
|
||
dsTone: "Tone", dsNoise: "Noise", dsFilter: "Filter", dsOut: "Out",
|
||
dsNotStored: "not stored yet", dsStored: "stored",
|
||
dsBad: "The FM-1 refused it", dsCopyAsk: "Make {k} a copy of {x}?", dsCopied: "Copied:",
|
||
dsStop: "Stop the song first, then store", dsFlash: "Could not write the flash", dsSaved: "Stored on the FM-1",
|
||
tabTheme: "Theme", thTitle: "Theme",
|
||
thHelp: "Make the FM-1's screen your own: pick the screen's five colours (faintest first), the background, the accent and the four tracks' colours, check them in the preview, then Send to the FM-1 (again after every change). On the FM-1 it comes after MONO in MENU → COLOR, under the name you gave it. For a white background: Light ↔ dark.",
|
||
thStart: "Start from", thScreen: "Screen (faint → strong)", thTracks: "Track colours",
|
||
thAcc: "Accent", thAccHelp: "what you touch, the cursor, the play head", thInvert: "Light ↔ dark", thFix: "Make it readable",
|
||
thDarkAcc: "The accent is too close to the background: the FM-1 would refuse it (the menu's cursor must stay visible).",
|
||
thDarkBoth: "The Values colour (5) and the accent are too close to the background: the FM-1 would refuse it (its menu must stay readable).",
|
||
thSendDark: "The FM-1 would refuse this one: press Make it readable, or change the colours",
|
||
thStSent: "Same as on the FM-1", thStNew: "Changed: Send to see it on the FM-1",
|
||
thC1: "Lines", thC2: "Dim", thC3: "Labels", thC4: "Secondary", thC5: "Values", thT4: "Drums",
|
||
thRampFrom: "Five steps from one colour", thRamp: "Make", thBg: "Background", thBlack: "Back to black",
|
||
thDark: "The Values colour (5) is too close to the background: the FM-1 would refuse it (its menu must stay readable).",
|
||
thSend: "Send to the FM-1", thRead: "Read from the FM-1", thRemove: "Remove from the FM-1",
|
||
thNoDev: "Connect the FM-1 to send it. Without it you can still make and share themes.",
|
||
thOld: "This FM-1's firmware has no themes (SLOOP 2.7 or later).",
|
||
thShare: "Share", thShareHelp: "This one line is the whole theme: copy it into a comment or a message, and anyone can paste it below to use it.",
|
||
thCopy: "Copy", thApply: "Use", thPasteHint: "Paste a SLOOP-THEME-1:… line",
|
||
thSent: "Sent to the FM-1 (MENU → COLOR)", thGot: "Read the FM-1's theme", thNone: "No theme on the FM-1",
|
||
thRemoved: "Theme removed from the FM-1", thStop: "Stop the song first, then send", thRefused: "The FM-1 refused it",
|
||
thCopied: "Copied", thBadCode: "That is not a theme line", thMine: "The FM-1's theme",
|
||
dsFileBad: "Not a SLOOP drum synth kit", dsOpenAsk: "Load {x} into {k}?", dsOpened: "Loaded:",
|
||
/* SLOOP 2.5: length, piano roll, MIDI files, song */
|
||
lenLabel: "Length (steps)", viewGrid: "Grid", viewRoll: "Piano roll",
|
||
midiExport: "Export MIDI", midiImportBtn: "Import MIDI",
|
||
rollLen: "Note length", rollUp: "Octave up", rollDown: "Octave down",
|
||
rollHelp: "Click an empty spot: a note of the chosen length (notes at the same step make a chord, 4 at most). Click a note: it goes. Drag a note's right end: its length (ties).",
|
||
len_whole: "1/1", len_half: "1/2", len_quarter: "1/4", len_eighth: "1/8", len_sixteenth: "1/16",
|
||
midiEmpty: "This track has no notes to export", midiSaved: "MIDI file saved. Notes: ",
|
||
midiPreview: "MIDI import", midiNoNotes: "This file has no notes.", midiCancel: "Cancel", midiTrack: "track",
|
||
midiSource: "Track to import:", midiNotes: "Notes: {n}", midiGrid: "Grid: this track's DIV ({div})",
|
||
midiSteps: "Steps: {n} (of {max})",
|
||
midiMoved: "Notes moved to the nearest step: {n}", midiChord: "Notes left out (4 a step at most, the loudest kept): {n}",
|
||
midiOverlap: "Notes cut short where the next one starts: {n}", midiMerged: "The same note twice on a step, played once: {n}",
|
||
midiDropped: "Notes past step {max}, left out: {n}",
|
||
midiClean: "Everything fits as it is.", midiHow: "Note lengths become ties; each step keeps the loudest velocity of its notes.",
|
||
midiHowDrum: "GM drum notes (36 kick, 38 snare, 42 hat…) go to the drum lanes, velocity to the levels ghost to hard.",
|
||
midiSetLen: "Set the track's length to {n} steps", midiImport: "Import",
|
||
midiConfirm: "This replaces the track's pattern. Go on?", midiDone: "Imported. Notes: ", midiBad: "Not a readable MIDI file: ",
|
||
tabSong: "Song", songTitle: "Song",
|
||
songHelp: "The FM-1's SONG screen: the sections A–D (SAVE → SECTION on the FM-1) in order, each for so many bars. 16 entries at most. PLAY it in song mode (SAVE + key 13).",
|
||
songSection: "Section", songBars: "Bars", songTimes: "Times",
|
||
songEmpty: "A section has an empty slot: save it on the FM-1 first (SAVE + keys 5–8).",
|
||
songAdd: "Add", songSum: "{n} of {max} entries, {bars} bars", songLoop: "At the end:",
|
||
songLoopOff: "stop", songLoopOn: "start again", songRead: "Read from the FM-1", songSend: "Send to the FM-1",
|
||
songUp: "Up", songDown: "Down", songDel: "Remove",
|
||
songOld: "This FM-1's firmware cannot share its song (SLOOP 2.5 or later).",
|
||
songBad: "This song cannot be sent (16 entries, 1–64 bars each)", songRefused: "Stop the song first, then send",
|
||
songSent: "Song sent to the FM-1",
|
||
},
|
||
};
|
||
let lang = (navigator.language || "en").toLowerCase().startsWith("ja") ? "ja" : "en";
|
||
const t = (k) => TEXT[lang][k] ?? k;
|
||
let lastKey = null, lastArg = "";
|
||
const ERR_KEYS = /fail|error|denied|nomidi|nodevice|noreply|lost|refused|full|bad/i;
|
||
function sayK(k, arg = "") {
|
||
lastKey = k; lastArg = arg;
|
||
$("status").textContent = t(k) + arg;
|
||
$("status").classList.toggle("err", ERR_KEYS.test(k));
|
||
}
|
||
function applyLang() {
|
||
document.documentElement.lang = lang;
|
||
document.querySelectorAll("[data-t]").forEach((e) => setLabel(e, t(e.dataset.t)));
|
||
$("lang").textContent = t("other");
|
||
setLabel($("connect"), t(dev ? "disconnect" : "connect"));
|
||
if (lastKey) $("status").textContent = t(lastKey) + lastArg;
|
||
$("libq").placeholder = t("libSearch");
|
||
renderLive();
|
||
renderLib();
|
||
renderBank();
|
||
renderPanels();
|
||
if (dev) { renderSlots(); renderStepHead(); renderSamples(); renderTrackbar(); renderMixer(); renderSysinfo(); }
|
||
renderKits();
|
||
renderPreviewKeys();
|
||
renderPreview();
|
||
}
|
||
$("lang").addEventListener("click", () => { lang = lang === "ja" ? "en" : "ja"; applyLang(); });
|
||
|
||
/* ---------------------------------------------------------------- tabs --- */
|
||
/* one panel at a time; the last one is remembered (localStorage) and in the URL hash (#sound ...) */
|
||
const TABS = ["live", "sound", "sequencer", "tracks", "song", "library", "samples", "kits", "drumsynth", "projects", "settings", "theme"];
|
||
const TAB_KEY = "felucca-editor-tab";
|
||
const TRACK_TABS = new Set(["sound", "sequencer", "tracks"]);
|
||
let tab = (() => {
|
||
const h = location.hash.slice(1);
|
||
if (TABS.includes(h)) return h;
|
||
try { const v = localStorage.getItem(TAB_KEY); if (TABS.includes(v)) return v; } catch (e) { /* no storage */ }
|
||
return "sound";
|
||
})();
|
||
const hasTracks = () => !!dev && !!dev.info && !!dev.info.ntrk;
|
||
function showTab(name) {
|
||
if (!TABS.includes(name)) name = "sound";
|
||
const prev = tab;
|
||
tab = name;
|
||
try { localStorage.setItem(TAB_KEY, name); } catch (e) { /* no storage */ }
|
||
if (location.hash !== "#" + name) history.replaceState(null, "", location.pathname + location.search + "#" + name);
|
||
renderPanels();
|
||
if (name === "tracks" && prev !== "tracks" && hasTracks() && dev.dump) op(readMixer);
|
||
}
|
||
function renderPanels() {
|
||
/* the Tracks tab only with a four-track firmware */
|
||
const tracksOk = !dev || hasTracks() || !dev.info;
|
||
const want = tab === "tracks" && dev && dev.info && !hasTracks() ? "sound" : tab;
|
||
for (const b of $("tabs").querySelectorAll("button[data-tab]")) {
|
||
const on = b.dataset.tab === want;
|
||
b.setAttribute("aria-selected", on ? "true" : "false");
|
||
b.tabIndex = on ? 0 : -1;
|
||
if (b.dataset.tab === "tracks") b.hidden = !tracksOk;
|
||
}
|
||
const ready = !!dev && !!dev.dump;
|
||
let hint = "";
|
||
for (const p of document.querySelectorAll(".panel")) {
|
||
const mine = p.dataset.tab === want;
|
||
let show = mine && (!("dev" in p.dataset) || ready);
|
||
if (mine && "dev" in p.dataset && !dev) hint = "needDevice"; /* (while connecting the status line says it) */
|
||
if (show && (want === "samples" || want === "kits") && !dev.smp) { show = false; hint = "smpNone"; }
|
||
p.hidden = !show;
|
||
}
|
||
$("hint").hidden = !hint;
|
||
if (hint) $("hint").textContent = t(MOCK && hint === "needDevice" ? "previewLocalConnect" : hint);
|
||
$("trackbar").hidden = !(ready && hasTracks() && TRACK_TABS.has(want));
|
||
const nb = $("tabs").querySelector(`button[data-tab="${want}"]`); /* the page's title: its name in the side bar */
|
||
$("pagetitle").textContent = nb ? t(nb.dataset.t) : "";
|
||
if (want === "kits") renderKits();
|
||
if (want === "drumsynth" && ready) { /* (2.5) the SYN kits, read once per connection */
|
||
if (DS.dev !== dev) { Object.assign(DS, { dev, kit: null, list: null, k: 0, lane: 0 }); if (dsOk()) op(() => dsLoad(0)); renderDs(); } else renderDs();
|
||
}
|
||
if (want === "theme") renderTheme(); /* (2.7) works without a device too */
|
||
if (want === "live" && ready) lvShow(); else lvHide(); /* (2.7) the LIVE page reads the FM-1 while it shows */
|
||
$("preview").hidden = !MOCK || want === "live";
|
||
if (want === "song" && ready) { /* (2.5) read the song order once per connection */
|
||
if (SG.dev !== dev) { Object.assign(SG, { dev, rows: null, err: "", dirty: false }); op(readSong); } else renderSong();
|
||
}
|
||
renderPreview();
|
||
}
|
||
$("tabs").addEventListener("click", (e) => { const b = e.target.closest("button[data-tab]"); if (b) showTab(b.dataset.tab); });
|
||
$("tabs").addEventListener("keydown", (e) => { /* arrow keys move between the tabs */
|
||
const dir = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: 1, ArrowUp: -1 }[e.key];
|
||
if (!dir) return;
|
||
const bs = [...$("tabs").querySelectorAll("button[data-tab]:not([hidden])")];
|
||
const i = bs.findIndex((b) => b.getAttribute("aria-selected") === "true");
|
||
const n = bs[(i + dir + bs.length) % bs.length];
|
||
e.preventDefault();
|
||
showTab(n.dataset.tab);
|
||
n.focus();
|
||
});
|
||
window.addEventListener("hashchange", () => { const h = location.hash.slice(1); if (TABS.includes(h) && h !== tab) showTab(h); });
|
||
|
||
const QS = new URLSearchParams(location.search);
|
||
const MOCK = QS.get("mock") === "1";
|
||
$("mock").hidden = !MOCK;
|
||
let mock = null;
|
||
|
||
/* ------------------------------------------------------- local browser audio --- */
|
||
let localAudio = null, previewStarting = null, previewPlaying = false, previewOctave = 60, previewKeysHidden = false, previewExpanded = false;
|
||
const previewHeld = new Map();
|
||
let previewPositions = [-1, -1, -1, -1];
|
||
const PREVIEW_KEYS = ["a", "w", "s", "e", "d", "f", "t", "g", "y", "h", "u", "j", "k", "o", "l", "p"];
|
||
$("preview").hidden = !MOCK;
|
||
$("preview-volume").setAttribute("aria-label", "Local audio volume");
|
||
function previewButton(id, key, shape) {
|
||
const b = $(id), label = t(key), stamp = `${lang}:${label}:${shape}`;
|
||
if (b.dataset.label === stamp) return;
|
||
b.dataset.label = stamp;
|
||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||
svg.setAttribute("viewBox", "0 0 16 16");
|
||
svg.setAttribute("aria-hidden", "true");
|
||
const path = document.createElementNS(svg.namespaceURI, "path");
|
||
path.setAttribute("d", {
|
||
play: "M4 2v12l10-6z", pause: "M3 2h4v12H3zM9 2h4v12H9z", stop: "M3 3h10v10H3z",
|
||
audio: "M1 6h3l4-4v12l-4-4H1zM10 5l1-1c3 2 3 6 0 8l-1-1c2-2 2-4 0-6z",
|
||
muted: "M1 6h3l4-4v12l-4-4H1zM10 5l1-1 2 3 2-3 1 1-2 3 2 3-1 1-2-3-2 3-1-1 2-3z"
|
||
}[shape]);
|
||
svg.append(path);
|
||
b.replaceChildren(svg, el("span", { text: label }));
|
||
}
|
||
function renderPreview() {
|
||
$("preview").dataset.expanded = String(previewExpanded);
|
||
for (const id of ["preview-instrument-panel", "preview-footer", "preview-volume-panel"]) $(id).hidden = !previewExpanded;
|
||
$("preview-enable").hidden = !previewExpanded;
|
||
$("preview-summary").hidden = previewExpanded;
|
||
$("preview-disclosure").textContent = (previewExpanded ? "▾ " : "▸ ") + t(previewExpanded ? "previewHide" : "previewShow");
|
||
$("preview-disclosure").setAttribute("aria-expanded", String(previewExpanded));
|
||
$("preview-disclosure").title = t("previewDisclosureHint");
|
||
const active = !!localAudio?.node;
|
||
const ready = !!dev?.dump, drum = mock?.state.sel === 3;
|
||
previewButton("preview-enable", active ? "previewAudioOn" : "previewAudioOff", active ? "audio" : "muted");
|
||
previewButton("preview-play", previewPlaying ? "previewPause" : "previewPlay", previewPlaying ? "stop" : "play");
|
||
previewButton("preview-stop", "previewStop", "stop");
|
||
$("preview-enable").title = t(active ? "previewDisable" : "previewEnable");
|
||
$("preview-enable").setAttribute("aria-label", $("preview-enable").title);
|
||
$("preview-enable").setAttribute("aria-pressed", String(active));
|
||
$("preview-enable").disabled = !ready || !!previewStarting;
|
||
$("preview-play").disabled = !ready || !!previewStarting;
|
||
$("preview-stop").disabled = !active;
|
||
$("preview-keys").hidden = !previewExpanded || previewKeysHidden;
|
||
$("preview-fold").textContent = t(previewKeysHidden ? (drum ? "previewShowPads" : "previewShowKeys") : (drum ? "previewHidePads" : "previewHideKeys"));
|
||
$("preview-fold").setAttribute("aria-expanded", String(!previewKeysHidden));
|
||
$("preview-octaves").hidden = drum || previewKeysHidden;
|
||
$("preview-sound").textContent = ready ? (drum ? "" : (dev.names[dev.dump.engine] || [])[dev.dump.preset] || "") : "";
|
||
$("preview-keys").querySelectorAll("button").forEach((b) => { b.disabled = !dev?.dump || !!previewStarting; });
|
||
$("preview-play").setAttribute("aria-pressed", String(previewPlaying));
|
||
$("preview-volume-value").textContent = $("preview-volume").value + "%";
|
||
if (!previewStarting && $("preview-status").dataset.error !== "true") $("preview-status").textContent = t(!ready ? "previewConnect" : tab === "song" ? "previewSongHint" : previewPlaying ? "previewPlaying" : active ? "previewReady" : "previewHint");
|
||
renderPreviewSummary();
|
||
renderPreviewSequence();
|
||
}
|
||
function renderPreviewSummary() {
|
||
const box = $("preview-summary");
|
||
if ($("preview-status").dataset.error === "true" || previewStarting) {
|
||
box.textContent = previewStarting ? t("previewLoading") : $("preview-status").textContent;
|
||
box.title = box.textContent;
|
||
return;
|
||
}
|
||
if (!mock || !dev?.dump) { box.textContent = t("previewConnect"); return; }
|
||
const k = mock.state.sel, track = mock.state.tracks[k];
|
||
const name = k === 3 ? t("drum") : (dev.names[track.engine] || [])[track.preset] || t("track");
|
||
const position = previewPlaying ? previewPositions[k] : -1;
|
||
const muted = !!track.p[40] || !!(mock.state.solo && !(mock.state.solo & (1 << k)));
|
||
let state = t(previewPlaying ? "previewRunning" : "previewStopped");
|
||
if (position >= 0) {
|
||
const step = (k === 3 ? track.dstep : track.step)[position];
|
||
const notes = k === 3 ? DRUM_LANES.filter((_, lane) => step?.on & (1 << lane)).map(([, name]) => name) :
|
||
step?.time === 0 ? step.notes.slice(0, step.n).map(noteName) : [];
|
||
const sound = muted ? t("previewMuted") : notes.length ? notes.join(" + ") : step?.time === 1 ? t("previewTie") : t("previewRest");
|
||
state = `${t("previewStep")} ${position + 1}/${track.p[29]} · ${sound}`;
|
||
}
|
||
box.textContent = `${t("track")} ${k + 1} · ${name} · ${state}`;
|
||
box.title = box.textContent + (tab === "song" ? " · " + t("previewSongHint") : "");
|
||
}
|
||
$("preview-disclosure").addEventListener("click", () => {
|
||
previewExpanded = !previewExpanded;
|
||
if (!previewExpanded) releasePreviewKeys();
|
||
renderPreview();
|
||
});
|
||
/* Inline edits use the same editor commands as the full sequencer. Serialize clicks so
|
||
two fast toggles (or two drum lanes on one step) cannot overwrite one another. */
|
||
let previewEditQueue = Promise.resolve();
|
||
const previewNotes = [60, 60, 60], previewPages = [0, 0, 0, 0];
|
||
let previewAllDrums = false, previewDrumExpanded = false;
|
||
function expandPreviewDrums(expanded) {
|
||
previewDrumExpanded = expanded;
|
||
renderPreviewSequence();
|
||
}
|
||
function previewSequenceClick(k, index, lane = -1, replacement = null) {
|
||
const d = dev, m = mock, note = previewNotes[k];
|
||
if (!d?.dump || !m) return;
|
||
busy++;
|
||
previewEditQueue = previewEditQueue.then(async () => {
|
||
if (d !== dev || m !== mock || index >= m.state.tracks[k].p[29]) return;
|
||
const track = m.state.tracks[k];
|
||
const command = k === 3 ? req.drumStep(index, previewToggleDrum(track.dstep[index], lane)) :
|
||
req.trackStep(k, index, replacement || previewToggleStep(track.step[index], note));
|
||
const response = await d.link.request(command);
|
||
if (d !== dev) return false;
|
||
if (d.sel === k) {
|
||
if (k === 3) {
|
||
const r = parse[CMD.DRUM_STEP](response);
|
||
d.dsteps[index] = r; d.steps[index] = drumAsStep(r);
|
||
} else d.steps[index] = parse[CMD.TRACK_STEP](response);
|
||
stepEdit.set(index, performance.now());
|
||
renderSteps();
|
||
}
|
||
return true;
|
||
}).catch(report).finally(() => { busy--; renderPreviewSequence(); });
|
||
return previewEditQueue;
|
||
}
|
||
const previewStepGestures = new WeakMap();
|
||
let previewNoteTarget = null, previewNoteAudition = null;
|
||
function stopPreviewNoteAudition() {
|
||
const held = previewNoteAudition;
|
||
previewNoteAudition = null;
|
||
if (!held) return;
|
||
clearTimeout(held.timer);
|
||
if (held.active) localAudio?.note(held.track, held.pitch, false);
|
||
}
|
||
async function auditionPreviewNote(pitch) {
|
||
stopPreviewNoteAudition();
|
||
const target = previewNoteTarget;
|
||
if (!target || !$("preview-note-listen").checked) return;
|
||
const held = previewNoteAudition = { track: target.track, pitch, active: false };
|
||
if (await startPreview() && previewNoteTarget === target && previewNoteAudition === held) {
|
||
held.active = true;
|
||
localAudio.note(held.track, pitch, true);
|
||
held.timer = setTimeout(() => { if (previewNoteAudition === held) stopPreviewNoteAudition(); }, 350);
|
||
}
|
||
}
|
||
function renderPreviewNotePicker() {
|
||
const target = previewNoteTarget;
|
||
if (!target) return;
|
||
const fields = $("preview-note-fields");
|
||
if (fields.children.length !== target.notes.length) {
|
||
fields.replaceChildren(...target.notes.map((_, n) => el("button", { type: "button",
|
||
onclick: () => { target.member = n; target.octave = Math.floor(target.notes[n] / 12) * 12; renderPreviewNotePicker(); } })));
|
||
fields.className = "preview-note-chord";
|
||
}
|
||
fields.hidden = target.notes.length < 2;
|
||
[...fields.children].forEach((b, n) => {
|
||
b.textContent = `${n + 1} · ${noteName(target.notes[n])}`;
|
||
b.setAttribute("aria-label", `${t("notes")} ${n + 1}: ${noteName(target.notes[n])}`);
|
||
b.setAttribute("aria-pressed", String(target.member === n));
|
||
});
|
||
$("preview-note-value").textContent = noteName(target.notes[target.member]);
|
||
$("preview-note-down").disabled = target.octave === 0;
|
||
$("preview-note-up").disabled = target.octave === 120;
|
||
$("preview-note-down").setAttribute("aria-label", t("previewOctaveDown"));
|
||
$("preview-note-up").setAttribute("aria-label", t("previewOctaveUp"));
|
||
$("preview-note-octave").textContent = `${noteName(target.octave)}–${noteName(Math.min(127, target.octave + 11))}`;
|
||
const piano = $("preview-note-piano"), stamp = `${target.octave}:${lang}`;
|
||
piano.setAttribute("aria-label", t("previewChooseNote"));
|
||
if (piano.dataset.layout !== stamp) {
|
||
piano.dataset.layout = stamp;
|
||
const blackAt = { 1: 1, 3: 2, 6: 4, 8: 5, 10: 6 }, names = ["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B"];
|
||
piano.replaceChildren(...names.map((name, offset) => {
|
||
const pitch = target.octave + offset;
|
||
const b = el("button", { type: "button", class: blackAt[offset] ? "black-key" : "white-key", "data-pitch": pitch,
|
||
"aria-label": noteName(pitch), disabled: pitch > 127, text: blackAt[offset] ? name : noteName(pitch),
|
||
onclick: () => {
|
||
if (target !== previewNoteTarget) return;
|
||
target.notes[target.member] = pitch;
|
||
renderPreviewNotePicker();
|
||
auditionPreviewNote(pitch).catch(previewError);
|
||
} });
|
||
if (blackAt[offset]) b.style.setProperty("--key", blackAt[offset]);
|
||
return b;
|
||
}));
|
||
}
|
||
for (const b of piano.children) b.setAttribute("aria-pressed", String(+b.dataset.pitch === target.notes[target.member]));
|
||
}
|
||
for (const [id, delta] of [["preview-note-down", -12], ["preview-note-up", 12]]) $(id).addEventListener("click", () => {
|
||
if (!previewNoteTarget) return;
|
||
previewNoteTarget.octave = Math.max(0, Math.min(120, previewNoteTarget.octave + delta));
|
||
renderPreviewNotePicker();
|
||
});
|
||
$("preview-note-listen").addEventListener("change", () => { if (!$("preview-note-listen").checked) stopPreviewNoteAudition(); });
|
||
function previewCellClick(e, cell, k, lane) {
|
||
const index = +cell.dataset.step;
|
||
if (lane === -2) { expandPreviewDrums(true); return; }
|
||
if (k === 3 || e.detail === 0) { previewSequenceClick(k, index, lane); return; }
|
||
const pending = previewStepGestures.get(cell);
|
||
if (e.detail > 1) { clearTimeout(pending?.timer); return; }
|
||
clearTimeout(pending?.timer);
|
||
const original = { ...mock.state.tracks[k].step[index], notes: mock.state.tracks[k].step[index].notes.slice() };
|
||
const device = dev, model = mock;
|
||
const timer = setTimeout(() => { if (device === dev && model === mock) previewSequenceClick(k, index); }, 250);
|
||
previewStepGestures.set(cell, { timer, original, index, device, model });
|
||
}
|
||
async function previewOpenNote(cell, k) {
|
||
const gesture = previewStepGestures.get(cell);
|
||
clearTimeout(gesture?.timer);
|
||
previewStepGestures.delete(cell);
|
||
if (gesture && (gesture.device !== dev || gesture.model !== mock)) return;
|
||
const d = dev, m = mock, index = gesture?.index ?? +cell.dataset.step;
|
||
await previewEditQueue;
|
||
if (d !== dev || m !== mock || index >= m.state.tracks[k].p[29]) return;
|
||
const current = m.state.tracks[k].step[index], step = gesture?.original || { ...current, notes: current.notes.slice() };
|
||
// A slow double click can arrive after the single-click delay. Restore its starting state.
|
||
if (JSON.stringify(current) !== JSON.stringify(step) && !await previewSequenceClick(k, index, -1, step)) return;
|
||
const dialog = $("preview-note-dialog");
|
||
if (dialog.open) dialog.close();
|
||
const notes = step.n > 0 ? step.notes.slice(0, step.n) : [previewNotes[k]];
|
||
previewNoteTarget = { device: d, model: m, track: k, index, step, notes, member: 0, octave: Math.floor(notes[0] / 12) * 12 };
|
||
dialog.style.setProperty("--c", `var(--t${k + 1})`);
|
||
dialog.style.setProperty("--trk", `var(--t${k + 1})`);
|
||
$("preview-note-title").textContent = `${t("track")} ${k + 1} · ${t("previewStep")} ${index + 1}`;
|
||
$("preview-note-fields").replaceChildren();
|
||
delete $("preview-note-piano").dataset.layout;
|
||
renderPreviewNotePicker();
|
||
dialog.showModal();
|
||
}
|
||
$("preview-note-cancel").addEventListener("click", () => $("preview-note-dialog").close());
|
||
$("preview-note-dialog").addEventListener("close", () => { stopPreviewNoteAudition(); previewNoteTarget = null; });
|
||
$("preview-note-form").addEventListener("submit", async (e) => {
|
||
e.preventDefault();
|
||
const target = previewNoteTarget;
|
||
if (!target || target.device !== dev || target.model !== mock) { $("preview-note-dialog").close(); return; }
|
||
const notes = target.notes.slice();
|
||
stopPreviewNoteAudition();
|
||
$("preview-note-apply").disabled = true;
|
||
try {
|
||
if (await previewSequenceClick(target.track, target.index, -1, previewSetStepNotes(target.step, notes))) {
|
||
previewNotes[target.track] = notes[0];
|
||
$("preview-note-dialog").close();
|
||
renderPreviewSequence();
|
||
}
|
||
} finally { $("preview-note-apply").disabled = false; }
|
||
});
|
||
function previewPageTools(k) {
|
||
const move = (delta) => {
|
||
$("preview-follow").checked = false;
|
||
previewPages[k] = Math.max(0, Math.min(Math.floor((mock.state.tracks[k].p[29] - 1) / 16) * 16, previewPages[k] + delta));
|
||
renderPreviewSequence();
|
||
};
|
||
return el("div", { class: "preview-seq-tools" },
|
||
el("button", { type: "button", class: "seq-prev", text: "‹", onclick: () => move(-16) }),
|
||
el("span", { class: "preview-seq-pages" }),
|
||
el("button", { type: "button", class: "seq-next", text: "›", onclick: () => move(16) }));
|
||
}
|
||
function previewTrackButton(k) {
|
||
return el("button", { type: "button", class: "preview-seq-track", onclick: () => selectTrack(k), "aria-pressed": "false" },
|
||
el("span", { class: "seq-no", text: k + 1 }), el("span", { class: "seq-name" }), el("span", { class: "seq-position" }));
|
||
}
|
||
function previewSequenceCells(k, lane = -1) {
|
||
const cells = el("div", { class: "preview-seq-steps" });
|
||
for (let i = 0; i < 16; i++) {
|
||
const cell = el("button", { type: "button", class: "preview-seq-cell", "data-track": k, "data-lane": lane,
|
||
onclick: (e) => previewCellClick(e, cell, k, lane),
|
||
ondblclick: k < 3 ? () => previewOpenNote(cell, k).catch(report) : null },
|
||
el("span", { class: "preview-seq-note", "aria-hidden": "true" }), el("span", { class: "seq-hit", "aria-hidden": "true" }));
|
||
cells.append(cell);
|
||
}
|
||
return cells;
|
||
}
|
||
function renderPreviewSequence() {
|
||
const visible = previewExpanded && !!mock && !!dev?.dump;
|
||
$("preview-sequence").hidden = !visible;
|
||
if (!visible) return;
|
||
const box = $("preview-sequence-rows"), st = mock.state;
|
||
if (!box.children.length) {
|
||
const numbers = el("div", { class: "preview-seq-row preview-seq-numbers" }, el("span"),
|
||
el("div", { class: "preview-seq-steps" }, ...Array.from({ length: 16 }, (_, i) => el("span", { text: i + 1 }))));
|
||
box.append(numbers);
|
||
for (let k = 0; k < 3; k++) {
|
||
const picker = el("select", { class: "seq-pitch", onchange: () => { previewNotes[k] = +picker.value; renderPreviewSequence(); } },
|
||
...Array.from({ length: 128 }, (_, n) => el("option", { value: n, text: noteName(n) })));
|
||
const label = el("div", { class: "preview-seq-label" }, previewTrackButton(k), previewPageTools(k));
|
||
label.lastChild.prepend(picker);
|
||
box.append(el("div", { class: "preview-seq-row", "data-seq-track": k, style: `--c:var(--t${k + 1})` }, label, previewSequenceCells(k)));
|
||
}
|
||
const all = el("button", { type: "button", class: "seq-all-drums", onclick: () => { previewAllDrums = !previewAllDrums; renderPreviewSequence(); } });
|
||
const toggle = el("button", { type: "button", class: "seq-drum-toggle", "aria-controls": "preview-drum-details",
|
||
onclick: () => expandPreviewDrums(!previewDrumExpanded) });
|
||
const details = el("div", { id: "preview-drum-details" },
|
||
el("div", { class: "preview-seq-drumhead" }, el("p", { class: "preview-seq-legend seq-drum-help" }), all));
|
||
const summary = previewSequenceCells(3, -2);
|
||
for (const cell of summary.children) cell.classList.add("seq-drum-brief");
|
||
const drums = el("div", { class: "preview-seq-drums", "data-seq-track": 3, style: "--c:var(--t4)" },
|
||
el("div", { class: "preview-seq-row" }, el("div", { class: "preview-seq-label" }, previewTrackButton(3), previewPageTools(3), toggle), summary), details);
|
||
for (let lane = 0; lane < 16; lane++) details.append(el("div", { class: "preview-seq-row", "data-drum-lane": lane },
|
||
el("span", { class: "preview-seq-lane", text: DRUM_LANES[lane][1] }), previewSequenceCells(3, lane)));
|
||
box.append(drums);
|
||
}
|
||
st.tracks.forEach((track, k) => {
|
||
const group = box.querySelector(`[data-seq-track="${k}"]`), button = group.querySelector(".preview-seq-track");
|
||
const len = Math.max(1, Math.min(64, track.p[29] || 16));
|
||
const position = previewPlaying ? previewPositions[k] : -1;
|
||
// Keep the page still under the pointer or keyboard focus while editing.
|
||
if ($("preview-follow").checked && position >= 0 && !group.matches(":hover, :focus-within")) previewPages[k] = Math.floor(position / 16) * 16;
|
||
const page = previewPages[k] = Math.min(previewPages[k], Math.floor((len - 1) / 16) * 16);
|
||
const name = k === 3 ? t("drum") : (dev.names[track.engine] || [])[track.preset] || t("track");
|
||
const muted = !!track.p[40] || !!(st.solo && !(st.solo & (1 << k)));
|
||
button.querySelector(".seq-name").textContent = name;
|
||
button.querySelector(".seq-position").textContent = `${position < 0 ? "–" : position + 1}/${len}`;
|
||
button.setAttribute("aria-pressed", String(st.sel === k));
|
||
button.setAttribute("aria-label", `${t("track")} ${k + 1}: ${name}${muted ? " · " + t("previewMuted") : ""}`);
|
||
button.title = button.getAttribute("aria-label");
|
||
group.classList.toggle("is-muted", muted);
|
||
const tools = group.querySelector(".preview-seq-tools");
|
||
tools.querySelector(".preview-seq-pages").textContent = `${page + 1}–${Math.min(page + 16, len)}`;
|
||
tools.querySelector(".preview-seq-pages").hidden = len <= 16;
|
||
for (const [className, key, disabled] of [["seq-prev", "previewPrevSteps", page === 0], ["seq-next", "previewNextSteps", page + 16 >= len]]) {
|
||
const b = tools.querySelector("." + className);
|
||
b.hidden = len <= 16; b.disabled = disabled;
|
||
b.setAttribute("aria-label", `${t(key)} · ${t("track")} ${k + 1}`); b.title = b.getAttribute("aria-label");
|
||
}
|
||
if (k < 3) {
|
||
const picker = group.querySelector(".seq-pitch");
|
||
picker.value = String(previewNotes[k]);
|
||
picker.setAttribute("aria-label", `${t("previewNewNote")} · ${t("track")} ${k + 1}`); picker.title = picker.getAttribute("aria-label");
|
||
} else {
|
||
const toggle = group.querySelector(".seq-drum-toggle");
|
||
toggle.textContent = (previewDrumExpanded ? "▾ " : "▸ ") + t(previewDrumExpanded ? "previewHideDrumGrid" : "previewShowDrumGrid");
|
||
toggle.setAttribute("aria-expanded", String(previewDrumExpanded));
|
||
group.querySelector("#preview-drum-details").hidden = !previewDrumExpanded;
|
||
for (const cell of group.querySelectorAll(".seq-drum-brief")) cell.setAttribute("aria-expanded", String(previewDrumExpanded));
|
||
const all = group.querySelector(".seq-all-drums");
|
||
all.textContent = t(previewAllDrums ? "previewFewerDrums" : "previewAllDrums");
|
||
all.setAttribute("aria-expanded", String(previewAllDrums));
|
||
group.querySelector(".seq-drum-help").textContent = t("previewDrumHint");
|
||
const active = track.dstep.slice(0, len).reduce((mask, d) => mask | d.on, 0);
|
||
for (const row of group.querySelectorAll("[data-drum-lane]")) {
|
||
const lane = +row.dataset.drumLane;
|
||
row.hidden = !(previewAllDrums || [0, 2, 3, 4, 5].includes(lane) || (active & (1 << lane)));
|
||
}
|
||
}
|
||
const source = (k === 3 ? track.dstep : track.step).slice(page, page + 16);
|
||
const stamp = JSON.stringify([source, len, page, lang, previewNotes[k]]);
|
||
if (group.dataset.pattern !== stamp) {
|
||
group.dataset.pattern = stamp;
|
||
for (const cell of group.querySelectorAll(".preview-seq-cell")) {
|
||
const i = Array.prototype.indexOf.call(cell.parentNode.children, cell), index = page + i, s = source[i], lane = +cell.dataset.lane;
|
||
const notes = k < 3 && s && s.time === 0 ? s.notes.slice(0, s.n).map(noteName) : [];
|
||
const tie = k < 3 && s?.time === 1;
|
||
const hits = k === 3 && lane === -2 && s ? DRUM_LANES.filter((_, l) => s.on & (1 << l)).map(([, name]) => name) : [];
|
||
const on = k === 3 ? lane === -2 ? hits.length > 0 : !!(s?.on & (1 << lane)) : notes.length > 0 || tie;
|
||
cell.dataset.step = index;
|
||
cell.disabled = index >= len;
|
||
cell.classList.toggle("on", on);
|
||
cell.classList.toggle("unused", index >= len);
|
||
cell.classList.toggle("bar-start", i % 4 === 0);
|
||
const stored = k < 3 && s?.n > 0 ? s.notes.slice(0, s.n).map(noteName) : [];
|
||
cell.firstChild.textContent = k === 3 ? lane === -2 ? hits.length > 1 ? String(hits.length) : on ? "●" : "" : on ? "●" : "" : tie ? "→" : stored.length ? stored[0] + (stored.length > 1 ? "+" + (stored.length - 1) : "") : "+";
|
||
if (lane !== -2) cell.setAttribute("aria-pressed", String(on));
|
||
else cell.setAttribute("aria-controls", "preview-drum-details");
|
||
const content = k === 3 ? lane === -2 ? hits.join(", ") || t("previewRest") : DRUM_LANES[lane][1] : tie ? t("previewTie") : on ? notes.join(", ") : s?.n > 0 ? s.notes.slice(0, s.n).map(noteName).join(", ") : noteName(previewNotes[k]);
|
||
const description = `${t(lane === -2 ? "previewShowDrumGrid" : k < 3 && s?.n > 0 ? on ? "previewDeactivate" : "previewReactivate" : on ? "previewRemove" : "previewAdd")} · ${content} · ${t("track")} ${k + 1} · ${t("previewStep")} ${index + 1}`;
|
||
cell.setAttribute("aria-label", description); cell.title = description + (k < 3 ? " · " + t("previewDoubleClick") : "");
|
||
}
|
||
}
|
||
for (const cell of group.querySelectorAll(".preview-seq-cell")) cell.classList.toggle("is-current", +cell.dataset.step === position);
|
||
});
|
||
}
|
||
$("preview-follow").addEventListener("change", renderPreviewSequence);
|
||
function renderPreviewKeys() {
|
||
if (!MOCK) return;
|
||
const drum = mock && mock.state.sel === 3;
|
||
$("preview").dataset.instrument = drum ? "drums" : "keys";
|
||
$("preview-instrument").textContent = `${t("track")} ${(mock?.state.sel || 0) + 1} · ${t(drum ? "previewDrums" : "previewKeys")}`;
|
||
$("preview-octaves").hidden = !!drum || previewKeysHidden;
|
||
const stamp = `${mock?.state.sel || 0}:${previewOctave}:${lang}`;
|
||
if ($("preview-keys").dataset.layout === stamp) return;
|
||
releasePreviewKeys();
|
||
$("preview-keys").dataset.layout = stamp;
|
||
$("preview-keys").className = "preview-keys " + (drum ? "pads" : "piano");
|
||
$("preview-keys").replaceChildren();
|
||
const names = ["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B", "C"];
|
||
const blackAt = { 1: 1, 3: 2, 6: 4, 8: 5, 10: 6 };
|
||
for (let i = 0; i < (drum ? 16 : 13); i++) {
|
||
const octave = Math.floor((previewOctave + i) / 12) - 1;
|
||
const note = drum ? DRUM_LANES[i][1] : names[i] + (i % 12 === 0 ? octave : "");
|
||
const shortcut = PREVIEW_KEYS[i].toUpperCase();
|
||
const b = el("button", { type: "button", class: drum ? "drum-pad" : blackAt[i] ? "black-key" : "white-key", "data-note": i, "aria-pressed": "false" },
|
||
el("span", { text: note }), el("kbd", { text: shortcut, "aria-hidden": "true" }));
|
||
if (!drum && blackAt[i]) b.style.setProperty("--key", blackAt[i]);
|
||
b.setAttribute("aria-label", (drum ? note : names[i] + octave) + ` (${shortcut})`);
|
||
b.setAttribute("aria-keyshortcuts", shortcut);
|
||
b.disabled = !mock;
|
||
b.title = `${note} · ${shortcut}`;
|
||
$("preview-keys").append(b);
|
||
}
|
||
$("preview-octave").textContent = drum ? "16 drums" : `C${previewOctave / 12 - 1}–C${previewOctave / 12}`;
|
||
$("preview-down").disabled = !!drum || previewOctave <= 24;
|
||
$("preview-up").disabled = !!drum || previewOctave >= 84;
|
||
}
|
||
function previewError(error) {
|
||
stopPreview().then(() => { $("preview-status").dataset.error = "true"; $("preview-status").textContent = error.message; renderPreviewSummary(); }).catch(console.error);
|
||
console.error(error);
|
||
}
|
||
function previewChanged(cmd, args) {
|
||
renderPreviewSummary();
|
||
renderPreviewSequence();
|
||
if (!localAudio?.node) return;
|
||
const samples = [CMD.SMP_END, CMD.SMP_ERASE, CMD.BK_PUT].includes(cmd);
|
||
localAudio.sync(samples);
|
||
if (cmd === CMD.DSYN_PLAY) localAudio.hit(args[0], args[1], args[2]);
|
||
}
|
||
async function startPreview() {
|
||
if (!dev?.dump || !mock) return false;
|
||
delete $("preview-status").dataset.error;
|
||
if (localAudio?.node && localAudio.context.state === "running") return true;
|
||
if (!previewStarting) {
|
||
previewStarting = (async () => {
|
||
if (!localAudio) {
|
||
const { LocalPreview } = await import("./preview.js");
|
||
localAudio = new LocalPreview((samples) => previewSnapshot(mock.state, samples), previewError,
|
||
(peak) => { $("preview-meter").value = peak * localAudio.volume; },
|
||
({ positions }) => { previewPositions = positions; renderPreviewSummary(); renderPreviewSequence(); });
|
||
}
|
||
await localAudio.start();
|
||
localAudio.setVolume(Number($("preview-volume").value) / 100);
|
||
if (!dev?.dump) { await localAudio.close(); return false; }
|
||
return true;
|
||
})().finally(() => { previewStarting = null; renderPreview(); });
|
||
$("preview-status").textContent = t("previewLoading");
|
||
renderPreview();
|
||
}
|
||
return previewStarting;
|
||
}
|
||
function releasePreviewKeys() {
|
||
stopPreviewNoteAudition();
|
||
for (const { track, note } of previewHeld.values()) localAudio?.note(track, note, false);
|
||
previewHeld.clear();
|
||
$("preview-keys").querySelectorAll("button").forEach((b) => b.setAttribute("aria-pressed", "false"));
|
||
}
|
||
async function stopPreview() {
|
||
releasePreviewKeys();
|
||
previewPlaying = false;
|
||
previewPositions = [-1, -1, -1, -1];
|
||
if (mock) mock.sim.play(false);
|
||
if (previewStarting) await previewStarting.catch(() => {});
|
||
await localAudio?.close();
|
||
$("preview-meter").value = 0;
|
||
renderPreview();
|
||
}
|
||
async function playPreview() {
|
||
if (!await startPreview()) return;
|
||
previewPlaying = !previewPlaying;
|
||
mock.sim.play(previewPlaying);
|
||
localAudio.play(previewPlaying);
|
||
renderPreview();
|
||
}
|
||
async function previewNoteOn(token, offset) {
|
||
if (!dev?.dump || previewHeld.has(token)) return;
|
||
const track = mock.state.sel;
|
||
const note = track === 3 ? DRUM_LANES[offset][0] : previewOctave + offset;
|
||
if (track < 3) { previewNotes[track] = note; renderPreviewSequence(); }
|
||
const held = { track, note };
|
||
previewHeld.set(token, held);
|
||
if (await startPreview() && previewHeld.get(token) === held) {
|
||
localAudio.note(track, note, true);
|
||
$("preview-keys").querySelector(`[data-note="${offset}"]`)?.setAttribute("aria-pressed", "true");
|
||
}
|
||
}
|
||
function previewNoteOff(token, offset) {
|
||
const held = previewHeld.get(token);
|
||
if (!held) return;
|
||
localAudio?.note(held.track, held.note, false);
|
||
previewHeld.delete(token);
|
||
$("preview-keys").querySelector(`[data-note="${offset}"]`)?.setAttribute("aria-pressed", "false");
|
||
}
|
||
$("preview-enable").addEventListener("click", () => {
|
||
(localAudio?.node ? stopPreview() : startPreview()).catch(previewError);
|
||
});
|
||
$("preview-play").addEventListener("click", () => playPreview().catch(previewError));
|
||
$("preview-stop").addEventListener("click", () => {
|
||
releasePreviewKeys(); localAudio?.panic(); previewPlaying = false; mock?.sim.play(false); renderPreview();
|
||
});
|
||
$("preview-volume").addEventListener("input", (e) => {
|
||
localAudio?.setVolume(Number(e.target.value) / 100);
|
||
$("preview-volume-value").textContent = e.target.value + "%";
|
||
});
|
||
$("preview-fold").addEventListener("click", () => {
|
||
releasePreviewKeys();
|
||
previewKeysHidden = !previewKeysHidden;
|
||
renderPreview();
|
||
});
|
||
$("preview-edit").addEventListener("click", () => showTab("sequencer"));
|
||
for (const [id, delta] of [["preview-down", -12], ["preview-up", 12]]) $(id).addEventListener("click", () => {
|
||
previewOctave = Math.max(24, Math.min(84, previewOctave + delta)); renderPreviewKeys();
|
||
});
|
||
$("preview-keys").addEventListener("pointerdown", (e) => {
|
||
const b = e.target.closest("button[data-note]");
|
||
if (!b || b.disabled) return;
|
||
e.preventDefault(); b.setPointerCapture(e.pointerId);
|
||
previewNoteOn(`pointer:${e.pointerId}`, Number(b.dataset.note)).catch(previewError);
|
||
});
|
||
for (const name of ["pointerup", "pointercancel", "lostpointercapture"]) $("preview-keys").addEventListener(name, (e) => {
|
||
const b = e.target.closest("button[data-note]");
|
||
if (b) previewNoteOff(`pointer:${e.pointerId}`, Number(b.dataset.note));
|
||
});
|
||
// Focused keys/pads also play with Enter or Space; these events must not toggle the sequencer.
|
||
$("preview-keys").addEventListener("keydown", (e) => {
|
||
const b = e.target.closest("button[data-note]");
|
||
if (!b || !["Enter", "Space"].includes(e.code)) return;
|
||
e.preventDefault(); e.stopPropagation();
|
||
if (!e.repeat && !b.disabled) previewNoteOn(`button:${b.dataset.note}`, Number(b.dataset.note)).catch(previewError);
|
||
});
|
||
$("preview-keys").addEventListener("keyup", (e) => {
|
||
const b = e.target.closest("button[data-note]");
|
||
if (!b || !["Enter", "Space"].includes(e.code)) return;
|
||
e.preventDefault(); e.stopPropagation();
|
||
previewNoteOff(`button:${b.dataset.note}`, Number(b.dataset.note));
|
||
});
|
||
$("preview-keys").addEventListener("focusout", (e) => {
|
||
const b = e.target.closest("button[data-note]");
|
||
if (b) previewNoteOff(`button:${b.dataset.note}`, Number(b.dataset.note));
|
||
});
|
||
function previewEditing(e) { return e.target.closest("input, select, textarea, [contenteditable='true'], .preview-sequence button, #preview-note-dialog, #preview-disclosure"); }
|
||
window.addEventListener("keydown", (e) => {
|
||
if (!MOCK || !dev?.dump || tab === "live" || e.repeat || e.ctrlKey || e.metaKey || e.altKey || previewEditing(e)) return;
|
||
if (e.code === "Space") { e.preventDefault(); playPreview().catch(previewError); return; }
|
||
const i = PREVIEW_KEYS.indexOf(e.key.toLowerCase());
|
||
if (i < 0) return;
|
||
e.preventDefault(); previewNoteOn(`key:${e.code}`, i).catch(previewError);
|
||
});
|
||
window.addEventListener("keyup", (e) => {
|
||
const i = PREVIEW_KEYS.indexOf(e.key.toLowerCase());
|
||
if (i >= 0) previewNoteOff(`key:${e.code}`, i);
|
||
});
|
||
window.addEventListener("blur", releasePreviewKeys);
|
||
document.addEventListener("visibilitychange", () => {
|
||
if (document.hidden && localAudio?.node) {
|
||
releasePreviewKeys(); localAudio.panic(); previewPlaying = false; mock?.sim.play(false); renderPreview();
|
||
}
|
||
});
|
||
window.addEventListener("pagehide", () => { localAudio?.panic(); });
|
||
renderPreviewKeys();
|
||
|
||
/* -------------------------------------------------------------- state --- */
|
||
let access = null; /* MIDIAccess */
|
||
let dev = null; /* {link, input, output, info, pdesc[], gdesc[], names[][], dump, steps[], slotUsed[],
|
||
keys[] (paramKeys), watch (pushes on), bank ({total, slots[]} or null: no user bank)} */
|
||
let busy = 0; /* multi-request operations in progress: no polling */
|
||
let dragging = null; /* key of the slider being dragged */
|
||
let wantConnected = false;
|
||
const ctl = new Map(); /* key "s:id" -> {input, out, desc, scope, id, row} */
|
||
const sets = new SetGate(); /* key -> {last: time of the user's last change, sent: the value last requested} */
|
||
let needReload = false; /* a RELOAD push came: re-read DESC, DUMP and steps when free */
|
||
let lastDump = 0; /* Date.now() of the last DUMP */
|
||
/* the device also pushes RELOAD after loads the editor asked for (SET of G_ENGSEL, PRESET, PROJECT load,
|
||
UP_LOAD); the editor re-reads after those anyway, so it skips that many RELOADs for a moment */
|
||
const selfReload = { n: 0, until: 0 };
|
||
function selfLoad() {
|
||
if (!dev || !dev.watch) return;
|
||
const now = Date.now();
|
||
selfReload.n = now < selfReload.until ? selfReload.n + 1 : 1;
|
||
selfReload.until = now + 1500;
|
||
}
|
||
const stepEdit = new Map(); /* index -> time of the last edit */
|
||
|
||
/* parameter ids (firmware/src/core.h); used only when P_COUNT / G_COUNT match */
|
||
/* pcount 71 / pe0 63: 2.6's INSERT, filter TYPE, ENV SYNC, LFO 2 (P_ITYPE 53 .. P_LPOL 62, after Felucca 1.4 / 1.5) */
|
||
const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49, 50], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT; 50: 2.7.2's FX FADE */
|
||
const P = { LEVEL: 0, SLEN: 29, CHORD: 49 };
|
||
const LAYOUT = (pe0) => {
|
||
const v251 = pe0 >= 63; /* (2.6: the pages the device has for the new parameters) */
|
||
const opt = (yes, ...pages) => (yes ? pages : []);
|
||
return [
|
||
{ t: "ENV", pages: [["ENV", 0, [1, 2, 3, 4]], ["ENV DEST", 0, [5, 6, 7, 8]], ...opt(v251, ["ENV SYNC", 0, [59]])] },
|
||
{ t: "LFO", pages: [["LFO", 0, [9, 10, 11, 12]], ...opt(v251, ["LFO 2", 0, [60, 61, 62]]), ["LFO DEST", 0, [13, 14, 15, 16]]] },
|
||
{ t: "EDIT", engine: true, pages: [["EDIT 1", 0, [pe0, pe0 + 1, pe0 + 2, pe0 + 3]], ["EDIT 2", 0, [pe0 + 4, pe0 + 5, pe0 + 6, pe0 + 7]],
|
||
...opt(v251, ["FILTER", 0, [58], 0])] }, /* (4th: the engine it is shown with: ANALOG's filter TYPE) */
|
||
{ t: "VOICE", pages: [["LEVEL", 0, [0]], ["VOICE", 0, [37, 38, 41, 42]], ["VOICE 2", 0, [43, 44, 39, 40]]] },
|
||
{ t: "FX", pages: [["FX", 0, [33, 34, 35, 36]], ["FILTER", 0, [50]], ["SLICER", 0, [45, 46, 47, 48]],
|
||
...opt(v251, ["INSERT", 0, [53, 54, 55, 56]], ["INSERT 2", 0, [57]]), ["DLY", 1, [4, 5, 6, 7]], ["REV/CHO", 1, [8, 9, 10, 11]]] },
|
||
{ t: "SEL", pages: [["SEL", 0, [25, 26, 27, 49]], ["SEL 2", 0, [28, 51, 52]]] },
|
||
{ t: "ARP", pages: [["ARP", 0, [17, 18, 19, 20]], ["ARP 2", 0, [21, 22, 23, 24]]] },
|
||
{ t: "SEQ PATTERN", tab: "seqgroups", pages: [["PATTERN", 0, [29, 30, 31, 32]]] },
|
||
{ t: "GLOBAL", tab: "setgroups", pages: [["GLOBAL", 1, [0, 1, 2, 3]]] },
|
||
{ t: "MASTER", tab: "setgroups", pages: [["MASTER", 1, [27, 28, 29, 30]]] },
|
||
{ t: "DRUMS", tab: "setgroups", pages: [["DRUMS", 1, [24, 25, 26, 32]]] },
|
||
...opt(v251, { t: "MIDI", tab: "setgroups", pages: [["MIDI", 1, [33, 34, 35, 24]], ["MIDI 2", 1, [14, 36, 12, 44]], ["MIDI 3", 1, [45, 46, 47, 48]]] }), /* CH1 CH2 CH3 CH4 (drums);
|
||
* IN OTHER OUT BEND (settings of the FM-1; IN and OUT: the FM-1 only, G_SKIP) */
|
||
...opt(v251, { t: "TEXTURE", tab: "setgroups", pages: [["TEXTURE", 1, [37, 38, 39, 40]], ["TEXTURE 2", 1, [41, 42, 43]]] }), /* the bed */
|
||
];
|
||
};
|
||
/* globals that are actions or placeholders on the device: buttons instead, or hidden */
|
||
const G_SKIP = new Set(["SLOT", "SECT", "NAME", "LOAD", "SAVE", "ENG", "SET", "CLRSQ", "INIT", "MIDI", "OUT", "SYNC", "ROUT", "IN", "CPU", "NEW"]);
|
||
const key = (s, id) => s + ":" + id;
|
||
const gEng = () => { const i = dev.gdesc.findIndex((d) => d && d.label === "ENG"); return i >= 0 ? i : 20; };
|
||
const pSlen = () => { const i = dev.pdesc.findIndex((d) => d && d.fmt === F.STEPS); return i >= 0 ? i : P.SLEN; };
|
||
/* mixer ids by DESC label (core.h: P_PAN 39, P_MUTE 40, G_DRLVL 25) */
|
||
const pById = (label, def) => { const i = dev.pdesc.findIndex((d, k) => d && k < dev.info.pe0 && d.label === label); return i >= 0 ? i : def; };
|
||
const pPan = () => pById("PAN", 39), pMute = () => pById("MUTE", 40);
|
||
const gDrLvl = () => { const i = dev.gdesc.findIndex((d, k) => d && k > gEng() && (d.label === "LVL" || d.label === "LEVEL")); return i >= 0 ? i : 25; };
|
||
const isDrum = () => !!dev && !!dev.dump && dev.dump.engine >= dev.info.nengines;
|
||
/* v5 (SLOOP 2.0): the drum track is edited as its 16 lanes (DRUM_STEP); older firmware: as GM notes */
|
||
const drumGrid = () => isDrum() && !!dev.info.proto && dev.info.proto >= 5;
|
||
|
||
/* -------------------------------------------------------------- MIDI --- */
|
||
async function connect() {
|
||
wantConnected = true;
|
||
if (!MOCK && !navigator.requestMIDIAccess) { sayK("nomidi"); return; }
|
||
$("connect").disabled = true;
|
||
sayK("connecting");
|
||
try {
|
||
if (!access) {
|
||
if (MOCK) { mock = makeMockDevice({ auto: false, legacy: QS.get("legacy") === "1", onChange: previewChanged }); access = mock.access; }
|
||
else {
|
||
try { access = await navigator.requestMIDIAccess({ sysex: true }); }
|
||
catch (e) { sayK("denied"); return; }
|
||
}
|
||
access.onstatechange = onState;
|
||
}
|
||
const pairs = fm1Ports(access);
|
||
if (!pairs.length) { sayK("nodevice"); return; }
|
||
let link = null, input = null, output = null;
|
||
for (const pr of pairs) { /* the first pair that answers (a generic name may be other gear) */
|
||
const l = new Link((d) => pr.output.send(d), {
|
||
timeout: 300,
|
||
onUnknown: (f) => console.debug("ignored reply", f),
|
||
onTimeout: () => sayK("noreply"),
|
||
onPush: (f) => onPush(f),
|
||
onGap: () => { rewatch = true; },
|
||
});
|
||
pr.input.onmidimessage = (e) => l.receive(e.data);
|
||
if (pr.input.open) await pr.input.open().catch(() => {});
|
||
try {
|
||
await l.request(req.info(), { timeout: 500, retries: 3, quiet: true }); /* (the first frame can be lost) */
|
||
link = l, input = pr.input, output = pr.output;
|
||
break;
|
||
} catch (e) {
|
||
l.close();
|
||
pr.input.onmidimessage = null;
|
||
}
|
||
}
|
||
if (!link) { sayK(pairs.length ? "noreply" : "nodevice"); return; }
|
||
dev = { link, input, output, info: null, pdesc: [], gdesc: [], names: [], dump: null, steps: [], slotUsed: [null, null, null, null],
|
||
keys: null, watch: false, bank: null };
|
||
sets.clear(); /* (another FM-1, maybe) */
|
||
setLabel($("connect"), t("disconnect"));
|
||
renderLive();
|
||
await load(dev);
|
||
} catch (e) {
|
||
console.error(e);
|
||
if (dev) { /* not unplugged meanwhile (that says "lost") */
|
||
const timeout = /^timeout/.test(e.message);
|
||
disconnect();
|
||
sayK(timeout ? "noreply" : "error", timeout ? "" : e.message);
|
||
}
|
||
} finally {
|
||
$("connect").disabled = false;
|
||
}
|
||
}
|
||
|
||
function disconnect(reasonKey = "disconnected") {
|
||
stopPreview();
|
||
if (dev) {
|
||
dev.link.close();
|
||
dev.input.onmidimessage = null;
|
||
}
|
||
dev = null;
|
||
busy = 0;
|
||
needReload = false;
|
||
renderPanels();
|
||
renderMixer();
|
||
renderSysinfo();
|
||
renderLive();
|
||
renderLib();
|
||
renderBank();
|
||
$("version").textContent = "";
|
||
setLabel($("connect"), t("connect"));
|
||
sayK(reasonKey);
|
||
}
|
||
|
||
function onState(e) {
|
||
const p = e.port;
|
||
if (!p || !FM1_PORT.test(p.name || "")) return;
|
||
if (dev && p.state === "disconnected" && (p.id === dev.input.id || p.id === dev.output.id)) {
|
||
disconnect("lost");
|
||
} else if (!dev && wantConnected && p.state === "connected" && p.type === "output") {
|
||
clearTimeout(onState.tm); /* the device came back: reconnect */
|
||
onState.tm = setTimeout(() => { if (!dev && wantConnected) connect(); }, 800);
|
||
}
|
||
}
|
||
|
||
const rq = (r, opt) => dev.link.request(r, opt);
|
||
async function getDesc(scope, id) { return parse[CMD.DESC](await rq(req.desc(scope, id))); }
|
||
async function getDump() { lastDump = Date.now(); return parse[CMD.DUMP](await rq(req.dump()), dev.info); }
|
||
async function getStep(i) { return parse[CMD.STEP_GET](await rq(req.stepGet(i))); }
|
||
async function getDrumStep(i) { return parse[CMD.DRUM_STEP](await rq(req.drumStep(i))); }
|
||
/* a drum step as an old step (firmware ed_dstep_old): for what still reads dev.steps */
|
||
function drumAsStep(d) {
|
||
const notes = [];
|
||
for (let l = 0; l < 16 && notes.length < 4; l++) if ((d.on >> l) & 1) notes.push(DRUM_LANES[l][0]);
|
||
return { index: d.index, n: notes.length, notes: [...notes, 0, 0, 0, 0].slice(0, 4), time: notes.length ? 0 : 2, flags: 0, vel: notes.length ? 100 : 0 };
|
||
}
|
||
|
||
/* the whole connect sequence */
|
||
async function load(d) {
|
||
busy++;
|
||
try {
|
||
/* the first frame after opening the port can be lost: a few tries */
|
||
d.info = parse[CMD.INFO](await d.link.request(req.info(), { timeout: 500, retries: 3 }));
|
||
$("version").textContent = d.info.version;
|
||
const total = d.info.pcount + d.info.gcount;
|
||
for (let i = 0; i < d.info.pcount; i++) { sayK("reading", `${i + 1}/${total}`); d.pdesc[i] = await getDescOrNull(0, i); }
|
||
for (let i = 0; i < d.info.gcount; i++) { sayK("reading", `${d.info.pcount + i + 1}/${total}`); d.gdesc[i] = await getDescOrNull(1, i); }
|
||
const kd = d.pdesc[d.info.pe0];
|
||
if (kd && kd.label === "KIT" && kd.names.length) d.kitNames = kd.names; /* (the drum track was selected) */
|
||
d.titles = [];
|
||
for (let e = 0; e < d.info.nengines; e++) {
|
||
const r = parse[CMD.NAMES](await d.link.request(req.names(e)));
|
||
d.names[e] = r.names;
|
||
d.titles[e] = r.titles;
|
||
}
|
||
for (let k = 0; k < 4; k++) { /* PROJECT op 2: is the slot used */
|
||
try { d.slotUsed[k] = parse[CMD.PROJECT](await d.link.request(req.project(2, k))).used; }
|
||
catch (e) { if (e.message === "closed") throw e; }
|
||
}
|
||
try { d.smp = parse[CMD.SMP_INFO](await d.link.request(req.smpInfo())); }
|
||
catch (e) { if (e.message === "closed") throw e; d.smp = null; } /* older firmware, or no flash */
|
||
d.keys = paramKeys(d.pdesc, d.info.pe0, d.info.pcount);
|
||
d.fm6 = null; /* v9: the FM6 patch slots (FM6_LIST), else null */
|
||
if (d.info.proto >= 9) {
|
||
try { d.fm6 = parse[CMD.FM6_LIST](await d.link.request(req.fm6List())); }
|
||
catch (e) { if (e.message === "closed") throw e; }
|
||
}
|
||
fm6Names(d);
|
||
await libAdopt(d);
|
||
if (d.info.ntrk) d.sel = parse[CMD.TRACK](await d.link.request(req.track())).sel; /* v3: the selected track */
|
||
d.dump = await getDump();
|
||
buildUI();
|
||
renderPanels();
|
||
await loadSteps();
|
||
if (d.info.ntrk) await readMixer();
|
||
/* protocol v2: live pushes and the user bank; older firmware: DUMP polling, no bank */
|
||
const rqd = (r, o) => d.link.request(r, o);
|
||
d.watch = await startWatch(rqd);
|
||
d.v4 = d.watch === 3; /* TRACK_PARAM / TRACK_CHANGED */
|
||
if (d.watch) {
|
||
sayK("readingBank");
|
||
try { d.bank = await bank.list((r, o) => d.link.request(r, { ...o, quiet: true })); }
|
||
catch (e) { if (e.message === "closed") throw e; d.bank = null; }
|
||
}
|
||
renderLive();
|
||
renderLib();
|
||
renderBank();
|
||
renderSysinfo();
|
||
sayK("ready");
|
||
} finally { busy--; }
|
||
}
|
||
async function getDescOrNull(s, i) { try { return await getDesc(s, i); } catch (e) { if (e.message === "closed") throw e; return null; } }
|
||
|
||
/* rebuilds the controls only when the engine or its parameters changed (a slider being dragged survives) */
|
||
async function rereadEngineDesc() {
|
||
const pe0 = dev.info.pe0;
|
||
const before = JSON.stringify(dev.pdesc.slice(pe0));
|
||
for (let i = 0; i < 8 && pe0 + i < dev.info.pcount; i++) dev.pdesc[pe0 + i] = await getDescOrNull(0, pe0 + i);
|
||
const kd = dev.pdesc[pe0];
|
||
if (kd && kd.label === "KIT" && kd.names.length) dev.kitNames = kd.names; /* the drum track's kits, for the mixer */
|
||
fm6Names();
|
||
if (dev.built !== dev.dump.engine || JSON.stringify(dev.pdesc.slice(pe0)) !== before) buildGroups();
|
||
}
|
||
|
||
async function loadSteps() {
|
||
const n = dev.info.nstep, drum = drumGrid();
|
||
if (!dev.dsteps) dev.dsteps = [];
|
||
for (let i = 0; i < n; i++) {
|
||
if (i % 8 === 0) sayK("steploading", `${i}/${n}`);
|
||
if (drum) { dev.dsteps[i] = await getDrumStep(i); dev.steps[i] = drumAsStep(dev.dsteps[i]); }
|
||
else dev.steps[i] = await getStep(i);
|
||
}
|
||
dev.dstepsOk = drum;
|
||
await loadLocks();
|
||
renderSteps();
|
||
}
|
||
/* v7: the selected track's nudges and locks (none on older firmware); v8: its fill conditions too */
|
||
const hasLocks = () => !!dev && !!dev.info && dev.info.proto >= 7;
|
||
const hasFill = () => !!dev && !!dev.info && dev.info.proto >= 8;
|
||
async function loadLocks() {
|
||
const d = dev;
|
||
if (!hasLocks()) { d.micro = null; d.locks = null; d.fill = null; return; }
|
||
const m = parse[CMD.MICRO_GET](await rq(req.microGet(d.sel), { key: "micro" }));
|
||
const l = parse[CMD.LOCK_GET](await rq(req.lockGet(d.sel), { key: "locks" }));
|
||
const f = hasFill() ? parse[CMD.FILL_GET](await rq(req.fillGet(d.sel), { key: "fill" })) : null;
|
||
if (d !== dev) return;
|
||
d.micro = m.micro;
|
||
d.locks = l.locks;
|
||
d.fill = f ? f.fill : null;
|
||
}
|
||
|
||
/* --------------------------------------------------------------- UI --- */
|
||
function buildUI() {
|
||
const sel = $("engine");
|
||
sel.replaceChildren(...dev.info.engines.map((n, i) => el("option", { value: i, text: n })));
|
||
dev.mix = null;
|
||
buildGroups();
|
||
updateBrowser();
|
||
renderSlots();
|
||
renderSamples();
|
||
renderSysinfo();
|
||
$("bkgroup").hidden = !(dev.info.proto >= 6); /* v6 firmware: backup / restore */
|
||
$("sfgroup").hidden = !(dev.info.proto >= 6); /* (2.7) a song as one file: the same commands */
|
||
}
|
||
|
||
/* the track selector (v3): T1..T3 synth parts, T4 the drum track; the editor shows the selected one */
|
||
/* the device's track colours (ui_studio.c TE_COL): the selected one is the editor's accent (--trk) */
|
||
const TCOL = ["var(--t1)", "var(--t2)", "var(--t3)", "var(--t4)"];
|
||
function renderTrackbar() {
|
||
renderPreviewKeys();
|
||
const box = $("trackbtns");
|
||
const ntrk = hasTracks() ? dev.info.ntrk : 0;
|
||
if (box.children.length !== ntrk || box.dataset.lang !== lang) {
|
||
box.dataset.lang = lang;
|
||
box.replaceChildren(...Array.from({ length: ntrk }, (_, i) => el("button", { type: "button", "data-i": i, style: `--c:${TCOL[i % 4]}`,
|
||
onclick: () => selectTrack(i) }, el("span", { class: "no", text: String(i + 1) }), el("span", { class: "nm" }))));
|
||
}
|
||
for (const b of box.children) {
|
||
const i = +b.dataset.i, x = dev.mix && dev.mix.tracks[i];
|
||
b.setAttribute("aria-pressed", i === (dev.sel || 0) ? "true" : "false");
|
||
const nm = !x ? [i === ntrk - 1 ? "DRUMS" : "", ""] : x.engine >= dev.info.nengines ? [(dev.kitNames || [])[x.e0] || "", "drums"]
|
||
: [(dev.names[x.engine] || [])[x.preset] || "", String(dev.info.engines[x.engine] || "").toLowerCase()];
|
||
b.lastChild.replaceChildren(nm[0] + " ", el("span", { class: "dim", text: nm[1] }));
|
||
b.title = `${t("track")} ${i + 1}`;
|
||
}
|
||
document.documentElement.style.setProperty("--trk", TCOL[(dev.sel || 0) % 4]);
|
||
renderPreview();
|
||
}
|
||
function selectTrack(i) {
|
||
if (!dev || !hasTracks() || i === dev.sel) return;
|
||
op(async () => {
|
||
dev.sel = parse[CMD.TRACK](await rq(req.track(i))).sel;
|
||
await afterSoundChange();
|
||
});
|
||
}
|
||
|
||
/* settings > system: what the device reported */
|
||
function renderSysinfo() {
|
||
const box = $("sysinfo");
|
||
if (!dev || !dev.info) { box.replaceChildren(); return; }
|
||
const i = dev.info;
|
||
const rows = [
|
||
["firmware", i.version], ["sync", t(dev.watch ? "live" : "polling")], ["enginesL", i.engines.join(", ")],
|
||
["tracksN", i.ntrk ? String(i.ntrk) : "1"], ["stepsN", String(i.nstep)],
|
||
["smpSlots", dev.smp ? `${dev.smp.nslots} × ${dev.smp.slotKiB} KiB` : t("none")],
|
||
["userBank", dev.bank ? String(dev.bank.total) : t("none")],
|
||
];
|
||
box.replaceChildren(...rows.map(([k, v]) => el("tr", {}, el("th", { text: t(k) }), el("td", { text: v }))));
|
||
}
|
||
|
||
function updateBrowser() {
|
||
const e = dev.dump.engine;
|
||
const sel = $("engine");
|
||
const drum = e >= dev.info.nengines; /* the drum track: no engine, no presets */
|
||
renderTrackbar();
|
||
sel.disabled = drum;
|
||
$("preset").disabled = drum;
|
||
$("init").disabled = drum;
|
||
$("factlib").disabled = drum;
|
||
$("drumnote").hidden = !drum;
|
||
$("browser").hidden = drum;
|
||
$("groups").hidden = drum;
|
||
$("ctlhelp").hidden = drum;
|
||
drumPanel(drum);
|
||
if (document.activeElement !== sel) sel.value = drum ? "" : String(e);
|
||
const ps = $("preset");
|
||
const names = dev.names[e] || [];
|
||
if (ps.dataset.engine !== String(e)) {
|
||
ps.replaceChildren(...names.map((n, i) => el("option", { value: i, text: n })));
|
||
ps.dataset.engine = String(e);
|
||
}
|
||
if (document.activeElement !== ps) ps.value = String(dev.dump.preset);
|
||
fm6Show();
|
||
}
|
||
|
||
/* ---- (2.7) the drum track on the Sound page: the kit (heard), its level, pan, filter, sends and INSERT, and each pad's
|
||
TUNE and DECAY (LIVE op 12: the DRUMS screen's SOUND page). The drum track is the selected one: its values go by SET */
|
||
const DP = { built: null, timer: 0, s: null, pad: 0, local: new Map() }; /* local: lane -> {tune, dec, t}: what the hand set */
|
||
const DP_HOLD = 1500; /* ms a pad's own value wins over what the FM-1 answers */
|
||
/* a state from the FM-1, with the pads just turned here kept as the hand set them (a reply to an older request, or
|
||
the poll, never pulls a knob back while it moves) */
|
||
function drumPanelMerge(s) {
|
||
const now = performance.now();
|
||
if (s && s.dtw) for (const [lane, v] of DP.local) {
|
||
if (now - v.t < DP_HOLD) s.dtw[lane] = { tune: v.tune, dec: v.dec };
|
||
else DP.local.delete(lane);
|
||
}
|
||
return s;
|
||
}
|
||
function drumPanel(drum) {
|
||
const box = $("drumpanel");
|
||
box.hidden = !drum;
|
||
$("drumnote").hidden = true;
|
||
if (!drum) { clearInterval(DP.timer); DP.timer = 0; return; }
|
||
if (DP.built !== dev) drumPanelBuild();
|
||
drumPanelRender();
|
||
if (!DP.timer) DP.timer = setInterval(() => { if (tab === "sound" && dev && dev.dump && isDrum() && !busy) drumPanelRead(); else { clearInterval(DP.timer); DP.timer = 0; } }, 1500);
|
||
drumPanelRead();
|
||
}
|
||
async function drumPanelRead() {
|
||
if (!dev || !dev.info || dev.info.proto < 12) return;
|
||
if (DP.s && (!dev.link.idle || [...DP.local.values()].some((v) => performance.now() - v.t < DP_HOLD))) return; /* (not while turning) */
|
||
try { DP.s = drumPanelMerge(parse[CMD.LIVE](await rq(req.live(LIVE.STATE), { key: "live:state", retries: 0, quiet: true }))); } catch (e) { return; }
|
||
drumPanelRender();
|
||
}
|
||
function drumPanelBuild() {
|
||
const box = $("drumpanel"), pe0 = dev.info.pe0, U = DP.ui = {};
|
||
DP.built = dev;
|
||
const knob = (lbl, s, id, d) => {
|
||
d = d || (s ? dev.gdesc[id] : dev.pdesc[id]) || { min: 0, max: 127, def: 0 };
|
||
return lvKnob(lbl, { min: d.min, max: d.max, def: d.def, bip: d.min < 0, get: () => (s ? dev.dump.g[id] : dev.dump.p[id]) ?? 0,
|
||
set: (v, f) => userSet(s, id, v, f), fmt: (v) => { const [x, u] = fmtValue(d, v); return u && u !== "%" ? `${x} ${u}`.toLowerCase() : x + (u || ""); } });
|
||
};
|
||
U.kit = el("select", { "aria-label": t("lvKit") });
|
||
U.kit.addEventListener("change", () => userSet(0, pe0, +U.kit.value, true));
|
||
const step = (d) => { const n = U.kit.options.length || 1; userSet(0, pe0, ((dev.dump.p[pe0] ?? 0) + d + n) % n, true); drumPanelRender(); };
|
||
U.prev = el("button", { type: "button", text: "‹", "aria-label": "previous", onclick: () => step(-1) });
|
||
U.next = el("button", { type: "button", text: "›", "aria-label": "next", onclick: () => step(1) });
|
||
U.mix = [knob(t("lvLevel"), 1, gDrLvl()), knob(t("lvPan"), 0, 39), knob(t("lvFilter"), 0, 50), knob(t("lvRev"), 1, 26), knob(t("lvDly"), 1, 32)];
|
||
const itd = dev.pdesc[53];
|
||
U.ins = el("select", { "aria-label": "INSERT" }, ...((itd && itd.names) || ["OFF"]).map((n, k) => el("option", { value: String(k), text: n })));
|
||
U.ins.addEventListener("change", () => userSet(0, 53, +U.ins.value, true));
|
||
U.insK = [54, 55, 56, 57].map((id) => knob((dev.pdesc[id] || { label: "" }).label.toLowerCase(), 0, id));
|
||
/* the 16 pads: a tap plays it; TUNE and DECAY as on the FM-1 */
|
||
U.pads = DRUM_LANES.map(([, name], lane) => {
|
||
const hit = el("button", { type: "button", class: "dppad", text: name, title: t("dpHear") });
|
||
lvHold(hit, () => drumHear(lane, true), () => drumHear(lane, false));
|
||
const tw = (k, lbl, min, max) => lvKnob(t(lbl), { min, max, def: 0, bip: true,
|
||
get: () => (DP.s && DP.s.dtw ? DP.s.dtw[lane][k] : 0),
|
||
set: (v) => {
|
||
if (!DP.s || !DP.s.dtw) return;
|
||
const d = DP.s.dtw[lane];
|
||
if (d[k] === v) return;
|
||
d[k] = v;
|
||
DP.local.set(lane, { tune: d.tune, dec: d.dec, t: performance.now() });
|
||
drumPanelTw(lane);
|
||
},
|
||
fmt: (v) => (v > 0 ? "+" + v : String(v)) });
|
||
const k = [tw("tune", "lvxTune", -8, 7), tw("dec", "lvxDecay", -4, 3)];
|
||
return { node: el("div", { class: "dpcell" }, hit, el("div", { class: "dpk" }, ...k)), k };
|
||
});
|
||
U.reset = el("button", { type: "button", text: t("dpReset"), onclick: async () => {
|
||
if (!DP.s || !DP.s.dtw || !confirm(t("dpResetAsk"))) return;
|
||
for (let l = 0; l < 16; l++) { DP.s.dtw[l] = { tune: 0, dec: 0 }; DP.local.set(l, { tune: 0, dec: 0, t: performance.now() }); await drumPanelTw(l); }
|
||
} });
|
||
U.needs = el("p", { class: "lvneeds", text: t("dpNeeds"), hidden: true });
|
||
box.replaceChildren(
|
||
el("h2", { ic: "symbol_drum", text: "DRUMS" }),
|
||
el("p", { class: "dim", text: t("dpHelp") }),
|
||
el("div", { class: "dprow" },
|
||
el("label", { class: "fld dpkit" }, el("span", { text: t("lvKit") }), el("span", { class: "dpkitsel" }, U.prev, U.kit, U.next)),
|
||
el("div", { class: "lvknobs" }, ...U.mix)),
|
||
el("div", { class: "dprow" },
|
||
el("label", { class: "fld dpkit" }, el("span", { text: "insert" }), U.ins), el("div", { class: "lvknobs" }, ...U.insK)),
|
||
el("h3", { text: t("dpPads") }), U.needs,
|
||
el("div", { class: "dppads" }, ...U.pads.map((x) => x.node)),
|
||
el("p", { class: "bar" }, U.reset, el("span", { class: "dim", text: " " + t("dpPadsHelp") })));
|
||
(async () => { /* the kits' names: the KIT parameter's list */
|
||
let d = dev.pdesc[pe0];
|
||
if (!d || d.label !== "KIT") d = await getDescOrNull(0, pe0).catch(() => null);
|
||
if (d && d.names) { U.kit.replaceChildren(...d.names.map((n, k) => el("option", { value: String(k), text: n }))); drumPanelRender(); }
|
||
})();
|
||
}
|
||
async function drumPanelTw(lane) {
|
||
const d = DP.s.dtw[lane];
|
||
drumPanelRender();
|
||
/* one request a pad in the queue (key): while one is on its way, the moves after it become the next one */
|
||
try { DP.s = drumPanelMerge(parse[CMD.LIVE](await rq(req.live(LIVE.DRUM_TW, lane, d.tune + 8, d.dec + 4), { key: "dtw:" + lane, front: true }))); }
|
||
catch (e) { report(e); }
|
||
drumPanelRender();
|
||
}
|
||
/* a pad heard: a MIDI note on the drum track's channel (as the LIVE page's pads) */
|
||
function drumHear(lane, on) {
|
||
const tr = (dev.info.ntrk || 4) - 1, tok = "dp:" + lane;
|
||
const km = LV.kmode;
|
||
LV.kmode = "play"; /* (always heard: not the LIVE page's roll / erase) */
|
||
try { if (on) lvNoteOn(tok, tr, lvDrumNote(lane), 100); else lvNoteOff(tok); } finally { LV.kmode = km; }
|
||
}
|
||
function drumPanelRender() {
|
||
const U = DP.ui;
|
||
if (!U || DP.built !== dev || !dev.dump) return;
|
||
const pe0 = dev.info.pe0;
|
||
if (document.activeElement !== U.kit && U.kit.options.length) U.kit.value = String(dev.dump.p[pe0] ?? 0);
|
||
if (document.activeElement !== U.ins) U.ins.value = String(dev.dump.p[53] ?? 0);
|
||
[...U.mix, ...U.insK].forEach((k) => k.update());
|
||
const pro = !!(DP.s && DP.s.pro);
|
||
U.needs.hidden = pro;
|
||
U.reset.disabled = !pro;
|
||
U.pads.forEach((x, lane) => {
|
||
x.k.forEach((k) => { k.update(); k.classList.toggle("dpoff", !pro); });
|
||
const tw = pro && (DP.s.dtw[lane].tune || DP.s.dtw[lane].dec);
|
||
x.node.classList.toggle("tweaked", !!tw);
|
||
});
|
||
}
|
||
|
||
function visible(d) { return d && d.max > d.min && d.label !== "-"; }
|
||
|
||
function buildGroups() {
|
||
ctl.clear();
|
||
dev.built = dev.dump.engine;
|
||
/* Sound: the selected track's parameters; Sequencer: its pattern settings; Settings: globals and drums */
|
||
const groups = { groups: [], seqgroups: [], setgroups: [] };
|
||
const { info } = dev;
|
||
const known = EXPECT.pcount.indexOf(info.pcount);
|
||
if (known >= 0 && EXPECT.gcount.includes(info.gcount) && info.pe0 === EXPECT.pe0[known]) {
|
||
for (const g of LAYOUT(info.pe0)) {
|
||
/* a card per button of the device (ENV, LFO, EDIT ...), its pages as rows of four knobs, one colour per knob */
|
||
const div = el("div", { class: "group" }, el("h2", { ic: HEAD_IC[g.t] },
|
||
g.engine ? `EDIT ${info.engines[dev.dump.engine] || ""}` : g.t));
|
||
let pages = 0;
|
||
for (const [title, s, ids, onlyEng] of g.pages) {
|
||
if (onlyEng != null && dev.dump.engine !== onlyEng) continue;
|
||
const rows = ids.map((id) => paramRow(s, id)).filter(Boolean);
|
||
if (!rows.length) continue;
|
||
const tt = g.engine && (dev.titles[dev.dump.engine] || [])[g.pages.findIndex((x) => x[0] === title)];
|
||
if (g.pages.length > 1) div.append(el("h3", { ic: PAGE_IC[tt || title], text: tt || title }));
|
||
div.append(el("div", { class: "knobs" }, ...rows));
|
||
pages++;
|
||
}
|
||
if (pages > 1) div.firstChild.append(el("span", { class: "sub", text: `${pages} ${lang === "ja" ? "ページ" : "pages"}` }));
|
||
if (pages) groups[g.tab || "groups"].push(div);
|
||
}
|
||
} else {
|
||
/* unknown firmware layout: everything in id order, four knobs a row */
|
||
const box = (ic, title, ...pre) => el("div", { class: "group" }, el("h2", { ic: HEAD_IC[ic], text: title }), ...pre);
|
||
const a = box("INSTRUMENT", "INSTRUMENT", el("p", { class: "dim", text: t("layout") }));
|
||
const b = box("EDIT", "EDIT"), c = box("GLOBAL", "GLOBAL");
|
||
const ka = el("div", { class: "knobs" }), kb = el("div", { class: "knobs" }), kc = el("div", { class: "knobs" });
|
||
for (let i = 0; i < info.pcount; i++) { const r = paramRow(0, i); if (r) (i >= info.pe0 ? kb : ka).append(r); }
|
||
for (let i = 0; i < info.gcount; i++) { const r = paramRow(1, i); if (r) kc.append(r); }
|
||
a.append(ka); b.append(kb); c.append(kc);
|
||
groups.groups.push(a, b);
|
||
groups.setgroups.push(c);
|
||
}
|
||
for (const [id, divs] of Object.entries(groups)) $(id).replaceChildren(...divs);
|
||
}
|
||
|
||
function paramRow(s, id) {
|
||
const d = s ? dev.gdesc[id] : dev.pdesc[id];
|
||
if (!visible(d) || (s === 1 && G_SKIP.has(d.label))) return null;
|
||
const k = key(s, id);
|
||
let input;
|
||
if (d.fmt === F.ENUM || d.fmt === F.NOTE || d.fmt === F.ONOFF) {
|
||
const wave = RICH_SELECT && d.fmt === F.ENUM && /^WAVE2?$/.test(d.label);
|
||
input = el("select", { class: wave ? "wave" : null });
|
||
/* the closed select shows a copy of the chosen option (icon span included), not its bare text */
|
||
if (wave) input.append(el("button", {}, el("selectedcontent")));
|
||
for (let v = d.min; v <= d.max; v++) {
|
||
const [txt] = fmtValue(d, v);
|
||
const name = d.fmt === F.ENUM && d.names[v - d.min] == null ? String(v) : txt;
|
||
input.append(el("option", { value: v, ic: wave && WAVE_IC[name] }, name));
|
||
}
|
||
input.addEventListener("change", () => userSet(s, id, +input.value, true));
|
||
} else {
|
||
input = el("input", { type: "range", min: d.min, max: d.max, step: 1 });
|
||
input.addEventListener("pointerdown", () => { dragging = k; });
|
||
input.addEventListener("input", () => userSet(s, id, +input.value, false));
|
||
input.addEventListener("change", () => userSet(s, id, +input.value, true));
|
||
input.addEventListener("dblclick", () => { input.value = d.def; userSet(s, id, d.def, true); });
|
||
/* fine adjust: wheel over the focused slider, Shift+arrows in steps of 10 (plain arrows are native) */
|
||
const nudge = (dv) => {
|
||
const nv = Math.max(d.min, Math.min(d.max, +input.value + dv));
|
||
if (nv !== +input.value) { input.value = String(nv); userSet(s, id, nv, true); }
|
||
};
|
||
let acc = 0;
|
||
input.addEventListener("wheel", (e) => {
|
||
if (document.activeElement !== input) return;
|
||
e.preventDefault();
|
||
acc += (e.deltaMode === 1 ? 33 : 1) * (Math.abs(e.deltaY) >= Math.abs(e.deltaX) ? -e.deltaY : e.deltaX);
|
||
const n = Math.trunc(acc / 50);
|
||
if (n) { acc -= n * 50; nudge(n * (e.shiftKey ? 10 : 1)); }
|
||
}, { passive: false });
|
||
input.addEventListener("keydown", (e) => {
|
||
const dir = { ArrowUp: 1, ArrowRight: 1, ArrowDown: -1, ArrowLeft: -1 }[e.key];
|
||
if (!dir || !e.shiftKey) return;
|
||
e.preventDefault();
|
||
nudge(dir * 10);
|
||
});
|
||
}
|
||
input.title = d.label;
|
||
const out = el("span", { class: "v", title: d.label });
|
||
const isSel = input.tagName === "SELECT";
|
||
const row = el("div", { class: "knob" + (isSel ? " enum" : "") }, el("span", { class: "kl", text: d.label }), out, input);
|
||
ctl.set(k, { input, out, desc: d, scope: s, id, row });
|
||
if (!isSel) valueDrag(k, out, input, d);
|
||
showValue(k, s ? dev.dump.g[id] : dev.dump.p[id], true);
|
||
return row;
|
||
}
|
||
/* the big value turns like a knob: drag it up or down (the whole range over about 200 px, Shift: fine) */
|
||
function valueDrag(k, out, input, d) {
|
||
let y0 = 0, v0 = 0, on = false;
|
||
out.addEventListener("pointerdown", (e) => {
|
||
if (e.button !== 0) return;
|
||
on = true; y0 = e.clientY; v0 = +input.value; dragging = k;
|
||
out.setPointerCapture(e.pointerId);
|
||
e.preventDefault();
|
||
});
|
||
out.addEventListener("pointermove", (e) => {
|
||
if (!on) return;
|
||
const per = (d.max - d.min) / (e.shiftKey ? 800 : 200);
|
||
const v = Math.max(d.min, Math.min(d.max, Math.round(v0 + (y0 - e.clientY) * Math.max(per, e.shiftKey ? 0.05 : 0.12))));
|
||
if (v !== +input.value) { input.value = String(v); userSet(...ctlScopeId(k), v, false); }
|
||
});
|
||
const end = () => { if (!on) return; on = false; dragging = null; userSet(...ctlScopeId(k), +input.value, true); };
|
||
out.addEventListener("pointerup", end);
|
||
out.addEventListener("pointercancel", end);
|
||
out.addEventListener("dblclick", () => { input.value = d.def; userSet(...ctlScopeId(k), d.def, true); });
|
||
}
|
||
const ctlScopeId = (k) => { const c = ctl.get(k); return [c.scope, c.id]; };
|
||
|
||
function showValue(k, v, force) {
|
||
const c = ctl.get(k);
|
||
if (!c || v == null) return;
|
||
const [txt, unit] = fmtValue(c.desc, v);
|
||
c.out.replaceChildren(String(txt), ...(unit ? [el("small", { text: unit })] : []));
|
||
c.out.classList.toggle("long", String(txt).length + (unit ? Math.ceil(unit.length / 2) : 0) > 6);
|
||
if (force || !touched(k)) c.input.value = String(v);
|
||
if (c.input.type === "range") { /* the bar: from the left, or from 0 for a value either side of it */
|
||
const d = c.desc, pc = (x) => (d.max > d.min ? ((x - d.min) / (d.max - d.min)) * 100 : 0);
|
||
const p = pc(+c.input.value), z = d.min < 0 && d.max > 0 ? pc(0) : 0;
|
||
c.input.style.setProperty("--a", Math.min(p, z).toFixed(1) + "%");
|
||
c.input.style.setProperty("--p", Math.max(p, z).toFixed(1) + "%");
|
||
}
|
||
}
|
||
/* a SET of this control queued or in flight */
|
||
function pendingSet(k) { return !!dev && (dev.link.hasQueued(k) || (!!dev.link.cur && dev.link.cur.key === k)); }
|
||
/* the user is working on this control: polling and pushes must not move it */
|
||
function touched(k) {
|
||
const c = ctl.get(k), st = sets.get(k);
|
||
if (dragging === k) return true;
|
||
if (c && c.input.tagName === "SELECT" && document.activeElement === c.input) return true;
|
||
if (st && performance.now() - st.last < 600) return true;
|
||
return pendingSet(k);
|
||
}
|
||
|
||
window.addEventListener("pointerup", () => { if (dragging) { const k = dragging; dragging = null; const c = ctl.get(k); if (c) userSet(c.scope, c.id, +c.input.value, true); } });
|
||
window.addEventListener("pointercancel", () => { dragging = null; });
|
||
|
||
/* SET as fast as the device answers: one SET per control in flight and at most one queued, which
|
||
always carries the latest value (Link coalesces by key), so a drag never builds a backlog */
|
||
function userSet(s, id, v, final) {
|
||
if (!dev) return;
|
||
const k = key(s, id);
|
||
(s ? dev.dump.g : dev.dump.p)[id] = v;
|
||
showValue(k, v, false);
|
||
mixFromDump();
|
||
if (!s && id === pSlen()) lenChanged(); /* (2.5: the grid follows LEN at once) */
|
||
if (!sets.user(k, v, pendingSet(k), performance.now())) return; /* the pending request already carries it */
|
||
sendSet(s, id, k);
|
||
}
|
||
async function sendSet(s, id, k) {
|
||
if (!dev) return;
|
||
const st = sets.get(k);
|
||
const v = (s ? dev.dump.g : dev.dump.p)[id];
|
||
st.sent = v;
|
||
try {
|
||
const r = parse[CMD.SET](await rq(req.set(s, id, v), { key: k }));
|
||
if (dev && dragging !== k && st.sent === v && !dev.link.hasQueued(k)) { /* the device's value after clamping */
|
||
(s ? dev.dump.g : dev.dump.p)[id] = r.value;
|
||
showValue(k, r.value, false);
|
||
mixFromDump();
|
||
if (!s && id === pSlen() && r.value !== v) lenChanged(); /* (clamped by the device) */
|
||
if (!s && id === dev.info.pe0 + 7 && fm6On()) fm6Later(); /* PTCH: the device loaded that patch */
|
||
}
|
||
} catch (e) { if (e.message !== "closed") console.warn(e); }
|
||
}
|
||
|
||
/* engine / preset browser */
|
||
$("engine").addEventListener("change", () => choosePreset(+$("engine").value, 0));
|
||
$("preset").addEventListener("change", () => { if (dev) choosePreset(dev.dump.engine, +$("preset").value); });
|
||
async function choosePreset(e, p) {
|
||
if (!dev) return;
|
||
busy++;
|
||
try {
|
||
selfLoad();
|
||
parse[CMD.PRESET](await rq(req.preset(e, p)));
|
||
await afterSoundChange();
|
||
} catch (err) { report(err); } finally { busy--; }
|
||
}
|
||
async function afterSoundChange(msg = "ready") {
|
||
needReload = false; /* this re-reads everything a RELOAD asks for */
|
||
sets.clear(); /* another track / sound under the controls: a value equal to the one
|
||
sent before is sent again, and they show the device's at once */
|
||
dev.dump = await getDump();
|
||
await rereadEngineDesc();
|
||
updateBrowser();
|
||
refreshAll();
|
||
await loadSteps(); /* a preset can bring a pattern */
|
||
if (hasTracks()) await readMixer(); /* the sound names and the selected strip */
|
||
await fm6Follow(); /* FM6: the track's patch (a PTCH value may have loaded one) */
|
||
sayK(msg);
|
||
}
|
||
$("init").addEventListener("click", async () => {
|
||
if (!dev || !confirm(t("confirmInit"))) return;
|
||
busy++;
|
||
try { selfLoad(); await rq(req.set(1, gEng(), dev.dump.engine)); await afterSoundChange(); }
|
||
catch (err) { report(err); } finally { busy--; }
|
||
});
|
||
|
||
function refreshAll() {
|
||
for (const [k, c] of ctl) showValue(k, c.scope ? dev.dump.g[c.id] : dev.dump.p[c.id], false);
|
||
renderSteps();
|
||
}
|
||
function report(err) { if (err && err.message !== "closed") { console.warn(err); sayK("error", err.message); } }
|
||
|
||
/* projects: the protocol cannot ask whether a slot is used without loading or saving it */
|
||
function renderSlots() {
|
||
const box = $("slots");
|
||
box.replaceChildren();
|
||
for (let i = 0; i < 4; i++) {
|
||
const u = dev.slotUsed[i];
|
||
box.append(el("div", { class: "slot" + (u ? " used" : "") },
|
||
el("b", { text: "ABCD"[i] }),
|
||
el("span", { class: "st", text: u == null ? t("unknown") : t(u ? "used" : "empty") }),
|
||
el("p", { class: "bar" },
|
||
el("button", { class: u ? "pri" : null, ic: "symbol_folder_open", onclick: () => project(0, i) }, t("load")),
|
||
el("button", { ic: "port_disk", onclick: () => project(1, i) }, t("save")))));
|
||
}
|
||
}
|
||
async function project(op, slot) {
|
||
if (!dev) return;
|
||
if (!confirm(t(op ? "confirmSave" : "confirmLoad").replace("{n}", "ABCD"[slot]))) return;
|
||
busy++;
|
||
try {
|
||
/* save writes flash: a long timeout and no retry */
|
||
if (!op) selfLoad();
|
||
const r = parse[CMD.PROJECT](await rq(req.project(op, slot), { timeout: 4000, retries: 0 }));
|
||
if (r.busy) throw new Error("Stop playback before loading or saving a section.");
|
||
dev.slotUsed[slot] = r.used;
|
||
renderSlots();
|
||
if (!op && r.used) await afterSoundChange();
|
||
sayK(op ? "secSaved" : r.used ? "secLoaded" : "secEmpty", "ABCD"[slot]);
|
||
} catch (err) { report(err); } finally { busy--; }
|
||
}
|
||
|
||
/* ---------------------------------------------------------- steps --- */
|
||
const TIMES = ["NOTE", "TIE", "REST"];
|
||
function renderStepHead() { if (dev && dev.steps.length) renderSteps(); }
|
||
const stepLen = () => Math.max(1, Math.min(dev.info.nstep, dev.dump.p[pSlen()] || 16));
|
||
/* a step's notes as text: GM drum names on the drum track */
|
||
const stepNotes = (s) => s.notes.slice(0, s.n).map(isDrum() ? drumName : noteName).join(" ");
|
||
function renderSteps() {
|
||
if (!dev || !dev.steps.length) return;
|
||
const dg = drumGrid() && !!dev.dstepsOk;
|
||
$("drumbar").hidden = $("drumgrid").hidden = !dg;
|
||
$("stepgrid").hidden = $("steptables").hidden = dg;
|
||
renderSeqTools();
|
||
const rollOn = !dg && !isDrum() && RV.view === "roll"; /* (2.5) the piano roll instead of the tiles */
|
||
$("roll").hidden = !rollOn;
|
||
if (rollOn) $("stepgrid").hidden = true;
|
||
renderStepDetail();
|
||
$("steplist").hidden = dg;
|
||
if (dg) { $("noteshelp").textContent = t("drumGridHelp"); $("steplen").textContent = t("stepsOf").replace("{n}", stepLen()); renderDrums(); return; }
|
||
const len = stepLen();
|
||
const box = $("steptables");
|
||
const shape = len + (isDrum() ? "d" : "");
|
||
$("steplen").textContent = t("stepsOf").replace("{n}", len);
|
||
$("noteshelp").textContent = t(isDrum() ? "drumHelp" : "notesHelp");
|
||
renderGrid();
|
||
/* keep the rows the user is typing in */
|
||
if (box.contains(document.activeElement) && box.dataset.len === shape) { updateStepRows(); return; }
|
||
box.dataset.len = shape;
|
||
const tables = [];
|
||
for (let b = 0; b < len; b += 16) {
|
||
const tb = el("table", {}, el("tr", {}, el("th"), el("th", { text: t("notes") }), el("th", { text: t("time") }),
|
||
el("th", { text: t("acc") }), el("th", { text: t("slide") }), el("th", { text: t("vel") })));
|
||
for (let i = b; i < Math.min(len, b + 16); i++) tb.append(stepRow(i));
|
||
tables.push(tb);
|
||
}
|
||
box.replaceChildren(...tables);
|
||
}
|
||
function stepRow(i) {
|
||
const notes = el("input", { type: "text", placeholder: "—", spellcheck: "false" });
|
||
const time = el("select", {}, ...TIMES.map((n, k) => el("option", { value: k, text: n })));
|
||
const acc = el("input", { type: "checkbox" });
|
||
const sl = el("input", { type: "checkbox" });
|
||
const vel = el("input", { type: "number", min: 0, max: 127 });
|
||
const tr = el("tr", { "data-i": i }, el("td", { class: "i", text: String(i + 1) }),
|
||
el("td", {}, notes), el("td", {}, time), el("td", {}, acc), el("td", {}, sl), el("td", {}, vel));
|
||
tr._c = { notes, time, acc, sl, vel };
|
||
fillStep(tr, dev.steps[i]);
|
||
tr.addEventListener("focusin", () => selectStep(i)); /* (v7: the step detail follows the row being edited) */
|
||
const send = () => writeStep(i, tr);
|
||
notes.addEventListener("change", send);
|
||
time.addEventListener("change", send);
|
||
acc.addEventListener("change", send);
|
||
sl.addEventListener("change", send);
|
||
vel.addEventListener("change", send);
|
||
return tr;
|
||
}
|
||
function fillStep(tr, s) {
|
||
const c = tr._c;
|
||
if (!s) return;
|
||
c.notes.value = stepNotes(s);
|
||
c.notes.classList.remove("bad");
|
||
c.time.value = String(s.time);
|
||
c.acc.checked = !!(s.flags & 1);
|
||
c.sl.checked = !!(s.flags & 2);
|
||
c.vel.value = String(s.vel);
|
||
tr.classList.toggle("off", !s.n || s.time === 2);
|
||
}
|
||
function updateStepRows() {
|
||
if (drumGrid() && dev.dstepsOk) { renderDrums(); return; }
|
||
for (const tr of $("steptables").querySelectorAll("tr[data-i]")) {
|
||
if (tr.contains(document.activeElement)) continue;
|
||
fillStep(tr, dev.steps[+tr.dataset.i]);
|
||
}
|
||
renderGrid();
|
||
}
|
||
/* the step grid: one cell per step up to LEN; a cell jumps to its row in the table */
|
||
function renderGrid() {
|
||
const box = $("stepgrid");
|
||
if (!dev || !dev.steps.length) { box.replaceChildren(); return; }
|
||
const len = stepLen();
|
||
if (box.children.length !== len) {
|
||
box.replaceChildren(...Array.from({ length: len }, (_, i) => el("button", { type: "button", "data-i": i, onclick: () => focusStep(i) })));
|
||
}
|
||
for (const b of box.children) {
|
||
const i = +b.dataset.i, s = dev.steps[i];
|
||
const on = !!s && s.n > 0 && s.time === 0, tie = !!s && s.time === 1;
|
||
const txt = on ? stepNotes(s) : tie ? "—" : "";
|
||
const marks = s && on ? (s.flags & 1 ? " >" : "") + (s.flags & 2 ? " ~" : "") : "";
|
||
const lk = stepLocked(i), fc = stepFill(i);
|
||
b.className = [on && "on", tie && "tie", on && s.flags & 1 && "acc", i % 4 === 0 && "beat", lk && "lk", fc && "fc" + fc, i === selStep && hasLocks() && "sel"].filter(Boolean).join(" ");
|
||
b.title = `${i + 1}: ${on ? txt : tie ? "TIE" : "REST"}${marks}${fc ? " (" + FC.NAMES[fc] + ")" : ""}`;
|
||
b.replaceChildren(el("span", { class: "n", text: String(i + 1) + marks }), el("span", { class: "x", text: txt }));
|
||
}
|
||
if (!$("roll").hidden) renderRoll();
|
||
}
|
||
function focusStep(i) {
|
||
const tr = $("steptables").querySelector(`tr[data-i="${i}"]`);
|
||
selectStep(i);
|
||
if (!tr) return;
|
||
$("steplist").open = true; /* (the list opens on the step clicked) */
|
||
tr.scrollIntoView({ block: "center", behavior: "smooth" });
|
||
tr._c.notes.focus({ preventScroll: true });
|
||
tr.classList.add("hl");
|
||
setTimeout(() => tr.classList.remove("hl"), 1200);
|
||
}
|
||
async function writeStep(i, tr) {
|
||
const c = tr._c;
|
||
const notes = parseNotes(c.notes.value);
|
||
if (!notes) { c.notes.classList.add("bad"); return; }
|
||
c.notes.classList.remove("bad");
|
||
const old = dev.steps[i];
|
||
const all = notes.concat(old.notes.slice(notes.length)).slice(0, 4);
|
||
let time = +c.time.value;
|
||
if (notes.length && !old.n && time === 2) time = 0; /* typing notes into an empty step makes it play */
|
||
const s = { n: notes.length, notes: all, time, flags: (c.acc.checked ? 1 : 0) | (c.sl.checked ? 2 : 0),
|
||
vel: Math.max(0, Math.min(127, +c.vel.value || 0)), lvl: old.lvl, rat: old.rat }; /* v5: level / ratchet kept */
|
||
if (s.n && !s.vel) s.vel = 96;
|
||
stepEdit.set(i, performance.now());
|
||
try {
|
||
dev.steps[i] = parse[CMD.STEP_SET](await rq(req.stepSet(i, s)));
|
||
if (!tr.contains(document.activeElement) || document.activeElement === c.notes) fillStep(tr, dev.steps[i]);
|
||
} catch (err) { report(err); }
|
||
}
|
||
/* ---- SLOOP 2.5: LEN at hand, the piano roll of a synth track, MIDI files ---- */
|
||
const RV = { view: "grid", frac: 1 / 16, lo: null, rows: 25, trk: -1, drag: null, geo: null }; /* view: grid | roll */
|
||
try { if (localStorage.getItem("sloop-seq-view") === "roll") RV.view = "roll"; } catch (e) { /* no storage */ }
|
||
const ROLL_ROW = 16, ROLL_LAB = 40;
|
||
const pDiv = () => pById("DIV", 30);
|
||
const curDiv = () => Math.max(0, Math.min(ROLL.DIV_PER_BAR.length - 1, dev.dump.p[pDiv()] | 0));
|
||
const gBpm = () => { const i = dev.gdesc.findIndex((d) => d && d.label === "BPM"); return i >= 0 ? dev.dump.g[i] : 120; };
|
||
function setLen(v) {
|
||
if (!dev || !dev.dump) return;
|
||
v = Math.max(1, Math.min(dev.info.nstep, Math.round(v) || 1));
|
||
if (v !== stepLen()) userSet(0, pSlen(), v, true);
|
||
else $("lenval").value = String(v);
|
||
}
|
||
function lenChanged() { $("steptables").dataset.len = ""; renderSteps(); }
|
||
function renderSeqTools() {
|
||
if (!dev || !dev.dump) return;
|
||
const lv = $("lenval");
|
||
lv.max = String(dev.info.nstep);
|
||
if (document.activeElement !== lv) lv.value = String(stepLen());
|
||
const synth = !isDrum();
|
||
$("viewseg").hidden = !synth;
|
||
for (const b of $("viewseg").children) b.setAttribute("aria-pressed", b.dataset.v === RV.view ? "true" : "false");
|
||
}
|
||
function setView(v) {
|
||
RV.view = v;
|
||
try { localStorage.setItem("sloop-seq-view", v); } catch (e) { /* no storage */ }
|
||
renderSteps();
|
||
}
|
||
$("lenminus").addEventListener("click", () => setLen(stepLen() - 1));
|
||
$("lenplus").addEventListener("click", () => setLen(stepLen() + 1));
|
||
$("lenval").addEventListener("change", (e) => setLen(+e.target.value));
|
||
for (const b of $("viewseg").children) b.addEventListener("click", () => setView(b.dataset.v));
|
||
|
||
/* the roll: rows = notes (black keys darker), columns = steps (bar lines from DIV), a chord = one bar per note */
|
||
function rollColors() {
|
||
const cs = getComputedStyle(document.documentElement), g = (v) => cs.getPropertyValue(v).trim();
|
||
return { bg: g("--bg"), s1: g("--s1"), s2: g("--s2"), s3: g("--s3"), dim: g("--dim"), fg: g("--fg"), trk: g("--trk") };
|
||
}
|
||
function rollFit(len) { /* around the track's notes, the first time a track shows */
|
||
const tr = dev.sel || 0;
|
||
if (RV.trk === tr && RV.lo != null) return;
|
||
RV.trk = tr;
|
||
const ns = ROLL.chords(dev.steps, len).flatMap((c) => c.notes);
|
||
if (!ns.length) { RV.lo = 48; RV.rows = 25; return; }
|
||
const lo = Math.min(...ns), hi = Math.max(...ns);
|
||
RV.rows = Math.max(25, Math.min(49, hi - lo + 7));
|
||
RV.lo = Math.max(0, Math.min(128 - RV.rows, Math.round((lo + hi) / 2 - RV.rows / 2)));
|
||
}
|
||
function renderRollTools() {
|
||
const box = $("rolllen");
|
||
if (!box.children.length)
|
||
box.replaceChildren(...ROLL.LENGTHS.map(([k, f]) => el("button", { type: "button", "data-f": String(f), onclick: () => { RV.frac = f; renderRollTools(); } }, t("len_" + k))));
|
||
for (const b of box.children) b.setAttribute("aria-pressed", +b.dataset.f === RV.frac ? "true" : "false");
|
||
}
|
||
function renderRoll() {
|
||
const cv = $("rollcv");
|
||
if (!dev || !dev.steps.length || $("roll").hidden) return;
|
||
const len = stepLen();
|
||
rollFit(len);
|
||
renderRollTools();
|
||
const lo = RV.lo, rows = RV.rows, hi = lo + rows - 1;
|
||
const avail = Math.max(320, cv.parentElement.clientWidth || 800);
|
||
const cw = Math.max(12, Math.floor((avail - ROLL_LAB) / len));
|
||
const W = ROLL_LAB + cw * len, H = rows * ROLL_ROW, dpr = window.devicePixelRatio || 1;
|
||
cv.width = W * dpr; cv.height = H * dpr; cv.style.width = W + "px"; cv.style.height = H + "px";
|
||
const g = cv.getContext("2d"), C = rollColors();
|
||
g.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||
RV.geo = { lo, hi, cw, len };
|
||
g.fillStyle = C.bg; g.fillRect(0, 0, W, H);
|
||
g.font = '16px "SLOOP Terminus", monospace'; g.textBaseline = "top";
|
||
for (let r = 0; r < rows; r++) {
|
||
const p = hi - r, black = [1, 3, 6, 8, 10].includes(p % 12);
|
||
g.fillStyle = black ? C.s1 : C.s2; g.fillRect(ROLL_LAB, r * ROLL_ROW, W - ROLL_LAB, ROLL_ROW - 1);
|
||
if (p % 12 === 0) { g.fillStyle = C.dim; g.fillText(noteName(p), 2, r * ROLL_ROW); }
|
||
}
|
||
const per = ROLL.DIV_PER_BAR[curDiv()], beat = per / 4;
|
||
for (let i = 0; i <= len; i++) {
|
||
const bar = per >= 1 && i % per === 0, bt = Number.isInteger(beat) && beat >= 1 && i % beat === 0;
|
||
if (!bar && !bt) continue;
|
||
g.fillStyle = bar ? C.dim : C.s3; g.fillRect(ROLL_LAB + i * cw - (bar ? 1 : 0), 0, bar ? 2 : 1, H);
|
||
}
|
||
for (const c of ROLL.chords(dev.steps, len)) {
|
||
const dur = RV.drag && RV.drag.at === c.at ? RV.drag.dur : c.dur, acc = dev.steps[c.at].flags & 1;
|
||
const x = ROLL_LAB + c.at * cw + 1, w = dur * cw - 2;
|
||
for (const p of c.notes) {
|
||
g.fillStyle = C.trk;
|
||
if (p > hi || p < lo) { g.fillRect(x, p > hi ? 0 : H - 3, w, 3); continue; } /* (outside the view: a mark at its edge) */
|
||
const y = (hi - p) * ROLL_ROW + 1;
|
||
g.fillRect(x, y, w, ROLL_ROW - 3);
|
||
if (acc) { g.fillStyle = C.fg; g.fillRect(x, y, w, 2); }
|
||
g.fillStyle = C.bg; g.fillRect(x + w - 4, y + 3, 1, ROLL_ROW - 9); /* the grip: drag the end */
|
||
}
|
||
}
|
||
$("rollrange").textContent = `${noteName(lo)} – ${noteName(hi)}`;
|
||
}
|
||
function rollAt(e) {
|
||
const G = RV.geo, r = $("rollcv").getBoundingClientRect();
|
||
if (!G) return null;
|
||
const x = e.clientX - r.left - ROLL_LAB, y = e.clientY - r.top;
|
||
const i = Math.floor(x / G.cw), p = G.hi - Math.floor(y / ROLL_ROW);
|
||
return { i, p, fx: x / G.cw - i, inside: x >= 0 && i >= 0 && i < G.len && p >= G.lo && p <= G.hi };
|
||
}
|
||
function rollNoteAt(h) { /* the chord (and its note) under the pointer */
|
||
const own = ROLL.owner(dev.steps, h.i);
|
||
if (own < 0) return null;
|
||
const c = ROLL.chords(dev.steps, stepLen()).find((x) => x.at === own);
|
||
return c && c.notes.includes(h.p) ? c : null;
|
||
}
|
||
let rollWriting = false;
|
||
async function rollApply(ch) {
|
||
if (!ch.size || rollWriting) { renderRoll(); return; }
|
||
rollWriting = true;
|
||
for (const [i, s] of ch) dev.steps[i] = { ...dev.steps[i], ...s, index: i }; /* (drawn at once, the device follows) */
|
||
renderGrid();
|
||
try { await writeSteps([...ch.keys()].sort((a, b) => a - b)); } catch (err) { report(err); }
|
||
finally { rollWriting = false; updateStepRows(); }
|
||
}
|
||
/* dev.steps[i] -> the device, keeping what it answers */
|
||
async function writeSteps(idx) {
|
||
busy++;
|
||
try {
|
||
for (const i of idx) {
|
||
const s = dev.steps[i];
|
||
stepEdit.set(i, performance.now());
|
||
dev.steps[i] = parse[CMD.STEP_SET](await rq(req.stepSet(i, { n: s.n, notes: s.notes, time: s.time, flags: s.flags,
|
||
vel: s.vel, lvl: s.lvl || 0, rat: s.rat || 0 })));
|
||
}
|
||
} finally { busy--; }
|
||
}
|
||
$("rollcv").addEventListener("pointerdown", (e) => {
|
||
if (!dev || rollWriting) return;
|
||
const h = rollAt(e);
|
||
if (!h || !h.inside) return;
|
||
const c = rollNoteAt(h), len = stepLen();
|
||
if (c) {
|
||
if (h.i === c.at + c.dur - 1 && h.fx > 0.55) { /* the end of a note: drag its length */
|
||
RV.drag = { at: c.at, dur: c.dur };
|
||
$("rollcv").setPointerCapture(e.pointerId);
|
||
renderRoll();
|
||
return;
|
||
}
|
||
rollApply(ROLL.remove(dev.steps, len, c.at, h.p));
|
||
return;
|
||
}
|
||
rollApply(ROLL.place(dev.steps, len, h.i, h.p, ROLL.steps(RV.frac, curDiv())));
|
||
});
|
||
$("rollcv").addEventListener("pointermove", (e) => {
|
||
const h = rollAt(e);
|
||
if (RV.drag) {
|
||
if (!h) return;
|
||
const d = Math.max(1, Math.min(stepLen() - RV.drag.at, h.i - RV.drag.at + 1));
|
||
if (d !== RV.drag.dur) { RV.drag.dur = d; renderRoll(); }
|
||
return;
|
||
}
|
||
const c = h && h.inside ? rollNoteAt(h) : null;
|
||
$("rollcv").style.cursor = c && h.i === c.at + c.dur - 1 && h.fx > 0.55 ? "ew-resize" : "pointer";
|
||
});
|
||
const rollDrop = () => {
|
||
if (!RV.drag) return;
|
||
const d = RV.drag;
|
||
RV.drag = null;
|
||
rollApply(ROLL.resize(dev.steps, stepLen(), d.at, d.dur));
|
||
};
|
||
$("rollcv").addEventListener("pointerup", rollDrop);
|
||
$("rollcv").addEventListener("pointercancel", () => { RV.drag = null; renderRoll(); });
|
||
$("rollup").addEventListener("click", () => { if (RV.lo != null) { RV.lo = Math.min(128 - RV.rows, RV.lo + 12); renderRoll(); } });
|
||
$("rolldown").addEventListener("click", () => { if (RV.lo != null) { RV.lo = Math.max(0, RV.lo - 12); renderRoll(); } });
|
||
window.addEventListener("resize", () => { if (RV.view === "roll") renderRoll(); });
|
||
|
||
/* MIDI files: the selected track's pattern out as a .mid, a .mid in (a preview first) */
|
||
function midiExport() {
|
||
if (!dev || !dev.steps.length) return;
|
||
const len = stepLen(), div = curDiv(), tr = dev.sel || 0, drum = isDrum();
|
||
const notes = drum && drumGrid() && dev.dstepsOk ? SMF.fromDrums(dev.dsteps, len, div) : SMF.fromSteps(dev.steps, len, div);
|
||
if (!notes.length) { sayK("midiEmpty"); return; }
|
||
downloadBytes(`sloop-track${tr + 1}.mid`, SMF.write(notes, { bpm: gBpm(), ch: drum ? 9 : tr, name: `SLOOP track ${tr + 1}` }));
|
||
sayK("midiSaved", String(notes.length));
|
||
}
|
||
let MI = null; /* the file being imported: {name, smf, src} */
|
||
const midiDrum = () => isDrum() && drumGrid() && !!dev.dstepsOk;
|
||
const midiPlan = () => SMF.toSteps(MI.smf.tracks[MI.src].notes, MI.smf.ppq, curDiv(), dev.info.nstep, midiDrum());
|
||
function renderMidiPrev() {
|
||
const box = $("midiprev");
|
||
if (!MI || !dev || !dev.dump) { box.hidden = true; box.replaceChildren(); return; }
|
||
const srcs = MI.smf.tracks.map((x, k) => [x, k]).filter(([x]) => x.notes.length);
|
||
const cancel = el("button", { type: "button", onclick: () => { MI = null; renderMidiPrev(); } }, t("midiCancel"));
|
||
if (!srcs.length) {
|
||
box.replaceChildren(el("h3", { text: `${t("midiPreview")}: ${MI.name}` }), el("p", { text: t("midiNoNotes") }), el("p", { class: "bar" }, cancel));
|
||
box.hidden = false;
|
||
return;
|
||
}
|
||
if (!srcs.some(([, k]) => k === MI.src)) MI.src = srcs[0][1];
|
||
const plan = midiPlan(), R = plan.report;
|
||
const sel = el("select", { onchange: (e) => { MI.src = +e.target.value; renderMidiPrev(); } },
|
||
...srcs.map(([x, k]) => el("option", { value: k, text: `${k + 1}: ${x.name || t("midiTrack")} (${x.notes.length})` })));
|
||
sel.value = String(MI.src);
|
||
const dd = dev.pdesc[pDiv()], divName = dd && dd.names && dd.names[curDiv()] ? dd.names[curDiv()] : "";
|
||
const info = [t("midiNotes").replace("{n}", R.notes), t("midiGrid").replace("{div}", divName),
|
||
t("midiSteps").replace("{n}", plan.len).replace("{max}", dev.info.nstep)];
|
||
const warn = [];
|
||
if (R.moved) warn.push(t("midiMoved").replace("{n}", R.moved));
|
||
if (R.chordCut) warn.push(t("midiChord").replace("{n}", R.chordCut));
|
||
if (R.overlap) warn.push(t("midiOverlap").replace("{n}", R.overlap));
|
||
if (R.merged) warn.push(t("midiMerged").replace("{n}", R.merged));
|
||
if (R.dropped) warn.push(t("midiDropped").replace("{n}", R.dropped).replace("{max}", dev.info.nstep));
|
||
const setlen = el("input", { type: "checkbox", id: "midisetlen" });
|
||
setlen.checked = true;
|
||
box.replaceChildren(
|
||
el("h3", { text: `${t("midiPreview")}: ${MI.name}` }),
|
||
el("p", { class: "bar" }, el("span", { text: t("midiSource") }), sel),
|
||
el("ul", {}, ...info.map((s) => el("li", { text: s }))),
|
||
warn.length ? el("ul", { class: "warn" }, ...warn.map((s) => el("li", { text: s }))) : el("p", { class: "dim", text: t("midiClean") }),
|
||
el("p", { class: "dim", text: t(midiDrum() ? "midiHowDrum" : "midiHow") }),
|
||
el("p", { class: "bar" }, el("label", {}, setlen, " " + t("midiSetLen").replace("{n}", plan.len)),
|
||
el("button", { type: "button", class: "pri", onclick: midiImport }, t("midiImport")), cancel));
|
||
box.hidden = false;
|
||
}
|
||
async function midiImport() {
|
||
if (!MI || !dev) return;
|
||
if (!confirm(t("midiConfirm"))) return;
|
||
const plan = midiPlan(), setlen = $("midisetlen").checked;
|
||
busy++;
|
||
try {
|
||
if (plan.dsteps) {
|
||
for (let i = 0; i < dev.info.nstep; i++) {
|
||
const r = parse[CMD.DRUM_STEP](await rq(req.drumStep(i, plan.dsteps[i])));
|
||
dev.dsteps[i] = r;
|
||
dev.steps[i] = drumAsStep(r);
|
||
}
|
||
} else {
|
||
for (let i = 0; i < dev.info.nstep; i++) dev.steps[i] = { ...plan.steps[i], index: i };
|
||
await writeSteps([...Array(dev.info.nstep).keys()]);
|
||
}
|
||
MI = null;
|
||
renderMidiPrev();
|
||
if (setlen) setLen(plan.len);
|
||
RV.lo = null;
|
||
lenChanged();
|
||
sayK("midiDone", String(plan.report.notes));
|
||
} catch (err) { report(err); } finally { busy--; }
|
||
}
|
||
$("midiexp").addEventListener("click", midiExport);
|
||
$("midiimp").addEventListener("click", () => $("midifile").click());
|
||
$("midifile").addEventListener("change", async (e) => {
|
||
const f = e.target.files && e.target.files[0];
|
||
e.target.value = "";
|
||
if (!f || !dev) return;
|
||
try {
|
||
MI = { name: f.name, smf: SMF.read(new Uint8Array(await f.arrayBuffer())), src: 0 };
|
||
renderMidiPrev();
|
||
} catch (err) { MI = null; renderMidiPrev(); sayK("midiBad", err.message); }
|
||
});
|
||
|
||
/* ---- SLOOP 2.7: the THEME page (firmware v11: backup object 11, gfx.c theme_t) ----
|
||
Made here, with or without an FM-1: five screen colours (darkest first, as the built-in palettes), the four tracks'
|
||
colours, a name. The preview draws a SLOOP page with them, through RGB565 as the FM-1 shows them. Send writes the
|
||
theme to the FM-1 (with its settings, the song stopped) and shows it; Read takes the FM-1's back; the code line
|
||
shares it (THEME.code / THEME.fromCode). */
|
||
const TH = { t: Object.assign(THEME.builtin(4), { name: "MY THEME" }), from: "4", built: false, sent: null };
|
||
const thOk = () => !!dev && !!dev.info && dev.info.proto >= 11;
|
||
const TH_SCREEN = ["thC1", "thC2", "thC3", "thC4", "thC5"];
|
||
function thBuild() {
|
||
if (TH.built) return;
|
||
TH.built = true;
|
||
const mk = (box, n, key, get, set) => {
|
||
for (let k = 0; k < n; k++) {
|
||
const inp = el("input", { type: "color" });
|
||
inp.addEventListener("input", () => { set(k, THEME.unhex(inp.value)); TH.from = ""; renderTheme(); });
|
||
const lab = el("span", { "data-k": String(k) });
|
||
box.append(el("label", {}, lab, inp));
|
||
}
|
||
};
|
||
mk($("thscreen"), 5, "c", null, (k, v) => { TH.t.c[k] = v; });
|
||
mk($("thtracks"), 4, "trk", null, (k, v) => { TH.t.trk[k] = v; });
|
||
}
|
||
function thDraw() {
|
||
const cv = $("thprev"), g = cv.getContext("2d"), th = TH.t;
|
||
const P = th.c.map((x) => THEME.hex(THEME.shown(x))), T = th.trk.map((x) => THEME.shown(x)), BG = THEME.hex(THEME.shown(th.bg || [0, 0, 0]));
|
||
const HI = THEME.hex(THEME.shown(THEME.hiOf(th)));
|
||
const col = (k) => THEME.hex(T[k]), part = (k, f) => THEME.hex(T[k].map((x) => Math.round(x * f)));
|
||
const sel = 0;
|
||
g.fillStyle = BG; g.fillRect(0, 0, 240, 240);
|
||
g.textBaseline = "top";
|
||
g.font = "bold 12px ui-monospace, monospace";
|
||
g.fillStyle = P[4]; g.fillText("ANALOG1 SOFT PAD", 4, 4);
|
||
g.fillStyle = col(sel); g.fillRect(168, 2, 12, 16);
|
||
g.fillStyle = P[2]; g.fillText("FLT 1/3", 186, 4);
|
||
g.fillStyle = P[0]; g.fillRect(0, 21, 240, 1);
|
||
[["CUT", "64", ""], ["RES", "31", "%"], ["ENV", "+12", "st"], ["DRV", "8", ""]].forEach(([l, v, u], c) => {
|
||
const x = c * 60 + 4;
|
||
g.font = "bold 11px ui-monospace, monospace"; g.fillStyle = P[2]; g.fillText(l, x, 26);
|
||
g.font = "bold 22px ui-monospace, monospace"; g.fillStyle = c === 0 ? HI : col(c); g.fillText(v, x, 40); /* (CUT: being turned) */
|
||
g.font = "bold 10px ui-monospace, monospace"; g.fillStyle = P[1]; g.fillText(u, x + 2 + g.measureText(v).width * 2.1, 52);
|
||
});
|
||
for (let y = 78; y <= 150; y += 18) { g.fillStyle = P[0]; g.fillRect(4, y, 232, 1); }
|
||
g.strokeStyle = col(sel); g.lineWidth = 2; g.beginPath();
|
||
for (let x = 4; x <= 236; x++) {
|
||
const f = (x - 4) / 232, y = 150 - 52 / (1 + Math.pow(f / 0.55, 6)) - 22 * Math.exp(-Math.pow((f - 0.55) / 0.05, 2));
|
||
if (x === 4) g.moveTo(x, y); else g.lineTo(x, y);
|
||
}
|
||
g.stroke();
|
||
g.font = "bold 10px ui-monospace, monospace"; g.fillStyle = P[3]; g.fillText("1.2k", 128, 154);
|
||
for (let i = 0; i < 16; i++) {
|
||
const x = 4 + i * 14.5, on = [0, 3, 6, 8, 11, 14].includes(i);
|
||
g.fillStyle = i === 4 ? HI : on ? col(sel) : P[1]; /* (the play head: the accent) */
|
||
g.fillRect(x, 170, 12, 12);
|
||
if (!on && i !== 4) { g.fillStyle = BG; g.fillRect(x + 1, 171, 10, 10); }
|
||
}
|
||
["T1", "T2", "T3", "DR"].forEach((l, k) => {
|
||
const x = 4 + k * 59, lv = [0.8, 0.55, 0.35, 0.9][k];
|
||
g.fillStyle = part(k, 1 / 3); g.fillRect(x, 202, 52, 10);
|
||
g.fillStyle = col(k); g.fillRect(x, 202, Math.round(52 * lv), 10);
|
||
g.fillStyle = part(k, 2 / 3); g.fillRect(x, 214, 52, 2);
|
||
g.font = "bold 11px ui-monospace, monospace"; g.fillStyle = P[3]; g.fillText(l, x, 222);
|
||
});
|
||
}
|
||
function renderTheme() {
|
||
thBuild();
|
||
const sel = $("thfrom"), keep = TH.from;
|
||
sel.replaceChildren(el("option", { value: "", text: "—" }), ...THEME.BUILTIN.map(([n], i) => el("option", { value: String(i), text: n })));
|
||
sel.value = keep;
|
||
$("thname").value = TH.t.name;
|
||
[...$("thscreen").querySelectorAll("label")].forEach((lb, k) => {
|
||
lb.querySelector("span").textContent = `${k + 1} ${t(TH_SCREEN[k])}`;
|
||
lb.querySelector("input").value = THEME.hex(TH.t.c[k]);
|
||
});
|
||
[...$("thtracks").querySelectorAll("label")].forEach((lb, k) => {
|
||
lb.querySelector("span").textContent = k < 3 ? `T${k + 1}` : t("thT4");
|
||
lb.querySelector("input").value = THEME.hex(TH.t.trk[k]);
|
||
});
|
||
$("thbg").value = THEME.hex(TH.t.bg || [0, 0, 0]);
|
||
$("thacc").value = THEME.hex(THEME.hiOf(TH.t));
|
||
const pb = THEME.problems(TH.t), readable = !pb.val && !pb.acc;
|
||
$("thdarkbar").hidden = readable;
|
||
$("thdark").textContent = readable ? "" : t(pb.val && pb.acc ? "thDarkBoth" : pb.val ? "thDark" : "thDarkAcc");
|
||
$("thscreen").querySelectorAll("input")[4].classList.toggle("thbad", pb.val);
|
||
$("thacc").classList.toggle("thbad", pb.acc);
|
||
$("thnodev").hidden = !!dev;
|
||
$("thold").hidden = !dev || !dev.info || thOk();
|
||
$("thsend").disabled = !thOk(); /* (an unreadable theme: Send says why, Fix next to it) */
|
||
$("thstate").textContent = !thOk() || TH.sent === null ? "" : TH.sent === THEME.code(TH.t) ? t("thStSent") : t("thStNew");
|
||
$("thread").disabled = !thOk();
|
||
$("thremove").disabled = !thOk();
|
||
$("thcode").value = THEME.code(TH.t);
|
||
$("thpaste").placeholder = t("thPasteHint");
|
||
thDraw();
|
||
}
|
||
$("thfrom").addEventListener("change", () => {
|
||
const v = $("thfrom").value;
|
||
if (v === "") return;
|
||
const name = TH.t.name, bg = TH.t.bg, hi = THEME.hiOf(TH.t);
|
||
TH.t = THEME.builtin(+v);
|
||
TH.t.name = name;
|
||
TH.t.bg = bg || [0, 0, 0]; /* (a palette: the screen's five; the background and accent stay;
|
||
on a light background the palette the other way round) */
|
||
TH.t.hi = hi;
|
||
if (THEME.light(TH.t.bg)) TH.t.c.reverse();
|
||
TH.from = v;
|
||
renderTheme();
|
||
});
|
||
$("thname").addEventListener("input", () => { TH.t.name = THEME.cleanName($("thname").value); $("thcode").value = THEME.code(TH.t);
|
||
$("thstate").textContent = !thOk() || TH.sent === null ? "" : TH.sent === THEME.code(TH.t) ? t("thStSent") : t("thStNew"); });
|
||
$("thname").addEventListener("change", () => renderTheme());
|
||
$("thbg").addEventListener("input", () => { TH.t.bg = THEME.unhex($("thbg").value); TH.from = ""; renderTheme(); });
|
||
$("thacc").addEventListener("input", () => { TH.t.hi = THEME.unhex($("thacc").value); renderTheme(); });
|
||
$("thbgblack").addEventListener("click", () => { TH.t.bg = [0, 0, 0]; renderTheme(); });
|
||
$("thinvert").addEventListener("click", () => { TH.t = THEME.invert(TH.t); TH.from = ""; renderTheme(); });
|
||
$("thfix").addEventListener("click", () => { TH.t = THEME.fix(TH.t); renderTheme(); });
|
||
$("thramp").addEventListener("click", () => { TH.t.c = THEME.ramp(THEME.unhex($("thbase").value), TH.t.bg); TH.from = ""; renderTheme(); });
|
||
$("thcopy").addEventListener("click", async () => {
|
||
const s = THEME.code(TH.t);
|
||
try { await navigator.clipboard.writeText(s); } catch (e) { $("thcode").select(); document.execCommand && document.execCommand("copy"); }
|
||
sayK("thCopied");
|
||
});
|
||
$("thapply").addEventListener("click", () => {
|
||
const th = THEME.fromCode($("thpaste").value);
|
||
if (!th) { sayK("thBadCode"); return; }
|
||
TH.t = th;
|
||
TH.from = "";
|
||
$("thpaste").value = "";
|
||
renderTheme();
|
||
});
|
||
async function thPut(bytes) { /* -> the BK_PUT rc (0 written) */
|
||
let r = parse[CMD.BK_PUT](await rq(req.bkBegin(THEME.ID, bytes.length, crc32(bytes)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) return r.rc;
|
||
if (bytes.length) {
|
||
r = parse[CMD.BK_PUT](await rq(req.bkData(THEME.ID, 0, bytes), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) return r.rc;
|
||
}
|
||
return parse[CMD.BK_PUT](await rq(req.bkCommit(THEME.ID), { timeout: 5000, retries: 0 })).rc;
|
||
}
|
||
const thSay = (rc, okKey) => sayK(rc === 0 ? okKey : rc === 3 ? "thStop" : "thRefused");
|
||
$("thsend").addEventListener("click", () => {
|
||
if (!thOk()) return;
|
||
if (!THEME.readable(TH.t)) { sayK("thSendDark"); $("thfix").focus(); return; } /* (the FM-1 would refuse it: why, and Fix) */
|
||
const code = THEME.code(TH.t);
|
||
op(async () => { const rc = await thPut(THEME.encode(TH.t)); if (rc === 0) TH.sent = code; thSay(rc, "thSent"); renderTheme(); });
|
||
});
|
||
$("thremove").addEventListener("click", () => { if (thOk()) op(async () => { const rc = await thPut(new Uint8Array(0)); if (rc === 0) TH.sent = null; thSay(rc, "thRemoved"); renderTheme(); }); });
|
||
$("thread").addEventListener("click", () => {
|
||
if (!thOk()) return;
|
||
op(async () => {
|
||
const L = parse[CMD.BK_LIST](await rq(req.bkList(), { timeout: 5000, retries: 0 }));
|
||
const it = !L.rc && L.items.find((x) => x.id === THEME.ID);
|
||
if (!it) { sayK("thNone"); return; }
|
||
const g = parse[CMD.BK_GET](await rq(req.bkGet(THEME.ID, 0, it.len), { timeout: 1500, retries: 2 }));
|
||
const th = !g.rc && THEME.decode(Uint8Array.from(g.data));
|
||
if (!th) { sayK("thNone"); return; }
|
||
TH.t = th;
|
||
TH.from = "";
|
||
TH.sent = THEME.code(th);
|
||
renderTheme();
|
||
sayK("thGot");
|
||
});
|
||
});
|
||
|
||
/* ---- SLOOP 2.5: the DRUM SYNTH page (firmware v10, editor_dsyn.c): SYN1..SYN4, your synthesised kits ----
|
||
Every change goes to the FM-1's RAM at once (the drum voices play from there); STORE keeps the four kits in flash
|
||
(with the settings, the song stopped). A sound's values as the firmware's dsnd_t (DSYN.decode / encode). */
|
||
const DS = { dev: null, list: null, k: 0, kit: null, lane: 0, src: null, err: "", timer: 0, pend: new Set() };
|
||
const dsOk = () => !!dev && !!dev.info && dev.info.proto >= 10;
|
||
const dsKitName = (k = DS.k) => `SYN${k + 1}`;
|
||
const dsMs = (ms) => (ms >= 1000 ? `${(ms / 1000).toFixed(ms >= 10000 ? 0 : 1)}` : `${Math.round(ms)}`);
|
||
const dsHz = (hz) => (hz >= 1000 ? `${(hz / 1000).toFixed(hz >= 10000 ? 0 : 1)}k` : `${Math.round(hz)}`);
|
||
const NOTE12 = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
||
const dsNote = (n) => `${NOTE12[n % 12]}${Math.floor(n / 12) - 1}`;
|
||
/* the page's values: [key, label, min, max, format -> [value, unit]] by group */
|
||
const DS_GROUPS = [
|
||
["dsTone", [
|
||
["wave", "WAVE", 0, 5, (v) => [DSYN.WAVES[v]], DSYN.WAVES],
|
||
["pitch", "PITCH", 0, 127, (v, o) => [dsNote(v), `${dsHz(DSYN.hz(v, o.fine))} Hz`]],
|
||
["fine", "FINE", 0, 15, (v) => [`+${v}`, "/16"]],
|
||
["bend", "BEND", 0, 96, (v) => [v, "st"]],
|
||
["btime", "B.TIME", 0, 127, (v) => [dsMs(DSYN.decayMs(v)), DSYN.decayMs(v) >= 1000 ? "s" : "ms"]],
|
||
["hold", "HOLD", 0, 255, (v) => [v * 2, "ms"]],
|
||
["decay", "DECAY", 0, 127, (v) => [dsMs(DSYN.decayMs(v)), DSYN.decayMs(v) >= 1000 ? "s" : "ms"]],
|
||
["tlev", "LEVEL", 0, 127, (v) => [v]],
|
||
["t2", "2ND", 0, 255, (v) => (v ? [`×${(v / 32).toFixed(2)}`] : ["OFF"])],
|
||
["t2lev", "2ND LVL", 0, 127, (v) => [v]],
|
||
["click", "CLICK", 0, 127, (v) => [v]]]],
|
||
["dsNoise", [
|
||
["noise", "NOISE", 0, 4, (v) => [DSYN.NOISES[v]], DSYN.NOISES],
|
||
["clap", "CLAP", 0, 1, (v) => [v ? "ON" : "OFF"], ["OFF", "ON"]],
|
||
["nlev", "LEVEL", 0, 127, (v) => [v]],
|
||
["nhold", "HOLD", 0, 255, (v) => [v * 2, "ms"]],
|
||
["ndec", "DECAY", 0, 127, (v) => [dsMs(DSYN.decayMs(v)), DSYN.decayMs(v) >= 1000 ? "s" : "ms"]],
|
||
["hpf", "HPF", 0, 127, (v) => (v ? [dsHz(DSYN.cutHz(v)), "Hz"] : ["OFF"])],
|
||
["chip", "CHIP", 0, 127, (v) => (v ? [dsHz(DSYN.hz(v) * 8), "Hz"] : ["-"])]]],
|
||
["dsFilter", [
|
||
["fmode", "FILTER", 0, 3, (v) => [DSYN.FMODES[v]], DSYN.FMODES],
|
||
["fall", "ON", 0, 1, (v) => [v ? "ALL" : "NOISE"], ["NOISE", "ALL"]],
|
||
["fcut", "CUTOFF", 0, 127, (v) => [dsHz(DSYN.cutHz(v)), "Hz"]],
|
||
["res", "RES", 0, 31, (v) => [Math.round((v * 100) / 31), "%"]],
|
||
["fenv", "ENV", -128, 127, (v) => [`${v > 0 ? "+" : ""}${(v / DSYN.STEPS_PER_OCT).toFixed(1)}`, "oct"]]]],
|
||
["dsOut", [
|
||
["drive", "DRIVE", 0, 127, (v) => [v]],
|
||
["level", "LEVEL", 0, 255, (v) => [`${v >= 128 ? "+" : ""}${DSYN.db(v).toFixed(1)}`, "dB"]]]],
|
||
];
|
||
const dsCtl = new Map(); /* key -> {input, out, def, fmt, sel} */
|
||
function dsSound() { return DSYN.decode(DS.kit.sounds[DS.lane]); }
|
||
function dsKnob([key, label, min, max, fmt, names]) {
|
||
const o = dsSound();
|
||
let input, out = el("span", { class: "v", title: label });
|
||
if (names) {
|
||
input = el("select", { title: label, onchange: () => dsSet(key, +input.value, true) },
|
||
...names.map((n, i) => el("option", { value: i + min, text: n })));
|
||
} else {
|
||
input = el("input", { type: "range", min, max, step: 1, title: label });
|
||
input.addEventListener("input", () => dsSet(key, +input.value, false));
|
||
input.addEventListener("change", () => dsSet(key, +input.value, true));
|
||
input.addEventListener("dblclick", () => dsSet(key, dsDefault(key), true));
|
||
let y0 = 0, v0 = 0, on = false; /* drag the value up / down like a knob (Shift: fine) */
|
||
out.addEventListener("pointerdown", (e) => { if (e.button) return; on = true; y0 = e.clientY; v0 = +input.value; out.setPointerCapture(e.pointerId); e.preventDefault(); });
|
||
out.addEventListener("pointermove", (e) => {
|
||
if (!on) return;
|
||
const per = Math.max((max - min) / (e.shiftKey ? 800 : 200), e.shiftKey ? 0.05 : 0.12);
|
||
const v = Math.max(min, Math.min(max, Math.round(v0 + (y0 - e.clientY) * per)));
|
||
if (v !== +input.value) dsSet(key, v, false);
|
||
});
|
||
const end = () => { if (on) { on = false; dsSet(key, +input.value, true); } };
|
||
out.addEventListener("pointerup", end);
|
||
out.addEventListener("pointercancel", end);
|
||
out.addEventListener("dblclick", () => dsSet(key, dsDefault(key), true));
|
||
}
|
||
const row = el("div", { class: "knob" + (names ? " enum" : "") }, el("span", { class: "kl", text: label }), out, input);
|
||
dsCtl.set(key, { input, out, fmt, names, min, max });
|
||
dsShowValue(key, o[key], o);
|
||
return row;
|
||
}
|
||
function dsShowValue(key, v, o) {
|
||
const c = dsCtl.get(key);
|
||
if (!c) return;
|
||
c.input.value = String(v);
|
||
const [txt, unit] = c.fmt(v, o);
|
||
c.out.replaceChildren(String(txt), ...(unit ? [el("small", { text: unit })] : []));
|
||
c.out.classList.toggle("long", String(txt).length + (unit ? Math.ceil(unit.length / 2) : 0) > 6);
|
||
if (!c.names) {
|
||
const pc = (x) => ((x - c.min) / (c.max - c.min)) * 100, p = pc(v), z = c.min < 0 ? pc(0) : 0;
|
||
c.input.style.setProperty("--a", Math.min(p, z).toFixed(1) + "%");
|
||
c.input.style.setProperty("--p", Math.max(p, z).toFixed(1) + "%");
|
||
}
|
||
}
|
||
/* the value of the sound the kit started from (a double-click puts it back) */
|
||
function dsDefault(key) {
|
||
const f = DS.src && DS.src.sounds[DS.lane];
|
||
return f ? DSYN.decode(f)[key] : dsSound()[key];
|
||
}
|
||
function dsSet(key, v, done) {
|
||
const o = dsSound();
|
||
o[key] = v;
|
||
DS.kit.sounds[DS.lane] = DSYN.encode(o);
|
||
const n = DSYN.decode(DS.kit.sounds[DS.lane]);
|
||
for (const k of dsCtl.keys()) dsShowValue(k, n[k], n);
|
||
DS.pend.add(DS.lane);
|
||
dsDirty(true);
|
||
clearTimeout(DS.timer);
|
||
DS.timer = setTimeout(() => op(() => dsFlush(done && $("dsauto").checked)), done ? 0 : 80);
|
||
}
|
||
async function dsFlush(play) {
|
||
const k = DS.k;
|
||
for (const l of [...DS.pend]) {
|
||
DS.pend.delete(l);
|
||
const r = parse[CMD.DSYN_PUT](await rq(req.dsynSound(k, l, DS.kit.sounds[l])));
|
||
if (r.rc) { sayK("dsBad"); return; }
|
||
}
|
||
if (play) await dsPlay();
|
||
}
|
||
async function dsPlay(lane = DS.lane) {
|
||
const r = parse[CMD.DSYN_PLAY](await rq(req.dsynPlay(DS.k, lane, 110)));
|
||
if (r.rc) sayK("dsBad");
|
||
}
|
||
function dsDirty(on) {
|
||
if (DS.list) DS.list.stored = !on && DS.list.stored;
|
||
if (on && DS.list) DS.list.stored = false;
|
||
$("dsstore").classList.toggle("pri", !!DS.list && !DS.list.stored);
|
||
$("dsstate").textContent = DS.list && !DS.list.stored ? t("dsNotStored") : t("dsStored");
|
||
}
|
||
async function dsLoad(k = DS.k) {
|
||
DS.list = parse[CMD.DSYN_LIST](await rq(req.dsynList()));
|
||
const r = parse[CMD.DSYN_GET](await rq(req.dsynGet(DSYN.USER + k)));
|
||
if (r.rc) throw new Error(`DSYN_GET rc ${r.rc}`);
|
||
DS.k = k;
|
||
DS.kit = { name: r.name, crush: r.crush, src: r.src, sounds: r.sounds };
|
||
const f = parse[CMD.DSYN_GET](await rq(req.dsynGet(r.src))); /* the kit it started from: double-click resets to it */
|
||
DS.src = f.rc ? null : { sounds: f.sounds };
|
||
renderDs();
|
||
}
|
||
function renderDs() {
|
||
const box = $("dsbody");
|
||
$("dsold").hidden = dsOk();
|
||
box.hidden = !dsOk() || !DS.kit;
|
||
if (box.hidden) return;
|
||
for (const b of $("dsk").children) b.setAttribute("aria-pressed", +b.dataset.v === DS.k ? "true" : "false");
|
||
$("dsname").value = DS.kit.name;
|
||
const from = $("dsfrom"), keep = from.value;
|
||
from.replaceChildren(...DS.list.names.map((n, i) => el("option", { value: i, text: n })));
|
||
from.value = keep !== "" ? keep : String(DS.kit.src);
|
||
$("dsbits").value = String(DS.kit.crush & 15);
|
||
$("dssh").value = String((DS.kit.crush >> 4) + 1);
|
||
$("dsbitsv").textContent = (DS.kit.crush & 15) ? `-${DS.kit.crush & 15} bits` : t("dsOff");
|
||
$("dsshv").textContent = (DS.kit.crush >> 4) ? `1/${(DS.kit.crush >> 4) + 1}` : t("dsOff");
|
||
for (const id of ["dsbits", "dssh"]) {
|
||
const i = $(id), p = ((+i.value - +i.min) / (+i.max - +i.min)) * 100;
|
||
i.style.setProperty("--a", "0%"); i.style.setProperty("--p", p.toFixed(1) + "%");
|
||
}
|
||
$("dslanes").replaceChildren(...DSYN.LANES_N.map((n, l) => el("button", { type: "button", "data-l": l,
|
||
"aria-pressed": l === DS.lane ? "true" : "false", onclick: () => { DS.lane = l; renderDsSound(); dsLaneMarks(); op(() => dsPlay(l)); } }, n)));
|
||
renderDsSound();
|
||
dsDirty(!DS.list.stored);
|
||
}
|
||
function dsLaneMarks() { for (const b of $("dslanes").children) b.setAttribute("aria-pressed", +b.dataset.l === DS.lane ? "true" : "false"); }
|
||
function renderDsSound() {
|
||
dsCtl.clear();
|
||
$("dslane").textContent = `${dsKitName()} · ${DSYN.LANES_N[DS.lane]}`;
|
||
$("dsgroups").replaceChildren(...DS_GROUPS.map(([title, ks]) => el("div", { class: "group" },
|
||
el("h3", { text: t(title) }), el("div", { class: "knobs" }, ...ks.map(dsKnob)))));
|
||
}
|
||
async function dsHead() {
|
||
const r = parse[CMD.DSYN_PUT](await rq(req.dsynHead(DS.k, DS.kit.name, DS.kit.crush, DS.kit.src)));
|
||
if (r.rc) sayK("dsBad");
|
||
}
|
||
$("dsk").addEventListener("click", (e) => {
|
||
const b = e.target.closest("button[data-v]");
|
||
if (b && dev) op(() => dsLoad(+b.dataset.v));
|
||
});
|
||
$("dsname").addEventListener("change", (e) => {
|
||
if (!DS.kit) return;
|
||
DS.kit.name = e.target.value.replace(/[^\x20-\x7E]/g, "").slice(0, 8) || dsKitName();
|
||
e.target.value = DS.kit.name;
|
||
dsDirty(true);
|
||
op(dsHead);
|
||
});
|
||
for (const id of ["dsbits", "dssh"]) $(id).addEventListener("input", () => {
|
||
if (!DS.kit) return;
|
||
DS.kit.crush = (+$("dsbits").value & 15) | ((+$("dssh").value - 1) & 15) << 4;
|
||
renderDs();
|
||
dsDirty(true);
|
||
clearTimeout(DS.timer);
|
||
DS.timer = setTimeout(() => op(dsHead), 80);
|
||
});
|
||
$("dscopy").addEventListener("click", () => {
|
||
if (!DS.kit) return;
|
||
const i = +$("dsfrom").value;
|
||
if (!confirm(t("dsCopyAsk").replace("{x}", DS.list.names[i]).replace("{k}", dsKitName()))) return;
|
||
op(async () => {
|
||
const r = parse[CMD.DSYN_PUT](await rq(req.dsynCopy(DS.k, i)));
|
||
if (r.rc) { sayK("dsBad"); return; }
|
||
await dsLoad(DS.k);
|
||
dsDirty(true);
|
||
sayK("dsCopied", ` ${DS.list.names[i]}`);
|
||
});
|
||
});
|
||
$("dsstore").addEventListener("click", () => op(async () => {
|
||
const r = parse[CMD.DSYN_STORE](await rq(req.dsynStore(), { timeout: 5000, retries: 0 }));
|
||
if (r.rc === 3) { sayK("dsStop"); return; }
|
||
if (r.rc) { sayK("dsFlash"); return; }
|
||
if (DS.list) DS.list.stored = true;
|
||
dsDirty(false);
|
||
sayK("dsSaved");
|
||
}));
|
||
$("dsplay").addEventListener("click", () => { if (DS.kit) op(() => dsPlay()); });
|
||
$("dsuse").addEventListener("click", () => {
|
||
if (!dev || !hasTracks() || !DS.kit) return;
|
||
op(async () => {
|
||
const drum = dev.info.ntrk - 1;
|
||
if (dev.sel !== drum) { dev.sel = parse[CMD.TRACK](await rq(req.track(drum))).sel; await afterSoundChange(); }
|
||
const d = dev.pdesc[dev.info.pe0], i = d && d.names ? d.names.indexOf(dsKitName()) : -1;
|
||
if (i < 0) { sayK("kitNoKit"); return; }
|
||
userSet(0, dev.info.pe0, i + d.min, true);
|
||
sayK("kitUsing", dsKitName());
|
||
});
|
||
});
|
||
$("dssave").addEventListener("click", () => {
|
||
if (!DS.kit) return;
|
||
downloadBytes(`${fileSlug(DS.kit.name || dsKitName())}.sloopdrums.json`, new TextEncoder().encode(JSON.stringify(DSYN.toFile(DS.kit))));
|
||
});
|
||
$("dsopen").addEventListener("click", () => $("dsfile").click());
|
||
$("dsfile").addEventListener("change", async (e) => {
|
||
const f = e.target.files && e.target.files[0];
|
||
e.target.value = "";
|
||
if (!f || !DS.kit) return;
|
||
let kit;
|
||
try { kit = DSYN.fromFile(JSON.parse(await f.text())); } catch (err) { sayK("dsFileBad"); return; }
|
||
if (!confirm(t("dsOpenAsk").replace("{x}", kit.name).replace("{k}", dsKitName()))) return;
|
||
op(async () => {
|
||
DS.kit.name = kit.name;
|
||
DS.kit.crush = kit.crush;
|
||
for (let l = 0; l < DSYN.LANES; l++) {
|
||
DS.kit.sounds[l] = kit.sounds[l];
|
||
const r = parse[CMD.DSYN_PUT](await rq(req.dsynSound(DS.k, l, kit.sounds[l])));
|
||
if (r.rc) { sayK("dsBad"); return; }
|
||
}
|
||
await dsHead();
|
||
renderDs();
|
||
dsDirty(true);
|
||
sayK("dsOpened", ` ${kit.name}`);
|
||
});
|
||
});
|
||
|
||
/* ---- SLOOP 2.5: the Song page: the order of the sections A..D (the device's SONG screen, from the browser) ---- */
|
||
const SG = { rows: null, loop: false, bytes: null, err: "", dirty: false };
|
||
async function readSong() {
|
||
if (!dev || !(dev.info.proto >= 6)) { Object.assign(SG, { rows: null, err: "songOld" }); renderSong(); return; }
|
||
const L = parse[CMD.BK_LIST](await rq(req.bkList(), { timeout: 5000, retries: 0 }));
|
||
const it = L.rc ? null : L.items.find((x) => x.id === 1);
|
||
if (!it) throw new Error("the settings are not readable (rc " + L.rc + ")");
|
||
const data = new Uint8Array(it.len);
|
||
for (let off = 0; off < it.len; off += 256) {
|
||
const n = Math.min(256, it.len - off);
|
||
const g = parse[CMD.BK_GET](await rq(req.bkGet(1, off, n), { timeout: 1500, retries: 2 }));
|
||
if (g.rc || g.data.length !== n) throw new Error(`settings: GET rc ${g.rc}`);
|
||
data.set(g.data, off);
|
||
}
|
||
if (!ARR.ok(data)) { Object.assign(SG, { rows: null, err: "songOld" }); renderSong(); return; }
|
||
const song = ARR.decode(data);
|
||
Object.assign(SG, { bytes: data, rows: ARR.group(song.entries), loop: song.loop, err: "", dirty: false });
|
||
renderSong();
|
||
}
|
||
async function sendSong() {
|
||
if (!dev || !SG.rows) return;
|
||
const song = { loop: SG.loop, entries: ARR.expand(SG.rows) };
|
||
if (!ARR.valid(song)) { sayK("songBad"); return; }
|
||
const d = ARR.encode(SG.bytes, song);
|
||
let r = parse[CMD.BK_PUT](await rq(req.bkBegin(1, d.length, crc32(d)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new Error(`song: begin rc ${r.rc}`);
|
||
for (let off = 0; off < d.length; off += 256) {
|
||
r = parse[CMD.BK_PUT](await rq(req.bkData(1, off, d.subarray(off, off + 256)), { timeout: 1500, retries: 1 }));
|
||
if (r.rc) throw new Error(`song: data rc ${r.rc}`);
|
||
}
|
||
r = parse[CMD.BK_PUT](await rq(req.bkCommit(1), { timeout: 5000, retries: 0 }));
|
||
if (r.rc === 3) { sayK("songRefused"); return; } /* (project.c settings_restore: the song is playing) */
|
||
if (r.rc) throw new Error(`song: commit rc ${r.rc}`);
|
||
await readSong();
|
||
sayK("songSent");
|
||
}
|
||
const songCount = () => (SG.rows || []).reduce((a, r) => a + Math.max(1, r.times | 0), 0);
|
||
function songEdit(fn) { fn(); SG.dirty = true; renderSong(); }
|
||
function renderSong() {
|
||
const box = $("songrows");
|
||
if (!dev || !dev.dump) return;
|
||
$("songerr").hidden = !SG.err;
|
||
if (SG.err) $("songerr").textContent = t(SG.err);
|
||
$("songbody").hidden = !SG.rows;
|
||
if (!SG.rows) return;
|
||
const LET = "ABCD", n = songCount(), bars = (SG.rows || []).reduce((a, r) => a + r.bars * Math.max(1, r.times | 0), 0);
|
||
box.replaceChildren(...SG.rows.map((r, k) => {
|
||
const sec = el("select", { onchange: (e) => songEdit(() => { r.scene = +e.target.value; }) },
|
||
...[0, 1, 2, 3].map((s) => el("option", { value: s, text: LET[s] + (dev.slotUsed[s] === false ? ` (${t("empty")})` : "") })));
|
||
sec.value = String(r.scene);
|
||
const num = (v, max, set) => el("input", { type: "number", min: 1, max, value: String(v), onchange: (e) =>
|
||
songEdit(() => set(Math.max(1, Math.min(max, Math.round(+e.target.value) || 1)))) });
|
||
const empty = dev.slotUsed[r.scene] === false;
|
||
return el("tr", { class: empty ? "bad" : null },
|
||
el("td", { class: "i", text: String(k + 1) }), el("td", {}, sec),
|
||
el("td", {}, num(r.bars, ARR.MAX_BARS, (v) => { r.bars = v; })),
|
||
el("td", {}, num(r.times, ARR.STEPS, (v) => { r.times = v; })),
|
||
el("td", { class: "acts" },
|
||
el("button", { type: "button", title: t("songUp"), disabled: k === 0, onclick: () => songEdit(() => { SG.rows.splice(k - 1, 0, SG.rows.splice(k, 1)[0]); }) }, "▲"),
|
||
el("button", { type: "button", title: t("songDown"), disabled: k === SG.rows.length - 1, onclick: () => songEdit(() => { SG.rows.splice(k + 1, 0, SG.rows.splice(k, 1)[0]); }) }, "▼"),
|
||
el("button", { type: "button", title: t("songDel"), disabled: SG.rows.length < 2, onclick: () => songEdit(() => { SG.rows.splice(k, 1); }) }, "✕")));
|
||
}));
|
||
$("songsum").textContent = t("songSum").replace("{n}", n).replace("{max}", ARR.STEPS).replace("{bars}", bars);
|
||
$("songsum").classList.toggle("bad", n > ARR.STEPS);
|
||
$("songadd").disabled = n >= ARR.STEPS;
|
||
$("songsend").disabled = n > ARR.STEPS || !n;
|
||
$("songsend").classList.toggle("pri", SG.dirty);
|
||
for (const b of $("songloop").children) b.setAttribute("aria-pressed", (b.dataset.v === "1") === SG.loop ? "true" : "false");
|
||
$("songempty").hidden = !SG.rows.some((r) => dev.slotUsed[r.scene] === false);
|
||
}
|
||
$("songadd").addEventListener("click", () => songEdit(() => {
|
||
const last = SG.rows[SG.rows.length - 1];
|
||
SG.rows.push({ scene: last ? (last.scene + 1) % 4 : 0, bars: last ? last.bars : 4, times: 1 });
|
||
}));
|
||
$("songread").addEventListener("click", () => op(readSong));
|
||
$("songsend").addEventListener("click", () => op(sendSong));
|
||
$("songexp").addEventListener("click", () => { if (dev) songExport(); }); /* (2.7) a song as one file */
|
||
$("songimp").addEventListener("click", () => { if (dev) $("sf-file").click(); });
|
||
for (const b of $("songloop").children) b.addEventListener("click", () => songEdit(() => { SG.loop = b.dataset.v === "1"; }));
|
||
|
||
/* ---- v7 (SLOOP 2.4): the selected step's nudge and parameter locks (a grid cell or a drum column picks it) */
|
||
let selStep = 0;
|
||
const stepLocked = (i) => !!dev && !!dev.micro && (dev.micro[i] !== 0 || dev.locks.some((l) => l.step === i));
|
||
const stepFill = (i) => dev && dev.fill ? fillGet(dev.fill, i) % 3 : 0; /* v8: 0 normal, 1 fill only, 2 no fill */
|
||
function selectStep(i) {
|
||
if (!dev || i === selStep) return;
|
||
selStep = i;
|
||
renderStepDetail();
|
||
renderGrid();
|
||
}
|
||
function renderStepDetail() {
|
||
const box = $("stepdetail");
|
||
box.hidden = !hasLocks() || !dev.micro;
|
||
if (box.hidden) return;
|
||
const len = stepLen(), i = Math.min(selStep, len - 1);
|
||
if (i !== selStep) { selStep = i; }
|
||
const shape = `${len}:${lang}:${hasFill() ? 1 : 0}`;
|
||
if (box.dataset.shape !== shape) {
|
||
box.dataset.shape = shape;
|
||
const pick = el("input", { type: "number", id: "sdstep", min: 1, max: len, title: t("stepDetail") });
|
||
pick.addEventListener("change", () => { selectStep(Math.max(0, Math.min(len - 1, (+pick.value || 1) - 1))); renderGrid(); });
|
||
const nudge = el("input", { type: "number", id: "sdnudge", min: MICRO.MIN, max: MICRO.MAX, title: t("nudge") });
|
||
nudge.addEventListener("change", () => writeMicro(selStep, +nudge.value || 0));
|
||
const fill = el("select", { id: "sdfill", title: t("fillCond") }, /* v8: the fill condition */
|
||
...["fcNorm", "fcFill", "fcNoFill"].map((k, c) => el("option", { value: c, text: t(k) })));
|
||
fill.addEventListener("change", () => writeFill(selStep, +fill.value || 0));
|
||
fill.hidden = !hasFill();
|
||
const add = el("button", { type: "button", id: "sdadd", text: t("addLock") });
|
||
add.addEventListener("click", () => addLock(selStep));
|
||
box.replaceChildren(
|
||
el("p", { class: "bar" }, el("label", {}, t("stepDetail") + " ", pick), el("label", {}, t("nudge") + " ", nudge),
|
||
hasFill() ? el("label", {}, t("fillCond") + " ", fill) : fill,
|
||
el("span", { class: "dim", text: t("locks") }), add),
|
||
el("table", { id: "sdlocks" }),
|
||
el("p", { class: "dim", text: t("lockHelp") }));
|
||
}
|
||
if (document.activeElement !== $("sdstep")) $("sdstep").value = String(i + 1);
|
||
if (document.activeElement !== $("sdnudge")) $("sdnudge").value = String(dev.micro[i] || 0);
|
||
if (dev.fill && document.activeElement !== $("sdfill")) $("sdfill").value = String(stepFill(i));
|
||
const tb = $("sdlocks"), rows = dev.locks.filter((l) => l.step === i);
|
||
if (tb.contains(document.activeElement)) return; /* (a value being typed) */
|
||
tb.replaceChildren(...rows.map((l) => lockRow(i, l)));
|
||
if (!rows.length) tb.append(el("tr", {}, el("td", { class: "dim", text: t("noLock") })));
|
||
$("sdadd").disabled = dev.locks.length >= 24 || !lockableIds().some((id) => !rows.some((l) => l.param === id));
|
||
}
|
||
/* the parameters a lock may hold on this track, by id (the device's DESC labels; the engine's 8 as their current names) */
|
||
function lockableIds() {
|
||
const ids = [];
|
||
for (let id = 0; id < dev.info.pcount; id++) if (lockable(id) && dev.pdesc[id] && dev.pdesc[id].max > dev.pdesc[id].min) ids.push(id);
|
||
return ids;
|
||
}
|
||
const lockName = (id) => { const d = dev.pdesc[id]; return d ? `${d.label}${id >= dev.info.pe0 ? " (E" + (id - dev.info.pe0 + 1) + ")" : ""}` : String(id); };
|
||
function lockRow(i, l) {
|
||
const sel = el("select", {}, ...lockableIds().map((id) => el("option", { value: id, text: lockName(id) })));
|
||
sel.value = String(l.param);
|
||
const d = dev.pdesc[l.param] || { min: -8192, max: 8191, fmt: 0, names: [] };
|
||
const val = d.fmt === F.ENUM && d.names.length
|
||
? el("select", {}, ...d.names.map((n, k) => el("option", { value: k + d.min, text: n })))
|
||
: el("input", { type: "number", min: d.min, max: d.max });
|
||
val.value = String(l.value);
|
||
const del = el("button", { type: "button", text: "\u00d7", title: t("delete") });
|
||
const tr = el("tr", {}, el("td", {}, sel), el("td", {}, val), el("td", { class: "dim", text: fmtValue(d, l.value).join("") }), el("td", {}, del));
|
||
sel.addEventListener("change", async () => { /* another parameter: the old lock goes, a new one at the track's value */
|
||
const id = +sel.value;
|
||
await writeLock(i, l.param, null);
|
||
await writeLock(i, id, dev.dump.p[id]);
|
||
});
|
||
val.addEventListener("change", () => writeLock(i, l.param, +val.value));
|
||
del.addEventListener("click", () => writeLock(i, l.param, null));
|
||
return tr;
|
||
}
|
||
function addLock(i) { /* a new lock at the track's value: ENV > FLT (5), else the first free parameter */
|
||
const taken = dev.locks.filter((l) => l.step === i).map((l) => l.param);
|
||
const id = [5, ...lockableIds()].find((x) => lockableIds().includes(x) && !taken.includes(x));
|
||
if (id == null) return;
|
||
writeLock(i, id, dev.dump.p[id]);
|
||
}
|
||
async function writeMicro(i, m) {
|
||
const d = dev;
|
||
stepEdit.set(i, performance.now());
|
||
try {
|
||
const r = parse[CMD.MICRO_SET](await rq(req.microSet(d.sel, i, m), { key: "micro:" + i }));
|
||
if (d !== dev || !d.micro) return;
|
||
d.micro[i] = r.micro;
|
||
renderStepDetail();
|
||
renderGrid();
|
||
} catch (err) { report(err); }
|
||
}
|
||
async function writeFill(i, c) { /* v8: the step's fill condition */
|
||
const d = dev;
|
||
stepEdit.set(i, performance.now());
|
||
try {
|
||
const r = parse[CMD.FILL_SET](await rq(req.fillSet(d.sel, i, c), { key: "fill:" + i }));
|
||
if (d !== dev || !d.fill) return;
|
||
fillSet(d.fill, i, r.cond);
|
||
renderStepDetail();
|
||
renderGrid();
|
||
} catch (err) { report(err); }
|
||
}
|
||
async function writeLock(i, param, v) {
|
||
const d = dev;
|
||
stepEdit.set(i, performance.now());
|
||
try {
|
||
const r = parse[CMD.LOCK_SET](await rq(req.lockSet(d.sel, i, param, v), { key: `lock:${i}:${param}` }));
|
||
if (d !== dev || !d.locks) return;
|
||
if (r.rc) sayK(r.rc === 3 ? "lockFull" : "lockRefused");
|
||
const k = d.locks.findIndex((l) => l.step === i && l.param === param);
|
||
if (r.has && k < 0) d.locks.push({ step: i, param, value: r.value });
|
||
else if (r.has) d.locks[k].value = r.value;
|
||
else if (k >= 0) d.locks.splice(k, 1);
|
||
renderStepDetail();
|
||
renderGrid();
|
||
} catch (err) { report(err); }
|
||
}
|
||
async function refreshLocks() { /* a STEP_CHANGED push: the device's nudges / locks may have moved */
|
||
const d = dev;
|
||
try {
|
||
await loadLocks();
|
||
if (d !== dev) return;
|
||
renderStepDetail();
|
||
renderGrid();
|
||
} catch (err) { report(err); }
|
||
}
|
||
|
||
/* ---- v5: the drum track's 16 lanes. A click puts a hit with the level / roll chosen above, or takes it
|
||
away when it already has them; Shift+click steps the level of a hit. One DRUM_STEP per step in flight
|
||
and one queued with the latest lanes (Link coalesces by key). */
|
||
const paint = { lvl: 0, rat: 0 };
|
||
function renderDrumBar() {
|
||
const box = $("drumbar");
|
||
const kd = dev.pdesc[dev.info.pe0], pe0 = dev.info.pe0;
|
||
if (box.dataset.lang !== lang || !box.children.length) {
|
||
box.dataset.lang = lang;
|
||
const kit = el("select", { id: "drumkit", title: t("kit") });
|
||
kit.addEventListener("change", () => userSet(0, pe0, +kit.value, true));
|
||
const seg = (label, vals, name, k) => el("span", { class: "seg", role: "group", "aria-label": label },
|
||
...vals.map((v) => el("button", { type: "button", "data-k": k, "data-v": v, onclick: () => { paint[k] = v; renderDrumBar(); } }, name(v))));
|
||
box.replaceChildren(el("label", {}, t("kit") + " ", kit), el("span", { class: "dim" }, t("hitLevel")),
|
||
seg(t("hitLevel"), LV_ORDER, (v) => LV_NAMES[v], "lvl"),
|
||
el("span", { class: "dim" }, t("ratchet")), seg(t("ratchet"), [0, 1, 2, 3], (v) => "x" + (v + 1), "rat"));
|
||
}
|
||
const kit = $("drumkit");
|
||
const names = kd && kd.fmt === F.ENUM && kd.names.length ? kd.names : null;
|
||
kit.hidden = !names;
|
||
if (names && kit.dataset.n !== String(names.length)) {
|
||
kit.replaceChildren(...names.map((n, i) => el("option", { value: i + kd.min, text: n })));
|
||
kit.dataset.n = String(names.length);
|
||
}
|
||
if (names && document.activeElement !== kit) kit.value = String(dev.dump.p[pe0]);
|
||
for (const b of box.querySelectorAll("button[data-k]")) b.setAttribute("aria-pressed", paint[b.dataset.k] === +b.dataset.v ? "true" : "false");
|
||
}
|
||
function renderDrums() {
|
||
renderDrumBar();
|
||
const box = $("drumgrid"), len = stepLen();
|
||
const shape = `${len}:${lang}:${hasFill() ? 1 : 0}`;
|
||
if (box.dataset.shape !== shape) {
|
||
box.dataset.shape = shape;
|
||
const cols = Math.min(16, len);
|
||
box.style.gridTemplateColumns = `auto repeat(${cols}, minmax(16px, 1fr))`;
|
||
const kids = [];
|
||
for (let b0 = 0; b0 < len; b0 += 16) {
|
||
if (b0) kids.push(el("span", { class: "gap" }));
|
||
kids.push(el("span", { class: "hd" }));
|
||
for (let i = b0; i < b0 + cols; i++) kids.push(el("span", { class: "hd", text: i < len && i % 4 === 0 ? String(i + 1) : "" }));
|
||
for (let l = 0; l < 16; l++) {
|
||
kids.push(el("span", { class: "ln", text: DRUM_LANES[l][1] }));
|
||
for (let i = b0; i < b0 + cols; i++) {
|
||
if (i >= len) { kids.push(el("span")); continue; }
|
||
kids.push(el("button", { type: "button", "data-i": i, "data-l": l, class: i % 4 === 0 ? "beat" : null,
|
||
onclick: (e) => drumClick(i, l, e.shiftKey) }));
|
||
}
|
||
}
|
||
}
|
||
box.replaceChildren(...kids);
|
||
}
|
||
for (const b of box.querySelectorAll("button[data-i]")) {
|
||
const i = +b.dataset.i, l = +b.dataset.l, d = dev.dsteps[i];
|
||
const on = !!d && ((d.on >> l) & 1) === 1;
|
||
b.classList.toggle("on", on);
|
||
for (let k = 1; k < 4; k++) b.classList.toggle("l" + k, on && d.lvl[l] === k);
|
||
b.textContent = on && d.rat[l] ? String(d.rat[l] + 1) : "";
|
||
b.title = `${i + 1} ${DRUM_LANES[l][1]}${on ? ` ${LV_NAMES[d.lvl[l]]} x${d.rat[l] + 1}` : ""}`;
|
||
}
|
||
}
|
||
function drumClick(i, l, shift) {
|
||
if (!dev || !dev.dsteps[i]) return;
|
||
selectStep(i);
|
||
const d = { ...dev.dsteps[i], lvl: dev.dsteps[i].lvl.slice(), rat: dev.dsteps[i].rat.slice() };
|
||
const on = (d.on >> l) & 1;
|
||
if (on && shift) d.lvl[l] = LV_ORDER[(LV_ORDER.indexOf(d.lvl[l]) + 1) % 4]; /* louder, then GHOST again */
|
||
else if (on && d.lvl[l] === paint.lvl && d.rat[l] === paint.rat) { d.on &= ~(1 << l); d.lvl[l] = d.rat[l] = 0; }
|
||
else { d.on |= 1 << l; d.lvl[l] = paint.lvl; d.rat[l] = paint.rat; }
|
||
dev.dsteps[i] = d;
|
||
dev.steps[i] = drumAsStep(d);
|
||
stepEdit.set(i, performance.now());
|
||
renderDrums();
|
||
writeDrum(i);
|
||
}
|
||
async function writeDrum(i) {
|
||
const d = dev;
|
||
try {
|
||
const r = parse[CMD.DRUM_STEP](await rq(req.drumStep(i, d.dsteps[i]), { key: "dstep:" + i }));
|
||
if (d !== dev || d.link.hasQueued("dstep:" + i) || r.index !== i) return;
|
||
d.dsteps[i] = r; /* what the device has now */
|
||
d.steps[i] = drumAsStep(r);
|
||
renderDrums();
|
||
} catch (err) { report(err); }
|
||
}
|
||
$("reloadsteps").addEventListener("click", async () => {
|
||
if (!dev) return;
|
||
busy++;
|
||
try { await loadSteps(); sayK("ready"); } catch (err) { report(err); } finally { busy--; }
|
||
});
|
||
$("clearseq").addEventListener("click", async () => {
|
||
if (!dev || !confirm(t("confirmClear"))) return;
|
||
busy++;
|
||
try {
|
||
const drum = drumGrid() && dev.dstepsOk;
|
||
for (let i = 0; i < dev.info.nstep; i++) {
|
||
if (i % 8 === 0) sayK("applying", `${i}/${dev.info.nstep}`);
|
||
if (drum) { dev.dsteps[i] = parse[CMD.DRUM_STEP](await rq(req.drumStep(i, emptyDrum()))); dev.steps[i] = drumAsStep(dev.dsteps[i]); }
|
||
else dev.steps[i] = parse[CMD.STEP_SET](await rq(req.stepSet(i, { n: 0, notes: [0, 0, 0, 0], time: 2, flags: 0, vel: 0 })));
|
||
}
|
||
$("steptables").dataset.len = "";
|
||
renderSteps();
|
||
sayK("ready");
|
||
} catch (err) { report(err); } finally { busy--; }
|
||
});
|
||
|
||
/* ---------------------------------------------------------- samples --- */
|
||
const smpDraft = [0, 1, 2, 3].map(() => ({ name: "", files: [] })); /* USR1..USR4 */
|
||
let smpBusy = false;
|
||
const SMP_RC = { 1: "size", 2: "header", 3: "data CRC", 4: "flash", 5: "zones" };
|
||
const kib = (n) => (n / 1024).toFixed(1);
|
||
|
||
/* auto key split, as in buildSlot (for the preview) */
|
||
function splitKeys(files) {
|
||
const z = files.map((f, i) => ({ i, root: f.root })).sort((a, b) => a.root - b.root);
|
||
const out = [];
|
||
z.forEach((x, j) => {
|
||
out[x.i] = [j === 0 ? 0 : Math.floor((z[j - 1].root + x.root) / 2) + 1, j === z.length - 1 ? 127 : Math.floor((x.root + z[j + 1].root) / 2)];
|
||
});
|
||
files.forEach((f, i) => { if (f.lo != null) out[i] = [f.lo, f.hi]; }); /* (chops: their own keys) */
|
||
return out;
|
||
}
|
||
|
||
const draftBytes = (d) => d.files.reduce((a, f) => a + ((f.s.length + 1) >> 1), 0);
|
||
|
||
async function decodeFile(f) {
|
||
const buf = await f.arrayBuffer();
|
||
let x, wl = null;
|
||
try {
|
||
const w = parseWav(buf);
|
||
x = resample(w.x, w.sr, SMP.RATE);
|
||
if (w.loop) wl = w.loop.map((p) => Math.round(p * SMP.RATE / w.sr)); /* (2.7) the file's own loop: LOOP+TAIL */
|
||
} catch (e) { /* not a plain WAV: let the browser decode it */
|
||
const Ctx = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
||
const ab = await new Ctx(1, 1, SMP.RATE).decodeAudioData(buf.slice(0));
|
||
x = new Float64Array(ab.length);
|
||
for (let c = 0; c < ab.numberOfChannels; c++) { const d = ab.getChannelData(c); for (let i = 0; i < d.length; i++) x[i] += d[i] / ab.numberOfChannels; }
|
||
}
|
||
if (!x.length) throw new Error("no audio");
|
||
const z = { fname: f.name, s: normalize(x), root: rootFromName(f.name.replace(/\.[^.]*$/, "")) };
|
||
if (wl && wl[1] > wl[0] && wl[1] - wl[0] + 1 >= LOOP.MIN && z.s.length >= 4 * LOOP.MIN) [z.loop, z.ls, z.le] = [2, ...LOOP.range({ s: z.s, loop: 2, ls: wl[0], le: wl[1] })];
|
||
return z;
|
||
}
|
||
|
||
|
||
/* ---- the Samples page (2.4): 1 the slot, 2 the sound (from files, one note each; or CHOP, one recording cut in
|
||
pieces), 3 send it and play it on a track. One draft for the files (smpPage.draft), whichever slot it goes to. */
|
||
const smpPage = { slot: 0, mode: "files", draft: { name: "", files: [] }, ui: null };
|
||
let smpAudio = null, smpSrc = null;
|
||
function playInt16(s, onend) { /* a preview in the computer (22050 Hz mono) */
|
||
const Ctx = window.AudioContext || window.webkitAudioContext;
|
||
if (!smpAudio) smpAudio = new Ctx();
|
||
if (smpSrc) try { smpSrc.stop(); } catch (e) { /* ended */ }
|
||
const buf = smpAudio.createBuffer(1, s.length, SMP.RATE), ch = buf.getChannelData(0);
|
||
for (let i = 0; i < s.length; i++) ch[i] = s[i] / 32768;
|
||
smpSrc = smpAudio.createBufferSource();
|
||
smpSrc.buffer = buf;
|
||
smpSrc.connect(smpAudio.destination);
|
||
if (onend) smpSrc.onended = onend;
|
||
smpSrc.start();
|
||
}
|
||
/* 2.7: a file with a loop, heard as the FM-1 plays it: held, the loop goes round; let go, the rest to the end */
|
||
function playLoop(s, ls, le) {
|
||
playInt16(s);
|
||
smpSrc.loop = true;
|
||
smpSrc.loopStart = ls / SMP.RATE;
|
||
smpSrc.loopEnd = (le + 1) / SMP.RATE;
|
||
}
|
||
function releaseLoop() { if (smpSrc) smpSrc.loop = false; }
|
||
/* the ▶ of a looped file: hold it (mouse, touch, or Enter / Space held) */
|
||
function holdToPlay(b, start) {
|
||
b.addEventListener("pointerdown", (e) => { e.preventDefault(); try { b.setPointerCapture(e.pointerId); } catch (x) { /* gone */ } start(); });
|
||
for (const ev of ["pointerup", "pointercancel"]) b.addEventListener(ev, releaseLoop);
|
||
b.addEventListener("keydown", (e) => { if ((e.key === "Enter" || e.key === " ") && !e.repeat) { e.preventDefault(); start(); } });
|
||
b.addEventListener("keyup", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); releaseLoop(); } });
|
||
}
|
||
/* LOOP+TAIL: the file's wave, its loop lit */
|
||
function drawLoopWave(cv, f) {
|
||
const w = cv.width = Math.max(120, cv.clientWidth || 600), h = cv.height = 48, g = cv.getContext("2d");
|
||
const cs = getComputedStyle(cv), s = f.s, n = s.length, [ls, le] = LOOP.range(f);
|
||
const col = cs.getPropertyValue("--c").trim(), dim = getComputedStyle(document.documentElement).getPropertyValue("--s3").trim();
|
||
g.clearRect(0, 0, w, h);
|
||
for (let x = 0; x < w; x++) {
|
||
const a = Math.floor(x / w * n), b = Math.max(a + 1, Math.floor((x + 1) / w * n));
|
||
let pk = 0;
|
||
for (let i = a; i < b && i < n; i += 2) pk = Math.max(pk, Math.abs(s[i]));
|
||
const y = Math.max(1, Math.round(pk / 32768 * (h / 2 - 2)));
|
||
g.fillStyle = b > ls && a <= le ? col : dim;
|
||
g.fillRect(x, h / 2 - y, 1, y * 2);
|
||
}
|
||
g.fillStyle = col;
|
||
for (const i of [ls, le + 1]) g.fillRect(Math.min(w - 2, Math.round(i / n * w)), 0, 2, h);
|
||
}
|
||
async function addSmpFiles(list) {
|
||
const d = smpPage.draft;
|
||
let full = false;
|
||
for (const f of list) {
|
||
try {
|
||
const z = await decodeFile(f);
|
||
if (d.files.length >= SMP.MAX_ZONES) { full = true; break; }
|
||
d.files.push(z);
|
||
if (!d.name) d.name = f.name.replace(/\.[^.]*$/, "").toUpperCase().replace(/[^\x20-\x7E]/g, "").slice(0, 8);
|
||
} catch (e) { sayK("smpDecodeFail", `${f.name} (${e.message})`); }
|
||
}
|
||
if (full) sayK("smpFull");
|
||
renderSamples();
|
||
}
|
||
/* the keyboard C1..C7 and which file each key plays (its root: a bright mark) */
|
||
function drawKeymap(cv, files, keys) {
|
||
const lo = 24, hi = 108, n = hi - lo + 1, w = cv.width = Math.max(300, cv.clientWidth || 600), h = cv.height = 44, g = cv.getContext("2d");
|
||
const cs = getComputedStyle(document.documentElement), col = ["--t1", "--t2", "--t3", "--t4"].map((v) => cs.getPropertyValue(v).trim());
|
||
g.clearRect(0, 0, w, h);
|
||
const kw = w / n, black = (k) => [1, 3, 6, 8, 10].includes(k % 12);
|
||
for (let k = lo; k <= hi; k++) {
|
||
const x = (k - lo) * kw;
|
||
g.fillStyle = black(k) ? "#1a1a1e" : "#36363c";
|
||
g.fillRect(x, 20, Math.max(1, kw - 1), 24);
|
||
if (k % 12 === 0) { g.fillStyle = "#76767e"; g.font = '16px "SLOOP Terminus", monospace'; g.fillText("C" + (k / 12 - 1), x + 1, 14); }
|
||
}
|
||
files.forEach((f, i) => {
|
||
const [a, b] = keys[i], c = col[i % 4];
|
||
const x0 = (Math.max(lo, a) - lo) * kw, x1 = (Math.min(hi, b) - lo + 1) * kw;
|
||
if (x1 <= x0) return;
|
||
g.fillStyle = c; g.globalAlpha = 0.45; g.fillRect(x0, 20, x1 - x0 - 1, 24); g.globalAlpha = 1;
|
||
if (f.root >= lo && f.root <= hi) { g.fillStyle = c; g.fillRect((f.root - lo) * kw, 20, Math.max(2, kw - 1), 24); }
|
||
});
|
||
}
|
||
function renderSamples() {
|
||
chopUI(); /* (once; then its parts follow the device) */
|
||
chopRender();
|
||
const box = $("smpslots"); /* the tab says when there are no slots (renderPanels) */
|
||
if (!dev || !dev.smp) { box.replaceChildren(); return; }
|
||
const P = smpPage, n = dev.smp.nslots;
|
||
if (P.slot >= n) P.slot = 0;
|
||
if (!P.ui || P.ui.lang !== lang || P.ui.n !== n) {
|
||
const u = P.ui = { lang, n };
|
||
const step = (k, title, ...kids) => el("section", { class: "kstep" }, el("h3", {}, el("span", { class: "num", text: String(k) }), title), ...kids);
|
||
/* 1: the slots */
|
||
u.slots = el("div", { class: "dest slots4", role: "radiogroup", "aria-label": t("smpStep1") }, ...Array.from({ length: n }, (_, k) => {
|
||
const b = el("button", { type: "button", role: "radio", "data-k": k, onclick: () => { P.slot = k; renderSamples(); } },
|
||
el("b", { text: `USR${k + 1}` }), el("span", { class: "now" }), el("progress", { max: 1, value: 0 }), el("span", { class: "cap" }));
|
||
return b;
|
||
}));
|
||
u.erase = el("button", { class: "warn", ic: "symbol_trash", onclick: () => smpErase(P.slot) });
|
||
u.slotNote = el("p", { class: "destnote" });
|
||
/* 2: files or CHOP */
|
||
u.modes = el("div", { class: "seg modes", role: "tablist" }, ...[["files", "smpModeFiles"], ["chop", "smpModeChop"]].map(([m, k]) =>
|
||
el("button", { type: "button", role: "tab", "data-m": m, onclick: () => { P.mode = m; renderSamples(); } }, t(k))));
|
||
u.modeHelp = el("div", { class: "modehelp" });
|
||
u.file = el("input", { type: "file", accept: ".wav,audio/wav,audio/x-wav,audio/*", multiple: true, hidden: true });
|
||
u.file.addEventListener("change", () => { addSmpFiles([...u.file.files]); u.file.value = ""; });
|
||
u.drop = el("div", { class: "dropzone", tabindex: "0", role: "button", onclick: () => u.file.click(),
|
||
onkeydown: (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); u.file.click(); } } },
|
||
el("b", { text: t("smpDrop") }), el("span", { class: "dim", text: t("smpDropHint") }));
|
||
for (const z of [u.drop]) {
|
||
z.addEventListener("dragover", (e) => { e.preventDefault(); z.classList.add("over"); });
|
||
z.addEventListener("dragleave", () => z.classList.remove("over"));
|
||
z.addEventListener("drop", (e) => { e.preventDefault(); z.classList.remove("over"); if (!smpBusy && e.dataTransfer.files.length) addSmpFiles([...e.dataTransfer.files]); });
|
||
}
|
||
u.keymap = el("canvas", { class: "keymap", title: t("smpKeymap") });
|
||
u.list = el("div", { class: "flist" });
|
||
u.meter = el("progress", { max: SMP.MAX_DATA, value: 0 });
|
||
u.meterTxt = el("span", { class: "dim" });
|
||
u.meterBox = el("div", { class: "kitmeter" }, u.meter, u.meterTxt);
|
||
u.clear = el("button", { class: "warn", ic: "symbol_trash", onclick: () => { P.draft.files = []; renderSamples(); } }, t("clearList"));
|
||
u.match = el("button", { ic: "symbol_audio", onclick: () => {
|
||
const g = matchGains(P.draft.files.map((f) => f.s));
|
||
P.draft.files.forEach((f, i) => { f.gain = g[i]; });
|
||
sayK("levelsMatched");
|
||
renderSamples();
|
||
} }, t("matchLevels"));
|
||
u.filesPane = el("div", { class: "pane" }, u.drop, u.file,
|
||
el("div", { class: "kithead" }, el("div", { class: "bar", style: "margin:0" }, el("span", { class: "dim", text: t("smpKeymap") })), u.meterBox),
|
||
u.keymap, u.list, el("p", { class: "bar" }, u.match, el("span", { class: "dim", text: t("matchHelp") }), u.clear));
|
||
u.chopPane = el("div", { class: "pane" });
|
||
const chop = $("chop");
|
||
chop.hidden = false;
|
||
u.chopPane.append(chop); /* (the CHOP tool, as before, inside step 2) */
|
||
/* 3: send and play */
|
||
u.name = el("input", { type: "text", class: "name", maxlength: 8, spellcheck: "false", placeholder: "NAME",
|
||
oninput: () => {
|
||
const v = u.name.value.toUpperCase().replace(/[^\x20-\x7E]/g, "").slice(0, 8);
|
||
if (v !== u.name.value) u.name.value = v;
|
||
if (P.mode === "chop") CH.name = v; else P.draft.name = v;
|
||
smpButtons();
|
||
} });
|
||
u.prog = el("progress", { max: 1, value: 0, hidden: true });
|
||
u.send = el("button", { class: "pri", ic: "symbol_upload", onclick: smpSendPage });
|
||
u.play = el("div", { class: "seg" }, ...[0, 1, 2].map((i) => el("button", { type: "button", "data-i": i, style: `--c:${TCOL[i]}`, class: "trk",
|
||
onclick: () => smpUseOn(i, P.slot) }, `${t("track")} ${i + 1}`)));
|
||
u.where = el("p", { class: "dim" });
|
||
box.replaceChildren(el("div", { class: "card" },
|
||
el("h2", { ic: "symbol_waves" }, t("samples")),
|
||
el("p", { class: "dim", text: t("smpIntro") }),
|
||
step(1, t("smpStep1"), u.slots, el("div", { class: "bar" }, u.erase), u.slotNote),
|
||
step(2, t("smpStep2"), u.modes, u.modeHelp, u.filesPane, u.chopPane),
|
||
step(3, t("smpStep3"), el("div", { class: "bar" }, el("span", { class: "dim", text: t("smpName") }), u.name, u.send, u.prog),
|
||
el("div", { class: "bar" }, el("span", { class: "dim", text: t("smpPlayOn") }), u.play), u.where)));
|
||
}
|
||
const u = P.ui;
|
||
/* 1 */
|
||
for (const b of u.slots.children) {
|
||
const k = +b.dataset.k, x = dev.smp.slots[k];
|
||
b.setAttribute("aria-checked", k === P.slot ? "true" : "false");
|
||
b.classList.toggle("full", !!x.zones);
|
||
b.querySelector(".now").textContent = x.zones ? `${x.name || "—"} · ${x.zones} ${t("zones")}` : t("empty");
|
||
const pg = b.querySelector("progress");
|
||
pg.max = dev.smp.slotKiB; pg.value = x.kib;
|
||
b.querySelector(".cap").textContent = `${x.kib} / ${dev.smp.slotKiB} KiB` + (k === 3 ? " · 2.4" : "");
|
||
}
|
||
const cur = dev.smp.slots[P.slot];
|
||
setLabel(u.erase, t("smpEraseSlot").replace("{n}", P.slot + 1));
|
||
u.erase.disabled = smpBusy || !cur.zones;
|
||
u.slotNote.textContent = (cur.zones ? t("smpReplaces").replace("{n}", P.slot + 1).replace("{x}", cur.name || "—") : t("smpSlotFree").replace("{n}", P.slot + 1))
|
||
+ (n >= 4 && P.slot >= 2 ? " " + t("smpKitHint") : "");
|
||
/* 2 */
|
||
for (const b of u.modes.children) b.setAttribute("aria-selected", b.dataset.m === P.mode ? "true" : "false");
|
||
u.filesPane.hidden = P.mode !== "files";
|
||
u.chopPane.hidden = P.mode !== "chop";
|
||
u.modeHelp.replaceChildren(...t(P.mode === "files" ? "smpFilesHelp" : "smpChopHelp").split("\n").map((x) => el("p", { text: x })));
|
||
const d = P.draft, keys = splitKeys(d.files), bytes = draftBytes(d);
|
||
u.meter.value = Math.min(bytes, SMP.MAX_DATA);
|
||
u.meterBox.classList.toggle("over", bytes > SMP.MAX_DATA);
|
||
u.meterTxt.textContent = (bytes > SMP.MAX_DATA ? t("smpTooBig") + " · " : "") +
|
||
t("kitUsed").replace("{s}", (d.files.reduce((a, f) => a + f.s.length, 0) / SMP.RATE).toFixed(1)).replace("{t}", (SMP.MAX_DATA * 2 / SMP.RATE).toFixed(1));
|
||
u.keymap.hidden = u.list.hidden = !d.files.length;
|
||
u.match.disabled = d.files.length < 2;
|
||
u.list.replaceChildren(...(d.files.length ? [el("div", { class: "frow fhead" }, el("span"), el("span", { text: t("file") }), el("span", { text: t("smpNote") }),
|
||
el("span", { text: t("keys") }), el("span", { text: t("length") }), el("span", { text: t("smpLoop") }), el("span", { text: t("kitGain") }), el("span"))] : []),
|
||
...d.files.map((f, i) => {
|
||
const root = el("input", { type: "text", class: "root", value: noteName(f.root), spellcheck: "false", title: t("smpNoteHelp") });
|
||
root.addEventListener("change", () => {
|
||
const nn = parseNote(root.value.trim());
|
||
if (nn == null) { root.classList.add("bad"); return; }
|
||
f.root = nn;
|
||
renderSamples();
|
||
});
|
||
const gi = el("input", { type: "range", min: LEVEL_MIN, max: 0, step: 1, value: String(f.gain || 0), title: t("smpGainHelp") });
|
||
const gv = el("span", { class: "val", text: `${f.gain || 0} dB` });
|
||
gi.addEventListener("input", () => { f.gain = +gi.value; gv.textContent = `${f.gain} dB`; barFill(gi); });
|
||
gi.addEventListener("change", () => playInt16(withGain(f.s, f.gain)));
|
||
requestAnimationFrame(() => barFill(gi));
|
||
/* 2.7: ONE SHOT, LOOP (the whole file while held), LOOP+TAIL (its points below) */
|
||
const lsel = el("select", { title: t("smpLoopHelp"), "aria-label": t("smpLoop") },
|
||
...LOOP.NAMES.map((nm, k) => el("option", { value: String(k), text: nm, disabled: k === 2 && f.s.length < 4 * LOOP.MIN })));
|
||
lsel.value = String(f.loop || 0);
|
||
lsel.addEventListener("change", () => {
|
||
f.loop = +lsel.value;
|
||
if (f.loop === 2 && f.ls == null) [f.ls, f.le] = LOOP.snapRange(f.s, Math.round(f.s.length / 4), Math.round(f.s.length * 3 / 4));
|
||
renderSamples();
|
||
});
|
||
const play = el("button", { type: "button", title: t(f.loop ? "smpHoldPlay" : "kitPlay") }, "▶");
|
||
if (f.loop) holdToPlay(play, () => { const [a, b] = LOOP.range(f); playLoop(withGain(f.s, f.gain), a, b); });
|
||
else play.addEventListener("click", () => playInt16(withGain(f.s, f.gain)));
|
||
const row = el("div", { class: "frow", style: `--c:${TCOL[i % 4]}` },
|
||
play,
|
||
el("span", { class: "fn", text: f.fname, title: f.fname }), root,
|
||
el("span", { text: `${noteName(keys[i][0])}–${noteName(keys[i][1])}` }),
|
||
el("span", { class: "dim", text: `${(f.s.length / SMP.RATE).toFixed(2)} s` }),
|
||
lsel,
|
||
el("div", { class: "gain" }, gi, gv),
|
||
el("button", { type: "button", class: "warn", title: t("remove"), disabled: smpBusy, onclick: () => { d.files.splice(i, 1); renderSamples(); } }, "×"));
|
||
if (f.loop !== 2) return row;
|
||
/* LOOP+TAIL: where the loop starts and ends, snapped to a zero crossing when let go */
|
||
const cv = el("canvas", { class: "loopwave" }), n = f.s.length;
|
||
const ms = (x) => `${Math.round(x / SMP.RATE * 1000)} ms`;
|
||
const mk = (key, idx) => {
|
||
const r = el("input", { type: "range", min: 0, max: n - 1, step: 1, value: String(LOOP.range(f)[idx]), "aria-label": t(key) });
|
||
const v = el("span", { class: "val", text: ms(LOOP.range(f)[idx]) });
|
||
r.addEventListener("input", () => {
|
||
if (idx) f.le = Math.max(+r.value, (f.ls ?? 0) + LOOP.MIN - 1); else f.ls = Math.min(+r.value, (f.le ?? n - 1) - LOOP.MIN + 1);
|
||
v.textContent = ms(LOOP.range(f)[idx]);
|
||
drawLoopWave(cv, f);
|
||
});
|
||
r.addEventListener("change", () => {
|
||
[f.ls, f.le] = LOOP.snapRange(f.s, ...LOOP.range(f));
|
||
renderSamples();
|
||
});
|
||
return el("label", { class: "lpt" }, el("span", { class: "dim", text: t(key) }), r, v);
|
||
};
|
||
requestAnimationFrame(() => drawLoopWave(cv, f));
|
||
return el("div", { class: "floopbox" }, row,
|
||
el("div", { class: "floop", style: `--c:${TCOL[i % 4]}` }, cv, mk("smpLoopStart", 0), mk("smpLoopEnd", 1),
|
||
el("span", { class: "dim", text: t("smpLoopTail") })));
|
||
}));
|
||
if (d.files.length) requestAnimationFrame(() => drawKeymap(u.keymap, d.files, keys));
|
||
/* 3 */
|
||
if (document.activeElement !== u.name) u.name.value = P.mode === "chop" ? CH.name || "" : d.name;
|
||
smpButtons();
|
||
}
|
||
function smpButtons() {
|
||
const u = smpPage.ui;
|
||
if (!u || !dev || !dev.smp) return;
|
||
const P = smpPage, k = P.slot, x = dev.smp.slots[k];
|
||
setLabel(u.send, t("smpSendTo").replace("{n}", k + 1));
|
||
let ready;
|
||
if (P.mode === "files") ready = P.draft.files.length && draftBytes(P.draft) <= SMP.MAX_DATA && P.draft.name;
|
||
else { const U = chopUsed(), over = U.use.reduce((a, q) => a + ((q.end - q.start + 1) >> 1), 0) > SMP.MAX_DATA; ready = CH.x && U.use.length && !over && CH.name; }
|
||
u.send.disabled = smpBusy || !ready;
|
||
for (const b of u.play.children) b.disabled = smpBusy || !x.zones || !hasTracks();
|
||
u.where.textContent = t("smpWhere").replace(/\{n\}/g, k + 1);
|
||
}
|
||
async function smpSendPage() {
|
||
const P = smpPage, k = P.slot;
|
||
if (P.mode === "chop") { await chopSend(k, P.ui.prog); }
|
||
else if (await smpUpload(k, P.ui.prog, true, P.draft)) sayK("smpDone", `${k + 1}`);
|
||
P.ui.prog.hidden = true;
|
||
renderSamples();
|
||
}
|
||
/* track i plays slot k: the track selected, engine SAMPLE (its first preset), SET = USRk */
|
||
function smpUseOn(i, k) {
|
||
if (!dev || !hasTracks()) return;
|
||
op(async () => {
|
||
if (dev.sel !== i) { dev.sel = parse[CMD.TRACK](await rq(req.track(i))).sel; await afterSoundChange(); }
|
||
const e = dev.info.engines.indexOf("SAMPLE");
|
||
if (e < 0) { sayK("smpNoEngine"); return; }
|
||
if (dev.dump.engine !== e) { selfLoad(); parse[CMD.PRESET](await rq(req.preset(e, 0))); await afterSoundChange(); }
|
||
const d = dev.pdesc[dev.info.pe0], v = d && d.names ? d.names.indexOf(`USR${k + 1}`) : -1;
|
||
if (v < 0) { sayK("smpNoEngine"); return; }
|
||
userSet(0, dev.info.pe0, v + d.min, true);
|
||
sayK("smpPlaying", ` ${i + 1}: SAMPLE, SET = USR${k + 1}`);
|
||
});
|
||
}
|
||
|
||
/* ---------------------------------------------------------- drum kit (2.4) --- */
|
||
/* 16 pads, one per drum lane (DRUM_LANES, the white keys F3..), each a sound kitPad tunes, cuts and levels; the kit
|
||
goes to a USR slot as one zone per lane (kitZones) and the drum track plays it with KIT = USR1..USR3 */
|
||
const kitDraft = { name: "", slot: 4, pads: Array(16).fill(null), sel: -1 }; /* slot 0..3: USR1..4; 4: USR3+4 (a big kit) */
|
||
const KIT_PAIR = 4;
|
||
const kitSlots = (d = kitDraft.slot) => (d === KIT_PAIR ? [2, 3] : [d]);
|
||
const kitDest = (d = kitDraft.slot) => (d === KIT_PAIR ? "USR3+4" : `USR${d + 1}`);
|
||
const kitRoom = () => SMP.MAX_DATA - 64; /* (a slot, less a margin: kitLen may undercount a sample) */
|
||
const kitHas4 = () => !!dev && !!dev.smp && dev.smp.nslots >= 4;
|
||
const KEY_OF_LANE = ["F3", "G3", "A3", "B3", "C4", "D4", "E4", "F4", "G4", "A4", "B4", "C5", "D5", "E5", "F5", "G5"];
|
||
let kitUi = null, kitAudio = null, kitSrc = null;
|
||
function kitProg() { return kitUi && kitUi.prog; }
|
||
const kitKiB = (b) => (b / 1024).toFixed(1);
|
||
async function kitAddFiles(list, lane = -1) {
|
||
const done = [];
|
||
let full = false;
|
||
for (const f of list) {
|
||
if (/\.zip$/i.test(f.name)) { await kitOpenZip(f); continue; }
|
||
try {
|
||
const z = await decodeFile(f);
|
||
const pads = kitDraft.pads; /* (after the decode: CLEAR ALL may have come meanwhile) */
|
||
const l = kitPlace(pads, f.name, lane);
|
||
if (l < 0) { full = true; break; }
|
||
pads[l] = { s: z.s, fname: f.name, tune: 0, gain: 0, len: 0 };
|
||
done.push(`${DRUM_LANES[l][1]} ← ${f.name}`);
|
||
if (!kitDraft.name) kitDraft.name = "KIT";
|
||
if (lane >= 0) lane = -1; /* (more files dropped on one pad: the rest by name) */
|
||
} catch (e) { sayK("smpDecodeFail", `${f.name} (${e.message})`); }
|
||
}
|
||
if (done.length) sayK("kitAssigned", done.join(", ") + (full ? " — " + t("kitFull") : ""));
|
||
else if (full) sayK("kitFull");
|
||
renderKits();
|
||
}
|
||
async function kitOpenZip(f) {
|
||
try {
|
||
const files = (await zipRead(await f.arrayBuffer())).filter((x) => /\.(wav|aif|aiff|mp3|flac|ogg)$/i.test(x.name));
|
||
const base = f.name.replace(/\.zip$/i, "").toUpperCase().replace(/[^\x20-\x7E]/g, "").slice(0, 8);
|
||
await kitAddFiles(files.map((x) => new File([x.data], x.name.split("/").pop())));
|
||
if (base) kitDraft.name = base;
|
||
sayK("kitLoaded", f.name);
|
||
} catch (e) { sayK("smpDecodeFail", `${f.name} (${e.message})`); }
|
||
}
|
||
function kitPlayPad(l) {
|
||
const p = kitDraft.pads[l];
|
||
if (!p) return;
|
||
const Ctx = window.AudioContext || window.webkitAudioContext;
|
||
if (!kitAudio) kitAudio = new Ctx();
|
||
if (kitSrc) try { kitSrc.stop(); } catch (e) { /* ended */ }
|
||
const s = kitPad(p), buf = kitAudio.createBuffer(1, s.length, SMP.RATE), ch = buf.getChannelData(0);
|
||
for (let i = 0; i < s.length; i++) ch[i] = s[i] / 32768;
|
||
kitSrc = kitAudio.createBufferSource();
|
||
kitSrc.buffer = buf;
|
||
kitSrc.connect(kitAudio.destination);
|
||
kitSrc.start();
|
||
const pad = kitUi && kitUi.pads[l];
|
||
if (pad) { pad.box.classList.add("playing"); kitSrc.onended = () => pad.box.classList.remove("playing"); }
|
||
}
|
||
function kitDrawWave(cv, p) {
|
||
const w = cv.width = Math.max(60, cv.clientWidth || 200), h = cv.height = 48, g = cv.getContext("2d");
|
||
g.clearRect(0, 0, w, h);
|
||
const s = p.s, n = s.length, keep = kitLen(p) * (p.tune ? Math.pow(2, p.tune / 12) : 1);
|
||
const col = getComputedStyle(cv).getPropertyValue("--c") || "#ff621a";
|
||
for (let x = 0; x < w; x++) {
|
||
const a = Math.floor(x / w * n), b = Math.max(a + 1, Math.floor((x + 1) / w * n));
|
||
let pk = 0;
|
||
for (let i = a; i < b && i < n; i += 4) pk = Math.max(pk, Math.abs(s[i]));
|
||
const y = Math.max(1, Math.round(pk / 32768 * (h / 2 - 2)));
|
||
g.fillStyle = a < keep ? col.trim() || "#ff621a" : "#36363c";
|
||
g.fillRect(x, h / 2 - y, 1, y * 2);
|
||
}
|
||
}
|
||
function renderKits() {
|
||
const box = $("kit");
|
||
if (!box) return;
|
||
const ok = !!dev && !!dev.smp;
|
||
if (!kitUi || kitUi.lang !== lang) {
|
||
const u = kitUi = { lang, pads: [] };
|
||
u.file = el("input", { type: "file", accept: ".wav,.zip,audio/*", multiple: true, hidden: true });
|
||
u.file.addEventListener("change", () => { kitAddFiles([...u.file.files], u.want ?? -1); u.want = -1; u.file.value = ""; });
|
||
u.name = el("input", { type: "text", class: "name", maxlength: 8, spellcheck: "false", placeholder: "NAME",
|
||
oninput: () => { const v = u.name.value.toUpperCase().replace(/[^\x20-\x7E]/g, "").slice(0, 8); if (v !== u.name.value) u.name.value = v; kitDraft.name = v; kitButtons(); } });
|
||
/* where the kit goes: one slot (about 7 s), or USR3+4 (about 15 s, the big kit) */
|
||
u.dest = el("div", { class: "dest", role: "radiogroup", "aria-label": t("kitStep2") }, ...[KIT_PAIR, 0, 1, 2, 3].map((d) => el("button", {
|
||
type: "button", role: "radio", "data-d": d, class: d === KIT_PAIR ? "big" : null, onclick: () => { kitDraft.slot = d; renderKits(); } },
|
||
el("b", { text: kitDest(d) }), el("span", { class: "cap", text: d === KIT_PAIR ? t("kitCapBig") : t("kitCapOne") }), el("span", { class: "now" }))));
|
||
u.destNote = el("p", { class: "destnote" });
|
||
u.meter = el("progress", { max: SMP.MAX_DATA, value: 0 });
|
||
u.meterTxt = el("span", { class: "dim" });
|
||
u.meterBox = el("div", { class: "kitmeter" }, u.meter, u.meterTxt);
|
||
u.prog = el("progress", { max: 1, value: 0, hidden: true });
|
||
u.send = el("button", { class: "pri", ic: "symbol_upload", onclick: kitSend });
|
||
u.use = el("button", { ic: "symbol_drum", onclick: () => kitUse(kitDraft.slot) });
|
||
u.fit = el("button", { onclick: () => { if (kitFit(kitDraft.pads, kitRoom(), kitSlots().length)) renderKits(); } }, t("kitFit"));
|
||
u.match = el("button", { ic: "symbol_audio", onclick: kitMatch }, t("matchLevels"));
|
||
u.add = el("button", { ic: "symbol_folder_open", onclick: () => { u.want = -1; u.file.click(); } }, t("kitAdd"));
|
||
u.zip = el("button", { ic: "symbol_download", onclick: kitZip }, t("kitZip"));
|
||
u.clear = el("button", { class: "warn", ic: "symbol_trash", onclick: () => { kitDraft.pads = Array(16).fill(null); kitDraft.sel = -1; renderKits(); } }, t("kitClear"));
|
||
const grid = el("div", { class: "pads" });
|
||
for (let l = 0; l < 16; l++) {
|
||
const pu = {};
|
||
pu.box = el("div", { class: "pad", "data-l": l });
|
||
pu.cv = el("canvas", { title: t("kitPlay"), onclick: () => kitPlayPad(l) });
|
||
pu.fn = el("div", { class: "fn" });
|
||
pu.empty = el("div", { class: "empty", onclick: () => { u.want = l; u.file.click(); } }, ...t("kitEmptyPad").split("\n").flatMap((x, i) => (i ? [el("br"), x] : [x])));
|
||
const knob = (lab, min, max, step, key, fmt) => {
|
||
const inp = el("input", { type: "range", min, max, step });
|
||
const val = el("span", { class: "val" });
|
||
inp.addEventListener("input", () => {
|
||
const p = kitDraft.pads[l];
|
||
if (!p) return;
|
||
p[key] = key === "len" ? Math.round(+inp.value / 1000 * SMP.RATE) : +inp.value;
|
||
if (key === "len" && +inp.value >= +inp.max) p.len = 0;
|
||
kitPadUpdate(l);
|
||
kitMeter();
|
||
});
|
||
inp.addEventListener("change", () => kitPlayPad(l));
|
||
pu[key] = { inp, val, fmt };
|
||
return el("div", { class: "row3" }, el("span", { text: lab }), inp, val);
|
||
};
|
||
pu.ctrls = el("div", {}, knob(t("kitTune"), -KIT.TUNE, KIT.TUNE, 1, "tune"), knob(t("kitGain"), KIT.GAIN_MIN, 0, 1, "gain"),
|
||
knob(t("kitLen"), 10, 2000, 5, "len"));
|
||
pu.acts = el("div", { class: "acts" }, el("button", { onclick: () => kitPlayPad(l) }, "▶ " + t("kitPlay")),
|
||
el("button", { class: "warn", onclick: () => { kitDraft.pads[l] = null; renderKits(); } }, "×"));
|
||
pu.box.append(el("div", { class: "ph" }, el("b", { text: DRUM_LANES[l][1] }), el("span", { class: "key", text: KEY_OF_LANE[l] })),
|
||
pu.empty, pu.cv, pu.fn, pu.ctrls, pu.acts);
|
||
pu.box.addEventListener("dragover", (e) => { e.preventDefault(); pu.box.classList.add("over"); });
|
||
pu.box.addEventListener("dragleave", () => pu.box.classList.remove("over"));
|
||
pu.box.addEventListener("drop", (e) => {
|
||
e.preventDefault(); e.stopPropagation(); pu.box.classList.remove("over"); /* (not the card's drop too) */
|
||
if (e.dataTransfer.files.length) kitAddFiles([...e.dataTransfer.files], l);
|
||
});
|
||
grid.append(pu.box);
|
||
u.pads[l] = pu;
|
||
}
|
||
const step = (n, title, ...kids) => el("section", { class: "kstep" }, el("h3", {}, el("span", { class: "num", text: String(n) }), title), ...kids);
|
||
u.where = el("p", { class: "dim" });
|
||
const card = el("div", { class: "card" },
|
||
el("h2", { ic: "symbol_drum" }, t("kitTitle")),
|
||
el("p", { class: "dim", text: t("kitHelp") }),
|
||
step(1, t("kitStep1"), el("p", { class: "dim", text: t("kitStep1Help") }),
|
||
el("div", { class: "kithead" }, el("div", { class: "bar", style: "margin:0" }, u.add, u.file, u.zip, u.clear), u.meterBox),
|
||
grid, el("div", { class: "bar" }, u.match, el("span", { class: "dim", text: t("matchHelp") })),
|
||
el("div", { class: "bar" }, u.fit, el("span", { class: "dim", text: t("kitFitHelp") }))),
|
||
step(2, t("kitStep2"), u.dest, u.destNote,
|
||
el("div", { class: "bar" }, el("span", { class: "dim", text: t("kitName") }), u.name)),
|
||
step(3, t("kitStep3"), el("div", { class: "bar" }, u.send, u.prog, u.use), u.where));
|
||
card.addEventListener("dragover", (e) => e.preventDefault());
|
||
card.addEventListener("drop", (e) => { e.preventDefault(); if (e.dataTransfer.files.length) kitAddFiles([...e.dataTransfer.files]); });
|
||
box.replaceChildren(card);
|
||
}
|
||
const u = kitUi;
|
||
if (document.activeElement !== u.name) u.name.value = kitDraft.name;
|
||
if (!kitHas4() && ok && kitDraft.slot >= 3) kitDraft.slot = 2; /* (a firmware without USR4) */
|
||
for (const b of u.dest.children) {
|
||
const d = +b.dataset.d, sl = kitSlots(d).map((k) => ok && dev.smp.slots[k]);
|
||
b.setAttribute("aria-checked", d === kitDraft.slot ? "true" : "false");
|
||
b.disabled = ok && !kitHas4() && (d === KIT_PAIR || d === 3);
|
||
b.querySelector(".now").textContent = !ok ? "" : sl.every((x) => !x || !x.zones) ? t("empty")
|
||
: sl.filter((x) => x && x.zones).map((x) => x.name || "\u2014").filter((x, i, a) => a.indexOf(x) === i).join(" + ");
|
||
b.classList.toggle("full", ok && sl.some((x) => x && x.zones));
|
||
}
|
||
const used = kitSlots().map((k) => ok && dev.smp.slots[k]).filter((x) => x && x.zones);
|
||
u.destNote.replaceChildren(t(kitDraft.slot === KIT_PAIR ? "kitNotePair" : "kitNoteOne").replace("{x}", kitDest()),
|
||
...(used.length ? [" ", el("span", { class: "warn", text: t("kitReplaces").replace("{x}", used.map((x) => x.name || "\u2014").join(" + ")) })] : []),
|
||
...(ok && !kitHas4() ? [" ", el("span", { class: "dim", text: t("kitNo4") })] : []));
|
||
setLabel(u.use, t("kitUse").replace("{x}", kitDest()));
|
||
u.where.textContent = t("kitWhereFM1").replace("{x}", kitDest());
|
||
for (let l = 0; l < 16; l++) kitPadUpdate(l);
|
||
kitMeter();
|
||
}
|
||
function kitPadUpdate(l) {
|
||
const pu = kitUi && kitUi.pads[l], p = kitDraft.pads[l];
|
||
if (!pu) return;
|
||
pu.empty.hidden = !!p;
|
||
pu.cv.hidden = pu.fn.hidden = pu.ctrls.hidden = pu.acts.hidden = !p;
|
||
if (!p) return;
|
||
pu.fn.textContent = p.fname;
|
||
pu.fn.title = p.fname;
|
||
const full = kitLen({ ...p, len: 0 });
|
||
pu.len.inp.max = String(10 + Math.max(0, Math.ceil((full / SMP.RATE * 1000 - 10) / 5)) * 5); /* (on the step grid: the end reachable) */
|
||
if (document.activeElement !== pu.tune.inp) pu.tune.inp.value = String(p.tune);
|
||
if (document.activeElement !== pu.gain.inp) pu.gain.inp.value = String(p.gain);
|
||
if (document.activeElement !== pu.len.inp) pu.len.inp.value = String(p.len ? Math.round(p.len / SMP.RATE * 1000) : pu.len.inp.max);
|
||
pu.tune.val.textContent = (p.tune > 0 ? "+" : "") + p.tune + " st";
|
||
pu.gain.val.textContent = p.gain + " dB";
|
||
pu.len.val.textContent = (kitLen(p) / SMP.RATE).toFixed(2) + " s";
|
||
for (const k of ["tune", "gain", "len"]) barFill(pu[k].inp);
|
||
kitDrawWave(pu.cv, p);
|
||
}
|
||
function kitMeter() {
|
||
const u = kitUi;
|
||
if (!u) return;
|
||
const n = kitSlots().length, cap = SMP.MAX_DATA * n, bytes = kitBytes(kitDraft.pads), secs = kitDraft.pads.reduce((a, p) => a + (p ? kitLen(p) : 0), 0) / SMP.RATE;
|
||
const over = n > 1 ? !kitSplit(kitDraft.pads, kitRoom()) : bytes > kitRoom();
|
||
u.meter.max = cap;
|
||
u.meter.value = Math.min(bytes, cap);
|
||
u.meterBox.classList.toggle("over", over);
|
||
u.meterTxt.textContent = (over ? t("kitOver") + " \u00b7 " : "") + t("kitUsed").replace("{s}", secs.toFixed(1)).replace("{t}", (cap * 2 / SMP.RATE).toFixed(1));
|
||
u.fit.disabled = !over;
|
||
kitButtons();
|
||
}
|
||
/* a slider's bar (--a .. --p): from its left end, or from 0 when its range has both signs */
|
||
function barFill(i) {
|
||
const lo = +i.min, hi = +i.max, pc = (x) => (hi > lo ? ((x - lo) / (hi - lo)) * 100 : 0), p = pc(+i.value), z = lo < 0 && hi > 0 ? pc(0) : 0;
|
||
i.style.setProperty("--a", Math.min(p, z).toFixed(1) + "%");
|
||
i.style.setProperty("--p", Math.max(p, z).toFixed(1) + "%");
|
||
}
|
||
/* KIT's value for USRn on the drum track (its names come with the drum track's DESC: -1 while not known) */
|
||
const kitIndexOf = (d) => (dev && dev.kitNames ? dev.kitNames.indexOf(kitDest(d)) : -1);
|
||
function kitButtons() {
|
||
const u = kitUi;
|
||
if (!u) return;
|
||
const ok = !!dev && !!dev.smp, any = kitDraft.pads.some(Boolean), pair = kitDraft.slot === KIT_PAIR;
|
||
const over = pair ? !kitSplit(kitDraft.pads, kitRoom()) : kitBytes(kitDraft.pads) > kitRoom();
|
||
setLabel(u.send, t("kitSend").replace("{x}", kitDest()));
|
||
u.send.disabled = !ok || smpBusy || !any || over || !kitDraft.name || (!kitHas4() && kitDraft.slot >= 3);
|
||
const sl = kitSlots().map((k) => ok && dev.smp.slots[k]);
|
||
u.use.disabled = !ok || smpBusy || !sl.some((x) => x && x.zones) || !hasTracks();
|
||
u.use.title = dev && dev.kitNames && kitIndexOf(kitDraft.slot) < 0 ? t("kitNoKit") : "";
|
||
u.zip.disabled = !any;
|
||
u.match.disabled = kitDraft.pads.filter(Boolean).length < 2;
|
||
}
|
||
/* the pads to the same heard level (as they sound with their pitch and length): Gain set on each, by ear after */
|
||
function kitMatch() {
|
||
const g = matchGains(kitDraft.pads.map((p) => (p ? kitPad({ ...p, gain: 0 }) : null)));
|
||
kitDraft.pads.forEach((p, l) => { if (p) p.gain = g[l]; });
|
||
sayK("levelsMatched");
|
||
renderKits();
|
||
}
|
||
/* the kit to its slot, or shared out over USR3 and USR4 (kitSplit); a slot of the pair that gets no pad is erased, so
|
||
nothing old plays on a lane the kit leaves empty */
|
||
async function kitSend() {
|
||
const d = kitDraft.slot, ks = kitSlots(d);
|
||
if (!kitDraft.pads.some(Boolean)) { sayK("kitNone"); return; }
|
||
const parts = ks.length > 1 ? kitSplit(kitDraft.pads, kitRoom()) : [kitDraft.pads.map((p, l) => (p ? l : -1)).filter((l) => l >= 0)];
|
||
if (!parts) { sayK("kitOver"); return; }
|
||
if (!confirm(t("kitConfirm").replace("{x}", ks.map((k) => `USR${k + 1}`).join(" + ")))) return;
|
||
let done = true;
|
||
for (let j = 0; j < ks.length && done; j++) {
|
||
const k = ks[j];
|
||
if (!parts[j].length) {
|
||
busy++;
|
||
try { const r = parse[CMD.SMP_ERASE](await rq(req.smpErase(k), { timeout: 2500, retries: 0 })); if (r.rc) throw new Error("erase rc " + r.rc); await smpInfo(); }
|
||
catch (e) { done = false; report(e); } finally { busy--; }
|
||
continue;
|
||
}
|
||
const sub = kitDraft.pads.map((p, l) => (parts[j].includes(l) ? p : null));
|
||
done = await smpUpload(k, kitProg(), false, { name: kitDraft.name || "KIT", files: kitZones(sub) });
|
||
}
|
||
if (kitProg()) kitProg().hidden = true;
|
||
renderKits();
|
||
if (done) sayK("kitSent", kitDest(d));
|
||
}
|
||
/* the drum track on that kit: select track 4, then its KIT (P_E0) = USRn */
|
||
function kitUse(k) {
|
||
if (!dev || !hasTracks()) return;
|
||
op(async () => {
|
||
const drum = dev.info.ntrk - 1;
|
||
if (dev.sel !== drum) { dev.sel = parse[CMD.TRACK](await rq(req.track(drum))).sel; await afterSoundChange(); }
|
||
const d = dev.pdesc[dev.info.pe0], i = d && d.names ? d.names.indexOf(kitDest(k)) : -1; /* (the drum track's DESC now) */
|
||
if (i < 0) { sayK("kitNoKit"); return; }
|
||
userSet(0, dev.info.pe0, i + d.min, true);
|
||
if (drumGrid() && dev.dstepsOk) renderDrumBar();
|
||
sayK("kitUsing", kitDest(k));
|
||
});
|
||
}
|
||
function kitZip() {
|
||
const files = kitZones(kitDraft.pads).map((z) => ({ name: `${kitDraft.name || "KIT"}/${String(z.lane + 1).padStart(2, "0")} ${DRUM_LANES[z.lane][1]}.wav`, data: wavFile(z.s) }));
|
||
if (!files.length) return;
|
||
downloadBytes(`${fileSlug(kitDraft.name || "kit")}-drumkit.zip`, zipStore(files));
|
||
}
|
||
|
||
async function smpInfo() { dev.smp = parse[CMD.SMP_INFO](await rq(req.smpInfo())); }
|
||
|
||
async function smpUpload(k, prog, ask = true, d = smpDraft[k]) { /* (d: the DRUM KIT page's own, not the Samples draft) */
|
||
let built, done = false;
|
||
try { built = buildSlot(d.name, d.files.map((f) => ({ s: withGain(f.s, f.gain), root: f.root, lo: f.lo, hi: f.hi,
|
||
loop: f.loop || 0, ls: f.ls, le: f.le }))); }
|
||
catch (e) { sayK("smpFail", e.message); return false; }
|
||
if (ask && !confirm(t("confirmUpload").replace("{n}", k + 1))) return false;
|
||
const { hdr, data } = built;
|
||
busy++;
|
||
smpBusy = true;
|
||
renderSamples();
|
||
renderKits();
|
||
if (!prog || !prog.isConnected) /* (the Samples page was drawn again just now: its new bar) */
|
||
prog = $("smpslots").querySelector(`[data-k="${k}"] progress[max="1"]`) || { value: 0, hidden: true };
|
||
prog.hidden = false;
|
||
try {
|
||
const t0 = performance.now();
|
||
let r = parse[CMD.SMP_BEGIN](await rq(req.smpBegin(k), { timeout: 1000, retries: 0 }));
|
||
if (r.rc) throw new Error("begin rc " + r.rc);
|
||
for (let off = 0; off < data.length; off += 256) {
|
||
const a = SMP.DATA_OFF + off;
|
||
const w = parse[CMD.SMP_WRITE](await rq(req.smpWrite(k, a, data.subarray(off, off + 256)), { timeout: 1000, retries: 1 }));
|
||
if (w.rc) throw new Error(`write at 0x${a.toString(16)} rc ${w.rc}`);
|
||
prog.value = (off + 256) / data.length;
|
||
sayK("smpUploading", `${k + 1} ${kib(Math.min(data.length, off + 256))} / ${kib(data.length)} KiB`);
|
||
}
|
||
r = parse[CMD.SMP_END](await rq(req.smpEnd(k, hdr), { timeout: 2000, retries: 0 }));
|
||
if (r.rc) throw new Error(`end rc ${r.rc} (${SMP_RC[r.rc] || "?"})`);
|
||
sayK("smpDone", `${k + 1} ${((performance.now() - t0) / 1000).toFixed(1)} s`);
|
||
done = true;
|
||
} catch (e) {
|
||
if (e.message !== "closed") sayK("smpFail", e.message);
|
||
} finally {
|
||
try { if (dev) await smpInfo(); } catch (e) { /* shown by the next action */ }
|
||
smpBusy = false;
|
||
busy--;
|
||
renderSamples();
|
||
renderKits();
|
||
}
|
||
return done;
|
||
}
|
||
|
||
async function smpErase(k) {
|
||
if (!dev || !confirm(t("confirmErase").replace("{n}", k + 1))) return;
|
||
busy++;
|
||
smpBusy = true;
|
||
renderSamples();
|
||
try {
|
||
const r = parse[CMD.SMP_ERASE](await rq(req.smpErase(k), { timeout: 2500, retries: 0 }));
|
||
if (r.rc) throw new Error("erase rc " + r.rc);
|
||
sayK("smpErased", String(k + 1));
|
||
} catch (e) {
|
||
if (e.message !== "closed") sayK("smpFail", e.message);
|
||
} finally {
|
||
try { if (dev) await smpInfo(); } catch (e) { /* ignore */ }
|
||
smpBusy = false;
|
||
busy--;
|
||
renderSamples();
|
||
renderKits();
|
||
}
|
||
}
|
||
|
||
/* ---------------------------------------------------------------- CHOP --- */
|
||
/* Load a recording, mark the chops (live: TAP / space while it plays, each tap moved to the hit it
|
||
meant; or by hits, a tempo grid, equal parts; double-click adds, drag moves, Delete removes),
|
||
audition them (click, keys 1-9 0), keep or leave out each one and set its length (a recording longer
|
||
than a slot: keep the chops you want, shorten them, or Fit to slot), then one chop per key into
|
||
USR1..4 or as WAV files. CH.opt[i] = {off, len} goes with marker i. */
|
||
const CH = { x: null, nov: null, name: "", marks: [], opt: [], sel: -1, v0: 0, v1: 1, ctx: null, src: null, t0: 0, raf: 0,
|
||
drag: -1, dragEnd: false, key0: 60, mode: 0, maxLen: 0, ui: null };
|
||
const chR = () => SMP.RATE;
|
||
const chSecs = (n) => (n / SMP.RATE).toFixed(2) + " s";
|
||
|
||
function chopChops() { return CH.x ? chopList(CH.marks, CH.x.length, Math.round(CH.maxLen * SMP.RATE), CH.opt) : []; }
|
||
function chopUsed() { /* the chops the slot gets, their samples, and each chop's key */
|
||
const c = chopChops(), use = chopPick(c, CH.mode, Math.max(0, CH.sel)), key = new Map();
|
||
if (CH.mode === 0) use.forEach((q, j) => key.set(q.i, Math.min(127, CH.key0 + j)));
|
||
return { all: c, use, n: use.reduce((a, q) => a + (q.end - q.start), 0), key };
|
||
}
|
||
/* the label of chop i: its key, "—" when left out, nothing past the 16 kept ones or over the whole keyboard */
|
||
function chopKeyName(u, i) {
|
||
if (CH.mode === 1) return "";
|
||
const c = u.all[i];
|
||
return c && c.off ? " —" : u.key.has(i) ? " " + noteName(u.key.get(i)) : "";
|
||
}
|
||
function chopOpt(i) { return CH.opt[i] || (CH.opt[i] = { off: false, len: 0 }); }
|
||
function chopKeep(i, keep) { /* keep / leave out chop i (keep undefined: toggle) */
|
||
if (!CH.x || i < 0 || i >= CH.marks.length) return;
|
||
const o = chopOpt(i);
|
||
o.off = keep === undefined ? !o.off : !keep;
|
||
chopRender();
|
||
}
|
||
function chopKeepAll(keep) { if (CH.x) { CH.opt = CH.marks.map((_, i) => ({ ...chopOpt(i), off: !keep })); chopRender(); } }
|
||
function chopSetLen(i, len) { /* the length of chop i in samples (0: up to the next marker) */
|
||
if (!CH.x || i < 0 || i >= CH.marks.length) return;
|
||
chopOpt(i).len = Math.max(0, Math.round(len));
|
||
chopRender();
|
||
}
|
||
function chopFitAll() { /* shorten the longest kept chops so they all fit the slot */
|
||
const { use } = chopUsed(), L = chopFit(use, SMP.MAX_DATA * 2 - use.length); /* (an odd chop takes half a byte more) */
|
||
if (!isFinite(L)) return;
|
||
for (const c of use) if (c.end - c.start > L) chopOpt(c.i).len = L;
|
||
sayK("chopFitted", chSecs(L));
|
||
chopRender();
|
||
}
|
||
|
||
async function chopDecode(buf) { /* any file the browser decodes -> mono Float64 at SMP.RATE */
|
||
try { const w = parseWav(buf); return resample(w.x, w.sr, SMP.RATE); } catch (e) { /* not a plain WAV */ }
|
||
const Ctx = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
||
const ab = await new Ctx(1, 1, SMP.RATE).decodeAudioData(buf.slice(0));
|
||
const x = new Float64Array(ab.length);
|
||
for (let c = 0; c < ab.numberOfChannels; c++) { const d = ab.getChannelData(c); for (let i = 0; i < d.length; i++) x[i] += d[i] / ab.numberOfChannels; }
|
||
return x;
|
||
}
|
||
|
||
async function chopLoad(f) {
|
||
chopStop();
|
||
try {
|
||
const x = await chopDecode(await f.arrayBuffer());
|
||
if (!x.length) throw new Error("no audio");
|
||
CH.x = x;
|
||
CH.nov = chopNovelty(x);
|
||
CH.name = f.name.replace(/\.[^.]*$/, "").toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, 8) || "CHOP";
|
||
CH.marks = [];
|
||
CH.opt = [];
|
||
CH.sel = -1;
|
||
CH.v0 = 0;
|
||
CH.v1 = x.length;
|
||
sayK("chopLoaded", `${f.name} (${chSecs(x.length)})`);
|
||
} catch (e) { sayK("smpDecodeFail", `${f.name} (${e.message})`); }
|
||
chopRender();
|
||
}
|
||
|
||
/* new markers; opt (aligned with m) their options, else each keeps the options of the marker it was */
|
||
function chopSetMarks(m, opt = null) {
|
||
const was = new Map(CH.marks.map((v, i) => [v, CH.opt[i]])), seen = new Set(), pairs = [];
|
||
m.forEach((v, i) => {
|
||
const p = Math.max(0, Math.min(CH.x.length - 1, Math.round(v)));
|
||
if (seen.has(p)) return;
|
||
seen.add(p);
|
||
const o = opt ? opt[i] : was.get(p);
|
||
pairs.push([p, o ? { ...o } : { off: false, len: 0 }]);
|
||
});
|
||
pairs.sort((a, b) => a[0] - b[0]);
|
||
CH.marks = pairs.map((q) => q[0]);
|
||
CH.opt = pairs.map((q) => q[1]);
|
||
if (CH.sel >= CH.marks.length) CH.sel = CH.marks.length - 1;
|
||
chopRender();
|
||
}
|
||
function chopAdd(pos) { /* a new marker; one within 30 ms is moved there instead */
|
||
const near = CH.marks.findIndex((m) => Math.abs(m - pos) < 0.03 * chR());
|
||
const m = CH.marks.slice(), opt = CH.marks.map((_, i) => CH.opt[i]);
|
||
if (near >= 0) m[near] = pos; else { m.push(pos); opt.push(null); }
|
||
chopSetMarks(m, opt);
|
||
CH.sel = CH.marks.indexOf(Math.round(pos));
|
||
chopDraw();
|
||
}
|
||
|
||
/* ---- audio */
|
||
function chopCtx() {
|
||
if (!CH.ctx) CH.ctx = new (window.AudioContext || window.webkitAudioContext)();
|
||
if (CH.ctx.state === "suspended") CH.ctx.resume();
|
||
return CH.ctx;
|
||
}
|
||
function chopBuffer(a, b) {
|
||
const ctx = chopCtx(), n = Math.max(1, b - a), buf = ctx.createBuffer(1, n, SMP.RATE), d = buf.getChannelData(0);
|
||
for (let i = 0; i < n; i++) d[i] = CH.x[a + i];
|
||
return buf;
|
||
}
|
||
function chopStop() {
|
||
if (CH.src) { try { CH.src.stop(); } catch (e) { /* ended */ } CH.src = null; }
|
||
cancelAnimationFrame(CH.raf);
|
||
if (CH.ui) { CH.ui.play.textContent = t("chopPlay"); chopDraw(); }
|
||
}
|
||
/* play a..b; whole = the transport (a playhead, TAP marks), else an audition */
|
||
function chopPlay(a, b, whole) {
|
||
if (!CH.x) return;
|
||
chopStop();
|
||
const ctx = chopCtx(), src = ctx.createBufferSource();
|
||
const g = ctx.createGain();
|
||
src.buffer = chopBuffer(a, b);
|
||
src.connect(g).connect(ctx.destination);
|
||
if (!whole) { /* the fades the slot will have */
|
||
const n = b - a, fo = Math.min(CHOP.FADE_OUT, n >> 2) / SMP.RATE, now = ctx.currentTime + 0.005, end = now + n / SMP.RATE;
|
||
g.gain.setValueAtTime(1, now);
|
||
g.gain.setValueAtTime(1, Math.max(now, end - fo));
|
||
g.gain.linearRampToValueAtTime(0, end);
|
||
}
|
||
CH.t0 = ctx.currentTime + 0.005 - a / SMP.RATE;
|
||
src.start(ctx.currentTime + 0.005);
|
||
src.onended = () => { if (CH.src === src) { CH.src = null; if (whole) chopStop(); } };
|
||
CH.src = src;
|
||
CH.src.whole = whole;
|
||
if (whole) {
|
||
CH.ui.play.textContent = t("chopStop");
|
||
const tick = () => { chopDraw(); if (CH.src === src) CH.raf = requestAnimationFrame(tick); };
|
||
CH.raf = requestAnimationFrame(tick);
|
||
}
|
||
}
|
||
/* where the listener is now, in samples (what comes out of the speakers, not what is computed) */
|
||
function chopHeard(ev) {
|
||
const ctx = CH.ctx;
|
||
let ct = ctx.currentTime - (ctx.outputLatency || ctx.baseLatency || 0);
|
||
if (ev && ctx.getOutputTimestamp) {
|
||
const ts = ctx.getOutputTimestamp();
|
||
if (ts.performanceTime > 0) ct = ts.contextTime + (ev.timeStamp - ts.performanceTime) / 1000;
|
||
}
|
||
return (ct - CH.t0) * SMP.RATE;
|
||
}
|
||
function chopTap(ev) { /* TAP while it plays: a marker on the hit you meant */
|
||
if (!CH.src || !CH.src.whole) return;
|
||
const p = chopHeard(ev);
|
||
if (p < 0 || p >= CH.x.length) return;
|
||
chopAdd(CH.ui.snap.checked ? chopSnap(CH.x, CH.nov, p) : Math.round(p));
|
||
}
|
||
function chopAudition(i) {
|
||
const c = chopChops()[i];
|
||
if (!c) return;
|
||
CH.sel = i;
|
||
chopPlay(c.start, c.end, false);
|
||
chopRender();
|
||
}
|
||
|
||
/* ---- drawing (the page's own two colours) */
|
||
function chopDraw() {
|
||
const u = CH.ui;
|
||
if (!u) return;
|
||
const cv = u.cv, dpr = window.devicePixelRatio || 1, W = Math.max(200, cv.clientWidth), Hh = 150;
|
||
if (cv.width !== Math.round(W * dpr)) { cv.width = Math.round(W * dpr); cv.height = Math.round(Hh * dpr); }
|
||
const g = cv.getContext("2d"), cs = getComputedStyle(document.documentElement);
|
||
const FG = cs.getPropertyValue("--fg").trim(), DIM = cs.getPropertyValue("--dim").trim(), LINE = cs.getPropertyValue("--line").trim();
|
||
g.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||
g.clearRect(0, 0, W, Hh);
|
||
const PIX = '16px "SLOOP Terminus", monospace', TRK = cs.getPropertyValue("--t1").trim() || FG;
|
||
if (!CH.x) { g.fillStyle = DIM; g.font = PIX; g.fillText(t("chopDrop"), 12, Hh / 2 + 4); return; }
|
||
const x = CH.x, v0 = CH.v0, span = CH.v1 - CH.v0, X = (p) => (p - v0) / span * W, mid = Hh / 2 + 6;
|
||
const U = chopUsed(), { all: chops, use } = U;
|
||
const hatch = (a, b) => { /* what the slot does not get */
|
||
g.save(); g.beginPath(); g.rect(a, 12, b - a, Hh - 12); g.clip(); g.strokeStyle = LINE;
|
||
for (let q = Math.floor(a / 8) * 8 - 8; q < b; q += 8) { g.beginPath(); g.moveTo(q, Hh); g.lineTo(q + 8, 12); g.stroke(); }
|
||
g.restore();
|
||
};
|
||
if (chops.length && chops[0].start > 0) hatch(X(0), X(chops[0].start));
|
||
chops.forEach((c, i) => { /* the chops: the selected one filled, left-out parts hatched */
|
||
const a = X(c.start), b = X(c.end), f = X(c.full);
|
||
if (f < 0 || a > W) return;
|
||
if (i === CH.sel) { g.fillStyle = LINE; g.fillRect(a, 12, b - a, Hh - 12); }
|
||
if (!use.includes(c)) hatch(a, f); else if (c.end < c.full) hatch(b, f);
|
||
});
|
||
g.fillStyle = TRK;
|
||
for (let px = 0; px < W; px++) { /* the wave: min / max per pixel */
|
||
const a = Math.floor(v0 + px / W * span), b = Math.min(x.length, Math.max(a + 1, Math.floor(v0 + (px + 1) / W * span)));
|
||
let lo = 0, hi = 0;
|
||
for (let i = a; i < b; i += Math.max(1, (b - a) >> 6)) { if (x[i] < lo) lo = x[i]; if (x[i] > hi) hi = x[i]; }
|
||
g.fillRect(px, mid - hi * (Hh / 2 - 8), 1, Math.max(1, (hi - lo) * (Hh / 2 - 8)));
|
||
}
|
||
g.font = PIX;
|
||
CH.marks.forEach((m, i) => { /* the markers, numbered; the chop's key above */
|
||
const px = X(m);
|
||
if (px < -1 || px > W + 1) return;
|
||
g.fillStyle = FG;
|
||
g.fillRect(Math.round(px), 0, i === CH.sel ? 2 : 1, Hh);
|
||
g.fillText(String(i + 1) + chopKeyName(U, i), px + 3, 12);
|
||
});
|
||
const sc = chops[CH.sel];
|
||
if (sc) { /* the selected chop's end: a handle at the bottom, drag it */
|
||
const px = Math.round(X(sc.end));
|
||
g.fillStyle = FG;
|
||
g.fillRect(px - 1, Hh - 30, 2, 30);
|
||
g.beginPath(); g.moveTo(px, Hh - 30); g.lineTo(px - 7, Hh - 38); g.lineTo(px - 7, Hh - 22); g.closePath(); g.fill();
|
||
}
|
||
if (CH.src && CH.src.whole && CH.ctx) { /* the playhead, as heard */
|
||
const p = X(chopHeard());
|
||
g.fillStyle = DIM;
|
||
g.fillRect(Math.round(p), 12, 1, Hh - 12);
|
||
}
|
||
}
|
||
|
||
/* ---- the block */
|
||
function chopUI() {
|
||
const box = $("chop");
|
||
if (!box || CH.ui) return;
|
||
const u = CH.ui = {};
|
||
const file = el("input", { type: "file", accept: "audio/*,.wav,.mp3,.aif,.aiff,.flac,.ogg,.m4a", hidden: true });
|
||
file.addEventListener("change", () => { if (file.files[0]) chopLoad(file.files[0]); file.value = ""; });
|
||
u.info = el("span", { class: "dim" });
|
||
u.cv = el("canvas", { class: "wave", tabindex: "0", title: t("chopHint") });
|
||
u.play = el("button", { onclick: () => { if (CH.src && CH.src.whole) chopStop(); else if (CH.x) chopPlay(Math.round(CH.v0), CH.x.length, true); } }, t("chopPlay"));
|
||
u.tap = el("button", { class: "tap", onpointerdown: (e) => { e.preventDefault(); chopTap(e); } }, t("chopTap"));
|
||
u.snap = el("input", { type: "checkbox", checked: true });
|
||
u.sens = el("input", { type: "range", min: 1, max: 10, value: 5, title: t("chopSens") });
|
||
u.bpm = el("input", { type: "number", min: 40, max: 240, step: 0.1, value: 90, class: "num" });
|
||
u.div = el("select", {}, ...[["1 bar", 4], ["1/2", 2], ["1/4", 1], ["1/8", 0.5], ["1/16", 0.25]].map(([n, v]) => el("option", { value: v, text: n })));
|
||
u.div.value = "1";
|
||
u.n = el("select", {}, ...[2, 3, 4, 6, 8, 12, 16].map((n) => el("option", { value: n, text: String(n) })));
|
||
u.n.value = "8";
|
||
u.key = el("select", {}, ...Array.from({ length: 49 }, (_, i) => 36 + i).map((n) => el("option", { value: n, text: noteName(n) })));
|
||
u.key.value = String(CH.key0);
|
||
u.mode = el("select", {}, el("option", { value: 0, text: t("chopModeKeys") }), el("option", { value: 1, text: t("chopModeOne") }));
|
||
u.max = el("select", {}, ...[["—", 0], ["0.25 s", 0.25], ["0.5 s", 0.5], ["1 s", 1], ["2 s", 2]].map(([n, v]) => el("option", { value: v, text: n })));
|
||
u.meter = el("progress", { max: SMP.MAX_DATA * 2, value: 0 });
|
||
u.room = el("span", { class: "dim" });
|
||
u.list = el("div", { class: "chops" });
|
||
/* the selected chop: keep it or not, its length; and all of them at once */
|
||
u.selName = el("b", { class: "selname" });
|
||
u.keep = el("input", { type: "checkbox", onchange: () => chopKeep(CH.sel, u.keep.checked) });
|
||
u.len = el("input", { type: "range", class: "len", min: 10, max: 1000, step: 1, title: t("chopLen"),
|
||
oninput: () => { const c = chopChops()[CH.sel]; if (c) { const ms = +u.len.value, full = c.full - c.start; chopSetLen(CH.sel, ms >= Math.floor(full / SMP.RATE * 1000) ? 0 : ms * SMP.RATE / 1000); } } });
|
||
u.lenTxt = el("span", { class: "dim" });
|
||
u.selPlay = el("button", { onclick: () => chopAudition(CH.sel) }, "▶");
|
||
u.full = el("button", { onclick: () => chopSetLen(CH.sel, 0) }, t("chopFull"));
|
||
u.selRow = el("div", { class: "head selrow" }, u.selName, el("label", {}, u.keep, " " + t("chopKeep")),
|
||
el("span", { text: t("chopLen") }), u.len, u.lenTxt, u.selPlay, u.full);
|
||
u.fit = el("button", { onclick: chopFitAll }, t("chopFit"));
|
||
u.send = [0, 1, 2, 3].map((k) => el("button", { ic: "symbol_upload", onclick: () => chopSend(k) }, `USR${k + 1}`));
|
||
const region = () => { /* first..last marker when there are two, else all */
|
||
const m = CH.marks;
|
||
return m.length >= 2 ? [m[0], m[m.length - 1]] : [m[0] || 0, CH.x.length];
|
||
};
|
||
u.key.addEventListener("change", () => { CH.key0 = +u.key.value; chopRender(); });
|
||
u.mode.addEventListener("change", () => { CH.mode = +u.mode.value; chopRender(); });
|
||
u.max.addEventListener("change", () => { CH.maxLen = +u.max.value; chopRender(); });
|
||
box.append(
|
||
el("div", { class: "head" }, el("b", { text: "CHOP" }),
|
||
el("button", { ic: "symbol_folder_open", onclick: () => file.click() }, t("chopOpen")), file, u.info),
|
||
u.cv,
|
||
el("div", { class: "head" }, u.play, u.tap, el("label", {}, u.snap, " " + t("chopSnap")),
|
||
el("button", { onclick: () => { if (CH.x) chopSetMarks([]); } }, t("chopClear")),
|
||
el("span", { class: "dim", text: t("chopHint") })),
|
||
el("div", { class: "head" },
|
||
el("button", { onclick: () => { if (CH.x) chopSetMarks(chopHits(CH.x, CH.nov, +u.sens.value)); } }, t("chopHits")), u.sens,
|
||
el("span", { class: "sep" }),
|
||
el("button", { onclick: () => { if (CH.x) { const [a, b] = region(); chopSetMarks(chopGrid(a, b, Math.max(40, +u.bpm.value || 90), +u.div.value)); } } }, t("chopGrid")),
|
||
u.bpm, el("span", { text: "BPM" }), u.div,
|
||
el("span", { class: "sep" }),
|
||
el("button", { onclick: () => { if (CH.x) { const [a, b] = region(); chopSetMarks(chopEqual(a, b, +u.n.value)); } } }, t("chopEqual")), u.n),
|
||
el("div", { class: "head" }, el("span", { text: t("chopKey") }), u.key, u.mode,
|
||
el("span", { text: t("chopMax") }), u.max, u.meter, u.room),
|
||
el("div", { class: "head" }, el("button", { onclick: () => chopKeepAll(true) }, t("chopAll")),
|
||
el("button", { onclick: () => chopKeepAll(false) }, t("chopNone")), u.fit,
|
||
el("span", { class: "dim", text: t("chopKeepHint") })),
|
||
u.list, u.selRow,
|
||
el("div", { class: "head" }, el("button", { ic: "symbol_download", onclick: chopZip }, t("chopZip")),
|
||
el("span", { class: "dim", text: t("chopSendBelow") }))); /* (sending: step 3 of the page) */
|
||
/* the wave: click = select + listen, double-click = a marker, drag a marker, wheel = zoom */
|
||
const posAt = (e) => { const r = u.cv.getBoundingClientRect(); return CH.v0 + (e.clientX - r.left) / r.width * (CH.v1 - CH.v0); };
|
||
const markAt = (e) => {
|
||
const r = u.cv.getBoundingClientRect(), per = (CH.v1 - CH.v0) / r.width;
|
||
return CH.marks.findIndex((m) => Math.abs(m - posAt(e)) < 5 * per);
|
||
};
|
||
const endAt = (e) => { /* on the selected chop's end handle (the bottom of the wave)? */
|
||
const c = chopChops()[CH.sel];
|
||
if (!c) return false;
|
||
const r = u.cv.getBoundingClientRect(), per = (CH.v1 - CH.v0) / r.width;
|
||
return e.clientY - r.top > r.height - 40 && Math.abs(c.end - posAt(e)) < 7 * per;
|
||
};
|
||
u.cv.addEventListener("pointerdown", (e) => {
|
||
if (!CH.x) { file.click(); return; }
|
||
u.cv.focus();
|
||
if (endAt(e)) { CH.dragEnd = true; u.cv.setPointerCapture(e.pointerId); return; }
|
||
const k = markAt(e);
|
||
if (k >= 0) { CH.drag = k; CH.sel = k; u.cv.setPointerCapture(e.pointerId); chopDraw(); return; }
|
||
const p = posAt(e), i = chopChops().findIndex((c) => p >= c.start && p < c.end);
|
||
if (i >= 0) chopAudition(i);
|
||
});
|
||
u.cv.addEventListener("pointermove", (e) => {
|
||
if (CH.dragEnd) { /* the selected chop's length; up to the next marker = full */
|
||
const c = chopChops()[CH.sel];
|
||
if (!c) return;
|
||
const n = Math.round(Math.max(0.01 * SMP.RATE, Math.min(c.full - c.start, posAt(e) - c.start)));
|
||
chopOpt(CH.sel).len = n >= c.full - c.start ? 0 : n;
|
||
chopDraw();
|
||
return;
|
||
}
|
||
if (CH.drag < 0) { u.cv.style.cursor = CH.x && (markAt(e) >= 0 || endAt(e)) ? "ew-resize" : "default"; return; }
|
||
const m = CH.marks, k = CH.drag, lo = k ? m[k - 1] + 1 : 0, hi = k + 1 < m.length ? m[k + 1] - 1 : CH.x.length - 1;
|
||
m[k] = Math.round(Math.max(lo, Math.min(hi, posAt(e))));
|
||
chopDraw();
|
||
});
|
||
u.cv.addEventListener("pointerup", () => {
|
||
if (CH.dragEnd) { CH.dragEnd = false; chopRender(); }
|
||
if (CH.drag >= 0) { CH.drag = -1; chopRender(); }
|
||
});
|
||
u.cv.addEventListener("dblclick", (e) => { if (CH.x) chopAdd(u.snap.checked ? chopSnap(CH.x, CH.nov, posAt(e), 0.02) : Math.round(posAt(e))); });
|
||
u.cv.addEventListener("wheel", (e) => {
|
||
if (!CH.x) return;
|
||
e.preventDefault();
|
||
const n = CH.x.length, span = CH.v1 - CH.v0;
|
||
if (e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY)) {
|
||
const d = (e.deltaX || e.deltaY) / 400 * span, v0 = Math.max(0, Math.min(n - span, CH.v0 + d));
|
||
CH.v0 = v0; CH.v1 = v0 + span;
|
||
} else {
|
||
const p = posAt(e), z = Math.exp(e.deltaY / 300), ns = Math.max(SMP.RATE * 0.05, Math.min(n, span * z));
|
||
CH.v0 = Math.max(0, Math.min(n - ns, p - (p - CH.v0) / span * ns));
|
||
CH.v1 = CH.v0 + ns;
|
||
}
|
||
chopDraw();
|
||
}, { passive: false });
|
||
u.cv.addEventListener("keydown", (e) => {
|
||
if (!CH.x) return;
|
||
const k = e.key;
|
||
if (k === " ") { e.preventDefault(); if (CH.src && CH.src.whole) chopTap(e); else chopPlay(Math.round(CH.v0), CH.x.length, true); }
|
||
else if (k === "Enter" || k === "Escape") { e.preventDefault(); if (CH.src) chopStop(); else chopPlay(Math.round(CH.v0), CH.x.length, true); }
|
||
else if (/^[0-9]$/.test(k)) { e.preventDefault(); chopAudition(k === "0" ? 9 : +k - 1); }
|
||
else if ((k === "Delete" || k === "Backspace") && CH.sel >= 0) {
|
||
e.preventDefault();
|
||
chopSetMarks(CH.marks.filter((_, i) => i !== CH.sel), CH.marks.map((_, i) => CH.opt[i]).filter((_, i) => i !== CH.sel));
|
||
}
|
||
else if ((k === "k" || k === "K") && CH.sel >= 0) { e.preventDefault(); chopKeep(CH.sel); }
|
||
else if ((k === "ArrowLeft" || k === "ArrowRight") && CH.sel >= 0) { /* nudge the selected marker: 2 ms, shift 20 ms */
|
||
e.preventDefault();
|
||
const m = CH.marks.slice();
|
||
m[CH.sel] += (k === "ArrowLeft" ? -1 : 1) * Math.round((e.shiftKey ? 0.02 : 0.002) * SMP.RATE);
|
||
const keep = CH.sel;
|
||
chopSetMarks(m, CH.marks.map((_, i) => CH.opt[i]));
|
||
CH.sel = keep;
|
||
chopRender();
|
||
}
|
||
});
|
||
box.addEventListener("dragover", (e) => { e.preventDefault(); box.classList.add("over"); });
|
||
box.addEventListener("dragleave", () => box.classList.remove("over"));
|
||
box.addEventListener("drop", (e) => { e.preventDefault(); box.classList.remove("over"); if (e.dataTransfer.files[0]) chopLoad(e.dataTransfer.files[0]); });
|
||
window.addEventListener("resize", () => chopDraw());
|
||
chopRender();
|
||
}
|
||
|
||
function chopRender() {
|
||
const u = CH.ui;
|
||
if (!u) return;
|
||
const U = chopUsed(), { all, use, n } = U, room = SMP.MAX_DATA * 2, over = use.reduce((a, q) => a + ((q.end - q.start + 1) >> 1), 0) > SMP.MAX_DATA;
|
||
const kept = all.filter((c) => !c.off).length;
|
||
u.info.textContent = CH.x ? `${CH.name} · ${chSecs(CH.x.length)} · ${all.length} ${t("chopChops")}` +
|
||
(kept < all.length ? ` (${kept} ${t("chopKept")})` : "") : t("chopHelp");
|
||
u.meter.value = Math.min(room, n);
|
||
u.room.textContent = `${chSecs(n)} / ${chSecs(room)}` + (over ? " " + t("chopTooLong") + " " + t("chopOverHint") : "") +
|
||
(CH.mode === 0 && kept > CHOP.MAX ? " " + t("chopTooMany") : "");
|
||
u.room.className = over ? "bad" : "dim";
|
||
u.fit.disabled = !over;
|
||
u.send.forEach((b, k) => { b.disabled = !use.length || over || smpBusy || !dev || !dev.smp || k >= dev.smp.nslots; });
|
||
u.list.replaceChildren(...all.map((c, i) => { /* a chip per chop: the box keeps it, the rest listens */
|
||
const box = el("input", { type: "checkbox", title: t("chopKeep"), onclick: (e) => { e.stopPropagation(); chopKeep(i, box.checked); } });
|
||
box.checked = !c.off;
|
||
return el("span", {
|
||
class: "chip" + (i === CH.sel ? " on" : "") + (use.includes(c) ? "" : " off"),
|
||
title: `${chSecs(c.start)} · ${chSecs(c.end - c.start)}` + (c.end < c.full ? ` / ${chSecs(c.full - c.start)}` : ""),
|
||
onclick: () => chopAudition(i),
|
||
}, box, `${i + 1}` + chopKeyName(U, i));
|
||
}));
|
||
const c = all[CH.sel]; /* the selected chop's row */
|
||
u.selRow.hidden = !c;
|
||
if (c) {
|
||
const full = c.full - c.start;
|
||
u.selName.textContent = `${t("chopSel")} ${CH.sel + 1}${chopKeyName(U, CH.sel)}`;
|
||
u.keep.checked = !c.off;
|
||
u.len.max = String(Math.max(10, Math.floor(full / SMP.RATE * 1000)));
|
||
u.len.value = String(Math.round((c.end - c.start) / SMP.RATE * 1000));
|
||
u.lenTxt.textContent = `${chSecs(c.end - c.start)} / ${chSecs(full)}`;
|
||
u.full.disabled = c.end >= c.full;
|
||
}
|
||
chopDraw();
|
||
if (smpPage.ui && smpPage.mode === "chop" && document.activeElement !== smpPage.ui.name) smpPage.ui.name.value = CH.name || "";
|
||
smpButtons();
|
||
}
|
||
|
||
/* the chops into slot k's list (it shows below), then the usual upload */
|
||
async function chopSend(k, prog) {
|
||
if (!CH.x || smpBusy) return;
|
||
const { use } = chopUsed();
|
||
if (!use.length) return;
|
||
const zones = chopZones(CH.x, chopChops(), CH.key0, CH.mode, Math.max(0, CH.sel)); /* (the kept ones) */
|
||
if (await smpUpload(k, prog, true, { name: CH.name || "CHOP", files: zones })) sayK("chopSent", `USR${k + 1}: ${zones.length} ${t("chopChops")}, ${noteName(zones[0].lo === 0 ? zones[0].root : zones[0].lo)}…`);
|
||
}
|
||
|
||
function chopZip() {
|
||
if (!CH.x) return;
|
||
const zones = chopZones(CH.x, chopChops(), CH.key0, CH.mode, Math.max(0, CH.sel));
|
||
if (!zones.length) return;
|
||
const blob = new Blob([zipStore(zones.map((z) => ({ name: `${CH.name}/${z.fname}`, data: wavFile(z.s) })))], { type: "application/zip" });
|
||
const a = el("a", { href: URL.createObjectURL(blob), download: `${CH.name}-chops.zip` });
|
||
document.body.append(a);
|
||
a.click();
|
||
a.remove();
|
||
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
||
}
|
||
|
||
/* ---------------------------------------------------------- mixer (v3) --- */
|
||
/* dev.mix = TRACK reply + pan per track ({sel, ntrk, tracks: [{engine, preset, level, mute, armed, pan}]}).
|
||
Read on connect, after every RELOAD / sound change, with the slow safety DUMP and when the tab opens.
|
||
The selected track's level / pan / mute are also Sound parameters: both views follow each other. */
|
||
let mixDrag = null; /* "lv:i" / "pan:i" while a strip control is dragged */
|
||
const mixEdit = new Map(); /* "lv:i" / "pan:i" -> time of the user's last change */
|
||
const mixCtl = []; /* per track: the strip's elements */
|
||
let panning = false; /* v3 firmware: another track is selected for a moment (pan of a track that is not selected) */
|
||
const mixTouched = (kind, i) => mixDrag === `${kind}:${i}` || performance.now() - (mixEdit.get(`${kind}:${i}`) || 0) < 600
|
||
|| (!!dev && kind === "lv" && dev.link.hasQueued("mix:" + i))
|
||
|| (kind === "pan" && (panWant.has(i) || (!!dev && dev.link.hasQueued("pan:" + i))));
|
||
const drumTrack = (i) => !!dev && !!dev.mix && i === dev.mix.ntrk - 1;
|
||
function trackName(x) {
|
||
if (x.engine >= dev.info.nengines) return ["DRUMS", (dev.kitNames || [])[x.e0]].filter(Boolean).join(" ");
|
||
return [dev.info.engines[x.engine], (dev.names[x.engine] || [])[x.preset]].filter(Boolean).join(" ");
|
||
}
|
||
|
||
async function readMixer() {
|
||
const d = dev;
|
||
if (!d || !hasTracks()) return;
|
||
const m = await mixer.read(rq, d.info, { pan: pPan() });
|
||
if (d !== dev) return;
|
||
if (d.mix) m.tracks.forEach((x, i) => { /* what the user is moving stays */
|
||
const o = d.mix.tracks[i];
|
||
if (!o) return;
|
||
if (mixTouched("lv", i)) { x.level = o.level; x.mute = o.mute; }
|
||
if (mixTouched("pan", i)) x.pan = o.pan;
|
||
});
|
||
d.mix = m;
|
||
if (m.sel !== d.sel && !panning) { d.sel = m.sel; needReload = true; } /* selected on the device, push missed */
|
||
renderMixer();
|
||
}
|
||
|
||
/* the Sound view's values of the selected track (and the drum level, a global) -> the strips */
|
||
function mixFromDump() {
|
||
if (!dev || !dev.mix || !dev.dump || panning) return;
|
||
const m = dev.mix, ds = m.ntrk - 1, x = m.tracks[dev.sel];
|
||
if (!mixTouched("lv", ds)) m.tracks[ds].level = dev.dump.g[gDrLvl()];
|
||
if (x) {
|
||
if (!mixTouched("lv", dev.sel)) {
|
||
if (dev.sel !== ds) x.level = dev.dump.p[P.LEVEL];
|
||
x.mute = dev.dump.p[pMute()] ? 1 : 0;
|
||
}
|
||
if (!mixTouched("pan", dev.sel)) x.pan = dev.dump.p[pPan()];
|
||
}
|
||
if (mixCtl.length === m.ntrk) m.tracks.forEach((_, i) => updateStrip(i));
|
||
}
|
||
/* a strip's values -> the Sound view (selected track; the drum level always) */
|
||
function mixToSound(i) {
|
||
const x = dev.mix.tracks[i];
|
||
const put = (s, id, v) => { if (v == null) return; (s ? dev.dump.g : dev.dump.p)[id] = v; showValue(key(s, id), v, false); };
|
||
if (drumTrack(i)) put(1, gDrLvl(), x.level);
|
||
if (i !== dev.sel) return;
|
||
if (!drumTrack(i)) put(0, P.LEVEL, x.level);
|
||
put(0, pMute(), x.mute ? 1 : 0);
|
||
put(0, pPan(), x.pan);
|
||
}
|
||
|
||
function renderMixer() {
|
||
const box = $("mixer");
|
||
if (!dev || !dev.mix) { box.replaceChildren(); mixCtl.length = 0; return; }
|
||
const m = dev.mix;
|
||
if (mixCtl.length !== m.ntrk || box.dataset.lang !== lang) {
|
||
box.dataset.lang = lang;
|
||
mixCtl.length = 0;
|
||
box.replaceChildren(...m.tracks.map((_, i) => buildStrip(i)));
|
||
}
|
||
m.tracks.forEach((_, i) => updateStrip(i));
|
||
renderTrackbar();
|
||
}
|
||
function buildStrip(i) {
|
||
const drum = drumTrack(i);
|
||
const lvDesc = (drum ? dev.gdesc[gDrLvl()] : dev.pdesc[P.LEVEL]) || { fmt: F.INT, min: 0, max: 127, def: 100 };
|
||
const pDesc = dev.pdesc[pPan()] || { fmt: F.BIPCT, min: -64, max: 63, def: 0 };
|
||
const fader = el("input", { type: "range", class: "fader", min: 0, max: 127, step: 1, "aria-label": `${t("level")} ${i + 1}` });
|
||
fader.addEventListener("pointerdown", () => { mixDrag = "lv:" + i; });
|
||
fader.addEventListener("input", () => setLevel(i, +fader.value));
|
||
fader.addEventListener("change", () => setLevel(i, +fader.value));
|
||
fader.addEventListener("dblclick", () => setLevel(i, Math.max(0, Math.min(127, lvDesc.def))));
|
||
const pan = el("input", { type: "range", class: "pan", min: pDesc.min, max: pDesc.max, step: 1, "aria-label": `${t("pan")} ${i + 1}` });
|
||
pan.addEventListener("pointerdown", () => { mixDrag = "pan:" + i; });
|
||
pan.addEventListener("input", () => setPan(i, +pan.value, false));
|
||
pan.addEventListener("change", () => setPan(i, +pan.value, true));
|
||
pan.addEventListener("dblclick", () => setPan(i, pDesc.def, true));
|
||
const c = {
|
||
lvDesc, pDesc, fader, pan,
|
||
num: el("button", { type: "button", class: "tog num", title: t("selectTrack"), onclick: () => selectTrack(i) }, String(i + 1)),
|
||
snd: el("div", { class: "snd" }),
|
||
rec: el("span", { class: "rec", ic: "control_rec_f", title: t("rec") }, t("rec")),
|
||
solo: el("span", { class: "solo", text: t("solo") }),
|
||
lvOut: el("span", { class: "v lv" }),
|
||
mute: el("button", { type: "button", class: "tog", ic: "control_speaker_mute", onclick: () => setMute(i, !dev.mix.tracks[i].mute) }, t("mute")),
|
||
panOut: el("span", { class: "v" }),
|
||
selb: el("button", { type: "button", class: "selb", onclick: () => selectTrack(i) }),
|
||
};
|
||
c.strip = el("div", { class: "strip", role: "group", style: `--c:${TCOL[i % 4]}`, "aria-label": `${t("track")} ${i + 1}` },
|
||
c.num, c.snd, c.rec, c.solo, fader, c.lvOut, c.mute, el("span", { class: "v dim", ic: "symbol_pan" }, t("pan")), pan, c.panOut, c.selb);
|
||
mixCtl[i] = c;
|
||
return c.strip;
|
||
}
|
||
function updateStrip(i) {
|
||
const c = mixCtl[i], x = dev && dev.mix && dev.mix.tracks[i];
|
||
if (!c || !x) return;
|
||
const sel = i === dev.sel;
|
||
c.strip.classList.toggle("sel", sel);
|
||
c.num.setAttribute("aria-pressed", sel ? "true" : "false");
|
||
const nm = trackName(x);
|
||
c.snd.textContent = nm;
|
||
c.snd.title = nm;
|
||
if (!mixTouched("lv", i)) c.fader.value = String(x.level);
|
||
c.fader.style.setProperty("--p", (+c.fader.value / 127 * 100).toFixed(1) + "%");
|
||
const [lt, lu] = fmtValue(c.lvDesc, x.level);
|
||
c.lvOut.textContent = lu ? `${lt} ${lu}` : lt;
|
||
c.mute.setAttribute("aria-pressed", x.mute ? "true" : "false");
|
||
c.strip.classList.toggle("muted", !!x.mute || !x.level);
|
||
c.pan.disabled = x.pan == null;
|
||
if (x.pan != null) {
|
||
if (!mixTouched("pan", i)) c.pan.value = String(x.pan);
|
||
barFill(c.pan);
|
||
const [pt, pu] = fmtValue(c.pDesc, x.pan);
|
||
c.panOut.textContent = pu ? `${pt} ${pu}` : pt;
|
||
}
|
||
c.rec.classList.toggle("on", !!x.armed);
|
||
c.solo.classList.toggle("on", !!((dev.mix.solo >> i) & 1)); /* v5: soloed on the device (GLO + key) */
|
||
c.selb.disabled = sel;
|
||
c.selb.textContent = t(sel ? "selectedTrack" : "selectTrack");
|
||
}
|
||
window.addEventListener("pointerup", () => { mixDrag = null; });
|
||
window.addEventListener("pointercancel", () => { mixDrag = null; });
|
||
|
||
/* level and mute: TRACK_MIX, one in flight per track and one queued with the latest values (as SET) */
|
||
function setLevel(i, v) {
|
||
if (!dev || !dev.mix) return;
|
||
dev.mix.tracks[i].level = v;
|
||
mixEdit.set("lv:" + i, performance.now());
|
||
updateStrip(i);
|
||
mixToSound(i);
|
||
sendMix(i);
|
||
}
|
||
function setMute(i, on) {
|
||
if (!dev || !dev.mix) return;
|
||
dev.mix.tracks[i].mute = on ? 1 : 0;
|
||
mixEdit.set("lv:" + i, performance.now());
|
||
updateStrip(i);
|
||
mixToSound(i);
|
||
sendMix(i);
|
||
}
|
||
async function sendMix(i) {
|
||
const d = dev, x = d.mix.tracks[i];
|
||
try {
|
||
const r = await mixer.setMix(rq, i, x.level, x.mute, { key: "mix:" + i });
|
||
if (d !== dev || !d.mix || mixDrag === "lv:" + i || d.link.hasQueued("mix:" + i)) return;
|
||
const y = d.mix.tracks[i]; /* the device's values after clamping */
|
||
y.level = r.level; y.mute = r.mute;
|
||
updateStrip(i);
|
||
mixToSound(i);
|
||
} catch (e) { report(e); }
|
||
}
|
||
/* pan: the selected track as any Sound parameter; another track with TRACK_PARAM (v4: while dragging, one in
|
||
flight and one queued with the latest value), or with v3 firmware on release (it is selected for a moment) */
|
||
const panWant = new Map();
|
||
function setPan(i, v, final) {
|
||
if (!dev || !dev.mix) return;
|
||
dev.mix.tracks[i].pan = v;
|
||
mixEdit.set("pan:" + i, performance.now());
|
||
updateStrip(i);
|
||
if (i === dev.sel) { userSet(0, pPan(), v, final); return; }
|
||
if (dev.v4) panTrack(i, v);
|
||
else if (final) panOther(i, v);
|
||
}
|
||
async function panTrack(i, v) {
|
||
const d = dev;
|
||
try {
|
||
const r = await mixer.setPan(rq, i, d.sel, pPan(), v, true);
|
||
if (d !== dev || !d.mix || mixDrag === "pan:" + i || d.link.hasQueued("pan:" + i)) return;
|
||
d.mix.tracks[i].pan = r; /* the device's value after clamping */
|
||
updateStrip(i);
|
||
if (i === d.sel) mixToSound(i);
|
||
} catch (e) { report(e); }
|
||
}
|
||
async function panOther(i, v) {
|
||
panWant.set(i, v);
|
||
if (panOther.run) return;
|
||
panOther.run = true;
|
||
const d = dev;
|
||
try {
|
||
while (busy && d === dev) await sleep(20); /* not in the middle of another multi-request operation */
|
||
busy++;
|
||
panning = true;
|
||
try {
|
||
while (panWant.size && d === dev) {
|
||
const [tr, val] = panWant.entries().next().value;
|
||
panWant.delete(tr);
|
||
const r = await mixer.setPan(rq, tr, d.sel, pPan(), val);
|
||
if (d.mix && !panWant.has(tr)) { d.mix.tracks[tr].pan = r; updateStrip(tr); }
|
||
}
|
||
} finally { panning = false; busy--; }
|
||
} catch (e) { report(e); } finally { panOther.run = false; panWant.clear(); }
|
||
}
|
||
|
||
/* ------------------------------------------------- live sync / polling --- */
|
||
/* With WATCH (protocol v2) the device pushes CHANGED / RELOAD / STEP_CHANGED; the editor PINGs about
|
||
once a second so the watch stays on (it ends 3 s after the last request), and DUMPs every 5 s as a
|
||
safety net. Older firmware: DUMP every 400 ms and two steps per round. */
|
||
function onPush(f) {
|
||
const d = dev;
|
||
if (!d || !d.dump || !d.info) return;
|
||
if (tab === "live") livePush(f); /* (2.7) the LIVE page follows the FM-1 too */
|
||
try {
|
||
if (f.cmd === CMD.CHANGED) {
|
||
const c = parse[CMD.CHANGED](f.a);
|
||
if (panning && !c.scope) return; /* about the track selected for a moment, not ours */
|
||
const arr = c.scope ? d.dump.g : d.dump.p;
|
||
if (c.id >= arr.length) return;
|
||
const k = key(c.scope, c.id);
|
||
if (touched(k)) return; /* the user's value wins; their SET follows */
|
||
const old = arr[c.id];
|
||
arr[c.id] = c.value;
|
||
showValue(k, c.value, false);
|
||
blink(k);
|
||
mixFromDump();
|
||
if (!c.scope && c.id === pSlen() && old !== c.value) { $("steptables").dataset.len = ""; renderSteps(); }
|
||
if (!c.scope && c.id === d.info.pe0 && drumGrid() && d.dstepsOk) renderDrumBar(); /* the kit, changed on the device */
|
||
if (!c.scope && c.id === d.info.pe0 + 7 && fm6On()) fm6Later(); /* PTCH turned on the device: another patch */
|
||
} else if (f.cmd === CMD.RELOAD) {
|
||
d.sel = parse[CMD.RELOAD](f.a).track; /* v3: another track may be selected on the device */
|
||
if (selfReload.n > 0 && Date.now() < selfReload.until) { selfReload.n--; return; }
|
||
needReload = true;
|
||
maybeReload();
|
||
} else if (f.cmd === CMD.STEP_CHANGED) {
|
||
const { index } = parse[CMD.STEP_CHANGED](f.a);
|
||
if (index < d.info.nstep) refreshStep(index);
|
||
} else if (f.cmd === CMD.TRACK_CHANGED) { /* v4: level / pan / mute of a track that is not selected */
|
||
const c = parse[CMD.TRACK_CHANGED](f.a), x = d.mix && d.mix.tracks[c.track];
|
||
if (!x || c.track === d.sel) return;
|
||
if (c.id === pPan()) { if (!mixTouched("pan", c.track)) x.pan = c.value; }
|
||
else if (c.id === pMute()) { if (!mixTouched("lv", c.track)) x.mute = c.value ? 1 : 0; }
|
||
else if (c.id === P.LEVEL && !drumTrack(c.track)) { if (!mixTouched("lv", c.track)) x.level = c.value; }
|
||
else return;
|
||
updateStrip(c.track);
|
||
}
|
||
} catch (e) { console.warn("bad push", f, e); }
|
||
}
|
||
function blink(k) {
|
||
const c = ctl.get(k);
|
||
if (!c || !c.row) return;
|
||
c.row.classList.add("pushed");
|
||
clearTimeout(c.blink);
|
||
c.blink = setTimeout(() => c.row.classList.remove("pushed"), 400);
|
||
}
|
||
async function refreshStep(i) {
|
||
const d = dev;
|
||
if (hasLocks()) refreshLocks();
|
||
try {
|
||
if (drumGrid() && d.dstepsOk) {
|
||
const r = parse[CMD.DRUM_STEP](await rq(req.drumStep(i), { key: "dstep:" + i }));
|
||
if (d !== dev || r.index !== i || !drumGrid()) return;
|
||
d.dsteps[i] = r;
|
||
d.steps[i] = drumAsStep(r);
|
||
renderDrums();
|
||
return;
|
||
}
|
||
const s = parse[CMD.STEP_GET](await rq(req.stepGet(i), { key: "step:" + i }));
|
||
if (d !== dev || s.index !== i) return;
|
||
d.steps[i] = s;
|
||
updateStepRows();
|
||
} catch (err) { report(err); }
|
||
}
|
||
function maybeReload() {
|
||
if (!dev || busy || !needReload || !dev.dump || tab === "live") return; /* (LIVE: when another page shows) */
|
||
op(() => afterSoundChange("reloaded"));
|
||
}
|
||
/* one multi-request operation; polling waits for it */
|
||
async function op(fn) {
|
||
if (!dev) return;
|
||
busy++;
|
||
try { await fn(); } catch (err) { report(err); } finally { busy--; }
|
||
}
|
||
function renderLive() {
|
||
$("live").textContent = !dev || !dev.dump ? "" : t(dev.watch ? "live" : "polling");
|
||
$("led").className = "led" + (dev && dev.dump ? " on" : dev ? " busy" : "");
|
||
renderPreview();
|
||
}
|
||
|
||
/* keep-alive: PING when nothing else went out for ~1 s; after a longer gap (hidden tab, a long flash
|
||
write: Link.onGap) the watch may have ended: WATCH again and re-read what may have been missed */
|
||
let rewatch = false;
|
||
async function keepAlive() {
|
||
const d = dev;
|
||
if (!d || !d.watch || !d.dump || document.hidden) return;
|
||
const gap = Date.now() - d.link.lastSent;
|
||
if (rewatch || gap > 2500) {
|
||
if (keepAlive.run) return;
|
||
keepAlive.run = true;
|
||
try {
|
||
const on = await startWatch((r, o) => d.link.request(r, o));
|
||
rewatch = false; /* (this WATCH itself may have flagged the gap) */
|
||
if (on) { d.v4 = on === 3; needReload = true; maybeReload(); }
|
||
else if (d === dev) { d.watch = false; renderLive(); }
|
||
} catch (e) { /* closed */ } finally { keepAlive.run = false; }
|
||
} else if (gap > 850 && d.link.idle) {
|
||
d.link.request(req.ping(), { key: "ping", quiet: true, retries: 0 }).catch(() => {});
|
||
}
|
||
}
|
||
setInterval(keepAlive, 1000);
|
||
document.addEventListener("visibilitychange", () => { if (!document.hidden && dev && dev.watch) { rewatch = true; keepAlive(); } });
|
||
|
||
let stepRR = 0;
|
||
setInterval(async () => {
|
||
if (!dev || busy || dragging || document.hidden || !dev.dump || !dev.link.idle) return;
|
||
if (needReload) { maybeReload(); return; }
|
||
if (dev.watch && Date.now() - lastDump < 5000) return;
|
||
busy++;
|
||
const d = dev;
|
||
try {
|
||
const dump = await getDump();
|
||
if (d !== dev) return;
|
||
const soundChanged = dump.engine !== d.dump.engine || dump.preset !== d.dump.preset;
|
||
const engineChanged = dump.engine !== d.dump.engine;
|
||
const oldLen = d.dump.p[pSlen()];
|
||
for (const [k, c] of ctl) {
|
||
const v = c.scope ? dump.g[c.id] : dump.p[c.id];
|
||
if (touched(k)) { (c.scope ? dump.g : dump.p)[c.id] = c.scope ? d.dump.g[c.id] : d.dump.p[c.id]; continue; }
|
||
showValue(k, v, false);
|
||
}
|
||
d.dump = dump;
|
||
if (engineChanged) await rereadEngineDesc();
|
||
if (hasTracks()) await readMixer(); /* the strips (other tracks push nothing) */
|
||
if (soundChanged) { updateBrowser(); await loadSteps(); sayK("ready"); return; }
|
||
if (dump.p[pSlen()] !== oldLen) { $("steptables").dataset.len = ""; renderSteps(); }
|
||
if (d.watch) return; /* steps come as STEP_CHANGED */
|
||
/* steps are not in DUMP: follow them two at a time */
|
||
const len = Math.max(1, Math.min(d.info.nstep, dump.p[pSlen()] || 16));
|
||
for (let n = 0; n < 2; n++) {
|
||
stepRR = (stepRR + 1) % len;
|
||
if (performance.now() - (stepEdit.get(stepRR) || 0) < 1500) continue;
|
||
if (drumGrid() && d.dstepsOk) {
|
||
const r = await getDrumStep(stepRR), o = d.dsteps[stepRR];
|
||
d.dsteps[stepRR] = r;
|
||
d.steps[stepRR] = drumAsStep(r);
|
||
if (JSON.stringify(o) !== JSON.stringify(r)) renderDrums();
|
||
continue;
|
||
}
|
||
const s = await getStep(stepRR);
|
||
const o = d.steps[stepRR];
|
||
d.steps[stepRR] = s;
|
||
if (JSON.stringify(o) !== JSON.stringify(s)) updateStepRows();
|
||
}
|
||
} catch (err) { report(err); } finally { busy--; }
|
||
}, 400);
|
||
|
||
/* ------------------------------------------------------------ files --- */
|
||
$("savefile").addEventListener("click", () => {
|
||
if (!dev) return;
|
||
const engine = dev.dump.engine, preset = dev.dump.preset;
|
||
const data = { format: "felucca-patch", version: 1, firmware: dev.info.version,
|
||
pCount: dev.info.pcount, pE0: dev.info.pe0, /* (2.6: read by count on another version, patchByCount) */
|
||
engineName: dev.info.engines[engine], presetName: (dev.names[engine] || [])[preset],
|
||
engine, preset, p: dev.dump.p.slice(), g: dev.dump.g.slice(),
|
||
steps: dev.steps.map((s) => ({ n: s.n, notes: s.notes.slice(), time: s.time, flags: s.flags, vel: s.vel })) };
|
||
download(`felucca-${fileSlug(data.engineName || "patch")}-${fileSlug(data.presetName || preset)}.json`, data);
|
||
});
|
||
$("loadfile").addEventListener("click", () => { $("file").value = ""; $("file").click(); });
|
||
$("file").addEventListener("change", async () => {
|
||
const f = $("file").files[0];
|
||
if (!f || !dev) return;
|
||
let data;
|
||
try {
|
||
data = JSON.parse(await f.text());
|
||
if (!Number.isInteger(data.engine) || !Number.isInteger(data.preset) || !Array.isArray(data.p)) throw new Error("engine / preset / p");
|
||
if (data.engine < 0 || data.engine >= dev.info.nengines) throw new Error("engine " + data.engine);
|
||
} catch (e) { sayK("badfile", e.message); return; }
|
||
busy++;
|
||
try {
|
||
selfLoad();
|
||
await rq(req.preset(data.engine, data.preset));
|
||
dev.dump = await getDump();
|
||
await rereadEngineDesc();
|
||
const pv = patchByCount(data.p, data.pE0, dev.info.pcount), n = pv.length; /* (a file of another version) */
|
||
for (let i = 0; i < n; i++) {
|
||
const d = dev.pdesc[i];
|
||
if (!visible(d) || !Number.isFinite(pv[i])) continue;
|
||
if (i % 8 === 0) sayK("applying", `${i}/${n}`);
|
||
await rq(req.set(0, i, pv[i]));
|
||
}
|
||
if (Array.isArray(data.steps)) {
|
||
const m = Math.min(data.steps.length, dev.info.nstep);
|
||
for (let i = 0; i < m; i++) {
|
||
const s = data.steps[i] || {};
|
||
if (i % 8 === 0) sayK("applying", `steps ${i}/${m}`);
|
||
dev.steps[i] = parse[CMD.STEP_SET](await rq(req.stepSet(i, {
|
||
n: s.n | 0, notes: Array.isArray(s.notes) ? s.notes : [0, 0, 0, 0], time: s.time ?? 2, flags: s.flags | 0, vel: s.vel | 0 })));
|
||
}
|
||
}
|
||
dev.dump = await getDump();
|
||
updateBrowser();
|
||
$("steptables").dataset.len = "";
|
||
refreshAll();
|
||
sayK("applied");
|
||
} catch (err) { report(err); } finally { busy--; }
|
||
});
|
||
|
||
/* ----------------------------------------------------------- library --- */
|
||
/* Patches live in IndexedDB "felucca-editor": store "patches" (by id), store "meta" ("layout": the
|
||
parameter keys / engine names the stored values are in). Without IndexedDB (some private windows)
|
||
the library is kept in memory only. */
|
||
const store = (() => {
|
||
let dbp = null;
|
||
const open = () => dbp || (dbp = new Promise((res) => {
|
||
try {
|
||
const r = indexedDB.open("felucca-editor", 1);
|
||
r.onupgradeneeded = () => { r.result.createObjectStore("patches", { keyPath: "id" }); r.result.createObjectStore("meta"); };
|
||
r.onsuccess = () => res(r.result);
|
||
r.onerror = r.onblocked = () => res(null);
|
||
} catch (e) { res(null); }
|
||
}));
|
||
const tx = async (name, mode, fn) => {
|
||
const db = await open();
|
||
if (!db) return undefined;
|
||
return new Promise((res, rej) => {
|
||
const x = db.transaction(name, mode);
|
||
let out;
|
||
const r = fn(x.objectStore(name));
|
||
if (r) r.onsuccess = () => { out = r.result; };
|
||
x.oncomplete = () => res(out);
|
||
x.onerror = x.onabort = () => rej(x.error || new Error("IndexedDB"));
|
||
});
|
||
};
|
||
return {
|
||
ok: async () => !!(await open()),
|
||
all: () => tx("patches", "readonly", (os) => os.getAll()),
|
||
putMany: (ps) => tx("patches", "readwrite", (os) => { ps.forEach((p) => os.put(p)); }),
|
||
del: (id) => tx("patches", "readwrite", (os) => os.delete(id)),
|
||
getMeta: (k) => tx("meta", "readonly", (os) => os.get(k)),
|
||
setMeta: (k, v) => tx("meta", "readwrite", (os) => os.put(v, k)),
|
||
};
|
||
})();
|
||
|
||
let lib = []; /* patches (cleanPatch + id) */
|
||
let libMeta = { keys: null, engines: null, pe0: null };
|
||
let libPersistent = false;
|
||
let libSel = null, bankSel = null;
|
||
let libBusy = false; /* a library / bank operation is running */
|
||
const newId = () => (self.crypto && crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(36) + Math.random().toString(36).slice(2));
|
||
const nowIso = () => new Date().toISOString();
|
||
const slotName = (i) => "U" + String(i + 1).padStart(2, "0");
|
||
const libCtx = () => (dev && dev.keys ? { keys: dev.keys, engines: dev.info.engines, firmware: dev.info.version, pe0: dev.info.pe0 }
|
||
: { keys: libMeta.keys, engines: libMeta.engines, firmware: "", pe0: libMeta.pe0 });
|
||
|
||
async function libInit() {
|
||
try {
|
||
libPersistent = await store.ok();
|
||
if (libPersistent) {
|
||
lib = ((await store.all()) || []).filter((p) => p && p.id);
|
||
libMeta = (await store.getMeta("layout")) || libMeta;
|
||
}
|
||
} catch (e) { console.warn(e); libPersistent = false; }
|
||
renderLib();
|
||
}
|
||
async function libWrite(ps) {
|
||
try { await store.putMany(ps); } catch (e) { console.warn(e); sayK("error", "IndexedDB: " + e.message); }
|
||
}
|
||
async function libAdd(patches) {
|
||
const add = patches.map((p) => ({ ...cleanPatch(p), id: newId() }));
|
||
lib.push(...add);
|
||
if (add.length) libSel = add[add.length - 1].id;
|
||
await libWrite(add);
|
||
renderLib();
|
||
return add;
|
||
}
|
||
async function libUpdate(p) {
|
||
p.modified = nowIso();
|
||
await libWrite([p]);
|
||
renderLib();
|
||
}
|
||
/* the device's parameter layout becomes the library's; patches stored with another layout are mapped by key */
|
||
async function libAdopt(d) {
|
||
const keys = d.keys, engines = d.info.engines, changed = [];
|
||
if ((libMeta.keys && !sameKeys(libMeta.keys, keys)) || (libMeta.engines && !sameKeys(libMeta.engines, engines))) {
|
||
for (const p of lib) {
|
||
const name = p.engineName || (libMeta.engines || [])[p.engine];
|
||
const e = name ? engines.indexOf(name) : p.engine;
|
||
p.p = remapParams(p.p, libMeta.keys, keys);
|
||
if (e >= 0) { p.engine = e; p.engineName = engines[e]; }
|
||
changed.push(p);
|
||
}
|
||
}
|
||
libMeta = { keys, engines, pe0: d.info.pe0 };
|
||
if (changed.length) await libWrite(changed);
|
||
try { await store.setMeta("layout", libMeta); } catch (e) { console.warn(e); }
|
||
renderLib();
|
||
}
|
||
const engineOk = (p) => !!dev && p.engine < dev.info.nengines && (!p.engineName || dev.info.engines[p.engine] === p.engineName);
|
||
/* a full parameter set for UP_PUT: unknown values get the DESC default where it is known, else 0 */
|
||
function fullParams(p) {
|
||
const out = [];
|
||
for (let i = 0; i < dev.info.pcount; i++) {
|
||
let v = p.p[i];
|
||
if (v == null) {
|
||
const d = dev.pdesc[i];
|
||
v = d && (i < dev.info.pe0 || p.engine === dev.dump.engine) ? d.def : 0;
|
||
}
|
||
out.push(v);
|
||
}
|
||
return out;
|
||
}
|
||
|
||
function libView() {
|
||
const q = $("libq").value.trim().toLowerCase(), fe = $("libeng").value, ft = $("libtag").value;
|
||
const by = {
|
||
name: (a, b) => a.name.localeCompare(b.name),
|
||
engine: (a, b) => (a.engineName || "").localeCompare(b.engineName || "") || a.name.localeCompare(b.name),
|
||
created: (a, b) => b.created.localeCompare(a.created),
|
||
modified: (a, b) => b.modified.localeCompare(a.modified),
|
||
}[$("libsort").value] || ((a, b) => b.modified.localeCompare(a.modified));
|
||
return lib.filter((p) => (!q || p.name.toLowerCase().includes(q) || p.tags.some((x) => x.toLowerCase().includes(q)))
|
||
&& (!fe || p.engineName === fe) && (!ft || p.tags.includes(ft))).sort(by);
|
||
}
|
||
function fillSelect(sel, opts) {
|
||
const v = sel.value;
|
||
sel.replaceChildren(...opts.map(([val, txt]) => el("option", { value: val, text: txt })));
|
||
if (opts.some(([val]) => val === v)) sel.value = v;
|
||
}
|
||
function renderLib() {
|
||
const engs = [...new Set([...(dev && dev.info ? dev.info.engines : libMeta.engines || []), ...lib.map((p) => p.engineName).filter(Boolean)])];
|
||
fillSelect($("libeng"), [["", t("allEngines")], ...engs.map((e) => [e, e])]);
|
||
const tags = [...new Set(lib.flatMap((p) => p.tags))].sort();
|
||
fillSelect($("libtag"), [["", t("allTags")], ...tags.map((x) => [x, x])]);
|
||
fillSelect($("libsort"), [["modified", t("sortModified")], ["created", t("sortCreated")], ["name", t("sortName")], ["engine", t("sortEngine")]]);
|
||
const v = libView();
|
||
if (libSel && !lib.some((p) => p.id === libSel)) libSel = null;
|
||
const box = $("liblist");
|
||
if (!lib.length) box.replaceChildren(el("div", { class: "none", text: t("libEmpty") }));
|
||
else {
|
||
const tb = el("table", {}, el("colgroup", {}, el("col"), el("col", { class: "e" }), el("col"), el("col", { class: "d" })),
|
||
el("tr", {}, el("th", { text: t("name") }), el("th", { text: t("engine") }), el("th", { text: t("tagsCol") }), el("th", { text: t("date") })));
|
||
for (const p of v) {
|
||
const tr = el("tr", { "data-id": p.id, class: p.id === libSel ? "sel" : null, draggable: "true", title: p.name },
|
||
el("td", {}, p.pattern ? icon("note_eight") : "", p.name),
|
||
el("td", { text: p.engineName || String(p.engine) }),
|
||
el("td", { text: p.tags.join(", ") }),
|
||
el("td", { text: new Date(p.modified).toLocaleDateString(lang) }));
|
||
tr.addEventListener("click", () => { libSel = p.id; renderLib(); });
|
||
tr.addEventListener("dblclick", () => libAudition(p.id));
|
||
tr.addEventListener("dragstart", (e) => { libSel = p.id; e.dataTransfer.setData("text/x-felucca-lib", p.id); e.dataTransfer.effectAllowed = "copy"; });
|
||
tb.append(tr);
|
||
}
|
||
box.replaceChildren(tb, ...(v.length ? [] : [el("div", { class: "none", text: t("noMatch") })]));
|
||
}
|
||
$("libcount").textContent = `${v.length} / ${lib.length}` + (libPersistent ? "" : " " + t("noLibDB"));
|
||
const sel = lib.find((p) => p.id === libSel);
|
||
for (const id of ["libren", "libtags", "libdup", "libdel", "libexp1"]) $(id).disabled = !sel;
|
||
$("libaud").disabled = !sel || !dev || libBusy;
|
||
$("libput").disabled = !sel || !dev || !dev.bank || bankSel == null || libBusy;
|
||
$("libsave").disabled = !dev || libBusy;
|
||
$("libexport").disabled = !lib.length;
|
||
}
|
||
["libq", "libeng", "libtag", "libsort"].forEach((id) => $(id).addEventListener(id === "libq" ? "input" : "change", renderLib));
|
||
|
||
function renderBank() {
|
||
const pane = $("bankpane");
|
||
$("bankhint").hidden = !!(dev && dev.bank);
|
||
$("bankhint").textContent = t(!dev || !dev.dump ? "bankConnect" : "bankNone");
|
||
if (!dev || !dev.bank) { pane.hidden = true; return; }
|
||
pane.hidden = false;
|
||
const b = dev.bank, used = b.slots.filter((x) => x.used).length;
|
||
$("bankhead").textContent = `${used} / ${b.total} ${t("used")}`;
|
||
const tb = el("table", {}, el("colgroup", {}, el("col", { class: "n" }), el("col"), el("col", { class: "e" })),
|
||
el("tr", {}, el("th", { text: "#" }), el("th", { text: t("name") }), el("th", { text: t("engine") })));
|
||
for (const x of b.slots) {
|
||
const tr = el("tr", { "data-slot": x.slot, class: [x.slot === bankSel ? "sel" : "", x.used ? "" : "empty"].join(" ").trim() || null,
|
||
draggable: x.used ? "true" : null },
|
||
el("td", { text: slotName(x.slot) }), el("td", { text: x.used ? x.name : t("empty") }),
|
||
el("td", { text: x.used ? dev.info.engines[x.engine] || String(x.engine) : "" }));
|
||
tr.addEventListener("click", () => { bankSel = x.slot; renderBank(); renderLib(); });
|
||
tr.addEventListener("dblclick", () => { if (x.used) bankLoad(x.slot); });
|
||
tr.addEventListener("dragstart", (e) => { e.dataTransfer.setData("text/x-felucca-slot", String(x.slot)); e.dataTransfer.effectAllowed = "copy"; });
|
||
tr.addEventListener("dragover", (e) => { if (e.dataTransfer.types.includes("text/x-felucca-lib")) { e.preventDefault(); tr.classList.add("over"); } });
|
||
tr.addEventListener("dragleave", () => tr.classList.remove("over"));
|
||
tr.addEventListener("drop", (e) => {
|
||
e.preventDefault();
|
||
tr.classList.remove("over");
|
||
const id = e.dataTransfer.getData("text/x-felucca-lib");
|
||
if (id) { bankSel = x.slot; libPut(id, x.slot); }
|
||
});
|
||
tb.append(tr);
|
||
}
|
||
$("banklist").replaceChildren(tb);
|
||
const s = bankSel == null ? null : b.slots[bankSel];
|
||
const idle = !libBusy;
|
||
$("bkload").disabled = !s || !s.used || !idle;
|
||
$("bkstore").disabled = !s || !idle;
|
||
$("bkget").disabled = !s || !s.used || !idle;
|
||
$("bkerase").disabled = !s || !s.used || !idle;
|
||
$("bkrefresh").disabled = !idle;
|
||
$("bkexport").disabled = !used || !idle;
|
||
}
|
||
/* a slot dropped on the library: copy it there */
|
||
$("liblist").addEventListener("dragover", (e) => { if (e.dataTransfer.types.includes("text/x-felucca-slot")) { e.preventDefault(); $("liblist").classList.add("over"); } });
|
||
$("liblist").addEventListener("dragleave", () => $("liblist").classList.remove("over"));
|
||
$("liblist").addEventListener("drop", (e) => {
|
||
e.preventDefault();
|
||
$("liblist").classList.remove("over");
|
||
const s = e.dataTransfer.getData("text/x-felucca-slot");
|
||
if (s !== "") bankGet(+s);
|
||
});
|
||
|
||
/* library operations that talk to the device: one at a time, buttons off meanwhile */
|
||
async function libOp(fn) {
|
||
if (!dev || libBusy) return;
|
||
libBusy = true;
|
||
busy++;
|
||
renderLib(); renderBank();
|
||
try { await fn(); } catch (err) { report(err); } finally { busy--; libBusy = false; renderLib(); renderBank(); }
|
||
}
|
||
const rqf = (r, o) => rq(r, o);
|
||
const checkRc = (rc) => { if (rc === 3) throw new Error(t("bkStop")); if (rc) throw new Error(t("flashFail").replace("{rc}", rc)); };
|
||
async function refreshSlot(slot) {
|
||
const r = parse[CMD.UP_LIST](await rq(req.upList(slot, 1)));
|
||
if (dev && dev.bank && r.slots[0]) dev.bank.slots[slot] = r.slots[0];
|
||
}
|
||
|
||
function libAudition(id) {
|
||
const p = lib.find((x) => x.id === id);
|
||
if (!p || !dev || libBusy) return;
|
||
if (isDrum()) { sayK("drumNoSound"); return; }
|
||
libOp(async () => {
|
||
if (!engineOk(p)) throw new Error(t("badEngine") + (p.engineName || p.engine));
|
||
sayK("auditioning", p.name);
|
||
selfLoad();
|
||
const r = await auditionPatch(rqf, dev.info, p, { gEng: gEng(),
|
||
progress: (i, n) => { if (i % 8 === 0) sayK("auditioning", `${p.name} ${i}/${n}`); } });
|
||
await afterSoundChange();
|
||
sayK(r.wrote ? "auditionedPat" : "auditioned", p.name);
|
||
});
|
||
}
|
||
$("libaud").addEventListener("click", () => libAudition(libSel));
|
||
|
||
$("libsave").addEventListener("click", () => libOp(async () => {
|
||
if (isDrum()) { sayK("drumNoSound"); return; }
|
||
const def = upName((dev.names[dev.dump.engine] || [])[dev.dump.preset] || dev.info.engines[dev.dump.engine]);
|
||
const name = prompt(t("promptName"), def);
|
||
if (name == null) return;
|
||
const { patch } = await capturePatch(rqf, dev.info, name.trim() || def);
|
||
await libAdd([patch]);
|
||
sayK("savedLib", patch.name);
|
||
}));
|
||
|
||
/* factory preset -> library: PRESET, then DUMP + steps; its pattern only if it brought one (the device
|
||
loads a preset's pattern into an empty sequencer, or over one that is still an untouched preset pattern) */
|
||
$("factlib").addEventListener("click", () => libOp(async () => {
|
||
const e = dev.dump.engine, pi = $("preset").value === "" ? dev.dump.preset : +$("preset").value;
|
||
const name = (dev.names[e] || [])[pi] || "PRESET";
|
||
const before = dev.steps.length >= UP.PAT ? patternFromSteps(dev.steps) : null;
|
||
const wasEmpty = dev.steps.length && dev.steps.every((s) => !s || !s.n);
|
||
selfLoad();
|
||
await rq(req.preset(e, pi));
|
||
const { patch } = await capturePatch(rqf, dev.info, name);
|
||
const brought = wasEmpty || !before || JSON.stringify(before) !== JSON.stringify(patch.pattern || patternFromSteps([]));
|
||
if (!brought) patch.pattern = null;
|
||
patch.tags = ["factory"];
|
||
await libAdd([patch]);
|
||
await afterSoundChange();
|
||
sayK("copiedLib", `${dev.info.engines[e]} ${name}`);
|
||
}));
|
||
|
||
function libPut(id, slot) {
|
||
const p = lib.find((x) => x.id === id);
|
||
if (!p || !dev || !dev.bank || slot == null || libBusy) return;
|
||
const s = dev.bank.slots[slot];
|
||
if (!engineOk(p)) { sayK("badEngine", p.engineName || p.engine); return; }
|
||
if (s.used && !confirm(t("confirmOverwrite").replace("{n}", slotName(slot)).replace("{name}", s.name))) return;
|
||
libOp(async () => {
|
||
checkRc(await bank.put(rqf, slot, { ...p, name: upName(p.name), p: fullParams(p) }));
|
||
await refreshSlot(slot);
|
||
sayK("putDone", `${slotName(slot)} ${upName(p.name)}`);
|
||
});
|
||
}
|
||
$("libput").addEventListener("click", () => libPut(libSel, bankSel));
|
||
|
||
$("libren").addEventListener("click", () => {
|
||
const p = lib.find((x) => x.id === libSel);
|
||
if (!p) return;
|
||
const v = prompt(t("promptName"), p.name);
|
||
if (v == null || !v.trim()) return;
|
||
p.name = v.trim().slice(0, 32);
|
||
libUpdate(p);
|
||
});
|
||
$("libtags").addEventListener("click", () => {
|
||
const p = lib.find((x) => x.id === libSel);
|
||
if (!p) return;
|
||
const v = prompt(t("promptTags"), p.tags.join(", "));
|
||
if (v == null) return;
|
||
p.tags = [...new Set(v.split(",").map((x) => x.trim()).filter(Boolean))];
|
||
libUpdate(p);
|
||
});
|
||
$("libdup").addEventListener("click", () => {
|
||
const p = lib.find((x) => x.id === libSel);
|
||
if (p) libAdd([{ ...p, name: (p.name + " 2").slice(0, 32), created: nowIso(), modified: nowIso() }]);
|
||
});
|
||
$("libdel").addEventListener("click", async () => {
|
||
const p = lib.find((x) => x.id === libSel);
|
||
if (!p || !confirm(t("confirmDelete").replace("{name}", p.name))) return;
|
||
lib = lib.filter((x) => x !== p);
|
||
libSel = null;
|
||
try { await store.del(p.id); } catch (e) { console.warn(e); }
|
||
renderLib();
|
||
});
|
||
|
||
function download(name, obj) {
|
||
const blob = new Blob([JSON.stringify(obj, null, 1)], { type: "application/json" });
|
||
const a = el("a", { href: URL.createObjectURL(blob), download: name });
|
||
document.body.append(a);
|
||
a.click();
|
||
a.remove();
|
||
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
||
}
|
||
const fileSlug = (s) => String(s).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "patch";
|
||
function downloadBytes(name, bytes) {
|
||
const blob = new Blob([bytes], { type: "application/octet-stream" });
|
||
const a = el("a", { href: URL.createObjectURL(blob), download: name });
|
||
document.body.append(a);
|
||
a.click();
|
||
a.remove();
|
||
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
||
}
|
||
|
||
/* ------------------------------------------------------------------ FM6 --- */
|
||
/* The FM6 engine's patch (firmware v9, EDITOR_PROTOCOL.md "FM6 patches"), in the Sound tab while the selected
|
||
track plays FM6: the device's eight EDIT values are macros on top of it. "Send to track" makes it the track's own
|
||
patch at once (a project keeps PTCH only: the patch stays until PTCH turns or a sound loads), "Store in bank"
|
||
keeps it in a PTCH slot B1..B27 (flash; the song must be stopped). SysEx files (.syx): a single voice or a 32-voice
|
||
bank (pick a voice). */
|
||
let fm6v = FM6.init(); /* the patch being edited (155 bytes) */
|
||
let fm6Imported = []; /* voices of the last imported file: [{name, v}] */
|
||
let fm6Timer = null, fm6Pending = false;
|
||
const fm6Eng = () => (dev && dev.info ? dev.info.engines.indexOf("FM6") : -1);
|
||
const fm6Ok = () => !!dev && !!dev.info && dev.info.proto >= 9 && !!dev.fm6 && fm6Eng() >= 0;
|
||
const fm6On = () => fm6Ok() && !!dev.dump && dev.dump.engine === fm6Eng(); /* the selected track plays FM6 */
|
||
const fm6Track = () => (dev && dev.sel != null ? dev.sel : 0);
|
||
const fm6SlotName = (i) => (i < dev.fm6.factory ? "F" : "B") + (i < dev.fm6.factory ? i + 1 : i - dev.fm6.factory + 1);
|
||
const FM6_WAVES = ["TRI", "SAW-", "SAW+", "SQR", "SIN", "S&H"];
|
||
const FM6_CURVES = ["-LIN", "-EXP", "+EXP", "+LIN"];
|
||
/* the names the device shows for ALG (PAT, 1..32) and PTCH (F1..F8, B1..B27): DESC sends none for F_INT */
|
||
function fm6Names(d = dev) {
|
||
if (!d || !d.pdesc || !d.info || !d.dump || d.dump.engine !== (d.info.engines || []).indexOf("FM6") || !d.fm6) return;
|
||
const pe0 = d.info.pe0, alg = d.pdesc[pe0], ptch = d.pdesc[pe0 + 7];
|
||
if (alg && alg.label === "ALG" && alg.fmt === F.INT) alg.names = ["PAT", ...Array.from({ length: 32 }, (_, k) => String(k + 1))];
|
||
if (ptch && ptch.label === "PTCH" && ptch.fmt === F.INT) ptch.names = Array.from({ length: d.fm6.factory + d.fm6.bank }, (_, i) => fm6SlotName(i));
|
||
}
|
||
function fm6Show() {
|
||
const on = fm6On();
|
||
$("fm6panel").hidden = !on;
|
||
if (on) { renderFm6Slots(); renderFm6(); }
|
||
}
|
||
function fm6Set(i, val) {
|
||
fm6v[i] = Math.max(0, Math.min(FM6.max(i), Math.round(+val || 0)));
|
||
if ($("fm6live").checked && fm6On()) {
|
||
clearTimeout(fm6Timer);
|
||
fm6Timer = setTimeout(() => op(() => fm6Send(true)), 150);
|
||
}
|
||
}
|
||
function fm6Num(i, title) {
|
||
return el("input", { type: "number", min: 0, max: FM6.max(i), value: fm6v[i], title, class: "fm6n",
|
||
onchange: (e) => { fm6Set(i, e.target.value); e.target.value = fm6v[i]; renderFm6Ops(); } });
|
||
}
|
||
function fm6Sel(i, names, title) {
|
||
const sel = el("select", { title, onchange: (e) => { fm6Set(i, e.target.value); renderFm6(); } },
|
||
...names.map((n, k) => el("option", { value: k, text: n })));
|
||
sel.value = fm6v[i];
|
||
return sel;
|
||
}
|
||
function renderFm6Voice() {
|
||
const V = FM6.VI, alg = fm6v[V.ALG], fb = FM6.feedbackOp(alg);
|
||
const nm = el("input", { type: "text", maxlength: 10, value: FM6.name(fm6v), size: 11,
|
||
onchange: (e) => { FM6.setName(fm6v, e.target.value); fm6Set(0, fm6v[0]); e.target.value = FM6.name(fm6v); } });
|
||
const row = (label, ...kids) => el("tr", {}, el("th", { text: label }), el("td", {}, ...kids));
|
||
$("fm6voice").replaceChildren(el("table", {},
|
||
row(t("name"), nm),
|
||
row("ALG", fm6Sel(V.ALG, Array.from({ length: 32 }, (_, k) => String(k + 1)), "ALG"),
|
||
el("span", { class: "dim", text: ` ${t("fm6Carriers")} ${FM6.carriers(alg).join(" ")}, ${t("fm6Feedback")} OP${fb}` })),
|
||
row("FB", fm6Num(V.FB, "FB"), " OKS ", fm6Num(V.OKS, "OKS"), " TRNSP ", fm6Num(V.TRNSP, "TRNSP")),
|
||
row("LFO", fm6Sel(V.LFW, FM6_WAVES, "WAVE"), " SPD ", fm6Num(V.LFS, "SPEED"), " DLY ", fm6Num(V.LFD, "DELAY"),
|
||
" PMD ", fm6Num(V.LPMD, "PMD"), " AMD ", fm6Num(V.LAMD, "AMD"), " PMS ", fm6Num(V.LPMS, "PMS"), " SYNC ", fm6Num(V.LKS, "SYNC")),
|
||
row(t("fm6PitchEg"), "R ", ...[0, 1, 2, 3].map((k) => fm6Num(V.PR1 + k, "R" + (k + 1))),
|
||
" L ", ...[0, 1, 2, 3].map((k) => fm6Num(V.PL1 + k, "L" + (k + 1))))));
|
||
}
|
||
function renderFm6Ops() {
|
||
const car = FM6.carriers(fm6v[FM6.VI.ALG]);
|
||
const head = el("tr", {}, el("th", { text: "OP" }), ...FM6.OP.map(([n]) => el("th", { text: n })), el("th", { text: t("fm6Freq") }));
|
||
const rows = [1, 2, 3, 4, 5, 6].map((n) => el("tr", {}, el("td", { text: `${n}${car.includes(n) ? " \u25CF" : ""}` }),
|
||
...FM6.OP.map(([f]) => el("td", {}, f === "LC" || f === "RC" ? fm6Sel(FM6.at(n, f), FM6_CURVES, f)
|
||
: f === "MODE" ? fm6Sel(FM6.at(n, f), ["RATIO", "FIXED"], f) : fm6Num(FM6.at(n, f), `OP${n} ${f}`))),
|
||
el("td", { class: "dim", text: FM6.freqText(fm6v, n) })));
|
||
$("fm6ops").replaceChildren(el("div", { class: "fm6ops" }, el("table", {}, head, ...rows)), el("p", { class: "dim", text: t("fm6Legend") }));
|
||
}
|
||
/* the imported voices: click one to edit it; tick the ones that go to the bank (2.5: Store cartridge, B1.. in order) */
|
||
let fm6Tick = new Set(), fm6File = "", fm6Up = "none"; /* fm6Up: also as user presets? "none", "free" or a first slot */
|
||
function renderFm6Imported() {
|
||
const box = $("fm6imported");
|
||
if (!fm6Imported.length) { box.replaceChildren(); return; }
|
||
const nb = dev && dev.fm6 ? dev.fm6.bank : FM6.BANK_N, order = [...fm6Tick].sort((a, b) => a - b), n = order.length;
|
||
const items = fm6Imported.map((x, k) => {
|
||
const at = order.indexOf(k);
|
||
const cb = el("input", { type: "checkbox", title: t("fm6CartTick"), onchange: (e) => {
|
||
if (e.target.checked && fm6Tick.size >= nb) { e.target.checked = false; sayK("fm6CartFull", ` ${nb}`); return; }
|
||
if (e.target.checked) fm6Tick.add(k); else fm6Tick.delete(k);
|
||
renderFm6Imported();
|
||
} });
|
||
cb.checked = fm6Tick.has(k);
|
||
return el("span", { class: "fm6v" + (at >= 0 ? " on" : "") }, cb,
|
||
el("button", { type: "button", text: `${k + 1} ${x.name}`, onclick: () => { fm6v = Uint8Array.from(x.v); renderFm6(); sayK("fm6Picked", ` ${x.name}`); } }),
|
||
el("span", { class: "dim", text: at >= 0 ? `B${at + 1}` : "" }));
|
||
});
|
||
const cart = el("button", { type: "button", class: "pri", disabled: !n || !fm6Ok(), onclick: fm6StoreCart },
|
||
t("fm6Cart").replace("{n}", n).replace("{b}", n ? `B1–B${n}` : "B1"));
|
||
box.replaceChildren(el("p", { class: "dim", text: t(fm6Imported.length > 1 ? "fm6PickMany" : "fm6Pick") }),
|
||
el("div", { class: "fm6list" }, ...items),
|
||
...(fm6Imported.length > 1 || n ? [el("p", { class: "bar" }, el("label", { for: "fm6up", text: t("fm6UpWhere") + " " }), fm6UpSelect()),
|
||
el("p", { class: "bar" },
|
||
el("button", { type: "button", onclick: () => { fm6Tick = new Set(fm6Imported.slice(0, nb).map((_, k) => k)); renderFm6Imported(); } }, t("fm6CartFirst").replace("{n}", Math.min(nb, fm6Imported.length))),
|
||
el("button", { type: "button", onclick: () => { fm6Tick.clear(); renderFm6Imported(); } }, t("fm6CartNone")), cart)] : []));
|
||
}
|
||
/* 2.5: the choice before the store: the bank only (PTCH), or also user presets (PRESETS / SELECT on the FM-1) */
|
||
function fm6UpSelect() {
|
||
const b = dev && dev.bank, free = b ? b.slots.filter((x) => !x.used).length : 0, total = b ? b.total : 32;
|
||
const s = el("select", { id: "fm6up", onchange: (e) => { fm6Up = e.target.value === "none" || e.target.value === "free" ? e.target.value : +e.target.value; } },
|
||
el("option", { value: "none", text: t("fm6UpNone") }),
|
||
el("option", { value: "free", text: t("fm6UpFree").replace("{k}", b ? free : "?") }),
|
||
...Array.from({ length: total }, (_, i) => el("option", { value: String(i), text: t("fm6UpFrom").replace("{u}", slotName(i)) })));
|
||
s.value = String(fm6Up);
|
||
return s;
|
||
}
|
||
/* the ticked voices into B1..Bn in one write: the bank is read whole (backup object 8), those slots replaced, the rest
|
||
kept, and written back whole (BK_PUT: one flash write, stopped only, as a restore) */
|
||
async function fm6StoreCart() {
|
||
if (!fm6Ok()) return;
|
||
const order = [...fm6Tick].sort((a, b) => a - b), n = order.length, nf = dev.fm6.factory;
|
||
if (!n) return;
|
||
const busyN = order.filter((_, i) => dev.fm6.slots[nf + i] && dev.fm6.slots[nf + i].used).length;
|
||
op(async () => {
|
||
let puts = [], upTxt = "";
|
||
if (fm6Up !== "none") { /* the user presets: read the slots now, then ask */
|
||
const list = await bank.list(rq);
|
||
const slots = fm6CartSlots(list, n, fm6Up);
|
||
if (!slots) {
|
||
sayK(fm6Up === "free" ? "fm6UpNoRoom" : "fm6UpPast", fm6Up === "free" ? ` ${list.slots.filter((x) => !x.used).length}` : ` ${slotName(fm6Up)} + ${n}`);
|
||
return;
|
||
}
|
||
const base = dev.pdesc.slice(0, dev.info.pcount).map((d) => (d ? d.def : 0));
|
||
puts = order.map((k, i) => ({ slot: slots[i], pt: fm6CartPreset(dev.info, base, nf, i, fm6Imported[k].name) }));
|
||
const over = slots.map((s) => list.slots[s]).filter((x) => x && x.used);
|
||
upTxt = "\n" + t("fm6UpAsk").replace("{n}", n).replace("{u}", fm6SlotsTxt(slots))
|
||
+ (over.length ? "\n" + t("fm6UpOver").replace("{k}", over.length).replace("{names}", over.slice(0, 6).map((x) => `${slotName(x.slot)} ${x.name}`).join(", ") + (over.length > 6 ? "…" : "")) : "");
|
||
}
|
||
if (!confirm(t("fm6CartAsk").replace("{n}", n).replace("{b}", `B1–B${n}`).replace("{x}", fm6File || "SysEx")
|
||
+ (busyN ? "\n" + t("fm6CartOver").replace("{k}", busyN) : "") + upTxt)) return;
|
||
const rc = await fm6CartWrite(rq, order.map((k) => FM6.pack(Uint8Array.from(fm6Imported[k].v))));
|
||
if (rc === "old") { sayK("fm6CartOld"); return; }
|
||
if (rc === 3) { sayK("fm6CartStop"); return; }
|
||
await fm6Refresh();
|
||
if (!puts.length) { sayK("fm6CartDone", ` ${n} → B1–B${n}`); return; }
|
||
const ru = await fm6CartPresets(rq, puts);
|
||
try { dev.bank = await bank.list(rq); renderBank(); } catch (e) { /* (the list comes back at the next connect) */ }
|
||
renderFm6Imported();
|
||
if (ru === 3) { sayK("fm6UpStop"); return; }
|
||
checkRc(ru);
|
||
sayK("fm6UpDone", ` ${n} → B1–B${n}, ${fm6SlotsTxt(puts.map((x) => x.slot))}`);
|
||
});
|
||
}
|
||
/* U04–U08 when they follow each other, else U04, U05, U07… */
|
||
function fm6SlotsTxt(sl) {
|
||
if (sl.length > 1 && sl.every((x, i) => !i || x === sl[i - 1] + 1)) return `${slotName(sl[0])}–${slotName(sl[sl.length - 1])}`;
|
||
return sl.slice(0, 8).map(slotName).join(", ") + (sl.length > 8 ? "…" : "");
|
||
}
|
||
function renderFm6Slots() {
|
||
if (!fm6Ok()) return;
|
||
const ss = $("fm6slot"), keep = ss.value;
|
||
const n = dev.fm6.factory + dev.fm6.bank;
|
||
ss.replaceChildren(...Array.from({ length: n }, (_, i) => {
|
||
const x = dev.fm6.slots[i];
|
||
return el("option", { value: i, text: `${fm6SlotName(i)} ${x && x.used ? x.name : t("empty")}` });
|
||
}));
|
||
ss.value = keep !== "" && +keep < n ? keep : String(dev.dump ? Math.min(n - 1, dev.dump.p[dev.info.pe0 + 7] | 0) : 0);
|
||
}
|
||
function renderFm6() { renderFm6Voice(); renderFm6Ops(); renderFm6Imported(); }
|
||
async function fm6Refresh(d = dev) {
|
||
d.fm6 = parse[CMD.FM6_LIST](await rq(req.fm6List()));
|
||
fm6Names(d);
|
||
renderFm6Slots();
|
||
}
|
||
/* the selected track's patch into the editor (after a sound change: a PTCH value loaded one) */
|
||
async function fm6ReadTrack(quiet) {
|
||
const r = parse[CMD.FM6_GET](await rq(req.fm6Get(FM6.TARGET.TRACK, fm6Track())));
|
||
if (r.rc) { if (!quiet) checkRc(r.rc); return; }
|
||
fm6v = FM6.unpack(r.packed);
|
||
renderFm6();
|
||
if (!quiet) sayK("fm6Read", ` ${fm6Track() + 1}: ${FM6.name(fm6v)}`);
|
||
}
|
||
async function fm6Follow() { if (fm6On()) await fm6ReadTrack(true); }
|
||
function fm6Later() { /* a PTCH change: read the new patch once the queue is quiet */
|
||
if (fm6Pending) return;
|
||
fm6Pending = true;
|
||
setTimeout(() => { fm6Pending = false; op(fm6Follow); }, 250);
|
||
}
|
||
async function fm6Send(quiet) {
|
||
const r = parse[CMD.FM6_PUT](await rq(req.fm6Put(FM6.TARGET.TRACK, fm6Track(), FM6.pack(fm6v))));
|
||
checkRc(r.rc);
|
||
if (!quiet) sayK("fm6Sent", ` ${fm6Track() + 1}`);
|
||
}
|
||
$("fm6read").addEventListener("click", () => op(() => fm6ReadTrack(false)));
|
||
$("fm6send").addEventListener("click", () => op(() => fm6Send(false)));
|
||
$("fm6load").addEventListener("click", () => op(async () => {
|
||
const i = +$("fm6slot").value, nf = dev.fm6.factory;
|
||
const r = parse[CMD.FM6_GET](await rq(i < nf ? req.fm6Get(FM6.TARGET.FACTORY, i) : req.fm6Get(FM6.TARGET.BANK, i - nf)));
|
||
if (r.rc === 2) { sayK("emptySlot", fm6SlotName(i)); return; }
|
||
checkRc(r.rc);
|
||
fm6v = FM6.unpack(r.packed);
|
||
renderFm6();
|
||
sayK("fm6Loaded", ` ${fm6SlotName(i)}: ${FM6.name(fm6v)}`);
|
||
}));
|
||
$("fm6store").addEventListener("click", () => {
|
||
if (!fm6Ok()) return;
|
||
const i = +$("fm6slot").value, nf = dev.fm6.factory;
|
||
if (i < nf) { sayK("fm6Factory"); return; }
|
||
const x = dev.fm6.slots[i];
|
||
if (x && x.used && !confirm(t("confirmOverwrite").replace("{n}", fm6SlotName(i)).replace("{name}", x.name))) return;
|
||
op(async () => {
|
||
checkRc(parse[CMD.FM6_PUT](await rq(req.fm6Put(FM6.TARGET.BANK, i - nf, FM6.pack(fm6v)), { timeout: 3000 })).rc);
|
||
await fm6Refresh();
|
||
sayK("storedSlot", fm6SlotName(i));
|
||
});
|
||
});
|
||
$("fm6erase").addEventListener("click", () => {
|
||
if (!fm6Ok()) return;
|
||
const i = +$("fm6slot").value, nf = dev.fm6.factory, x = dev.fm6.slots[i];
|
||
if (i < nf || !x || !x.used || !confirm(t("confirmEraseSlot").replace("{n}", fm6SlotName(i)).replace("{name}", x.name))) return;
|
||
op(async () => {
|
||
checkRc(parse[CMD.FM6_ERASE](await rq(req.fm6Erase(i - nf), { timeout: 3000 })).rc);
|
||
await fm6Refresh();
|
||
sayK("erasedSlot", fm6SlotName(i));
|
||
});
|
||
});
|
||
$("fm6init").addEventListener("click", () => { fm6v = FM6.init(); renderFm6(); });
|
||
$("fm6import").addEventListener("click", () => $("fm6file").click());
|
||
async function fm6ImportFile(f) {
|
||
if (!f) return;
|
||
try {
|
||
const r = FM6.parseSysex(new Uint8Array(await f.arrayBuffer()));
|
||
if (!r.voices.length) { const [k, x] = fm6Why(r); sayK(k, `${x}: ${f.name}`); return; }
|
||
fm6Imported = r.voices;
|
||
fm6File = f.name;
|
||
fm6Tick = new Set(r.voices.length > 1 ? r.voices.slice(0, dev && dev.fm6 ? dev.fm6.bank : FM6.BANK_N).map((_, k) => k) : []);
|
||
if (r.voices.length === 1) fm6v = Uint8Array.from(r.voices[0].v);
|
||
renderFm6();
|
||
const notes = [r.badSum && t("fm6BadSum"), r.short && t("fm6Short"), r.skipped && t("fm6Skipped").replace("{x}", r.skipped)].filter(Boolean);
|
||
sayK("imported", `${f.name}: ${r.voices.length}` + (notes.length ? ` (${notes.join(", ")})` : ""));
|
||
} catch (err) { sayK("badfile", err.message); }
|
||
}
|
||
$("fm6file").addEventListener("change", (e) => { const f = e.target.files[0]; e.target.value = ""; fm6ImportFile(f); });
|
||
/* 2.5: drop a .syx on the FM6 panel */
|
||
$("fm6panel").addEventListener("dragover", (e) => {
|
||
if (![...(e.dataTransfer.types || [])].includes("Files")) return;
|
||
e.preventDefault();
|
||
$("fm6panel").classList.add("drop");
|
||
});
|
||
$("fm6panel").addEventListener("dragleave", (e) => { if (e.target === $("fm6panel")) $("fm6panel").classList.remove("drop"); });
|
||
$("fm6panel").addEventListener("drop", (e) => {
|
||
e.preventDefault();
|
||
$("fm6panel").classList.remove("drop");
|
||
const f = e.dataTransfer.files && e.dataTransfer.files[0];
|
||
if (f) fm6ImportFile(f);
|
||
});
|
||
/* why a file had no 6-operator voice: [message key, what to add before the file name] (after Felucca 1.0.3) */
|
||
function fm6Why(r) {
|
||
const mk = r.kinds.find((k) => k.startsWith("maker:"));
|
||
if (r.kinds.includes("fm4")) return ["fm6Is4op", ""];
|
||
if (r.kinds.includes("other43")) return ["fm6OtherBlocks", ""];
|
||
if (mk) return ["fm6OtherMaker", ` (ID ${mk.slice(6)})`];
|
||
if (r.kinds.includes("universal")) return ["fm6Universal", ""];
|
||
return [r.sysex ? "fm6NoVoice" : "fm6NotSysex", ""];
|
||
}
|
||
$("fm6export").addEventListener("click", () => downloadBytes(`${fileSlug(FM6.name(fm6v))}.syx`, FM6.singleSysex(fm6v)));
|
||
$("fm6bankexp").addEventListener("click", () => op(async () => {
|
||
const out = [];
|
||
for (let k = 0; k < dev.fm6.bank; k++) {
|
||
const r = parse[CMD.FM6_GET](await rq(req.fm6Get(FM6.TARGET.BANK, k)));
|
||
out.push(r.rc ? null : FM6.unpack(r.packed));
|
||
}
|
||
downloadBytes(`sloop-fm6-bank-${today()}.syx`, FM6.bankSysex(out));
|
||
sayK("fm6Exported");
|
||
}));
|
||
const today = () => new Date().toISOString().slice(0, 10);
|
||
/* v6: backup / restore (the work: backupCapture / backupRestore above) */
|
||
function bkProgress(key) {
|
||
const pr = $("bk-prog");
|
||
pr.hidden = false;
|
||
return (d, n) => { pr.value = d / n; sayK(key, `${Math.round(100 * d / n)} %`); };
|
||
}
|
||
function bkReport(e) {
|
||
if (e && e.code && TEXT[lang][e.code]) sayK(e.code, e.code === "bkStop" ? "" : e.message);
|
||
else report(e);
|
||
}
|
||
$("bk-save").addEventListener("click", () => op(async () => {
|
||
try {
|
||
const arc = await backupCapture(rq, dev.info, bkProgress("bkSaving"));
|
||
download(`SLOOP-backup-${today()}.json`, arc);
|
||
sayK("bkSaved");
|
||
} catch (e) { bkReport(e); } finally { $("bk-prog").hidden = true; }
|
||
}));
|
||
$("bk-load").addEventListener("click", () => { if (dev) $("bk-file").click(); });
|
||
/* (2.7) a song as one file: export it; load one (also from the LIVE page's playlist: lvSongLoad) */
|
||
async function songExport() {
|
||
const name = prompt(t("sfName"), "SONG " + today());
|
||
if (name == null) return;
|
||
await op(async () => {
|
||
try {
|
||
const f = await songCapture(rq, dev.info, name.trim() || "SONG", bkProgress("sfSaving"));
|
||
download(`${fileSlug(f.name) || "song"}.sloopsong`, f);
|
||
sayK("sfSaved", f.name);
|
||
} catch (e) { bkReport(e); } finally { $("bk-prog").hidden = true; }
|
||
});
|
||
}
|
||
async function songLoadUI(file, progress) {
|
||
selfLoad();
|
||
await songLoad(rq, file, progress);
|
||
dev.slotUsed = [null, null, null, null];
|
||
for (let k = 0; k < 4; k++) {
|
||
try { dev.slotUsed[k] = parse[CMD.PROJECT](await rq(req.project(2, k))).used; } catch (e) { if (e.message === "closed") throw e; }
|
||
}
|
||
SG.dev = null; /* (the Song tab reads the order again) */
|
||
}
|
||
$("sf-save").addEventListener("click", () => { if (dev) songExport(); });
|
||
$("sf-load").addEventListener("click", () => { if (dev) $("sf-file").click(); });
|
||
$("sf-file").addEventListener("change", async () => {
|
||
const f = $("sf-file").files[0];
|
||
$("sf-file").value = "";
|
||
if (!f || !dev) return;
|
||
let file;
|
||
try { file = JSON.parse(await f.text()); songObjects(file); }
|
||
catch (e) { sayK("songBadFile", ""); return; }
|
||
if (!confirm(t("sfConfirm").replace("{name}", file.name || f.name))) return;
|
||
await op(async () => {
|
||
try {
|
||
await songLoadUI(file, bkProgress("sfLoading"));
|
||
renderSlots();
|
||
await afterSoundChange("sfLoaded");
|
||
sayK("sfLoaded", file.name || f.name);
|
||
} catch (e) { bkReport(e); } finally { $("bk-prog").hidden = true; }
|
||
});
|
||
});
|
||
$("bk-file").addEventListener("change", async () => {
|
||
const f = $("bk-file").files[0];
|
||
$("bk-file").value = "";
|
||
if (!f || !dev) return;
|
||
let file;
|
||
try { file = JSON.parse(await f.text()); backupObjects(file); }
|
||
catch (e) { sayK("bkBad", e.message); return; }
|
||
if (!confirm(t("bkConfirm"))) return;
|
||
await op(async () => {
|
||
try {
|
||
selfLoad();
|
||
await backupRestore(rq, file, bkProgress("bkRestoring"));
|
||
dev.slotUsed = [null, null, null, null];
|
||
renderSlots();
|
||
try { await smpInfo(); renderSamples(); } catch (e) { /* shown by the next action */ }
|
||
await afterSoundChange("bkRestored");
|
||
} catch (e) { bkReport(e); } finally { $("bk-prog").hidden = true; }
|
||
});
|
||
});
|
||
|
||
$("libexp1").addEventListener("click", () => {
|
||
const p = lib.find((x) => x.id === libSel);
|
||
if (p) download(`felucca-patch-${fileSlug(p.name)}.json`, libraryFile("patch", [p], libCtx()));
|
||
});
|
||
$("libexport").addEventListener("click", () => download(`felucca-library-${today()}.json`, libraryFile("library", lib, libCtx())));
|
||
$("libimport").addEventListener("click", () => { $("libfile").value = ""; $("libfile").click(); });
|
||
$("libfile").addEventListener("change", async () => {
|
||
let n = 0, skipped = 0;
|
||
for (const f of [...$("libfile").files]) {
|
||
try {
|
||
const obj = JSON.parse(await f.text());
|
||
const ctx = libCtx();
|
||
const r = readLibraryFile(obj, ctx);
|
||
if (!ctx.keys && r.keys) { /* no layout yet: the file's becomes the library's */
|
||
libMeta = { keys: r.keys, engines: Array.isArray(obj.engines) ? obj.engines : null, pe0: obj.pE0 ?? null };
|
||
try { await store.setMeta("layout", libMeta); } catch (e) { console.warn(e); }
|
||
}
|
||
if (obj.kind === "bank") r.patches.forEach((p) => { if (!p.tags.includes("bank")) p.tags.push("bank"); });
|
||
await libAdd(r.patches);
|
||
n += r.patches.length;
|
||
skipped += r.skipped;
|
||
} catch (e) { sayK("badfile", `${f.name}: ${e.message}`); return; }
|
||
}
|
||
sayK("imported", n + (skipped ? t("skippedN").replace("{n}", skipped) : t("patchesN")));
|
||
});
|
||
|
||
/* device bank */
|
||
function bankLoad(slot) {
|
||
if (!dev || !dev.bank || slot == null || libBusy) return;
|
||
if (isDrum()) { sayK("drumNoSound"); return; }
|
||
const s = dev.bank.slots[slot];
|
||
libOp(async () => {
|
||
selfLoad();
|
||
const rc = await bank.load(rqf, slot);
|
||
if (rc) { sayK("emptySlot", slotName(slot)); return; }
|
||
await afterSoundChange();
|
||
sayK("loadedUser", `${slotName(slot)} ${s.name}`);
|
||
});
|
||
}
|
||
$("bkload").addEventListener("click", () => bankLoad(bankSel));
|
||
$("bkstore").addEventListener("click", () => {
|
||
const slot = bankSel;
|
||
if (!dev || !dev.bank || slot == null) return;
|
||
if (isDrum()) { sayK("drumNoSound"); return; }
|
||
const s = dev.bank.slots[slot];
|
||
const name = prompt(t("promptNameAuto"), s.used ? s.name : "");
|
||
if (name == null) return;
|
||
if (s.used && !confirm(t("confirmOverwrite").replace("{n}", slotName(slot)).replace("{name}", s.name))) return;
|
||
libOp(async () => {
|
||
checkRc(await bank.store(rqf, slot, name.trim()));
|
||
await refreshSlot(slot);
|
||
sayK("storedSlot", `${slotName(slot)} ${dev.bank.slots[slot].name}`);
|
||
});
|
||
});
|
||
function bankGet(slot) {
|
||
if (!dev || !dev.bank || slot == null || libBusy) return;
|
||
libOp(async () => {
|
||
const u = await bank.get(rqf, dev.info, slot);
|
||
if (!u.used) { sayK("emptySlot", slotName(slot)); return; }
|
||
await libAdd([{ name: u.name, engine: u.engine, engineName: dev.info.engines[u.engine], p: u.p, pattern: u.pattern, tags: ["device"] }]);
|
||
sayK("copiedLib", u.name);
|
||
});
|
||
}
|
||
$("bkget").addEventListener("click", () => bankGet(bankSel));
|
||
$("bkerase").addEventListener("click", () => {
|
||
const slot = bankSel;
|
||
if (!dev || !dev.bank || slot == null) return;
|
||
const s = dev.bank.slots[slot];
|
||
if (!s.used || !confirm(t("confirmEraseSlot").replace("{n}", slotName(slot)).replace("{name}", s.name))) return;
|
||
libOp(async () => {
|
||
checkRc(await bank.erase(rqf, slot));
|
||
await refreshSlot(slot);
|
||
sayK("erasedSlot", slotName(slot));
|
||
});
|
||
});
|
||
$("bkrefresh").addEventListener("click", () => libOp(async () => {
|
||
sayK("readingBank");
|
||
dev.bank = await bank.list(rqf);
|
||
sayK("ready");
|
||
}));
|
||
$("bkexport").addEventListener("click", () => libOp(async () => {
|
||
const out = [];
|
||
for (const x of dev.bank.slots) {
|
||
if (!x.used) continue;
|
||
sayK("readingBank", ` ${slotName(x.slot)}`);
|
||
const u = await bank.get(rqf, dev.info, x.slot);
|
||
if (u.used) out.push({ name: u.name, engine: u.engine, engineName: dev.info.engines[u.engine], p: u.p, pattern: u.pattern, slot: x.slot });
|
||
}
|
||
download(`felucca-bank-${today()}.json`, libraryFile("bank", out, libCtx()));
|
||
sayK("ready");
|
||
}));
|
||
|
||
/* ================================================================ LIVE (2.7) === */
|
||
/* The LIVE page: the whole FM-1 under the hands for a show, from the computer, a tablet or a phone. What the FM-1's own
|
||
buttons do goes through LIVE (protocol v12, firmware editor_live.c: the same code as the buttons); the mix through
|
||
TRACK_MIX / TRACK_PARAM / SET; the notes as plain MIDI notes on the tracks' channels (no SysEx between a key and its
|
||
sound). The state (transport, sections, mutes, solos, the effect, the steps, the meters) is read about 8 times a
|
||
second while the page shows. An FM-1 before 2.7 (protocol < 12): the mix and the notes only. */
|
||
|
||
const LV = {
|
||
built: false, timer: 0, polling: false, s: null, at: 0, /* s: the last state (parse[CMD.LIVE]) */
|
||
tr: [], /* per track: {engine, preset, level, mute, p: [] (TRACK_DUMP)} */
|
||
touch: new Map(), /* "kind:i" -> time of the user's last change (their value wins for a moment) */
|
||
target: 0, oct: 4, vel: 100, dlv: 2, latch: false, fxHeld: -1,
|
||
held: new Map(), /* token -> {ch, note, track} */
|
||
stale: false, /* the selected track's values changed here: the other pages re-read when they show */
|
||
dump: 0, kitNames: null, ui: {},
|
||
pl: { songs: [], cur: -1, auto: true, loading: false, at: -1, pct: 0, restored: false }, /* the playlist */
|
||
};
|
||
const lvOk = () => !!dev && !!dev.info && dev.info.proto >= 12;
|
||
const lvTouched = (k) => performance.now() - (LV.touch.get(k) || 0) < 900;
|
||
const lvTouch = (k) => LV.touch.set(k, performance.now());
|
||
/* parameter ids by their labels (core.h P_* / params.c G_*; the numbers: 2.7's) */
|
||
const lvP = (label, def) => { const i = dev.pdesc.findIndex((d, k) => d && k < dev.info.pe0 && d.label === label); return i >= 0 ? i : def; };
|
||
const lvG = (label, def) => { const i = dev.gdesc.findIndex((d, k) => d && k > gEng() && d.label === label); return i >= 0 ? i : def; };
|
||
const lvGany = (label, def) => { const i = dev.gdesc.findIndex((d) => d && d.label === label); return i >= 0 ? i : def; };
|
||
const LVP = () => ({ pan: lvP("PAN", 39), filt: lvP("FILT", 50), rev: lvP("REV", 36), dly: lvP("DLY", 35), cho: lvP("CHO", 34), dst: lvP("DST", 33),
|
||
mode: lvP("MODE", 17), hold: lvP("HOLD", 23), mute: lvP("MUTE", 40) });
|
||
const LVG = () => ({ bpm: lvGany("BPM", 0), swing: lvGany("SWING", 1), filt: lvG("FILT", 29), dust: lvG("DUST", 27), duck: lvG("DUCK", 28),
|
||
drRev: lvG("REV", 26), drDly: lvG("DLY", 32), ch: [lvG("CH1", 33), lvG("CH2", 34), lvG("CH3", 35)], drCh: lvG("CH4", 24),
|
||
other: lvG("OTHER", 36), route: lvGany("IN", 14), fxCh: lvG("FX CH", 45), drMap: lvG("DR MAP", 46), remote: lvG("REMOTE", 47) });
|
||
const lvDrum = (i) => i === (dev && dev.info ? dev.info.ntrk || 4 : 4) - 1;
|
||
const lvGv = (id) => (dev && dev.dump ? dev.dump.g[id] : 0);
|
||
|
||
/* ---- requests: the buttons' ones go first in the queue and are never sent twice (a mute is a toggle) */
|
||
async function lvSend(op, ...a) {
|
||
if (!lvOk()) return null;
|
||
try {
|
||
const s = parse[CMD.LIVE](await rq(req.live(op, ...a), { front: true, retries: 0 }));
|
||
lvApply(s);
|
||
return s;
|
||
} catch (e) { report(e); return null; }
|
||
}
|
||
const lvKey = (layer, w, down) => lvSend(LIVE.KEY, layer, w, down ? 1 : 0);
|
||
async function lvTap(layer, w) { await lvKey(layer, w, true); await lvKey(layer, w, false); }
|
||
|
||
/* ---- the state, read while the page shows */
|
||
async function lvPoll() {
|
||
const d = dev;
|
||
if (!d || !d.dump || tab !== "live" || document.hidden || LV.polling || LV.pl.loading) return;
|
||
LV.polling = true;
|
||
try {
|
||
if (lvOk()) lvApply(parse[CMD.LIVE](await rq(req.live(LIVE.STATE), { key: "live:state", retries: 0, quiet: true })));
|
||
else if (Date.now() - LV.at > 600) { LV.at = Date.now(); await lvReadTracks(false); }
|
||
if (d === dev && Date.now() - LV.dump > 1500) { /* one track's sound a time: what the FM-1 changed shows */
|
||
LV.dump = Date.now();
|
||
LV.next = ((LV.next ?? -1) + 1) % (d.info.ntrk || 4);
|
||
await lvReadTrack(LV.next);
|
||
if (LV.next === 0) await lvReadTracks(false);
|
||
}
|
||
} catch (e) { if (e.message !== "closed" && !/^timeout/.test(e.message)) report(e); }
|
||
finally { LV.polling = false; }
|
||
}
|
||
function lvStart() {
|
||
if (LV.timer) return;
|
||
LV.timer = setInterval(lvPoll, 120);
|
||
lvPoll();
|
||
}
|
||
function lvStop() {
|
||
clearInterval(LV.timer);
|
||
LV.timer = 0;
|
||
lvAllOff();
|
||
if (LV.fxHeld >= 0) { lvSend(LIVE.FX, LV.fxHeld, 0); LV.fxHeld = -1; } /* (a latched effect too: the page is gone) */
|
||
}
|
||
async function lvReadTracks(dumps = true) {
|
||
const d = dev;
|
||
const tr = parse[CMD.TRACK](await rq(req.track(), { key: "live:track" }));
|
||
if (d !== dev) return;
|
||
tr.tracks.forEach((x, i) => {
|
||
const o = LV.tr[i] || (LV.tr[i] = { p: [] });
|
||
o.engine = x.engine; o.preset = x.preset;
|
||
if (!lvTouched("lv:" + i)) { o.level = x.level; o.mute = x.mute; }
|
||
});
|
||
LV.solo = tr.solo;
|
||
d.sel = tr.sel;
|
||
if (dumps) for (let i = 0; i < tr.ntrk; i++) await lvReadTrack(i);
|
||
lvRender();
|
||
}
|
||
async function lvReadTrack(i) {
|
||
const d = dev;
|
||
const r = parse[CMD.TRACK_DUMP](await rq(req.trackDump(i), { key: "live:dump:" + i }), d.info);
|
||
if (d !== dev) return;
|
||
const o = LV.tr[i] || (LV.tr[i] = { p: [] });
|
||
r.p.forEach((v, k) => { if (!lvTouched(`p:${i}:${k}`)) o.p[k] = v; });
|
||
o.engine = r.engine; o.preset = r.preset;
|
||
lvRenderStrip(i);
|
||
}
|
||
/* the drum kits' names: the drum track's KIT (DESC of P_E0 with the drum track selected) */
|
||
async function lvKits() {
|
||
if (dev.kitNames && dev.kitNames.length) { LV.kitNames = dev.kitNames; return; }
|
||
const ds = (dev.info.ntrk || 4) - 1, sel = dev.sel;
|
||
try {
|
||
if (sel !== ds) await rq(req.track(ds));
|
||
const kd = await getDescOrNull(0, dev.info.pe0);
|
||
if (kd && kd.label === "KIT") LV.kitNames = dev.kitNames = kd.names;
|
||
} finally { if (sel !== ds) await rq(req.track(sel)).catch(() => {}); }
|
||
}
|
||
|
||
/* ---- what the state shows */
|
||
function lvApply(s) {
|
||
if (!s || !dev) return;
|
||
const was = LV.s;
|
||
LV.s = s;
|
||
if (!lvTouched("g:bpm")) { const id = LVG().bpm; if (dev.dump.g[id] !== s.bpm) { dev.dump.g[id] = s.bpm; showValue(key(1, id), s.bpm, false); } }
|
||
s.tracks.forEach((x, i) => {
|
||
const o = LV.tr[i];
|
||
if (o && !lvTouched("lv:" + i)) o.mute = (s.mutes >> i) & 1;
|
||
});
|
||
LV.solo = s.solo;
|
||
if (s.sel !== dev.sel) { dev.sel = s.sel; LV.stale = true; }
|
||
if (MOCK && localAudio?.node && s.playing !== previewPlaying) { /* the mock: its local audio follows PLAY */
|
||
previewPlaying = s.playing; localAudio.play(s.playing); localAudio.sync(false); renderPreview();
|
||
} else if (MOCK && localAudio?.node && was && (was.mutes !== s.mutes || was.solo !== s.solo)) localAudio.sync(false);
|
||
lvRenderState();
|
||
}
|
||
|
||
/* ---- controls: a knob (drag up / down, the wheel, the arrow keys, double-click: its default) and a fader */
|
||
function lvArc(a0, a1, r = 18) {
|
||
const p = (a) => [24 + r * Math.cos(a), 24 + r * Math.sin(a)];
|
||
const [x0, y0] = p(a0), [x1, y1] = p(a1);
|
||
return `M${x0.toFixed(2)} ${y0.toFixed(2)} A${r} ${r} 0 ${Math.abs(a1 - a0) > Math.PI ? 1 : 0} ${a1 > a0 ? 1 : 0} ${x1.toFixed(2)} ${y1.toFixed(2)}`;
|
||
}
|
||
function lvDrag(e, node, o) { /* o: {min, max, get, set(v, final), def, step, vertical} */
|
||
const span = o.max - o.min, start = o.get(), y0 = e.clientY;
|
||
let last = start;
|
||
node.setPointerCapture(e.pointerId);
|
||
node.classList.add("drag");
|
||
const move = (ev) => {
|
||
const px = o.px || 160, d = (y0 - ev.clientY) * (ev.shiftKey ? 0.25 : 1);
|
||
const v = Math.max(o.min, Math.min(o.max, Math.round(start + d * span / px)));
|
||
if (v !== last) { last = v; o.set(v, false); }
|
||
};
|
||
const end = () => { node.removeEventListener("pointermove", move); node.removeEventListener("pointerup", end); node.removeEventListener("pointercancel", end);
|
||
node.classList.remove("drag"); o.set(last, true); };
|
||
node.addEventListener("pointermove", move);
|
||
node.addEventListener("pointerup", end);
|
||
node.addEventListener("pointercancel", end);
|
||
}
|
||
function lvSlider(node, o) {
|
||
node.setAttribute("role", "slider");
|
||
node.tabIndex = 0;
|
||
node.addEventListener("pointerdown", (e) => { if (e.button) return; e.preventDefault(); node.focus({ preventScroll: true }); lvDrag(e, node, o); });
|
||
node.addEventListener("dblclick", () => o.set(o.def, true));
|
||
node.addEventListener("wheel", (e) => { e.preventDefault(); o.set(Math.max(o.min, Math.min(o.max, o.get() + (e.deltaY < 0 ? 1 : -1) * (o.step || 1))), true); }, { passive: false });
|
||
node.addEventListener("keydown", (e) => {
|
||
const d = { ArrowUp: 1, ArrowRight: 1, ArrowDown: -1, ArrowLeft: -1, PageUp: 8, PageDown: -8 }[e.key];
|
||
if (!d) return;
|
||
e.preventDefault(); e.stopPropagation();
|
||
o.set(Math.max(o.min, Math.min(o.max, o.get() + d * (e.shiftKey ? 8 : o.step || 1))), true);
|
||
});
|
||
}
|
||
function lvKnob(label, o0) { /* o: {min, max, def, bip, get, set, fmt} */
|
||
/* (2.7) the knob redraws itself at each move: what it drives need not redraw it (the drum card's values did not move
|
||
until the next read: it felt like lag) */
|
||
const o = { ...o0, set: (v, f) => { o0.set(v, f); if (node.update) node.update(); } };
|
||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||
svg.setAttribute("viewBox", "0 0 48 48");
|
||
svg.setAttribute("aria-hidden", "true");
|
||
const bg = document.createElementNS(svg.namespaceURI, "path"), fg = document.createElementNS(svg.namespaceURI, "path");
|
||
bg.setAttribute("class", "kb"); fg.setAttribute("class", "kf");
|
||
bg.setAttribute("d", lvArc(Math.PI * 0.75, Math.PI * 2.25));
|
||
svg.append(bg, fg);
|
||
const val = el("span", { class: "kv" });
|
||
const node = el("div", { class: "lk", "aria-label": label }, svg, el("span", { class: "kl", text: label }), val);
|
||
lvSlider(node, o);
|
||
node._lvo = o; /* (LIVE pro: MIDI learn sets it; data-lvm names it) */
|
||
if (o.mid) node.dataset.lvm = o.mid;
|
||
node.update = () => {
|
||
const v = o.get(), f = (v - o.min) / (o.max - o.min || 1), a0 = Math.PI * 0.75, a1 = Math.PI * 2.25;
|
||
const z = o.bip ? (0 - o.min) / (o.max - o.min) : 0, az = a0 + z * (a1 - a0), av = a0 + f * (a1 - a0);
|
||
fg.setAttribute("d", Math.abs(av - az) < 0.02 ? "" : lvArc(Math.min(az, av), Math.max(az, av)));
|
||
val.textContent = o.fmt ? o.fmt(v) : String(v);
|
||
node.setAttribute("aria-valuenow", String(v));
|
||
node.setAttribute("aria-valuetext", val.textContent);
|
||
};
|
||
node.setAttribute("aria-valuemin", String(o.min));
|
||
node.setAttribute("aria-valuemax", String(o.max));
|
||
return node;
|
||
}
|
||
function lvFader(label, o0) { /* vertical: drag, wheel, keys; o.meter: 0..1 shown beside it */
|
||
const o = { ...o0, set: (v, f) => { o0.set(v, f); if (node.update) node.update(); } };
|
||
const fill = el("span", { class: "ff" }), cap = el("span", { class: "fc" }), meter = el("span", { class: "fm" }, el("i"));
|
||
const track = el("div", { class: "ft" }, fill, cap);
|
||
const node = el("div", { class: "lfd", "aria-label": label }, meter, track);
|
||
lvSlider(node, { ...o, px: 180 });
|
||
node._lvo = o;
|
||
if (o.mid) node.dataset.lvm = o.mid;
|
||
track.addEventListener("pointerdown", (e) => { /* a click on the track: the value there */
|
||
if (e.button || e.target === cap) return;
|
||
const r = track.getBoundingClientRect();
|
||
o.set(Math.round(o.min + (1 - (e.clientY - r.top) / r.height) * (o.max - o.min)), true);
|
||
});
|
||
node.update = () => {
|
||
const f = (o.get() - o.min) / (o.max - o.min || 1);
|
||
fill.style.height = (f * 100).toFixed(1) + "%";
|
||
cap.style.bottom = `calc(${(f * 100).toFixed(1)}% - 3px)`;
|
||
node.setAttribute("aria-valuenow", String(o.get()));
|
||
};
|
||
node.meter = (m) => { meter.firstChild.style.height = (Math.max(0, Math.min(1, m)) * 100).toFixed(1) + "%"; };
|
||
node.setAttribute("aria-valuemin", String(o.min));
|
||
node.setAttribute("aria-valuemax", String(o.max));
|
||
return node;
|
||
}
|
||
/* a button that holds while pressed (pointer, touch, Enter / Space): down(), up() */
|
||
function lvHold(node, down, up) {
|
||
let on = false;
|
||
const go = (e) => { if (on) return; on = true; node.classList.add("on"); down(e); };
|
||
const stop = () => { if (!on) return; on = false; node.classList.remove("on"); up(); };
|
||
node.addEventListener("pointerdown", (e) => { if (e.button) return; e.preventDefault(); node.setPointerCapture(e.pointerId); go(e); });
|
||
for (const n of ["pointerup", "pointercancel", "lostpointercapture"]) node.addEventListener(n, stop);
|
||
node.addEventListener("keydown", (e) => { if (e.key === "Enter" && !e.repeat) { e.preventDefault(); e.stopPropagation(); go(e); } });
|
||
node.addEventListener("keyup", (e) => { if (e.key === "Enter") { e.preventDefault(); e.stopPropagation(); stop(); } });
|
||
node.addEventListener("blur", stop);
|
||
node.press = () => go({}); /* (LIVE pro: a learned MIDI pad holds it) */
|
||
node.release = stop;
|
||
return node;
|
||
}
|
||
|
||
/* ---- the mix: level / mute (TRACK_MIX), the rest (TRACK_PARAM; the drum track's sends are globals) */
|
||
async function lvSetMix(i) {
|
||
const o = LV.tr[i];
|
||
try {
|
||
const r = await mixer.setMix(rq, i, o.level, o.mute, { key: "mix:" + i, front: true });
|
||
if (!dev.link.hasQueued("mix:" + i) && !lvTouched("lv:" + i)) { o.level = r.level; o.mute = r.mute; lvRenderStrip(i); }
|
||
} catch (e) { report(e); }
|
||
if (i === dev.sel) LV.stale = true;
|
||
if (dev.mix && dev.mix.tracks[i]) { dev.mix.tracks[i].level = o.level; dev.mix.tracks[i].mute = o.mute; }
|
||
}
|
||
function lvLevel(i, v) { LV.tr[i].level = v; lvTouch("lv:" + i); lvRenderStrip(i); lvSetMix(i); }
|
||
function lvMute(i, on) { LV.tr[i].mute = on ? 1 : 0; lvTouch("lv:" + i); lvRenderStrip(i); lvSetMix(i); }
|
||
async function lvParam(i, id, v) {
|
||
const o = LV.tr[i];
|
||
o.p[id] = v;
|
||
lvTouch(`p:${i}:${id}`);
|
||
lvRenderStrip(i);
|
||
if (i === dev.sel) { LV.stale = true; dev.dump.p[id] = v; }
|
||
try {
|
||
const r = parse[CMD.TRACK_PARAM](await rq(req.trackParam(i, id, v), { key: `tp:${i}:${id}`, front: true }));
|
||
if (!dev.link.hasQueued(`tp:${i}:${id}`) && !lvTouched(`p:${i}:${id}`)) { o.p[id] = r.value; lvRenderStrip(i); }
|
||
} catch (e) { report(e); }
|
||
}
|
||
function lvGlobal(id, v, final = true) {
|
||
lvTouch("g:" + id);
|
||
userSet(1, id, v, final);
|
||
lvRenderMaster();
|
||
lvRenderState();
|
||
for (let i = 0; i < LV.tr.length; i++) if (lvDrum(i)) lvRenderStrip(i);
|
||
}
|
||
async function lvSolo(i) {
|
||
if (!lvOk()) return;
|
||
LV.solo ^= 1 << i;
|
||
lvRenderStrip(i);
|
||
await lvTap(LIVE.LY_MIX, LIVE.SOLO + i);
|
||
}
|
||
/* the keys play this track: it is selected on the FM-1 too (REC records it; OTHER = SEL channels reach it) */
|
||
async function lvTarget(i) {
|
||
lvAllOff();
|
||
LV.target = i;
|
||
lvRenderPlay();
|
||
for (let k = 0; k < LV.tr.length; k++) lvRenderStrip(k);
|
||
lvxBuildPerf();
|
||
if (dev.sel === i) return;
|
||
try { dev.sel = parse[CMD.TRACK](await rq(req.track(i), { front: true })).sel; LV.stale = true; } catch (e) { report(e); }
|
||
lvRenderPlay();
|
||
lvxBuildPerf();
|
||
}
|
||
async function lvSound(i, e, p) { /* a sound for track i (PRESET acts on the selected track) */
|
||
const sel = dev.sel;
|
||
try {
|
||
if (sel !== i) await rq(req.track(i), { front: true });
|
||
selfLoad();
|
||
await rq(req.preset(e, p), { front: true });
|
||
if (sel !== i && LV.target !== i) await rq(req.track(sel)).catch(() => {});
|
||
else dev.sel = i;
|
||
LV.stale = true;
|
||
await lvReadTrack(i);
|
||
} catch (err) { report(err); }
|
||
}
|
||
|
||
/* ---- notes: plain MIDI on the track's channel; the drum track: its 16 sounds as GM notes, or 36.. with DR MAP 1-16 */
|
||
function lvChan(i) {
|
||
const g = LVG(), route = lvGv(g.route);
|
||
if (route === 1) return { err: "lvClock" };
|
||
if (route >= 2) return { ch: route - 2 }; /* IN = CH n: that channel, on the selected track */
|
||
const own = lvDrum(i) ? lvGv(g.drCh) : lvGv(g.ch[i]);
|
||
if (own) return { ch: own - 1 };
|
||
if (lvGv(g.other)) return { err: "lvNoChan" }; /* OTHER = OFF */
|
||
const used = new Set([...g.ch.map(lvGv), lvGv(g.drCh), lvGv(g.fxCh), lvGv(g.remote)].filter(Boolean).map((c) => c - 1));
|
||
for (let c = 15; c >= 0; c--) if (!used.has(c)) return { ch: c, sel: true }; /* a free channel plays the selected track */
|
||
return { err: "lvNoChan" };
|
||
}
|
||
const lvPro = () => lvOk() && !!(LV.s && LV.s.pro); /* (2.7) the firmware has the page's own ops 6..12 */
|
||
const LV_ROLL_LVL = [1, 2, 0, 3]; /* GHOST SOFT NORM HARD -> the FM-1's levels (core.h LV_*) */
|
||
const lvxLaneOf = (note) => (lvGv(LVG().drMap) ? (note - 36) & 15 : DRUM_LANES.findIndex(([n]) => n === note));
|
||
function lvNoteOn(token, track, note, vel) {
|
||
if (!dev || LV.held.has(token)) return;
|
||
if (LV.kmode && LV.kmode !== "play" && lvPro()) { /* (2.7) ROLL / ERASE while held, on the FM-1 itself */
|
||
const drum = lvDrum(track), nt = drum ? lvxLaneOf(note) : note & 127;
|
||
if (nt < 0) return;
|
||
if (LV.kmode === "roll") lvSend(LIVE.ROLL, track, nt, drum ? LV_ROLL_LVL[LV.dlv] : 0, 1);
|
||
else lvSend(LIVE.ERASE, track, nt, 1);
|
||
LV.held.set(token, { op: LV.kmode, track, note: nt });
|
||
return;
|
||
}
|
||
const c = lvChan(track);
|
||
if (c.err) { sayK(c.err); return; }
|
||
if (c.sel && dev.sel !== track) { lvTarget(track); return; }
|
||
dev.output.send([0x90 | c.ch, note & 127, Math.max(1, Math.min(127, vel | 0))]);
|
||
LV.held.set(token, { ch: c.ch, note, track });
|
||
if (!lvDrum(track)) LV.lastNote = note & 127; /* (LIVE pro: a step the grid adds plays this note) */
|
||
if (MOCK) startPreview().then((ok) => { if (ok && LV.held.get(token)) localAudio.note(track, note, true); }).catch(() => {});
|
||
}
|
||
function lvNoteOff(token) {
|
||
const h = LV.held.get(token);
|
||
if (!h) return;
|
||
LV.held.delete(token);
|
||
if (h.op) {
|
||
if (h.op === "roll") lvSend(LIVE.ROLL, h.track, h.note, 0, 0); else lvSend(LIVE.ERASE, h.track, h.note, 0);
|
||
document.querySelectorAll(`[data-tok="${CSS.escape(token)}"]`).forEach((b) => b.classList.remove("on"));
|
||
return;
|
||
}
|
||
try { dev && dev.output.send([0x80 | h.ch, h.note & 127, 0]); } catch (e) { /* unplugged */ }
|
||
if (MOCK) localAudio?.note(h.track, h.note, false);
|
||
document.querySelectorAll(`[data-tok="${CSS.escape(token)}"]`).forEach((b) => b.classList.remove("on"));
|
||
}
|
||
function lvAllOff() {
|
||
for (const tok of [...LV.held.keys()]) lvNoteOff(tok);
|
||
if (LV.fxHeld >= 0 && !LV.latch) { lvSend(LIVE.FX, LV.fxHeld, 0); LV.fxHeld = -1; }
|
||
if (LV.ui.fill && LV.ui.fill.release) LV.ui.fill.release();
|
||
}
|
||
const lvDrumNote = (lane) => (lvGv(LVG().drMap) ? 36 + lane : DRUM_LANES[lane][0]);
|
||
const LV_KEYS = ["a", "w", "s", "e", "d", "f", "t", "g", "y", "h", "u", "j", "k", "o", "l", "p"];
|
||
const LV_VEL = [40, 70, 100, 127]; /* GHOST SOFT NORM HARD */
|
||
|
||
/* ---- the effects: hold, or LATCH (one at a time, as on the FM-1) */
|
||
function lvFx(fx, on) {
|
||
if (!lvOk()) return;
|
||
if (on) { LV.fxHeld = fx; lvSend(LIVE.FX, fx, 1); }
|
||
else if (LV.fxHeld === fx) { LV.fxHeld = -1; lvSend(LIVE.FX, fx, 0); }
|
||
}
|
||
const LV_FX_GROUPS = [["lvFxLoops", [0, 1, 2, 3, 24, 4, 5, 6, 7, 19, 23]], ["lvFxTone", [8, 9, 16, 17, 18, 10]],
|
||
["lvFxColour", [11, 12, 20, 21, 14]], ["lvFxMove", [13, 15, 22, 25, 26]]];
|
||
|
||
/* ---- (2.7) the playlist: song files (Song & sections → Export this song), loaded one after the other. A song loads
|
||
with the FM-1 stopped (a few seconds of flash), then plays if "play when loaded" is on. The list is kept in this
|
||
browser (IndexedDB), and saved / opened as one file to take to a gig */
|
||
const PLF = { FORMAT: "sloop-playlist", VERSION: 1 };
|
||
async function plStore() {
|
||
try { await store.setMeta("playlist", { songs: LV.pl.songs, cur: LV.pl.cur, auto: LV.pl.auto }); } catch (e) { console.warn(e); }
|
||
}
|
||
async function plRestore() {
|
||
try {
|
||
const v = await store.getMeta("playlist");
|
||
if (v && Array.isArray(v.songs)) Object.assign(LV.pl, { songs: v.songs.filter((f) => { try { songObjects(f); return true; } catch (e) { return false; } }),
|
||
cur: v.cur ?? -1, auto: v.auto !== false });
|
||
} catch (e) { /* no storage: the list lives in this page only */ }
|
||
lvRenderPl();
|
||
}
|
||
async function plAddFiles(files) {
|
||
let bad = 0;
|
||
for (const f of files) {
|
||
try {
|
||
const obj = JSON.parse(await f.text());
|
||
if (obj && obj.format === PLF.FORMAT && Array.isArray(obj.songs)) {
|
||
for (const x of obj.songs) { songObjects(x); LV.pl.songs.push(x); }
|
||
if (Array.isArray(obj.scenes) && obj.scenes.some(Boolean) && confirm(t("lvxSetScenes"))) { /* LIVE pro: the set's scenes */
|
||
obj.scenes.slice(0, LVX.NSCENE).forEach((x, k) => { LVS.scenes[k] = x && x.v === 1 ? x : null; });
|
||
LVS.names = Array.isArray(obj.sceneNames) ? obj.sceneNames.slice(0, LVX.NSCENE) : [];
|
||
if (obj.midiMap && typeof obj.midiMap === "object") LVS.map = obj.midiMap;
|
||
lvxSave(); lvxRenderAll();
|
||
}
|
||
} else {
|
||
songObjects(obj);
|
||
if (!obj.name) obj.name = f.name.replace(/\.(sloopsong|json)$/i, "");
|
||
LV.pl.songs.push(obj);
|
||
}
|
||
} catch (e) { bad++; }
|
||
}
|
||
if (bad) sayK("songBadFile", ` (${bad})`);
|
||
plStore();
|
||
lvRenderPl();
|
||
}
|
||
async function lvSongGo(i) {
|
||
const pl = LV.pl, f = pl.songs[i];
|
||
if (!f || pl.loading || !dev || !dev.dump) return;
|
||
pl.loading = true;
|
||
pl.at = i;
|
||
pl.pct = 0;
|
||
lvRenderPl();
|
||
try {
|
||
if (LV.s && LV.s.playing) { await lvSend(LIVE.PLAY, 0); await sleep(150); }
|
||
lvAllOff();
|
||
busy++; /* (the editor's own polling waits) */
|
||
try { await songLoadUI(f, (d, n) => { pl.pct = Math.round(100 * d / n); lvRenderPl(); }); }
|
||
finally { busy--; }
|
||
pl.cur = i;
|
||
LV.stale = true;
|
||
plStore();
|
||
await lvReadTracks(true);
|
||
if (f.live && f.live.bpm) lvGlobal(LVX.BPM, f.live.bpm, true); /* (LIVE pro: the setlist's tempo for this song) */
|
||
sayK("sfLoaded", f.name || "");
|
||
if (pl.auto && lvOk()) await lvSend(LIVE.PLAY, 1);
|
||
} catch (e) { bkReport(e); }
|
||
finally { pl.loading = false; pl.at = -1; lvRenderPl(); }
|
||
}
|
||
const lvSongNext = () => { const n = LV.pl.songs.length; if (n) lvSongGo(LV.pl.cur + 1 < n ? LV.pl.cur + 1 : 0); };
|
||
function lvPlBuild() {
|
||
const U = LV.ui;
|
||
U.plFile = el("input", { type: "file", accept: ".sloopsong,.sloopset,.json,application/json", multiple: true, hidden: true });
|
||
U.plFile.addEventListener("change", () => { const fs = [...U.plFile.files]; U.plFile.value = ""; plAddFiles(fs); });
|
||
U.plAuto = el("button", { type: "button", class: "tog", text: t("plAuto"), onclick: () => { LV.pl.auto = !LV.pl.auto; plStore(); lvRenderPl(); } });
|
||
U.plNext = el("button", { type: "button", class: "pri", text: t("plNext") + " ▶", "data-lvm": "pl:next", onclick: lvSongNext });
|
||
U.plCue = el("div", { class: "lvcue" });
|
||
U.plList = el("ol", { class: "lvpl" });
|
||
U.plEmpty = el("p", { class: "dim lvhint", text: t("plEmpty") });
|
||
return el("div", { class: "card lvcard lvplbox" },
|
||
el("div", { class: "lvhead" }, el("h2", { text: t("plTitle") }), U.plNext),
|
||
U.plCue, U.plList, U.plEmpty,
|
||
el("p", { class: "bar lvplbar" },
|
||
el("button", { type: "button", text: t("plAdd"), onclick: () => U.plFile.click() }),
|
||
el("button", { type: "button", text: t("plSave"), onclick: () => download(`sloop-playlist-${today()}.sloopset`,
|
||
{ format: PLF.FORMAT, version: PLF.VERSION, songs: LV.pl.songs, scenes: LVS.scenes, sceneNames: LVS.names, midiMap: LVS.map }) }),
|
||
U.plAuto, U.plFile));
|
||
}
|
||
/* LIVE pro: a song's tempo (set when it loads) and its cue (a note for the stage), kept in the setlist */
|
||
function lvxSongEdit(i) {
|
||
const f = LV.pl.songs[i];
|
||
if (!f) return;
|
||
const bpm = prompt(t("lvxSongBpm"), f.live && f.live.bpm ? String(f.live.bpm) : "");
|
||
if (bpm == null) return;
|
||
const note = prompt(t("lvxSongNote"), f.live && f.live.note ? f.live.note : "");
|
||
if (note == null) return;
|
||
const b = Math.round(+bpm);
|
||
f.live = { bpm: b >= 40 && b <= 240 ? b : null, note: note.trim().slice(0, 120) };
|
||
plStore();
|
||
lvRenderPl();
|
||
}
|
||
function lvRenderPl() {
|
||
const U = LV.ui, pl = LV.pl;
|
||
if (!U.plList) return;
|
||
{ /* the cue: the song playing and its note, then the next one */
|
||
const cur = pl.songs[pl.cur], nx = pl.songs.length ? pl.songs[pl.cur + 1 < pl.songs.length ? pl.cur + 1 : 0] : null;
|
||
U.plCue.hidden = !cur && !nx;
|
||
U.plCue.replaceChildren(
|
||
cur ? el("p", {}, el("b", { text: cur.name || "SONG" }), el("span", { text: cur.live && cur.live.note ? " — " + cur.live.note : "" })) : "",
|
||
nx && nx !== cur ? el("p", { class: "dim" }, el("span", { text: t("lvxNext") + " " }), el("b", { text: nx.name || "SONG" }),
|
||
el("span", { text: nx.live && nx.live.note ? " — " + nx.live.note : "" })) : "");
|
||
}
|
||
U.plEmpty.hidden = !!pl.songs.length;
|
||
U.plNext.disabled = !pl.songs.length || pl.loading;
|
||
U.plAuto.setAttribute("aria-pressed", String(pl.auto));
|
||
const move = (i, d) => {
|
||
const j = i + d;
|
||
if (j < 0 || j >= pl.songs.length || pl.loading) return;
|
||
[pl.songs[i], pl.songs[j]] = [pl.songs[j], pl.songs[i]];
|
||
if (pl.cur === i) pl.cur = j; else if (pl.cur === j) pl.cur = i;
|
||
plStore(); lvRenderPl();
|
||
};
|
||
U.plList.replaceChildren(...pl.songs.map((f, i) => {
|
||
const cur = i === pl.cur, at = pl.loading && pl.at === i;
|
||
const secs = (f.objects || []).filter((o) => o.id >= 2).map((o) => "ABCD"[o.id - 2]).join("");
|
||
return el("li", { class: (cur ? "cur" : "") + (at ? " at" : "") },
|
||
el("button", { type: "button", class: "lvplgo", disabled: pl.loading, onclick: () => lvSongGo(i), title: t("plLoad") },
|
||
el("b", { text: f.name || "SONG" }), el("small", { text: at ? `${t("sfLoading")}${pl.pct} %` : secs + (f.live && f.live.bpm ? ` · ${f.live.bpm}` : "") })),
|
||
el("span", { class: "lvplact" },
|
||
el("button", { type: "button", text: "✎", title: t("lvxSongEdit"), "aria-label": t("lvxSongEdit"), disabled: pl.loading, onclick: () => lvxSongEdit(i) }),
|
||
el("button", { type: "button", text: "▲", title: t("plUp"), "aria-label": t("plUp"), disabled: !i || pl.loading, onclick: () => move(i, -1) }),
|
||
el("button", { type: "button", text: "▼", title: t("plDown"), "aria-label": t("plDown"), disabled: i === pl.songs.length - 1 || pl.loading, onclick: () => move(i, 1) }),
|
||
el("button", { type: "button", text: "✕", title: t("plRemove"), "aria-label": t("plRemove"), disabled: pl.loading,
|
||
onclick: () => { pl.songs.splice(i, 1); if (pl.cur === i) pl.cur = -1; else if (pl.cur > i) pl.cur--; plStore(); lvRenderPl(); } })));
|
||
}));
|
||
}
|
||
|
||
/* ---- the page */
|
||
function lvBuild() {
|
||
const box = $("lv");
|
||
const U = LV.ui = {};
|
||
const g = LVG();
|
||
/* transport */
|
||
U.play = el("button", { type: "button", class: "lvbig lvplay", "data-lvm": "play", onclick: () => lvSend(LIVE.PLAY, LV.s && LV.s.playing ? 0 : 1) });
|
||
U.rec = el("button", { type: "button", class: "lvrec", ic: "control_rec_f", "data-lvm": "rec", onclick: () => lvSend(LIVE.REC) });
|
||
U.undo = el("button", { type: "button", "data-lvm": "undo", onclick: () => lvSend(LIVE.UNDO, 0), text: t("lvUndo") });
|
||
U.redo = el("button", { type: "button", "data-lvm": "redo", onclick: () => lvSend(LIVE.UNDO, 1), text: t("lvRedo") });
|
||
const bpmD = dev.gdesc[g.bpm] || { min: 40, max: 240, def: 90 };
|
||
U.bpm = lvKnob(t("lvBpm"), { min: bpmD.min, max: bpmD.max, def: bpmD.def, get: () => lvGv(g.bpm), set: (v, f) => lvGlobal(g.bpm, v, f), mid: "g:0" });
|
||
U.bpm.classList.add("lvbpm");
|
||
U.tap = el("button", { type: "button", text: t("lvTap"), "data-lvm": "tap", onclick: () => lvTap(LIVE.LY_MIX, LIVE.TAP) });
|
||
const swD = dev.gdesc[g.swing] || { min: 0, max: 100, def: 0 };
|
||
U.swing = lvKnob(t("lvSwing"), { min: swD.min, max: swD.max, def: swD.def, get: () => lvGv(g.swing), set: (v, f) => lvGlobal(g.swing, v, f), mid: "g:1" });
|
||
U.pos = el("div", { class: "lvpos" });
|
||
U.loop = el("button", { type: "button", class: "tog", "data-lvm": "loop", onclick: () => { if (!LV.s || LV.s.songMode) lvTap(LIVE.LY_SONG, LIVE.SONG); } , text: t("lvLoop") });
|
||
U.song = el("button", { type: "button", class: "tog", "data-lvm": "song", onclick: () => { if (!LV.s || !LV.s.songMode) lvTap(LIVE.LY_SONG, LIVE.SONG); }, text: t("lvSong") });
|
||
U.srec = el("button", { type: "button", class: "tog", "data-lvm": "songrec", onclick: () => lvTap(LIVE.LY_SONG, LIVE.SONG_REC), text: t("lvSongRec") });
|
||
U.fill = lvHold(el("button", { type: "button", class: "lvfill", "data-lvm": "fill" }, el("b", { text: t("lvFill") }), el("small", { text: t("lvFillHold") })),
|
||
() => lvKey(LIVE.LY_MIX, LIVE.FILL, true), () => lvKey(LIVE.LY_MIX, LIVE.FILL, false));
|
||
U.fillbar = el("button", { type: "button", class: "tog", "data-lvm": "fillbar", onclick: () => lvTap(LIVE.LY_MIX, LIVE.FILL_BAR), text: t("lvFillBar") });
|
||
U.cpu = el("span", { class: "lvcpu dim" });
|
||
U.full = el("button", { type: "button", class: "lvfull", onclick: lvFull });
|
||
U.panic = el("button", { type: "button", class: "warn", "data-lvm": "panic", onclick: () => { lvAllOff(); if (LV.s && LV.s.fx >= 0) lvSend(LIVE.FX, LV.s.fx, 0); }, text: t("lvPanic") });
|
||
U.needs = el("p", { class: "lvneeds", text: t("lvNeeds") });
|
||
const transport = el("div", { class: "card lvcard lvtrans" },
|
||
el("div", { class: "lvgrp" }, U.play, U.rec, el("span", { class: "lvundo" }, U.undo, U.redo)),
|
||
el("div", { class: "lvgrp" }, U.bpm, U.tap, U.swing, U.pos),
|
||
el("div", { class: "lvgrp" }, el("span", { class: "seg" }, U.loop, U.song), U.srec, U.fill, U.fillbar),
|
||
el("div", { class: "lvgrp lvright" }, U.cpu, U.panic, U.full), lvxBuildTools(),
|
||
el("div", { class: "lvlearnbar" }, U.learnMsg, U.learnClear));
|
||
/* sections */
|
||
U.secs = [0, 1, 2, 3].map((k) => {
|
||
const b = el("button", { type: "button", class: "lvsec", style: `--c:${TCOL[k]}`, "data-lvm": "sec:" + k, onclick: () => lvTap(LIVE.LY_SONG, LIVE.SEC + k) },
|
||
el("b", { text: "ABCD"[k] }), el("small", {}));
|
||
return b;
|
||
});
|
||
U.stores = [0, 1, 2, 3].map((k) => el("button", { type: "button", class: "lvstore", text: "ABCD"[k], onclick: () => lvStore(k) }));
|
||
/* (2.7) a chain: sections in a row, each for its bars, looped (as SAVE + several keys) */
|
||
LV.chain = LV.chain || [];
|
||
U.chainList = el("span", { class: "lvchainlist" });
|
||
U.chainAdd = [0, 1, 2, 3].map((k) => el("button", { type: "button", class: "lvstore", text: "ABCD"[k], "data-lvm": "chain:" + k,
|
||
onclick: () => { if (LV.chain.length < LIVE.CHAIN_MAX) LV.chain.push(k); lvxRenderChain(); } }));
|
||
U.chainGo = el("button", { type: "button", class: "pri", text: t("lvxChainPlay"), "data-lvm": "chain:play", onclick: () => {
|
||
if (!LV.s || !LV.s.playing) { sayK("lvxChainStopped"); return; }
|
||
lvSend(LIVE.CHAIN, LV.chain.length, ...LV.chain);
|
||
} });
|
||
U.chainStop = el("button", { type: "button", text: t("lvxChainStop"), "data-lvm": "chain:stop", onclick: () => lvSend(LIVE.CHAIN, 0) });
|
||
U.chainClear = el("button", { type: "button", text: "✕", "aria-label": t("lvxChainClear"), title: t("lvxChainClear"), onclick: () => { LV.chain = []; lvxRenderChain(); } });
|
||
const secs = el("div", { class: "card lvcard lvsecs" },
|
||
el("h2", { text: t("lvSections") }),
|
||
el("div", { class: "lvsecrow" }, ...U.secs),
|
||
el("p", { class: "lvstorerow dim" }, el("span", { text: t("lvStore") }), ...U.stores),
|
||
el("p", { class: "lvstorerow dim lvxpro" }, el("span", { text: t("lvxChain") }), ...U.chainAdd, U.chainList, U.chainClear, U.chainGo, U.chainStop),
|
||
el("p", { class: "dim lvhint", text: t("lvSecHint") }));
|
||
/* master fx */
|
||
const mk = (lbl, id, bip) => { const d = dev.gdesc[id] || { min: bip ? -64 : 0, max: bip ? 63 : 127, def: 0 };
|
||
return lvKnob(lbl, { min: d.min, max: d.max, def: d.def, bip, get: () => lvGv(id), set: (v, f) => lvGlobal(id, v, f), mid: "g:" + id }); };
|
||
U.master = [mk(t("lvFilter"), g.filt, true), mk(t("lvDust"), g.dust), mk(t("lvDuck"), g.duck)];
|
||
/* (2.7) the master level from here (the MASTER knob takes it back when turned) and the THROWs (as FX + OCT- / OCT+) */
|
||
U.vol = lvKnob(t("lvxVolume"), { min: 0, max: 126, def: 100, mid: "master", get: () => (LV.volAt && performance.now() - LV.volAt < 1500 ? LV.vol : LV.s && LV.s.master >= 0 ? LV.s.master : LV.vol ?? 100),
|
||
set: (v) => { LV.vol = v; LV.volAt = performance.now(); lvSend(LIVE.MASTER, v); }, fmt: (v) => (LV.s && LV.s.master < 0 ? t("lvxKnob") : String(v)) });
|
||
U.volKnob = el("button", { type: "button", class: "tog", text: t("lvxKnob"), "data-lvm": "master:knob", onclick: () => lvSend(LIVE.MASTER, 127) });
|
||
const thr = (bit, lbl) => {
|
||
const b = lvHold(el("button", { type: "button", class: "lvthrow", text: t(lbl), "data-lvm": "throw:" + bit }),
|
||
() => { LV.thr = (LV.thr || 0) | bit; lvSend(LIVE.THROW, LV.thr); }, () => { LV.thr = (LV.thr || 0) & ~bit; lvSend(LIVE.THROW, LV.thr); });
|
||
return b;
|
||
};
|
||
U.throws = [thr(1, "lvxThrowRev"), thr(2, "lvxThrowEcho")];
|
||
const master = el("div", { class: "card lvcard lvmaster" }, el("h2", { text: t("lvMaster") }), el("div", { class: "lvknobs" }, ...U.master),
|
||
el("div", { class: "lvknobs lvxpro" }, U.vol, U.volKnob, ...U.throws));
|
||
/* mixer */
|
||
U.strips = [];
|
||
const n = dev.info.ntrk || 4;
|
||
for (let i = 0; i < n; i++) U.strips.push(lvStrip(i));
|
||
const mixerBox = el("div", { class: "card lvcard lvmix" }, el("h2", { text: t("lvMixer") }), el("div", { class: "lvstrips" }, ...U.strips.map((s) => s.node)));
|
||
/* effects */
|
||
U.fx = [];
|
||
U.latch = el("button", { type: "button", class: "tog", text: t("lvLatch"), "data-lvm": "latch", onclick: () => { LV.latch = !LV.latch; if (!LV.latch && LV.fxHeld >= 0) lvFx(LV.fxHeld, false); lvRenderFx(); } });
|
||
const groups = LV_FX_GROUPS.map(([k, list]) => el("div", { class: "lvfxg" }, el("span", { class: "dim", text: t(k) }),
|
||
el("div", { class: "lvfxpads" }, ...list.map((fx) => {
|
||
const b = el("button", { type: "button", class: "lvfx", "data-lvm": "fx:" + fx }, el("b", { text: LIVE.FX_NAMES[fx] }), fx < 16 ? el("kbd", { text: "⇧" + LV_KEYS[fx].toUpperCase() }) : "");
|
||
lvHold(b, () => { if (LV.latch) lvFx(fx, LV.fxHeld !== fx); else lvFx(fx, true); }, () => { if (!LV.latch) lvFx(fx, false); });
|
||
U.fx[fx] = b;
|
||
return b;
|
||
}))));
|
||
const fxBox = el("div", { class: "card lvcard lvfxbox" }, el("div", { class: "lvhead" }, el("h2", { text: t("lvFx") }), U.latch),
|
||
el("p", { class: "dim lvhint", text: t("lvFxHint") }), ...groups);
|
||
/* the keys */
|
||
U.targets = [0, 1, 2, 3].slice(0, n).map((i) => el("button", { type: "button", class: "tog", style: `--trk:${TCOL[i]}`, text: lvDrum(i) ? "D" : String(i + 1), onclick: () => lvTarget(i) }));
|
||
U.octDn = el("button", { type: "button", text: "−", "aria-label": t("lvOct") + " −", onclick: () => { LV.oct = Math.max(1, LV.oct - 1); lvRenderPlay(); } });
|
||
U.octUp = el("button", { type: "button", text: "+", "aria-label": t("lvOct") + " +", onclick: () => { LV.oct = Math.min(7, LV.oct + 1); lvRenderPlay(); } });
|
||
U.octV = el("span", { class: "lvoct" });
|
||
U.vel = el("input", { type: "range", min: 1, max: 127, value: LV.vel, "aria-label": t("lvVel") });
|
||
U.vel.addEventListener("input", () => { LV.vel = +U.vel.value; U.vel.style.setProperty("--p", (LV.vel / 127 * 100).toFixed(1) + "%"); });
|
||
U.lvls = LV_VEL.map((_, k) => el("button", { type: "button", text: t("lvLvl")[k], onclick: () => { LV.dlv = k; lvRenderPlay(); } }));
|
||
U.arp = el("select", { "aria-label": t("lvArp") });
|
||
U.arp.addEventListener("change", () => lvParam(LV.target, LVP().mode, +U.arp.value));
|
||
U.hold = el("button", { type: "button", class: "tog", text: t("lvHold"), onclick: () => lvParam(LV.target, LVP().hold, LV.tr[LV.target].p[LVP().hold] ? 0 : 1) });
|
||
/* (2.7) what the keys do: play, ROLL (note repeat while held, as ARP + key) or ERASE (as EDIT + key) */
|
||
LV.kmode = LV.kmode || "play";
|
||
U.kmodes = ["play", "roll", "erase"].map((m) => el("button", { type: "button", text: t("lvxK_" + m), "data-lvm": "kmode:" + m,
|
||
onclick: () => { lvAllOff(); LV.kmode = m; lvRenderPlay(); } }));
|
||
U.kmodeBox = el("span", { class: "lvgrp lvxpro" }, el("span", { class: "seg" }, ...U.kmodes));
|
||
U.rollRate = el("span", { class: "lvxpro lvrollrate" });
|
||
U.chanMsg = el("p", { class: "bad lvchan", hidden: true });
|
||
U.keys = el("div", { class: "lvkeys" });
|
||
U.pads = el("div", { class: "lvpads" });
|
||
const playBox = el("div", { class: "card lvcard lvplaybox" },
|
||
el("div", { class: "lvhead" }, el("h2", { text: t("lvKeys") }),
|
||
el("span", { class: "lvgrp" }, el("span", { class: "dim", text: t("lvTrack") }), el("span", { class: "seg" }, ...U.targets)),
|
||
el("span", { class: "lvgrp lvsynth" }, el("span", { class: "dim", text: t("lvOct") }), U.octDn, U.octV, U.octUp),
|
||
el("label", { class: "lvgrp lvsynth" }, el("span", { class: "dim", text: t("lvVel") }), U.vel),
|
||
el("span", { class: "lvgrp lvdrumv seg" }, ...U.lvls),
|
||
el("label", { class: "lvgrp lvsynth" }, el("span", { class: "dim", text: t("lvArp") }), U.arp), el("span", { class: "lvsynth" }, U.hold),
|
||
U.kmodeBox, U.rollRate),
|
||
U.chanMsg, U.keys, U.pads);
|
||
/* LIVE pro: the PERFORM card (the track the keys play) */
|
||
U.perfTrk = el("span", { class: "lvperftrk" });
|
||
U.perfTabs = LVX_TABS.map((k) => el("button", { type: "button", role: "tab", class: "lvptab", "data-tab": k, text: t("lvxTab_" + k),
|
||
onclick: () => { LVS.tab = k; lvxBuildPerf(); } }));
|
||
U.perfBody = el("div", { class: "lvperfbody" });
|
||
U.perf = el("div", { class: "card lvcard lvperf" },
|
||
el("div", { class: "lvhead" }, el("h2", { text: t("lvxPerform") }), U.perfTrk, el("span", { class: "lvptabs", role: "tablist" }, ...U.perfTabs)), U.perfBody);
|
||
const scenes = lvxBuildScenes(), plBox = lvPlBuild();
|
||
/* every card: what it is in one line, its "?" for how to use it (LIVE pro: a page a newcomer can read) */
|
||
[[transport, "transport"], [secs, "sections"], [scenes, "scenes"], [mixerBox, "mixer"], [playBox, "keys"], [U.perf, "perform"],
|
||
[fxBox, "fx"], [master, "master"], [plBox, "playlist"]].forEach(([c, k]) => lvxDecorate(c, k));
|
||
for (const c of [scenes, U.perf, plBox]) c.classList.add("lvadv"); /* (the "essentials" view hides them) */
|
||
box.replaceChildren(U.needs, lvxBuildGuide(), transport, secs, scenes,
|
||
el("div", { class: "lvcols" }, el("div", { class: "lvmain" }, mixerBox, playBox, U.perf), el("div", { class: "lvside" }, fxBox, master, plBox)),
|
||
el("p", { class: "dim lvkeyshelp", text: t("lvShortcuts") }));
|
||
lvBuildKeys();
|
||
LV.built = dev;
|
||
LV.lang = lang;
|
||
lvxBuildPerf();
|
||
lvxTips();
|
||
lvxRenderAll();
|
||
}
|
||
function lvStrip(i) {
|
||
const drum = lvDrum(i), P = LVP(), g = LVG();
|
||
const tr = () => LV.tr[i] || { p: [] };
|
||
const pd = (id, d) => dev.pdesc[id] || d;
|
||
const lvD = (drum ? dev.gdesc[gDrLvl()] : dev.pdesc[P.LEVEL ?? 0]) || { min: 0, max: 127, def: 100 };
|
||
const s = {};
|
||
s.name = el("div", { class: "lsname" });
|
||
s.sound = el("select", { class: "lssound", "aria-label": t(drum ? "lvKit" : "lvSound") });
|
||
s.sound.addEventListener("change", () => {
|
||
if (drum) lvParam(i, dev.info.pe0, +s.sound.value);
|
||
else if (s.sound.value.startsWith("u:")) lvxUser(i, +s.sound.value.slice(2));
|
||
else { const [e, p] = s.sound.value.split(":").map(Number); lvSound(i, e, p); }
|
||
});
|
||
s.prev = el("button", { type: "button", class: "lsnav", text: "‹", "aria-label": "previous", "data-lvm": `s${i}:prev`, onclick: () => lvStep(i, -1) });
|
||
s.next = el("button", { type: "button", class: "lsnav", text: "›", "aria-label": "next", "data-lvm": `s${i}:next`, onclick: () => lvStep(i, 1) });
|
||
s.fav = el("button", { type: "button", class: "lsfav", text: "☆", title: t("lvxFavToggle"), "aria-label": t("lvxFavToggle"), onclick: () => lvxFav(i) });
|
||
s.fader = lvFader(t("lvLevel") + " " + (i + 1), { min: 0, max: 127, def: lvD.def ?? 100, get: () => tr().level ?? 0, set: (v) => lvLevel(i, v), mid: `s${i}:lvl` });
|
||
s.mute = el("button", { type: "button", class: "tog lsmute", text: t("lvMute"), "data-lvm": `s${i}:mute`, onclick: () => lvMute(i, !tr().mute) });
|
||
s.solo = el("button", { type: "button", class: "tog lssolo", text: t("lvSolo"), "data-lvm": `s${i}:solo`, onclick: () => lvSolo(i) });
|
||
s.sel = el("button", { type: "button", class: "tog lssel", "data-lvm": `s${i}:sel`, onclick: () => lvTarget(i) });
|
||
s.prog = el("div", { class: "lsprog" }, el("i"));
|
||
const kn = (lbl, id, bip, glob) => {
|
||
const d = glob ? (dev.gdesc[id] || { min: 0, max: 127, def: 0 }) : pd(id, { min: bip ? -64 : 0, max: bip ? 63 : 127, def: 0 });
|
||
return lvKnob(lbl, { min: d.min, max: d.max, def: d.def, bip,
|
||
get: () => (glob ? lvGv(id) : tr().p[id] ?? 0), set: (v, f) => (glob ? lvGlobal(id, v, f) : lvParam(i, id, v)), mid: glob ? `g:${id}` : `s${i}:${id}` });
|
||
};
|
||
s.knobs = drum
|
||
? [kn(t("lsFilt"), P.filt, true), kn(t("lsPan"), P.pan, true), kn(t("lsRev"), g.drRev, false, true), kn(t("lsDly"), g.drDly, false, true)]
|
||
: [kn(t("lsFilt"), P.filt, true), kn(t("lsPan"), P.pan, true), kn(t("lsRev"), P.rev), kn(t("lsDly"), P.dly), kn(t("lsCho"), P.cho), kn(t("lsDrv"), P.dst)];
|
||
s.node = el("div", { class: "lstrip" + (drum ? " drum" : ""), style: `--c:${TCOL[i % 4]}`, role: "group", "aria-label": `${t("lvTrack")} ${i + 1}` },
|
||
el("div", { class: "lshead" }, el("span", { class: "lsnum", text: drum ? "D" : String(i + 1) }), s.name, drum ? "" : s.fav),
|
||
el("div", { class: "lssnd" }, s.prev, s.sound, s.next), s.prog,
|
||
el("div", { class: "lsbody" }, s.fader, el("div", { class: "lsknobs" }, ...s.knobs)),
|
||
el("div", { class: "lsbtns" }, s.mute, s.solo, s.sel));
|
||
return s;
|
||
}
|
||
/* the next / previous sound of the track's engine (the drum track: kit) */
|
||
function lvStep(i, d) {
|
||
const o = LV.tr[i];
|
||
if (!o) return;
|
||
if (lvDrum(i)) {
|
||
const nk = (LV.kitNames || []).length || 46, v = ((o.p[dev.info.pe0] ?? 0) + d + nk) % nk;
|
||
lvParam(i, dev.info.pe0, v);
|
||
return;
|
||
}
|
||
const names = dev.names[o.engine] || [];
|
||
if (!names.length) return;
|
||
lvSound(i, o.engine, ((o.preset ?? 0) + d + names.length) % names.length);
|
||
}
|
||
async function lvStore(k) {
|
||
if (!lvOk()) return;
|
||
const used = LV.s && (LV.s.ready >> k) & 1;
|
||
if (used && !confirm(t("lvStoreAsk").replace("{x}", "ABCD"[k]))) return;
|
||
if (used) await lvTap(LIVE.LY_SONG, LIVE.STORE + k); /* (over a used section the FM-1 asks for a second press) */
|
||
const s = await lvTap(LIVE.LY_SONG, LIVE.STORE + k);
|
||
dev.slotUsed[k] = true;
|
||
sayK("lvStored", "ABCD"[k]);
|
||
return s;
|
||
}
|
||
function lvBuildKeys() {
|
||
const U = LV.ui;
|
||
/* two octaves and a C: 15 white keys, the black ones over them */
|
||
const whites = [], blacks = [];
|
||
const W = [0, 2, 4, 5, 7, 9, 11], B = [[1, 0], [3, 1], [6, 3], [8, 4], [10, 5]];
|
||
for (let o = 0; o < 2; o++) {
|
||
W.forEach((s, k) => whites.push({ semi: o * 12 + s, x: o * 7 + k }));
|
||
B.forEach(([s, k]) => blacks.push({ semi: o * 12 + s, x: o * 7 + k }));
|
||
}
|
||
whites.push({ semi: 24, x: 14 });
|
||
const key = (k, black) => {
|
||
const b = el("button", { type: "button", class: black ? "bk" : "wk", style: `--x:${k.x}`, "data-semi": k.semi });
|
||
const tok = "lvk:" + k.semi;
|
||
b.dataset.tok = tok;
|
||
const ki = k.semi < 16 ? LV_KEYS[k.semi] : null;
|
||
if (ki) b.append(el("kbd", { text: ki.toUpperCase() }));
|
||
lvHold(b, () => { lvNoteOn(tok, LV.target, (LV.oct + 1) * 12 + k.semi, LV.vel); b.classList.add("on"); }, () => lvNoteOff(tok));
|
||
return b;
|
||
};
|
||
U.keys.replaceChildren(...whites.map((k) => key(k, false)), ...blacks.map((k) => key(k, true)));
|
||
U.padBtns = DRUM_LANES.map(([, name], lane) => {
|
||
const b = el("button", { type: "button", class: "lvpad", "data-lvm": "pad:" + lane }, el("b", { text: name }), el("kbd", { text: LV_KEYS[lane].toUpperCase() }));
|
||
const tok = "lvp:" + lane;
|
||
b.dataset.tok = tok;
|
||
lvHold(b, () => { lvNoteOn(tok, LV.target, lvDrumNote(lane), LV_VEL[LV.dlv]); b.classList.add("on"); }, () => lvNoteOff(tok));
|
||
return b;
|
||
});
|
||
U.pads.replaceChildren(...U.padBtns);
|
||
}
|
||
|
||
function lvRender() {
|
||
if (!dev || !dev.dump || tab !== "live") return;
|
||
if (LV.built !== dev || LV.lang !== lang) lvBuild();
|
||
LV.ui.needs.hidden = lvOk();
|
||
for (let i = 0; i < LV.ui.strips.length; i++) lvRenderStrip(i);
|
||
lvRenderMaster();
|
||
lvRenderPlay();
|
||
lvRenderFx();
|
||
lvRenderPl();
|
||
lvRenderState();
|
||
lvxRenderAll();
|
||
}
|
||
function lvRenderStrip(i) {
|
||
const s = LV.ui.strips && LV.ui.strips[i], o = LV.tr[i];
|
||
if (!s || !o || LV.built !== dev) return;
|
||
const drum = lvDrum(i);
|
||
const nm = drum ? (LV.kitNames || [])[o.p[dev.info.pe0]] || "DRUMS" : (dev.names[o.engine] || [])[o.preset] || "";
|
||
s.name.textContent = drum ? "DRUMS" : dev.info.engines[o.engine] || "";
|
||
/* the sound picker: the engine's presets (any engine: grouped), the drum track: the kits */
|
||
const sig = drum ? "k" + (LV.kitNames || []).length : "e" + dev.names.length + ":" + [...LVS.favs].join(",") + ":" + (dev.bank ? dev.bank.slots.map((x) => x.used ? x.name : "").join("|") : "");
|
||
if (s.sound.dataset.sig !== sig) {
|
||
s.sound.dataset.sig = sig;
|
||
if (drum) s.sound.replaceChildren(...(LV.kitNames || []).map((n, k) => el("option", { value: String(k), text: n })));
|
||
else s.sound.replaceChildren(...lvxSoundOptions(false), ...dev.names.map((names, e) => el("optgroup", { label: dev.info.engines[e] },
|
||
...(names || []).map((n, p) => el("option", { value: `${e}:${p}`, text: n })))));
|
||
}
|
||
if (s.fav) { const on = LVS.favs.has(lvxFavKey(o.engine, o.preset)); s.fav.textContent = on ? "★" : "☆"; s.fav.setAttribute("aria-pressed", String(on)); }
|
||
const want = drum ? String(o.p[dev.info.pe0] ?? 0) : `${o.engine}:${o.preset}`;
|
||
if (document.activeElement !== s.sound && s.sound.value !== want) s.sound.value = want;
|
||
s.sound.title = nm;
|
||
s.fader.update();
|
||
s.knobs.forEach((k) => k.update());
|
||
const muted = !!o.mute, solo = !!((LV.solo >> i) & 1);
|
||
s.mute.setAttribute("aria-pressed", String(muted));
|
||
s.solo.setAttribute("aria-pressed", String(solo));
|
||
s.solo.disabled = !lvOk(); /* (solo: the GLO keys, 2.7) */
|
||
s.node.classList.toggle("muted", muted || (!!LV.solo && !solo));
|
||
const target = LV.target === i;
|
||
s.sel.setAttribute("aria-pressed", String(target));
|
||
s.sel.textContent = t(target ? "lvSelOn" : "lvSel");
|
||
s.node.classList.toggle("target", target);
|
||
if (target) lvxRenderPerf();
|
||
}
|
||
function lvRenderMaster() {
|
||
if (!LV.ui.master) return;
|
||
LV.ui.master.forEach((k) => k.update());
|
||
LV.ui.bpm.update();
|
||
LV.ui.swing.update();
|
||
}
|
||
function lvRenderPlay() {
|
||
const U = LV.ui;
|
||
if (!U.keys) return;
|
||
const drum = lvDrum(LV.target), o = LV.tr[LV.target] || { p: [] }, P = LVP();
|
||
U.targets.forEach((b, i) => b.setAttribute("aria-pressed", String(i === LV.target)));
|
||
U.keys.hidden = drum;
|
||
U.pads.hidden = !drum;
|
||
document.querySelectorAll("#lv .lvsynth").forEach((x) => { x.hidden = drum; });
|
||
document.querySelectorAll("#lv .lvdrumv").forEach((x) => { x.hidden = !drum; });
|
||
U.lvls.forEach((b, k) => b.setAttribute("aria-pressed", String(k === LV.dlv)));
|
||
U.octV.textContent = `C${LV.oct}–C${LV.oct + 2}`;
|
||
U.vel.style.setProperty("--p", (LV.vel / 127 * 100).toFixed(1) + "%");
|
||
U.keys.style.setProperty("--trk", TCOL[LV.target % 4]);
|
||
U.pads.style.setProperty("--trk", TCOL[3]);
|
||
const md = dev.pdesc[P.mode];
|
||
if (md && md.names && U.arp.options.length !== md.names.length) U.arp.replaceChildren(...md.names.map((n, k) => el("option", { value: String(k), text: n })));
|
||
if (!drum && document.activeElement !== U.arp) U.arp.value = String(o.p[P.mode] ?? 0);
|
||
U.hold.setAttribute("aria-pressed", String(!!o.p[P.hold]));
|
||
const c = lvChan(LV.target);
|
||
U.chanMsg.hidden = !c.err || (LV.kmode !== "play" && lvPro());
|
||
if (c.err) U.chanMsg.textContent = t(c.err);
|
||
U.kmodes.forEach((b, k) => b.setAttribute("aria-pressed", String(["play", "roll", "erase"][k] === LV.kmode)));
|
||
U.keys.classList.toggle("roll", LV.kmode === "roll"); U.keys.classList.toggle("erase", LV.kmode === "erase");
|
||
U.pads.classList.toggle("roll", LV.kmode === "roll"); U.pads.classList.toggle("erase", LV.kmode === "erase");
|
||
if (!U.rollRate.firstChild && dev.gdesc[30]) U.rollRate.append(lvxCtl(1, 30, LV.target, dev.gdesc[30], t("lvxRollRate")));
|
||
U.rollRate.hidden = LV.kmode !== "roll";
|
||
if (U.rollRate.firstChild && U.rollRate.firstChild.update) U.rollRate.firstChild.update();
|
||
}
|
||
function lvxRenderChain() {
|
||
const U = LV.ui;
|
||
if (!U.chainList) return;
|
||
const s = LV.s, run = s && s.chainN >= 2;
|
||
U.chainList.textContent = LV.chain.length ? LV.chain.map((k) => "ABCD"[k]).join(" ") : t("lvxChainEmpty");
|
||
U.chainList.classList.toggle("run", !!run);
|
||
U.chainGo.disabled = LV.chain.length < 2;
|
||
U.chainStop.disabled = !run;
|
||
}
|
||
function lvRenderFx() {
|
||
const U = LV.ui;
|
||
if (!U.fx) return;
|
||
const cur = LV.s ? LV.s.fx : -1;
|
||
U.fx.forEach((b, fx) => { if (b) { b.classList.toggle("act", fx === cur); b.disabled = !lvOk(); } });
|
||
U.latch.setAttribute("aria-pressed", String(LV.latch));
|
||
}
|
||
function lvRenderState() {
|
||
const U = LV.ui, s = LV.s;
|
||
if (!U.play || LV.built !== dev) return;
|
||
const ok = lvOk();
|
||
const playing = !!(s && s.playing);
|
||
setLabel(U.play, t(playing ? "lvStop" : "lvPlay"));
|
||
U.play.classList.toggle("on", playing);
|
||
U.play.setAttribute("aria-pressed", String(playing));
|
||
const armed = !!(s && (s.rec || s.recWait || s.freeTake)); /* (a free take: REC again closes the loop) */
|
||
setLabel(U.rec, t(s && s.freeTake ? "lvRecFree" : s && s.recWait && !s.rec ? "lvRecArm" : "lvRec"));
|
||
U.rec.classList.toggle("on", armed);
|
||
U.rec.classList.toggle("wait", !!(s && s.recWait && !s.rec));
|
||
U.undo.disabled = !ok || !(s && s.canUndo);
|
||
U.redo.disabled = !ok || !(s && s.canRedo);
|
||
for (const b of [U.play, U.rec, U.tap, U.loop, U.song, U.srec, U.fill, U.fillbar, ...U.secs, ...U.stores]) b.disabled = !ok;
|
||
U.loop.setAttribute("aria-pressed", String(!!(s && !s.songMode)));
|
||
U.song.setAttribute("aria-pressed", String(!!(s && s.songMode)));
|
||
U.srec.setAttribute("aria-pressed", String(!!(s && s.songRec)));
|
||
U.fill.classList.toggle("act", !!(s && s.fillNow));
|
||
U.fillbar.setAttribute("aria-pressed", String(!!(s && s.fillBar)));
|
||
U.cpu.textContent = s ? `${t("lvCpu")} ${s.cpu}%` : "";
|
||
/* the position: the drum track's step as bar.beat (16 steps a bar), the song's part */
|
||
const ds = s && s.tracks[s.tracks.length - 1];
|
||
const st = ds ? ds.step : 0;
|
||
U.pos.replaceChildren(el("b", { text: playing && ds ? `${Math.floor(st / 16) + 1}.${Math.floor((st % 16) / 4) + 1}` : "–.–" }),
|
||
el("span", { class: "dim", text: s && s.songRuns ? `${t("lvSong")} ${s.songAt + 1}/${s.songLen} · ${t("lvBar")} ${s.songBar + 1}/${s.songBars}` : t("lvBar") }),
|
||
el("span", { class: "lvbeat" }, ...[0, 1, 2, 3].map((k) => el("i", { class: playing && Math.floor((st % 16) / 4) === k ? "on" : "" }))));
|
||
U.secs.forEach((b, k) => {
|
||
const used = s ? (s.ready >> k) & 1 : dev.slotUsed[k];
|
||
const cur = s && s.sec === k, next = s && s.next === k;
|
||
b.classList.toggle("cur", !!cur);
|
||
b.classList.toggle("next", !!next);
|
||
b.classList.toggle("empty", !used);
|
||
b.lastChild.textContent = t(next ? "lvSecNext" : cur ? "lvSecPlaying" : used ? "" : "lvSecEmpty");
|
||
});
|
||
if (s) s.tracks.forEach((x, i) => {
|
||
const st2 = U.strips[i];
|
||
if (!st2) return;
|
||
st2.fader.meter(x.meter ? Math.max(0, (x.meter - 48) / 80) : 0);
|
||
st2.prog.firstChild.style.width = (playing ? ((x.step + 1) / Math.max(1, x.len)) * 100 : 0).toFixed(1) + "%";
|
||
lvRenderStripFlags(i);
|
||
});
|
||
lvRenderFx();
|
||
U.full.textContent = t(document.documentElement.classList.contains("lvfocus") ? "lvFullOff" : "lvFull");
|
||
lvxRenderTools();
|
||
if (LVS.tab === "steps") lvxRenderGrid();
|
||
$("lv").classList.toggle("nopro", !lvPro()); /* (an FM-1 on a 2.7 test build without ops 6..12: those hide) */
|
||
lvxRenderChain();
|
||
if (U.vol) { U.vol.update(); U.volKnob.setAttribute("aria-pressed", String(!!(s && s.master < 0))); }
|
||
if (U.throws) U.throws.forEach((b, k) => b.classList.toggle("act", !!(s && (s.throws >> k) & 1)));
|
||
if (LVS.tab === "sound" && lvDrum(LV.target) && U.padTw) U.padTw.forEach((k) => k.update && k.update());
|
||
}
|
||
function lvRenderStripFlags(i) {
|
||
const s = LV.ui.strips[i], o = LV.tr[i];
|
||
if (!s || !o) return;
|
||
const muted = !!o.mute, solo = !!((LV.solo >> i) & 1);
|
||
s.mute.setAttribute("aria-pressed", String(muted));
|
||
s.solo.setAttribute("aria-pressed", String(solo));
|
||
s.node.classList.toggle("muted", muted || (!!LV.solo && !solo));
|
||
s.node.classList.toggle("rec", !!(LV.s && (LV.s.rec >> i) & 1));
|
||
}
|
||
/* full screen: the side bar and the header go, the page fills the screen (and the display, where the browser can) */
|
||
function lvFull() {
|
||
const on = !document.documentElement.classList.contains("lvfocus");
|
||
document.documentElement.classList.toggle("lvfocus", on);
|
||
try {
|
||
if (on && document.documentElement.requestFullscreen && !document.fullscreenElement) document.documentElement.requestFullscreen().catch(() => {});
|
||
if (!on && document.fullscreenElement) document.exitFullscreen().catch(() => {});
|
||
} catch (e) { /* no full screen API (iPhone): the page alone */ }
|
||
lvRenderState();
|
||
}
|
||
document.addEventListener("fullscreenchange", () => {
|
||
if (!document.fullscreenElement && document.documentElement.classList.contains("lvfocus")) { document.documentElement.classList.remove("lvfocus"); lvRenderState(); }
|
||
});
|
||
|
||
/* ============================================================ LIVE pro === */
|
||
/* Editor only: the 2.7 firmware as it is. Scenes (8, recalled at once or morphed over bars, the A / B crossfader), a
|
||
PERFORM card for the track the keys play (its sound, arp and key, INSERT and the master bus, its steps), sounds with
|
||
favourites and the USER presets, MIDI learn (any control on any controller), and the stage tools (lock, the clock and
|
||
the set's time, the set recorded from the FM-1's USB audio, the setlist's tempo and cue). Kept in this browser
|
||
(IndexedDB "lvpro"); the scenes travel with a saved setlist */
|
||
const LVS = {
|
||
scenes: new Array(LVX.NSCENE).fill(null), names: [], morph: 0, store: false, sounds: false, tempo: false,
|
||
xa: 0, xb: 1, xf: 0, anim: 0, cur: -1, busy: false,
|
||
learn: false, target: null, map: {}, edge: new Map(), ins: new Set(),
|
||
lock: false, rec: null, setStart: 0, tab: "sound", favs: new Set(), edesc: {}, keyAll: false,
|
||
grid: { track: -1, page: 0, steps: [], fill: null, at: 0, loading: false },
|
||
restored: false, saveT: 0,
|
||
};
|
||
const LVX_TABS = ["sound", "arp", "fx", "steps"];
|
||
async function lvxRestore() {
|
||
if (LVS.restored) return;
|
||
LVS.restored = true;
|
||
try {
|
||
const v = await store.getMeta("lvpro");
|
||
if (v) {
|
||
if (Array.isArray(v.scenes)) v.scenes.slice(0, LVX.NSCENE).forEach((s, k) => { LVS.scenes[k] = s && s.v === 1 ? s : null; });
|
||
LVS.names = Array.isArray(v.names) ? v.names.slice(0, LVX.NSCENE) : [];
|
||
for (const k of ["morph", "xa", "xb"]) if (Number.isInteger(v[k])) LVS[k] = v[k];
|
||
LVS.sounds = !!v.sounds; LVS.tempo = !!v.tempo; LVS.keyAll = !!v.keyAll;
|
||
if (v.map && typeof v.map === "object") LVS.map = v.map;
|
||
if (Array.isArray(v.favs)) LVS.favs = new Set(v.favs);
|
||
}
|
||
} catch (e) { /* no storage: this page only */ }
|
||
lvxRenderAll();
|
||
}
|
||
function lvxSave() {
|
||
clearTimeout(LVS.saveT);
|
||
LVS.saveT = setTimeout(() => {
|
||
store.setMeta("lvpro", { scenes: LVS.scenes, names: LVS.names, morph: LVS.morph, xa: LVS.xa, xb: LVS.xb, sounds: LVS.sounds, tempo: LVS.tempo,
|
||
keyAll: LVS.keyAll, map: LVS.map, favs: [...LVS.favs] }).catch((e) => console.warn(e));
|
||
}, 300);
|
||
}
|
||
|
||
/* ---- scenes */
|
||
function lvxNow() { /* the page's values as a scene */
|
||
const n = dev.info.ntrk || 4;
|
||
const tracks = [];
|
||
for (let i = 0; i < n; i++) {
|
||
const o = LV.tr[i] || { p: [] };
|
||
tracks.push({ level: o.level, mute: o.mute, engine: o.engine, preset: o.preset, kit: lvDrum(i) ? o.p[dev.info.pe0] ?? null : null, p: o.p });
|
||
}
|
||
return LVX.capture(tracks, dev.dump.g, { sounds: LVS.sounds, tempo: LVS.tempo });
|
||
}
|
||
const lvxName = (k) => LVS.names[k] || `${t("lvxScene")} ${k + 1}`;
|
||
async function lvxStore(k) {
|
||
if (!dev || !dev.dump) return;
|
||
if (LVS.scenes[k] && !confirm(t("lvxReplace").replace("{x}", lvxName(k)))) return;
|
||
await lvReadTracks(true); /* (the values as the FM-1 has them now) */
|
||
LVS.scenes[k] = lvxNow();
|
||
LVS.store = false;
|
||
lvxSave();
|
||
sayK("lvxStored", lvxName(k));
|
||
lvxRenderScenes();
|
||
}
|
||
/* the values of v onto the FM-1: only what differs from the page's (TRACK_MIX, TRACK_PARAM, SET; queued by key, so a
|
||
morph's later value replaces one not sent yet) */
|
||
function lvxSend(v, final) {
|
||
v.tracks.forEach((x, i) => {
|
||
const o = LV.tr[i];
|
||
if (!o) return;
|
||
if (o.level !== x.level || (o.mute ? 1 : 0) !== x.mute) { o.level = x.level; o.mute = x.mute; lvTouch("lv:" + i); lvSetMix(i); }
|
||
for (const [id, val] of Object.entries(x.p)) if (o.p[id] !== val) lvParam(i, +id, val);
|
||
if (x.e && !lvDrum(i)) x.e.forEach((val, k) => { if (val != null && o.p[LVX.E0 + k] !== val) lvParam(i, LVX.E0 + k, val); });
|
||
lvRenderStrip(i);
|
||
});
|
||
for (const [id, val] of Object.entries(v.g)) if (lvGv(+id) !== val) lvGlobal(+id, val, final);
|
||
if (v.bpm != null && lvGv(LVX.BPM) !== v.bpm) lvGlobal(LVX.BPM, v.bpm, final);
|
||
lvxRenderPerf();
|
||
}
|
||
/* a scene's sounds first (a sound brings its own values: the scene's go over them after) */
|
||
async function lvxSounds(sc) {
|
||
for (let i = 0; i < sc.tracks.length; i++) {
|
||
const x = sc.tracks[i], o = LV.tr[i];
|
||
if (!o) continue;
|
||
if (lvDrum(i)) { if (x.kit != null && o.p[dev.info.pe0] !== x.kit) await lvParam(i, dev.info.pe0, x.kit); }
|
||
else if (o.engine !== x.engine || o.preset !== x.preset) await lvSound(i, x.engine, x.preset);
|
||
}
|
||
}
|
||
function lvxStop() { clearInterval(LVS.anim); LVS.anim = 0; }
|
||
async function lvxRecall(k) {
|
||
const sc = LVS.scenes[k];
|
||
if (!sc || !dev || !dev.dump || LVS.busy) return;
|
||
lvxStop();
|
||
LVS.busy = true;
|
||
try {
|
||
if (sc.sounds) await lvxSounds(sc);
|
||
const from = lvxNow(), bars = LVX.MORPH_BARS[LVS.morph] || 0;
|
||
const to = { ...sc, bpm: sc.tempo ? sc.bpm : null };
|
||
const ms = LVX.morphMs(bars, lvGv(LVX.BPM));
|
||
LVS.cur = k;
|
||
if (!ms) { lvxSend({ ...LVX.mix(from, to, 1), bpm: to.bpm }, true); return; }
|
||
const t0 = performance.now(), b0 = lvGv(LVX.BPM);
|
||
LVS.anim = setInterval(() => {
|
||
const f = Math.min(1, (performance.now() - t0) / ms);
|
||
const v = LVX.mix(from, to, f);
|
||
v.bpm = to.bpm == null ? null : Math.round(b0 + (to.bpm - b0) * f);
|
||
lvxSend(v, f >= 1);
|
||
lvxRenderScenes(f);
|
||
if (f >= 1) lvxStop();
|
||
}, 90);
|
||
} finally { LVS.busy = false; lvxRenderScenes(); }
|
||
}
|
||
/* the crossfader: the mix of scenes A and B, as it moves */
|
||
function lvxCross(f) {
|
||
LVS.xf = f;
|
||
const a = LVS.scenes[LVS.xa], b = LVS.scenes[LVS.xb];
|
||
if (!a || !b) { sayK("lvxNoAB"); return; }
|
||
lvxStop();
|
||
const v = LVX.mix(a, b, f / 100);
|
||
v.bpm = a.tempo && b.tempo && a.bpm != null && b.bpm != null ? Math.round(a.bpm + (b.bpm - a.bpm) * f / 100) : null;
|
||
lvxSend(v, false);
|
||
lvxRenderScenes();
|
||
}
|
||
function lvxBuildScenes() {
|
||
const U = LV.ui;
|
||
U.scn = Array.from({ length: LVX.NSCENE }, (_, k) => {
|
||
const b = el("button", { type: "button", class: "lvscn", "data-lvm": "scene:" + k },
|
||
el("b", { text: String(k + 1) }), el("small", {}), el("kbd", { text: "F" + (k + 1) }));
|
||
b.addEventListener("click", () => (LVS.store ? lvxStore(k) : LVS.scenes[k] ? lvxRecall(k) : sayK("lvxSceneEmpty")));
|
||
b.addEventListener("dblclick", (e) => {
|
||
if (!LVS.scenes[k]) return;
|
||
e.preventDefault();
|
||
const nm = prompt(t("lvxRename"), lvxName(k));
|
||
if (nm != null) { LVS.names[k] = nm.trim().slice(0, 16); lvxSave(); lvxRenderScenes(); }
|
||
});
|
||
return b;
|
||
});
|
||
U.scnStore = el("button", { type: "button", class: "tog", text: t("lvxStore"), "data-lvm": "scene:store", onclick: () => { LVS.store = !LVS.store; lvxRenderScenes(); } });
|
||
U.scnMorph = el("select", { "aria-label": t("lvxMorph"), "data-lvm": "scene:morph" },
|
||
...LVX.MORPH_BARS.map((b, k) => el("option", { value: String(k), text: b ? `${b} ${t(b > 1 ? "lvxBars" : "lvxBar")}` : t("lvxAtOnce") })));
|
||
U.scnMorph.addEventListener("change", () => { LVS.morph = +U.scnMorph.value; lvxSave(); });
|
||
const opt = (k, lbl) => {
|
||
const b = el("button", { type: "button", class: "tog", text: t(lbl), onclick: () => { LVS[k] = !LVS[k]; lvxSave(); lvxRenderScenes(); } });
|
||
b.dataset.k = k;
|
||
return b;
|
||
};
|
||
U.scnOpts = [opt("sounds", "lvxWithSounds"), opt("tempo", "lvxWithTempo")];
|
||
const pick = (k) => {
|
||
const s = el("select", { "aria-label": k === "xa" ? "A" : "B" }, ...Array.from({ length: LVX.NSCENE }, (_, j) => el("option", { value: String(j), text: String(j + 1) })));
|
||
s.addEventListener("change", () => { LVS[k] = +s.value; lvxSave(); lvxRenderScenes(); });
|
||
return s;
|
||
};
|
||
U.xa = pick("xa"); U.xb = pick("xb");
|
||
U.xf = el("input", { type: "range", min: 0, max: 100, value: 0, class: "lvxf", "aria-label": t("lvxCross"), "data-lvm": "scene:xf" });
|
||
U.xf.addEventListener("input", () => lvxCross(+U.xf.value));
|
||
U.xf._lvo = { min: 0, max: 100, set: (v) => { U.xf.value = String(v); lvxCross(v); } };
|
||
return el("div", { class: "card lvcard lvscnbox" },
|
||
el("div", { class: "lvhead" }, el("h2", { text: t("lvxScenes") }),
|
||
el("label", { class: "lvgrp" }, el("span", { class: "dim", text: t("lvxMorph") }), U.scnMorph), ...U.scnOpts, U.scnStore),
|
||
el("div", { class: "lvscnrow" }, ...U.scn),
|
||
el("div", { class: "lvxrow" }, el("span", { class: "dim", text: t("lvxCross") }), el("b", { text: "A" }), U.xa, U.xf, U.xb, el("b", { text: "B" })));
|
||
}
|
||
function lvxRenderScenes(f) {
|
||
const U = LV.ui;
|
||
if (!U.scn) return;
|
||
U.scn.forEach((b, k) => {
|
||
const sc = LVS.scenes[k];
|
||
b.classList.toggle("empty", !sc);
|
||
b.classList.toggle("cur", LVS.cur === k);
|
||
b.classList.toggle("store", LVS.store);
|
||
b.style.setProperty("--m", LVS.cur === k && f != null && f < 1 ? (f * 100).toFixed(0) + "%" : "100%");
|
||
b.children[1].textContent = sc ? lvxName(k) + (sc.sounds ? " ♪" : "") + (sc.tempo ? " ♩" : "") : t(LVS.store ? "lvxStoreHere" : "lvSecEmpty");
|
||
});
|
||
U.scnStore.setAttribute("aria-pressed", String(LVS.store));
|
||
U.scnMorph.value = String(LVS.morph);
|
||
U.scnOpts.forEach((b) => b.setAttribute("aria-pressed", String(!!LVS[b.dataset.k])));
|
||
U.xa.value = String(LVS.xa); U.xb.value = String(LVS.xb);
|
||
if (document.activeElement !== U.xf) U.xf.value = String(LVS.xf);
|
||
}
|
||
|
||
/* ---- PERFORM: the track the keys play */
|
||
/* a control for a parameter: a list (enum) or a knob. scope 0: track tr's P_*, 1: a global; d: its DESC */
|
||
function lvxCtl(scope, id, tr, d, lbl, after) {
|
||
if (!d) return null;
|
||
const get = () => (scope ? lvGv(id) : (LV.tr[tr] || { p: [] }).p[id] ?? d.def ?? 0);
|
||
const set = (v, f = true) => { if (scope) lvGlobal(id, v, f); else lvParam(tr, id, v); if (after) after(v); };
|
||
const mid = scope ? `g:${id}` : `perf:${id}`;
|
||
if (d.fmt === F.ENUM && d.names && d.names.length) {
|
||
const s = el("select", { "aria-label": lbl || d.label, "data-lvm": mid }, ...d.names.map((n, k) => el("option", { value: String(d.min + k), text: n })));
|
||
s.addEventListener("change", () => { set(+s.value); });
|
||
const w = el("label", { class: "lvxsel" }, el("span", { class: "dim", text: (lbl || d.label).toLowerCase() }), s);
|
||
w.update = () => { if (document.activeElement !== s) s.value = String(get()); };
|
||
s._lvo = { min: d.min, max: d.max, set: (v) => { s.value = String(v); set(v); } };
|
||
return w;
|
||
}
|
||
const k = lvKnob((lbl || d.label).toLowerCase(), { min: d.min, max: d.max, def: d.def, bip: d.min < 0, get, set, mid, fmt: (v) => { const [x, u] = fmtValue(d, v); return u && u !== "%" ? `${x} ${u}`.toLowerCase() : x + (u || ""); } });
|
||
return k;
|
||
}
|
||
async function lvxEdesc(i) { /* the engine's 8 values' DESC (the selected track's engine) */
|
||
const o = LV.tr[i];
|
||
if (!o || lvDrum(i) || LVS.edesc[o.engine] || dev.sel !== i) return;
|
||
const out = [];
|
||
for (let k = 0; k < LVX.NE; k++) out.push(await getDescOrNull(0, dev.info.pe0 + k));
|
||
LVS.edesc[o.engine] = out;
|
||
lvxBuildPerf();
|
||
}
|
||
function lvxBuildPerf() {
|
||
const U = LV.ui;
|
||
if (!U.perf) return;
|
||
const i = LV.target, drum = lvDrum(i), o = LV.tr[i] || { p: [] }, pd = (id) => dev.pdesc[id], gd = (id) => dev.gdesc[id];
|
||
U.perfTabs.forEach((b) => b.setAttribute("aria-selected", String(b.dataset.tab === LVS.tab)));
|
||
U.perfTrk.textContent = drum ? "DRUMS" : `${t("lvTrack")} ${i + 1} · ${dev.info.engines[o.engine] || ""}`;
|
||
U.perf.style.setProperty("--c", TCOL[i % 4]);
|
||
const ctls = [];
|
||
const row = (title, list) => { const xs = list.filter(Boolean); ctls.push(...xs); return xs.length ? el("div", { class: "lvxgrp" }, el("span", { class: "dim", text: t(title) }), el("div", { class: "lvknobs" }, ...xs)) : ""; };
|
||
let body = [];
|
||
if (LVS.tab === "sound") {
|
||
if (drum) {
|
||
/* (2.7) each pad's TUNE and DECAY, as the DRUMS screen's SOUND page */
|
||
LV.padSel = LV.padSel ?? 0;
|
||
const pads = el("select", { "aria-label": t("lvxPad") }, ...DRUM_LANES.map(([, n], k) => el("option", { value: String(k), text: n })));
|
||
pads.value = String(LV.padSel);
|
||
pads.addEventListener("change", () => { LV.padSel = +pads.value; lvxBuildPerf(); });
|
||
const tw = (k, lbl, min, max) => lvKnob(t(lbl), { min, max, def: 0, bip: true, mid: "pad:" + k,
|
||
get: () => (LV.s && LV.s.dtw ? LV.s.dtw[LV.padSel][k] : 0),
|
||
set: (v) => { const d = LV.s.dtw[LV.padSel]; d[k] = v; lvSend(LIVE.DRUM_TW, LV.padSel, d.tune + 8, d.dec + 4); },
|
||
fmt: (v) => (v > 0 ? "+" + v : String(v)) });
|
||
U.padTw = [tw("tune", "lvxTune", -8, 7), tw("dec", "lvxDecay", -4, 3)];
|
||
ctls.push(...U.padTw);
|
||
body = [el("div", { class: "lvxgrp lvxpro" }, el("span", { class: "dim", text: t("lvxPadSound") }),
|
||
el("div", { class: "lvknobs" }, el("label", { class: "lvxsel" }, el("span", { class: "dim", text: t("lvxPad") }), pads), ...U.padTw)),
|
||
row("lvxIns", [53, 54, 55, 56, 57].map((id) => lvxCtl(0, id, i, pd(id)))), row("lvxTrkFilt", [lvxCtl(0, 50, i, pd(50))])];
|
||
} else {
|
||
const ed = LVS.edesc[o.engine];
|
||
if (!ed && dev.sel === i) op(() => lvxEdesc(i));
|
||
body = [row("lvxEngine", (ed || []).map((d, k) => (d && d.label && d.label !== "--" ? lvxCtl(0, dev.info.pe0 + k, i, { ...d }, d.label) : null))),
|
||
row("lvxMacro", [5, 6, 7].map((id) => lvxCtl(0, id, i, pd(id)))),
|
||
row("lvxEnv", [1, 2, 3, 4, 38].map((id) => lvxCtl(0, id, i, pd(id)))),
|
||
row("lvxLfo", [9, 13, 14, 15, 16].map((id) => lvxCtl(0, id, i, pd(id), id === 9 ? "lfo rate" : "lfo " + (pd(id) || {}).label)))];
|
||
}
|
||
} else if (LVS.tab === "arp") {
|
||
if (drum) body = [el("p", { class: "dim lvhint", text: t("lvxDrumArp") })];
|
||
else {
|
||
U.keyAll = el("button", { type: "button", class: "tog", text: t("lvxKeyAll"), "aria-pressed": String(LVS.keyAll),
|
||
onclick: () => { LVS.keyAll = !LVS.keyAll; lvxSave(); lvxBuildPerf(); } });
|
||
/* "every synth track": the key's values go to the other synth tracks too */
|
||
const keyCtl = (id) => lvxCtl(0, id, i, pd(id), null, (v) => {
|
||
if (LVS.keyAll) for (let k = 0; k < (dev.info.ntrk || 4); k++) if (k !== i && !lvDrum(k)) lvParam(k, id, v);
|
||
});
|
||
const keys = [25, 26, 49, 28].map(keyCtl).filter(Boolean);
|
||
ctls.push(...keys);
|
||
body = [row("lvxArp", [17, 18, 19, 20, 21, 24, 23].map((id) => lvxCtl(0, id, i, pd(id)))),
|
||
el("div", { class: "lvxgrp" }, el("span", { class: "dim", text: t("lvxKey") }), el("div", { class: "lvknobs" }, ...keys, U.keyAll))];
|
||
}
|
||
} else if (LVS.tab === "fx") {
|
||
body = [row("lvxIns", [53, 54, 55, 56, 57].map((id) => lvxCtl(0, id, i, pd(id)))), row("lvxTrkFilt", [lvxCtl(0, 50, i, pd(50))]),
|
||
row("lvxDelay", [4, 5, 6, 7].map((id) => lvxCtl(1, id, i, gd(id)))),
|
||
row("lvxReverb", [8, 9].map((id) => lvxCtl(1, id, i, gd(id)))),
|
||
row("lvxChorus", [10, 11].map((id) => lvxCtl(1, id, i, gd(id)))),
|
||
row("lvxTexture", [37, 38, 39, 40, 41, 42, 43].map((id) => lvxCtl(1, id, i, gd(id)))),
|
||
row("lvxClick", [lvxCtl(1, 2, i, gd(2))])];
|
||
} else { body = [lvxBuildGrid()]; ctls.push(...U.gridCtl); }
|
||
U.perfCtls = ctls;
|
||
U.perfBody.replaceChildren(el("p", { class: "dim lvtabsub", text: t("lvxTabSub_" + LVS.tab) }), ...body.filter(Boolean));
|
||
lvxTips(U.perfBody);
|
||
lvxRenderPerf();
|
||
}
|
||
function lvxRenderPerf() {
|
||
const U = LV.ui;
|
||
if (!U.perfCtls) return;
|
||
{ /* the title follows the track's sound (read after the card was built) */
|
||
const i = LV.target, o = LV.tr[i] || {};
|
||
U.perfTrk.textContent = lvDrum(i) ? "DRUMS" : `${t("lvTrack")} ${i + 1} · ${dev.info.engines[o.engine] || ""}`;
|
||
}
|
||
for (const c of U.perfCtls) if (c.update) c.update();
|
||
if (LVS.tab === "steps") lvxRenderGrid();
|
||
}
|
||
|
||
/* ---- the steps of the track the keys play: 16 a page (a drum lane a row), a tap toggles, a right-click its fill */
|
||
function lvxBuildGrid() {
|
||
const U = LV.ui, i = LV.target, drum = lvDrum(i), pd = (id) => dev.pdesc[id];
|
||
const g = LVS.grid;
|
||
if (g.track !== i) { g.track = i; g.page = 0; g.steps = []; g.fill = null; }
|
||
U.grid = el("div", { class: "lvgrid" + (drum ? " drum" : "") });
|
||
const len = (LV.tr[i] || { p: [] }).p[29] ?? 16, pages = Math.max(1, Math.ceil(len / 16));
|
||
U.gridPages = el("span", { class: "seg" }, ...Array.from({ length: pages }, (_, k) => el("button", { type: "button", text: String(k + 1),
|
||
"aria-pressed": String(k === g.page), onclick: () => { g.page = k; lvxBuildPerf(); lvxLoadGrid(); } })));
|
||
const ctl = [29, 30, 31, 32].map((id) => lvxCtl(0, id, i, pd(id), null, (v) => { if (v !== undefined) lvxRenderGrid(); })).filter(Boolean);
|
||
U.gridCtl = ctl;
|
||
if (!g.steps.length || g.at < Date.now() - 2500) lvxLoadGrid();
|
||
/* (2.7) the pattern's tools, as EDIT + KNOB 1..3: shift it, x2 / half, transpose (each one undo) */
|
||
const pt = (tool, up, lbl) => el("button", { type: "button", text: t(lbl), "data-lvm": `pat:${tool}:${up}`,
|
||
onclick: async () => { await lvSend(LIVE.PATTERN, i, tool, up ? 1 : 0); await lvReadTrack(i); g.at = 0; lvxBuildPerf(); } });
|
||
const tools = el("div", { class: "lvgrp lvxpro lvpattools" }, el("span", { class: "dim", text: t("lvxPattern") }),
|
||
pt(0, 0, "lvxShiftL"), pt(0, 1, "lvxShiftR"), pt(1, 0, "lvxHalf"), pt(1, 1, "lvxDouble"),
|
||
...(drum ? [] : [pt(2, 0, "lvxTrDown"), pt(2, 1, "lvxTrUp")]));
|
||
return el("div", { class: "lvxsteps" },
|
||
el("div", { class: "lvhead" }, el("span", { class: "dim", text: t("lvxPage") }), U.gridPages, el("div", { class: "lvknobs" }, ...ctl)), tools,
|
||
U.grid, el("p", { class: "dim lvhint", text: t(drum ? "lvxGridDrumHint" : "lvxGridHint") }));
|
||
}
|
||
async function lvxLoadGrid() {
|
||
const g = LVS.grid, i = g.track, d = dev;
|
||
if (!d || g.loading || i < 0) return;
|
||
g.loading = true;
|
||
g.at = Date.now();
|
||
try {
|
||
const drum = lvDrum(i), out = [];
|
||
for (let k = 0; k < 16; k++) {
|
||
const idx = g.page * 16 + k;
|
||
if (idx >= (d.info.nstep || 64)) break;
|
||
out.push(drum ? parse[CMD.DRUM_STEP](await rq(req.drumStep(idx), { key: "lvg:" + idx, quiet: true }))
|
||
: parse[CMD.TRACK_STEP](await rq(req.trackStep(i, idx), { key: "lvg:" + idx, quiet: true })));
|
||
if (d !== dev || g.track !== i) return;
|
||
}
|
||
g.steps = out;
|
||
if (d.info.proto >= 8) g.fill = parse[CMD.FILL_GET](await rq(req.fillGet(i), { key: "lvg:fill", quiet: true })).fill;
|
||
g.at = Date.now();
|
||
} catch (e) { if (e.message !== "closed") report(e); }
|
||
finally { g.loading = false; }
|
||
lvxRenderGrid();
|
||
}
|
||
async function lvxToggle(idx, lane) {
|
||
const g = LVS.grid, i = g.track, k = idx - g.page * 16, st = g.steps[k];
|
||
if (!st || !dev) return;
|
||
try {
|
||
if (lvDrum(i)) {
|
||
const nd = previewToggleDrum(st, lane);
|
||
g.steps[k] = { ...nd, index: idx };
|
||
lvxRenderGrid();
|
||
g.steps[k] = parse[CMD.DRUM_STEP](await rq(req.drumStep(idx, nd), { key: "dstep:" + idx, front: true }));
|
||
} else {
|
||
const ns = previewToggleStep(st, LV.lastNote ?? 60);
|
||
g.steps[k] = { ...ns, index: idx };
|
||
lvxRenderGrid();
|
||
g.steps[k] = parse[CMD.TRACK_STEP](await rq(req.trackStep(i, idx, ns), { key: "tstep:" + idx, front: true }));
|
||
}
|
||
if (i === dev.sel) LV.stale = true;
|
||
} catch (e) { report(e); }
|
||
lvxRenderGrid();
|
||
}
|
||
async function lvxFill(idx) {
|
||
const g = LVS.grid;
|
||
if (!g.fill || !dev || dev.info.proto < 8) return;
|
||
const c = (fillGet(g.fill, idx) % 3 + 1) % 3;
|
||
fillSet(g.fill, idx, c);
|
||
lvxRenderGrid();
|
||
try { const r = parse[CMD.FILL_SET](await rq(req.fillSet(g.track, idx, c), { key: "fill:" + idx, front: true })); fillSet(g.fill, idx, r.cond); }
|
||
catch (e) { report(e); }
|
||
lvxRenderGrid();
|
||
}
|
||
function lvxRenderGrid() { /* the cells, from the steps read */
|
||
const U = LV.ui, g = LVS.grid;
|
||
if (!U.grid || !U.grid.isConnected) return;
|
||
const i = g.track, drum = lvDrum(i), len = (LV.tr[i] || { p: [] }).p[29] ?? 16;
|
||
const sig = JSON.stringify([i, g.page, len, g.steps, g.fill]);
|
||
if (U.grid.dataset.sig !== sig) {
|
||
U.grid.dataset.sig = sig;
|
||
U.gridCols = Array.from({ length: 16 }, () => []);
|
||
const cell = (k, on, txt, lane) => {
|
||
const idx = g.page * 16 + k;
|
||
const b = el("button", { type: "button", class: "lvgc" + (on ? " on" : "") + (idx >= len ? " out" : "") + (k % 4 === 0 ? " beat" : ""),
|
||
"aria-pressed": String(!!on), "aria-label": `${idx + 1}`, text: txt || "" });
|
||
const fc = g.fill ? fillGet(g.fill, idx) % 3 : 0;
|
||
if (fc) b.classList.add(fc === 1 ? "fillonly" : "nofill");
|
||
b.addEventListener("click", () => lvxToggle(idx, lane));
|
||
b.addEventListener("contextmenu", (e) => { e.preventDefault(); lvxFill(idx); });
|
||
U.gridCols[k].push(b);
|
||
return b;
|
||
};
|
||
if (drum) {
|
||
U.grid.replaceChildren(...DRUM_LANES.map(([, name], lane) => el("div", { class: "lvgr" }, el("span", { class: "lvgl", text: name }),
|
||
...Array.from({ length: 16 }, (_, k) => { const st = g.steps[k]; return cell(k, st && (st.on >> lane) & 1, "", lane); }))));
|
||
} else {
|
||
U.grid.replaceChildren(el("div", { class: "lvgr" }, ...Array.from({ length: 16 }, (_, k) => {
|
||
const st = g.steps[k], tie = st && st.time === 1, on = st && st.n > 0 && (st.time === 0 || tie);
|
||
return cell(k, on, st && st.n > 0 && st.time !== 2 ? (tie ? "—" : noteName(st.notes[0])) : "", 0);
|
||
})));
|
||
}
|
||
U.gridPh = -1;
|
||
}
|
||
/* the play head: the column of the step playing */
|
||
const play = LV.s && LV.s.playing && LV.s.tracks[i] ? LV.s.tracks[i].step - g.page * 16 : -1;
|
||
if (U.gridPh !== play) {
|
||
if (U.gridPh >= 0 && U.gridCols[U.gridPh]) U.gridCols[U.gridPh].forEach((b) => b.classList.remove("ph"));
|
||
if (play >= 0 && play < 16) U.gridCols[play].forEach((b) => b.classList.add("ph"));
|
||
U.gridPh = play;
|
||
}
|
||
if (Date.now() - g.at > 3000 && !g.loading && tab === "live") lvxLoadGrid(); /* what the FM-1 recorded shows */
|
||
}
|
||
|
||
/* ---- sounds: favourites (this browser) and the USER presets (the FM-1's bank) in each track's list */
|
||
const lvxFavKey = (e, p) => `${e}:${p}`;
|
||
function lvxFav(i) {
|
||
const o = LV.tr[i];
|
||
if (!o || lvDrum(i)) return;
|
||
const k = lvxFavKey(o.engine, o.preset);
|
||
if (LVS.favs.has(k)) LVS.favs.delete(k); else LVS.favs.add(k);
|
||
lvxSave();
|
||
for (let j = 0; j < LV.tr.length; j++) lvRenderStrip(j);
|
||
}
|
||
async function lvxUser(i, slot) {
|
||
const sel = dev.sel;
|
||
try {
|
||
if (sel !== i) await rq(req.track(i), { front: true });
|
||
selfLoad();
|
||
const rc = await bank.load(rqf, slot);
|
||
if (rc) sayK("lvxUserEmpty");
|
||
if (sel !== i && LV.target !== i) await rq(req.track(sel)).catch(() => {}); else dev.sel = i;
|
||
LV.stale = true;
|
||
await lvReadTrack(i);
|
||
} catch (e) { report(e); }
|
||
}
|
||
function lvxSoundOptions(drum) { /* the option groups before the engines' presets */
|
||
if (drum) return [];
|
||
const favs = [...LVS.favs].map((k) => k.split(":").map(Number)).filter(([e, p]) => dev.names[e] && dev.names[e][p] != null);
|
||
const out = [];
|
||
if (favs.length) out.push(el("optgroup", { label: "★ " + t("lvxFavs") }, ...favs.map(([e, p]) => el("option", { value: `${e}:${p}`, text: "★ " + dev.names[e][p] }))));
|
||
const us = dev.bank ? dev.bank.slots.filter((s) => s.used) : [];
|
||
if (us.length) out.push(el("optgroup", { label: "USER" }, ...us.map((s) => el("option", { value: `u:${s.slot}`, text: `U${String(s.slot + 1).padStart(2, "0")} ${s.name}` }))));
|
||
return out;
|
||
}
|
||
|
||
/* ---- MIDI learn: any control of the page (data-lvm) on a controller's CC or note */
|
||
function lvxMidiOn() {
|
||
if (!access || MOCK) return;
|
||
for (const inp of access.inputs.values()) {
|
||
if (LVS.ins.has(inp) || (dev && inp === dev.input) || FM1_PORT.test(inp.name || "")) continue;
|
||
inp.addEventListener("midimessage", lvxMidiIn);
|
||
LVS.ins.add(inp);
|
||
}
|
||
}
|
||
function lvxMidiOff() { for (const inp of LVS.ins) inp.removeEventListener("midimessage", lvxMidiIn); LVS.ins.clear(); }
|
||
function lvxMidiIn(e) { lvxMidi(e.data); }
|
||
if (MOCK) { window.__lvxMidi = (d) => lvxMidi(Uint8Array.from(d)); window.__lvs = LVS; window.__mockState = () => mock && mock.state; } /* (the mock has no controller: the tests play one) */
|
||
function lvxMidi(data) {
|
||
if (tab !== "live" || !LV.built) return;
|
||
const m = LVX.midiKey(data);
|
||
if (!m) return;
|
||
if (LVS.learn && LVS.target) {
|
||
if (!m.on && m.kind === "note") return;
|
||
for (const [k, v] of Object.entries(LVS.map)) if (v === LVS.target) delete LVS.map[k];
|
||
LVS.map[m.key] = LVS.target;
|
||
sayK("lvxLearned", `${LVS.target} ← ${m.key.replace(/:/g, " ")}`);
|
||
LVS.target = null;
|
||
lvxSave();
|
||
lvxRenderLearn();
|
||
return;
|
||
}
|
||
const id = LVS.map[m.key];
|
||
if (!id) return;
|
||
const node = document.querySelector(`#lv [data-lvm="${CSS.escape(id)}"]`);
|
||
if (!node) return;
|
||
const was = LVS.edge.get(m.key) || false;
|
||
LVS.edge.set(m.key, m.on);
|
||
if (node._lvo) { /* a knob, a fader, a list: the value */
|
||
if (m.kind === "note" && !m.on) return;
|
||
node._lvo.set(LVX.midiValue(m, node._lvo.min, node._lvo.max), true);
|
||
if (node.update) node.update();
|
||
} else if (node.press) { /* a held button: while the pad / key is down */
|
||
if (m.on) node.press(); else node.release();
|
||
} else if (m.on && !was && !node.disabled) node.click(); /* a button: on the press (a CC: crossing 64) */
|
||
}
|
||
function lvxRenderLearn() {
|
||
const U = LV.ui;
|
||
if (!U.learn) return;
|
||
U.learn.setAttribute("aria-pressed", String(LVS.learn));
|
||
$("lv").classList.toggle("learn", LVS.learn);
|
||
const mapped = new Set(Object.values(LVS.map));
|
||
document.querySelectorAll("#lv [data-lvm]").forEach((n) => {
|
||
n.classList.toggle("lvmapped", LVS.learn && mapped.has(n.dataset.lvm));
|
||
n.classList.toggle("lvlearnat", LVS.learn && LVS.target === n.dataset.lvm);
|
||
});
|
||
U.learnMsg.hidden = !LVS.learn;
|
||
U.learnMsg.textContent = !LVS.learn ? "" : LVS.target ? t("lvxLearnWait").replace("{x}", LVS.target) : t("lvxLearnPick");
|
||
}
|
||
/* in learn mode a tap picks the control instead of using it; a right-click forgets its mapping */
|
||
function lvxLearnPick(e) {
|
||
if (!LVS.learn) return;
|
||
const n = e.target.closest("[data-lvm]");
|
||
if (!n || n === LV.ui.learn || n.closest(".lvlearnbar")) return;
|
||
e.preventDefault(); e.stopPropagation();
|
||
if (e.type === "contextmenu") {
|
||
for (const [k, v] of Object.entries(LVS.map)) if (v === n.dataset.lvm) delete LVS.map[k];
|
||
lvxSave();
|
||
} else if (e.type === "pointerdown") LVS.target = n.dataset.lvm;
|
||
lvxRenderLearn();
|
||
}
|
||
|
||
/* ---- stage tools: lock, the clock and the set's time, the set recorded from the FM-1's USB audio */
|
||
function lvxLock(on) {
|
||
LVS.lock = on;
|
||
$("lv").classList.toggle("locked", on);
|
||
if (LV.ui.lock) { LV.ui.lock.setAttribute("aria-pressed", String(on)); setLabel(LV.ui.lock, t(on ? "lvxUnlock" : "lvxLock")); }
|
||
}
|
||
async function lvxRecStart() {
|
||
if (LVS.rec) return;
|
||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia || !window.AudioWorkletNode) { sayK("lvxRecNo"); return; }
|
||
try {
|
||
let stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||
const devs = (await navigator.mediaDevices.enumerateDevices()).filter((d) => d.kind === "audioinput");
|
||
const fm = devs.find((d) => /fm-?1|m-?vave|sloop|felucca/i.test(d.label));
|
||
const want = fm || devs.find((d) => d.deviceId === stream.getAudioTracks()[0].getSettings().deviceId);
|
||
stream.getTracks().forEach((x) => x.stop());
|
||
stream = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: want ? { exact: want.deviceId } : undefined, channelCount: 2,
|
||
echoCancellation: false, noiseSuppression: false, autoGainControl: false } });
|
||
const ctx = new AudioContext();
|
||
const code = `class R extends AudioWorkletProcessor{process(i){const x=i[0];if(x&&x.length){const l=x[0],r=x[1]||x[0],o=new Float32Array(l.length*2);
|
||
for(let k=0;k<l.length;k++){o[2*k]=l[k];o[2*k+1]=r[k];}this.port.postMessage(o,[o.buffer]);}return true;}}registerProcessor("lvx-rec",R);`;
|
||
const url = URL.createObjectURL(new Blob([code], { type: "text/javascript" }));
|
||
await ctx.audioWorklet.addModule(url);
|
||
URL.revokeObjectURL(url);
|
||
const src = ctx.createMediaStreamSource(stream), node = new AudioWorkletNode(ctx, "lvx-rec"), mute = ctx.createGain();
|
||
mute.gain.value = 0;
|
||
const rec = { ctx, stream, src, node, mute, chunks: [], n: 0, peak: 0, t0: Date.now(), name: want ? want.label : "" };
|
||
node.port.onmessage = (ev) => {
|
||
const pc = LVX.pcm16(ev.data);
|
||
rec.chunks.push(pc); rec.n += pc.length;
|
||
for (let k = 0; k < ev.data.length; k += 8) rec.peak = Math.max(rec.peak, Math.abs(ev.data[k]));
|
||
};
|
||
src.connect(node); node.connect(mute); mute.connect(ctx.destination);
|
||
LVS.rec = rec;
|
||
if (!fm) sayK("lvxRecOther", rec.name);
|
||
else sayK("lvxRecOn", rec.name);
|
||
} catch (e) { sayK("lvxRecNo", e.message || ""); }
|
||
lvxRenderTools();
|
||
}
|
||
function lvxRecStop() {
|
||
const r = LVS.rec;
|
||
if (!r) return;
|
||
LVS.rec = null;
|
||
try { r.src.disconnect(); r.node.disconnect(); r.stream.getTracks().forEach((x) => x.stop()); r.ctx.close(); } catch (e) { /* gone */ }
|
||
if (r.n) {
|
||
const d = new Date(), stamp = `${today()}-${String(d.getHours()).padStart(2, "0")}${String(d.getMinutes()).padStart(2, "0")}`;
|
||
downloadBytes(`SLOOP-live-${stamp}.wav`, LVX.wav(r.chunks, r.ctx.sampleRate, 2));
|
||
sayK("lvxRecSaved", LVX.clock(Date.now() - r.t0));
|
||
}
|
||
lvxRenderTools();
|
||
}
|
||
function lvxRenderTools() {
|
||
const U = LV.ui;
|
||
if (!U.clock) return;
|
||
const now = new Date(), r = LVS.rec;
|
||
if (LV.s && LV.s.playing && !LVS.setStart) LVS.setStart = Date.now();
|
||
U.clock.replaceChildren(el("b", { text: `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}` }),
|
||
el("span", { class: "dim", text: `${t("lvxSet")} ${LVS.setStart ? LVX.clock(Date.now() - LVS.setStart) : "–:––"}` }));
|
||
U.recSet.classList.toggle("on", !!r);
|
||
U.recSet.setAttribute("aria-pressed", String(!!r));
|
||
setLabel(U.recSet, r ? `${t("lvxRecStop")} ${LVX.clock(Date.now() - r.t0)}` : t("lvxRecSet"));
|
||
if (r) { U.recSet.style.setProperty("--lv", Math.min(100, r.peak * 100).toFixed(0) + "%"); r.peak *= 0.6; }
|
||
}
|
||
function lvxBuildTools() {
|
||
const U = LV.ui;
|
||
U.clock = el("button", { type: "button", class: "lvclock", title: t("lvxSetReset"), onclick: () => { LVS.setStart = 0; lvxRenderTools(); } });
|
||
U.lock = lvHold(el("button", { type: "button", class: "tog lvlockbtn" }), () => {
|
||
if (!LVS.lock) { lvxLock(true); return; }
|
||
U.lock._t = setTimeout(() => lvxLock(false), 800); /* unlocking: hold it a moment (no accident on stage) */
|
||
}, () => clearTimeout(U.lock._t));
|
||
U.learn = el("button", { type: "button", class: "tog lvlearnbtn", text: t("lvxLearn"), onclick: () => { LVS.learn = !LVS.learn; LVS.target = null; if (LVS.learn) lvxMidiOn(); lvxRenderLearn(); } });
|
||
U.learnMsg = el("span", { class: "lvlearnmsg", hidden: true });
|
||
U.learnClear = el("button", { type: "button", text: t("lvxLearnClear"), onclick: () => { if (confirm(t("lvxLearnClearAsk"))) { LVS.map = {}; lvxSave(); lvxRenderLearn(); } } });
|
||
U.recSet = el("button", { type: "button", class: "lvrecset", onclick: () => (LVS.rec ? lvxRecStop() : lvxRecStart()) });
|
||
U.view = el("button", { type: "button", class: "tog lvviewbtn", onclick: () => lvxView(!LVS.all) });
|
||
U.recSet.classList.add("lvadv"); U.learn.classList.add("lvadv");
|
||
return el("div", { class: "lvgrp lvtools" }, U.view, U.clock, U.recSet, U.learn, U.lock);
|
||
}
|
||
/* ---- a page a newcomer can read: each card's line and "?", the tips on every control, the first steps, the view */
|
||
function lvxDecorate(card, k) {
|
||
const head = card.querySelector(":scope > .lvhead, :scope > h2");
|
||
const help = el("div", { class: "lvhelp", hidden: true });
|
||
help.append(...String(t("lvxHelp_" + k)).split("\n").map((x) => el("p", { text: x })));
|
||
const q = el("button", { type: "button", class: "lvq", text: "?", "aria-expanded": "false", title: t("lvxHelpShow"), "aria-label": t("lvxHelpShow"),
|
||
onclick: () => { help.hidden = !help.hidden; q.setAttribute("aria-expanded", String(!help.hidden)); } });
|
||
const sub = el("p", { class: "lvsub" }, el("span", { text: t("lvxSub_" + k) }), q);
|
||
if (head) head.after(sub, help); else card.prepend(sub, help);
|
||
}
|
||
/* a tip on every control (a hover on a computer; the "?" of each card says more) */
|
||
function lvxTipOf(id) {
|
||
const P = { 39: "pan", 50: "filt", 36: "send", 35: "send", 34: "send", 33: "drive", 5: "macro", 6: "macro", 7: "macro", 1: "env", 2: "env", 3: "env",
|
||
4: "env", 38: "glide", 9: "lfo", 13: "lfo", 14: "lfo", 15: "lfo", 16: "lfo", 53: "ins", 54: "ins", 55: "ins", 56: "ins", 57: "ins", 17: "arp",
|
||
18: "arp", 19: "arp", 20: "arp", 21: "arp", 23: "hold", 24: "arp", 25: "key", 26: "key", 49: "key", 28: "key", 29: "len", 30: "len", 31: "len", 32: "len" };
|
||
const G = { 0: "bpm", 1: "swing", 29: "mfilt", 27: "dust", 28: "duck", 26: "send", 32: "send", 4: "bus", 5: "bus", 6: "bus", 7: "bus", 8: "bus",
|
||
9: "bus", 10: "bus", 11: "bus", 37: "tex", 38: "tex", 39: "tex", 40: "tex", 41: "tex", 42: "tex", 43: "tex", 2: "click" };
|
||
let m;
|
||
if ((m = /^g:(\d+)$/.exec(id))) return G[+m[1]];
|
||
if ((m = /^(?:s\d+|perf):(\d+)$/.exec(id))) return +m[1] >= LVX.E0 ? "engine" : P[+m[1]];
|
||
if ((m = /^s\d+:(\w+)$/.exec(id))) return { lvl: "lvl", mute: "mute", solo: "solo", sel: "sel", prev: "snd", next: "snd" }[m[1]];
|
||
if ((m = /^(sec|scene|fx|pad):\d+$/.exec(id))) return m[1];
|
||
if (/^chain:\d$/.test(id)) return "chain";
|
||
if (/^kmode:/.test(id)) return "kmode";
|
||
if (/^pat:/.test(id)) return "pat";
|
||
if (/^throw:/.test(id)) return "throw";
|
||
if (id === "pad:tune" || id === "pad:dec") return "padtw";
|
||
return { master: "vol", "master:knob": "volknob", "chain:play": "chainplay", "chain:stop": "chainplay", play: "play", rec: "rec", undo: "undo", redo: "undo", tap: "tap", loop: "loop", song: "loop", songrec: "songrec", fill: "fill", fillbar: "fillbar",
|
||
"panic": "panic", latch: "latch", "pl:next": "next", "scene:store": "store", "scene:morph": "morph", "scene:xf": "xf" }[id];
|
||
}
|
||
function lvxTips(root = $("lv")) {
|
||
root.querySelectorAll("[data-lvm]").forEach((n) => {
|
||
const k = lvxTipOf(n.dataset.lvm), tip = k ? t("lvxTip_" + k) : "";
|
||
if (tip && !n.title) n.title = tip;
|
||
});
|
||
const extra = [[".lsfav", "fav"], [".lvrecset", "recset"], [".lvlearnbtn", "learn"], [".lvlockbtn", "lock"], [".lvclock", "clock"], [".lvviewbtn", "view"],
|
||
[".lvxrow select", "ab"], [".lvscnbox .tog[data-k=sounds]", "wsounds"], [".lvscnbox .tog[data-k=tempo]", "wtempo"], [".lvstore", "storesec"]];
|
||
for (const [sel, k] of extra) root.querySelectorAll(sel).forEach((n) => { n.title = t("lvxTip_" + k); });
|
||
}
|
||
/* the first steps: a short path through the page, shown until "got it" (the "?" at the top brings it back) */
|
||
function lvxBuildGuide() {
|
||
const U = LV.ui;
|
||
let seen = false;
|
||
try { seen = localStorage.getItem("sloop-live-guide") === "1"; } catch (e) { /* no storage */ }
|
||
const steps = t("lvxGuideSteps").map((x) => el("li", { text: x }));
|
||
U.guide = el("div", { class: "card lvcard lvguide", hidden: seen },
|
||
el("div", { class: "lvhead" }, el("h2", { text: t("lvxGuideTitle") }),
|
||
el("button", { type: "button", class: "pri", text: t("lvxGuideOk"), onclick: () => { U.guide.hidden = true; U.guideBtn.hidden = false;
|
||
try { localStorage.setItem("sloop-live-guide", "1"); } catch (e) { /* no storage */ } } })),
|
||
el("ol", { class: "lvsteps" }, ...steps),
|
||
el("p", { class: "dim", text: t("lvxGuideFoot") }));
|
||
U.guideBtn = el("button", { type: "button", class: "lvguidebtn", text: "? " + t("lvxGuideTitle"), hidden: !seen,
|
||
onclick: () => { U.guide.hidden = false; U.guideBtn.hidden = true; } });
|
||
return el("div", {}, U.guide, U.guideBtn);
|
||
}
|
||
/* the view: the essentials (transport, sections, mixer, keys, effects) or everything (+ scenes, PERFORM, the setlist, the stage tools) */
|
||
function lvxView(all) {
|
||
LVS.all = all;
|
||
try { localStorage.setItem("sloop-live-view", all ? "all" : "simple"); } catch (e) { /* no storage */ }
|
||
$("lv").classList.toggle("simple", !all);
|
||
if (LV.ui.view) { setLabel(LV.ui.view, t(all ? "lvxViewAll" : "lvxViewSimple")); LV.ui.view.setAttribute("aria-pressed", String(all)); }
|
||
}
|
||
function lvxRenderAll() {
|
||
if (!LV.built) return;
|
||
if (LVS.all == null) { let v = null; try { v = localStorage.getItem("sloop-live-view"); } catch (e) { /* no storage */ } LVS.all = v !== "simple"; }
|
||
lvxView(LVS.all);
|
||
lvxRenderScenes();
|
||
lvxRenderPerf();
|
||
lvxRenderLearn();
|
||
lvxRenderTools();
|
||
lvxLock(LVS.lock);
|
||
}
|
||
|
||
for (const ev of ["pointerdown", "mousedown", "click", "contextmenu", "change"]) document.addEventListener(ev, (e) => {
|
||
if (!LVS.learn || tab !== "live" || !e.target.closest || !e.target.closest("#lv")) return;
|
||
if (ev === "click" || ev === "change" || ev === "mousedown") { if (e.target.closest("[data-lvm]") && !e.target.closest(".lvlearnbtn, .lvlearnbar")) { e.preventDefault(); e.stopPropagation(); } return; }
|
||
lvxLearnPick(e);
|
||
}, true);
|
||
|
||
/* the page shows / goes (renderPanels) */
|
||
let lvShown = false;
|
||
function lvShow() {
|
||
if (!dev || !dev.dump) return;
|
||
if (!lvShown) {
|
||
lvShown = true;
|
||
LV.target = dev.sel ?? 0;
|
||
if (!LV.pl.restored) { LV.pl.restored = true; plRestore(); }
|
||
lvxRestore();
|
||
op(async () => {
|
||
await lvKits().catch(() => {});
|
||
await lvReadTracks(true);
|
||
if (lvOk() && !dev.bank) dev.bank = await bank.list(rqf).catch(() => null); /* (the USER presets in the lists) */
|
||
lvRender();
|
||
});
|
||
}
|
||
lvRender();
|
||
lvStart();
|
||
if (Object.keys(LVS.map).length) lvxMidiOn(); /* learned controls work as soon as the page shows */
|
||
}
|
||
function lvHide() {
|
||
if (!lvShown) return;
|
||
lvShown = false;
|
||
lvStop();
|
||
lvxStop();
|
||
lvxMidiOff();
|
||
LVS.learn = false;
|
||
document.documentElement.classList.remove("lvfocus");
|
||
if (LV.stale && dev && dev.dump) { LV.stale = false; needReload = true; maybeReload(); } /* the other pages see what changed here */
|
||
}
|
||
/* pushes while the page shows: a track's level, pan, mute or a parameter turned on the FM-1 */
|
||
function livePush(f) {
|
||
if (!LV.built) return;
|
||
if (f.cmd === CMD.TRACK_CHANGED) {
|
||
const c = parse[CMD.TRACK_CHANGED](f.a), o = LV.tr[c.track];
|
||
if (!o) return;
|
||
if (c.id === LVP().mute) { if (!lvTouched("lv:" + c.track)) o.mute = c.value ? 1 : 0; }
|
||
else if (c.id === 0 && !lvDrum(c.track)) { if (!lvTouched("lv:" + c.track)) o.level = c.value; }
|
||
else if (!lvTouched(`p:${c.track}:${c.id}`)) o.p[c.id] = c.value;
|
||
lvRenderStrip(c.track);
|
||
} else if (f.cmd === CMD.CHANGED) {
|
||
const c = parse[CMD.CHANGED](f.a), o = LV.tr[dev.sel];
|
||
if (c.scope) { lvRenderMaster(); if (c.id === gDrLvl()) { const ds = (dev.info.ntrk || 4) - 1; if (LV.tr[ds] && !lvTouched("lv:" + ds)) LV.tr[ds].level = c.value; lvRenderStrip(ds); } lvRenderPlay(); return; }
|
||
if (!o) return;
|
||
if (c.id === 0 && !lvDrum(dev.sel)) { if (!lvTouched("lv:" + dev.sel)) o.level = c.value; }
|
||
else if (c.id === LVP().mute) { if (!lvTouched("lv:" + dev.sel)) o.mute = c.value ? 1 : 0; }
|
||
else if (!lvTouched(`p:${dev.sel}:${c.id}`)) o.p[c.id] = c.value;
|
||
lvRenderStrip(dev.sel);
|
||
if (dev.sel === LV.target) lvRenderPlay();
|
||
} else if (f.cmd === CMD.RELOAD) {
|
||
op(async () => { await lvReadTracks(true); });
|
||
}
|
||
}
|
||
|
||
/* the computer keyboard on the page (not in a field): see lvShortcuts */
|
||
const lvEditing = (e) => e.target.closest("input:not([type=range]), select, textarea, [contenteditable='true']");
|
||
const lvDown = new Map(); /* e.code -> what its keyup ends */
|
||
window.addEventListener("keydown", (e) => {
|
||
if (tab !== "live" || !dev || !dev.dump || e.ctrlKey || e.metaKey || e.altKey || lvEditing(e)) return;
|
||
if (e.repeat) { if (lvDown.has(e.code) || e.code === "Space") e.preventDefault(); return; }
|
||
const k = e.key.toLowerCase(), digit = /^Digit(\d)$/.exec(e.code), li = LV_KEYS.indexOf(k);
|
||
let up = null;
|
||
const fk = /^F([1-8])$/.exec(e.key);
|
||
if (fk) { const k = +fk[1] - 1; if (e.shiftKey) lvxStore(k); else lvxRecall(k); } /* LIVE pro: scenes (Shift: store) */
|
||
else if (e.code === "Space") lvSend(LIVE.PLAY, LV.s && LV.s.playing ? 0 : 1); /* (always: a focused button takes Enter) */
|
||
else if (digit) {
|
||
const d = +digit[1];
|
||
if (d >= 1 && d <= 4) lvTap(LIVE.LY_SONG, LIVE.SEC + d - 1);
|
||
else if (d >= 5 && d <= 8) { if (e.shiftKey) lvSolo(d - 5); else if (LV.tr[d - 5]) lvMute(d - 5, !LV.tr[d - 5].mute); }
|
||
else if (d === 9) { lvKey(LIVE.LY_MIX, LIVE.FILL, true); up = () => lvKey(LIVE.LY_MIX, LIVE.FILL, false); }
|
||
else if (d === 0) lvTap(LIVE.LY_MIX, LIVE.FILL_BAR);
|
||
} else if (k === "b") lvTap(LIVE.LY_MIX, LIVE.TAP);
|
||
else if (k === "c") lvSend(LIVE.REC);
|
||
else if (k === "n") lvSongNext();
|
||
else if (k === "z" || k === "x") { LV.oct = Math.max(1, Math.min(7, LV.oct + (k === "z" ? -1 : 1))); lvRenderPlay(); }
|
||
else if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
||
if (e.target.closest("[role=slider]")) return;
|
||
const n = dev.info.ntrk || 4; lvTarget((LV.target + (e.key === "ArrowLeft" ? n - 1 : 1)) % n);
|
||
} else if (e.key === "Escape") { lvAllOff(); if (LV.s && LV.s.fx >= 0) lvSend(LIVE.FX, LV.s.fx, 0); }
|
||
else if (li >= 0 && e.shiftKey) {
|
||
lvFx(li, LV.latch ? LV.fxHeld !== li : true);
|
||
if (!LV.latch) up = () => lvFx(li, false);
|
||
LV.ui.fx[li]?.classList.add("on");
|
||
const b = LV.ui.fx[li]; const prev = up; up = () => { b?.classList.remove("on"); if (prev) prev(); };
|
||
} else if (li >= 0) {
|
||
const tok = "lvkb:" + e.code, drum = lvDrum(LV.target);
|
||
lvNoteOn(tok, LV.target, drum ? lvDrumNote(li) : (LV.oct + 1) * 12 + li, drum ? LV_VEL[LV.dlv] : LV.vel);
|
||
const b = drum ? LV.ui.padBtns[li] : LV.ui.keys.querySelector(`[data-semi="${li}"]`);
|
||
if (b) { b.classList.add("on"); b.dataset.tok = tok; }
|
||
up = () => { lvNoteOff(tok); b?.classList.remove("on"); };
|
||
} else return;
|
||
e.preventDefault();
|
||
if (up) lvDown.set(e.code, up);
|
||
});
|
||
window.addEventListener("keyup", (e) => { const up = lvDown.get(e.code); if (up) { lvDown.delete(e.code); up(); } });
|
||
function lvLetGo() { for (const up of lvDown.values()) up(); lvDown.clear(); lvAllOff(); }
|
||
window.addEventListener("blur", lvLetGo);
|
||
document.addEventListener("visibilitychange", () => { if (document.hidden) lvLetGo(); });
|
||
|
||
$("connect").addEventListener("click", () => {
|
||
if (dev) { wantConnected = false; disconnect(); } else connect();
|
||
});
|
||
applyLang();
|
||
showTab(tab);
|
||
libInit();
|
||
if (!MOCK && !navigator.requestMIDIAccess) sayK("nomidi");
|
||
})();
|
||
/* the site without internet (SLOOP 2.6, webapp/sw.js): opened once online, the editor and the installer work
|
||
* offline too, still on https (Android: a downloaded file opens as content://, where Chrome refuses MIDI) */
|
||
/*PWA*/if ("serviceWorker" in navigator && /^https?:$/.test(location.protocol))
|
||
navigator.serviceWorker.register("../sw.js").catch(() => {});
|
||
{ /* (outside the editor's own scope: no $ here) */
|
||
let ask = null;
|
||
const btn = document.getElementById("install");
|
||
window.addEventListener("beforeinstallprompt", (e) => { e.preventDefault(); ask = e; btn.hidden = false; });
|
||
window.addEventListener("appinstalled", () => { ask = null; btn.hidden = true; });
|
||
btn.addEventListener("click", async () => {
|
||
if (!ask) return;
|
||
ask.prompt();
|
||
await ask.userChoice.catch(() => {});
|
||
ask = null;
|
||
btn.hidden = true;
|
||
});
|
||
}/*/PWA*/
|
||
</script>
|
||
</body>
|
||
</html>
|