mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 04:44:33 +01:00
Felucca 1.0.4
DRUM: five more kits on KIT (80, 10, 66, 55, 77) in the manner of classic analog drum machines, every lane its own synthesized voice; a key-off before the first audio block no longer loses the hit. SLICE gets PIANO as a source next to BREAK (SRC 4, the SAMPLE PIANO middle C). An empty or invalid sample slot, or a missing built-in set, plays a sine at the note's pitch on SAMPLE, GRAIN and SLICE, with a NO SAMPLE alert (SAMPLE NOT FOUND on the SLICES page). The PRESETS knob changes the sound on every page that is not a list and moves the step cursor on the SEQ pages (Discussions #92, #94); REC held on the SEQ pages clears the sequence after asking (#91, #108); on STEP the keys light the cursor step's notes while stopped (#89); MOTION is now called AUTOMATION (#93). The web editor reads and changes the MENU settings (MENU_DESC 72, MENU_SET 73). OCT- pressed quickly with GLO, SCL, EDIT or, with FX LATCH, FX (all off) now acts. The firmware runs in the browser: web/emu, after charlesvestal's X0X (#101). EDIT layer: the engine cells are 20 px tall, 8 px clear of the sound row.
This commit is contained in:
1 parent
852bc724d2
commit
2da8a71cf8
48 files changed
+3394
-284
No files matched your search
+18
-2
@@ -30,6 +30,7 @@ The build makes three files in `build/`:
|
||||
```
|
||||
|
||||
- Node.js (optional, for the web tests).
|
||||
- Emscripten (optional, `emcc`: the browser emulator, `web/emu/`).
|
||||
|
||||
On Linux x86-64 the toolchain runs natively and Docker is not needed.
|
||||
|
||||
@@ -70,7 +71,22 @@ Build options (environment, `0` or `1`; defaults in `firmware/src/felucca.c`, `c
|
||||
The CC0 instrument samples that the SAMPLE engine uses are in `assets/samples-cc0/`
|
||||
(Versilian Studios, see `ATTRIBUTION.txt` there). `tools/fetch_cc0.py` downloads them
|
||||
again from the source repositories. Without that folder the build still works, with no
|
||||
instrument sets in the SAMPLE engine.
|
||||
instrument sets in the SAMPLE engine and no PIANO in SLICE (the PIANO set's middle C): they play a plain sine
|
||||
at the note's pitch instead, and the screen says NO SAMPLE.
|
||||
|
||||
## Browser emulator
|
||||
|
||||
```
|
||||
./build.sh
|
||||
web/emu/build.sh
|
||||
python3 -m http.server -d build/emu 8790 # open http://localhost:8790/
|
||||
```
|
||||
|
||||
`web/emu/felucca_web.c` builds the firmware's sources as the host tests do, against a simulated FM-1, and
|
||||
Emscripten compiles it to WebAssembly (`build/emu/felucca.wasm`, with `index.html` and `worklet.js`). The page
|
||||
keeps the flash's storage sectors (projects, user presets, settings) in the browser. Not emulated: USB (audio,
|
||||
MIDI out, the editor, updates), TRS MIDI and the user sample slots. A build of it is on the site:
|
||||
<https://hugelton.github.io/Felucca/webapp/try/>.
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -78,7 +94,7 @@ instrument sets in the SAMPLE engine.
|
||||
tests/run_tests.sh
|
||||
```
|
||||
|
||||
Runs the host tests and, with Node.js, the web page tests. Run it after `./build.sh`
|
||||
Runs the host tests and, with Node.js, the web page tests (and, with Emscripten too, the browser emulator's). Run it after `./build.sh`
|
||||
(it uses `build/` and needs `AC79_SDK` set as for the build). The suites cover flash storage,
|
||||
user presets, projects of every format, backup, the keys and knobs, MIDI (USB, TRS, clock,
|
||||
control), USB audio, the update entry and loader, the command-line installer, the UI (the real
|
||||
|
||||
+3
-2
@@ -13,7 +13,7 @@ Every file in this tree that carries an `SPDX-License-Identifier: GPL-3.0-only`
|
||||
|
||||
- the firmware: `firmware/` (app, HAL, update loader)
|
||||
- the build script and tools: `build.sh`, `tools/`
|
||||
- the web pages (installer, editor) and their tests: `web/` (not the Fukiai font, below)
|
||||
- the web pages (installer, editor, the browser emulator `web/emu/`) and their tests: `web/` (not the Fukiai font, below)
|
||||
- the host tests: `tests/`
|
||||
|
||||
Three source files are ports and keep the licence of their originals:
|
||||
@@ -43,11 +43,12 @@ All by Hügelton Instruments (Leo Kuroshita), in this tree:
|
||||
| What | Licence | Where |
|
||||
| --- | --- | --- |
|
||||
| Inter Tight font by The Inter Project Authors: the UI text, rasterised into the firmware at build time (`tools/gen_aa_font.py`; the generated tables are not offered as a font, and the font declares no Reserved Font Name) | SIL OFL 1.1 | `assets/fonts/InterTight[wght].ttf`, `LICENSES/OFL-InterTight.txt` (also `assets/fonts/OFL.txt`) |
|
||||
| Instrument samples (Versilian Studios VSCO-2 Community Edition, VCSL) | CC0 1.0 | `assets/samples-cc0/`, provenance in `ATTRIBUTION.txt` there |
|
||||
| Instrument samples (Versilian Studios VSCO-2 Community Edition, VCSL): the SAMPLE sets, also the SLICE engine's PIANO (the PIANO set's middle C) | CC0 1.0 | `assets/samples-cc0/`, provenance in `ATTRIBUTION.txt` there |
|
||||
| DaisySP by Electrosmith, Corp and Emilie Gillet (<https://github.com/electro-smith/DaisySP>): the PHYS engine's modal and string models and the resonator, ported to fixed point | MIT | `firmware/src/phys_dsp.c`, `LICENSES/MIT-DaisySP.txt` |
|
||||
| Rings by Emilie Gillet (<https://github.com/pichenettes/eurorack>): the PHYS engine's sympathetic strings, ported to fixed point | MIT | `firmware/src/phys_symp.c`, `LICENSES/MIT-Rings.txt` |
|
||||
| msfa by Google Inc. and Pascal Gauthier, from Dexed (<https://github.com/asb2m10/dexed>): the FM6 engine's synthesis, ported to integer C (Dexed itself is GPL-3.0; only msfa is used; the FM6 factory patches are Felucca's own) | Apache-2.0 | `firmware/src/fm6_core.c`, `LICENSES/Apache-2.0-msfa.txt` |
|
||||
| klattsch by Tony Gies (<https://github.com/tgies/klattsch>): design reference for the VOICE engine; no code copied. Formant data from Klatt (1980) / Hillenbrand et al. (1995) | MIT (klattsch) | credit only |
|
||||
| X0X by charlesvestal (<https://github.com/charlesvestal/fm1-x0x>), a Felucca fork: the design of the browser emulator (the worklet, the device clock driven by its audio, the exports); its files credit it in their headers | GPL-3.0 | `web/emu/` |
|
||||
| JieLi AC79 SDK by JieLi Technology: three of its files go into every `.fwsc` package (below); none are in this tree | Apache-2.0 | `LICENSES/Apache-2.0.txt` |
|
||||
|
||||
On the device, HOME held > ABOUT opens the information screen; turning PRESETS scrolls on into
|
||||
|
||||
@@ -5,15 +5,18 @@
|
||||
|
||||

|
||||
|
||||
**TL;DR:** Felucca 1.0.3.1 — Big New Features, field testing. Connect your FM-1 to a computer by USB,
|
||||
**TL;DR:** Felucca 1.0.4 — Big New Features, field testing. Connect your FM-1 to a computer by USB,
|
||||
open the [web installer](https://hugelton.github.io/Felucca/) in Chrome or Edge, and press Install;
|
||||
no extra hardware is needed. Installing is at your own risk: M-VAVE's updater or the installer's
|
||||
**Return to official V15** takes you back.
|
||||
**Return to official V15** takes you back. Want to look around first?
|
||||
[Try it in your browser](https://hugelton.github.io/Felucca/webapp/try/), no FM-1 needed.
|
||||
|
||||
Multi-engine synthesizer firmware for the M-VAVE FM-1. Please report what you find in
|
||||
[Issues](https://github.com/hugelton/Felucca/issues).
|
||||
|
||||
- Install: [web installer](https://hugelton.github.io/Felucca/) (Chrome or Edge, USB), or `tools/fm1_install.py` from a terminal
|
||||
- Try: [Felucca in your browser](https://hugelton.github.io/Felucca/webapp/try/): the same firmware compiled to
|
||||
WebAssembly, with the panel on screen (mouse, touch, computer keyboard, Web MIDI in)
|
||||
- Editor: [web editor](https://hugelton.github.io/Felucca/webapp/editor/); its development has moved to
|
||||
[Felucca-WebApp](https://github.com/hugelton/Felucca-WebApp)
|
||||
- Build: [BUILDING.md](BUILDING.md)
|
||||
@@ -26,9 +29,10 @@ Multi-engine synthesizer firmware for the M-VAVE FM-1. Please report what you fi
|
||||
- **Four tracks**, one synth part each with its own engine and sound (drums are the DRUM engine);
|
||||
8 voices shared between them. ALGORITHM selects the track on every page
|
||||
- **Sequencer:** 64 steps per track with chords, ties, accent, slide and per-step chance; a piano
|
||||
roll of the steps; a drum grid (white keys = steps, black keys = lanes); motion recording of knob
|
||||
moves (a motion icon marks the cards it drives); live loop recording with overdub; divisions listed
|
||||
by length, 4 bars to 1/32; loading a sound never touches your patterns
|
||||
roll of the steps; a drum grid (white keys = steps, black keys = lanes); automation (formerly motion):
|
||||
recording of knob moves per step (an automation icon marks the cards it drives); live loop recording
|
||||
with overdub; REC held on the SEQ pages clears the sequence (it asks first, and SAVE held undoes it);
|
||||
divisions listed by length, 4 bars to 1/32; loading a sound never touches your patterns
|
||||
- **Songs:** chain patterns A–D
|
||||
- **Chord keys:** one finger plays an in-key chord (triads or sevenths of the scale, or fixed chord
|
||||
shapes), with voicings; on the keys, MIDI in, recording and the arpeggiator
|
||||
@@ -43,13 +47,14 @@ Multi-engine synthesizer firmware for the M-VAVE FM-1. Please report what you fi
|
||||
- **Quick layers:** hold FX, GLO, SCL or EDIT for shortcuts on the keys and knobs, or double-tap it to
|
||||
keep the layer open; one-step undo (SAVE held); REC on every page; OCT+ confirms, OCT- goes back
|
||||
- **Presets:** factory presets, 32 user preset slots and 4 projects, named on the device (an FM6
|
||||
sound keeps its own patch in both); projects from every earlier version load
|
||||
sound keeps its own patch in both); projects from every earlier version load. The PRESETS knob
|
||||
changes the sound from every page that is not a list, and moves the step cursor on the SEQ pages
|
||||
- **Screen:** flat UI with Inter Tight and Fukiai icons, FLAT or LINE style, 10 palettes including
|
||||
grayscale, black and white, high contrast and NIGHT; tracks numbered 1–4 on small cushions;
|
||||
MENU > LARGE for tall knob cards with larger labels and values
|
||||
- **LEDs:** idle buttons and keys glow dim so the panel can be found in the dark (MENU > LEDS: OFF,
|
||||
DIM LO, DIM HI or INV, the official firmware's look); PLAY turns green while playing; the keys show
|
||||
the notes the sequencer and MIDI IN play
|
||||
the notes the sequencer and MIDI IN play, and on SEQ > STEP (stopped) the notes of the step under the cursor
|
||||
- **USB:** class-compliant MIDI in and out, and a 44.1 kHz stereo audio input ("Felucca") that
|
||||
records the master output on the computer, no driver needed (at a fixed level with MENU > USB LEVEL FIXED;
|
||||
on macOS 13–15, set MENU > USB SERIAL to OFF so the audio input appears)
|
||||
@@ -57,8 +62,8 @@ Multi-engine synthesizer firmware for the M-VAVE FM-1. Please report what you fi
|
||||
(ROUT SEL: every channel plays the selected track), and the keys send on the track's channel; pitch
|
||||
bend, sustain, panic; clock from internal, USB or TRS
|
||||
- **Web:** editor for every parameter (with a 6-operator FM patch editor), step grid, mixer,
|
||||
preset library, sample upload and recording with trim; full backup and restore; return to the
|
||||
official firmware
|
||||
preset library, sample upload and recording with trim, the MENU settings; full backup and restore;
|
||||
return to the official firmware; Felucca itself running in the browser
|
||||
|
||||
## Controls
|
||||
|
||||
@@ -67,13 +72,15 @@ Multi-engine synthesizer firmware for the M-VAVE FM-1. Please report what you fi
|
||||
- Tap a page button for its page, again for the next; HOME returns home
|
||||
- Hold FX, GLO, SCL or EDIT for its quick layer; hold SAVE to undo, HOME for the menu, SEQ for the song
|
||||
- Double-tap FX, GLO, SCL or EDIT to keep its layer open without holding; tap it again to close
|
||||
- Hold REC on SEQ > STEP (or the drum grid), PATTERN or CHANCE to clear the track's sequence: OCT+ clears, OCT− cancels
|
||||
- On action pages, in dialogs and the menu, OCT+ does it and OCT− goes back
|
||||
- Save a sound: stop, tap SAVE, pick a slot with KNOB 1, then OCT+ and OCT+ again (name it with the keys)
|
||||
|
||||
## Menu
|
||||
|
||||
Hold **HOME** for the menu. PRESETS moves through the rows, KNOB 1 or OCT+ changes the value, hold HOME
|
||||
again to leave. Every new setting defaults to the earlier behaviour.
|
||||
again to leave. Every new setting defaults to the earlier behaviour. From 1.0.4 the web editor's Settings
|
||||
tab reads and changes them too (COLOR to USB SERIAL), saved the same way as from the menu.
|
||||
|
||||
- **COLOR:** the palette. GREY (grayscale, called MONO up to 1.0.1), GREEN, AMBER, ICE, VIOLET, ROSE,
|
||||
PAPER (light), HI-CON (high contrast), NIGHT (the 0.9 look: true black, green-tinted text) and MONO
|
||||
@@ -118,15 +125,24 @@ In the order the device lists them:
|
||||
- **GRAIN**: granular textures from the built-in samples or a user slot
|
||||
- **PHYS**: physical models: modal resonators, strings, struck membranes, sympathetic strings
|
||||
- **NOISE**: noise from analog to digital: colours, crackle, shift-register and metallic tones
|
||||
- **SLICE**: a drum break or your own sample cut into slices, one per key; set the slices by hand
|
||||
on the SLICES page
|
||||
- **DRUM**: an 8-lane kit of Felucca's own drum voices on the General MIDI key map
|
||||
- **SLICE**: a drum break, a piano note (both built in) or your own sample cut into slices, one per key;
|
||||
set the slices by hand on the SLICES page
|
||||
- **DRUM**: an 8-lane kit of Felucca's own drum voices on the General MIDI key map. KIT picks the
|
||||
standard, hand-percussion and cymbal variants, or one of five virtual-analog (VA) kits in the manner of
|
||||
classic analog drum machines (the numbers are a hint), every lane its own voice: **80** (deep sine kick with a long decay, noisy snare,
|
||||
six-square hats), **10** (swept kick, white-noise snare, long-tailed claps, a cymbal), **66** (soft
|
||||
round kick, bright snare, noise hats, a conga), **55** (dropping kick, high metal hats, a metal bell)
|
||||
and **77** (swelling kick, multi-burst claps, claves, a cymbal). All of them are synthesized by
|
||||
Felucca, no samples
|
||||
|
||||
The DIGITAL engine of 0.9 has been replaced by FM6: projects and presets with DIGITAL sounds load
|
||||
as FM6 sounds converted from them. The SAMPLE engine's PERC kit was removed in 1.0.2: sounds and
|
||||
projects that used it load as the DRUM engine's kit, on the same key map. FM6's patch bank (the B
|
||||
slots) was removed in 1.0.3: user presets keep their own FM6 patch, and presets that used a B slot get
|
||||
that patch on the first start of 1.0.3.
|
||||
that patch on the first start of 1.0.3. SLICE gained a second built-in sound in 1.0.4, PIANO (the SAMPLE
|
||||
engine's middle C), next to BREAK. Since 1.0.4 a missing sample (an empty user slot, or a set missing
|
||||
from the build) plays a plain sine at the note's pitch on SAMPLE, GRAIN and SLICE, and the screen says
|
||||
NO SAMPLE once.
|
||||
|
||||
**SLICER** (FX page, every track): a tempo-synced 16-step gate or stutter, with 16 patterns.
|
||||
|
||||
@@ -158,7 +174,7 @@ sevenths, or a fixed shape) and VOIC the voicing.
|
||||
| `firmware/` | firmware sources: `src/` app, `hal/` hardware layer, `loader/` update loader |
|
||||
| `tools/` | build script, generators, package maker, installer and sample uploader |
|
||||
| `assets/` | UI font, icon names, CC0 instrument samples |
|
||||
| `web/` | the web installer and the editor the site serves (the new editor: [Felucca-WebApp](https://github.com/hugelton/Felucca-WebApp)) |
|
||||
| `web/` | the web installer, the earlier editor and the browser emulator (`web/emu/`); the new editor: [Felucca-WebApp](https://github.com/hugelton/Felucca-WebApp) |
|
||||
| `tests/` | tests that run on the build machine |
|
||||
| `LICENSES/` | licence texts of the bundled font, icons, ported DSP and SDK files |
|
||||
|
||||
@@ -187,14 +203,15 @@ moved there. Pull requests are welcome: see [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
- **[Hügelton Instruments](https://hugelton.com)** (Leo Kuroshita, [@kurogedelic](https://github.com/kurogedelic)):
|
||||
Felucca itself; the PHASE engine's waveforms (a C port of the oscillator of
|
||||
[CrispyZebra](https://github.com/hugelton/CrispyZebra), GPL-3.0); the DRUM voices; the Hügelton Sample
|
||||
[CrispyZebra](https://github.com/hugelton/CrispyZebra), GPL-3.0); the DRUM voices and kits; the Hügelton Sample
|
||||
Pack (the drum samples, GPL-3.0-only, not CC0); the [Fukiai](https://github.com/hugelton/Fukiai) icon
|
||||
font ([MIT](LICENSES/MIT-Fukiai.txt))
|
||||
- Font: [Inter Tight](https://github.com/rsms/inter-tight) by The Inter Project Authors, [SIL OFL 1.1](LICENSES/OFL-InterTight.txt)
|
||||
- Samples: [Versilian Studios](https://versilian-studios.com/) [VSCO-2 Community Edition](https://github.com/sgossner/VSCO-2-CE) and [VCSL](https://github.com/sgossner/VCSL), CC0 1.0 ([attribution](assets/samples-cc0/ATTRIBUTION.txt))
|
||||
- Samples: [Versilian Studios](https://versilian-studios.com/) [VSCO-2 Community Edition](https://github.com/sgossner/VSCO-2-CE) and [VCSL](https://github.com/sgossner/VCSL), CC0 1.0: the SAMPLE sets, also SLICE's PIANO ([attribution](assets/samples-cc0/ATTRIBUTION.txt))
|
||||
- VOICE engine: after [klattsch](https://github.com/tgies/klattsch) by Tony Gies (MIT); formant data from Klatt (1980) and Hillenbrand et al. (1995)
|
||||
- PHYS engine: models ported from [DaisySP](https://github.com/electro-smith/DaisySP) by Electrosmith and Emilie Gillet ([MIT](LICENSES/MIT-DaisySP.txt)) and from Emilie Gillet's [eurorack](https://github.com/pichenettes/eurorack) code ([MIT](LICENSES/MIT-Rings.txt))
|
||||
- FM6 engine: msfa from [Dexed](https://github.com/asb2m10/dexed) by Google Inc. and Pascal Gauthier ([Apache-2.0](LICENSES/Apache-2.0-msfa.txt))
|
||||
- Browser emulator: after [X0X](https://github.com/charlesvestal/fm1-x0x) by [charlesvestal](https://github.com/charlesvestal) (GPL-3.0), a Felucca fork whose browser build showed the way
|
||||
- Package format and boot files: [JieLi AC79 SDK](https://gitee.com/Jieli-Tech/fw-AC79_AIoT_SDK) ([Apache-2.0](LICENSES/Apache-2.0.txt); three of its files are in every package, none in this tree)
|
||||
- Contributions: [keremimo](https://github.com/keremimo) (white-key scales, #2), [ChanceTheMaker](https://github.com/ChanceTheMaker)
|
||||
(TRS MIDI, bend, sustain and clock, palettes, favourites, editor display settings: #8, #10, #11, #12),
|
||||
|
||||
+336
-17
@@ -36,6 +36,19 @@
|
||||
* BELL two square waves (f, 1.48 f) through a band-pass under a short strike and a tail envelope
|
||||
* (extra: STRIKE; TONE: the squares themselves mixed in). CYM: the metal source through two
|
||||
* band-passes (TONE: high / low balance; TUNE moves both) under a strike (STRIKE) and a ring
|
||||
* The model kits (KIT 80 10 66 55 77): each lane a kit's own voice, played through the runs above with that kit's
|
||||
* numbers (DV_KIT: pitches, sweeps, decays, the noise's colour, the metal clusters, the clap's bursts, the accent):
|
||||
* 80 a deep sine kick with a small drop and a long decay, a snare of two shells and bright noise, a 1 kHz clap of
|
||||
* three bursts and a tail, the six-square hats, a low-noise tom, a rim's crack, a two-square bell
|
||||
* 10 a small kit: a kick swept down from 90 Hz, one shell over white noise, three slow claps and a long tail,
|
||||
* hats and a cymbal (on BELL) of four squares; TOM and RIM stand-ins built from its body and shell
|
||||
* 66 an early rhythm box: a kick that swells in, a bright noisy snare with a short shell, hats of noise in a
|
||||
* narrow band near 8 kHz, a low conga on TOM, a high rim, a bell of two sines; a CLAP stand-in from its
|
||||
* snare's noise
|
||||
* 55 a kick dropping from 100 Hz, a 245 Hz snare under band noise, hats of a high cluster and noise, a tom with
|
||||
* its stick, a click rim, a bell of a wide metal cluster; a CLAP stand-in from its snare's noise
|
||||
* 77 a long kick that swells in, a 226 Hz snare under wide noise, six close claps and a tail, pulse-cluster
|
||||
* hats, a bent tom, claves on RIM, the cymbal on BELL
|
||||
* Parameters per lane (dv_param_t): TUNE (1/16 semitone from the designed pitch, held in the voice's
|
||||
* range), DECAY, TONE, extra, LEVEL, accent, 0..127 each; the designed sound is at DV_DEF's values.
|
||||
* Accent adds up to 4 dB, a little more on the transient (click, spike, the claps). At LEVEL 100 the
|
||||
@@ -57,9 +70,14 @@ static const uint8_t DV_LANE_TYPE[DV_NLANE][2] = { /* lane, variant -> type */
|
||||
{DVT_PUNCH, DVT_ROUND}, {DVT_SNARE, DVT_SNARE}, {DVT_CLAP, DVT_CLAP}, {DVT_HATC, DVT_HATC},
|
||||
{DVT_HATO, DVT_HATO}, {DVT_TOM, DVT_CONGA}, {DVT_RIM, DVT_CLAVE}, {DVT_BELL, DVT_CYM},
|
||||
};
|
||||
/* a lane of a model kit as a type: the kit (1..DV_NKIT) in the high 4 bits, the lane in the low 3 (Felucca's own
|
||||
* types: 0 above). Its run (the DVT_* it plays through) is the kit's (DV_KIT) */
|
||||
#define DV_NKIT 5
|
||||
#define DV_KITOF(t) ((uint32_t)(t) >> 4)
|
||||
#define DV_KTYPE(kit, lane) ((uint8_t)(((kit) << 4) | (lane)))
|
||||
|
||||
typedef struct {
|
||||
uint8_t type; /* DVT_* */
|
||||
uint8_t type; /* DVT_*, or a model kit's (DV_KTYPE) */
|
||||
uint8_t decay, tone, extra, level, accent; /* 0..127 */
|
||||
int16_t tune; /* 1/16 semitone from the designed pitch */
|
||||
} dv_param_t;
|
||||
@@ -75,7 +93,7 @@ typedef struct { /* coefficients (dv_set
|
||||
int32_t out; /* output gain: type, LEVEL, accent (Q12) */
|
||||
uint16_t hold, click; /* kick: hold (blocks), click length (samples); clap:
|
||||
* tooth spacing (samples), teeth */
|
||||
uint8_t type, pad;
|
||||
uint8_t type, mrow; /* mrow: the metal source's ratios (DV_METAL_R) */
|
||||
int16_t metal; /* the metal source's pitch (p16) for this lane */
|
||||
} dv_coef_t;
|
||||
|
||||
@@ -120,9 +138,143 @@ static const struct {
|
||||
#define DV_P16(hz_p16) pitch_inc(clamp((hz_p16), 0, 2047))
|
||||
/* the metal source's ratios (Q12). Hats: the six-square cluster of the classic analog hats (205.3, 304.4,
|
||||
* 369.6, 522.7, 540, 800 Hz over 205.3); the cymbal: inharmonic, picked by ear */
|
||||
static const uint16_t DV_METAL_R[2][6] = {
|
||||
static const uint16_t DV_METAL_R[7][6] = {
|
||||
{4096, 6073, 7374, 10428, 10774, 15961},
|
||||
{4096, 5800, 6560, 7530, 8810, 10650},
|
||||
/* the model kits' (a ratio 0: that square stands still, a constant the band-passes take away) */
|
||||
{4096, 5989, 10562, 14799, 0, 0}, /* 10: four squares, 318 465 820 1149 Hz */
|
||||
{4096, 4203, 4368, 4836, 6059, 7486}, /* 55 hats: a high cluster, 8.0 .. 14.7 kHz */
|
||||
{4096, 12254, 17607, 21692, 25765, 43372}, /* 55 bell: 720 Hz .. 7.6 kHz, wide apart */
|
||||
{4096, 4695, 5646, 10855, 13031, 15117}, /* 77: two triads of pulses, 3.7 .. 13.5 kHz */
|
||||
{0, 0, 0, 0, 0, 0}, /* 66: none (its metal is noise through a narrow band) */
|
||||
};
|
||||
|
||||
/* The model kits (KIT 80 10 66 55 77 in eng_drum.c): every lane a kit's own voice, built on the runs above
|
||||
* with its own numbers. Per lane: the run, the designed pitch (p16; TUNE +-1 octave), the main decay's tau at
|
||||
* DECAY 0 (0.1 ms) and its span (octaves x 16 over DECAY 0..127), the output gain (Q12), then the run's own
|
||||
* numbers, v[] (p16 pitches and offsets, gains Q15, taus in 0.1 ms unless noted):
|
||||
* KICK v0 the sweep (p16, x TONE / 64, TONE above 64 adds up to 4 semitones), v1 its tau, v2 an attack
|
||||
* sweep above it (tau 1.5 ms), v3 v4 the 2nd and 3rd harmonics, v5 the click's pitch (0: none), v6 its
|
||||
* level, v7 the drive (Q12, x (SNAP + 64) / 128, at least x1), v8 a rise (tau; 0: none), v9 a hold (blocks)
|
||||
* SNARE v0 the 2nd shell sine's ratio - 1 (x 256), v1 the glide (p16), v2 its tau, v3 the shell's tau
|
||||
* (x 1/64 of the noise's), v4 the 2nd sine's level, v5 the shell's level, v6 the noise band (p16, TONE
|
||||
* +-8 semitones), v7 its damping (Q12), v8 the spike's tau, v9 the spike, v10 the noise (x SNAP / 64),
|
||||
* v11 high-passed noise on the spike, v12 its corner (p16)
|
||||
* CLAP v1 the band's damping (its centre: the pitch, TONE +-8 semitones), v2 the bright noise's corner, v3 its
|
||||
* level (x TONE / 64), v4 the tail, v5 the teeth, v6 a tooth's tau, v7 the teeth's spacing (samples,
|
||||
* x 0.5 .. 1.5 with SNAP), v8 how many
|
||||
* HATS v0 the band (p16, TONE +-8 semitones), v1 its damping, v2 the high-pass (p16, TONE +-12 semitones), v3
|
||||
* the sizzle's corner,
|
||||
* v4 the sizzle (Q12, x SNAP / 64; SNAP above 64 adds up to x1), v5 the metal source's level, v6 white
|
||||
* noise's, v7 the rise, v8 the source's ratios (DV_METAL_R)
|
||||
* CYM v0 v1 the high band and its damping, v2 v3 the low band, v4 the high band's share (x TONE / 64), v5 the
|
||||
* strike (x SNAP / 64), v6 its tau (ms), v7 v8 the metal source's and noise's levels, v9 the ratios
|
||||
* TOM v0 the bend (p16, x SNAP / 64; SNAP above 64 adds up to 4 semitones), v1 the stick's tau, v2 its
|
||||
* low-pass (p16), v3 the stick (low noise), v4 the slap (high noise), both x TONE / 64, v5 a soft clip
|
||||
* (Q12, 0: none; TONE above 64 drives it up to x1 more)
|
||||
* RIM v0 the 2nd sine (p16 from the 1st), v1 v2 their levels (the 2nd x TONE / 64), v3 the drive (Q12, as
|
||||
* the kick's)
|
||||
* BELL v0 the 2nd square (p16 from the 1st), v1 the band (p16 from the 1st, TONE +-8 semitones), v2 its
|
||||
* damping, v3 the strike (Q14, x SNAP / 64), v4 its tau, v5 the squares themselves (x TONE / 64) */
|
||||
typedef struct {
|
||||
uint8_t run, oct16;
|
||||
int16_t p16;
|
||||
uint16_t tau0, gain;
|
||||
int16_t v[13];
|
||||
} dv_kit_t;
|
||||
/* the accent per kit: + (x / 16384) per accent step (75: +4 dB at full, as Felucca's own) */
|
||||
static const uint8_t DV_KIT_ACC[DV_NKIT] = {120, 45, 100, 40, 40};
|
||||
static const dv_kit_t DV_KIT[DV_NKIT][DV_NLANE] = {
|
||||
{ /* 80 */
|
||||
/* deep sine, a small drop, long decay */
|
||||
{DVT_PUNCH, 64, 499, 198, 3124, {26, 150, 0, 300, 0, 0, 0, 4096, 12, 0, 0, 0, 0}},
|
||||
/* shells 173 / 336 Hz, noise 2.7 .. 7 kHz, tau 30 ms */
|
||||
{DVT_SNARE, 40, 845, 125, 5690, {241, 0, 100, 53, 32767, 11000, 1678, 6827, 30, 0, 28000, 0, 1828}},
|
||||
/* band 1 kHz, 3 teeth 10 ms, tail 90 ms */
|
||||
{DVT_CLAP, 48, 1331, 316, 13485, {0, 4096, 1678, 0, 2000, 30000, 35, 441, 3, 0, 0, 0, 0}},
|
||||
/* six squares, band 7.1 kHz, tau 16 ms */
|
||||
{DVT_HATC, 45, 893, 60, 9017, {1874, 5120, 2020, 2042, 7209, 32767, 0, 3, 0, 0, 0, 0, 0}},
|
||||
/* tau 75 ms */
|
||||
{DVT_HATO, 63, 893, 253, 13955, {1874, 5120, 1934, 2042, 1147, 32767, 0, 3, 0, 0, 0, 0, 0}},
|
||||
/* mid tom 139 Hz, tau 58 ms, a little bend */
|
||||
{DVT_TOM, 53, 785, 182, 4055, {8, 100, 1302, 1200, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* 455 + 1667 Hz into a hard clip */
|
||||
{DVT_RIM, 32, 1113, 12, 4599, {360, 12000, 30000, 32000, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* squares 540 / 800 Hz, band 860 Hz */
|
||||
{DVT_BELL, 50, 1161, 252, 2697, {109, 129, 3413, 30000, 45, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
},
|
||||
{ /* 10 */
|
||||
/* 62 Hz swept from 90, tau 190 ms */
|
||||
{DVT_PUNCH, 60, 561, 464, 2239, {103, 180, 0, 0, 0, 1233, 2600, 4096, 0, 0, 0, 0, 0}},
|
||||
/* one shell 185 Hz swept from 280, noise tau 100 ms */
|
||||
{DVT_SNARE, 40, 864, 418, 3710, {0, 115, 160, 77, 0, 9000, 1828, 8192, 30, 0, 32767, 0, 1828}},
|
||||
/* 3 claps 28 ms apart, a 0.7 s tail */
|
||||
{DVT_CLAP, 30, 1678, 3636, 2932, {0, 9102, 1715, 8000, 17000, 30000, 100, 1235, 3, 0, 0, 0, 0}},
|
||||
/* four squares, band 7.2 kHz, tau 80 ms */
|
||||
{DVT_HATC, 45, 1014, 300, 6315, {1900, 3277, 1444, 2042, 0, 19661, 0, 3, 2, 0, 0, 0, 0}},
|
||||
/* tau 0.7 s */
|
||||
{DVT_HATO, 63, 1014, 1516, 5167, {1900, 3277, 1444, 2042, 0, 19661, 0, 3, 2, 0, 0, 0, 0}},
|
||||
/* (stand-in) a body of the kit: 120 Hz bent down from 160 */
|
||||
{DVT_TOM, 53, 744, 377, 2858, {80, 30, 1444, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* (stand-in) a short shell click, 740 Hz */
|
||||
{DVT_RIM, 32, 1248, 25, 5868, {254, 22000, 9000, 8192, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* the cymbal: band 4.2 kHz, 60 ms + 0.9 s */
|
||||
{DVT_CYM, 53, 1014, 3773, 10841, {1766, 3413, 1729, 3413, 16384, 20000, 60, 19661, 0, 2, 0, 0, 0}},
|
||||
},
|
||||
{ /* 66 */
|
||||
/* 64 Hz, a slow rise, tau 58 ms */
|
||||
{DVT_PUNCH, 64, 570, 119, 4353, {0, 100, 0, 0, 0, 0, 0, 4096, 40, 0, 0, 0, 0}},
|
||||
/* shells 280 / 397 Hz, bright noise, tau 14 ms */
|
||||
{DVT_SNARE, 40, 979, 54, 10633, {107, 0, 100, 120, 6000, 1200, 1907, 8192, 30, 16000, 32767, 32767, 1828}},
|
||||
/* (stand-in) the snare noise struck 3 times */
|
||||
{DVT_CLAP, 48, 1777, 210, 7505, {0, 6827, 1870, 0, 6000, 30000, 50, 400, 3, 0, 0, 0, 0}},
|
||||
/* noise through a narrow band at 8 kHz, tau 52 ms */
|
||||
{DVT_HATC, 45, 1907, 225, 4594, {1907, 1024, 1870, 2042, 0, 0, 7000, 3, 6, 0, 0, 0, 0}},
|
||||
/* tau 78 ms */
|
||||
{DVT_HATO, 63, 1907, 197, 6084, {1907, 1024, 1870, 2042, 0, 0, 7000, 3, 6, 0, 0, 0, 0}},
|
||||
/* a low conga 157 Hz, tau 30 ms */
|
||||
{DVT_CONGA, 53, 819, 94, 5803, {0, 50, 1523, 0, 1500, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* 1.5 kHz, tau 2.7 ms */
|
||||
{DVT_RIM, 32, 1441, 13, 8636, {304, 26000, 1000, 4096, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* sines 830 / 613 Hz, tau 14 ms */
|
||||
{DVT_RIM, 40, 1280, 60, 3629, {-84, 30000, 7500, 4096, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
},
|
||||
{ /* 55 */
|
||||
/* 55 Hz dropping from 100, tau 45 ms */
|
||||
{DVT_PUNCH, 60, 531, 103, 4388, {163, 120, 0, 1600, 0, 1444, 1500, 6000, 0, 0, 0, 0, 0}},
|
||||
/* 245 Hz, noise 4.2 .. 7.6 kHz, tau 22 ms */
|
||||
{DVT_SNARE, 40, 942, 92, 5087, {0, 26, 180, 64, 0, 9000, 1809, 4096, 100, 32767, 32000, 0, 1828}},
|
||||
/* (stand-in) the snare noise struck 3 times */
|
||||
{DVT_CLAP, 48, 1809, 175, 6050, {0, 5120, 1870, 0, 6000, 30000, 50, 360, 3, 0, 0, 0, 0}},
|
||||
/* a cluster 8 .. 14.7 kHz + noise, tau 25 ms */
|
||||
{DVT_HATC, 45, 1909, 94, 2473, {1996, 5120, 1940, 2042, 4000, 11469, 18022, 3, 3, 0, 0, 0, 0}},
|
||||
/* tau 125 ms */
|
||||
{DVT_HATO, 63, 1909, 354, 1662, {1996, 5120, 1940, 2042, 4000, 11469, 18022, 3, 3, 0, 0, 0, 0}},
|
||||
/* a low tom 150 Hz, tau 57 ms */
|
||||
{DVT_TOM, 53, 824, 179, 4091, {21, 600, 1523, 9000, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* 500 + 1467 Hz, tau 2 ms */
|
||||
{DVT_RIM, 32, 1139, 10, 5884, {435, 22000, 22000, 24576, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* a wide cluster 0.7 .. 7.6 kHz, tau 34 ms */
|
||||
{DVT_CYM, 50, 1240, 114, 13203, {1701, 4096, 1550, 4096, 22000, 20000, 30, 19661, 8192, 4, 0, 0, 0}},
|
||||
},
|
||||
{ /* 77 */
|
||||
/* 66 Hz, a swell, tau 140 ms */
|
||||
{DVT_PUNCH, 60, 579, 337, 2590, {26, 450, 0, 1500, 520, 1478, 1800, 4096, 30, 0, 0, 0, 0}},
|
||||
/* 226 Hz, noise 1.2 .. 8 kHz, 2.5 + 60 ms */
|
||||
{DVT_SNARE, 40, 919, 251, 4125, {0, 0, 100, 37, 0, 20000, 1585, 10240, 25, 32767, 14000, 0, 1828}},
|
||||
/* 8 claps 7 ms apart, a tail */
|
||||
{DVT_CLAP, 48, 1393, 281, 8368, {0, 6302, 1585, 1500, 8000, 30000, 52, 322, 6, 0, 0, 0, 0}},
|
||||
/* six pulses 3.7 .. 13.5 kHz, tau 80 ms */
|
||||
{DVT_HATC, 45, 1690, 300, 3359, {1828, 8192, 1596, 2042, 0, 29491, 0, 3, 5, 0, 0, 0, 0}},
|
||||
/* tau 0.47 s */
|
||||
{DVT_HATO, 63, 1690, 1188, 2748, {1828, 8192, 1596, 2042, 0, 29491, 0, 3, 5, 0, 0, 0, 0}},
|
||||
/* tom 140 Hz bent 7.5 %, tau 120 ms */
|
||||
{DVT_TOM, 53, 797, 377, 2858, {20, 180, 1523, 2500, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* claves 2350 / 3180 Hz, tau 30 ms */
|
||||
{DVT_CLAVE, 32, 1568, 149, 2131, {84, 28000, 10000, 6348, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
/* the cymbal: 34 ms + 0.3 s */
|
||||
{DVT_CYM, 53, 1690, 1100, 7582, {1969, 5120, 1748, 5120, 24000, 16000, 34, 24576, 6554, 5, 0, 0, 0}},
|
||||
},
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------- setup helpers (not in the sample loops) --- */
|
||||
@@ -151,12 +303,14 @@ static uint32_t dv_kb(uint32_t us)
|
||||
k = 65536u - x + (x2 >> 1) - x3 / 6u + x4 / 24u;
|
||||
return k > 65535u ? 65535u : k;
|
||||
}
|
||||
/* the main tau of a type at DECAY d (us) */
|
||||
static uint32_t dv_tau(uint32_t type, uint32_t d)
|
||||
/* a main tau at DECAY d (us), from its tau at DECAY 0 (0.1 ms) and its span (octaves x 16) */
|
||||
static uint32_t dv_tau_of(uint32_t tau0, uint32_t oct16, uint32_t d)
|
||||
{
|
||||
uint32_t m = dv_exp2(d * DV_DEF[type].oct16 * 4096u / (127u * 16u)); /* Q16, below 2^21 */
|
||||
return (DV_DEF[type].tau0 * ((m * 100u) >> 12)) >> 4;
|
||||
uint32_t m = dv_exp2(d * oct16 * 4096u / (127u * 16u)); /* Q16, below 2^21 */
|
||||
return (tau0 * ((m * 100u) >> 12)) >> 4;
|
||||
}
|
||||
/* the main tau of a type at DECAY d (us) */
|
||||
static uint32_t dv_tau(uint32_t type, uint32_t d) { return dv_tau_of(DV_DEF[type].tau0, DV_DEF[type].oct16, d); }
|
||||
/* p16 -> the SVF's cutoff index (0..127 << 8: 30 Hz .. 16 kHz) */
|
||||
static int32_t dv_cut(int32_t p16) { return clamp(((p16 - 360) * 4785) >> 8, 0, 127 << 8); }
|
||||
/* p16 -> one-pole coefficient, Q15: w / (1 + w), w = 2 pi f / fs */
|
||||
@@ -177,7 +331,7 @@ static void dv_hp1(int32_t *g, int32_t *p, int32_t p16)
|
||||
/* 0..127 -> a / b .. 1: a gain in Q15 from v (lin) */
|
||||
static int32_t dv_lin(uint32_t v, int32_t lo, int32_t hi) { return lo + (int32_t)(((hi - lo) * (int32_t)v) / 127); }
|
||||
|
||||
static void dv_setup(dv_coef_t *c, const dv_param_t *p)
|
||||
static void dv_setup_own(dv_coef_t *c, const dv_param_t *p)
|
||||
{
|
||||
uint32_t t = p->type < DVT_COUNT ? p->type : 0u, d = p->decay, tn = p->tone, x = p->extra;
|
||||
int32_t p16 = clamp(DV_DEF[t].p16 + p->tune, DV_DEF[t].lo, DV_DEF[t].hi), acc = p->accent;
|
||||
@@ -185,6 +339,7 @@ static void dv_setup(dv_coef_t *c, const dv_param_t *p)
|
||||
for (i = 0; i < sizeof *c / 4u; i++)
|
||||
((uint32_t *)c)[i] = 0;
|
||||
c->type = (uint8_t)t;
|
||||
c->mrow = t == DVT_CYM;
|
||||
c->inc[0] = DV_P16(p16);
|
||||
c->metal = (int16_t)p16;
|
||||
/* output: the type's gain x LEVEL (127 = 1) x accent (+0..4 dB) */
|
||||
@@ -214,6 +369,7 @@ static void dv_setup(dv_coef_t *c, const dv_param_t *p)
|
||||
break;
|
||||
}
|
||||
case DVT_SNARE:
|
||||
c->click = 154; /* the 2nd shell sine: x1.6 */
|
||||
c->span[0] = DV_P16(p16 + 11) - c->inc[0]; /* glide: +4 % */
|
||||
c->k[0] = dv_k(20000);
|
||||
c->k[1] = dv_k(tau * 2u / 5u); /* shell: 0.4 x the noise body */
|
||||
@@ -297,10 +453,150 @@ static void dv_setup(dv_coef_t *c, const dv_param_t *p)
|
||||
}
|
||||
}
|
||||
|
||||
/* x (0..127) of a design value v at 64: v x / 64 */
|
||||
static int32_t dv_at(int32_t v, uint32_t x) { return v * (int32_t)x / 64; }
|
||||
/* a drive g (Q12, at least x1) and its level kept (Q15) */
|
||||
static void dv_drive(int32_t *g, int32_t *keep, int32_t d)
|
||||
{
|
||||
*g = d < 4096 ? 4096 : d;
|
||||
*keep = (int32_t)((19661u << 15) / (uint32_t)softclip((19661 * *g) >> 12));
|
||||
}
|
||||
|
||||
/* a model kit's voice: the same runs, the kit's numbers (DV_KIT). TUNE TONE DECAY extra (SNAP) and the accent move
|
||||
* them as they move Felucca's own (64: the kit's design) */
|
||||
static void dv_setup_kit(dv_coef_t *c, const dv_param_t *p)
|
||||
{
|
||||
uint32_t kit = DV_KITOF(p->type) - 1u, d = p->decay, tn = p->tone, x = p->extra, i;
|
||||
const dv_kit_t *K = &DV_KIT[kit][p->type & 7u];
|
||||
const int16_t *v = K->v;
|
||||
int32_t p16, dp, acc = p->accent;
|
||||
uint32_t tau;
|
||||
p16 = clamp(K->p16 + p->tune, K->p16 - 192, K->p16 + 192);
|
||||
dp = p16 - K->p16;
|
||||
tau = dv_tau_of(K->tau0, K->oct16, d);
|
||||
for (i = 0; i < sizeof *c / 4u; i++)
|
||||
((uint32_t *)c)[i] = 0;
|
||||
c->type = K->run; /* (the run; the lane's type is the caller's) */
|
||||
c->inc[0] = DV_P16(p16);
|
||||
c->metal = (int16_t)p16;
|
||||
c->out = (int32_t)(K->gain * (uint32_t)p->level / 127u);
|
||||
c->out += (c->out * acc * DV_KIT_ACC[kit]) >> 14;
|
||||
switch (K->run) {
|
||||
case DVT_PUNCH: {
|
||||
int32_t b = dv_at(v[0], tn) + (tn > 64u ? (int32_t)tn - 64 : 0); /* (TONE above 64: +4 semitones more) */
|
||||
c->span[1] = DV_P16(p16 + b) - c->inc[0];
|
||||
c->span[0] = DV_P16(p16 + v[2] + b) - DV_P16(p16 + b);
|
||||
c->k[0] = dv_k(1500);
|
||||
c->k[1] = dv_k((uint32_t)v[1] * 100u);
|
||||
c->k[2] = v[8] ? dv_k((uint32_t)v[8] * 100u) : 0; /* the rise */
|
||||
c->kb[0] = dv_kb(tau);
|
||||
c->hold = (uint16_t)v[9];
|
||||
c->g[0] = v[3];
|
||||
c->g[1] = v[4];
|
||||
if (v[5]) {
|
||||
c->inc[1] = DV_P16(v[5] + dp);
|
||||
c->inc[2] = c->inc[1] >> 1;
|
||||
c->click = (uint16_t)(0xFFFFFFFFu / c->inc[2]);
|
||||
c->g[2] = v[6] + ((v[6] * acc) >> 8);
|
||||
}
|
||||
dv_drive(&c->g[3], &c->g[4], v[7] * ((int32_t)x + 64) / 128);
|
||||
break;
|
||||
}
|
||||
case DVT_SNARE:
|
||||
c->click = (uint16_t)v[0];
|
||||
c->span[0] = DV_P16(p16 + v[1]) - c->inc[0];
|
||||
c->k[0] = dv_k((uint32_t)v[2] * 100u);
|
||||
c->k[1] = dv_k(tau * (uint32_t)v[3] / 64u);
|
||||
c->k[2] = dv_k((uint32_t)v[8] * 100u);
|
||||
c->kb[0] = dv_kb(tau);
|
||||
tsvf_coef_k(&c->f[0], dv_cut(v[6] + ((int32_t)tn - 64) * 2 + dp), v[7]);
|
||||
c->hp = dv_pole(v[12] + dp);
|
||||
c->g[0] = v[4];
|
||||
c->g[1] = v[5];
|
||||
c->g[2] = dv_at(v[10], x);
|
||||
c->g[3] = v[9] + ((v[9] * acc) >> 8);
|
||||
c->g[4] = v[11];
|
||||
break;
|
||||
case DVT_CLAP:
|
||||
tsvf_coef_k(&c->f[0], dv_cut(p16 + ((int32_t)tn - 64) * 2), v[1]);
|
||||
c->hp = dv_pole(v[2] + dp);
|
||||
c->k[0] = dv_k((uint32_t)v[6] * 100u);
|
||||
c->kb[0] = dv_kb(tau);
|
||||
c->hold = (uint16_t)(v[7] * (int32_t)(x + 64u) / 128);
|
||||
c->click = (uint16_t)v[8];
|
||||
c->g[0] = dv_at(v[3], tn);
|
||||
c->g[1] = v[4];
|
||||
c->g[2] = v[5] + acc * 20;
|
||||
break;
|
||||
case DVT_HATC:
|
||||
case DVT_HATO: {
|
||||
int32_t tp = ((int32_t)tn - 64) * 3 + dp;
|
||||
tsvf_coef_k(&c->f[0], dv_cut(v[0] + dp + ((int32_t)tn - 64) * 2), v[1]);
|
||||
dv_hp1(&c->g[2], &c->g[3], v[2] + tp);
|
||||
dv_hp1(&c->g[4], &c->g[5], v[3] + tp);
|
||||
c->g[1] = dv_at(v[4], x) + (x > 64u ? ((int32_t)x - 64) * 64 : 0); /* (SNAP above 64: up to x1 more) */
|
||||
c->kb[0] = dv_kb(tau);
|
||||
c->k[1] = dv_k((uint32_t)v[7] * 100u);
|
||||
c->kb[1] = dv_kb(1500);
|
||||
c->span[0] = (uint32_t)v[5]; /* the metal source, noise (dv_run) */
|
||||
c->span[1] = (uint32_t)v[6];
|
||||
c->mrow = (uint8_t)v[8];
|
||||
break;
|
||||
}
|
||||
case DVT_CYM:
|
||||
tsvf_coef_k(&c->f[0], dv_cut(v[0] + dp), v[1]);
|
||||
tsvf_coef_k(&c->f[1], dv_cut(v[2] + dp), v[3]);
|
||||
c->kb[0] = dv_kb(tau);
|
||||
c->kb[1] = dv_kb((uint32_t)v[6] * 1000u);
|
||||
c->g[0] = clamp(dv_at(v[4], tn), 0, 32767);
|
||||
c->g[1] = 32767 - c->g[0];
|
||||
c->g[2] = dv_at(v[5], x) + acc * 60;
|
||||
c->span[0] = (uint32_t)v[7];
|
||||
c->span[1] = (uint32_t)v[8];
|
||||
c->mrow = (uint8_t)v[9];
|
||||
break;
|
||||
case DVT_TOM:
|
||||
case DVT_CONGA:
|
||||
c->kb[0] = dv_kb(tau);
|
||||
c->span[0] = DV_P16(p16 + dv_at(v[0], x) + (x > 64u ? (int32_t)x - 64 : 0)) - c->inc[0];
|
||||
c->k[0] = dv_k((uint32_t)v[1] * 100u);
|
||||
c->hp = dv_pole(v[2] + ((int32_t)tn - 64) * 3);
|
||||
c->g[0] = dv_at(v[3], tn);
|
||||
c->g[2] = dv_at(v[4], tn);
|
||||
c->g[1] = tn > 64u ? (v[5] > 4096 ? v[5] : 4096) + ((int32_t)tn - 64) * 64 : v[5]; /* (TONE above 64:
|
||||
* into the soft clip, up to x1 more) */
|
||||
break;
|
||||
case DVT_RIM:
|
||||
case DVT_CLAVE:
|
||||
c->k[0] = dv_k(tau);
|
||||
c->inc[1] = DV_P16(p16 + v[0]);
|
||||
c->g[0] = v[1];
|
||||
c->g[1] = dv_at(v[2], tn);
|
||||
dv_drive(&c->g[2], &c->g[3], v[3] * ((int32_t)x + 64) / 128 * (512 + acc) / 512);
|
||||
break;
|
||||
default: /* DVT_BELL */
|
||||
c->inc[1] = DV_P16(p16 + v[0]);
|
||||
tsvf_coef_k(&c->f[0], dv_cut(p16 + v[1] + ((int32_t)tn - 64) * 2), v[2]);
|
||||
c->k[0] = dv_k((uint32_t)v[4] * 100u);
|
||||
c->kb[0] = dv_kb(tau);
|
||||
c->g[0] = dv_at(v[3], x) * 2 + acc * 40;
|
||||
c->g[1] = dv_at(v[5], tn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void dv_setup(dv_coef_t *c, const dv_param_t *p)
|
||||
{
|
||||
if (DV_KITOF(p->type) - 1u < DV_NKIT)
|
||||
dv_setup_kit(c, p);
|
||||
else
|
||||
dv_setup_own(c, p);
|
||||
}
|
||||
|
||||
static void dv_metal_tune(dv_metal_t *b, const dv_coef_t *c)
|
||||
{
|
||||
uint32_t i, inc = DV_P16(c->metal);
|
||||
const uint16_t *r = DV_METAL_R[c->type == DVT_CYM];
|
||||
const uint16_t *r = DV_METAL_R[c->mrow];
|
||||
for (i = 0; i < 6u; i++)
|
||||
b->inc[i] = (inc >> 12) * r[i];
|
||||
}
|
||||
@@ -346,7 +642,7 @@ static inline void dv_slow(int32_t *q, uint32_t kb, int32_t *a, int32_t *d)
|
||||
|
||||
static __attribute__((noinline)) void dv_kick_run(const dv_coef_t *c, dv_voice_t *v, int32_t *y, uint32_t n)
|
||||
{
|
||||
uint32_t i, ph = v->ph[0], cph = v->ph[1], wph = v->ph[2], p1 = v->e[0], p2 = v->e[1], cn = v->n;
|
||||
uint32_t i, ph = v->ph[0], cph = v->ph[1], wph = v->ph[2], p1 = v->e[0], p2 = v->e[1], cn = v->n, r = v->e[2];
|
||||
uint32_t k2 = v->cnt ? 32768u : c->k[1], s1 = c->span[0] >> 16, s2 = c->span[1] >> 16;
|
||||
int32_t a, d;
|
||||
dv_slow(&v->q[0], v->cnt ? 65536u : c->kb[0], &a, &d); /* (held) */
|
||||
@@ -359,7 +655,8 @@ static __attribute__((noinline)) void dv_kick_run(const dv_coef_t *c, dv_voice_t
|
||||
p2 = (p2 * k2) >> 15;
|
||||
b = sine_i(ph) + ((sine_i(ph << 1) * c->g[0]) >> 15) + ((sine_i(ph * 3u) * c->g[1]) >> 15);
|
||||
a += d;
|
||||
x = (b * (a >> 5)) >> 15;
|
||||
x = (b * ((a >> 5) - (int32_t)(r >> 1))) >> 15; /* (r: a rise, the model kits'; 0 on Felucca's own) */
|
||||
r = (r * c->k[2]) >> 15;
|
||||
if (cn) { /* the click: a windowed burst, mean 0 */
|
||||
int32_t w = (32768 - sine_i(wph + 0x40000000u)) >> 1;
|
||||
x += (((sine_i(cph) * w) >> 15) * c->g[2]) >> 15;
|
||||
@@ -369,7 +666,7 @@ static __attribute__((noinline)) void dv_kick_run(const dv_coef_t *c, dv_voice_t
|
||||
}
|
||||
y[i] = (softclip((x * c->g[3]) >> 12) * c->g[4]) >> 15;
|
||||
}
|
||||
v->ph[0] = ph, v->ph[1] = cph, v->ph[2] = wph, v->e[0] = p1, v->e[1] = p2, v->n = (uint16_t)cn;
|
||||
v->ph[0] = ph, v->ph[1] = cph, v->ph[2] = wph, v->e[0] = p1, v->e[1] = p2, v->e[2] = r, v->n = (uint16_t)cn;
|
||||
v->live = v->q[0] > DV_QUIET;
|
||||
}
|
||||
|
||||
@@ -383,7 +680,7 @@ static __attribute__((noinline)) void dv_snare_run(const dv_coef_t *c, dv_voice_
|
||||
int32_t sh, nz = DV_NOISE(v), bp, hp, x;
|
||||
eg = (eg * c->k[0]) >> 15;
|
||||
p0 += inc;
|
||||
p1 += inc + (inc >> 8) * 154u; /* x1.6 */
|
||||
p1 += inc + (inc >> 8) * c->click; /* x (1 + click / 256) */
|
||||
sh = sine_i(p0) + ((sine_i(p1) * c->g[0]) >> 15);
|
||||
sh = (sh * (int32_t)(es >> 1)) >> 15;
|
||||
es = (es * c->k[1]) >> 15;
|
||||
@@ -527,6 +824,16 @@ static __attribute__((noinline)) void dv_cym_run(const dv_coef_t *c, dv_voice_t
|
||||
v->live = v->q[0] > DV_QUIET;
|
||||
}
|
||||
|
||||
/* a model kit's metal: the source (c->span[0], Q15) and white noise (c->span[1]) mixed into y */
|
||||
static __attribute__((noinline)) void dv_metal_mix(const dv_coef_t *c, dv_voice_t *v, const int32_t *m, int32_t *y,
|
||||
uint32_t n)
|
||||
{
|
||||
uint32_t i;
|
||||
int32_t gm = (int32_t)c->span[0], gn = (int32_t)c->span[1];
|
||||
for (i = 0; i < n; i++)
|
||||
y[i] = (m[i] * gm + DV_NOISE(v) * gn) >> 15;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- the API --- */
|
||||
static void dv_init(dv_voice_t *v, uint32_t type)
|
||||
{
|
||||
@@ -553,6 +860,7 @@ static void dv_strike(const dv_coef_t *c, dv_voice_t *v)
|
||||
case DVT_ROUND:
|
||||
v->cnt = c->hold;
|
||||
v->n = c->click;
|
||||
v->e[2] = c->k[2] ? 65536u : 0; /* the rise, if any */
|
||||
break;
|
||||
case DVT_CLAP:
|
||||
v->q[0] = 0;
|
||||
@@ -591,6 +899,10 @@ static void dv_run(const dv_coef_t *c, dv_voice_t *v, const int32_t *metal, int3
|
||||
v->live = 0;
|
||||
return;
|
||||
}
|
||||
if (dv_uses_metal(c->type) && c->span[1]) { /* a model kit's metal: the source and white noise */
|
||||
dv_metal_mix(c, v, metal, y, n);
|
||||
metal = y; /* (the runs read a sample before they write it) */
|
||||
}
|
||||
switch (c->type) {
|
||||
case DVT_PUNCH:
|
||||
case DVT_ROUND:
|
||||
@@ -624,13 +936,20 @@ static void dv_run(const dv_coef_t *c, dv_voice_t *v, const int32_t *metal, int3
|
||||
dv_out(c, y, n);
|
||||
}
|
||||
|
||||
/* the designed parameters of a type (LEVEL 100, no accent) */
|
||||
/* the run a type plays through (DVT_*): itself, or its model kit's lane's */
|
||||
static uint32_t dv_run_type(uint32_t type)
|
||||
{
|
||||
return DV_KITOF(type) - 1u < DV_NKIT ? DV_KIT[DV_KITOF(type) - 1u][type & 7u].run : type < DVT_COUNT ? type : 0u;
|
||||
}
|
||||
|
||||
/* the designed parameters of a type (LEVEL 100, no accent); a model kit's lane: 64 each */
|
||||
static void dv_default(dv_param_t *p, uint32_t type)
|
||||
{
|
||||
uint32_t own = DV_KITOF(type) == 0;
|
||||
p->type = (uint8_t)type;
|
||||
p->decay = DV_DEF[type].def[0];
|
||||
p->tone = DV_DEF[type].def[1];
|
||||
p->extra = DV_DEF[type].def[2];
|
||||
p->decay = own ? DV_DEF[type].def[0] : 64;
|
||||
p->tone = own ? DV_DEF[type].def[1] : 64;
|
||||
p->extra = own ? DV_DEF[type].def[2] : 64;
|
||||
p->level = 100;
|
||||
p->accent = 0;
|
||||
p->tune = 0;
|
||||
|
||||
@@ -338,6 +338,7 @@ static int ed_flash_stop(void)
|
||||
#include "editor_preferences.c"
|
||||
#include "editor_backup.c"
|
||||
#include "editor_fm6.c"
|
||||
#include "editor_menu.c"
|
||||
|
||||
static void ed_motion_reply(uint32_t k, uint32_t rc)
|
||||
{
|
||||
@@ -361,8 +362,10 @@ static int ed_args_ok(uint32_t cmd, const uint8_t *a, uint32_t n)
|
||||
case ED_SET:
|
||||
return n == 4u;
|
||||
case ED_STEP_GET: case ED_NAMES: case ED_SMP_BEGIN: case ED_SMP_ERASE:
|
||||
case ED_UP_GET: case ED_UP_LOAD: case ED_UP_ERASE: case ED_WATCH: case ED_TRACK_DUMP:
|
||||
case ED_UP_GET: case ED_UP_LOAD: case ED_UP_ERASE: case ED_WATCH: case ED_TRACK_DUMP: case ED_MENU_DESC:
|
||||
return n == 1u;
|
||||
case ED_MENU_SET:
|
||||
return n == 3u;
|
||||
case ED_STEP_SET:
|
||||
return n == 9u || n == 12u || (n == 13u && a[12] <= 100u); /* notes only, or the complete grid extension */
|
||||
case ED_TRACK:
|
||||
@@ -396,6 +399,7 @@ static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes between F0
|
||||
if (ed_ui_handle(cmd, a, na)) { ed_send(); return; }
|
||||
if (ed_backup_handle(cmd, a, na)) { ed_send(); return; }
|
||||
if (ed_fm6_handle(cmd, a, na)) { ed_send(); return; }
|
||||
if (ed_menu_handle(cmd, a, na)) { ed_send(); return; }
|
||||
switch (cmd) {
|
||||
case ED_MOTION: {
|
||||
track_t *t = &trk[a[0]]; uint32_t rc = 0;
|
||||
@@ -429,6 +433,7 @@ static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes between F0
|
||||
ed_b(0x53); ed_b(1); ed_b(3); /* live sync: bit 0 WATCH while on keeps the shadow, bit 1 no RELOAD echo */
|
||||
ed_b(0x50); ed_b(1); ed_b(3); /* FM6 patches v2: bit 0 no bank (SLOT F1..F8, 8 OWN), bit 1 user preset
|
||||
* patches (FM6 target 3, backup id 9) */
|
||||
ed_b(0x4E); ed_b(1); ed_b(ED_MENU_N); /* MENU settings: cmds 72, 73; the items MENU_DESC offers */
|
||||
break;
|
||||
case ED_GET:
|
||||
case ED_SET:
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* MENU's settings for the editor (EDITOR_PROTOCOL.md "MENU settings"): MENU_DESC describes one, MENU_SET sets one;
|
||||
* INFO 4E 01 count. The editor builds its settings from these; the values, names and the apply path are the menu's
|
||||
* own (menu_items.c), so the two cannot differ. CALIBRATION and ABOUT are not offered (no value).
|
||||
* ED_MENU: {row, id} in the menu's order. An id keeps its meaning for good: a new setting takes the next free id
|
||||
* (append-only), wherever its row goes; ids 0..126 (127: none). */
|
||||
enum { ED_MENU_DESC = 72, ED_MENU_SET };
|
||||
enum { EDM_ENUM, EDM_INT }; /* kind: names follow; or a unit (none yet) */
|
||||
static const uint8_t ED_MENU[][2] = {
|
||||
{MI_COLOR, 0}, {MI_STYLE, 1}, {MI_LARGE, 2}, {MI_ANIM, 3}, {MI_LEDS, 4}, {MI_HOLD, 5}, {MI_ACCEL, 6},
|
||||
{MI_LATCH, 7}, {MI_BPMLOCK, 8}, {MI_LOWCUT, 9}, {MI_USB, 10}, {MI_SERIAL, 11},
|
||||
};
|
||||
#define ED_MENU_N NELEM(ED_MENU)
|
||||
|
||||
/* rc as UI_SET: 0 applied and saved, 3 applied in RAM only (no flash, a failed write), 4 queued until STOP */
|
||||
static uint32_t ed_menu_save(void)
|
||||
{
|
||||
settings_save();
|
||||
#if FELUCCA_FLASH
|
||||
if (!flash_ok || persist_pending == 2u) return 3;
|
||||
if (persist_pending == 1u) return 4;
|
||||
{
|
||||
persist_t p = persist_saved;
|
||||
settings_export(&p);
|
||||
return memcmp(&p, &persist_saved, sizeof p) ? 3u : 0u;
|
||||
}
|
||||
#else
|
||||
return 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ed_menu_handle(uint32_t cmd, const uint8_t *a, uint32_t n)
|
||||
{
|
||||
uint32_t i, row, k;
|
||||
int32_t v;
|
||||
if (cmd == ED_MENU_DESC) { /* index -> index, id, kind, value, min, max (v14), name, names */
|
||||
ed_b(a[0]);
|
||||
if (a[0] >= ED_MENU_N) {
|
||||
ed_b(127); /* no such item: the list ends */
|
||||
return 1;
|
||||
}
|
||||
row = ED_MENU[a[0]][0];
|
||||
k = menu_n(row);
|
||||
ed_b(ED_MENU[a[0]][1]);
|
||||
ed_b(EDM_ENUM);
|
||||
ed_v((int32_t)menu_get(row));
|
||||
ed_v(0);
|
||||
ed_v((int32_t)k - 1);
|
||||
ed_str(MI_NAME[row], 12);
|
||||
for (i = 0; i < k; i++)
|
||||
ed_str(menu_vname(row, i), 12);
|
||||
return 1;
|
||||
}
|
||||
if (cmd != ED_MENU_SET)
|
||||
return 0;
|
||||
(void)n; /* id, value v14 -> rc, id, value v14 (the device's, clamped) */
|
||||
v = ed_rv(a + 1);
|
||||
for (i = 0; i < ED_MENU_N && ED_MENU[i][1] != a[0]; i++)
|
||||
;
|
||||
if (i == ED_MENU_N) {
|
||||
ed_b(1); ed_b(a[0]); ed_v(v);
|
||||
return 1;
|
||||
}
|
||||
row = ED_MENU[i][0];
|
||||
menu_put(row, (uint32_t)clamp(v, 0, (int32_t)menu_n(row) - 1));
|
||||
if (row == MI_SERIAL)
|
||||
menu_serial_at = fm1_ms | 1u; /* (applied 200 ms after this reply: usb_serial_apply) */
|
||||
ui.force = 1; /* (the MENU page, if shown, redraws) */
|
||||
ed_b(ed_menu_save());
|
||||
ed_b(a[0]);
|
||||
ed_v((int32_t)menu_get(row));
|
||||
return 1;
|
||||
}
|
||||
+39
-19
@@ -11,7 +11,8 @@
|
||||
* load as this engine, core.h drum_from_perc).
|
||||
*
|
||||
* Parameters: KIT what the lanes 6..8 play (STD: TOM RIM BELL, HAND: CONGA CLAVE BELL, CYM: TOM RIM CYM,
|
||||
* H+CYM: CONGA CLAVE CYM), KICK the kick (PUNCH, ROUND). TUNE (64: as designed, +-12 semitones), TONE,
|
||||
* H+CYM: CONGA CLAVE CYM), or a model kit (80 10 66 55 77: every lane that kit's own piece, drum_voice.c DV_KIT;
|
||||
* KICK does not apply), KICK the kick (PUNCH, ROUND). TUNE (64: as designed, +-12 semitones), TONE,
|
||||
* DECY and SNAP (each lane's extra: the kick's drive, the snare's snappiness, the clap's spread, the hats'
|
||||
* noise, the toms' bend, the rim's drive, the bell's strike) move every lane from its designed value. ACC
|
||||
* is the accent at full velocity (velocity scales it), DRV a soft clip on every hit (x1..x4, level kept).
|
||||
@@ -31,7 +32,10 @@
|
||||
* source of each lane). */
|
||||
#include "drum_voice.c"
|
||||
|
||||
enum { DK_STD, DK_HAND, DK_CYM, DK_HCYM };
|
||||
enum { DK_STD, DK_HAND, DK_CYM, DK_HCYM, DK_80, DK_10, DK_66, DK_55, DK_77, DK_COUNT };
|
||||
/* the model kits' pieces where a lane plays another than its own (the lane's name): 1 TOM -> CONGA, 2 RIM -> CLAVE,
|
||||
* 4 BELL -> CYM */
|
||||
static const uint8_t DK_SWAP[DV_NKIT] = {0, 4, 1, 0, 2 | 4};
|
||||
static const uint8_t DV_TYPE_LANE[DVT_COUNT] = {
|
||||
DV_KICK, DV_KICK, DV_SNARE, DV_CLAP, DV_HATC, DV_HATO, DV_TOM, DV_TOM, DV_RIM, DV_RIM, DV_BELL, DV_BELL,
|
||||
};
|
||||
@@ -49,7 +53,7 @@ typedef struct {
|
||||
|
||||
static drum_lane_t drum_kit[NPART][DV_NLANE] __attribute__((section(".pool")));
|
||||
|
||||
static const char *const N_DRUM_KIT[] = {"STD", "HAND", "CYM", "H+CYM"};
|
||||
static const char *const N_DRUM_KIT[] = {"STD", "HAND", "CYM", "H+CYM", "80", "10", "66", "55", "77"};
|
||||
static const char *const N_DRUM_KICK[] = {"PUNCH", "ROUND"};
|
||||
|
||||
/* General MIDI notes 35..81 -> the drum (DVT_*; DVT_PUNCH: the kick KICK picks) and semitones from its
|
||||
@@ -64,13 +68,15 @@ static const int8_t DRUM_GM[47][2] = {
|
||||
{DVT_CLAVE, 7}, {DVT_CLAVE, 5}, {DVT_HATC, -4}, {DVT_HATC, -6}, {DVT_CLAVE, 0}, {DVT_CLAVE, -4}, /* 71 */
|
||||
{DVT_CLAVE, -7}, {DVT_CONGA, 7}, {DVT_CONGA, 3}, {DVT_BELL, 12}, {DVT_BELL, 12}, /* 77 */
|
||||
};
|
||||
/* the drum of a note (DVT_*) and its semitones; KICK picks the kick, KIT swaps TOM RIM for CONGA CLAVE
|
||||
* (HAND) and BELL for CYM (CYM) */
|
||||
/* the drum of a note (DVT_*, or a model kit's lane: DV_KTYPE) and its semitones; KICK picks the kick, KIT swaps
|
||||
* TOM RIM for CONGA CLAVE (HAND) and BELL for CYM (CYM); a model kit plays its own piece on the note's lane */
|
||||
static uint32_t drum_gm(const int16_t *p, uint32_t note, int32_t *st)
|
||||
{
|
||||
uint32_t n = note >= 35u && note <= 81u ? note : 36u + (note + 120u - 36u) % 12u, t = (uint32_t)DRUM_GM[n - 35u][0];
|
||||
uint32_t kit = (uint32_t)clamp(p[P_E0], 0, 3); /* STD HAND CYM H+CYM */
|
||||
uint32_t kit = (uint32_t)clamp(p[P_E0], 0, DK_COUNT - 1); /* STD HAND CYM H+CYM, the model kits */
|
||||
*st = DRUM_GM[n - 35u][1];
|
||||
if (kit >= DK_80)
|
||||
return DV_KTYPE(kit - DK_80 + 1u, DV_TYPE_LANE[t]);
|
||||
if (t == DVT_PUNCH && p[P_E6] > 0)
|
||||
t = DVT_ROUND;
|
||||
if (kit & 1u)
|
||||
@@ -93,25 +99,36 @@ static uint32_t drum_lane(uint32_t note)
|
||||
return DV_TYPE_LANE[DRUM_GM[n - 35u][0]];
|
||||
}
|
||||
|
||||
/* KIT's swaps of lanes 6..8 (1 TOM -> CONGA, 2 RIM -> CLAVE, 4 BELL -> CYM) */
|
||||
static uint32_t drum_swaps(const track_t *t)
|
||||
{
|
||||
uint32_t kit = (uint32_t)clamp(t->p[P_E0], 0, DK_COUNT - 1);
|
||||
return kit >= DK_80 ? DK_SWAP[kit - DK_80] : (kit & 1u) * 3u | (kit & 2u) << 1;
|
||||
}
|
||||
|
||||
/* the lane's name as the track's KIT plays it (5 characters at most) */
|
||||
static const char *drum_lane_name(const track_t *t, uint32_t l)
|
||||
{
|
||||
static const char *const N[NLANE] = {"KICK", "SNARE", "CLAP", "HATCL", "HATOP", "TOM", "RIM", "BELL"};
|
||||
uint32_t kit = (uint32_t)clamp(t->p[P_E0], 0, 3);
|
||||
uint32_t kit = drum_swaps(t);
|
||||
l &= NLANE - 1u;
|
||||
if ((kit & 1u) && (l == DV_TOM || l == DV_RIM))
|
||||
return l == DV_TOM ? "CONGA" : "CLAVE";
|
||||
return (kit & 2u) && l == DV_BELL ? "CYM" : N[l];
|
||||
if (l == DV_TOM && (kit & 1u))
|
||||
return "CONGA";
|
||||
if (l == DV_RIM && (kit & 2u))
|
||||
return "CLAVE";
|
||||
return (kit & 4u) && l == DV_BELL ? "CYM" : N[l];
|
||||
}
|
||||
/* .. in two letters, the drum machine way (the grid's lane column) */
|
||||
static const char *drum_lane_abbr(const track_t *t, uint32_t l)
|
||||
{
|
||||
static const char *const N[NLANE] = {"BD", "SD", "CP", "CH", "OH", "TM", "RS", "CB"};
|
||||
uint32_t kit = (uint32_t)clamp(t->p[P_E0], 0, 3);
|
||||
uint32_t kit = drum_swaps(t);
|
||||
l &= NLANE - 1u;
|
||||
if ((kit & 1u) && (l == DV_TOM || l == DV_RIM))
|
||||
return l == DV_TOM ? "CG" : "CL";
|
||||
return (kit & 2u) && l == DV_BELL ? "CY" : N[l];
|
||||
if (l == DV_TOM && (kit & 1u))
|
||||
return "CG";
|
||||
if (l == DV_RIM && (kit & 2u))
|
||||
return "CL";
|
||||
return (kit & 4u) && l == DV_BELL ? "CY" : N[l];
|
||||
}
|
||||
|
||||
/* the lanes step s strikes: its hits, and its notes on their lanes (a NOTE step only) */
|
||||
@@ -189,12 +206,12 @@ static void drum_note_on(track_t *t, voice_t *v)
|
||||
if (!K || i >= NVOICE)
|
||||
return;
|
||||
role = drum_gm(t->p, v->note, &st);
|
||||
lane = DV_TYPE_LANE[role];
|
||||
lane = drum_lane(v->note);
|
||||
L = &K[(uint32_t)v->s[0] & (DV_NLANE - 1u)];
|
||||
if (L->owner == i + 1u) /* this voice played another lane: it stops there */
|
||||
L->owner = 0;
|
||||
L = &K[lane];
|
||||
if (L->role != role || L->v.type != role) { /* another drum on this lane: from rest */
|
||||
if (L->role != role || L->v.type != dv_run_type(role)) { /* another drum on this lane: from rest */
|
||||
dv_init(&L->v, role);
|
||||
L->key.type = 0xFF;
|
||||
L->role = (uint8_t)role;
|
||||
@@ -203,6 +220,9 @@ static void drum_note_on(track_t *t, voice_t *v)
|
||||
L->owner = (uint8_t)(i + 1u); /* (its last voice, if another, ends: drum_amp) */
|
||||
v->s[0] = (int32_t)lane;
|
||||
v->env_out = v->vel * 258; /* the hit starts at its level (no ramp from 0) */
|
||||
v->env = 1 << 24; /* the ADSR held at full from here, not from drum_amp:
|
||||
* a key-off before the first block (zero-length MIDI
|
||||
* notes) would end a fresh voice at env 0 in env_tick */
|
||||
dv_trigger(&L->v);
|
||||
if (lane == DV_HATC && K[DV_HATO].v.live) /* a closed hat chokes the open one */
|
||||
dv_choke(&K[DV_HATO].v);
|
||||
@@ -248,10 +268,10 @@ static void drum_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
((const uint32_t *)&k)[1] != ((const uint32_t *)&L->key)[1]) {
|
||||
dv_setup(&L->c, &k); /* (a parameter moved) */
|
||||
L->key = k;
|
||||
if (dv_uses_metal(r))
|
||||
if (dv_uses_metal(L->c.type))
|
||||
dv_metal_tune(&L->mb, &L->c);
|
||||
}
|
||||
if (dv_uses_metal(r) && (L->v.live || L->v.trig))
|
||||
if (dv_uses_metal(L->c.type) && (L->v.live || L->v.trig))
|
||||
dv_metal_run(&L->mb, mb, n);
|
||||
dv_run(&L->c, &L->v, mb, y, n);
|
||||
if (drv > 0) { /* DRV: x1..x4 into the soft clip, the level kept (Q12) */
|
||||
@@ -282,7 +302,7 @@ static const engine_t ENG_DRUM = {
|
||||
.name = "DRUM",
|
||||
.page_title = {"KIT", "HIT"},
|
||||
.edit = {
|
||||
{"KIT", F_ENUM, 0, 3, DK_STD, N_DRUM_KIT, 0},
|
||||
{"KIT", F_ENUM, 0, DK_COUNT - 1, DK_STD, N_DRUM_KIT, 0},
|
||||
{"TUNE", F_PCT, 0, 127, 64, 0, 0},
|
||||
{"TONE", F_PCT, 0, 127, 64, 0, 0},
|
||||
{"DECY", F_PCT, 0, 127, 64, 0, 0},
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
* entry below, then up to 255 decodes skipped. A forward grain then decodes as it plays (one
|
||||
* decode per source sample); a reverse grain reads a 128-sample window that it refills from the
|
||||
* index as it moves down (about two decodes per source sample). A SRC change or a new upload into
|
||||
* the slot (smp_user_gen) rebuilds the index.
|
||||
* the slot (smp_user_gen) rebuilds the index. A source with no data (an empty user slot, a set this build lacks)
|
||||
* plays a plain sine voice instead (eng_sample.c smp_sine): no grains, clearly a fallback.
|
||||
*
|
||||
* Grains: a pool of GR_NG per part, shared by its voices (each voice may hold its share of the
|
||||
* pool: GR_NG / sounding voices, at least 2), at most GR_POLY voices. A grain: position, length
|
||||
@@ -129,11 +130,14 @@ static inline int32_t gr_dec(const smp_zone_t *z, uint32_t pos, int32_t *pred, i
|
||||
}
|
||||
|
||||
/* the zone of a note (as SAMPLE: the last zone that holds it; a built-in set falls back to its
|
||||
* first zone, a user slot stays silent), -1 = none */
|
||||
* first zone, a user slot stays silent), -1 = none, GR_SINE = the source has no data (smp_sine) */
|
||||
#define GR_SINE (-2)
|
||||
static int32_t gr_find(uint32_t src, uint32_t note)
|
||||
{
|
||||
uint32_t i, nz = gr_nz(src);
|
||||
int32_t zl = src < SMP_NSETS ? 0 : -1;
|
||||
if (smp_set_missing(src))
|
||||
return GR_SINE;
|
||||
for (i = 0; i < nz && i < GR_MAXZ; i++) {
|
||||
const smp_zone_t *z = gr_zone(src, i);
|
||||
if (note >= z->lo && note <= z->hi)
|
||||
@@ -352,6 +356,7 @@ static void grain_note_on(track_t *t, voice_t *v)
|
||||
uint32_t vi = (uint32_t)(v - t->v) % NVOICE, i;
|
||||
v->s[0] = gr_find((uint32_t)t->p[P_E0] % SMP_NALL, v->note);
|
||||
v->s[1] = 0; /* the first grain at once */
|
||||
v->ph[0] = 0; /* (the sine's phase: no data) */
|
||||
if (!v->env) { /* a fresh voice: no grains left from before */
|
||||
for (i = 0; i < GR_NG; i++)
|
||||
if (P->g[i].owner == vi + 1u)
|
||||
@@ -388,6 +393,11 @@ static void grain_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
int32_t zl = v->s[0], acc[CTL], lp, y = v->s[2];
|
||||
if (n > CTL)
|
||||
n = CTL;
|
||||
if (zl == GR_SINE) { /* no data: a plain sine at the note's pitch + PTCH, TONE */
|
||||
lp = 4000 + ((clamp((p[P_E7] << 8) + m->cutoff, 0, 127 << 8) * 28767) >> 15);
|
||||
smp_sine(out, n, m, p[P_E4] * 16, lp, &v->ph[0], &v->s[2]);
|
||||
return;
|
||||
}
|
||||
if (zl < 0 || zl >= P->nz || P->src != (uint32_t)p[P_E0] % SMP_NALL + 1u) {
|
||||
if (zl < 0)
|
||||
v->active = 0; /* a user slot key with no zone: silent */
|
||||
|
||||
@@ -96,6 +96,30 @@ static void smp_user_scan(uint32_t k)
|
||||
slc_user_scan(k, 1);
|
||||
}
|
||||
|
||||
/* A missing sample (SAMPLE, GRAIN, SLICE: an empty or invalid user slot, a set this build has no data for) plays
|
||||
* this instead, like a hardware sampler with its sample gone: a plain sine at the note's pitch (+ d16, 1/16
|
||||
* semitones), at half the peak of a full sample, through the engine's one-pole low-pass (lp Q15, state *y) and the
|
||||
* voice's amp (the ADSR: no click at the start, phase 0, or the end). *ph its phase. The UI says so once
|
||||
* (engines.c snd_missing, ui_input.c sample_notice). */
|
||||
static void smp_sine(int32_t *out, uint32_t n, const vmod_t *m, int32_t d16, int32_t lp, uint32_t *ph, int32_t *y)
|
||||
{
|
||||
uint32_t i, p = *ph, inc = pitch_inc((uint32_t)clamp(m->pitch16 + d16, 0, 2047));
|
||||
int32_t s = *y;
|
||||
for (i = 0; i < n; i++, p += inc) {
|
||||
s += mulq15((sine_i(p) >> 1) - s, lp);
|
||||
out[i] += voice_amp(s, m, i) << 1;
|
||||
}
|
||||
*ph = p;
|
||||
*y = s;
|
||||
}
|
||||
/* SET / SRC si (0..SMP_NALL - 1) has no sample data: an empty or invalid user slot, a built-in set without data */
|
||||
static int smp_set_missing(uint32_t si)
|
||||
{
|
||||
if (si < SMP_NSETS)
|
||||
return !SMP_ZONES[SMP_SETS[si].z0].n;
|
||||
return !usr_nz[(si - SMP_NSETS) % SMP_USER_SLOTS];
|
||||
}
|
||||
|
||||
/* zone index in a voice: < 0x8000 built-in, else 0x8000 | slot << 5 | zone */
|
||||
static inline const smp_zone_t *smp_zone(uint32_t zi)
|
||||
{
|
||||
@@ -156,6 +180,8 @@ static void sample_note_on(track_t *t, voice_t *v)
|
||||
v->s[2] = v->s[3] = 0;
|
||||
v->s[6] = zi == 0xFFFFu; /* 1 = sample ended (one-shot); a kit key with no sound stays silent */
|
||||
v->s[7] = 0; /* lo-pass state */
|
||||
if (smp_set_missing(si))
|
||||
v->s[6] = 2; /* 2 = no sample data: the sine (smp_sine; ph[0] its phase) */
|
||||
}
|
||||
|
||||
static void sample_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
|
||||
@@ -167,6 +193,10 @@ static void sample_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, cons
|
||||
uint32_t r = pow2_q16(d16), stepq = (r >> 8) * (z->rate >> 8); /* Q16 samples per output */
|
||||
int32_t bits = p[P_E2], lp = 4000 + ((clamp((p[P_E4] << 8) + m->cutoff, 0, 127 << 8) * 28767) >> 15);
|
||||
int32_t drv = p[P_E6], sh = bits / 10;
|
||||
if (v->s[6] == 2) { /* no sample data: the sine at the note's pitch + TUNE */
|
||||
smp_sine(out, n, m, p[P_E1] * 16, lp, &v->ph[0], &v->s[7]);
|
||||
return;
|
||||
}
|
||||
if (v->s[6] || !z->n) {
|
||||
v->active = 0;
|
||||
return;
|
||||
|
||||
+42
-25
@@ -3,16 +3,20 @@
|
||||
/* SLICE: a sample slicer, played from the keys and the sequencer. Felucca's own design.
|
||||
*
|
||||
* Material (SRC): the built-in BREAK (tools/gen_samples.py: one bar of 16ths at 120 BPM arranged
|
||||
* from Felucca's generated drums, stored after the SAMPLE sets) or a user slot USR1..3 (the same
|
||||
* from Felucca's generated drums, stored after the SAMPLE sets), a user slot USR1..3 (the same
|
||||
* slots as SAMPLE's, eng_sample.c), whose zones are played one after the other as one recording
|
||||
* (a zone that shares its data with an earlier one is skipped). An empty slot plays BREAK.
|
||||
* (a zone that shares its data with an earlier one is skipped), or PIANO (SRC 4, since 1.0.4: one
|
||||
* note, the SAMPLE engine's PIANO zone of middle C, played from its data in SMP_DATA: no copy).
|
||||
* A source with no material (an empty or invalid slot; PIANO in a build without the CC0 samples)
|
||||
* plays a plain sine at the key's pitch (+ PTCH) instead, through DCAY, TONE and the ADSR (MODE ONE
|
||||
* acts as GATE there: no slice end), and the UI says so (ui_input.c sample_notice).
|
||||
*
|
||||
* Slices (DIV): 4 / 8 / 16 / 32 equal ones, AUTO: one per onset, or MAN: set by hand on the EDIT family's SLICES
|
||||
* page (ui_slice.c) for a user slot (BREAK and an empty slot: MAN plays AUTO). IMA ADPCM can only be entered
|
||||
* page (ui_slice.c) for a user slot (BREAK and PIANO: MAN plays AUTO). IMA ADPCM can only be entered
|
||||
* at a known decoder state, so each source keeps a table (slc_src_t): the states at the 128 grid
|
||||
* points k * len / 128 (every equal slice starts on one, and they are the reverse checkpoints) and
|
||||
* up to 32 AUTO starts with their states. BREAK's table is written at build time (its hits are
|
||||
* the AUTO slices); a user slot's is computed by slc_scan when the slot becomes valid
|
||||
* up to 32 AUTO starts with their states. BREAK's and PIANO's tables are written at build time (BREAK's
|
||||
* hits are its AUTO slices; PIANO has one, the attack); a user slot's is computed by slc_scan when the slot becomes valid
|
||||
* (smp_user_scan: boot, upload end; main loop, never the audio ISR): two decoding passes; per hop
|
||||
* of 32 samples the peak of the first difference (hats, snares, clicks stand out, a kick's tail
|
||||
* does not) and the plain peak (low hits); an onset is a hop where either rises 1.75x over its
|
||||
@@ -33,8 +37,8 @@
|
||||
* over one block (0.7 ms).
|
||||
* Voice state: ph[0] position (reverse: position + 1), ph[1] fraction Q16, ph[2] slice end (reverse:
|
||||
* its start), s[0] predictor (reverse: window start), s[1] step index, s[2] / s[3] previous / current
|
||||
* sample, s[4] source | segment << 2 | reverse << 6 | slice << 8 | DIV << 16, s[5] DECAY level Q15,
|
||||
* s[6] 0 to prime, 1 playing, 3 fading out, 2 ended, s[7] low-pass. */
|
||||
* sample, s[4] source | segment << 3 | reverse << 7 | slice << 8 | DIV << 16 (source SLC_SINE: the sine, its
|
||||
* phase in ph[0]), s[5] DECAY level Q15, s[6] 0 to prime, 1 playing, 3 fading out, 2 ended, s[7] low-pass. */
|
||||
#define SLC_GRID 128u /* grid points: decoder states at k * len / SLC_GRID */
|
||||
#define SLC_GRID_LOG2 7
|
||||
#define SLC_AUTO 32u /* AUTO slices at most */
|
||||
@@ -55,9 +59,14 @@ typedef struct {
|
||||
} slc_src_t;
|
||||
|
||||
static const slc_src_t SLC_BREAK = SLC_BREAK_INIT;
|
||||
static const slc_src_t SLC_PIANO = SLC_PIANO_INIT;
|
||||
static slc_src_t slc_usr[SMP_USER_SLOTS];
|
||||
static int16_t slc_rbuf[NPART][NVOICE][SLC_RB]; /* reverse windows, one per part voice */
|
||||
static const char *const N_SLC_SRC[] = {"BREAK", "USR1", "USR2", "USR3"};
|
||||
/* append-only: stored sounds keep their SRC numbers (1.0.4 added PIANO) */
|
||||
static const char *const N_SLC_SRC[] = {"BREAK", "USR1", "USR2", "USR3", "PIANO"};
|
||||
#define SLC_SRC_PIANO 4u
|
||||
#define SLC_NSRC 5
|
||||
#define SLC_SINE 7u /* a voice's source when it has no material: the sine */
|
||||
static const char *const N_SLC_DIV[] = {"4", "8", "16", "32", "AUTO", "MAN"};
|
||||
static const char *const N_SLC_MODE[] = {"ONE", "GATE", "LOOP"};
|
||||
static const char *const N_SLC_REV[] = {"OFF", "ON"};
|
||||
@@ -79,11 +88,15 @@ static volatile uint8_t slc_man_cur[SMP_USER_SLOTS];
|
||||
static void (*slc_man_load)(uint32_t k); /* slice_store.c: a slot was read (smp_user_scan): its stored slices */
|
||||
static uint8_t slc_man_save; /* bit k: slot k's slices changed, to flash (slice_store.c) */
|
||||
|
||||
/* source 0 = BREAK, 1..3 = USR1..3; 0 = no material (an empty or erased slot) */
|
||||
/* the SRC of a part's sound (0..4: a stored value out of range reads as the nearest) */
|
||||
static uint32_t slc_src_of(const int16_t *p) { return (uint32_t)clamp(p[P_E0], 0, SLC_NSRC - 1); }
|
||||
/* source 0 = BREAK, 1..3 = USR1..3, 4 = PIANO; 0 = no material (an empty or erased slot, no PIANO in the build) */
|
||||
static const slc_src_t *slc_get(uint32_t src)
|
||||
{
|
||||
if (!src)
|
||||
return SLC_BREAK.len ? &SLC_BREAK : 0;
|
||||
if (src == SLC_SRC_PIANO)
|
||||
return SLC_PIANO.len ? &SLC_PIANO : 0;
|
||||
src--;
|
||||
return src < SMP_USER_SLOTS && usr_nz[src] && slc_usr[src].len ? &slc_usr[src] : 0;
|
||||
}
|
||||
@@ -134,7 +147,7 @@ static inline int32_t slc_dec_next(const slc_src_t *s, slc_dec_t *d)
|
||||
}
|
||||
|
||||
static inline uint32_t slc_gpos(const slc_src_t *s, uint32_t k) { return (k * s->len) >> SLC_GRID_LOG2; }
|
||||
/* the user slot of s (0..2), SMP_USER_SLOTS for BREAK; its MAN slices in use, 0 = none (BREAK has none) */
|
||||
/* the user slot of s (0..2), SMP_USER_SLOTS for BREAK / PIANO; its MAN slices in use, 0 = none (BREAK, PIANO: none) */
|
||||
static uint32_t slc_slot_of(const slc_src_t *s)
|
||||
{
|
||||
return s >= slc_usr && s < slc_usr + SMP_USER_SLOTS ? (uint32_t)(s - slc_usr) : SMP_USER_SLOTS;
|
||||
@@ -420,26 +433,26 @@ static int16_t *slc_rb(track_t *t, voice_t *v)
|
||||
static void slice_note_on(track_t *t, voice_t *v)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
uint32_t src = (uint32_t)p[P_E0] & 3u, div = (uint32_t)clamp(p[P_E1], 0, SLC_DIV_MAN), rev = p[P_E5] != 0;
|
||||
uint32_t src = slc_src_of(p), div = (uint32_t)clamp(p[P_E1], 0, SLC_DIV_MAN), rev = p[P_E5] != 0;
|
||||
uint32_t a, b, st, j;
|
||||
const slc_src_t *s = slc_get(src);
|
||||
if (!s) { /* an empty slot: the built-in BREAK */
|
||||
src = 0;
|
||||
s = slc_get(0);
|
||||
}
|
||||
v->ph[1] = 0;
|
||||
v->s[2] = v->s[3] = 0;
|
||||
v->s[5] = 32767;
|
||||
v->s[6] = 2;
|
||||
v->s[7] = 0;
|
||||
v->env_out = 0; /* a new slice fades in over one block */
|
||||
if (!s)
|
||||
if (!s) { /* no material: the sine (from phase 0: no click) */
|
||||
v->s[4] = (int32_t)SLC_SINE;
|
||||
v->s[6] = 1;
|
||||
v->ph[0] = 0;
|
||||
return;
|
||||
}
|
||||
j = slc_note_slice(p, v->note, slc_count(s, div));
|
||||
slc_bounds(s, div, j, &a, &b, &st);
|
||||
if (b <= a || (rev && !slc_rb(t, v)))
|
||||
return;
|
||||
v->s[4] = (int32_t)(src | (st >> 24) << 2 | rev << 6 | j << 8 | div << 16);
|
||||
v->s[4] = (int32_t)(src | (st >> 24) << 3 | rev << 7 | j << 8 | div << 16);
|
||||
v->s[6] = 0;
|
||||
if (rev) {
|
||||
v->ph[0] = b;
|
||||
@@ -519,8 +532,8 @@ static inline int slc_rev(const slc_src_t *s, voice_t *v, int16_t *rb, int loop,
|
||||
static int32_t slice_amp(track_t *t, voice_t *v, int32_t adsr)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
if (p[P_E4] == SLC_ONE && v->stage == 3u)
|
||||
v->stage = 2; /* ONE: the slice plays to its end */
|
||||
if (p[P_E4] == SLC_ONE && v->stage == 3u && ((uint32_t)v->s[4] & 7u) != SLC_SINE)
|
||||
v->stage = 2; /* ONE: the slice plays to its end (the sine has none) */
|
||||
if (p[P_E6] < 127) {
|
||||
v->s[5] -= mulq16(v->s[5], ENV_EXP[p[P_E6] & 127]);
|
||||
if (v->s[5] < 8)
|
||||
@@ -532,12 +545,16 @@ static int32_t slice_amp(track_t *t, voice_t *v, int32_t adsr)
|
||||
static void slice_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
uint32_t pk = (uint32_t)v->s[4], i, frac = v->ph[1], rev = (pk >> 6) & 1u, stepq, rem;
|
||||
uint32_t pk = (uint32_t)v->s[4], i, frac = v->ph[1], rev = (pk >> 7) & 1u, stepq, rem;
|
||||
int32_t lp = 4000 + ((clamp((p[P_E7] << 8) + m->cutoff, 0, 127 << 8) * 28767) >> 15), x;
|
||||
int loop = p[P_E4] == SLC_LOOP && v->gate;
|
||||
const slc_src_t *s = v->s[6] == 2 ? 0 : slc_get(pk & 3u);
|
||||
const slc_src_t *s = v->s[6] == 2 || (pk & 7u) == SLC_SINE ? 0 : slc_get(pk & 7u);
|
||||
int16_t *rb = slc_rb(t, v);
|
||||
slc_dec_t d;
|
||||
if ((pk & 7u) == SLC_SINE && v->s[6] != 2) { /* no material: the sine at the key's pitch + PTCH */
|
||||
smp_sine(out, n, m, p[P_E3] * 16, lp, &v->ph[0], &v->s[7]);
|
||||
return;
|
||||
}
|
||||
if (!s) { /* ended, or its slot was erased */
|
||||
v->active = 0;
|
||||
return;
|
||||
@@ -546,7 +563,7 @@ static void slice_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
d.pos = v->ph[0];
|
||||
d.pred = v->s[0];
|
||||
d.idx = v->s[1];
|
||||
d.seg = (pk >> 2) & 15u;
|
||||
d.seg = (pk >> 3) & 15u;
|
||||
if (!v->s[6]) { /* prime the interpolator */
|
||||
if (!(rev ? slc_rev(s, v, rb, 0, &x) : slc_fwd(s, v, &d, 0, &x))) {
|
||||
v->active = 0;
|
||||
@@ -582,11 +599,11 @@ static void slice_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
v->ph[0] = d.pos;
|
||||
v->s[0] = d.pred;
|
||||
v->s[1] = d.idx;
|
||||
v->s[4] = (int32_t)((pk & ~(15u << 2)) | d.seg << 2);
|
||||
v->s[4] = (int32_t)((pk & ~(15u << 3)) | d.seg << 3);
|
||||
}
|
||||
}
|
||||
|
||||
/* two factory sounds, both on BREAK (always there; an empty slot plays it too). PATTERNS (engines.c): CHOP suggests
|
||||
/* two factory sounds, both on BREAK (always there). PATTERNS (engines.c): CHOP suggests
|
||||
* 9 CHOP (16 slices re-ordered), STUTTER 10 STUTTER (8 slices, repeats); 11 SLICES plays 0..15 in order */
|
||||
static const preset_t SLICE_PRESETS[] = {
|
||||
{"CHOP", {0, 2, 0, 0, SLC_ONE, 0, 127, 127}, {0, 127, 127, 30}, 0, 0, FX(0, 0, 0, 12), PAT(9)},
|
||||
@@ -603,7 +620,7 @@ static const engine_t ENG_SLICE = {
|
||||
.name = "SLICE",
|
||||
.page_title = {"SLCE", "PLAY"},
|
||||
.edit = {
|
||||
{"SRC", F_ENUM, 0, 3, 0, N_SLC_SRC, 0},
|
||||
{"SRC", F_ENUM, 0, SLC_NSRC - 1, 0, N_SLC_SRC, 0},
|
||||
{"DIV", F_ENUM, 0, 5, 2, N_SLC_DIV, 0},
|
||||
{"START", F_INT, 0, 31, 0, 0, 0},
|
||||
{"PTCH", F_SEMI, -24, 24, 0, 0, 0},
|
||||
|
||||
@@ -50,6 +50,27 @@ static const engine_t *const ENGINES[NENGINES] = {
|
||||
/* a track's engine number as an index (the audio paths: a compare, cheaper than % NENGINES; a bad number: 0) */
|
||||
static inline uint32_t eng_idx(uint32_t e) { return e < NENGINES ? e : 0u; }
|
||||
|
||||
/* the sample source a track's sound plays that has no data (SAMPLE's SET, GRAIN's SRC, SLICE's SRC: an empty or
|
||||
* invalid user slot, a set or PIANO this build lacks): its name (it plays a sine: eng_sample.c smp_sine), 0 = none;
|
||||
* *code a small number for it (1.., per engine and source) so the UI says it once (ui_input.c sample_notice) */
|
||||
static uint8_t snd_said[NTRK]; /* per track: the code last said, 0 = none (a project load clears them: said again) */
|
||||
static const char *snd_missing(const track_t *t, uint32_t *code)
|
||||
{
|
||||
const engine_t *e = ENGINES[eng_idx(t->eng_req)];
|
||||
uint32_t si = (uint32_t)t->p[P_E0] % SMP_NALL;
|
||||
#if FELUCCA_SLICE
|
||||
if (e == &ENG_SLICE) {
|
||||
si = slc_src_of(t->p);
|
||||
*code = 64u + si;
|
||||
return slc_get(si) ? 0 : N_SLC_SRC[si];
|
||||
}
|
||||
#endif
|
||||
if (e != &ENG_SAMPLE && e != &ENG_GRAIN)
|
||||
return 0;
|
||||
*code = (e == &ENG_GRAIN ? 32u : 1u) + si % 32u;
|
||||
return smp_set_missing(si) ? SMP_ALL_NAMES[si] : 0;
|
||||
}
|
||||
|
||||
/* the order the engines are shown in (PRESETS browsing and its ENG knob, the EDIT layer's keys, the editor's list):
|
||||
* engine indices, never DIGITAL's reserved 1 (with FELUCCA_FM4 it follows FM6). The indices stay as they are (the
|
||||
* stores and the protocol hold them); only this table orders them */
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */
|
||||
#endif
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "v1.0.3.1" /* shown in the menu, the console and the editor; build.py --release X.Y */
|
||||
#define FELUCCA_VERSION "v1.0.4" /* 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"
|
||||
@@ -77,6 +77,7 @@
|
||||
/* -------------------------------------------------------------- UI --- */
|
||||
#include "panel.c"
|
||||
#include "ui.c"
|
||||
#include "menu_items.c" /* MENU's rows and settings (ui_menu.c, editor_menu.c) */
|
||||
#include "icons.c" /* parameter icons (FELUCCA_ICONS), used by ui_draw.c */
|
||||
#include "ui_graph.c"
|
||||
#include "ui_draw.c"
|
||||
|
||||
@@ -22,9 +22,10 @@ static int32_t cv_trk(int32_t x, int32_t y, uint32_t size, uint32_t k, uint16_t
|
||||
char s[2] = {(char)('1' + k), 0};
|
||||
const aag_t *g = &f->g[glyph(f, (uint8_t)s[0])];
|
||||
int32_t in = size > 16u ? 2 : 0, w = (int32_t)size - 2 * in;
|
||||
int32_t nud = k == 0u ? 1 : 0; /* the 1's ink centred looks right of centre (its flag): nudged left 1 px (2 looked left) */
|
||||
cv_rrect(x + in, y + in, w, w, -(w / 4), fill, under);
|
||||
GFX_HOOK_ALIGN(x + in, y + in, x + in + w, y + in + w, AL_HV, "track cushion digit");
|
||||
cv_text_on(x + in + (w - g->bw) / 2 - g->bx, y + in + (w - g->bh) / 2 - g->by, f, s, under, fill); /* its ink centred */
|
||||
GFX_HOOK_ALIGN(x + in - nud, y + in, x + in + w - nud, y + in + w, AL_HV, "track cushion digit"); /* (the 1: measured against its nudge) */
|
||||
cv_text_on(x + in + (w - g->bw) / 2 - g->bx - nud, y + in + (w - g->bh) / 2 - g->by, f, s, under, fill); /* its ink centred */
|
||||
GFX_HOOK_ITEM(x + in, y + in, x + in + w, y + in + w);
|
||||
return (int32_t)size;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* MENU's rows and their settings: what ui_menu.c draws and steps, and what the editor reads and sets (editor_menu.c
|
||||
* MENU_DESC / MENU_SET). One apply path for both: menu_put. Grouped: the screen (COLOR, STYLE, LARGE, ANIM, LEDS), the
|
||||
* controls (HOLD: the layer threshold, KNOB ACCEL, FX LATCH, BPM LOCK), the sound (SPEAKER EQ: FLAT LOWCUT BASS+,
|
||||
* USB LEVEL), USB SERIAL, then CALIBRATION (the setup screen: HARDWARE CALIBRATION) and ABOUT, the two rows with no
|
||||
* value (MI_VALUES: the rows before them hold one). */
|
||||
enum { MI_COLOR, MI_STYLE, MI_LARGE, MI_ANIM, MI_LEDS, MI_HOLD, MI_ACCEL, MI_LATCH, MI_BPMLOCK, MI_LOWCUT, MI_USB, MI_SERIAL, MI_PANEL, MI_ABOUT, MI_COUNT };
|
||||
#define MI_VALUES MI_PANEL
|
||||
static const char *const MI_NAME[MI_COUNT] = {"COLOR", "STYLE", "LARGE", "ANIM", "LEDS", "HOLD", "KNOB ACCEL", "FX LATCH", "BPM LOCK",
|
||||
"SPEAKER EQ", "USB LEVEL", "USB SERIAL", "CALIBRATION", "ABOUT"};
|
||||
/* STYLE (ui_style, gfx.c ST_*): FLAT the filled cards; LINE black areas divided by 1 px rules (#50, #57: the 0.9 look)
|
||||
* (1.0.2: PIXEL retired, a saved PIXEL reads as LINE) */
|
||||
static const char *const STYLE_N[2] = {"FLAT", "LINE"};
|
||||
/* the two-valued rows: a bit of ui_prefs and its names (bit clear = the default, bit set); KNOB 1 right = set
|
||||
* (the other value), left = clear (the default) */
|
||||
typedef struct { uint8_t row, bit; const char *name[2]; } menu_flag_t;
|
||||
static const menu_flag_t MENU_FLAGS[] = {
|
||||
{MI_LARGE, PREF_LARGE, {"OFF", "ON"}}, /* #15 / Discussion #80: ON, big knob labels and values (ui.c large_kind) */
|
||||
{MI_ANIM, PREF_ANIM_OFF, {"ON", "OFF"}}, /* #46: OFF, values snap (ui_draw.c roll_note, ui_graph.c pr_follow) */
|
||||
{MI_ACCEL, PREF_ACCEL, {"OFF", "ON"}}, /* #52: ui_input.c accel */
|
||||
{MI_LATCH, PREF_LATCH, {"OFF", "ON"}},
|
||||
{MI_USB, PREF_USB_FIXED, {"MASTER", "FIXED"}}, /* fx.c fx_usb_fixed: FIXED, USB at the full level */
|
||||
{MI_BPMLOCK, PREF_BPM_LOCK, {"OFF", "ON"}}, /* #58: ON, SELECT sets the tempo with GLO held only (ui_input.c) */
|
||||
{MI_SERIAL, PREF_SERIAL_OFF, {"ON", "OFF"}}, /* #67: OFF, no serial console (usb_serial_apply) */
|
||||
};
|
||||
/* SPEAKER EQ (settings.lowcut, fx.c fx_lowcut): an EQ on the master for the small speaker, not a speaker switch
|
||||
* (#42: "OFF" read as the speaker off). FLAT is the old OFF (0, stored as before). The built-in speaker cannot be
|
||||
* turned off from the firmware (no amp enable or mute line is known); the EQ reaches
|
||||
* the headphone / line out and USB audio too (one DAC, uac_tap reads the master) */
|
||||
static const char *const SPK_EQ[3] = {"FLAT", "LOWCUT", "BASS+"};
|
||||
static const char *const HOLD_N[4] = {"0.3 s", "0.4 s", "0.5 s", "0.6 s"}; /* (the editor's names; the menu draws its own) */
|
||||
|
||||
/* MENU > USB SERIAL (#67). The serial console is a developer tool (README: FELUCCA_CDC). ON (the default) presents it,
|
||||
* the descriptors byte for byte as before; OFF re-enumerates as audio + MIDI only, device class 0 (the bytes of a
|
||||
* FELUCCA_CDC=0 build): macOS 13-15 then attach their USB audio driver (with the console Apple's CDC composite driver
|
||||
* takes the device and the audio input never appears). USB-MIDI stays, and with it the editor, the update installer
|
||||
* and the soft key (SysEx on EP1). Applied at boot before USB starts (main.c: enumerated with it from the start, never
|
||||
* on then off) and while the menu is closed (ui_input: one re-enumeration when it closes, not one per KNOB 1 step).
|
||||
* A change from the editor (MENU_SET) waits 200 ms (menu_serial_at) so its reply leaves before the device drops off
|
||||
* the bus: the whole device re-enumerates, USB-MIDI and audio too */
|
||||
static uint32_t menu_serial_at; /* fm1_ms | 1 of the editor's change; 0 none */
|
||||
static void usb_serial_apply(void)
|
||||
{
|
||||
#if FELUCCA_CDC
|
||||
if (menu_serial_at && fm1_ms - menu_serial_at < 200u)
|
||||
return;
|
||||
menu_serial_at = 0;
|
||||
usb_cdc_switch(FELUCCA_CDC_DEFAULT && !(ui_prefs & PREF_SERIAL_OFF)); /* (a FELUCCA_CDC_DEFAULT=0 build: off) */
|
||||
#endif
|
||||
}
|
||||
static const menu_flag_t *menu_flag(uint32_t row)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < NELEM(MENU_FLAGS); i++)
|
||||
if (MENU_FLAGS[i].row == row)
|
||||
return &MENU_FLAGS[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* a row's value as 0..menu_n(row) - 1 in the order the menu steps it (LEDS: OFF DIM LO DIM HI INV, LEDS_MENU) */
|
||||
static uint32_t menu_n(uint32_t row)
|
||||
{
|
||||
return row == MI_COLOR ? NPALETTES : row == MI_LOWCUT ? 3u : row == MI_HOLD ? 4u : row == MI_LEDS ? LEDS_COUNT : 2u;
|
||||
}
|
||||
static uint32_t menu_get(uint32_t row)
|
||||
{
|
||||
const menu_flag_t *f = menu_flag(row);
|
||||
uint32_t i = 0;
|
||||
if (f)
|
||||
return (ui_prefs & f->bit) != 0;
|
||||
switch (row) {
|
||||
case MI_COLOR: return settings.palette % NPALETTES;
|
||||
case MI_STYLE: return ui_style == ST_LINE;
|
||||
case MI_LOWCUT: return settings.lowcut % 3u;
|
||||
case MI_HOLD: return settings_hold % 4u;
|
||||
case MI_LEDS:
|
||||
while (i + 1u < LEDS_COUNT && LEDS_MENU[i] != settings_leds)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static const char *menu_vname(uint32_t row, uint32_t v)
|
||||
{
|
||||
const menu_flag_t *f = menu_flag(row);
|
||||
if (f)
|
||||
return f->name[v & 1u];
|
||||
switch (row) {
|
||||
case MI_COLOR: return UI_PALETTES[v % NPALETTES].name;
|
||||
case MI_STYLE: return STYLE_N[v & 1u];
|
||||
case MI_LOWCUT: return SPK_EQ[v % 3u];
|
||||
case MI_HOLD: return HOLD_N[v & 3u];
|
||||
case MI_LEDS: return LEDS_NAME[LEDS_MENU[v % LEDS_COUNT]];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/* set a row (v below menu_n(row)) and do what the menu does on a change: the palette, the EQ and USB LEVEL at once;
|
||||
* STYLE (ui_draw.c style_apply), LARGE, ANIM, LEDS, HOLD, the flags are read where they are used, every frame;
|
||||
* USB SERIAL when the menu has closed (usb_serial_apply). Saved by the caller (menu_close, the editor) */
|
||||
static void menu_put(uint32_t row, uint32_t v)
|
||||
{
|
||||
const menu_flag_t *f = menu_flag(row);
|
||||
if (f) {
|
||||
ui_prefs = (uint8_t)(v ? ui_prefs | f->bit : ui_prefs & ~f->bit);
|
||||
fx_usb_fixed = (ui_prefs & PREF_USB_FIXED) != 0u; /* (at once; every frame too: ui_input) */
|
||||
return;
|
||||
}
|
||||
switch (row) {
|
||||
case MI_COLOR:
|
||||
settings.palette = v;
|
||||
palette_set(v); /* (the menu signature redraws) */
|
||||
ui.force = 1;
|
||||
break;
|
||||
case MI_STYLE: ui_style = (uint8_t)(v ? ST_LINE : ST_FLAT); break; /* (drawn so from the next frame) */
|
||||
case MI_LOWCUT: settings.lowcut = v; fx_lowcut = (uint8_t)v; break;
|
||||
case MI_HOLD: settings_hold = (uint8_t)v; break;
|
||||
case MI_LEDS: settings_leds = LEDS_MENU[v]; break;
|
||||
}
|
||||
}
|
||||
/* the menu's step: KNOB 1 (s) stops at the ends (COLOR wraps), OCT+ (s 0) steps and wraps */
|
||||
static uint32_t menu_step(uint32_t row, int32_t s)
|
||||
{
|
||||
uint32_t v = menu_get(row), n = menu_n(row);
|
||||
if (s > 0)
|
||||
return v + 1u < n ? v + 1u : row == MI_COLOR ? 0u : v;
|
||||
if (s < 0)
|
||||
return v ? v - 1u : row == MI_COLOR ? n - 1u : 0u;
|
||||
return (v + 1u) % n;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ static const page_t PAGES[] = {
|
||||
{"MIXER", FAM_TRK, SC_TRK, GR_TRK, {0, 1, 2, 3}}, /* GLO button; LEVEL PAN REV MUTE */
|
||||
{"SONG", FAM_SEQ, SC_GLOBAL, GR_SONG, {0xFF, 0xFF, 0xFF, 0xFF}},
|
||||
{"CHANCE", FAM_SEQ, SC_STEP, GR_CHANCE, {0xFF, 0xFF, 0xFF, 0xFF}},
|
||||
{"MOTION", FAM_SEQ, SC_TRACK, GR_MOTION, {0xFF, 0xFF, 0xFF, 0xFF}},
|
||||
{"AUTOMATION", FAM_SEQ, SC_TRACK, GR_MOTION, {0xFF, 0xFF, 0xFF, 0xFF}},
|
||||
};
|
||||
#define NPAGES (sizeof(PAGES) / sizeof(PAGES[0]))
|
||||
static uint8_t mod_ui_slot; /* the MOD page: the matrix slot (0..3) KNOB 2..4 edit */
|
||||
|
||||
@@ -871,6 +871,7 @@ static int project_restore_runtime(const project_t *input)
|
||||
sync_reload = 1;
|
||||
ui.force = 1;
|
||||
ui_message("LOADED");
|
||||
memset(snd_said, 0, sizeof snd_said); /* a missing sample is said again, after LOADED */
|
||||
return 0;
|
||||
}
|
||||
static void project_load(uint32_t slot)
|
||||
|
||||
+8
-3
@@ -128,8 +128,8 @@ static struct {
|
||||
} ui;
|
||||
|
||||
enum { CF_NONE, CF_CLEAR_SEQ, CF_CLEAR_TRK, CF_OVR_PROJ, CF_OVR_USER, CF_LOAD_PAT,
|
||||
CF_DEL_ROW, CF_CLEAR_SONG, CF_INIT_SOUND, CF_CLEAR_MOTION, CF_ERASE_USER }; /* ui.confirm: REC held on
|
||||
* SEQ / ARP, on TRACKS; SAVE over a used slot; a pattern over the user's steps;
|
||||
CF_DEL_ROW, CF_CLEAR_SONG, CF_INIT_SOUND, CF_CLEAR_MOTION, CF_ERASE_USER }; /* ui.confirm: TOOLS' clears, REC
|
||||
* held on SEQ (#91); SAVE over a used slot; a pattern over the user's steps;
|
||||
* USER ERASE */
|
||||
|
||||
static const page_t *page_over; /* a quick layer's own four knobs (ui_layer.c), while it edits or draws them */
|
||||
@@ -220,6 +220,11 @@ static void ui_say(const char *a, const char *b)
|
||||
}
|
||||
|
||||
static void ui_message(const char *s) { ui_say(s, ""); }
|
||||
/* a message led by an icon: its first byte (ui_draw.c draw_head draws the icon, then the words) */
|
||||
#define MSG_NOFILE "\x01" /* the no-file icon (ICON_X_NOFILE) */
|
||||
/* a missing sample (ui_input.c sample_notice): NO SAMPLE (SAMPLE NOT FOUND, the SLICES page's, is 4 px too wide
|
||||
* for the header's 130 px after the icon) */
|
||||
#define MSG_NO_SAMPLE MSG_NOFILE "NO SAMPLE"
|
||||
|
||||
static int chain_busy(void) { return chain.running || chain.armed; }
|
||||
/* Main loop only, with interrupts enabled. PLAY may be consumed between reads;
|
||||
@@ -539,7 +544,7 @@ static void undo_swap(void)
|
||||
motion_store_t current_motion;
|
||||
motion_snapshot_track(t, ¤t_motion);
|
||||
if (motion_replace_track(t, &undo.motion_backup) != 0) {
|
||||
ui_message("MOTION FULL");
|
||||
ui_message("AUTOMATION FULL");
|
||||
return;
|
||||
}
|
||||
undo.motion_backup = current_motion;
|
||||
|
||||
+13
-3
@@ -188,7 +188,13 @@ static void draw_head(void)
|
||||
GFX_HOOK_ALIGN(0, 0, 0, H_HEAD, AL_V, "header text on its middle");
|
||||
roll_text(ROLL_BPM, BPM_X, HEAD_MY, b, ui.bpm_t ? T_ACCENT : T_THEME);
|
||||
if (ui.msg_t || ui.layer) { /* a message, or the layer's name */
|
||||
int32_t x = cv_free_hint(106, HEAD_SY, ui.msg_t ? ui.msg : layer_head(), T_TEXT, T_BG, 236 - 106); /* (may start with a keycap) */
|
||||
const char *m = ui.msg_t ? ui.msg : layer_head();
|
||||
int32_t x = 106;
|
||||
if (m[0] == MSG_NOFILE[0]) { /* a message led by an icon (ui.c MSG_NOFILE), the accent's */
|
||||
x += cv_icon_mid(x, H_HEAD / 2, 16, ICON_X_NOFILE, T_ACCENT, T_BG) + KH_GAP;
|
||||
m++;
|
||||
}
|
||||
x = cv_free_hint(x, HEAD_SY, m, T_TEXT, T_BG, 236 - x); /* (may start with a keycap) */
|
||||
if (!ui.msg_t && layer_locked()) /* #83: locked open (a double tap): the lock after its name */
|
||||
cv_icon_mid(x + 6, H_HEAD / 2, 16, ICON_X_LOCK, T_THEME, T_BG);
|
||||
} else {
|
||||
@@ -605,9 +611,13 @@ static void draw_foot(void)
|
||||
x += cv_icon_in(x, 19 + AF_S_CAP_Y, 0, AF_S_CAP_H, 12, engine_icon(ename), T_MID, T_BG) + 5;
|
||||
}
|
||||
x = cv_text_fit(x, 19, &AF_S, ename, T_THEME, T_BG, 80);
|
||||
{ /* the page title at the right, its icon before it (MIXER, PHRASES, SONG, CHANCE, MOTION) */
|
||||
{ /* the page title at the right, its icon before it (MIXER, PHRASES, SONG, CHANCE, AUTOMATION) */
|
||||
uint32_t pi = ui.home ? ICON_NONE : page_icon(pg);
|
||||
int32_t tx = 232 - text_w(&AF_S, ti) - (pi != ICON_NONE ? 16 : 0);
|
||||
if (!ui.home && pg->graph == GR_MOTION && tx - 12 - (x + 10) < text_w(&AF_S, pn)) {
|
||||
str_cpy(ti + 4, ti + 10, sizeof ti - 4); /* #93: "AUTOMATION 6/6" -> "AUTO 6/6" where the sound's name */
|
||||
tx = 232 - text_w(&AF_S, ti) - (pi != ICON_NONE ? 16 : 0); /* would be cut (MENU > LARGE) */
|
||||
}
|
||||
cv_free_text(x + 10, 19, &AF_S, pn, T_TEXT, T_BG, tx - 12 - (x + 10));
|
||||
if (pi != ICON_NONE) {
|
||||
GFX_HOOK_ALIGN(0, 19 + AF_S_CAP_Y, 0, 19 + AF_S_CAP_Y + AF_S_CAP_H, AL_V,
|
||||
@@ -897,7 +907,7 @@ static void confirm_text(char *a, char *b)
|
||||
str_cpy(a, "INITIALIZE SOUND?", 24);
|
||||
break;
|
||||
case CF_CLEAR_MOTION:
|
||||
str_cpy(a, "CLEAR T1 MOTION?", 24); a[7] = (char)('1' + k % NTRK);
|
||||
str_cpy(a, "CLEAR T1 AUTOMATION?", 24); a[7] = (char)('1' + k % NTRK);
|
||||
break;
|
||||
case CF_OVR_USER:
|
||||
str_cpy(a, "OVERWRITE ", 24);
|
||||
|
||||
+20
-3
@@ -311,6 +311,7 @@ static void graph_scale(const track_t *t, uint16_t c)
|
||||
* C4) over the keys from the C below its lowest note (two octaves, three for a wide one): its notes THEME, its
|
||||
* root's ACCENT, the others RAISE. OFF or a kit: what to do instead */
|
||||
static void panel_note(const char *a, const char *b, const char *c);
|
||||
static void panel_alert(uint32_t id, const char *a);
|
||||
static void graph_chord(const track_t *t, uint16_t c)
|
||||
{
|
||||
static const uint8_t BLACK[12] = {0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0};
|
||||
@@ -523,8 +524,8 @@ static void graph_slices(void)
|
||||
{
|
||||
uint32_t a, b, len, n = slice_count(), j = slice_sel(), i, src, div, ma, mb;
|
||||
char t[20], u[12];
|
||||
if (!slice_src(&src, &div) || !n) {
|
||||
panel_note("NO SAMPLE", "SRC: BREAK OR USR1-3", 0);
|
||||
if (!slice_src(&src, &div) || !n) { /* (it plays a sine: eng_slice.c) */
|
||||
panel_alert(ICON_X_NOFILE, "SAMPLE NOT FOUND");
|
||||
return;
|
||||
}
|
||||
slice_view(&a, &b, &len);
|
||||
@@ -566,7 +567,7 @@ static void graph_slices(void)
|
||||
str_cpy(t + 4, u, sizeof t - 4);
|
||||
str_cpy(t + str_len(t), " S", sizeof t - str_len(t));
|
||||
cv_text(12, 106, &AF_S, t, T_MID);
|
||||
cv_text_r(228, 106, &AF_S, src ? N_SLC_SRC[src] : "BREAK", src ? T_THEME : T_DIM, T_SURF);
|
||||
cv_text_r(228, 106, &AF_S, N_SLC_SRC[src], src && src != SLC_SRC_PIANO ? T_THEME : T_DIM, T_SURF);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -983,6 +984,22 @@ static void panel_note(const char *a, const char *b, const char *c)
|
||||
if (b) note_line(60, b, T_MID);
|
||||
if (c) note_line(82, c, T_DIM);
|
||||
}
|
||||
/* the same title led by an icon (16 px, the accent's: the header message's, ui_draw.c draw_head) in the middle of
|
||||
* the panel: the title's capitals centred up and down in it, the icon's ink on them; across, the pair centred by
|
||||
* its ink */
|
||||
#define PA_GAP 6 /* icon ink -> title ink (setup_title's) */
|
||||
static void panel_alert(uint32_t id, const char *a)
|
||||
{
|
||||
int32_t bi[4], bt[4], x, y = CAP_IN(M, (int32_t)graph_h());
|
||||
icon_ink(16, id, bi);
|
||||
text_ink(&AF_M, a, bt);
|
||||
x = HALF_UP(240 - (bi[2] - bi[0] + PA_GAP + bt[2] - bt[0])) - bi[0];
|
||||
GFX_HOOK_ALIGN(0, 0, 240, 0, AL_H | AL_N(2), "panel alert centred");
|
||||
GFX_HOOK_ALIGN(0, y + AF_M_CAP_Y, 0, y + AF_M_CAP_Y + AF_M_CAP_H, AL_V | AL_PASS, "panel alert icon on its title's line");
|
||||
cv_icon_in(x, y + AF_M_CAP_Y, 0, AF_M_CAP_H, 16, id, T_ACCENT, T_SURF);
|
||||
GFX_HOOK_ALIGN(0, 0, 0, (int32_t)graph_h(), AL_V | AL_PASS, "panel alert title in the panel's middle");
|
||||
cv_text_on(x + bi[2] + PA_GAP - bt[0], y, &AF_M, a, T_TEXT, T_SURF);
|
||||
}
|
||||
|
||||
/* preset browser: the global list (every engine), the current one selected; tag DIM, name TEXT,
|
||||
* favourites starred (the accent), the selected row's suggested pattern at its right */
|
||||
|
||||
+113
-13
@@ -143,6 +143,32 @@ static uint32_t play_leds(void)
|
||||
return m | midi_leds(t);
|
||||
}
|
||||
|
||||
/* Discussion #89: on SEQ > STEP (the piano roll; the DRUM grid has its own map) while stopped, the keys of the
|
||||
* notes stored in the cursor step, bit k = key k: as play_leds, where the keys play that note now (kb_map: the
|
||||
* octave, TRN, QNT), the lowest key that gives it; a note no key plays is not shown, nor a REST step's. Playing,
|
||||
* the keys show what plays (play_leds) instead. Read from the step: no state of its own */
|
||||
static uint32_t step_leds(void)
|
||||
{
|
||||
const track_t *t = TSEL;
|
||||
const step_t *st;
|
||||
uint32_t i, k, note, used = 0, m = 0;
|
||||
if (ui.home || ui.menu || ui.confirm || !song.seq_mode || cur_page()->graph != GR_ROLL || song.playing ||
|
||||
chain_busy() || ui.cursor >= NSTEP)
|
||||
return 0;
|
||||
st = &t->step[ui.cursor];
|
||||
if (!st->n || st->time == ST_REST)
|
||||
return 0;
|
||||
for (k = 0; k < 27u; k++) {
|
||||
note = kb_map(t, k);
|
||||
for (i = 0; i < st->n && i < 4u; i++)
|
||||
if (st->note[i] == note && !((used >> i) & 1u)) {
|
||||
used |= 1u << i;
|
||||
m |= 1u << k;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* 1: the keys show a map of their own (NAME, a layer's map: SCL's scale, FX; the DRUM grid, SLICES), lit or
|
||||
* dark; 0: the keys held and the notes playing, over the idle glow */
|
||||
static int keys_own(void)
|
||||
@@ -155,11 +181,12 @@ static int keys_own(void)
|
||||
}
|
||||
|
||||
/* the key LEDs, bit k = key k: NAME's keys, the layer's map, the DRUM grid, else the keys held and the notes
|
||||
* the selected track's sequencer, ARP and MIDI IN play (and on SLICES the keys of the selected slice) */
|
||||
* the selected track's sequencer, ARP and MIDI IN play, on STEP while stopped the cursor step's notes (#89; and
|
||||
* on SLICES the keys of the selected slice) */
|
||||
static uint32_t key_leds(void)
|
||||
{
|
||||
uint32_t c = name_on() && !ui.menu ? name_leds() : ui.layer ? layer_leds() : grid_on() ? grid_leds() :
|
||||
(fm1_in.notes & ~kb_layer) | play_leds();
|
||||
(fm1_in.notes & ~kb_layer) | play_leds() | step_leds();
|
||||
#if FELUCCA_SLICE
|
||||
if (!ui.layer && !ui.menu && !name_on() && slice_page_on())
|
||||
c |= slice_leds(); /* SLICES: and the keys of the selected slice */
|
||||
@@ -312,6 +339,27 @@ static void confirm_open(uint32_t kind, uint32_t trk)
|
||||
ui.force = 1;
|
||||
}
|
||||
|
||||
/* Discussion #91: REC held 0.7 s on the SEQ pages that show the pattern (STEP, the DRUM grid, PATTERN, CHANCE) asks
|
||||
* "CLEAR Tn SEQUENCE?", TOOLS' clear (OCT+ clears, OCT- cancels, SAVE held undoes it). REC arms / disarms when let go
|
||||
* (btn_hold: a tap), so a hold never toggles the arming: it fired, its release is no tap. Elsewhere REC has no hold:
|
||||
* a long press is a tap when let go, as before (0.9's hold cleared on every page; 1.0 removed it) */
|
||||
static int rec_hold_page(void)
|
||||
{
|
||||
const page_t *pg;
|
||||
if (ui.home || ui.menu || ui.confirm || ui.layer || name_on())
|
||||
return 0;
|
||||
pg = cur_page();
|
||||
return pg->fam == FAM_SEQ && (pg->graph == GR_ROLL || pg->graph == GR_STEPS || pg->graph == GR_CHANCE);
|
||||
}
|
||||
|
||||
static void rec_hold_clear(void)
|
||||
{
|
||||
if (seq_is_empty(TSEL) && !motion_count(TSEL))
|
||||
ui_message("NOTHING TO CLEAR");
|
||||
else
|
||||
confirm_open(CF_CLEAR_SEQ, song.sel);
|
||||
}
|
||||
|
||||
/* the grid's page down (-1) / up (+1): the cursor to the same place on it (at most the last step) */
|
||||
static void page_go(int32_t d)
|
||||
{
|
||||
@@ -645,6 +693,30 @@ static void seq_entry(uint32_t pressed)
|
||||
cursor_set(ui.cursor + 1);
|
||||
}
|
||||
|
||||
/* Discussions #92 / #94: the PRESETS knob by page (the menu, a dialog, NAME and the layers: ui_input before this).
|
||||
* SEQ pages that show the steps (STEP and the DRUM grid, PATTERN, CHANCE, MOTION): the step cursor, as STEP's KNOB 1
|
||||
* (a sound load there would drop the track's motion: never)
|
||||
* the list / action pages USER, PROJECT, PHRASES, SONG: the selection, as their KNOB 1; TOOLS and SLICES: nothing
|
||||
* HOME, PRESETS and every other page (EDIT, ENV, LFO, FX, SCL, ARP, MIXER, GLOBAL, ...): the selected track's
|
||||
* sound, one list over every engine, then the used user presets (preset_step). A sound load keeps the steps
|
||||
* (SAVE held undoes it). Up to 1.0.3 it did that on HOME and PRESETS only */
|
||||
static void presets_turn(int32_t s)
|
||||
{
|
||||
const page_t *pg = cur_page();
|
||||
uint32_t g = pg->graph;
|
||||
if (ui.home || g == GR_BROWSE) {
|
||||
preset_step(s);
|
||||
} else if (g == GR_ROLL || g == GR_CHANCE || g == GR_USER || g == GR_SLOTS || g == GR_PATS || g == GR_SONG) {
|
||||
edit_param(0, s); /* KNOB 1's (STEP: STOP TO EDIT while a song plays) */
|
||||
ui.hot_col = 0;
|
||||
ui.hot_t = 40;
|
||||
} else if (pg->fam == FAM_SEQ && (g == GR_STEPS || g == GR_MOTION)) {
|
||||
cursor_set(ui.cursor + s); /* (PATTERN draws it; MOTION: STEP shows it) */
|
||||
} else if (g != GR_TOOLS && g != GR_SLICES) {
|
||||
preset_step(s);
|
||||
}
|
||||
}
|
||||
|
||||
/* HOME / REC / SAVE: tap on release, hold 0.7 s fires once. t0 = press time | 1,
|
||||
* bit 1 = fired (or swallowed: then the release is no tap either) */
|
||||
enum { BT_NONE, BT_TAP, BT_HOLD };
|
||||
@@ -678,6 +750,7 @@ static void layer_knob(uint32_t k, int32_t s);
|
||||
static int layer_play(void);
|
||||
static int layer_set_open(void);
|
||||
static uint32_t layer_oct(uint32_t pressed, uint32_t oct);
|
||||
static void layer_oct_open(uint32_t pressed);
|
||||
static int layer_allowed(void);
|
||||
static uint32_t ly_bit(uint32_t l);
|
||||
static void layer_lock_input(uint32_t pressed);
|
||||
@@ -710,11 +783,36 @@ static int page_tap(uint32_t b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* a track whose sound's sample is missing (engines.c snd_missing: an empty user slot, a built-in set this build lacks;
|
||||
* it plays a sine): the no-file icon and NO SAMPLE (ui.c MSG_NO_SAMPLE). Once per track and source: at power-on, a sound
|
||||
* or project load, SRC / SET turned, a slot erased; again after another source or a project load. One a frame; after
|
||||
* a message already showing (LOADED) as the second message. Not on notes: nothing in the audio path */
|
||||
static void sample_notice(void)
|
||||
{
|
||||
uint32_t k, code;
|
||||
for (k = 0; k < NTRK; k++) {
|
||||
code = 0;
|
||||
if (!snd_missing(&trk[k], &code)) {
|
||||
snd_said[k] = 0;
|
||||
continue;
|
||||
}
|
||||
if (snd_said[k] == code)
|
||||
continue;
|
||||
snd_said[k] = (uint8_t)code;
|
||||
if (ui.msg_t)
|
||||
str_cpy(ui.msg2, MSG_NO_SAMPLE, sizeof ui.msg2);
|
||||
else
|
||||
ui_message(MSG_NO_SAMPLE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* messages of things that happened elsewhere (a load, the editor, MIDI in): after this frame's own */
|
||||
static void ui_notices(void)
|
||||
{
|
||||
static uint32_t midi_t, midi_last;
|
||||
if (motion_full) { motion_full = 0; ui_message("MOTION FULL"); }
|
||||
sample_notice();
|
||||
if (motion_full) { motion_full = 0; ui_message("AUTOMATION FULL"); }
|
||||
if (midi_hint) { /* MIDI notes into a track that is not selected */
|
||||
uint32_t h = midi_hint;
|
||||
midi_hint = 0;
|
||||
@@ -731,10 +829,10 @@ static void ui_input(void)
|
||||
{
|
||||
uint32_t pressed = fm1_input_edges(0), notes = fm1_input_note_edges(), now = fm1_ticks(), id, b, k;
|
||||
uint32_t home = btn_hold(&ui.home_t0, B_HOME, now, 1);
|
||||
uint32_t rec = btn_hold(&ui.rec_t0, B_REC, now, 0);
|
||||
uint32_t rec = btn_hold(&ui.rec_t0, B_REC, now, rec_hold_page()); /* (#91: held on SEQ: the clear) */
|
||||
uint32_t seq = btn_hold(&ui.seq_t0, B_SEQ, now, !ui.menu && !ui.confirm);
|
||||
uint32_t save = btn_hold(&ui.save_t0, B_SAVE, now, !ui.menu && !ui.confirm); /* held: UNDO (ui.c undo_swap) */
|
||||
uint32_t oct = oct_taps(pressed, ui.menu || ui.confirm || act_cols() || name_on() || layer_set_open());
|
||||
uint32_t oct;
|
||||
uint32_t lay, combo = 0, lytap, lkeys, glo, kq = 0;
|
||||
int32_t s, sel = 0, ks[4] = {0, 0, 0, 0};
|
||||
static uint32_t lock_ms; /* BPM LOCK: the last locked SELECT turn (fm1_ms | 1; 0 none) */
|
||||
@@ -749,8 +847,10 @@ static void ui_input(void)
|
||||
if (!ui.menu)
|
||||
usb_serial_apply(); /* (MENU > USB SERIAL: when the menu has closed) */
|
||||
layer_lock_input(pressed); /* (#83: a button closes a locked layer) */
|
||||
oct = layer_oct(pressed, oct); /* (a SET layer's OCT-: put back) */
|
||||
layer_arm(pressed, now);
|
||||
layer_oct_open(pressed); /* (OCT± with a SET layer's button down: it opens now) */
|
||||
oct = oct_taps(pressed, ui.menu || ui.confirm || act_cols() || name_on() || layer_set_open());
|
||||
oct = layer_oct(pressed, oct); /* (a SET layer's OCT-: put back) */
|
||||
layer_masks(); /* seq.c: keys pressed with a layer's button are its own */
|
||||
lay = layer_held();
|
||||
glo = lay && ui.ly == LAYER_GLO; /* GLO held: SELECT is the tempo, BPM LOCK or not (#58) */
|
||||
@@ -815,8 +915,12 @@ static void ui_input(void)
|
||||
}
|
||||
if (ui.menu || ui.confirm || name_on()) {
|
||||
/* REC does nothing in the menu, a dialog or NAME (no transport start there) */
|
||||
} else if (chain_busy() && rec == BT_HOLD) {
|
||||
ui_message("STOP TO EDIT");
|
||||
} else if (chain_busy() && rec != BT_NONE) {
|
||||
ui_message("STOP TO RECORD");
|
||||
} else if (rec == BT_HOLD) {
|
||||
rec_hold_clear();
|
||||
} else if (rec == BT_TAP) {
|
||||
rec_tap();
|
||||
}
|
||||
@@ -860,7 +964,7 @@ static void ui_input(void)
|
||||
str_cpy(ui.msg2, "[SAVE] HOLD TO UNDO", sizeof ui.msg2);
|
||||
} else if (kind == CF_CLEAR_MOTION) {
|
||||
track_t *t = &trk[ui.confirm_trk % NTRK];
|
||||
if (!chain_busy()) { load_begin(t, UNDO_PAT); motion_clear(t); load_end(t); ui_message("MOTION CLEARED"); }
|
||||
if (!chain_busy()) { load_begin(t, UNDO_PAT); motion_clear(t); load_end(t); ui_message("AUTOMATION CLEARED"); }
|
||||
} else if (kind == CF_DEL_ROW) {
|
||||
uint32_t r = ui.confirm_trk;
|
||||
if (!chain_busy() && r < chain_config.count) {
|
||||
@@ -981,12 +1085,8 @@ static void ui_input(void)
|
||||
* pass runs, so one landing after the layer's read went to the page as well: KNOB 1..4 edited the layer's control
|
||||
* and the page under it (HOME's sound, motion recorded), PRESETS could load a sound. They stay for the next pass */
|
||||
kq |= lay;
|
||||
if (!lay && (s = panel_enc(EN_PRESET)) != 0 && (ui.home || cur_page()->graph == GR_BROWSE)) {
|
||||
/* PRESETS browses the selected part's sounds (all engines, then user presets) on HOME and the
|
||||
* PRESETS page only (never the steps); elsewhere (TRACKS too, where one records) a stray turn
|
||||
* would throw away the sound being edited */
|
||||
preset_step(s); /* past the factory ones: user presets */
|
||||
}
|
||||
if (!lay && (s = panel_enc(EN_PRESET)) != 0)
|
||||
presets_turn(s);
|
||||
if (!lay && (s = panel_enc(EN_ALGO)) != 0) /* ALGORITHM: the selected track, on every page */
|
||||
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 knob = global tempo; */
|
||||
|
||||
+13
-1
@@ -394,6 +394,18 @@ static int layer_play(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OCT- / OCT+ pressed with a SET layer's button down (FX LATCH: FX's) before it opened: a combo, so it opens now,
|
||||
* before oct_taps and layer_oct read it (else the press was nobody's: no put back / ALL OFF, no octave) */
|
||||
static void layer_oct_open(uint32_t pressed)
|
||||
{
|
||||
uint32_t l = ui.ly, oct = 1u << panel.btn[B_OCTDN] | 1u << panel.btn[B_OCTUP];
|
||||
if ((pressed & oct) && l && !(ui.ly_t0 & (LY_OPEN | LY_DEAD)) && layer_held() &&
|
||||
(LAYERS[l].kind == LK_SET || (l == LAYER_FX && perf_latch_on))) {
|
||||
ui.ly_t0 |= LY_OPEN | LY_COMBO;
|
||||
layer_opened(l);
|
||||
}
|
||||
}
|
||||
|
||||
/* OCT- / OCT+ in a SET layer: no octave; OCT- let go puts back what the layer changed. Returns the taps left */
|
||||
static uint32_t layer_oct(uint32_t pressed, uint32_t oct)
|
||||
{
|
||||
@@ -610,7 +622,7 @@ static void layer_scl(void) /* KNOB 2's scales, 4 x
|
||||
}
|
||||
static void layer_edit(void) /* the engines from F3, INIT next (LY_INIT), the sound under them */
|
||||
{ /* (cells show the engine's icon, not the key's note) */
|
||||
uint32_t n = NENG_SHOWN < LY_INIT ? NENG_SHOWN : LY_INIT, cells = n + 1u, i, h = cells > 12u ? 22u : 28u;
|
||||
uint32_t n = NENG_SHOWN < LY_INIT ? NENG_SHOWN : LY_INIT, cells = n + 1u, i, h = cells > 12u ? 20u : 28u; /* 4 rows of 20: 8 px clear above the sound row */
|
||||
for (i = 0; i < cells; i++) {
|
||||
int32_t x = LC_X(i % 4u), y = 4 + (int32_t)(h + 4u) * (int32_t)(i / 4u);
|
||||
const engine_t *en = ENGINES[eng_vis(i) % NENGINES];
|
||||
|
||||
+10
-95
@@ -1,55 +1,11 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* Felucca menu (HOME held): a list that scrolls (MENU_VIS rows shown, the selected one kept in the middle: no state),
|
||||
* grouped: the screen (COLOR, STYLE, LARGE, ANIM, LEDS), the controls (HOLD: the layer threshold, KNOB ACCEL, FX LATCH,
|
||||
* BPM LOCK), the sound (SPEAKER EQ: FLAT LOWCUT BASS+, USB LEVEL), USB SERIAL, then CALIBRATION (the setup screen: HARDWARE
|
||||
* CALIBRATION) and ABOUT. No BACK row: OCT- is back.
|
||||
* its rows in menu_items.c (the settings, shared with the editor's MENU_DESC / MENU_SET). No BACK row: OCT- is back.
|
||||
* The two-valued rows are bits of ui_prefs (MENU_FLAGS). PRESETS scrolls from ABOUT through all credits.
|
||||
* ui.menu: 1 list, 2 information. */
|
||||
/* ------------------------------------------------------------ menu --- */
|
||||
enum { MI_COLOR, MI_STYLE, MI_LARGE, MI_ANIM, MI_LEDS, MI_HOLD, MI_ACCEL, MI_LATCH, MI_BPMLOCK, MI_LOWCUT, MI_USB, MI_SERIAL, MI_PANEL, MI_ABOUT, MI_COUNT };
|
||||
static const char *const MI_NAME[MI_COUNT] = {"COLOR", "STYLE", "LARGE", "ANIM", "LEDS", "HOLD", "KNOB ACCEL", "FX LATCH", "BPM LOCK",
|
||||
"SPEAKER EQ", "USB LEVEL", "USB SERIAL", "CALIBRATION", "ABOUT"};
|
||||
/* STYLE (ui_style, gfx.c ST_*): FLAT the filled cards; LINE black areas divided by 1 px rules (#50, #57: the 0.9 look)
|
||||
* (1.0.2: PIXEL retired, a saved PIXEL reads as LINE) */
|
||||
static const char *const STYLE_N[2] = {"FLAT", "LINE"};
|
||||
/* the two-valued rows: a bit of ui_prefs and its names (bit clear = the default, bit set); KNOB 1 right = set
|
||||
* (the other value), left = clear (the default) */
|
||||
typedef struct { uint8_t row, bit; const char *name[2]; } menu_flag_t;
|
||||
static const menu_flag_t MENU_FLAGS[] = {
|
||||
{MI_LARGE, PREF_LARGE, {"OFF", "ON"}}, /* #15 / Discussion #80: ON, big knob labels and values (ui.c large_kind) */
|
||||
{MI_ANIM, PREF_ANIM_OFF, {"ON", "OFF"}}, /* #46: OFF, values snap (ui_draw.c roll_note, ui_graph.c pr_follow) */
|
||||
{MI_ACCEL, PREF_ACCEL, {"OFF", "ON"}}, /* #52: ui_input.c accel */
|
||||
{MI_LATCH, PREF_LATCH, {"OFF", "ON"}},
|
||||
{MI_USB, PREF_USB_FIXED, {"MASTER", "FIXED"}}, /* fx.c fx_usb_fixed: FIXED, USB at the full level */
|
||||
{MI_BPMLOCK, PREF_BPM_LOCK, {"OFF", "ON"}}, /* #58: ON, SELECT sets the tempo with GLO held only (ui_input.c) */
|
||||
{MI_SERIAL, PREF_SERIAL_OFF, {"ON", "OFF"}}, /* #67: OFF, no serial console (usb_serial_apply) */
|
||||
};
|
||||
/* MENU > USB SERIAL (#67). The serial console is a developer tool (README: FELUCCA_CDC). ON (the default) presents it,
|
||||
* the descriptors byte for byte as before; OFF re-enumerates as audio + MIDI only, device class 0 (the bytes of a
|
||||
* FELUCCA_CDC=0 build): macOS 13-15 then attach their USB audio driver (with the console Apple's CDC composite driver
|
||||
* takes the device and the audio input never appears). USB-MIDI stays, and with it the editor, the update installer
|
||||
* and the soft key (SysEx on EP1). Applied at boot before USB starts (main.c: enumerated with it from the start, never
|
||||
* on then off) and while the menu is closed (ui_input: one re-enumeration when it closes, not one per KNOB 1 step) */
|
||||
static void usb_serial_apply(void)
|
||||
{
|
||||
#if FELUCCA_CDC
|
||||
usb_cdc_switch(FELUCCA_CDC_DEFAULT && !(ui_prefs & PREF_SERIAL_OFF)); /* (a FELUCCA_CDC_DEFAULT=0 build: off) */
|
||||
#endif
|
||||
}
|
||||
static const menu_flag_t *menu_flag(uint32_t row)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < NELEM(MENU_FLAGS); i++)
|
||||
if (MENU_FLAGS[i].row == row)
|
||||
return &MENU_FLAGS[i];
|
||||
return 0;
|
||||
}
|
||||
/* SPEAKER EQ (settings.lowcut, fx.c fx_lowcut): an EQ on the master for the small speaker, not a speaker switch
|
||||
* (#42: "OFF" read as the speaker off). FLAT is the old OFF (0, stored as before). The built-in speaker cannot be
|
||||
* turned off from the firmware (no amp enable or mute line is known); the EQ reaches
|
||||
* the headphone / line out and USB audio too (one DAC, uac_tap reads the master) */
|
||||
static const char *const SPK_EQ[3] = {"FLAT", "LOWCUT", "BASS+"};
|
||||
/* (the rows, their values and names, usb_serial_apply: menu_items.c) */
|
||||
|
||||
/* https://hugelton.github.io/Felucca, QR version 3, correction M, generated by CoreImage.
|
||||
* One row per word, leftmost module in bit 0; the constant matrix needs no encoder or RAM. */
|
||||
@@ -269,7 +225,6 @@ static void draw_menu(void)
|
||||
int32_t ny = y + CAP_IN(S, 24), vy = y + CAP_IN(M, 24); /* the name, the value: centred */
|
||||
int sel = i == ui.menu_sel;
|
||||
uint16_t bg = sel ? T_THEME : T_SURF, fg = sel ? T_INK : T_TEXT, val = sel ? T_INK : T_THEME;
|
||||
const menu_flag_t *f = menu_flag(i);
|
||||
if (y + 24 <= top_y || y >= top_y + (int32_t)cv_h)
|
||||
continue;
|
||||
cv_rrect(4, y, MENU_R, 24, 6, bg, T_BG);
|
||||
@@ -279,14 +234,10 @@ static void draw_menu(void)
|
||||
cv_icon_in(12, y, 0, 24, 16, ICO[i], sel ? T_INK : T_MID, bg);
|
||||
GFX_HOOK_ALIGN(0, y, 0, y + 24, AL_V, "menu row name centred up/down");
|
||||
cv_text_on(36, ny, &AF_S, MI_NAME[i], fg, bg);
|
||||
if (f || i == MI_LOWCUT || i == MI_STYLE || i == MI_HOLD || i == MI_LEDS || i == MI_COLOR)
|
||||
if (i < MI_VALUES)
|
||||
GFX_HOOK_ALIGN(0, y, 0, y + 24, AL_V, "menu row value centred up/down");
|
||||
if (f)
|
||||
cv_text_r(vr, vy, &AF_M, f->name[(ui_prefs & f->bit) != 0], val, bg);
|
||||
if (i == MI_LOWCUT)
|
||||
cv_text_r(vr, vy, &AF_M, SPK_EQ[settings.lowcut % 3u], val, bg);
|
||||
if (i == MI_STYLE)
|
||||
cv_text_r(vr, vy, &AF_M, STYLE_N[ui_style & 1u], val, bg);
|
||||
if (i < MI_VALUES && i != MI_HOLD && i != MI_COLOR)
|
||||
cv_text_r(vr, vy, &AF_M, menu_vname(i, menu_get(i)), val, bg);
|
||||
if (i == MI_HOLD) { /* "0.4" and its unit */
|
||||
char b[8] = "0.4";
|
||||
b[2] = (char)('0' + HOLD_MS[settings_hold % 4u] / 100u);
|
||||
@@ -294,8 +245,6 @@ static void draw_menu(void)
|
||||
cv_text_r(cv_text_r(vr, vy + AF_M.asc - AF_S.asc, &AF_S, "s", val == T_INK ? T_INK : T_MID, bg) - 3, vy, &AF_M, b,
|
||||
val, bg);
|
||||
}
|
||||
if (i == MI_LEDS)
|
||||
cv_text_r(vr, vy, &AF_M, LEDS_NAME[settings_leds % LEDS_COUNT], val, bg);
|
||||
if (i == MI_COLOR) {
|
||||
uint32_t k;
|
||||
const uint16_t *tok = &T_BG; /* BG SURF TEXT THEME ACCENT */
|
||||
@@ -350,49 +299,15 @@ static void menu_input(uint32_t oct) /* oct: ui_input.c oct_tap
|
||||
ui.menu_scroll = (uint16_t)clamp((int32_t)ui.menu_scroll + clamp(s, -128, 128) * 18, 0, menu_scroll_max());
|
||||
}
|
||||
s = panel_enc(EN_K1);
|
||||
if (s != 0 && ui.menu == 1 && ui.menu_sel == MI_COLOR) {
|
||||
settings.palette = (settings.palette + (s > 0 ? 1u : NPALETTES - 1u)) % NPALETTES; /* (wraps) */
|
||||
palette_set(settings.palette); /* (the menu signature redraws) */
|
||||
ui.force = 1;
|
||||
}
|
||||
if ((s != 0 || ok) && ui.menu == 1 && ui.menu_sel == MI_LOWCUT) {
|
||||
/* KNOB 1 steps FLAT LOWCUT BASS+, OCT+ steps and wraps */
|
||||
uint32_t *v = &settings.lowcut, top = 2u;
|
||||
*v = s > 0 ? (*v < top ? *v + 1u : top) : s < 0 ? (*v ? *v - 1u : 0u) : (*v < top ? *v + 1u : 0u);
|
||||
fx_lowcut = (uint8_t)(settings.lowcut % 3u);
|
||||
ok = 0;
|
||||
}
|
||||
if ((s != 0 || ok) && ui.menu == 1 && ui.menu_sel == MI_STYLE) {
|
||||
/* KNOB 1: right = LINE, left = FLAT; OCT+ toggles; drawn so from the next frame (ui_draw.c style_apply) */
|
||||
ui_style = (uint8_t)(s > 0 ? ST_LINE : s < 0 ? ST_FLAT : ui_style == ST_LINE ? ST_FLAT : ST_LINE);
|
||||
ok = 0;
|
||||
}
|
||||
if ((s != 0 || ok) && ui.menu == 1 && ui.menu_sel == MI_HOLD) {
|
||||
/* KNOB 1 steps 0.3 .. 0.6 s, OCT+ steps and wraps */
|
||||
uint32_t v = settings_hold % 4u;
|
||||
settings_hold = (uint8_t)(s > 0 ? (v < 3u ? v + 1u : 3u) : s < 0 ? (v ? v - 1u : 0u) : (v + 1u) % 4u);
|
||||
ok = 0;
|
||||
}
|
||||
if ((s != 0 || ok) && ui.menu == 1 && ui.menu_sel == MI_LEDS) {
|
||||
/* KNOB 1 steps OFF DIM LO DIM HI INV, OCT+ steps and wraps */
|
||||
settings_leds = (uint8_t)leds_step(settings_leds, s);
|
||||
ok = 0;
|
||||
}
|
||||
if ((s != 0 || ok) && ui.menu == 1 && menu_flag(ui.menu_sel)) {
|
||||
/* KNOB 1: right = the second value (ON), left = the first (OFF); OCT+ toggles (FX LATCH: the latched
|
||||
* effects are off while the menu is up) */
|
||||
uint32_t b = menu_flag(ui.menu_sel)->bit;
|
||||
ui_prefs = (uint8_t)(s > 0 ? ui_prefs | b : s < 0 ? ui_prefs & ~b : ui_prefs ^ b);
|
||||
fx_usb_fixed = (ui_prefs & PREF_USB_FIXED) != 0u; /* (at once; every frame too: ui_input) */
|
||||
if ((s != 0 || ok) && ui.menu == 1 && ui.menu_sel < MI_VALUES) {
|
||||
/* KNOB 1 steps (the two-valued rows: right = the second value (ON), left = the first), OCT+ steps and wraps;
|
||||
* COLOR previews the palette, STYLE is drawn so from the next frame (FX LATCH: the latched effects are off
|
||||
* while the menu is up) */
|
||||
menu_put(ui.menu_sel, menu_step(ui.menu_sel, s));
|
||||
ok = 0;
|
||||
}
|
||||
if (ok && ui.menu == 1) {
|
||||
switch (ui.menu_sel) {
|
||||
case MI_COLOR: /* OCT+ steps through the palettes too */
|
||||
settings.palette = (settings.palette + 1u) % NPALETTES;
|
||||
palette_set(settings.palette);
|
||||
ui.force = 1;
|
||||
break;
|
||||
case MI_PANEL:
|
||||
panel_setup();
|
||||
ui.force = 1;
|
||||
|
||||
+17
-12
@@ -10,7 +10,8 @@
|
||||
* KNOB 3 SPLIT picked (right): OCT+ splits the slice at its middle (up to 32 slices)
|
||||
* KNOB 4 JOIN picked (right): OCT+ joins the slice to the one before (its start goes)
|
||||
* OCT- drops the pick, or (none) goes HOME
|
||||
* Edits are for a user slot (USR1..3: SRC); BREAK and an empty slot show their slices only. The first edit takes
|
||||
* Edits are for a user slot (USR1..3: SRC); BREAK and PIANO show their slices only, a source with no material (it
|
||||
* plays a sine) says SAMPLE NOT FOUND (the no-file icon). The first edit takes
|
||||
* the slices shown into the slot's MAN table (eng_slice.c) and sets DIV to MAN; later edits change that table (the
|
||||
* audio side switches tables between notes). Leaving the page saves them with the sample (slice_store.c, once
|
||||
* stopped). Included by ui.c (before the action pages); the cards: ui_draw.c, the waveform: ui_graph.c. */
|
||||
@@ -26,14 +27,12 @@ static struct {
|
||||
static int slice_page_ok(void) { return ENGINES[TSEL->eng_req % NENGINES] == &ENG_SLICE; }
|
||||
static int slice_page_on(void) { return !ui.home && cur_page()->graph == GR_SLICES && slice_page_ok(); }
|
||||
|
||||
/* the source the selected part plays (an empty slot: BREAK, as slice_note_on), its DIV; 0 = no material */
|
||||
/* the source the selected part plays, its DIV; 0 = no material (an empty slot: the sine, as slice_note_on) */
|
||||
static const slc_src_t *slice_src(uint32_t *src, uint32_t *div)
|
||||
{
|
||||
const int16_t *p = TSEL->p;
|
||||
uint32_t k = (uint32_t)p[P_E0] & 3u;
|
||||
uint32_t k = slc_src_of(p);
|
||||
const slc_src_t *s = slc_get(k);
|
||||
if (!s)
|
||||
s = slc_get(k = 0);
|
||||
*src = k;
|
||||
*div = (uint32_t)clamp(p[P_E1], 0, SLC_DIV_MAN);
|
||||
return s;
|
||||
@@ -76,17 +75,16 @@ static void slice_view(uint32_t *a, uint32_t *b, uint32_t *len)
|
||||
*b = *a + 1u;
|
||||
}
|
||||
|
||||
/* the edit table of the selected part's slot, the first time from the slices shown (DIV becomes MAN); 0 = BREAK
|
||||
* or an empty slot: nothing to edit (says so) */
|
||||
/* the edit table of the selected part's slot, the first time from the slices shown (DIV becomes MAN); 0 = BREAK,
|
||||
* PIANO or an empty slot: nothing to edit (says so) */
|
||||
static slc_man_t *slice_edit_begin(uint32_t *k)
|
||||
{
|
||||
uint32_t src, div, n, i, a, b, st;
|
||||
const slc_src_t *s = slice_src(&src, &div);
|
||||
slc_man_t *m;
|
||||
if (!s || !src) {
|
||||
if (!s || !src || src == SLC_SRC_PIANO) {
|
||||
static const char *const EMPTY[3] = {"USR1 EMPTY", "USR2 EMPTY", "USR3 EMPTY"};
|
||||
uint32_t u = (uint32_t)TSEL->p[P_E0] & 3u; /* (an empty USR slot plays BREAK: src 0) */
|
||||
ui_message(u ? EMPTY[u - 1u] : "SRC USR1-3 TO EDIT");
|
||||
ui_message(src && src != SLC_SRC_PIANO ? EMPTY[src - 1u] : "SRC USR1-3 TO EDIT");
|
||||
return 0;
|
||||
}
|
||||
*k = src - 1u;
|
||||
@@ -129,8 +127,11 @@ static void slice_knob(uint32_t slot, int32_t steps)
|
||||
{
|
||||
uint32_t n = slice_count(), j = slice_sel(), k, a, b, len;
|
||||
slc_man_t *m;
|
||||
if (!n)
|
||||
if (!n) { /* no material (a sine plays): KNOB 2 says why ("USR2 EMPTY") */
|
||||
if (slot)
|
||||
slice_edit_begin(&k);
|
||||
return;
|
||||
}
|
||||
if (slot == 0u) {
|
||||
sp.sel = (uint8_t)clamp((int32_t)j + steps, 0, (int32_t)n);
|
||||
return;
|
||||
@@ -157,7 +158,7 @@ static int slice_act_ready(uint32_t c)
|
||||
{
|
||||
uint32_t src, div, n = slice_count(), j = slice_sel();
|
||||
const slc_src_t *s = slice_src(&src, &div);
|
||||
if (!s || !src || j >= n)
|
||||
if (!s || slc_slot_of(s) >= SMP_USER_SLOTS || j >= n) /* (BREAK, PIANO: no edits) */
|
||||
return 0;
|
||||
if (c == 3u)
|
||||
return j > 0u;
|
||||
@@ -167,6 +168,10 @@ static void slice_act(uint32_t c)
|
||||
{
|
||||
uint32_t n = slice_count(), j = slice_sel(), k;
|
||||
slc_man_t *m;
|
||||
if (!n) { /* no material: says why */
|
||||
slice_edit_begin(&k);
|
||||
return;
|
||||
}
|
||||
if (j >= n) {
|
||||
ui_message("PICK A SLICE");
|
||||
return;
|
||||
|
||||
@@ -55,6 +55,11 @@ cpu/PHYS/06_TOMS 937
|
||||
cpu/PHYS/07_DRONE_STRING 1002
|
||||
cpu/PHYS/08_HARP 1023
|
||||
cpu/DRUM/00_DRUM_KIT 1099
|
||||
cpu/DRUM/kit_80 1156
|
||||
cpu/DRUM/kit_10 1169
|
||||
cpu/DRUM/kit_66 1198
|
||||
cpu/DRUM/kit_55 1189
|
||||
cpu/DRUM/kit_77 1209
|
||||
cpu/NOISE/00_WIND 1392
|
||||
cpu/NOISE/01_RAIN 1395
|
||||
cpu/NOISE/02_ARCADE 1140
|
||||
|
||||
+270
-3
@@ -24,7 +24,11 @@
|
||||
* 8. cost: host instructions per sample per voice while it sounds (retriggered), the metal source on its own,
|
||||
* and a device estimate (1.7 % per 100 instructions per sample, the PHYS measurements' ratio).
|
||||
* 9. demos into DEMODIR: every voice and variant (designed, then DECAY / TONE / extra swept), the kit through
|
||||
* the DRUM engine (the 8 keys), a beat. */
|
||||
* the DRUM engine (the 8 keys), a beat (and on each model kit).
|
||||
* 10. the model kits (KIT 80 10 66 55 77): every lane of each at its design against its targets (t-30, centroid
|
||||
* as 1., the level of its lane on STD), DC, its end; DECAY / TUNE / TONE / SNAP each move it; the corners under
|
||||
* full scale; a retrigger the same; every GM note on its lane's piece, the lanes through the engine; the cost of
|
||||
* a kit's 8 lanes at once. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
@@ -732,6 +736,37 @@ static void engine(void)
|
||||
printf("drum_test: engine: a crash 0.5 s after its key-off still rings (ADSR SUS 0 REL 0), its voice free after "
|
||||
"%.1f s: %s\n", (double)i * CTL / FS + 0.5, k && !voices_on(&trk[0]) ? "ok" : "FAIL");
|
||||
bad += !k || voices_on(&trk[0]);
|
||||
/* a zero-length note (key-off before the first block, common in MIDI drum parts) on a fresh track: each lane
|
||||
* sounds the same over 1/8 s as without the key-off (before the fix: the voice ended at once, -25..-40 dB) */
|
||||
{
|
||||
static const uint8_t KIT8[8] = {36, 38, 39, 42, 46, 45, 37, 56};
|
||||
double worst = 0;
|
||||
for (i = 0; i < 8u; i++) {
|
||||
double e[2], d;
|
||||
for (k = 0; k < 2u; k++) {
|
||||
int32_t o[2 * CTL];
|
||||
uint32_t b, j;
|
||||
double s = 0;
|
||||
kit_fresh();
|
||||
trk[0].p[P_CHOR] = trk[0].p[P_DLY] = trk[0].p[P_REV] = 0; /* dry: no tail of the run before */
|
||||
trk_note_on(&trk[0], KIT8[i], 120);
|
||||
if (k)
|
||||
trk_note_off(&trk[0], KIT8[i]);
|
||||
for (b = 0; b < FS / 8u / CTL; b++) {
|
||||
mix_block(o, CTL);
|
||||
for (j = 0; j < 2u * CTL; j++)
|
||||
s += (double)o[j] * o[j];
|
||||
}
|
||||
e[k] = s;
|
||||
}
|
||||
d = 10 * log10((e[0] + 1) / (e[1] + 1));
|
||||
worst = d > worst ? d : worst;
|
||||
}
|
||||
k = worst < 0.5; /* (the mix carries a little state between runs) */
|
||||
printf("drum_test: engine: a key-off right after the key-on (before the first block) keeps the hit, 8 lanes "
|
||||
"(at most %.2f dB quieter): %s\n", worst, k ? "ok" : "FAIL");
|
||||
bad += !k;
|
||||
}
|
||||
/* VOICE MONO, GLIDE: the kit still plays POLY */
|
||||
kit_fresh();
|
||||
trk[0].p[P_VOICE] = V_MONO;
|
||||
@@ -808,6 +843,229 @@ static void cost(void)
|
||||
sum + metal, (sum + metal) * 0.017);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- the model kits --- */
|
||||
static const char *const KITN[DV_NKIT] = {"80", "10", "66", "55", "77"};
|
||||
static const char *const LANEN[DV_NLANE] = {"KICK", "SNARE", "CLAP", "HATCL", "HATOP", "TOM", "RIM", "BELL"};
|
||||
#define KLEN (FS * 6u)
|
||||
|
||||
/* each kit lane at its design: t-30 (s) and the centroid of the first 100 ms (Hz), Felucca's own numbers for the
|
||||
* kits (measured, the shapes set against the circuits each kit models); the level of 0..0.2 s is its lane's on
|
||||
* the STD kit's terms (KICK -14.5, SNARE -18.2, CLAP -24.2, HAT CL -27.4, HAT OP -23.8, TOM -13.6, RIM -22.5,
|
||||
* BELL -21 dBFS) */
|
||||
static const float KTGT[DV_NKIT][DV_NLANE][2] = {
|
||||
{{0.300, 1304}, {0.100, 5785}, {0.150, 4339}, {0.060, 10712}, /* 80 */
|
||||
{0.350, 9524}, {0.200, 402}, {0.020, 4241}, {0.220, 1590}},
|
||||
{{0.620, 1863}, {0.350, 7962}, {2.120, 9100}, {0.280, 7787}, /* 10 */
|
||||
{2.000, 7902}, {0.420, 392}, {0.020, 1823}, {2.830, 5233}},
|
||||
{{0.180, 505}, {0.050, 10507}, {0.160, 8175}, {0.210, 9473}, /* 66 */
|
||||
{0.270, 9422}, {0.110, 1379}, {0.010, 2421}, {0.050, 1274}},
|
||||
{{0.150, 651}, {0.080, 7928}, {0.130, 8209}, {0.090, 13073}, /* 55 */
|
||||
{0.500, 13024}, {0.200, 3480}, {0.010, 3868}, {0.110, 5821}},
|
||||
{{0.450, 1253}, {0.120, 4518}, {0.230, 5906}, {0.290, 8723}, /* 77 */
|
||||
{1.630, 8771}, {0.420, 1151}, {0.110, 3517}, {1.090, 9998}},
|
||||
};
|
||||
static const float KLVL[DV_NLANE] = {-14.5f, -18.2f, -24.2f, -27.4f, -23.8f, -13.6f, -22.5f, -21.0f};
|
||||
|
||||
/* every kit: every lane against its targets, DC, its end; DECAY / TUNE / TONE / SNAP each move it; the corners
|
||||
* (DECAY TONE SNAP 0 / 127, TUNE +-25 st, LEVEL 127, full accent) under full scale; a retrigger renders the same */
|
||||
static void kits(void)
|
||||
{
|
||||
static const uint8_t C[2] = {0, 127};
|
||||
static const int16_t TU[2] = {-400, 400};
|
||||
uint32_t k, l, bad_all = 0;
|
||||
for (k = 0; k < DV_NKIT; k++) {
|
||||
uint32_t bad = 0, knee = 0;
|
||||
int32_t worst = 0;
|
||||
char line[600] = "";
|
||||
for (l = 0; l < DV_NLANE; l++) {
|
||||
uint32_t type = DV_KTYPE(k + 1u, l), a, b, c, d, i, diff = 0;
|
||||
dv_param_t p;
|
||||
double t3, ce, lv, dc, lo, hi;
|
||||
char why[300] = "";
|
||||
dv_default(&p, type);
|
||||
render(&p, NMAX, 0, &B);
|
||||
t3 = t30(&B), ce = centroid100(&B), lv = rms_db(&B, 0, FS / 5u), dc = dc_share(&B);
|
||||
snprintf(line + strlen(line), sizeof line - strlen(line), " %s %.2f s %.0f Hz %.1f dB;", LANEN[l], t3, ce, lv);
|
||||
if (getenv("KTGT"))
|
||||
printf("KTGT %u %u {%.3ff, %.0ff},\n", k, l, t3, ce);
|
||||
if (fabs(t3 - KTGT[k][l][0]) > KTGT[k][l][0] * 0.15 + 0.01)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " t-30 %.3f (target %.3f);", t3, KTGT[k][l][0]);
|
||||
if (fabs(ce / KTGT[k][l][1] - 1) > 0.2)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " centroid %.0f (target %.0f);", ce, KTGT[k][l][1]);
|
||||
if (fabs(lv - KLVL[l]) > 1.5)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " level %.1f (target %.1f);", lv, KLVL[l]);
|
||||
if (dc > 0.01)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " DC %.2f %%;", dc * 100);
|
||||
if (!B.stop || B.stop > (uint32_t)((4 * t3 + 0.5) * FS))
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " stops at %.2f s;", B.stop / (double)FS);
|
||||
/* the controls: DECAY up -> longer, TUNE up -> brighter, TONE and SNAP change it */
|
||||
p.decay = 32;
|
||||
render(&p, KLEN, 0, &B);
|
||||
lo = t30(&B);
|
||||
p.decay = 96;
|
||||
render(&p, KLEN, 0, &B2);
|
||||
hi = t30(&B2);
|
||||
if (!(hi > lo))
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " DECAY 32/96: t-30 %.3f / %.3f;", lo, hi);
|
||||
dv_default(&p, type);
|
||||
p.tune = -48;
|
||||
render(&p, FS / 2u, 0, &B);
|
||||
p.tune = 48;
|
||||
render(&p, FS / 2u, 0, &B2);
|
||||
lo = centroid100(&B), hi = centroid100(&B2); /* (the drums: their dominant frequency) */
|
||||
if (!(hi > lo) && !(pitch(&B2, FS / 50u, FS * 3u / 10u, 30, 4000) > pitch(&B, FS / 50u, FS * 3u / 10u, 30, 4000)))
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " TUNE -3/+3 st: centroid %.0f / %.0f;", lo, hi);
|
||||
for (a = 0; a < 2u; a++) {
|
||||
dv_default(&p, type);
|
||||
if (a)
|
||||
p.extra = 0;
|
||||
else
|
||||
p.tone = 0;
|
||||
render(&p, FS / 2u, 0, &B);
|
||||
if (a)
|
||||
p.extra = 127;
|
||||
else
|
||||
p.tone = 127;
|
||||
render(&p, FS / 2u, 0, &B2);
|
||||
for (i = 0, lo = hi = 0; i < FS / 2u; i++) { /* the change against the sound: above -30 dB */
|
||||
lo += (double)(B.y[i] - B2.y[i]) * (B.y[i] - B2.y[i]);
|
||||
hi += (double)B.y[i] * B.y[i];
|
||||
}
|
||||
if (lo < hi * 1e-3)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " %s 0/127 does nothing;", a ? "SNAP" : "TONE");
|
||||
}
|
||||
/* the corners */
|
||||
for (a = 0; a < 16u; a++) {
|
||||
dv_default(&p, type);
|
||||
p.decay = C[a & 1u], p.tone = C[(a >> 1) & 1u], p.extra = C[(a >> 2) & 1u], p.tune = TU[a >> 3];
|
||||
p.level = 127, p.accent = 127;
|
||||
render(&p, KLEN, 0, &B);
|
||||
knee += B.knee > 0;
|
||||
worst = B.peak > worst ? B.peak : worst;
|
||||
if (B.over || dc_share(&B) > 0.01)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " corner %u: peak %d, DC %.2f %%;", a, B.peak,
|
||||
dc_share(&B) * 100);
|
||||
}
|
||||
/* a retrigger at 0.5 s */
|
||||
dv_default(&p, type);
|
||||
c = CTL * 689u;
|
||||
render(&p, c * 2u, 0, &B);
|
||||
render(&p, c * 2u, c, &B2);
|
||||
for (i = 0; i < c; i++)
|
||||
diff += B.y[i] != B2.y[c + i];
|
||||
if (diff)
|
||||
snprintf(why + strlen(why), sizeof why - strlen(why), " retrigger: %u samples differ;", diff);
|
||||
(void)b, (void)d;
|
||||
if (why[0]) {
|
||||
printf("drum_test: KIT %s %s FAIL:%s\n", KITN[k], LANEN[l], why);
|
||||
bad++;
|
||||
}
|
||||
}
|
||||
printf("drum_test: kit %s:%s\n", KITN[k], line);
|
||||
printf("drum_test: kit %s: targets (t-30 +-15 %% + 10 ms, centroid +-20 %%, level +-1.5 dB), DC, the end, DECAY TUNE "
|
||||
"TONE SNAP, the corners (largest peak %d, %u renders in the knee), retrigger: %s\n", KITN[k], worst, knee,
|
||||
bad ? "FAIL" : "ok");
|
||||
bad_all += bad;
|
||||
}
|
||||
fails += bad_all != 0;
|
||||
}
|
||||
|
||||
/* KIT 80..77: every note plays its lane's piece of the kit (KICK ignored); the 8 lanes through the engine all sound
|
||||
* together; the lanes' names */
|
||||
static void kit_keys(void)
|
||||
{
|
||||
static const uint8_t KIT[8] = {36, 38, 39, 42, 46, 45, 37, 56};
|
||||
uint32_t k, n, bad = 0;
|
||||
for (k = 0; k < DV_NKIT; k++) {
|
||||
uint32_t i, nv, live = 0, quiet = 0;
|
||||
int32_t st, pk;
|
||||
host_tracks_init();
|
||||
host_preset(&trk[0], ENGI_DRUM, 0);
|
||||
trk[0].p[P_E0] = (int16_t)(DK_80 + k);
|
||||
trk[0].p[P_E6] = 1;
|
||||
for (n = 0; n < 128u; n++) {
|
||||
uint32_t t = drum_gm(trk[0].p, n, &st);
|
||||
bad += t != DV_KTYPE(k + 1u, drum_lane(n));
|
||||
}
|
||||
for (i = 0; i < 8u; i++) {
|
||||
kit_fresh();
|
||||
trk[0].p[P_E0] = (int16_t)(DK_80 + k);
|
||||
trk_note_on(&trk[0], KIT[i], 110);
|
||||
quiet += blocks_peak(8) < 200;
|
||||
}
|
||||
kit_fresh();
|
||||
trk[0].p[P_E0] = (int16_t)(DK_80 + k);
|
||||
for (i = 0; i < 8u; i++)
|
||||
trk_note_on(&trk[0], KIT[i], 110);
|
||||
pk = blocks_peak(2);
|
||||
nv = voices_on(&trk[0]);
|
||||
for (i = 0; i < DV_NLANE; i++)
|
||||
live += drum_kit[0][i].v.live;
|
||||
if (quiet || nv != 8u || live != 8u || pk < 1000) {
|
||||
printf("drum_test: KIT %s engine FAIL: %u lanes silent alone, %u voices, %u lanes live, peak %d\n", KITN[k], quiet,
|
||||
nv, live, pk);
|
||||
bad++;
|
||||
}
|
||||
}
|
||||
host_tracks_init();
|
||||
host_preset(&trk[0], ENGI_DRUM, 0);
|
||||
trk[0].p[P_E0] = DK_10;
|
||||
bad += strcmp(drum_lane_name(&trk[0], DV_BELL), "CYM") != 0 || strcmp(drum_lane_abbr(&trk[0], DV_TOM), "TM") != 0;
|
||||
trk[0].p[P_E0] = DK_66;
|
||||
bad += strcmp(drum_lane_name(&trk[0], DV_TOM), "CONGA") != 0 || strcmp(drum_lane_name(&trk[0], DV_BELL), "BELL") != 0;
|
||||
trk[0].p[P_E0] = DK_77;
|
||||
bad += strcmp(drum_lane_name(&trk[0], DV_RIM), "CLAVE") != 0 || strcmp(drum_lane_abbr(&trk[0], DV_BELL), "CY") != 0;
|
||||
trk[0].p[P_E0] = DK_HCYM;
|
||||
bad += strcmp(drum_lane_name(&trk[0], DV_TOM), "CONGA") != 0 || strcmp(drum_lane_name(&trk[0], DV_BELL), "CYM") != 0;
|
||||
bad += ENG_DRUM.edit[0].max != DK_COUNT - 1 || strcmp(ENG_DRUM.edit[0].names[DK_77], "77") != 0;
|
||||
printf("drum_test: kits 80 10 66 55 77: every GM note on its lane's piece, the 8 lanes alone and together through the "
|
||||
"engine, the lanes' names: %s\n", bad ? "FAIL" : "ok");
|
||||
fails += bad != 0;
|
||||
}
|
||||
|
||||
/* host instructions per sample of a kit's 8 lanes at once (each struck every 0.25 s; a metal source per lane that
|
||||
* needs one) */
|
||||
static double kit_cost(uint32_t k)
|
||||
{
|
||||
static dv_coef_t c[DV_NLANE];
|
||||
static dv_voice_t v[DV_NLANE];
|
||||
static dv_metal_t mb[DV_NLANE];
|
||||
static int32_t y[CTL], m[CTL];
|
||||
uint32_t i, l, nb = FS * 4u / CTL;
|
||||
uint64_t i0;
|
||||
for (l = 0; l < DV_NLANE; l++) {
|
||||
dv_param_t p;
|
||||
dv_default(&p, DV_KTYPE(k + 1u, l));
|
||||
dv_setup(&c[l], &p);
|
||||
dv_init(&v[l], c[l].type);
|
||||
dv_metal_tune(&mb[l], &c[l]);
|
||||
}
|
||||
i0 = instr_now();
|
||||
for (i = 0; i < nb; i++)
|
||||
for (l = 0; l < DV_NLANE; l++) {
|
||||
if (i % (FS / 4u / CTL) == 0)
|
||||
dv_trigger(&v[l]);
|
||||
if (dv_uses_metal(c[l].type))
|
||||
dv_metal_run(&mb[l], m, CTL);
|
||||
dv_run(&c[l], &v[l], m, y, CTL);
|
||||
__asm__ volatile("" : : "r"(y) : "memory");
|
||||
}
|
||||
return (double)(instr_now() - i0) / (nb * CTL);
|
||||
}
|
||||
|
||||
static void kit_costs(void)
|
||||
{
|
||||
uint32_t k;
|
||||
char line[300] = "";
|
||||
if (!instr_now())
|
||||
return;
|
||||
for (k = 0; k < DV_NKIT; k++) {
|
||||
double c = kit_cost(k);
|
||||
snprintf(line + strlen(line), sizeof line - strlen(line), " %s %.0f (~%.1f %%);", KITN[k], c, c * 0.017);
|
||||
}
|
||||
printf("drum_test: cost, the 8 lanes at once per kit, host instructions per sample (device estimate):%s\n", line);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ demos --- */
|
||||
static FILE *wav_open(const char *dir, const char *name, uint32_t frames)
|
||||
{
|
||||
@@ -908,14 +1166,21 @@ static void demos(const char *dir)
|
||||
demo_seq(dir, "kit_keys", (const uint8_t(*)[3])kit, 16, 64, 0, DK_HCYM);
|
||||
demo_seq(dir, "beat_punch", BEAT, sizeof BEAT / sizeof BEAT[0], 64, 0, DK_STD);
|
||||
demo_seq(dir, "beat_round", BEAT, sizeof BEAT / sizeof BEAT[0], 64, 1, DK_STD);
|
||||
for (k = 0; k < DV_NKIT; k++) {
|
||||
char name[32];
|
||||
snprintf(name, sizeof name, "beat_kit_%s", KITN[k]);
|
||||
demo_seq(dir, name, BEAT, sizeof BEAT / sizeof BEAT[0], 64, 0, (int16_t)(DK_80 + k));
|
||||
}
|
||||
printf("drum_test: demos in %s: %u voices (designed, DECAY / TONE / extra low and high, TUNE -5 / +5 st), the kit's "
|
||||
"keys, a beat (PUNCH, ROUND)\n", dir, (uint32_t)DVT_COUNT);
|
||||
"keys, a beat (PUNCH, ROUND, the kits 80 10 66 55 77)\n", dir, (uint32_t)DVT_COUNT);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (!getenv("NOCOST"))
|
||||
if (!getenv("NOCOST")) {
|
||||
cost();
|
||||
kit_costs();
|
||||
}
|
||||
targets();
|
||||
controls();
|
||||
safety();
|
||||
@@ -923,6 +1188,8 @@ int main(int argc, char **argv)
|
||||
choke();
|
||||
kick_speaker();
|
||||
keys();
|
||||
kits();
|
||||
kit_keys();
|
||||
lane_budget();
|
||||
engine();
|
||||
if (argc > 1)
|
||||
|
||||
+178
-10
@@ -7,6 +7,7 @@ static unsigned char host_samples[3][0x14000];
|
||||
#define FELUCCA_OTA 1
|
||||
#define FELUCCA_FLASH 0
|
||||
#define FELUCCA_VERSION "TEST"
|
||||
#define FELUCCA_CDC 1 /* (as the firmware: MENU > USB SERIAL switches the console) */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
@@ -39,6 +40,7 @@ static void lcd_blit(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const uint1
|
||||
#include "../firmware/src/gfx.c"
|
||||
#include "../firmware/src/panel.c"
|
||||
#include "../firmware/src/ui.c"
|
||||
#include "../firmware/src/menu_items.c"
|
||||
static void panel_setup(void) {}
|
||||
#include "../firmware/src/upreset.c"
|
||||
#include "../firmware/src/project.c"
|
||||
@@ -112,15 +114,16 @@ static int preferences(void)
|
||||
uint32_t n = request(ED_INFO, a, 0);
|
||||
bad += check("INFO explicitly tags display capabilities after SONG without changing command 33",
|
||||
ED_SONG == 33 && ED_UI_STATE == 34 && ED_FAV_SET == 38 &&
|
||||
host_wire[n - 22] == CHAIN_ROWS && host_wire[n - 21] == 0x55 &&
|
||||
host_wire[n - 20] == 1 && host_wire[n - 19] == 9 &&
|
||||
host_wire[n - 18] == 0x4d && host_wire[n - 17] == 1 &&
|
||||
host_wire[n - 16] == MOTION_MAX && host_wire[n - 15] == 1 &&
|
||||
host_wire[n - 14] == 0x42 && host_wire[n - 13] == 1 && host_wire[n - 12] == 3 &&
|
||||
host_wire[n - 11] == 0x46 && host_wire[n - 10] == 1 && host_wire[n - 9] == FM6_NFACTORY &&
|
||||
host_wire[n - 8] == 0 && /* (no bank since 1.0.3) */
|
||||
host_wire[n - 7] == 0x53 && host_wire[n - 6] == 1 && host_wire[n - 5] == 3 &&
|
||||
host_wire[n - 4] == 0x50 && host_wire[n - 3] == 1 && host_wire[n - 2] == 3); /* FM6 v2: no bank, preset patches */
|
||||
host_wire[n - 25] == CHAIN_ROWS && host_wire[n - 24] == 0x55 &&
|
||||
host_wire[n - 23] == 1 && host_wire[n - 22] == 9 &&
|
||||
host_wire[n - 21] == 0x4d && host_wire[n - 20] == 1 &&
|
||||
host_wire[n - 19] == MOTION_MAX && host_wire[n - 18] == 1 &&
|
||||
host_wire[n - 17] == 0x42 && host_wire[n - 16] == 1 && host_wire[n - 15] == 3 &&
|
||||
host_wire[n - 14] == 0x46 && host_wire[n - 13] == 1 && host_wire[n - 12] == FM6_NFACTORY &&
|
||||
host_wire[n - 11] == 0 && /* (no bank since 1.0.3) */
|
||||
host_wire[n - 10] == 0x53 && host_wire[n - 9] == 1 && host_wire[n - 8] == 3 &&
|
||||
host_wire[n - 7] == 0x50 && host_wire[n - 6] == 1 && host_wire[n - 5] == 3 && /* FM6 v2: no bank, preset patches */
|
||||
host_wire[n - 4] == 0x4E && host_wire[n - 3] == 1 && host_wire[n - 2] == 12); /* MENU settings: 12 items */
|
||||
request(ED_UI_SET, a, 2);
|
||||
bad += check("UI_SET updates the actual palette and reports RAM-only saving",
|
||||
host_wire[5] == 3 && settings.palette == 7 && T_BG == UI_PALETTES[7].bg);
|
||||
@@ -661,10 +664,175 @@ static int usb_burst(void)
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* ---- MENU_DESC / MENU_SET (72, 73): the menu's settings over the editor ---- */
|
||||
typedef struct { uint32_t index, id, kind, nnames; int32_t value, min, max; char name[16], names[12][12]; } menu_item_t;
|
||||
static uint32_t menu_desc(uint32_t index, menu_item_t *it) /* the reply's payload length; it parsed */
|
||||
{
|
||||
uint8_t a[1] = {(uint8_t)index};
|
||||
uint32_t n = request(ED_MENU_DESC, a, 1), p = 14, k;
|
||||
memset(it, 0, sizeof *it);
|
||||
if (n < 8u || host_wire[4] != ED_MENU_DESC || host_wire[n - 1] != 0xF7) return 0;
|
||||
it->index = host_wire[5]; it->id = host_wire[6];
|
||||
if (n < 15u) return n - 6u;
|
||||
it->kind = host_wire[7];
|
||||
it->value = ed_rv(host_wire + 8); it->min = ed_rv(host_wire + 10); it->max = ed_rv(host_wire + 12);
|
||||
for (k = 0; p < n - 1u && host_wire[p] && k < 15u; ) it->name[k++] = (char)host_wire[p++];
|
||||
p++;
|
||||
while (p < n - 1u && it->nnames < 12u) {
|
||||
for (k = 0; p < n - 1u && host_wire[p] && k < 11u; ) it->names[it->nnames][k++] = (char)host_wire[p++];
|
||||
p++; it->nnames++;
|
||||
}
|
||||
return n - 6u;
|
||||
}
|
||||
static uint32_t menu_set(uint32_t id, int32_t v) /* -> rc; host_wire[6], [7..8]: id, value */
|
||||
{
|
||||
uint8_t a[3] = {(uint8_t)id, (uint8_t)((v + 8192) & 127), (uint8_t)(((v + 8192) >> 7) & 127)};
|
||||
uint32_t n = request(ED_MENU_SET, a, 3);
|
||||
return n == 10u && host_wire[4] == ED_MENU_SET ? host_wire[5] : 99u;
|
||||
}
|
||||
static int menu_protocol(void)
|
||||
{
|
||||
static const char *const WANT[12][2] = {
|
||||
{"COLOR", 0}, {"STYLE", "FLAT,LINE"}, {"LARGE", "OFF,ON"}, {"ANIM", "ON,OFF"}, {"LEDS", "OFF,DIM LO,DIM HI,INV"},
|
||||
{"HOLD", "0.3 s,0.4 s,0.5 s,0.6 s"}, {"KNOB ACCEL", "OFF,ON"}, {"FX LATCH", "OFF,ON"}, {"BPM LOCK", "OFF,ON"},
|
||||
{"SPEAKER EQ", "FLAT,LOWCUT,BASS+"}, {"USB LEVEL", "MASTER,FIXED"}, {"USB SERIAL", "ON,OFF"}};
|
||||
static const int32_t DEF[12] = {-1, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0}; /* (COLOR: the default palette) */
|
||||
int bad = 0, ok = 1;
|
||||
uint32_t i, k, n;
|
||||
menu_item_t it;
|
||||
char joined[96];
|
||||
const char *json = getenv("MENU_JSON");
|
||||
FILE *jf = json ? fopen(json, "w") : 0;
|
||||
reset();
|
||||
if (jf) fprintf(jf, "[");
|
||||
for (i = 0; i < 12u; i++) {
|
||||
n = menu_desc(i, &it);
|
||||
joined[0] = 0;
|
||||
for (k = 0; k < it.nnames; k++) { if (k) strcat(joined, ","); strcat(joined, it.names[k]); }
|
||||
ok &= n > 10u && it.index == i && it.id == i && it.kind == 0 && it.min == 0 &&
|
||||
it.max + 1 == (int32_t)it.nnames && !strcmp(it.name, WANT[i][0]) &&
|
||||
(WANT[i][1] ? !strcmp(joined, WANT[i][1]) : it.nnames == NPALETTES) &&
|
||||
it.value == (DEF[i] < 0 ? (int32_t)settings.palette : DEF[i]);
|
||||
if (i == 0)
|
||||
for (k = 0; k < NPALETTES; k++) ok &= !strcmp(it.names[k], UI_PALETTES[k].name);
|
||||
if (!ok) { printf(" MENU_DESC %u: %s [%s] value %d max %d\n", i, it.name, joined, it.value, it.max); break; }
|
||||
if (jf) {
|
||||
fprintf(jf, "%s\n {\"id\":%u,\"kind\":%u,\"min\":%d,\"max\":%d,\"value\":%d,\"name\":\"%s\",\"names\":[", i ? "," : "",
|
||||
it.id, it.kind, it.min, it.max, it.value, it.name);
|
||||
for (k = 0; k < it.nnames; k++) fprintf(jf, "%s\"%s\"", k ? "," : "", it.names[k]);
|
||||
fprintf(jf, "]}");
|
||||
}
|
||||
}
|
||||
if (jf) { fprintf(jf, "]\n"); fclose(jf); }
|
||||
bad += check("MENU_DESC: 12 items in the menu's order, ids 0..11, every name and value name, the defaults", ok);
|
||||
ok = 1;
|
||||
for (i = 0; i < 12u; i++) {
|
||||
menu_desc(i, &it);
|
||||
ok &= strcmp(it.name, "CALIBRATION") && strcmp(it.name, "ABOUT");
|
||||
}
|
||||
n = menu_desc(12, &it);
|
||||
ok &= n == 2u && it.index == 12 && it.id == 127;
|
||||
n = menu_desc(127, &it);
|
||||
bad += check("MENU_DESC: no CALIBRATION / ABOUT; an index past the list answers index, 127 (no item)",
|
||||
ok && n == 2u && it.index == 127 && it.id == 127);
|
||||
{
|
||||
uint8_t a[3] = {0, 0, 0};
|
||||
ok = request(ED_MENU_DESC, a, 0) == 0 && request(ED_MENU_DESC, a, 2) == 0 && request(ED_MENU_SET, a, 2) == 0 &&
|
||||
request(ED_MENU_SET, a, 1) == 0;
|
||||
bad += check("MENU_DESC / MENU_SET with the wrong length: no reply", ok);
|
||||
}
|
||||
|
||||
/* MENU_SET: each setting, applied as the menu applies it; RAM only here (no flash: rc 3) */
|
||||
reset();
|
||||
ui.force = 0;
|
||||
ok = menu_set(0, 2) == 3 && host_wire[6] == 0 && ed_rv(host_wire + 7) == 2 && settings.palette == 2u &&
|
||||
T_BG == UI_PALETTES[2].bg && ui.force;
|
||||
ok &= menu_set(1, 1) == 3 && ui_style == ST_LINE;
|
||||
ok &= menu_set(2, 1) == 3 && (ui_prefs & PREF_LARGE);
|
||||
ok &= menu_set(3, 1) == 3 && (ui_prefs & PREF_ANIM_OFF);
|
||||
ok &= menu_set(4, 0) == 3 && settings_leds == LEDS_OFF && menu_set(4, 1) == 3 && settings_leds == LEDS_DIM_LO;
|
||||
ok &= menu_set(5, 3) == 3 && settings_hold == 3u;
|
||||
ok &= menu_set(6, 1) == 3 && (ui_prefs & PREF_ACCEL);
|
||||
ok &= menu_set(7, 1) == 3 && (ui_prefs & PREF_LATCH);
|
||||
ok &= menu_set(8, 1) == 3 && (ui_prefs & PREF_BPM_LOCK);
|
||||
ok &= menu_set(9, 2) == 3 && settings.lowcut == 2u && fx_lowcut == 2u;
|
||||
ok &= menu_set(10, 1) == 3 && (ui_prefs & PREF_USB_FIXED) && fx_usb_fixed;
|
||||
for (i = 0; i < 12u; i++) { /* MENU_DESC reads them back */
|
||||
static const int32_t SET[12] = {2, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 0};
|
||||
menu_desc(i, &it);
|
||||
ok &= it.value == SET[i];
|
||||
}
|
||||
bad += check("MENU_SET: every setting applied as the menu does (palette, EQ, USB LEVEL at once), read back", ok);
|
||||
ok = menu_set(3, 0) == 3 && !(ui_prefs & PREF_ANIM_OFF) && (ui_prefs & PREF_LARGE) && menu_set(10, 0) == 3 &&
|
||||
!fx_usb_fixed && menu_set(1, 0) == 3 && ui_style == ST_FLAT;
|
||||
bad += check("MENU_SET: a flag back to its default leaves the other flags", ok);
|
||||
|
||||
/* clamping: the reply carries the device's value */
|
||||
ok = menu_set(0, 50) == 3 && ed_rv(host_wire + 7) == (int32_t)NPALETTES - 1 && settings.palette == NPALETTES - 1u;
|
||||
ok &= menu_set(0, -5) == 3 && ed_rv(host_wire + 7) == 0 && settings.palette == 0u;
|
||||
ok &= menu_set(4, 99) == 3 && ed_rv(host_wire + 7) == 3 && settings_leds == LEDS_INV;
|
||||
ok &= menu_set(5, 8191) == 3 && ed_rv(host_wire + 7) == 3 && settings_hold == 3u;
|
||||
ok &= menu_set(2, 7) == 3 && ed_rv(host_wire + 7) == 1 && (ui_prefs & PREF_LARGE);
|
||||
bad += check("MENU_SET: out-of-range values clamped, the reply says the value the device took", ok);
|
||||
|
||||
/* an id nobody has */
|
||||
{
|
||||
static uint8_t fav0[sizeof favorites], set0[sizeof settings];
|
||||
uint8_t hold0 = settings_hold, leds0 = settings_leds;
|
||||
memcpy(fav0, &favorites, sizeof favorites); memcpy(set0, &settings, sizeof settings);
|
||||
ok = menu_set(12, 1) == 1 && host_wire[6] == 12 && ed_rv(host_wire + 7) == 1;
|
||||
ok &= menu_set(126, -3) == 1 && host_wire[6] == 126 && ed_rv(host_wire + 7) == -3;
|
||||
ok &= menu_set(127, 0) == 1 && host_wire[6] == 127;
|
||||
ok &= !memcmp(fav0, &favorites, sizeof favorites) && !memcmp(set0, &settings, sizeof settings) &&
|
||||
hold0 == settings_hold && leds0 == settings_leds;
|
||||
bad += check("MENU_SET: an unknown id answers rc 1, id and value echoed, nothing changed", ok);
|
||||
}
|
||||
|
||||
/* the MENU page shown: the editor's change redraws it */
|
||||
ui.menu = 1; ui.force = 0;
|
||||
menu_set(7, 0);
|
||||
bad += check("MENU_SET while the MENU page is shown: the page redraws (ui.force)", ui.force && ui.menu == 1);
|
||||
ui.menu = 0;
|
||||
|
||||
/* USB SERIAL: the reply first, the re-enumeration 200 ms later (usb_serial_apply, called every frame). (usb.up
|
||||
* stays 0 here: the host has no USB registers; usb.config 0 = the device off the bus, enumerated afresh) */
|
||||
{
|
||||
uint32_t t0;
|
||||
reset();
|
||||
usb_cdc_on = 1;
|
||||
usb_serial_apply();
|
||||
ok = usb_cdc_on && usb.config;
|
||||
ok &= menu_set(11, 1) == 3 && host_wire[6] == 11 && ed_rv(host_wire + 7) == 1 && (ui_prefs & PREF_SERIAL_OFF);
|
||||
t0 = fm1_ms;
|
||||
usb_serial_apply();
|
||||
ok &= usb_cdc_on && usb.config; /* the reply has left; USB as it was */
|
||||
fm1_ms = t0 + 150u; usb_serial_apply();
|
||||
ok &= usb_cdc_on && usb.config;
|
||||
fm1_ms = t0 + 201u; usb_serial_apply();
|
||||
ok &= !usb_cdc_on && !usb.config; /* off the bus: usb_retry attaches again without the console */
|
||||
bad += check("MENU_SET USB SERIAL OFF: reply first, applied ~200 ms later (the device re-enumerates)", ok);
|
||||
usb.config = 1;
|
||||
ok = menu_set(11, 0) == 3 && !(ui_prefs & PREF_SERIAL_OFF);
|
||||
t0 = fm1_ms;
|
||||
ui.menu = 1; /* the MENU shown: applied when it closes, as the menu's own */
|
||||
fm1_ms = t0 + 500u; /* (ui_input calls usb_serial_apply only with the menu closed) */
|
||||
ok &= !usb_cdc_on && usb.config;
|
||||
ui.menu = 0; usb_serial_apply();
|
||||
ok &= usb_cdc_on && !usb.config;
|
||||
usb.config = 1;
|
||||
ok &= menu_set(11, 0) == 3; /* unchanged: no re-enumeration */
|
||||
fm1_ms += 300u; usb_serial_apply();
|
||||
ok &= usb_cdc_on && usb.config;
|
||||
bad += check("MENU_SET USB SERIAL ON: applied later (with the MENU open: when it closes); unchanged: no drop", ok);
|
||||
}
|
||||
reset();
|
||||
return bad;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int bad = preferences() + framing() + uart_recovery() + steps() + samples() + song_protocol() + malformed_saves() +
|
||||
fm6_patches() + user_preset_roundtrip() + live_sync() + usb_burst();
|
||||
fm6_patches() + user_preset_roundtrip() + live_sync() + usb_burst() + menu_protocol();
|
||||
printf("%s\n", bad ? "EDITOR TEST FAILED" : "editor test passed");
|
||||
return bad != 0;
|
||||
}
|
||||
@@ -70,6 +70,11 @@ preset/FM6/07_PLUCK 91e9132dd7237f14
|
||||
preset/SLICE/00_CHOP 6d1e706b5119b570
|
||||
preset/SLICE/01_STUTTER 94226b45e8a75cf0
|
||||
drums/drum_gm_kit a88dcac7803e88d4
|
||||
drums/kit_80 e3de7e091a481244
|
||||
drums/kit_10 0cd4e95937dc519c
|
||||
drums/kit_66 04e60dfd865541b0
|
||||
drums/kit_55 b86935ebf007cdbc
|
||||
drums/kit_77 1e3617b89fd7e2fc
|
||||
mode/ANALOG/POLY 37fb068bc75b2f5c
|
||||
mode/ANALOG/MONO 4904e99e3020a8b0
|
||||
mode/ANALOG/LEGATO 8fff1c8dc8b7ded8
|
||||
|
||||
@@ -23,6 +23,7 @@ static void lcd_blit(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const uint1
|
||||
#include "../firmware/src/gfx.c"
|
||||
#include "../firmware/src/panel.c"
|
||||
#include "../firmware/src/ui.c"
|
||||
#include "../firmware/src/menu_items.c"
|
||||
static void panel_setup(void) {}
|
||||
|
||||
static uint8_t nor[0x100000], flash_ok = 1;
|
||||
@@ -55,11 +56,14 @@ static void fl_plain_window_init(void) {}
|
||||
#include "../firmware/src/project.c"
|
||||
|
||||
enum { ED_UI_STATE = 34, ED_UI_SET, ED_UI_PALETTES, ED_FAV_GET, ED_FAV_SET };
|
||||
static void ed_b(uint32_t n) { (void)n; }
|
||||
static void ed_v(int32_t n) { (void)n; }
|
||||
static uint8_t ed_rep[64]; /* the reply's bytes (MENU_SET) */
|
||||
static uint32_t ed_repn;
|
||||
static void ed_b(uint32_t n) { if (ed_repn < sizeof ed_rep) ed_rep[ed_repn++] = (uint8_t)(n & 127u); }
|
||||
static void ed_v(int32_t n) { ed_b((uint32_t)(n + 8192)); ed_b((uint32_t)(n + 8192) >> 7); }
|
||||
static int32_t ed_rv(const uint8_t *a) { return (int32_t)(a[0] | (uint32_t)a[1] << 7) - 8192; }
|
||||
static void ed_str(const char *s, uint32_t n) { (void)s; (void)n; }
|
||||
#include "../firmware/src/editor_preferences.c"
|
||||
#include "../firmware/src/editor_menu.c"
|
||||
|
||||
static int check(const char *what, int ok)
|
||||
{
|
||||
@@ -252,6 +256,46 @@ int main(void)
|
||||
const uint8_t bold[] = {1, 1};
|
||||
bad += check("the retired font weight is refused without a write", ed_ui_set(bold, sizeof bold) == 2);
|
||||
}
|
||||
{ /* MENU_SET (editor_menu.c): the same settings record, the same deferral, retry and idempotence */
|
||||
const uint8_t leds_off[] = {4, 0, 64}, large_on[] = {2, 1, 64}, hold_06[] = {5, 3, 64}, eq_bass[] = {9, 2, 64};
|
||||
persist_t q;
|
||||
reset();
|
||||
settings_init();
|
||||
song.playing = 1;
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, leds_off, 3);
|
||||
bad += check("MENU_SET while playing: applied, rc 4 (queued until STOP), no erase",
|
||||
ed_repn == 4 && ed_rep[0] == 4 && ed_rep[1] == 4 && settings_leds == LEDS_OFF && persist_pending == 1 && !erases);
|
||||
song.playing = 0;
|
||||
settings_poll();
|
||||
bad += check("STOP commits the MENU setting (LEDS OFF in the settings record)",
|
||||
!persist_pending && erases == 1 && st_load(OBJ_SETTINGS, &q, sizeof q) == (int)sizeof q &&
|
||||
leds_from_stored(q.zoom) == LEDS_OFF);
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, large_on, 3);
|
||||
ok = ed_rep[0] == 0 && (ui_prefs & PREF_LARGE);
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, hold_06, 3);
|
||||
ok &= ed_rep[0] == 0 && settings_hold == 3u;
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, eq_bass, 3);
|
||||
ok &= ed_rep[0] == 0 && st_load(OBJ_SETTINGS, &q, sizeof q) == (int)sizeof q && q.lowcut == 2u &&
|
||||
hold_from_stored(q.bold) == 3u && (q.favorites.factory[15][30] & PREF_LARGE) && leds_from_stored(q.zoom) == LEDS_OFF;
|
||||
bad += check("MENU_SET stopped: rc 0, saved at once (LARGE, HOLD, SPEAKER EQ), the others kept", ok);
|
||||
before = erases;
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, hold_06, 3);
|
||||
bad += check("repeating an unchanged MENU_SET: rc 0, no erase", ed_rep[0] == 0 && erases == before);
|
||||
erase_error = 1;
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, leds_off, 3); /* unchanged: still rc 0 (no write) */
|
||||
ok = ed_rep[0] == 0;
|
||||
{
|
||||
const uint8_t leds_inv[] = {4, 3, 64};
|
||||
ed_repn = 0; ed_menu_handle(ED_MENU_SET, leds_inv, 3);
|
||||
}
|
||||
ok &= ed_rep[0] == 3 && settings_leds == LEDS_INV && persist_pending == 2 && leds_from_stored(persist_saved.zoom) == LEDS_OFF;
|
||||
bad += check("MENU_SET with a failing flash: applied, rc 3, the saved setting kept", ok);
|
||||
erase_error = 0;
|
||||
fm1_ms += 1000;
|
||||
settings_poll();
|
||||
bad += check("... and retried by the settings path", !persist_pending && leds_from_stored(persist_saved.zoom) == LEDS_INV);
|
||||
settings_hold = HOLD_DEF; settings_leds = LEDS_DIM;
|
||||
}
|
||||
reset();
|
||||
settings.palette = 3;
|
||||
settings.lowcut = 2;
|
||||
|
||||
+21
-3
@@ -3,7 +3,8 @@
|
||||
/* Regression suite of the FELUCCA DSP on the Mac (same sources as the firmware, through hostsim.c).
|
||||
* build/host/regress [GOLDEN_FILE CPU_FILE] (run_tests.sh builds and runs it)
|
||||
*
|
||||
* 1. golden renders: every engine x factory preset, the GM map on DRUM (SAMPLE PERC until 1.0.2), the voice modes (POLY / MONO /
|
||||
* 1. golden renders: every engine x factory preset, the GM map on DRUM (SAMPLE PERC until 1.0.2; and on each model kit,
|
||||
* KIT 80 10 66 55 77), the voice modes (POLY / MONO /
|
||||
* LEGATO / UNISON) of three engines, the FX sends, a 4-track sequencer mix, and the SLICER (slicer.c:
|
||||
* GATE / STUT on the phrase, and on the 4-track mix with the transport). Each render plays
|
||||
* a fixed phrase (notes, an overlap, a chord, note-offs, the release tail) and is reduced to a
|
||||
@@ -204,13 +205,13 @@ static void job_sends(const job_t *j) /* arg: 0 dry, 1 chorus, 2 delay
|
||||
phrase(t, 60);
|
||||
}
|
||||
|
||||
static void job_drums(const job_t *j) /* every GM note through DRUM on part 4, a roll */
|
||||
static void job_drums(const job_t *j) /* every GM note through DRUM on part 4, a roll; arg: KIT (0: STD) */
|
||||
{
|
||||
track_t *t = &trk[3];
|
||||
uint32_t n, k = 0;
|
||||
(void)j;
|
||||
host_tracks_init();
|
||||
host_drums(t);
|
||||
t->p[P_E0] = j->arg;
|
||||
for (n = 35; n <= 81u; n++, k++) {
|
||||
input_on(t, n, 60u + (n * 7u) % 60u);
|
||||
run_to(at(0.06 * (k + 1)));
|
||||
@@ -331,6 +332,8 @@ static void job_cpu(const job_t *j)
|
||||
host_tracks_init();
|
||||
for (p = 0; p < NPART; p++) {
|
||||
host_preset(&trk[p], parts[p][0], parts[p][1]);
|
||||
if (j->arg && ENGINES[parts[p][0]] == &ENG_DRUM)
|
||||
trk[p].p[P_E0] = j->arg; /* DRUM: a KIT (the model kits) */
|
||||
if (parts[p][2] == DRUM_HITS)
|
||||
continue;
|
||||
trk[p].p[P_VOICE] = V_POLY;
|
||||
@@ -1033,6 +1036,10 @@ int main(int argc, char **argv)
|
||||
j->pi = (uint8_t)pi;
|
||||
}
|
||||
add(J_DRUMS, "drums/drum_gm_kit");
|
||||
for (i = 0; i < DV_NKIT; i++) { /* the model kits (KIT 80 10 66 55 77) */
|
||||
snprintf(name, sizeof name, "drums/kit_%s", N_DRUM_KIT[DK_80 + i]);
|
||||
add(J_DRUMS, name)->arg = (uint8_t)(DK_80 + i);
|
||||
}
|
||||
for (i = 0; i < 3u; i++)
|
||||
for (k0 = 0; k0 < 4u && eng_ok(MODE_E[i][0]); k0++) {
|
||||
job_t *j;
|
||||
@@ -1100,6 +1107,17 @@ int main(int argc, char **argv)
|
||||
j->e = (uint8_t)e;
|
||||
j->pi = (uint8_t)pi;
|
||||
}
|
||||
for (i = 0; i < DV_NKIT; i++) { /* DRUM's model kits: the 8 lanes, as its preset above */
|
||||
job_t *j;
|
||||
snprintf(name, sizeof name, "cpu/DRUM/kit_%s", N_DRUM_KIT[DK_80 + i]);
|
||||
j = add(J_CPU, name);
|
||||
memset(cpu_parts[ncpu], 0, sizeof cpu_parts[ncpu]);
|
||||
cpu_parts[ncpu][0][0] = ENGI_DRUM, cpu_parts[ncpu][0][1] = 0, cpu_parts[ncpu][0][2] = 8;
|
||||
j->parts = (const uint8_t (*)[3])cpu_parts[ncpu++];
|
||||
j->e = ENGI_DRUM;
|
||||
j->pi = 0;
|
||||
j->arg = (uint8_t)(DK_80 + i);
|
||||
}
|
||||
{ /* mixes: idle (subtracted from the presets' counts), idle + drums (part 4 DRUM; SAMPLE PERC until 1.0.2), FM (DIGITAL with
|
||||
* FELUCCA_FM4, else FM6) + PHASE + VOICE asking 8 + 8 + 4 + the drums (the budget keeps 8; FM6 plays 6) */
|
||||
job_t *j = add(J_CPU, "cpu/mix/idle");
|
||||
|
||||
+21
-3
@@ -32,7 +32,8 @@
|
||||
# the DRUM grid (keys, knobs, LEDs, pages, live recording into it, BEAT from PATTERNS).
|
||||
# Audio / persistence / editor: the real C paths against simulated DMA and NOR flash: bounded overload
|
||||
# fades, shared-voice limits, deferred settings and retries, failed-save rollback,
|
||||
# malformed transfers, transport-stop timeouts, MIDI and UART recovery.
|
||||
# malformed transfers, transport-stop timeouts, MIDI and UART recovery; the MENU settings over the
|
||||
# editor (MENU_DESC / MENU_SET: every item, clamping, unknown ids, saving, USB SERIAL applied later).
|
||||
# CHORD (tests/chord_test.c): the chord keys (src/chord.c): diatonic triads / sevenths of several scales and roots,
|
||||
# the fixed shapes and voicings (at most 4 notes), names, MONO plays the root, a release ends
|
||||
# exactly what its key / MIDI note started, recording, the ARP, MIDI IN, kits ignore CHRD.
|
||||
@@ -55,7 +56,11 @@
|
||||
# USB audio (tests/uac_test.c): the UAC1 descriptors as a host parses them (with and without CDC), the
|
||||
# ring and packetiser: 44.1 frames per packet, every frame in order, underrun / overrun, restart.
|
||||
# web (web/test_web.mjs): the editor protocol against its mock device, whose tables must equal the
|
||||
# firmware's (tests/descdump.c -> build/host/desc.json), the package builder, the updater.
|
||||
# firmware's (tests/descdump.c -> build/host/desc.json; the MENU settings: tests/editor_test.c -> build/host/menu.json),
|
||||
# the package builder, the updater.
|
||||
# Browser emulator (web/emu, when emcc is there): the firmware in WebAssembly (build/emu) boots, plays keys and MIDI,
|
||||
# draws, lights its LEDs, keeps a save across instances, plays a song bit for bit as the same file
|
||||
# built with cc (web/emu/native_check.c); the cost of 1 s of a heavy song against real time.
|
||||
# PHYS (tests/phys_test.c): stability over the whole parameter and pitch range, the worst-case cost against
|
||||
# the heaviest factory preset, demos in build/phys_demo/; tests/phys_ref.cpp compares the
|
||||
# fixed-point models with DaisySP's float originals when DaisySP is there (DAISYSP=path).
|
||||
@@ -181,7 +186,8 @@ if [ -f build/gen/felucca_tables.h ]; then
|
||||
$CC -w -Ibuild/gen -Ifirmware/src -o "$OUT/backup_test" tests/backup_test.c -lm
|
||||
run "full backup: CRC before writes, stale runtime, USB reset / timeout, malformed objects, older projects" "$OUT/backup_test"
|
||||
$CC -w -Ibuild/gen -Ifirmware/src -o "$OUT/editor_test" tests/editor_test.c -lm
|
||||
run "editor: real C protocol, malformed transfers and queue recovery" "$OUT/editor_test"
|
||||
run "editor: real C protocol, malformed transfers, queue recovery, MENU settings (writes build/host/menu.json)" \
|
||||
env MENU_JSON="$OUT/menu.json" "$OUT/editor_test"
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/mod_test" tests/mod_test.c -lm
|
||||
mkdir -p build/mod_demo
|
||||
run "modulation matrix: off = bit-identical, the math, MIDI CC1 / CC11 / aftertouch, cost, demos" "$OUT/mod_test" build/mod_demo
|
||||
@@ -251,4 +257,16 @@ else
|
||||
echo "== skip web tests (no node)"
|
||||
fi
|
||||
|
||||
if ! command -v emcc >/dev/null 2>&1; then
|
||||
echo "== skip the browser emulator (no emcc: Emscripten builds web/emu)"
|
||||
elif ! command -v node >/dev/null 2>&1 || [ ! -f build/gen/felucca_tables.h ]; then
|
||||
echo "== skip the browser emulator (needs node and build/gen)"
|
||||
else
|
||||
run "browser emulator: the firmware to WebAssembly (web/emu/build.sh -> build/emu)" sh web/emu/build.sh
|
||||
cc -O2 -ffp-contract=off -w -Ibuild/gen -Ifirmware/src -o "$OUT/emu_native" web/emu/native_check.c -lm
|
||||
run "browser emulator: the same song from the native build" "$OUT/emu_native" "$OUT/emu_native.f32"
|
||||
run "browser emulator: boot, keys, MIDI, screen, LEDs, PLAY, a save kept across instances, = native, cost" \
|
||||
node web/emu/emu_test.mjs build/emu/felucca.wasm "$OUT/emu_native.f32"
|
||||
fi
|
||||
|
||||
[ $fail -eq 0 ] && echo "ALL HOST TESTS PASSED" || { echo "HOST TESTS FAILED"; exit 1; }
|
||||
+125
-7
@@ -9,8 +9,11 @@
|
||||
* 2. AUTO: the detector (slc_scan) on BREAK finds its hits; on the user loop every onset has a slice
|
||||
* start at most 6 ms before it and 1 ms after it, and no slice starts away from an onset.
|
||||
* 3. REV: a slice read backwards (64-sample windows from checkpoints) == the forward decode reversed.
|
||||
* 4. keys / steps -> slices (mod the count, START, ROOT, an empty slot plays BREAK); ONE / GATE / LOOP.
|
||||
* 4. keys / steps -> slices (mod the count, START, ROOT, an empty slot plays the sine); ONE / GATE / LOOP.
|
||||
* 5. demos into DEMO_DIR: both presets with their patterns, BREAK re-sequenced, the user loop sliced AUTO and MAN.
|
||||
* 8. PIANO (SRC 4, 1.0.4): the SAMPLE PIANO zone of middle C itself (no copy), its table, one AUTO slice, played;
|
||||
* a missing sample (SLICE / SAMPLE / GRAIN on an empty slot) plays a sine at the note's pitch: zero crossings,
|
||||
* level, no click, no other sample, it ends after the note-off.
|
||||
* 6. MAN, the slices set by hand (the SLICES page; ported from hugelton/Felucca#27 by andreahaku): none set = AUTO,
|
||||
* move / end / split / join within their limits, the decoder states, keys / bounds / REV after a commit, a slot
|
||||
* scan clearing them, restore == save, bad tables refused, a start moved past a reverse voice, no room.
|
||||
@@ -156,7 +159,7 @@ static uint32_t rev_check(uint32_t src, uint32_t div, uint32_t j)
|
||||
v.ph[0] = b;
|
||||
v.ph[2] = a;
|
||||
v.s[0] = 0x7FFFFFFF;
|
||||
v.s[4] = (int32_t)(src | (st >> 24) << 2 | 1u << 6 | j << 8 | div << 16);
|
||||
v.s[4] = (int32_t)(src | (st >> 24) << 3 | 1u << 7 | j << 8 | div << 16);
|
||||
for (i = 0; i < n; i++)
|
||||
bad += !slc_rev(s, &v, rb, 0, &x) || x != fw[n - 1u - i];
|
||||
bad += slc_rev(s, &v, rb, 0, &x) != 0; /* and then it ends */
|
||||
@@ -241,6 +244,76 @@ static int in_child(int (*fn)(const char *, const demo_t *), const char *dir, co
|
||||
return !WIFEXITED(st) || WEXITSTATUS(st);
|
||||
}
|
||||
|
||||
/* 8: track 1 on engine eng (preset 0, SRC / SET src, no sends, ADSR 0 / 127 / 127 / 10) plays note for 0.5 s, then
|
||||
* lets go: the steady part's pitch (rising zero crossings over 0.4 s), its peak, the largest step between samples
|
||||
* (a click: more than a sine of that peak and pitch can move), the voice gone 0.3 s after the note-off */
|
||||
static void voices_off(void) /* nothing sounding */
|
||||
{
|
||||
uint32_t i, k;
|
||||
for (k = 0; k < NTRK; k++)
|
||||
for (i = 0; i < NVOICE; i++)
|
||||
trk[k].v[i].active = 0;
|
||||
}
|
||||
typedef struct {
|
||||
double hz;
|
||||
uint32_t peak, step, ended, sine;
|
||||
} sine_run_t;
|
||||
static sine_run_t sine_run(uint32_t eng, int16_t src, uint32_t note)
|
||||
{
|
||||
static int32_t x[FS];
|
||||
track_t *t = &trk[0];
|
||||
voice_t *v;
|
||||
sine_run_t r = {0, 0, 0, 0, 0};
|
||||
uint32_t i, k, n = 0, up = 0, first = 0, last = 0;
|
||||
voices_off();
|
||||
host_tracks_init();
|
||||
host_preset(t, eng, 0);
|
||||
t->p[P_E0] = src;
|
||||
for (i = 0; i < 4u; i++)
|
||||
t->p[P_DIST + i] = 0;
|
||||
t->p[P_ATK] = 0;
|
||||
t->p[P_DEC] = 127;
|
||||
t->p[P_SUS] = 127;
|
||||
t->p[P_REL] = 10;
|
||||
trk_note_on(t, note, 100);
|
||||
v = voice_of(t, note);
|
||||
r.sine = v && (eng == SLC_ENG ? ((uint32_t)v->s[4] & 7u) == SLC_SINE : eng == 8u ? v->s[0] == GR_SINE : v->s[6] == 2);
|
||||
for (k = 0; k < FS / 2u / CTL; k++) {
|
||||
int32_t o[2 * CTL];
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < CTL; i++)
|
||||
x[n++] = o[2 * i];
|
||||
}
|
||||
trk_note_off(t, note);
|
||||
blocks(FS * 3u / 10u / CTL);
|
||||
r.ended = !(v && v->active);
|
||||
for (i = 1; i < n; i++) {
|
||||
uint32_t d = (uint32_t)abs(x[i] - x[i - 1u]), a = (uint32_t)abs(x[i]);
|
||||
r.step = d > r.step ? d : r.step;
|
||||
if (i >= n - FS * 2u / 5u) { /* the last 0.4 s held */
|
||||
r.peak = a > r.peak ? a : r.peak;
|
||||
if (x[i - 1u] < 0 && x[i] >= 0) {
|
||||
if (!up++)
|
||||
first = i;
|
||||
last = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
r.hz = up > 1u ? (double)(up - 1u) * FS / (double)(last - first) : 0.0;
|
||||
return r;
|
||||
}
|
||||
static int sine_ok(const char *what, sine_run_t r, double hz)
|
||||
{
|
||||
char m[120];
|
||||
/* a sine of peak A at f moves at most 2 pi f A / FS a sample (+ a margin for the fade-in ramp) */
|
||||
uint32_t lim = (uint32_t)(6.2832 * hz * r.peak / FS * 1.25) + 64u;
|
||||
int ok = r.sine && r.hz > hz * 0.99 && r.hz < hz * 1.01 && r.peak > 4000u && r.peak < 30000u && r.step <= lim && r.ended;
|
||||
snprintf(m, sizeof m, "%s plays a sine (%.0f Hz), ends after the note-off", what, hz);
|
||||
check(m, ok, "%s, %.1f Hz, peak %u, largest step %u of %u, %s", r.sine ? "sine" : "NOT the sine", r.hz, r.peak,
|
||||
r.step, lim, r.ended ? "ended" : "still sounding");
|
||||
return ok;
|
||||
}
|
||||
|
||||
static long load(const char *path, void *dst, long max)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
@@ -364,13 +437,13 @@ int main(int argc, char **argv)
|
||||
t->p[P_E1] = SLC_DIV_AUTO;
|
||||
trk_note_on(t, 72, 100); /* 12 mod 10 hits */
|
||||
ok &= (v = voice_of(t, 72)) && slice_of(v) == 12u % SLC_BREAK.nauto && v->ph[0] == SLC_BREAK.apos[12u % SLC_BREAK.nauto];
|
||||
t->p[P_E0] = 2; /* USR2: empty -> BREAK */
|
||||
t->p[P_E0] = 2; /* USR2: empty -> the sine */
|
||||
trk_note_on(t, 61, 100);
|
||||
ok &= (v = voice_of(t, 61)) && ((uint32_t)v->s[4] & 3u) == 0u && v->ph[0] == SLC_BREAK.apos[1];
|
||||
ok &= (v = voice_of(t, 61)) && ((uint32_t)v->s[4] & 7u) == SLC_SINE;
|
||||
t->p[P_E0] = 1; /* USR1 */
|
||||
trk_note_on(t, 63, 100);
|
||||
ok &= (v = voice_of(t, 63)) && ((uint32_t)v->s[4] & 3u) == 1u && v->ph[0] == slc_usr[0].apos[3];
|
||||
check("keys: AUTO count, an empty slot plays BREAK, USR1", ok, 0);
|
||||
ok &= (v = voice_of(t, 63)) && ((uint32_t)v->s[4] & 7u) == 1u && v->ph[0] == slc_usr[0].apos[3];
|
||||
check("keys: AUTO count, an empty slot plays the sine, USR1", ok, 0);
|
||||
ok = 1;
|
||||
song.octave = 0;
|
||||
t->p[P_E0] = 0;
|
||||
@@ -733,7 +806,7 @@ int main(int argc, char **argv)
|
||||
{"break_in_order.wav", 0, 120, 16, 2, SLICES, -1, -1},
|
||||
{"break_resequenced.wav", 0, 120, 32, 4, RESEQ, -1, -1},
|
||||
{"break_resequenced_32.wav", 0, 120, 32, 4, RESEQ, -1, 3},
|
||||
{"usr_empty_plays_break.wav", 0, 120, 16, 2, SLICES, 2, SLC_DIV_AUTO}, /* USR2 empty: BREAK, AUTO */
|
||||
{"usr_empty_plays_sine.wav", 0, 120, 16, 2, SLICES, 2, SLC_DIV_AUTO}, /* USR2 empty: a sine per key */
|
||||
{"usr_loop_auto_in_order.wav", 0, 96, 16, 2, SLICES, 1, SLC_DIV_AUTO},
|
||||
{"usr_loop_auto_resequenced.wav", 0, 96, 32, 4, USR, 1, SLC_DIV_AUTO},
|
||||
{"usr_loop_16_resequenced.wav", 0, 96, 32, 4, USR, 1, 2},
|
||||
@@ -743,6 +816,51 @@ int main(int argc, char **argv)
|
||||
df += in_child(demo, dir, &D[i]);
|
||||
check("demos rendered (peak above -24 dBFS, no clipping)", !df, "%s", dir);
|
||||
}
|
||||
|
||||
/* 8: PIANO (SRC 4), a missing sample's sine */
|
||||
#ifdef SLC_PIANO_NOTE
|
||||
check("PIANO: build-time table == decoder states", !(bad = table_check(&SLC_PIANO)), "%u of %u differ", bad,
|
||||
SLC_GRID + SLC_PIANO.nauto);
|
||||
for (i = 0; i < NELEM(SMP_ZONES) && !(SMP_ZONES[i].root16 == SLC_PIANO_NOTE * 16 &&
|
||||
SMP_ZONES[i].off == SLC_PIANO.seg[0].off); i++)
|
||||
;
|
||||
check("PIANO (SRC 4): the SAMPLE PIANO zone itself (no copy), one AUTO slice at 0",
|
||||
slc_get(SLC_SRC_PIANO) == &SLC_PIANO && i < NELEM(SMP_ZONES) && SLC_PIANO.nseg == 1u &&
|
||||
SLC_PIANO.len == SMP_ZONES[i].n && SLC_PIANO.seg[0].n == SLC_PIANO.len && SLC_PIANO.rate == SMP_ZONES[i].rate &&
|
||||
SLC_PIANO.nauto == 1u && SLC_PIANO.apos[0] == 0u && SLC_PIANO.ast[0] == 0u,
|
||||
"%u samples, %u AUTO", SLC_PIANO.len, SLC_PIANO.nauto);
|
||||
{ /* SRC 4 plays the zone from its start */
|
||||
track_t *t = &trk[0];
|
||||
voice_t *v;
|
||||
uint32_t ok;
|
||||
int32_t o[2 * CTL], pk = 0;
|
||||
voices_off();
|
||||
host_tracks_init();
|
||||
host_preset(t, SLC_ENG, 0);
|
||||
t->p[P_E0] = (int16_t)SLC_SRC_PIANO;
|
||||
t->p[P_E1] = SLC_DIV_AUTO;
|
||||
trk_note_on(t, 60, 100);
|
||||
v = voice_of(t, 60);
|
||||
ok = v && ((uint32_t)v->s[4] & 7u) == SLC_SRC_PIANO && v->ph[0] == 0u && v->ph[2] == SLC_PIANO.len;
|
||||
for (i = 0; i < 40u; i++) {
|
||||
mix_block(o, CTL);
|
||||
for (n = 0; n < (long)CTL; n++)
|
||||
pk = abs(o[2 * n]) > pk ? abs(o[2 * n]) : pk;
|
||||
}
|
||||
check("PIANO (SRC 4): a key plays the zone (AUTO: the whole note), sounding", ok && pk > 2000, "peak %d", pk);
|
||||
}
|
||||
#else
|
||||
check("PIANO (SRC 4): none in a build without the CC0 samples", !slc_get(SLC_SRC_PIANO), 0);
|
||||
#endif
|
||||
check("SRC: BREAK USR1 USR2 USR3 PIANO (append-only: 1.0.3's numbers kept)",
|
||||
ENG_SLICE.edit[0].max == 4 && str_eq(N_SLC_SRC[0], "BREAK") && str_eq(N_SLC_SRC[1], "USR1") &&
|
||||
str_eq(N_SLC_SRC[3], "USR3") && str_eq(N_SLC_SRC[4], "PIANO") && SLC_BREAK.len != 0u, 0);
|
||||
sine_ok("SLICE on an empty USR2: A4", sine_run(SLC_ENG, 2, 69), 440.0);
|
||||
sine_ok("SLICE on an empty USR2: A3", sine_run(SLC_ENG, 2, 57), 220.0);
|
||||
sine_ok("SAMPLE on an empty USR2: A4", sine_run(4u, (int16_t)(SMP_NSETS + 1), 69), 440.0);
|
||||
sine_ok("GRAIN on an empty USR3: C5", sine_run(8u, (int16_t)(SMP_NSETS + 2), 72), 523.25);
|
||||
check("SLICE on USR1 (a sample), SAMPLE on PIANO: not the sine", !sine_run(SLC_ENG, 1, 60).sine &&
|
||||
!sine_run(4u, 0, 60).sine, 0);
|
||||
printf("slice: %s\n", fails ? "FAILED" : "all checks ok");
|
||||
return fails != 0;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ FUNCS = ["analog_render", "digital_render", "digital_render_legacy", "digital_re
|
||||
"grain_render", "grain_block", "phys_render", "drum_render", "noise_render", "fm6_render", "fm6_op_run", "fm6_op_fb", "px_modal_block", "px_modal_run", "px_memb_block",
|
||||
"px_string_excite", "px_string_run", "px_symp_run",
|
||||
"dv_metal_run", "dv_kick_run", "dv_snare_run", "dv_clap_run", "dv_hat_run", "dv_tom_run", # drum_voice.c
|
||||
"dv_rim_run", "dv_bell_run", "dv_cym_run", "dv_out",
|
||||
"dv_rim_run", "dv_bell_run", "dv_cym_run", "dv_out", "dv_metal_mix",
|
||||
"slicer_track",
|
||||
"slice_render", "slc_rev", # SLICE (eng_slice.c): the render, the reverse windows
|
||||
"fm1_alnk0_irq", "fm1_timer5_irq", # the audio ISR; TIMER5: the key / LED scan (hal/fm1_input.h)
|
||||
|
||||
@@ -34,6 +34,7 @@ dv_rim_run 61
|
||||
dv_bell_run 52
|
||||
dv_cym_run 67
|
||||
dv_out 35
|
||||
dv_metal_mix 16
|
||||
slicer_track 632
|
||||
slice_render 453
|
||||
slc_rev 120
|
||||
|
||||
+7
-4
@@ -611,7 +611,7 @@ static void eng(uint32_t e) { set_engine_of(TSEL, e); }
|
||||
* OP LEVEL pages and the algorithm charts, exist only there: fm4_screen) */
|
||||
#define E_FM (FELUCCA_FM4 ? ENGI_DIGITAL : ENGI_FM6)
|
||||
|
||||
enum { S_HOME, S_HOME_IDLE, S_MESSAGE, S_MESSAGE_KEY, S_PRESETS, S_PRESETS_NOFAV, S_USER, S_PHRASES, S_PROJECT, S_TOOLS,
|
||||
enum { S_HOME, S_HOME_IDLE, S_MESSAGE, S_MESSAGE_KEY, S_MESSAGE_NOFILE, S_PRESETS, S_PRESETS_NOFAV, S_USER, S_PHRASES, S_PROJECT, S_TOOLS,
|
||||
S_SONG_EMPTY, S_SONG, S_STEP, S_PATTERN, S_CHANCE, S_MOTION, S_DRUM, S_DRUM_HAND, S_DRUM_CYM, S_MIXER, S_MIXER_PAN,
|
||||
S_ENV, S_ENVDEST, S_LFO, S_MOD, S_FX, S_SLICER, S_DLY, S_SCL, S_CHORD, S_CHORD_WIDE, S_CHORD_OFF, S_CHORD_KIT, S_ARP, S_VOICE, S_GLOBAL, S_SYSTEM,
|
||||
S_EDIT_ANALOG, S_EDIT_DIGITAL, S_OP_ENV, S_EDIT_WHEEL, S_EDIT_SAMPLE, S_EDIT_GRAIN, S_EDIT_PHYS,
|
||||
@@ -623,10 +623,10 @@ enum { S_HOME, S_HOME_IDLE, S_MESSAGE, S_MESSAGE_KEY, S_PRESETS, S_PRESETS_NOFAV
|
||||
S_FX_PEEK, S_FX_HELD, S_FX_WAIT, S_FX_HARM, S_MENU_HOLD, S_MENU_LEDS, S_MENU_END, S_REVERB,
|
||||
S_GLO_PEEK, S_GLO_ACTIVE, S_GLO_EXT, S_SCL_PEEK, S_SCL_ACTIVE, S_EDIT_PEEK, S_EDIT_ACTIVE, S_EDIT_USER, S_LAYER_HINT, S_LAYER_LOCK, S_LAYER_LOCK_FX,
|
||||
S_NAME_USER, S_NAME_TYPING, S_NAME_123, S_NAME_EMPTY, S_NAME_FULL, S_NAME_PLAYING, S_PROJECT_NAMED, S_SONG_NAMED,
|
||||
S_USER_FOOT, S_SLICES_BREAK, S_SLICES_USR,
|
||||
S_USER_FOOT, S_SLICES_BREAK, S_SLICES_USR, S_SLICES_NOFILE,
|
||||
S_ROLL_EMPTY, S_ROLL_ACID, S_ROLL_CHORDS, S_ROLL_TIES, S_ROLL_LEN32, S_ROLL_HIGH, S_ROLL_LOW, S_ROLL_WIDE, S_ROLL_PLAYING,
|
||||
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", "presets", "presets_nofav", "user",
|
||||
static const char *const S_NAME[S_COUNT] = {"home", "home_idle", "message", "message_key", "message_nofile", "presets", "presets_nofav", "user",
|
||||
"phrases", "project", "tools", "song_empty", "song", "step", "pattern", "chance", "motion", "drum",
|
||||
"drum_hand", "drum_cym", "mixer", "mixer_pan", "env", "env_dest", "lfo", "mod", "fx", "slicer", "dly", "scl", "chord", "chord_wide", "chord_off", "chord_kit", "arp",
|
||||
"voice", "global", "system", "edit_analog", FELUCCA_FM4 ? "edit_digital" : "edit_fm6", "op_env", "edit_wheel", "edit_sample",
|
||||
@@ -637,7 +637,7 @@ static const char *const S_NAME[S_COUNT] = {"home", "home_idle", "message", "mes
|
||||
"layer_glo_peek", "layer_glo_active", "layer_glo_ext", "layer_scl_peek", "layer_scl_active", "layer_edit_peek",
|
||||
"layer_edit_active", "layer_edit_user", "layer_hint", "layer_lock", "layer_lock_fx",
|
||||
"name_user", "name_typing", "name_123", "name_empty", "name_full", "name_playing", "project_named", "song_named",
|
||||
"user_foot", "slices_break", "slices_usr",
|
||||
"user_foot", "slices_break", "slices_usr", "slices_nofile",
|
||||
"roll_empty", "roll_acid", "roll_chords", "roll_ties", "roll_len32_p2", "roll_high", "roll_low", "roll_wide", "roll_playing",
|
||||
"mock_home", "mock_presets", "mock_seq", "mock_drum", "mock_mixer", "mock_dialog", "mock_menu"};
|
||||
|
||||
@@ -797,6 +797,8 @@ static void setup(int s)
|
||||
case S_HOME_IDLE: song.playing = 0; song.batt_raw = 570; ui.hot_col = 1; ui.hot_t = 30; break;
|
||||
case S_MESSAGE: ui_say("LOADED ", "07 A VERY LONG PATTERN NAME"); break;
|
||||
case S_MESSAGE_KEY: ui_message("[SAVE] HOLD TO UNDO"); break; /* a message with a keycap */
|
||||
case S_MESSAGE_NOFILE: /* a missing sample (ui_input.c sample_notice): USR2 */
|
||||
eng(ENGI_SAMPLE); TSEL->p[P_E0] = (int16_t)(SMP_NSETS + 1); memset(snd_said, 0, sizeof snd_said); sample_notice(); break;
|
||||
case S_PRESETS: favorite_set(0, 4, 1); favorite_set(0, 5, 1); go_page(GR_BROWSE); break;
|
||||
case S_PRESETS_NOFAV: favorites.filter = 1; go_page(GR_BROWSE); break;
|
||||
case S_USER: song.playing = 0; up_store(3, "MY LONG BASS NAME"); up_store(4, "PAD"); ui.uslot = 3; go_page(GR_USER); break;
|
||||
@@ -999,6 +1001,7 @@ static void setup(int s)
|
||||
go_page(GR_SLICES); sp.sel = 0; slice_knob(0, 2); slice_knob(1, 6); ui.act = 3; ui.msg_t = 0;
|
||||
ui.hot_col = 1; ui.hot_t = 30;
|
||||
break;
|
||||
case S_SLICES_NOFILE: eng(13u); TSEL->p[P_E0] = 2; go_page(GR_SLICES); ui.msg_t = 0; break; /* USR2 empty: SAMPLE NOT FOUND */
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
|
||||
+390
-8
@@ -94,6 +94,7 @@ static struct { uint32_t stage; } felucca_dbg;
|
||||
#include "../firmware/src/gfx.c"
|
||||
#include "../firmware/src/panel.c"
|
||||
#include "../firmware/src/ui.c"
|
||||
#include "../firmware/src/menu_items.c"
|
||||
#include "../firmware/src/icons.c"
|
||||
#include "../firmware/src/ui_graph.c"
|
||||
#include "../firmware/src/ui_draw.c"
|
||||
@@ -171,6 +172,7 @@ static void ui_power_on(void)
|
||||
memset(&motion, 0, sizeof motion); /* (main.c: no motion at power-on) */
|
||||
memset(motion_active, 0, sizeof motion_active);
|
||||
motion_base_valid = motion_full = 0;
|
||||
memset(snd_said, 0, sizeof snd_said); /* (.bss at power-on: nothing said yet) */
|
||||
}
|
||||
/* card slot drawn with MOTION's mark (ui_draw.c card_mot: its icon, or a long label in the theme colour) */
|
||||
static int card_motion(uint32_t slot) { return (card_mot >> slot) & 1u; }
|
||||
@@ -579,7 +581,14 @@ static int test_rec(void)
|
||||
press(B_REC);
|
||||
bad += check("REC again disarms (the transport runs on)", song.rec == 0u && transport_req == 0u);
|
||||
hold(B_REC);
|
||||
bad += check("REC held remains record transport and never clears a pattern", ui.confirm == CF_NONE && song.rec == 4u);
|
||||
if (k == 1u) /* #91: on SEQ a hold asks to clear; the arming stays */
|
||||
bad += check("#91 REC held on SEQ > STEP: CLEAR T3 SEQUENCE? (or NOTHING TO CLEAR), not armed",
|
||||
song.rec == 0u && (seq_is_empty(&trk[2]) ? msg_is("NOTHING TO CLEAR") && !ui.confirm :
|
||||
ui.confirm == CF_CLEAR_SEQ && ui.confirm_trk == 2u));
|
||||
else
|
||||
bad += check("REC held elsewhere remains record transport and never clears a pattern",
|
||||
ui.confirm == CF_NONE && song.rec == 4u);
|
||||
ui.confirm = 0;
|
||||
}
|
||||
ui_power_on();
|
||||
press(B_REC);
|
||||
@@ -943,7 +952,11 @@ static int test_tracks(void)
|
||||
open_family(FAM_TRK);
|
||||
before = trk[0];
|
||||
turn(EN_PRESET, 1);
|
||||
bad += check("TRACKS: the PRESETS knob does nothing", trk[0].preset == before.preset && !memcmp(trk[0].p, before.p, sizeof before.p));
|
||||
bad += check("#94 MIXER: the PRESETS knob loads the next sound; the steps and the mix stay",
|
||||
trk[0].preset != before.preset && !memcmp(trk[0].step, before.step, sizeof before.step) &&
|
||||
trk[0].p[P_LEVEL] == before.p[P_LEVEL] && cur_page()->graph == GR_TRK);
|
||||
hold(B_SAVE);
|
||||
bad += check("#94 MIXER: SAVE held undoes it", trk[0].preset == before.preset && !memcmp(trk[0].p, before.p, sizeof before.p));
|
||||
turn(EN_K4, 1);
|
||||
bad += check("MIXER KNOB 4 right: MUTE ON (the selected track stays)", trk[0].p[P_MUTE] == 1 && song.sel == 0);
|
||||
turn(EN_K1, -3);
|
||||
@@ -1843,6 +1856,155 @@ static int test_chain(void)
|
||||
|
||||
/* Product controls are exercised through the actual button/encoder handlers
|
||||
* and canvas, including all pages, both fonts and every shipped palette. */
|
||||
/* Discussion #91: REC held 0.7 s on SEQ > STEP / PATTERN / CHANCE / the DRUM grid asks "CLEAR Tn SEQUENCE?" (TOOLS'
|
||||
* dialog): OCT+ clears, OCT- cancels, SAVE held undoes the clear; the arming never changes on a hold (REC acts
|
||||
* when let go: a tap); a tap there arms as before; elsewhere (HOME, PHRASES, SONG, AUTOMATION, ENV) a hold is a tap;
|
||||
* an empty pattern says NOTHING TO CLEAR; a song playing STOP TO EDIT */
|
||||
static int test_rec_hold_clear(void)
|
||||
{
|
||||
static const uint8_t SEQ_G[3] = {GR_ROLL, GR_STEPS, GR_CHANCE};
|
||||
static const uint8_t ELSE_G[4] = {GR_PATS, GR_SONG, GR_MOTION, GR_ADSR};
|
||||
int bad = 0, ok = 1;
|
||||
uint32_t k;
|
||||
step_t before[NSTEP];
|
||||
for (k = 0; k < 3u; k++) {
|
||||
ui_power_on();
|
||||
song.sel = 1;
|
||||
my_steps(&trk[1]);
|
||||
go_page(SEQ_G[k]);
|
||||
frame();
|
||||
hold(B_REC);
|
||||
ok &= ui.confirm == CF_CLEAR_SEQ && ui.confirm_trk == 1u && song.rec == 0u && !transport_req;
|
||||
}
|
||||
bad += check("#91 REC held on STEP, PATTERN, CHANCE: CLEAR T2 SEQUENCE?, nothing armed or started", ok);
|
||||
memcpy(before, trk[1].step, sizeof before);
|
||||
press(B_OCTDN);
|
||||
bad += check("#91 OCT- cancels: the steps stay", !ui.confirm && !memcmp(trk[1].step, before, sizeof before));
|
||||
hold(B_REC);
|
||||
press(B_OCTUP);
|
||||
bad += check("#91 OCT+ clears the pattern", !ui.confirm && seq_is_empty(&trk[1]) && msg_is("PATTERN CLEARED") &&
|
||||
song.rec == 0u);
|
||||
hold(B_SAVE);
|
||||
bad += check("#91 SAVE held undoes the clear", !memcmp(trk[1].step, before, sizeof before));
|
||||
ui_power_on();
|
||||
song.sel = 0;
|
||||
track_defaults_steps(&trk[0]);
|
||||
go_page(GR_ROLL);
|
||||
frame();
|
||||
hold(B_REC);
|
||||
bad += check("#91 an empty pattern: NOTHING TO CLEAR, no dialog, not armed",
|
||||
!ui.confirm && msg_is("NOTHING TO CLEAR") && song.rec == 0u);
|
||||
my_steps(&trk[0]);
|
||||
press(B_REC);
|
||||
bad += check("#91 a REC tap on STEP still arms (PLAY starts)", song.rec == 1u && transport_req == 1u && !ui.confirm);
|
||||
song.playing = 1;
|
||||
transport_req = 0;
|
||||
hold(B_REC);
|
||||
bad += check("#91 armed and playing: a hold asks, the arming and the transport stay",
|
||||
ui.confirm == CF_CLEAR_SEQ && song.rec == 1u && song.playing);
|
||||
press(B_OCTDN);
|
||||
press(B_REC);
|
||||
bad += check("#91 a tap after it disarms as before", song.rec == 0u && !ui.confirm);
|
||||
song.playing = 0;
|
||||
ui_power_on();
|
||||
set_engine_of(TSEL, ENGI_DRUM);
|
||||
TSEL->engine = TSEL->eng_req;
|
||||
TSEL->step[2] = (step_t){.hit = 1u << DV_KICK, .time = ST_NOTE};
|
||||
go_page(GR_ROLL);
|
||||
frame();
|
||||
ok = grid_on();
|
||||
hold(B_REC);
|
||||
bad += check("#91 the DRUM grid: REC held asks too", ok && ui.confirm == CF_CLEAR_SEQ && song.rec == 0u);
|
||||
press(B_OCTUP);
|
||||
bad += check("#91 OCT+ clears its hits", seq_is_empty(TSEL));
|
||||
ok = 1;
|
||||
for (k = 0; k < 5u; k++) {
|
||||
ui_power_on();
|
||||
my_steps(TSEL);
|
||||
if (k < 4u)
|
||||
go_page(ELSE_G[k]);
|
||||
frame();
|
||||
hold(B_REC);
|
||||
ok &= !ui.confirm && !seq_is_empty(TSEL) &&
|
||||
(ELSE_G[k % 4u] == GR_SONG && k < 4u ? song.rec == 0u : song.rec == 1u);
|
||||
}
|
||||
bad += check("#91 elsewhere (PHRASES, SONG, AUTOMATION, ENV, HOME) a REC hold is a tap, as before; no clear", ok);
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* Discussions #92 / #94: the PRESETS knob on every page. SEQ's step pages (STEP, the DRUM grid, PATTERN, CHANCE,
|
||||
* AUTOMATION): the step cursor, the sound and the steps untouched; USER, PROJECT, PHRASES, SONG: the selection, as KNOB
|
||||
* 1; TOOLS: nothing; HOME, PRESETS and every other page: the next sound, the steps untouched, SAVE held undoes it */
|
||||
static int test_presets_knob(void)
|
||||
{
|
||||
int bad = 0, cur_ok = 1, sel_ok = 1, snd_ok = 1, undo_ok = 1, tools_ok = 1, grid_ok;
|
||||
uint32_t i, n_snd = 0, n_cur = 0;
|
||||
for (i = 0; i < NPAGES; i++) {
|
||||
track_t before;
|
||||
uint32_t g = PAGES[i].graph, uslot, ppick;
|
||||
int16_t slot;
|
||||
ui_power_on();
|
||||
song.sel = 0;
|
||||
my_steps(TSEL);
|
||||
ui.home = 0; ui.page = (uint8_t)i; page_entered();
|
||||
if (!page_visible(i))
|
||||
continue;
|
||||
frame();
|
||||
before = *TSEL;
|
||||
uslot = ui.uslot; ppick = pat_pick(); slot = song.g[G_SLOT];
|
||||
turn(EN_PRESET, 1);
|
||||
{
|
||||
int same_snd = TSEL->preset == before.preset && TSEL->eng_req == before.eng_req &&
|
||||
!memcmp(TSEL->p, before.p, sizeof before.p);
|
||||
int same_steps = !memcmp(TSEL->step, before.step, sizeof before.step);
|
||||
if (PAGES[i].fam == FAM_SEQ && (g == GR_ROLL || g == GR_STEPS || g == GR_CHANCE || g == GR_MOTION)) {
|
||||
cur_ok &= ui.cursor == 1u && same_snd && same_steps && ui.page == i;
|
||||
n_cur++;
|
||||
} else if (g == GR_USER) {
|
||||
sel_ok &= ui.uslot == uslot + 1u && same_snd && same_steps;
|
||||
} else if (g == GR_SLOTS) {
|
||||
sel_ok &= song.g[G_SLOT] == slot + 1 && same_snd && same_steps;
|
||||
} else if (g == GR_PATS) {
|
||||
sel_ok &= pat_pick() == ppick + 1u && same_snd && same_steps;
|
||||
} else if (g == GR_SONG) {
|
||||
sel_ok &= same_snd && same_steps && ui.page == i;
|
||||
} else if (g == GR_TOOLS) {
|
||||
tools_ok &= same_snd && same_steps && !ui.confirm;
|
||||
} else {
|
||||
snd_ok &= !same_snd && same_steps && ui.page == i && !ui.home;
|
||||
hold(B_SAVE);
|
||||
undo_ok &= TSEL->preset == before.preset && TSEL->eng_req == before.eng_req &&
|
||||
!memcmp(TSEL->p, before.p, sizeof before.p) && !memcmp(TSEL->step, before.step, sizeof before.step);
|
||||
n_snd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
bad += check("#92 PRESETS on STEP, PATTERN, CHANCE, AUTOMATION: the step cursor; the sound and the steps stay",
|
||||
cur_ok && n_cur == 4u);
|
||||
bad += check("#94 PRESETS on USER, PROJECT, PHRASES, SONG: the selection (KNOB 1's); nothing loaded", sel_ok);
|
||||
bad += check("#94 PRESETS on TOOLS does nothing", tools_ok);
|
||||
bad += check("#94 PRESETS elsewhere (EDIT, ENV, LFO, FX, SCL, ARP, MIXER, GLOBAL, ...): the next sound, the steps stay",
|
||||
snd_ok && n_snd >= 15u);
|
||||
bad += check("#94 SAVE held undoes each of those loads", undo_ok);
|
||||
ui_power_on();
|
||||
set_engine_of(TSEL, ENGI_DRUM);
|
||||
TSEL->engine = TSEL->eng_req;
|
||||
TSEL->p[P_SLEN] = 32;
|
||||
go_page(GR_ROLL);
|
||||
frame();
|
||||
turn(EN_PRESET, 17);
|
||||
grid_ok = grid_on() && ui.cursor == 17u && ui.bank == 1u && TSEL->eng_req == ENGI_DRUM;
|
||||
turn(EN_PRESET, -18);
|
||||
grid_ok &= ui.cursor == 31u;
|
||||
bad += check("#92 the DRUM grid: PRESETS moves the cursor (and the page), as KNOB 1; wraps", grid_ok);
|
||||
ui_power_on();
|
||||
hold(B_HOME);
|
||||
i = ui.menu_sel;
|
||||
turn(EN_PRESET, 1);
|
||||
bad += check("#94 the menu: PRESETS still moves the selection", ui.menu == 1 && ui.menu_sel == i + 1u);
|
||||
return bad;
|
||||
}
|
||||
|
||||
static int test_product_ux(void)
|
||||
{
|
||||
int bad = 0, ok = 1;
|
||||
@@ -1909,13 +2071,22 @@ static int test_product_ux(void)
|
||||
press(B_PLAY); events_block(32);
|
||||
bad += check("stopping returns the original sound after a recorded knob gesture", TSEL->p[P_E0] == baseline);
|
||||
go_page(GR_MOTION); turn(EN_K1, -1);
|
||||
bad += check("#93 the page is AUTOMATION (GR_MOTION inside)", str_eq(cur_page()->title, "AUTOMATION"));
|
||||
bad += check("MOTION playback OFF preserves its stored events", !motion_enabled(TSEL) && motion_count(TSEL) == 1);
|
||||
turn(EN_K4, 1); press(B_OCTUP);
|
||||
bad += check("MOTION clear always asks confirmation", ui.confirm == CF_CLEAR_MOTION && motion_count(TSEL) == 1);
|
||||
{
|
||||
char qa[24], qb[24];
|
||||
confirm_text(qa, qb);
|
||||
bad += check("#93 the dialog asks CLEAR T1 AUTOMATION?", str_eq(qa, "CLEAR T1 AUTOMATION?"));
|
||||
}
|
||||
press(B_OCTDN); turn(EN_K4, 1); press(B_OCTUP); press(B_OCTUP);
|
||||
bad += check("confirmed MOTION clear removes events and SAVE hold restores them", motion_count(TSEL) == 0);
|
||||
bad += check("confirmed MOTION clear removes events and SAVE hold restores them", motion_count(TSEL) == 0 &&
|
||||
msg_is("AUTOMATION CLEARED"));
|
||||
hold(B_SAVE);
|
||||
bad += check("motion-clear UNDO restores the recorded events", motion_count(TSEL) == 1);
|
||||
motion_full = 1; frame();
|
||||
bad += check("#93 the events used up: AUTOMATION FULL", msg_is("AUTOMATION FULL") && !motion_full);
|
||||
{ /* #63: a card shows MOTION's icon while the track's motion changes its parameter */
|
||||
uint32_t id = ENGINES[TSEL->eng_req]->knob[0];
|
||||
ui_power_on(); go_home(); frame();
|
||||
@@ -2082,9 +2253,20 @@ static int test_layer(void)
|
||||
press(B_OCTUP); ok &= settings_leds == LEDS_OFF && ui.menu == 1u;
|
||||
ok &= !strcmp(LEDS_NAME[LEDS_OFF], "OFF") && !strcmp(LEDS_NAME[LEDS_DIM_LO], "DIM LO") &&
|
||||
!strcmp(LEDS_NAME[LEDS_DIM], "DIM HI") && !strcmp(LEDS_NAME[LEDS_INV], "INV");
|
||||
{ /* a setting changed from elsewhere (the editor's MENU_SET: menu_put) while the MENU is shown: redrawn */
|
||||
static uint16_t before[240 * 240];
|
||||
frame();
|
||||
memcpy(before, host_screen, sizeof before);
|
||||
menu_put(MI_LEDS, 3); /* (OFF -> INV, the row shown) */
|
||||
frame();
|
||||
ok &= settings_leds == LEDS_INV && memcmp(before, host_screen, sizeof before) && menu_get(MI_LEDS) == 3u;
|
||||
menu_put(MI_LEDS, 0);
|
||||
frame();
|
||||
ok &= !memcmp(before, host_screen, sizeof before);
|
||||
}
|
||||
hold(B_HOME);
|
||||
bad += check("menu LEDS: DIM HI by default; KNOB 1 OFF < DIM LO < DIM HI < INV (stops at the ends), OCT+ cycles",
|
||||
ok && !ui.menu);
|
||||
bad += check("menu LEDS: DIM HI by default; KNOB 1 OFF < DIM LO < DIM HI < INV (stops at the ends), OCT+ cycles; "
|
||||
"a change from the editor redraws the shown MENU", ok && !ui.menu);
|
||||
{
|
||||
persist_t p = {0};
|
||||
uint32_t m;
|
||||
@@ -2542,6 +2724,80 @@ static int test_edit_cycle(void)
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* a missing sample (an empty user slot; a set this build lacks): it plays a sine (eng_sample.c smp_sine) and the UI
|
||||
* says NO SAMPLE, led by the no-file icon (ui.c MSG_NO_SAMPLE), once per track and source (ui_input.c
|
||||
* sample_notice): when it is chosen, not on its notes; again for another source; after a project load (behind
|
||||
* LOADED); the icon and the words fit the header */
|
||||
static int test_sample_alert(void)
|
||||
{
|
||||
const char *nf = MSG_NO_SAMPLE;
|
||||
int bad = 0, ok, seen;
|
||||
uint32_t i;
|
||||
char b[48];
|
||||
ui_power_on();
|
||||
frames(100);
|
||||
bad += check("missing sample: the power-on sounds have their samples (no alert)", !snd_missing(&trk[0], &i) &&
|
||||
!snd_missing(&trk[1], &i) && !snd_missing(&trk[2], &i) && !snd_missing(&trk[3], &i) &&
|
||||
!str_eq(ui.msg, nf));
|
||||
set_engine_of(TSEL, ENGI_SAMPLE);
|
||||
TSEL->p[P_E0] = (int16_t)(SMP_NSETS + 1u); /* SET USR2: empty */
|
||||
frame();
|
||||
ok = msg_is(nf);
|
||||
frames(1500);
|
||||
trk_note_on(TSEL, 60, 100);
|
||||
frames(100);
|
||||
trk_note_off(TSEL, 60);
|
||||
frames(100);
|
||||
ok &= !ui.msg_t;
|
||||
bad += check("SAMPLE on an empty USR2: NO SAMPLE once (not again on a note)", ok);
|
||||
TSEL->p[P_E0] = (int16_t)(SMP_NSETS + 2u); /* USR3: said for it */
|
||||
frame();
|
||||
ok = msg_is(nf);
|
||||
TSEL->p[P_E0] = 0; /* PIANO: nothing; then USR3 again: said again */
|
||||
frames(1500);
|
||||
ok &= !ui.msg_t;
|
||||
TSEL->p[P_E0] = (int16_t)(SMP_NSETS + 2u);
|
||||
frame();
|
||||
ok &= msg_is(nf);
|
||||
bad += check("SAMPLE: another empty slot is said; back to it after a sample: said again", ok);
|
||||
frames(1500);
|
||||
set_engine_of(TSEL, 8u); /* GRAIN, SRC USR2 */
|
||||
TSEL->p[P_E0] = (int16_t)(SMP_NSETS + 1u);
|
||||
frame();
|
||||
bad += check("GRAIN on an empty USR2: said", msg_is(nf));
|
||||
frames(1500);
|
||||
#if FELUCCA_SLICE
|
||||
set_engine_of(TSEL, 13u); /* SLICE, SRC USR3 */
|
||||
TSEL->p[P_E0] = 3;
|
||||
frame();
|
||||
ok = msg_is(nf);
|
||||
frames(1500);
|
||||
TSEL->p[P_E0] = 4; /* PIANO: there (the CC0 build) */
|
||||
frame();
|
||||
ok &= !ui.msg_t && !snd_missing(TSEL, &i) == (SLC_PIANO.len != 0u);
|
||||
bad += check("SLICE on an empty USR3: said; PIANO: not (it has its sample)", ok);
|
||||
frames(1500);
|
||||
#endif
|
||||
/* a project with an empty slot: said after LOADED */
|
||||
set_engine_of(TSEL, ENGI_SAMPLE);
|
||||
TSEL->p[P_E0] = (int16_t)(SMP_NSETS + 1u);
|
||||
frames(1500);
|
||||
project_save(2);
|
||||
frames(1500);
|
||||
project_load(2);
|
||||
frame();
|
||||
ok = msg_is("LOADED") && str_eq(ui.msg2, nf);
|
||||
for (seen = 0, i = 0; i < 200u && !seen; i++) {
|
||||
frame();
|
||||
seen = msg_is(nf);
|
||||
}
|
||||
bad += check("a project load with an empty slot: LOADED, then NO SAMPLE", ok && seen);
|
||||
bad += check("missing sample: the icon and NO SAMPLE fit the header",
|
||||
nf[0] == MSG_NOFILE[0] && !text_fit(b, sizeof b, nf + 1, &AF_S, 236 - 106 - 16 - KH_GAP));
|
||||
ui_power_on();
|
||||
return bad;
|
||||
}
|
||||
|
||||
#if FELUCCA_SLICE
|
||||
/* SLICES (EDIT family, a SLICE track: ui_slice.c; the MAN slices of eng_slice.c, ported from hugelton/Felucca#27 by
|
||||
* andreahaku): in the EDIT cycle after EDIT 2 on SLICE only; BREAK shows its slices, edits need a user slot; the first
|
||||
@@ -2583,12 +2839,20 @@ static int test_slices(void)
|
||||
turn(EN_K1, 2); turn(EN_K2, 3);
|
||||
ok = n == 16u && slice_sel() == 2u && TSEL->p[P_E1] == p0 && msg_is("SRC USR1-3 TO EDIT") && !slice_act_ready(2);
|
||||
bad += check("SLICES on BREAK: its 16 slices shown, KNOB 1 picks; edits need USR1-3 (DIV unchanged)", ok);
|
||||
TSEL->p[P_E0] = 2; /* SRC USR2, empty: BREAK's slices, the slot named */
|
||||
TSEL->p[P_E0] = 2; /* SRC USR2, empty: no slices (a sine plays): NO SAMPLE */
|
||||
frame();
|
||||
ok = slice_count() == 0u && (msg_is(MSG_NO_SAMPLE) || str_eq(ui.msg2, MSG_NO_SAMPLE));
|
||||
turn(EN_K2, 1);
|
||||
ok &= TSEL->p[P_E1] == p0 && msg_is("USR2 EMPTY");
|
||||
TSEL->p[P_E0] = 0;
|
||||
bad += check("SLICES on an empty USR2: NO SAMPLE, no slices; edits: \"USR2 EMPTY\"", ok);
|
||||
TSEL->p[P_E0] = 4; /* SRC PIANO: its 16 slices shown, no edits */
|
||||
frame();
|
||||
turn(EN_K2, 1);
|
||||
ok = slice_count() == 16u && TSEL->p[P_E1] == p0 && msg_is("USR2 EMPTY");
|
||||
ok = slice_count() == 16u && TSEL->p[P_E1] == p0 && msg_is("SRC USR1-3 TO EDIT");
|
||||
TSEL->p[P_E0] = 0;
|
||||
bad += check("SLICES on an empty USR2: \"USR2 EMPTY\" (DIV unchanged)", ok);
|
||||
frame();
|
||||
bad += check("SLICES on PIANO: its 16 slices shown; edits need USR1-3 (DIV unchanged)", ok);
|
||||
|
||||
host_slot_make(0);
|
||||
smp_user_scan(0);
|
||||
@@ -3726,6 +3990,68 @@ static int test_play_leds(void)
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* Discussion #89: on SEQ > STEP (the piano roll) while stopped the keys of the cursor step's notes light, at the
|
||||
* octave now (the lowest key that gives each); with the keys held; playing, what plays instead (#38); not on
|
||||
* other pages, not for a REST step; the DRUM grid keeps its own map */
|
||||
static int test_cursor_step_leds(void)
|
||||
{
|
||||
int bad = 0, ok;
|
||||
track_t *t;
|
||||
ui_power_on();
|
||||
song.sel = 0;
|
||||
t = TSEL;
|
||||
t->step[0] = (step_t){.note = {60, 64}, .n = 2, .time = ST_NOTE};
|
||||
t->step[1] = (step_t){.note = {100}, .n = 1, .time = ST_NOTE};
|
||||
t->step[2] = (step_t){.note = {62}, .n = 1, .time = ST_REST};
|
||||
t->step[3] = (step_t){.note = {67}, .n = 1, .time = ST_TIE};
|
||||
t->seq_active = 1;
|
||||
bad += check("#89 HOME, stopped: no step's keys lit", key_leds() == 0u);
|
||||
go_page(GR_ROLL);
|
||||
frame();
|
||||
bad += check("#89 STEP, stopped: the cursor step's C4 and E4 light keys 8 and 12",
|
||||
ui.cursor == 0u && key_leds() == (1u << 7 | 1u << 11));
|
||||
song.octave = -1;
|
||||
ok = key_leds() == (1u << 19 | 1u << 23);
|
||||
song.octave = 1;
|
||||
ok &= key_leds() == 0u; /* (below the keys an octave up) */
|
||||
song.octave = 0;
|
||||
bad += check("#89 the step's keys follow the octave; notes off the keyboard are not shown", ok);
|
||||
fm1_in.notes = 1u << 0;
|
||||
bad += check("#89 a key held lights with them", key_leds() == (1u << 0 | 1u << 7 | 1u << 11));
|
||||
fm1_in.notes = 0;
|
||||
turn(EN_K1, 1);
|
||||
ok = ui.cursor == 1u && key_leds() == 0u; /* G#7: off the keyboard */
|
||||
turn(EN_K1, 1);
|
||||
ok &= ui.cursor == 2u && key_leds() == 0u; /* a REST */
|
||||
turn(EN_K1, 1);
|
||||
ok &= ui.cursor == 3u && key_leds() == 1u << 14; /* a TIE carries its G4 */
|
||||
turn(EN_K1, 1);
|
||||
ok &= ui.cursor == 4u && key_leds() == 0u; /* empty */
|
||||
bad += check("#89 KNOB 1 moves the cursor and the keys follow its step (REST, empty, off the keys: dark)", ok);
|
||||
turn(EN_K1, -4);
|
||||
seq_start();
|
||||
events_block(CTL);
|
||||
bad += check("#89 playing: the keys show what plays, not the cursor step", song.playing && ui.cursor == 0u &&
|
||||
key_leds() == play_leds());
|
||||
turn(EN_K1, 3);
|
||||
bad += check("#89 (the cursor on G4's step changes nothing while playing)", key_leds() == play_leds() &&
|
||||
!((key_leds() >> 14) & 1u));
|
||||
transport_req = 2;
|
||||
events_block(CTL);
|
||||
frame();
|
||||
bad += check("#89 stopped again: the cursor step's keys", !song.playing && key_leds() == 1u << 14);
|
||||
go_page(GR_CHANCE);
|
||||
frame();
|
||||
bad += check("#89 CHANCE (same cursor): no step keys", key_leds() == 0u);
|
||||
set_engine_of(t, ENGI_DRUM);
|
||||
t->engine = t->eng_req;
|
||||
t->step[0] = (step_t){.hit = 1u << DV_KICK, .time = ST_NOTE};
|
||||
go_page(GR_ROLL);
|
||||
frame();
|
||||
bad += check("#89 the DRUM grid keeps its map", grid_on() && key_leds() == grid_leds());
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* Discussion #81: the notes MIDI IN holds on the selected track light their keys as the sequencer's do: USB and TRS,
|
||||
* routed by ROUT; at the octave now, the lowest key; off the keyboard nothing; the pedal holds them; the layer's map
|
||||
* and the DRUM grid keep their keys */
|
||||
@@ -4472,6 +4798,58 @@ static int test_fx_latch(void)
|
||||
ok &= !perf_latched && !perf_k[0] && !perf_k[1] && song.octave == 0 && msg_is("FX ALL OFF");
|
||||
btn_up(B_FX); frame();
|
||||
bad += check(" FX + OCT-: every latched effect and macro off (no octave)", ok);
|
||||
/* the quick combo: FX down and OCT- before HOLD, nothing else touched (it was nobody's: no ALL OFF, no octave) */
|
||||
btn_down(B_FX); key_down(lpf); frame(); key_up(lpf); frame(); turn(EN_K2, 20); btn_up(B_FX); frame();
|
||||
frames(400);
|
||||
ok = perf_latched == PF_BIT(PF_LPF) && perf_k[1] == 20 && !ui.layer;
|
||||
btn_down(B_FX); frame(); btn_down(B_OCTDN); frame();
|
||||
ok &= ui.layer == LAYER_FX && song.octave == 0; /* (a combo: the map at once) */
|
||||
btn_up(B_OCTDN); frame();
|
||||
ok &= !perf_latched && !perf_k[1] && song.octave == 0 && msg_is("FX ALL OFF");
|
||||
{ uint32_t h = ui.home, pg = ui.page;
|
||||
btn_up(B_FX); frame();
|
||||
ok &= !ui.layer && ui.home == h && ui.page == pg && !ui.lock; /* (no tap: no page) */
|
||||
}
|
||||
bad += check(" FX LATCH: FX + OCT- quick (before HOLD): all off, no octave, no page", ok);
|
||||
btn_down(B_FX); key_down(lpf); frame(); key_up(lpf); frame(); btn_up(B_FX); frame();
|
||||
frames(400);
|
||||
btn_down(B_FX); btn_down(B_OCTDN); frame(); btn_up(B_OCTDN); frame(); /* (both in one frame) */
|
||||
ok = !perf_latched && song.octave == 0 && msg_is("FX ALL OFF");
|
||||
btn_up(B_FX); frame();
|
||||
btn_down(B_FX); frame(); frames(800); /* held past HOLD, then OCT- */
|
||||
ok &= ui.layer == LAYER_FX;
|
||||
press(B_OCTDN);
|
||||
ok &= song.octave == 0;
|
||||
btn_up(B_FX); frame();
|
||||
press(B_OCTDN); /* no FX: the octave as always */
|
||||
ok &= song.octave == -1 && !ui.layer;
|
||||
press(B_OCTUP);
|
||||
ok &= song.octave == 0;
|
||||
bad += check(" FX LATCH: FX + OCT- in one frame / held: no octave; OCT- alone: the octave", ok);
|
||||
fx_latch = 0;
|
||||
frame();
|
||||
btn_down(B_FX); frame(); btn_down(B_OCTDN); frame(); btn_up(B_OCTDN); frame();
|
||||
ok = song.octave == -1 && ui.layer == LAYER_FX; /* LATCH OFF: FX's HOLD layer, OCT- is the octave */
|
||||
{ uint32_t h = ui.home, pg = ui.page;
|
||||
btn_up(B_FX); frame();
|
||||
ok &= !ui.layer && ui.home == h && ui.page == pg;
|
||||
}
|
||||
btn_down(B_FX); frame(); frames(800); press(B_OCTUP); btn_up(B_FX); frame();
|
||||
ok &= song.octave == 0;
|
||||
btn_down(B_FX); frame(); btn_up(B_FX); frame(); /* FX tap: its page still */
|
||||
ok &= !ui.home && cur_page()->fam == FAM_FX;
|
||||
go_home();
|
||||
frames(400);
|
||||
btn_down(B_GLO); frame(); btn_down(B_OCTDN); frame(); /* a SET layer the same: GLO + OCT- quick */
|
||||
ok &= ui.layer == LAYER_GLO;
|
||||
btn_up(B_OCTDN); frame();
|
||||
ok &= song.octave == 0 && msg_is("MIX PUT BACK");
|
||||
btn_up(B_GLO); frame();
|
||||
ok &= ui.home && !ui.layer;
|
||||
bad += check(" FX LATCH OFF: FX + OCT- quick / held shifts the octave (no page); FX tap: the FX page; "
|
||||
"GLO + OCT- quick: put back, no octave", ok);
|
||||
fx_latch = 1;
|
||||
frame();
|
||||
btn_down(B_FX); key_down(lpf); frame(); key_up(lpf); frame(); btn_up(B_FX); frame();
|
||||
hold(B_HOME);
|
||||
ok = ui.menu && !perf_latched;
|
||||
@@ -5194,6 +5572,8 @@ int main(void)
|
||||
bad += test_sound_loads();
|
||||
bad += test_patterns();
|
||||
bad += test_rec();
|
||||
bad += test_rec_hold_clear();
|
||||
bad += test_presets_knob();
|
||||
bad += test_midi();
|
||||
bad += test_save();
|
||||
bad += test_actions();
|
||||
@@ -5229,12 +5609,14 @@ int main(void)
|
||||
#if FELUCCA_SLICE
|
||||
bad += test_slices();
|
||||
#endif
|
||||
bad += test_sample_alert();
|
||||
bad += test_quick_layers();
|
||||
bad += test_chord_page();
|
||||
bad += test_bughunt_ui();
|
||||
bad += test_bughunt_ui2();
|
||||
bad += test_piano_roll();
|
||||
bad += test_play_leds();
|
||||
bad += test_cursor_step_leds();
|
||||
bad += test_midi_leds();
|
||||
bad += test_seq_quant();
|
||||
bad += test_idle_glow();
|
||||
|
||||
@@ -87,6 +87,8 @@ EXTRA = {
|
||||
# OCT UP / OCT DN (the harmonizer): stand-ins until Fukiai has a pitch-shift glyph;
|
||||
# the first of each tuple the font has
|
||||
"x_oct_up": ("symbol_pitch_up", "control_arrow_up"), "x_oct_dn": ("symbol_pitch_down", "control_arrow_down"),
|
||||
# a missing sample (the header message, the SLICES page): SAMPLE NOT FOUND
|
||||
"x_nofile": "symbol_document_disabled",
|
||||
}
|
||||
|
||||
# a glyph given as a tuple: the first one the font has (a glyph still to be drawn falls back to a stand-in;
|
||||
@@ -115,7 +117,8 @@ BIG_DEFAULT = ["x_play", "x_stop", "x_pause", "x_rec", "x_rec_o", "x_usb", "x_st
|
||||
"x_cog", "x_power", "x_warn", "x_palette", "x_speaker", "x_info", "x_hugelton", "x_doc",
|
||||
"wave", "algorithm", "phase", "bits", "sample", "mouth", "trio", "drawbar", "slice", "grain",
|
||||
"phys", "drum", "noise", "mod", "tempo", "tape",
|
||||
"x_song", "x_motion", "x_motion_del", "x_doctor", "x_fx", "x_knob", "x_timer", "rate", "x_bat0", "x_bat1", "x_bat3", "x_bat4", "x_bat_chg"]
|
||||
"x_song", "x_motion", "x_motion_del", "x_doctor", "x_fx", "x_knob", "x_timer", "rate", "x_bat0", "x_bat1", "x_bat3", "x_bat4", "x_bat_chg",
|
||||
"x_nofile"]
|
||||
|
||||
|
||||
def glyph_table(font_path):
|
||||
|
||||
@@ -59,7 +59,7 @@ GROUPS = [
|
||||
(("MASTER",), 0, ("Volume", "音量"), None),
|
||||
(("ALGORITHM",), 0, ("Track T1–T4, on every page", "トラック T1–T4 を選ぶ(全ページ)"), None),
|
||||
(("PRESETS",), 0, ("The track's sound", "トラックの音色"),
|
||||
("on HOME and SAVE > PRESETS", "HOME と SAVE > PRESETS で")),
|
||||
("SEQ steps: the cursor; lists: the selection", "SEQ のステップ: カーソル、リスト: 選択")),
|
||||
(("KNOB 1–4",), 0, ("The four columns of the page", "ページの 4 列を編集"), None),
|
||||
]),
|
||||
dict(n=2, col=0, title=("Page buttons", "ページボタン"), note=("again: the next page", "もう一度で次のページ"),
|
||||
@@ -74,7 +74,7 @@ GROUPS = [
|
||||
(("HOME",), 0, ("Home screen", "ホーム画面"), None),
|
||||
(("SAVE",), 0, ("Presets, user sounds, projects", "プリセット、ユーザー音色、プロジェクト"), None),
|
||||
(("ARP",), 0, ("Arpeggiator; flashes on the beat", "アルペジエーター(拍で点滅)"), None),
|
||||
(("SEQ",), 0, ("Sequencer: steps, pattern", "シーケンサー(ステップ、パターン)"), None),
|
||||
(("SEQ",), 0, ("Sequencer: steps, pattern, automation", "シーケンサー(ステップ、パターン、オートメーション)"), None),
|
||||
]),
|
||||
dict(n=3, col=0, title=("Keys", "鍵盤"), note=None,
|
||||
bands=[("KEYS",)],
|
||||
@@ -106,6 +106,7 @@ GROUPS = [
|
||||
(("SCL",), 1, ("A key sets the root; scale, chords", "鍵盤でルート、スケール・コード"), None),
|
||||
(("EDIT",), 1, ("A white key picks the engine", "白鍵でエンジンを選ぶ"), None),
|
||||
(("SAVE",), 1, ("Undo the last load (again: redo)", "直前の読み込みを取り消し(再度でやり直し)"), None),
|
||||
(("REC",), 1, ("On SEQ: clear the sequence (asks first)", "SEQ で: シーケンスを消去(確認あり)"), None),
|
||||
(("HOME",), 1, ("Menu", "メニュー"), None),
|
||||
(("SEQ",), 1, ("Song: chain patterns", "ソング(パターンをつなぐ)"), None),
|
||||
(("GLO", "SELECT"), 1, ("Tempo, even with BPM LOCK", "テンポ(BPM LOCK 中も)"), None),
|
||||
|
||||
+43
-9
@@ -28,6 +28,10 @@ offsets do not move) and NOT one of the SAMPLE sets (the SET list, its presets a
|
||||
USR1-3 numbers stay as they were). Its slice table (decoder states on a 128-point grid,
|
||||
the hits as AUTO slices) is written with it: SLC_BREAK_INIT.
|
||||
|
||||
SLICE's SRC PIANO (added in 1.0.4 after BREAK and USR1-3) is the PIANO set's middle C zone itself:
|
||||
no data of its own, only its slice table (one AUTO slice, the note's attack): SLC_PIANO_INIT.
|
||||
Without the CC0 library (no PIANO set) it has no material (SLICE plays a sine there).
|
||||
|
||||
The header is cached (build/gen_samples.cache) under a hash of every
|
||||
input file, this script, sampleio.py and the Python version, so unchanged
|
||||
inputs skip the slow pitch detection.
|
||||
@@ -77,7 +81,8 @@ BREAK_HITS = [(0, "kick", 1.0), (0, "chh", 0.55), (2, "kick", 0.7), (2, "chh", 0
|
||||
(4, "chh", 0.45), (6, "chh", 0.4), (7, "kick", 0.8), (8, "chh", 0.55), (9, "snare", 0.3),
|
||||
(10, "kick", 0.9), (10, "ohh", 0.4), (12, "snare", 1.0), (12, "chh", 0.45), (14, "chh", 0.4),
|
||||
(14, "snare", 0.35)]
|
||||
SLC_GRID, SLC_AUTO = 128, 32 # eng_slice.c slc_src_t
|
||||
SLC_PIANO_NOTE = 60 # SLICE's SRC PIANO: the PIANO zone of this root (middle C)
|
||||
SLC_GRID, SLC_AUTO = 128, 32 # eng_slice.c slc_src_t
|
||||
|
||||
ENV = {"wave":(5, 80, 100, 50), "kit": (0, 127, 127, 60), "multi": (0, 85, 0, 75),
|
||||
"oneshot": (0, 127, 127, 70), "sus": (12, 80, 120, 60)}
|
||||
@@ -241,6 +246,7 @@ class Builder:
|
||||
self.zones, self.sets, self.blob, self.kinds = [], [], bytearray(), {}
|
||||
self.alias = {} # set index -> the set index it aliases
|
||||
self.brk = None
|
||||
self.pno = None
|
||||
|
||||
def slice_break(self):
|
||||
"""SLICE's BREAK, after every set; its slice table: decoder states at k * len / SLC_GRID, the hits"""
|
||||
@@ -252,6 +258,18 @@ class Builder:
|
||||
hits = hits[:SLC_AUTO]
|
||||
self.brk = dict(off=off, n=n, grid=grid, apos=hits, ast=ima_states(data, hits))
|
||||
|
||||
def slice_piano(self):
|
||||
"""SLICE's PIANO: the PIANO set's SLC_PIANO_NOTE zone (its data, no copy); its slice table: decoder states
|
||||
at k * len / SLC_GRID, one AUTO slice at 0 (a single note has one attack)"""
|
||||
z = next((z for name, z0, nz in self.sets if name == "PIANO"
|
||||
for z in self.zones[z0:z0 + nz] if z["root16"] == SLC_PIANO_NOTE * 16), None)
|
||||
if not z:
|
||||
return
|
||||
off, n = z["off"], z["n"]
|
||||
data = self.blob[off:off + (n + 1) // 2]
|
||||
grid = ima_states(data, [k * n // SLC_GRID for k in range(SLC_GRID)])
|
||||
self.pno = dict(off=off, n=n, grid=grid, apos=[0], ast=ima_states(data, [0]))
|
||||
|
||||
def add(self, s, loop_start):
|
||||
"""ADPCM-encode s into the blob (each sample starts on an even offset) -> (offset, state at loop_start)"""
|
||||
enc, st = ima_encode(s, loop_start)
|
||||
@@ -340,26 +358,41 @@ class Builder:
|
||||
L.append("#define SMP_SET_NAMES_INIT " + names)
|
||||
L.append("static const char *const SMP_SET_NAMES[] = {" + names + "};")
|
||||
L += self.break_header()
|
||||
L += self.piano_header()
|
||||
return "\n".join(L) + "\n"
|
||||
|
||||
def break_header(self):
|
||||
"""SLC_BREAK_INIT: an eng_slice.c slc_src_t (len, rate, nseg, nauto, seg[], grid[], apos[], ast[])"""
|
||||
b = self.brk
|
||||
if not b:
|
||||
return ["#define SLC_BREAK_INIT {0}"]
|
||||
@staticmethod
|
||||
def slc_init(name, b):
|
||||
"""an eng_slice.c slc_src_t initializer (len, rate, nseg, nauto, seg[], grid[], apos[], ast[])"""
|
||||
rate = int(round(TR / 44100 * 65536))
|
||||
|
||||
def lst(v, k):
|
||||
v = list(v) + [0] * (k - len(v))
|
||||
return ", \\\n ".join(", ".join(map(str, v[i:i + 12])) for i in range(0, len(v), 12))
|
||||
return ["", f"/* SLICE's BREAK: one bar of {BREAK_STEPS} steps at {BREAK_BPM} BPM, {len(b['apos'])} hits */",
|
||||
f"#define SLC_BREAK_BPM {BREAK_BPM}", f"#define SLC_BREAK_STEPS {BREAK_STEPS}",
|
||||
f"#define SLC_BREAK_INIT {{{b['n']}, {rate}, 1, {len(b['apos'])}, {{{{{b['off']}, 0, {b['n']}}}}}, {{ \\",
|
||||
return [f"#define {name} {{{b['n']}, {rate}, 1, {len(b['apos'])}, {{{{{b['off']}, 0, {b['n']}}}}}, {{ \\",
|
||||
" " + lst(b["grid"], SLC_GRID) + "}, { \\", " " + lst(b["apos"], SLC_AUTO) + "}, { \\",
|
||||
" " + lst(b["ast"], SLC_AUTO) + "}}"]
|
||||
|
||||
def break_header(self):
|
||||
"""SLC_BREAK_INIT: SLICE's BREAK ({0}: none)"""
|
||||
b = self.brk
|
||||
if not b:
|
||||
return ["#define SLC_BREAK_INIT {0}"]
|
||||
return ["", f"/* SLICE's BREAK: one bar of {BREAK_STEPS} steps at {BREAK_BPM} BPM, {len(b['apos'])} hits */",
|
||||
f"#define SLC_BREAK_BPM {BREAK_BPM}", f"#define SLC_BREAK_STEPS {BREAK_STEPS}"] + \
|
||||
self.slc_init("SLC_BREAK_INIT", b)
|
||||
|
||||
def piano_header(self):
|
||||
"""SLC_PIANO_INIT: SLICE's PIANO, the PIANO zone of middle C ({0}: none, no CC0 library)"""
|
||||
b = self.pno
|
||||
if not b:
|
||||
return ["#define SLC_PIANO_INIT {0}"]
|
||||
return ["", f"/* SLICE's PIANO: the PIANO zone of MIDI {SLC_PIANO_NOTE} ({b['n']} samples at SMP_DATA[{b['off']}]) */",
|
||||
f"#define SLC_PIANO_NOTE {SLC_PIANO_NOTE}"] + self.slc_init("SLC_PIANO_INIT", b)
|
||||
|
||||
def summary(self):
|
||||
brk = f", SLICE BREAK {self.brk['n']} samples" if self.brk else ""
|
||||
brk += f", SLICE PIANO (shared) {self.pno['n']} samples" if self.pno else ""
|
||||
return f"samples: {len(self.sets)} sets, {len(self.zones)} zones, {len(self.blob)} B ADPCM{brk}"
|
||||
|
||||
|
||||
@@ -407,6 +440,7 @@ def main(out):
|
||||
b.cc0_set(name, kind)
|
||||
if slice_on(): # SLICE's BREAK: only when that engine is built
|
||||
b.slice_break() # last: the sets' offsets stay as they were
|
||||
b.slice_piano() # (no data of its own: the PIANO set's)
|
||||
text = b.header()
|
||||
Path(out).write_text(text)
|
||||
CACHE.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@ from pathlib import Path
|
||||
_ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC = _ROOT / "firmware" / "src" if (_ROOT / "firmware" / "src").is_dir() else _ROOT / "src" # either layout
|
||||
# the UI, the stores, the editor and the console: main loop only, never called by sound code
|
||||
SIZE_FILES = ["ui.c", "favorites.c", "icons.c", "ui_graph.c", "ui_draw.c", "ui_menu.c", "ui_input.c",
|
||||
SIZE_FILES = ["ui.c", "favorites.c", "menu_items.c", "icons.c", "ui_graph.c", "ui_draw.c", "ui_menu.c", "ui_input.c",
|
||||
"storage.c", "upreset.c", "project.c", "settings_persist.c",
|
||||
"editor.c", "editor_preferences.c", "editor_backup.c", "console.c"]
|
||||
"editor.c", "editor_preferences.c", "editor_backup.c", "editor_menu.c", "console.c"]
|
||||
DEF = re.compile(r"^(?:static|void|int|uint\w*|int\w*|const)\b[^;=(]*?\b([A-Za-z_]\w*)\s*\(", re.M)
|
||||
IR_DEF = re.compile(r"^(define [^\n]*?@\"?([\w.]+)\"?\([^\n]*\)(?: unnamed_addr| local_unnamed_addr)?)( #\d+[^\n]*\{)$",
|
||||
re.M)
|
||||
|
||||
+67
-1
@@ -28,6 +28,9 @@ restore the whole device. P_COUNT is 89 and P_E0 is 81: twenty FM operator param
|
||||
before the engine parameters, which moved from 61..68 to 81..88. Always take P_E0 from `INFO`. INFO ends with
|
||||
tagged capability blocks for these (see `INFO`).
|
||||
|
||||
**MENU settings (1.0.4):** `MENU_DESC` (72) and `MENU_SET` (73) read and set the device's MENU settings, described
|
||||
by the device (see "MENU settings" at the end); INFO advertises them with `4E 01 count`.
|
||||
|
||||
**Chord keys (91 parameters, 1.0):** two track parameters, `CHRD` (81) and `VOIC` (82), went in before the
|
||||
engine parameters, which moved from 81..88 to 83..90: P_COUNT 91, P_E0 83. No command changed; an editor that
|
||||
takes P_COUNT and P_E0 from `INFO` keeps working (see "The chord keys" below).
|
||||
@@ -123,7 +126,7 @@ global `G_CLOCK` (id 2, label "CLK") 3 (INT, USB, TRS). `G_MIDI` (id 12) is an e
|
||||
|
||||
| cmd | Request args | Reply args |
|
||||
| --- | --- | --- |
|
||||
| 1 INFO | — | version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then NENGINES engine-name strings, then (v3) NTRK (4), then (v6) CHAIN_ROWS (16), then the tagged blocks `55 01 uiCaps`, `4D 01 64 01`, `42 01 3`, `46 01 nfactory nbank` and `53 01 3` (below); older firmware ends earlier |
|
||||
| 1 INFO | — | version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then NENGINES engine-name strings, then (v3) NTRK (4), then (v6) CHAIN_ROWS (16), then the tagged blocks `55 01 uiCaps`, `4D 01 64 01`, `42 01 3`, `46 01 nfactory nbank`, `53 01 3`, (1.0.3) `50 01 3` and (1.0.4) `4E 01 count` (MENU settings) (below); older firmware ends earlier |
|
||||
| 2 GET | scope, id | scope, id, v14 |
|
||||
| 3 SET | scope, id, v14 | scope, id, v14 (the value after clamping). Setting global `G_ENGSEL` (id from DESC label "ENG") changes the engine: its defaults, then its first preset (as on the device) |
|
||||
| 4 DUMP | — | engine, preset, then P_COUNT × v14 (the selected track), then G_COUNT × v14 (globals) |
|
||||
@@ -640,3 +643,66 @@ rc 0 = applied and saved; 1 = invalid arguments; 2 = unsupported feature;
|
||||
by the same persistence path as the panel. These changes never stop playback.
|
||||
Unchanged writes do not erase flash. Replies echo preference ids/values and
|
||||
favorite ranges so the editor rejects replies to a different request.
|
||||
|
||||
## MENU settings (72, 73; 1.0.4)
|
||||
|
||||
The device describes the settings of its MENU (HOME held) to the editor, which builds its settings from what it
|
||||
is told: no list of settings is fixed in the editor. INFO advertises `4E 01 count` after the FM6 v2 tag
|
||||
(`50 01 caps`): `count` items, MENU_DESC index 0..count−1. Firmware without the tag answers neither command.
|
||||
|
||||
| cmd | Request args | Reply args |
|
||||
| --- | --- | --- |
|
||||
| 72 MENU_DESC | index (0..count−1) | index, id, kind, value v14, min v14, max v14, name string, then for kind 0 (max−min+1) value-name strings, for kind 1 a unit string. An index past the list: index, 127 (no more bytes) |
|
||||
| 73 MENU_SET | id, value v14 | rc, id, value v14: the device's value after the write (clamped to min..max) |
|
||||
|
||||
- **index** is the position in the device's menu order (show them in this order); **id** names the setting and
|
||||
never changes its meaning: a new setting takes a new id (append-only), wherever it shows in the menu. Ids are
|
||||
0..126; 127 means "no item". Remember settings by id, not by index.
|
||||
- **kind**: 0 an enum (the value is an index into the names, min..max), 1 a number (min..max, its unit after the
|
||||
name; no setting uses it yet). An editor shows a kind it does not know read-only, or not at all.
|
||||
- Values are v14 like the rest of the protocol, so a setting may later go past 127; today every value is 0..9.
|
||||
- **rc** as `UI_SET`: 0 applied and saved, 3 applied in RAM only (no flash or a failed write; retried by the
|
||||
settings path), 4 applied and saved after STOP; 1 an unknown id (the request's id and value are echoed,
|
||||
nothing changes). A value out of range is not refused: it is clamped and the reply says which value the device
|
||||
took. A wrong argument length gets no reply.
|
||||
- A MENU_SET is applied exactly as the menu's KNOB 1 / OCT+ applies it (`src/menu_items.c` `menu_put`, shared by
|
||||
both), and saved through the same settings record (`settings_save`; unchanged values write nothing). If the
|
||||
device shows the MENU page, it redraws with the new value. There is no push: an editor that wants to follow
|
||||
changes made on the device reads MENU_DESC again (for instance when its settings page opens).
|
||||
- CALIBRATION and ABOUT have no value and are not offered. COLOR (id 0) is the same setting as `UI_SET` id 0.
|
||||
|
||||
This firmware (count 12):
|
||||
|
||||
| index | id | name | kind | values (min 0) | default |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 0 | 0 | COLOR | 0 | 0..9: GREY GREEN AMBER ICE VIOLET ROSE PAPER HI-CON NIGHT MONO (the order of `UI_PALETTES`) | GREY |
|
||||
| 1 | 1 | STYLE | 0 | 0 FLAT, 1 LINE | FLAT |
|
||||
| 2 | 2 | LARGE | 0 | 0 OFF, 1 ON | OFF |
|
||||
| 3 | 3 | ANIM | 0 | 0 ON, 1 OFF | ON |
|
||||
| 4 | 4 | LEDS | 0 | 0 OFF, 1 DIM LO, 2 DIM HI, 3 INV (darkest first, as the menu steps them) | DIM HI |
|
||||
| 5 | 5 | HOLD | 0 | 0 "0.3 s", 1 "0.4 s", 2 "0.5 s", 3 "0.6 s" | 0.4 s |
|
||||
| 6 | 6 | KNOB ACCEL | 0 | 0 OFF, 1 ON | OFF |
|
||||
| 7 | 7 | FX LATCH | 0 | 0 OFF, 1 ON | OFF |
|
||||
| 8 | 8 | BPM LOCK | 0 | 0 OFF, 1 ON | OFF |
|
||||
| 9 | 9 | SPEAKER EQ | 0 | 0 FLAT, 1 LOWCUT, 2 BASS+ | FLAT |
|
||||
| 10 | 10 | USB LEVEL | 0 | 0 MASTER, 1 FIXED | MASTER |
|
||||
| 11 | 11 | USB SERIAL | 0 | 0 ON, 1 OFF | ON |
|
||||
|
||||
Example (bytes in hex): `F0 7D 46 4C 48 04 F7` asks for index 4; the reply
|
||||
`F0 7D 46 4C 48 04 04 00 02 40 00 40 03 40 4C 45 44 53 00 4F 46 46 00 44 49 4D 20 4C 4F 00 44 49 4D 20 48 49 00 49 4E 56 00 F7`
|
||||
is index 4, id 4, kind 0, value 2 (`02 40`), min 0 (`00 40`), max 3 (`03 40`), "LEDS", then "OFF" "DIM LO"
|
||||
"DIM HI" "INV". `F0 7D 46 4C 49 04 03 40 F7` sets LEDS to INV and answers `F0 7D 46 4C 49 00 04 03 40 F7` (rc 0).
|
||||
`F0 7D 46 4C 49 00 32 40 F7` (COLOR 50) answers `F0 7D 46 4C 49 00 00 09 40 F7` (clamped to 9, MONO).
|
||||
`F0 7D 46 4C 48 0C F7` answers `F0 7D 46 4C 48 0C 7F F7` (no index 12).
|
||||
|
||||
**USB SERIAL (id 11).** The menu applies it when it closes; a MENU_SET applies it about 200 ms after its reply
|
||||
(`usb_serial_apply`), so the reply leaves first (if the device shows the MENU at that moment: when it closes).
|
||||
A change (ON <-> OFF; setting the value it already has does nothing) re-enumerates the whole device: it drops off
|
||||
the bus (its D+ pull-up off) and comes back with the other descriptors, so USB-MIDI, USB audio and the serial
|
||||
console all go away and come back. On the device the gap is about 25 ms plus one main-loop pass (`usb_retry`,
|
||||
`usb_start`), or up to 1 s when it re-enumerated in the second before; the host then debounces the attach
|
||||
(>= 100 ms), resets and enumerates the device. Measured on macOS (CoreMIDI): OFF -> ON, the reply at ~0.04 s, the
|
||||
device gone at ~0.3 s, the MIDI port gone at ~0.57 s and back at ~1.15 s; ON -> OFF, the serial port goes
|
||||
at ~0.6 s while the MIDI port was not seen to disappear at all (so do not wait for a disconnect event: after
|
||||
a real change, wait ~1.5 s and open again). What the editor sends in that window is lost, `WATCH` ends with the
|
||||
bus reset (send `INFO` and `WATCH` again after reconnecting), and a backup in progress answers rc 5 (stale).
|
||||
+8
-8
@@ -1740,7 +1740,7 @@ function makeMockDevice(opt = {}) {
|
||||
P("KALIMBA", [0, 34, 16, 56, 100, 90, 0, 48], [0, 100, 127, 60], 0, 7), P("HAND DRUM", [2, 112, 76, 56, 44, 100, 14, 24], [0, 100, 127, 64], 0, 6),
|
||||
P("TOMS", [2, 0, 52, 40, 30, 100, 40, 30], [0, 100, 127, 70], 0, 2), P("DRONE STRING", [3, 127, 80, 88, 64, 100, 92, 0], [0, 100, 127, 90], 0, 3),
|
||||
P("HARP", [3, 8, 62, 74, 60, 90, 0, 0], [0, 100, 127, 80], 0, 3)] },
|
||||
{ name: "DRUM", titles: ["KIT", "HIT"], edit: [E("KIT", ["STD", "HAND", "CYM", "H+CYM"], 0), D("TUNE", F.PCT, 0, 127, 64),
|
||||
{ name: "DRUM", titles: ["KIT", "HIT"], edit: [E("KIT", ["STD", "HAND", "CYM", "H+CYM", "80", "10", "66", "55", "77"], 0), D("TUNE", F.PCT, 0, 127, 64),
|
||||
D("TONE", F.PCT, 0, 127, 64), D("DECY", F.PCT, 0, 127, 64), D("SNAP", F.PCT, 0, 127, 64), D("ACC", F.PCT, 0, 127, 100),
|
||||
E("KICK", ["PUNCH", "ROUND"], 0), D("DRV", F.PCT, 0, 127, 0)],
|
||||
presets: [P("DRUM KIT", [0, 64, 70, 64, 64, 100, 0, 0], [0, 100, 127, 100], 0, 12)] },
|
||||
@@ -1756,7 +1756,7 @@ function makeMockDevice(opt = {}) {
|
||||
P("FM BASS", [0, 0, 0, 0, 0, 0, 0, 2], [0, 0, 127, 0], 1, 2), P("BRASS", [0, 0, 0, 0, 0, 0, 0, 3], [0, 0, 127, 0], 0, 4),
|
||||
P("PAD", [0, 0, 0, 0, 0, 0, 30, 4], [0, 0, 127, 0], 0, 5), P("MARIMBA", [0, 0, 0, 0, 0, 0, 0, 5], [0, 0, 127, 0], 0, 3),
|
||||
P("ORGAN", [0, 0, 0, 0, 0, 0, 0, 6], [0, 0, 127, 0], 0, 6), P("PLUCK", [0, 0, 0, 0, 0, 0, 0, 7], [0, 0, 127, 0], 0, 13)] },
|
||||
{ name: "SLICE", titles: ["SLCE", "PLAY"], edit: [E("SRC", ["BREAK", "USR1", "USR2", "USR3"], 0),
|
||||
{ name: "SLICE", titles: ["SLCE", "PLAY"], edit: [E("SRC", ["BREAK", "USR1", "USR2", "USR3", "PIANO"], 0),
|
||||
E("DIV", ["4", "8", "16", "32", "AUTO", "MAN"], 2), D("START", F.INT, 0, 31, 0), D("PTCH", F.SEMI, -24, 24, 0),
|
||||
E("MODE", ["ONE", "GATE", "LOOP"], 0), E("REV", ["OFF", "ON"], 0), D("DCAY", F.TIME, 0, 127, 127), D("TONE", F.INT, 0, 127, 127)],
|
||||
presets: [P("CHOP", [0, 2, 0, 0, 0, 0, 127, 127], [0, 127, 127, 30], 0, 9), P("STUTTER", [0, 1, 0, 0, 1, 0, 90, 110], [0, 127, 127, 12], 0, 10)] },
|
||||
@@ -2489,7 +2489,7 @@ const TEXT = {
|
||||
fm6Factories: "ファクトリー音色",
|
||||
fm6NeedDevice: "FM-1 を接続すると 6-OP FM の音色を編集してトラックへ送れます。",
|
||||
fm6NoFw: "このファームウェアには 6-OP FM(FM6)がありません。Felucca 1.0 以降に更新すると使えます。",
|
||||
motion: "モーション", motionOn: "再生", motionClear: "モーションを消去", motionConfirm: "選択トラックのモーションを消しますか?", chance: "確率 %", motionStep: "ステップ", motionParam: "パラメーター", motionValue: "値",
|
||||
motion: "オートメーション", motionOn: "再生", motionClear: "オートメーションを消去", motionConfirm: "選択トラックのオートメーションを消しますか?", chance: "確率 %", motionStep: "ステップ", motionParam: "パラメーター", motionValue: "値",
|
||||
backupTitle: "全体バックアップ", backupExport: "バックアップ保存", backupImport: "バックアップ復元", backupHelp: "現在の曲・A〜D・音色バンク・ユーザーサンプル・設定を、このパソコンへ保存。", backupOld: "全体バックアップには対応版への更新が必要です。", backupConfirm: "全体バックアップを復元しますか? 現在の曲、保存データとサンプルを置き換えます。USBを抜かないでください。", backupWorking: "バックアップ処理中 ", backupDone: "バックアップを保存しました", backupRestored: "全体バックアップを復元しました",
|
||||
deviceDisplay: "本体の画面",
|
||||
deviceDisplayHelp: "FM-1 の画面に反映し、保存します。再生中の変更は停止後に保存されます。",
|
||||
@@ -2592,7 +2592,7 @@ const TEXT = {
|
||||
fm6Factories: "Factory patch",
|
||||
fm6NeedDevice: "Connect the FM-1 to edit 6-OP FM voices and send them to a track.",
|
||||
fm6NoFw: "This firmware has no 6-OP FM (FM6). Update to Felucca 1.0 or later to use it.",
|
||||
motion: "Motion", motionOn: "Play motion", motionClear: "Clear motion", motionConfirm: "Clear this track's motion?", chance: "Chance %", motionStep: "Step", motionParam: "Parameter", motionValue: "Value",
|
||||
motion: "Automation", motionOn: "Play automation", motionClear: "Clear automation", motionConfirm: "Clear this track's automation?", chance: "Chance %", motionStep: "Step", motionParam: "Parameter", motionValue: "Value",
|
||||
backupTitle: "Complete backup", backupExport: "Save backup", backupImport: "Restore backup", backupHelp: "Save the current music, A–D, sound banks, user samples and settings to this computer.", backupOld: "Complete backups need firmware with archive support.", backupConfirm: "Restore this complete backup? Current music, saved data and samples will be replaced. Keep USB connected.", backupWorking: "Backing up / restoring ", backupDone: "Backup saved", backupRestored: "Complete backup restored",
|
||||
deviceDisplay: "Device display",
|
||||
deviceDisplayHelp: "Changes apply to the FM-1 screen and save. Changes made while playing save after STOP.",
|
||||
@@ -3378,12 +3378,12 @@ function renderMotion() {
|
||||
value.addEventListener("change", () => op(async () => {
|
||||
assertSession(d);
|
||||
const r = parse[CMD.MOTION](await sessionRequest(d, req.motion(m.track, 3, {...e,value:+value.value})));
|
||||
if (r.rc) throw new Error("Motion edit refused"); d.motion = r; renderMotion();
|
||||
if (r.rc) throw new Error("Automation edit refused"); d.motion = r; renderMotion();
|
||||
}));
|
||||
return el("tr", {}, el("td", {text:e.step + 1}), el("td", {text:label}), el("td", {}, value),
|
||||
el("td", {}, el("button", {text:t("remove"),onclick:() => op(async () => {
|
||||
const r = parse[CMD.MOTION](await sessionRequest(d, req.motion(m.track, 4, e)));
|
||||
if (r.rc) throw new Error("Motion edit refused"); d.motion = r; renderMotion();
|
||||
if (r.rc) throw new Error("Automation edit refused"); d.motion = r; renderMotion();
|
||||
})})));
|
||||
}));
|
||||
}
|
||||
@@ -3391,13 +3391,13 @@ $("motion-on").addEventListener("change", () => op(async () => {
|
||||
const d = dev, track = d?.sel ?? 0;
|
||||
if (!d?.info?.motionMax) return;
|
||||
const r = parse[CMD.MOTION](await sessionRequest(d, req.motion(track, 1, {on:$("motion-on").checked})));
|
||||
if (r.rc) throw new Error("Motion edit refused"); d.motion = r; renderMotion();
|
||||
if (r.rc) throw new Error("Automation edit refused"); d.motion = r; renderMotion();
|
||||
}));
|
||||
$("motion-clear").addEventListener("click", () => op(async () => {
|
||||
const d = dev;
|
||||
if (!d?.info?.motionMax || !confirm(t("motionConfirm"))) return;
|
||||
const r = parse[CMD.MOTION](await sessionRequest(d, req.motion(d.sel ?? 0, 2)));
|
||||
if (r.rc) throw new Error("Motion edit refused"); d.motion = r; renderMotion();
|
||||
if (r.rc) throw new Error("Automation edit refused"); d.motion = r; renderMotion();
|
||||
}));
|
||||
setInterval(async () => {
|
||||
const d = dev;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
# Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
||||
# Felucca in the browser: the firmware's sources as the host tests build them (web/emu/felucca_web.c), compiled
|
||||
# to WebAssembly with Emscripten, plus the page. After X0X's web/emu/build.sh (charlesvestal/fm1-x0x, GPL-3.0).
|
||||
# web/emu/build.sh -> build/emu/{index.html, worklet.js, felucca.wasm}
|
||||
# Run after one ./build.sh (build/gen: the tables, the fonts, the CC0 samples).
|
||||
# -ffp-contract=off: no fused multiply-adds, as the host build. EMU_OPT replaces -O2, EMU_CFLAGS adds flags
|
||||
# (EMU_CFLAGS=-msimd128: let the compiler vectorise; every browser with AudioWorklet has wasm SIMD).
|
||||
# The page names the version (FELUCCA_VERSION) as a preview of the next release; EMU_PREVIEW=0 drops that line.
|
||||
set -e
|
||||
cd "$(dirname "$0")/../.."
|
||||
[ -f build/gen/felucca_tables.h ] || { echo "emu: run ./build.sh once first (build/gen)"; exit 1; }
|
||||
command -v emcc >/dev/null 2>&1 || { echo "emu: no emcc (Emscripten)"; exit 1; }
|
||||
VERSION=$(sed -n 's/^#define FELUCCA_VERSION "\([^"]*\)".*/\1/p' firmware/src/felucca.c)
|
||||
mkdir -p build/emu
|
||||
# shellcheck disable=SC2086
|
||||
emcc ${EMU_OPT:--O2} -ffp-contract=off -std=gnu99 -w ${EMU_CFLAGS:-} \
|
||||
"-DFELUCCA_VERSION=\"$VERSION\"" -Ibuild/gen -Ifirmware/src \
|
||||
--no-entry -sSTANDALONE_WASM -sSTACK_SIZE=1048576 -sINITIAL_MEMORY=33554432 -sFILESYSTEM=0 \
|
||||
-o build/emu/felucca.wasm web/emu/felucca_web.c
|
||||
[ "${EMU_PREVIEW:-1}" = 0 ] && DROP='/class="preview"/d' || DROP=''
|
||||
sed -e "$DROP" -e "s/@VERSION@/${VERSION#v}/g" web/emu/index.html > build/emu/index.html
|
||||
cp web/emu/worklet.js build/emu/
|
||||
echo "emu: build/emu ($(wc -c < build/emu/felucca.wasm | tr -d ' ') B wasm, $VERSION)"
|
||||
@@ -0,0 +1,135 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
||||
// The browser build (build/emu/felucca.wasm, web/emu/felucca_web.c) in Node, as the worklet runs it. After X0X's
|
||||
// tests/host/emu_test.mjs (charlesvestal/fm1-x0x, GPL-3.0).
|
||||
// node web/emu/emu_test.mjs build/emu/felucca.wasm [NATIVE.f32]
|
||||
// Checks: it boots (splash, then HOME on the screen, the HOME LED), a held key sounds and lights its LED, PLAY
|
||||
// starts the sequencer (PLAY's green LED), a user preset saved from the panel (SAVE, OCT+, OCT+) reaches the flash,
|
||||
// and the flash sectors kept as the page keeps them bring it back in a fresh instance; the same gestures twice
|
||||
// give the same audio (deterministic), with NATIVE.f32 (web/emu/native_check.c) the native build's, bit for bit.
|
||||
// Then the cost: 1 s of a heavy song (FM6, PHYS, GRAIN chords, DRUM) against real time (BENCH_MAX, default 0.5:
|
||||
// fails above half of real time on this machine).
|
||||
import fs from "fs";
|
||||
import { storeSectors, restoreSectors } from "./worklet.js";
|
||||
|
||||
const wasmPath = process.argv[2] || "build/emu/felucca.wasm", nativePath = process.argv[3];
|
||||
const bytes = fs.readFileSync(wasmPath);
|
||||
const B = { FX: 0, SCL: 1, ENV: 2, LFO: 3, EDIT: 4, GLO: 5, HOME: 6, SAVE: 7, ARP: 8, SEQ: 9, PLAY: 10, REC: 11, OCTDN: 12, OCTUP: 13 };
|
||||
const EN = { SELECT: 0, ALGO: 1, PRESETS: 2, K1: 3, K2: 4, K3: 5, K4: 6 };
|
||||
let fails = 0;
|
||||
const check = (what, ok) => { console.log(`emu: ${what.padEnd(76)} ${ok ? "ok" : "FAIL"}`); if (!ok) fails++; };
|
||||
|
||||
async function device(saved) {
|
||||
const { instance } = await WebAssembly.instantiate(bytes, {});
|
||||
const ex = instance.exports, mem = ex.memory;
|
||||
ex._initialize();
|
||||
ex.web_nor_erase();
|
||||
if (saved) restoreSectors(new Uint8Array(mem.buffer, ex.web_nor(), ex.web_nor_size()), saved);
|
||||
ex.web_boot();
|
||||
const d = { ex, mem, peak: 0, sig: 0, rec: false, frames: 0, kept: [] };
|
||||
d.render = (ms) => {
|
||||
const n = Math.round(ms * 44.1);
|
||||
for (let k = 0; k < n; k += 128) {
|
||||
const m = Math.min(128, n - k);
|
||||
ex.web_render(m);
|
||||
const l = new Float32Array(mem.buffer, ex.web_out_l(), m), r = new Float32Array(mem.buffer, ex.web_out_r(), m);
|
||||
for (let i = 0; i < m; i++) {
|
||||
d.peak = Math.max(d.peak, Math.abs(l[i]), Math.abs(r[i]));
|
||||
if (d.rec) {
|
||||
d.sig = (d.sig * 31 + Math.round(l[i] * 32768) + 7 * Math.round(r[i] * 32768)) % 1000000007;
|
||||
d.kept.push(l[i], r[i]);
|
||||
}
|
||||
}
|
||||
d.frames += m;
|
||||
}
|
||||
};
|
||||
d.tap = (b) => { ex.web_buttons(1 << b); d.render(60); ex.web_buttons(0); d.render(60); };
|
||||
d.turn = (role, n) => { for (let i = 0; i < Math.abs(n); i++) { ex.web_enc(role, Math.sign(n)); d.render(40); } };
|
||||
Object.defineProperty(d, "samples", { get: () => new Float32Array(d.kept) });
|
||||
d.screen = () => new Uint16Array(mem.buffer, ex.web_screen(), 240 * 240).slice();
|
||||
return d;
|
||||
}
|
||||
const colours = (fb) => new Set(fb).size;
|
||||
|
||||
// ---- boot, keys, screen, LEDs
|
||||
const a = await device(null);
|
||||
a.render(200);
|
||||
const splash = colours(a.screen());
|
||||
a.render(800);
|
||||
const home = a.screen();
|
||||
check(`boots: the splash, then HOME (${colours(home)} colours), the HOME LED lit`,
|
||||
splash > 1 && colours(home) > 4 && (a.ex.web_lit_buttons() >> B.HOME & 1) === 1);
|
||||
check("silent at rest", a.peak === 0);
|
||||
a.ex.web_keys(1 << 7); // C4
|
||||
a.render(300);
|
||||
const keyLit = (a.ex.web_lit_keys() >> 7) & 1;
|
||||
a.ex.web_keys(0);
|
||||
a.render(400);
|
||||
check(`a key sounds (peak ${a.peak.toFixed(3)}) and lights its LED`, a.peak > 0.01 && keyLit === 1);
|
||||
a.render(1500);
|
||||
a.peak = 0;
|
||||
a.ex.web_midi(0x90, 64, 100); // Web MIDI: E4 on channel 1
|
||||
a.render(300);
|
||||
a.ex.web_midi(0x80, 64, 0);
|
||||
a.render(300);
|
||||
check(`a MIDI note in (USB-MIDI's queue) sounds (peak ${a.peak.toFixed(3)})`, a.peak > 0.01);
|
||||
const draws = a.ex.web_screen_draws();
|
||||
a.turn(EN.K1, 3);
|
||||
check("KNOB 1 redraws the screen", a.ex.web_screen_draws() > draws);
|
||||
a.tap(B.PLAY);
|
||||
a.render(1000);
|
||||
check("PLAY: the sequencer runs, PLAY's green LED", a.ex.web_playing() === 1 && (a.ex.web_lit_buttons() >> 14 & 1) === 1);
|
||||
a.tap(B.PLAY);
|
||||
a.render(300);
|
||||
check("PLAY again stops it", a.ex.web_playing() === 0);
|
||||
|
||||
// ---- a user preset saved from the panel, kept across a fresh instance
|
||||
const w0 = a.ex.web_flash_writes_count();
|
||||
a.tap(B.SAVE);
|
||||
a.tap(B.OCTUP);
|
||||
a.tap(B.OCTUP);
|
||||
a.render(200);
|
||||
const saved = storeSectors(new Uint8Array(a.mem.buffer, a.ex.web_nor(), a.ex.web_nor_size()));
|
||||
check(`SAVE, OCT+, OCT+: user preset 1 written (${Object.keys(saved).length} sectors kept)`,
|
||||
a.ex.web_test_user_preset(0) === 1 && a.ex.web_flash_writes_count() > w0 && Object.keys(saved).length > 0);
|
||||
const kept = JSON.parse(JSON.stringify(Object.fromEntries( // as the page keeps them (base64 in localStorage)
|
||||
Object.entries(saved).map(([k, v]) => [k, Buffer.from(v).toString("base64")]))));
|
||||
const b = await device(Object.fromEntries(Object.entries(kept).map(([k, v]) => [k, new Uint8Array(Buffer.from(v, "base64"))])));
|
||||
b.render(600);
|
||||
const c = await device(null);
|
||||
c.render(600);
|
||||
check("a fresh instance with the kept sectors has it; one without does not",
|
||||
b.ex.web_test_user_preset(0) === 1 && c.ex.web_test_user_preset(0) === 0);
|
||||
|
||||
// ---- deterministic: the same gestures, the same samples
|
||||
async function song() {
|
||||
const d = await device(null);
|
||||
d.render(500);
|
||||
d.ex.web_test_heavy();
|
||||
d.tap(B.PLAY);
|
||||
d.rec = true;
|
||||
d.render(2000);
|
||||
return d;
|
||||
}
|
||||
const s1 = await song(), s2 = await song();
|
||||
check(`the heavy song plays (peak ${s1.peak.toFixed(3)}), twice the same samples`, s1.peak > 0.05 && s1.sig === s2.sig);
|
||||
if (nativePath) { // web/emu/native_check.c: the same song, built with cc
|
||||
const nat = new Float32Array(new Uint8Array(fs.readFileSync(nativePath)).buffer);
|
||||
const web = s1.samples;
|
||||
let diff = nat.length === web.length ? 0 : Infinity;
|
||||
for (let i = 0; i < web.length && diff === 0; i++) if (nat[i] !== web[i]) diff = i + 1;
|
||||
check(`the same song from the native build (cc): ${web.length / 2} frames, ${diff === 0 ? "bit for bit" : "differs at " + diff}`, diff === 0);
|
||||
}
|
||||
|
||||
// ---- the cost: 1 s of the heavy song against real time (the best of 3, after 2 s to settle)
|
||||
let best = Infinity;
|
||||
s1.rec = false;
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const t0 = performance.now();
|
||||
s1.render(1000);
|
||||
best = Math.min(best, performance.now() - t0);
|
||||
}
|
||||
const ratio = best / 1000, max = +(process.env.BENCH_MAX || 0.5);
|
||||
check(`1 s of the heavy song (FM6 PHYS GRAIN chords + DRUM) in ${best.toFixed(1)} ms: ${(ratio * 100).toFixed(1)} % of real time`, ratio < max);
|
||||
console.log(fails ? `emu: ${fails} FAILED` : "emu: all ok");
|
||||
process.exit(fails ? 1 : 0);
|
||||
@@ -0,0 +1,420 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
||||
* The design (the device clock driven by the audio the worklet asks for, the exports below, the saved
|
||||
* flash handed back before boot) follows X0X's browser build, web/emu/x0x_web.c of charlesvestal/fm1-x0x
|
||||
* (GPL-3.0), a Felucca fork. */
|
||||
/* Felucca in the browser: the firmware's sources, as the host tests build them (tests/hostsim.c: libc,
|
||||
* engines, voices, FX, sequencer; then the UI, main.c, storage and projects, in src/felucca.c's order),
|
||||
* compiled to WebAssembly and run in an AudioWorklet against a simulated FM-1:
|
||||
* - the device clock: TIMER4 ticks (24 MHz) and fm1_ms advance with the audio the worklet asks for; the
|
||||
* audio ISR (audio.c fm1_alnk0_irq, the real one) renders each I2S half (HALF_FRAMES) as the DMA would
|
||||
* ask for it, and the main loop (main.c's, below in web_frame) runs every 15 ms, with ui_input on every
|
||||
* millisecond in between as main.c's wait loop calls it;
|
||||
* - the panel: buttons and encoders by their printed labels (panel.c's table maps them to the matrix),
|
||||
* the keys as fm1_in.notes, the LEDs read back from fm1_led / fm1_led_dim through the key matrix;
|
||||
* - the screen: lcd_fill / lcd_blit into a 240 x 240 RGB565 frame (the panel's byte order);
|
||||
* - the flash: a 1 MiB NOR image behind storage.c's hooks (settings, projects, user presets, the user
|
||||
* sample slots read through it as XIP); the page keeps its storage sectors and gives them back at boot.
|
||||
* Not here: USB (MIDI, audio, the editor, updates), TRS MIDI, the serial console, the battery (full), the
|
||||
* crash / UBOOT paths. Nothing of the firmware changes for this file.
|
||||
* web/emu/build.sh -> build/emu/{felucca.wasm, worklet.js, index.html} */
|
||||
#include <stdint.h>
|
||||
|
||||
#define FELUCCA_WEB 1
|
||||
#ifndef FELUCCA_CDC
|
||||
#define FELUCCA_CDC 1 /* as src/felucca.c: MENU > USB SERIAL is there (nothing behind it) */
|
||||
#endif
|
||||
#define FELUCCA_FLASH 1
|
||||
#define FELUCCA_OTA 0
|
||||
#define FELUCCA_UAC 0
|
||||
#define FELUCCA_UART 0
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "WEB"
|
||||
#endif
|
||||
|
||||
static uint8_t nor[0x100000]; /* the SPI NOR (erased: 0xFF) */
|
||||
#define SMP_USER_XIP(k) ((const uint8_t *)nor + SMP_USER_BASE + (k) * SMP_USER_SIZE) /* eng_sample.c */
|
||||
#define main hostsim_main
|
||||
#include "../../tests/hostsim.c"
|
||||
#undef main
|
||||
|
||||
/* ------------------------------------------------------------ the clock --- */
|
||||
#define FM1_TICKS_PER_US 24u /* TIMER4: 24 MHz */
|
||||
static uint32_t web_ticks;
|
||||
static uint32_t fm1_ticks(void) { return web_ticks; }
|
||||
|
||||
/* ------------------------------------------------------ audio (ALNK0) --- */
|
||||
static uint32_t web_half; /* the half the next render fills */
|
||||
#define FM1_AUDIO_HALF 1u
|
||||
static uint8_t fm1_audio_pending(void) { return FM1_AUDIO_HALF; }
|
||||
static void fm1_audio_ack_aux(uint8_t p) { (void)p; }
|
||||
static uint32_t fm1_audio_free_half(void) { return web_half; }
|
||||
static void fm1_audio_ack_half(void) {}
|
||||
static void fm1_audio_init(int32_t *buf, uint32_t words, void (*isr)(void), uint32_t prio)
|
||||
{ (void)buf; (void)words; (void)isr; (void)prio; }
|
||||
static void fm1_audio_stop(void) {}
|
||||
void isr_alnk0(void) {}
|
||||
#include "../../firmware/src/audio.c"
|
||||
|
||||
/* ------------------------------------------------------------ the panel --- */
|
||||
#define FM1_NCOL 11u
|
||||
static const int8_t FM1_KEYMAP[6][FM1_NCOL] = { /* as hal/fm1_input.h: key id at (column, row bit) */
|
||||
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
|
||||
{ 5, 11, 4, 10, 3, 9, 2, 8, -1, -1, -1},
|
||||
{34, 35, 36, 37, 38, 40, 39, 13, 7, 6, 12},
|
||||
{23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33},
|
||||
{ 0, 1, 15, 14, 17, 16, 19, 18, 20, 21, 22},
|
||||
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
|
||||
};
|
||||
static uint8_t fm1_led[FM1_NCOL], fm1_led_dim[FM1_NCOL];
|
||||
static uint32_t web_dim_lo;
|
||||
static void fm1_led_dim_level(uint32_t lo) { web_dim_lo = lo; }
|
||||
static uint32_t web_pressed, web_released, web_notes_pressed;
|
||||
static int32_t web_enc_steps[7];
|
||||
static uint32_t fm1_input_edges(uint32_t *released)
|
||||
{
|
||||
uint32_t p = web_pressed;
|
||||
if (released)
|
||||
*released = web_released;
|
||||
web_pressed = web_released = 0;
|
||||
return p;
|
||||
}
|
||||
static uint32_t fm1_input_note_edges(void) { uint32_t n = web_notes_pressed; web_notes_pressed = 0; return n; }
|
||||
static int32_t fm1_enc_take(uint32_t e) { int32_t s = web_enc_steps[e % 7u]; web_enc_steps[e % 7u] = 0; return s; }
|
||||
static void fm1_input_init(void) {}
|
||||
static void fm1_input_tick(void) {}
|
||||
static void fm1_wdt_feed(void) {}
|
||||
static void fm1_irq_off(void) {}
|
||||
static void fm1_irq_on(void) {}
|
||||
|
||||
/* ----------------------------------------------------------- the screen --- */
|
||||
static uint16_t web_fb[240 * 240]; /* RGB565 as the panel gets it (high byte first) */
|
||||
static uint32_t web_draws;
|
||||
static void lcd_fill(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t c)
|
||||
{
|
||||
uint32_t i, j;
|
||||
uint16_t sw = (uint16_t)((c >> 8) | (c << 8));
|
||||
for (j = 0; j < h && y + j < 240u; j++)
|
||||
for (i = 0; i < w && x + i < 240u; i++)
|
||||
web_fb[(y + j) * 240u + x + i] = sw;
|
||||
web_draws++;
|
||||
}
|
||||
static void lcd_blit(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const uint16_t *p)
|
||||
{
|
||||
uint32_t i, j;
|
||||
for (j = 0; j < h && y + j < 240u; j++)
|
||||
for (i = 0; i < w && x + i < 240u; i++)
|
||||
web_fb[(y + j) * 240u + x + i] = p[j * w + i];
|
||||
web_draws++;
|
||||
}
|
||||
static void lcd_sync(void) {}
|
||||
static void lcd_init(void) {}
|
||||
|
||||
#include "../../firmware/src/gfx.c"
|
||||
#include "../../firmware/src/panel.c"
|
||||
#include "../../firmware/src/ui.c"
|
||||
#include "../../firmware/src/menu_items.c"
|
||||
#include "../../firmware/src/icons.c"
|
||||
#include "../../firmware/src/ui_graph.c"
|
||||
#include "../../firmware/src/ui_draw.c"
|
||||
#include "../../firmware/src/ui_menu.c"
|
||||
#include "../../firmware/src/ui_input.c"
|
||||
#include "../../firmware/src/ui_layer.c"
|
||||
|
||||
/* ------------------------------------------------------------ the flash --- */
|
||||
static uint32_t web_flash_writes;
|
||||
static uint8_t flash_ok;
|
||||
static int st_read(uint32_t off, void *dst, uint32_t n)
|
||||
{
|
||||
if (off >= sizeof nor || n > sizeof nor - off)
|
||||
return -1;
|
||||
memcpy(dst, nor + off, n);
|
||||
return 0;
|
||||
}
|
||||
static int st_erase(uint32_t off)
|
||||
{
|
||||
if (off >= sizeof nor || 4096u > sizeof nor - off)
|
||||
return -8;
|
||||
memset(nor + (off & ~4095u), 0xFF, 4096);
|
||||
web_flash_writes++;
|
||||
return 0;
|
||||
}
|
||||
static int st_prog(uint32_t off, const void *src, uint32_t n) /* NOR: a write only clears bits */
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint32_t i;
|
||||
if (off >= sizeof nor || n > sizeof nor - off)
|
||||
return -8;
|
||||
for (i = 0; i < n; i++)
|
||||
nor[off + i] &= s[i];
|
||||
web_flash_writes++;
|
||||
return 0;
|
||||
}
|
||||
static uint32_t irq_save(void) { return 0; }
|
||||
static void irq_restore(uint32_t f) { (void)f; }
|
||||
static uint32_t fl_jedec_ram(void) { return 0x856014u; } /* the FM-1's part (project.c) */
|
||||
static void fl_plain_window_init(void) {}
|
||||
#define FL_FAR(fn) (fn)
|
||||
#include "../../firmware/src/storage.c"
|
||||
#include "../../firmware/src/upreset.c"
|
||||
#include "../../firmware/src/project.c"
|
||||
|
||||
/* ------------------------------------------------- main.c and its HAL --- */
|
||||
typedef struct { uint32_t vec, pc, emu, dbg, rets; } fm1_crash_t;
|
||||
static struct { uint8_t p3_rst, wdt_con; uint32_t rst_src; } fm1_boot;
|
||||
uint32_t _data_start[1], _data_end[1], _data_load[1], _bss_start[1], _bss_end[1];
|
||||
uint32_t _pool_start[1], _pool_end[1], _rt_start[1], _rt_end[1], _rt_load[1];
|
||||
static uint32_t web_master_adc = 700; /* MASTER, 0..1023 as the ADC reads it */
|
||||
enum { FM1_ADC_BATT = 3, FM1_ADC_MASTER = 4 };
|
||||
static int32_t fm1_adc_read(uint32_t ch) { return ch == FM1_ADC_MASTER ? (int32_t)web_master_adc : 620; }
|
||||
static void fm1_adc_init(void) {}
|
||||
static void fm1_timer5_ack(void) {}
|
||||
static void fm1_timer5_start(void (*isr)(void), uint32_t prio) { (void)isr; (void)prio; }
|
||||
void isr_timer5(void) {}
|
||||
static void fm1_reboot(void) {}
|
||||
static void fm1_enter_uboot(void) {}
|
||||
static void fm1_guard_lock_top(void) {}
|
||||
static void fm1_irq_enable_all(void) {}
|
||||
static void fm1_irq_init(void) {}
|
||||
static void fm1_time_init(void) {}
|
||||
static void fm1_reset_reason(void) {}
|
||||
static void fm1_wdt_arm(uint32_t v) { (void)v; }
|
||||
static void fm1_mailbox_clear(void) {}
|
||||
static void fm1_guard_enable(uint32_t m) { (void)m; }
|
||||
enum { FM1_GUARD_STACK = 1, FM1_GUARD_WRITE = 2, FM1_GUARD_BUS = 4, FM1_GUARD_PC = 8 };
|
||||
#if FELUCCA_CDC
|
||||
static void cdc_task(void) {}
|
||||
#endif
|
||||
/* main.c's calls into the USB driver (registers): nothing here (usb.c's own functions stay as they are) */
|
||||
#define usb_poll() ((void)0)
|
||||
#define usb_start() ((void)0)
|
||||
#define usb_retry(ms) ((void)(ms))
|
||||
#define usb_detach() ((void)0)
|
||||
#include "../../firmware/src/main.c"
|
||||
#undef usb_poll
|
||||
#undef usb_start
|
||||
#undef usb_retry
|
||||
#undef usb_detach
|
||||
|
||||
/* --------------------------------------------------------- the device --- */
|
||||
static uint32_t web_booted, web_boot_ms, web_last_frame;
|
||||
static int32_t web_knob = 512 * 16; /* main.c: the MASTER filter (ADC x 16) */
|
||||
|
||||
/* main.c fm1_main's boot, up to the main loop (no USB, no UART, no panel setup) */
|
||||
static void web_power_on(void)
|
||||
{
|
||||
persist_boot();
|
||||
settings_init();
|
||||
usb_serial_apply();
|
||||
lcd_init();
|
||||
lcd_fill(0, 0, 240, 240, T_BG);
|
||||
draw_text_box(0, 94, 240, &AF_L, "FELUCCA", T_THEME, 1);
|
||||
draw_text_box(0, 134, 240, &AF_S, "MULTI-ENGINE SYNTH", T_MID, 1);
|
||||
memset(&felucca_dbg, 0, sizeof felucca_dbg);
|
||||
felucca_dbg.magic = DBG_MAGIC;
|
||||
fm1_input_init();
|
||||
fm1_adc_init();
|
||||
panel_init();
|
||||
felucca_init();
|
||||
audio_init();
|
||||
web_boot_ms = fm1_ms + 430u; /* main.c: 30 + 400 ms before the first frame */
|
||||
web_booted = 1;
|
||||
}
|
||||
|
||||
/* one pass of main.c fm1_main's loop (what the browser has: no USB, editor, UBOOT, console) */
|
||||
static void web_frame(void)
|
||||
{
|
||||
int32_t b = fm1_adc_read(FM1_ADC_BATT), a = fm1_adc_read(FM1_ADC_MASTER);
|
||||
uint32_t k10;
|
||||
if (b > 0)
|
||||
song.batt_raw = song.batt_raw ? song.batt_raw + (b - song.batt_raw) / 32 : b;
|
||||
web_knob += (a * 16 - web_knob) / 8;
|
||||
k10 = (uint32_t)(web_knob / 16);
|
||||
song.master_q12 = (k10 * k10) >> 8;
|
||||
felucca_dbg.ui_frames++;
|
||||
ui_input();
|
||||
settings_poll();
|
||||
ui_leds();
|
||||
ui_draw();
|
||||
}
|
||||
|
||||
/* output ring, stereo float, filled by web_ms, drained by web_render */
|
||||
#define RING 4096u
|
||||
static float ring[RING * 2];
|
||||
static uint32_t ring_w, ring_r, web_samples_due;
|
||||
|
||||
/* one millisecond of the device: the clock, the audio halves due by now, the main loop */
|
||||
static void web_ms(void)
|
||||
{
|
||||
fm1_ms++;
|
||||
web_ticks += 1000u * FM1_TICKS_PER_US;
|
||||
web_samples_due += FS;
|
||||
while (web_samples_due >= 1000u * HALF_FRAMES) { /* an I2S half: the audio ISR renders it */
|
||||
uint32_t k;
|
||||
const int32_t *o = &abuf[web_half * HALF_WORDS];
|
||||
web_samples_due -= 1000u * HALF_FRAMES;
|
||||
fm1_alnk0_irq();
|
||||
for (k = 0; k < HALF_FRAMES; k++) {
|
||||
uint32_t i = (ring_w++ % RING) * 2u;
|
||||
ring[i] = (float)o[2u * k] / 8388608.0f;
|
||||
ring[i + 1] = (float)o[2u * k + 1u] / 8388608.0f;
|
||||
}
|
||||
web_half ^= 1u;
|
||||
}
|
||||
if (!web_booted || (int32_t)(fm1_ms - web_boot_ms) < 0)
|
||||
return;
|
||||
if (web_boot_ms) { /* main.c: the splash goes, the loop starts */
|
||||
web_boot_ms = 0;
|
||||
lcd_fill(0, 0, 240, 240, T_BG);
|
||||
web_last_frame = fm1_ms - 15u;
|
||||
}
|
||||
if (fm1_ms - web_last_frame >= 15u) { /* main.c: a frame, then ui_input until 15 ms are over */
|
||||
web_last_frame = fm1_ms;
|
||||
web_frame();
|
||||
} else {
|
||||
ui_input(); /* main.c's wait loop */
|
||||
}
|
||||
}
|
||||
|
||||
#define EXPORT __attribute__((used, visibility("default")))
|
||||
#undef __attribute__
|
||||
|
||||
static float out_l[1024], out_r[1024];
|
||||
EXPORT float *web_out_l(void) { return out_l; }
|
||||
EXPORT float *web_out_r(void) { return out_r; }
|
||||
/* n frames (<= 1024) into out_l / out_r: the device runs until they exist */
|
||||
EXPORT void web_render(uint32_t n)
|
||||
{
|
||||
uint32_t k;
|
||||
if (n > 1024u)
|
||||
n = 1024u;
|
||||
while (ring_w - ring_r < n)
|
||||
web_ms();
|
||||
for (k = 0; k < n; k++) {
|
||||
uint32_t i = (ring_r++ % RING) * 2u;
|
||||
out_l[k] = ring[i];
|
||||
out_r[k] = ring[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* the flash: erased, then the page's saved sectors (web_nor), then boot */
|
||||
EXPORT uint8_t *web_nor(void) { return nor; }
|
||||
EXPORT uint32_t web_nor_size(void) { return sizeof nor; }
|
||||
EXPORT void web_nor_erase(void) { memset(nor, 0xFF, sizeof nor); }
|
||||
EXPORT uint32_t web_flash_writes_count(void) { return web_flash_writes; }
|
||||
EXPORT void web_boot(void)
|
||||
{
|
||||
if (!web_booted)
|
||||
web_power_on();
|
||||
}
|
||||
|
||||
/* input, by the printed labels: buttons bit b = B_FX .. B_OCTUP (panel.c), keys bit k = key k (F3 .. G5),
|
||||
* encoders by role (EN_SELECT .. EN_K4), MASTER 0..1023 */
|
||||
static uint32_t web_btn_labels, web_key_mask;
|
||||
EXPORT void web_buttons(uint32_t labels)
|
||||
{
|
||||
uint32_t m = 0, b, old = fm1_in.buttons;
|
||||
web_btn_labels = labels;
|
||||
for (b = 0; b < NB; b++)
|
||||
if ((labels >> b) & 1u)
|
||||
m |= 1u << panel.btn[b];
|
||||
web_pressed |= m & ~old;
|
||||
web_released |= old & ~m;
|
||||
fm1_in.buttons = m;
|
||||
}
|
||||
EXPORT void web_keys(uint32_t mask)
|
||||
{
|
||||
uint32_t old = fm1_in.notes;
|
||||
mask &= (1u << 27) - 1u;
|
||||
web_key_mask = mask;
|
||||
web_notes_pressed |= mask & ~old;
|
||||
fm1_in.notes = mask;
|
||||
}
|
||||
EXPORT void web_enc(uint32_t role, int32_t n)
|
||||
{
|
||||
if (role < NE)
|
||||
web_enc_steps[panel.enc[role] % 7u] += n * panel.dir[role];
|
||||
}
|
||||
EXPORT void web_master(uint32_t v) { web_master_adc = v > 1023u ? 1023u : v; }
|
||||
/* a channel message from Web MIDI, as a USB-MIDI packet arrives (usb.c midi_enqueue): 0 = the ring was full */
|
||||
EXPORT uint32_t web_midi(uint32_t status, uint32_t d1, uint32_t d2)
|
||||
{
|
||||
if (status < 0x80u || status >= 0xF0u)
|
||||
return 1;
|
||||
return (uint32_t)midi_enqueue((status >> 4) | status << 8 | (d1 & 127u) << 16 | (d2 & 127u) << 24, 1);
|
||||
}
|
||||
|
||||
/* the LEDs: bit b = the button labelled b lit (bit 14: PLAY's green), keys bit k; the dim glow alike */
|
||||
static uint32_t led_on(const uint8_t *l, uint32_t id)
|
||||
{
|
||||
uint32_t c, r;
|
||||
for (c = 0; c < FM1_NCOL; c++)
|
||||
for (r = 1; r < 5u; r++)
|
||||
if (FM1_KEYMAP[r][c] == (int8_t)id)
|
||||
return (l[c] >> r) & 1u;
|
||||
return 0;
|
||||
}
|
||||
static uint32_t led_buttons(const uint8_t *l)
|
||||
{
|
||||
uint32_t b, m = 0;
|
||||
for (b = 0; b < NB; b++)
|
||||
m |= led_on(l, panel.btn[b]) << b;
|
||||
return m;
|
||||
}
|
||||
static uint32_t led_keys(const uint8_t *l)
|
||||
{
|
||||
uint32_t k, m = 0;
|
||||
for (k = 0; k < 27u; k++)
|
||||
m |= led_on(l, 14u + k) << k;
|
||||
return m;
|
||||
}
|
||||
EXPORT uint32_t web_lit_buttons(void)
|
||||
{
|
||||
return led_buttons(fm1_led) | ((fm1_led[LED_PLAY_GREEN >> 3] >> (LED_PLAY_GREEN & 7u)) & 1u) << 14;
|
||||
}
|
||||
EXPORT uint32_t web_lit_keys(void) { return led_keys(fm1_led); }
|
||||
EXPORT uint32_t web_dim_buttons(void) { return led_buttons(fm1_led_dim); }
|
||||
EXPORT uint32_t web_dim_keys(void) { return led_keys(fm1_led_dim); }
|
||||
EXPORT uint32_t web_dim_level(void) { return web_dim_lo; }
|
||||
|
||||
/* for the test and the bench (web/emu/emu_test.mjs), a heavy song straight into the tracks (as hostsim's
|
||||
* renders set them): T1 FM6 PAD, T2 PHYS DRONE STRING (SYMP), T3 GRAIN CLOUD PAD, 4-note chords on all 16
|
||||
* steps, held; T4 DRUM, kick snare and hats. PLAY is the page's (or the test's) to press */
|
||||
EXPORT void web_test_heavy(void)
|
||||
{
|
||||
static const uint8_t ENG[3][2] = {{12, 4}, {ENGI_PHYS, 7}, {8, 0}};
|
||||
static const uint8_t CH[4][4] = {{48, 55, 60, 64}, {45, 52, 57, 60}, {41, 48, 53, 57}, {43, 50, 55, 59}};
|
||||
uint32_t p, i;
|
||||
for (p = 0; p < 3u; p++) {
|
||||
track_t *t = &trk[p];
|
||||
host_preset(t, ENG[p][0], ENG[p][1]);
|
||||
t->p[P_VOICE] = V_POLY;
|
||||
t->p[P_SUS] = 127;
|
||||
for (i = 0; i < 16u; i++) {
|
||||
uint8_t n[4], k;
|
||||
for (k = 0; k < 4u; k++)
|
||||
n[k] = (uint8_t)(CH[i / 4u][k] + 12u * p);
|
||||
put_step(t, i, 4, n, ST_NOTE, 0);
|
||||
}
|
||||
}
|
||||
host_drums(&trk[3]);
|
||||
for (i = 0; i < 16u; i++) {
|
||||
uint8_t n[4];
|
||||
uint32_t k = 0;
|
||||
if (i % 4u == 0u)
|
||||
n[k++] = 36;
|
||||
if (i == 4u || i == 12u)
|
||||
n[k++] = 38;
|
||||
n[k++] = i % 2u ? 42 : 46;
|
||||
put_step(&trk[3], i, k, n, ST_NOTE, 0);
|
||||
}
|
||||
ui.force = 1;
|
||||
}
|
||||
|
||||
EXPORT uint32_t web_test_user_preset(uint32_t i) { return (uint32_t)up_used(i); }
|
||||
|
||||
EXPORT uint16_t *web_screen(void) { return web_fb; }
|
||||
EXPORT uint32_t web_screen_draws(void) { return web_draws; }
|
||||
EXPORT uint32_t web_now_ms(void) { return fm1_ms; }
|
||||
EXPORT uint32_t web_playing(void) { return song.playing; }
|
||||
EXPORT uint32_t web_sample_rate(void) { return FS; }
|
||||
@@ -0,0 +1,460 @@
|
||||
<!doctype html>
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only
|
||||
Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
||||
The page follows X0X's browser page, web/emu/index.html of charlesvestal/fm1-x0x (GPL-3.0), a Felucca fork. -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Felucca</title>
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 16 16%22%3E%3Crect width=%2216%22 height=%2216%22 rx=%223%22/%3E%3Crect x=%224%22 y=%224%22 width=%228%22 height=%228%22 fill=%22%23fff%22/%3E%3C/svg%3E">
|
||||
<meta name="description" content="Felucca, the multi-engine synth firmware for the FM-1, running in your browser: the same code the instrument runs.">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=DotGothic16&display=swap">
|
||||
<style>
|
||||
:root { --bg: #8e8e93; --fg: #111; --dim: #2c2c2e; --rule: #5a5a5e;
|
||||
--body: #1d1d1f; --tray: #141415; --part: #2a2a2d; --edge: #3a3a3e; --label: #d6d6d8;
|
||||
--lit: #fff4d6; --green: #5fe08a; color-scheme: light; }
|
||||
html, body { background: var(--bg); }
|
||||
body { margin: 0; color: var(--fg); font: 13px/1.6 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; }
|
||||
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 32px; }
|
||||
@media (orientation: portrait) and (max-width: 700px) { main { padding: 8px 8px 24px; } }
|
||||
a { color: inherit; }
|
||||
.device { position: relative; width: 100%; aspect-ratio: 1000 / 624; user-select: none; -webkit-user-select: none;
|
||||
-webkit-touch-callout: none; touch-action: manipulation; }
|
||||
.device svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
||||
.device canvas { position: absolute; image-rendering: crisp-edges; image-rendering: pixelated; background: #000; }
|
||||
.hit { position: absolute; touch-action: none; cursor: pointer; -webkit-tap-highlight-color: transparent; border-radius: 10px; }
|
||||
.hit.knob { cursor: ns-resize; border-radius: 50%; }
|
||||
.hit:focus-visible { outline: 2px solid var(--lit); outline-offset: 2px; }
|
||||
.face { transition: fill .05s; }
|
||||
.dim .face.btn { fill: #3a3934; }
|
||||
.lit .face.btn { fill: var(--lit); }
|
||||
.lit text { fill: #1d1d1f; }
|
||||
.green .face.btn { fill: var(--green); }
|
||||
.green text { fill: #0d2414; }
|
||||
.face.key { fill: #0c0c0d; stroke: var(--edge); stroke-width: 1.5; }
|
||||
.slit { fill: #3a3a3c; transition: fill .05s; }
|
||||
.dim .slit { fill: #77777b; }
|
||||
.lit .slit { fill: #ececee; filter: drop-shadow(0 0 3px rgba(255, 255, 255, .6)); }
|
||||
.held .face { stroke: var(--lit); stroke-width: 3; }
|
||||
.latched .face { stroke: #79b8ff; stroke-width: 3; }
|
||||
.start { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
|
||||
background: rgba(0, 0, 0, .5); border-radius: 4% / 6%; }
|
||||
.start[hidden] { display: none; }
|
||||
.start button { font: inherit; font-size: 18px; padding: 12px 28px; background: #fff; color: #000; border: 0; cursor: pointer; }
|
||||
.start button:disabled { opacity: .4; cursor: progress; }
|
||||
.start p { margin: 0; max-width: 32em; text-align: center; color: #fff; }
|
||||
.keys, footer { margin: 16px 0 0; color: var(--dim); text-align: center; }
|
||||
.keys span { white-space: nowrap; margin: 0 8px; }
|
||||
kbd { font: 600 11px ui-monospace, Menlo, monospace; border: 1px solid var(--rule); padding: 0 4px; color: var(--fg); }
|
||||
footer { margin-top: 12px; font-size: 12px; }
|
||||
footer nav a { margin: 0 6px; }
|
||||
.preview { margin: 0 0 6px; color: var(--fg); }
|
||||
footer small { font-size: 11px; opacity: .8; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="device" id="device">
|
||||
<svg id="panel" viewBox="0 0 1000 624" aria-hidden="true"></svg>
|
||||
<canvas id="screen" width="240" height="240" role="img" aria-label="The screen"></canvas>
|
||||
<div class="start" id="start"><button id="go" type="button">Switch on</button><p id="status" hidden></p></div>
|
||||
</div>
|
||||
|
||||
<p class="keys">
|
||||
<span><kbd>Z</kbd>–<kbd>'</kbd> <kbd>Q</kbd>–<kbd>O</kbd> keys</span>
|
||||
<span><kbd>1</kbd>–<kbd>=</kbd> FX … REC</span>
|
||||
<span><kbd>[</kbd> <kbd>]</kbd> OCT</span>
|
||||
<span><kbd>↑</kbd> <kbd>↓</kbd> SELECT</span>
|
||||
<span><kbd>←</kbd> <kbd>→</kbd> ALGORITHM</span>
|
||||
<span><kbd>Shift</kbd>-click holds a button</span>
|
||||
</p>
|
||||
|
||||
<footer>
|
||||
<p class="preview">Preview of Felucca @VERSION@, the next version: some features aren't on the installer yet.</p>
|
||||
Felucca by Leo Kuroshita, Hügelton Instruments · <a href="https://www.gnu.org/licenses/gpl-3.0.html">GPL-3.0</a> · browser build after charlesvestal's <a href="https://github.com/charlesvestal/fm1-x0x">X0X</a><br>
|
||||
<nav><a href="../installer/">Install</a><a href="../editor/">Editor</a><a href="https://github.com/hugelton/Felucca">Source</a></nav>
|
||||
<small>M-VAVE and FM-1 are trademarks of their respective owners. Felucca is not affiliated with or endorsed by them.</small>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
<script type="module">
|
||||
const NS = "http://www.w3.org/2000/svg";
|
||||
// panel.c's labels (bit = label) and encoder roles
|
||||
const B = { FX: 0, SCL: 1, ENV: 2, LFO: 3, EDIT: 4, GLO: 5, HOME: 6, SAVE: 7, ARP: 8, SEQ: 9, PLAY: 10, REC: 11, "OCT-": 12, "OCT+": 13 };
|
||||
const EN = { SELECT: 0, ALGORITHM: 1, PRESETS: 2, "KNOB 1": 3, "KNOB 2": 4, "KNOB 3": 5, "KNOB 4": 6 };
|
||||
const PLAY_GREEN = 14;
|
||||
// the 27 keys F3..G5: key k = k semitones above F3
|
||||
const WHITE = [0, 2, 4, 6, 7, 9, 11, 12, 14, 16, 18, 19, 21, 23, 24, 26];
|
||||
const BLACK = [1, 3, 5, 8, 10, 13, 15, 17, 20, 22, 25];
|
||||
const BLACK_AFTER = [0, 1, 2, 4, 5, 7, 8, 9, 11, 12, 14]; // the white key each black one follows
|
||||
const STORE = "felucca-emu-flash";
|
||||
|
||||
// ------------------------------------------------------------------ the panel
|
||||
// Two drawings of the same controls: WIDE after the FM-1's own layout, TALL for a phone held upright (the
|
||||
// screen larger, the keys across the whole width). Rebuilt when the orientation changes; the state stays.
|
||||
const ROW1 = ["FX", "SCL", "ENV", "LFO", "EDIT", "GLO"], ROW2 = ["HOME", "SAVE", "ARP", "SEQ", "PLAY", "REC"];
|
||||
const KNOBS = ["MASTER", "SELECT", "PRESETS", "ALGORITHM", "KNOB 1", "KNOB 2", "KNOB 3", "KNOB 4"];
|
||||
const LAYOUTS = {
|
||||
wide: {
|
||||
w: 1000, h: 624, screen: [292, 44, 256],
|
||||
knobs: [[105, 100, 24], [215, 100, 24], [105, 205, 24], [215, 205, 24], [610, 100, 22], [714, 100, 22], [818, 100, 22], [922, 100, 22]],
|
||||
trays: [[50, 250, 220, 50], [568, 160, 400, 140]],
|
||||
oct: [[60, 258, 90, 34], [170, 258, 90, 34]],
|
||||
grid: [582, 174, 54, 48, 63, 62], keybed: [36, 332, 928, 256],
|
||||
},
|
||||
tall: {
|
||||
w: 600, h: 1070, screen: [130, 104, 340],
|
||||
knobs: [[66, 64, 24], [186, 64, 24], [414, 64, 24], [534, 64, 24], [90, 512, 26], [230, 512, 26], [370, 512, 26], [510, 512, 26]],
|
||||
trays: [[14, 572, 572, 146], [150, 728, 300, 62]],
|
||||
oct: [[164, 737, 128, 44], [308, 737, 128, 44]],
|
||||
grid: [24, 582, 86, 60, 94, 70], keybed: [14, 800, 572, 256],
|
||||
},
|
||||
};
|
||||
const svg = document.getElementById("panel"), device = document.getElementById("device"), canvas = document.getElementById("screen");
|
||||
function el(tag, attrs, parent = svg) {
|
||||
const e = document.createElementNS(NS, tag);
|
||||
for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v);
|
||||
parent.appendChild(e);
|
||||
return e;
|
||||
}
|
||||
const SANS = "-apple-system, 'Helvetica Neue', Arial, sans-serif", DOT = "'DotGothic16', " + SANS;
|
||||
function label(parent, x, y, s, size, font = SANS, ink = "var(--label)") {
|
||||
const t = el("text", { x, y, "text-anchor": "middle", "font-family": font,
|
||||
"font-size": size, "font-weight": 600, fill: ink, "letter-spacing": ".04em" }, parent);
|
||||
t.textContent = s;
|
||||
return t;
|
||||
}
|
||||
const KEYNAMES = ["F", "F♯", "G", "G♯", "A", "A♯", "B", "C", "C♯", "D", "D♯", "E"];
|
||||
const keyName = (k) => KEYNAMES[k % 12] + (3 + Math.floor((k + 5) / 12));
|
||||
|
||||
let node = null, btnMask = 0, keyMask = 0, latched = 0, masterValue = 700, lastLeds = [0, 0, 0, 0, 0], layout = null;
|
||||
const angle = Object.fromEntries(KNOBS.map((n) => [n, 0]));
|
||||
angle.MASTER = -135 + 270 * masterValue / 1023;
|
||||
const knobs = [], buttons = [], keys = [];
|
||||
const btnBy = new Map(), keyBy = new Map(); // pointer / key code -> label bit or key
|
||||
const send = (m) => { if (node) node.port.postMessage(m); };
|
||||
|
||||
function build(name) {
|
||||
const L = LAYOUTS[name];
|
||||
layout = name;
|
||||
svg.innerHTML = "";
|
||||
svg.setAttribute("viewBox", `0 0 ${L.w} ${L.h}`);
|
||||
device.style.aspectRatio = `${L.w} / ${L.h}`;
|
||||
for (const d of device.querySelectorAll(".hit")) d.remove();
|
||||
knobs.length = buttons.length = keys.length = 0;
|
||||
el("rect", { x: 4, y: 4, width: L.w - 8, height: L.h - 8, rx: 40, fill: "var(--body)" });
|
||||
for (const [x, y, w, h] of L.trays) el("rect", { x, y, width: w, height: h, rx: 14, fill: "var(--tray)" });
|
||||
const [sx, sy, ss] = L.screen;
|
||||
el("rect", { x: sx, y: sy, width: ss, height: ss, rx: 18, fill: "#0b0b0c" });
|
||||
const inset = ss / 32; // the 240 x 240 panel inside its bezel
|
||||
Object.assign(canvas.style, { left: `${(sx + inset) / L.w * 100}%`, top: `${(sy + inset) / L.h * 100}%`,
|
||||
width: `${(ss - 2 * inset) / L.w * 100}%`, height: `${(ss - 2 * inset) / L.h * 100}%` });
|
||||
KNOBS.forEach((n, i) => {
|
||||
const [x, y, r] = L.knobs[i], g = el("g", {});
|
||||
el("circle", { cx: x, cy: y, r: r + 5, fill: "var(--tray)" }, g);
|
||||
el("circle", { cx: x, cy: y, r, fill: "var(--part)", stroke: "var(--edge)", "stroke-width": 2 }, g);
|
||||
const ind = n === "MASTER" ? el("line", { x1: x, y1: y - r + 5, x2: x, y2: y - r + 14, stroke: "var(--label)", "stroke-width": 3, "stroke-linecap": "round" }, g) : null;
|
||||
label(g, x, y - r - 12, n, 16, DOT);
|
||||
el("circle", { cx: x, cy: y, r: r + 12, fill: "transparent" }, g);
|
||||
knobs.push({ g, ind, x, y, name: n, role: n === "MASTER" ? "master" : EN[n] });
|
||||
});
|
||||
const button = ([x, y, w, h], n, sub) => {
|
||||
const g = el("g", {});
|
||||
el("rect", { x, y, width: w, height: h, rx: 8, fill: "var(--part)", stroke: "var(--edge)", "stroke-width": 1.5, class: "face btn" }, g);
|
||||
const ink = n === "REC" ? "#ff453a" : undefined;
|
||||
if (sub) { label(g, x + w / 2, y + h / 2 - 2, n, 10.8, SANS, ink); label(g, x + w / 2, y + h / 2 + 11, sub, 9.9); }
|
||||
else label(g, x + w / 2, y + h / 2 + 4.5, n, 12.6, SANS, ink);
|
||||
buttons.push({ g, bit: B[n], name: sub ? `${n} / ${sub}` : n });
|
||||
};
|
||||
button(L.oct[0], "OCT-");
|
||||
button(L.oct[1], "OCT+");
|
||||
const [gx, gy, gw, gh, dx, dy] = L.grid;
|
||||
for (let i = 0; i < 6; i++) {
|
||||
button([gx + i * dx, gy, gw, gh], ROW1[i]);
|
||||
button([gx + i * dx, gy + dy, gw, gh], ROW2[i], ROW2[i] === "PLAY" ? "STOP" : "");
|
||||
}
|
||||
const [x0, y0, w, h] = L.keybed;
|
||||
el("rect", { x: x0, y: y0, width: w, height: h, rx: 18, fill: "var(--tray)" });
|
||||
// the keys: two rows of the same black keys, each with a slit down its middle that lights
|
||||
const pitch = (w - 24) / 16, kw = pitch * 0.78, kh = h * 0.425, sw = Math.max(3, kw * 0.14);
|
||||
const key = (cx, cy, k) => {
|
||||
const g = el("g", {}), y = cy - kh / 2;
|
||||
el("rect", { x: cx - kw / 2, y, width: kw, height: kh, rx: kw / 2, class: "face key" }, g);
|
||||
el("rect", { x: cx - sw / 2, y: y + kw * 0.4, width: sw, height: kh - kw * 0.8, rx: sw / 2, class: "slit" }, g);
|
||||
el("rect", { x: cx - pitch / 2, y: cy - h * 0.24, width: pitch, height: h * 0.48, fill: "transparent" }, g); // its target
|
||||
keys[k] = { g, name: keyName(k) };
|
||||
};
|
||||
WHITE.forEach((k, i) => key(x0 + 12 + (i + 0.5) * pitch, y0 + h * 0.75, k));
|
||||
BLACK_AFTER.forEach((a, j) => key(x0 + 12 + (a + 1) * pitch, y0 + h * 0.25, BLACK[j]));
|
||||
// HTML targets over the drawing (pointer-events: none): touch-action and pointer capture work on them everywhere
|
||||
const hit = (c, cls, role) => {
|
||||
const b = c.g.getBBox(), d = document.createElement("div");
|
||||
d.className = "hit" + (cls ? " " + cls : "");
|
||||
Object.assign(d.style, { left: `${b.x / L.w * 100}%`, top: `${b.y / L.h * 100}%`,
|
||||
width: `${b.width / L.w * 100}%`, height: `${b.height / L.h * 100}%` });
|
||||
d.setAttribute("role", role);
|
||||
d.setAttribute("aria-label", c.name);
|
||||
d.title = c.name;
|
||||
d.tabIndex = 0;
|
||||
d.addEventListener("touchstart", (e) => e.preventDefault(), { passive: false });
|
||||
d.addEventListener("contextmenu", (e) => e.preventDefault());
|
||||
device.insertBefore(d, document.getElementById("start"));
|
||||
c.hit = d;
|
||||
};
|
||||
knobs.forEach((k) => { hit(k, "knob", "slider"); bindKnob(k); drawKnob(k); });
|
||||
buttons.forEach((b) => { hit(b, "", "button"); bindButton(b); });
|
||||
keys.forEach((k, i) => { hit(k, "", "button"); bindKey(k, i); });
|
||||
syncButtons(true);
|
||||
syncKeys(true);
|
||||
drawLights(lastLeds);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ input
|
||||
function syncButtons(redraw) {
|
||||
let m = latched;
|
||||
for (const b of btnBy.values()) m |= 1 << b;
|
||||
if (m !== btnMask) { btnMask = m; send({ type: "buttons", mask: m }); }
|
||||
else if (!redraw) return;
|
||||
for (const b of buttons) {
|
||||
const on = !!(m & (1 << b.bit));
|
||||
b.g.classList.toggle("held", on);
|
||||
b.g.classList.toggle("latched", !!(latched & (1 << b.bit)));
|
||||
b.hit.setAttribute("aria-pressed", on);
|
||||
}
|
||||
}
|
||||
function syncKeys(redraw) {
|
||||
let m = 0;
|
||||
for (const k of keyBy.values()) m |= 1 << k;
|
||||
if (m !== keyMask) { keyMask = m; send({ type: "keys", mask: m }); }
|
||||
else if (!redraw) return;
|
||||
keys.forEach((k, i) => k.g.classList.toggle("held", !!(m & (1 << i))));
|
||||
}
|
||||
function bindButton(b) {
|
||||
b.hit.addEventListener("pointerdown", (e) => {
|
||||
e.preventDefault();
|
||||
if (e.shiftKey || e.button === 2) { latched ^= 1 << b.bit; syncButtons(true); return; }
|
||||
if (latched & (1 << b.bit)) { latched &= ~(1 << b.bit); syncButtons(true); return; }
|
||||
b.hit.setPointerCapture(e.pointerId);
|
||||
btnBy.set("p" + e.pointerId, b.bit);
|
||||
syncButtons();
|
||||
});
|
||||
b.hit.addEventListener("keydown", (e) => {
|
||||
if ((e.key === "Enter" || e.key === " ") && !e.repeat) { btnBy.set("f" + b.bit, b.bit); syncButtons(); e.preventDefault(); e.stopPropagation(); }
|
||||
});
|
||||
b.hit.addEventListener("keyup", () => { if (btnBy.delete("f" + b.bit)) syncButtons(); });
|
||||
}
|
||||
function bindKey(k, i) {
|
||||
k.hit.addEventListener("pointerdown", (e) => {
|
||||
e.preventDefault();
|
||||
k.hit.setPointerCapture(e.pointerId);
|
||||
keyBy.set("p" + e.pointerId, i);
|
||||
syncKeys();
|
||||
});
|
||||
}
|
||||
function release(e) {
|
||||
const id = "p" + e.pointerId;
|
||||
if (btnBy.delete(id)) syncButtons();
|
||||
if (keyBy.delete(id)) syncKeys();
|
||||
}
|
||||
for (const t of ["pointerup", "pointercancel", "lostpointercapture"]) device.addEventListener(t, release);
|
||||
|
||||
function drawKnob(k) { if (k.ind) k.ind.setAttribute("transform", `rotate(${angle[k.name]} ${k.x} ${k.y})`); }
|
||||
function turn(k, n) {
|
||||
if (!n) return;
|
||||
if (k.role === "master") {
|
||||
masterValue = Math.max(0, Math.min(1023, masterValue + n * 16));
|
||||
angle.MASTER = -135 + 270 * masterValue / 1023;
|
||||
send({ type: "master", value: masterValue });
|
||||
} else {
|
||||
angle[k.name] = (angle[k.name] + n * 18) % 360; // 20 detents a turn
|
||||
send({ type: "enc", role: k.role, n });
|
||||
}
|
||||
drawKnob(k);
|
||||
}
|
||||
function bindKnob(k) {
|
||||
let drag = null, wheel = 0;
|
||||
k.hit.addEventListener("pointerdown", (e) => {
|
||||
e.preventDefault();
|
||||
k.hit.setPointerCapture(e.pointerId);
|
||||
drag = { y: e.clientY, acc: 0 };
|
||||
});
|
||||
k.hit.addEventListener("pointermove", (e) => {
|
||||
if (!drag) return;
|
||||
drag.acc += drag.y - e.clientY;
|
||||
drag.y = e.clientY;
|
||||
const step = k.role === "master" ? 3 : 8, n = Math.trunc(drag.acc / step);
|
||||
if (n) { drag.acc -= n * step; turn(k, n); }
|
||||
});
|
||||
const end = () => { drag = null; };
|
||||
k.hit.addEventListener("pointerup", end);
|
||||
k.hit.addEventListener("pointercancel", end);
|
||||
k.hit.addEventListener("wheel", (e) => {
|
||||
e.preventDefault();
|
||||
const dy = e.deltaMode === 1 ? e.deltaY * 33 : e.deltaY;
|
||||
if (Math.abs(dy) >= 50) { turn(k, dy < 0 ? 1 : -1); wheel = 0; return; } // a wheel notch: one detent
|
||||
wheel -= dy; // a trackpad: by distance
|
||||
const n = Math.trunc(wheel / 25);
|
||||
if (n) { wheel -= n * 25; turn(k, n); }
|
||||
}, { passive: false });
|
||||
k.hit.addEventListener("keydown", (e) => {
|
||||
const d = { ArrowUp: 1, ArrowRight: 1, ArrowDown: -1, ArrowLeft: -1 }[e.key];
|
||||
if (d) { turn(k, d); e.preventDefault(); e.stopPropagation(); }
|
||||
});
|
||||
}
|
||||
const tall = matchMedia("(orientation: portrait) and (max-width: 700px)");
|
||||
build(tall.matches ? "tall" : "wide");
|
||||
tall.addEventListener("change", () => build(tall.matches ? "tall" : "wide"));
|
||||
document.fonts?.load("16px DotGothic16").then(() => build(layout), () => {}); // the labels' width: the hit areas
|
||||
|
||||
// the computer keyboard, every key one control: F3..A#4 on the Z (white) and A (black) rows, B4..G5 on Q..O
|
||||
// in semitones, the twelve buttons on the number row in the panel's order (held while the key is), [ ] OCT
|
||||
const KEYMAP = {};
|
||||
["KeyZ", "KeyX", "KeyC", "KeyV", "KeyB", "KeyN", "KeyM", "Comma", "Period", "Slash"].forEach((c, i) => KEYMAP[c] = { key: WHITE[i] });
|
||||
[["KeyS", 1], ["KeyD", 3], ["KeyF", 5], ["KeyH", 8], ["KeyJ", 10], ["KeyL", 13], ["Semicolon", 15], ["Quote", 17]].forEach(([c, k]) => KEYMAP[c] = { key: k });
|
||||
["KeyQ", "KeyW", "KeyE", "KeyR", "KeyT", "KeyY", "KeyU", "KeyI", "KeyO"].forEach((c, i) => KEYMAP[c] = { key: 18 + i });
|
||||
["Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "Digit0", "Minus", "Equal"]
|
||||
.forEach((c, i) => KEYMAP[c] = { btn: B[[...ROW1, ...ROW2][i]] });
|
||||
Object.assign(KEYMAP, { BracketLeft: { btn: B["OCT-"] }, BracketRight: { btn: B["OCT+"] } });
|
||||
const ARROWS = { ArrowUp: [EN.SELECT, 1], ArrowDown: [EN.SELECT, -1], ArrowRight: [EN.ALGORITHM, 1], ArrowLeft: [EN.ALGORITHM, -1] };
|
||||
addEventListener("keydown", (e) => {
|
||||
if (!node || e.metaKey || e.ctrlKey || e.altKey || e.target.closest?.(".hit.knob")) return;
|
||||
if (ARROWS[e.code]) { const [r, n] = ARROWS[e.code]; turn(knobs.find((k) => k.role === r), n); e.preventDefault(); return; }
|
||||
const m = KEYMAP[e.code];
|
||||
if (!m) return;
|
||||
e.preventDefault();
|
||||
if (e.repeat) return;
|
||||
if (m.key !== undefined) { keyBy.set("k" + e.code, m.key); syncKeys(); }
|
||||
else { btnBy.set("k" + e.code, m.btn); syncButtons(); }
|
||||
});
|
||||
addEventListener("keyup", (e) => {
|
||||
const id = "k" + e.code;
|
||||
if (keyBy.delete(id)) syncKeys();
|
||||
if (btnBy.delete(id)) syncButtons();
|
||||
});
|
||||
addEventListener("blur", () => {
|
||||
for (const id of [...btnBy.keys()]) if (id[0] !== "p") btnBy.delete(id);
|
||||
for (const id of [...keyBy.keys()]) if (id[0] !== "p") keyBy.delete(id);
|
||||
syncButtons();
|
||||
syncKeys();
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------ screen and lights
|
||||
const ctx = document.getElementById("screen").getContext("2d");
|
||||
const img = ctx.createImageData(240, 240);
|
||||
function drawScreen(fb) {
|
||||
const d = img.data;
|
||||
for (let i = 0; i < 240 * 240; i++) {
|
||||
const v = fb[i], p = ((v >> 8) | (v << 8)) & 0xFFFF; // the panel's byte order -> RGB565
|
||||
d[i * 4] = ((p >> 11) & 31) * 255 / 31;
|
||||
d[i * 4 + 1] = ((p >> 5) & 63) * 255 / 63;
|
||||
d[i * 4 + 2] = (p & 31) * 255 / 31;
|
||||
d[i * 4 + 3] = 255;
|
||||
}
|
||||
ctx.putImageData(img, 0, 0);
|
||||
}
|
||||
function drawLights([litB, litK, dimB, dimK]) {
|
||||
for (const b of buttons) {
|
||||
const bit = 1 << b.bit, green = b.bit === B.PLAY && (litB & (1 << PLAY_GREEN));
|
||||
b.g.classList.toggle("lit", !!(litB & bit) && !green);
|
||||
b.g.classList.toggle("green", !!green);
|
||||
b.g.classList.toggle("dim", !!(dimB & bit));
|
||||
}
|
||||
keys.forEach((k, i) => {
|
||||
k.g.classList.toggle("lit", !!(litK & (1 << i)));
|
||||
k.g.classList.toggle("dim", !!(dimK & (1 << i)));
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ the flash, kept in this browser
|
||||
function loadFlash() {
|
||||
try {
|
||||
const raw = JSON.parse(localStorage.getItem(STORE) || "{}"), out = {};
|
||||
for (const [off, b64] of Object.entries(raw)) out[off] = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
||||
return out;
|
||||
} catch { return {}; }
|
||||
}
|
||||
function saveFlash(sectors) {
|
||||
try {
|
||||
const raw = {};
|
||||
for (const [off, u8] of Object.entries(sectors)) {
|
||||
let s = "";
|
||||
for (let i = 0; i < u8.length; i += 4096) s += String.fromCharCode.apply(null, u8.subarray(i, i + 4096));
|
||||
raw[off] = btoa(s);
|
||||
}
|
||||
localStorage.setItem(STORE, JSON.stringify(raw));
|
||||
return true;
|
||||
} catch { return false; } // private mode, full: this session only
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ Web MIDI in (channel messages)
|
||||
async function midiOn() {
|
||||
if (!navigator.requestMIDIAccess) return;
|
||||
try {
|
||||
const access = await navigator.requestMIDIAccess();
|
||||
const bind = () => {
|
||||
for (const input of access.inputs.values()) {
|
||||
input.onmidimessage = (e) => {
|
||||
const d = e.data;
|
||||
if (d.length >= 2 && d[0] >= 0x80 && d[0] < 0xF0) send({ type: "midi", data: [d[0], d[1], d[2] || 0] });
|
||||
};
|
||||
}
|
||||
};
|
||||
access.onstatechange = bind;
|
||||
bind();
|
||||
} catch { /* no permission: the panel only */ }
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ switching on
|
||||
const status = document.getElementById("status");
|
||||
const say = (t) => { status.textContent = t; status.hidden = !t; };
|
||||
async function switchOn() {
|
||||
const go = document.getElementById("go");
|
||||
go.disabled = true;
|
||||
go.textContent = "Starting…";
|
||||
try {
|
||||
const ac = new AudioContext({ sampleRate: 44100, latencyHint: "interactive" });
|
||||
const [wasm] = await Promise.all([
|
||||
fetch("felucca.wasm").then((r) => { if (!r.ok) throw new Error(`felucca.wasm: ${r.status}`); return r.arrayBuffer(); }),
|
||||
ac.audioWorklet.addModule("worklet.js")]);
|
||||
node = new AudioWorkletNode(ac, "felucca", { numberOfInputs: 0, numberOfOutputs: 1, outputChannelCount: [2] });
|
||||
node.connect(ac.destination);
|
||||
let warned = false;
|
||||
await new Promise((res, rej) => {
|
||||
node.port.onmessage = (e) => {
|
||||
const m = e.data;
|
||||
if (m.type === "ready") res();
|
||||
else if (m.type === "error") rej(new Error(m.message));
|
||||
else if (m.type === "frame") {
|
||||
if (m.fb) drawScreen(m.fb);
|
||||
if (m.leds) drawLights(lastLeds = m.leds);
|
||||
if (m.sectors && !saveFlash(m.sectors) && !warned) {
|
||||
warned = true;
|
||||
console.warn("Felucca: this browser does not keep the saves; they last until the page closes.");
|
||||
}
|
||||
}
|
||||
};
|
||||
node.port.postMessage({ type: "load", wasm, sectors: loadFlash(), master: masterValue }, [wasm]);
|
||||
});
|
||||
await ac.resume();
|
||||
document.getElementById("start").hidden = true;
|
||||
go.textContent = "On";
|
||||
if (ac.sampleRate !== 44100) console.warn(`Felucca: the browser plays at ${ac.sampleRate} Hz, the pitch is off by ${(1200 * Math.log2(ac.sampleRate / 44100)).toFixed(0)} cents.`);
|
||||
syncButtons();
|
||||
syncKeys();
|
||||
send({ type: "visible", on: !document.hidden });
|
||||
midiOn();
|
||||
} catch (err) {
|
||||
node = null;
|
||||
go.disabled = false;
|
||||
go.textContent = "Switch on";
|
||||
say("Could not start: " + (err && err.message || err) + ". A current Chrome, Edge, Firefox or Safari should work.");
|
||||
}
|
||||
}
|
||||
document.getElementById("go").addEventListener("click", switchOn);
|
||||
document.addEventListener("visibilitychange", () => send({ type: "visible", on: !document.hidden }));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,41 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* web/emu/felucca_web.c built natively (cc, as the host tests), playing emu_test.mjs's heavy song with the same
|
||||
* gestures and the same render calls: its samples, float32 L R interleaved, to OUT. emu_test.mjs compares the
|
||||
* WebAssembly build's against them (the browser plays what the host build plays).
|
||||
* cc -O2 -ffp-contract=off -w -Ibuild/gen -Ifirmware/src -o build/emu/native_check web/emu/native_check.c -lm
|
||||
* build/emu/native_check OUT.f32 */
|
||||
#include "felucca_web.c"
|
||||
|
||||
static FILE *out;
|
||||
static int rec;
|
||||
static void render(double ms) /* as emu_test.mjs: 128-frame calls, the last one shorter */
|
||||
{
|
||||
uint32_t n = (uint32_t)(ms * 44.1 + 0.5), k, i;
|
||||
for (k = 0; k < n; k += 128u) {
|
||||
uint32_t m = n - k < 128u ? n - k : 128u;
|
||||
web_render(m);
|
||||
for (i = 0; rec && i < m; i++) {
|
||||
float s[2] = {out_l[i], out_r[i]};
|
||||
fwrite(s, sizeof s, 1, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2 || !(out = fopen(argv[1], "wb")))
|
||||
return 2;
|
||||
web_nor_erase();
|
||||
web_boot();
|
||||
render(500);
|
||||
web_test_heavy();
|
||||
web_buttons(1u << B_PLAY);
|
||||
render(60);
|
||||
web_buttons(0);
|
||||
render(60);
|
||||
rec = 1;
|
||||
render(2000);
|
||||
fclose(out);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
||||
// Felucca in an AudioWorklet: felucca.wasm is the whole FM-1 firmware against a simulated FM-1
|
||||
// (web/emu/felucca_web.c). Each render quantum asks it for 128 frames, which runs the device's clock forward;
|
||||
// between quanta the page's input goes in and, about 30 times a second (4 when the page is hidden), the screen,
|
||||
// the lights and any changed flash go out. After X0X's web/emu/worklet.js (charlesvestal/fm1-x0x, GPL-3.0).
|
||||
|
||||
// The flash the page keeps: storage.c's areas (projects, user presets and their FM6 patches, the user sample
|
||||
// slots 0x97000..0xDFFFF; the settings and the second FM6 copy 0xFC000..0xFFFFF), only the sectors that hold
|
||||
// something (an erased sector is all 0xFF). {offset: bytes}
|
||||
export const STORE_AREAS = [[0x97000, 0xE0000], [0xFC000, 0x100000]];
|
||||
export function storeSectors(nor) {
|
||||
const out = {};
|
||||
for (const [a, b] of STORE_AREAS)
|
||||
for (let off = a; off < b; off += 4096) {
|
||||
const s = nor.subarray(off, off + 4096);
|
||||
if (s.some((v) => v !== 0xFF)) out[off] = s.slice();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
export function restoreSectors(nor, sectors) {
|
||||
for (const [k, v] of Object.entries(sectors || {})) {
|
||||
const off = +k, b = v instanceof Uint8Array ? v : new Uint8Array(v);
|
||||
if (STORE_AREAS.some(([a, e]) => off >= a && off + 4096 <= e && off % 4096 === 0) && b.length === 4096)
|
||||
nor.set(b, off);
|
||||
}
|
||||
}
|
||||
|
||||
export const HOLD_MS = 24;
|
||||
|
||||
if (typeof registerProcessor === "function") {
|
||||
const clock = globalThis.performance ? () => globalThis.performance.now() : () => Date.now();
|
||||
class Felucca extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.ex = null;
|
||||
this.sentDraws = -1;
|
||||
this.sentWrites = -1;
|
||||
this.sentLeds = "";
|
||||
this.lastFrame = 0;
|
||||
this.period = 1 / 30;
|
||||
this.busy = 0;
|
||||
this.frames = 0;
|
||||
this.queue = []; // button / key changes, each held >= HOLD_MS of device time
|
||||
this.nextOk = 0;
|
||||
this.port.onmessage = (e) => this.onMessage(e.data);
|
||||
}
|
||||
|
||||
async onMessage(m) {
|
||||
if (m.type === "load") {
|
||||
try {
|
||||
const { instance } = await WebAssembly.instantiate(m.wasm, {});
|
||||
const ex = instance.exports;
|
||||
ex._initialize();
|
||||
ex.web_nor_erase();
|
||||
restoreSectors(new Uint8Array(ex.memory.buffer, ex.web_nor(), ex.web_nor_size()), m.sectors);
|
||||
ex.web_master(m.master ?? 700);
|
||||
ex.web_boot();
|
||||
this.ex = ex;
|
||||
this.sentWrites = ex.web_flash_writes_count();
|
||||
this.port.postMessage({ type: "ready", rate: ex.web_sample_rate() });
|
||||
} catch (err) {
|
||||
this.port.postMessage({ type: "error", message: String(err && err.message || err) });
|
||||
}
|
||||
return;
|
||||
}
|
||||
const ex = this.ex;
|
||||
if (!ex) return;
|
||||
if (m.type === "buttons" || m.type === "keys") this.queue.push(m);
|
||||
else if (m.type === "enc") ex.web_enc(m.role, m.n | 0);
|
||||
else if (m.type === "master") ex.web_master(m.value | 0);
|
||||
else if (m.type === "midi") ex.web_midi(m.data[0] | 0, m.data[1] | 0, m.data[2] | 0);
|
||||
else if (m.type === "visible") this.period = m.on ? 1 / 30 : 1 / 4;
|
||||
}
|
||||
|
||||
publish() {
|
||||
const ex = this.ex, mem = ex.memory.buffer;
|
||||
const msg = { type: "frame" };
|
||||
const leds = [ex.web_lit_buttons(), ex.web_lit_keys(), ex.web_dim_buttons(), ex.web_dim_keys(), ex.web_dim_level()];
|
||||
const key = leds.join(",");
|
||||
if (key !== this.sentLeds) {
|
||||
this.sentLeds = key;
|
||||
msg.leds = leds;
|
||||
}
|
||||
if (this.frames >= 44100) { // the share of real time spent running the device
|
||||
msg.load = this.busy / (this.frames / 44.1);
|
||||
this.busy = this.frames = 0;
|
||||
}
|
||||
const transfer = [];
|
||||
const draws = ex.web_screen_draws();
|
||||
if (draws !== this.sentDraws) {
|
||||
this.sentDraws = draws;
|
||||
msg.fb = new Uint16Array(mem, ex.web_screen(), 240 * 240).slice();
|
||||
transfer.push(msg.fb.buffer);
|
||||
}
|
||||
const writes = ex.web_flash_writes_count();
|
||||
if (writes !== this.sentWrites) { // a save is done within one main-loop pass: whole here
|
||||
this.sentWrites = writes;
|
||||
msg.sectors = storeSectors(new Uint8Array(mem, ex.web_nor(), ex.web_nor_size()));
|
||||
}
|
||||
if (msg.leds || msg.fb || msg.sectors || msg.load !== undefined) this.port.postMessage(msg, transfer);
|
||||
}
|
||||
|
||||
// A click's down and up can arrive within one render quantum, but the FM-1's contacts never close for less than
|
||||
// its debounce, and the UI reads them once a frame: each change of the buttons or the keys stays HOLD_MS of the
|
||||
// device's time before the next one goes in (a tap: down for a frame and more, then up).
|
||||
input() {
|
||||
const ex = this.ex, now = ex.web_now_ms();
|
||||
while (this.queue.length && now - this.nextOk >= 0) {
|
||||
const m = this.queue.shift();
|
||||
if (m.type === "buttons") ex.web_buttons(m.mask >>> 0);
|
||||
else ex.web_keys(m.mask >>> 0);
|
||||
this.nextOk = now + HOLD_MS;
|
||||
}
|
||||
}
|
||||
|
||||
process(inputs, outputs) {
|
||||
const ex = this.ex;
|
||||
if (!ex) return true;
|
||||
if (this.queue.length) this.input();
|
||||
const out = outputs[0], n = out[0].length;
|
||||
const t0 = clock();
|
||||
ex.web_render(n);
|
||||
this.busy += clock() - t0;
|
||||
this.frames += n;
|
||||
out[0].set(new Float32Array(ex.memory.buffer, ex.web_out_l(), n));
|
||||
if (out[1]) out[1].set(new Float32Array(ex.memory.buffer, ex.web_out_r(), n));
|
||||
if (currentTime - this.lastFrame >= this.period) {
|
||||
this.lastFrame = currentTime;
|
||||
this.publish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
registerProcessor("felucca", Felucca);
|
||||
}
|
||||
+34
-1
@@ -38,7 +38,8 @@ const E = vm.runInNewContext(proto + `
|
||||
;({ frame, unframe, parse, req, Link, parseWav, resample, normalize, takeSample, autoTrim, zoomView, rootFromName, buildSlot, makeMockDevice, CMD, SMP,
|
||||
UP, bank, capturePatch, auditionPatch, startWatch, libraryFile, readLibraryFile, paramKeys, patternFromSteps, stepsFromPattern, upName,
|
||||
mixer, parseNotes, parseHits, hitsText, gridFromSteps, LANE_NOTE, LANE_OF, readDevicePreferences, devicePresetRows, engineOrder, ENGINE_ORDER, aliasOf, fmtValue, FM6, enumShown, F,
|
||||
FM4, fromDigital, fromPerc, DRUM_KIT_E })`,
|
||||
FM4, fromDigital, fromPerc, DRUM_KIT_E,
|
||||
MENU: typeof MENU === "undefined" ? null : MENU, readDeviceMenu: typeof readDeviceMenu === "undefined" ? null : readDeviceMenu })`,
|
||||
{ setTimeout, clearTimeout, setInterval, clearInterval, console });
|
||||
|
||||
async function editorMock() {
|
||||
@@ -153,6 +154,32 @@ async function editorMock() {
|
||||
}
|
||||
const none = await E.readDevicePreferences(() => { throw new Error("unexpected request"); }, { uiCaps: 0 }, []);
|
||||
ok(none === null, "editor: old firmware receives no unsupported preference requests");
|
||||
if (!E.readDeviceMenu) console.log(`${"editor: MENU settings (this editor has none)".padEnd(64)} skip`);
|
||||
else { /* the MENU settings (1.0.4): INFO 4E 01 count, MENU_DESC (72), MENU_SET (73) */
|
||||
ok(info.menuCount === 12, "editor: INFO advertises the MENU settings (4E 01 12)");
|
||||
const items = await E.readDeviceMenu(rq, info);
|
||||
ok(items.length === 12 && items.map((d) => d.id).join() === "0,1,2,3,4,5,6,7,8,9,10,11" &&
|
||||
items.map((d) => d.name).join() === "COLOR,STYLE,LARGE,ANIM,LEDS,HOLD,KNOB ACCEL,FX LATCH,BPM LOCK,SPEAKER EQ,USB LEVEL,USB SERIAL" &&
|
||||
items.every((d) => d.kind === 0 && d.min === 0 && d.names.length === d.max - d.min + 1) &&
|
||||
eq(items[0].names, prefs.palettes) && items[0].value === m.state.palette &&
|
||||
items[4].names.join() === "OFF,DIM LO,DIM HI,INV" && items[4].value === 2 && items[5].value === 1,
|
||||
"editor: MENU_DESC lists every setting, its value names and value");
|
||||
ok(E.parse[E.CMD.MENU_DESC](await rq(E.req.menuDesc(12))).id === 127, "editor: MENU_DESC past the list answers id 127");
|
||||
let r = E.parse[E.CMD.MENU_SET](await rq(E.req.menuSet(4, 3)));
|
||||
ok(r.rc === 0 && r.id === 4 && r.value === 3 && E.parse[E.CMD.MENU_DESC](await rq(E.req.menuDesc(4))).value === 3,
|
||||
"editor: MENU_SET round trip (LEDS INV)");
|
||||
const pal = m.state.palette;
|
||||
r = E.parse[E.CMD.MENU_SET](await rq(E.req.menuSet(0, 50)));
|
||||
ok(r.rc === 0 && r.value === 9 && E.parse[E.CMD.UI_STATE](await rq(E.req.uiState())).palette === 9,
|
||||
"editor: MENU_SET clamps (COLOR 50 -> 9), the same setting as UI_SET 0");
|
||||
ok(E.parse[E.CMD.MENU_SET](await rq(E.req.menuSet(12, 1))).rc === 1, "editor: MENU_SET of an unknown id: rc 1");
|
||||
await rq(E.req.menuSet(0, pal)); await rq(E.req.menuSet(4, 2));
|
||||
const d = E.parse[E.CMD.MENU_DESC]([3, 20, 1, 5, 64, 0, 64, 100, 64, 88, 0, 109, 115, 0]);
|
||||
ok(d.kind === 1 && d.value === 5 && d.max === 100 && d.name === "X" && d.unit === "ms" && d.names === null,
|
||||
"editor: MENU_DESC kind 1 (a number): its unit");
|
||||
ok((await E.readDeviceMenu(() => { throw new Error("unexpected request"); }, { menuCount: 0 })).length === 0,
|
||||
"editor: firmware without MENU settings is not asked");
|
||||
}
|
||||
await rq(E.req.uiSet(3, 0));
|
||||
const scale = E.parse[E.CMD.DESC](await rq(E.req.desc(0, 26)));
|
||||
const scaleNames = ["CHR", "MAJ", "MIN", "DOR", "MIX", "PEN", "MPEN", "HARM", "PHRY", "LYD", "LOC", "MEL", "BLUES", "WHOLE", "DIMHW", "DIMWH"];
|
||||
@@ -295,6 +322,12 @@ function mockTables() {
|
||||
cmp("FM6 patches (init, factory, bank size)", T.FM6, fw.FM6);
|
||||
cmp("DRUM grid: the lanes' GM notes", [...E.LANE_NOTE], fw.LANE_NOTE);
|
||||
cmp("DRUM grid: the lane of GM 35..81", E.LANE_OF, fw.LANE_OF);
|
||||
const mj = join(DESC, "../menu.json");
|
||||
if (E.MENU && existsSync(mj)) { /* the MENU settings: tests/editor_test.c's MENU_DESC replies */
|
||||
const fm = JSON.parse(readFileSync(mj, "utf8"));
|
||||
cmp("MENU settings", E.MENU.map((x) => ({ id: x.id, kind: 0, min: 0, max: (x.names || m2.state.palettes).length - 1,
|
||||
value: x.def, name: x.name, names: x.names || m2.state.palettes })), fm);
|
||||
}
|
||||
diffs.slice(0, 20).forEach((d) => console.log(" " + d));
|
||||
ok(!diffs.length, `editor: mock tables == firmware (${diffs.length} differences)`);
|
||||
/* #31: percent values as the firmware formats them (param_format), SWG 0..100 shows its value */
|
||||
|
||||
Reference in new issue
Block a user