mirror of
https://github.com/isod89/sloop-fm1.git
synced 2026-12-06 21:04:24 +01:00
SLOOP 2.2: new drum engine, 68 sounds by kind, grand piano, stereo effects
This commit is contained in:
1 parent
e421e4362e
commit
f2b44c219b
73 files changed
+2087
-545
No files matched your search
+3
-1
@@ -39,7 +39,8 @@ typedef struct {
|
||||
enum { /* per-track parameters */
|
||||
P_LEVEL,
|
||||
P_ATK, P_DEC, P_SUS, P_REL,
|
||||
P_ED_FLT, P_ED_PIT, P_ED_SHP, P_ED_FX, /* P_ED_FX: unused, kept for the formats / protocol */
|
||||
P_ED_FLT, P_ED_PIT, P_ED_SHP, P_ED_FX, /* P_ED_FX: the sound's level trim (1/2 dB), set by the presets so
|
||||
* every factory sound comes out as loud as the others (fx.c) */
|
||||
P_LRATE, P_LWAVE, P_LPHASE, P_LFADE,
|
||||
P_LD_PIT, P_LD_FLT, P_LD_SHP, P_LD_AMP,
|
||||
P_AMODE, P_ARATE, P_AOCT, P_AGATE,
|
||||
@@ -217,6 +218,7 @@ typedef struct track {
|
||||
uint8_t mono_note; /* note the MONO / LEGATO / UNISON voice(s) play, 0 = none */
|
||||
uint8_t rr; /* POLY ROTATE: next voice to try */
|
||||
/* mix runtime */
|
||||
int32_t lvl; /* the LEVEL gain (Q12) of the last block: a change is ramped (fx.c) */
|
||||
int32_t peak;
|
||||
int32_t dist_hp, dist_lp1, dist_lp2; /* DIST insert state (fx.c) */
|
||||
int32_t att; /* mute / solo fade: attenuation, Q15 (0 = heard; fx.c mix_part, drums_mix) */
|
||||
|
||||
+119
-49
@@ -1,27 +1,38 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Synthesised drum kits (drums.c kits DRUM_SAMPLED..): analogue-style models in fixed
|
||||
* point, in the spirit of the classic drum machines and the PO-32. Every sound of a kit
|
||||
* is one dsnd_t (tools/gen_drumkits.py writes the kits into felucca_drumkits.h):
|
||||
* tone SINE / TRI / SQUARE / FM / BELL (two squares 1 : 1.48) with an exponential
|
||||
* pitch drop (BEND semitones, over BTIME) and its own decay
|
||||
* noise WHITE / METAL (six squares at the 808 cymbal ratios) / CYM (metal + white) /
|
||||
* CHIP (15-bit LFSR, clocked by LPF) with its own decay; CLAP: 3 bursts, then the tail
|
||||
* filter one-pole low-pass, two one-pole high-passes (on the noise; BELL: on the tone too)
|
||||
* drive tanh; the kit's crush: bit depth and sample-and-hold
|
||||
* Costs ~40 integer ops per voice and sample (METAL: +6 adds); envelopes and the pitch
|
||||
* run at the control rate (CTL) and are ramped per sample. */
|
||||
/* Synthesised drum kits (drums.c kits DRUM_SAMPLED..): analogue-style models in fixed point, in the
|
||||
* spirit of the classic drum machines. Every sound of a kit is one dsnd_t, written in musical units
|
||||
* by tools/gen_drumkits.py (felucca_drumkits.h). A sound is up to four layers into one filter:
|
||||
* tone SINE / TRI / SQUARE / FM / BELL (two squares 1 : 1.48), with an exponential pitch drop
|
||||
* (BEND semitones over BTIME); its envelope HOLDs at full, then decays. A second partial
|
||||
* (T2: a sine at RATIO x the tone, decaying twice as fast): the second mode of a drum head
|
||||
* click the attack: a 1-2 ms burst of bright noise (the beater, the stick)
|
||||
* noise WHITE / METAL (six squares at the 808 cymbal ratios) / CYM (metal + white) / CHIP
|
||||
* (15-bit LFSR at its own clock); its own hold and decay. CLAP: three bursts, then the tail
|
||||
* filter a resonant state-variable filter (LP / BP / HP) on the noise, or on everything; its
|
||||
* cutoff follows the pitch envelope (FENV) and the velocity (softer = darker); a
|
||||
* 12 dB/oct high-pass (HPF) on the noise before it
|
||||
* out drive (tanh), the kit's crush (bit depth, sample-and-hold), the sound's level
|
||||
* The envelopes, the pitch and the filter run at the control rate (CTL samples) and are ramped
|
||||
* per sample. Cost: ~50-60 integer ops per voice and sample (METAL: +6 adds). */
|
||||
enum { DW_NONE, DW_SINE, DW_TRI, DW_SQUARE, DW_FM, DW_BELL };
|
||||
enum { DN_NONE, DN_WHITE, DN_METAL, DN_CYM, DN_CHIP, DN_CLAP = 0x10 };
|
||||
enum { DF_OFF, DF_LP, DF_BP, DF_HP, DF_ALL = 4 }; /* flt: mode | DF_ALL (the tone too) | res << 3 */
|
||||
typedef struct {
|
||||
uint8_t wave, src; /* DW_*, DN_* (| DN_CLAP) */
|
||||
uint8_t pitch; /* MIDI note of the tone (METAL / CYM: their base) */
|
||||
uint8_t pitch, fine; /* the tone: MIDI note + 1/16 semitones (METAL / CYM: their base) */
|
||||
uint8_t bend, btime; /* pitch drop: semitones at the hit, DECAY_K index of its fall */
|
||||
uint8_t decay, tlev; /* tone: DECAY_K index, level 0..127 */
|
||||
uint8_t nlev, ndec; /* noise: level 0..127, DECAY_K index */
|
||||
uint8_t lpf, hpf; /* CUTOFF_HZ index; lpf 127 / hpf 0 = off; CHIP: lpf = clock */
|
||||
uint8_t drive; /* 0..127 */
|
||||
uint8_t hold, decay, tlev; /* tone: hold (2 ms units), DECAY_K index, level 0..127 */
|
||||
uint8_t t2, t2lev; /* second partial: ratio x32 (0 = none), level 0..127 */
|
||||
uint8_t click; /* attack burst level 0..127 */
|
||||
uint8_t nlev, nhold, ndec; /* noise: level 0..127, hold (2 ms units), DECAY_K index */
|
||||
uint8_t flt, fcut; /* filter: DF_* | res (0..31) << 3; CUTOFF_HZ index */
|
||||
int8_t fenv; /* cutoff offset at the hit (CUTOFF_HZ steps, follows the pitch drop) */
|
||||
uint8_t hpf; /* CUTOFF_HZ index of the noise high-pass, 0 = off */
|
||||
uint8_t chip; /* CHIP noise: clock note */
|
||||
uint8_t drive, level; /* drive 0..127; level: 128 + 4 x dB (-32 .. +31.75 dB) */
|
||||
} dsnd_t;
|
||||
#define DS_LANES 14 /* the synthesised sounds (DS_NOTE): kick .. cowbell, clave */
|
||||
#define DS_LANES 16 /* kick snare clap hat open-hat tom-lo tom-hi crash ride shaker conga
|
||||
* rim cowbell clave kick-2 snare-2 */
|
||||
typedef struct {
|
||||
const char *name, *style;
|
||||
uint8_t crush; /* low nibble: bits dropped, high nibble: sample-and-hold - 1 */
|
||||
@@ -29,9 +40,9 @@ typedef struct {
|
||||
} dkit_t;
|
||||
#include "felucca_drumkits.h" /* DS_KITS[], DS_NKITS (tools/gen_drumkits.py) */
|
||||
|
||||
/* GM note -> synth lane (low nibble + 16 * ...) and a pitch offset in semitones */
|
||||
/* GM note -> synth lane and a pitch offset in semitones */
|
||||
static const struct { uint8_t lane; int8_t semi; } DS_MAP[128 - 35] = {
|
||||
/* 35 */ {0, -2}, {0, 0}, {11, 0}, {1, 0}, {2, 0}, {1, 1}, {5, -3}, {3, 0}, {5, 0}, {3, -1},
|
||||
/* 35 */ {14, 0}, {0, 0}, {11, 0}, {1, 0}, {2, 0}, {15, 0}, {5, -3}, {3, 0}, {5, 0}, {3, -1},
|
||||
/* 45 */ {5, 3}, {4, 0}, {6, -3}, {6, 0}, {7, 0}, {6, 3}, {8, 0}, {7, 3}, {8, 6}, {9, 4},
|
||||
/* 55 */ {7, 5}, {12, 0}, {7, 1}, {9, -5}, {8, 1}, {10, 9}, {10, 6}, {10, 3}, {10, 0}, {10, -5},
|
||||
/* 65 */ {6, 5}, {6, 1}, {12, 7}, {12, 3}, {9, -3}, {9, 0}, {13, 9}, {13, 6}, {9, -7}, {9, -9},
|
||||
@@ -52,22 +63,25 @@ static uint32_t ds_lane(uint32_t note, int32_t *semi)
|
||||
typedef struct {
|
||||
const dsnd_t *d;
|
||||
uint32_t ph, inc, inc_to; /* tone phase; increment now and at the end of the block */
|
||||
uint32_t ph2, mph[6]; /* BELL / FM second oscillator, the six metal squares */
|
||||
uint32_t ph2, ph3, mph[6]; /* BELL / FM second oscillator, the second partial, the metal squares */
|
||||
uint32_t minc[6];
|
||||
int32_t pe; /* pitch envelope Q15 (32767 = BEND semitones) */
|
||||
int32_t amp, amp_to; /* tone envelope Q15, now and at the end of the block */
|
||||
int32_t nz, nz_to; /* noise envelope Q15 */
|
||||
int32_t ck, ck_to; /* click envelope Q15 */
|
||||
uint32_t kpe, ka, kn; /* per-block decay factors Q16 */
|
||||
uint32_t t; /* samples since the hit (CLAP bursts) */
|
||||
uint16_t hold, nhold; /* blocks left at full level */
|
||||
int32_t base16; /* pitch in 1/16 semitones */
|
||||
int32_t lp, hp1, hp2, hpx1, hpx2; /* filter states */
|
||||
int32_t alp, ahp; /* one-pole coefficients Q15, 0 = off */
|
||||
int32_t rnd; /* white noise state */
|
||||
int32_t cut; /* filter cutoff (CUTOFF_HZ index << 8) without the envelope */
|
||||
int32_t f1, f2, fk; /* SVF states, damping (Q12) */
|
||||
int32_t a1, a2, a3; /* SVF coefficients (dsp.c tsvf_coef) */
|
||||
int32_t hp1, hp2, ahp; /* noise high-pass states, coefficient Q15 (0 = off) */
|
||||
int32_t rnd, cprev; /* white noise state, the click's last noise sample */
|
||||
uint32_t lfsr, cacc, cinc; /* CHIP noise */
|
||||
int32_t cval;
|
||||
int32_t gain; /* velocity Q15 */
|
||||
int32_t gain, lg; /* velocity Q15, the sound's level Q10 */
|
||||
int32_t held, holdn; /* crush: sample-and-hold */
|
||||
uint8_t crush, bursts;
|
||||
uint8_t crush, bursts, fmode;
|
||||
} dsv_t;
|
||||
|
||||
/* per-sample DECAY_K (Q16) -> per-block (CTL = 32 samples) by squaring five times */
|
||||
@@ -84,6 +98,23 @@ static int32_t ds_onepole(uint32_t cut) /* CUTOFF_HZ index -> a
|
||||
return (int32_t)((g << 15) / (4096u + g));
|
||||
}
|
||||
static uint32_t ds_inc(int32_t p16) { return PITCH_INC[clamp(p16, 0, 127 * 16 + 15)]; }
|
||||
static uint16_t ds_blocks(uint32_t units2ms) { return (uint16_t)(units2ms * 2u * FS / 1000u / CTL); }
|
||||
|
||||
/* the filter's coefficients for this block: the cutoff plus the envelope's share */
|
||||
static void ds_filter(dsv_t *s)
|
||||
{
|
||||
const dsnd_t *d = s->d;
|
||||
int32_t cut = s->cut + ((s->pe * (int32_t)d->fenv) >> 7), i, g, den; /* (pe Q15 x steps << 8) */
|
||||
cut = clamp(cut, 0, 127 << 8);
|
||||
i = cut >> 8;
|
||||
g = SVF_G[i];
|
||||
if (i < 127)
|
||||
g += ((SVF_G[i + 1] - g) * (cut & 255)) >> 8;
|
||||
den = 4096 + ((g * (g + s->fk)) >> 12);
|
||||
s->a1 = (int32_t)((4096u << 13) / (uint32_t)den);
|
||||
s->a2 = (s->a1 * g) >> 12;
|
||||
s->a3 = (s->a2 * g) >> 12;
|
||||
}
|
||||
|
||||
/* the 808 cymbal oscillators (205.3 304.4 369.6 522.7 540 800 Hz) as 1/16 semitones above the first */
|
||||
static const int16_t DS_METAL[6] = {0, 109, 163, 259, 268, 377};
|
||||
@@ -97,21 +128,36 @@ static void ds_on(dsv_t *s, const dkit_t *kit, uint32_t note, uint32_t vel)
|
||||
s->d = d;
|
||||
s->crush = kit->crush;
|
||||
s->gain = (int32_t)vel * 258;
|
||||
s->base16 = ((int32_t)d->pitch + semi) * 16;
|
||||
s->pe = d->bend ? 32767 : 0;
|
||||
{ /* level: quarter dB from 128; 24 quarters = 6 dB = x2 (0.02 dB off per 6 dB) */
|
||||
static const uint16_t QDB[24] = {1024, 1054, 1085, 1116, 1149, 1182, 1217, 1252, 1289, 1326, 1365, 1405,
|
||||
1446, 1488, 1532, 1576, 1622, 1669, 1718, 1768, 1820, 1873, 1928, 1984};
|
||||
int32_t e = (int32_t)d->level - 128 + 192, q = e / 24 - 8; /* (+192: positive for the divide) */
|
||||
uint32_t g = QDB[e % 24];
|
||||
s->lg = (int32_t)(q >= 0 ? g << q : g >> -q);
|
||||
}
|
||||
s->base16 = ((int32_t)d->pitch + semi) * 16 + d->fine;
|
||||
s->pe = d->bend || d->fenv ? 32767 : 0;
|
||||
s->kpe = ds_k32(d->btime);
|
||||
s->inc = s->inc_to = ds_inc(s->base16 + ((s->pe * (int32_t)d->bend * 16) >> 15));
|
||||
s->amp = s->amp_to = d->wave ? (int32_t)d->tlev * 258 : 0;
|
||||
s->ka = ds_k32(d->decay);
|
||||
s->hold = ds_blocks(d->hold);
|
||||
s->nz = s->nz_to = (d->src & 15u) ? (int32_t)d->nlev * 258 : 0;
|
||||
s->kn = (d->src & DN_CLAP) ? ds_k32(12) : ds_k32(d->ndec); /* CLAP: short bursts first */
|
||||
s->nhold = (d->src & DN_CLAP) ? 0 : ds_blocks(d->nhold);
|
||||
s->ck = s->ck_to = (int32_t)d->click * 258;
|
||||
s->bursts = 1;
|
||||
s->alp = d->lpf < 127u && (d->src & 15u) != DN_CHIP ? ds_onepole(d->lpf) : 0;
|
||||
s->fmode = d->flt & 7u;
|
||||
s->fk = 8192 - (int32_t)(d->flt >> 3) * 245; /* damping 2.0 .. ~0.15 (Q12), as tsvf_coef */
|
||||
/* softer hits are darker: about an octave from the hardest to a ghost note */
|
||||
s->cut = ((int32_t)d->fcut << 8) + ((int32_t)vel - 110) * 40;
|
||||
if (s->fmode & 3u)
|
||||
ds_filter(s);
|
||||
s->ahp = d->hpf ? ds_onepole(d->hpf) : 0;
|
||||
s->rnd = (int32_t)(0x9E3779B9u ^ (note * 2654435761u) ^ rng());
|
||||
s->lfsr = 0x4001u;
|
||||
{ /* CHIP clock: 8x that note; saturated (the top notes would wrap 32 bits: a dull noise) */
|
||||
uint32_t ci = PITCH_INC[clamp((int32_t)d->lpf, 0, 127) * 16];
|
||||
uint32_t ci = PITCH_INC[clamp((int32_t)d->chip, 0, 127) * 16];
|
||||
s->cinc = ci >= 0x20000000u ? 0xFFFFFFFFu : ci << 3;
|
||||
}
|
||||
for (i = 0; i < 6u; i++)
|
||||
@@ -124,34 +170,48 @@ static void ds_control(dsv_t *s)
|
||||
const dsnd_t *d = s->d;
|
||||
s->amp = s->amp_to;
|
||||
s->nz = s->nz_to;
|
||||
s->ck = s->ck_to;
|
||||
s->inc = s->inc_to;
|
||||
s->amp_to = (int32_t)(((uint32_t)s->amp * s->ka) >> 16);
|
||||
if ((d->src & DN_CLAP) && s->bursts < 4u && s->t >= s->bursts * 400u) {
|
||||
s->nz = (int32_t)d->nlev * 258; /* bursts at 0, 9, 18 ms; the 4th is the tail */
|
||||
if (++s->bursts == 4u)
|
||||
if (s->hold)
|
||||
s->hold--;
|
||||
else
|
||||
s->amp_to = (int32_t)(((uint32_t)s->amp * s->ka) >> 16);
|
||||
if ((d->src & DN_CLAP) && s->bursts < 4u && s->t >= s->bursts * 420u) {
|
||||
s->nz = (int32_t)d->nlev * 258; /* bursts at 0, 9.5, 19 ms; the 4th is the tail */
|
||||
if (++s->bursts == 4u) {
|
||||
s->kn = ds_k32(d->ndec);
|
||||
s->nhold = ds_blocks(d->nhold);
|
||||
}
|
||||
}
|
||||
s->nz_to = (int32_t)(((uint32_t)s->nz * s->kn) >> 16);
|
||||
if (s->nhold)
|
||||
s->nhold--;
|
||||
else
|
||||
s->nz_to = (int32_t)(((uint32_t)s->nz * s->kn) >> 16);
|
||||
s->ck_to = (s->ck * 3) >> 3; /* ~1 ms: gone in a few blocks */
|
||||
s->pe = (int32_t)(((uint32_t)s->pe * s->kpe) >> 16);
|
||||
s->inc_to = ds_inc(s->base16 + ((s->pe * (int32_t)d->bend * 16) >> 15));
|
||||
if ((s->fmode & 3u) && d->fenv)
|
||||
ds_filter(s);
|
||||
}
|
||||
|
||||
static int ds_alive(const dsv_t *s)
|
||||
{
|
||||
if ((s->d->src & DN_CLAP) && s->bursts < 4u)
|
||||
return 1; /* bursts still to come */
|
||||
return s->amp > 8 || s->amp_to > 8 || s->nz > 8 || s->nz_to > 8;
|
||||
return s->hold || s->amp > 8 || s->amp_to > 8 || s->nz > 8 || s->nz_to > 8 || s->ck > 8;
|
||||
}
|
||||
|
||||
/* n (<= CTL) samples of voice s into out[] (Q15-ish, peak ~ 32767); returns 0 when it ended */
|
||||
static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
|
||||
{
|
||||
const dsnd_t *d = s->d;
|
||||
uint32_t i, src = d->src & 15u, wave = d->wave;
|
||||
uint32_t i, src = d->src & 15u, wave = d->wave, fmode = s->fmode & 3u, fall = s->fmode & DF_ALL;
|
||||
int32_t da = (s->amp_to - s->amp) >> CTL_LOG2, dn = (s->nz_to - s->nz) >> CTL_LOG2; /* (no divide) */
|
||||
int32_t dc = (s->ck_to - s->ck) >> CTL_LOG2;
|
||||
int32_t di = (int32_t)(s->inc_to - s->inc) >> CTL_LOG2;
|
||||
int32_t a = s->amp, z = s->nz, inc = (int32_t)s->inc;
|
||||
int32_t a = s->amp, z = s->nz, c = s->ck, inc = (int32_t)s->inc;
|
||||
int32_t drive = 16 + d->drive, bits = s->crush & 15, hold = (s->crush >> 4) + 1;
|
||||
int32_t t2l = (int32_t)d->t2lev * 258;
|
||||
for (i = 0; i < n; i++) {
|
||||
int32_t tone = 0, nz = 0, x;
|
||||
if (wave) {
|
||||
@@ -170,6 +230,10 @@ static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
|
||||
}
|
||||
s->ph += (uint32_t)inc;
|
||||
tone = mulq15(tone, a);
|
||||
if (d->t2) { /* the second mode: a sine, decaying twice as fast */
|
||||
s->ph3 += ((uint32_t)inc >> 5) * d->t2;
|
||||
tone += mulq15(mulq15(sine_i(s->ph3), mulq15(a, a)), t2l);
|
||||
}
|
||||
}
|
||||
if (src) {
|
||||
if (src == DN_WHITE) {
|
||||
@@ -195,10 +259,6 @@ static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
|
||||
}
|
||||
if (wave == DW_BELL)
|
||||
nz += tone, tone = 0;
|
||||
if (s->alp) {
|
||||
s->lp += mulq15(nz - s->lp, s->alp);
|
||||
nz = s->lp;
|
||||
}
|
||||
if (s->ahp) { /* two one-pole high-passes: 12 dB / oct */
|
||||
s->hp1 += mulq15(nz - s->hp1, s->ahp);
|
||||
nz -= s->hp1;
|
||||
@@ -208,13 +268,22 @@ static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
|
||||
nz = mulq15(nz, z);
|
||||
if (d->src & DN_CLAP)
|
||||
nz <<= 1; /* band-passed: as loud as the others */
|
||||
} else if (wave == DW_BELL && (s->alp || s->ahp)) {
|
||||
x = tone;
|
||||
if (s->alp) { s->lp += mulq15(x - s->lp, s->alp); x = s->lp; }
|
||||
if (s->ahp) { s->hp1 += mulq15(x - s->hp1, s->ahp); x -= s->hp1; }
|
||||
tone = x;
|
||||
}
|
||||
x = tone + nz;
|
||||
if (c) { /* the click: differentiated noise, bright */
|
||||
int32_t w = (int32_t)noise32(&s->rnd) >> 17;
|
||||
nz += mulq15(w - s->cprev, c);
|
||||
s->cprev = w;
|
||||
}
|
||||
x = fall ? tone + nz : nz;
|
||||
if (fmode) { /* SVF (dsp.c tsvf_lp), with the BP / HP outs */
|
||||
int32_t v3 = x - s->f2;
|
||||
int32_t v1 = (s->a1 * s->f1 + s->a2 * v3) >> 13;
|
||||
int32_t v2 = s->f2 + ((s->a2 * s->f1 + s->a3 * v3) >> 13);
|
||||
s->f1 = clamp(2 * v1 - s->f1, -150000, 150000);
|
||||
s->f2 = clamp(2 * v2 - s->f2, -150000, 150000);
|
||||
x = fmode == DF_LP ? v2 : fmode == DF_BP ? v1 : x - ((s->fk * v1) >> 12) - v2;
|
||||
}
|
||||
x += fall ? 0 : tone;
|
||||
if (d->drive)
|
||||
x = softclip((x * drive) >> 4);
|
||||
if (s->crush) {
|
||||
@@ -224,9 +293,10 @@ static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
|
||||
}
|
||||
x = s->held;
|
||||
}
|
||||
out[i] = mulq15(x, s->gain);
|
||||
out[i] = ((mulq15(x, s->gain) >> 2) * s->lg) >> 8;
|
||||
a += da;
|
||||
z += dn;
|
||||
c += dc;
|
||||
inc += di;
|
||||
}
|
||||
s->t += n;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* treatments (as before: old projects keep their kit), 5..: the synthesised kits. */
|
||||
#define DRUM_SAMPLED 5u
|
||||
#define DRUM_KITS (DRUM_SAMPLED + DS_NKITS)
|
||||
static const char *const DRUM_KIT_NAMES[] = {"ORIGINAL", "DEEP", "TIGHT", "BRIGHT", "DUST", DS_KIT_NAME_LIST};
|
||||
static const char *const DRUM_KIT_STYLES[] = {"ACOUSTIC", "SOFT", "PUNCHY", "BRIGHT", "DUSTY", DS_KIT_STYLE_LIST};
|
||||
static const char *const DRUM_KIT_NAMES[] = {"ACOUSTIC", "DEEP", "TIGHT", "BRIGHT", "DUST", DS_KIT_NAME_LIST};
|
||||
static const char *const DRUM_KIT_STYLES[] = {"STUDIO", "SOFT", "PUNCHY", "BRIGHT", "DUSTY", DS_KIT_STYLE_LIST};
|
||||
static uint32_t drum_kit(void) { return (uint32_t)clamp(TDRUM->p[P_E0], 0, DRUM_KITS - 1); }
|
||||
#define DRUM_DEFAULT_KIT DRUM_SAMPLED /* power-on: 808 */
|
||||
|
||||
@@ -252,6 +252,7 @@ static inline void drums_mix(int32_t *ml, int32_t *mr, int32_t *rev, int32_t *mo
|
||||
if (!v->active)
|
||||
continue;
|
||||
g = mulq15(lvl, v->vel * 258);
|
||||
g += g * 3 >> 2; /* x1.75 (+5 dB): as loud as the synthesised kits */
|
||||
for (i = 0; i < n; i++) {
|
||||
int32_t s;
|
||||
frac += stepq;
|
||||
|
||||
@@ -96,6 +96,11 @@ static const preset_t ANALOG_PRESETS[] = {
|
||||
{"808 BOOM", {3, 0, 0, 0, 127, 0, 48, 0}, {0, 112, 0, 52}, 0, 1, FX(0, 0, 0, 0), XP(P_GLIDE + 1, 59, P_GLMODE + 1, 1, P_ED_PIT + 1, 18, P_TRANS + 1, -24)},
|
||||
{"808 DIRTY", {3, 0, 0, 0, 96, 12, 118, 30}, {0, 108, 0, 46}, 0, 1, FX(24, 0, 0, 0), XP(P_GLIDE + 1, 56, P_GLMODE + 1, 1, P_ED_PIT + 1, 24, P_TRANS + 1, -24)},
|
||||
{"SUB BASS", {3, 0, 0, 0, 127, 0, 10, 0}, {0, 60, 118, 24}, 0, 1, FX(0, 0, 0, 0), XP(P_GLIDE + 1, 40, P_TRANS + 1, -24)},
|
||||
{"808 SLIDE", {3, 0, 0, 0, 127, 0, 72, 0}, {0, 118, 0, 60}, 0, 1, FX(30, 0, 0, 0), XP(P_GLIDE + 1, 82, P_GLMODE + 1, 1, P_ED_PIT + 1, 12, P_TRANS + 1, -24)},
|
||||
/* acid: one saw, high resonance, the envelope on the filter, slides where notes overlap */
|
||||
{"ACID 303", {0, 0, 0, 0, 36, 112, 44, 64}, {0, 56, 24, 20}, 52, 1, FX(28, 0, 22, 10), XP(P_GLIDE + 1, 34, P_GLMODE + 1, 1, P_TRANS + 1, -12)},
|
||||
/* plugg / soft trap: a round triangle bass */
|
||||
{"PLUGG BASS", {2, 0, 0, 0, 92, 0, 30, 0}, {0, 96, 92, 34}, 0, 1, FX(0, 0, 0, 6), XP(P_GLIDE + 1, 52, P_GLMODE + 1, 1, P_TRANS + 1, -24)},
|
||||
/* drum & bass: two detuned saws, slowly moving filter */
|
||||
{"REESE", {0, 22, 64, 0, 56, 22, 36, 40}, {0, 70, 118, 28}, 0, 1, FX(0, 22, 0, 6), XP(P_LRATE + 1, 22, P_LD_FLT + 1, 10, P_TRANS + 1, -24)},
|
||||
{"WOBBLE", {0, 9, 64, 0, 38, 72, 62, 30}, {0, 64, 127, 22}, 0, 1, FX(10, 0, 0, 4), XP(P_LRATE + 1, 74, P_LD_FLT + 1, 40, P_TRANS + 1, -24)},
|
||||
@@ -103,8 +108,10 @@ static const preset_t ANALOG_PRESETS[] = {
|
||||
{"FUNK BASS", {1, 6, 50, 0, 50, 30, 22, 64}, {0, 55, 62, 20}, 30, 1, FX(0, 0, 0, 4), XP(P_GLIDE + 1, 50, P_GLMODE + 1, 1, P_TRANS + 1, -24)},
|
||||
{"G-FUNK LD", {2, 0, 0, 0, 92, 0, 10, 64}, {6, 70, 112, 46}, 0, 1, FX(0, 0, 28, 30),
|
||||
XP(P_GLIDE + 1, 74, P_LD_PIT + 1, 2, P_LRATE + 1, 89, P_LFADE + 1, 50)},
|
||||
{"TRAP PLUCK", {0, 8, 64, 0, 30, 35, 0, 64}, {0, 58, 0, 45}, 45, 0, FX(0, 15, 34, 26)},
|
||||
{"TRAP PLUCK", {0, 8, 64, 0, 52, 35, 20, 64}, {0, 80, 24, 45}, 48, 0, FX(0, 15, 34, 26)},
|
||||
{"SYN BRASS", {0, 10, 64, 0, 45, 20, 16, 64}, {12, 70, 96, 35}, 34, 0, FX(0, 15, 12, 24)},
|
||||
/* trance / EDM: eight detuned saw voices on one note */
|
||||
{"SUPERSAW", {0, 14, 64, 0, 96, 12, 10, 64}, {4, 70, 112, 46}, 10, 1, FX(0, 20, 30, 36), XP(P_VOICE + 1, 3, P_DETUNE + 1, 64, P_GLIDE + 1, 30)},
|
||||
{"WARM PAD", {4, 12, 64, 6, 52, 8, 0, 32}, {75, 90, 115, 90}, 0, 0, FX(0, 55, 20, 55), XP(P_LRATE + 1, 30, P_LD_SHP + 1, 20)},
|
||||
{"DARK STR", {0, 18, 64, 0, 48, 6, 0, 32}, {60, 90, 118, 85}, 0, 0, FX(0, 50, 18, 60)},
|
||||
{"ATMOS PAD", {4, 25, 64, 20, 60, 15, 0, 32}, {90, 100, 120, 100}, 0, 0, FX(0, 60, 30, 75), XP(P_LRATE + 1, 18, P_LD_PIT + 1, 1)},
|
||||
|
||||
@@ -117,10 +117,18 @@ static const preset_t DIGITAL_PRESETS[] = {
|
||||
{"RHODES", {4, 1, 1, 14, 26, 35, 0, 0}, {0, 85, 35, 55}, 0, 0, FX(0, 30, 12, 26), XP(P_LD_AMP + 1, 26, P_LRATE + 1, 84)},
|
||||
{"DX RHODES", {4, 1, 1, 14, 85, 45, 0, 0}, {0, 82, 40, 55}, 0, 0, FX(0, 45, 20, 30)},
|
||||
{"WURLI", {4, 1, 2, 3, 62, 35, 8, 0}, {0, 75, 30, 45}, 0, 0, FX(10, 20, 10, 20), XP(P_LD_AMP + 1, 16, P_LRATE + 1, 89)},
|
||||
{"CLAV", {3, 1, 3, 5, 90, 25, 20, 0}, {0, 50, 20, 18}, 0, 0, FX(10, 10, 6, 10)},
|
||||
{"CLAV", {3, 1, 3, 5, 90, 25, 20, 0}, {0, 58, 34, 18}, 0, 0, FX(10, 10, 6, 10)},
|
||||
/* house piano: bright, fast hammer, the tine stack for the attack */
|
||||
{"M1 PIANO", {4, 1, 2, 13, 74, 30, 12, 0}, {0, 86, 30, 48}, 0, 0, FX(0, 24, 14, 26)},
|
||||
/* afro house / amapiano: round keys with a bell on top */
|
||||
{"AFRO KEYS", {4, 1, 1, 7, 40, 50, 0, 0}, {0, 82, 40, 60}, 0, 0, FX(0, 30, 26, 36)},
|
||||
{"TRAP BELL", {4, 8, 1, 4, 80, 70, 0, 0}, {0, 92, 0, 70}, 0, 0, FX(0, 0, 30, 40)},
|
||||
{"MUSIC BOX", {4, 4, 3, 9, 45, 75, 0, 0}, {0, 90, 0, 75}, 0, 0, FX(0, 10, 32, 45)},
|
||||
{"MARIMBA", {4, 4, 1, 1, 60, 30, 0, 0}, {0, 80, 0, 60}, 0, 0, FX(0, 0, 22, 30)},
|
||||
{"KALIMBA", {4, 4, 1, 6, 52, 24, 0, 0}, {0, 78, 0, 58}, 0, 0, FX(0, 0, 26, 38)},
|
||||
/* pluggnb / cloud rap: a soft bell, lots of space */
|
||||
{"PLUGG BELL", {4, 3, 1, 4, 56, 60, 0, 0}, {0, 90, 0, 82}, 0, 0, FX(0, 22, 36, 56)},
|
||||
{"GLASS PAD", {4, 2, 1, 5, 34, 100, 0, 0}, {62, 92, 112, 92}, 0, 0, FX(0, 50, 26, 62), XP(P_LD_PIT + 1, 1, P_LRATE + 1, 40)},
|
||||
{"FM BASS", {0, 1, 1, 1, 34, 40, 8, 0}, {0, 60, 70, 25}, 0, 1, FX(0, 0, 0, 6), XP(P_GLIDE + 1, 36, P_TRANS + 1, -24)},
|
||||
};
|
||||
|
||||
|
||||
@@ -272,6 +272,8 @@ static const preset_t DRAWBAR_PRESETS[] = {
|
||||
{"GOSPEL", {6, 0, 0, 0, 1, 60, 40, 2}, {0, 64, 127, 45}, 0, 0, FX(0, 0, 0, 30)},
|
||||
{"JAZZ ORGAN", {4, 0, 0, 0, 2, 50, 8, 1}, {0, 64, 127, 40}, 0, 0, FX(0, 0, 0, 22)},
|
||||
{"DIRTY B3", {5, 0, 0, 0, 0, 60, 90, 2}, {0, 64, 127, 40}, 0, 0, FX(30, 0, 6, 20)},
|
||||
/* 90s house: the percussive organ that plays bass lines and chords */
|
||||
{"HOUSE ORGN", {13, 2, 0, 1, 1, 80, 22, 0}, {0, 60, 96, 22}, 0, 0, FX(0, 10, 12, 18)},
|
||||
};
|
||||
|
||||
static const engine_t ENG_DRAWBAR = {
|
||||
|
||||
@@ -422,7 +422,7 @@ static void grain_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
|
||||
static const preset_t GRAIN_PRESETS[] = {
|
||||
/* name, {SRC, POS, SIZE, DENS, PTCH, SPRD, RAND, TONE}, {A D S R}, fenv, mono.
|
||||
* SRC: the SAMPLE sets (0 DUSTY piano, 2 VIBES, 5 FLUTE...: tools/gen_samples.py CC0_SETS) */
|
||||
* SRC: the SAMPLE sets (0 PIANO, 2 VIBES, 5 FLUTE...: tools/gen_samples.py CC0_SETS) */
|
||||
{"LOFI CLOUD", {0, 45, 95, 85, 0, 35, 12, 80}, {70, 90, 120, 90}, 0, 0, FX(0, 45, 20, 70)},
|
||||
{"VIBE HAZE", {2, 30, 100, 90, 0, 25, 10, 90}, {50, 100, 120, 95}, 0, 0, FX(0, 40, 25, 75)},
|
||||
{"FLUTE DUST", {5, 50, 108, 72, 0, 10, 10, 85}, {50, 100, 127, 100}, 0, 0, FX(0, 30, 20, 70)},
|
||||
|
||||
@@ -171,7 +171,7 @@ static void phase_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
|
||||
static const preset_t PHASE_PRESETS[] = {
|
||||
/* name, {WAVE, WAVE2, DCW, ENV, DTN, LINE, SUB, -}, {A D S R}, fenv, mono */
|
||||
{"CZ BASS", {5, 0, 28, 70, 0, 0, 40, 0}, {0, 60, 50, 22}, 0, 1, FX(5, 0, 0, 4), XP(P_GLIDE + 1, 36, P_TRANS + 1, -24)},
|
||||
{"CZ BASS", {5, 0, 36, 70, 0, 0, 72, 0}, {0, 64, 64, 22}, 0, 1, FX(5, 0, 0, 4), XP(P_GLIDE + 1, 36, P_TRANS + 1, -24)},
|
||||
{"SOFT KEYS", {3, 0, 40, 70, 0, 0, 0, 0}, {0, 80, 20, 50}, 0, 0, FX(0, 35, 14, 28)},
|
||||
{"CZ STRING", {0, 4, 50, 40, 12, 0, 0, 0}, {50, 90, 105, 75}, 0, 0, FX(0, 50, 20, 55)},
|
||||
{"RESO PLUCK", {5, 0, 60, 60, 0, 0, 0, 0}, {0, 70, 30, 60}, 0, 0, FX(0, 0, 30, 30)},
|
||||
|
||||
@@ -358,9 +358,14 @@ static void trio_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
|
||||
static const preset_t TRIO_PRESETS[] = {
|
||||
/* name, {WAVE, INT2, INT3, DTN, MODE, CUT, RES, PW}, {A D S R}, fenv, mono. INT2 / INT3: one-finger chords */
|
||||
{"FAT BASS", {0, 0, -12, 9, 0, 62, 45, 64}, {0, 62, 60, 25}, 40, 1, FX(10, 0, 0, 6), XP(P_TRANS + 1, -24)},
|
||||
{"MIN STAB", {0, 3, 7, 6, 0, 80, 20, 64}, {0, 50, 0, 30}, 30, 0, FX(0, 20, 20, 30)},
|
||||
{"MIN7 STAB", {3, 3, 10, 5, 0, 75, 15, 64}, {0, 60, 20, 40}, 20, 0, FX(0, 25, 18, 30)},
|
||||
{"FAT BASS", {0, 0, -12, 9, 0, 72, 45, 64}, {0, 64, 80, 25}, 40, 1, FX(22, 0, 0, 6), XP(P_TRANS + 1, -24)},
|
||||
{"MIN STAB", {0, 3, 7, 6, 0, 82, 20, 64}, {0, 66, 26, 36}, 30, 0, FX(0, 20, 20, 30)},
|
||||
{"MIN7 STAB", {3, 3, 10, 5, 0, 75, 15, 64}, {0, 66, 28, 40}, 20, 0, FX(0, 25, 18, 30)},
|
||||
/* rave: a bright minor stab, the filter snapping shut */
|
||||
{"RAVE STAB", {0, 3, 7, 14, 0, 98, 30, 64}, {0, 66, 30, 34}, 40, 0, FX(16, 20, 24, 30)},
|
||||
/* dub techno: a dark minor 7th chord into the delay */
|
||||
{"DUB CHORD", {3, 3, 10, 6, 0, 68, 40, 64}, {0, 66, 22, 46}, 28, 0, FX(0, 10, 72, 40)},
|
||||
{"SAW PAD", {0, 0, 12, 30, 0, 72, 10, 64}, {52, 90, 115, 86}, 6, 0, FX(0, 40, 20, 60)},
|
||||
{"SYNC LEAD", {9, 9, 0, 0, 0, 82, 30, 64}, {2, 70, 100, 40}, 18, 1, FX(0, 10, 30, 22), XP(P_GLIDE + 1, 56)},
|
||||
{"HOOVER", {0, 0, -12, 40, 0, 70, 20, 64}, {10, 70, 110, 40}, 10, 1, FX(10, 40, 10, 24), XP(P_GLIDE + 1, 70)},
|
||||
};
|
||||
|
||||
@@ -21,3 +21,11 @@ static const engine_t *const ENGINES[NENGINES] = {&ENG_ANALOG, &ENG_DIGITAL, &EN
|
||||
&ENG_SLICE,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* every factory sound as loud as the others: a level trim per preset, 1/2 dB, measured on a phrase
|
||||
* that fits the sound (tools/level_presets.py writes preset_trim.h); a track keeps it in P_ED_FX */
|
||||
#include "preset_trim.h"
|
||||
static int16_t preset_trim(uint32_t e, uint32_t pi)
|
||||
{
|
||||
return e < PT_ENGINES && pi < PT_MAX ? PRESET_TRIM[e][pi] : 0;
|
||||
}
|
||||
+81
-47
@@ -1,20 +1,24 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* Effects: per-track DIST insert, then sends into three
|
||||
* shared buses (chorus, tempo delay, reverb). Mono buses, stereo dry mix. */
|
||||
/* Effects: per-track DIST insert, then sends into three shared buses (chorus, tempo delay, reverb).
|
||||
* Stereo dry mix; the chorus and the reverb come back in stereo, the delay in the middle. */
|
||||
#define DLY_LEN 65536u /* 1.49 s: 1/4 at 40 BPM fits */
|
||||
#define CHO_LEN 2048u
|
||||
static int16_t dly_buf[DLY_LEN] __attribute__((section(".pool")));
|
||||
static int16_t cho_buf[CHO_LEN] __attribute__((section(".pool")));
|
||||
static const uint16_t REV_COMB[4] = {1116, 1188, 1277, 1356};
|
||||
/* the reverb: two input diffusers, then four delay lines mixed by a Hadamard matrix (a feedback delay
|
||||
* network: every echo feeds all four, so it thickens instead of ringing like a comb), damped in the
|
||||
* loop, one line slowly modulated (no metallic tone on long tails); left and right take different lines */
|
||||
#define REV_MOD 12 /* samples the modulated line moves (+-) */
|
||||
static const uint16_t REV_LINE[4] = {1559, 1931, 2389, 2791}; /* 35..63 ms, coprime */
|
||||
static const uint16_t REV_AP[2] = {556, 441};
|
||||
static int16_t rev_comb[1116 + 1188 + 1277 + 1356] __attribute__((section(".pool")));
|
||||
static int16_t rev_line[1559 + 1931 + 2389 + 2791 + REV_MOD + 2]; /* (.bss: the pool is full) */
|
||||
static int16_t rev_ap[556 + 441] __attribute__((section(".pool")));
|
||||
static struct {
|
||||
uint32_t dly_w, cho_w, cho_ph;
|
||||
uint32_t dly_w, cho_w, cho_ph, rev_ph;
|
||||
int32_t dly_lp;
|
||||
uint16_t comb_i[4], ap_i[2];
|
||||
int32_t comb_lp[4];
|
||||
uint16_t line_i[4], ap_i[2];
|
||||
int32_t line_lp[4];
|
||||
} fx;
|
||||
|
||||
/* DIST: low cut -> drive (1x..8x, exponential) -> asymmetric soft clip
|
||||
@@ -124,70 +128,98 @@ static uint32_t delay_samples(void)
|
||||
return s < 16u ? 16u : s >= DLY_LEN ? DLY_LEN - 1u : s;
|
||||
}
|
||||
|
||||
/* process the three buses for one block; sends in, wet stereo-equal out */
|
||||
static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t *rev_in, int32_t *wet,
|
||||
uint32_t n)
|
||||
/* process the three buses for one block; sends in, wet out (stereo). The LFOs (chorus, reverb line)
|
||||
* are computed per block and ramped: no sine per sample */
|
||||
static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t *rev_in, int32_t *wet_l,
|
||||
int32_t *wet_r, uint32_t n)
|
||||
{
|
||||
uint32_t i, k, dl = delay_samples();
|
||||
int32_t fb = song.g[G_DFDBK] * 230, col = 2000 + song.g[G_DCOLOR] * 240;
|
||||
int32_t dmix = song.g[G_DMIX] * 258;
|
||||
int32_t size = 25000 + song.g[G_RSIZE] * 50, damp = 32767 - song.g[G_RDAMP] * 200;
|
||||
int32_t g = 17000 + song.g[G_RSIZE] * 104, lpk = 32767 - song.g[G_RDAMP] * 200; /* loop gain (RT60 ~0.4..4 s), damping */
|
||||
int32_t cdepth = song.g[G_CDEPTH] * 6;
|
||||
uint32_t cinc = LFO_INC[song.g[G_CRATE] & 127] / CTL;
|
||||
int32_t ca0, ca1, cb0, cb1, ma, mb, dca, dcb;
|
||||
const uint32_t L0 = REV_LINE[0] + REV_MOD + 2u, B1 = L0, B2 = B1 + REV_LINE[1], B3 = B2 + REV_LINE[2];
|
||||
{ /* the chorus' two read points (Q8 samples back) and line 0's extra length, at both ends of the block */
|
||||
int32_t s0 = osc_sine(fx.cho_ph), s1, m0 = osc_sine(fx.rev_ph), m1;
|
||||
fx.cho_ph += LFO_INC[song.g[G_CRATE] & 127];
|
||||
fx.rev_ph += LFO_INC[30];
|
||||
s1 = osc_sine(fx.cho_ph);
|
||||
m1 = osc_sine(fx.rev_ph);
|
||||
ca0 = (400 << 8) + ((s0 + 32768) * cdepth >> 8), ca1 = (400 << 8) + ((s1 + 32768) * cdepth >> 8);
|
||||
cb0 = (400 << 8) + ((32767 - s0) * cdepth >> 8), cb1 = (400 << 8) + ((32767 - s1) * cdepth >> 8);
|
||||
ma = (REV_MOD << 8) + ((m0 * REV_MOD) >> 7), mb = (REV_MOD << 8) + ((m1 * REV_MOD) >> 7);
|
||||
dca = (ca1 - ca0) >> CTL_LOG2, dcb = (cb1 - cb0) >> CTL_LOG2;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
int32_t y = 0, x, r, a;
|
||||
/* chorus: modulated short delay, 5..15 ms */
|
||||
int32_t yl, yr, x, a, o0, o1, o2, o3;
|
||||
/* chorus: two modulated short delays, 5..15 ms, the LFO half a turn apart: left and right move apart */
|
||||
cho_buf[fx.cho_w & (CHO_LEN - 1u)] = (int16_t)clamp(cho_in[i] >> 1, -32768, 32767);
|
||||
fx.cho_ph += cinc;
|
||||
r = (400 << 8) + ((osc_sine(fx.cho_ph) + 32768) * cdepth >> 8); /* Q8 delay: read between samples */
|
||||
{
|
||||
uint32_t ri = (uint32_t)r >> 8;
|
||||
int32_t f = r & 255, c0 = cho_buf[(fx.cho_w - ri) & (CHO_LEN - 1u)];
|
||||
int32_t c1 = cho_buf[(fx.cho_w - ri - 1u) & (CHO_LEN - 1u)];
|
||||
y += (c0 + (((c1 - c0) * f) >> 8)) << 1;
|
||||
int32_t r0 = ca0 + dca * (int32_t)i, r1 = cb0 + dcb * (int32_t)i;
|
||||
uint32_t i0 = (uint32_t)r0 >> 8, i1 = (uint32_t)r1 >> 8;
|
||||
int32_t c0 = cho_buf[(fx.cho_w - i0) & (CHO_LEN - 1u)], c1 = cho_buf[(fx.cho_w - i0 - 1u) & (CHO_LEN - 1u)];
|
||||
int32_t d0 = cho_buf[(fx.cho_w - i1) & (CHO_LEN - 1u)], d1 = cho_buf[(fx.cho_w - i1 - 1u) & (CHO_LEN - 1u)];
|
||||
yl = (c0 + (((c1 - c0) * (r0 & 255)) >> 8)) << 1;
|
||||
yr = (d0 + (((d1 - d0) * (r1 & 255)) >> 8)) << 1;
|
||||
}
|
||||
fx.cho_w++;
|
||||
/* delay with a low-passed feedback */
|
||||
/* delay with a low-passed feedback (in the middle) */
|
||||
x = dly_buf[(fx.dly_w - dl) & (DLY_LEN - 1u)];
|
||||
fx.dly_lp += mulq15(x - fx.dly_lp, col);
|
||||
dly_buf[fx.dly_w & (DLY_LEN - 1u)] =
|
||||
(int16_t)clamp((dly_in[i] >> 1) + mulq15(fx.dly_lp, fb), -32768, 32767);
|
||||
fx.dly_w++;
|
||||
y += mulq15(x << 1, dmix);
|
||||
/* reverb: 4 damped combs + 2 allpasses (Freeverb-like, mono) */
|
||||
a = 0;
|
||||
x = mulq15(x << 1, dmix);
|
||||
yl += x;
|
||||
yr += x;
|
||||
/* reverb: two diffusers, then the four lines */
|
||||
a = mulq15(rev_in[i], 13000);
|
||||
{
|
||||
int16_t *c = rev_comb;
|
||||
int32_t in = mulq15(rev_in[i], 2580); /* 1/8 at -4 dB */
|
||||
for (k = 0; k < 4u; k++) {
|
||||
int32_t o = c[fx.comb_i[k]];
|
||||
fx.comb_lp[k] = o + mulq15(fx.comb_lp[k] - o, 32767 - damp);
|
||||
c[fx.comb_i[k]] = (int16_t)clamp(in + mulq15(fx.comb_lp[k], size), -32768, 32767);
|
||||
if (++fx.comb_i[k] >= REV_COMB[k])
|
||||
fx.comb_i[k] = 0;
|
||||
a += o;
|
||||
c += REV_COMB[k];
|
||||
}
|
||||
c = rev_ap;
|
||||
int16_t *c = rev_ap;
|
||||
for (k = 0; k < 2u; k++) {
|
||||
int32_t o = c[fx.ap_i[k]];
|
||||
int32_t v = a + (o >> 1);
|
||||
int32_t b = c[fx.ap_i[k]], v = a + (b >> 1);
|
||||
c[fx.ap_i[k]] = (int16_t)clamp(v, -32768, 32767);
|
||||
a = o - a; /* Freeverb: out = buf - in (o - v would be a notch comb) */
|
||||
a = b - (v >> 1);
|
||||
if (++fx.ap_i[k] >= REV_AP[k])
|
||||
fx.ap_i[k] = 0;
|
||||
c += REV_AP[k];
|
||||
}
|
||||
}
|
||||
y += a;
|
||||
wet[i] = y;
|
||||
{
|
||||
int16_t *c = rev_line;
|
||||
int32_t s0, s1, d0, d1, r = ma + (((mb - ma) * (int32_t)i) >> CTL_LOG2); /* (between the two: never below 0) */
|
||||
uint32_t ri = fx.line_i[0] + ((uint32_t)r >> 8), rj;
|
||||
if (ri >= L0) /* (the oldest sample is at line_i: reading */
|
||||
ri -= L0; /* past it shortens line 0 by 0..2 REV_MOD) */
|
||||
rj = ri + 1u >= L0 ? 0u : ri + 1u;
|
||||
o0 = c[ri] + (((c[rj] - c[ri]) * (r & 255)) >> 8);
|
||||
o1 = c[B1 + fx.line_i[1]];
|
||||
o2 = c[B2 + fx.line_i[2]];
|
||||
o3 = c[B3 + fx.line_i[3]];
|
||||
s0 = o0 + o1, d0 = o0 - o1, s1 = o2 + o3, d1 = o2 - o3; /* Hadamard / 2: each feeds all four */
|
||||
fx.line_lp[0] += mulq15(((s0 + s1) >> 1) - fx.line_lp[0], lpk);
|
||||
fx.line_lp[1] += mulq15(((d0 + d1) >> 1) - fx.line_lp[1], lpk);
|
||||
fx.line_lp[2] += mulq15(((s0 - s1) >> 1) - fx.line_lp[2], lpk);
|
||||
fx.line_lp[3] += mulq15(((d0 - d1) >> 1) - fx.line_lp[3], lpk);
|
||||
c[fx.line_i[0]] = (int16_t)clamp(mulq15(fx.line_lp[0], g) + a, -32768, 32767);
|
||||
c[B1 + fx.line_i[1]] = (int16_t)clamp(mulq15(fx.line_lp[1], g) - a, -32768, 32767);
|
||||
c[B2 + fx.line_i[2]] = (int16_t)clamp(mulq15(fx.line_lp[2], g) + a, -32768, 32767);
|
||||
c[B3 + fx.line_i[3]] = (int16_t)clamp(mulq15(fx.line_lp[3], g) - a, -32768, 32767);
|
||||
if (++fx.line_i[0] >= L0) fx.line_i[0] = 0;
|
||||
if (++fx.line_i[1] >= REV_LINE[1]) fx.line_i[1] = 0;
|
||||
if (++fx.line_i[2] >= REV_LINE[2]) fx.line_i[2] = 0;
|
||||
if (++fx.line_i[3] >= REV_LINE[3]) fx.line_i[3] = 0;
|
||||
}
|
||||
wet_l[i] = yl + o0 + o2;
|
||||
wet_r[i] = yr + o1 - o3;
|
||||
}
|
||||
}
|
||||
|
||||
/* one block of the whole mix (shared with tests/hostsim.c): events -> each part
|
||||
* -> dist -> SLICER -> level / pan / sends -> drums (-> SLICER) -> buses -> master; out: stereo Q15 */
|
||||
static void events_block(uint32_t n); /* seq.c */
|
||||
static int32_t send_c[CTL], send_d[CTL], send_r[CTL], wet[CTL], mix_l[CTL], mix_r[CTL], part_buf[CTL];
|
||||
static int32_t send_c[CTL], send_d[CTL], send_r[CTL], wet_l[CTL], wet_r[CTL], mix_l[CTL], mix_r[CTL], part_buf[CTL];
|
||||
|
||||
/* ---- mute / solo: a track that goes silent fades out over ~6 ms (and back in) */
|
||||
#define MUTE_STEP 4096 /* Q15 per block: 8 blocks */
|
||||
@@ -243,7 +275,7 @@ static void mix_part(track_t *t, uint32_t n)
|
||||
return;
|
||||
}
|
||||
{
|
||||
int32_t lvl = LEVEL_Q12[t->p[P_LEVEL] & 127], pan = t->p[P_PAN];
|
||||
int32_t lvl = LEVEL_Q12[t->p[P_LEVEL] ? clamp(t->p[P_LEVEL] + t->p[P_ED_FX], 1, 127) : 0], pan = t->p[P_PAN]; /* (+ the sound's trim: 1/2 dB steps, as LEVEL's) */
|
||||
int32_t gl = 4096 - (pan > 0 ? pan * 64 : 0), gr = 4096 + (pan < 0 ? pan * 64 : 0);
|
||||
int32_t c = t->p[P_CHOR] * 258, d = t->p[P_DLY] * 258, r = t->p[P_REV] * 258, pk = t->peak;
|
||||
int32_t xmax = c > d ? c : d;
|
||||
@@ -251,8 +283,10 @@ static void mix_part(track_t *t, uint32_t n)
|
||||
xmax = 0x7FFFFFFF / ((xmax > r ? xmax : r) | 1); /* sends: loud chords at a high LEVEL */
|
||||
track_dist(t, b, n);
|
||||
slicer_track(t, b, n); /* slicer.c: before the level, pan and sends */
|
||||
int32_t lvl0 = t->lvl ? t->lvl : lvl, dl = (lvl - lvl0) >> CTL_LOG2; /* a new sound's trim: ramped */
|
||||
t->lvl = lvl;
|
||||
for (i = 0; i < n; i++) {
|
||||
int32_t x = ((b[i] >> 2) * lvl) >> 10, a; /* pre-shift: 8 loud voices */
|
||||
int32_t x = ((b[i] >> 2) * (lvl0 + dl * (int32_t)i)) >> 10, a; /* pre-shift: 8 loud voices */
|
||||
int32_t xs, g = ga + (((gb - ga) * (int32_t)i) >> CTL_LOG2);
|
||||
if (g < 32767)
|
||||
x = (x >> 4) * (g >> 3) >> 8; /* (Q15 in two halves: no 32-bit overflow) */
|
||||
@@ -384,10 +418,10 @@ static void mix_block(int32_t *out, uint32_t n)
|
||||
drums.a0 = TDRUM->att; /* the drum track's mute / solo fade */
|
||||
drums.a1 = 32767 - gain_next(TDRUM);
|
||||
slicer_drums(mix_l, mix_r, send_r, n); /* drums_render, through the SLICER when on */
|
||||
fx_buses(send_c, send_d, send_r, wet, n);
|
||||
fx_buses(send_c, send_d, send_r, wet_l, wet_r, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
mix_l[i] += wet[i];
|
||||
mix_r[i] += wet[i];
|
||||
mix_l[i] += wet_l[i];
|
||||
mix_r[i] += wet_r[i];
|
||||
}
|
||||
dust_process(mix_l, mix_r, n);
|
||||
punch_process(mix_l, mix_r, n);
|
||||
|
||||
+19
-5
@@ -12,7 +12,7 @@ void fm1_timer5_irq(void)
|
||||
fm1_timer5_ack();
|
||||
felucca_dbg.timer_irqs++;
|
||||
if (felucca_dbg.in_audio)
|
||||
felucca_dbg.nested++; /* only possible if this IRQ outranks ALNK0 */
|
||||
felucca_dbg.nested++; /* a tick inside the audio render (it outranks ALNK0) */
|
||||
fm1_input_tick();
|
||||
if (sub % 5u == 0u)
|
||||
usb_poll(); /* 2 kHz: all USB SIE traffic lives here */
|
||||
@@ -37,7 +37,11 @@ extern void isr_timer5(void);
|
||||
|
||||
static void timer5_start(void) /* OSC /4 = 6 MHz, PRD 600 -> 10 kHz */
|
||||
{
|
||||
fm1_timer5_start(isr_timer5, 1); /* below ALNK0 (3): no nesting into audio */
|
||||
/* above ALNK0 (3): the tick may nest into the audio render (a few us; plain registers, the
|
||||
* MIDI rings are single-producer / single-consumer). Below it, a tick waited for the render
|
||||
* and the column it had lit stayed on longer: the LEDs shimmered, beating against the audio
|
||||
* blocks (1378 / s against the 909 / s scan) */
|
||||
fm1_timer5_start(isr_timer5, 4);
|
||||
}
|
||||
|
||||
static void hexs(char *b, uint32_t v)
|
||||
@@ -161,11 +165,12 @@ static void fm1_main(void)
|
||||
song.master_q12 = (k10 * k10) >> 8; /* 0 .. ~4096 */
|
||||
}
|
||||
}
|
||||
{ /* OCT- + OCT+ held 5 s: enter UBOOT with RAM intact (debug / update); a countdown
|
||||
* shows from 2 s, letting go cancels it */
|
||||
{ /* OCT- + OCT+ held 5 s, stopped: enter UBOOT with RAM intact (debug / update); a countdown
|
||||
* shows from 2 s, letting go cancels it. Not while playing: on the drum track these are the
|
||||
* ghost / hard modifiers, held for a long time */
|
||||
static uint32_t t0, shown;
|
||||
uint32_t both = (1u << panel.btn[B_OCTDN]) | (1u << panel.btn[B_OCTUP]);
|
||||
if ((fm1_in.buttons & both) != both) {
|
||||
if ((fm1_in.buttons & both) != both || song.playing) {
|
||||
if (shown)
|
||||
ui_say("UPDATE MODE ", "CANCELLED");
|
||||
shown = 0;
|
||||
@@ -179,6 +184,9 @@ static void fm1_main(void)
|
||||
}
|
||||
} else if (fm1_ms - t0 > 5000u) {
|
||||
fm1_audio_stop();
|
||||
#if FELUCCA_ARRANGER
|
||||
persist_flush_now(); /* (live sections, song, project: RAM-only so far) */
|
||||
#endif
|
||||
lcd_fill(0, 0, 240, 240, C_BLACK);
|
||||
draw_text_box(0, 110, 240, &FONT_S, "UBOOT", RGB(80, 120, 255), 1);
|
||||
usb_detach();
|
||||
@@ -193,6 +201,9 @@ static void fm1_main(void)
|
||||
if (usb.ota_req) { /* M-UPGRADE upgrade command */
|
||||
usb.ota_req = 0;
|
||||
panic_req = (1u << NTRK) - 1u; /* every track (bit per track) */
|
||||
#if FELUCCA_ARRANGER
|
||||
persist_flush_now(); /* an update ends in a reset: RAM-only work first */
|
||||
#endif
|
||||
if (flash_ok)
|
||||
ota_session(); /* returns only if nothing was committed */
|
||||
lcd_fill(0, 0, 240, 240, C_BLACK);
|
||||
@@ -201,6 +212,9 @@ static void fm1_main(void)
|
||||
#endif
|
||||
if (usb.uboot_req) { /* SysEx F0 22 24 35 7D F7 from the host */
|
||||
fm1_audio_stop();
|
||||
#if FELUCCA_ARRANGER
|
||||
persist_flush_now(); /* (live sections, song, project: RAM-only so far) */
|
||||
#endif
|
||||
lcd_fill(0, 0, 240, 240, C_BLACK);
|
||||
draw_text_box(0, 110, 240, &FONT_S, "UBOOT (USB)", C_WHITE, 1);
|
||||
fm1_delay_ms(20);
|
||||
|
||||
@@ -52,9 +52,13 @@ static uint32_t panel_btn_of(uint32_t matrix_id) /* label of a matrix but
|
||||
static void panel_led(uint32_t label, int on) { fm1_led_key(panel.btn[label], on); }
|
||||
|
||||
/* steps of a role, + = clockwise */
|
||||
static uint32_t ui_input_ms; /* the last button, key or knob turn (ui_input.c; autosave) */
|
||||
static int32_t panel_enc(uint32_t role)
|
||||
{
|
||||
return fm1_enc_take(panel.enc[role]) * panel.dir[role];
|
||||
int32_t s = fm1_enc_take(panel.enc[role]) * panel.dir[role];
|
||||
if (s)
|
||||
ui_input_ms = fm1_ms; /* a knob turning is not idle either: autosave waits */
|
||||
return s;
|
||||
}
|
||||
|
||||
/* user settings that survive a reset */
|
||||
@@ -62,6 +66,7 @@ static int32_t panel_enc(uint32_t role)
|
||||
struct { uint32_t magic, palette, lowcut, zoom; } settings __attribute__((section(".noinit")));
|
||||
|
||||
static void settings_save(void); /* project.c: flash copy (FELUCCA_FLASH) */
|
||||
static uint8_t settings_later; /* changed while playing: saved once stopped (project.c) */
|
||||
|
||||
static void settings_init(void)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ static const param_desc_t TP[P_COUNT] = {
|
||||
[P_ED_FLT] = PD("FLT", F_BIPCT, -64, 63, 0),
|
||||
[P_ED_PIT] = PD("PIT", F_BIPCT, -64, 63, 0),
|
||||
[P_ED_SHP] = PD("SHP", F_BIPCT, -64, 63, 0),
|
||||
[P_ED_FX] = PD("FX", F_BIPCT, -64, 63, 0),
|
||||
[P_ED_FX] = PD("TRIM", F_INT, -64, 63, 0), /* the sound's level trim, 1/2 dB (presets set it) */
|
||||
[P_LRATE] = PD("RATE", F_LFOHZ, 0, 127, 60),
|
||||
[P_LWAVE] = PE("WAVE", N_LWAVE, 0),
|
||||
[P_LPHASE] = PD("PHS", F_INT, 0, 127, 0),
|
||||
@@ -276,7 +276,7 @@ typedef struct {
|
||||
|
||||
static const page_t PAGES[] = {
|
||||
{"ENV", FAM_ENV, SC_TRACK, GR_ADSR, {P_ATK, P_DEC, P_SUS, P_REL}},
|
||||
{"ENV DEST", FAM_ENV, SC_TRACK, GR_NONE, {P_ED_FLT, P_ED_PIT, P_ED_SHP, 0xFF}}, /* (P_ED_FX: nothing reads it) */
|
||||
{"ENV DEST", FAM_ENV, SC_TRACK, GR_NONE, {P_ED_FLT, P_ED_PIT, P_ED_SHP, 0xFF}}, /* (P_ED_FX: the level trim, no page) */
|
||||
{"LFO", FAM_LFO, SC_TRACK, GR_LFO, {P_LRATE, P_LWAVE, P_LPHASE, P_LFADE}},
|
||||
{"LFO DEST", FAM_LFO, SC_TRACK, GR_NONE, {P_LD_PIT, P_LD_FLT, P_LD_SHP, P_LD_AMP}},
|
||||
{"FX", FAM_FX, SC_TRACK, GR_FX, {P_DIST, P_CHOR, P_DLY, P_REV}},
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/* generated by tools/level_presets.py: the level trim of each factory preset, 1/2 dB */
|
||||
#pragma once
|
||||
#define PT_ENGINES 9u
|
||||
#define PT_MAX 16u
|
||||
static const int8_t PRESET_TRIM[PT_ENGINES][PT_MAX] = {
|
||||
{/* 0.0 808 BOOM */ -9, /* 0.1 808 DIRTY */ -3, /* 0.2 SUB BASS */ -10, /* 0.3 808 SLIDE */ -4, /* 0.4 ACID 303 */ 23, /* 0.5 PLUGG BASS */ -6, /* 0.6 REESE */ 3, /* 0.7 WOBBLE */ 7, /* 0.8 FUNK BASS */ 16, /* 0.9 G-FUNK LD */ -10, /* 0.10 TRAP PLUCK */ 23, /* 0.11 SYN BRASS */ 23, /* 0.12 SUPERSAW */ -18, /* 0.13 WARM PAD */ -7, /* 0.14 DARK STR */ -4, /* 0.15 ATMOS PAD */ -9},
|
||||
{/* 1.0 RHODES */ 23, /* 1.1 DX RHODES */ 15, /* 1.2 WURLI */ 23, /* 1.3 CLAV */ 14, /* 1.4 M1 PIANO */ 17, /* 1.5 AFRO KEYS */ 18, /* 1.6 TRAP BELL */ 6, /* 1.7 MUSIC BOX */ 7, /* 1.8 MARIMBA */ 23, /* 1.9 KALIMBA */ 23, /* 1.10 PLUGG BELL */ 16, /* 1.11 GLASS PAD */ -18, /* 1.12 FM BASS */ 11},
|
||||
{/* 2.0 CZ BASS */ 23, /* 2.1 SOFT KEYS */ 23, /* 2.2 CZ STRING */ -21, /* 2.3 RESO PLUCK */ 19, /* 2.4 CZ BRASS */ 8},
|
||||
{/* 3.0 GAME LEAD */ -4, /* 3.1 GB BASS */ 15, /* 3.2 8BIT ARP */ -5},
|
||||
{/* 4.0 GRAND PNO */ 17, /* 4.1 UP BASS */ 2, /* 4.2 VIBES */ -4, /* 4.3 HORN STAB */ -8, /* 4.4 STRING STB */ 23, /* 4.5 LOFI FLUTE */ -1, /* 4.6 SCRATCH */ -3, /* 4.7 GM KIT */ 0, /* 4.8 DUSTY PNO */ 19, /* 4.9 LOFI KEYS */ 11, /* 4.10 DEEP BASS */ 23},
|
||||
{/* 5.0 CHOIR AAH */ -26, /* 5.1 SOUL OOH */ -24, /* 5.2 TALKBOX */ -7, /* 5.3 WOW BASS */ 6},
|
||||
{/* 6.0 FAT BASS */ 23, /* 6.1 MIN STAB */ 23, /* 6.2 MIN7 STAB */ 23, /* 6.3 RAVE STAB */ 23, /* 6.4 DUB CHORD */ 23, /* 6.5 SAW PAD */ -11, /* 6.6 SYNC LEAD */ -3, /* 6.7 HOOVER */ 5},
|
||||
{/* 7.0 SOUL ORGAN */ -14, /* 7.1 GOSPEL */ -10, /* 7.2 JAZZ ORGAN */ -8, /* 7.3 DIRTY B3 */ -10, /* 7.4 HOUSE ORGN */ -7},
|
||||
{/* 8.0 LOFI CLOUD */ 4, /* 8.1 VIBE HAZE */ 2, /* 8.2 FLUTE DUST */ -1},
|
||||
};
|
||||
+51
-17
@@ -288,6 +288,7 @@ static void proj_apply(const project_t *p, int all)
|
||||
#if FELUCCA_ARRANGER
|
||||
#include "arranger_scene.c"
|
||||
#endif
|
||||
static uint8_t sec_dirty, song_dirty; /* live sections / the song: in RAM, not yet in flash */
|
||||
#if FELUCCA_FLASH
|
||||
/* slot from flash into RAM (format 4, or an old one converted) */
|
||||
static union {
|
||||
@@ -484,11 +485,18 @@ static void persist_boot(void) /* before settings_init / pane
|
||||
panel = old;
|
||||
}
|
||||
}
|
||||
{ /* projects: fill empty RAM slots from flash, so the slot list is right after power-on */
|
||||
{ /* projects: fill empty RAM slots from flash, so the slot list is right after power-on. A slot
|
||||
* still valid in RAM (a warm reset: an update, UPDATE MODE, a crash) may never have reached
|
||||
* flash (a live section stored while playing): marked to be written when quiet */
|
||||
uint32_t i;
|
||||
for (i = 0; i < 4u; i++)
|
||||
if (!proj_ok(&proj_slot[i]))
|
||||
if (!proj_ok(&proj_slot[i])) {
|
||||
proj_fetch(i);
|
||||
} else {
|
||||
int n = st_load(OBJ_PROJECT0 + i, &proj_tmp, sizeof proj_tmp);
|
||||
if (n != (int)sizeof proj_slot[i] || memcmp(&proj_tmp.v4, &proj_slot[i], sizeof proj_slot[i]))
|
||||
sec_dirty |= (uint8_t)(1u << i);
|
||||
}
|
||||
}
|
||||
up_boot(); /* user presets */
|
||||
#endif
|
||||
@@ -538,7 +546,6 @@ static void arrangement_save(void)
|
||||
/* ---- live sections (SAVE + key, ui_layers.c). A section is a project slot (A..D = 1..4): stored into RAM
|
||||
* at once (playing too), written to flash once the transport is stopped and nothing sounds (an erase
|
||||
* stops the audio for ~50 ms); a song recorded with SONG REC is saved the same way. */
|
||||
static uint8_t sec_dirty, song_dirty;
|
||||
static void section_store(uint32_t s)
|
||||
{
|
||||
s &= 3u;
|
||||
@@ -554,9 +561,39 @@ static void section_load(uint32_t s) /* stopped: the section
|
||||
project_apply(&proj_slot[s]);
|
||||
live_sec = (int8_t)s;
|
||||
}
|
||||
static void sections_flush(void) /* main loop */
|
||||
static void sections_write(void) /* the dirty sections and song into flash */
|
||||
{
|
||||
uint32_t i;
|
||||
#if FELUCCA_FLASH
|
||||
if (flash_ok)
|
||||
for (i = 0; i < 4u; i++)
|
||||
if (((sec_dirty >> i) & 1u) && st_save(OBJ_PROJECT0 + i, &proj_slot[i], sizeof proj_slot[i]) == 0)
|
||||
sec_dirty &= (uint8_t)~(1u << i); /* (a failed write stays dirty: tried again later) */
|
||||
if (!flash_ok)
|
||||
#endif
|
||||
sec_dirty = 0;
|
||||
(void)i;
|
||||
if (song_dirty) {
|
||||
song_dirty = 0;
|
||||
settings_save();
|
||||
}
|
||||
}
|
||||
/* before an intentional reset (an update, UPDATE MODE, UBOOT from the host): the audio is stopped, so
|
||||
* whatever is only in RAM goes to flash now: the live sections, the song, the working project */
|
||||
static void persist_flush_now(void)
|
||||
{
|
||||
sections_write();
|
||||
#if FELUCCA_FLASH
|
||||
if (flash_ok && !arrangement_clock.running) { /* (a song playing: the tracks hold a section) */
|
||||
proj_capture(&autosave_buf);
|
||||
if (autosave_buf.sum != autosave_hash && st_save(OBJ_AUTOSAVE, &autosave_buf, sizeof autosave_buf) == 0)
|
||||
autosave_hash = autosave_buf.sum;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
static void sections_flush(void) /* main loop */
|
||||
{
|
||||
static uint32_t tried;
|
||||
if (srec_done) {
|
||||
song_dirty = srec_done != 0xFFu;
|
||||
if (song_dirty) {
|
||||
@@ -568,20 +605,17 @@ static void sections_flush(void) /* main loop */
|
||||
}
|
||||
srec_done = 0;
|
||||
}
|
||||
if ((!sec_dirty && !song_dirty) || song.playing || transport_req || !audio_quiet() || fm1_ms - ui_input_ms < 1500u)
|
||||
return;
|
||||
#if FELUCCA_FLASH
|
||||
if (flash_ok)
|
||||
for (i = 0; i < 4u; i++)
|
||||
if ((sec_dirty >> i) & 1u)
|
||||
st_save(OBJ_PROJECT0 + i, &proj_slot[i], sizeof proj_slot[i]);
|
||||
#endif
|
||||
(void)i;
|
||||
sec_dirty = 0;
|
||||
if (song_dirty) {
|
||||
song_dirty = 0;
|
||||
settings_save();
|
||||
if (settings_later) { /* the menu closed while playing */
|
||||
settings_later = 0;
|
||||
song_dirty = 1; /* (settings_save when quiet, with the song) */
|
||||
}
|
||||
if ((!sec_dirty && !song_dirty) || song.playing || transport_req || !audio_quiet() || fm1_ms - ui_input_ms < 1500u ||
|
||||
fm1_ms - tried < 5000u)
|
||||
return;
|
||||
tried = fm1_ms; /* (a failed write: again in 5 s, not every frame) */
|
||||
sections_write();
|
||||
if (sec_dirty)
|
||||
ui_message("SAVE ERROR: RETRYING");
|
||||
}
|
||||
#endif
|
||||
#endif /* PROJ_HOST */
|
||||
+16
-1
@@ -109,6 +109,20 @@ static int32_t punch_ring_fx(int32_t fx)
|
||||
return k < 64u ? (y * (int32_t)k) >> 6 : len - k < 64u ? (y * (int32_t)(len - k)) >> 6 : y;
|
||||
}
|
||||
|
||||
/* the loops, STUTTER, HALF and REVERSE replay ring samples [start, start + len) (REVERSE: up to start,
|
||||
* backwards). The ring keeps recording the mix, and after PUNCH_N samples (0.74 s) the writer comes
|
||||
* round into that span: it skips those slots once the loop is captured, so a held loop plays for as
|
||||
* long as the key is held. The rest of the ring keeps recording (the next effect has its past). */
|
||||
static int punch_owns(int32_t fx, uint32_t w)
|
||||
{
|
||||
uint32_t d = w - punch.start, len = punch.len;
|
||||
if (fx < 0 || fx > PX_HALF || fx == PX_STOP || punch.pre)
|
||||
return 0;
|
||||
if (fx == PX_REV)
|
||||
return d >= 1u && ((d + len - 1u) & (PUNCH_N - 1u)) < len;
|
||||
return d >= len && (d & (PUNCH_N - 1u)) < len;
|
||||
}
|
||||
|
||||
/* l, r: the mix before the master (fx.c mix_block), n samples, in place */
|
||||
static void punch_process(int32_t *l, int32_t *r, uint32_t n)
|
||||
{
|
||||
@@ -142,7 +156,8 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n)
|
||||
int32_t x = l[i], y = r[i], wl = x, wr = y, m = (x + y) >> 1;
|
||||
int32_t fx = punch.cur;
|
||||
uint32_t target = want == fx ? 32767u : 0u;
|
||||
punch_ring[punch.w & (PUNCH_N - 1u)] = (int16_t)clamp(m >> 3, -32768, 32767);
|
||||
if (!punch_owns(fx, punch.w)) /* (a held loop keeps its material) */
|
||||
punch_ring[punch.w & (PUNCH_N - 1u)] = (int16_t)clamp(m >> 3, -32768, 32767);
|
||||
switch (fx) {
|
||||
case PX_LPF:
|
||||
wl = tsvf_lp(&c1, x >> 1, &punch.f1l, &punch.f2l) << 1;
|
||||
|
||||
+18
-5
@@ -69,10 +69,15 @@ static uint32_t scale_mask(const track_t *t)
|
||||
enum { LY_PLAY, LY_FX, LY_ERASE, LY_ROLL, LY_STEP, LY_SCALE, LY_MIX, LY_SONG, LY_COUNT };
|
||||
static uint32_t ly_bit[LY_COUNT]; /* the button (fm1_in.buttons bit) of each layer: the UI sets them */
|
||||
static uint32_t dyn_bit[2]; /* OCT- / OCT+: ghost / hard on the drum track */
|
||||
/* the layer the keys are in: the held function button (FX, EDIT, ARP, SEQ, SCL, GLO in that order) */
|
||||
/* a layer locked open (its button held + HOME tapped: ui_input.c), LY_PLAY = none: the keys and knobs
|
||||
* stay in it with the button let go, as if it were held */
|
||||
static volatile uint8_t ly_lock = LY_PLAY;
|
||||
static uint32_t layer_buttons(void) { return fm1_in.buttons | (ly_lock != LY_PLAY ? ly_bit[ly_lock % LY_COUNT] : 0u); }
|
||||
/* the layer the keys are in: the held function button (FX, EDIT, ARP, SEQ, SCL, GLO in that order),
|
||||
* else the locked one */
|
||||
static uint32_t layer_now(void)
|
||||
{
|
||||
uint32_t b = fm1_in.buttons, l;
|
||||
uint32_t b = layer_buttons(), l;
|
||||
for (l = LY_FX; l < LY_COUNT; l++)
|
||||
if (b & ly_bit[l])
|
||||
return l;
|
||||
@@ -709,6 +714,8 @@ static void arp_tick(track_t *t, uint32_t adv)
|
||||
t->arp_new = 0;
|
||||
t->arp_abs = into * 4u >= slen * 3u ? abs : abs - 1u; /* the last quarter: the grid plays it */
|
||||
}
|
||||
if (abs + 1u == t->arp_abs)
|
||||
abs = t->arp_abs; /* ARP SWG turned up inside an odd step: no replay */
|
||||
fire = abs != t->arp_abs;
|
||||
t->arp_abs = abs;
|
||||
} else {
|
||||
@@ -1081,7 +1088,7 @@ static void key_up(uint32_t k)
|
||||
static void keyboard_block(void)
|
||||
{
|
||||
uint32_t cur = fm1_in.notes, ch = cur ^ kb_prev, k, r;
|
||||
if (!(fm1_in.buttons & ly_bit[LY_ROLL])) /* ARP up: the rolls end (the keys stay silent) */
|
||||
if (!(layer_buttons() & ly_bit[LY_ROLL])) /* ARP up (and not locked): the rolls end (the keys stay silent) */
|
||||
for (r = 0; r < NROLL; r++)
|
||||
if (roll[r].on)
|
||||
roll_end(r);
|
||||
@@ -1166,7 +1173,8 @@ static void srec_add(uint32_t s)
|
||||
/* STOP (or SONG REC pressed again): the bar playing counts if it had begun */
|
||||
static void srec_stop(void)
|
||||
{
|
||||
if (srec == 2u && srec_n && (clk_beat & 3u || clk_pos) && srec_e[srec_n - 1u].bars < 64u)
|
||||
if (srec == 2u && srec_n && srec_e[srec_n - 1u].bars < 64u &&
|
||||
((!(clk_beat & 3u) && (clk_beat >> 2) != live_bar) || (clk_beat & 3u)))
|
||||
srec_e[srec_n - 1u].bars++;
|
||||
if (srec == 2u)
|
||||
srec_finish();
|
||||
@@ -1406,6 +1414,8 @@ static void seq_tick(track_t *t, uint32_t adv)
|
||||
if (!song.playing)
|
||||
return;
|
||||
abs = trk_grid(t, &into, &slen);
|
||||
if (t->seq_abs != SEQ_NONE && abs + 1u == t->seq_abs)
|
||||
abs = t->seq_abs; /* SWING turned up inside a played odd step */
|
||||
if (abs != t->seq_abs) { /* a new step: one a block at most */
|
||||
t->seq_abs = abs;
|
||||
idx = abs % len;
|
||||
@@ -1491,7 +1501,10 @@ static void events_block(uint32_t n)
|
||||
#if FELUCCA_ARRANGER
|
||||
if (song.playing && arrangement_clock.running) {
|
||||
int scene = arr_next(&arrangement_clock, &arrangement, FS);
|
||||
if (scene == ARR_DONE) seq_stop();
|
||||
if (scene == ARR_DONE) {
|
||||
arrangement_clock.running = 1; /* (arr_next cleared it: seq_stop brings the loop back) */
|
||||
seq_stop();
|
||||
}
|
||||
else if (scene >= 0) {
|
||||
arrangement_apply((uint32_t)scene);
|
||||
seq_reset_tracks(arrangement_clock.phase); /* (the remainder: exactly on the bar) */
|
||||
|
||||
+61
-16
@@ -3,7 +3,7 @@
|
||||
/* Felucca user interface. Four columns map to KNOB 1..4. Rendering is lazy:
|
||||
* every element remembers what it last drew and is redrawn only on change. */
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "SLOOP 2.1" /* the beat machine firmware for the FM-1 (based on Felucca) */
|
||||
#define FELUCCA_VERSION "SLOOP 2.2" /* the beat machine firmware for the FM-1 (based on Felucca) */
|
||||
#endif
|
||||
static void project_save(uint32_t slot);
|
||||
static void arrangement_save(void);
|
||||
@@ -85,7 +85,6 @@ static struct {
|
||||
|
||||
static const page_t *cur_page(void) { return &PAGES[ui.page]; }
|
||||
static int32_t accel(uint32_t role, int32_t s, int32_t range); /* ui_input.c */
|
||||
static uint32_t ui_input_ms; /* the last button / key (ui_input.c; autosave) */
|
||||
static void layer_screen_draw(void); /* ui_layers.c */
|
||||
static void hold_screen_draw(void);
|
||||
static uint8_t layer_shown;
|
||||
@@ -258,6 +257,7 @@ static void apply_preset_to(track_t *t, uint32_t pi)
|
||||
t->p[P_SUS] = e->presets[pi].env[2];
|
||||
t->p[P_REL] = e->presets[pi].env[3];
|
||||
t->p[P_ED_FLT] = e->presets[pi].fenv;
|
||||
t->p[P_ED_FX] = preset_trim(t->eng_req % NENGINES, pi); /* level-matched (tools/level_presets.py) */
|
||||
t->p[P_VOICE] = e->presets[pi].mono ? V_LEGATO : V_POLY; /* mono presets keep the legato feel */
|
||||
{ /* the rest of the patch: sends, arpeggiator (never a pattern: LIVE) */
|
||||
static const uint8_t FX_DEF[4] = {0, 24, 28, 36};
|
||||
@@ -307,30 +307,75 @@ static void select_engine(uint32_t e)
|
||||
ui.force = 1;
|
||||
}
|
||||
|
||||
/* the presets of every engine, then the used user presets, as one list (the PRESETS knob and the PRESETS page browse it) */
|
||||
/* the factory presets as one list by kind (basses, keys, organs, pads, leads, plucks and bells, stabs,
|
||||
* the rest), then the used user presets: the PRESETS knob and the PRESETS page browse it. By name: an
|
||||
* engine's preset table may change order; tests/ui_pages_test.c checks every preset is here once */
|
||||
enum { BK_BASS, BK_KEYS, BK_ORGAN, BK_PAD, BK_LEAD, BK_PLUCK, BK_STAB, BK_FX };
|
||||
static const char *const BANK_KIND[] = {"BASS", "KEYS", "ORGN", "PAD", "LEAD", "PLCK", "STAB", "FX"};
|
||||
static const struct { uint8_t kind, e; const char *name; } BANK[] = {
|
||||
{BK_BASS, 0, "808 BOOM"}, {BK_BASS, 0, "808 DIRTY"}, {BK_BASS, 0, "808 SLIDE"}, {BK_BASS, 0, "SUB BASS"},
|
||||
{BK_BASS, 0, "PLUGG BASS"}, {BK_BASS, 0, "REESE"}, {BK_BASS, 0, "WOBBLE"}, {BK_BASS, 0, "ACID 303"},
|
||||
{BK_BASS, 1, "FM BASS"}, {BK_BASS, 2, "CZ BASS"}, {BK_BASS, 6, "FAT BASS"}, {BK_BASS, 0, "FUNK BASS"},
|
||||
{BK_BASS, 5, "WOW BASS"}, {BK_BASS, 3, "GB BASS"}, {BK_BASS, 4, "UP BASS"}, {BK_BASS, 4, "DEEP BASS"},
|
||||
{BK_KEYS, 1, "RHODES"}, {BK_KEYS, 1, "DX RHODES"}, {BK_KEYS, 1, "WURLI"}, {BK_KEYS, 1, "M1 PIANO"},
|
||||
{BK_KEYS, 1, "AFRO KEYS"}, {BK_KEYS, 4, "GRAND PNO"}, {BK_KEYS, 4, "DUSTY PNO"}, {BK_KEYS, 4, "LOFI KEYS"}, {BK_KEYS, 2, "SOFT KEYS"},
|
||||
{BK_KEYS, 1, "CLAV"},
|
||||
{BK_ORGAN, 7, "SOUL ORGAN"}, {BK_ORGAN, 7, "GOSPEL"}, {BK_ORGAN, 7, "JAZZ ORGAN"}, {BK_ORGAN, 7, "DIRTY B3"},
|
||||
{BK_ORGAN, 7, "HOUSE ORGN"},
|
||||
{BK_PAD, 0, "WARM PAD"}, {BK_PAD, 6, "SAW PAD"}, {BK_PAD, 1, "GLASS PAD"}, {BK_PAD, 0, "DARK STR"},
|
||||
{BK_PAD, 2, "CZ STRING"}, {BK_PAD, 0, "ATMOS PAD"}, {BK_PAD, 8, "LOFI CLOUD"}, {BK_PAD, 8, "VIBE HAZE"},
|
||||
{BK_PAD, 5, "CHOIR AAH"}, {BK_PAD, 5, "SOUL OOH"},
|
||||
{BK_LEAD, 0, "SUPERSAW"}, {BK_LEAD, 0, "G-FUNK LD"}, {BK_LEAD, 6, "SYNC LEAD"}, {BK_LEAD, 6, "HOOVER"},
|
||||
{BK_LEAD, 5, "TALKBOX"}, {BK_LEAD, 3, "GAME LEAD"}, {BK_LEAD, 4, "LOFI FLUTE"}, {BK_LEAD, 8, "FLUTE DUST"},
|
||||
{BK_PLUCK, 0, "TRAP PLUCK"}, {BK_PLUCK, 2, "RESO PLUCK"}, {BK_PLUCK, 1, "PLUGG BELL"}, {BK_PLUCK, 1, "TRAP BELL"},
|
||||
{BK_PLUCK, 1, "MUSIC BOX"}, {BK_PLUCK, 1, "KALIMBA"}, {BK_PLUCK, 1, "MARIMBA"}, {BK_PLUCK, 4, "VIBES"},
|
||||
{BK_PLUCK, 3, "8BIT ARP"},
|
||||
{BK_STAB, 6, "MIN STAB"}, {BK_STAB, 6, "MIN7 STAB"}, {BK_STAB, 6, "RAVE STAB"}, {BK_STAB, 6, "DUB CHORD"},
|
||||
{BK_STAB, 0, "SYN BRASS"}, {BK_STAB, 2, "CZ BRASS"}, {BK_STAB, 4, "HORN STAB"}, {BK_STAB, 4, "STRING STB"},
|
||||
{BK_FX, 4, "SCRATCH"}, {BK_FX, 4, "GM KIT"},
|
||||
};
|
||||
#define NBANK (sizeof BANK / sizeof BANK[0])
|
||||
static uint8_t bank_pi[NBANK]; /* the preset index of each entry in its engine */
|
||||
static uint8_t bank_ready;
|
||||
static void bank_resolve(void)
|
||||
{
|
||||
uint32_t i, k;
|
||||
for (i = 0; i < NBANK; i++) {
|
||||
const engine_t *e = ENGINES[BANK[i].e % NENGINES];
|
||||
bank_pi[i] = 0xFF;
|
||||
for (k = 0; k < e->npresets; k++)
|
||||
if (str_eq(e->presets[k].name, BANK[i].name))
|
||||
bank_pi[i] = (uint8_t)k;
|
||||
}
|
||||
bank_ready = 1;
|
||||
}
|
||||
static uint32_t preset_pos(uint32_t *total) /* list index of the selected track's preset */
|
||||
{
|
||||
uint32_t n = 0, cur = 0, e;
|
||||
for (e = 0; e < NENGINES; e++) {
|
||||
if (e == TSEL->eng_req)
|
||||
cur = n + TSEL->preset % (ENGINES[e]->npresets ? ENGINES[e]->npresets : 1u);
|
||||
n += ENGINES[e]->npresets;
|
||||
}
|
||||
uint32_t i, cur = 0;
|
||||
if (!bank_ready)
|
||||
bank_resolve();
|
||||
for (i = 0; i < NBANK; i++)
|
||||
if (BANK[i].e == TSEL->eng_req && bank_pi[i] == TSEL->preset)
|
||||
cur = i;
|
||||
if (user_of(TSEL) < UP_SLOTS)
|
||||
cur = n + up_rank(user_of(TSEL));
|
||||
*total = n + up_count();
|
||||
cur = NBANK + up_rank(user_of(TSEL));
|
||||
*total = NBANK + up_count();
|
||||
return cur;
|
||||
}
|
||||
|
||||
/* list index n (< total) -> engine, *k its preset; NENGINES = user preset, *k its slot */
|
||||
static uint32_t preset_at(uint32_t n, uint32_t *k)
|
||||
{
|
||||
uint32_t e;
|
||||
for (e = 0; e < NENGINES && n >= ENGINES[e]->npresets; e++)
|
||||
n -= ENGINES[e]->npresets;
|
||||
*k = e < NENGINES ? n : up_nth(n);
|
||||
return e;
|
||||
if (!bank_ready)
|
||||
bank_resolve();
|
||||
if (n >= NBANK) {
|
||||
*k = up_nth(n - NBANK);
|
||||
return NENGINES;
|
||||
}
|
||||
*k = bank_pi[n] == 0xFF ? 0u : bank_pi[n];
|
||||
return BANK[n].e;
|
||||
}
|
||||
static const char *preset_kind(uint32_t n) { return n < NBANK ? BANK_KIND[BANK[n].kind] : "USER"; }
|
||||
|
||||
static void preset_go(uint32_t n) /* load list index n into the selected track */
|
||||
{
|
||||
|
||||
@@ -376,7 +376,7 @@ static uint32_t graph_signature(void)
|
||||
}
|
||||
return h;
|
||||
}
|
||||
/* preset browser: the global list (every engine), current one in white */
|
||||
/* preset browser: the list by kind (ui.c BANK), the current one in white */
|
||||
static void graph_browse(void)
|
||||
{
|
||||
uint32_t total, cur = preset_pos(&total), e, k;
|
||||
@@ -385,14 +385,15 @@ static void graph_browse(void)
|
||||
return;
|
||||
for (row = -3; row <= 3; row++) {
|
||||
int32_t y = 4 + (row + 3) * 17;
|
||||
char tag[4], nm[13];
|
||||
char tag[5], nm[13];
|
||||
int sel = row == 0;
|
||||
e = preset_at((cur + total * 4u + (uint32_t)row) % total, &k);
|
||||
uint32_t n = (cur + total * 4u + (uint32_t)row) % total;
|
||||
e = preset_at(n, &k);
|
||||
if (e == NENGINES) { /* user preset: "U07" and its name */
|
||||
up_slot_label(tag, k);
|
||||
up_name(k, nm);
|
||||
} else {
|
||||
str_cpy(tag, ENGINES[e]->name, sizeof tag);
|
||||
} else { /* its kind: BASS, KEYS, PAD... */
|
||||
str_cpy(tag, preset_kind(n), sizeof tag);
|
||||
str_cpy(nm, ENGINES[e]->presets[k].name, sizeof nm);
|
||||
}
|
||||
if (sel)
|
||||
|
||||
+52
-7
@@ -127,7 +127,8 @@ static void ui_leds(void)
|
||||
led_pos_init();
|
||||
ready = 1;
|
||||
}
|
||||
led_put(nl, panel.btn[ui.layer != LY_PLAY ? LAYER_BTN[ui.layer] : cur_btn()], 1);
|
||||
led_put(nl, panel.btn[ui.layer != LY_PLAY ? LAYER_BTN[ui.layer] : cur_btn()],
|
||||
ly_lock == LY_PLAY || ((fm1_ms / 300u) & 1u) != 0u || (fm1_in.buttons & ly_bit[ly_lock % LY_COUNT]) != 0u); /* locked: blinks */
|
||||
led_put(nl, panel.btn[B_PLAY], play_led() || (song.playing && !song.rec && ft_on));
|
||||
led_put(nl, panel.btn[B_REC], song.rec != 0u || ft_on || (rec_wait && ((fm1_ms / 125u) & 1u)) ||
|
||||
(ui.hold_kind == 1u && ((fm1_ms / 60u) & 1u))); /* blinks: armed; fast: clearing */
|
||||
@@ -343,6 +344,12 @@ static void edit_param(uint32_t slot, int32_t steps)
|
||||
break;
|
||||
case G_NEWPRJ:
|
||||
*vp = 0;
|
||||
#if FELUCCA_ARRANGER
|
||||
if (song.playing && arrangement_enabled) { /* (the song's stop would bring the old loop back) */
|
||||
ui_message("STOP THE SONG FIRST");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
project_new();
|
||||
ui_message("NEW PROJECT");
|
||||
break;
|
||||
@@ -458,18 +465,40 @@ static void layer_tap(uint32_t layer)
|
||||
}
|
||||
}
|
||||
|
||||
/* the layers, once a frame: which one is held, the taps on release, its keys and knobs. Returns 1
|
||||
* while one is held (the page does not take the knobs then) */
|
||||
static int layers_input(uint32_t note_edges)
|
||||
/* a layer locked open: a layer button held + HOME tapped. The layer stays with the button let go (both
|
||||
* hands free for the keys and the knobs); any other button but PLAY, REC and OCT- / OCT+ lets it go
|
||||
* (and does only that: its press is eaten) */
|
||||
static uint8_t home_eat; /* HOME pressed to unlock: its tap is eaten */
|
||||
static void layer_unlock(void)
|
||||
{
|
||||
if (ly_lock != LY_PLAY) {
|
||||
ly_lock = LY_PLAY;
|
||||
ui.force = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* the layers, once a frame: which one is held (or locked), the taps on release, its keys and knobs.
|
||||
* Returns 1 while one is held or locked (the page does not take the knobs then) */
|
||||
static int layers_input(uint32_t note_edges, uint32_t *pressed, uint32_t home)
|
||||
{
|
||||
static uint8_t down[LY_COUNT], used[LY_COUNT];
|
||||
static uint32_t t0[LY_COUNT];
|
||||
uint32_t l, now = fm1_ms, held = LY_PLAY;
|
||||
uint32_t l, now = fm1_ms, held = LY_PLAY, eat = 0;
|
||||
if (ly_lock != LY_PLAY) {
|
||||
uint32_t keep = 1u << panel.btn[B_PLAY] | 1u << panel.btn[B_REC] | 1u << panel.btn[B_OCTDN] | 1u << panel.btn[B_OCTUP];
|
||||
eat = *pressed & ~keep;
|
||||
if (eat) {
|
||||
layer_unlock();
|
||||
if (eat & 1u << panel.btn[B_HOME])
|
||||
home_eat = 1;
|
||||
*pressed &= ~eat;
|
||||
}
|
||||
}
|
||||
for (l = LY_FX; l < LY_COUNT; l++) {
|
||||
uint32_t d = (fm1_in.buttons & ly_bit[l]) != 0u;
|
||||
if (d && !down[l]) {
|
||||
t0[l] = now;
|
||||
used[l] = 0;
|
||||
used[l] = (uint8_t)((eat & ly_bit[l]) != 0u); /* (the press that unlocked: not a tap) */
|
||||
}
|
||||
if (d && note_edges)
|
||||
used[l] = 1; /* a key while held: not a tap */
|
||||
@@ -479,6 +508,16 @@ static int layers_input(uint32_t note_edges)
|
||||
if (d && held == LY_PLAY)
|
||||
held = l;
|
||||
}
|
||||
if (held != LY_PLAY && home == BT_TAP && !home_eat) { /* held + HOME: locked open */
|
||||
ly_lock = (uint8_t)held;
|
||||
used[held] = 1;
|
||||
ui.layer = (uint8_t)held;
|
||||
ui.force = 1;
|
||||
}
|
||||
if (held == LY_PLAY && ly_lock != LY_PLAY) {
|
||||
held = ly_lock;
|
||||
used[held] = 1;
|
||||
}
|
||||
punch.hold = (uint8_t)(held == LY_FX);
|
||||
if (held != LY_PLAY && held != ui.layer && ui.layer != LY_PLAY)
|
||||
ui.layer = (uint8_t)held; /* (from one layer straight to another) */
|
||||
@@ -604,6 +643,7 @@ static void ui_input(void)
|
||||
if (ui.menu) {
|
||||
menu_close();
|
||||
} else {
|
||||
layer_unlock();
|
||||
ui.menu = 1;
|
||||
ui.menu_sel = 0;
|
||||
ui.confirm = 0;
|
||||
@@ -617,7 +657,12 @@ static void ui_input(void)
|
||||
menu_input(pressed);
|
||||
return;
|
||||
}
|
||||
layered = layers_input(notes);
|
||||
layered = layers_input(notes, &pressed, home);
|
||||
if (home_eat && !((fm1_in.buttons >> panel.btn[B_HOME]) & 1u)) { /* (the HOME that unlocked: let go) */
|
||||
if (home == BT_TAP)
|
||||
home = BT_NONE;
|
||||
home_eat = 0;
|
||||
}
|
||||
pressed &= ~(ly_bit[LY_FX] | ly_bit[LY_ERASE] | ly_bit[LY_ROLL] | ly_bit[LY_STEP] | ly_bit[LY_SCALE] | ly_bit[LY_MIX] |
|
||||
ly_bit[LY_SONG]);
|
||||
holds_input(pressed, fm1_ms);
|
||||
|
||||
@@ -435,13 +435,19 @@ static void tiles_draw(const tile_t *tl, uint32_t *cache)
|
||||
|
||||
static void layer_title(const char *name, const char *sub, uint16_t col, uint32_t *cache)
|
||||
{
|
||||
uint32_t sig = studio_hash(studio_hash(col, name), sub) + (ui.msg_t ? studio_hash(3u, ui.msg) : 0u);
|
||||
uint32_t locked = ly_lock != LY_PLAY;
|
||||
uint32_t sig = studio_hash(studio_hash(col, name), sub) + (ui.msg_t ? studio_hash(3u, ui.msg) : 0u) + locked * 7919u;
|
||||
if (!ui.force && sig == *cache)
|
||||
return;
|
||||
*cache = sig;
|
||||
cv_begin(240, 40, C_BLACK);
|
||||
cv_text(4, 2, &FONT_L, name, col);
|
||||
cv_text(4 + text_w(&FONT_L, name) + 10, 18, &FONT_S, ui.msg_t ? ui.msg : sub, ui.msg_t ? C_WHITE : TE_G3);
|
||||
if (locked) { /* locked open (HOME): any button lets it go */
|
||||
int32_t w = (int32_t)text_w(&FONT_S, "LOCK") + 8;
|
||||
cv_rect(236 - w, 4, w, 15, C_WHITE);
|
||||
cv_text(240 - w, 4, &FONT_S, "LOCK", C_BLACK);
|
||||
}
|
||||
cv_rect(0, 38, 240, 1, TE_G1);
|
||||
cv_blit(0, 0);
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ static void draw_menu(void)
|
||||
cv_text(4, 88, &FONT_S, "H\xDCGELTON INSTRUMENTS", C_HI); /* Latin-1 U-umlaut */
|
||||
cv_text(4, 104, &FONT_S, "HUGELTON.COM", C_AMB);
|
||||
cv_text(4, 119, &FONT_S, "GPL-3.0, NO WARRANTY", C_HI);
|
||||
cv_text(4, 132, &FONT_S, "GITHUB.COM/HUGELTON/FELUCCA", C_AMB);
|
||||
cv_text(4, 132, &FONT_S, "GITHUB.COM/ISOD89/SLOOP-FM1", C_AMB); /* (the source of this firmware) */
|
||||
cv_text(4, 146, &FONT_S, "FONT: TERMINUS (OFL)", C_DIM);
|
||||
cv_text(4, 159, &FONT_S, "SAMPLES: VERSILIAN (CC0)", C_DIM);
|
||||
cv_text(4, 172, &FONT_S, "+ H\xDCGELTON SAMPLE PACK", C_DIM);
|
||||
cv_text(4, 172, &FONT_S, "+ SONIC PI (CC0)", C_DIM);
|
||||
cv_text(4, 185, &FONT_S, "PHASE: CRISPYZEBRA (GPL)", C_DIM);
|
||||
cv_text(4, 198, &FONT_S, "VOICE: REF. KLATTSCH (MIT)", C_DIM);
|
||||
} else {
|
||||
@@ -71,7 +71,10 @@ static void enc_drop(void) /* knob turns nobody take
|
||||
|
||||
static void menu_close(void)
|
||||
{
|
||||
settings_save(); /* palette / panel table, if changed */
|
||||
if (song.playing || transport_req)
|
||||
settings_later = 1; /* (a flash write stops the audio: once stopped) */
|
||||
else
|
||||
settings_save(); /* palette / panel table, if changed */
|
||||
ui.menu = 0;
|
||||
ui.force = 1;
|
||||
go_home();
|
||||
|
||||
@@ -307,6 +307,10 @@ static void up_ui(uint32_t op, uint32_t k) /* 0 load, 1 erase, 2 save */
|
||||
ui_say("LOADED ", l);
|
||||
return;
|
||||
}
|
||||
if (song.playing || transport_req) { /* a flash erase stops the audio ~50 ms */
|
||||
ui_message("STOP BEFORE SAVE");
|
||||
return;
|
||||
}
|
||||
rc = op == 1u ? up_put(k, 0) : up_store(k, 0);
|
||||
if (rc == 3)
|
||||
ui_message(op == 1u ? "ERASED (RAM)" : "SAVED (RAM)");
|
||||
|
||||
@@ -254,6 +254,13 @@ static void voice_start(track_t *t, voice_t *v, uint32_t note, uint32_t vel, int
|
||||
} else if (e == &ENG_LOFI) {
|
||||
v->s[0] = s0;
|
||||
v->s[4] = s4;
|
||||
} else if (e == &ENG_TRIO) {
|
||||
v->s[0] = s0; /* filter */
|
||||
v->s[1] = s1;
|
||||
v->s[4] = s4; /* the sample waiting for its step corrections */
|
||||
} else if (e == &ENG_PHASE) {
|
||||
v->s[0] = s0; /* the WAVE / WAVE2 toggles go with the phases kept */
|
||||
v->s[1] = s1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,11 +277,12 @@ static void mono_play(track_t *t, uint32_t note, uint32_t vel, int retrig, int g
|
||||
k = k * (NVOICE - 1) / (int32_t)(nv - 1u); /* fewer voices: the outer ones as wide */
|
||||
v->fine = nv > 1u ? k * t->p[P_DETUNE] * 56 / 889 : 0; /* up to ~±40 cents */
|
||||
if (retrig || !v->active || !v->gate) {
|
||||
int was_sounding = v->active && v->stage != 0;
|
||||
if ((!v->active || v->stage == 4u) && !voice_room(t, i > 0))
|
||||
continue; /* no room for this extra UNISON voice */
|
||||
/* level: about the same sum for 8 or 4 voices at random phases */
|
||||
voice_start(t, v, note, nv >= NVOICE ? vel * 36u / 100u : nv > 1u ? vel / 2u : vel, glide);
|
||||
if (nv > 1u && i && !eng_sampled(ENGINES[t->engine])) { /* random start phases: */
|
||||
if (nv > 1u && i && !eng_sampled(ENGINES[t->engine]) && !was_sounding) { /* random start phases: */
|
||||
static uint32_t seed = 0x1234567u; /* in phase they stack, evenly spread they cancel */
|
||||
seed = seed * 1664525u + 1013904223u;
|
||||
v->ph[0] += seed;
|
||||
|
||||
Reference in new issue
Block a user