Skiff 1.1: build an FM6 sound on the unit

EDIT > OPERATOR and EDIT > ALL OPS put every value of an FM6 patch on the
unit's knobs: each operator's ratio, envelope and keyboard scaling, the
algorithm, the pitch envelope and the LFO. The graph draws every operator's
envelope as the engine plays it, each carrier coloured by how bright the
modulators make it (after an idea by Floyd Steinberg). INIT on FM6 is a bare
sine; a sound saved with a typed name names its patch too. CRYPT, NEON and
QUARK dress the new pages their own way. The FM6 engine's sound is unchanged.
This commit is contained in:
illuminus5 committed 2026-10-13 16:44:43 -05:00
1 parent 01fe8c381c
commit b5c999bdb2
34 files changed
+2307 -105

No files matched your search

+1 -1
View File
@@ -46,7 +46,7 @@ On Linux x86-64 the toolchain runs natively and Docker is not needed.
`./build.sh --release 1.0` makes a release build: the package identity becomes `FM-1_710`
(Skiff's 7XY; Felucca's are 9XY) and the version string `v1.0`; the package is `build/skiff-1.0.fwsc`, and
`build/release-1.0/` holds what a release ships: the package, the app
(`skiff-1.0-app.bin`), `SHA256SUMS`, the sample attribution, `LICENSE`, `LICENSING.md` and
(`skiff-1.1-app.bin`), `SHA256SUMS`, the sample attribution, `LICENSE`, `LICENSING.md` and
`LICENSES/` (the package contains Apache-2.0 SDK files, so the licence texts travel with it).
`web/make_site.py build/skiff-1.0.fwsc 1.0 OUT` makes the GitHub Pages site from it: the browser installer, the
editor and the package with its licences.
+20 -4
View File
@@ -13,13 +13,13 @@ Each rule comes from what FM-1 owners said about the stock firmware, Felucca and
| Encoder | Job |
|---|---|
| ALGORITHM | Track |
| PRESETS | Sound, the step cursor on SEQ pages, or the list selection (DRUM-X's SOUND sheet: the drum sound) |
| PRESETS | Sound, the step cursor on SEQ pages, or the list selection (DRUM-X's SOUND sheet: the drum sound; FM6's OPERATOR and ALL OPS: the operator) |
| SELECT | The page before or after in the family |
Tempo changes only while GLO is held, so it can't be bumped by accident. (#58, D#84, D#128)
- A new unit starts with BPM LOCK on, and (U1) a unit coming from Felucca gets it turned on once at its first boot (`main.c`, `ui_set_rev`); the MENU can turn it off again.
- **SELECT turns pages** (phase 8; `ui.c` `page_step`, `ui_input.c` `select_turn`): either way, a detent a page, in the order the family's button steps them, stopping at the first and the last (no wrap). GLO's MIXER, DELAY, REVERB, CHORUS and GLOBAL are one family (U3). The button still steps forward from wherever SELECT left you. On DRUM-X's SOUND sheet SELECT moves the knobs down the sheet first, then on to the page beside it.
- On HOME (no pages) SELECT still says BPM LOCKED; with a layer held it does nothing to the page under it. With BPM LOCK OFF, SELECT is the tempo everywhere, Felucca's way, except on DRUM-X's SOUND sheet, where nothing else reaches its rows (U1).
- **SELECT turns pages** (phase 8; `ui.c` `page_step`, `ui_input.c` `select_turn`): either way, a detent a page, in the order the family's button steps them, stopping at the first and the last (no wrap). GLO's MIXER, DELAY, REVERB, CHORUS and GLOBAL are one family (U3). The button still steps forward from wherever SELECT left you. On a sheet (DRUM-X's SOUND, FM6's OPERATOR and ALL OPS; `ui.c` `sheet_t`) SELECT moves the knobs down the sheet first, then on to the page beside it.
- On HOME (no pages) SELECT still says BPM LOCKED; with a layer held it does nothing to the page under it. With BPM LOCK OFF, SELECT is the tempo everywhere, Felucca's way, except on the sheets, where nothing else reaches their rows (U1).
4. **There is one modifier model: layers.** A button held for longer than the hold time (MENU > HOLD, every button's) shows its map, and SHIFT + the button keeps it open (U2: it was a double tap, which fast page flipping set off).
- HOME held is **SHIFT**. Held alone a moment, its map covers the panel under the page's cards (U5, the review's A1; `ui_layer.c` `draw_shift`): what every control does on this page, 4 rows of 3 cells as the layer maps, this page's own jobs in TEXT (STEP: PRESETS STEP, KEYS + REC STEPS, EDIT + REC CLEAR), the ones the same everywhere in MID, the SHIFT combos lit (+ SAVE TAKE, + REC REC SET, + BUTTON LOCK); the header's title says SHIFT, the footer LET GO: MENU. A combo ends it; HINTS OFF shows none.
- HOME held alone and then let go opens the MENU, on release, so it never races a combo.
@@ -242,6 +242,22 @@ Add a combo here before adding it to the code. Every SHIFT combo has to appear o
- **A kit edit isn't undoable,** as a knob turn isn't. **INIT SOUND** on a DRUM-X track puts the factory kit back too (the dialog says INITIALIZE SOUND? and the DRUM-X kit); SAVE held undoes both at once (`ui.c` `sound_init`, UNDO_KIT).
- Left out of JIANT's DRUM-X, for now: its group mutes, X-MOD (a tempo-synced LFO on MORPH), PUNCH and the dice. Features like these would come as one considered choice, not piecemeal. The SOUND pages' look may be revisited.
**FM6 LAB** (2026-10-13; `ui_fm6.c`; the user's pick of four mockups, `design/mock_fm6.py` direction D): every value of an FM6 patch on the unit, so a sound can be built from the bare sine and saved, without the web editor.
- **EDIT › OPERATOR and EDIT › ALL OPS** (after EDIT 2, FM6 tracks only): two sheets. PRESETS picks the operator (OP1 .. OP6, no sound is loaded; the header says OPERATOR 3), SELECT moves the knobs through five windows each, then on to the page beside it.
- OPERATOR: TONE (OUTPUT, RATIO, FINE, DETUNE), ENV 1 (RATE 1, LEVEL 1, RATE 2, LEVEL 2), ENV 2 (3 and 4), KEYS (L CURVE, L DEPTH, R DEPTH, R CURVE: the keys below BREAK on the left, above it on the right, as the chart), MORE (BREAK, KEY RATE, VELOCITY, LFO AMP).
- ALL OPS: ALGO (ALGO, FEEDBACK, TRANSP), PITCH 1 and PITCH 2 (the pitch envelope's rates and levels), LFO (WAVE, RATE in Hz, FADE, KEY SYNC), DEPTH (VIBRATO, VIB SENS, TREMOLO). OKS isn't there: the engine never reads it.
- **RATIO** is one knob over x0.5, x1 .. x31, then the fixed frequencies 1, 10, 100, 1K HZ (MODE); FINE shows the ratio or the Hz it makes (x14.00); DETUNE ±7; the curves -LIN -EXP +EXP +LIN; BREAK a note (MIDI 21 + it: C4 at 39); PITCH in semitones.
- **What plays:** ALGO and FEEDBACK show the patch through EDIT 1's ALGO and FEEDBACK, and a turn puts that into the patch with the macro back to neutral (PAT, 0). The other macros (MOD LVL, RATIO, MOD ENV, VEL MOD, DETUNE) stay offsets over several operators.
- A knob edits a copy of the patch, then `fm6_set_patch` and `fm6_adopt`: SLOT turns OWN (or the factory patch it now equals), so PATCH never loads over an edit. Some values sound from the next note (OUTPUT, the ratios, the scaling); the rates and levels from the next stage. A patch edit isn't undoable, as a knob turn isn't.
- **The panel** (after an idea in a video by Floyd Steinberg, drawn our own way): every operator's envelope as the engine runs it (`fm6_op_env_init`; the macros through `fm6_macro`, as the audio's copy), a note of MIDI 60 at velocity 100, straight between its breakpoints on a log time axis (the held note, a dotted key up, the release), so a 1 ms attack and a 4 s decay both show.
- **Brightness:** each carrier is a thick line, shaded along its length in 12 steps from cool blue (a sine) to REC's red (FM's bite): the strongest modulator feeding it at that moment, its level over its top 60 dB, square-rooted (a little FM is heard at once), the feedback counted as FB / 7 of its operator. (Steinberg averages the modulators; with six operators and several carriers an average dulls a bright pair.) The caption says where it bites most (BRIGHTEST 12 MS, a mark under it) or PURE SINE, the length, and the key: SINE, the ramp, FM. Colour is never the only cue.
- The modulators are thin lines in their own colours (the palette's six), the one picked brighter; the picked operator's breakpoints are rings, the one the knob just turned filled. Tabs OP1 .. OP6 above, the picked one outlined; under each its line's colour (a carrier's the ramp); on TONE each with its ratio.
- KEYS and MORE: the picked operator's level across the keyboard (MIDI 21 .. 108, 0 to -48 dB), BREAK a dotted line with its note, C4 a dot. ALGO: the algorithm chart with the picked operator lit, and what it does (OP4 MODULATES OP3, GOES TO THE OUTPUT, IS SILENT). PITCH: the pitch envelope over the note, the sound's outline behind. LFO and DEPTH: two seconds of vibrato from the key, FADE bringing it in, the tremolo under it.
- The simulation runs only when what it draws changes (`fm_sig`), at most a few ms.
- **In the themes of their own** (FM6 LAB T, 2026-10-13): CRYPT's fire (the ramp ash, blood, ember, gold, flame; square chunky strokes; skulls for handles, the one turned aflame; a flame where it bites; stone tabs, the picked one gold-framed; the ASCII shade under the sound; KEYS' BREAK a dagger; the vibrato a snake), NEON's night to sunset (cyan, violet, pink, orange, yellow; tubes and their glow; sparkles; a laser where it bites; the striped sun and the grid behind; glass tabs, a laser frame; the sun's bands under KEYS, PITCH and LFO; BREAK a laser), QUARK's energy (dim cyan, cyan, white, gold; the modulators a bubble chamber's dotted tracks in the colour charges; nuclei; a collision where it bites; a Monte Carlo fill under the sound; a cell's brackets on the tabs). ALGO's picked operator: a gold frame, a laser, brackets. SKIFF, HI-CON and PAPER as drawn above.
- **INIT SOUND** on an FM6 track is the bare sine to build from: `FM6_INIT` (OP1 alone, ALG 1), SLOT OWN, the macros at 0; SAVE held undoes it. An FM6 track on its own patch shows the patch's name (INIT VOICE) where the sound's name goes.
- **Saved as a sound** (SAVE › USER): the user sound keeps the whole patch, as before (`up_fm6.c`); a name typed for it goes into the patch's own name too (its first 10 letters), so a `.syx` from the web editor carries it. The automatic name and a factory patch (F n) leave it alone.
**Factory presets for the themes** (2026-10-11): ten sounds each for CRYPT (dungeon synth), NEON (synthwave) and QUARK (particles), added at the end of their engines' lists, so every earlier preset keeps its number.
- CRYPT: CRYPT CHOIR, MONK CHANT, CATHEDRAL, HARPSICHORD, BONE FLUTE, WAR HORN, GRAVE BELL, DARK STRINGS, WAR DRUMS, CAVE WIND.
- NEON: NIGHT BASS, NEON LEAD, SUNSET PAD, HERO BRASS, GLASS KEYS, TURBO SYNC, NEON ARP, DREAM CHOIR, NEON KIT, SYN TOM.
@@ -320,7 +336,7 @@ The colours differ in lightness as well as hue, and always appear with the track
- **MENU > SYSTEM > RESET SETTINGS** (U4, A3): its dialog on the page under the MENU, then every MENU setting as a new unit has it (Skiff's palette, BPM LOCK ON, CLOCK INT, MIDI IN CH1-6, TUNE 0, HINTS ON ..); the calibration, the favourites and the music stay.
- **One word for one thing** (U4, the review's L1–L3; `params.c` TP / GP, the engines' rows, the cards' own words): spelled out where the card has room (Barlow Condensed fits 8 letters), the vocabulary of the review's appendix: LEVEL, ATTACK DECAY SUSTAIN RELEASE, CUTOFF PITCH SHAPE (ENV and LFO DEST), PHASE, OCTAVE, SWING, CHANCE, ORDER, SCALE, QUANTIZE, TRANSP, LENGTH, DIST CHORUS DELAY REVERB, VOICE GLIDE GL MODE PRIORITY DETUNE, SLICER PATTERN, CHORD VOICING, CLOCK FEEDBACK COLOR ROUTE ENGINE; on the engines DETUNE, NOISE, CUTOFF, DRIVE, KEYTRK, CRUSH, SWEEP, VIBRATO, VOWEL, BREATH, RANDOM, PITCH (every semitone pitch: SAMPLE's and the drums' TUNE, VOICE's SHIFT, TRIO's PITCH2 PITCH3), SOURCE, DENSITY, SPREAD, STRUCT, BRIGHT, ACCENT, EXCITE, DRIFT, ALGO, MOD LVL, RATIO, MOD ENV, VEL MOD, PATCH (FM6's SLOT), MORPH, COLOR (DRUM-X's TONE, its sheet's COLR); the cards VELOCITY, CHANCE, RATCHET, SOURCE DEST AMOUNT (MOD). One name, one meaning (L2): DEST for a destination (DST was distortion too), RVRS for reverse (REV is reverb: SLICE's, the play direction's), PLAYED for the arp's order as played. The lanes CL HAT and OP HAT in full, BD SD CH OH on the grid. AUTOMATION's PARAM card shows ENV or LFO on its label's line (ENV ATTACK). The web editor's library files keyed by the labels of before (LVL ATK ..) still load: `legacyKeys` takes them to today's by id.
- **Messages say the way out** (U4, the review's F3, L6): a refusal names what to do, on the header's second line where it needs one (`ui.c` `ui_way`): PATTERNS FULL, then SAVE > PATTERNS: CLEAR; AUTOMATION FULL, then AUTOMATION: DELETE ONE; BPM LOCKED, then GLO + SELECT: TEMPO; PLAY ONE LOOP FIRST, DISARM REC FOR A TAKE, NOTHING BEFORE TO JOIN, STOP TO ERASE / RENAME / SAVE as it is. Musicians' words for developers': CLOCK IS EXTERNAL, SLICES NOW MANUAL, PICK A USR SAMPLE FIRST, SAVED UNTIL POWER OFF (no flash), STORAGE ERROR, UPDATE MODE, KEYS RECORD LANES, HOLD [GLO]: SHORTCUTS, UNDONE: SEQUENCE / MIX / SCALE / REC, PATTERN 06 CLEARED, SOUND INITIALIZED. After a crash the session is not restored on purpose, and the boot says SESSION NOT RESTORED. MIDI IN into a track not selected marks its number on HOME for 0.4 s (was a header message every 4 s, covering the title). Values show up to 7 letters (SPRING, MELLOW; were cut at 5), the card falling to M, then S, where V is too wide. AUTOMATION names a lane as its kit plays it (CONGA). The REC layer says CLICK, COUNT-IN, CLICK LVL as MENU > AUDIO does; GLOBAL's swing is SWING+ (it adds to PATTERN's SWG).
- **Every page has a graph of its own** (U5, the review's V1; `ui_pgraph.c`, design/mock_u5.py): ENV DEST the ENV page's envelope scaled by each amount around a zero line; LFO DEST the LFO's wave a row a destination, as tall as its amount, a dot where it is now; DELAY the dry hit and an echo every TIME, the first MIX high, each next FEEDBACK lower (`fx.c`), over the bar's beats; REVERB the first reflections and the tail SIZE long, its top dimmed by DAMP, SPRING's coil; CHORUS the dry line and its drifting copy (one modulated delay); GLOBAL a bar's 16 steps, the off steps late by SWING+ over where they would be, the long:short share; VOICE what the mode does and the GLIDE between two notes; VOICE 2 the engine's voices, those sounding lit, the next one outlined (POLY, ROT), DETUNE's UNI spread; ANALOG's OSC the wave and its detuned second, FLT the low pass's curve, its peak at CUTOFF as high as RES; ARP and ARP 2 one graph, the arp's notes over 16 steps from the notes held (else C E G, said), GATE a tile's length, SWING, the steps CHANCE skips outlined. Of a page's curves the knob just turned (else the biggest amount) is the track's colour, the others MID, a zero one DIM. The other engines' EDIT pages keep their charts (FM6, WHEEL, SAMPLE) or the output's scope.
- **Every page has a graph of its own** (U5, the review's V1; `ui_pgraph.c`, design/mock_u5.py): ENV DEST the ENV page's envelope scaled by each amount around a zero line; LFO DEST the LFO's wave a row a destination, as tall as its amount, a dot where it is now; DELAY the dry hit and an echo every TIME, the first MIX high, each next FEEDBACK lower (`fx.c`), over the bar's beats; REVERB the first reflections and the tail SIZE long, its top dimmed by DAMP, SPRING's coil; CHORUS the dry line and its drifting copy (one modulated delay); GLOBAL a bar's 16 steps, the off steps late by SWING+ over where they would be, the long:short share; VOICE what the mode does and the GLIDE between two notes; VOICE 2 the engine's voices, those sounding lit, the next one outlined (POLY, ROT), DETUNE's UNI spread; ANALOG's OSC the wave and its detuned second, FLT the low pass's curve, its peak at CUTOFF as high as RES; ARP and ARP 2 one graph, the arp's notes over 16 steps from the notes held (else C E G, said), GATE a tile's length, SWING, the steps CHANCE skips outlined. Of a page's curves the knob just turned (else the biggest amount) is the track's colour, the others MID, a zero one DIM. The other engines' EDIT pages keep their charts (FM6, WHEEL, SAMPLE) or the output's scope; FM6's OPERATOR and ALL OPS draw the note as the engine plays it (FM6 LAB, below).
- **The page families** (U3, the review's structure; `params.c` `PAGES`, `ui.c` `page_visible`):
- FX holds the track's effects (FX, SLICER, DUCK). The buses every track shares are GLO's, after MIXER: DELAY, REVERB (TYPE SIZE DAMP), CHORUS (RATE DEPTH, were CRT CDP), then GLOBAL (BPM, SWING). Its footer counts the five as one (MIXER 1/5).
- SEQ goes by task: STEP, ROLL, CHANCE, PLAY, PATTERN, AUTOMATION, SONG last. On a drum track STEP is the grid and ROLL is not there.
+35 -8
View File
@@ -19,7 +19,9 @@ synths and drums, patterns and songs, live performance, and a screen that shows
Skiff turns the FM-1 into a six-track groovebox: fourteen synth and drum engines, a 64-step sequencer with chords,
ratchets, trig conditions and parameter locks, a shared pool of patterns played through per-track lists and scenes,
and a performance layer for launching it all live. Every page draws what its knobs do, and holding HOME shows what
every button, encoder and key does right there. A browser editor reaches all of it from a computer.
every button, encoder and key does right there. FM6 sounds can be built from a bare sine on the unit itself, every
operator's envelope drawn as it plays and coloured by how bright the FM makes it. A browser editor reaches all of it
from a computer.
Skiff is free software, a fork of [Felucca](https://github.com/hugelton/Felucca) 1.1.5 by Hügelton Instruments: it
keeps Felucca's engines, sound and file formats, so Felucca's sounds and projects load in Skiff. Skiff is not
@@ -33,12 +35,12 @@ Custom firmware, at your own risk; the way back to the official firmware is belo
connect the FM-1 by USB and follow it. The same page takes the FM-1 back to the official V15 firmware, saving a
complete backup of your music first.
**With Python 3:** download `skiff-1.0.fwsc` from the [latest release](https://github.com/illuminus5/skiff/releases/latest)
**With Python 3:** download `skiff-1.1.fwsc` from the [latest release](https://github.com/illuminus5/skiff/releases/latest)
and, with this repository's `tools/` folder,
```
pip install mido python-rtmidi
python tools/fm1_install.py skiff-1.0.fwsc
python tools/fm1_install.py skiff-1.1.fwsc
```
It takes about two minutes and the FM-1 restarts on Skiff.
@@ -52,7 +54,7 @@ Edge, over USB MIDI).
| | |
| --- | --- |
| **Tracks** | 6, each with its own engine, sound, sequence and mix; 8 voices shared between them (T5 and T6 play every engine but PHYS and GRAIN) |
| **Engines** | 14: ANALOG, FM6, PHASE, LOFI, SAMPLE, VOICE, TRIO, WHEEL, GRAIN, PHYS, NOISE, SLICE, DRUM, DRUM-X; 100 factory sounds |
| **Engines** | 14: ANALOG, FM6, PHASE, LOFI, SAMPLE, VOICE, TRIO, WHEEL, GRAIN, PHYS, NOISE, SLICE, DRUM, DRUM-X; 100 factory sounds; every value of an FM6 patch (6 operators, 32 algorithms) editable on the unit |
| **Sequencer** | 64 steps a track; LENGTH 1–64; 1/1 to 1/32, triplets, 2 and 4 bars a step; chords of up to 4 notes, velocity, accent, slide, tie; per-step chance, ratchet ×1–4 or FLAM, 12 trig conditions (FILL, !FILL, 1:2 … 4:4), NUDGE (−32 to +31 64ths of a step); swing, gate; FWD, RVRS, PING or RAND |
| **Recording** | live with overdub, FEEL (keeps where you played), count-in and click; step recording; TAKE keeps the last loop you played, after the fact |
| **Automation** | knob moves and parameter locks (hold a step, turn a knob), 64 records, listed and edited on SEQ › AUTOMATION |
@@ -98,6 +100,25 @@ Edge, over USB MIDI).
</tr>
</table>
### FM6 from scratch
EDIT › OPERATOR and ALL OPS put every value of an FM6 patch on the unit's knobs: PRESETS picks the operator, SELECT
its ratio, envelope, keyboard scaling, the algorithm, the pitch envelope and the LFO. INIT starts from a bare sine, and
SAVE › USER keeps the result as a sound of its own. The graph, after an idea by Floyd Steinberg, is the note as the
engine plays it: every operator's envelope, each carrier coloured along its length from cool (a sine) to hot (where
the modulators make it bite).
<table>
<tr>
<td width="25%"><img src="docs/img/fm_op_tone.png" alt="EDIT › OPERATOR, TONE"><br><sub><b>OPERATOR</b>: OP4's ratio; the carriers hot where it bites</sub></td>
<td width="25%"><img src="docs/img/fm_op_env.png" alt="EDIT › OPERATOR, ENV 1"><br><sub><b>ENV</b>: the stage being turned, a filled handle</sub></td>
<td width="25%"><img src="docs/img/fm_op_keys.png" alt="EDIT › OPERATOR, KEYS"><br><sub><b>KEYS</b>: the level across the keyboard</sub></td>
<td width="25%"><img src="docs/img/fm_all_lfo.png" alt="EDIT › ALL OPS, LFO"><br><sub><b>ALL OPS</b>: the LFO's vibrato fading in</sub></td>
</tr>
</table>
![OPERATOR in CRYPT, NEON and QUARK](docs/img/fm6_themes.png)
### Sound: every page draws what it does
<table>
@@ -152,6 +173,9 @@ FM6 patches from `.syx` files and saves complete backups.
- **Six tracks**, each its own engine and sound; 8 voices shared between them. T5 and T6 play every engine but
PHYS and GRAIN. ALGORITHM selects the track on every page; HOME, PERFORM, SONG and the MIXER show all six
- **Fourteen engines** (below), DRUM-X among them, each with its own factory presets
- **FM6 from scratch** (1.1): every value of an FM6 patch on the unit (EDIT › OPERATOR and ALL OPS), INIT a bare
sine, the sound saved as a user sound; the operators' envelopes drawn as they play, each carrier shaded by its
brightness, in every theme's own look
- **Every page shows what it does:** the four knobs as cards across the top, and a graph of the page below:
the envelope, the LFO per destination, the delay's echoes, the reverb's tail, the swing grid, the glide,
the oscillator and filter, the arpeggio. Hold **HOME** (SHIFT) and a map shows what every button, encoder
@@ -238,9 +262,11 @@ by the keys, with what each key is in Skiff.
In the order the device lists them:
- **ANALOG**: virtual analog; two oscillators, noise, drive, resonant low-pass filter
- **FM6**: classic 6-operator FM (Dexed-based): 32 algorithms, a full patch per track edited in the
web editor (which imports .syx files), macros on the device, an algorithm chart on screen; SLOT
picks a factory patch (F1–F8) or the track's own (OWN)
- **FM6**: classic 6-operator FM (Dexed-based): 32 algorithms, a full patch per track, every value of it
editable on the device (EDIT › OPERATOR and ALL OPS: the operators' envelopes drawn as they play, each
carrier shaded by how bright the modulators make it) or in the web editor (which imports .syx files);
INIT starts from a bare sine; macros on the device, an algorithm chart; SLOT picks a factory patch
(F1–F8) or the track's own (OWN)
- **PHASE**: phase distortion (ported from CrispyZebra)
- **LOFI**: chiptune; pulse, triangle, saw, noise and a 4-bit wave RAM, stepped envelope, sweep, arpeggio
- **SAMPLE**: multisampled instruments and 3 user sample slots
@@ -311,7 +337,8 @@ every setting back as a new unit has it. The web editor's Settings tab reads and
jump. ON or OFF, every click of a fast turn counts
- **BPM LOCK:** ON (default), SELECT turns the pages of a family; hold GLO and turn SELECT, tap F4 in the GLO
layer or use GLO › GLOBAL for the tempo. OFF, SELECT is the tempo everywhere, Felucca's way. Skiff turns it
ON once on a unit coming from Felucca; DRUM-X's SOUND sheet moves its rows with SELECT either way
ON once on a unit coming from Felucca; DRUM-X's SOUND sheet and FM6's OPERATOR and ALL OPS move their rows with
SELECT either way
- **SCALE LEDS:** OFF or ON: the keys show the selected track's scale all the time (the root a little
brighter); not on DRUM or SLICE tracks
- **CLOCK:** INT, USB or TRS, where the tempo comes from. **MIDI IN:** CH1-6, channels 1–6 play tracks 1–6,
+889
View File
@@ -0,0 +1,889 @@
#!/usr/bin/env python3
"""FM6 LAB mockups: every value of an FM6 patch on the unit, and a sound built from the bare sine (plan 2026-10-13).
Two FM6-only EDIT pages after EDIT 2, drawn in BLOCKS (SKIFF) on track 1:
OPERATOR PRESETS picks OP1..OP6; SELECT moves the four knobs: TONE, ENV 1, ENV 2, KEYS, MORE
ALL OPS ALGO, PITCH 1, PITCH 2, LFO, DEPTH
The centrepiece is after an idea in a video by Floyd Steinberg (drawn our own way): the sound over time is the carriers'
envelope, each moment shaded cool -> hot by how hard the modulators drive them (a sine is cold, FM's bite hot), every
operator's envelope behind it. The curves are the engine's: msfa's envelope, pitch envelope and LFO as fm6_core.c runs
them (a Python port below), the patches tools/gen_fm6_patches.py's. Three directions:
A HEAT operator tabs + the brightness envelope, full height; the ramp cool blue -> REC red
B HEAT + LENS the same, shorter, over a strip that explains the window: the ratios on a ruler, the stages
numbered under their time, the keyboard
C TRACK HEAT A's layout; the ramp is the track's colour, dark -> full -> white-hot
Starts from the firmware's renders (tests/ui_render.c, SKIFF: P6_RENDERS); FM6_GEN: build/gen (the LFO table).
P6_RENDERS=~/skiff-fm6-ui/build/ui_new/ppm FM6_GEN=~/skiff-fm6-ui/build/gen python3 mock_fm6.py
Writes out/FM6<dir>_<screen>.png (1x, x2, x3) and mockups/fm6_sheet.png.
"""
import math
import os
import re
import sys
from pathlib import Path
from PIL import Image, ImageDraw
import mock
import mock_u3 as u3
from mock import OUT, W, H, mix, HERE
sys.path.insert(0, str(HERE.parent / "tools"))
import gen_fm6_patches as G # noqa: E402
GEN = Path(os.path.expanduser(os.environ.get("FM6_GEN", str(HERE.parent / "build" / "gen"))))
# ---------------------------------------------------------------- the engine (fm6_core.c), as it runs
FS, N = 44100, 32
BPS = FS / N # envelope steps a second
R1, L1, BP, LD, RD, LC, RC, RS, AMS, KVS, OL, MODE, FC, FF, DET = 0, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
PR1, PL1 = 126, 130
ALG, FB, OKS, LFS, LFD, LPMD, LAMD, LKS, LFW, LPMS, TRNSP = range(134, 145)
LEVELLUT = [0, 5, 9, 13, 17, 20, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 42, 43, 45, 46]
STATICS = [1764000, 1764000, 1411200, 1411200, 1190700, 1014300, 992250, 882000, 705600, 705600, 584325, 507150,
502740, 441000, 418950, 352800, 308700, 286650, 253575, 220500, 220500, 176400, 145530, 145530, 125685,
110250, 110250, 88200, 88200, 74970, 61740, 61740, 55125, 48510, 44100, 37485, 31311, 30870, 27562, 27562,
22050, 18522, 17640, 15435, 14112, 13230, 11025, 9261, 9261, 7717, 6615, 6615, 5512, 5512, 4410, 3969, 3969,
3439, 2866, 2690, 2249, 1984, 1896, 1808, 1411, 1367, 1234, 1146, 926, 837, 837, 705, 573, 573, 529, 441, 441]
PENV_RATE = [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 16, 17, 18,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 33, 34, 36, 37, 38, 39, 41, 42, 44, 46, 47, 49, 51, 53,
54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 79, 82, 85, 88, 91, 94, 98, 102, 106, 110, 115, 120, 125,
130, 135, 141, 147, 153, 159, 165, 171, 178, 185, 193, 202, 211, 232, 243, 254, 255]
PENV_TAB = [-128, -116, -104, -95, -85, -76, -68, -61, -56, -52, -49, -46, -43, -41, -39, -37, -35, -33, -32, -31, -30,
-29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8,
-7, -6, -5, -4, -3, -2, -1, 0, 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, 33, 34, 35, 38, 40, 43, 46, 49, 53, 58, 65, 73, 82, 92, 103, 115,
127]
PENV_UNIT, LFO_UNIT = 572, 18279
VELDATA = [0, 70, 86, 97, 106, 114, 121, 126, 132, 138, 142, 148, 152, 156, 160, 163, 166, 170, 173, 174, 178, 181, 184,
186, 189, 190, 194, 196, 198, 200, 202, 205, 206, 209, 211, 214, 216, 218, 220, 222, 224, 225, 227, 229, 230,
232, 233, 235, 237, 238, 240, 241, 242, 243, 244, 246, 246, 248, 249, 250, 251, 252, 253, 254]
EXPSCALE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 14, 16, 19, 23, 27, 33, 39, 47, 56, 66, 80, 94, 110, 126, 142, 158, 174,
190, 206, 222, 238, 250]
PMS = [0, 10, 20, 33, 55, 92, 153, 255]
ALGS = [[0xc1, 0x11, 0x11, 0x14, 0x01, 0x14], [0x01, 0x11, 0x11, 0x14, 0xc1, 0x14], [0xc1, 0x11, 0x14, 0x01, 0x11, 0x14],
[0xc1, 0x11, 0x94, 0x01, 0x11, 0x14], [0xc1, 0x14, 0x01, 0x14, 0x01, 0x14], [0xc1, 0x94, 0x01, 0x14, 0x01, 0x14],
[0xc1, 0x11, 0x05, 0x14, 0x01, 0x14], [0x01, 0x11, 0xc5, 0x14, 0x01, 0x14], [0x01, 0x11, 0x05, 0x14, 0xc1, 0x14],
[0x01, 0x05, 0x14, 0xc1, 0x11, 0x14], [0xc1, 0x05, 0x14, 0x01, 0x11, 0x14], [0x01, 0x05, 0x05, 0x14, 0xc1, 0x14],
[0xc1, 0x05, 0x05, 0x14, 0x01, 0x14], [0xc1, 0x05, 0x11, 0x14, 0x01, 0x14], [0x01, 0x05, 0x11, 0x14, 0xc1, 0x14],
[0xc1, 0x11, 0x02, 0x25, 0x05, 0x14], [0x01, 0x11, 0x02, 0x25, 0xc5, 0x14], [0x01, 0x11, 0x11, 0xc5, 0x05, 0x14],
[0xc1, 0x14, 0x14, 0x01, 0x11, 0x14], [0x01, 0x05, 0x14, 0xc1, 0x14, 0x14], [0x01, 0x14, 0x14, 0xc1, 0x14, 0x14],
[0xc1, 0x14, 0x14, 0x14, 0x01, 0x14], [0xc1, 0x14, 0x14, 0x01, 0x14, 0x04], [0xc1, 0x14, 0x14, 0x14, 0x04, 0x04],
[0xc1, 0x14, 0x14, 0x04, 0x04, 0x04], [0xc1, 0x05, 0x14, 0x01, 0x14, 0x04], [0x01, 0x05, 0x14, 0xc1, 0x14, 0x04],
[0x04, 0xc1, 0x11, 0x14, 0x01, 0x14], [0xc1, 0x14, 0x01, 0x14, 0x04, 0x04], [0x04, 0xc1, 0x11, 0x14, 0x04, 0x04],
[0xc1, 0x14, 0x04, 0x04, 0x04, 0x04], [0xc4, 0x04, 0x04, 0x04, 0x04, 0x04]]
def lfo_delta():
try:
t = (GEN / "felucca_tables.h").read_text()
body = t[t.index("FM6_LFO_DELTA[100]"):]
return [int(x) for x in re.findall(r"\d+", body[body.index("{"):body.index("}")])]
except (OSError, ValueError): # (no build: msfa's curve, near enough for a picture)
return [round(2 ** 32 / BPS * 0.062 * 1.0657 ** i) for i in range(100)]
LFO_DELTA = lfo_delta()
def scaleout(ol):
return 28 + ol if ol >= 20 else LEVELLUT[max(ol, 0)]
def scale_vel(vel, sens):
return ((sens * (VELDATA[max(0, min(127, vel)) >> 1] - 239) + 7) >> 3) << 4
def scale_rate(note, sens):
return (sens * max(0, min(31, note // 3 - 7))) >> 3
def scale_curve(group, depth, curve):
s = (group * depth * 329) >> 12 if curve in (0, 3) else (EXPSCALE[min(group, 32)] * depth * 329) >> 15
return -s if curve < 2 else s
def scale_level(note, op):
off = note - op[BP] - 17
return scale_curve((off + 1) // 3, op[RD], op[RC]) if off >= 0 else scale_curve(-(off - 1) // 3, op[LD], op[LC])
class Env: # fm6_env_t: fm6_env_init / advance / get / key
def __init__(s, op, outlevel, rscale):
s.op, s.outlevel, s.rscale, s.level, s.down = op, outlevel, rscale, 0, 1
s.advance(0)
def advance(s, ix):
s.ix = ix
if ix >= 4:
return
lv = s.op[L1 + ix]
actual = max(((scaleout(lv) >> 1) << 6) + s.outlevel - 4256, 16)
s.target = actual << 16
s.rising = s.target > s.level
qrate = min(((s.op[R1 + ix] * 41) >> 6) + s.rscale, 63)
if s.target == s.level or (ix == 0 and lv == 0):
sr = min(s.op[R1 + ix] + s.rscale, 99)
s.statc = STATICS[sr] if sr < 77 else 20 * (99 - sr)
if sr < 77 and ix == 0 and lv == 0:
s.statc //= 20
else:
s.statc = 0
s.inc = (4 + (qrate & 3)) << (2 + 5 + (qrate >> 2))
def get(s):
if s.statc:
s.statc -= N
if s.statc <= 0:
s.statc = 0
s.advance(s.ix + 1)
if s.ix < 3 or (s.ix < 4 and not s.down):
if s.statc:
pass
elif s.rising:
s.level = max(s.level, 1716 << 16)
s.level += (((17 << 24) - s.level) >> 24) * s.inc
if s.level >= s.target:
s.level = s.target
s.advance(s.ix + 1)
else:
s.level -= s.inc
if s.level <= s.target:
s.level = s.target
s.advance(s.ix + 1)
return s.level
def key(s, down):
if s.down != down:
s.down = down
s.advance(0 if down else 3)
class PEnv: # fm6_penv_t
def __init__(s, p):
s.p, s.level, s.down = p, PENV_TAB[p[PL1 + 3] % 100] << 19, 1
s.advance(0)
def advance(s, ix):
s.ix = ix
if ix < 4:
s.target = PENV_TAB[s.p[PL1 + ix] % 100] << 19
s.rising = s.target > s.level
s.inc = PENV_RATE[s.p[PR1 + ix] % 100] * PENV_UNIT
def get(s):
if s.ix < 3 or (s.ix < 4 and not s.down):
s.level += s.inc if s.rising else -s.inc
if (s.rising and s.level >= s.target) or (not s.rising and s.level <= s.target):
s.level = s.target
s.advance(s.ix + 1)
return s.level
def key(s, down):
if s.down != down:
s.down = down
s.advance(0 if down else 3)
class Lfo: # fm6_lfo_t (sine and triangle are all the mockups need)
def __init__(s, p):
a = 99 - p[LFD] % 100
s.delta, s.wave, s.dstate = LFO_DELTA[p[LFS] % 100], p[LFW], 0
s.phase = (1 << 31) - 1 if p[LKS] else 0
if a == 99:
s.dinc = s.dinc2 = 2 ** 32 - 1
else:
a = (16 + (a & 15)) << (1 + (a >> 4))
s.dinc = LFO_UNIT * a
s.dinc2 = LFO_UNIT * max(a & 0xff80, 0x80)
def sample(s):
s.phase = (s.phase + s.delta) & 0xFFFFFFFF
if s.wave == 4:
return 0.5 + 0.5 * math.sin(2 * math.pi * s.phase / 2 ** 32)
x = s.phase / 2 ** 32
return 2 * x if x < 0.5 else 2 - 2 * x
def delay(s):
d = s.dinc if s.dstate < 2 ** 31 else s.dinc2
n = s.dstate + d
if n >= 2 ** 32:
return 1.0
s.dstate = n
return 0.0 if n < 2 ** 31 else ((n >> 7) & ((1 << 24) - 1)) / (1 << 24)
def carriers(alg):
"""per operator 1..6: a carrier of algorithm alg (1..32)"""
return [not (ALGS[alg - 1][5 - k] & 3) for k in range(6)]
def fb_op(alg):
return next((k for k in range(6) if ALGS[alg - 1][5 - k] & 0xC0 == 0xC0), 5)
def op_bytes(p, k): # operator k + 1's 21 bytes (the sixth first in the patch)
return p[(5 - k) * 21:(6 - k) * 21]
TOP, SPAN, HSPAN = 15 << 24, 10 << 24, 10 << 24 # full scale; the 60 dB shown; the modulators' 60 dB of heat
def run(p, note=60, vel=100, held=None, rel=None):
"""the note as the engine plays it: per step every operator's level (Q24 log2), the pitch envelope (semitones), the
LFO's vibrato (semitones); the key up at step `held`. held/rel None: found (every carrier at its sustain, cap 4 s;
the release until the carriers fall below the 60 dB shown, cap 2 s)"""
note += p[TRNSP] - 24
car = carriers(p[ALG] + 1)
env = []
for k in range(6):
op = op_bytes(p, k)
ol = (min(scaleout(op[OL]) + scale_level(note, op), 127) << 5) + scale_vel(vel, op[KVS])
env.append(Env(op, max(ol, 0), scale_rate(note, op[RS])))
pe, lfo = PEnv(p), Lfo(p)
cap = held if held is not None else int(4 * BPS)
lv, pitch, vib, stage, n = [[] for _ in range(6)], [], [], [], 0
while True:
if n == cap:
for e in env:
e.key(0)
pe.key(0)
for k in range(6):
lv[k].append(env[k].get())
stage.append([e.ix for e in env])
pitch.append(pe.get() / (1 << 24) * 12)
d = lfo.delay()
s = lfo.sample()
pmd = (p[LPMD] % 100) * 165 >> 6
vib.append(pmd * d * PMS[p[LPMS] & 7] * (s - 0.5) / 2 ** 15 * 12) # (Q24 octaves: the >> 39)
n += 1
if held is None and n < cap and all(env[k].ix >= 3 for k in range(6) if car[k]):
return run(p, note - p[TRNSP] + 24, vel, max(n + int(n / 4), int(0.35 * BPS)), rel)
if n > cap and (n - cap >= (rel or int(2 * BPS)) or
(rel is None and all(lv[k][-1] < TOP - SPAN for k in range(6) if car[k]))):
break
return dict(lv=lv, pitch=pitch, vib=vib, stage=stage, held=cap, n=n, car=car)
def heat(p, r, i):
"""0..1: how hard the modulators drive the carriers at step i: the strongest modulator's level over its top 60 dB
(the feedback one more, scaled by FB / 7). (Steinberg averages the modulators: with six operators and several
carriers an average dulls a bright pair beside quiet ones, so the strongest one rules here)"""
car, terms = r["car"], []
for k in range(6):
if not car[k] and op_bytes(p, k)[OL]:
terms.append(max(0.0, min(1.0, (r["lv"][k][i] - (TOP - HSPAN)) / HSPAN)))
if p[FB]:
k = fb_op(p[ALG] + 1)
terms.append(p[FB] / 7 * max(0.0, min(1.0, (r["lv"][k][i] - (TOP - HSPAN)) / HSPAN)))
return math.sqrt(max(terms)) if terms else 0.0 # (the square root: a little FM is already heard)
def routes(alg):
"""m[k]: the operators (bit j: operator j + 1) that modulate operator k + 1 (ui_graph.c fm6_routes)"""
f, bus, m = ALGS[alg - 1], [0, 0, 0, 0], [0] * 6
for k in range(6):
op, inn, o = 5 - k, (f[k] >> 4) & 3, f[k] & 3
m[op] = bus[inn] if inn else 0
bus[o] = (bus[o] if f[k] & 4 else 0) | 1 << op
return m
def feeders(alg, c):
m, seen, todo = routes(alg), 0, [c]
while todo:
k = todo.pop()
new = m[k] & ~seen
seen |= new
todo += [j for j in range(6) if new >> j & 1]
return seen
def heat_of(p, r, i, c):
"""D: carrier c's own heat: the strongest of the modulators feeding it (the feedback if its operator is among
them or c itself)"""
terms, f = [], feeders(p[ALG] + 1, c)
for k in range(6):
if f >> k & 1 and op_bytes(p, k)[OL]:
terms.append(max(0.0, min(1.0, (r["lv"][k][i] - (TOP - HSPAN)) / HSPAN)))
k = fb_op(p[ALG] + 1)
if p[FB] and (f >> k & 1 or k == c):
terms.append(p[FB] / 7 * max(0.0, min(1.0, (r["lv"][k][i] - (TOP - HSPAN)) / HSPAN)))
return math.sqrt(max(terms)) if terms else 0.0 # (the square root: a little FM is already heard)
def loud(r, i):
return max(r["lv"][k][i] for k in range(6) if r["car"][k])
# ---------------------------------------------------------------- the patches
def patch(name):
if name == "INIT VOICE":
return list(G.INIT)
return list(next(v for n, v in G.PATCHES if v[145:155] == [ord(c) for c in name.ljust(10)] or n == name))
TINE = patch("TINE EP")
KEYS = list(TINE) # OP2 played softer up the keyboard (the mock's edit)
KEYS[(5 - 1) * 21 + RD], KEYS[(5 - 1) * 21 + RC] = 40, 0
BRASS, INIT = patch("BRASS"), patch("INIT VOICE")
# ---------------------------------------------------------------- the screen
BLUE = (40, 92, 232)
TRK0 = mock.hexc("#FF5A36")
def ramp(s, d, t1=TRK0):
"""the 12 shades, cold to hot"""
if d == "C":
lo = mix(s.c["surf"], t1, 0.3)
return [mix(lo, t1, i / 6) if i <= 6 else mix(t1, (255, 255, 255), (i - 6) / 5 * 0.85) for i in range(12)]
cold = mix(s.c["surf"], BLUE, 0.6 if d != "D" else 0.8)
return [mix(cold, s.c["rec"], i / 11) for i in range(12)]
def base(title, cards, hot, name="TINE EP", right="SELECT: ROWS"):
s = u3.kit("SKIFF_edit_fm6")
s.c["rec"] = (255, 72, 72)
u3.title(s, title)
u3.cards(s, [it or ("", "", "", None) for it in cards], hot)
s.box(0, 74, 239, 216, fill=s.c["bg"])
s.box(3, 76, 236, 213, fill=s.c["surf"])
s.box(0, 218, 239, 239, fill=s.c["bg"])
s.text((5, 236), "1", "val", s.trk[0])
s.text((21, 234), "FM6", "lab", "text")
s.text((21 + s.tw("FM6", "lab") + 7, 234), name, "lab", "text")
s.text((235, 234), right, "lab", "mid", anchor="rs")
return s
def raise_(s):
return mix(s.c["surf"], s.c["text"], 0.12)
def ratio_txt(op):
if op[MODE]:
return ("1", "10", "100", "1K")[op[FC] & 3]
return "0.5" if op[FC] == 0 else str(op[FC])
def tabs(s, p, sel, y=80, h=17, ratios=False):
car = carriers(p[ALG] + 1)
for k in range(6):
x = 8 + k * 38
op = op_bytes(p, k)
on = k == sel
fill = s.trk[0] if on else raise_(s)
s.box(x, y, x + 33, y + h - 1, fill=fill)
ink = s.c["ink"] if on else (s.c["dim"] if not op[OL] else s.c["text"])
if ratios:
s.text((x + 4, y + h - 4), str(k + 1), "lab", ink)
s.text((x + 30, y + h - 4), ratio_txt(op) + ("x" if not op[MODE] else ""), "lab",
s.c["ink"] if on else s.c["mid"], anchor="rs")
else:
s.text((x + 17, y + h - 4), str(k + 1), "lab", ink, anchor="ms")
if car[k]: # the carriers: the output bus under them
s.box(x, y + h + 1, x + 33, y + h + 2, fill=s.trk[0] if on else s.c["mid"])
def scroll(s, w, n=5, y0=80, y1=211):
s.box(236, y0, 237, y1, fill=raise_(s))
hgt = (y1 - y0) // n
s.box(236, y0 + w * hgt, 237, y0 + (w + 1) * hgt, fill=s.c["mid"])
X0, XW = 10, 220 # the graph's columns
HELD_W = 160 # the held part's columns; the release's the rest
def col_step(r, x):
"""the step column x shows: the held part and the release each on a log time axis (the attack gets room)"""
tau = 0.02 * BPS
if x < HELD_W:
T = r["held"]
return min(T - 1, int(tau * ((1 + T / tau) ** (x / (HELD_W - 1)) - 1)))
T = r["n"] - r["held"]
return min(r["n"] - 1, r["held"] + int(tau * ((1 + T / tau) ** ((x - HELD_W) / (XW - HELD_W - 1)) - 1)))
def step_col(r, i):
return next((x for x in range(XW) if col_step(r, x) >= i), XW - 1)
def lv_at(r, k, x):
"""operator k's level at column x, between the steps where a column is less than one"""
i = col_step(r, x)
j = col_step(r, x + 1) if x + 1 < XW else i
if j <= i + 1 and x > 0:
a = col_step(r, x - 1)
nx = next((xx for xx in range(x + 1, XW) if col_step(r, xx) != i), XW)
px = next((xx for xx in range(x - 1, -1, -1) if col_step(r, xx) != i), -1) + 1
if nx - px > 1 and nx < XW: # x is in a run of columns on one step: slide to the next
f = (x - px) / (nx - px)
return r["lv"][k][i] + f * (r["lv"][k][col_step(r, nx)] - r["lv"][k][i])
return r["lv"][k][i]
def lvy(v, y0, h):
return y0 + round(max(0.0, min(1.0, (TOP - v) / SPAN)) * (h - 1))
def secs(i):
t = i / BPS
return f"{max(1, round(t * 1000))} MS" if t < 0.1 else f"{t:.2f} S" if t < 1 else f"{t:.1f} S"
def heat_view(s, p, sel, d, y0, h, marks=(), hot_mark=None, outline_only=False):
"""the brightness envelope: per column the carriers' level, filled with the heat's shade; the operators behind"""
r = run(p)
sh = ramp(s, d)
hs = [heat(p, r, col_step(r, x)) for x in range(XW)]
for x in range(XW):
i = col_step(r, x)
top = lvy(loud(r, i), y0, h)
col = raise_(s) if outline_only else sh[round(hs[x] * 11)]
s.box(X0 + x, top, X0 + x, y0 + h - 1, fill=col)
kx = X0 + HELD_W # the key up
for yy in range(y0, y0 + h, 2):
s.g.point((kx, yy), fill=s.c["dim"])
if outline_only:
return r
for k in sorted(range(6), key=lambda k: k == sel): # the operators: MID, the selected one bright on a shadow
if not op_bytes(p, k)[OL]:
continue
pts = [(X0 + x, lvy(r["lv"][k][col_step(r, x)], y0, h)) for x in range(XW)]
if k == sel:
s.g.line([(x, y + 1) for x, y in pts], fill=s.c["bg"], width=2)
s.g.line(pts, fill=s.c["text"] if d == "C" else s.trk[0], width=2)
else:
s.g.line(pts, fill=s.c["mid"], width=1)
ends = [] # the selected operator's stage ends: where each was reached
st = [row[sel] for row in r["stage"]]
for i in range(1, len(st)):
if st[i] != st[i - 1] and st[i - 1] < 4 and (st[i] == st[i - 1] + 1):
ends.append((st[i - 1], i))
for stg, i in ends:
if stg in marks:
x = X0 + step_col(r, i)
y = lvy(r["lv"][sel][i], y0, h)
s.box(x - 2, y - 2, x + 2, y + 2, fill=s.c["text"] if stg == hot_mark else s.trk[0])
best = max(range(XW), key=lambda x: hs[x])
if hs[best] > 0.01:
s.g.polygon([(X0 + best - 3, y0 + h + 5), (X0 + best + 3, y0 + h + 5), (X0 + best, y0 + h + 1)],
fill=s.c["text"])
s.text((10, 211), "BRIGHTEST " + secs(col_step(r, best)), "lab", "mid")
else:
live = sum(1 for k, c in enumerate(carriers(p[ALG] + 1)) if c and op_bytes(p, k)[OL])
s.text((10, 211), "PURE SINE" if live == 1 else "NO MODULATION", "lab", "mid")
s.text((X0 + HELD_W - 3, 211), "KEY UP " + secs(r["held"]), "lab", "dim", anchor="rs")
s.text((229, 211), secs(r["n"]), "lab", "mid", anchor="rs")
return r
OPC = ["#FF5A36", "#22C3B4", "#FFBF00", "#9580FF", "#FF6FAE", "#A3E635"] # an operator's own colour (the
# palette's six: T_TRK)
def warp(r, i):
"""step i -> its column: the held part and the release each on a log time axis (the attack gets room)"""
tau = 0.02 * BPS
if i <= r["held"]:
T = r["held"]
return (HELD_W - 1) * math.log(1 + i / tau) / math.log(1 + T / tau)
T = max(1, r["n"] - r["held"])
return HELD_W + (XW - HELD_W - 1) * math.log(1 + min(i - r["held"], T) / tau) / math.log(1 + T / tau)
def breaks(r, k):
"""operator k's envelope as straight segments: (column, level) at its start, every stage it finishes, the key up
and the end; and where each stage ends among them (the handles). lv[i] is the level after step i: at time i + 1"""
st, lv = [row[k] for row in r['stage']], r['lv'][k]
pts, ends, prev = [(0.0, 0)], {}, 0
for i in range(r['n']):
if st[i] != prev or i + 1 == r['held']:
pts.append((warp(r, i + 1), lv[i]))
for s_ in range(prev, min(st[i], 4) if st[i] > prev else prev):
ends[s_] = len(pts) - 1
prev = st[i]
pts.append((warp(r, r['n']), lv[r['n'] - 1]))
return pts, ends
def at(pts, x):
for (xa, va), (xb, vb) in zip(pts, pts[1:]):
if xa <= x <= xb:
return va if xb == xa else va + (vb - va) * (x - xa) / (xb - xa)
return pts[-1][1]
def brush(s, x, y, w, col):
"""a round brush w px wide (2..5): a square with its corners off"""
a, b = -(w // 2), w - w // 2 - 1
x, y = round(x), round(y)
if w > 3:
s.box(x + a, y + a + 1, x + b, y + b - 1, fill=col)
s.box(x + a + 1, y + a, x + b - 1, y + b, fill=col)
else:
s.box(x + a, y + a, x + b, y + b, fill=col)
def stroke(s, pts, w, colf):
"""a polyline with the round brush, its colour per column (colf(x))"""
for (xa, ya), (xb, yb) in zip(pts, pts[1:]):
n = max(1, int(max(abs(xb - xa), abs(yb - ya)) * 2))
for j in range(n + 1):
x, y = xa + (xb - xa) * j / n, ya + (yb - ya) * j / n
brush(s, x, y, w, colf(x))
def ring(s, x, y, filled):
"""a breakpoint's handle: a 9 px ring (the one the knob just turned: filled)"""
x, y = round(x), round(y)
s.g.ellipse([x - 5, y - 5, x + 5, y + 5], fill=s.c["bg"])
s.g.ellipse([x - 4, y - 4, x + 4, y + 4], outline=s.c["text"], width=2, fill=s.c["text"] if filled else s.c["surf"])
def lines_view(s, p, sel, y0, h, marks=(), hot_mark=None):
"""D LINES, as Floyd Steinberg's screen: every operator's envelope as straight segments between its breakpoints;
the modulators thin in their own colours, each carrier thick and shaded along its length by its own heat (the
modulators feeding it, at that moment, as drawn); the picked operator's breakpoints as handles"""
r = run(p)
sh = ramp(s, "D")
car = carriers(p[ALG] + 1)
alg = p[ALG] + 1
seg = {k: breaks(r, k) for k in range(6) if op_bytes(p, k)[OL]}
def yv(v):
return lvy(v, y0 + 4, h - 8)
def norm(v):
return max(0.0, min(1.0, (v - (TOP - HSPAN)) / HSPAN))
def heat_x(c, x):
f = feeders(alg, c)
terms = [norm(at(seg[k][0], x)) for k in seg if f >> k & 1]
k = fb_op(alg)
if p[FB] and k in seg and (f >> k & 1 or k == c):
terms.append(p[FB] / 7 * norm(at(seg[k][0], x)))
return math.sqrt(max(terms)) if terms else 0.0 # (the square root: a little FM is already heard)
kx = X0 + HELD_W
for yy in range(y0, y0 + h, 2): # the key up
s.g.point((kx, yy), fill=s.c["dim"])
order = [k for k in seg if not car[k] and k != sel] + [k for k in seg if car[k] and k != sel] + \
([sel] if sel in seg else [])
best, bx = 0.0, 0
for k in order:
pts = [(X0 + x, yv(v)) for x, v in seg[k][0]]
if car[k]:
hc = {}
def colf(x, k=k, hc=hc):
xi = round(x - X0)
if xi not in hc:
hc[xi] = heat_x(k, xi)
return sh[round(hc[xi] * 11)]
stroke(s, [(x, y + 1) for x, y in pts], 5, lambda x: s.c["bg"])
stroke(s, pts, 4 if k != sel else 5, colf)
for xi, hv in hc.items():
if hv > best:
best, bx = hv, xi
else:
col = mock.hexc(OPC[k])
c = col if k == sel else mix(s.c["surf"], col, 0.7)
stroke(s, pts, 2 if k != sel else 3, lambda x, c=c: c)
if sel in seg: # the handles: the breakpoints the window's knobs move
pts, ends = seg[sel]
for stg in marks:
if stg in ends:
x, v = pts[ends[stg]]
ring(s, X0 + x, yv(v), stg == hot_mark)
if best > 0.01:
s.g.polygon([(X0 + bx - 3, y0 + h + 5), (X0 + bx + 3, y0 + h + 5), (X0 + bx, y0 + h + 1)], fill=s.c["text"])
i = next((i for i in range(r["n"]) if warp(r, i) >= bx), 0)
s.text((10, 211), "BRIGHTEST " + secs(i), "lab", "mid")
else:
live = sum(1 for k, c in enumerate(car) if c and op_bytes(p, k)[OL])
s.text((10, 211), "PURE SINE" if live == 1 else "NO MODULATION", "lab", "mid")
s.text((229, 211), secs(r["n"]), "lab", "mid", anchor="rs")
s.text((129, 211), "SINE", "lab", "dim", anchor="rs") # the key: cold .. hot (the key up: the dotted line)
for j, c in enumerate(sh):
s.box(132 + j * 3, 204, 134 + j * 3, 210, fill=c)
s.text((171, 211), "FM", "lab", "dim")
return r
def tabs_d(s, p, sel, y=80, h=17, ratios=False):
"""D's tabs, outlined as his, the picked one in the track's colour; under each, its line's colour (a carrier's:
the ramp, it shows the heat)"""
car = carriers(p[ALG] + 1)
sh = ramp(s, "D")
for k in range(6):
x = 8 + k * 38
op = op_bytes(p, k)
on = k == sel
s.box(x, y, x + 33, y + h - 1, fill=s.c["surf"], outline=s.c["text"] if on else s.c["dim"], w=2 if on else 1)
ink = s.c["text"] if on else (s.c["dim"] if not op[OL] else s.c["mid"])
if ratios:
s.text((x + 5, y + h - 4), str(k + 1), "lab", ink)
s.text((x + 29, y + h - 4), ratio_txt(op) + ("x" if not op[MODE] else ""), "lab", s.c["mid"], anchor="rs")
else:
s.text((x + 17, y + h - 4), "OP" + str(k + 1), "lab", ink, anchor="ms")
if not op[OL]:
continue
if car[k]:
for j in range(12):
s.box(x + 3 + j * 2 + (j > 5) * 4, y + h + 2, x + 4 + j * 2 + (j > 5) * 4, y + h + 3, fill=sh[j])
else:
s.box(x + 3, y + h + 2, x + 30, y + h + 3, fill=mock.hexc(OPC[k]))
def lens_ratios(s, p, sel, y0):
"""B's TONE strip: the ratios on a ruler, x0.5 .. x32 (log), modulators above, carriers below"""
car = carriers(p[ALG] + 1)
y = y0 + 17
s.box(14, y, 225, y, fill=s.c["line"])
for i, lab in enumerate(["0.5", "1", "2", "4", "8", "16", "32"]):
x = 14 + round(i * 211 / 6)
s.box(x, y - 2, x, y + 2, fill=s.c["dim"])
s.text((x, y0 + 35), lab, "lab", "dim", anchor="ms")
seen = {}
for k in range(6):
op = op_bytes(p, k)
if not op[OL] or op[MODE]:
continue
rt = (op[FC] or 0.5) * (1 + op[FF] / 100)
x = 14 + round((math.log2(rt) + 1) * 211 / 6)
row = 0 if not car[k] else 1
n = seen.get((x // 12, row), 0)
seen[(x // 12, row)] = n + 1
bx = x - 5 + n * 12
by = y0 + 3 if row == 0 else y + 4
on = k == sel
s.box(bx, by, bx + 10, by + 10, fill=s.trk[0] if on else raise_(s))
s.text((bx + 5, by + 10), str(k + 1), "lab", s.c["ink"] if on else s.c["text"], anchor="ms")
def lens_stages(s, r, sel, y0, lit, hot):
"""B's ENV strip: the selected operator's stages numbered under their time (the heat view's own axis)"""
st = [row[sel] if row[sel] < 3 else (3 if i >= r["held"] else -1) for i, row in enumerate(r["stage"])]
spans, a = [], 0 # (-1: holding at LEVEL 3 with the key down)
for i in range(1, len(st) + 1):
if i == len(st) or st[i] != st[a]:
spans.append((st[a], step_col(r, a), step_col(r, i - 1)))
a = i
for stg, xa, xb in spans:
if stg >= 4 or xb - xa < 3:
continue
on = stg in lit
fill = s.trk[0] if stg == hot else (mix(s.c["surf"], s.trk[0], 0.35) if on else raise_(s))
s.box(X0 + xa + 1, y0 + 6, X0 + xb - 1, y0 + 22, fill=fill)
if xb - xa > 12:
s.text(((2 * X0 + xa + xb) / 2, y0 + 19), str(stg + 1) if stg >= 0 else "HOLD", "lab",
s.c["ink"] if stg == hot else s.c["text"] if on else s.c["mid"], anchor="ms")
s.text((X0, y0 + 34), "STAGES OF OP" + str(sel + 1), "lab", "dim")
def note_name(n): # ui.c note_name: MIDI 60 = C4
return ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"][n % 12] + str(n // 12 - 1)
def keyboard(s, p, sel, y0, h):
"""the selected operator's level across the keys: its offset (dB) for MIDI 21..108, BREAK marked, C4 a dot"""
op = op_bytes(p, sel)
kb = y0 + h - 16
for o in range(1, 8): # the octaves under the curve, C1 .. C7 (MIDI 24 ..)
xa = X0 + (12 * o + 12 - 21) * (XW - 1) / 87
xb = min(X0 + XW - 1, X0 + (12 * o + 24 - 21) * (XW - 1) / 87)
s.box(round(xa), kb + 2, round(xb) - 1, kb + 5, fill=raise_(s) if o % 2 else s.c["dim"])
if o in (2, 4, 6):
s.text((round(xa), kb + 15), "C" + str(o), "lab", "dim")
zy, rng = y0 + 22, (kb - 6) - (y0 + 22)
s.hline(zy, "line", X0, X0 + XW - 1)
s.text((X0 + XW - 1, zy - 3), "0 DB", "lab", "dim", anchor="rs")
s.text((X0 + XW - 1, kb - 4), "-48 DB", "lab", "dim", anchor="rs")
pts = []
for n in range(21, 109):
db = scale_level(n, op) * 0.75 # an outlevel step: 1/8 of 6 dB
x = X0 + (n - 21) * (XW - 1) / 87
pts.append((x, zy + max(-12.0, min(48.0, -db)) / 48 * rng))
s.g.line([(x, y + 1) for x, y in pts], fill=s.c["bg"], width=2)
s.g.line(pts, fill=s.trk[0], width=2)
bx = X0 + (op[BP] + 21 - 21) * (XW - 1) / 87
for yy in range(y0 + 4, kb - 2, 2):
s.g.point((round(bx), yy), fill=s.c["text"])
s.text((round(bx) + 4, y0 + 13), "BREAK " + note_name(op[BP] + 21), "lab", "text")
cx = X0 + (60 - 21) * (XW - 1) / 87
cy = zy + max(-12.0, min(48.0, -scale_level(60, op) * 0.75)) / 48 * rng
s.box(round(cx) - 2, round(cy) - 2, round(cx) + 2, round(cy) + 2, fill=s.c["text"])
db_hi = scale_level(96, op) * 0.75
s.text((X0, y0 + 13), f"C7 {db_hi:+.0f} DB", "lab", "mid")
def pitch_view(s, p, y0, h, lfo=False):
"""ALL OPS' PITCH and LFO windows: the sound's outline in RAISE, the pitch (envelope + vibrato) bright"""
if lfo:
r = run(p, held=int(2 * BPS), rel=1)
n = int(2 * BPS)
steps = [round(x * (n - 1) / (XW - 1)) for x in range(XW)]
else:
r = run(p)
steps = [col_step(r, x) for x in range(XW)]
for x, i in enumerate(steps): # the sound behind
s.box(X0 + x, lvy(loud(r, i), y0, h), X0 + x, y0 + h - 1, fill=raise_(s))
vals = [r["vib"][i] if lfo else r["pitch"][i] for i in steps] # (LFO: the vibrato alone, PITCH its envelope)
m = max(abs(v) for v in vals) or 1
rng = next(v for v in (0.1, 0.25, 0.5, 1, 2, 4, 12, 24, 48) if v >= m)
zy = y0 + h // 2
s.hline(zy, "line", X0, X0 + XW - 1)
pts = [(X0 + x, zy - v / rng * (h // 2 - 6)) for x, v in enumerate(vals)]
s.g.line([(x, y + 1) for x, y in pts], fill=s.c["bg"], width=2)
s.g.line(pts, fill=s.trk[0], width=2)
s.text((10, y0 + 12), f"+{rng:g} ST", "lab", "mid")
s.text((10, y0 + h - 4), f"-{rng:g} ST", "lab", "mid")
if lfo:
hz = LFO_DELTA[p[LFS]] * BPS / 2 ** 32
s.text((10, 211), f"VIBRATO {hz:.1f} HZ, IN AFTER " + secs(next((i for i, v in enumerate(r['vib'])
if abs(v) > 0.2 * m), 0)), "lab", "mid")
s.text((229, 211), "2.0 S", "lab", "mid", anchor="rs")
else:
s.text((10, 211), "PITCH OVER THE NOTE", "lab", "mid")
s.text((229, 211), secs(r["n"]), "lab", "mid", anchor="rs")
def algo(s):
"""ALL OPS ALGO: the firmware's chart (algorithm 5), the operator PRESETS picked lit"""
chart = Image.open(u3.p6.RENDERS / "SKIFF_fm6_alg_05.ppm").convert("RGB").crop((3, 76, 237, 214))
s.img.paste(chart, (3, 76))
s.g = ImageDraw.Draw(s.img)
s.g.fontmode = "L"
x, y = 120 + 1 * 24 - 2 * 12, 76 + 19 + 52 - 23 # OP4: column 1, row 1 (ui_graph.c graph_fm6)
s.box(x - 10, y, x + 10, y + 16, fill=s.c["text"])
s.text((x, y + 13), "4", "lab", s.c["ink"], anchor="ms")
s.text((10, 211), "OP4 MODULATES OP3", "lab", "mid")
# ---------------------------------------------------------------- the screens
def op_cards(p, k, win):
op = op_bytes(p, k)
cv = ["-LIN", "-EXP", "+EXP", "+LIN"]
if win == 0:
rt = (op[FC] or 0.5) * (1 + op[FF] / 100)
return [("OUTPUT", str(op[OL]), "", op[OL] / 99), ("RATIO", ratio_txt(op), "x", op[FC] / 31),
("FINE", f"{rt:.2f}", "", op[FF] / 99), ("DETUNE", str(op[DET] - 7), "", op[DET] / 14)]
if win == 1:
return [("RATE 1", str(op[R1]), "", op[R1] / 99), ("LEVEL 1", str(op[L1]), "", op[L1] / 99),
("RATE 2", str(op[R1 + 1]), "", op[R1 + 1] / 99), ("LEVEL 2", str(op[L1 + 1]), "", op[L1 + 1] / 99)]
return [("L CURVE", cv[op[LC]], "", op[LC] / 3), ("L DEPTH", str(op[LD]), "", op[LD] / 99),
("R DEPTH", str(op[RD]), "", op[RD] / 99), ("R CURVE", cv[op[RC]], "", op[RC] / 3)]
def screen(d, what):
lens = d == "B"
hy, hh = (101, 58) if lens else (102, 94)
if what == "tone":
s = base("OPERATOR 4", op_cards(TINE, 3, 0), 0)
(tabs_d if d == "D" else tabs)(s, TINE, 3, ratios=True)
r = lines_view(s, TINE, 3, hy, hh, marks=(0, 1, 2, 3)) if d == "D" else heat_view(s, TINE, 3, d, hy, hh)
if lens:
lens_ratios(s, TINE, 3, 160)
scroll(s, 0)
elif what == "env":
s = base("OPERATOR 4", op_cards(TINE, 3, 1), 2)
(tabs_d if d == "D" else tabs)(s, TINE, 3)
r = (lines_view(s, TINE, 3, hy, hh, marks=(0, 1, 2, 3), hot_mark=1) if d == "D" else
heat_view(s, TINE, 3, d, hy, hh, marks=(0, 1), hot_mark=1))
if lens:
lens_stages(s, r, 3, 160, (0, 1), 1)
scroll(s, 1)
elif what == "keys":
s = base("OPERATOR 2", op_cards(KEYS, 1, 3), 2)
(tabs_d if d == "D" else tabs)(s, KEYS, 1)
keyboard(s, KEYS, 1, 101, 108)
scroll(s, 3)
elif what == "algo":
s = base("ALL OPS", [("ALGO", "5", "", 4 / 31), ("FEEDBACK", "3", "", 3 / 7), ("TRANSP", "0", "ST", 0.5),
None], 0)
algo(s)
scroll(s, 0)
elif what == "pitch":
s = base("ALL OPS", [("RATE 1", "80", "", 80 / 99), ("PITCH 1", "-1.5", "ST", 46 / 99),
("RATE 2", "60", "", 60 / 99), ("PITCH 2", "0.0", "ST", 0.5)], 1, name="BRASS SECT")
pitch_view(s, BRASS, 82, 116)
scroll(s, 1)
elif what == "lfo":
s = base("ALL OPS", [("WAVE", "SINE", "", 0.8), ("RATE", "5.5", "HZ", 33 / 99), ("FADE", "50", "", 50 / 99),
("KEY SYNC", "ON", "", 1.0)], 2, name="BRASS SECT")
pitch_view(s, BRASS, 82, 116, lfo=True)
scroll(s, 3)
else: # the bare sine INIT gives
s = base("OPERATOR 1", op_cards(INIT, 0, 0), None, name="INIT VOICE")
(tabs_d if d == "D" else tabs)(s, INIT, 0, ratios=True)
lines_view(s, INIT, 0, hy, hh, marks=(0, 1, 2, 3)) if d == "D" else heat_view(s, INIT, 0, d, hy, hh)
if lens:
lens_ratios(s, INIT, 0, 160)
scroll(s, 0)
return s
def save(s, name):
img = s.img
img.save(OUT / f"{name}.png")
for z in (2, 3):
(OUT / f"x{z}").mkdir(parents=True, exist_ok=True)
img.resize((W * z, H * z), Image.NEAREST).save(OUT / f"x{z}" / f"{name}.png")
return img
PALS = [("SKIFF", (12, 12, 12), (30, 30, 30), (255, 255, 255), (255, 72, 72), (255, 90, 54)),
("HI-CON", (0, 0, 0), (40, 40, 40), (255, 255, 255), (255, 72, 72), (255, 232, 0)),
("PAPER", (244, 239, 228), (226, 218, 202), (34, 30, 24), (190, 24, 40), (10, 84, 70)),
("CRYPT", (10, 7, 5), (34, 24, 16), (236, 214, 172), (255, 72, 72), (236, 110, 50)),
("NEON", (12, 4, 26), (30, 12, 50), (244, 236, 255), (255, 72, 72), (255, 64, 176)),
("QUARK", (3, 7, 12), (10, 21, 32), (216, 243, 255), (255, 72, 72), (255, 84, 96))]
def ramps_strip(z=2):
"""the two ramps in every palette: A/B (cool blue -> REC), C (the track's colour to white-hot)"""
im = Image.new("RGB", (W * z, 6 * 34 * z + 30 * z), (24, 24, 24))
s = u3.kit()
s.img, s.g = im, ImageDraw.Draw(im)
s.g.fontmode = "L"
for i, (name, bg, surf, text, rec, t1) in enumerate(PALS):
y = 6 + i * 34
s.box(0, y * z, W * z, (y + 32) * z, fill=bg)
s.c["surf"], s.c["rec"] = surf, rec
for row, d in enumerate("AC"):
for j, c in enumerate(ramp(s, d, t1)):
x = 60 + j * 14
s.box(x * z, (y + 3 + row * 14) * z, (x + 13) * z - 1, (y + 15 + row * 14) * z - 1, fill=c)
s.text((6 * z, (y + 13 + row * 14) * z), f"{name} {d}", "lab", text)
return im
def main():
names = ["tone", "env", "keys", "algo", "pitch", "lfo", "init"]
rows = []
for d in "ABCD":
rows.append([save(screen(d, w), f"FM6{d}_{w}") for w in names])
gap, z, top = 16, 2, 36
lw = 120
out = Image.new("RGB", (lw + len(names) * (W * z + gap) + gap, top + len(rows) * (H * z + gap) + gap),
(24, 24, 24))
s = u3.kit()
s.img, s.g = out, ImageDraw.Draw(out)
s.g.fontmode = "L"
heads = ["OPERATOR: TONE", "OPERATOR: ENV 1", "OPERATOR: KEYS", "ALL OPS: ALGO", "ALL OPS: PITCH 1",
"ALL OPS: LFO", "AFTER INIT: THE BARE SINE"]
for i, hd in enumerate(heads):
s.text((lw + gap + i * (W * z + gap), top - 10), hd, "lab", (184, 184, 184))
for r, shots in enumerate(rows):
y = top + gap + r * (H * z + gap)
s.text((16, y + 40), "ABCD"[r], "big", (255, 255, 255))
s.text((16, y + 70), ["HEAT", "HEAT + LENS", "TRACK HEAT", "LINES"][r], "lab", (184, 184, 184))
for i, im in enumerate(shots):
out.paste(im.resize((W * z, H * z), Image.NEAREST), (lw + gap + i * (W * z + gap), y))
out.save(HERE / "mockups" / "fm6_sheet.png")
ramps_strip().save(HERE / "mockups" / "fm6_ramps.png")
print("fm6_sheet.png", out.size)
if __name__ == "__main__":
main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

+22 -11
View File
@@ -242,12 +242,30 @@ static void fm6_poll(void)
}
/* -------------------------------------------------------------- macros --- */
/* RATIO, MOD ENV and VEL MOD (e: P_E0..) on the modulators of patch p in algorithm alg (0..31), as they play: the
* audio ISR's copy (fm6_sync) and (FM6 LAB) the editor's graph (ui_fm6.c) */
static void fm6_macro(uint8_t *p, uint32_t alg, const int16_t *e)
{
uint32_t car = fm6_carriers(alg), k, j;
int32_t meg = clamp(e[4], -64, 63) * 40 / 64; /* MEG: rate steps (+ slower) */
for (k = 0; k < 6u; k++) {
uint8_t *op = p + k * FP_OP;
if ((car >> k) & 1u)
continue;
if (!op[FP_MODE])
op[FP_FC] = (uint8_t)clamp(op[FP_FC] + e[3], 0, 31);
for (j = 0; j < 4u; j++)
op[FP_R1 + j] = (uint8_t)clamp(op[FP_R1 + j] - meg, 0, 99);
op[FP_KVS] = (uint8_t)clamp(op[FP_KVS] + e[5], 0, 7);
}
}
/* the patch through E0..E6 (audio ISR; cheap when nothing changed) */
static void fm6_sync(const track_t *t)
{
uint32_t tr = (uint32_t)(t - trk), k, j, car, n = 0;
uint32_t tr = (uint32_t)(t - trk), k, car, n = 0;
const int16_t *e = &t->p[P_E0];
int32_t meg, step;
int32_t step;
if (tr >= NTRK)
return;
if (fm6_eff[tr].ok && fm6_eff[tr].gen == fm6_pgen[tr]) {
@@ -266,23 +284,16 @@ static void fm6_sync(const track_t *t)
fm6_eff[tr].alg = (uint8_t)alg;
fm6_eff[tr].fb = (uint8_t)clamp(p[FP_FB] + e[1], 0, 7);
car = fm6_carriers(alg);
meg = clamp(e[4], -64, 63) * 40 / 64; /* MEG: rate steps (+ slower) */
step = clamp(e[6], 0, 127) * (12 * 13981) / 127; /* DTUN: up to 12 cents a step (1 cent = 13981) */
for (k = 0; k < 6u; k++) {
uint8_t *op = p + (5u - k) * FP_OP; /* OP1 first: carriers in their order */
for (k = 0; k < 6u; k++) { /* OP1 first: carriers in their order */
uint32_t ki = 5u - k;
fm6_eff[tr].dt[ki] = 0;
if ((car >> ki) & 1u) { /* carriers 0, +1, -1, +2, -2, +3 steps apart */
static const int8_t SPREAD[6] = {0, 1, -1, 2, -2, 3};
fm6_eff[tr].dt[ki] = SPREAD[n++] * step;
continue;
}
if (!op[FP_MODE])
op[FP_FC] = (uint8_t)clamp(op[FP_FC] + e[3], 0, 31);
for (j = 0; j < 4u; j++)
op[FP_R1 + j] = (uint8_t)clamp(op[FP_R1 + j] - meg, 0, 99);
op[FP_KVS] = (uint8_t)clamp(op[FP_KVS] + e[5], 0, 7);
}
fm6_macro(p, alg, e);
fm6_lfo_reset(&fm6_lfo[tr], p);
}
fm6_eff[tr].ok = 1;
+1 -1
View File
@@ -32,7 +32,7 @@
#define FELUCCA_ID "FM-1_700" /* package identity (build.py: the .fwsc marker string) */
#endif
#ifndef FELUCCA_VERSION
#define FELUCCA_VERSION "v1.0" /* Skiff's; shown in the menu, the console and the editor; build.py --release X.Y */
#define FELUCCA_VERSION "v1.1" /* Skiff's; shown in the menu, the console and the editor; build.py --release X.Y */
#endif
#if FELUCCA_OTA && !FELUCCA_FLASH
#error "FELUCCA_OTA needs FELUCCA_FLASH"
+17 -8
View File
@@ -127,7 +127,9 @@ static void fm6_env_init(fm6_env_t *e, const uint8_t *op, int32_t outlevel, int3
fm6_env_advance(e, op, 0);
}
static int32_t fm6_env_get(fm6_env_t *e, const uint8_t *op)
/* (FM6 LAB) the envelopes' steps (and the pitch envelope's) always inline: the editor runs them too (ui_fm6.c), and a
* second caller would leave them out of the audio loop as calls */
static inline __attribute__((always_inline)) int32_t fm6_env_get(fm6_env_t *e, const uint8_t *op)
{
if (e->statc) {
e->statc -= FM6_N;
@@ -158,7 +160,7 @@ static int32_t fm6_env_get(fm6_env_t *e, const uint8_t *op)
return e->level;
}
static void fm6_env_key(fm6_env_t *e, const uint8_t *op, int down)
static inline __attribute__((always_inline)) void fm6_env_key(fm6_env_t *e, const uint8_t *op, int down)
{
if (e->down != (uint8_t)down) {
e->down = (uint8_t)down;
@@ -198,7 +200,7 @@ static void fm6_penv_init(fm6_penv_t *e, const uint8_t *p)
e->down = 1;
fm6_penv_advance(e, p, 0);
}
static int32_t fm6_penv_get(fm6_penv_t *e, const uint8_t *p)
static inline __attribute__((always_inline)) int32_t fm6_penv_get(fm6_penv_t *e, const uint8_t *p)
{
if (e->ix < 3u || (e->ix < 4u && !e->down)) {
if (e->rising) {
@@ -217,7 +219,7 @@ static int32_t fm6_penv_get(fm6_penv_t *e, const uint8_t *p)
}
return e->level;
}
static void fm6_penv_key(fm6_penv_t *e, const uint8_t *p, int down)
static inline __attribute__((always_inline)) void fm6_penv_key(fm6_penv_t *e, const uint8_t *p, int down)
{
if (e->down != (uint8_t)down) {
e->down = (uint8_t)down;
@@ -463,6 +465,16 @@ static int32_t fm6_osc_base(const uint8_t *op, int32_t note, int32_t extra)
return ((4458616 * ((op[FP_FC] & 3) * 100 + op[FP_FF] % 100u)) >> 3) + (det > 7 ? 13457 * (det - 7) : 0);
}
/* operator op's envelope at a note-on of MIDI note `note`, velocity vel: its output level with the key's level scaling
* and the velocity, its rate scaling. The note's, and (FM6 LAB) the editor's: ui_fm6.c draws what plays */
static void fm6_op_env_init(fm6_env_t *e, const uint8_t *op, int32_t note, int32_t vel)
{
int32_t ol = fm6_scaleout(op[FP_OL]) + fm6_scale_level(note, op);
ol = (ol > 127 ? 127 : ol) << 5;
ol += fm6_scale_vel(vel, op[FP_KVS]);
fm6_env_init(e, op, ol < 0 ? 0 : ol, fm6_scale_rate(note, op[FP_RS]));
}
/* a note-on (msfa note init) of patch p, MIDI note `note` (transposed), velocity vel. fresh: from silence
* (phases, gains, feedback 0); else a retrigger keeps them, as msfa does */
static void fm6_note_init(fm6_note_t *n, const uint8_t *p, int32_t note, int32_t vel, int fresh)
@@ -478,10 +490,7 @@ static void fm6_note_init(fm6_note_t *n, const uint8_t *p, int32_t note, int32_t
n->fixed = 0;
for (k = 0; k < 6u; k++) {
const uint8_t *op = p + k * FP_OP;
int32_t ol = fm6_scaleout(op[FP_OL]) + fm6_scale_level(note, op);
ol = (ol > 127 ? 127 : ol) << 5;
ol += fm6_scale_vel(vel, op[FP_KVS]);
fm6_env_init(&n->env[k], op, ol < 0 ? 0 : ol, fm6_scale_rate(note, op[FP_RS]));
fm6_op_env_init(&n->env[k], op, note, vel);
n->base[k] = fm6_osc_base(op, note, 0);
n->fixed |= (uint8_t)((op[FP_MODE] & 1u) << k);
}
+4 -1
View File
@@ -378,7 +378,8 @@ enum { GR_NONE, GR_ADSR, GR_LFO, GR_STEPS, GR_ARP, GR_SCALE, GR_FX, GR_ROLL, GR_
GR_DXSND, /* (Skiff phase 7, 8) EDIT > SOUND: a sound of the DRUM-X kit, the sheet (ui_dx.c) */
GR_LANES, /* (Skiff U3, R6) EDIT > LANES (DRUM): the eight lane levels, KNOB 1 the lane (ui.lane) */
GR_ENVDST, GR_LFODST, GR_DELAY, GR_REVERB, GR_CHORUS, GR_GLOBAL, GR_VOICE, GR_VOICE2,
GR_ARP2 }; /* (Skiff U5, V1) the pages' own graphs, the scope's before (ui_pgraph.c); ARP 2: ARP's */
GR_ARP2, /* (Skiff U5, V1) the pages' own graphs, the scope's before (ui_pgraph.c); ARP 2: ARP's */
GR_FMOP, GR_FMALL }; /* (FM6 LAB) EDIT > OPERATOR and ALL OPS: FM6's patch, two sheets (ui_fm6.c) */
typedef struct {
const char *title;
@@ -403,6 +404,8 @@ static const page_t PAGES[] = {
{"CHORD", FAM_SCL, SC_TRACK, GR_CHORD, {P_CHRD, P_VOIC, 0xFF, 0xFF}}, /* SCL again: the chord keys (chord.c) */
{"EDIT 1", FAM_EDIT, SC_ENGINE, GR_NONE, {P_E0, P_E1, P_E2, P_E3}},
{"EDIT 2", FAM_EDIT, SC_ENGINE, GR_NONE, {P_E4, P_E5, P_E6, P_E7}},
{"OPERATOR", FAM_EDIT, SC_TRACK, GR_FMOP, {0xFF, 0xFF, 0xFF, 0xFF}}, /* (FM6 LAB) FM6 only: an operator's values */
{"ALL OPS", FAM_EDIT, SC_TRACK, GR_FMALL, {0xFF, 0xFF, 0xFF, 0xFF}}, /* (FM6 LAB) FM6 only: the voice's (ui_fm6.c) */
{"LANES", FAM_EDIT, SC_TRACK, GR_LANES, {0xFF, 0xFF, 0xFF, 0xFF}}, /* DRUM only: LANE, its LEVEL (page_desc) */
{"SOUND", FAM_EDIT, SC_TRACK, GR_DXSND, {0xFF, 0xFF, 0xFF, 0xFF}}, /* (Skiff phase 7, 8) DRUM-X only: a sound of the
* project's kit on one sheet (ui_dx.c) */
+43 -14
View File
@@ -371,6 +371,30 @@ static void scr_shown(void) /* after the frame: the r
static const page_t *page_over; /* a quick layer's own four knobs (ui_layer.c), while it edits or draws them */
static const page_t *cur_page(void) { return page_over ? page_over : &PAGES[ui.page]; }
/* (FM6 LAB) a sheet: a page whose four knobs are a window over a table, SELECT moving it before the pages beside it
* (DRUM-X's SOUND, FM6's OPERATOR and ALL OPS: ui_input.c SHEETS). sheet_of: the page's, or 0 */
typedef struct {
uint8_t graph, eng, nwin, *win; /* the page (GR_*), the engine it is for, its windows, the one shown */
void (*knob)(uint32_t k, int32_t s);
void (*cards)(void);
uint32_t (*sig)(void); /* what the cards and the panel show (ui_graph.c graph_signature) */
void (*draw)(const track_t *t, uint16_t c); /* the panel, from its top */
const char *(*title)(void); /* the header's */
void (*pick)(int32_t s); /* PRESETS */
const char *pj; /* PRESETS' job (SHIFT's map) */
} sheet_t;
static const sheet_t *sheet_of(uint32_t g);
/* SELECT on a sheet: its window down (d > 0) or up; 0 at its ends (SELECT goes on to the page there) */
static int sheet_rows(const sheet_t *sh, int32_t d)
{
int32_t w = (int32_t)(*sh->win % sh->nwin) + (d > 0 ? 1 : -1);
if (w < 0 || w >= (int32_t)sh->nwin)
return 0;
*sh->win = (uint8_t)w;
ui.hot_t = 0; /* (another knob's card: none lit) */
return 1;
}
/* MENU > LARGE (#15, Discussion #80: what KNOB 1..4 do, in bigger type). Per page type:
* LK_TALL HOME and the value pages (EDIT ENV LFO MOD FX SLICER SCL CHORD ARP VOICE PATTERN STEP's knobs, MIXER,
* GLOBAL, SYSTEM, TOOLS, MOTION): tall cards (a K1..K4 keycap, the icon, the label in M, the value in L,
@@ -392,8 +416,8 @@ static uint32_t large_kind(void)
return LK_TALL;
g = cur_page()->graph;
return g == GR_BROWSE || g == GR_SLOTS || g == GR_USER || g == GR_BANK || step_page(g) ||
g == GR_CHANCE || g == GR_PLAY || g == GR_SLICES || g == GR_EVENTS || g == GR_SONG || g == GR_DXSND ? LK_LABEL
: LK_TALL;
g == GR_CHANCE || g == GR_PLAY || g == GR_SLICES || g == GR_EVENTS || g == GR_SONG || sheet_of(g) ? LK_LABEL
: LK_TALL;
}
/* the geometry of the page shown: the cards' height, the panel's top and height */
static uint32_t card_h(void) { return large_kind() == LK_TALL ? LG_CARD_H : CARD_H; }
@@ -434,13 +458,9 @@ static uint32_t layer_btn(void);
/* (Skiff phase 7, 8) EDIT > SOUND, the DRUM-X sound sheet (ui_dx.c, included by ui_input.c): the sound edited, the
* sheet's window the knobs are on (0..3) */
static uint8_t dx_ui_lane, dx_ui_win;
static void dx_knob(uint32_t k, int32_t s);
static void dx_cards(void);
static uint32_t dx_sig(void);
static void graph_dx(const track_t *t, uint16_t c);
static int dx_rows(int32_t d);
static void dx_lane_turn(int32_t s);
static const char *dx_title(void);
/* (FM6 LAB) EDIT > OPERATOR and ALL OPS (ui_fm6.c): the operator picked (0..5: OP1..OP6), OPERATOR's window, ALL
* OPS' window (.pool: off the audio ISR's merged globals) */
static uint8_t fm_ui[3] __attribute__((section(".pool")));
/* FM operator pages belong to DIGITAL; they never appear on other instruments (without FELUCCA_FM4: never). SLICES:
* a SLICE track's (ui_slice.c); (Skiff U3, R6) LANES a DRUM track's (its lane levels; DRUM-X's sheet has them);
@@ -451,9 +471,10 @@ static const char *dx_title(void);
static int page_visible(uint32_t i)
{
const engine_t *e = ENGINES[TSEL->eng_req % NENGINES];
const sheet_t *sh = sheet_of(PAGES[i].graph);
uint32_t id = PAGES[i].id[0];
if (PAGES[i].graph == GR_DXSND)
return TSEL->eng_req % NENGINES == ENGI_DRUMX;
if (sh)
return TSEL->eng_req % NENGINES == sh->eng;
if (PAGES[i].graph == GR_LANES)
return TSEL->eng_req % NENGINES == ENGI_DRUM;
if (PAGES[i].graph == GR_ROLL)
@@ -812,8 +833,9 @@ static int page_step(int32_t dir)
static const char *page_head(void)
{
const page_t *pg = cur_page();
if (pg->graph == GR_DXSND)
return dx_title();
const sheet_t *sh = sheet_of(pg->graph);
if (sh)
return sh->title();
if (pg->scope == SC_ENGINE) /* ((Skiff U4, L5) EDIT: the engine's own name (OSC, KIT), the
* footer only where it is (n/m); the footer said it before) */
return ENGINES[TSEL->eng_req % NENGINES]->page_title[pg->id[0] != P_E0];
@@ -1354,7 +1376,8 @@ static int set_engine_of(track_t *t, uint32_t ei)
static void apply_preset(uint32_t pi) { apply_preset_to(TSEL, pi); }
static int set_engine(uint32_t ei) { return set_engine_of(TSEL, ei); }
/* INIT (TOOLS, the EDIT layer): the selected track's engine from its defaults and first preset, the steps kept;
* (Skiff phase 7) on a DRUM-X track the project's kit back to the factory's too. One undo copy holds both (UNDO_KIT) */
* (Skiff phase 7) on a DRUM-X track the project's kit back to the factory's too. One undo copy holds both (UNDO_KIT).
* (FM6 LAB) on FM6 the bare sine to build a sound from (FM6_INIT: OP1 alone, ALG 1; SLOT OWN; the macros at 0) */
static void sound_init(void)
{
track_t *t = TSEL;
@@ -1363,6 +1386,12 @@ static void sound_init(void)
set_engine(t->eng_req);
if (kit)
memcpy(dx_kit, DX_KIT_DEF, sizeof dx_kit);
if (t->eng_req % NENGINES == ENGI_FM6) {
uint8_t v[FP_SIZE + 1u];
fm6_unpack(FM6_INIT, v);
fm6_set_patch(trk_index(t), v);
fm6_adopt(trk_index(t));
}
load_end(t);
ui_message("SOUND INITIALIZED");
}
+12 -7
View File
@@ -479,14 +479,21 @@ static void foot_hint(char *a, char *b)
str_cpy(b, ui.act || ui.ev_del ? "OCT- CANCEL" : "OCT- HOME", 16); /* ((Skiff U2) where it goes: HOME, not "BACK") */
}
/* the sound's name on the track: a user preset or the engine's preset (b holds 16) */
/* the sound's name on the track: a user preset or the engine's preset (b holds 16); (FM6 LAB) an FM6 track on its own
* patch (edited, INIT's): the patch's name ("INIT VOICE") */
static void sound_name(const track_t *t, char *b)
{
const engine_t *e = ENGINES[t->eng_req % NENGINES];
b[0] = 0;
if (user_of(t) < UP_SLOTS)
up_name(user_of(t), b);
else if (e->npresets)
else if (t->eng_req % NENGINES == ENGI_FM6 && t->p[P_E7] == FM6_OWN) {
uint32_t n = 10;
memcpy(b, fm6_patch[trk_index(t) % NTRK] + FP_NAME, 10);
while (n && b[n - 1u] == ' ')
n--;
b[n] = 0;
} else if (e->npresets)
str_cpy(b, e->presets[t->preset % e->npresets].name, 16);
}
@@ -510,9 +517,7 @@ static void draw_foot(void)
if (ui.home)
ti[0] = 0; /* ((Skiff U4, L5) the header names the page: here only where it */
else /* is in its family, "2/2" (was "ENV DEST 2/2", "HOME") */
page_pos(ti);
if (!ui.home && pg->graph == GR_DXSND) /* ((Skiff phase 8) the sound sheet: what SELECT does, as the */
str_cpy(ti, "SELECT: ROWS", sizeof ti); /* mockup's; the header names the page and the sound) */
page_pos(ti); /* (a sheet: "SELECT: ROWS") */
str_cpy(s, ename, sizeof s);
s[str_len(s) + 1u] = 0;
s[str_len(s)] = (char)('1' + song.sel);
@@ -775,8 +780,8 @@ static void draw_columns(void)
draw_column(3, "LIST", favorites.filter ? "FAV" : "ALL", "", VAL(3u), -1, ICON_X_FOLDER);
return;
}
if (cur_page()->graph == GR_DXSND) { /* (Skiff phase 7, 8) EDIT > SOUND, the sheet (ui_dx.c) */
dx_cards();
if (sheet_of(cur_page()->graph)) { /* (Skiff phase 7, 8; FM6 LAB) a sheet's window (SHEETS) */
sheet_of(cur_page()->graph)->cards();
return;
}
if (cur_page()->graph == GR_SONG) { /* (Skiff phase 5) ENTRY PATTERN REPS SONG (ui_input.c song_knob):
-10
View File
@@ -40,16 +40,6 @@ static void dx_follow(void)
}
}
static void dx_lane_turn(int32_t s) { dx_ui_lane = (uint8_t)clamp((int32_t)(dx_ui_lane & 7u) + (s > 0 ? 1 : -1), 0, 7); }
/* SELECT on the sheet: the window up or down; 0 at its ends (SELECT goes on to the page there) */
static int dx_rows(int32_t d)
{
int32_t w = (int32_t)(dx_ui_win % DX_NWIN) + (d > 0 ? 1 : -1);
if (w < 0 || w >= (int32_t)DX_NWIN)
return 0;
dx_ui_win = (uint8_t)w;
ui.hot_t = 0; /* (another knob's card: none lit) */
return 1;
}
static const char *dx_title(void) /* the header's: "SOUND SD" */
{
static char t[12];
+999
View File
@@ -0,0 +1,999 @@
/* SPDX-License-Identifier: GPL-3.0-only */
/* (FM6 LAB) EDIT > OPERATOR and ALL OPS on an FM6 track: every value of the track's patch (eng_fm6.c fm6_patch), on
* two sheets (ui.c sheet_t; ui_input.c SHEETS). Included by ui_input.c.
* PRESETS: the operator, OP1 .. OP6, on both. SELECT: the windows (past their ends, the pages either side).
* OPERATOR TONE OUTPUT RATIO FINE DETUNE ALL OPS ALGO ALGO FEEDBACK TRANSP
* ENV 1 RATE 1 LEVEL 1 RATE 2 LEVEL 2 PITCH 1 RATE 1 PITCH 1 RATE 2 PITCH 2
* ENV 2 RATE 3 LEVEL 3 RATE 4 LEVEL 4 PITCH 2 RATE 3 PITCH 3 RATE 4 PITCH 4
* KEYS L CURVE L DEPTH R DEPTH R CURVE LFO WAVE RATE FADE KEY SYNC
* MORE BREAK KEY RATE VELOCITY LFO AMP DEPTH VIBRATO VIB SENS TREMOLO
* A knob edits a copy of the patch: fm6_set_patch (the audio ISR's copy follows), fm6_adopt (SLOT: OWN, or the
* factory patch it now is). ALGO and FEEDBACK show what plays (EDIT 1's ALGO and FEEDBACK on the patch) and turning
* them puts that in the patch, the macro back to neutral. OKS is not here: the engine never reads it.
* The panel (design/mock_fm6.py, direction D, the user's pick; after an idea in a video by Floyd Steinberg, drawn our
* own way): the operators' envelopes as the engine runs them (fm6_op_env_init, the macros through fm6_macro), each as
* straight segments between its breakpoints on a log time axis (the held note, then its release); the modulators
* thin in their own colours (the palette's six), each carrier thick and shaded along its length from cool (a sine) to
* hot (the strongest modulator feeding it at that moment: FM's bite); the operator picked: its breakpoints as handles.
* KEYS and MORE: its level across the keyboard. ALGO: the chart (ui_graph.c graph_fm6). PITCH: the pitch envelope;
* LFO and DEPTH: the vibrato over two seconds. All drawn in the theme's colours (the ramp: blue to REC). */
enum { FMW_TONE, FMW_ENV1, FMW_ENV2, FMW_KEYS, FMW_MORE }; /* OPERATOR's windows */
enum { FMW_ALGO, FMW_PITCH1, FMW_PITCH2, FMW_LFO, FMW_DEPTH }; /* ALL OPS' */
enum { FMF_NUM, FMF_RATIO, FMF_FINE, FMF_DET, FMF_CURVE, FMF_NOTE, FMF_ALG, FMF_FB, FMF_TRNSP, FMF_PITCH, FMF_WAVE,
FMF_HZ, FMF_ONOFF };
#define FM_NWIN 5u
typedef struct {
const char *label; /* 0: an empty card */
uint8_t off, fmt; /* OPERATOR: the byte in the operator (0..20); ALL OPS: in the patch */
} fm_field_t;
static const fm_field_t FM_F[2][FM_NWIN][4] = {
{{{"OUTPUT", FP_OL, FMF_NUM}, {"RATIO", FP_FC, FMF_RATIO}, {"FINE", FP_FF, FMF_FINE}, {"DETUNE", FP_DET, FMF_DET}},
{{"RATE 1", FP_R1, FMF_NUM}, {"LEVEL 1", FP_L1, FMF_NUM}, {"RATE 2", FP_R1 + 1, FMF_NUM}, {"LEVEL 2", FP_L1 + 1, FMF_NUM}},
{{"RATE 3", FP_R1 + 2, FMF_NUM}, {"LEVEL 3", FP_L1 + 2, FMF_NUM}, {"RATE 4", FP_R1 + 3, FMF_NUM},
{"LEVEL 4", FP_L1 + 3, FMF_NUM}},
{{"L CURVE", FP_LC, FMF_CURVE}, {"L DEPTH", FP_LD, FMF_NUM}, {"R DEPTH", FP_RD, FMF_NUM}, {"R CURVE", FP_RC, FMF_CURVE}},
{{"BREAK", FP_BP, FMF_NOTE}, {"KEY RATE", FP_RS, FMF_NUM}, {"VELOCITY", FP_KVS, FMF_NUM}, {"LFO AMP", FP_AMS, FMF_NUM}}},
{{{"ALGO", FP_ALG, FMF_ALG}, {"FEEDBACK", FP_FB, FMF_FB}, {"TRANSP", FP_TRNSP, FMF_TRNSP}, {0, 0, 0}},
{{"RATE 1", FP_PR1, FMF_NUM}, {"PITCH 1", FP_PL1, FMF_PITCH}, {"RATE 2", FP_PR1 + 1, FMF_NUM},
{"PITCH 2", FP_PL1 + 1, FMF_PITCH}},
{{"RATE 3", FP_PR1 + 2, FMF_NUM}, {"PITCH 3", FP_PL1 + 2, FMF_PITCH}, {"RATE 4", FP_PR1 + 3, FMF_NUM},
{"PITCH 4", FP_PL1 + 3, FMF_PITCH}},
{{"WAVE", FP_LFW, FMF_WAVE}, {"RATE", FP_LFS, FMF_HZ}, {"FADE", FP_LFD, FMF_NUM}, {"KEY SYNC", FP_LKS, FMF_ONOFF}},
{{"VIBRATO", FP_LPMD, FMF_NUM}, {"VIB SENS", FP_LPMS, FMF_NUM}, {"TREMOLO", FP_LAMD, FMF_NUM}, {0, 0, 0}}},
};
static const char *const FM_CURVE[4] = {"-LIN", "-EXP", "+EXP", "+LIN"};
static const char *const FM_WAVE[6] = {"TRI", "SAW DN", "SAW UP", "SQUARE", "SINE", "RANDOM"};
static uint32_t fm_tr(void) { return trk_index(TSEL) % NTRK; }
/* field f's byte in the patch (operator fm_ui[0] on OPERATOR) */
static uint32_t fm_at(uint32_t pg, const fm_field_t *f)
{
return pg ? f->off : (5u - fm_ui[0] % 6u) * FP_OP + f->off;
}
/* the RATIO knob's position: x0.5, x1 .. x31 (FC 0..31), then 1, 10, 100, 1K HZ (MODE fixed, FC 0..3) */
static int32_t fm_ratio_pos(const uint8_t *op) { return op[FP_MODE] ? 32 + (op[FP_FC] & 3) : op[FP_FC]; }
/* a signed number: "+3", "-3", "0" */
static void fm_signed(char *b, int32_t v)
{
if (v > 0)
*b++ = '+';
fmt_int(b, v);
}
/* tenths: "-1.5", "5.5", "+0.4" (sign: a plus too) */
static void fm_tenths(char *b, int32_t v, int sign)
{
if (v < 0)
*b++ = '-';
else if (sign && v > 0)
*b++ = '+';
v = v < 0 ? -v : v;
fmt_int(b, v / 10);
b += str_len(b);
*b++ = '.';
*b++ = (char)('0' + v % 10);
*b = 0;
}
/* hundredths: "14.00", "0.50" */
static void fm_hundredths(char *b, int32_t v)
{
fmt_int(b, v / 100);
b += str_len(b);
*b++ = '.';
*b++ = (char)('0' + v / 10 % 10);
*b++ = (char)('0' + v % 10);
*b = 0;
}
/* a fixed-frequency operator's Hz x 100 (fm6_osc_base: log2 Hz in 1/100 decades of FC & 3 and FF) */
static uint32_t fm_fixed_hz100(const uint8_t *op)
{
int32_t x = (4458616 * ((op[FP_FC] & 3) * 100 + op[FP_FF] % 100u)) >> 3, i = x >> 24; /* 1 .. 9772 Hz: 0 .. 13 */
return (uint32_t)(((uint64_t)fm6_mant(x) * 100u) >> (30 - i));
}
/* the LFO's rate in tenths of a Hz (FM6_LFO_DELTA a block, 44100 / 32 blocks a second) */
static uint32_t fm_lfo_hz10(uint32_t v) { return (uint32_t)(((uint64_t)FM6_LFO_DELTA[v % 100u] * 13781u) >> 32); }
/* field f's card: its value, unit and gauge (0..1000) from patch p, track t */
static int32_t fm_val(const fm_field_t *f, uint32_t i, const uint8_t *p, const track_t *t, char *val, const char **unit)
{
const uint8_t *op = p + (i / FP_OP) * FP_OP;
uint32_t v = p[i], mx = fm6_max(i);
*unit = "";
switch (f->fmt) {
case FMF_RATIO: {
int32_t pos = fm_ratio_pos(op);
static const char *const HZ[4] = {"1", "10", "100", "1K"};
if (op[FP_MODE]) {
str_cpy(val, HZ[op[FP_FC] & 3u], 8);
*unit = "HZ";
} else {
if (op[FP_FC])
fmt_int(val, op[FP_FC]);
else
str_cpy(val, "0.5", 8);
*unit = "x";
}
return pos * 1000 / 35;
}
case FMF_FINE:
if (op[FP_MODE]) { /* the frequency it plays */
uint32_t h = fm_fixed_hz100(op);
if (h < 1000u)
fm_hundredths(val, (int32_t)h);
else if (h < 10000u)
fm_tenths(val, (int32_t)h / 10, 0);
else
fmt_int(val, (int32_t)(h / 100u));
*unit = "HZ";
} else /* the ratio it plays */
fm_hundredths(val, op[FP_FC] ? op[FP_FC] * (100 + (int32_t)op[FP_FF]) : (100 + (int32_t)op[FP_FF]) / 2);
break;
case FMF_DET:
fm_signed(val, (int32_t)v - 7);
break;
case FMF_CURVE:
str_cpy(val, FM_CURVE[v & 3u], 8);
break;
case FMF_NOTE:
note_name(val, v + 21u);
break;
case FMF_ALG:
v = fm6_alg_of(t);
fmt_int(val, (int32_t)v + 1);
break;
case FMF_FB:
v = (uint32_t)clamp((int32_t)p[FP_FB] + t->p[P_E1], 0, 7);
fmt_int(val, (int32_t)v);
break;
case FMF_TRNSP:
fm_signed(val, (int32_t)v - 24);
*unit = "ST";
break;
case FMF_PITCH:
fm_tenths(val, FM6_PENV_TAB[v % 100u] * 15 / 4, 1); /* (1/32 octave a step: 3/8 of a semitone) */
*unit = "ST";
break;
case FMF_WAVE:
str_cpy(val, FM_WAVE[v % 6u], 8);
break;
case FMF_HZ:
fm_tenths(val, (int32_t)fm_lfo_hz10(v), 0);
*unit = "HZ";
break;
case FMF_ONOFF:
str_cpy(val, v ? "ON" : "OFF", 8);
break;
default:
fmt_int(val, (int32_t)v);
break;
}
return (int32_t)(v * 1000u / (mx ? mx : 1u));
}
/* KNOB k (0..3) turned s on sheet pg (0 OPERATOR, 1 ALL OPS) */
static void fm_knob(uint32_t pg, uint32_t k, int32_t s)
{
track_t *t = TSEL;
uint32_t tr = fm_tr(), w = fm_ui[1 + pg] % FM_NWIN, i, mx;
const fm_field_t *f = &FM_F[pg & 1u][w][k & 3u];
uint8_t v[FP_SIZE + 1u];
int32_t d = s > 0 ? 1 : -1, x;
if (!f->label || t->eng_req % NENGINES != ENGI_FM6)
return;
i = fm_at(pg, f);
mx = fm6_max(i);
memcpy(v, fm6_patch[tr], sizeof v);
switch (f->fmt) {
case FMF_RATIO: { /* one knob over both modes: x0.5 .. x31, 1 .. 1K HZ */
uint8_t *op = v + (i / FP_OP) * FP_OP;
x = clamp(fm_ratio_pos(op) + accel(EN_K1 + k, s, 36), 0, 35);
op[FP_MODE] = (uint8_t)(x >= 32);
op[FP_FC] = (uint8_t)(x >= 32 ? x - 32 : x);
break;
}
case FMF_ALG: /* what plays, into the patch; ALGO (EDIT 1) to PAT */
v[FP_ALG] = (uint8_t)clamp((int32_t)fm6_alg_of(t) + accel(EN_K1 + k, s, 32), 0, 31);
t->p[P_E0] = 0;
break;
case FMF_FB: /* the same: FEEDBACK (EDIT 1) to 0 */
v[FP_FB] = (uint8_t)clamp(clamp((int32_t)v[FP_FB] + t->p[P_E1], 0, 7) + d, 0, 7);
t->p[P_E1] = 0;
break;
default:
v[i] = (uint8_t)clamp((int32_t)v[i] + (mx > 7u ? accel(EN_K1 + k, s, (int32_t)mx) : d), 0, (int32_t)mx);
break;
}
fm6_set_patch(tr, v);
fm6_adopt(tr);
}
static void fm_op_knob(uint32_t k, int32_t s) { fm_knob(0, k, s); }
static void fm_all_knob(uint32_t k, int32_t s) { fm_knob(1, k, s); }
/* the four cards: the window's */
static void fm_cards_of(uint32_t pg)
{
const uint8_t *p = fm6_patch[fm_tr()];
uint32_t w = fm_ui[1 + pg] % FM_NWIN, k;
for (k = 0; k < 4u; k++) {
const fm_field_t *f = &FM_F[pg & 1u][w][k];
char val[12];
const char *unit;
int32_t g;
if (!f->label) {
draw_column(k, "", "", "", T_THEME, -1, ICON_NONE);
continue;
}
g = fm_val(f, fm_at(pg, f), p, TSEL, val, &unit);
draw_column(k, f->label, val, unit, VAL(k), g, ICON_NONE);
}
}
static void fm_op_cards(void) { fm_cards_of(0); }
static void fm_all_cards(void) { fm_cards_of(1); }
static void fm_op_turn(int32_t s) { fm_ui[0] = (uint8_t)clamp((int32_t)(fm_ui[0] % 6u) + s, 0, 5); }
static const char *fm_op_title(void) /* the header's: "OPERATOR 3" */
{
static char t[12];
str_cpy(t, "OPERATOR ", sizeof t);
t[9] = (char)('1' + fm_ui[0] % 6u);
t[10] = 0;
return t;
}
static const char *fm_all_title(void) { return "ALL OPS"; }
/* what the cards and the panel show besides the track's values (ui_graph.c graph_signature hashes those) */
static uint32_t fm_sig(void)
{
return (fm6_pgen[fm_tr()] + 1u) * 2246822519u ^ (fm_ui[0] + fm_ui[1] * 7u + fm_ui[2] * 49u) * 40503u ^
(ui.hot_t ? ui.hot_col + 1u : 0u) * 65537u;
}
/* ------------------------------------------------------------------ the panel: the note as the engine plays it --- */
#define FM_X0 10 /* the graph: x 10 .. 229, y 26 .. 119 (the canvas's) */
#define FM_XW 220
#define FM_HW 160 /* the held note's columns; the release the rest */
#define FM_GY 26
#define FM_GH 94
#define FM_CY 124 /* the caption's row, 12 high */
#define FM_TOP (15 << 16) /* levels Q16 log2 (6 dB a unit): full scale, */
#define FM_SPAN (10 << 16) /* the 60 dB drawn, */
#define FM_HEAT (10 << 16) /* a modulator's 60 dB of heat */
#define FM_TAU 7056u /* the log time axis' knee: 20 ms in 1/256 blocks */
#define FM_NBP 12 /* an envelope's breakpoints at most: start, stages, key up, end */
#define FM_GUIDE (ux.crypt ? T_DIM : T_LINE) /* (CRYPT's stone eats LINE) */
typedef struct {
int32_t i[FM_NBP], v[FM_NBP]; /* the block it is reached at; the level (Q16 log2 / semitone Q16) */
int16_t x[FM_NBP]; /* its column */
uint8_t n, end[4]; /* how many; the point each stage ended at (0xFF: none) */
} fm_env_line_t;
typedef struct {
fm_env_line_t op[6], pitch; /* OP1 .. OP6, the pitch envelope */
int32_t held, n, modlvl; /* the key up's block, the last; MOD LVL on the modulators (Q16) */
uint32_t car, live, alg, fb; /* bit k: OP k+1 a carrier, sounding (OUTPUT > 0) */
uint8_t q[FP_SIZE + 1u]; /* the patch through the macros */
} fm_sim_t;
/* log2 x, Q16 (x > 0): the exponent, the mantissa's log2 ~ f + 0.34 f (1 - f) (within 0.004) */
static int32_t fm_log2(uint32_t x)
{
int32_t e = 0;
uint32_t f;
while (x >= 2u << e && e < 31)
e++;
f = (e > 16 ? x >> (e - 16) : x << (16 - e)) - 65536u;
return (e << 16) + (int32_t)f + (int32_t)(((f >> 1) * ((65536u - f) >> 1) >> 14) * 22u >> 6);
}
/* block b's column: the held part, the release, each on a log axis (the attack gets room) */
static int32_t fm_warp(const fm_sim_t *s, int32_t b)
{
int32_t l0 = fm_log2(FM_TAU);
if (b <= s->held)
return (FM_HW - 1) * (fm_log2((uint32_t)b * 256u + FM_TAU) - l0) / (fm_log2((uint32_t)s->held * 256u + FM_TAU) - l0);
return FM_HW + (FM_XW - FM_HW - 1) * (fm_log2((uint32_t)(b - s->held) * 256u + FM_TAU) - l0) /
(fm_log2((uint32_t)(s->n - s->held) * 256u + FM_TAU) - l0);
}
static void fm_bp(fm_env_line_t *l, int32_t i, int32_t v)
{
if (l->n < FM_NBP) {
l->i[l->n] = i;
l->v[l->n++] = v;
}
}
/* the note (MIDI 60 + TRANSP, velocity 100), its key up at `held` (< 0: found: once every sounding carrier holds,
* a quarter more, at least 0.35 s; none by 4 s: at 4 s) and its release (the carriers 60 dB down, at most 2 s) */
static void fm_run(fm_sim_t *s, const track_t *t, int32_t held)
{
fm6_env_t e[6];
fm6_penv_t pe;
uint32_t k, prev[6], pp = 0;
int32_t b, note, cap = held >= 0 ? held : 4 * 1378, last[7];
note = 60 + s->q[FP_TRNSP] - 24;
for (k = 0; k < 6u; k++) {
fm6_op_env_init(&e[k], s->q + (5u - k) * FP_OP, note, 100);
prev[k] = 0;
if (held >= 0) {
memset(&s->op[k], 0, sizeof s->op[k]);
memset(s->op[k].end, 0xFF, 4);
fm_bp(&s->op[k], 0, 0);
}
}
fm6_penv_init(&pe, s->q);
if (held >= 0) {
memset(&s->pitch, 0, sizeof s->pitch);
memset(s->pitch.end, 0xFF, 4);
fm_bp(&s->pitch, 0, pe.level >> 8);
}
for (b = 0;; b++) {
uint32_t quiet = 1, hold = 1;
if (b == cap) {
if (held < 0) { /* none held by 4 s */
fm_run(s, t, cap);
return;
}
for (k = 0; k < 6u; k++)
fm6_env_key(&e[k], s->q + (5u - k) * FP_OP, 0);
fm6_penv_key(&pe, s->q, 0);
}
for (k = 0; k < 6u; k++) {
int32_t lv = last[k] = fm6_env_get(&e[k], s->q + (5u - k) * FP_OP) >> 8;
if ((s->car >> k & 1u) && (s->live >> k & 1u)) {
hold &= e[k].ix >= 3u;
quiet &= lv < FM_TOP - FM_SPAN;
}
if (held >= 0 && (e[k].ix != prev[k] || b + 1 == held)) {
fm_env_line_t *l = &s->op[k];
uint32_t j;
fm_bp(l, b + 1, lv);
for (j = prev[k]; j < e[k].ix && j < 4u; j++)
l->end[j] = (uint8_t)(l->n - 1u);
prev[k] = e[k].ix;
}
}
{
int32_t pv = last[6] = fm6_penv_get(&pe, s->q) >> 8;
if (held >= 0 && (pe.ix != pp || b + 1 == held)) {
uint32_t j;
fm_bp(&s->pitch, b + 1, pv);
for (j = pp; j < pe.ix && j < 4u; j++)
s->pitch.end[j] = (uint8_t)(s->pitch.n - 1u);
pp = pe.ix;
}
}
if (held < 0 && hold) { /* found: run it again with the key up there */
b++;
fm_run(s, t, b + b / 4 > 482 ? b + b / 4 : 482);
return;
}
if (held >= 0 && b >= cap && (quiet || b - cap >= 2 * 1378)) {
s->n = b + 1;
break;
}
}
s->held = cap;
for (k = 0; k < 7u; k++) { /* the end of each line, and every point's column */
fm_env_line_t *l = k < 6u ? &s->op[k] : &s->pitch;
uint32_t j;
if (l->n && l->i[l->n - 1u] < s->n) {
if (l->n == FM_NBP)
l->n--;
fm_bp(l, s->n, last[k]);
}
for (j = 0; j < l->n; j++)
l->x[j] = (int16_t)fm_warp(s, l->i[j]);
}
}
/* the patch as it plays (the macros), its algorithm, carriers and sounding operators */
static void fm_ops(fm_sim_t *s, const track_t *t)
{
uint32_t k;
memcpy(s->q, fm6_patch[trk_index(t) % NTRK], FP_SIZE);
s->alg = fm6_alg_of(t);
s->fb = (uint32_t)clamp((int32_t)s->q[FP_FB] + t->p[P_E1], 0, 7);
fm6_macro(s->q, s->alg, &t->p[P_E0]);
s->car = fm6_car_ops(s->alg);
s->live = 0;
for (k = 0; k < 6u; k++)
s->live |= (uint32_t)(s->q[(5u - k) * FP_OP + FP_OL] != 0) << k;
s->modlvl = clamp(t->p[P_E2], -64, 63) * 24 << 8; /* (fm6_render: microsteps of 1/32 of an outlevel step) */
}
static void fm_sim(fm_sim_t *s, const track_t *t)
{
fm_ops(s, t);
s->held = 0;
fm_run(s, t, -1);
}
/* line l's level at column x: between its breakpoints */
static int32_t fm_at_x(const fm_env_line_t *l, int32_t x)
{
uint32_t j;
for (j = 1; j < l->n; j++)
if (x <= l->x[j]) {
int32_t xa = l->x[j - 1u], xb = l->x[j];
return xb <= xa ? l->v[j] : l->v[j - 1u] + (l->v[j] - l->v[j - 1u]) * (x - xa) / (xb - xa);
}
return l->n ? l->v[l->n - 1u] : 0;
}
static int32_t fm_lvy(int32_t v)
{
return FM_GY + 4 + clamp(FM_TOP - v, 0, FM_SPAN) * (FM_GH - 9) / FM_SPAN;
}
/* the operators feeding OP c+1, directly or through others (bit k: OP k+1) */
static uint32_t fm_feeders(uint32_t alg, uint32_t c)
{
uint8_t m[6];
uint32_t seen = 0, todo = 1u << c, k;
fm6_routes(alg, m);
while (todo) {
for (k = 0; !(todo >> k & 1u); k++)
;
todo &= ~(1u << k);
todo |= m[k] & ~seen;
seen |= m[k];
}
return seen;
}
/* carrier c's heat at column x, 0 .. 11: the strongest modulator feeding it (and the feedback, by FB / 7, where its
* operator is c or one of them), its level over its top 60 dB, the square root (a little FM is heard at once) */
static uint32_t fm_heat(const fm_sim_t *s, uint32_t c, uint32_t fed, int32_t x)
{
static const uint8_t SQ[11] = {1, 5, 13, 26, 43, 64, 89, 119, 153, 191, 233}; /* 256 ((i + 0.5) / 11)^2 */
int32_t best = 0, n;
uint32_t k, f = fm6_fb_op(s->alg), i;
for (k = 0; k < 6u; k++)
if ((fed >> k & 1u) && (s->live >> k & 1u)) {
n = clamp((fm_at_x(&s->op[k], x) + s->modlvl - (FM_TOP - FM_HEAT)) * 16 / (FM_HEAT >> 4), 0, 256);
best = n > best ? n : best;
}
if (s->fb && (s->live >> f & 1u) && (f == c || (fed >> f & 1u))) {
int32_t lv = fm_at_x(&s->op[f], x) + ((s->car >> f & 1u) ? 0 : s->modlvl);
n = clamp((lv - (FM_TOP - FM_HEAT)) * 16 / (FM_HEAT >> 4), 0, 256) * (int32_t)s->fb / 7;
best = n > best ? n : best;
}
for (i = 0; i < 11u && best >= SQ[i]; i++)
;
return i;
}
/* the 12 shades, a sine to FM's bite: cool blue to REC; (FM6 LAB T) CRYPT fire (ash, blood, ember, gold, flame), NEON
* the night to the sunset (cyan, violet, pink, orange, yellow), QUARK energy (dim cyan, cyan, white, gold) */
static void fm_ramp(uint16_t *r)
{
uint16_t st[5];
uint32_t n = 2, i;
if (ux.crypt) {
st[0] = T_DIM, st[1] = CR_BLOOD, st[2] = CR_EMBER, st[3] = CR_GOLD, st[4] = CR_FLAME, n = 5;
} else if (ux.neon) {
st[0] = T_ACCENT, st[1] = NE_VIOLET, st[2] = T_THEME, st[3] = NE_ORANGE, st[4] = NE_YELLOW, n = 5;
} else if (ux.quark) {
st[0] = ux_mix(T_SURF, T_THEME, 40), st[1] = T_THEME, st[2] = T_TEXT, st[3] = T_ACCENT, n = 4;
} else {
st[0] = ux_mix(T_SURF, RGB(40, 92, 232), 80), st[1] = T_REC;
}
for (i = 0; i < 12u; i++)
r[i] = ne_ramp(st, n, (int32_t)i * 1000 / 11);
}
/* a round brush w px wide (2..5) at x, y ((FM6 LAB T) CRYPT: square, its ASCII strokes' chunky pixels) */
static void fm_brush(int32_t x, int32_t y, int32_t w, uint16_t c)
{
int32_t a = -(w / 2);
if (w > 3 && !ux.crypt) {
cv_rect(x + a, y + a + 1, w, w - 2, c);
cv_rect(x + a + 1, y + a, w - 2, w, c);
} else
cv_rect(x + a, y + a, w, w, c);
}
/* a straight segment with the brush; its colour per column from sh[shade[column]] (or c when shade is 0); w < 0: dotted
* (QUARK: a bubble chamber's track), a dot every 3 px */
static void fm_seg(int32_t xa, int32_t ya, int32_t xb, int32_t yb, int32_t w, uint16_t c, const uint8_t *shade,
const uint16_t *sh)
{
int32_t n = 2 * ((xb > xa ? xb - xa : xa - xb) > (yb > ya ? yb - ya : ya - yb) ? (xb > xa ? xb - xa : xa - xb)
: (yb > ya ? yb - ya : ya - yb)), j;
int dot = w < 0;
if (dot)
w = -w;
if (n < 1)
n = 1;
for (j = 0; j <= n; j++) {
int32_t x = xa + (xb - xa) * j / n, y = ya + (yb - ya) * j / n;
if (!dot || j / 2 % 3 == 0)
fm_brush(x, y, w, shade ? sh[shade[clamp(x - FM_X0, 0, FM_XW - 1)]] : c);
}
}
/* a line in c over its shadow ((FM6 LAB T) NEON: over its glow, a tube's) */
static void fm_seg2(int32_t xa, int32_t ya, int32_t xb, int32_t yb, int32_t w, uint16_t c)
{
if (ux.neon)
fm_seg(xa, ya, xb, yb, w + 2, ux_mix(c, T_SURF, 62), 0, 0);
else
fm_seg(xa, ya + 1, xb, yb + 1, w, T_BG, 0, 0);
fm_seg(xa, ya, xb, yb, w, c, 0, 0);
}
/* (FM6 LAB T) the sound under a line (PITCH, LFO; CRYPT and QUARK's D: the loudest carrier), column x from y to the
* foot: RAISE; CRYPT the ASCII shade (a dot every 4 px, every 6th column), NEON the sun's bands, QUARK a Monte Carlo
* fill */
static void fm_under(int32_t x, int32_t y, int32_t foot)
{
if (ux.crypt) {
if ((x - FM_X0) % 6 == 0)
for (y = (y + 4) & ~3; y < foot; y += 4)
cv_pset(x, y, T_DIM);
} else if (ux.neon)
ne_band_col(x, y, FM_GY, foot);
else if (ux.quark)
qk_mc(x, y, foot);
else
cv_rect(x, y, 1, foot - y, T_RAISE);
}
static void fm_line(const fm_env_line_t *l, int32_t dy, int32_t w, uint16_t c, const uint8_t *shade, const uint16_t *sh)
{
uint32_t j;
for (j = 1; j < l->n; j++)
fm_seg(FM_X0 + l->x[j - 1u], fm_lvy(l->v[j - 1u]) + dy, FM_X0 + l->x[j], fm_lvy(l->v[j]) + dy, w, c, shade, sh);
}
/* a breakpoint's handle: a ring 9 px across on a dark halo; filled: the one the knob just turned. (FM6 LAB T) CRYPT a
* skull (the one turned aflame, its eyes blood), NEON a sparkle (the one turned cyan and twice the size), QUARK a
* nucleus (the one turned gold, larger) */
static void fm_ring(int32_t x, int32_t y, int filled)
{
int32_t dx, dy;
if (ux.crypt) {
for (dx = 0; dx < 4; dx++) /* (in a dark outline: on the lines) */
cr_skull(x - 4 + (dx == 0) - (dx == 1), y - 4 + (dx == 2) - (dx == 3), T_BG, T_BG, 0);
cr_skull(x - 4, y - 4, filled ? CR_FLAME : T_TEXT, filled ? CR_BLOOD : T_BG, 0);
return;
}
if (ux.neon) {
ne_spark(x, y, filled ? T_ACCENT : T_THEME, filled ? 2 : 1);
return;
}
if (ux.quark) {
qk_disc(x, y, 3, T_SURF);
qk_nucleus(x, y, filled ? T_ACCENT : T_THEME, filled ? 9 : 7);
return;
}
for (dy = -5; dy <= 5; dy++)
for (dx = -5; dx <= 5; dx++) {
int32_t d2 = dx * dx + dy * dy;
if (d2 <= 30)
cv_pset(x + dx, y + dy, d2 > 20 ? T_BG : d2 >= 7 || filled ? T_TEXT : T_SURF);
}
}
/* "12 MS", "0.67 S", "4.3 S" (blocks of 32 samples at 44.1 kHz) */
static void fm_secs(char *b, int32_t blocks)
{
int32_t ms = blocks * 1000 / 1378;
if (ms < 100) {
fmt_int(b, ms < 1 ? 1 : ms);
str_cpy(b + str_len(b), " MS", 4);
} else if (ms < 1000) {
fm_hundredths(b, ms / 10);
str_cpy(b + str_len(b), " S", 3);
} else {
fm_tenths(b, ms / 100, 0);
str_cpy(b + str_len(b), " S", 3);
}
}
/* the caption's right: the length; and the key (SINE, the ramp, FM) */
static void fm_caption(const fm_sim_t *s, const uint16_t *sh)
{
char b[16];
uint32_t j;
fm_secs(b, s->n);
GFX_HOOK_ALIGN(0, FM_CY, 0, FM_CY + 12, AL_V, "FM6 graph caption on its row");
cv_text_r(229, FM_CY + CAP_IN(S, 12), &AF_S, b, T_MID, T_SURF);
if (!sh)
return;
cv_text_r(129, FM_CY + CAP_IN(S, 12), &AF_S, "SINE", T_DIM, T_SURF);
for (j = 0; j < 12u; j++)
cv_rect(132 + (int32_t)j * 3, FM_CY + 3, 3, 7, sh[j]);
cv_text(171, FM_CY + CAP_IN(S, 12), &AF_S, "FM", T_DIM);
}
/* the operator tabs: OP1 .. OP6 outlined, the one picked in TEXT; under each its line's colour (a carrier's: the
* ramp: it shows the heat); TONE: the ratio beside the number */
static void fm_tabs(const fm_sim_t *s, const uint16_t *sh, int ratios)
{
uint32_t k, sel = fm_ui[0] % 6u;
for (k = 0; k < 6u; k++) {
int32_t x = 8 + (int32_t)k * 38;
const uint8_t *op = fm6_patch[fm_tr()] + (5u - k) * FP_OP;
int on = k == sel, live = s->live >> k & 1u;
uint16_t ink = on ? T_TEXT : live ? T_MID : T_DIM;
char b[8];
if (ux.crypt || ux.neon) { /* ((FM6 LAB T) stone or glass; the one picked: a gold frame, */
cv_rrect(x, 4, 34, 17, 3, T_SURF, T_SURF); /* a laser; QUARK: a cell's brackets, the one picked gold) */
if (on && ux.crypt)
cr_frame2(x - 2, 2, 38, 21, CR_GOLD);
else if (on)
ne_laser(x, 4, 34, 17, T_SURF);
} else if (ux.quark) {
qk_corners(x, 4, 34, 17, on ? T_ACCENT : T_DIM, 5);
} else {
cv_frame(x, 4, 34, 17, on ? T_TEXT : T_DIM);
if (on)
cv_frame(x + 1, 5, 32, 15, T_TEXT);
}
if (ratios) {
b[0] = (char)('1' + k);
b[1] = 0;
cv_text_on(x + 5, 4 + CAP_IN(S, 17), &AF_S, b, ink, T_SURF);
if (op[FP_MODE])
str_cpy(b, ((const char *const[]){"1", "10", "100", "1K"})[op[FP_FC] & 3u], sizeof b);
else if (op[FP_FC])
fmt_int(b, op[FP_FC]);
else
str_cpy(b, ".5", sizeof b);
str_cpy(b + str_len(b), op[FP_MODE] ? "" : "x", sizeof b - str_len(b));
cv_text_r(x + 30, 4 + CAP_IN(S, 17), &AF_S, b, live ? T_MID : T_DIM, T_SURF);
if (ux.crypt || ux.neon) /* ((FM6 LAB T) the pixel letters run together: a divider) */
cv_rect(x + 12, 8, 1, 9, T_DIM);
} else {
b[0] = 'O', b[1] = 'P', b[2] = (char)('1' + k), b[3] = 0;
GFX_HOOK_ALIGN(x, 4, x + 34, 21, AL_HV, "FM6 operator tab name centred");
cv_text_in(x, 4 + CAP_IN(S, 17), 34, &AF_S, b, ink, T_SURF);
}
if (!live)
continue;
if (s->car >> k & 1u) {
uint32_t j;
for (j = 0; j < 12u; j++)
cv_rect(x + 3 + (int32_t)j * 2 + (j > 5u) * 4, 23, 2, 2, sh[j]);
} else
cv_rect(x + 3, 23, 28, 2, T_TRK(k));
}
}
/* the handles on line l's stage ends (stages 0..3); filled: hot (0xFF none) */
static void fm_handles(const fm_env_line_t *l, uint32_t hot, int32_t (*y)(int32_t))
{
uint32_t j;
for (j = 0; j < 4u; j++)
if (l->end[j] != 0xFFu)
fm_ring(FM_X0 + l->x[l->end[j]], y(l->v[l->end[j]]), j == hot);
}
/* the stage a window's hot knob moves (ENV 1: K1 K2 stage 1, K3 K4 stage 2; ENV 2: 3, 4), 0xFF: none */
static uint32_t fm_hot_stage(uint32_t w)
{
if (!ui.hot_t || (w != 1u && w != 2u))
return 0xFFu;
return (w - 1u) * 2u + ui.hot_col / 2u;
}
/* the loudest sounding carrier's level at column x */
static int32_t fm_loud(const fm_sim_t *s, int32_t x)
{
int32_t lv = 0, v;
uint32_t k;
for (k = 0; k < 6u; k++)
if ((s->car & s->live) >> k & 1u && (v = fm_at_x(&s->op[k], x)) > lv)
lv = v;
return lv;
}
/* D: the envelopes, the carriers shaded by their heat, the picked operator's handles */
static void fm_lines(const fm_sim_t *s, const uint16_t *sh, uint32_t w)
{
uint8_t shade[FM_XW];
uint16_t glow[12];
uint32_t k, sel = fm_ui[0] % 6u, pass, best = 0, bk = 0;
int32_t x, bx = 0;
char b[24];
for (k = 0; k < 6u; k++) /* where it bites most (the carrier, the column) */
if ((s->car & s->live) >> k & 1u) {
uint32_t fed = fm_feeders(s->alg, k), h;
for (x = 0; x < FM_XW; x++)
if ((h = fm_heat(s, k, fed, x)) > best)
best = h, bx = x, bk = k;
}
if (ux.neon) { /* ((FM6 LAB T) NEON: the sun and the grid floor behind; */
ne_sun(FM_X0 + 172, FM_GY + FM_GH - 28, 24, 62); /* the brightest moment a laser) */
ne_grid(FM_X0, FM_X0 + FM_XW, FM_GY + FM_GH - 28, FM_GY + FM_GH, NE_VIOLET, T_SURF);
if (best) {
cv_rect(FM_X0 + bx - 1, FM_GY, 3, FM_GH, ux_mix(T_ACCENT, T_SURF, 70));
cv_rect(FM_X0 + bx, FM_GY, 1, FM_GH, T_ACCENT);
}
} else if (ux.crypt || ux.quark) { /* (CRYPT's shade, QUARK's energy under the sound) */
for (x = 0; x < FM_XW; x++)
fm_under(FM_X0 + x, fm_lvy(fm_loud(s, x)), FM_GY + FM_GH);
if (ux.quark && best) /* (QUARK: a collision where it bites most) */
qk_burst(FM_X0 + bx, fm_lvy(fm_at_x(&s->op[bk], bx)), 5, 0x9E3779B9u, 18, T_SURF);
}
for (x = FM_GY; x < FM_GY + FM_GH; x += 2) /* the key up: dotted */
cv_pset(FM_X0 + FM_HW, x, T_DIM);
for (k = 0; k < 12u; k++)
glow[k] = ux_mix(sh[k], T_SURF, 62);
for (pass = 0; pass < 3u; pass++) /* the modulators, the carriers, the one picked */
for (k = 0; k < 6u; k++) {
int car = s->car >> k & 1u, wd = k == sel ? 3 : 2;
if (!(s->live >> k & 1u) || (pass == 2u) != (k == sel) || (pass < 2u && (uint32_t)car != pass))
continue;
if (!car) {
fm_env_line_t l = s->op[k];
uint32_t j;
uint16_t c = k == sel ? T_TRK(k) : ux_mix(T_SURF, T_TRK(k), 70);
for (j = 0; j < l.n; j++)
l.v[j] += s->modlvl;
if (ux.neon) /* (NEON: a tube's glow; QUARK: a bubble chamber's dots) */
fm_line(&l, 0, wd + 2, ux_mix(c, T_SURF, 62), 0, 0);
fm_line(&l, 0, ux.quark ? -wd : wd, c, 0, 0);
continue;
}
{
uint32_t fed = fm_feeders(s->alg, k);
for (x = 0; x < FM_XW; x++)
shade[x] = (uint8_t)fm_heat(s, k, fed, x);
}
if (ux.neon)
fm_line(&s->op[k], 0, 7, 0, shade, glow); /* (its glow) */
else
fm_line(&s->op[k], 1, 5, T_BG, 0, 0); /* a shadow under it */
fm_line(&s->op[k], 0, k == sel ? 5 : 4, 0, shade, sh);
}
if (s->live >> sel & 1u) {
fm_env_line_t l = s->op[sel];
uint32_t j;
if (!(s->car >> sel & 1u))
for (j = 0; j < l.n; j++)
l.v[j] += s->modlvl;
fm_handles(&l, fm_hot_stage(w), fm_lvy);
}
if (best) { /* where it bites most: a mark under it, the caption */
int32_t r, lo = 0, hi = s->n; /* (the block at that column: the axis rises) */
if (ux.crypt) { /* ((FM6 LAB T) CRYPT: a flame; NEON, QUARK: theirs behind) */
static const char *const FL[6] = {" # ", " ## ", " #.# ", "##.##", "#...#", " ### "};
cr_sprite(FM_X0 + bx - 2, FM_GY + FM_GH - 3, FL, 6, CR_EMBER, CR_FLAME);
} else if (!ux.neon && !ux.quark)
for (r = 0; r < 4; r++)
cv_rect(FM_X0 + bx - r, FM_GY + FM_GH + 1 + r, 2 * r + 1, 1, T_TEXT);
while (lo < hi) {
int32_t mid = (lo + hi) / 2;
if (fm_warp(s, mid) < bx)
lo = mid + 1;
else
hi = mid;
}
str_cpy(b, "BRIGHTEST ", sizeof b);
fm_secs(b + 10, lo);
} else {
uint32_t live = s->car & s->live, n = 0;
for (; live; live &= live - 1u)
n++;
str_cpy(b, n == 1u ? "PURE SINE" : n ? "NO MODULATION" : "NO CARRIER SOUNDS", sizeof b);
}
cv_text_on(10, FM_CY + CAP_IN(S, 12), &AF_S, b, T_MID, T_SURF);
fm_caption(s, sh);
}
/* KEYS and MORE: the picked operator's level across the keyboard (fm6_scale_level, MIDI 21 .. 108): 0 dB at the top
* third, -48 dB at the bottom; BREAK a dotted line with its note, C4 a dot; the octaves under it */
static int32_t fm_keys_y(const uint8_t *op, uint32_t note, int32_t zy, int32_t rng)
{
int32_t q = fm6_scale_level((int32_t)note, op) * 3; /* an outlevel step 3/4 dB: in 1/4 dB */
return zy + clamp(-q, -48, 192) * rng / 192;
}
static void fm_keys(uint16_t c)
{
const uint8_t *op = fm6_patch[fm_tr()] + (5u - fm_ui[0] % 6u) * FP_OP;
int32_t zy = FM_GY + 21, kb = FM_GY + 91, rng = kb - 6 - zy, o, x, bx;
uint32_t n;
char b[16];
cv_rect(FM_X0, zy, FM_XW, 1, FM_GUIDE);
cv_text_r(229, zy - 13 + CAP_IN(S, 12), &AF_S, "0 DB", T_DIM, T_SURF);
cv_text_r(229, kb - 14 + CAP_IN(S, 12), &AF_S, "-48 DB", T_DIM, T_SURF);
for (o = 1; o < 8; o++) { /* the octaves C1 .. C7: bands, C2 C4 C6 named */
int32_t xa = FM_X0 + (12 * o + 12 - 21) * (FM_XW - 1) / 87, xb = FM_X0 + (12 * o + 24 - 21) * (FM_XW - 1) / 87;
cv_rect(xa, kb + 2, (xb > FM_X0 + FM_XW - 1 ? FM_X0 + FM_XW - 1 : xb) - xa, 4, o & 1 ? T_RAISE : T_DIM);
if (!(o & 1)) {
b[0] = 'C', b[1] = (char)('0' + o), b[2] = 0;
cv_text_on(xa, kb + 6 + CAP_IN(S, 12), &AF_S, b, T_DIM, T_SURF);
}
}
bx = FM_X0 + clamp((int32_t)op[FP_BP] * (FM_XW - 1) / 87, 0, FM_XW - 1); /* BREAK: MIDI BP + 21 */
if (ux.crypt || ux.neon || ux.quark) /* ((FM6 LAB T) the theme's fill under the curve) */
for (x = 0; x < FM_XW; x++)
fm_under(FM_X0 + x, fm_keys_y(op, 21u + (uint32_t)x * 87u / (FM_XW - 1), zy, rng), kb);
if (ux.neon) { /* (NEON: BREAK a laser) */
cv_rect(bx - 1, FM_GY + 4, 3, kb - 6 - FM_GY, ux_mix(T_ACCENT, T_SURF, 70));
cv_rect(bx, FM_GY + 4, 1, kb - 6 - FM_GY, T_ACCENT);
} else
for (x = FM_GY + 4; x < kb - 2; x += 2)
cv_pset(bx, x, T_TEXT);
str_cpy(b, "BREAK ", sizeof b);
note_name(b + 6, op[FP_BP] + 21u);
cv_text_on(bx + 4 > 160 ? bx - 4 - text_w(&AF_S, b) : bx + 4, FM_GY + CAP_IN(S, 12), &AF_S, b, T_TEXT, T_SURF);
for (n = 21; n < 108u; n++) {
int32_t xa = FM_X0 + (int32_t)(n - 21u) * (FM_XW - 1) / 87, xn = FM_X0 + (int32_t)(n - 20u) * (FM_XW - 1) / 87;
fm_seg2(xa, fm_keys_y(op, n, zy, rng), xn, fm_keys_y(op, n + 1u, zy, rng), 2, c);
}
if (ux.crypt) /* (CRYPT: a dagger planted where the curve breaks) */
cr_dagger(bx - 4, fm_keys_y(op, op[FP_BP] + 21u, zy, rng) - 14, CR_GOLD);
x = FM_X0 + (60 - 21) * (FM_XW - 1) / 87;
if (ux.crypt || ux.neon || ux.quark) /* C4: the theme's handle (a skull, a sparkle, a nucleus) */
fm_ring(x, fm_keys_y(op, 60, zy, rng), 0);
else
cv_rect(x - 2, fm_keys_y(op, 60, zy, rng) - 2, 5, 5, T_TEXT);
str_cpy(b, "C7 ", sizeof b);
fm_signed(b + 3, fm6_scale_level(96, op) * 3 / 4);
str_cpy(b + str_len(b), " DB", sizeof b - str_len(b));
cv_text_on(FM_X0, FM_GY + CAP_IN(S, 12), &AF_S, b, T_MID, T_SURF);
}
/* ALGO: the chart (graph_fm6, the picked operator lit) and what the operator does in it */
static void fm_algo(const track_t *t, uint16_t c)
{
uint8_t m[6];
uint32_t alg = fm6_alg_of(t), sel = fm_ui[0] % 6u, k, n = 0;
char b[32];
cv_oy = GOY + graph_pad();
graph_fm6(t, c);
cv_oy = 0;
fm6_routes(alg, m);
str_cpy(b, "OP", sizeof b);
b[2] = (char)('1' + sel);
b[3] = 0;
if (!fm6_patch[fm_tr()][(5u - sel) * FP_OP + FP_OL])
str_cpy(b + 3, " IS SILENT: OUTPUT 0", sizeof b - 3u);
else if (fm6_car_ops(alg) >> sel & 1u)
str_cpy(b + 3, " GOES TO THE OUTPUT", sizeof b - 3u);
else {
str_cpy(b + 3, " MODULATES", sizeof b - 3u);
for (k = 0; k < 6u; k++)
if (m[k] >> sel & 1u) {
str_cpy(b + str_len(b), n++ ? ", OP" : " OP", sizeof b - str_len(b));
b[str_len(b) + 1u] = 0;
b[str_len(b)] = (char)('1' + k);
}
}
cv_text_on(10, FM_CY + CAP_IN(S, 12), &AF_S, b, T_MID, T_SURF);
}
/* PITCH: the pitch envelope over the note (the sound's outline behind, on its time axis); LFO, DEPTH: the vibrato
* over two seconds from the key, the tremolo under it */
static int32_t fm_prng; /* (fm_pitch_y's range, 1/100 semitone) */
static int32_t fm_pitch_y(int32_t v) /* a semitone Q16 (from octaves Q16 x 12) */
{
return FM_GY + FM_GH / 2 - clamp(v, -fm_prng * 65536 / 100, fm_prng * 65536 / 100) / 64 * (FM_GH / 2 - 6) /
(fm_prng * 1024 / 100);
}
static void fm_range_labels(void)
{
char b[12];
b[0] = '+';
if (fm_prng < 100)
fm_hundredths(b + 1, fm_prng);
else
fmt_int(b + 1, fm_prng / 100);
str_cpy(b + str_len(b), " ST", sizeof b - str_len(b));
cv_text_on(10, FM_GY + CAP_IN(S, 12), &AF_S, b, T_MID, T_SURF);
b[0] = '-';
cv_text_on(10, FM_GY + FM_GH - 12 + CAP_IN(S, 12), &AF_S, b, T_MID, T_SURF);
}
static int32_t fm_range(int32_t cents)
{
static const int16_t R[9] = {10, 25, 50, 100, 200, 400, 1200, 2400, 4800};
uint32_t i;
for (i = 0; i < 8u && R[i] < cents; i++)
;
return R[i];
}
static void fm_pitch(const fm_sim_t *s, uint16_t c, uint32_t w)
{
fm_env_line_t l = s->pitch;
int32_t x, m = 0;
uint32_t j, flat = 1;
for (x = 0; x < FM_XW; x++) /* the sound behind, its outline (the theme's fill) */
fm_under(FM_X0 + x, fm_lvy(fm_loud(s, x)), FM_GY + FM_GH);
for (j = 0; j < l.n; j++) { /* octaves -> semitones; the range */
l.v[j] *= 12;
x = (l.v[j] < 0 ? -l.v[j] : l.v[j]) * 100 / 65536;
m = x > m ? x : m;
flat &= l.v[j] == 0;
}
fm_prng = fm_range(m);
cv_rect(FM_X0, FM_GY + FM_GH / 2, FM_XW, 1, FM_GUIDE);
for (j = 1; j < l.n; j++)
fm_seg2(FM_X0 + l.x[j - 1u], fm_pitch_y(l.v[j - 1u]), FM_X0 + l.x[j], fm_pitch_y(l.v[j]), 2, c);
fm_handles(&l, ui.hot_t && (w == 1u || w == 2u) ? (w - 1u) * 2u + ui.hot_col / 2u : 0xFFu, fm_pitch_y);
fm_range_labels();
cv_text_on(10, FM_CY + CAP_IN(S, 12), &AF_S, flat ? "NO PITCH MOVEMENT" : "PITCH OVER THE NOTE", T_MID, T_SURF);
fm_caption(s, 0);
}
static void fm_lfo(const fm_sim_t *s, uint16_t c)
{
const uint8_t *q = s->q;
fm6_lfo_t lf;
fm6_env_t e[6];
int16_t vib[FM_XW];
uint8_t loud[FM_XW], trem[FM_XW];
int32_t b, x = 0, m = 0, in = -1, note = 60 + q[FP_TRNSP] - 24;
uint32_t k, pmd = (uint32_t)(q[FP_LPMD] % 100u) * 165u >> 6, amd = (uint32_t)(q[FP_LAMD] % 100u) * 165u >> 6;
char t[40];
memset(&lf, 0, sizeof lf);
fm6_lfo_reset(&lf, q);
fm6_lfo_key(&lf);
for (k = 0; k < 6u; k++)
fm6_op_env_init(&e[k], q + (5u - k) * FP_OP, note, 100);
for (b = 0; b < 2 * 1378 && x < FM_XW; b++) { /* two seconds, a column every 12.5 blocks */
int32_t v = fm6_lfo_sample(&lf), d = fm6_lfo_delay(&lf), lv = 0;
int32_t sens = FM6_PMS[q[FP_LPMS] & 7u] * (v - (1 << 23));
int32_t pm = (int32_t)(((int64_t)(pmd * (uint32_t)d) * sens) >> 39); /* Q24 octaves (fm6_note_compute) */
uint32_t am = (uint32_t)(((int64_t)((amd * (uint32_t)d) >> 8) * ((1 << 24) - v)) >> 24);
for (k = 0; k < 6u; k++) {
int32_t ev = fm6_env_get(&e[k], q + (5u - k) * FP_OP) >> 8;
if ((s->car & s->live) >> k & 1u)
lv = ev > lv ? ev : lv;
}
if (in < 0 && d >= 1 << 22 && (pmd || amd))
in = b;
if (b >= x * (2 * 1378 - 1) / (FM_XW - 1)) {
vib[x] = (int16_t)clamp(pm / 13981, -32767, 32767); /* cents (a cent: 13981 in Q24 octaves) */
loud[x] = (uint8_t)fm_lvy(lv);
trem[x] = (uint8_t)clamp((int32_t)(am >> 19), 0, 24); /* (Q24: up to 24 px of dip) */
m = (vib[x] < 0 ? -vib[x] : vib[x]) > m ? (vib[x] < 0 ? -vib[x] : vib[x]) : m;
x++;
}
}
for (b = 0; b < x; b++)
fm_under(FM_X0 + b, loud[b], FM_GY + FM_GH);
fm_prng = fm_range(m);
cv_rect(FM_X0, FM_GY + FM_GH / 2, FM_XW, 1, FM_GUIDE);
for (b = 1; b < x; b++)
if (amd)
cv_rect(FM_X0 + b, FM_GY + FM_GH - 3 - trem[b], 1, 2, T_MID);
if (ux.crypt && x > 24) { /* ((FM6 LAB T) CRYPT: the vibrato a snake, as the LFO's: its */
int32_t e = x - 12; /* belly under it, gold scales, its head at the end) */
for (b = 1; b < e; b++)
fm_seg(FM_X0 + b - 1, fm_pitch_y(vib[b - 1] * 65536 / 100) + 2, FM_X0 + b,
fm_pitch_y(vib[b] * 65536 / 100) + 2, 2, ux_mix(c, T_BG, 55), 0, 0);
for (b = 1; b < e; b++)
fm_seg(FM_X0 + b - 1, fm_pitch_y(vib[b - 1] * 65536 / 100), FM_X0 + b, fm_pitch_y(vib[b] * 65536 / 100),
2, c, 0, 0);
for (b = 6; b < e - 4; b += 8)
cv_rect(FM_X0 + b, fm_pitch_y(vib[b] * 65536 / 100), 2, 1, CR_GOLD);
cr_head(FM_X0 + e, fm_pitch_y(vib[e] * 65536 / 100) + 1, c);
} else
for (b = 1; b < x; b++)
fm_seg2(FM_X0 + b - 1, fm_pitch_y(vib[b - 1] * 65536 / 100), FM_X0 + b, fm_pitch_y(vib[b] * 65536 / 100), 2, c);
fm_range_labels();
if (!pmd && !amd)
str_cpy(t, "VIBRATO AND TREMOLO AT 0", sizeof t);
else {
str_cpy(t, pmd ? "VIBRATO " : "TREMOLO ", sizeof t);
fm_tenths(t + 8, (int32_t)fm_lfo_hz10(q[FP_LFS]), 0);
str_cpy(t + str_len(t), " HZ, IN AFTER ", sizeof t - str_len(t));
fm_secs(t + str_len(t), in < 0 ? 0 : in);
}
cv_text_on(10, FM_CY + CAP_IN(S, 12), &AF_S, t, T_MID, T_SURF);
cv_text_r(229, FM_CY + CAP_IN(S, 12), &AF_S, "2.0 S", T_MID, T_SURF);
}
/* the scroll bar: where the knobs are among the windows */
static void fm_scroll(uint32_t w)
{
int32_t h = 132 / (int32_t)FM_NWIN;
cv_rect(236, 4, 2, 132, T_RAISE);
cv_rect(236, 4 + (int32_t)w * h, 2, h, T_MID);
}
static void fm_draw(uint32_t pg, const track_t *t, uint16_t c)
{
static fm_sim_t s __attribute__((section(".pool"))); /* (1.2 KB: off the stack and the ISR's globals) */
uint16_t sh[12];
uint32_t w = fm_ui[1 + pg] % FM_NWIN;
fm_ramp(sh);
if (pg && w == FMW_ALGO) {
fm_algo(t, c);
} else if (!pg && (w == FMW_KEYS || w == FMW_MORE)) {
fm_ops(&s, t);
fm_tabs(&s, sh, 0);
fm_keys(c);
} else {
fm_sim(&s, t);
if (pg && (w == FMW_LFO || w == FMW_DEPTH))
fm_lfo(&s, c);
else if (pg)
fm_pitch(&s, c, w);
else {
fm_tabs(&s, sh, w == FMW_TONE);
fm_lines(&s, sh, w);
}
}
fm_scroll(w);
}
static void graph_fm_op(const track_t *t, uint16_t c) { fm_draw(0, t, c); }
static void graph_fm_all(const track_t *t, uint16_t c) { fm_draw(1, t, c); }
+23 -11
View File
@@ -1136,6 +1136,16 @@ static void graph_fm6(const track_t *t, uint16_t c)
y[k] = bus - 6 - FM_BH - 23 * (int32_t)(FM6_CELL[alg][k] >> 4);
if (car >> k & 1u) { cl = x[k] < cl ? x[k] : cl; cr = x[k] > cr ? x[k] : cr; }
}
if (sheet_of(cur_page()->graph)) { /* ((FM6 LAB T) ALL OPS: the theme's mark round the operator picked,
* under the chart: a gold frame, a laser, a cell's brackets) */
k = fm_ui[0] % 6u;
if (ux.crypt)
cv_frame(x[k] - 12, y[k] - 2, 25, FM_BH + 4, CR_GOLD);
else if (ux.neon)
ne_laser(x[k] - 12, y[k] - 2, 25, FM_BH + 4, T_SURF);
else if (ux.quark)
qk_corners(x[k] - 13, y[k] - 3, 27, FM_BH + 6, T_ACCENT, 4);
}
for (k = 0; k < 6u; k++) { /* into k: its sources down to its jog row, across, down */
for (j = 0; j < 6u; j++)
if (m[k] >> j & 1u) {
@@ -1154,9 +1164,10 @@ static void graph_fm6(const track_t *t, uint16_t c)
fm_bus(cl, cr, bus);
FM6_CHART_HOOK(FMH_FB, fbop, 0);
fm_loop(x[fbop], y[fbop], hot == P_E1 ? T_ACCENT : fb ? T_MID : T_DIM);
for (k = 0; k < 6u; k++) {
uint32_t on = pt[(5u - k) * FP_OP + FP_OL] != 0, fill_c = (car >> k & 1u) && on;
uint16_t f = hotset >> k & 1u ? T_ACCENT : c, fill = fill_c ? f : T_RAISE;
for (k = 0; k < 6u; k++) { /* ((FM6 LAB) ALL OPS: the operator picked, ACCENT) */
uint32_t on = pt[(5u - k) * FP_OP + FP_OL] != 0, pick = sheet_of(cur_page()->graph) && k == fm_ui[0] % 6u;
uint32_t fill_c = ((car >> k & 1u) && on) || pick;
uint16_t f = hotset >> k & 1u || pick ? T_ACCENT : c, fill = fill_c ? f : T_RAISE;
char n[2] = {(char)('1' + k), 0};
FM6_CHART_HOOK(FMH_BOX, k, 0);
cv_rrect(x[k] - 10, y[k], 21, FM_BH, 3, fill, T_SURF);
@@ -1286,13 +1297,13 @@ static void page_title(char *ti)
str_cpy(ti + str_len(ti), N_SCALE[clamp(t->p[P_SCALE], 0, (int32_t)(sizeof N_SCALE / sizeof N_SCALE[0]) - 1)], 8);
}
}
/* (Skiff U4, L5) where the page is in its family, for the footer: "2/3" ("": a family of one; DRUM-X's sheet: what
* SELECT does) */
/* (Skiff U4, L5) where the page is in its family, for the footer: "2/3" ("": a family of one; a sheet (DRUM-X's,
* FM6's): what SELECT does) */
static void page_pos(char *ti)
{
uint32_t i, n = 0, k = 0;
ti[0] = 0;
if (cur_page()->graph == GR_DXSND) {
if (sheet_of(cur_page()->graph)) {
str_cpy(ti, "SELECT: ROWS", 20);
return;
}
@@ -1352,8 +1363,8 @@ static uint32_t graph_signature(void)
}
if (pg->graph == GR_MOD)
h ^= (mod_ui_slot + 1u) * 40503u;
if (pg->graph == GR_DXSND) /* (Skiff phase 7) the DRUM-X sound edited (ui_dx.c) */
h ^= dx_sig();
if (sheet_of(pg->graph)) /* (Skiff phase 7; FM6 LAB) a sheet's: what it edits (SHEETS) */
h ^= sheet_of(pg->graph)->sig();
if (pg->graph == GR_SLCR && t->p[P_SLCR]) /* the SLICER's step playing */
h ^= (sl[song.sel].idx + 1u) * 2654435761u;
if (pg->graph == GR_SLOTS) { /* (a checksum over each slot) */
@@ -2309,10 +2320,11 @@ static void draw_graph(void)
cv_oy = 0;
graph_bank();
break;
case GR_DXSND: /* (Skiff phase 7, 8) EDIT > SOUND: the sheet, from the panel's top
* (ui_dx.c) */
case GR_DXSND: /* (Skiff phase 7, 8; FM6 LAB) a sheet, from the panel's top */
case GR_FMOP:
case GR_FMALL:
cv_oy = 0;
graph_dx(t, c);
sheet_of(pg->graph)->draw(t, c);
break;
case GR_SONG: /* (Skiff phase 5) the rows from the panel's top (the mockup's) */
cv_oy = 0;
+35 -14
View File
@@ -742,8 +742,8 @@ static void edit_param(uint32_t slot, int32_t steps)
song_knob(slot, steps);
return;
}
if (pg->graph == GR_DXSND) { /* (Skiff phase 7, 8) EDIT > SOUND: the sheet's window (ui_dx.c) */
dx_knob(slot, steps);
if (sheet_of(pg->graph)) { /* (Skiff phase 7, 8; FM6 LAB) a sheet: its window (SHEETS) */
sheet_of(pg->graph)->knob(slot, steps);
return;
}
if (pg->graph == GR_LANES && slot == 0u) { /* (Skiff U3, R6) LANES: KNOB 1 the lane (the grid's too), KNOB 2
@@ -993,8 +993,8 @@ static void presets_turn(int32_t s)
ui.hot_t = 40;
} else if (pg->fam == FAM_SEQ && g == GR_STEPS) {
cursor_set(ui.cursor + s); /* (PATTERN draws it; MOTION: STEP shows it) */
} else if (g == GR_DXSND) { /* (Skiff phase 8) DRUM-X's sheet: the sound (BD .. CB) */
dx_lane_turn(s);
} else if (sheet_of(g)) { /* (Skiff phase 8; FM6 LAB) a sheet's pick: DRUM-X's sound */
sheet_of(g)->pick(s); /* (BD .. CB), FM6's operator */
} else if (g == GR_SLICES) { /* ((Skiff U4, F7) SLICES: KNOB 1's, the slice; was nothing) */
#if FELUCCA_SLICE
if (slice_page_ok())
@@ -1005,21 +1005,23 @@ static void presets_turn(int32_t s)
}
}
/* (Skiff phase 8, DESIGN.md rule 3) SELECT turned s on a page: a detent a step, either way. DRUM-X's sheet moves its
* knobs' window first, then the page beside it; any other page steps to the page before or after in its family (ui.c
* page_step: the ends where they are). The sheet entered from the page after it: its foot, as SELECT left it */
/* (Skiff phase 8, DESIGN.md rule 3) SELECT turned s on a page: a detent a step, either way. A sheet (DRUM-X's, FM6's)
* moves its knobs' window first, then the page beside it; any other page steps to the page before or after in its
* family (ui.c page_step: the ends where they are). A sheet entered from the page after it: its foot, as SELECT left
* it */
static void select_turn(int32_t s)
{
int32_t d = s > 0 ? 1 : -1, n = s > 0 ? s : -s;
const sheet_t *sh;
while (n-- > 0) {
if (cur_page()->graph == GR_DXSND && dx_rows(d))
if ((sh = sheet_of(cur_page()->graph)) != 0 && sheet_rows(sh, d))
continue;
if (!page_step(d)) {
ui.edge_t = 24; /* ((Skiff U4, F7) the end: the footer's n/m flashes) */
break;
}
if (cur_page()->graph == GR_DXSND)
dx_ui_win = d > 0 ? 0u : 3u;
if ((sh = sheet_of(cur_page()->graph)) != 0)
*sh->win = (uint8_t)(d > 0 ? 0u : sh->nwin - 1u);
}
}
@@ -1491,8 +1493,8 @@ static void ui_input(void)
track_select((uint32_t)clamp((int32_t)song.sel + (s > 0 ? 1 : -1), 0, NTRK - 1));
if ((s = glo ? sel : panel_enc(EN_SELECT)) != 0) { /* SELECT: the tempo with GLO held (or BPM LOCK OFF, Felucca's
* way); (Skiff phase 8, rule 3) else the pages */
int sheet = !lay && !ui.home && cur_page()->graph == GR_DXSND; /* (Skiff U1) the sound sheet's rows: SELECT
* is their only way, BPM LOCK or not */
int sheet = !lay && !ui.home && sheet_of(cur_page()->graph); /* (Skiff U1) a sheet's rows: SELECT is their
* only way, BPM LOCK or not */
if (glo || (!(ui_prefs & PREF_BPM_LOCK) && !sheet)) {
song.g[G_BPM] = (int16_t)clamp(song.g[G_BPM] + accel(EN_SELECT, s, 200), GP[G_BPM].min, GP[G_BPM].max);
ui.bpm_t = 40; /* the header's BPM lights up; no message over the header */
@@ -1522,8 +1524,8 @@ static void ui_input(void)
if (ui.home || pg->scope == SC_STEP || pg->scope == SC_TRK || page_desc(pg, k, &hv) ||
((pg->graph == GR_USER || pg->graph == GR_BANK || pg->graph == GR_MOD) && k == 0u)
|| ((pg->graph == GR_SLICES || pg->graph == GR_PLAY) && k < 2u) ||
(pg->graph == GR_PLAY && k == 3u) || pg->graph == GR_SONG || pg->graph == GR_DXSND) { /* (not an empty
* column; (Skiff) PLAY's GATE; SONG's four; SOUND's four) */
(pg->graph == GR_PLAY && k == 3u) || pg->graph == GR_SONG || sheet_of(pg->graph)) { /* (not an empty
* column; (Skiff) PLAY's GATE; SONG's four; a sheet's four) */
ui.hot_col = (uint8_t)k;
ui.hot_t = 40;
}
@@ -1629,3 +1631,22 @@ timeout:
}
#include "ui_dx.c" /* (Skiff phase 7, 8) EDIT > SOUND: the DRUM-X sound sheet */
#include "ui_fm6.c" /* (FM6 LAB) EDIT > OPERATOR, ALL OPS: FM6's patch */
/* (FM6 LAB) the sheets (ui.c sheet_t): their pages' every hook (the knobs, cards, panel, header, PRESETS, SELECT,
* SHIFT's map) goes through here */
static const sheet_t SHEETS[] = {
{GR_DXSND, ENGI_DRUMX, DX_NWIN, &dx_ui_win, dx_knob, dx_cards, dx_sig, graph_dx, dx_title, dx_lane_turn, "DRUM"},
{GR_FMOP, ENGI_FM6, FM_NWIN, &fm_ui[1], fm_op_knob, fm_op_cards, fm_sig, graph_fm_op, fm_op_title, fm_op_turn,
"OPERATOR"},
{GR_FMALL, ENGI_FM6, FM_NWIN, &fm_ui[2], fm_all_knob, fm_all_cards, fm_sig, graph_fm_all, fm_all_title, fm_op_turn,
"OPERATOR"},
};
static const sheet_t *sheet_of(uint32_t g)
{
uint32_t i;
for (i = 0; i < sizeof SHEETS / sizeof SHEETS[0]; i++)
if (SHEETS[i].graph == g)
return &SHEETS[i];
return 0;
}
+4 -3
View File
@@ -1240,19 +1240,20 @@ static void shift_map(smap_t *m)
uint32_t g = ui.home ? GR_NONE : cur_page()->graph, steps = !ui.home && (step_page(g) || g == GR_CHANCE ||
g == GR_PLAY || g == GR_STEPS);
static const char SND[] = "SOUND"; /* (PRESETS' job on most pages: not this page's own) */
const sheet_t *sh = sheet_of(g);
const char *pj = ui.home || g == GR_BROWSE ? SND : steps ? "STEP" : g == GR_USER || g == GR_SLOTS ? "SLOT" :
g == GR_BANK ? "PATTERN" : g == GR_EVENTS ? "ROW" : g == GR_SONG ? "ENTRY" :
g == GR_DXSND ? "DRUM" : g == GR_SLICES ? "SLICE" : SND;
sh ? sh->pj : g == GR_SLICES ? "SLICE" : SND;
static const smap_t ALL[6] = {{"BUTTONS", "PAGES", 0}, {"HOLD ONE", "ITS LAYER", 0}, {"HOLD SAVE", "UNDO", 0},
{"+ SAVE", "TAKE", 2}, {"+ REC", "REC SET", 2}, {"+ BUTTON", "LOCK", 2}};
uint32_t i;
m[0] = (smap_t){"PRESETS", pj, (uint8_t)(pj != SND)};
if (!(ui_prefs & PREF_BPM_LOCK) && g != GR_DXSND)
if (!(ui_prefs & PREF_BPM_LOCK) && !sh)
m[1] = (smap_t){"SELECT", "TEMPO", 1};
else if (ui.home)
m[1] = (smap_t){"GLO + SELECT", "TEMPO", 0};
else
m[1] = (smap_t){"SELECT", g == GR_DXSND ? "ROWS" : "PAGE", (uint8_t)(g == GR_DXSND)};
m[1] = (smap_t){"SELECT", sh ? "ROWS" : "PAGE", (uint8_t)(sh != 0)};
m[2] = (smap_t){"ALGO", "TRACK", 0};
m[3] = steps ? (smap_t){"KEYS + REC", "STEPS", 1} : (smap_t){"KEYS", drum_track(TSEL) ? "DRUMS" : "NOTES", 0};
m[4] = steps ? (smap_t){"EDIT + REC", "CLEAR", 1} : !ui.home && act_cols() ? (smap_t){"OCT+", "DO IT", 1} :
+14
View File
@@ -343,6 +343,20 @@ static int up_store(uint32_t k, const char *name)
up_set_name(&r, k, name);
for (i = 0; i < P_COUNT; i++)
up_set_value(&r, i, motion_base_value(TSEL, i));
if (r.engine == ENGI_FM6 && TSEL->p[P_E7] == FM6_OWN && name && name[0]) { /* (FM6 LAB) its own patch takes a
* typed name (its first 10: .syx keeps it); a factory patch
* (F n) and the automatic name leave it as it is */
char a[16];
up_auto_name(a, r.engine, k);
if (!str_eq(a, name)) {
uint32_t tr = trk_index(TSEL) % NTRK, n = str_len(name);
uint8_t v[FP_SIZE + 1u];
memcpy(v, fm6_patch[tr], sizeof v);
for (i = 0; i < 10u; i++)
v[FP_NAME + i] = (uint8_t)(i < n ? name[i] : ' ');
fm6_set_patch(tr, v);
}
}
{
int rc = up_put(k, &r); /* the record first, then its FM6 patch (up_fm6.c) */
if ((rc == 0 || rc == 3) && r.engine == ENGI_FM6) {
+2 -2
View File
@@ -522,8 +522,8 @@ static int fm6_patches(void)
up_store(5, "MINE"); /* track 3 (MY PATCH, OWN) -> slot 6 */
a[0] = ED_FM6_USER; a[1] = 5;
request(ED_FM6_GET, a, 2);
bad += check("UP_STORE of an FM6 track: FM6_GET user 6 gives its patch", host_wire[7] == 0 &&
!memcmp(host_wire + 8 + 118, "MY PATCH ", 10));
bad += check("UP_STORE of an FM6 track: FM6_GET user 6 gives its patch, named as the sound (FM6 LAB)",
host_wire[7] == 0 && !memcmp(host_wire + 8 + 118, "MINE ", 10));
memcpy(a + 2, pk, FM6_PACKED);
memcpy(a + 2 + 118, "EDITOR ", 10);
a[2 + 14] = 120; /* OP6 output level 120: stored as 99 */
+2
View File
@@ -210,6 +210,8 @@ static int mig_test(void)
mig_boot();
trk[song.sel].eng_req = ENGI_FM6;
fm6_load_slot(song.sel, 3);
trk[song.sel].p[P_E7] = 3; /* (SLOT F4, as a load sets it: (FM6 LAB) a factory patch keeps
* its name when a sound is saved) */
fail_after = (int)((sizeof(up_bank_t) + 255u) / 256u + 1u + 3u); /* the preset bank's write passes, the patches' fails */
up_store(20, "CUT");
fail_after = -1;
+31
View File
@@ -715,6 +715,7 @@ enum { S_HOME, S_HOME_IDLE, S_MESSAGE, S_MESSAGE_KEY, S_MESSAGE_NOFILE, S_PRESET
S_SIX_EDIT, S_SIX_EDIT_SAID,
S_LFO_DEST, S_VOICE2, S_VOICE2_UNI, S_ARP_ON, S_ARP2, S_EDIT_FLT, S_GLOBAL_SWING, S_VOICE_GLIDE, /* (Skiff U5) */
S_SHIFT_ENV, S_SHIFT_STEP, S_SHIFT_HOME, S_LFO_RUN, S_LFO_DEST_RUN, S_HOME_SCOPE,
S_FM_TONE, S_FM_ENV, S_FM_KEYS, S_FM_ALGO, S_FM_PITCH, S_FM_LFO, S_FM_INIT, /* (FM6 LAB) */
S_MOCK_HOME, S_MOCK_PRESETS, S_MOCK_SEQ, S_MOCK_DRUM, S_MOCK_MIXER, S_MOCK_DIALOG, S_MOCK_MENU, S_COUNT };
static const char *const S_NAME[S_COUNT] = {"home", "home_idle", "message", "message_key", "message_nofile", "presets", "presets_nofav", "user",
"project", "lanes", "step", "pattern", "chance", "motion", "drum",
@@ -741,6 +742,7 @@ static const char *const S_NAME[S_COUNT] = {"home", "home_idle", "message", "mes
"six_home", "six_song", "six_perform", "six_mixer", "six_glo", "six_fx", "six_edit", "six_edit_said",
"lfo_dest", "voice_2", "voice_2_uni", "arp_on", "arp_2", "edit_flt", "global_swing", "voice_glide",
"shift_env", "shift_step", "shift_home", "lfo_run", "lfo_dest_run", "home_scope",
"fm_op_tone", "fm_op_env", "fm_op_keys", "fm_all_algo", "fm_all_pitch", "fm_all_lfo", "fm_init",
"mock_home", "mock_presets", "mock_seq", "mock_drum", "mock_mixer", "mock_dialog", "mock_menu"};
/* the scenes of the UI design screens: the state the UI-redesign
@@ -1145,6 +1147,35 @@ static void setup(int s)
case S_SIX_HOME: song.octave = 2; song.rec = 1; usb.config = 1; song.sel = NTRK - 2u; break;
case S_SIX_SONG: /* (SEQ > SONG playing, SONG ON: entry B picked) */
song_lists(1); go_page(GR_SONG); song.sel = NTRK - 2u; sg.entry = 1; break;
case S_FM_TONE: /* (FM6 LAB) EDIT > OPERATOR and ALL OPS as the mockup's */
case S_FM_ENV: /* (design/mock_fm6.py, D): TINE EP's OP4 (TONE, OUTPUT turned; */
case S_FM_KEYS: /* ENV 1, RATE 2 turned); OP2 softer up the keys (R DEPTH 40 */
case S_FM_ALGO: /* -LIN); ALGO with OP4 picked; BRASS's pitch envelope (PITCH 1) */
case S_FM_PITCH: /* and its LFO (FADE); INIT's bare sine */
case S_FM_LFO:
case S_FM_INIT: {
static const uint8_t HOT[7] = {0, 2, 2, 0, 1, 2, 0xFF}, OP[7] = {3, 3, 1, 3, 0, 0, 0};
static const uint8_t WIN[7] = {FMW_TONE, FMW_ENV1, FMW_KEYS, FMW_ALGO, FMW_PITCH1, FMW_LFO, FMW_TONE};
uint32_t i = s - S_FM_TONE, tr = trk_index(TSEL);
uint8_t v[FP_SIZE + 1u];
eng(ENGI_FM6);
if (s == S_FM_PITCH || s == S_FM_LFO)
apply_preset_to(TSEL, 3); /* BRASS */
memcpy(v, fm6_patch[tr], sizeof v);
if (s == S_FM_KEYS) {
v[(5u - 1u) * FP_OP + FP_RD] = 40;
v[(5u - 1u) * FP_OP + FP_RC] = 0;
}
if (s == S_FM_INIT)
fm6_unpack(FM6_INIT, v);
fm6_set_patch(tr, v);
fm6_adopt(tr);
fm_ui[0] = OP[i];
go_title(i < 3u || s == S_FM_INIT ? "OPERATOR" : "ALL OPS");
fm_ui[i < 3u || s == S_FM_INIT ? 1 : 2] = WIN[i];
ui.hot_col = HOT[i] & 3u; ui.hot_t = HOT[i] == 0xFFu ? 0 : 30;
break;
}
case S_DX_SOUND: /* (Skiff phase 8) EDIT > SOUND, DRUM-X's sheet on track 6 as the */
case S_DX_SOUND2: /* mockup's (design/mock_p8.py): the snare, its PTCH B turned; its */
case S_DX_SOUND3: /* switches, WAVE turned; the kick's COLR LEVL DRV (DRV ON, PMOD LONG) */
+142 -7
View File
@@ -2472,9 +2472,130 @@ static int engine_cycle(const char *const *want, uint32_t n) /* EDIT tapped fr
}
return ok;
}
/* (FM6 LAB) EDIT > OPERATOR and ALL OPS: every byte of an FM6 track's patch from the knobs (ui_fm6.c) */
static int test_fm6_lab(void)
{
int bad = 0, ok;
uint32_t tr, i, pos;
uint8_t was[FP_SIZE + 1u], gen;
ui_power_on();
ui_prefs |= PREF_BPM_LOCK; /* (SELECT: the pages, the sheets' rows) */
tr = trk_index(TSEL);
set_engine_of(TSEL, ENGI_FM6); /* TINE EP: SLOT F1 */
ok = TSEL->p[P_E7] == 0;
go_title("OPERATOR"); frame();
fm_ui[0] = 0; fm_ui[1] = 0;
turn(EN_PRESET, 2); /* OP3 (no sound load) */
ok &= fm_ui[0] == 2u && TSEL->preset == 0u && TSEL->eng_req == ENGI_FM6 && str_eq(page_head(), "OPERATOR 3");
memcpy(was, fm6_patch[tr], sizeof was);
gen = fm6_pgen[tr];
turn(EN_K1, -3); /* OUTPUT */
for (i = 0; i < FP_SIZE; i++)
ok &= i == (5u - 2u) * FP_OP + FP_OL ? fm6_patch[tr][i] < was[i] : fm6_patch[tr][i] == was[i];
ok &= fm6_pgen[tr] != gen && TSEL->p[P_E7] == FM6_OWN && ui.hot_col == 0u;
bad += check("OPERATOR: PRESETS picks OP3 (no load), K1 turns its OUTPUT byte only, the patch is OWN now", ok);
turn(EN_K1, 3);
bad += check("OUTPUT back where it was: the patch is TINE EP's again, SLOT F1", TSEL->p[P_E7] == 0 &&
!memcmp(fm6_patch[tr], was, FP_SIZE));
{ /* RATIO: x0.5 .. x31, then 1 10 100 1K HZ, and back */
uint8_t *op = fm6_patch[tr] + (5u - 2u) * FP_OP;
turn(EN_K2, -40);
ok = !op[FP_MODE] && op[FP_FC] == 0;
for (pos = 1; pos < 36u; pos++) {
turn(EN_K2, 1);
ok &= op[FP_MODE] == (pos >= 32u) && op[FP_FC] == (pos >= 32u ? pos - 32u : pos);
}
turn(EN_K2, 1);
ok &= op[FP_MODE] && op[FP_FC] == 3;
turn(EN_K2, -40);
ok &= !op[FP_MODE] && op[FP_FC] == 0;
bad += check("RATIO walks x0.5, x1 .. x31, 1 10 100 1K HZ (MODE fixed) and back, the ends where they are", ok);
}
turn(EN_SELECT, 1); /* ENV 1: RATE 1 LEVEL 1 RATE 2 LEVEL 2 */
memcpy(was, fm6_patch[tr], sizeof was);
turn(EN_K3, -2);
ok = fm_ui[1] == 1u && str_eq(cur_page()->title, "OPERATOR") && fm6_patch[tr][(5u - 2u) * FP_OP + FP_R1 + 1] < was[(5u - 2u) * FP_OP + FP_R1 + 1];
turn(EN_SELECT, 3); /* MORE: BREAK KEY RATE VELOCITY LFO AMP */
turn(EN_K1, 1);
ok &= fm_ui[1] == 4u && fm6_patch[tr][(5u - 2u) * FP_OP + FP_BP] == was[(5u - 2u) * FP_OP + FP_BP] + 1u;
turn(EN_SELECT, 1); /* past MORE: ALL OPS, its top */
ok &= str_eq(cur_page()->title, "ALL OPS") && fm_ui[2] == 0u && str_eq(page_head(), "ALL OPS");
turn(EN_SELECT, -1); /* back: OPERATOR's foot */
ok &= str_eq(cur_page()->title, "OPERATOR") && fm_ui[1] == 4u;
bad += check("SELECT: OPERATOR's windows (ENV 1 RATE 2, MORE BREAK), past its foot ALL OPS's top, back its foot", ok);
go_title("ALL OPS"); fm_ui[2] = 0; frame();
TSEL->p[P_E0] = 5; TSEL->p[P_E1] = 2; /* EDIT 1's ALGO and FEEDBACK over the patch's 5 and 3 */
turn(EN_K1, 1);
turn(EN_K2, 1);
ok = fm6_patch[tr][FP_ALG] == 5u && TSEL->p[P_E0] == 0 && fm6_patch[tr][FP_FB] == 6u && TSEL->p[P_E1] == 0 &&
fm6_alg_of(TSEL) == 5u;
bad += check("ALL OPS: ALGO and FEEDBACK step from what plays (ALG 5 by EDIT 1, FB 3 + 2) into the patch, EDIT 1's to "
"neutral", ok);
turn(EN_SELECT, 3); /* LFO: WAVE RATE FADE KEY SYNC */
memcpy(was, fm6_patch[tr], sizeof was);
turn(EN_K1, 1); turn(EN_K4, -1);
ok = fm_ui[2] == 3u && fm6_patch[tr][FP_LFW] == was[FP_LFW] + 1u && fm6_patch[tr][FP_LKS] == 0u;
bad += check("ALL OPS LFO: WAVE on, KEY SYNC off", ok);
ui.fam_last[FAM_EDIT] = ui.page;
set_engine_of(TSEL, 0); frame();
bad += check("ALL OPS of a track no longer FM6 falls back to EDIT 1 (the sheets are FM6's)", str_eq(cur_page()->title, "EDIT 1"));
{ /* the panel's brightness (Steinberg's idea): INIT's sine cold everywhere; TINE EP's OP3 (fed by OP4, x14) hot
* at its attack, cooler at the key up; six carriers (ALG 32) with FEEDBACK 7: heat from the feedback alone */
static fm_sim_t s;
uint8_t v[FP_SIZE + 1u];
uint32_t x, h0, h1, any = 0;
set_engine_of(TSEL, ENGI_FM6);
fm_sim(&s, TSEL);
h0 = fm_heat(&s, 2, fm_feeders(s.alg, 2), 1);
h1 = fm_heat(&s, 2, fm_feeders(s.alg, 2), FM_HW);
ok = h0 >= 6u && h1 < h0 && s.held > 0 && s.n > s.held && s.op[2].n >= 4u && s.op[2].x[s.op[2].n - 1u] == FM_XW - 1;
fm6_unpack(FM6_INIT, v);
fm6_set_patch(tr, v);
fm_sim(&s, TSEL);
for (x = 0; x < FM_XW; x++)
any |= fm_heat(&s, 0, fm_feeders(s.alg, 0), (int32_t)x);
ok &= !any && s.live == 1u && (s.car & 1u);
v[FP_ALG] = 31; /* ALG 32: OP6 a carrier with the feedback */
v[FP_FB] = 7;
v[FP_OL] = 99; /* (OP6: the patch's first operator) */
fm6_set_patch(tr, v);
fm_sim(&s, TSEL);
ok &= fm_heat(&s, 5, fm_feeders(s.alg, 5), 2) > 0u && !fm_heat(&s, 0, fm_feeders(s.alg, 0), 2);
bad += check("brightness: TINE EP's OP3 hot at the attack, cooler at the key up; INIT cold; ALG 32 FB 7 warm", ok);
}
{ /* INIT on FM6: the bare sine to build from (OWN, the macros at 0, the footer INIT VOICE); SAVE held: back */
uint8_t ini[FP_SIZE + 1u], tine[FP_SIZE + 1u];
char nm[16];
set_engine_of(TSEL, ENGI_FM6); go_home(); frame();
TSEL->p[P_E2] = 20; /* (MOD LVL turned since the load) */
memcpy(tine, fm6_patch[tr], sizeof tine);
fm6_unpack(FM6_INIT, ini);
confirm_open(CF_INIT_SOUND, song.sel); frame();
press(B_OCTUP);
sound_name(TSEL, nm);
ok = !memcmp(fm6_patch[tr], ini, FP_SIZE) && TSEL->p[P_E7] == FM6_OWN && !TSEL->p[P_E0] && !TSEL->p[P_E2] &&
str_eq(nm, "INIT VOICE") && msg_is("SOUND INITIALIZED");
hold(B_SAVE);
sound_name(TSEL, nm);
ok &= !memcmp(fm6_patch[tr], tine, FP_SIZE) && TSEL->p[P_E2] == 20 && str_eq(nm, "TINE EP");
bad += check("INIT on FM6: the bare sine (OP1, ALG 1), SLOT OWN, macros 0, named INIT VOICE; SAVE held: TINE EP back", ok);
}
ui_prefs = 0; /* BPM LOCK OFF: on the sheet SELECT is still its rows */
set_engine_of(TSEL, ENGI_FM6);
go_page(GR_FMOP);
fm_ui[1] = 0;
{
int16_t b0 = song.g[G_BPM];
turn(EN_SELECT, 1);
bad += check("BPM LOCK OFF: OPERATOR's rows still on SELECT", fm_ui[1] == 1u && song.g[G_BPM] == b0);
}
return bad;
}
static int test_edit_cycle(void)
{
static const char *const CYC_A[] = {"EDIT 1", "EDIT 2", "VOICE", "VOICE 2", "EDIT 1"};
static const char *const CYC_F[] = {"EDIT 1", "EDIT 2", "OPERATOR", "ALL OPS", "VOICE", "VOICE 2", "EDIT 1"};
static const char *const CYC_D[] = {"EDIT 1", "EDIT 2", "OP1 ENV", "OP2 ENV", "OP3 ENV", "OP4 ENV",
"OP LEVEL", "VOICE", "VOICE 2", "EDIT 1"};
int bad = 0, ok;
@@ -2495,8 +2616,8 @@ static int test_edit_cycle(void)
engine_cycle(CYC_D, NELEM(CYC_D)));
#else
set_engine_of(TSEL, ENGI_DIGITAL);
bad += check("EDIT cycle (engine 1 asked for: FM6, DIGITAL retired): EDIT 1 EDIT 2 VOICE VOICE 2 EDIT 1",
TSEL->eng_req == ENGI_FM6 && engine_cycle(CYC_A, NELEM(CYC_A)));
bad += check("EDIT cycle (engine 1 asked for: FM6, DIGITAL retired): EDIT 1 EDIT 2 OPERATOR ALL OPS VOICE VOICE 2 EDIT 1",
TSEL->eng_req == ENGI_FM6 && engine_cycle(CYC_F, NELEM(CYC_F)));
(void)CYC_D;
#endif
{ /* #97: a DRUM track's lane levels on EDIT > LANES ((Skiff U3, R6) one page: KNOB 1 the lane, KNOB 2 its level;
@@ -3877,16 +3998,29 @@ static int test_fm4_retired(void)
up_rec(7)->engine == ENGI_DIGITAL && up_engine(7) == ENGI_FM6 &&
total == ENGINES[ENGI_FM6]->npresets + 1u);
up_store(8, "AGAIN");
{
uint8_t pk[FM6_PACKED], w[FP_SIZE + 1u];
bad += check(" saved again: an FM6 user preset with SLOT OWN and the converted patch beside it",
{ /* ((FM6 LAB) the typed name goes into the patch's own too: the rest as converted) */
uint8_t pk[FM6_PACKED], w[FP_SIZE + 1u], f[FP_SIZE + 1u];
char an[16];
bad += check(" saved again: an FM6 user preset with SLOT OWN and the converted patch beside it, named AGAIN",
up_rec(8)->engine == ENGI_FM6 && up_value(up_rec(8), P_E7) == FM6_OWN && !upf_get(8, pk) &&
(fm6_unpack(pk, w), !memcmp(w, v, FP_SIZE)));
(fm6_unpack(pk, w), !memcmp(w, v, FP_NAME)) && !memcmp(w + FP_NAME, "AGAIN ", 10));
fm6_load_slot(song.sel, 2); /* another patch on the track, then the preset again */
up_load(8);
frame();
bad += check(" .. which loads back: the same patch, SLOT OWN", !memcmp(fm6_patch[song.sel], v, FP_SIZE) &&
bad += check(" .. which loads back: the same patch (named AGAIN), SLOT OWN",
!memcmp(fm6_patch[song.sel], v, FP_NAME) && !memcmp(fm6_patch[song.sel] + FP_NAME, "AGAIN ", 10) &&
TSEL->p[P_E7] == FM6_OWN && fm6_slot[song.sel] == FM6_OWN);
memcpy(w, fm6_patch[song.sel], sizeof w);
up_auto_name(an, ENGI_FM6, 9);
up_store(9, an); /* the automatic name ("FM6 10"): the patch keeps its own */
ok = !memcmp(fm6_patch[song.sel], w, FP_SIZE);
fm6_load_slot(song.sel, 2); /* a factory patch, F3: a typed name leaves it F3 */
fm6_adopt(song.sel);
memcpy(f, fm6_patch[song.sel], sizeof f);
up_store(10, "TYPED");
ok &= TSEL->p[P_E7] == 2 && !memcmp(fm6_patch[song.sel], f, FP_SIZE);
bad += check(" (FM6 LAB) the automatic name, or a factory patch (F3): the patch's own name stays", ok);
up_put(9, 0); up_put(10, 0); /* (erased: as the tests after it found them) */
}
/* preset numbers of engine 1 */
set_engine_of(TSEL, ENGI_DIGITAL);
@@ -7686,6 +7820,7 @@ int main(void)
bad += test_browse_no_pattern();
bad += test_name();
bad += test_edit_cycle();
bad += test_fm6_lab();
#if FELUCCA_SLICE
bad += test_slices();
#endif
+8 -2
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-only
"""The README's pictures from the firmware's own screen renders (tests/ui_render.c: build/ui_new/ppm), pixel for pixel
at twice their size: docs/img/<screen>.png, and docs/img/themes.png (HOME in every THEME, 3 x 2).
at twice their size: docs/img/<screen>.png, docs/img/themes.png (HOME in every THEME, 3 x 2) and docs/img/fm6_themes.png (FM6's
OPERATOR in CRYPT, NEON and QUARK).
tools/gen_readme_shots.py build/ui_new/ppm
"""
@@ -13,7 +14,8 @@ from PIL import Image
SHOTS = ["step_tiles", "roll_chords", "drum", "chance_flam", "auto_list", "layer_seq_tools",
"song_playing", "pool", "layer_perform_scenes", "layer_glo_active",
"env", "lfo_dest", "dly", "reverb_spring", "global_swing", "voice_glide", "edit_analog", "edit_fm6",
"dx_sound", "slices_break", "edit_phys", "chord", "fx_duck", "menu", "splash"]
"dx_sound", "slices_break", "edit_phys", "chord", "fx_duck", "menu", "splash",
"fm_op_tone", "fm_op_env", "fm_op_keys", "fm_all_lfo"]
THEMES = ["SKIFF", "HI-CON", "PAPER", "CRYPT", "NEON", "QUARK"]
@@ -27,6 +29,10 @@ def main(ppm):
for i, t in enumerate(THEMES): # (a transparent gap: the README's page shows through)
sheet.paste(big(f"{t}_six_home"), ((i % 3) * (480 + gap), (i // 3) * (480 + gap)))
sheet.save(out / "themes.png", optimize=True)
fm6 = Image.new("RGBA", (3 * 480 + 2 * 24, 480), (0, 0, 0, 0)) # (1.1) OPERATOR in the three themes of their own
for i, t in enumerate(["CRYPT", "NEON", "QUARK"]):
fm6.paste(big(f"{t}_fm_op_tone"), (i * (480 + gap), 0))
fm6.save(out / "fm6_themes.png", optimize=True)
print(f"wrote {len(SHOTS)} screens and themes.png to {out}")
+3 -1
View File
@@ -278,7 +278,9 @@ numbered 0..31 (the device shows U01..U32).
they play the VA kits 66, 10 and 77, and a record holding one loads as that kit: `UP_GET` / `UP_LOAD` give KIT 6, 5
or 8 (the record itself is not rewritten). Projects, motion events and `SET` do the same.
- `UP_STORE`: name "" stores with the automatic name the device uses (engine name + slot number,
"ANALOG 07"). rc 1 for a bad slot or name.
"ANALOG 07"). rc 1 for a bad slot or name. An FM6 track on its own patch (SLOT OWN) given a name also
takes it into the patch's name (its first 10 characters, space-padded): `FM6_GET` of the user slot then
shows it. The automatic name and a factory patch (F n) leave the patch's name alone.
- rc 2 = the flash write failed or there is no flash. A failed flash write keeps the previous
record in RAM and flash, including its name. Without flash, a valid change is RAM-only until power-off.
(`UP_PUT` / `UP_STORE` / `UP_ERASE` stop the transport first, see "Saves while playing"; a device