From a831779eefbb3772e09dfe9a741ded016fe03412 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 10 Oct 2026 00:06:04 +0000 Subject: [PATCH] LOFI: one filter, the FILTER page's (TYPE CUT RES, per voice); EDIT 2's CUT left; beings' energy once a frame Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh --- README.md | 2 +- firmware/src/eng_lofi.c | 20 ++++++++++++++++---- firmware/src/ui_being.c | 10 ++++++++-- firmware/src/voice.c | 4 +++- tests/golden.txt | 18 +++++++++--------- tests/mod_test.c | 2 +- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a4e3b59b..a1d11652 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Ocho engines, todos de síntesis, sin samples: **ANALOG, FM6, PHASE, LOFI, VOICE - **VOICE** (formantes, según klattsch), **WHEEL** (órgano de drawbars) y **NOISE** (ruido coloreado y metálico). - **FILTER en todos los motores** (EDIT > FILTER): **TYPE** LP, HP, BP o **COMB** (un comb afinado a la nota que estás tocando; CUT lo mueve ±32 semitonos y RES es cuánto resuena), **CUT** y **RES**. En ANALOG es su filtro por voz, con - DRV; en los demás es un filtro sobre el track, que sigue al LFO y a la envolvente (LFO/ENV DEST FLT), y su DRV es el + DRV; en LOFI también es por voz (su CUT y RES son los de esta página); en los demás es un filtro sobre el track, que sigue al LFO y a la envolvente (LFO/ENV DEST FLT), y su DRV es el DIST del track. ### DRUM-X: batería sintetizada con morph diff --git a/firmware/src/eng_lofi.c b/firmware/src/eng_lofi.c index 70004990..0d8174f7 100644 --- a/firmware/src/eng_lofi.c +++ b/firmware/src/eng_lofi.c @@ -61,6 +61,8 @@ static const param_desc_t LOFI_VAR = {"VAR", F_PCT, 0, 127, 0, 0, 0}; * 2^5 steps: the formula's long evolution (0: free) folded into a short cycle repeating at the note: a pitched tone */ static const param_desc_t LOFI_RES = {"RES", F_PCT, 0, 127, 0, 0, 0}; /* = edit[5] (BYTE) */ static const param_desc_t LOFI_LOOP = {"LOOP", F_PCT, 0, 127, 0, 0, 0}; /* = edit[7] (BYTE) */ +/* (JIANT 0.5) E4 (CUT) left: the filter is the FILTER page's (TYPE, CUT, RES: P_FTYPE P_FCUT P_FRES), on every engine */ +static const param_desc_t LOFI_NONE = {"-", F_INT, 0, 0, 0, 0, 0}; static __attribute__((noinline)) uint32_t lofi_byte(uint32_t f, uint32_t t, uint32_t a) { switch (f & 31u) { @@ -127,6 +129,8 @@ static __attribute__((noinline)) void lofi_byte_render(track_t *t, voice_t *v, i const int16_t *p = t->p; uint32_t f = (uint32_t)p[P_E2] >> 2, a = 1u + ((uint32_t)p[P_E3] >> 3), tt = (uint32_t)v->s[2], tf = v->ph[0], i; uint32_t ti = (inc >> 8) * 31u; /* t a sample, Q24: C4 (inc ~2.55e7) ~0.18 = 8 kHz */ + uint32_t ft = (uint32_t)p[P_FTYPE] & 3u; /* (JIANT 0.5) the FILTER's type (COMB: open, voice.c combs) */ + int32_t kd = 8192 - (p[P_FRES] > 50 + p[P_E5] * 77 / 127 ? p[P_FRES] : 50 + p[P_E5] * 77 / 127) * 7600 / 127; uint32_t bs = p[P_E6] ? 13u - (uint32_t)p[P_E6] / 11u : 0u; /* BEND: the fold's shift, 13 .. 2 (0: none) */ int32_t held = v->s[0], cnt = v->s[1], ic1 = v->s[4], ic2 = v->s[5]; uint32_t lm = p[P_E7] ? (1u << (17u - (uint32_t)p[P_E7] * 12u / 127u)) - 1u : 0xFFFFFFFFu; /* LOOP: t's window */ @@ -142,7 +146,7 @@ static __attribute__((noinline)) void lofi_byte_render(track_t *t, voice_t *v, i tf += ti; tt += tf >> 24; tf &= 0xFFFFFFu; - out[i] += voice_amp(soft_knee(tsvf_lp(flt, held >> 1, &ic1, &ic2), 16000) << 1, m, i); + out[i] += voice_amp(soft_knee(svf_mode(flt, held >> 1, &ic1, &ic2, ft, kd), 16000) << 1, m, i); } v->s[0] = held; v->s[1] = cnt; @@ -156,6 +160,8 @@ static const param_desc_t *lofi_desc(const track_t *t, uint32_t k) { if (t->p[P_E1] == RW_BYTE && (k == 2u || k == 3u)) return k == 2u ? &LOFI_ALGO : &LOFI_VAR; + if (k == 4u) + return &LOFI_NONE; if (t->p[P_E1] == RW_BYTE && (k == 5u || k == 7u)) return k == 5u ? &LOFI_RES : &LOFI_LOOP; if (k == 2u && t->p[P_E1] == RW_WRAM) @@ -227,7 +233,8 @@ static void lofi_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const static const uint8_t STEP_DUTY[4] = {1, 2, 4, 6}; /* eighths: 12.5 / 25 / 50 / 75 % */ const int16_t *p = t->p; uint32_t chip = (uint32_t)p[P_E0], wave = (uint32_t)p[P_E1], i; - uint32_t stepc = chip == CHIP_STEP; + uint32_t stepc = chip == CHIP_STEP, ft = (uint32_t)p[P_FTYPE] & 3u; /* (JIANT 0.5) the FILTER's type */ + int32_t kd; uint32_t duty = stepc ? 0x20000000u * STEP_DUTY[(p[P_E2] / 32) & 3] : 0x20000000u * (1u + (uint32_t)p[P_E2] / 32u); /* 12.5 / 25 / 37.5 / 50 % */ int32_t crush = stepc ? 0 : p[P_E3]; /* STEP: CRSH is the envelope */ @@ -247,7 +254,12 @@ static void lofi_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const wdc = bits == 1 ? sum * 32767 / 32 : sum * 2 * Q4 / 32; /* (2 v - 15) Q4, or +-32767 at 1 bit */ } inc = pitch_inc(clamp(m->pitch16, 0, 2047)); /* (the vibrato below; the track's LFO in m->pitch16 already) */ - tsvf_coef(&flt, (p[P_E4] << 8) + m->cutoff, wave == RW_BYTE ? 50 + p[P_E5] * 77 / 127 : 50); /* CUT, a little + { /* (JIANT 0.5) its RES the FILTER page's (or BYTE's, the more) */ + int32_t rs = wave == RW_BYTE ? 50 + p[P_E5] * 77 / 127 : 50; + if (p[P_FRES] > rs) rs = p[P_FRES]; + tsvf_coef(&flt, (p[P_FCUT] << 8) + m->cutoff, rs); /* (JIANT 0.5: the FILTER page's CUT, was E4) */ + kd = 8192 - rs * 7600 / 127; + } /* CUT, a little * resonance (BYTE: RES up to the edge) */ if (p[P_E6]) lofi_bend_set(&bd, p[P_E6]); @@ -302,7 +314,7 @@ static void lofi_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const held = lofi_mask(s, msk); } ph += inc; - out[i] += voice_amp(soft_knee(tsvf_lp(&flt, held >> 1, &ic1, &ic2), 16000) << 1, m, i); + out[i] += voice_amp(soft_knee(svf_mode(&flt, held >> 1, &ic1, &ic2, ft, kd), 16000) << 1, m, i); } v->ph[0] = ph; v->s[0] = held; diff --git a/firmware/src/ui_being.c b/firmware/src/ui_being.c index 5f5ab628..2e330ce8 100644 --- a/firmware/src/ui_being.c +++ b/firmware/src/ui_being.c @@ -51,8 +51,12 @@ static int32_t bg_sin(uint32_t ang) { return sine_i(ang << 16); } /* Q15 */ static int32_t bg_energy(void) { static int32_t e; + static uint32_t fr = 0xFFFFFFFFu; uint32_t w = scope_w, i; int32_t pk = 0, v; + if (fr == ui.frame) /* (once a frame: a redraw in the same frame draws the same) */ + return e; + fr = ui.frame; for (i = 1; i <= 256u; i += 2u) { v = scope_buf[(w - i) & (SCOPE_N - 1u)]; if (v < 0) v = -v; @@ -215,9 +219,11 @@ static void graph_ecosys(void) uint8_t ids[4]; bfeat_t f; char num[2] = {(char)('1' + c), 0}; - t->peak = 0; if (v > 256) v = 256; - en[c] = v > en[c] ? v : en[c] + (v - en[c]) / 4; /* (a hit at once, a quick fall) */ + if (dt) { /* (once a frame: a redraw in the same frame draws the same) */ + t->peak = 0; + en[c] = v > en[c] ? v : en[c] + (v - en[c]) / 4; /* (a hit at once, a quick fall) */ + } if (en[c] > 2) tm[c] += dt * (uint32_t)(200 + en[c] * 5); else tm[c] += dt * 60u; /* (silent: it still breathes, slowly) */ for (v = 0; v < 4; v++) ids[v] = (uint8_t)ENGINES[e]->knob[v]; diff --git a/firmware/src/voice.c b/firmware/src/voice.c index e874cb30..988f84ac 100644 --- a/firmware/src/voice.c +++ b/firmware/src/voice.c @@ -665,7 +665,9 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n) } if (nr && e == &ENG_ANALOG && t->p[P_FTYPE] == FT_COMB) /* (JIANT 0.5) FILTER TYPE COMB */ track_comb(t, out, n, t->p[P_E4], t->p[P_E5]); - else if (nr && e != &ENG_ANALOG && (t->p[P_FTYPE] || t->p[P_FCUT] < 127 || t->p[P_FRES])) + else if (nr && e == &ENG_LOFI && t->p[P_FTYPE] == FT_COMB) /* (LOFI: its own filter, the FILTER page's CUT and RES) */ + track_comb(t, out, n, t->p[P_FCUT], t->p[P_FRES]); + else if (nr && e != &ENG_ANALOG && e != &ENG_LOFI && (t->p[P_FTYPE] || t->p[P_FCUT] < 127 || t->p[P_FRES])) track_filter(t, out, n); /* (JIANT 0.5) every other engine's FILTER */ if (fade) { for (i = 0; i < 8u; i++) diff --git a/tests/golden.txt b/tests/golden.txt index 9222a981..ee482c97 100644 --- a/tests/golden.txt +++ b/tests/golden.txt @@ -23,15 +23,15 @@ preset/PHASE/04_BELL 3ba75d0098df43c4 preset/PHASE/05_WIRE fc4668f86cf2cd68 preset/PHASE/06_GROWL 8497a70074f88c6c preset/PHASE/07_FB_BASS 9ac06e082b618f14 -preset/LOFI/00_BYTEBEAT 2c3e5bb9fc5a8104 -preset/LOFI/01_BYTE_VAR aff170cfafa97454 -preset/LOFI/02_BYTE_BENT fa4e2124ba42b560 +preset/LOFI/00_BYTEBEAT fb575acc2e74c358 +preset/LOFI/01_BYTE_VAR 310497d52fe74bf4 +preset/LOFI/02_BYTE_BENT 960147ff5ec0d5d0 preset/LOFI/03_PULSE_LD 2335c72b2e2db4b4 -preset/LOFI/04_WAVE_BASS af04e3e7b2d45ac4 -preset/LOFI/05_8BIT_KEYS 43021f1239198f88 -preset/LOFI/06_WAVE_LEAD 03a9935b4b36e5f8 +preset/LOFI/04_WAVE_BASS 3515cb3a94f0372c +preset/LOFI/05_8BIT_KEYS b6fd57621f0cd24c +preset/LOFI/06_WAVE_LEAD d2ce792fddcd19dc preset/LOFI/07_STEP_LEAD b567ef847a07b400 -preset/LOFI/08_BYTE_TONE 77fde8813a30f7d8 +preset/LOFI/08_BYTE_TONE 57e661f759429170 preset/VOICE/00_CHOIR_AAH ac0c59c065286178 preset/VOICE/01_VOX_LEAD cf797ebb5d070f38 preset/VOICE/02_WOW_BASS 9f9435d54838d3e0 @@ -69,6 +69,6 @@ sends/ANALOG/delay d14ef8ac0416854c sends/ANALOG/reverb 0a53925aa6e964d4 sends/ANALOG/all 708cbeb84d1fdba8 sends/ANALOG/dist d2ecfec43d6b9fbc -song/4track_mix 9e51cf11e463361c +song/4track_mix df9ea5839157d024 slicer/gate/ANALOG_ACID f47771572fe5c738 -slicer/song_gate_stut e291d7ebaa4096a4 +slicer/song_gate_stut 9aa799575026b440 diff --git a/tests/mod_test.c b/tests/mod_test.c index 2bf23fab..70db3963 100644 --- a/tests/mod_test.c +++ b/tests/mod_test.c @@ -795,7 +795,7 @@ static double lo_render(int16_t wave, int16_t cut, int16_t bend, int16_t mask, i double z = 0; fresh(3, 0); trk[0].p[P_E0] = 2; trk[0].p[P_E1] = wave; trk[0].p[P_E2] = 16; trk[0].p[P_E3] = 0; - trk[0].p[P_E4] = cut; trk[0].p[P_E5] = 0; trk[0].p[P_E6] = bend; trk[0].p[P_E7] = mask; + trk[0].p[P_FCUT] = cut; trk[0].p[P_E5] = 0; /* (JIANT 0.5: LOFI's CUT is the FILTER page's) */ trk[0].p[P_E6] = bend; trk[0].p[P_E7] = mask; trk[0].p[P_ATK] = 0; trk[0].p[P_SUS] = 127; trk_note_on(&trk[0], 57, 110); for (b = 0; b < n / CTL; b++) {