V10.8.45: the ARP on the transport's grid and recorded on its steps, GEN's sections half as long and each row its own colour, room freed (the owner)

(the owner: "the arp is not quantized, it should be on the 1/16 at least"; "in REC it has to be quantized")
- seq.c arp_step_do: playing (or counting in), a key's first arp step on its RATE's grid of the transport (the step this
  block holds, or one up to 20 ms back at once; armed: never late), then the sequencer's time (seq_n), so it stays there;
  stopped: from the key, as ever. It ran free from the key's block, on the DAC's samples
- rec_note_at: an arp's note recorded at its own step's sample (no key latency, whatever REC Q): on its step, MICRO 0
- tests/arp_grid_test.c (in the workflow): three tempos, four RATEs, 18 moments, every step on the grid; a recorded
  phrase every step its note, on its place, one a step

Room (the owner: "the CPU page out, the little purple bar a number, the velocity diagnostic too"): 720 B
- MENU > ABOUT: the CPU lines gone (clock, rails, crash); AUDIO LOAD stays
- the header's load: its per cent (0..99) in THEME where the five bars were, following the load once 3 away
- the velocity diagnostic out (captures, queue, console, vd_poll); the keys' velocity and pressure as they were; the
  editor's VEL answers as ever with the diagnostic off and nothing to read (web/vel.html: no presses, no captures);
  tests/vel_diag_test.c gone, vel_test / vel_seq_test stay

GEN (the owner: "a section lasts more than twice what it should, loops that do not evolve and come back the same;
every part its timbre, a story in the sound; the envelopes"; "the DJ FILTER's automations too long and abrupt";
"DANCE's decays too long, they cover the other layers"):
- a row half its bars and none over ~24 s (a slow tempo's shorter); RADIO's loop 16 / 8 / 4 bars (over 110 / over 74 /
  slower; were 32 / 16). MY LOOP's rows as they were
- a row its own colour: the scene's macros a row's own values (the first as the piece stands); a section come again
  (its fill row too): the lead's, the arp's and the free drums' lines ARRANGE's VAR 1 / 2 (rows that repeat a row
  before: 31 % -> 0)
- MOOD DANCE: the kit's DECAY a little shorter (was longer), the pump deeper (mood / 2)
- the build's high-pass: its last bar to 30 in eighths (was two bars to 48 in quarters)
- the envelopes: a held chord slower in (32) and longer out (80), a lead some release (32..63), the filter's envelope
  12 .. 27 on a bass, a lead, an arp (was 6 .. 13); towards CALM softer in and longer out
- tests: gen_entry_test (RADIO's 16 bars, MID's reference recorded again), ui_test (an arp with no transport's clock),
  tests/gen_sec.c (a study's tool: rows' seconds, repeats, envelopes)

Layout recorded again (FELUCCA_REPIN=keep: the arp's code in the RAM code); the plain build passes.
Image 583600 B of 584336 (736 B free), RAM 96832, RAM code 32688 of 34816, pool spare 8480 B, BT segment 73564 of
73728. audio.c as V23's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
Claude committed 2026-11-25 16:34:27 +00:00
1 parent bfca97c320
commit ceec4ab2cb
17 files changed
+2458 -2867

No files matched your search

+3 -3
View File
@@ -147,6 +147,8 @@ jobs:
build/song-check/drift | tee build/song-check/drift.log
cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/resync_test.c -lm -o build/song-check/resync
build/song-check/resync | tee build/song-check/resync.log
cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/arp_grid_test.c -lm -o build/song-check/arp-grid
build/song-check/arp-grid | tee build/song-check/arp-grid.log
cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/probability_component_test.c -lm -o build/song-check/probability
build/song-check/probability | tee build/song-check/probability.log
cc -O1 -g -w -Wno-implicit-function-declaration -fsanitize=address,bounds -Ibuild/gen -Ifirmware/src tests/ramp_test.c -lm -o build/song-check/ramp
@@ -250,11 +252,9 @@ jobs:
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 build/song-check/song-hold | tee build/song-check/song-hold.log
cc -O1 -g -w -Wno-implicit-function-declaration -fsanitize=address,bounds -Ibuild/gen -Ifirmware/src tests/prox_cal_test.c -lm -o build/song-check/prox-cal
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 build/song-check/prox-cal | tee build/song-check/prox-cal.log
- name: Velocity diagnostic, key velocity and pressure (V10.6z6) and the boot's packed RAM code (V10.6z5)
- name: Key velocity and pressure (V10.6z6) and the boot's packed RAM code (V10.6z5)
run: |
set -euo pipefail
cc -O1 -g -w -fsanitize=address,undefined -Ibuild/gen -Ifirmware/src tests/vel_diag_test.c -o build/song-check/vel-diag
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 build/song-check/vel-diag | tee build/song-check/vel-diag.log
cc -O1 -g -w -fsanitize=address,undefined -Ibuild/gen -Ifirmware/src tests/vel_test.c -o build/song-check/vel
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 build/song-check/vel | tee build/song-check/vel.log
cc -O1 -g -w -Wno-implicit-function-declaration -fsanitize=address,bounds -Ibuild/gen -Ifirmware/src tests/vel_seq_test.c -lm -o build/song-check/vel-seq
+1 -51
View File
@@ -380,61 +380,12 @@ static void con_params(void)
#endif
/* (V10.6z5) the velocity diagnostic (vel_diag.c): `vel on [DRIVE 0..4] | off`; while on and the console open, each
* press ("vel C4 D412 P188 2.2MS") and each capture ("vel C4 pre ..", "vel C4 post ..", d: a driven reading) */
static void con_vel_ev(const vd_ev_t *e)
{
char b[24];
vd_line(b, e);
con_puts("vel ");
con_puts(b);
con_puts("\r\n");
}
static void con_vel_cap(const vd_cap_t *c)
{
uint32_t i;
char b[4];
vd_key_name(b, c->key);
for (i = 0; i < VD_CAP; i++) {
if (i == 0u || i == VD_PRE) {
con_puts(i ? "\r\nvel " : "vel ");
con_puts(b);
con_puts(i ? " post" : " pre");
}
con_putc(' ');
if (c->v[i] & VD_DRIVEN)
con_putc('d');
con_dec(c->v[i] & 0x3FFu);
}
con_puts("\r\n");
}
static void con_vel_drain(void) /* (cdc_task) */
{
static vd_cap_t c;
vd_ev_t e;
uint32_t k;
if (!cdc.dtr)
return;
while ((k = vd_next(&c, &e)) != 0u) {
con.stalled = 0;
if (k == 2u)
con_vel_cap(&c);
else
con_vel_ev(&e);
}
}
static void con_vel(const char *p)
{
if (con_word(&p, "on")) {
while (*p == ' ')
p++;
vd_set(1, *p >= '0' && *p <= '4' ? (uint32_t)(*p - '0') : 2u);
} else if (con_word(&p, "off")) {
vd_set(0, 0);
}
(void)p;
con_puts(fm1_an.want ? "vel on, drive " : "vel off");
if (fm1_an.want)
con_dec(fm1_an.drive);
con_puts(" lost ");
con_dec(vd_lost);
con_puts(" adc_timeouts ");
con_dec(fm1_an.timeouts);
con_puts(" master ");
@@ -483,7 +434,6 @@ static void con_exec(const char *p)
static void cdc_task(void) /* main loop */
{
con_vel_drain(); /* (V10.6z5) the velocity diagnostic, when on */
if (cdc.dtr && !con.dtr_seen) {
con_puts("\r\nJIANT ");
con_puts(FELUCCA_VERSION);
+7 -18
View File
@@ -916,33 +916,22 @@ static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes between F0
break;
}
#ifdef VD_NK
case ED_VEL: {
static vd_cap_t c;
vd_ev_t e;
uint32_t k = 0;
case ED_VEL: { /* (V10.8.45, the owner: the diagnostic out) op 1 2 3 answer as
* ever with the diagnostic off and nothing to read (web/vel.html
* shows no presses); 0 4 5: the keys' velocity as it was */
if (!na || a[0] > 5u)
return;
if (a[0] == 1u || a[0] == 2u)
vd_set(a[0] == 1u, na > 1u ? a[1] : 2u);
if (a[0] == 5u)
vk_cal = 2; /* (1.2) the calibration's seeds back (vel.c vel_poll) */
ed_b(a[0]); ed_b(vs.diag); ed_b(fm1_an.drive);
ed_v(vd_lost); ed_v(fm1_an.timeouts); ed_v(fm1_an.master);
ed_b(a[0]); ed_b(0); ed_b(fm1_an.drive);
ed_v(0); ed_v(fm1_an.timeouts); ed_v(fm1_an.master);
if (a[0] >= 4u) { /* (1.2) the keys' velocity (in the Bluetooth segment: cold) */
if (bt_hw_seg())
ed_vel_live();
break;
}
if (a[0] != 3u)
break;
ed_b(k = vd_next(&c, &e));
if (k == 1u) {
ed_b(e.key); ed_v((int16_t)e.dt); ed_v((int16_t)e.pmin); ed_v((int16_t)e.dmin); /* (VD_NONE: -1) */
} else if (k == 2u) {
ed_b(c.key); ed_b(VD_CAP);
for (i = 0; i < VD_CAP; i++)
ed_v(c.v[i]);
}
if (a[0] == 3u)
ed_b(0);
break;
}
#endif
+1 -1
View File
@@ -49,7 +49,7 @@
#define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */
#endif
#ifndef FELUCCA_VERSION
#define FELUCCA_VERSION "V10.8.44" /* (2026-11-25) V10.8.44 (the owner): a GATE on the reverb and on the delay (FX > REVERB / DLY, OCT+ held + KNOB 4), a synth's LEVEL page (GAIN LEVEL PAN) after EDIT; V10.8.43 (BYTE's): RADIO: a STOP on the piece's last bar stops (chain.fin: the song's own END alone the next piece); GEN leaves SCL > HARMONY alone (on: the piece on the tonic chord); a lead's preset on a chord part without its fast vibrato. (2026-11-24) V10.8.42 (PR #241's ideas, in this generator): hard bass's DONK (PHASE's resonant saw), DREAM POP an organ's or a guitar's throw and its tape slower, an accented hit never thinned, IDM's roll in the phrase's turnaround; before: (2026-11-24) V10.8.41 (the owner: "the melodies and the drums sound generic", genre by genre): GEN: the riffs motifs of written rhythm and contour cells with an answer (BAILE FUNK, PHONK, DUBSTEP), JAZZ's comping written and its hats down, IDM GLITCH broken cells and placed rolls (no bursts), the basses under the drums and ducked (gen_stems' check), DUBSTEP low FOLD and chorus, CUMBIA, REGGAETON, HOUSE, HARD BASS, SHOEGAZE, DREAM POP as asked; TECHNO darker (phrygian, a line of 7 or 6 beats over the 4, its filter moving), EXPLORE its own: the minor modes, sevenths and ninths, borrowed chords, the drums edited, a cut, lines that evolve; MOOD: CALM lighter to -25, DANCE keeps a half-time's kick, EXPLORE's tempo; the FUGA genre gone (the owner); code no page reaches removed (no visible change). V10.8.40 (a user, the owner): the tempo exact and every DIV on one grid (a beat a multiple of 24 samples, the sequencer's time giving back what that cuts: fx.c beat_samples, seq.c tempo_acc; a 1/32 track was 12 ms a minute ahead of a 1/16 one at 133 BPM); a track's place from the transport's at every step (seq.c seq_anchor: after a LEN or DIV change, EUCLID, a variation, SWING, it is back with the others); SEQ held + PLAY: RESYNC at the next bar; GEN's MOOD on the drums in every GENRE mode (CALM: the kit down to a closed hat's tick, shorter, darker; DANCE: a kick on every beat, the kit up; MID as it was). V10.8.39 (the owner): GEN: every genre its traits (gen_tables.c GCHAR: hat rolls, ghosts and flams, ratchets, loops of other lengths, octave jumps, a hit's own cutoff or send, the bass's bursts, notes walking), IDM GLITCH far more extreme (two to five edits a bar, bursts x2 x4 x8, the bass and the lead up), AMBIENT and WEIRD deeper, the kick tuned to the key; GEN 4: RADIO (the next piece when one ends) and MOOD (CALM .. DANCE), its picture. V10.8.38 (the owner): SEQ > BAR, PHRASES and GLO > SYSTEM 2 gone (their rows kept: the index); GLO > MIXER, OCT+: KNOB 4 BPM <-> DJ FILTER; SEQ > NOTE back in the chain (after STEP), TRANS on SCL > CHORD's KNOB 4; GAIN on every engine (EDIT's first page, OCT+ held + KNOB 4); KEY TRK NOTE: the LP / HP resonance's peak on the note; SWARM: WAVE (a FLOAT formula's cycle, its level the sine's), wider DRIFT, MODE >T1 .. >T6 (its notes to a track's engine). V10.8.21: SEQ > CLAY (the owner): DRONE CLAY, JIANT BYTE's drone and its four modulators (DEST SHAPE EUCLID AMOUNT; DECAY, STEP, SEED) on any track, kept with the project ('C' 'Y'), its pages' picture the modulators' telemetry. V10.7.77: GEN (the owner): DUBSTEP's wobble its rate moving (the wobble bass's LFO RATE automated half a bar each: 1/4 1/8 1/8T 1/16); CUMBIA villera one throw in two (a villera 'teclado': 92 .. 100, minor, the keyboard's lead up front). V10.7.76: DRUM-X MATH a wavetable (the owner: "harsh"): its t whole cycles of the hit's time (one shape evolving), interpolated between its samples; SOUND 3 draws it (four moments, cold to hot); hints trimmed (flash). V10.7.75: DRUM-X MATH (the owner): its RATIO (1/4 .. 16, 24, the inharmonic between) on SOUND 3's KNOB 4, COLOR read MOD AMT; MATH's RESTART the scope (its ramps' picture gone), ten more hints out (flash). V10.7.74: DRUM-X MATH (the owner): a sound's WAVE past BELL a MATH formula F01..F48 as its FM's modulator (COLOR its index; its t the hit's time, a sample in eight), kept with the project ('D' 'F'). V10.7.73: SCL > HARMONY its own tab (KEY CHORD HARMONY SCENE); the defaults once (the owner): LARGE off, CLICK REC, COUNT-IN 1 BAR. V10.7.72: GEN (the owner): MATH WEST STRING more (the archetypes' third options theirs, 25 %; a bass's one time in ten); GLO > GLOBAL the scope, its bars gone. V10.7.71: SCL > HARMONY's picture (the owner): the progression's chords as roman numerals in the key ("-" minor, "o" diminished), each its root's colour, the one playing lit; the obvious knobs' hints out (flash). V10.7.70: FX > PUNCH IN: KNOB 4 M4 (its ERASE PUNCH LANE's only), so OCT+ always the punch-in editor (an ERASE picked took it). V10.7.69: MATH FLOAT MORPH (the owner): ALGO B where CHIP was, MORPH A -> B where BEND was (between the ends B a sample in eight, interpolated: +12.5 % CPU); MATH's formulas (lofi_float, lofi_byte) their 14 divisions by a constant as multiplies (JIANT BYTE 0.16's build pass, Line truncated
#define FELUCCA_VERSION "V10.8.45" /* (2026-11-25) V10.8.45 (the owner): the ARP on its RATE's grid of the transport while it plays, recorded on its steps; MENU > ABOUT's CPU lines and the velocity diagnostic out, the header's load a number; GEN: sections half as long, a row its own colour (the macros) and a section come again varied, DANCE's kit not longer, the build's filter sweep a bar, the envelopes. (2026-11-25) V10.8.44 (the owner): a GATE on the reverb and on the delay (FX > REVERB / DLY, OCT+ held + KNOB 4), a synth's LEVEL page (GAIN LEVEL PAN) after EDIT; V10.8.43 (BYTE's): RADIO: a STOP on the piece's last bar stops (chain.fin: the song's own END alone the next piece); GEN leaves SCL > HARMONY alone (on: the piece on the tonic chord); a lead's preset on a chord part without its fast vibrato. (2026-11-24) V10.8.42 (PR #241's ideas, in this generator): hard bass's DONK (PHASE's resonant saw), DREAM POP an organ's or a guitar's throw and its tape slower, an accented hit never thinned, IDM's roll in the phrase's turnaround; before: (2026-11-24) V10.8.41 (the owner: "the melodies and the drums sound generic", genre by genre): GEN: the riffs motifs of written rhythm and contour cells with an answer (BAILE FUNK, PHONK, DUBSTEP), JAZZ's comping written and its hats down, IDM GLITCH broken cells and placed rolls (no bursts), the basses under the drums and ducked (gen_stems' check), DUBSTEP low FOLD and chorus, CUMBIA, REGGAETON, HOUSE, HARD BASS, SHOEGAZE, DREAM POP as asked; TECHNO darker (phrygian, a line of 7 or 6 beats over the 4, its filter moving), EXPLORE its own: the minor modes, sevenths and ninths, borrowed chords, the drums edited, a cut, lines that evolve; MOOD: CALM lighter to -25, DANCE keeps a half-time's kick, EXPLORE's tempo; the FUGA genre gone (the owner); code no page reaches removed (no visible change). V10.8.40 (a user, the owner): the tempo exact and every DIV on one grid (a beat a multiple of 24 samples, the sequencer's time giving back what that cuts: fx.c beat_samples, seq.c tempo_acc; a 1/32 track was 12 ms a minute ahead of a 1/16 one at 133 BPM); a track's place from the transport's at every step (seq.c seq_anchor: after a LEN or DIV change, EUCLID, a variation, SWING, it is back with the others); SEQ held + PLAY: RESYNC at the next bar; GEN's MOOD on the drums in every GENRE mode (CALM: the kit down to a closed hat's tick, shorter, darker; DANCE: a kick on every beat, the kit up; MID as it was). V10.8.39 (the owner): GEN: every genre its traits (gen_tables.c GCHAR: hat rolls, ghosts and flams, ratchets, loops of other lengths, octave jumps, a hit's own cutoff or send, the bass's bursts, notes walking), IDM GLITCH far more extreme (two to five edits a bar, bursts x2 x4 x8, the bass and the lead up), AMBIENT and WEIRD deeper, the kick tuned to the key; GEN 4: RADIO (the next piece when one ends) and MOOD (CALM .. DANCE), its picture. V10.8.38 (the owner): SEQ > BAR, PHRASES and GLO > SYSTEM 2 gone (their rows kept: the index); GLO > MIXER, OCT+: KNOB 4 BPM <-> DJ FILTER; SEQ > NOTE back in the chain (after STEP), TRANS on SCL > CHORD's KNOB 4; GAIN on every engine (EDIT's first page, OCT+ held + KNOB 4); KEY TRK NOTE: the LP / HP resonance's peak on the note; SWARM: WAVE (a FLOAT formula's cycle, its level the sine's), wider DRIFT, MODE >T1 .. >T6 (its notes to a track's engine). V10.8.21: SEQ > CLAY (the owner): DRONE CLAY, JIANT BYTE's drone and its four modulators (DEST SHAPE EUCLID AMOUNT; DECAY, STEP, SEED) on any track, kept with the project ('C' 'Y'), its pages' picture the modulators' telemetry. V10.7.77: GEN (the owner): DUBSTEP's wobble its rate moving (the wobble bass's LFO RATE automated half a bar each: 1/4 1/8 1/8T 1/16); CUMBIA villera one throw in two (a villera 'teclado': 92 .. 100, minor, the keyboard's lead up front). V10.7.76: DRUM-X MATH a wavetable (the owner: "harsh"): its t whole cycles of the hit's time (one shape evolving), interpolated between its samples; SOUND 3 draws it (four moments, cold to hot); hints trimmed (flash). V10.7.75: DRUM-X MATH (the owner): its RATIO (1/4 .. 16, 24, the inharmonic between) on SOUND 3's KNOB 4, COLOR read MOD AMT; MATH's RESTART the scope (its ramps' picture gone), ten more hints out (flash). V10.7.74: DRUM-X MATH (the owner): a sound's WAVE past BELL a MATH formula F01..F48 as its FM's modulator (COLOR its index; its t the hit's time, a sample in eight), kept with the project ('D' 'F'). V10.7.73: SCL > HARMONY its own tab (KEY CHORD HARMONY SCENE); the defaults once (the owner): LARGE off, CLICK REC, COUNT-IN 1 BAR. V10.7.72: GEN (the owner): MATH WEST STRING more (the archetypes' third options theirs, 25 %; a bass's one time in ten); GLO > GLOBAL the scope, its bars gone. V10.7.71: SCL > HARMONY's picture (the owner): the progression's chords as roman numerals in the key ("-" minor, "o" diminished), each its root's colour, the one playing lit; the obvious knobs' hints out (flash). V10.7.70: FX > PUNCH IN: KNOB 4 M4Line truncated
#endif
#if FELUCCA_OTA && !FELUCCA_FLASH
#error "FELUCCA_OTA needs FELUCCA_FLASH"
+32 -7
View File
@@ -1733,6 +1733,9 @@ static __attribute__((noinline)) void gen_sound(track_t *t, uint32_t role, uint3
GSTAB(gs.g->pads) ? 2 : (0x103u >> gs.g->pads) & 1u ? 3 : 5]; /* (held: HOLD SWELL DRONE) */
for (i = 0; i < 4u; i++)
t->p[P_ATK + i] = (int16_t)clamp(t->p[P_ATK + i], (er[i] >> 4) * 8, (er[i] & 15u) * 8 + 7);
if (grd.mood < 0 && role != RL_BASS) { /* (V10.8.45) towards CALM: softer in, longer out */
t->p[P_ATK] -= grd.mood / 2; t->p[P_REL] = (int16_t)clamp(t->p[P_REL] - grd.mood / 2, 0, 120);
}
}
if (e == EG_FM) t->p[P_E2] = (int16_t)clamp(t->p[P_E2] - grr(4, 20), -64, 63); /* (warmer) */
if (ft != 7u) {
@@ -1745,7 +1748,7 @@ static __attribute__((noinline)) void gen_sound(track_t *t, uint32_t role, uint3
else { t->p[P_FCUT] = (int16_t)clamp(cut, 0, 127); t->p[P_FRES] = (int16_t)res; }
t->p[P_ED_FLT] = grg(r->envf, 4);
if (role != RL_PAD && role != RL_TEX && t->p[P_ED_FLT] < 6) /* (gen3: the filter's envelope on a bass, a lead, an arp) */
t->p[P_ED_FLT] = (int16_t)(6 + (gs.complex >> 4));
t->p[P_ED_FLT] = (int16_t)(12 + (gs.complex >> 3)); /* (V10.8.45: more of it, was 6 .. 12) */
}
if (r->lfo) { /* the LFO on the filter: a slow drift, or on the beat */
uint32_t lr = r->lfo & 15u;
@@ -1931,7 +1934,8 @@ static __attribute__((noinline)) void gen_kit(track_t *t)
* snare, the clap and the hats up, longer, driven (0: untouched) */
int32_t m = grd.mood, l, c = m / 2 + (m < -25 ? (m + 25) * 5 : 0), e = c < -50 ? -50 : c; /* (V10.8.41: to -25 a light
* hand, ~6 dB and a little shorter and darker; the kit gone only near -50) */
t->p[P_E3] = (int16_t)clamp(t->p[P_E3] + (m < 0 ? e : m / 4), 0, 127);
t->p[P_E3] = (int16_t)clamp(t->p[P_E3] + (m < 0 ? e : -m / 5), 0, 127); /* (V10.8.45, the owner: "DANCE's decays too long,
* they cover the other layers": a little shorter, was longer) */
if (m < 0) {
t->p[P_FCUT] = (int16_t)(t->p[P_FCUT] + e);
for (l = 0; l < 8; l++)
@@ -2199,6 +2203,23 @@ static uint32_t grow(uint32_t r, uint32_t s, uint32_t bars, uint32_t m, uint32_t
sc->on = (uint8_t)(1u | ((m >> 3) & 6u));
sc->mute = (uint8_t)((m & 15u) | gm << 4);
memcpy(sc->mac, macro_v, sizeof sc->mac);
if (!gls.on) { /* (V10.8.45, the owner: "loops that do not evolve and come back the
* same; every part its timbre, a story in the sound") a row its own
* colour: the macros (their routes every track's: the filter, the
* shape, the engine's, the sends) a row's own values, the first as
* the piece stands, M1 opening as the song goes; a section come
* again (its fill row too): the lead's and the arp's lines varied
* (ARRANGE's VAR 1 / 2, a row's own), the drums' where they are free */
static uint8_t seen[4];
uint32_t i, n;
if (!r) memset(seen, 0, sizeof seen);
n = seen[s & 3u]++;
for (i = 0; i < 4u && r; i++) sc->mac[i] = (uint8_t)((r * (29u + 18u * i) + (i ? 0u : r * 4u)) % 72u);
for (i = RL_DRUM; n && i <= RL_ARP; i += i ? 1u : RL_LEAD) { /* (the drums, the lead, the arp) */
uint32_t k = gs.trk_of[i];
if (k < NTRK && !((var >> (4u * k)) & 15u)) var |= (uint32_t)(RV_MUT1 + ((n - 1u) & 1u)) << (4u * k);
}
}
song_idx.tsrc[song_cur][r] = src;
song_idx.tvar[song_cur][r] = var;
return r + 1u;
@@ -2278,8 +2299,10 @@ static void gen_parts(void)
}
}
load_end(t);
if (plan && k == 2u) /* .. the master's high-pass opening over its last two bars */
for (i = 0; i < 8u; i++) gmot(t, 32u + 4u * i, MOT_DJF, (int32_t)((i + 1u) * (i + 1u) * 3u / 4u), 0);
if (plan && k == 2u) /* .. the master's high-pass opening over its last bar (V10.8.45, the
* owner: "the DJ FILTER's automations too long and abrupt": was
* two bars to 48 in quarter steps; a bar to 30 in eighths) */
for (i = 0; i < 8u; i++) gmot(t, 48u + 2u * i, MOT_DJF, (int32_t)((i + 1u) * (i + 1u) * 15u / 32u), 0);
}
/* (0.8.3) the section's harmony: the break and the apex on the predominant (not the modal loops: theirs keep
* the loop); PARTS' last section a whole step up where the genre lifts (pop's last chorus) */
@@ -2391,7 +2414,8 @@ static void gen_parts(void)
np = PLAN_OF[np + 1u] - PLAN_OF[np];
gseed(GS_FORM);
for (j = 0; j < np; j++) {
uint32_t t = pl[j] & 15u, nt = pl[(j + 1u) % np] & 15u, bars = (pl[j] >> 4) * 4u >> half, s, m = 0, gm = 0, fill, f;
uint32_t t = pl[j] & 15u, nt = pl[(j + 1u) % np] & 15u, bars = (pl[j] >> 4) * 4u >> (half + !gls.on), s, m = 0, gm = 0, fill, f; /* (V10.8.45, the owner: "a section lasts more than
* twice what it should": half; MY LOOP's as they were) */
if (bars < 4u) bars = 4u;
if (t >= GT_SEC) { s = t - GT_SEC; m = secm[s]; }
else { /* the kind's layers: the drums, the bass, then by priority */
@@ -2411,6 +2435,7 @@ static void gen_parts(void)
if (t == GT_DROP && gch(50)) bars *= 2u; /* (a drop of 16 or 32) */
if (gls.on && t == GT_DROP) m &= gls.add; /* (FROM LOOP: the drop the loop as it is, its own parts all in) */
}
while (!gls.on && bars > 4u && bars * 10u > (uint32_t)song.g[G_BPM]) bars /= 2u; /* (.. and none over ~24 s: a slow tempo's shorter) */
m |= gls.mute;
fill = dr < NTRK && gs.act[RL_DRUM] && nt != t && !gm && !((m >> dr) & 1u) && (((base | dense) >> s) & 1u);
if (t == GT_DROP && plan && !gls.on && dr < NTRK && gs.act[RL_DRUM] && bars > lb) { rows = grow(rows, 1, lb, m, gm, 0, 0); bars -= lb; } /* (the
@@ -3307,7 +3332,7 @@ static __attribute__((noinline)) void gen_make(void)
* CHORUS MIX towards the vibrato: SHOEGAZE's wobble, a little on DUBSTEP) */
song.g[G_DUCK] = (int16_t)(gs.act[RL_DRUM] ? (g->spec & GSP_PUMP ? grr(60, 80) : g->kick_mode == KM_SUSTAIN || gclub() ? grr(30, 50) : g->human < 40u ? grr(32, 46) : grr(14, 30)) : 0); /* (V10.8.41, the owner: "the bass should have sidechain": a machine genre's 3.5 .. 6 dB) */ /* (V10.6n:
* hard bass pumped) */
if (grd.mood > 0 && gs.act[RL_DRUM]) song.g[G_DUCK] += grd.mood / 3; /* (V10.8.41) DANCE: the kick's pump deeper */
if (grd.mood > 0 && gs.act[RL_DRUM]) song.g[G_DUCK] += grd.mood / 2; /* (V10.8.41) DANCE: the kick's pump deeper */
if (g->snd[GP_BASS] == SR_WOW && gs.act[RL_BASS] && gs.trk_of[RL_BASS] < NTRK) gwobble(&trk[gs.trk_of[RL_BASS]]);
song.g[G_DREL] = (int16_t)(g->drum == DM_TECHNO || g->drum == DM_HARD || g->drum == DM_HBASS ? grr(15, 30) : grr(25, 45));
song.g[G_CLIP] = (int16_t)(gs.act[RL_DRUM] ? (g->spec & GSP_HEAVY ? grr(60, 85) : grr(35, 65)) : grr(10, 30)); /* (gen3: a
@@ -3460,7 +3485,7 @@ static __attribute__((noinline)) void gen_tick(void) /* (every UI frame) */
* (V10.8.43, BYTE's) a STOP in that bar stops: only the bar played to its end, or the song to its own END
* (chain.fin), brings the next piece (it was asked for when the bar began, and a STOP made it and played it) */
{
uint32_t a = grd.arm, lb = song.g[G_BPM] > 110 ? 31u : 15u;
uint32_t a = grd.arm, lb = song.g[G_BPM] > 110 ? 15u : song.g[G_BPM] > 74 ? 7u : 3u; /* (V10.8.45: half) */
grd.arm = 0;
if (grd.on && song_draft && !gen_wait && gp.form < 3u) { /* (a draft: GEN's own piece, never a saved song) */
if (song.playing && (chain.running ? chain.row + 1u >= chain.config.count && chain.remaining <= 1u : (bar_n & lb) == lb))
+2 -2
View File
@@ -610,10 +610,10 @@ static const uint16_t RTRIM[SR_N] = {
* an EP's, a pluck's lead, its archetype's sustain under 56, a pluck's), an ARP's a pluck's (a fast attack, a short-medium decay, a low sustain), the CHORDS stabbed short (STAB PULSE DUB SKANK COMP
* BROKEN TRANCE: GSTAB) or held slow in and out (HOLD SWELL DRONE), a BASS fast in; the rest as the archetype has it */
static const uint8_t ENV_RULE[6][4] = {
{GR(0, 23), GR(48, 95), GR(56, 95), GR(16, 47)}, /* lead */
{GR(0, 23), GR(48, 95), GR(56, 95), GR(32, 63)}, /* lead (V10.8.45, the owner: "the envelopes": some release, was 16..47) */
{GR(0, 7), GR(32, 79), GR(0, 39), GR(16, 63)}, /* arp: a pluck */
{GR(0, 7), GR(32, 71), GR(0, 47), GR(16, 47)}, /* chords stabbed */
{GR(16, 127), GR(48, 127), GR(56, 127), GR(64, 127)}, /* chords held */
{GR(32, 127), GR(48, 127), GR(56, 127), GR(80, 127)}, /* chords held (V10.8.45: slower in 16 -> 32, longer out 64 -> 80) */
{GR(0, 15), GR(24, 127), GR(0, 127), GR(8, 63)}, /* bass */
{GR(0, 127), GR(0, 127), GR(0, 127), GR(0, 127)}, /* the others */
};
-1
View File
@@ -420,7 +420,6 @@ static void fm1_main(void)
}
master_poll();
#ifdef VD_NK
vd_poll(); /* (V10.6z5) the velocity diagnostic's last press, when on */
vel_poll(); /* (V10.6z6) key velocity and pressure: the settings, the sampling */
#endif
#if FELUCCA_DUAL_CORE
+23 -8
View File
@@ -577,6 +577,7 @@ static void arp_remove(track_t *t, uint32_t note)
}
static void rec_note(track_t *t, uint32_t note, uint32_t vel);
static uint32_t rec_arp; /* (V10.8.45) an arp's note recorded: its samples past its step + 1 */
static void rec_release(track_t *t, uint32_t note);
/* (V10.25) SCENE (SCL > SCENE, ui_scene.c): the keys play every track given a role at once, from the one key: CHORD the
* key's chord of the scale (its CHORD type, TRI if off), ARP that chord into the track's arp, BASS the key an octave
@@ -806,9 +807,21 @@ static void arp_step_do(track_t *t, uint32_t n)
uint32_t per = period + (uint32_t)((t->arp_idx & 1u) ? sw : -sw);
if (t->arp_pos < per && t->arp_pos != 0xFFFFFFF + n)
return;
if (t->arp_pos == 0xFFFFFFF + n) { /* the start: now */
t->arp_pos = 0;
if (t->arp_pos == 0xFFFFFFF + n) { /* the start: now; (V10.8.45, the owner: "the arp is not
* quantized") playing: on its RATE's grid of the transport, the
* step this block holds or one up to 20 ms back at once, else
* the next one */
uint32_t ph = 0;
if ((song.playing && clk_pos != CLK_START) || cin_left) { /* (the count-in: its beats' grid) */
ph = (song.playing ? clk_n * div_samples(2) + clk_pos : cin_pos) % period;
if (ph >= n + (song.rec ? 0u : FS / 50u)) { /* (armed: never late, what is recorded on its step) */
t->arp_pos = ph + (uint32_t)sw;
return;
}
}
t->arp_pos = ph;
ev_off = 0;
if (ph < n) ev_at(n - ph);
} else { /* (ctl64) the step at its sample; the samples past it kept
* (they were dropped: an ARP ran a block late a step) */
t->arp_pos -= per;
@@ -836,11 +849,12 @@ static void arp_step_do(track_t *t, uint32_t n)
j = t->p[P_AMODE] == AM_CHORD ? 0u : arp_pick(t, list, len);
if (t->arp_note)
arp_off(t);
rec_arp = t->arp_pos + 1u; /* (V10.8.45) recorded where its step is, not where a key was heard */
if ((uint32_t)(rng() & 127u) <= (uint32_t)t->p[P_APROB]) {
t->arp_off = period * (uint32_t)t->p[P_AGATE] / 128u + ev_off; /* (from the step's sample) */
if (t->p[P_AMODE] == AM_CHORD) { /* CHORD: the first 4 notes, an octave up each step */
arp_chord(t, list, cnt);
ev_off = 0;
ev_off = rec_arp = 0;
return;
}
uint32_t av = ARP_VEL(t); /* (V10.6z6: its keys' velocity) */
@@ -849,7 +863,7 @@ static void arp_step_do(track_t *t, uint32_t n)
rec_note(t, t->arp_note, av); /* recording: what the arp plays */
seq_note_on(t, t->arp_note, tvel(t, av));
}
ev_off = 0;
ev_off = rec_arp = 0;
}
static void arp_tick(track_t *t, uint32_t n) { arp_step(t, n, n); }
@@ -994,7 +1008,8 @@ static void rec_note_at(track_t *t, uint32_t note, uint32_t vel)
uint32_t len = t->p[P_SLEN] > 0 ? (uint32_t)t->p[P_SLEN] : 1u, idx = t->seq_idx % len, k;
uint32_t period = div_samples((uint32_t)t->p[P_SDIV]), sl = step_samples(t, period, t->seq_idx);
int32_t gp = (int32_t)t->seq_pos - (int32_t)t->ext /* (0.6.88: from the step's place; an early one began before) */
- REC_LAT; /* (p8, the owner: live notes landed late) what was heard: the
- (rec_arp ? (int32_t)rec_arp - 1 : REC_LAT); /* (V10.8.45, the owner: "recording, the arp quantized": its
* note at its own step's sample, whatever REC Q) */ /* (p8, the owner: live notes landed late) what was heard: the
* sequencer a half buffer and a block ahead of the DAC, the key
* up to a half more: the press placed where its sound was heard */
uint32_t next = gp > (int32_t)(sl / 2u); /* (V10.6z4: the block PLAY starts in, before its first step,
@@ -1004,9 +1019,9 @@ static void rec_note_at(track_t *t, uint32_t note, uint32_t vel)
if (next)
idx = (idx + 1u) % len;
s = &t->step[seq_src(t, idx)];
if (t->seq_pos < 0x7FFFFFFFu && t->p[P_HRQ] < 127) { /* (0.6.88) REC Q under 100 %: where it was played, kept */
if (t->seq_pos < 0x7FFFFFFFu && (t->p[P_HRQ] < 127 || rec_arp)) { /* (0.6.88) REC Q under 100 %: where it was played, kept */
int32_t off = next ? gp - (int32_t)sl : gp, l = (int32_t)(next ? step_samples(t, period, idx) : sl);
int32_t q = 127 - clamp(t->p[P_HRQ], 0, 127);
int32_t q = rec_arp ? 127 : 127 - clamp(t->p[P_HRQ], 0, 127);
mic = (off * 64 + (off < 0 ? -l / 2 : l / 2)) / (l ? l : 1); /* (0.9.1: 64ths of the step, rounded; was 16ths) */
mic = clamp((mic * q + (mic < 0 ? -63 : 63)) / 127, MICRO_MIN, MICRO_MAX); /* (REC Q's share of it, rounded) */
}
@@ -3761,7 +3776,7 @@ static void events_block(uint32_t n)
if (song.playing)
click_tick(seq_n);
for (i = 0; i < NPART; i++)
arp_step(&trk[i], clock_mode ? seq_n : n, clock_mode && song.playing ? seq_n : n);
arp_step(&trk[i], clock_mode || song.playing ? seq_n : n, clock_mode && song.playing ? seq_n : n); /* (V10.8.45: playing, the sequencer's time: its grid kept) */
beat_pos += clock_mode ? seq_n : n; /* the beat the ARP LED flashes on (ui_leds) */
if (beat_pos >= beat_samples()) {
beat_pos -= beat_samples();
+12 -8
View File
@@ -52,19 +52,23 @@ static uint32_t batt_icon(int32_t lvl)
static const uint8_t I[5] = {ICON_X_BAT0, ICON_X_BAT1, ICON_X_BAT3, ICON_X_BAT4, ICON_X_BAT_CHG};
return I[clamp(lvl, 0, 4)];
}
/* (JIANT 0.5) the load: how much of the audio's time the sound takes now (audio.c song.cpu_q8, averaged); 0..5.
* (0.8.5, the mock-up) five bars 3 x 7 side by side left of the battery, lit THEME from the left, the rest RAISE */
/* (JIANT 0.5) the load: how much of the audio's time the sound takes now (audio.c song.cpu_q8, averaged).
* (V10.8.45, the owner: "the little purple bar a small number, clearer") its per cent, 0 .. 99, in THEME left of the
* battery; the number shown follows the load once it is 3 away (no flicker) */
static uint32_t head_load(void)
{
uint32_t l = (song.cpu_q8 * 5u + 128u) >> 8;
return song.cpu_q8 && !l ? 1u : l > 5u ? 5u : l;
static uint8_t shown;
uint32_t p = (song.cpu_q8 * 100u) >> 8;
if (p > 99u) p = 99u;
if (p > shown + 2u || p + 2u < shown || !p) shown = (uint8_t)p;
return shown;
}
#define HEAD_LOAD_X 200 /* the load's bars: 200 .. 218 */
#define HEAD_LOAD_X 200 /* the load's number: 200 .. 218 */
static void draw_load(int32_t x)
{
uint32_t k, n = head_load();
for (k = 0; k < 5u; k++)
cv_rect(x + (int32_t)k * 4, HEAD_MID - 3, 3, 7, k < n ? T_THEME : T_RAISE);
char b[12];
fmt_int(b, (int32_t)head_load());
cv_text_r(x + 19, HEAD_MID - AF_X_CAP_H / 2 - AF_X_CAP_Y, &AF_X, b, T_THEME, T_BG);
}
static void draw_battery(int32_t bx)
{
-48
View File
@@ -149,53 +149,6 @@ static int32_t menu_lines(const uint8_t *packed, int32_t y, int draw)
return y;
}
/* MENU > ABOUT: the clock and the rails, the crash since power-on; (p1, main 0.9.12) the last crash kept in the settings
* (cpu_safe.c) */
static __attribute__((noinline)) int32_t about_cpu(int32_t y, int draw)
{
char b[40], n[12];
(void)n;
#if defined(FM1_IRQ_TARGET)
{ /* (0.9.9-stab) the clock (MENU > SYSTEM > CPU CLOCK, hal/fm1_sys.h fm1_clk_320) and the core supplies' steps
* as reached, and as the boot loader left them (fm1_rails_boot: V15's 7 / 15 wanted; the boot loader's 3 / 11) */
static const char RL[4][3] = {"S ", "/", " (", "/"};
uint32_t i;
str_cpy(b, fm1_clk_320() ? "CPU 320 MHZ RAIL" : "CPU 360 MHZ RAIL", sizeof b);
for (i = 0; i < 4u; i++) {
str_cpy(b + str_len(b), RL[i], 4);
fmt_int(n, fm1_rails[(i + 2u) & 3u]);
str_cpy(b + str_len(b), n, 4);
}
str_cpy(b + str_len(b), fm1_power_ready ? ") DC" : ")", 5); /* (V10.11) DC: the stock supply setup took */
y = menu_text(b, y, T_TEXT, draw);
if (fm1_crash.magic == FM1_CRASH_MAGIC && fm1_crash.count) { /* (0.9.9-stab) the last crash since power-on
* (.noinit, hal/fm1_irq.h): what its red screen showed, in hex */
static const char *const CL[6] = {"CRASH ", " VEC ", "PC ", " SP ", "C2 ", " BUS "};
const uint32_t cv[6] = {fm1_crash.count, fm1_crash.vec, fm1_crash.pc, fm1_crash.sp, fm1_crash.other_pc,
fm1_crash.bus[5] | fm1_crash.bus[3]};
for (i = 0; i < 6u; i++) {
uint32_t k, v = cv[i];
if (!(i & 1u))
b[0] = 0;
str_cpy(b + str_len(b), CL[i], 7);
if (i == 0) {
fmt_int(n, (int32_t)v);
str_cpy(b + str_len(b), n, 8);
} else {
for (k = str_len(b) + 8u; k > str_len(b); k--, v >>= 4)
b[k - 1u] = "0123456789ABCDEF"[v & 15u];
b[k + 8u] = 0;
}
if (i & 1u)
y = menu_text(b, y, T_TEXT, draw);
}
}
}
#endif
y = menu_text("LAST CRASH", y + 4, T_THEME, draw); /* (p1, main 0.9.12) kept across power-off (cpu_safe.c) */
y = menu_text(crash_log_get(b) ? b : "NONE", y, T_TEXT, draw);
return y;
}
/* (0.6.17) the audio's load since power-on (voice.c load_diag): to tell what happened when it clicked. (V10.13) In the
* segment (bt.c BTAPP_FN): without it ABOUT goes on with the CPU lines */
BTAPP_FN static int32_t about_load(int32_t y, int draw)
@@ -256,7 +209,6 @@ static int32_t menu_document(int32_t y, int draw)
y = menu_lines(ABOUT_PROJECT_PACK, y + 216, draw);
if (bt_hw_seg()) /* (V10.13: in the segment) */
y = about_load(y, draw);
y = about_cpu(y, draw); /* (p1: out of line, menu_document's room is pinned) */
y = menu_lines(ABOUT_CREDITS_PACK, y + 8, draw);
return y + 4;
}
+2 -147
View File
@@ -51,21 +51,8 @@ typedef struct {
uint8_t st, pi, dnext, up; /* state, ring index, drive the next sample, pulled-up samples let go */
uint32_t t_touch;
} vd_key_t;
typedef struct {
uint8_t key, n;
uint16_t v[VD_CAP];
} vd_cap_t;
typedef struct {
uint8_t key;
uint16_t dt, pmin, dmin;
} vd_ev_t;
static vd_key_t vd_key[VD_NK];
static vd_cap_t vd_cap[2] __attribute__((section(".lowbuf"))); /* (app.ld LOWBUF) one written, the other done */
static volatile uint8_t vd_cw, vd_cbusy, vd_cready; /* the one written; its key + 1 (0: none); the other done */
static vd_ev_t vd_ev[VD_NEV], vd_last; /* the presses not read yet; the last one (the message line) */
static volatile uint8_t vd_ev_w, vd_ev_r, vd_last_n;
static volatile uint16_t vd_lost; /* presses and captures nobody read in time */
static void vel_driven(uint32_t key, const vd_key_t *k, uint32_t v); /* (vel.c) */
static void vel_lift(uint32_t key, uint32_t strike);
@@ -75,23 +62,6 @@ static uint32_t vd_note(uint32_t col, uint32_t rowbit) /* the note on (column,
return id >= 14 && (uint32_t)id - 14u < VD_NK ? (uint32_t)id - 14u : VD_NK;
}
static void vd_cap_add(uint32_t key, uint32_t v)
{
vd_cap_t *c = &vd_cap[vd_cw];
if (vd_cbusy != key + 1u)
return;
c->v[c->n++] = (uint16_t)v;
if (c->n < VD_CAP)
return;
vd_cbusy = 0;
if (vd_cready)
vd_lost++; /* (the last one still unread: this one dropped) */
else {
vd_cw ^= 1u;
vd_cready = 1;
}
}
/* (the scan's ISR) one sample of the key at (col, rowbit): v 0..1023; driven: taken with the row driven high */
static void vd_sample(uint32_t col, uint32_t rowbit, uint32_t v, uint32_t driven)
{
@@ -107,7 +77,6 @@ static void vd_sample(uint32_t col, uint32_t rowbit, uint32_t v, uint32_t driven
k->dmin = (uint16_t)v;
vel_driven(key, k, v); /* (V10.6z6) the strike's window, the pressure (vel.c) */
}
vd_cap_add(key, v | VD_DRIVEN);
return;
}
if (k->st == VD_OPEN && v < VD_TOUCH) {
@@ -118,16 +87,7 @@ static void vd_sample(uint32_t col, uint32_t rowbit, uint32_t v, uint32_t driven
k->up = 0;
vk[key].pend = 1; /* (V10.6z6) the strike's window open (vel.c) */
vk[key].vel = vk[key].at = 0;
if (!vd_cbusy && vs.diag) { /* a capture: the samples before, then this one on */
vd_cap_t *c = &vd_cap[vd_cw];
c->key = (uint8_t)key;
for (i = 0; i < VD_PRE; i++)
c->v[i] = k->pre[(k->pi + i) % VD_PRE];
c->n = VD_PRE;
vd_cbusy = (uint8_t)(key + 1u);
}
}
vd_cap_add(key, v);
if (k->st != VD_OPEN) {
if (v < k->pmin)
k->pmin = (uint16_t)v;
@@ -141,22 +101,8 @@ static void vd_sample(uint32_t col, uint32_t rowbit, uint32_t v, uint32_t driven
else if (++k->up >= 2u) { /* let go (a graze: back over VD_TOUCH): the press queued */
k->st = VD_OPEN;
vel_lift(key, k->dt == VD_NONE ? VD_NONE : vs.strike[key]); /* (V10.6z6: no pressure; a seated one learnt) */
if (!vs.diag)
goto kept;
vd_last.key = (uint8_t)key;
vd_last.dt = k->dt;
vd_last.pmin = k->pmin;
vd_last.dmin = k->dmin;
vd_last_n++;
if ((uint8_t)(vd_ev_w - vd_ev_r) < VD_NEV) {
vd_ev[vd_ev_w % VD_NEV] = vd_last;
vd_ev_w++;
} else {
vd_lost++;
}
}
}
kept:
k->pre[k->pi] = (uint16_t)v;
k->pi = (uint8_t)((k->pi + 1u) % VD_PRE);
k->dnext = k->st != VD_OPEN; /* touched or held: the next sample driven */
@@ -174,7 +120,7 @@ static int vd_drive(uint32_t col, uint32_t rowbit)
* want it, the diagnostic's drive (else Velo's 2, the one calibrated); off, the scan lets go at its next tick */
static void vd_apply(void)
{
if (!vs.diag && !vk_on) {
if (!vk_on) {
fm1_an.want = 0;
return;
}
@@ -182,98 +128,7 @@ static void vd_apply(void)
memset(vd_key, 0, sizeof vd_key);
fm1_an.master = fm1_an.batt = -1; /* (until the scan's first readings) */
}
fm1_an.drive = vs.diag ? vs.dlv : 2u;
fm1_an.drive = 2u;
fm1_an.want = 1;
fm1_an.on = 1;
}
/* the diagnostic on (drive 0: no driven samples; 1..4 its strength, 2 Velo's) or off; off at power-on. (V10.6z6) Off,
* the sampling stays on while the keys' velocity or pressure use it */
static void vd_set(uint32_t on, uint32_t drive)
{
if (on && !vs.diag) { /* (its queue fresh: nothing from before) */
vd_cbusy = vd_cready = 0;
vd_ev_r = vd_ev_w;
vd_lost = 0;
}
vs.diag = (uint8_t)(on != 0u);
vs.dlv = (uint8_t)(drive > 4u ? 4u : drive);
vd_apply();
}
/* the next thing to read: 2 a capture (*c), 1 a press (*e), 0 nothing; taken */
static uint32_t vd_next(vd_cap_t *c, vd_ev_t *e)
{
if (vd_cready) {
*c = vd_cap[vd_cw ^ 1u];
vd_cready = 0;
return 2;
}
if (vd_ev_r != vd_ev_w) {
*e = vd_ev[vd_ev_r % VD_NEV];
vd_ev_r++;
return 1;
}
return 0;
}
static char *vd_num(char *b, uint32_t v) /* decimal; the end returned */
{
char t[6];
uint32_t n = 0;
do
t[n++] = (char)('0' + v % 10u);
while ((v /= 10u) != 0u && n < sizeof t);
while (n)
*b++ = t[--n];
*b = 0;
return b;
}
static char *vd_key_name(char *p, uint32_t key) /* "F3", "C#4" (note 0 F3, 7 C4, 19 C5); the end returned */
{
static const char N[12][3] = {"F", "F#", "G", "G#", "A", "A#", "B", "C", "C#", "D", "D#", "E"};
*p++ = N[key % 12u][0];
if (N[key % 12u][1])
*p++ = '#';
*p++ = (char)('3' + (key + 5u) / 12u);
*p = 0;
return p;
}
/* "C4 D412 P188 2.2MS" (D-, P-: no reading; GRAZE: touched, never seated) */
static void vd_line(char *b, const vd_ev_t *e)
{
char *p = vd_key_name(b, e->key);
*p++ = ' ';
*p++ = 'D';
if (e->dmin == VD_NONE) *p++ = '-'; else p = vd_num(p, e->dmin);
*p++ = ' ';
*p++ = 'P';
if (e->pmin == VD_NONE) *p++ = '-'; else p = vd_num(p, e->pmin);
*p++ = ' ';
if (e->dt == VD_NONE) {
str_cpy(p, "GRAZE", 6);
return;
}
p = vd_num(p, e->dt / 10u);
*p++ = '.';
p = vd_num(p, e->dt % 10u);
str_cpy(p, "MS", 3);
}
/* main loop: the last press on the message line (the console's streaming: console.c con_vel) */
static void vd_poll(void)
{
static uint8_t seen;
if (!vs.diag)
return;
if (seen != vd_last_n) {
char b[28];
vd_ev_t e = vd_last;
seen = vd_last_n;
str_cpy(b, "VEL ", 5);
vd_line(b + 4, &e);
ui_message(b);
}
}
+81
View File
@@ -0,0 +1,81 @@
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* (V10.8.45, the owner: "the arp is not quantized, it should be on the 1/16 at least, not to play out of phase") a key
* into a track's ARP while the transport plays, at 18 moments of a 1/16, four RATEs, three tempos: every step the arp
* takes afterwards on its RATE's grid of the transport (to the sample), its first one a 1/16 away at most or at once
* when the grid's step is in this block or 20 ms back; stopped: at once, as ever */
#define UI_TEST_NO_MAIN 1
#include "ui_test.c"
int main(void)
{
static const uint32_t tempos[] = {90, 121, 133}, rates[] = {2, 1, 3, 5}; /* 1/16 1/8 1/32 1/16T */
uint32_t bad = 0, off = 0, late = 0, n_on = 0;
for (uint32_t b = 0; b < NELEM(tempos); b++)
for (uint32_t r = 0; r < NELEM(rates); r++)
for (uint32_t m = 0; m < 18u; m++) {
track_t *t = &trk[0];
uint32_t per, i, started = 0, wait = 0, idx;
ui_power_on();
song.g[G_BPM] = (int16_t)tempos[b]; song.g[G_CLOCK] = 0;
t->p[P_AMODE] = 1; t->p[P_ARATE] = (int16_t)rates[r]; t->p[P_APROB] = 127; t->p[P_ASWING] = 0;
transport_req = 1;
events_block(CTL);
per = div_samples(rates[r]);
for (i = 0; i < 40u + m * (div_samples(2) / 18u / CTL + 1u); i++) events_block(seq_time(CTL));
arp_add(t, 60);
idx = t->arp_idx;
for (i = 0; i < 4000u; i++) {
events_block(seq_time(CTL));
if (t->arp_idx != idx) { /* a step taken in this block */
uint64_t at = (uint64_t)clk_n * div_samples(2) + clk_pos - t->arp_pos;
idx = t->arp_idx; n_on++;
if (at % per) off++;
if (!started) { started = 1; if (wait * CTL > per + CTL) late++; }
} else if (!started) wait++;
}
if (!started) bad++;
}
bad += check("ARP while playing: every step on its RATE's grid of the transport, three tempos, four RATEs, 18 moments", !off && n_on > 1000u);
bad += check(" its first step a RATE's step away at most", !late);
{ /* stopped: at once */
track_t *t = &trk[0];
ui_power_on();
t->p[P_AMODE] = 1; t->p[P_APROB] = 127;
events_block(CTL); events_block(CTL);
arp_add(t, 60);
events_block(CTL);
bad += check("ARP stopped: the first note in the key's block", t->arp_idx == 0u && t->arp_note == 60);
}
{ /* (the owner: "in REC it has to be quantized") armed, REC Q 0 (as played), keys off the grid: every recorded
* step on its place (MICRO 0), one note a step, none doubled or missing over the loop's end */
uint32_t offs = 0, miss = 0, dbl = 0, m;
for (m = 0; m < 6u; m++) {
track_t *t = &trk[0];
uint32_t i, n = 0;
ui_power_on();
song.g[G_BPM] = 121; song.g[G_CLOCK] = 0; song.sel = 0;
for (i = 0; i < NSTEP; i++) step_clear(&t->step[i]);
t->p[P_SLEN] = 16; t->p[P_SDIV] = 2; t->p[P_HRQ] = 0; t->p[P_QUANT] = QN_OFF;
t->p[P_AMODE] = 1; t->p[P_ARATE] = 2; t->p[P_APROB] = 127; t->p[P_ASWING] = 0; t->p[P_AGATE] = 60;
song.rec = 1;
transport_req = 1;
events_block(CTL);
for (i = 0; i < 30u + m * 17u; i++) events_block(seq_time(CTL));
arp_add(t, 60); arp_add(t, 64);
for (i = 0; i < 20u * div_samples(2) / CTL; i++) events_block(seq_time(CTL)); /* (over the loop's end) */
arp_remove(t, 60); arp_remove(t, 64);
for (i = 0; i < 16u; i++) {
const step_t *s = &t->step[i];
if (s->time != ST_NOTE || !s->n) { miss++; continue; }
n++;
if (ST_MICRO(s)) offs++;
if (s->n != 1u) dbl++;
}
}
bad += check("ARP recorded (REC Q as played, keys off the grid): every step its note, on its place, one a step", !offs && !miss && !dbl);
if (offs || miss || dbl) printf(" off %u missing %u doubled %u\n", offs, miss, dbl);
}
printf(bad ? "arp-grid: %u FAILED (off %u, late %u of %u)\n" : "arp-grid: all ok\n", bad, off, late, n_on);
return bad ? 1 : 0;
}
+6 -6
View File
@@ -31,7 +31,7 @@ int main(void)
ui_power_on();
{ /* (V10.8.40) MOOD MID: the pieces V10.8.39's, byte for byte (from power-on: the tracks' values and steps, the
* song's, the kit; a checksum of 8 seeds in EXPLORE, RANDOM and HOUSE; V10.8.39's own, the same tool) */
static const uint32_t MID[3] = {0x332a2b9eu, 0xf6802e87u, 0x158a05b2u}; /* (V10.8.42 recorded again; V10.8.41: the generator rewritten genre by genre:
static const uint32_t MID[3] = {0xd49db8e0u, 0x9b2fb1dcu, 0x5ac65091u}; /* (V10.8.45 recorded again: the envelopes' rules; V10.8.42 too; V10.8.41: the generator rewritten genre by genre:
* this version's own pieces, recorded with GEN_MID=1; a change to the generator records them again) */
uint32_t md, hs = 0, r, i;
for (r = 1; r <= NGENRE; r++) if (str_eq(GENRE[r - 1u].name, "HOUSE")) hs = r;
@@ -136,20 +136,20 @@ int main(void)
transport_req = 2; blk();
grd.on = 1;
transport_req = 1; blk();
bars(30);
ok &= song.playing && dice_print() == h0 && !grd.rn; /* (its 31st bar: still the piece) */
bars(14); /* (V10.8.45, the owner: half: 16 bars over 110 BPM, were 32) */
ok &= song.playing && dice_print() == h0 && !grd.rn; /* (its 15th bar: still the piece) */
bars(3); blk();
ok &= song.playing && grd.rn == 1u && gp.seed != sd0 && dice_print() != h0;
h0 = dice_print();
for (n = 0; n < 40u && grd.rn < 2u; n++) bars(1);
blk();
ok &= song.playing && grd.rn == 2u && n >= 31u && dice_print() != h0;
ok &= song.playing && grd.rn == 2u && n >= 15u && dice_print() != h0;
if (!ok) printf(" radio: playing %u rn %u seed %u (was %u)\n", (unsigned)song.playing, grd.rn, gp.seed, sd0);
bad += check("RADIO: off nothing; on, the next piece after the loop's 32 bars, playing on, twice", ok);
bad += check("RADIO: off nothing; on, the next piece after the loop's 16 bars, playing on, twice", ok);
{ /* (V10.8.43, BYTE's) a STOP right on the piece's last bar stops: no next piece made, nothing playing (it
* made the next piece and played it) */
uint32_t rn;
for (n = 0; n < 40u && (bar_n & 31u) != 31u; n++) bars(1);
for (n = 0; n < 40u && (bar_n & 15u) != 15u; n++) bars(1);
frames(8);
h0 = dice_print(); rn = grd.rn; sd0 = gp.seed;
ok = song.playing && grd.arm;
+53
View File
@@ -0,0 +1,53 @@
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant). All rights reserved.
/* (V10.8.45, the owner: "a section lasts more than twice what it should; loops that do not evolve and come back the
* same; envelopes") a song's rows measured, a genre a line (SONG, 4 seeds): the rows' seconds (mean, the longest), the
* rows that are a row before them again (section, mutes, sources, variations, the scene's macros), the automation
* records a piece; then the envelopes a role (ATK DEC SUS REL, the envelope's share of the filter), every genre.
* A study's tool (host): cc -O1 -w -Ibuild/gen -Ifirmware/src tests/gen_sec.c -lm -o build/host/gen_sec */
#define UI_TEST_NO_MAIN 1
#include "ui_test.c"
int main(void)
{
static const char *const RN[6] = {"DRUM", "BASS", "PAD", "LEAD", "ARP", "TEX"};
double env[6][5] = {{0}}, tsec = 0, tmax = 0, tsame = 0, trow = 0, tmot = 0;
uint32_t envn[6] = {0}, g, r, k;
ui_power_on();
printf("%-16s %5s %7s %7s %6s %7s\n", "genre", "BPM", "row s", "max s", "same%", "motion");
for (g = 0; g <= NGENRE; g++) {
double sec = 0, mx = 0, mot = 0, bpm = 0; uint32_t rows = 0, same = 0;
for (r = 0; r < 4u; r++) {
uint32_t i, j;
gp.genre = (uint8_t)(g == NGENRE ? GEN_EXPLORE : g + 1u);
gp.form = 2; gp.seed = (uint16_t)(300u + r * 91u);
grd.on = 0; grd.mood = 0;
gen_make();
bpm += song.g[G_BPM];
mot += motion.count;
for (i = 0; i < chain_config.count; i++) {
double s = chain_config.row[i].bars * 240.0 / song.g[G_BPM];
const scene_t *a = &song_idx.scene[song_cur][i];
sec += s; rows++; if (s > mx) mx = s;
for (j = 0; j < i; j++) {
const scene_t *b = &song_idx.scene[song_cur][j];
if (chain_config.row[j].slot == chain_config.row[i].slot && a->mute == b->mute && a->on == b->on &&
song_idx.tsrc[song_cur][i] == song_idx.tsrc[song_cur][j] && song_idx.tvar[song_cur][i] == song_idx.tvar[song_cur][j] &&
!memcmp(a->mac, b->mac, sizeof a->mac)) { same++; break; }
}
}
for (k = 0; k < NTRK; k++) {
uint32_t role = gs.role[k];
if (k >= trk_live || role > 5u || !gs.act[role]) continue;
env[role][0] += trk[k].p[P_ATK]; env[role][1] += trk[k].p[P_DEC]; env[role][2] += trk[k].p[P_SUS];
env[role][3] += trk[k].p[P_REL]; env[role][4] += trk[k].p[P_ED_FLT]; envn[role]++;
}
}
printf("%-16s %5.0f %7.1f %7.1f %6.0f %7.1f\n", g == NGENRE ? "EXPLORE" : GENRE[g].name, bpm / 4, rows ? sec / rows : 0, mx,
rows ? 100.0 * same / rows : 0, mot / 4);
tsec += sec; trow += rows; tsame += same; tmot += mot; if (mx > tmax) tmax = mx;
}
printf("%-16s %5s %7.1f %7.1f %6.0f %7.1f\n\n", "ALL", "", tsec / trow, tmax, 100.0 * tsame / trow, tmot / 4 / (NGENRE + 1));
printf("%-6s %5s %5s %5s %5s %7s\n", "role", "ATK", "DEC", "SUS", "REL", "ENV>FLT");
for (r = 0; r < 6u; r++) if (envn[r]) printf("%-6s %5.0f %5.0f %5.0f %5.0f %7.0f\n", RN[r], env[r][0] / envn[r], env[r][1] / envn[r], env[r][2] / envn[r], env[r][3] / envn[r], env[r][4] / envn[r]);
return 0;
}
+1
View File
@@ -1860,6 +1860,7 @@ static int test_rec(void)
for (i = 0; i < NSTEP; i++)
n += t->step[i].n;
bad += check("ARP on: the key held is not recorded", n == 0);
clk_pos = CLK_START; /* (V10.8.45: no transport's clock here: the arp at once; with one, on its grid: arp_grid_test) */
arp_tick(t, 1);
for (i = 0; i < NSTEP; i++)
if (t->step[i].n)
-325
View File
@@ -1,325 +0,0 @@
/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* (V10.6z5) Host test of the velocity diagnostic (firmware/src/vel_diag.c) and of its sampling in the key scan
* (hal/fm1_input.h fm1_input_tick, fm1__an_take / fm1__an_start; hal/fm1_adc.h), on synthetic ADC traces. The GPIO and
* the converter are memory here; a conversion started on a tick is "done" at the next with the reading of the model
* key under it (pulled up, or driven when its row's pin is an output driven high). Checked:
* - off (the default): the tick never touches the converter or the drive registers, the rows stay inputs (its only
* difference from V10.6z4's tick: two tests of fm1_an.on), fm1_adc_read converts as before;
* - on: the slots: in one frame PA7's eleven columns, in the next PA8's nine note columns, the MASTER pot (column 0,
* OCT-) and the battery (column 1, OCT+), every key of the two rows once every two frames; fm1_adc_read hands the
* pot and the battery to the main loop from those slots (it starts no conversion of its own); the MASTER follows
* the knob;
* - a driven sample only for a touched key, its row an input with its pull-up again before the rows are read (the
* digital scan sees what it saw), the strength in HD0 / HD and cleared after;
* - soft / normal / hard presses on F3, C4 and G4 (the model's driven reading 700 / 560 / 420, its fall 3..12 ms):
* one press each, its key, touch -> press within a sample period of the model's fall, the lowest driven and
* pulled-up readings exact; a graze (never under PRESS) reported as one; drive 0: no driven sample;
* - the capture of the first key touched: 8 samples before the touch (open), 48 from it, driven ones flagged and
* alternating while held; a second key pressed meanwhile reported, not captured; a full queue counted as lost;
* - off again: the scan lets go at its next tick (no conversion pending, the rows inputs).
* cc -O1 -Ibuild/gen -Ifirmware/src tests/vel_diag_test.c -o build/vel_diag_test */
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
static uint32_t host_now; /* TIMER4 ticks (24 MHz) */
#define FM1_INPUT_NOW() host_now
#include "../firmware/hal/fm1_time.h"
#include "../firmware/hal/fm1_gpio.h"
static volatile uint32_t host_reg[16][64]; /* the GPIO registers, as memory */
static uint32_t host_rows_bad; /* rows read while one of PA7 / PA8 was not an input */
static volatile uint32_t *host_pr(uint32_t p, uint32_t r)
{
if (p == FM1_PA && r == FM1_IN && (~host_reg[FM1_PA][FM1_DIR / 4u] & ((1u << 7) | (1u << 8))))
host_rows_bad++;
return &host_reg[p & 15u][(r / 4u) & 63u];
}
#undef FM1_PR
#define FM1_PR(p, r) (*host_pr((p), (r)))
static uint32_t host_ticks(void) { return host_now; }
#define fm1_ticks host_ticks
/* the converter as memory: CON / RES, the writes counted */
static uint32_t adc_con, adc_res, adc_wla, adc_writes, adc_instant;
static uint32_t *adc_reg(void) /* (adc_instant: a conversion done at once, the main loop's reads) */
{
adc_writes++;
if (adc_instant && (adc_con & 0x10u))
adc_con |= 0x80u;
return &adc_con;
}
#define FM1_ADC_CON (*adc_reg())
#define FM1_ADC_RES adc_res
#define FM1_WLA_CON0 adc_wla
static void vd_sample(uint32_t col, uint32_t rowbit, uint32_t v, uint32_t driven);
static int vd_drive(uint32_t col, uint32_t rowbit);
#define FM1_INPUT_ANALOG(col, rowbit, v, driven) vd_sample(col, rowbit, v, driven)
#define FM1_INPUT_DRIVE(col, rowbit) vd_drive(col, rowbit)
#include "../firmware/hal/fm1_input.h"
static unsigned str_len(const char *s) { unsigned n = 0; while (s[n]) n++; return n; }
static void str_cpy(char *d, const char *s, unsigned max)
{
unsigned i = 0;
for (; max && i + 1u < max && s[i]; i++)
d[i] = s[i];
if (max)
d[i] = 0;
}
static char host_msg[48];
static void ui_message(const char *s) { str_cpy(host_msg, s, sizeof host_msg); }
#include "../firmware/src/vel_diag.c"
/* (V10.6z6) the keys' velocity (vel.c), off here (vk_on 0: the diagnostic alone, as V10.6z5): its main-loop needs */
static struct { uint8_t factory[16][32]; } favorites;
#define ENGI_SAMPLE 4u
static volatile uint32_t fm1_ms;
static void settings_save(void) {}
static uint32_t kb_drum_keys(void) { return 0; } /* (V10.7.10: seq.c's) */
#include "../firmware/src/vel.c"
static int fails;
static int check(const char *what, int ok)
{
printf("vel_diag: %-96s %s\n", what, ok ? "ok" : "FAIL");
fails += !ok;
return ok;
}
/* ---- the model: each key's pulled-up and driven readings at time t (us) */
typedef struct { int on; uint32_t t0, fall, hold; uint32_t pseat, dseat, graze; } press_t;
static press_t model[VD_NK];
static uint32_t pot = 700, batt = 620, sim_us;
static uint32_t model_v(uint32_t key, uint32_t t, int driven)
{
const press_t *m = &model[key];
uint32_t lo, x;
if (!m->on || t < m->t0 || t >= m->t0 + m->fall + m->hold)
return 1023;
lo = m->graze ? m->graze : driven ? m->dseat : m->pseat;
if (t >= m->t0 + m->fall)
return lo;
x = t - m->t0; /* a straight fall from 880 (just touched) to the seat */
return 880u - (880u - lo) * x / m->fall;
}
/* the conversion started on the last tick, done now: the reading under it */
static uint32_t conv_n, conv_ch[64], conv_col[64], driven_n;
static void adc_finish(void)
{
uint32_t ch = (adc_con >> 8) & 15u, col = fm1_an.col, rb = fm1_an.rowbit, v = 0;
if (!(adc_con & 0x10u))
return; /* (none started) */
if (conv_n < 64u) {
conv_ch[conv_n] = ch;
conv_col[conv_n] = col;
}
conv_n++;
if (ch == FM1_ADC_MASTER)
v = pot;
else if (ch == FM1_ADC_BATT)
v = batt;
else {
uint32_t key = vd_note(col, rb), m = 1u << (rb == 3u ? 7 : 8);
int driven = !(host_reg[FM1_PA][FM1_DIR / 4u] & m) && (host_reg[FM1_PA][FM1_OUT / 4u] & m);
driven_n += driven;
v = key < VD_NK ? model_v(key, sim_us, driven) : 1023u;
}
adc_res = v;
adc_con |= 0x80u;
}
static void tick(void)
{
adc_finish();
sim_us += 100u;
host_now = sim_us * 24u;
fm1_input_tick();
}
static void run_ms(uint32_t ms)
{
uint32_t i;
for (i = 0; i < ms * 10u; i++)
tick();
}
static void poll_all(vd_ev_t *ev, uint32_t *nev, vd_cap_t *cap, uint32_t *ncap)
{
vd_cap_t c;
vd_ev_t e;
uint32_t k;
while ((k = vd_next(&c, &e)) != 0u) {
if (k == 1u && *nev < 64u) ev[(*nev)++] = e;
if (k == 2u && *ncap < 4u) cap[(*ncap)++] = c;
}
}
static void press(uint32_t key, uint32_t at_ms, uint32_t fall_ms10, uint32_t hold_ms, uint32_t pseat, uint32_t dseat)
{
press_t *m = &model[key];
m->on = 1;
m->t0 = at_ms * 1000u;
m->fall = fall_ms10 * 100u;
m->hold = hold_ms * 1000u;
m->pseat = pseat;
m->dseat = dseat;
m->graze = 0;
}
int main(void)
{
uint32_t i, j;
vd_ev_t ev[64];
vd_cap_t cap[4];
uint32_t nev = 0, ncap = 0;
host_reg[FM1_PA][FM1_IN / 4u] = host_reg[FM1_PB][FM1_IN / 4u] = 0xFFFFFFFFu; /* every row open */
host_reg[FM1_PA][FM1_DIR / 4u] = 0xFFFFFFFFu; /* inputs (fm1_input_init) */
check("the notes on PA8 / PA7: F3 col 3, C4 col 9 (PA8), G4 col 5 (PA7); OCT- / OCT+ and PA6 none",
vd_note(3, 4) == 0 && vd_note(9, 4) == 7 && vd_note(5, 3) == 14 && vd_note(0, 4) == VD_NK &&
vd_note(1, 4) == VD_NK && vd_note(0, 2) == VD_NK && vd_note(10, 3) == 19);
/* ---- off: no converter, no drive, the same GPIO writes as the tick without the diagnostic */
{
uint32_t hd0 = host_reg[FM1_PA][FM1_HD0 / 4u], hd = host_reg[FM1_PA][FM1_HD / 4u];
adc_writes = 0;
for (i = 0; i < 2200u; i++)
tick();
check("off: 2200 ticks, no converter access (fm1_an.on 0 by default)", adc_writes == 0 && !fm1_an.on);
check("off: the drive registers untouched, the rows inputs", host_reg[FM1_PA][FM1_HD0 / 4u] == hd0 &&
host_reg[FM1_PA][FM1_HD / 4u] == hd && !host_rows_bad);
adc_instant = 1;
adc_res = 512u;
check("off: fm1_adc_read converts itself (the main loop's, as before)", fm1_adc_read(FM1_ADC_MASTER) == 512 &&
adc_writes > 0);
adc_instant = 0;
}
/* ---- on: the slots, MASTER and the battery */
vd_set(1, 2);
adc_writes = 0;
check("on: fm1_adc_read hands -1 until the scan's first readings", fm1_adc_read(FM1_ADC_MASTER) == -1 &&
adc_writes == 0);
while (fm1__tick_col != 10u)
tick(); /* (to a frame's start) */
conv_n = 0;
for (i = 0; i < 2u * FM1_NCOL; i++)
tick();
{
uint32_t pa7 = 0, pa8 = 0, mst = 0, bat = 0, cols7 = 0, cols8 = 0;
for (i = 0; i < conv_n && i < 64u; i++) {
if (conv_ch[i] == FM1_ADC_ROW_PA7) pa7++, cols7 |= 1u << conv_col[i];
if (conv_ch[i] == FM1_ADC_ROW_PA8) pa8++, cols8 |= 1u << conv_col[i];
if (conv_ch[i] == FM1_ADC_MASTER) mst += conv_col[i] == 0u;
if (conv_ch[i] == FM1_ADC_BATT) bat += conv_col[i] == 1u;
}
check("on: two frames, a conversion each tick: PA7 x 11 (every column), PA8 x 9 (columns 2..10), MASTER at "
"column 0, the battery at column 1", conv_n == 22u && pa7 == 11u && pa8 == 9u && mst == 1u && bat == 1u &&
cols7 == 0x7FFu && cols8 == 0x7FCu);
}
check("on: fm1_adc_read: the pot and the battery from their slots, no conversion of its own",
(adc_writes = 0, fm1_adc_read(FM1_ADC_MASTER) == 700 && fm1_adc_read(FM1_ADC_BATT) == 620 && adc_writes == 0));
pot = 300;
run_ms(5);
check("on: the MASTER knob turned: fm1_adc_read follows it within ~2.2 ms", fm1_adc_read(FM1_ADC_MASTER) == 300);
check("on: nothing touched: no drive, no press", driven_n == 0 && vd_ev_r == vd_ev_w && !vd_cready);
/* ---- presses: soft / normal / hard on F3, C4, G4, 10 each, one at a time */
{
static const uint32_t KEY[3] = {0, 7, 14}, DS[3] = {700, 560, 420}, PS[3] = {240, 205, 186}, FALL[3] = {120, 60, 30};
uint32_t t = sim_us / 1000u + 10u, ok_n = 1, ok_dt = 1, ok_v = 1, n = 0;
nev = ncap = 0;
for (j = 0; j < 30u; j++) {
uint32_t k = KEY[j % 3u], f = j / 10u;
press(k, t, FALL[f], 80u + 7u * j, PS[f], DS[f]);
run_ms(80u + 7u * j + FALL[f] / 10u + 40u);
poll_all(ev, &nev, cap, &ncap);
if (nev != ++n) { ok_n = 0; break; }
{
const vd_ev_t *e = &ev[nev - 1u];
/* touch -> press: the model crosses 400 at fall x (880-400)/(880-seat); the samples 2.2 ms apart, 4.4
* after the touch (the next is driven) */
uint32_t want = FALL[f] * (880u - 400u) / (880u - PS[f]);
if (e->key != k || e->dt == VD_NONE || e->dt + 23u < want || e->dt > want + 45u) ok_dt = 0;
if (e->dmin != DS[f] || e->pmin != PS[f]) ok_v = 0;
}
model[k].on = 0;
t = sim_us / 1000u + 20u;
}
check("30 presses (10 soft, 10 normal, 10 hard on F3 C4 G4): one report each", ok_n && nev == 30u);
check("each: its key, touch -> press within the sampling's step (-2.2 .. +4.4 ms) of the model's", ok_dt);
check("each: the lowest driven reading (700 / 560 / 420) and the lowest pulled-up (240 / 205 / 186) exact", ok_v);
check("soft > normal > hard in the driven reading by 140 counts each: what the diagnostic is for",
ev[0].dmin > ev[10].dmin && ev[10].dmin > ev[20].dmin);
check("a capture of each press played alone (not read in time: the rest counted lost)", ncap >= 1u);
if (ncap) {
const vd_cap_t *c = &cap[0];
uint32_t pre_open = 1, drv = 0, alt = 1;
for (i = 0; i < VD_PRE; i++) pre_open &= c->v[i] == 1023u;
for (i = VD_PRE; i < VD_PRE + 36u; i++) drv += (c->v[i] & VD_DRIVEN) != 0u;
for (i = VD_PRE + 1u; i + 1u < VD_PRE + 36u; i++)
if (((c->v[i] & VD_DRIVEN) != 0u) == ((c->v[i + 1u] & VD_DRIVEN) != 0u)) alt = 0;
check("the capture: F3, 8 samples before the touch all open, 48 from it", c->key == 0 && c->n == VD_CAP &&
pre_open && !(c->v[VD_PRE] & VD_DRIVEN) && c->v[VD_PRE] < VD_TOUCH);
check("the capture: driven and pulled-up samples alternate from the touch on while the key is held", alt &&
drv == 18u);
}
check("the message line: the last press (\"VEL G4 D420 P186 ...MS\")",
(vd_poll(), !strncmp(host_msg, "VEL G4 D420 P186 ", 17)) && strstr(host_msg, "MS"));
check("driven samples were taken; every row read with PA7 / PA8 inputs again (the digital scan as before)",
driven_n > 0 && !host_rows_bad);
check("the drive (Velo's DRIVE 2, strength 1): HD0 / HD cleared once the row is let go",
!(host_reg[FM1_PA][FM1_HD0 / 4u] & ((1u << 7) | (1u << 8))) && !(host_reg[FM1_PA][FM1_HD / 4u] & ((1u << 7) | (1u << 8))));
}
/* ---- a graze, a chord, drive 0 */
{
uint32_t t = sim_us / 1000u + 10u;
nev = ncap = 0;
press(14, t, 50, 60, 0, 0);
model[14].graze = 650; /* touched, never under PRESS */
run_ms(120);
poll_all(ev, &nev, cap, &ncap);
check("a graze (to 650 and back): reported as one (GRAZE, no touch -> press)",
nev == 1u && ev[0].key == 14 && ev[0].dt == VD_NONE && ev[0].pmin == 650u &&
(vd_line(host_msg, &ev[0]), strstr(host_msg, "GRAZE") != NULL));
model[14].on = 0;
nev = ncap = 0;
t = sim_us / 1000u + 10u;
press(9, t, 40, 200, 200, 500); /* D4 first: captured */
press(19, t + 30u, 40, 150, 210, 600); /* C5 during it */
run_ms(300);
poll_all(ev, &nev, cap, &ncap);
check("a chord: both pressed reported, the first one's capture only", nev == 2u && ncap == 1u &&
cap[0].key == 9 && ((ev[0].key == 9 && ev[1].key == 19) || (ev[0].key == 19 && ev[1].key == 9)));
model[9].on = model[19].on = 0;
vd_set(1, 0);
driven_n = 0;
nev = ncap = 0;
press(3, sim_us / 1000u + 10u, 40, 100, 220, 500);
run_ms(200);
poll_all(ev, &nev, cap, &ncap);
check("drive 0: no driven sample, the press with no driven reading (D-)", driven_n == 0 && nev == 1u &&
ev[0].dmin == VD_NONE && ev[0].pmin == 220u);
model[3].on = 0;
vd_set(1, 2);
}
/* ---- nobody reading: the queue full, counted */
{
uint32_t lost0 = vd_lost;
for (j = 0; j < 12u; j++) {
press(j, sim_us / 1000u + 5u, 30, 30, 200, 500);
run_ms(80);
model[j].on = 0;
}
check("twelve presses unread: eight kept, the rest and the captures counted lost", (uint8_t)(vd_ev_w - vd_ev_r) == VD_NEV &&
vd_lost >= lost0 + 4u);
poll_all(ev, &nev, cap, &ncap);
}
/* ---- off again */
vd_set(0, 0);
tick();
adc_writes = 0;
check("off: the scan lets go at its next tick (nothing pending, the rows inputs)", !fm1_an.on && !fm1_an.pend &&
!fm1_an.driven && (host_reg[FM1_PA][FM1_DIR / 4u] & ((1u << 7) | (1u << 8))) == ((1u << 7) | (1u << 8)));
run_ms(10);
check("off: no converter access by the scan, the main loop's fm1_adc_read its own again",
adc_writes == 0 && (adc_instant = 1, adc_res = 333u, fm1_adc_read(FM1_ADC_MASTER) == 333));
printf("vel_diag: %s\n", fails ? "FAILED" : "all ok");
return fails != 0;
}
+2234 -2242
View File
File diff suppressed because it is too large. Load diff