mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-05 12:24:42 +01:00
v0.6.11: FM6 voice bank B1..B32 (from Felucca 1.5.1)
- fm6_vbank.c from Felucca 1.5.1: 32 voices in flash at 0xE7000 (free in JIANT), staged in the autosave's older copy, committed last: a power cut leaves the old bank or the new one. Its record type is 64 here (Felucca's 32 is a song object in JIANT's store) - eng_fm6.c / params.c: SLOT F1..F8, OWN, B1..B32 (9..40); the knob skips empty bank slots, elsewhere a B slot without a voice is refused; never stored as a bank slot (param_fit: OWN, the patch comes with the project / preset); the bank voice's name on the chart - storage.c st_crc32_add, fm1_flash.h FL_VBANK, up_fm6.c's 7/8-bit packing shared (Felucca's) - editor: cmds 74..77 (FM6B_BEGIN / WRITE / END / LIST) as Felucca's, INFO 56 01 32 - web editor: the bank sender (fm6Bank: a 32-voice .syx sent whole with its CRC, the device's bank shown) in the 6-OP FM tab; the mock device's bank; EDITOR_PROTOCOL.md - tests: Felucca's fm6bank_test (power cuts at every byte, CRC, SLOT, stored values; also under ASan/UBSan), its web bank test, FM6 SLOT range, the INFO tag; README, cheat sheets Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
28 files changed
+1244
-84
No files matched your search
@@ -15,7 +15,7 @@ and takes its song system from [SLOOP](https://github.com/isod89/sloop-fm1).
|
||||
the FM-1, with sound, and is played with your computer keyboard or the mouse. The emulator, the installer and the
|
||||
editor update themselves with every change merged into `main`.
|
||||
|
||||
> **Status: in development (v0.6.10).** It builds and passes every test (Felucca's and its own), Back up the flash before installing it.
|
||||
> **Status: in development (v0.6.11).** It builds and passes every test (Felucca's and its own), Back up the flash before installing it.
|
||||
|
||||
## Cheat sheets
|
||||
|
||||
@@ -30,6 +30,13 @@ Two printable sheets with everything on the device. Click an image to open it fu
|
||||
|
||||
Every update is listed here, newest first.
|
||||
|
||||
### v0.6.11
|
||||
- **FM6 voice bank**, from Felucca 1.5.1: a whole 32-voice DX7 cartridge (.syx) sent from the web editor (6-OP FM tab,
|
||||
**Send to the device's voice bank**), picked on the device with **SLOT B1–B32** after F1–F8 and OWN (empty slots
|
||||
skipped; the voice's name above the algorithm). Loading a voice copies it into the track, so projects and presets
|
||||
keep it whatever the bank holds later. Its own flash sector (0xE7000), written so a power cut leaves the old bank or
|
||||
the new one, never half; editor commands 74–77 as Felucca's. The full backup doesn't include it: keep the .syx.
|
||||
|
||||
### v0.6.10
|
||||
- **FM6 fully editable on the device**, brought from Felucca 1.5.1: EDIT > **OPERATOR** (operator 1–6, RATIO / FIXED,
|
||||
FINE, LEVEL), **OP ENV** (each stage's RATE and LEVEL, drawn) and **OPERATOR 2** (MODE, DTUN, VEL), on an FM6 track
|
||||
@@ -277,6 +284,11 @@ Eight engines, all synthesis, no samples: **ANALOG, FM6, PHASE, LOFI, VOICE, WHE
|
||||
ATK DEC SUS REL, its RATE and LEVEL, drawn as the envelope) and **OPERATOR 2** (MODE ratio/fixed, DTUN, VEL), the
|
||||
operator lit on the algorithm chart with its frequency. Editing makes the patch the track's own (SLOT OWN) and it is
|
||||
saved with the project; the macros (EDIT 1 / 2) still act on top. The web editor edits every byte of it too.
|
||||
**Voice bank** (from Felucca 1.4.1): import a 32-voice DX7 cartridge (.syx) in the web editor's 6-OP FM tab and press
|
||||
**Send to the device's voice bank**; on an FM6 track **SLOT** (EDIT 2, KNOB 4) then goes F1–F8, OWN, **B1–B32**
|
||||
(empty slots skipped), the voice's name on the chart. A voice loaded is copied into the track: projects and user
|
||||
presets keep it even after you send another bank. The bank lives in its own flash sector, written power-cut safe;
|
||||
the full backup does not include it (keep the .syx).
|
||||
- **PHASE**: phase distortion with **FB** (the output feeds back into the phase: from hard edge to growl).
|
||||
- **LOFI**: 1, 4 and 8-bit chip with **BYTE** (bytebeat: 32 formulas picked with ALGO and mutated with VAR). In
|
||||
BYTE, **MOTN** sets the speed of the formula's rhythm, **GRIT** crushes its rate, **BEND** folds time and **LOOP**
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 936 KiB After Width: | Height: | Size: 936 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 915 KiB After Width: | Height: | Size: 923 KiB |
@@ -51,9 +51,9 @@ ul { padding-left: 18px; } li { margin: 2px 0; }
|
||||
</style></head><body>
|
||||
<header><img src="signature.png" alt="JIANT FM signature"><div>
|
||||
<h1>JIANT FM · CONTROLS</h1><h2>every button, knob, layer, combo and page</h2>
|
||||
<div class="ver">firmware v0.6.10 · M-VAVE FM-1 · juanjiant-bit.github.io/JIANT</div></div></header>
|
||||
<div class="ver">firmware v0.6.11 · M-VAVE FM-1 · juanjiant-bit.github.io/JIANT</div></div></header>
|
||||
<div class="rule"></div>
|
||||
<div class="sec">THE PANEL<span></span></div><div class="grid g2"><div class="card" style="--c:#22d3ee" ><h3>KNOBS AND TRANSPORT</h3><table><tr><td class="n">MASTER</td><td>Master volume.</td></tr><tr><td class="n">SELECT</td><td>HOME and GLOBAL: the tempo. Any other page: <b>rolls the sound's dice</b>. Macros open (LFO held or latched): new random routes. GLO held: the tempo.</td></tr><tr><td class="n">PRESETS</td><td>Browses the sounds (factory and user). On step, list and song pages: the cursor / the row. <b>Hold a page button + PRESETS: jump through its pages.</b></td></tr><tr><td class="n">ALGORITHM</td><td>Selects the track, T1–T6, from any page.</td></tr><tr><td class="n">KNOB 1–4</td><td>The four columns on screen. Fast sweeps the whole range, slow fine-tunes. With a layer held: the layer's.</td></tr><tr><td class="n">OCT− · OCT+</td><td>The keyboard's octave (both together: back to 0). On action pages and dialogs: back / confirm.</td></tr><tr><td class="n">PLAY</td><td>Start / stop. GLO + PLAY: restart from the top.</td></tr><tr><td class="n">REC</td><td>Arms live recording on the selected track (notes and knob moves, overdub).</td></tr><tr><td class="n">HOME</td><td>Tap: the ecosystem. <b>Hold: the MENU.</b></td></tr><tr><td class="n">KEYS</td><td>27 keys play the selected track in its scale; with a layer held they become that layer's.</td></tr></table></div><div class="card" style="--c:#8b5cf6" ><h3>PAGE BUTTONS</h3><table class="pages"><tr><th>BUTTON</th><th>TAP: ITS PAGES, ONE PER TAP</th><th>HOLD</th></tr><tr><td class="n">ENV</td><td>ENV · ENV DEST</td><td class="dim">—</td></tr><tr><td class="n">LFO</td><td>LFO · LFO DEST · MOD · MSEQ · MSEQ 2</td><td class="dim">MACROS M1–M4 (stay latched)</td></tr><tr><td class="n">FX</td><td>FX · DIST · AUTOPAN · SLICER · SL BUS · SL BUS 2 · SL PITCH · DLY · DLY 2 · REVERB · REVERB 2 · CHORUS · MASTER</td><td class="dim">PUNCH-IN FX</td></tr><tr><td class="n">SCL</td><td>SCL · SCL 2</td><td class="dim">ROOT by key</td></tr><tr><td class="n">EDIT</td><td>EDIT 1 · EDIT 2 · FILTER · VOICE (FM6: OPERATOR · OP ENV · OPERATOR 2; DRUM: LANES · LANES 2 · SOUND 1–3 · X-MOD)</td><td class="dim">INIT · RECALL · sound mutes</td></tr><tr><td class="n">GLO</td><td>MIXER · GLOBAL · SYSTEM</td><td class="dim">MUTE · SOLO · LEVEL · TAP</td></tr><tr><td class="n">SAVE</td><td>PRESETS · USER · PROJECT · TOOLS</td><td class="dim">SONG layer</td></tr><tr><td class="n">ARP</td><td>ARP · ARP 2</td><td class="dim">—</td></tr><tr><td class="n">SEQ</td><td>STEP · PATTERN · SHIFT · PHRASES · SONG · CHANCE · AUTOMATION · AUTO LIST</td><td class="dim">SEQ TOOLS</td></tr><tr><td class="n">REC</td><td>(transport)</td><td class="dim">CLEAR · CLICK</td></tr></table><p style="margin-top:10px"><span class="k v">BUTTON</span> + <span class="k v">PRESETS</span> jumps straight to a page (no wrap); let go and you stay there.</p></div></div><div class="sec">LAYERS · HOLD A BUTTON<span></span></div><div class="grid g2"><div class="card" style="--c:#ff7a00" ><h3>FX · PUNCH-IN EFFECTS</h3><div class="kb"><div class="w on" style="left:0.0px;width:40.2px"><b>F3</b>REP 1/8</div><div class="w on" style="left:43.2px;width:40.2px"><b>G3</b>REP 1/16</div><div class="w on" style="left:86.5px;width:40.2px"><b>A3</b>REP 1/32</div><div class="w on" style="left:129.8px;width:40.2px"><b>B3</b>LPF</div><div class="w on" style="left:173.0px;width:40.2px"><b>C4</b>HPF</div><div class="w on" style="left:216.2px;width:40.2px"><b>D4</b>OCT−</div><div class="w on" style="left:259.5px;width:40.2px"><b>E4</b>OCT+</div><div class="w on" style="left:302.8px;width:40.2px"><b>F4</b>½ TEMPO</div><div class="w on" style="left:346.0px;width:40.2px"><b>G4</b>DEC−</div><div class="w on" style="left:389.2px;width:40.2px"><b>A4</b>DEC+</div><div class="w on" style="left:432.5px;width:40.2px"><b>B4</b>STUT 1/8</div><div class="w on" style="left:475.8px;width:40.2px"><b>C5</b>STUT 1/16</div><div class="w on" style="left:519.0px;width:40.2px"><b>D5</b>ATK+</div><div class="w on" style="left:562.2px;width:40.2px"><b>E5</b>ARP</div><div class="w on" style="left:605.5px;width:40.2px"><b>F5</b>RAND</div><div class="w on" style="left:648.8px;width:40.2px"><b>G5</b>ERASE</div><div class="b on" style="left:27.7px;width:31.1px"><b>F#</b>M1</div><div class="b on" style="left:70.9px;width:31.1px"><b>G#</b>M2</div><div class="b on" style="left:114.2px;width:31.1px"><b>A#</b>M3</div><div class="b on" style="left:200.7px;width:31.1px"><b>C#</b>M4</div><div class="b on" style="left:243.9px;width:31.1px"><b>D#</b>M5</div><div class="b on" style="left:330.4px;width:31.1px"><b>F#</b>M6</div><div class="b" style="left:373.7px;width:31.1px"><b>G#</b></div><div class="b on" style="left:416.9px;width:31.1px"><b>A#</b>TGT</div><div class="b" style="left:503.4px;width:31.1px"><b>C#</b></div><div class="b" style="left:546.7px;width:31.1px"><b>D#</b></div><div class="b" style="left:633.2pxLine truncated
|
||||
<footer><span>GPL-3.0 · fork of Felucca (Hügelton Instruments) · song mode from SLOOP</span>
|
||||
<span>JIANT FM v0.6.10</span></footer>
|
||||
<span>JIANT FM v0.6.11</span></footer>
|
||||
</body></html>
|
||||
@@ -51,9 +51,9 @@ ul { padding-left: 18px; } li { margin: 2px 0; }
|
||||
</style></head><body>
|
||||
<header><img src="signature.png" alt="JIANT FM signature"><div>
|
||||
<h1>JIANT FM · SOUND · FX · MOD</h1><h2>engines, effects, modulation, sequencer and songs</h2>
|
||||
<div class="ver">firmware v0.6.10 · M-VAVE FM-1 · juanjiant-bit.github.io/JIANT</div></div></header>
|
||||
<div class="ver">firmware v0.6.11 · M-VAVE FM-1 · juanjiant-bit.github.io/JIANT</div></div></header>
|
||||
<div class="rule"></div>
|
||||
<div class="sec">ENGINES · EDIT 1 / EDIT 2<span></span></div><div class="card" style="--c:#f4f1ea" ><h3>EIGHT ENGINES, ALL SYNTHESIS</h3><table><tr><th>ENGINE</th><th>EDIT 1</th><th>EDIT 2</th><th>WHAT TO KNOW</th></tr><tr><td class="n" style="--c:#3b82f6">ANALOG</td><td style="width:22%"><div class="knobs"><span class="">WAVE</span><span class="">DTN</span><span class="">MIX</span><span class="">NOIS</span></div></td><td style="width:22%"><div class="knobs"><span class="">CUT</span><span class="">RES</span><span class="">DRV</span><span class="">INT</span></div></td><td>SAW SQR TRI SIN PWM <b>SYNC RING SAW3</b>; INT: osc 2 ±24 st. Its filter is per voice.</td></tr><tr><td class="n" style="--c:#d946ef">FM6</td><td style="width:22%"><div class="knobs"><span class="">ALG</span><span class="">FB</span><span class="">MLVL</span><span class="">MRAT</span></div></td><td style="width:22%"><div class="knobs"><span class="">MEG</span><span class="">VMOD</span><span class="">DTUN</span><span class="">SLOT</span></div></td><td>Dexed's 6 operators, 32 algorithms drawn, .syx patches (SLOT), MLVL / MRAT move the modulators. <b>OPERATOR · OP ENV · OPERATOR 2</b>: each operator on the device (ratio / fixed, fine, level, its envelope, mode, detune, velocity).</td></tr><tr><td class="n" style="--c:#8b5cf6">PHASE</td><td style="width:22%"><div class="knobs"><span class="">WAVE</span><span class="">WAVE2</span><span class="">DCW</span><span class="">ENV</span></div></td><td style="width:22%"><div class="knobs"><span class="">DTN</span><span class="">LINE</span><span class="">SUB</span><span class="">FB</span></div></td><td>Phase distortion (CZ); <b>FB</b> feeds the output back into the phase: hard edge to growl.</td></tr><tr><td class="n" style="--c:#22d3ee">LOFI</td><td style="width:22%"><div class="knobs"><span class="">CHIP</span><span class="">WAVE</span><span class="">DUTY</span><span class="">CRSH</span></div></td><td style="width:22%"><div class="knobs"><span class="e">-</span><span class="">VIB</span><span class="">BEND</span><span class="">MASK</span></div></td><td>Chip: PLS TRI SAW NOIS WRAM. <b>BYTE</b>: ALGO VAR · MOTN GRIT BEND LOOP. <b>FLOAT</b> (floatbeat): ALGO VAR · MOTN FBK BEND LOOP; CHIP sets FULL / 4BIT / 1BIT.</td></tr><tr><td class="n" style="--c:#facc15">VOICE</td><td style="width:22%"><div class="knobs"><span class="">VOWL</span><span class="">VOWL2</span><span class="">TALK</span><span class="">SHIFT</span></div></td><td style="width:22%"><div class="knobs"><span class="">BUZZ</span><span class="">BRTH</span><span class="">Q</span><span class="">RAND</span></div></td><td>Formant voice (after klattsch): vowels, talk, breath.</td></tr><tr><td class="n" style="--c:#ff7a00">WHEEL</td><td style="width:22%"><div class="knobs"><span class="">REG</span><span class="">SUB</span><span class="">BODY</span><span class="">TOP</span></div></td><td style="width:22%"><div class="knobs"><span class="">PERC</span><span class="">CLICK</span><span class="">DRV</span><span class="">ROTR</span></div></td><td>Drawbar organ: registrations, percussion, rotary.</td></tr><tr><td class="n" style="--c:#ef4444">NOISE</td><td style="width:22%"><div class="knobs"><span class="">MODE</span><span class="">COLR</span><span class="">FREQ</span><span class="">PEAK</span></div></td><td style="width:22%"><div class="knobs"><span class="">TRK</span><span class="">DENS</span><span class="">DRFT</span><span class="">CRSH</span></div></td><td>Coloured and metallic noise, tracked or free.</td></tr><tr><td class="n" style="--c:#ff7a00">DRUM-X</td><td style="width:22%"><div class="knobs"><span class="">MRPH</span><span class="">TUNE</span><span class="">TONE</span><span class="">DECY</span></div></td><td style="width:22%"><div class="knobs"><span class="">NOIS</span><span class="">FM</span><span class="">FOLD</span><span class="">DRV</span></div></td><td>8 sounds BD SD CP CH OH TM RS CB, sides A / B: <b>MRPH</b> morphs the kit. SOUND 1–3: LANE SIDE PTCH PMOD · DCAY NOIS COLR MODE · LANE PMOD DRV WAVE. <b>X-MOD</b>: RATE DPTH SHPE RAND.</td></tr></table></div><div class="grid g3" style="margin-top:22px"><div class="card" style="--c:#d946ef" ><h3>FILTER · EVERY ENGINE</h3><div class="knobs"><span class="">TYPE</span><span class="">CUT</span><span class="">RES</span><span class="">DRV</span></div><p style="margin-top:8px"><b>LP · HP · BP · COMB</b>. COMB rings tuned to the note: CUT moves it ±32 st, RES how much it rings. ANALOG and LOFI: per voice; the others: on the track, following LFO / ENV DEST FLT (DRV = the track's DIST).</p></div><div class="card" style="--c:#8b5cf6" ><h3>VOICE · PLAYING</h3><div class="knobs"><span class="">VCE</span><span class="">GLD</span><span class="">GLMOD</span><span class="">PRIO</span></div><p style="margin-top:8px">POLY · MONO · LEG · UNI; glide and its mode; LAST / LOW / HIGH priority. <b>8 voices</b> shared by the six tracks (MONO and LEGATO keep their note).</p></div><div class="card" style=Line truncated
|
||||
<div class="sec">ENGINES · EDIT 1 / EDIT 2<span></span></div><div class="card" style="--c:#f4f1ea" ><h3>EIGHT ENGINES, ALL SYNTHESIS</h3><table><tr><th>ENGINE</th><th>EDIT 1</th><th>EDIT 2</th><th>WHAT TO KNOW</th></tr><tr><td class="n" style="--c:#3b82f6">ANALOG</td><td style="width:22%"><div class="knobs"><span class="">WAVE</span><span class="">DTN</span><span class="">MIX</span><span class="">NOIS</span></div></td><td style="width:22%"><div class="knobs"><span class="">CUT</span><span class="">RES</span><span class="">DRV</span><span class="">INT</span></div></td><td>SAW SQR TRI SIN PWM <b>SYNC RING SAW3</b>; INT: osc 2 ±24 st. Its filter is per voice.</td></tr><tr><td class="n" style="--c:#d946ef">FM6</td><td style="width:22%"><div class="knobs"><span class="">ALG</span><span class="">FB</span><span class="">MLVL</span><span class="">MRAT</span></div></td><td style="width:22%"><div class="knobs"><span class="">MEG</span><span class="">VMOD</span><span class="">DTUN</span><span class="">SLOT</span></div></td><td>Dexed's 6 operators, 32 algorithms drawn, .syx patches (SLOT), MLVL / MRAT move the modulators. <b>OPERATOR · OP ENV · OPERATOR 2</b>: each operator on the device (ratio / fixed, fine, level, its envelope, mode, detune, velocity). <b>SLOT B1–B32</b>: a 32-voice .syx sent from the web editor.</td></tr><tr><td class="n" style="--c:#8b5cf6">PHASE</td><td style="width:22%"><div class="knobs"><span class="">WAVE</span><span class="">WAVE2</span><span class="">DCW</span><span class="">ENV</span></div></td><td style="width:22%"><div class="knobs"><span class="">DTN</span><span class="">LINE</span><span class="">SUB</span><span class="">FB</span></div></td><td>Phase distortion (CZ); <b>FB</b> feeds the output back into the phase: hard edge to growl.</td></tr><tr><td class="n" style="--c:#22d3ee">LOFI</td><td style="width:22%"><div class="knobs"><span class="">CHIP</span><span class="">WAVE</span><span class="">DUTY</span><span class="">CRSH</span></div></td><td style="width:22%"><div class="knobs"><span class="e">-</span><span class="">VIB</span><span class="">BEND</span><span class="">MASK</span></div></td><td>Chip: PLS TRI SAW NOIS WRAM. <b>BYTE</b>: ALGO VAR · MOTN GRIT BEND LOOP. <b>FLOAT</b> (floatbeat): ALGO VAR · MOTN FBK BEND LOOP; CHIP sets FULL / 4BIT / 1BIT.</td></tr><tr><td class="n" style="--c:#facc15">VOICE</td><td style="width:22%"><div class="knobs"><span class="">VOWL</span><span class="">VOWL2</span><span class="">TALK</span><span class="">SHIFT</span></div></td><td style="width:22%"><div class="knobs"><span class="">BUZZ</span><span class="">BRTH</span><span class="">Q</span><span class="">RAND</span></div></td><td>Formant voice (after klattsch): vowels, talk, breath.</td></tr><tr><td class="n" style="--c:#ff7a00">WHEEL</td><td style="width:22%"><div class="knobs"><span class="">REG</span><span class="">SUB</span><span class="">BODY</span><span class="">TOP</span></div></td><td style="width:22%"><div class="knobs"><span class="">PERC</span><span class="">CLICK</span><span class="">DRV</span><span class="">ROTR</span></div></td><td>Drawbar organ: registrations, percussion, rotary.</td></tr><tr><td class="n" style="--c:#ef4444">NOISE</td><td style="width:22%"><div class="knobs"><span class="">MODE</span><span class="">COLR</span><span class="">FREQ</span><span class="">PEAK</span></div></td><td style="width:22%"><div class="knobs"><span class="">TRK</span><span class="">DENS</span><span class="">DRFT</span><span class="">CRSH</span></div></td><td>Coloured and metallic noise, tracked or free.</td></tr><tr><td class="n" style="--c:#ff7a00">DRUM-X</td><td style="width:22%"><div class="knobs"><span class="">MRPH</span><span class="">TUNE</span><span class="">TONE</span><span class="">DECY</span></div></td><td style="width:22%"><div class="knobs"><span class="">NOIS</span><span class="">FM</span><span class="">FOLD</span><span class="">DRV</span></div></td><td>8 sounds BD SD CP CH OH TM RS CB, sides A / B: <b>MRPH</b> morphs the kit. SOUND 1–3: LANE SIDE PTCH PMOD · DCAY NOIS COLR MODE · LANE PMOD DRV WAVE. <b>X-MOD</b>: RATE DPTH SHPE RAND.</td></tr></table></div><div class="grid g3" style="margin-top:22px"><div class="card" style="--c:#d946ef" ><h3>FILTER · EVERY ENGINE</h3><div class="knobs"><span class="">TYPE</span><span class="">CUT</span><span class="">RES</span><span class="">DRV</span></div><p style="margin-top:8px"><b>LP · HP · BP · COMB</b>. COMB rings tuned to the note: CUT moves it ±32 st, RES how much it rings. ANALOG and LOFI: per voice; the others: on the track, following LFO / ENV DEST FLT (DRV = the track's DIST).</p></div><div class="card" style="--c:#8b5cf6" ><h3>VOICE · PLAYING</h3><div class="knobs"><span class="">VCE</span><span class="">GLD</span><span class="">GLMOD</span><span class="">PRIO</span></div><p style="margin-top:8px">POLY · MONO · LEG · UNI; glide and its mode; LAST / LOW / HIGH priority. <b>8 voices</b> shared by the six tracks (MONLine truncated
|
||||
<footer><span>GPL-3.0 · fork of Felucca (Hügelton Instruments) · song mode from SLOOP</span>
|
||||
<span>JIANT FM v0.6.10</span></footer>
|
||||
<span>JIANT FM v0.6.11</span></footer>
|
||||
</body></html>
|
||||
@@ -42,14 +42,16 @@ static inline void *fl_far(void *p) { void *volatile q = p; return q; }
|
||||
#define FL_OTA_LO 0x000E0000u /* M-UPGRADE loader staging, ota.c */
|
||||
#define FL_OTA_HI 0x000E5000u
|
||||
#define FL_AUTO_LO 0x000E5000u /* 1.2: the autosave (storage.c OBJ_AUTOSAVE), A/B, just above */
|
||||
#define FL_AUTO_HI 0x000E7000u /* the OTA staging; 0xE7000 stays free */
|
||||
#define FL_AUTO_HI 0x000E7000u /* the OTA staging */
|
||||
#define FL_VBANK_LO 0x000E7000u /* (JIANT 0.6.11, Felucca 1.4.1) the FM6 voice bank (fm6_vbank.c), */
|
||||
#define FL_VBANK_HI 0x000E8000u /* the sector above (below the stock OTA's VM backup, 0xE8000) */
|
||||
/* [off, off + n) inside [lo, hi), without wrapping: off + n can overflow, and
|
||||
* the 1 MiB part ignores the high address bits, so a wrapped range lands low. */
|
||||
#define FL_IN(off, n, lo, hi) ((uint32_t)(off) >= (lo) && (uint32_t)(off) <= (hi) && \
|
||||
(uint32_t)(n) <= (hi) - (uint32_t)(off))
|
||||
/* Felucca's own store (projects, songs; settings; the autosave) */
|
||||
#define FL_STORE_OK(off, n) (FL_IN(off, n, FL_DATA_LO, FL_DATA_HI) || FL_IN(off, n, FL_GLOB_LO, FL_GLOB_HI) || \
|
||||
FL_IN(off, n, FL_AUTO_LO, FL_AUTO_HI))
|
||||
FL_IN(off, n, FL_AUTO_LO, FL_VBANK_HI)) /* (the autosave and the FM6 voice bank) */
|
||||
/* Where the RAM driver may erase / program. The app build allows only its own
|
||||
* data regions; the update loader (firmware/loader) defines its own window. */
|
||||
#ifndef FL_RANGE_OK
|
||||
|
||||
@@ -408,6 +408,7 @@ static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes between F0
|
||||
ed_b(0x4E); ed_b(1); ed_b(ED_MENU_N); /* MENU settings: cmds 72, 73; the items MENU_DESC offers */
|
||||
ed_b(0x52); ed_b(1); ed_b(4); /* RATCH: a step's ratchet (1..4 hits) after its chance */
|
||||
ed_b(0x4C); ed_b(1); ed_b(1); /* 1.1 parameter locks: MOTION ops 5..7, the kinds after the records */
|
||||
ed_b(0x56); ed_b(1); ed_b(FM6_NBANK); /* (JIANT 0.6.11, Felucca 1.4.1) FM6's voice bank: cmds 74..77, SLOT 9..40 */
|
||||
break;
|
||||
case ED_GET:
|
||||
case ED_SET:
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
/* Editor protocol: the FM6 patches (EDITOR_PROTOCOL.md "FM6 patches", cmds 68..71). A patch travels as the
|
||||
* 128-byte packed record (every byte 7-bit: no pack7). Targets: 0 a track's own patch (index 0..3), 1 the patch bank
|
||||
* (retired in 1.0.3: GET / PUT / ERASE answer rc 3, "no bank"; LIST counts 0 bank slots), 2 a factory patch
|
||||
* (0..FM6_NFACTORY-1, read only), 3 a user preset's patch (0..UP_SLOTS-1: an FM6 user preset; up_fm6.c). */
|
||||
* (0..FM6_NFACTORY-1, read only), 3 a user preset's patch (0..UP_SLOTS-1: an FM6 user preset; up_fm6.c).
|
||||
* 1.4.1: the voice bank (EDITOR_PROTOCOL.md "FM6 voice bank", cmds 74..77; fm6_vbank.c), written whole: BEGIN, a
|
||||
* WRITE per voice, END with the name and the CRC; LIST its names. */
|
||||
enum { ED_FM6_GET = 68, ED_FM6_PUT, ED_FM6_LIST, ED_FM6_ERASE };
|
||||
enum { ED_FM6B_BEGIN = 74, ED_FM6B_WRITE, ED_FM6B_END, ED_FM6B_LIST };
|
||||
enum { ED_FM6_TRACK, ED_FM6_BANK, ED_FM6_FACTORY, ED_FM6_USER };
|
||||
#define ED_FM6_NOBANK 3u /* rc: this firmware has no patch bank */
|
||||
|
||||
@@ -80,6 +83,45 @@ static int ed_fm6_handle(uint32_t cmd, const uint8_t *a, uint32_t n)
|
||||
rc = n != 1u ? 1u : ED_FM6_NOBANK;
|
||||
ed_b(n ? a[0] : 127u); ed_b(rc);
|
||||
return 1;
|
||||
case ED_FM6B_BEGIN: /* -> rc */
|
||||
ed_b(n ? 1u : ed_flash_stop() ? 3u : fvb_begin());
|
||||
return 1;
|
||||
case ED_FM6B_WRITE: /* index, 128 bytes -> index, rc */
|
||||
ed_b(n ? a[0] : 127u);
|
||||
ed_b(n != 1u + FM6_PACKED ? 1u : ed_flash_stop() ? 3u : fvb_write(a[0], a + 1));
|
||||
return 1;
|
||||
case ED_FM6B_END: /* name (10), CRC-32 (5 x 7 bits) -> rc, voices */
|
||||
rc = n != 15u || a[14] > 15u ? 1u : ed_flash_stop() ? 3u :
|
||||
fvb_end(a, (uint32_t)a[10] | (uint32_t)a[11] << 7 | (uint32_t)a[12] << 14 | (uint32_t)a[13] << 21 |
|
||||
(uint32_t)a[14] << 28);
|
||||
ed_b(rc);
|
||||
for (i = 0, n = 0; i < FM6_NBANK; i++)
|
||||
n += (fm6_bank_used >> i) & 1u;
|
||||
ed_b(n);
|
||||
return 1;
|
||||
case ED_FM6B_LIST: { /* -> voices (32), bank (0 none / 1), its name, per voice:
|
||||
* used, name */
|
||||
const fvb_info_t *in;
|
||||
char nm[11];
|
||||
if (n)
|
||||
return 0;
|
||||
in = fvb_info();
|
||||
for (i = 0; i < 10u; i++)
|
||||
nm[i] = in ? in->name[i] : 0;
|
||||
for (nm[10] = 0, i = 10; i && (nm[i - 1] == ' ' || !nm[i - 1]); i--)
|
||||
nm[i - 1] = 0;
|
||||
ed_b(FM6_NBANK); ed_b(in != 0);
|
||||
ed_str(nm, 10);
|
||||
for (i = 0; i < FM6_NBANK; i++) {
|
||||
uint32_t u = fm6_bank_read && !fm6_bank_read(i, pk);
|
||||
ed_b(u);
|
||||
if (u)
|
||||
ed_fm6_name(pk);
|
||||
else
|
||||
ed_b(0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+49
-15
@@ -18,9 +18,13 @@
|
||||
* DTUN spreads the carriers apart in pitch (up to about +-36 cents between the outer ones)
|
||||
* SLOT F1..F8 load a factory patch; OWN (8) is the track's own patch: what a project, a user preset or the
|
||||
* editor put there. A load shows F n when the patch is that factory one unchanged, else OWN (fm6_adopt).
|
||||
* Turning SLOT from OWN to F n keeps the own patch aside; back to OWN brings it back (fm6_poll).
|
||||
* B1..B32 (9..40, JIANT 0.6.11 from Felucca 1.4.1) load a voice of the 32-voice bank in flash (fm6_vbank.c)
|
||||
* as F n do; a bank slot without a voice is skipped by the knob (params.c enum_step) and refused anywhere
|
||||
* else (fm6_poll). Turning SLOT from OWN to F n / B n keeps the own patch aside; back to OWN brings it back.
|
||||
* Before 1.0.3 the values 8..34 were F1..F8 then B1..B27, a flash bank (retired: its patches moved into
|
||||
* the user presets, up_fm6.c); a stored 8..34 is clamped to 8, OWN, and its patch comes with the record
|
||||
* the user presets, up_fm6.c). A stored value is never a bank slot: projects, user presets and motion
|
||||
* load 9..40 as 8, OWN (params.c param_fit), and the patch comes with the project / the record. So a
|
||||
* project or a preset made with a bank voice sounds the same after the bank is replaced
|
||||
* The operator envelopes are the voice's amplitude and end it (engine_t.ownenv / done): the track's ADSR,
|
||||
* ENV DEST and the matrix's ENV do nothing here. The track's FLT moves MLVL (ENV / LFO -> FLT, the
|
||||
* matrix's CUT), SHP the feedback, PIT the pitch (bend, glide, tune: the voice's pitch and fine factor).
|
||||
@@ -35,6 +39,7 @@
|
||||
#define ENGI_FM6 12u /* engines.c ENGINES[] (append-only) */
|
||||
#define FM6_POLY 6 /* engine_t.poly */
|
||||
#define FM6_OWN FM6_NFACTORY /* SLOT: the track's own patch (F1..F8 before it) */
|
||||
#define FM6_NBANK 32u /* SLOT: B1..B32 after OWN, the voice bank (fm6_vbank.c) */
|
||||
#define FM6_PACKED 128u
|
||||
|
||||
static uint8_t fm6_patch[NTRK][FP_SIZE + 1u]; /* the tracks' patches (main loop writes, then fm6_pgen) */
|
||||
@@ -51,6 +56,21 @@ static struct { /* the patch through the macros
|
||||
static fm6_lfo_t fm6_lfo[NTRK];
|
||||
static int32_t fm6_lfo_v[NTRK], fm6_lfo_d[NTRK]; /* this block's LFO value and delay (Q24) */
|
||||
static fm6_note_t fm6_note[NTRK][FM6_POLY];
|
||||
/* the voice bank (fm6_vbank.c; in the pool, zeroed at boot: no bank without the store) */
|
||||
static uint32_t fm6_bank_used __attribute__((section(".pool"))); /* bit k: B k+1 holds a voice */
|
||||
static int (*fm6_bank_read)(uint32_t k, uint8_t *pk) __attribute__((section(".pool"))); /* voice k -> pk, 0 = read */
|
||||
|
||||
/* SLOT value s is a bank slot (B1..B32): its voice number, else -1 */
|
||||
static int32_t fm6_bank_slot(int32_t s)
|
||||
{
|
||||
return s > (int32_t)FM6_OWN && s <= (int32_t)(FM6_OWN + FM6_NBANK) ? s - (int32_t)FM6_OWN - 1 : -1;
|
||||
}
|
||||
/* SLOT value s can load: a factory slot, OWN, or a bank slot with a voice */
|
||||
static int fm6_slot_ok(int32_t s)
|
||||
{
|
||||
int32_t k = fm6_bank_slot(s);
|
||||
return k < 0 ? s >= 0 && s <= (int32_t)FM6_OWN : (int)((fm6_bank_used >> k) & 1u);
|
||||
}
|
||||
/* (JIANT 0.6.8, "certain syx sounds glitchy and noisy") a voice's output above the level every voice is made for
|
||||
* (VOICE_FS, dsp.c: the bus at 2^26) takes the track's trim down so it sits there: DX7 voices with several carriers
|
||||
* at full came out up to 5x the factory patches, and their chords held the master's limiter 10 dB down. A voice's own
|
||||
@@ -163,13 +183,22 @@ static void fm6_set_patch(uint32_t tr, const uint8_t *v)
|
||||
fm6_pgen[tr]++;
|
||||
}
|
||||
|
||||
/* SLOT value s < FM6_NFACTORY: that factory patch into track tr */
|
||||
static void fm6_load_slot(uint32_t tr, uint32_t s)
|
||||
/* SLOT value s < FM6_NFACTORY: that factory patch into track tr; a bank slot: its voice (0 = loaded; 1 = the bank
|
||||
* has none there, nothing changed) */
|
||||
static int fm6_load_slot(uint32_t tr, uint32_t s)
|
||||
{
|
||||
uint8_t v[FP_SIZE + 1u];
|
||||
fm6_unpack(FM6_FACTORY[s % FM6_NFACTORY], v);
|
||||
uint8_t v[FP_SIZE + 1u], pk[FM6_PACKED];
|
||||
int32_t k = fm6_bank_slot((int32_t)s);
|
||||
if (k < 0) {
|
||||
s %= FM6_NFACTORY;
|
||||
memcpy(pk, FM6_FACTORY[s], FM6_PACKED);
|
||||
} else if (!fm6_slot_ok((int32_t)s) || !fm6_bank_read || fm6_bank_read((uint32_t)k, pk)) {
|
||||
return 1;
|
||||
}
|
||||
fm6_unpack(pk, v);
|
||||
fm6_set_patch(tr, v);
|
||||
fm6_slot[tr % NTRK] = (uint8_t)(s % FM6_NFACTORY);
|
||||
fm6_slot[tr % NTRK] = (uint8_t)s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* track tr's patch was just put in as its own (a project, a user preset, the editor, a conversion): an FM6 track's
|
||||
@@ -220,8 +249,9 @@ static void fm6_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* main loop: SLOT turned (a knob, the editor, MIDI, motion) -> that factory patch; from OWN the own patch is kept
|
||||
* aside (fm6_own), and turning back to OWN brings it back */
|
||||
/* main loop: SLOT turned (a knob, the editor, MIDI, motion) -> that factory patch or bank voice; from OWN the own
|
||||
* patch is kept aside (fm6_own), and turning back to OWN brings it back. A bank slot without a voice (the editor, a
|
||||
* MIDI CC) is refused: SLOT goes back to what it was, nothing loads */
|
||||
static void fm6_poll(void)
|
||||
{
|
||||
uint32_t tr, bit;
|
||||
@@ -230,7 +260,7 @@ static void fm6_poll(void)
|
||||
if (trk[tr].eng_req != ENGI_FM6 || s == fm6_slot[tr])
|
||||
continue;
|
||||
bit = 1u << tr;
|
||||
if (s < 0 || s >= (int32_t)FM6_NFACTORY) { /* OWN */
|
||||
if (s < 0 || (s >= (int32_t)FM6_NFACTORY && fm6_bank_slot(s) < 0)) { /* OWN */
|
||||
if (fm6_own_ok & bit) {
|
||||
uint8_t v[FP_SIZE + 1u];
|
||||
fm6_unpack(fm6_own[tr], v);
|
||||
@@ -242,11 +272,12 @@ static void fm6_poll(void)
|
||||
trk[tr].p[P_E7] = FM6_OWN;
|
||||
continue;
|
||||
}
|
||||
if (fm6_slot[tr] == FM6_OWN && !(fm6_own_ok & bit)) {
|
||||
if (fm6_slot[tr] == FM6_OWN && !(fm6_own_ok & bit) && fm6_slot_ok(s)) {
|
||||
fm6_pack(fm6_patch[tr], fm6_own[tr]);
|
||||
fm6_own_ok |= (uint8_t)bit;
|
||||
}
|
||||
fm6_load_slot(tr, (uint32_t)s);
|
||||
if (fm6_load_slot(tr, (uint32_t)s)) /* a bank slot without a voice: SLOT back */
|
||||
trk[tr].p[P_E7] = (int16_t)(fm6_slot[tr] <= FM6_OWN + FM6_NBANK ? fm6_slot[tr] : FM6_OWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,8 +428,11 @@ static void fm6_render(track_t *t, voice_t *v, int32_t *out, uint32_t len, const
|
||||
static const char *const N_FM6_ALG[] = {"PAT", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
|
||||
"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25",
|
||||
"26", "27", "28", "29", "30", "31", "32", 0};
|
||||
static const char *const N_FM6_PATCH[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "OWN", 0};
|
||||
_Static_assert(NELEM(N_FM6_PATCH) == FM6_OWN + 2u, "a SLOT name per value");
|
||||
static const char *const N_FM6_PATCH[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "OWN",
|
||||
"B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "B11", "B12",
|
||||
"B13", "B14", "B15", "B16", "B17", "B18", "B19", "B20", "B21", "B22", "B23",
|
||||
"B24", "B25", "B26", "B27", "B28", "B29", "B30", "B31", "B32", 0};
|
||||
_Static_assert(NELEM(N_FM6_PATCH) == FM6_OWN + FM6_NBANK + 2u, "a SLOT name per value");
|
||||
|
||||
/* {ALG, FB, MLVL, MRAT, MEG, VMOD, DTUN, SLOT}: the factory patch F1..F8 as it is, DTUN on the pad */
|
||||
static const preset_t FM6_PRESETS[] = {
|
||||
@@ -423,7 +457,7 @@ static const engine_t ENG_FM6 = {
|
||||
{"MEG", F_BIPCT, -64, 63, 0, 0, 0},
|
||||
{"VMOD", F_INT, -7, 7, 0, 0, 0},
|
||||
{"DTUN", F_PCT, 0, 127, 0, 0, 0},
|
||||
{"SLOT", F_INT, 0, FM6_OWN, 0, N_FM6_PATCH, 0},
|
||||
{"SLOT", F_INT, 0, FM6_OWN + FM6_NBANK, 0, N_FM6_PATCH, 0},
|
||||
},
|
||||
.presets = FM6_PRESETS,
|
||||
.npresets = NELEM(FM6_PRESETS),
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */
|
||||
#endif
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "v0.6.10" /* JIANT's (based on Felucca 1.1.5.1): the splash, the menu, the console, the editor */
|
||||
#define FELUCCA_VERSION "v0.6.11" /* JIANT's (based on Felucca 1.1.5.1): the splash, the menu, the console, the editor */
|
||||
#endif
|
||||
#if FELUCCA_OTA && !FELUCCA_FLASH
|
||||
#error "FELUCCA_OTA needs FELUCCA_FLASH"
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
||||
* (JIANT 0.6.11: from Felucca 1.5.1; its record type OBJ_FM6VB is 64 here, storage.c) */
|
||||
/* The FM6 voice bank (1.4.1, Discussion #168): 32 voices loaded at once from the web editor (a 32-voice .syx, its
|
||||
* 128-byte packed records as they are), picked on the device with FM6's SLOT B1..B32 (eng_fm6.c). A voice is read
|
||||
* from flash when SLOT loads it, into the track's patch as F1..F8 load theirs: the patch is the track's from then on,
|
||||
* and a project or a user preset keeps it whatever the bank holds later. RAM: the used mask (eng_fm6.c
|
||||
* fm6_bank_used) and the transfer's state, in the pool; no copy of the bank.
|
||||
*
|
||||
* Where: flash 0xE7000 (fm1_flash.h FL_VBANK_*), the sector above the autosave's pair, which nothing else of Felucca
|
||||
* uses (the map: storage.c). Like the autosave's sectors it lies in the margin the stock firmware's own update stages
|
||||
* into, only while the stock firmware runs: a later Felucca finds no valid bank there (commit record, CRC) and starts
|
||||
* with none. Sector: the commit record (storage.c st_hdr_t, type OBJ_FM6VB) at 0, the bank's header (fvb_info_t) at
|
||||
* 224, the 32 voices at 256..3839, 112 bytes each (the record's 7-bit bytes 8 to 7, up_fm6.c upf_pk_put); the record's
|
||||
* CRC covers 224..3839. The tail from 0xF00 on stays erased: the record scans of the update loader and the SPL (a 4 KiB
|
||||
* boundary - 256) never find anything there.
|
||||
*
|
||||
* A new bank (the editor's FM6B_BEGIN / WRITE / END, editor_fm6.c) is written into the autosave's older copy first
|
||||
* (0xE5000 or 0xE6000: the one st_save writes next, never the copy the power-on restore takes), its commit record (slot
|
||||
* 1, the next seq) last and only once the voices match the editor's CRC; then it is copied to 0xE7000 (erase, payload,
|
||||
* commit record, read back). A power cut anywhere leaves the old bank (nothing committed) or the new one (committed:
|
||||
* fvb_boot finishes the copy at the next power-on, before any autosave can take that sector): never half of one. A
|
||||
* wrong CRC commits nothing. An autosave between two requests (it waits 10 s after the last, project.c) takes the
|
||||
* sector: WRITE and END find its commit record there and answer 5 (start again). Included by upreset.c. */
|
||||
#define FVB_HOME 0xE7000u
|
||||
#define FVB_INFO 224u /* the bank's header; the voices from FVB_VOICES */
|
||||
#define FVB_VOICES 256u
|
||||
#define FVB_MAGIC 0x56364D46u /* "FM6V" */
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint16_t ver, n; /* 1, FM6_NBANK */
|
||||
uint32_t used; /* bit k: voice k (B k+1) is there */
|
||||
char name[12]; /* the bank's name: 10 ASCII bytes, space-padded, then 0 0 */
|
||||
uint32_t rsv[2];
|
||||
} fvb_info_t;
|
||||
_Static_assert(sizeof(fvb_info_t) == FVB_VOICES - FVB_INFO, "FM6 voice bank header");
|
||||
#define FVB_LEN (FVB_VOICES - FVB_INFO + FM6_NBANK * UPF_PK) /* the record's payload: 3616 bytes */
|
||||
_Static_assert(FVB_INFO + FVB_LEN == 0xF00u, "the sector's tail (0xF00..) stays erased");
|
||||
|
||||
static struct {
|
||||
uint32_t used; /* the voices written since FM6B_BEGIN */
|
||||
uint8_t on, copy; /* a transfer is open; its sector: the autosave's copy A (0) / B (1) */
|
||||
} fvb_tx __attribute__((section(".pool"))); /* (zeroed at boot) */
|
||||
|
||||
/* the bank was replaced: a track on a bank slot keeps the voice it loaded, as its own patch (SLOT OWN) */
|
||||
static void fm6_bank_changed(void)
|
||||
{
|
||||
uint32_t tr;
|
||||
for (tr = 0; tr < NTRK; tr++)
|
||||
if (trk[tr].eng_req == ENGI_FM6 && fm6_bank_slot(fm6_slot[tr]) >= 0)
|
||||
fm6_adopt(tr);
|
||||
}
|
||||
|
||||
#if FELUCCA_FLASH
|
||||
_Static_assert(FVB_LEN <= ST_PAYLOAD_MAX, "the payload fits st_buf");
|
||||
static uint32_t fvb_stage(void) { return st_sector(OBJ_AUTOSAVE, fvb_tx.copy); }
|
||||
|
||||
/* n bytes from RAM to flash at off, a page (256 bytes) at a time */
|
||||
static int fvb_prog(uint32_t off, const void *src, uint32_t n)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
while (n) {
|
||||
uint32_t k = 256u - (off & 255u);
|
||||
if (k > n)
|
||||
k = n;
|
||||
if (st_prog(off, s, k))
|
||||
return -1;
|
||||
off += k;
|
||||
s += k;
|
||||
n -= k;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* a whole bank at base: its commit record (of slot `slot`: 0 at FVB_HOME, 1 staged) and payload valid; 0, with *h
|
||||
* its commit record and st_buf its payload */
|
||||
static int fvb_valid(uint32_t base, uint32_t slot, st_hdr_t *h)
|
||||
{
|
||||
const fvb_info_t *in = (const fvb_info_t *)st_buf;
|
||||
if (st_read(base, h, sizeof *h) || h->magic != ST_MAGIC || h->type != OBJ_FM6VB || h->slot != slot ||
|
||||
h->len != FVB_LEN || h->hcrc != st_crc32(h, sizeof *h - 4u) || st_read(base + FVB_INFO, st_buf, FVB_LEN) ||
|
||||
st_crc32(st_buf, FVB_LEN) != h->crc)
|
||||
return -1;
|
||||
return in->magic == FVB_MAGIC && in->ver == 1u && in->n == FM6_NBANK ? 0 : -1;
|
||||
}
|
||||
|
||||
/* the commit record of the payload in st_buf, at base (written last) */
|
||||
static int fvb_commit(uint32_t base, uint32_t slot, uint32_t seq)
|
||||
{
|
||||
st_hdr_t h;
|
||||
h.magic = ST_MAGIC;
|
||||
h.type = OBJ_FM6VB;
|
||||
h.slot = (uint16_t)slot;
|
||||
h.seq = seq;
|
||||
h.len = FVB_LEN;
|
||||
h.crc = st_crc32(st_buf, FVB_LEN);
|
||||
h.rsv[0] = h.rsv[1] = 0xFFFFFFFFu;
|
||||
h.hcrc = st_crc32(&h, sizeof h - 4u);
|
||||
return st_prog(base, &h, sizeof h);
|
||||
}
|
||||
|
||||
/* bank voice k -> pk (128 bytes): 0, 1 = none there (eng_fm6.c fm6_bank_read) */
|
||||
static int fvb_read(uint32_t k, uint8_t *pk)
|
||||
{
|
||||
uint8_t d[UPF_PK];
|
||||
if (k >= FM6_NBANK || !((fm6_bank_used >> k) & 1u) || st_read(FVB_HOME + FVB_VOICES + k * UPF_PK, d, UPF_PK))
|
||||
return 1;
|
||||
upf_pk_get(d, pk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* up_boot, and after a bank was staged: a staged bank newer than 0xE7000's is copied there; then the voices of the
|
||||
* bank at 0xE7000 (none without one) */
|
||||
static void fvb_boot(void)
|
||||
{
|
||||
st_hdr_t h, s, t;
|
||||
uint32_t c, best = 2u;
|
||||
int home;
|
||||
fm6_bank_used = 0;
|
||||
fm6_bank_read = fvb_read;
|
||||
if (!flash_ok)
|
||||
return;
|
||||
home = fvb_valid(FVB_HOME, 0, &h);
|
||||
for (c = 0; c < 2u; c++)
|
||||
if (!fvb_valid(st_sector(OBJ_AUTOSAVE, c), 1, &t) && (home || (t.seq != h.seq && t.seq - h.seq < 0x80000000u)) &&
|
||||
(best > 1u || (t.seq != s.seq && t.seq - s.seq < 0x80000000u))) {
|
||||
s = t;
|
||||
best = c;
|
||||
}
|
||||
if (best < 2u && !fvb_valid(st_sector(OBJ_AUTOSAVE, best), 1, &s) && !st_erase(FVB_HOME) &&
|
||||
!fvb_prog(FVB_HOME + FVB_INFO, st_buf, FVB_LEN))
|
||||
fvb_commit(FVB_HOME, 0, s.seq);
|
||||
if (!fvb_valid(FVB_HOME, 0, &h))
|
||||
fm6_bank_used = ((const fvb_info_t *)st_buf)->used;
|
||||
}
|
||||
|
||||
/* the transfer's sector holds only what it wrote: no autosave took it since FM6B_BEGIN (its commit record still
|
||||
* erased); else the transfer ends */
|
||||
static int fvb_tx_ok(void)
|
||||
{
|
||||
uint8_t b[32];
|
||||
uint32_t i, x = 0xFFu;
|
||||
if (!fvb_tx.on || st_read(fvb_stage(), b, sizeof b))
|
||||
return 0;
|
||||
for (i = 0; i < sizeof b; i++)
|
||||
x &= b[i];
|
||||
if (x != 0xFFu)
|
||||
fvb_tx.on = 0;
|
||||
return fvb_tx.on;
|
||||
}
|
||||
|
||||
/* FM6B_BEGIN: the sector erased, no voice yet. rc 0, 4 flash */
|
||||
static uint32_t fvb_begin(void)
|
||||
{
|
||||
st_hdr_t h;
|
||||
fvb_tx.on = 0;
|
||||
if (!flash_ok)
|
||||
return 4;
|
||||
fvb_tx.copy = st_current(OBJ_AUTOSAVE, &h) == 0 ? 1u : 0u; /* the copy st_save writes next */
|
||||
if (st_erase(fvb_stage()))
|
||||
return 4;
|
||||
fvb_tx.used = 0;
|
||||
fvb_tx.on = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FM6B_WRITE: voice k = pk (128 bytes), once each. rc 0, 1 index, 4 flash, 5 no transfer */
|
||||
static uint32_t fvb_write(uint32_t k, const uint8_t *pk)
|
||||
{
|
||||
uint8_t d[UPF_PK];
|
||||
if (!fvb_tx_ok())
|
||||
return 5;
|
||||
if (k >= FM6_NBANK || ((fvb_tx.used >> k) & 1u))
|
||||
return 1;
|
||||
upf_pk_put(pk, d);
|
||||
if (fvb_prog(fvb_stage() + FVB_VOICES + k * UPF_PK, d, UPF_PK)) {
|
||||
fvb_tx.on = 0;
|
||||
return 4;
|
||||
}
|
||||
fvb_tx.used |= 1u << k;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FM6B_END: name (10 bytes), crc: the CRC-32 of the written voices' records in index order. Staged, committed,
|
||||
* copied to 0xE7000. rc 0, 2 the CRC (nothing changed), 4 flash, 5 no transfer */
|
||||
static uint32_t fvb_end(const uint8_t *name, uint32_t crc)
|
||||
{
|
||||
fvb_info_t *in = (fvb_info_t *)st_buf;
|
||||
st_hdr_t h;
|
||||
uint32_t k, c = 0xFFFFFFFFu, seq, base = fvb_stage();
|
||||
if (!fvb_tx_ok())
|
||||
return 5;
|
||||
fvb_tx.on = 0;
|
||||
for (k = 0; k < FM6_NBANK; k++)
|
||||
if ((fvb_tx.used >> k) & 1u) {
|
||||
uint8_t d[UPF_PK], pk[FM6_PACKED];
|
||||
if (st_read(base + FVB_VOICES + k * UPF_PK, d, UPF_PK))
|
||||
return 4;
|
||||
upf_pk_get(d, pk);
|
||||
c = st_crc32_add(c, pk, FM6_PACKED);
|
||||
}
|
||||
if (~c != crc)
|
||||
return 2;
|
||||
seq = fvb_valid(FVB_HOME, 0, &h) ? 0u : h.seq; /* after the newest bank anywhere */
|
||||
for (k = 0; k < 2u; k++)
|
||||
if (!fvb_valid(st_sector(OBJ_AUTOSAVE, k), 1, &h) && h.seq - seq < 0x80000000u)
|
||||
seq = h.seq;
|
||||
seq++;
|
||||
if (st_read(base + FVB_INFO, st_buf, FVB_LEN)) /* the voices as written, the header still erased */
|
||||
return 4;
|
||||
memset(in, 0, sizeof *in);
|
||||
in->magic = FVB_MAGIC;
|
||||
in->ver = 1;
|
||||
in->n = FM6_NBANK;
|
||||
in->used = fvb_tx.used;
|
||||
for (k = 0; k < 10u; k++)
|
||||
in->name[k] = (char)(name[k] >= 32u && name[k] <= 126u ? name[k] : ' ');
|
||||
if (fvb_prog(base + FVB_INFO, in, sizeof *in) || fvb_commit(base, 1, seq) || fvb_valid(base, 1, &h))
|
||||
return 4;
|
||||
fvb_boot(); /* the copy to 0xE7000, the voices */
|
||||
fm6_bank_changed();
|
||||
return fvb_valid(FVB_HOME, 0, &h) || h.seq != seq ? 4u : 0u;
|
||||
}
|
||||
|
||||
/* FM6B_LIST: the bank at 0xE7000 -> its header (0 = none) */
|
||||
static const fvb_info_t *fvb_info(void)
|
||||
{
|
||||
st_hdr_t h;
|
||||
return flash_ok && !fvb_valid(FVB_HOME, 0, &h) ? (const fvb_info_t *)st_buf : 0;
|
||||
}
|
||||
#else
|
||||
static void fvb_boot(void) {}
|
||||
static uint32_t fvb_begin(void) { return 4; }
|
||||
static uint32_t fvb_write(uint32_t k, const uint8_t *pk) { (void)k; (void)pk; return 5; }
|
||||
static uint32_t fvb_end(const uint8_t *name, uint32_t crc) { (void)name; (void)crc; return 5; }
|
||||
static const fvb_info_t *fvb_info(void) { return 0; }
|
||||
#endif
|
||||
+18
-7
@@ -220,19 +220,30 @@ static int32_t enum_orig(const param_desc_t *d, int32_t v)
|
||||
return v;
|
||||
}
|
||||
|
||||
/* a stored value as the parameter takes it (projects, user presets, motion): inside d's range */
|
||||
/* a stored value as the parameter takes it (projects, user presets, motion): inside d's range. FM6's SLOT is never
|
||||
* stored as a bank slot (JIANT 0.6.11, from Felucca 1.4.1): 9..40 (B1..B32) is 8, OWN, and the patch comes with what is
|
||||
* loaded */
|
||||
static int32_t param_fit(const param_desc_t *d, int32_t v)
|
||||
{
|
||||
return clamp(v, d->min, d->max);
|
||||
v = clamp(v, d->min, d->max);
|
||||
return d->names == N_FM6_PATCH && v > (int32_t)FM6_OWN ? (int32_t)FM6_OWN : v;
|
||||
}
|
||||
|
||||
/* a knob moved an F_ENUM from `from` to v: past any alias in that direction (back to `from` at the end) */
|
||||
/* v is a value a knob passes over: an alias, or one of FM6's bank slots without a voice */
|
||||
static int enum_skip(const param_desc_t *d, int32_t v)
|
||||
{
|
||||
return enum_orig(d, v) != v || (d->names == N_FM6_PATCH && !fm6_slot_ok(v));
|
||||
}
|
||||
/* a knob moved an F_ENUM from `from` to v: past any value it skips in that direction; with none left to the end, the
|
||||
* last one it does not skip on the way from `from` (else `from`) */
|
||||
static int32_t enum_step(const param_desc_t *d, int32_t from, int32_t v)
|
||||
{
|
||||
int32_t dir = v > from ? 1 : -1;
|
||||
while (v != from && enum_orig(d, v) != v)
|
||||
v = v + dir > d->max || v + dir < d->min ? from : v + dir;
|
||||
return v;
|
||||
int32_t dir = v > from ? 1 : -1, w = v;
|
||||
while (w != from && enum_skip(d, w))
|
||||
w = w + dir > d->max || w + dir < d->min ? from : w + dir;
|
||||
while (w == from && v != from && enum_skip(d, v))
|
||||
v -= dir;
|
||||
return w == from ? v : w;
|
||||
}
|
||||
|
||||
/* #48: the note divisions in the order of their length, longest first (triplets between their neighbours), on the
|
||||
|
||||
+13
-5
@@ -17,7 +17,7 @@
|
||||
#define ST_PAYLOAD_OFF 256u
|
||||
#define ST_PAYLOAD_MAX (ST_SECTOR - ST_PAYLOAD_OFF)
|
||||
|
||||
/* flash map (FL_DATA 0x97000..0xDFFFF, FL_GLOB 0xFC000.., FL_AUTO 0xE5000..0xE6FFF): settings 0xFC000, projects
|
||||
/* flash map (FL_DATA 0x97000..0xDFFFF, FL_GLOB 0xFC000.., FL_AUTO 0xE5000..0xE6FFF, FL_VBANK 0xE7000): settings 0xFC000, projects
|
||||
* 0x97000..0x9EFFF, 0xA0000..0xDBFFF free (Felucca's user sample slots: JIANT's songs, docs/TONIC-SONG-PLAN.md 4d),
|
||||
* user preset banks 0xDC000..0xDFFFF (upreset.c),
|
||||
* the user presets' FM6 patches (up_fm6.c, since 1.0.3): copy A 0x9F000, copy B 0xFE000; the autosave (project.c,
|
||||
@@ -26,12 +26,19 @@
|
||||
* Those two sectors held the FM6 patch bank of 1.0..1.0.2 (OBJ_FM6BANK, retired): both objects use the same pair,
|
||||
* told apart by the commit record's type. The bank is only read, once, to move its patches into the user presets
|
||||
* (up_fm6.c upf_boot); the first write of the new object goes to the sector that does not hold the bank's newest
|
||||
* copy (st_save_to), so a power cut never loses both. */
|
||||
* copy (st_save_to), so a power cut never loses both.
|
||||
* The FM6 voice bank (JIANT 0.6.11, from Felucca 1.4.1, fm6_vbank.c): 0xE7000, the sector above the autosave, with a
|
||||
* commit record of the same kind (type OBJ_FM6VB, not an st_load object); a new bank is first staged in the
|
||||
* autosave's older copy (fm6_vbank.c). */
|
||||
enum { OBJ_SETTINGS, OBJ_PROJECT0, OBJ_UPRESET0 = OBJ_PROJECT0 + 4, OBJ_FM6BANK = OBJ_UPRESET0 + 2, OBJ_UPFM6,
|
||||
OBJ_AUTOSAVE, OBJ_SONGIDX, OBJ_SONG1, OBJ_COUNT = OBJ_SONG1 + 7 * 4 };
|
||||
/* JIANT's songs (song_chain.c): song 1's four sections are the four project slots (OBJ_PROJECT0..3, 0x97000..), songs
|
||||
* 2..8 four objects each (OBJ_SONG1 + (song - 1) * 4 + section) at 0xA0000..0xD7FFF, the song index (the songs' rows,
|
||||
* the current song) at 0xD8000 / 0xD9000; 0xDA000..0xDBFFF free */
|
||||
#define OBJ_FM6VB 64u /* the voice bank's commit records (fm6_vbank.c; >= OBJ_COUNT, 39 with
|
||||
* the songs: st_load never takes one, no object takes its sector.
|
||||
* Felucca's 32 is a song object here) */
|
||||
_Static_assert(OBJ_FM6VB >= OBJ_COUNT, "the voice bank's record type is no object's");
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
@@ -45,20 +52,21 @@ static int st_read(uint32_t off, void *dst, uint32_t n);
|
||||
static int st_erase(uint32_t off);
|
||||
static int st_prog(uint32_t off, const void *src, uint32_t n);
|
||||
|
||||
static uint32_t st_crc32(const void *p, uint32_t n) /* zlib CRC-32, 4 bits per step */
|
||||
static uint32_t st_crc32_add(uint32_t c, const void *p, uint32_t n) /* zlib CRC-32, 4 bits per step; running:
|
||||
* from 0xFFFFFFFF, the CRC is ~c */
|
||||
{
|
||||
static const uint32_t T[16] = {
|
||||
0x00000000u, 0x1DB71064u, 0x3B6E20C8u, 0x26D930ACu, 0x76DC4190u, 0x6B6B51F4u, 0x4DB26158u, 0x5005713Cu,
|
||||
0xEDB88320u, 0xF00F9344u, 0xD6D6A3E8u, 0xCB61B38Cu, 0x9B64C2B0u, 0x86D3D2D4u, 0xA00AE278u, 0xBDBDF21Cu};
|
||||
const uint8_t *b = p;
|
||||
uint32_t c = 0xFFFFFFFFu;
|
||||
while (n--) {
|
||||
c ^= *b++;
|
||||
c = (c >> 4) ^ T[c & 15u];
|
||||
c = (c >> 4) ^ T[c & 15u];
|
||||
}
|
||||
return ~c;
|
||||
return c;
|
||||
}
|
||||
static uint32_t st_crc32(const void *p, uint32_t n) { return ~st_crc32_add(0xFFFFFFFFu, p, n); }
|
||||
|
||||
static uint32_t st_sector(uint32_t obj, uint32_t copy) /* flash offset of copy A (0) / B (1) */
|
||||
{
|
||||
|
||||
@@ -654,6 +654,13 @@ static void graph_fm6(const track_t *t, uint16_t c, uint32_t sel) /* sel < 6:
|
||||
char fq[16] = {'O', 'P', (char)('1' + sel), ' ', 0};
|
||||
fop_freq(pt + (5u - sel) * FP_OP, fq + 4);
|
||||
cv_text_r(228, 4 - GOY, &AF_S, fq, T_TEXT, T_SURF);
|
||||
} else if (fm6_bank_slot(fm6_slot[(t - trk) % NTRK]) >= 0) { /* (0.6.11) SLOT B1..B32: the bank voice's name */
|
||||
char nm[11];
|
||||
for (k = 0; k < 10u; k++)
|
||||
nm[k] = (char)pt[FP_NAME + k];
|
||||
for (nm[10] = 0; k && nm[k - 1] == ' '; k--)
|
||||
nm[k - 1] = 0;
|
||||
cv_text_r(228, 4 - GOY, &AF_S, nm, T_TEXT, T_SURF);
|
||||
}
|
||||
FM6_CHART_HOOK(FMH_END, alg, 0);
|
||||
}
|
||||
|
||||
+26
-18
@@ -85,15 +85,10 @@ static uint32_t upf_tag(const up_rec_t *r) /* FNV-1a of the record without
|
||||
|
||||
static int upf_fm6(uint32_t k) { return up_used(k) && up_rec(k)->engine == ENGI_FM6; }
|
||||
|
||||
/* slot k's patch -> pk (128 bytes), 0 = it has one */
|
||||
static int upf_get(uint32_t k, uint8_t *pk)
|
||||
/* a 128-byte packed record's 7-bit bytes, 8 to 7 bytes (UPF_PK) and back (the voice bank too, fm6_vbank.c) */
|
||||
static void upf_pk_get(const uint8_t *d, uint8_t *pk)
|
||||
{
|
||||
uint32_t i, acc = 0, n = 0, o = 0;
|
||||
const uint8_t *d;
|
||||
if (k >= UP_SLOTS || !upf_valid(&upf) || !((upf.used >> k) & 1u) || !upf_fm6(k) ||
|
||||
upf.e[k].tag != upf_tag(up_rec(k)))
|
||||
return 1;
|
||||
d = upf.e[k].pk;
|
||||
for (i = 0; i < FM6_PACKED; i++) {
|
||||
while (n < 7u) {
|
||||
acc |= (uint32_t)d[o++] << n;
|
||||
@@ -103,6 +98,29 @@ static int upf_get(uint32_t k, uint8_t *pk)
|
||||
acc >>= 7;
|
||||
n -= 7u;
|
||||
}
|
||||
}
|
||||
static void upf_pk_put(const uint8_t *pk, uint8_t *d)
|
||||
{
|
||||
uint32_t i, acc = 0, n = 0, o = 0;
|
||||
memset(d, 0, UPF_PK);
|
||||
for (i = 0; i < FM6_PACKED; i++) {
|
||||
acc |= (uint32_t)(pk[i] & 127u) << n;
|
||||
n += 7u;
|
||||
while (n >= 8u) {
|
||||
d[o++] = (uint8_t)acc;
|
||||
acc >>= 8;
|
||||
n -= 8u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* slot k's patch -> pk (128 bytes), 0 = it has one */
|
||||
static int upf_get(uint32_t k, uint8_t *pk)
|
||||
{
|
||||
if (k >= UP_SLOTS || !upf_valid(&upf) || !((upf.used >> k) & 1u) || !upf_fm6(k) ||
|
||||
upf.e[k].tag != upf_tag(up_rec(k)))
|
||||
return 1;
|
||||
upf_pk_get(upf.e[k].pk, pk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -110,23 +128,13 @@ static int upf_get(uint32_t k, uint8_t *pk)
|
||||
static void upf_set(uint32_t k, const uint8_t *pk)
|
||||
{
|
||||
uint8_t v[FP_SIZE + 1u], c[FM6_PACKED];
|
||||
uint32_t i, acc = 0, n = 0, o = 0;
|
||||
if (k >= UP_SLOTS)
|
||||
return;
|
||||
if (!upf_valid(&upf))
|
||||
upf_empty();
|
||||
fm6_unpack(pk, v);
|
||||
fm6_pack(v, c);
|
||||
memset(upf.e[k].pk, 0, UPF_PK);
|
||||
for (i = 0; i < FM6_PACKED; i++) {
|
||||
acc |= (uint32_t)(c[i] & 127u) << n;
|
||||
n += 7u;
|
||||
while (n >= 8u) {
|
||||
upf.e[k].pk[o++] = (uint8_t)acc;
|
||||
acc >>= 8;
|
||||
n -= 8u;
|
||||
}
|
||||
}
|
||||
upf_pk_put(c, upf.e[k].pk);
|
||||
upf.e[k].tag = upf_tag(up_rec(k));
|
||||
upf.used |= 1u << k;
|
||||
}
|
||||
|
||||
@@ -255,6 +255,7 @@ static void up_values(const up_rec_t *r, int16_t *v) /* mapped and clamped for
|
||||
}
|
||||
|
||||
#include "up_fm6.c" /* the FM6 user presets' patches: the same kind of store */
|
||||
#include "fm6_vbank.c" /* FM6's voice bank (SLOT B1..B32; JIANT 0.6.11, from Felucca 1.4.1) */
|
||||
|
||||
static void up_boot(void) /* persist_boot: the banks from flash */
|
||||
{
|
||||
@@ -264,6 +265,7 @@ static void up_boot(void) /* persist_boot: the banks from f
|
||||
up_bank_check(b, flash_ok ? st_load(OBJ_UPRESET0 + b, &up_bank[b], sizeof up_bank[b]) : -1);
|
||||
#endif
|
||||
upf_boot(); /* (after the banks: it may move the retired FM6 bank's patches) */
|
||||
fvb_boot(); /* FM6's voice bank: a staged one finished, its voices */
|
||||
#ifdef FELUCCA_FAVORITES
|
||||
for (uint32_t k = 0; k < UP_SLOTS; k++)
|
||||
if (!up_used(k)) favorite_set(NENGINES, k, 0);
|
||||
|
||||
+13
-12
@@ -148,18 +148,19 @@ static int preferences(void)
|
||||
uint32_t n = request(ED_INFO, a, 0);
|
||||
bad += check("INFO explicitly tags display capabilities after SONG without changing command 33",
|
||||
ED_SONG == 33 && ED_UI_STATE == 34 && ED_FAV_SET == 38 &&
|
||||
host_wire[n - 31] == CHAIN_ROWS && host_wire[n - 30] == 0x55 &&
|
||||
host_wire[n - 29] == 1 && host_wire[n - 28] == 9 &&
|
||||
host_wire[n - 27] == 0x4d && host_wire[n - 26] == 1 &&
|
||||
host_wire[n - 25] == MOTION_MAX && host_wire[n - 24] == 1 &&
|
||||
host_wire[n - 23] == 0x42 && host_wire[n - 22] == 1 && host_wire[n - 21] == 3 &&
|
||||
host_wire[n - 20] == 0x46 && host_wire[n - 19] == 1 && host_wire[n - 18] == FM6_NFACTORY &&
|
||||
host_wire[n - 17] == 0 && /* (no bank since 1.0.3) */
|
||||
host_wire[n - 16] == 0x53 && host_wire[n - 15] == 1 && host_wire[n - 14] == 3 &&
|
||||
host_wire[n - 13] == 0x50 && host_wire[n - 12] == 1 && host_wire[n - 11] == 3 && /* FM6 v2: no bank, preset patches */
|
||||
host_wire[n - 10] == 0x4E && host_wire[n - 9] == 1 && host_wire[n - 8] == 18 && /* MENU settings: 18 items (1.2) */
|
||||
host_wire[n - 7] == 0x52 && host_wire[n - 6] == 1 && host_wire[n - 5] == 4 && /* RATCH */
|
||||
host_wire[n - 4] == 0x4C && host_wire[n - 3] == 1 && host_wire[n - 2] == 1); /* 1.1 parameter locks */
|
||||
host_wire[n - 34] == CHAIN_ROWS && host_wire[n - 33] == 0x55 &&
|
||||
host_wire[n - 32] == 1 && host_wire[n - 31] == 9 &&
|
||||
host_wire[n - 30] == 0x4d && host_wire[n - 29] == 1 &&
|
||||
host_wire[n - 28] == MOTION_MAX && host_wire[n - 27] == 1 &&
|
||||
host_wire[n - 26] == 0x42 && host_wire[n - 25] == 1 && host_wire[n - 24] == 3 &&
|
||||
host_wire[n - 23] == 0x46 && host_wire[n - 22] == 1 && host_wire[n - 21] == FM6_NFACTORY &&
|
||||
host_wire[n - 20] == 0 && /* (no bank since 1.0.3) */
|
||||
host_wire[n - 19] == 0x53 && host_wire[n - 18] == 1 && host_wire[n - 17] == 3 &&
|
||||
host_wire[n - 16] == 0x50 && host_wire[n - 15] == 1 && host_wire[n - 14] == 3 && /* FM6 v2: no bank, preset patches */
|
||||
host_wire[n - 13] == 0x4E && host_wire[n - 12] == 1 && host_wire[n - 11] == 18 && /* MENU settings: 18 items (1.2) */
|
||||
host_wire[n - 10] == 0x52 && host_wire[n - 9] == 1 && host_wire[n - 8] == 4 && /* RATCH */
|
||||
host_wire[n - 7] == 0x4C && host_wire[n - 6] == 1 && host_wire[n - 5] == 1 && /* 1.1 parameter locks */
|
||||
host_wire[n - 4] == 0x56 && host_wire[n - 3] == 1 && host_wire[n - 2] == 32); /* (0.6.11) FM6 voice bank */
|
||||
request(ED_UI_SET, a, 2);
|
||||
bad += check("UI_SET updates the actual palette and reports RAM-only saving",
|
||||
host_wire[5] == 3 && settings.palette == 7 && T_BG == UI_PALETTES[7].bg);
|
||||
|
||||
+4
-2
@@ -469,8 +469,10 @@ static void macros(void)
|
||||
trk[0].p[P_E7] = FM6_OWN;
|
||||
fm6_poll();
|
||||
check("SLOT back to OWN: the own patch again", fm6_slot[0] == FM6_OWN && !memcmp(fm6_patch[0], own, FP_SIZE));
|
||||
check("SLOT: F1..F8 and OWN, nothing past it", ENG_FM6.edit[7].max == FM6_OWN && FM6_OWN == FM6_NFACTORY &&
|
||||
!strcmp(ENG_FM6.edit[7].names[FM6_OWN], "OWN") && !ENG_FM6.edit[7].names[FM6_OWN + 1]);
|
||||
check("SLOT: F1..F8, OWN, then B1..B32 (0.6.11, the voice bank), nothing past it",
|
||||
ENG_FM6.edit[7].max == FM6_OWN + FM6_NBANK && FM6_OWN == FM6_NFACTORY && FM6_NBANK == 32u &&
|
||||
!strcmp(ENG_FM6.edit[7].names[FM6_OWN], "OWN") && !strcmp(ENG_FM6.edit[7].names[FM6_OWN + 1], "B1") &&
|
||||
!strcmp(ENG_FM6.edit[7].names[FM6_OWN + FM6_NBANK], "B32") && !ENG_FM6.edit[7].names[FM6_OWN + FM6_NBANK + 1]);
|
||||
trk[0].p[P_E7] = FM6_OWN;
|
||||
fm6_set_patch(0, own);
|
||||
trk[0].p[P_E7] = 2; /* a load that says F3 with F3 unchanged: F3; edited: OWN */
|
||||
|
||||
@@ -0,0 +1,575 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* FM6's voice bank (1.4.1, Discussion #168; src/fm6_vbank.c, the editor's FM6B_* in src/editor_fm6.c) against
|
||||
* simulated NOR flash: a bank written whole and read back, its sectors (0xE7000, staged in the autosave's older copy,
|
||||
* nothing else touched, the tail erased), a power cut after any programmed byte or during any erase (the old bank or
|
||||
* the new one, never half; the autosave kept), a wrong CRC and an autosave between requests changing nothing, SLOT
|
||||
* B1..B32 loading the exact records, bank slots without a voice skipped by the knob and refused elsewhere, a new
|
||||
* bank leaving a track's voice its own, projects and user presets keeping a bank voice whatever the bank holds later,
|
||||
* and the SLOT values stored before 1.4.1 (projects, user presets, motion) loading exactly as before. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
|
||||
static int32_t fm1_enc_take(uint32_t e) { (void)e; return 0; }
|
||||
static void fm1_irq_off(void) {}
|
||||
static void fm1_irq_on(void) {}
|
||||
static void lcd_sync(void) {}
|
||||
static void lcd_power(uint32_t s) { (void)s; }
|
||||
static void lcd_wake_now(void) {}
|
||||
static void lcd_blit(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const uint16_t *p)
|
||||
{ (void)x; (void)y; (void)w; (void)h; (void)p; }
|
||||
#define FELUCCA_FLASH 1
|
||||
#include "../firmware/src/gfx.c"
|
||||
#include "../firmware/src/panel.c"
|
||||
#include "../firmware/src/ui.c"
|
||||
#include "../firmware/src/menu_items.c"
|
||||
static void panel_setup(void) {}
|
||||
|
||||
static uint8_t nor[0x100000], flash_ok = 1;
|
||||
static long cut_bytes = -1, cut_erase = -1; /* the power goes after that many programmed bytes / at that erase */
|
||||
static int dead; /* .. and stays off: nothing more is written */
|
||||
static uint32_t progs, erases;
|
||||
static int st_read(uint32_t off, void *dst, uint32_t n) { memcpy(dst, nor + off, n); return 0; }
|
||||
static int st_erase(uint32_t off)
|
||||
{
|
||||
if (dead)
|
||||
return -8;
|
||||
erases++;
|
||||
if (cut_erase >= 0 && cut_erase-- == 0) { /* cut during the erase: half of it done */
|
||||
memset(nor + off, 0xFF, 2048);
|
||||
dead = 1;
|
||||
return -8;
|
||||
}
|
||||
memset(nor + off, 0xFF, 4096);
|
||||
return 0;
|
||||
}
|
||||
static int st_prog(uint32_t off, const void *src, uint32_t n)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint32_t i;
|
||||
if ((off & 0xFFu) + n > 256u) {
|
||||
printf("page wrap at %#x\n", off);
|
||||
exit(1);
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
if (dead || (cut_bytes >= 0 && cut_bytes-- == 0)) {
|
||||
dead = 1;
|
||||
return -9;
|
||||
}
|
||||
nor[off + i] &= s[i];
|
||||
progs++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static uint32_t irq_save(void) { return 0; }
|
||||
static void irq_restore(uint32_t f) { (void)f; }
|
||||
static uint32_t fl_jedec_ram(void) { return 0; }
|
||||
static void fl_plain_window_init(void) {}
|
||||
#define FL_FAR(fn) (fn)
|
||||
#include "../firmware/src/storage.c"
|
||||
#include "../firmware/src/upreset.c"
|
||||
#include "../firmware/src/project.c"
|
||||
|
||||
static uint8_t rep[1024]; /* the editor's reply */
|
||||
static uint32_t rep_n;
|
||||
static void ed_b(uint32_t v) { if (rep_n < sizeof rep) rep[rep_n++] = (uint8_t)(v & 127u); }
|
||||
static void ed_str(const char *s, uint32_t max)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; s && s[i] && i < max; i++)
|
||||
ed_b((uint8_t)s[i]);
|
||||
ed_b(0);
|
||||
}
|
||||
static int ed_flash_stop(void) { return transport_busy(); }
|
||||
#include "../firmware/src/editor_fm6.c"
|
||||
|
||||
static int check(const char *what, int ok)
|
||||
{
|
||||
printf("fm6bank: %-96s %s\n", what, ok ? "ok" : "FAIL");
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
static uint32_t request(uint32_t cmd, const uint8_t *a, uint32_t n)
|
||||
{
|
||||
rep_n = 0;
|
||||
if (!ed_fm6_handle(cmd, a, n))
|
||||
return 0;
|
||||
return rep_n;
|
||||
}
|
||||
|
||||
/* a bank: per voice a packed record (a factory patch renamed "<tag> k"), the used mask */
|
||||
typedef struct {
|
||||
uint8_t v[FM6_NBANK][FM6_PACKED];
|
||||
uint32_t used;
|
||||
char name[11];
|
||||
} bank_t;
|
||||
static void make_bank(bank_t *b, char tag, uint32_t used, const char *name)
|
||||
{
|
||||
uint32_t k;
|
||||
memset(b, 0, sizeof *b);
|
||||
for (k = 0; k < FM6_NBANK; k++) {
|
||||
uint8_t v[FP_SIZE + 1u];
|
||||
char nm[11];
|
||||
fm6_unpack(FM6_FACTORY[(k + (uint32_t)tag) % FM6_NFACTORY], v);
|
||||
snprintf(nm, sizeof nm, "%c VOICE %02u", tag, (unsigned)(k + 1u));
|
||||
memcpy(v + FP_NAME, nm, 10);
|
||||
v[FP_ALG] = (uint8_t)((k * 7u + (uint32_t)tag) % 32u); /* (each voice its own bytes) */
|
||||
v[FP_OP * 2u + FP_OL] = (uint8_t)(50u + k);
|
||||
fm6_pack(v, b->v[k]);
|
||||
}
|
||||
b->used = used;
|
||||
snprintf(b->name, sizeof b->name, "%s", name);
|
||||
}
|
||||
|
||||
/* the editor's transfer: BEGIN, a WRITE per used voice, END with the name and the CRC (crc_xor: a wrong one) -> END's rc
|
||||
* (or the first rc that was not 0) */
|
||||
static uint32_t send_bank(const bank_t *b, uint32_t crc_xor)
|
||||
{
|
||||
uint8_t a[1 + FM6_PACKED], e[15];
|
||||
uint32_t k, c = 0xFFFFFFFFu, rc;
|
||||
request(ED_FM6B_BEGIN, a, 0);
|
||||
if ((rc = rep[0]) != 0)
|
||||
return rc;
|
||||
for (k = 0; k < FM6_NBANK; k++) {
|
||||
if (!((b->used >> k) & 1u))
|
||||
continue;
|
||||
a[0] = (uint8_t)k;
|
||||
memcpy(a + 1, b->v[k], FM6_PACKED);
|
||||
request(ED_FM6B_WRITE, a, sizeof a);
|
||||
if ((rc = rep[1]) != 0)
|
||||
return rc;
|
||||
c = st_crc32_add(c, b->v[k], FM6_PACKED);
|
||||
}
|
||||
c = ~c ^ crc_xor;
|
||||
memset(e, ' ', 10);
|
||||
memcpy(e, b->name, strlen(b->name));
|
||||
for (k = 0; k < 5u; k++)
|
||||
e[10 + k] = (uint8_t)((c >> (7u * k)) & 127u);
|
||||
request(ED_FM6B_END, e, sizeof e);
|
||||
return rep[0];
|
||||
}
|
||||
|
||||
/* the bank the device holds now equals b (its voices, the used mask, the name: LIST) */
|
||||
static int bank_is(const bank_t *b)
|
||||
{
|
||||
uint8_t pk[FM6_PACKED];
|
||||
const fvb_info_t *in = fvb_info();
|
||||
char nm[11] = {0};
|
||||
uint32_t k;
|
||||
if (!in || fm6_bank_used != b->used)
|
||||
return 0;
|
||||
memcpy(nm, in->name, 10);
|
||||
for (k = 10; k && nm[k - 1] == ' '; k--)
|
||||
nm[k - 1] = 0;
|
||||
if (strcmp(nm, b->name))
|
||||
return 0;
|
||||
for (k = 0; k < FM6_NBANK; k++) {
|
||||
int has = !fvb_read(k, pk);
|
||||
if (has != (int)((b->used >> k) & 1u) || (has && memcmp(pk, b->v[k], FM6_PACKED)))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void reset(void)
|
||||
{
|
||||
uint32_t k;
|
||||
memset(nor, 0xFF, sizeof nor);
|
||||
memset(&song, 0, sizeof song);
|
||||
memset(trk, 0, sizeof trk);
|
||||
memset(&chain, 0, sizeof chain);
|
||||
chain_defaults(&chain_config);
|
||||
memset(proj_slot, 0, sizeof proj_slot);
|
||||
memset(up_bank, 0, sizeof up_bank);
|
||||
memset(&upf, 0, sizeof upf);
|
||||
memset(&ui, 0, sizeof ui);
|
||||
memset(&motion, 0, sizeof motion);
|
||||
memset(&fvb_tx, 0, sizeof fvb_tx);
|
||||
host_tracks_init();
|
||||
fm6_init();
|
||||
for (k = 0; k < NTRK; k++) {
|
||||
trk[k].eng_req = trk[k].engine = (uint8_t)ENGI_FM6;
|
||||
for (uint32_t i = 0; i < 8u; i++)
|
||||
trk[k].p[P_E0 + i] = ENG_FM6.edit[i].def;
|
||||
trk[k].p[P_E7] = FM6_OWN;
|
||||
fm6_slot[k] = FM6_OWN;
|
||||
}
|
||||
fm6_own_ok = 0;
|
||||
flash_ok = 1;
|
||||
dead = 0;
|
||||
cut_bytes = cut_erase = -1;
|
||||
fm1_ms = 0;
|
||||
transport_req = 0;
|
||||
up_boot();
|
||||
}
|
||||
|
||||
static void slot_to(uint32_t tr, int32_t s) /* SLOT set (the editor, MIDI, motion), then the main loop */
|
||||
{
|
||||
trk[tr].p[P_E7] = (int16_t)s;
|
||||
fm6_poll();
|
||||
}
|
||||
static int patch_is(uint32_t tr, const uint8_t *pk)
|
||||
{
|
||||
uint8_t got[FM6_PACKED];
|
||||
fm6_pack(fm6_patch[tr], got);
|
||||
return !memcmp(got, pk, FM6_PACKED);
|
||||
}
|
||||
|
||||
static int store_test(void)
|
||||
{
|
||||
int bad = 0, ok;
|
||||
static uint8_t snap[0x100000];
|
||||
static bank_t a, b;
|
||||
uint8_t as_data[600], got[600], arg[1 + FM6_PACKED];
|
||||
uint32_t k;
|
||||
reset();
|
||||
ok = !fm6_bank_used && !fvb_info() && fm6_bank_read;
|
||||
request(ED_FM6B_LIST, arg, 0);
|
||||
bad += check("an empty flash: no bank; LIST: 32 voices, no bank, \"\", every voice empty",
|
||||
ok && rep_n == 2u + 1u + 32u * 2u && rep[0] == 32 && rep[1] == 0 && rep[2] == 0 && rep[3] == 0 && rep[4] == 0);
|
||||
memset(as_data, 'S', sizeof as_data);
|
||||
st_save(OBJ_AUTOSAVE, as_data, sizeof as_data); /* an autosave (copy A) */
|
||||
memcpy(snap, nor, sizeof nor);
|
||||
make_bank(&a, 'A', 0xFFFFFFFFu, "BANK A");
|
||||
ok = send_bank(&a, 0) == 0 && rep[1] == 32 && bank_is(&a);
|
||||
bad += check("a whole bank written over the editor (BEGIN, 32 WRITEs, END): rc 0, 32 voices, read back exactly", ok);
|
||||
ok = 1;
|
||||
for (k = 0; k < 0x100000u; k++)
|
||||
if (nor[k] != snap[k] && !(k >= 0xE6000u && k < 0xE8000u))
|
||||
ok = 0;
|
||||
bad += check(" .. it wrote 0xE7000 (the bank) and 0xE6000 (the autosave's older copy, staged), nothing else", ok &&
|
||||
((st_hdr_t *)(nor + 0xE7000u))->type == OBJ_FM6VB && ((st_hdr_t *)(nor + 0xE6000u))->type == OBJ_FM6VB);
|
||||
ok = 1;
|
||||
for (k = 0xE7F00u; k < 0xE8000u; k++)
|
||||
ok &= nor[k] == 0xFFu;
|
||||
bad += check(" .. the sector's tail (0xE7F00..) erased: no update record can be read there", ok);
|
||||
bad += check(" .. the autosave still loads (its current copy untouched)",
|
||||
st_load(OBJ_AUTOSAVE, got, sizeof got) == (int)sizeof as_data && !memcmp(got, as_data, sizeof as_data));
|
||||
request(ED_FM6B_LIST, arg, 0);
|
||||
ok = rep[0] == 32 && rep[1] == 1 && !memcmp(rep + 2, "BANK A", 7);
|
||||
{
|
||||
uint32_t o = 9, n = 0;
|
||||
for (k = 0; k < 32u && ok; k++) {
|
||||
char nm[16];
|
||||
snprintf(nm, sizeof nm, "A VOICE %02u", (unsigned)(k + 1u));
|
||||
ok &= rep[o] == 1 && !strcmp((const char *)rep + o + 1, nm);
|
||||
o += 2u + (uint32_t)strlen(nm);
|
||||
n++;
|
||||
}
|
||||
ok &= o == rep_n && n == 32u;
|
||||
}
|
||||
bad += check(" .. LIST: the bank's name and each voice's name", ok);
|
||||
memset(&upf, 0, sizeof upf); /* a power-on: the RAM lost, the stores read */
|
||||
fm6_bank_used = 0;
|
||||
up_boot();
|
||||
bad += check(" .. after a power-on: the same bank", bank_is(&a));
|
||||
|
||||
/* a wrong CRC: nothing changes */
|
||||
make_bank(&b, 'B', 0x80000021u, "BANK B");
|
||||
ok = send_bank(&b, 1) == 2 && rep[1] == 32 && bank_is(&a);
|
||||
bad += check("a wrong CRC: rc 2, the bank stays", ok);
|
||||
/* requests out of order */
|
||||
arg[0] = 0;
|
||||
memcpy(arg + 1, b.v[0], FM6_PACKED);
|
||||
request(ED_FM6B_WRITE, arg, sizeof arg);
|
||||
ok = rep[0] == 0 && rep[1] == 5;
|
||||
request(ED_FM6B_BEGIN, arg, 0);
|
||||
request(ED_FM6B_WRITE, arg, sizeof arg);
|
||||
ok &= rep[1] == 0;
|
||||
request(ED_FM6B_WRITE, arg, sizeof arg);
|
||||
ok &= rep[1] == 1;
|
||||
arg[0] = 32;
|
||||
request(ED_FM6B_WRITE, arg, sizeof arg);
|
||||
ok &= rep[1] == 1;
|
||||
request(ED_FM6B_WRITE, arg, 20);
|
||||
ok &= rep[1] == 1;
|
||||
request(ED_FM6B_END, arg, 3);
|
||||
ok &= rep[0] == 1;
|
||||
ok &= bank_is(&a);
|
||||
bad += check("WRITE without BEGIN: rc 5; a voice twice, index 32, a short record, a short END: rc 1; the bank stays", ok);
|
||||
/* an autosave between two requests takes the transfer's sector: the transfer ends, nothing else lost */
|
||||
request(ED_FM6B_BEGIN, arg, 0);
|
||||
ok = rep[0] == 0;
|
||||
memset(as_data, 'T', sizeof as_data);
|
||||
st_save(OBJ_AUTOSAVE, as_data, sizeof as_data); /* (into the copy BEGIN took: the older one) */
|
||||
arg[0] = 1;
|
||||
request(ED_FM6B_WRITE, arg, sizeof arg);
|
||||
ok &= rep[1] == 5;
|
||||
request(ED_FM6B_END, arg, 0); /* (a short END: 1) */
|
||||
ok &= rep[0] == 1;
|
||||
{
|
||||
uint8_t e[15] = {0};
|
||||
request(ED_FM6B_END, e, sizeof e);
|
||||
ok &= rep[0] == 5;
|
||||
}
|
||||
bad += check("an autosave between BEGIN and WRITE: WRITE / END answer 5; the bank and the new autosave kept",
|
||||
ok && bank_is(&a) && st_load(OBJ_AUTOSAVE, got, sizeof got) == (int)sizeof as_data &&
|
||||
!memcmp(got, as_data, sizeof as_data));
|
||||
/* the next bank: staged in the autosave's older copy again (A now), the new autosave (B) kept */
|
||||
ok = send_bank(&b, 0) == 0 && rep[1] == 3 && bank_is(&b) && st_load(OBJ_AUTOSAVE, got, sizeof got) == (int)sizeof as_data &&
|
||||
!memcmp(got, as_data, sizeof as_data) && ((st_hdr_t *)(nor + 0xE5000u))->type == OBJ_FM6VB;
|
||||
bad += check("a second bank (3 voices): staged in the other copy, the autosave kept, read back exactly", ok);
|
||||
/* an empty bank: BEGIN, END (the CRC of nothing) */
|
||||
{
|
||||
bank_t e;
|
||||
make_bank(&e, 'E', 0, "");
|
||||
ok = send_bank(&e, 0) == 0 && rep[1] == 0 && bank_is(&e) && !fm6_bank_used;
|
||||
}
|
||||
bad += check("an empty bank (no WRITE): valid, no voice", ok);
|
||||
/* no flash: refused */
|
||||
flash_ok = 0;
|
||||
request(ED_FM6B_BEGIN, arg, 0);
|
||||
ok = rep[0] == 4;
|
||||
flash_ok = 1;
|
||||
transport_req = 0;
|
||||
bad += check("no flash: BEGIN rc 4", ok);
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* a power cut after every programmed byte, and during every erase, of a bank's transfer: the old bank or the new
|
||||
* one after the next power-on, never anything else; the autosave's current copy always kept */
|
||||
static int cut_test(void)
|
||||
{
|
||||
int bad = 0;
|
||||
static uint8_t pre[0x3000];
|
||||
static bank_t a, b;
|
||||
uint8_t as_data[600], got[600];
|
||||
uint32_t n, old = 0, new = 0, other = 0, total, e, eold = 0, enew = 0;
|
||||
reset();
|
||||
memset(as_data, 'S', sizeof as_data);
|
||||
st_save(OBJ_AUTOSAVE, as_data, sizeof as_data);
|
||||
make_bank(&a, 'A', 0x0000FFFFu, "OLD");
|
||||
make_bank(&b, 'B', 0xFFFFFFFFu, "NEW");
|
||||
send_bank(&a, 0);
|
||||
memcpy(pre, nor + 0xE5000u, sizeof pre); /* (only these three sectors are ever written here) */
|
||||
progs = 0;
|
||||
send_bank(&b, 0);
|
||||
total = progs;
|
||||
for (n = 0; n < total; n++) {
|
||||
memcpy(nor + 0xE5000u, pre, sizeof pre);
|
||||
memset(&fvb_tx, 0, sizeof fvb_tx);
|
||||
fvb_boot();
|
||||
dead = 0;
|
||||
cut_bytes = (long)n;
|
||||
send_bank(&b, 0);
|
||||
dead = 0;
|
||||
cut_bytes = -1;
|
||||
fvb_boot(); /* the next power-on */
|
||||
if (bank_is(&a))
|
||||
old++;
|
||||
else if (bank_is(&b))
|
||||
new++;
|
||||
else
|
||||
other++;
|
||||
if (st_load(OBJ_AUTOSAVE, got, sizeof got) != (int)sizeof as_data || memcmp(got, as_data, sizeof as_data))
|
||||
other++;
|
||||
}
|
||||
for (e = 0; e < 2u; e++) { /* BEGIN's erase, the copy's erase */
|
||||
memcpy(nor + 0xE5000u, pre, sizeof pre);
|
||||
memset(&fvb_tx, 0, sizeof fvb_tx);
|
||||
fvb_boot();
|
||||
dead = 0;
|
||||
cut_erase = (long)e;
|
||||
send_bank(&b, 0);
|
||||
dead = 0;
|
||||
cut_erase = -1;
|
||||
fvb_boot();
|
||||
eold += bank_is(&a);
|
||||
enew += bank_is(&b);
|
||||
if (st_load(OBJ_AUTOSAVE, got, sizeof got) != (int)sizeof as_data || memcmp(got, as_data, sizeof as_data))
|
||||
other++;
|
||||
}
|
||||
printf("fm6bank: %u cut points (bytes): %u the old bank, %u the new one, %u anything else\n", (unsigned)total,
|
||||
(unsigned)old, (unsigned)new, (unsigned)other);
|
||||
bad += check("a power cut after any programmed byte of a transfer: the old bank or the new one, never half",
|
||||
!other && old && new && old + new == total && total > 7000u);
|
||||
bad += check(" .. a cut during BEGIN's erase: the old bank; during the copy's erase: the new one (finished at boot)",
|
||||
eold == 1u && enew == 1u && !other);
|
||||
return bad;
|
||||
}
|
||||
|
||||
static int slot_test(void)
|
||||
{
|
||||
int bad = 0, ok;
|
||||
static bank_t a, b;
|
||||
const param_desc_t *d = &ENG_FM6.edit[7];
|
||||
uint32_t k;
|
||||
reset();
|
||||
ok = param_turn(d, FM6_OWN, 1) == FM6_OWN && param_turn(d, FM6_OWN, -1) == 7 && param_turn(d, 7, 1) == FM6_OWN &&
|
||||
param_turn(d, 7, 5) == FM6_OWN;
|
||||
slot_to(0, FM6_OWN + 3);
|
||||
ok &= trk[0].p[P_E7] == FM6_OWN && fm6_slot[0] == FM6_OWN;
|
||||
bad += check("no bank: the knob stops at OWN (B1..B32 skipped); a B value from elsewhere is refused (SLOT back)", ok);
|
||||
make_bank(&a, 'A', 0xFFFFFFFFu, "FULL");
|
||||
send_bank(&a, 0);
|
||||
ok = 1;
|
||||
for (k = 0; k < FM6_NBANK; k++) {
|
||||
slot_to(1, (int32_t)(FM6_OWN + 1u + k));
|
||||
ok &= fm6_slot[1] == FM6_OWN + 1u + k && trk[1].p[P_E7] == (int16_t)(FM6_OWN + 1u + k) && patch_is(1, a.v[k]);
|
||||
}
|
||||
bad += check("SLOT B1..B32 (9..40): each loads its voice's exact record into the track", ok);
|
||||
{
|
||||
char val[8];
|
||||
const char *u;
|
||||
param_format(d, FM6_OWN + 12, val, &u);
|
||||
ok = !strcmp(val, "B12");
|
||||
param_format(d, FM6_OWN + 32, val, &u);
|
||||
ok &= !strcmp(val, "B32");
|
||||
}
|
||||
bad += check(" .. the card shows B12, B32", ok);
|
||||
/* from OWN the own patch is kept aside, back to OWN brings it back (as for F n) */
|
||||
{
|
||||
uint8_t own[FM6_PACKED];
|
||||
slot_to(2, FM6_OWN);
|
||||
fm6_load_slot(2, 3);
|
||||
fm6_adopt(2);
|
||||
trk[2].p[P_E7] = FM6_OWN;
|
||||
fm6_slot[2] = FM6_OWN;
|
||||
fm6_pack(fm6_patch[2], own);
|
||||
own[110] = 30; /* (an own patch: no factory one) */
|
||||
{
|
||||
uint8_t v[FP_SIZE + 1u];
|
||||
fm6_unpack(own, v);
|
||||
fm6_set_patch(2, v);
|
||||
}
|
||||
slot_to(2, FM6_OWN + 5);
|
||||
ok = patch_is(2, a.v[4]);
|
||||
slot_to(2, FM6_OWN);
|
||||
ok &= patch_is(2, own);
|
||||
}
|
||||
bad += check("OWN -> B5 -> OWN: the own patch kept aside and back", ok);
|
||||
/* a partial bank: the knob passes the empty slots */
|
||||
slot_to(0, FM6_OWN + 5);
|
||||
make_bank(&b, 'B', 1u | 1u << 5 | 1u << 31, "SOME");
|
||||
send_bank(&b, 0);
|
||||
ok = trk[0].p[P_E7] == FM6_OWN && fm6_slot[0] == FM6_OWN && patch_is(0, a.v[4]);
|
||||
bad += check("a new bank: the track on B5 keeps that voice as its own (SLOT OWN)", ok);
|
||||
ok = param_turn(d, FM6_OWN, 1) == FM6_OWN + 1 && param_turn(d, FM6_OWN + 1, 1) == FM6_OWN + 6 &&
|
||||
param_turn(d, FM6_OWN + 6, 1) == FM6_OWN + 32 && param_turn(d, FM6_OWN + 32, 1) == FM6_OWN + 32 &&
|
||||
param_turn(d, FM6_OWN + 32, -1) == FM6_OWN + 6 && param_turn(d, FM6_OWN + 1, -1) == FM6_OWN &&
|
||||
param_turn(d, FM6_OWN, 3) == FM6_OWN + 6 && param_turn(d, FM6_OWN + 6, 9) == FM6_OWN + 32 &&
|
||||
param_turn(d, FM6_OWN + 6, 40) == FM6_OWN + 32;
|
||||
bad += check("bank voices 1, 6, 32 only: the knob goes OWN B1 B6 B32 and back, the empty slots skipped", ok);
|
||||
slot_to(0, FM6_OWN + 6);
|
||||
ok = patch_is(0, b.v[5]);
|
||||
slot_to(0, FM6_OWN + 2); /* B2: none there (the editor's SET, a MIDI CC) */
|
||||
ok &= trk[0].p[P_E7] == FM6_OWN + 6 && fm6_slot[0] == FM6_OWN + 6 && patch_is(0, b.v[5]);
|
||||
bad += check("SET B2 (no voice there) on B6: refused, SLOT back to B6, its voice kept", ok);
|
||||
slot_to(0, 2);
|
||||
ok = trk[0].p[P_E7] == 2 && patch_is(0, FM6_FACTORY[2]);
|
||||
bad += check(" .. F3 from there: the factory patch as always", ok);
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* projects, user presets and motion: a bank voice stays with what was saved; stored SLOT values load as before */
|
||||
static int keep_test(void)
|
||||
{
|
||||
int bad = 0, ok;
|
||||
static bank_t a, b;
|
||||
uint8_t pk[FM6_PACKED];
|
||||
reset();
|
||||
make_bank(&a, 'A', 0xFFFFFFFFu, "FIRST");
|
||||
make_bank(&b, 'B', 0xFFFFFFFFu, "SECOND");
|
||||
send_bank(&a, 0);
|
||||
song.sel = 0;
|
||||
slot_to(0, FM6_OWN + 5); /* track 1 on B5 */
|
||||
slot_to(1, FM6_OWN + 7); /* track 2 on B7 */
|
||||
ok = project_save(0) == 0;
|
||||
song.sel = 1;
|
||||
ok &= up_store(5, "BANK B7") == 0;
|
||||
send_bank(&b, 0); /* the bank replaced */
|
||||
slot_to(0, 1);
|
||||
slot_to(1, 1);
|
||||
memset(proj_slot, 0, sizeof proj_slot); /* (from flash) */
|
||||
project_load(0);
|
||||
ok &= patch_is(0, a.v[4]) && trk[0].p[P_E7] == FM6_OWN && patch_is(1, a.v[6]) && trk[1].p[P_E7] == FM6_OWN;
|
||||
bad += check("a project saved on B5 / B7: loads those voices (SLOT OWN) after the bank was replaced", ok);
|
||||
song.sel = 2;
|
||||
trk[2].p[P_E7] = 0;
|
||||
fm6_poll();
|
||||
up_load(5);
|
||||
ok = patch_is(2, a.v[6]) && trk[2].p[P_E7] == FM6_OWN && !upf_get(5, pk) && !memcmp(pk, a.v[6], FM6_PACKED);
|
||||
bad += check("a user preset stored on B7: loads that voice (SLOT OWN) after the bank was replaced", ok);
|
||||
|
||||
/* SLOT values stored before 1.4.1, with this bank in flash: never read as its voices */
|
||||
{
|
||||
project_t *p = &proj_scratch;
|
||||
int32_t s;
|
||||
uint8_t x[FM6_PACKED];
|
||||
project_capture(p);
|
||||
memcpy(x, FM6_FACTORY[3], FM6_PACKED);
|
||||
x[110] = 17; /* (an own patch) */
|
||||
ok = 1;
|
||||
for (s = FM6_OWN + 1; s <= (int32_t)(FM6_OWN + FM6_NBANK); s++) {
|
||||
p->t[0].p[P_E7] = (int16_t)s; /* (1.0.2's B2..B27: 9..34; any 9..40) */
|
||||
memcpy(p->fm6[0], x, FM6_PACKED);
|
||||
p->sum = proj_sum(p);
|
||||
ok &= !project_restore_runtime(p) && trk[0].p[P_E7] == FM6_OWN && fm6_slot[0] == FM6_OWN && patch_is(0, x);
|
||||
fm6_poll();
|
||||
ok &= patch_is(0, x) && trk[0].p[P_E7] == FM6_OWN;
|
||||
}
|
||||
p->t[0].p[P_E7] = 2;
|
||||
memcpy(p->fm6[0], FM6_FACTORY[2], FM6_PACKED);
|
||||
p->sum = proj_sum(p);
|
||||
ok &= !project_restore_runtime(p) && trk[0].p[P_E7] == 2 && patch_is(0, FM6_FACTORY[2]);
|
||||
bad += check("a project with a stored SLOT 9..40: its own patch, SLOT OWN (never a bank voice); F3 as before", ok);
|
||||
}
|
||||
{ /* a user preset record with a stored SLOT 13 (1.0.2's B5): with its patch, that patch; without, the init voice */
|
||||
up_rec_t *r;
|
||||
song.sel = 3;
|
||||
slot_to(3, FM6_OWN + 9);
|
||||
up_store(6, "OLD B");
|
||||
r = (up_rec_t *)up_rec(6);
|
||||
up_set_value(r, P_E7, FM6_OWN + 5);
|
||||
upf_set(6, a.v[1]); /* (tagged with the record as it is now) */
|
||||
slot_to(3, 0);
|
||||
up_load(6);
|
||||
ok = patch_is(3, a.v[1]) && trk[3].p[P_E7] == FM6_OWN;
|
||||
up_set_value(r, P_E0, 3); /* the record changed: its patch no longer counts */
|
||||
up_load(6);
|
||||
ok &= patch_is(3, FM6_INIT) && trk[3].p[P_E7] == FM6_OWN;
|
||||
bad += check("a user preset with a stored SLOT 13: its patch (OWN); with none, the init voice as before", ok);
|
||||
}
|
||||
{ /* motion records holding SLOT 9..40 (recorded on 1.0.2's B slots): they play OWN, never a bank voice */
|
||||
uint8_t x[FM6_PACKED];
|
||||
track_t *t = &trk[0];
|
||||
int32_t s;
|
||||
memcpy(x, FM6_FACTORY[1], FM6_PACKED);
|
||||
x[110] = 9;
|
||||
{
|
||||
uint8_t v[FP_SIZE + 1u];
|
||||
fm6_unpack(x, v);
|
||||
fm6_set_patch(0, v);
|
||||
fm6_adopt(0);
|
||||
}
|
||||
ok = trk[0].p[P_E7] == FM6_OWN;
|
||||
for (s = FM6_OWN + 1; s <= (int32_t)(FM6_OWN + FM6_NBANK); s++) {
|
||||
memset(&motion, 0, sizeof motion);
|
||||
motion.on = 1;
|
||||
motion.count = 1;
|
||||
motion.event[0].place = 3; /* track 1, step 3 */
|
||||
motion.event[0].param = P_E7;
|
||||
motion.event[0].value = (int8_t)s;
|
||||
motion_base_valid = 0;
|
||||
motion_step(t, 3, &motion, 1);
|
||||
fm6_poll();
|
||||
ok &= trk[0].p[P_E7] == FM6_OWN && patch_is(0, x);
|
||||
}
|
||||
ok &= motion_put(t, 4, P_E7, FM6_OWN + 3, 0) == 0 && motion.event[motion.count - 1u].value == FM6_OWN;
|
||||
bad += check("motion holding SLOT 9..40: plays OWN, the patch kept; a record made on B3 stores OWN", ok);
|
||||
memset(&motion, 0, sizeof motion);
|
||||
}
|
||||
return bad;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int bad = 0;
|
||||
bad += store_test();
|
||||
bad += cut_test();
|
||||
bad += slot_test();
|
||||
bad += keep_test();
|
||||
printf(bad ? "fm6bank: FAILED (%d)\n" : "fm6bank: all ok\n", bad);
|
||||
return bad ? 1 : 0;
|
||||
}
|
||||
+6
-1
@@ -85,6 +85,9 @@
|
||||
# operator envelopes (stages, rates, the voice ending), bit-stable notes, a click-free retrigger, no DC /
|
||||
# clipping over the factory patches, the macros' directions, PTCH, pack / unpack and the SysEx
|
||||
# layouts, the 6-voice cap, the cost per voice; demos in build/fm6_demo/.
|
||||
# FM6 BANK (tests/fm6bank_test.c, JIANT 0.6.11 from Felucca 1.4.1): the voice bank (src/fm6_vbank.c) and its editor
|
||||
# commands against simulated NOR: write / read back, its sectors only, a power cut at any byte or erase
|
||||
# (the old bank or the new one), a wrong CRC, SLOT B1..B32, the SLOT values stored before as before.
|
||||
# ROBUST (tests/robust_test.c): damaged or crafted stored data and editor requests: engine numbers past the last
|
||||
# refused, a retained older
|
||||
# RAM project bounded, user preset patterns inside their fields, malformed requests never stop PLAY.
|
||||
@@ -236,6 +239,8 @@ if [ -f build/gen/felucca_tables.h ]; then
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/fm6_test" tests/fm6_test.c -lm
|
||||
mkdir -p build/fm6_demo
|
||||
run "FM6: algorithms, envelopes, retrigger, DC, clipping, macros, patch formats, voices, cost, demos" "$OUT/fm6_test" build/fm6_demo
|
||||
$CC -w -Ibuild/gen -Ifirmware/src -o "$OUT/fm6bank_test" tests/fm6bank_test.c -lm
|
||||
run "FM6 voice bank: write / read, power cuts, CRC, SLOT B1..B32, stored SLOT values as before" "$OUT/fm6bank_test"
|
||||
else
|
||||
echo "== skip hostsim (run ./build.sh once)"
|
||||
fi
|
||||
@@ -262,7 +267,7 @@ else
|
||||
run "ASan/UBSan: update loader (other app -> this build)" "$A/ldr_test" "$OUT/old.fwsc" build/felucca.fwsc
|
||||
$SCC -DOWN_PKG=1 -o "$A/ota_test" tests/ota_test.c
|
||||
run "ASan/UBSan: M-UPGRADE entry (own loader)" "$A/ota_test" build/felucca.fwsc
|
||||
for t in editor_test project_test backup_test robust_test; do
|
||||
for t in editor_test project_test backup_test robust_test fm6bank_test; do
|
||||
$SCC -o "$A/$t" tests/$t.c -lm
|
||||
run "ASan/UBSan: $t" "$A/$t"
|
||||
done
|
||||
|
||||
@@ -7,7 +7,7 @@ import html, os
|
||||
|
||||
R = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
OUT = os.path.join(R, 'docs', 'cheatsheet')
|
||||
VERSION = 'v0.6.10'
|
||||
VERSION = 'v0.6.11'
|
||||
|
||||
HEAT = ['#22d3ee', '#3b82f6', '#8b5cf6', '#d946ef', '#ef4444', '#ff7a00', '#facc15', '#f4f1ea']
|
||||
|
||||
@@ -273,7 +273,7 @@ def sound():
|
||||
('FM6', HEAT[3], 'ALG FB MLVL MRAT', 'MEG VMOD DTUN SLOT',
|
||||
'Dexed\'s 6 operators, 32 algorithms drawn, .syx patches (SLOT), MLVL / MRAT move the modulators. '
|
||||
'<b>OPERATOR · OP ENV · OPERATOR 2</b>: each operator on the device (ratio / fixed, fine, level, its envelope, '
|
||||
'mode, detune, velocity).'),
|
||||
'mode, detune, velocity). <b>SLOT B1–B32</b>: a 32-voice .syx sent from the web editor.'),
|
||||
('PHASE', HEAT[2], 'WAVE WAVE2 DCW ENV', 'DTN LINE SUB FB',
|
||||
'Phase distortion (CZ); <b>FB</b> feeds the output back into the phase: hard edge to growl.'),
|
||||
('LOFI', HEAT[0], 'CHIP WAVE DUTY CRSH', '- VIB BEND MASK',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* build/video/capture build/video -> audio.wav (44.1 kHz stereo), screen.rgb (240 x 240 RGB24 a frame)
|
||||
* tools/video/compose.py makes the 1080p video from them. */
|
||||
#define UI_TEST_NO_MAIN 1
|
||||
#define FELUCCA_VERSION "v0.6.10"
|
||||
#define FELUCCA_VERSION "v0.6.11"
|
||||
#include "ui_test.c"
|
||||
|
||||
#define FPS 30u
|
||||
|
||||
@@ -79,7 +79,7 @@ glow_c = glow_m * np.array(VIOLET, np.float32) * 0.55 + glow_m ** 3 * np.array(O
|
||||
sig = Image.open(ROOT / 'docs/cheatsheet/signature.png').convert('RGB')
|
||||
|
||||
brand = text_layer(['JIANT FM'], F_SMALL, WHITE)
|
||||
tag = text_layer(['M-VAVE FM-1 · v0.6.10'], F_SMALL, DIM)
|
||||
tag = text_layer(['M-VAVE FM-1 · v0.6.11'], F_SMALL, DIM)
|
||||
LAYERS = [(text_layer([sc[2] or ' '], F_SMALL, ORANGE), text_layer(sc[3], F_BIG, WHITE, 0.98, gradient=True),
|
||||
text_layer(sc[4] or [' '], F_SUB, WHITE, 1.3)) for sc in SCENES]
|
||||
intro_t = text_layer(['JIANT FM'], font('Bold', 150), WHITE, gradient=True)
|
||||
|
||||
+28
-1
@@ -208,7 +208,7 @@ at 1..3 and hides 6 5 8: what it sets still plays the right kit, and the device
|
||||
|
||||
| cmd | Request args | Reply args |
|
||||
| --- | --- | --- |
|
||||
| 1 INFO | — | version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then NENGINES engine-name strings, then (v3) NTRK (6 since JIANT 0.6, 4 before), then (v6) CHAIN_ROWS (16), then the tagged blocks `55 01 uiCaps`, `4D 01 64 01`, `42 01 3`, `46 01 nfactory nbank`, `53 01 3`, (1.0.3) `50 01 3` and (1.0.4) `4E 01 count` (MENU settings; 12, 1.1: 15, 1.2: 17, 1.1.5: 18) and (1.0.5) `52 01 4` (ratchet) and (1.1) `4C 01 1` (parameter locks) (below); older firmware ends earlier |
|
||||
| 1 INFO | — | version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then NENGINES engine-name strings, then (v3) NTRK (6 since JIANT 0.6, 4 before), then (v6) CHAIN_ROWS (16), then the tagged blocks `55 01 uiCaps`, `4D 01 64 01`, `42 01 3`, `46 01 nfactory nbank`, `53 01 3`, (1.0.3) `50 01 3` and (1.0.4) `4E 01 count` (MENU settings; 12, 1.1: 15, 1.2: 17, 1.1.5: 18) and (1.0.5) `52 01 4` (ratchet) and (1.1) `4C 01 1` (parameter locks) and (JIANT 0.6.11) `56 01 32` (FM6's voice bank) (below); older firmware ends earlier |
|
||||
| 2 GET | scope, id | scope, id, v14 |
|
||||
| 3 SET | scope, id, v14 | scope, id, v14 (the value after clamping). Setting global `G_ENGSEL` (id from DESC label "ENG") changes the engine: its defaults, then its first preset (as on the device) |
|
||||
| 4 DUMP | — | engine, preset, then P_COUNT × v14 (the selected track), then G_COUNT × v14 (globals) |
|
||||
@@ -884,3 +884,30 @@ device gone at ~0.3 s, the MIDI port gone at ~0.57 s and back at ~1.15 s; ON ->
|
||||
at ~0.6 s while the MIDI port was not seen to disappear at all (so do not wait for a disconnect event: after
|
||||
a real change, wait ~1.5 s and open again). What the editor sends in that window is lost, `WATCH` ends with the
|
||||
bus reset (send `INFO` and `WATCH` again after reconnecting), and a backup in progress answers rc 5 (stale).
|
||||
|
||||
## FM6 voice bank (74-77; JIANT 0.6.11, from Felucca 1.4.1)
|
||||
|
||||
32 voices in flash, written whole from the editor (a 32-voice SysEx file: its 128-byte packed records, the format
|
||||
`FM6_PUT` takes), picked on the device with SLOT B1..B32 (9..40). Loading one copies it into the track's patch as F1..F8
|
||||
do: the patch is the track's from then on, saved with projects and user presets (`FM6_GET` target 0 reads it), so a
|
||||
project made with a bank voice sounds the same after the bank was replaced. INFO advertises `56 01 32` (32 voices)
|
||||
after `4C 01 1` (Felucca: after its `57 01 4`); firmware without the tag answers none of 74..77 and has SLOT 0..8.
|
||||
|
||||
| cmd | Request args | Reply args |
|
||||
| --- | --- | --- |
|
||||
| 74 FM6B_BEGIN | — | rc. Starts a transfer (stops the transport; erases a sector: allow 1 s) |
|
||||
| 75 FM6B_WRITE | index 0..31, the 128 bytes | index, rc. Each index at most once per transfer; voices not written are empty in the new bank |
|
||||
| 76 FM6B_END | name (10 ASCII bytes, space-padded), CRC-32 (zlib's) of the written records, 128 bytes each in index order (5 × 7 bits, LSB first: bits 0..6, 7..13, .., 28..31) | rc, voices (how many the bank the device holds now has). rc 0: the new bank replaced the old one (allow 1 s) |
|
||||
| 77 FM6B_LIST | — | 32, bank (1 there is one, 0 none), its name string, then per voice: used (0/1), name string ("" if empty) |
|
||||
|
||||
rc: 0 ok, 1 arguments (an index past 31 or written twice, a record that is not 128 bytes, an END that is not 15
|
||||
bytes), 2 the CRC did not match (nothing changed: the old bank stays; start again with `FM6B_BEGIN`), 3 playback did
|
||||
not stop, 4 flash (no flash, an erase or a write failed), 5 no transfer (no `FM6B_BEGIN`, an END already answered, or
|
||||
the device's autosave took the transfer's flash between two requests, after 10 s without one: start again).
|
||||
|
||||
- An END with no WRITE (the CRC of nothing: 0) writes an empty bank: every B slot is empty.
|
||||
- The old bank stays until END answers rc 0; a power cut at any point leaves the old bank or the new one, never a mix.
|
||||
- A track on a bank slot when a new bank arrives keeps the voice it played, as its own patch: SLOT becomes OWN.
|
||||
- The editor's import (6-OP FM tab): a 32-voice file's voices, each packed as for a single voice (every value into
|
||||
its range); an empty slot of a shorter file is not written. Flash: the bank is at 0xE7000; a transfer is staged in
|
||||
the autosave's older sector first (0xE5000 / 0xE6000), which the next autosave writes over anyway.
|
||||
+117
-8
@@ -340,7 +340,8 @@ const CMD = { INFO: 1, GET: 2, SET: 3, DUMP: 4, DESC: 5, STEP_GET: 6, STEP_SET:
|
||||
TRACK_PARAM: 31, TRACK_CHANGED: 32, SONG: 33,
|
||||
UI_STATE: 34, UI_SET: 35, UI_PALETTES: 36, FAV_GET: 37, FAV_SET: 38,
|
||||
MOTION: 64, BACKUP_LIST: 65, BACKUP_GET: 66, BACKUP_PUT: 67,
|
||||
FM6_GET: 68, FM6_PUT: 69, FM6_LIST: 70, FM6_ERASE: 71 };
|
||||
FM6_GET: 68, FM6_PUT: 69, FM6_LIST: 70, FM6_ERASE: 71,
|
||||
FM6B_BEGIN: 74, FM6B_WRITE: 75, FM6B_END: 76, FM6B_LIST: 77 }; /* (JIANT 0.6.11, Felucca 1.4.1) FM6's voice bank */
|
||||
/* 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) */
|
||||
@@ -425,6 +426,7 @@ const parse = {
|
||||
o.fm6 = null; /* FM6 patches (cmds 68..71): the factory and bank slot counts */
|
||||
o.syncCaps = 0; /* live sync: bit 0 WATCH while on keeps pending pushes, bit 1 no RELOAD */
|
||||
o.ratchet = 0; /* a step's ratchet (STEP_SET's byte after the chance), 0 = none */
|
||||
o.fm6Bank = 0; /* (JIANT 0.6.11) FM6's voice bank: its voices (cmds 74..77), 0 = none */
|
||||
for (const p of [8, 11]) if (o.motionMax && trailer[p] === 0x46 && trailer[p + 1] === 1) { /* for the editor's */
|
||||
o.fm6 = { factory: trailer[p + 2], bank: trailer[p + 3], caps: 0 }; /* PRESET / G_ENGSEL */
|
||||
if (trailer[p + 4] === 0x53 && trailer[p + 5] === 1) o.syncCaps = trailer[p + 6] & 3;
|
||||
@@ -432,7 +434,9 @@ const parse = {
|
||||
if (trailer[p + 7] === 0x50 && trailer[p + 8] === 1) o.fm6.caps = trailer[p + 9] & 3;
|
||||
let r = trailer[p + 7] === 0x50 ? p + 10 : p + 7; /* RATCH after FM6 v2 */
|
||||
if (trailer[r] === 0x4E && trailer[r + 1] === 1) r += 3; /* and the MENU settings (1.0.4) */
|
||||
if (o.syncCaps && trailer[r] === 0x52 && trailer[r + 1] === 1) o.ratchet = trailer[r + 2]; /* RATCH: max hits */
|
||||
if (o.syncCaps && trailer[r] === 0x52 && trailer[r + 1] === 1) { o.ratchet = trailer[r + 2]; r += 3; } /* RATCH: max hits */
|
||||
if (trailer[r] === 0x4C && trailer[r + 1] === 1) r += 3; /* parameter locks (1.1) */
|
||||
if (trailer[r] === 0x56 && trailer[r + 1] === 1) o.fm6Bank = trailer[r + 2]; /* (0.6.11) the voice bank's size */
|
||||
}
|
||||
return o;
|
||||
},
|
||||
@@ -556,6 +560,15 @@ const parse = {
|
||||
return o;
|
||||
},
|
||||
[CMD.FM6_ERASE](a) { return { index: a[0], rc: a[1] }; },
|
||||
/* (JIANT 0.6.11, Felucca 1.4.1) FM6's voice bank, EDITOR_PROTOCOL.md "FM6 voice bank (74-77)" */
|
||||
[CMD.FM6B_BEGIN](a) { return { rc: a[0] }; },
|
||||
[CMD.FM6B_WRITE](a) { return { index: a[0], rc: a[1] }; },
|
||||
[CMD.FM6B_END](a) { return { rc: a[0], voices: a[1] }; },
|
||||
[CMD.FM6B_LIST](a) {
|
||||
const r = new Reader(a), o = { n: r.b(), valid: !!r.b(), name: r.s(), voices: [] };
|
||||
for (let i = 0; i < o.n; i++) { const used = !!r.b(); o.voices.push({ used, name: r.s() }); }
|
||||
return o;
|
||||
},
|
||||
};
|
||||
|
||||
/* a name the device accepts: printable ASCII, 1..12 characters */
|
||||
@@ -619,6 +632,13 @@ const req = {
|
||||
fm6Put: (target, i, packed) => [CMD.FM6_PUT, [target & 0x7F, i & 0x7F, ...packed.map((x) => x & 0x7F)]],
|
||||
fm6List: () => [CMD.FM6_LIST, []],
|
||||
fm6Erase: (i) => [CMD.FM6_ERASE, [i & 0x7F]],
|
||||
/* (0.6.11) the voice bank: BEGIN, a WRITE per voice (index, the 128-byte record), END (name, the CRC of the records
|
||||
written, in index order: 5 x 7 bits), LIST */
|
||||
fm6bBegin: () => [CMD.FM6B_BEGIN, []],
|
||||
fm6bWrite: (i, packed) => [CMD.FM6B_WRITE, [i & 0x7F, ...packed.map((x) => x & 0x7F)]],
|
||||
fm6bEnd: (name, crc) => [CMD.FM6B_END, [...String(name ?? "").padEnd(10, " ").slice(0, 10)].map((c) => c.charCodeAt(0) & 0x7F)
|
||||
.concat([0, 7, 14, 21, 28].map((sh) => (crc >>> sh) & 0x7F))],
|
||||
fm6bList: () => [CMD.FM6B_LIST, []],
|
||||
};
|
||||
|
||||
/* which reply belongs to which request (the device echoes these) */
|
||||
@@ -635,6 +655,7 @@ function replyMatches(cmd, args, a) {
|
||||
case CMD.SONG: return a[0] === args[0];
|
||||
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.FM6B_WRITE: return a[0] === args[0];
|
||||
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: return a[0] === args[0];
|
||||
@@ -945,6 +966,36 @@ function readLibraryFile(obj, ctx) {
|
||||
/* device side; rq(r, opt) -> reply args (Link.request), info from INFO */
|
||||
const FLASH_OPT = { timeout: 2500, retries: 0 };
|
||||
const presetPatches = (info) => !!(info && info.fm6 && info.fm6.caps & 2); /* user presets carry FM6 patches (1.0.3) */
|
||||
/* zlib's CRC-32 (the voice bank's END: of the records written, in index order) */
|
||||
function crc32(bytes, c = 0xFFFFFFFF) {
|
||||
for (const x of bytes) { c ^= x; for (let k = 0; k < 8; k++) c = (c >>> 1) ^ (0xEDB88320 & -(c & 1)); }
|
||||
return (c ^ 0xFFFFFFFF) >>> 0;
|
||||
}
|
||||
/* (JIANT 0.6.11, Felucca 1.4.1) FM6's voice bank on the device: 32 voices in flash, SLOT B1..B32 picks them. A 32-voice
|
||||
.syx is sent whole (fm6_vbank.c: the old bank stays until END answers 0, a power cut leaves one or the other) */
|
||||
const fm6Bank = {
|
||||
N: 32,
|
||||
/* the voices of an import ({name, v} or 155-byte voices; null: an empty slot) -> 128-byte records */
|
||||
fromVoices: (voices) => Array.from({ length: Math.min(32, voices.length) }, (_, k) => {
|
||||
const x = voices[k]; return x ? FM6.pack(x.v || x) : null;
|
||||
}),
|
||||
/* the bank's name from a file name: its base, capitals, printable ASCII, 10 at most */
|
||||
nameOf: (file) => String(file ?? "").replace(/\.[^.]*$/, "").toUpperCase().replace(/[^\x20-\x7E]/g, " ").trim().slice(0, 10).trim(),
|
||||
async list(rq) { return parse[CMD.FM6B_LIST](await rq(req.fm6bList())); },
|
||||
/* packed: up to 32 records (null: not written, empty in the new bank) -> END's rc (0: the new bank is on the device) */
|
||||
async send(rq, packed, name) {
|
||||
let rc = parse[CMD.FM6B_BEGIN](await rq(req.fm6bBegin(), { timeout: 3000, retries: 0 })).rc; /* (no retries: a WRITE twice is rc 1) */
|
||||
if (rc) return rc;
|
||||
const done = [];
|
||||
for (let k = 0; k < Math.min(32, packed.length); k++) {
|
||||
if (!packed[k]) continue;
|
||||
rc = parse[CMD.FM6B_WRITE](await rq(req.fm6bWrite(k, packed[k]), { timeout: 2000, retries: 0 })).rc;
|
||||
if (rc) return rc;
|
||||
done.push(...packed[k].map((x) => x & 0x7F));
|
||||
}
|
||||
return parse[CMD.FM6B_END](await rq(req.fm6bEnd(name, crc32(done)), { timeout: 5000, retries: 0 })).rc;
|
||||
},
|
||||
};
|
||||
const bank = {
|
||||
async list(rq) {
|
||||
const first = parse[CMD.UP_LIST](await rq(req.upList(0, UP.LIST_MAX)));
|
||||
@@ -1524,7 +1575,7 @@ function makeMockDevice(opt = {}) {
|
||||
P("ARCADE", [2, 0, 127, 0, 127, 112, 0, 84], [0, 80, 0, 50], 0, 3), P("METAL", [3, 0, 100, 40, 100, 32, 0, 0], [0, 75, 40, 60], 0, 7)] },
|
||||
{ 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("SLOT", F.INT, 0, FM6.FACTORY_PK.length, 0)], /* F1..F8, then OWN (eng_fm6.c, 1.0.3) */
|
||||
D("SLOT", F.INT, 0, FM6.FACTORY_PK.length + 32, 0)], /* F1..F8, then OWN (eng_fm6.c, 1.0.3) */
|
||||
presets: [P("TINE EP", [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 127, 0], 0, 6), P("BELL", [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 127, 0], 0, 7),
|
||||
P("FM BASS", [0, 0, 0, 0, 0, 0, 0, 2], [0, 0, 127, 0], 1, 2), P("BRASS", [0, 0, 0, 0, 0, 0, 0, 3], [0, 0, 127, 0], 0, 4),
|
||||
P("PAD", [0, 0, 0, 0, 0, 0, 30, 4], [0, 0, 127, 0], 0, 5), P("MARIMBA", [0, 0, 0, 0, 0, 0, 0, 5], [0, 0, 127, 0], 0, 3),
|
||||
@@ -1577,6 +1628,7 @@ function makeMockDevice(opt = {}) {
|
||||
bank: new Array(opt.slots || 32).fill(null), /* user presets: {engine, name, p, pattern, grid, fm6 (FM6: its patch)} */
|
||||
uiCaps: opt.legacy || opt.v3 || opt.v5 ? 0 : opt.uiCaps ?? 9,
|
||||
palette: 0, font: 0, monitor: 0, filter: 0, bankSig: 0,
|
||||
vbank: { valid: false, name: "", voices: new Array(32).fill(null) }, vtx: null, /* (0.6.11) FM6's voice bank */
|
||||
palettes: ["GREY", "GREEN", "AMBER", "ICE", "VIOLET", "ROSE", "PAPER", "HI-CON", "NIGHT", "MONO"],
|
||||
favorites: Array.from({ length: ENG.length + 1 }, () => []),
|
||||
watch: false, v4: false, lastReq: 0,
|
||||
@@ -1625,9 +1677,11 @@ function makeMockDevice(opt = {}) {
|
||||
patch back */
|
||||
function fm6Slot(t, s) {
|
||||
if (s === t.slot) return;
|
||||
if (s >= FM6_OWN) { if (t.own) t.fm6 = t.own; t.own = null; t.slot = FM6_OWN; return; }
|
||||
const bk = s > FM6_OWN && s <= FM6_OWN + 32 ? s - FM6_OWN - 1 : -1; /* (0.6.11) B1..B32: the voice bank's */
|
||||
if (bk >= 0 && !st.vbank.voices[bk]) { t.p[P_E0 + 7] = t.slot ?? FM6_OWN; return; } /* (none there: refused) */
|
||||
if (s >= FM6_OWN && bk < 0) { if (t.own) t.fm6 = t.own; t.own = null; t.slot = FM6_OWN; return; }
|
||||
if (t.slot === FM6_OWN && !t.own) t.own = t.fm6.slice();
|
||||
t.fm6 = FM6.FACTORY_PK[s].slice(); t.slot = s;
|
||||
t.fm6 = (bk >= 0 ? st.vbank.voices[bk] : FM6.FACTORY_PK[s]).slice(); t.slot = s;
|
||||
}
|
||||
/* t's patch was put in as its own (eng_fm6.c fm6_adopt): SLOT = the factory patch it equals, else OWN */
|
||||
function fm6Adopt(t) {
|
||||
@@ -1831,7 +1885,8 @@ function makeMockDevice(opt = {}) {
|
||||
if (!opt.legacy && !opt.v3 && !opt.v5) {
|
||||
b(16);
|
||||
if (st.uiCaps) { b(0x55); b(1); b(st.uiCaps); b(0x4d); b(1); b(64); b(1); if (!opt.noFm6) { b(0x46); b(1); b(FM6.FACTORY_PK.length); b(0); }
|
||||
if (syncCaps()) { b(0x53); b(1); b(syncCaps()); if (!opt.noFm6) { b(0x50); b(1); b(3); } if (ratchetOn()) { b(0x52); b(1); b(4); } } } /* (FM6 v2: no bank, preset patches) */
|
||||
if (syncCaps()) { b(0x53); b(1); b(syncCaps()); if (!opt.noFm6) { b(0x50); b(1); b(3); } if (ratchetOn()) { b(0x52); b(1); b(4); }
|
||||
if (!opt.noFm6 && !opt.noVbank && ratchetOn()) { b(0x56); b(1); b(32); } } } /* (FM6 v2: no bank, preset patches; 0.6.11: the voice bank) */
|
||||
}
|
||||
break;
|
||||
case CMD.GET: case CMD.SET: {
|
||||
@@ -1900,6 +1955,37 @@ function makeMockDevice(opt = {}) {
|
||||
b(a[0]); stepOut(x, b);
|
||||
break;
|
||||
}
|
||||
case CMD.FM6B_BEGIN: case CMD.FM6B_WRITE: case CMD.FM6B_END: case CMD.FM6B_LIST: { /* (0.6.11) fm6_vbank.c */
|
||||
if (opt.noFm6 || !st.uiCaps) return null;
|
||||
const vb = st.vbank;
|
||||
if (cmd === CMD.FM6B_BEGIN) {
|
||||
if (a.length) { b(1); break; }
|
||||
st.vtx = { voices: new Array(32).fill(null) }; b(0);
|
||||
} else if (cmd === CMD.FM6B_WRITE) {
|
||||
b(a.length ? a[0] : 127);
|
||||
if (!st.vtx) b(5);
|
||||
else if (a.length !== 1 + 128 || a[0] > 31 || st.vtx.voices[a[0]]) b(1);
|
||||
else { st.vtx.voices[a[0]] = Array.from(a.slice(1)); b(0); }
|
||||
} else if (cmd === CMD.FM6B_END) {
|
||||
let rc = a.length !== 15 || a[14] > 15 ? 1 : !st.vtx ? 5 : 0;
|
||||
if (!rc) {
|
||||
const crc = (a[10] | a[11] << 7 | a[12] << 14 | a[13] << 21 | a[14] << 28) >>> 0;
|
||||
const tx = st.vtx; st.vtx = null;
|
||||
if (crc32(tx.voices.filter(Boolean).flat()) !== crc) rc = 2;
|
||||
else {
|
||||
st.vbank = { valid: true, name: String.fromCharCode(...a.slice(0, 10)).replace(/[\s\0]+$/, ""), voices: tx.voices };
|
||||
for (const t of st.tracks) /* a track on a bank slot keeps its voice, as its own */
|
||||
if (t.slot > FM6_OWN) { t.own = null; t.p[P_E0 + 7] = t.slot = FM6_OWN; }
|
||||
}
|
||||
}
|
||||
b(rc); b(st.vbank.voices.filter(Boolean).length);
|
||||
} else {
|
||||
if (a.length) return null;
|
||||
b(32); b(vb.valid ? 1 : 0); s(vb.name);
|
||||
vb.voices.forEach((pk) => { b(pk ? 1 : 0); s(pk ? FM6.name(FM6.unpack(pk)) : ""); });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD.FM6_GET: case CMD.FM6_PUT: case CMD.FM6_LIST: case CMD.FM6_ERASE: { /* editor_fm6.c */
|
||||
if (opt.noFm6 || !st.uiCaps) return null;
|
||||
const nf = FM6.FACTORY_PK.length, fm6User = (k) => k < NB && st.bank[k] && st.bank[k].engine === FM6_E;
|
||||
@@ -2221,6 +2307,7 @@ const TEXT = {
|
||||
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 が中央)。● はキャリア。",
|
||||
fm6BankSend: "本体のボイスバンクへ送る (B1–B32)", fm6BankSent: "ボイスバンクを送りました:", fm6BankFail: "ボイスバンクを送れませんでした (rc ", fm6BankNow: "本体のボイスバンク:", fm6BankNone: "なし",
|
||||
fm6Pick: "読み込んだファイルの音色(押すと編集へ):", fm6Picked: "編集中:", fm6Sent: "トラックへ送りました:", fm6Read: "トラックから読みました",
|
||||
fm6Loaded: "読み込みました", fm6BadSum: "チェックサム不一致あり",
|
||||
fm6Keep: "残すには、トラックへ送ってから本体でユーザープリセット(SAVE)かプロジェクトに保存してください。",
|
||||
@@ -2317,6 +2404,7 @@ const TEXT = {
|
||||
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.",
|
||||
fm6BankSend: "Send to the device's voice bank (B1–B32)", fm6BankSent: "Voice bank sent:", fm6BankFail: "The voice bank was not sent (rc ", fm6BankNow: "The device's voice bank:", fm6BankNone: "none",
|
||||
fm6Pick: "Voices of the imported file (click to edit):", fm6Picked: "Editing:", fm6Sent: "Sent to track", fm6Read: "Read from track",
|
||||
fm6Loaded: "Loaded", fm6BadSum: "a checksum did not match",
|
||||
fm6Keep: "To keep a voice, send it to a track, then save a user preset (SAVE) or a project on the device.",
|
||||
@@ -4221,11 +4309,30 @@ function renderFm6Ops() {
|
||||
}
|
||||
function renderFm6Imported() {
|
||||
const box = $("fm6imported");
|
||||
if (!fm6Imported.length || !fm6Ok()) { box.replaceChildren(); return; }
|
||||
if (!fm6Ok()) { box.replaceChildren(); return; }
|
||||
/* (JIANT 0.6.11) the device's voice bank (SLOT B1..B32): its name, and the imported file sent to it whole */
|
||||
const bankRow = dev.info.fm6Bank ? [el("p", { class: "dim",
|
||||
text: `${t("fm6BankNow")} ${fm6BankList ? (fm6BankList.valid ? `${fm6BankList.name || "-"} (${fm6BankList.voices.filter((v) => v.used).length})` : t("fm6BankNone")) : "…"}` })] : [];
|
||||
if (dev.info.fm6Bank && fm6Imported.length > 1)
|
||||
bankRow.push(el("p", { class: "bar" }, el("button", { text: t("fm6BankSend"), onclick: () => op(fm6BankSend) })));
|
||||
if (!fm6Imported.length) { box.replaceChildren(...bankRow); return; }
|
||||
box.replaceChildren(el("p", { class: "dim", text: t("fm6Pick") }),
|
||||
el("p", { class: "bar" }, ...fm6Imported.map((x, k) => el("button", { text: `${k + 1} ${x.name}`,
|
||||
"aria-pressed": k === fm6Picked ? "true" : "false",
|
||||
onclick: () => { fm6v = Uint8Array.from(x.v); fm6Picked = k; renderFm6(); sayK("fm6Picked", ` ${x.name}`); } }))));
|
||||
onclick: () => { fm6v = Uint8Array.from(x.v); fm6Picked = k; renderFm6(); sayK("fm6Picked", ` ${x.name}`); } }))), ...bankRow);
|
||||
}
|
||||
let fm6BankList = null, fm6ImportName = ""; /* (0.6.11) the device's voice bank (FM6B_LIST), the file imported last */
|
||||
async function fm6BankRefresh(d = dev) {
|
||||
if (!d || !d.info.fm6Bank) return;
|
||||
fm6BankList = await fm6Bank.list((r, o) => sessionRequest(d, r, o));
|
||||
renderFm6Imported();
|
||||
}
|
||||
async function fm6BankSend() {
|
||||
const name = fm6Bank.nameOf(fm6ImportName) || "BANK";
|
||||
const rc = await fm6Bank.send((r, o) => sessionRequest(dev, r, o), fm6Bank.fromVoices(fm6Imported), name);
|
||||
if (rc) { sayK("fm6BankFail", `${rc})`); return; }
|
||||
await fm6BankRefresh();
|
||||
sayK("fm6BankSent", ` ${name} (${Math.min(32, fm6Imported.length)})`);
|
||||
}
|
||||
function renderFm6() {
|
||||
if (!fm6Ok()) return;
|
||||
@@ -4246,6 +4353,7 @@ async function fm6Refresh(d = dev) {
|
||||
fm6Listing = true;
|
||||
try { fm6List = parse[CMD.FM6_LIST](await sessionRequest(d, req.fm6List())); } finally { fm6Listing = false; }
|
||||
renderFm6();
|
||||
await fm6BankRefresh(d);
|
||||
}
|
||||
async function fm6Send(quiet) {
|
||||
const r = parse[CMD.FM6_PUT](await sessionRequest(dev, req.fm6Put(FM6.TARGET.TRACK, fm6Track(), FM6.pack(fm6v))));
|
||||
@@ -4278,6 +4386,7 @@ $("fm6file").addEventListener("change", async (e) => {
|
||||
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;
|
||||
fm6ImportName = f.name;
|
||||
fm6Picked = r.voices.length === 1 ? 0 : -1;
|
||||
if (r.voices.length === 1) fm6v = Uint8Array.from(r.voices[0].v);
|
||||
renderFm6();
|
||||
|
||||
+78
-1
@@ -36,9 +36,85 @@ const E = vm.runInNewContext(proto + `
|
||||
mixer, parseNotes, parseHits, hitsText, gridFromSteps, LANE_NOTE, LANE_OF, readDevicePreferences, devicePresetRows, engineOrder, ENGINE_ORDER, aliasOf, fmtValue, FM6, enumShown, F,
|
||||
FM4, fromDigital, fromPerc, DRUM_KIT_E,
|
||||
MENU: typeof MENU === "undefined" ? null : MENU, MENU_TABS: typeof MENU_TABS === "undefined" ? null : MENU_TABS,
|
||||
readDeviceMenu: typeof readDeviceMenu === "undefined" ? null : readDeviceMenu })`,
|
||||
readDeviceMenu: typeof readDeviceMenu === "undefined" ? null : readDeviceMenu, fm6Bank, crc32 })`,
|
||||
{ setTimeout, clearTimeout, setInterval, clearInterval, console });
|
||||
|
||||
/* (JIANT 0.6.11, from Felucca 1.4.1's test) FM6's voice bank (cmds 74..77; the editor's fm6Bank) against the mock: INFO 56 01 32, a 32-voice .syx
|
||||
sent whole (BEGIN, 32 WRITEs, END with the CRC), LIST's names, SLOT B1..B32 loading the exact records, empty bank
|
||||
slots refused, a wrong CRC and a WRITE without BEGIN changing nothing, a new bank leaving a track's voice its own */
|
||||
async function editorFm6Bank() {
|
||||
if (!E.fm6Bank) { console.log("FM6 bank: (editor.html has no voice bank sender)".padEnd(64) + " skip"); return; }
|
||||
const F6 = E.FM6, C = E.CMD;
|
||||
const m = E.makeMockDevice({ auto: false });
|
||||
const link = new E.Link((d) => [...m.access.outputs.values()][0].send(d), { timeout: 200 });
|
||||
[...m.access.inputs.values()][0].onmidimessage = (e) => link.receive(e.data);
|
||||
const rq = (x, o) => link.request(x, o);
|
||||
const info = E.parse[C.INFO](await rq(E.req.info()));
|
||||
ok(info.fm6Bank === 32 && info.fm6.caps === 3, "FM6 bank: INFO 56 01 32 (after RATCH)");
|
||||
let list = await E.fm6Bank.list(rq);
|
||||
ok(list.n === 32 && !list.valid && list.name === "" && list.voices.every((v) => !v.used), "FM6 bank: LIST of an empty device: no bank");
|
||||
/* a 32-voice file: the factory patches renamed VOICE 01..32 (the import path: parseSysex, then the packed records) */
|
||||
const voices = Array.from({ length: 32 }, (_, k) => F6.setName(F6.factory(k % 8), `VOICE ${String(k + 1).padStart(2, "0")}`));
|
||||
const file = F6.bankSysex(voices), parsed = F6.parseSysex(file), packed = E.fm6Bank.fromVoices(parsed.voices);
|
||||
ok(parsed.voices.length === 32 && packed.length === 32 && packed.every((pk, k) => eq(pk, F6.pack(voices[k]))) &&
|
||||
E.fm6Bank.nameOf("my fm bank.syx") === "MY FM BANK" && E.fm6Bank.nameOf("äbc.SYX") === " BC".trim(),
|
||||
"FM6 bank: a 32-voice .syx -> 32 packed records; the bank's name from the file name");
|
||||
let rc = await E.fm6Bank.send(rq, packed, E.fm6Bank.nameOf("my fm bank.syx"));
|
||||
list = await E.fm6Bank.list(rq);
|
||||
ok(rc === 0 && list.valid && list.name === "MY FM BANK" && list.voices.every((v, k) => v.used && v.name === `VOICE ${String(k + 1).padStart(2, "0")}`),
|
||||
"FM6 bank: sent whole (rc 0); LIST: its name, 32 voices and their names");
|
||||
const eng = info.engines.indexOf("FM6"), slotId = info.pe0 + 7;
|
||||
await rq(E.req.set(1, 20, eng));
|
||||
let all = true;
|
||||
for (let k = 0; k < 32; k++) {
|
||||
await rq(E.req.set(0, slotId, 9 + k));
|
||||
const g = E.parse[C.FM6_GET](await rq(E.req.fm6Get(0, 0)));
|
||||
const sv = E.parse[C.GET](await rq(E.req.get(0, slotId))).value;
|
||||
all &&= eq(g.packed, packed[k]) && sv === 9 + k;
|
||||
}
|
||||
ok(all, "FM6 bank: SLOT 9..40 (B1..B32) loads each voice's exact record into the track");
|
||||
/* a bank with voices 1, 6 and 32 only (bank slots without a voice are refused: SLOT back) */
|
||||
const some = packed.map((pk, k) => ([0, 5, 31].includes(k) ? F6.pack(F6.setName(F6.unpack(pk), `ONLY ${k + 1}`)) : null));
|
||||
await rq(E.req.set(0, slotId, 9 + 4)); /* B5 of the full bank */
|
||||
rc = await E.fm6Bank.send(rq, some, "SOME");
|
||||
let sv = E.parse[C.GET](await rq(E.req.get(0, slotId))).value, g = E.parse[C.FM6_GET](await rq(E.req.fm6Get(0, 0)));
|
||||
ok(rc === 0 && sv === 8 && eq(g.packed, packed[4]), "FM6 bank: a new bank: the track on B5 keeps that voice as its own (SLOT OWN)");
|
||||
await rq(E.req.set(0, slotId, 9 + 1)); /* B2: none there */
|
||||
sv = E.parse[C.GET](await rq(E.req.get(0, slotId))).value;
|
||||
g = E.parse[C.FM6_GET](await rq(E.req.fm6Get(0, 0)));
|
||||
ok(sv === 8 && eq(g.packed, packed[4]), "FM6 bank: an empty bank slot (B2) is refused: SLOT back, the patch unchanged");
|
||||
await rq(E.req.set(0, slotId, 9 + 31));
|
||||
g = E.parse[C.FM6_GET](await rq(E.req.fm6Get(0, 0)));
|
||||
list = await E.fm6Bank.list(rq);
|
||||
ok(eq(g.packed, some[31]) && list.voices.filter((v) => v.used).map((v) => v.name).join() === "ONLY 1,ONLY 6,ONLY 32",
|
||||
"FM6 bank: B32 loads; LIST: the three voices, the rest empty");
|
||||
/* a wrong CRC: nothing changes */
|
||||
E.parse[C.FM6B_BEGIN](await rq(E.req.fm6bBegin()));
|
||||
const w = E.parse[C.FM6B_WRITE](await rq(E.req.fm6bWrite(0, packed[7])));
|
||||
const end = E.parse[C.FM6B_END](await rq(E.req.fm6bEnd("BAD", E.crc32(Uint8Array.from(packed[7])) ^ 1)));
|
||||
list = await E.fm6Bank.list(rq);
|
||||
ok(w.rc === 0 && end.rc === 2 && end.voices === 3 && list.name === "SOME", "FM6 bank: a wrong CRC (rc 2): the bank stays");
|
||||
const w2 = E.parse[C.FM6B_WRITE](await rq(E.req.fm6bWrite(0, packed[7])));
|
||||
const e2 = E.parse[C.FM6B_END](await rq(E.req.fm6bEnd("X", 0)));
|
||||
E.parse[C.FM6B_BEGIN](await rq(E.req.fm6bBegin()));
|
||||
E.parse[C.FM6B_WRITE](await rq(E.req.fm6bWrite(3, packed[3])));
|
||||
const w3 = E.parse[C.FM6B_WRITE](await rq(E.req.fm6bWrite(3, packed[3])));
|
||||
const w4 = E.parse[C.FM6B_WRITE](await rq(E.req.fm6bWrite(32, packed[3])));
|
||||
const w5 = E.parse[C.FM6B_WRITE](await rq([C.FM6B_WRITE, [4, 1, 2, 3]]));
|
||||
ok(w2.rc === 5 && e2.rc === 5 && w3.rc === 1 && w4.rc === 1 && w5.rc === 1,
|
||||
"FM6 bank: WRITE / END without BEGIN: rc 5; a voice twice, index 32, a short record: rc 1");
|
||||
rc = await E.fm6Bank.send(rq, new Array(32).fill(null), "");
|
||||
list = await E.fm6Bank.list(rq);
|
||||
ok(rc === 0 && list.valid && list.voices.every((v) => !v.used), "FM6 bank: an empty bank (no WRITE, CRC of nothing) clears it");
|
||||
link.close(); m.stop();
|
||||
const old = E.makeMockDevice({ auto: false, noVbank: true });
|
||||
const l2 = new E.Link((d) => [...old.access.outputs.values()][0].send(d), { timeout: 100 });
|
||||
[...old.access.inputs.values()][0].onmidimessage = (ev) => l2.receive(ev.data);
|
||||
const i2 = E.parse[C.INFO](await l2.request(E.req.info()));
|
||||
ok(i2.fm6Bank === 0 && i2.fm6.caps === 3, "FM6 bank: firmware before 0.6.11: no 56 tag (the editor offers no bank sending)");
|
||||
l2.close(); old.stop();
|
||||
}
|
||||
|
||||
async function editorMock() {
|
||||
const m = E.makeMockDevice();
|
||||
const inp = [...m.access.inputs.values()][0], out = [...m.access.outputs.values()][0];
|
||||
@@ -1413,6 +1489,7 @@ async function updater() {
|
||||
}
|
||||
|
||||
await editorMock();
|
||||
await editorFm6Bank();
|
||||
await editorSamplePresets();
|
||||
mockTables();
|
||||
await editorLibrarian();
|
||||
|
||||
Reference in new issue
Block a user