Files
JIANT/tests/gen_stems.c
T
Claude ea0c56d549 V10.8.41: GEN genre by genre (the owner), TECHNO and EXPLORE their own, MOOD's curve, code no page reaches out
GEN (the owner: "the melodies and the drums sound generic", then a note a genre):
- riffs (BAILE FUNK, PHONK, DUBSTEP): a motif of a written rhythm cell and a contour cell, an answer bar, the
  fourth bar home; JAZZ: the snare's comping written (eight bars, ghosts), the kick feathered, the foot and the
  ride down (lanes 118 -> 70 / 76: ~9 and ~7.6 dB by the square law); IDM GLITCH: the kick and the snare of
  broken cells a bar, one placed roll at most (no bursts), hits their own touch; its drums 9 dB up
- the basses under the drums (GMIX: CUMBIA, DEMBOW, SHOEGAZE, HIP HOP, DREAM POP, KRAUT, TECHNO ROCK, JAZZ,
  PHONK, BREAKBEAT; acid 4 dB down, its resonance capped), DUCK deeper in the machine genres;
  tests/gen_stems.c: the bass's peak too, its check in the workflow (RMS 3 dB, peak 5 dB over the drums)
- DUBSTEP: low FOLD, chorus, the SYNC bass; CUMBIA: a SYNC keyboard up front, the cowbell off the beat, the
  guiro short; REGGAETON faster, minor, a held 808, its hook +6 dB (track GAIN, the riffs' too); HOUSE: ninths
  (PR_NSOUL), ghosts, hat dynamics; HARD BASS heavy, 150-160; SHOEGAZE: a post-punk beat and bass, wet, the
  chorus towards vibrato; DREAM POP slow, an organ's vamps; KRAUT a hook (was TINTI: 4 leads of 24)
- MINIMAL / HARD TECHNO (the owner: "darker, hypnotic"): phrygian, a line of 7 or 6 beats over the 4 always
  there, its filter locked hit by hit, a slow filter movement on the bass and the stab
- EXPLORE (the owner: "darker, more glitch IDM, complex chords, cuts, original timbres, melodies that evolve"):
  the minor modes' weights every piece, two to four chords of sevenths, ninths, elevenths, the borrowed
  chords twice as often, the drums edited every piece (gidm_edit), its own traits (GCHAR: touches, placed
  ratchets, locks, notes walking on the arp, the lead and the bass), an odd engine more often, a cut at the
  cycle's end
- ELECTRO's / EBM's cells one note a throw's own, TINTI's passing note a throw's place (distinct first bars:
  ELECTRO 4 -> 19, KRAUT 4 -> 23, NEO CLASSIC 5 -> 10 of 24)
- MOOD: CALM lighter to -25 (the kit ~8 dB under MID, was 17; gone only near -50), DANCE: a half-time's or a
  break's kick keeps its places (the bar's one, the kit whole: GHALF), the pump deeper; EXPLORE's tempo with
  the mood (~82 .. 138)
- the FUGA genre gone (the owner: "no lo uso"): 29 genres, the seeds after it as they were

Code no page reaches removed (no visible change; tools/build.py: each recorded constant back at its slot).
tests: gen_entry_test (MOOD's cases, the seed cross on the whole piece, MID's reference recorded again),
gen_grid (the lines' check, in the workflow), gen_stems (the mix check), ui_test (the hidden rows).
Layout recorded again with FELUCCA_REPIN=keep (a UI function before .rodata grew); the plain build passes.
Image 582960 B of 584336 (1376 B free), RAM 97008, RAM code 32504 of 34816, pool spare 8480 B, BT segment
73532 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
2026-11-24 23:05:11 +00:00

75 lines
4.3 KiB
C

/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)
* The generator's mix measured (docs/GENERATOR-STUDY.es.md): a genre's pieces with every part on, each role alone
* (the others muted), 6 s each: its RMS against the drums' (dB) and its brightness (zero crossings a second / 2: a
* centroid's stand-in).
* cc -O2 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src -Itests -o build/host/gen_stems tests/gen_stems.c -lm
* build/host/gen_stems [SEEDS [GENRE [c]]]
* (V10.8.41, the owner: "breakbeat's and acid's bass far too loud") the bass's peak against the drums' too (a resonant line's
* peaks pass an RMS); c: the check (the workflow's): no genre's bass more than 3 dB over its drums by RMS, 5 by its peak (MINIMAL
* TECHNO aside: the owner's reference, its sub over the click kit) */
#define UI_TEST_NO_MAIN 1
#include "ui_test.c"
static const char *RLN[6] = {"DRUM", "BASS", "PAD", "LEAD", "ARP", "TEX"};
static double pk_db;
static void render(double secs, double *rms, double *zc)
{
int32_t pk = 1;
uint32_t nsamp = 0, want = (uint32_t)(secs * FS), f = 0, i; double e = 0; uint32_t z = 0; int32_t pv = 0;
transport_req = 1;
while (nsamp < want) {
uint32_t upto = (uint32_t)((uint64_t)(++f) * FS / 30u);
ui_input(); song_poll();
while (nsamp < upto && nsamp < want) {
int32_t o[2 * CTL];
mix_block(o, CTL);
for (i = 0; i < CTL; i++) { int32_t m = (o[2 * i] + o[2 * i + 1]) / 2; e += (double)m * m; if (m > pk) pk = m; if (-m > pk) pk = -m; z += (m >= 0) != (pv >= 0); pv = m; }
nsamp += CTL;
}
host_ticks += 1000000u / 30u; fm1_ms += 1000u / 30u;
}
transport_req = 2; ui_input();
for (i = 0; i < 40u; i++) { int32_t o[2 * CTL]; mix_block(o, CTL); }
pk_db = 20.0 * log10(pk / 32768.0);
*rms = 10.0 * log10(e / nsamp / (32768.0 * 32768.0) + 1e-12); *zc = z * FS / (2.0 * nsamp);
}
int main(int argc, char **argv)
{
uint32_t seeds = argc > 1 ? (uint32_t)atoi(argv[1]) : 3, only = argc > 2 ? (uint32_t)atoi(argv[2]) : 0, g, s, k, r;
double tot[6] = {0}; uint32_t tn[6] = {0}; int bad = 0, chk = argc > 3;
ui_power_on(); go_home(); frames(4);
ui_rec_prefs |= PREF_SIX >> 8; rp_apply();
song.master_q12 = 4096;
printf("%-15s %6s | rel dB to the drums (brightness Hz): BASS PAD LEAD ARP TEX | mix dB\n", "genre", "DRUM");
for (g = only ? only : 1; g <= (only ? only : NGENRE); g++) {
double sum[6] = {0}, zs[6] = {0}, mixs = 0, pks = 0, p0 = 0; uint32_t n[6] = {0};
for (s = 1; s <= seeds; s++) {
int16_t mu[NTRK]; double rm, zc, d0 = 0;
gp.genre = (uint8_t)g; gp.seed = (uint16_t)(s * 37u); gp.energy = 50; gp.form = 0;
for (k = 0; k < GP_N; k++) gp.amt[k] = 60;
gp.complex = 50; gp.swing = GA_AUTO; gp.human = 30;
gen_go();
for (k = 0; k < NTRK; k++) mu[k] = trk[k].p[P_MUTE];
render(6.0, &rm, &zc); mixs += rm;
for (r = 0; r < 6u; r++) {
uint32_t any = 0;
for (k = 0; k < NTRK; k++) { int on = gs.role[k] == r && gs.act[r] && !(r == RL_TEX && k != gs.trk_of[RL_TEX]); trk[k].p[P_MUTE] = (int16_t)!on; any |= on; }
if (!any) continue;
render(6.0, &rm, &zc);
if (r == 0) { d0 = rm; p0 = pk_db; }
if (r == RL_BASS && n[0]) pks += pk_db - p0;
sum[r] += r ? rm - d0 : rm; zs[r] += zc; n[r]++;
}
for (k = 0; k < NTRK; k++) trk[k].p[P_MUTE] = mu[k];
}
printf("%-15s %6.1f |", GENRE[g - 1].name, n[0] ? sum[0] / n[0] : 0);
for (r = 1; r < 6u; r++) { if (n[r]) { printf(" %5.1f (%4.0f)", sum[r] / n[r], zs[r] / n[r]); tot[r] += sum[r] / n[r]; tn[r]++; } else printf(" - "); }
printf(" | %5.1f | bass peak %+5.1f", mixs / seeds, n[1] ? pks / n[1] : 0);
if (g > 1 && n[0] == seeds && n[1] && (sum[1] / n[1] > 3.0 || pks / n[1] > 5.0)) { bad++; printf(" OVER"); }
printf("\n");
}
printf("%-15s |", "MEAN"); for (r = 1; r < 6u; r++) printf(" %5.1f ", tn[r] ? tot[r] / tn[r] : 0); printf("\n");
if (chk) printf(bad ? "gen-mix: %d FAILED\n" : "gen-mix: all ok\n", bad);
return chk && bad;
}