mirror of
https://github.com/ruppert/fmini-1.git
synced 2026-12-06 04:44:27 +01:00
The three engines and their 126 KB of factory IMA samples are gone, with the sample slots (80 KiB x 3 in flash), the SLICES page, the sample waveform, the web editor's sample protocol and the slice store. Their engine numbers stay (4, 8, 13): a track, a project or a user preset that names one is silent and is never offered, through a stub like DIGITAL's (ENG_RETIRED, engines.c). Image 536.6 KB -> 394.9 KB; RAM .data+.bss 65.9 KB -> 60.1 KB. The sample flash region 0xA0000..0xDBFFF is free for user presets. Protocol: SMP_BEGIN/WRITE/END/ERASE (11..14) get no reply; SMP_INFO answers 0 slots so the editor hides its Samples tab; backup ids 32..34 are gone. The PERC conversion (SAMPLE PERC -> DRUM) stays. See web/EDITOR_PROTOCOL.md. Tests: sample_test, slice_test, fuzz_smp removed; the others follow. Golden renders of the retired engines removed; target budgets for their functions removed and the ISR / mix_part costs updated on purpose. Known, unchanged failures: fm4, union_test, the regress hashes of Felucca's engines (66 changed at 1.12 too), web mock tables. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94
186 lines
10 KiB
C
186 lines
10 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
|
/* Engine table (order = PRESETS browsing order and the engine numbers of the editor protocol), the
|
|
* factory patterns (SAVE > PHRASES) and the parts' sounds at power-on. */
|
|
#include "../engines/src/dsp.c" /* Felucca-Engines (MIT): the shared DSP blocks */
|
|
|
|
/* The parts' engine memory (1.5): a part plays one engine at a time, so the engines with large per-part state
|
|
* (engine_t.mem: PHYS's slots, GRAIN's grains and index, DRUM's lanes, FM6's notes, SLICE's reverse windows)
|
|
* keep it in one region per part instead of an array each. The region holds the state of the engine that
|
|
* last claimed it (eng_mem_owner); a switch to another such engine zeroes its engine_t.mem bytes, which is
|
|
* the state each had at power-on, so a switch sounds as it did with the arrays (tests/union_test.c). State
|
|
* that runs on across notes and switches stays outside (WHEEL's wheels, GRAIN's random numbers).
|
|
* Sized by the largest, PHYS (3 x SYMP's slot); an engine that needs more than ENG_MEM_PART grows it for
|
|
* every part (x NPART of the pool). Zero-initialised pool section: main.c fm1_cstart clears it. */
|
|
#define ENG_MEM_PART 12888u
|
|
static union {
|
|
uint64_t align;
|
|
uint8_t b[ENG_MEM_PART];
|
|
} eng_mem[NPART] __attribute__((section(".pool")));
|
|
static uint8_t eng_mem_owner[NPART]; /* engine index + 1 whose state is in the region, 0 = none (zeros) */
|
|
#define ENG_MEM(p) ((void *)eng_mem[p].b) /* part p's region (p < NPART) */
|
|
#define ENG_MEM_FITS(name, size) _Static_assert((size) <= ENG_MEM_PART, name " state over ENG_MEM_PART")
|
|
|
|
#include "../engines/src/eng_analog.c" /* Felucca-Engines (MIT): ANALOG LOFI TRIO WHEEL NOISE */
|
|
#include "eng_phase.c"
|
|
#include "../engines/src/eng_lofi.c"
|
|
#include "eng_formant.c"
|
|
#include "../engines/src/eng_trio.c"
|
|
#include "../engines/src/eng_wheel.c"
|
|
#include "eng_phys.c" /* PHYS: DaisySP physical models (phys_dsp.c, MIT) */
|
|
#include "eng_drum.c" /* DRUM: the 8-lane kit (drum_voice.c) */
|
|
#include "../engines/src/eng_noise.c"
|
|
#include "eng_fm6.c" /* FM6: 6-operator FM, msfa ported (fm6_core.c, Apache-2.0) */
|
|
#include "fm4_convert.c" /* DIGITAL's tables, and its sounds -> FM6 */
|
|
#include "eng_fmini.c" /* FMINI (FMini-1): a three-oscillator ladder-filter monosynth */
|
|
#if FELUCCA_FM4
|
|
#include "eng_digital.c" /* DIGITAL: four-operator FM (retired; FELUCCA_FM4=1 builds it) */
|
|
#endif
|
|
|
|
/* the retired engines (SAMPLE 4, GRAIN 8, SLICE 13; 1.13): their numbers stay (projects, presets and the protocol
|
|
* hold them), their code is gone. A track that still has one is silent and is never offered (eng_ok): no presets,
|
|
* no memory, no sound. Like DIGITAL's stub (fm4_convert.c), the number is never picked again. */
|
|
static void retired_note_on(struct track *t, voice_t *v) { (void)t; (void)v; }
|
|
static void retired_render(struct track *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
|
|
{
|
|
(void)t; (void)v; (void)out; (void)n; (void)m;
|
|
}
|
|
static const engine_t ENG_RETIRED = {
|
|
.name = "-",
|
|
.page_title = {"-", "-"},
|
|
.edit = {{"-", F_INT, 0, 0, 0, 0, 0}, {"-", F_INT, 0, 0, 0, 0, 0}, {"-", F_INT, 0, 0, 0, 0, 0}, {"-", F_INT, 0, 0, 0, 0, 0},
|
|
{"-", F_INT, 0, 0, 0, 0, 0}, {"-", F_INT, 0, 0, 0, 0, 0}, {"-", F_INT, 0, 0, 0, 0, 0}, {"-", F_INT, 0, 0, 0, 0, 0}},
|
|
.note_on = retired_note_on,
|
|
.render = retired_render,
|
|
.knob = {P_E4, P_E5, P_E6, P_REL},
|
|
};
|
|
|
|
/* the editor protocol, user presets and projects store these indices: append, never reorder */
|
|
static const engine_t *const ENGINES[NENGINES] = {
|
|
&ENG_ANALOG, /* 0 */
|
|
#if FELUCCA_FM4
|
|
&ENG_DIGITAL, /* 1 (ENGI_DIGITAL) */
|
|
#else
|
|
&ENG_FM4_GONE, /* 1: reserved (DIGITAL, retired: its sounds convert to FM6, fm4_convert.c) */
|
|
#endif
|
|
&ENG_PHASE, /* 2 */
|
|
&ENG_LOFI, /* 3 */
|
|
&ENG_RETIRED, /* 4: SAMPLE (retired 1.13: its sounds are silent, not offered) */
|
|
&ENG_FORMANT, /* 5 VOICE (eng_formant.c: "voice" is a sounding note in voice.c) */
|
|
&ENG_TRIO, /* 6 */
|
|
&ENG_WHEEL, /* 7 */
|
|
&ENG_RETIRED, /* 8: GRAIN (retired 1.13) */
|
|
&ENG_PHYS, /* 9 (ENGI_PHYS) */
|
|
&ENG_DRUM, /* 10 (ENGI_DRUM) */
|
|
&ENG_NOISE, /* 11 */
|
|
&ENG_FM6, /* 12 (ENGI_FM6) */
|
|
&ENG_RETIRED, /* 13: SLICE (retired 1.13) */
|
|
&ENG_FMINI, /* 14 (ENGI_FMINI) */
|
|
};
|
|
|
|
/* 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; }
|
|
|
|
/* part t's engine memory goes to its engine (t->engine; voice.c engine_block, once a block: on a switch, after
|
|
* the old engine's fade, before any note on the new one): zeroed (its engine_t.mem bytes) when another
|
|
* engine's state is in it. An engine without memory leaves it as it is: a switch back finds its state. */
|
|
static void eng_mem_claim(const track_t *t)
|
|
{
|
|
uint32_t p = (uint32_t)(t - trk), e, k, n;
|
|
uint32_t *w;
|
|
if (p >= NPART)
|
|
return;
|
|
e = eng_idx(t->engine);
|
|
n = ENGINES[e]->mem;
|
|
if (!n || eng_mem_owner[p] == e + 1u)
|
|
return;
|
|
w = (uint32_t *)ENG_MEM(p);
|
|
for (k = 0; k < (n + 3u) / 4u; k++)
|
|
w[k] = 0;
|
|
eng_mem_owner[p] = (uint8_t)(e + 1u);
|
|
}
|
|
|
|
/* 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 */
|
|
static const uint8_t ENGINE_ORDER[NENG_SHOWN] = {
|
|
0, /* ANALOG */
|
|
12, /* FM6 */
|
|
ENGI_FMINI, /* FMINI */
|
|
#if FELUCCA_FM4
|
|
1, /* DIGITAL */
|
|
#endif
|
|
2, 3, 5, 6, 7, 9, /* PHASE LOFI VOICE TRIO WHEEL PHYS */
|
|
11, /* NOISE */
|
|
10, /* DRUM */
|
|
};
|
|
|
|
/* the engines one can pick (engine 1 only with FELUCCA_FM4), in ENGINE_ORDER: eng_ok(e), the n-th of them
|
|
* eng_vis(n), e's place among them eng_rank(e), the next / previous one eng_step(e, dir) (wraps) */
|
|
static int eng_ok(uint32_t e)
|
|
{
|
|
return e < NENGINES && (FELUCCA_FM4 || e != ENGI_DIGITAL) && e != ENGI_SAMPLE && e != ENGI_GRAIN && e != ENGI_SLICE;
|
|
}
|
|
static uint32_t eng_vis(uint32_t n) { return ENGINE_ORDER[n % NENG_SHOWN]; }
|
|
static uint32_t eng_rank(uint32_t e)
|
|
{
|
|
uint32_t n;
|
|
if (!eng_ok(e))
|
|
e = ENGI_FM6; /* (DIGITAL without FELUCCA_FM4: its sounds play as FM6) */
|
|
for (n = 0; n < NENG_SHOWN && ENGINE_ORDER[n] != e; n++)
|
|
;
|
|
return n < NENG_SHOWN ? n : 0u;
|
|
}
|
|
static uint32_t eng_step(uint32_t e, int32_t dir)
|
|
{
|
|
return eng_vis((eng_rank(e % NENGINES) + (dir > 0 ? 1u : NENG_SHOWN - 1u)) % NENG_SHOWN);
|
|
}
|
|
|
|
/* factory sequence patterns: SAVE > PHRASES loads one into the selected track (ui.c pat_load); a preset
|
|
* only suggests one with PAT(n), loading a sound never touches the steps. Absolute notes, loaded as they
|
|
* are (DRUM plays them as GM drums, SLICE as slices; SCL TRANS and OCT transpose): 0 = rest;
|
|
* flags 1 = accent, 2 = slide, 4 = tie (holds the previous note). Names: at most 8 characters */
|
|
#define T_ 4
|
|
static const struct {
|
|
const char *name;
|
|
uint8_t note[16], flags[16];
|
|
} PATTERNS[] = {
|
|
{"ACID", {45, 45, 57, 45, 0, 48, 45, 55, 45, 0, 57, 52, 45, 48, 0, 50}, /* 1 */
|
|
{1, 0, 2, 0, 0, 0, 1, 2, 0, 0, 1, 0, 0, 2, 0, 1}},
|
|
{"OFFBEAT", {0, 36, 0, 36, 0, 36, 0, 48, 0, 36, 0, 36, 0, 39, 0, 43}, /* 2 bass */
|
|
{0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}},
|
|
{"MELODY", {60, 0, 67, 0, 72, 67, 0, 64, 62, 0, 69, 0, 74, 69, 0, 67}, /* 3 pluck */
|
|
{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}},
|
|
{"LEAD", {72, 0, 0, 74, 0, 0, 76, 0, 79, 0, 76, 0, 74, 0, 0, 0}, /* 4 */
|
|
{1, T_, 0, 2, T_, 0, 0, 0, 1, 0, 2, 0, 0, T_, T_, 0}},
|
|
{"PAD", {60, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 55, 0, 0, 0}, /* 5 long notes */
|
|
{0, T_, T_, T_, T_, T_, T_, 0, 0, T_, T_, 0, 0, T_, T_, 0}},
|
|
{"KEYS", {0, 0, 60, 0, 0, 63, 0, 0, 0, 0, 60, 0, 0, 65, 0, 63}, /* 6 offbeat stabs */
|
|
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}},
|
|
{"BELL", {72, 0, 0, 79, 0, 0, 84, 0, 0, 0, 76, 0, 0, 0, 0, 0}, /* 7 sparse */
|
|
{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
{"SUB", {36, 0, 0, 0, 0, 0, 0, 36, 0, 0, 34, 0, 0, 0, 0, 0}, /* 8 low, held */
|
|
{1, T_, T_, T_, 0, 0, 0, 0, 0, 0, 0, T_, T_, T_, 0, 0}},
|
|
/* SLICE (retired 1.13: these stay, the factory patterns keep their numbers) */
|
|
{"CHOP", {60, 61, 62, 67, 64, 65, 60, 69, 68, 70, 62, 67, 72, 72, 74, 64}, /* 9 16 slices re-ordered */
|
|
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
|
|
{"STUTTER", {60, 60, 61, 61, 62, 0, 63, 63, 64, 65, 65, 0, 66, 66, 66, 67}, /* 10 8 slices, repeats */
|
|
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
|
|
{"SLICES", {60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75}, /* 11 in order */
|
|
{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}},
|
|
/* DRUM (General MIDI: 36 kick, 38 snare, 42 closed / 46 open hi-hat) */
|
|
{"BEAT", {36, 42, 42, 42, 38, 42, 36, 42, 36, 42, 42, 36, 38, 42, 46, 42}, /* 12 */
|
|
{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}},
|
|
/* 16ths up a C minor arpeggio, twice: the line the ARP presets (RAVE, ARP 8BIT, ARP LEAD) suggest
|
|
* now that the arpeggiator is the track's and a preset no longer switches it on */
|
|
{"ARP", {48, 51, 55, 60, 63, 67, 72, 75, 48, 51, 55, 60, 63, 67, 72, 75}, /* 13 */
|
|
{1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}},
|
|
};
|
|
#undef T_
|
|
#define NPATTERNS (sizeof PATTERNS / sizeof PATTERNS[0])
|
|
|
|
/* the parts at power-on (engine, preset, PATTERNS[n - 1] in the sequencer, 0 = empty: all are): bass, pad, lead, drums */
|
|
static const uint8_t TRK_DEF[NPART][3] = {{0, 4, 0}, {ENGI_FM6, 4, 0}, {3, 0, 0}, {ENGI_DRUM, 0, 0}}; /* ANALOG ACID,
|
|
* FM6 PAD (was DIGITAL PAD), LOFI PULSE LD, DRUM KIT */
|
|
static uint32_t trk_def_engine(uint32_t i) { return TRK_DEF[i % NPART][0]; }
|