From 92fc1d714cf56cc142e48d433fc5cf1e60d50f1b Mon Sep 17 00:00:00 2001 From: JUAN JIANT Date: Thu, 5 Nov 2026 20:33:04 -0300 Subject: [PATCH] Explore opt-in DRUM performance octaves and intentional multilingual VOICE; measure target budgets --- .github/workflows/voice-user-check.yml | 1 + firmware/src/core.h | 1 + firmware/src/drumx_voice.c | 12 +++- firmware/src/eng_drum.c | 82 +++++++++++++++++++--- firmware/src/midi_control.c | 7 +- firmware/src/params.c | 6 +- firmware/src/seq.c | 96 +++++++++++++++++++++----- firmware/src/sing.c | 92 ++++++++++++++++++------ firmware/src/sing_ext.c | 82 ++++++++++++++++++++++ firmware/src/ui.c | 33 ++++++++- firmware/src/ui_draw.c | 8 +++ firmware/src/ui_dx.c | 14 ++-- firmware/src/ui_input.c | 19 ++++- firmware/src/ui_lens.c | 2 +- firmware/src/voice.c | 6 +- tests/voice_test.c | 10 ++- tools/gen_lyrics.py | 71 +++++++++++++++---- 17 files changed, 462 insertions(+), 80 deletions(-) create mode 100644 firmware/src/sing_ext.c diff --git a/.github/workflows/voice-user-check.yml b/.github/workflows/voice-user-check.yml index 10ec750a..f93dc3de 100644 --- a/.github/workflows/voice-user-check.yml +++ b/.github/workflows/voice-user-check.yml @@ -41,6 +41,7 @@ jobs: test -s "$T/uboot.boot" && test -s "$T/cfg_tool.bin" && test -s "$T/cfg/eq_cfg_hw.bin" - name: FM-1 package and target budgets env: + FELUCCA_REPIN: keep AC79_SDK: /home/runner/fw-AC79_AIoT_SDK JIELI_TOOLCHAIN: /home/runner/.jieli/toolchain run: | diff --git a/firmware/src/core.h b/firmware/src/core.h index 98bd533f..f5e8acda 100644 --- a/firmware/src/core.h +++ b/firmware/src/core.h @@ -175,6 +175,7 @@ enum { /* per-track parameters */ #define P_SIMG P_LN0 /* (V10.49) a synth's EDIT > STEREO IMAGE, stored inverted (127 = 0 %: the lane level's * 127 every synth part holds); DRUM-X's lane 1 level there. (P_DXIMG is VOICE's LYRIC) */ #define P_VLANG P_LRTRG +#define P_DKEYMODE P_LRTRG /* DRUM-X only: 0 classic, 1 extended performance octaves. */ #define P_VLYR P_DXIMG /* (JIANT 0.6.9) AUTO PAN (fx.c mix_part), in the slots of the old per-track SLICER (one on a bus since 0.6.3, its * slots stored, never read but by proj_sl_migrate). Laid so what old stores hold means OFF: DPTH where SLCR was (0, or diff --git a/firmware/src/drumx_voice.c b/firmware/src/drumx_voice.c index 4694a9bb..c441ee3f 100644 --- a/firmware/src/drumx_voice.c +++ b/firmware/src/drumx_voice.c @@ -204,15 +204,15 @@ static __attribute__((noinline)) int32_t dx_hands_step(dx_voice_t *v, uint32_t n *g1 = (int32_t)(mul64(*g1, 4096 + s) >> 12); return (int32_t)(mul64(gn, 4096 + s0) >> 12); } -static __attribute__((noinline)) void dx_run(const dx_lane_t *L, dx_voice_t *v, int32_t morph, int32_t tune16, +static __attribute__((noinline)) void dx_run_fx(const dx_lane_t *L, dx_voice_t *v, int32_t morph, int32_t tune16, int32_t dofs, int32_t cofs, int32_t nofs, int32_t warp, int32_t fm, int32_t *y, - uint32_t n) + uint32_t n, uint32_t feedback) { int32_t q[DXP_N], p16, depth, ea1, en1, ep1, og, ng, ga, dga, gn, dgn, kd, inc, dinc; uint32_t i, k, wave = L->mode & 3u, flt = (L->mode >> 2) & 3u, ta, tn, tp, kb, inc1; tsvf_t c; uint32_t nf = n, ln = L >= dx_kit && L < dx_kit + 8 ? (uint32_t)(L - dx_kit) : 0u; - int32_t lay = (int32_t)DX_LAY_L(dx_lay[ln]), lfb = (int32_t)DX_TONE_FB(dx_tone) + (int32_t)DX_LAY_FB(dx_lay[ln]); + int32_t lay = (int32_t)DX_LAY_L(dx_lay[ln]), lfb = (int32_t)DX_TONE_FB(dx_tone) + (int32_t)DX_LAY_FB(dx_lay[ln]) + (int32_t)feedback; if (!v->live && !v->trig) { for (i = 0; i < n; i++) y[i] = 0; @@ -589,3 +589,9 @@ static int dx_kit_ok(const dx_lane_t *k) } return 1; } + + +/* Classic callers retain exactly the original feedback path. */ +static void dx_run(const dx_lane_t *L, dx_voice_t *v, int32_t morph, int32_t tune16, + int32_t dofs, int32_t cofs, int32_t nofs, int32_t warp, int32_t fm, int32_t *y, uint32_t n) +{ dx_run_fx(L,v,morph,tune16,dofs,cofs,nofs,warp,fm,y,n,0); } diff --git a/firmware/src/eng_drum.c b/firmware/src/eng_drum.c index 449b6e7a..bc4de2e4 100644 --- a/firmware/src/eng_drum.c +++ b/firmware/src/eng_drum.c @@ -152,8 +152,43 @@ static const uint8_t DRUM_LANE_NOTE[NLANE] = {36, 38, 39, 42, 46, 45, 37, 56}; /* the lane a note strikes */ static uint32_t drum_lane(uint32_t note) { return (uint32_t)DRUM_GM[drum_gm_ix(note)][0]; } +/* Extended note namespace is active only on an opted-in DRUM track. GM 35..81 + * remains unchanged. 0..12 are chromatic kick, 13..26 chromatic tom; twelve + * per-hit effect sounds use 27..34 and 82..85. Other upper notes are live + * performance controls, expanded into ordinary, recordable GM hits by seq.c. */ +#define DXF_REV 8u +#define DXF_DLY 16u +#define DXF_LONG 32u +#define DXF_FB 64u +#define DXF_FOLD 128u +#define DXF_NOISE 256u +static const uint16_t DX_EXT_FX[12] = { + DV_KICK|DXF_REV|DXF_LONG, DV_SNARE|DXF_DLY|DXF_LONG, DV_CLAP|DXF_REV, + DV_HATC|DXF_FB|DXF_FOLD, DV_HATO|DXF_REV|DXF_LONG, DV_TOM|DXF_DLY|DXF_LONG|DXF_FB, + DV_RIM|DXF_DLY|DXF_FB, DV_BELL|DXF_REV|DXF_LONG, DV_KICK|DXF_FB|DXF_LONG, + DV_SNARE|DXF_REV|DXF_NOISE, DV_TOM|DXF_LONG|DXF_FB|DXF_FOLD, DV_BELL|DXF_DLY|DXF_FB|DXF_LONG +}; +static uint32_t drum_ext(const track_t *t) { return t->p[P_DKEYMODE] == 1; } +static const char *drum_oct_label(const track_t *t, int32_t o) +{ + if(drum_ext(t)) { + static const char *const names[7]={"FLAM","FX KIT","KICK / TOM","DRUM-X KIT","FILLS","RATCH SETS","RATCH SETS"}; + return names[clamp(o,-3,3)+3]; + } + return drum_oct_name(o); +} +static uint32_t drum_fx_note(uint32_t k) { k %= 12u; return k < 8u ? 27u+k : 82u+k-8u; } +static uint32_t drum_fx_id(uint32_t note) { return note>=27u&¬e<=34u ? note-26u : note>=82u&¬e<=85u ? note-73u : 0u; } +static uint32_t drum_note_lane(const track_t *t, uint32_t note) +{ + uint32_t fx = drum_ext(t) ? drum_fx_id(note) : 0u; + if (drum_ext(t) && note < 27u) return note < 13u ? DV_KICK : DV_TOM; + return fx ? DX_EXT_FX[fx-1u]&7u : drum_lane(note); +} + /* a note of a muted group (dx_mute): voice.c trk_note_on drops it */ static int drum_muted(uint32_t note) { return dx_lane_muted(drum_lane(note)); } +static int drum_muted_t(const track_t *t, uint32_t note) { return dx_lane_muted(drum_note_lane(t,note)); } /* the lane's name (5 characters at most) */ static const char *drum_lane_name(const track_t *t, uint32_t l) @@ -229,7 +264,7 @@ static drum_lane_t *drum_lane_of(track_t *t, const voice_t *v) static voice_t *drum_reuse(track_t *t, uint32_t note) { drum_lane_t *K = drum_kit_of(t); - uint32_t lane = drum_lane(note), owner = K ? K[lane].owner : 0; + uint32_t lane = drum_note_lane(t,note), owner = K ? K[lane].owner : 0; voice_t *v; if (!owner || owner > NVOICE) return 0; @@ -243,13 +278,16 @@ static void drum_note_on(track_t *t, voice_t *v) uint32_t i = (uint32_t)(v - t->v), lane; if (!K || i >= NVOICE) return; - lane = drum_lane(v->note); + lane = drum_note_lane(t,v->note); L = &K[(uint32_t)v->s[0] & (DV_NLANE - 1u)]; if (L->owner == i + 1u) /* this voice played another lane: it stops there */ L->owner = 0; L = &K[lane]; L->st = (int8_t)clamp(DRUM_GM[drum_gm_ix(v->note)][1] + t->pfx_rpit / 16 + t->dpit, -60, 60); /* (pfx.c RANDOM; * 0.6.82: the step's components, seq.c) */ + if (drum_ext(t) && v->note < 27u) + L->st = (int8_t)clamp((int32_t)v->note-(v->note<13u?6:19)+t->pfx_rpit/16+t->dpit,-60,60); + else if (drum_ext(t) && drum_fx_id(v->note)) L->st = (int8_t)clamp(t->pfx_rpit/16+t->dpit,-60,60); L->bc = 0; /* (0.6.82) its BEND, from the step */ L->bd = t->dbend; L->bs = (int16_t)(t->dbend ? ((t->dbend < 0 ? -t->dbend : t->dbend) + t->dbt) / (t->dbt ? t->dbt : 1u) : 0); @@ -262,6 +300,7 @@ static void drum_note_on(track_t *t, voice_t *v) if (L->dm == 3u) L->fl = (uint8_t)(DXO_FLAM + 1u); /* (FLAM: the grace hit now, the hit DXO_FLAM blocks on, drum_render) */ } + if (drum_ext(t)) L->dm |= (uint8_t)(drum_fx_id(v->note)<<2); v->s[0] = (int32_t)lane; v->env_out = v->vel * 258; /* the hit starts at its level (no ramp from 0) */ v->env = 1 << 24; /* the ADSR held at full from here, not from drum_amp: @@ -335,6 +374,17 @@ static int32_t drum_amp(track_t *t, voice_t *v, int32_t adsr) #define DXS_BUS(s) ((uint32_t)(s) >> 6) /* 0 none, 1 CHORUS, 2 DELAY, 3 REVERB */ #define DXS_AMT(s) ((int32_t)(s) & 63) /* 0..63 */ static uint8_t dx_snd[DV_NLANE]; +static uint32_t drum_hit_fx(const drum_lane_t *L) +{ + uint32_t i=L->dm>>2; + return i && i<=NELEM(DX_EXT_FX) ? DX_EXT_FX[i-1u] : 0u; +} +static uint32_t drum_send(const track_t *t, uint32_t l) +{ + drum_lane_t *K=drum_kit_of(t); + uint32_t f=K&&K[l&7u].owner ? drum_hit_fx(&K[l&7u]) : 0; + return f&DXF_REV ? 255u : f&DXF_DLY ? 191u : dx_snd[l&7u]; +} /* (JIANT 0.7.8) a core's own (mod.c's mod_c the same way): the two cores render two parts at once (fx.c mix_block), and * with one set the other core's part cleared dx_xon and the sides mid-render: the image on and off block by block (a * grit at the block rate, like a downsampling) and clicks on the side a sound leaned to. A core renders its parts one @@ -413,8 +463,9 @@ static __attribute__((noinline)) void drum_side_begin(const track_t *t, uint32_t dc->lpan[l] = (int8_t)p; if (p || p0) on |= 1u; - if (DXS_BUS(dx_snd[l]) && DXS_AMT(dx_snd[l])) - on |= 1u << DXS_BUS(dx_snd[l]); + uint32_t send=drum_send(t,l); + if (DXS_BUS(send) && DXS_AMT(send)) + on |= 1u << DXS_BUS(send); } dc->xon = (uint8_t)on; if (n > CTL) @@ -431,11 +482,18 @@ static __attribute__((noinline)) void drum_side_begin(const track_t *t, uint32_t * g[0..3]: what it gives up of the left at the block's start and end, of the right at its start and end (a pan crossing * the middle within a block fades out of one side into the other) */ static int32_t dx_dump[CTL]; /* (the bus not fed: a sink, so the loop has no branch) */ -static __attribute__((noinline)) int drum_side_of(dx_core_t *dc, uint32_t l, int32_t *g, int32_t **d2, int32_t *a) +static __attribute__((noinline)) int drum_side_of(dx_core_t *dc, uint32_t l, uint32_t send, int32_t *g, int32_t **d2, int32_t *a) { int32_t p0 = dc->lpan0[l & 7u], p1 = dc->lpan[l & 7u]; - uint32_t b = DXS_BUS(dx_snd[l & 7u]); - *a = b ? DXS_AMT(dx_snd[l & 7u]) : 0; + uint32_t b = DXS_BUS(send); + *a = b ? DXS_AMT(send) : 0; + /* A note can start inside the render, after side_begin. Clear a newly + * requested bus before its first write, on this core only. */ + if(*a && !(dc->xon&(1u<sb[b-1u][i]=0; + dc->xon|=(uint8_t)(1u<xon & 1u)) p0 = p1 = 0; g[0] = p0 > 0 ? p0 : 0; g[1] = p1 > 0 ? p1 : 0; @@ -534,9 +592,12 @@ static void drum_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const dx_lane_t acoustic_patch; const dx_lane_t *patch=&dx_kit[(uint32_t)v->s[0] & (DV_NLANE-1u)]; if(dx_acoustic) { dx_acoustic_patch(&acoustic_patch,patch,(uint32_t)v->s[0],v->vel);patch=&acoustic_patch; } - dx_run(patch, &L->x, p[P_E0] + dx_mot_v + L->rm + lfo_shp, + uint32_t hitfx=drum_hit_fx(L); + dx_run_fx(patch, &L->x, p[P_E0] + dx_mot_v + L->rm + lfo_shp, L->st * 16 + L->rt + L->bc + (p[P_E1] - 64) * 3 + t->pfx_pit + lfo_pit, - p[P_E3] - 64 + DXO_DEC[L->dm & 3u], p[P_E2] - 64 + DXO_TON[L->dm & 3u], p[P_E4] - 64, p[P_E6], p[P_E5], y, n); + p[P_E3] - 64 + DXO_DEC[L->dm & 3u] + ((hitfx&DXF_LONG)?36:0), + p[P_E2] - 64 + DXO_TON[L->dm & 3u], p[P_E4] - 64 + ((hitfx&DXF_NOISE)?32:0), + (hitfx&DXF_FOLD)&&p[P_E6]<80 ? 80 : p[P_E6], p[P_E5], y, n, (hitfx&DXF_FB)?6u:0u); { /* PUNCH: the boost before the knee (driven into it, as * Drum Buss), the tail's cut on the amplitude ramp */ int32_t pu = pnch_eff; @@ -567,7 +628,7 @@ static void drum_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const int32_t *d2, g[4], a; dx_core_t *dc = &DXC; /* (0.7.8: this core's, read once) */ uint32_t vo = vo_off_c[MC_CPU() & 1u]; /* (ctl64) the voice's first sample in the part's block */ - if (dc->xon && drum_side_of(dc, (uint32_t)v->s[0], g, &d2, &a)) { /* (0.6.48) IMAGE, SEND: the same loop */ + if (drum_side_of(dc, (uint32_t)v->s[0], drum_send(t,(uint32_t)v->s[0]), g, &d2, &a)) { /* IMAGE, SEND: the same loop */ if (g[0] != g[1] || g[2] != g[3]) drum_side_ramp(dc->sl + vo, dc->sr + vo, y, out, n, m, g, d2 + vo, a); else @@ -716,3 +777,4 @@ static const engine_t ENG_DRUM = { .keys = drum_keys, }; + diff --git a/firmware/src/midi_control.c b/firmware/src/midi_control.c index 0ce43a1b..aec83b10 100644 --- a/firmware/src/midi_control.c +++ b/firmware/src/midi_control.c @@ -121,7 +121,8 @@ static void midi_release(uint32_t ch, uint32_t note) if (!--midi_ch[ch].owned[id - 1u]) midi_ch[ch].targets &= (uint8_t)~(1u << (id - 1u)); } - if (id && drum_track(&trk[id - 1u]) && drum_oct_of(note)) { /* (0.8.5) a band of the kit's octaves */ + if(id && drum_track(&trk[id-1u])) dxo_off(&trk[id-1u],DXO_MIDI+(ch<<7)+source); + if (id && drum_track(&trk[id - 1u]) && !drum_ext(&trk[id-1u]) && drum_oct_of(note)) { /* classic octave bands */ dxo_off(&trk[id - 1u], DXO_MIDI + (ch << 7) + source); if (!midi_local_held(&trk[id - 1u], drum_oct_base(note))) input_off(&trk[id - 1u], drum_oct_base(note)); @@ -132,6 +133,10 @@ static void midi_release(uint32_t ch, uint32_t note) /* a MIDI note-on (ch, note) of track t. A note another key or MIDI note holds already sounds: not started again */ static void midi_play(track_t *t, uint32_t ch, uint32_t note, uint32_t vel) { + if(drum_track(t)&&drum_ext(t)) { + dxo_on(t,note,0,vel,DXO_MIDI+(ch<<7)+note); + return; + } if (drum_track(t) && drum_oct_of(note)) { /* (0.8.5) the kit in another octave: its sound, ratcheted / * damped (seq.c dxo_on) */ dxo_on(t, drum_oct_base(note), drum_oct_of(note), vel, DXO_MIDI + (ch << 7) + note); diff --git a/firmware/src/params.c b/firmware/src/params.c index 0f20a0d6..61ca19fb 100644 --- a/firmware/src/params.c +++ b/firmware/src/params.c @@ -273,6 +273,8 @@ static const param_desc_t DRIFT_DESC = {"DRIFT", F_PCTINV, 0, 127, 127, 0, 0}; static const param_desc_t WROT_DESC[2] = { /* (0.7.8) WHEEL's ROTOR: P_WRDEP (127 = 100 %, as before), P_WDUST */ {"DEPTH", F_PCT, 0, 127, 127, 0, 0}, {"DUST", F_PCTINV, 0, 127, 127, 0, 0}}; static const param_desc_t VLANG_DESC = {"LANG", F_ENUM, 0, LG_N - 1, 0, N_LANG, 0}; /* (0.8.5) VOICE's words: */ +static const char *const N_DKEYMODE[] = {"CLASSIC", "EXTENDED"}; +static const param_desc_t DKEYMODE_DESC = {"KEY MAP",F_ENUM,0,1,0,N_DKEYMODE,0}; static const param_desc_t SIMG_DESC = {"IMAGE", F_PCTINV, 0, 127, 127, 0, 0}; /* (V10.49) P_SIMG: 127 = 0 % */ static const param_desc_t VLYR_DESC = {"LYRIC", F_ENUM, 0, LYR_N - 1, 0, N_LYRIC, 0}; /* P_VLANG, P_VLYR (sing.c) */ static const param_desc_t *track_desc(const track_t *t, uint32_t id) @@ -281,6 +283,7 @@ static const param_desc_t *track_desc(const track_t *t, uint32_t id) return &GP[G_DJF]; if (id == P_SIMG && ENGINES[eng_idx(t->eng_req)] != &ENG_DRUM) /* (V10.49) a synth's STEREO IMAGE */ return &SIMG_DESC; + if (id == P_DKEYMODE && ENGINES[eng_idx(t->eng_req)] == &ENG_DRUM) return &DKEYMODE_DESC; if ((id == P_VLANG || id == P_VLYR) && ENGINES[eng_idx(t->eng_req)] == &ENG_FORMANT) return id == P_VLANG ? &VLANG_DESC : &VLYR_DESC; if (id >= P_E0 && id <= P_E7) { /* the engine asked for (t->engine follows after a fade) */ @@ -578,7 +581,7 @@ enum { GR_NONE, GR_ADSR, GR_LFO, GR_STEPS, GR_ARP, GR_SCALE, GR_FX, GR_ROLL, GR_ GR_SLCR, GR_MOD, GR_PATS, GR_SONG, GR_TOOLS, GR_CHANCE, GR_MOTION, GR_EVENTS, GR_DXSND, GR_MSEQ, GR_SLPIT, GR_FMOP, GR_FMOP2, GR_FMENV, GR_COMP, GR_EUCLID, GR_MORPH, GR_DXIMG, GR_FUGUE, GR_SHAPE, GR_PUNCH, GR_BUSES, GR_FOCUS, GR_STAGE, - GR_LYRIC, GR_GCOMP, GR_LIVE, GR_SCENE, GR_SONGSAVE, GR_SPLIT, GR_SPLIT2 }; /* (p2, main 0.9.11) GLO > LIVE: MANO, RIELES (ui_live.c); the enum's last */ /* (0.8.5) EDIT > WORDS: VOICE's lyric (sing.c) */ /* (0.8.5: + GR_LYRIC, GR_GCOMP, GR_LIVE, GR_SCENE, GR_SONGSAVE, GR_SPLIT, GR_SPLIT2, GR_LYRSTEP }; /* append only */ /* (0.8.5: * LENTE's EDIT > FOCUS, ENV > STAGE) */ /* (0.6.99) FX > PUNCH: the punch-in lane */ /* (JIANT 0.6.39) SEQ > COMP: the step components (ui_input.c comp_*, ui_graph.c graph_comp) */ /* (JIANT 0.6.10, from Felucca 1.5: FM6's operator pages, ui_fm6op.c) */ typedef struct { @@ -704,6 +707,7 @@ static const page_t PAGES[] = { * KNOB 1 USB's state OFF WAIT BUS ENUM MIDI, KNOB 2 the TRS messages come in */ {"KEY SPLIT", FAM_GLO, SC_GLOBAL, GR_SPLIT, {0xFF, 0xFF, 0xFF, 0xFF}}, {"KEY SPLIT 2", FAM_GLO, SC_GLOBAL, GR_SPLIT2, {0xFF, 0xFF, 0xFF, 0xFF}}, + {"LYRIC STEP", FAM_SEQ, SC_TRACK, GR_LYRSTEP, {0xFF,0xFF,0xFF,0xFF}}, {"COMPS", FAM_GLO, SC_GLOBAL, GR_GCOMP, {0xFF, 0xFF, 0xFF, 0xFF}}, /* (0.9.9-seq2f) the global lane's step: ACTION * LENGTH CONDITION VALUE (ui_input.c gco_knob) */ {"COMPS 2", FAM_GLO, SC_GLOBAL, GR_GCOMP, {0xFF, 0xFF, 0xFF, 0xFF}}, /* .. its TRACKS, MONO / POLY */ diff --git a/firmware/src/seq.c b/firmware/src/seq.c index e6f218d6..cf95a3b3 100644 --- a/firmware/src/seq.c +++ b/firmware/src/seq.c @@ -76,7 +76,7 @@ static void mo_send(uint32_t st, uint32_t d1, uint32_t d2) static int mo_plays(const track_t *t, uint32_t note) /* trk_note_on would sound it (voice.c: the same tests) */ { return trk_index(t) < trk_live && !t->p[P_MUTE] && !((trk_hush >> trk_index(t)) & 1u) && - !(t->engine == ENGI_DRUM && drum_muted(note)); + !(t->engine == ENGI_DRUM && drum_muted_t(t, note)); } /* (0.9.9 ctl64) the block being handled (events_block: its samples) and the sample within it an event falls on (core.h * ev_off; voice.c starts or releases the voice there). Set around the note-ons and -offs fired inside the block, 0 @@ -654,7 +654,7 @@ static uint32_t rec_repeats(const track_t *t, const step_t *s); /* a hit (a GM note) into step s of a DRUM track (rec_note, a held ratchet's next step: dxo_rec_hold) */ static void rec_drum(track_t *t, step_t *s, uint32_t note, uint32_t vel, int32_t mic) { - uint32_t l = drum_lane(note), k, m = rec_lmode(), was; + uint32_t l = drum_note_lane(t, note), k, m = rec_lmode(), was; if (s->time != ST_NOTE || (!s->n && !s->hit)) { s->n = s->hit = s->acc = 0; s->flags = 0; @@ -933,10 +933,46 @@ static uint32_t dxo_part(const track_t *t, uint32_t r) /* the part of the playi p = t->seq_pos / (sl ? sl : 1u); return p < r ? p : r - 1u; } +/* Extended held performances use the existing four held-key slots. Each cell + * describes actual GM hits and a recordable per-lane 1/2/4 rate, never a jump + * of the playhead. No additional voice pool or per-track buffer. */ +static uint32_t dxp_note(const dxo_t *e, uint32_t phase, uint32_t slot, uint32_t *rate) +{ + static const uint16_t fills[12] = {0x8888,0xAAAA,0xF080,0xE8A0,0xC8C8,0xFF00, + 0x9249,0xA4A4,0x8421,0xE000,0xCCAA,0xFFFF}; + uint32_t key=e->note%12u, mask; + *rate=1; + if (e->half==2u) { + mask=slot==0u?fills[key]:slot==1u?(uint16_t)(fills[(key+5u)%12u]>>1):0x1111u; + if (!((mask>>(phase&15u))&1u)) return 0; + *rate=slot<2u && phase>=12u ? 1u<<((key+phase)%3u) : 1u; + return slot==0u?38u:slot==1u?(key%3u==0u?39u:DRUM_LANE_NOTE[DV_TOM]): + key&1u?42u:36u; + } + /* Sets vary rhythm, lane and density independently. */ + if (slot==2u && (phase&3u)) return 0; + *rate=1u<<((key+slot)%3u); + return slot==0u?(key&1u?42u:38u):slot==1u?(key%3u==0u?45u:37u):36u; +} +static void dxp_fire(track_t *t, const dxo_t *e, uint32_t phase, uint32_t sub, uint32_t how) +{ + uint32_t j, rate, note; + for(j=0;j<3u;j++) { + note=dxp_note(e,phase,j,&rate); + if(!note || (sub%(4u/rate))) continue; + dx_in_rat=(uint8_t)rate; + if(how==2u) rec_drum(t,&t->step[seq_src(t,t->seq_idx)],note,e->vel,0); + else if(how) input_on(t,note,e->vel); + else trk_note_on(t,note,e->vel); + } + dx_in_rat=0; +} static void dxo_on(track_t *t, uint32_t note, int32_t o, uint32_t vel, uint32_t id) { uint32_t ti = trk_index(t), k; dxo_t *e; + uint32_t ext=drum_track(t)&&drum_ext(t)&¬e>=86u&¬e<=121u; + if(ext) o=1; if (!o || t->p[P_AMODE] || ti >= NPART || !drum_track(t)) { input_on(t, note, vel); return; @@ -949,7 +985,7 @@ static void dxo_on(track_t *t, uint32_t note, int32_t o, uint32_t vel, uint32_t } dx_in_rat = DXO_RAT[o > 3 ? 3 : o]; rec_at = 0; - input_on(t, note, vel); /* (its first hit; recorded with the RATCH) */ + if(!ext) input_on(t, note, vel); /* (its first hit; recorded with the RATCH) */ for (k = 0; k < dxo_n[ti] && dxo[ti][k].id != id; k++) ; if (k == dxo_n[ti] && dxo_n[ti] < DXO_N) @@ -965,6 +1001,13 @@ static void dxo_on(track_t *t, uint32_t note, int32_t o, uint32_t vel, uint32_t e->idx = t->seq_idx; e->part = song.playing && t->seq_pos < 0x7FFFFFFFu ? (uint8_t)dxo_part(t, e->r) : 255u; e->quiet = e->rec = 0; + if(ext) { + e->half=note<98u?2u:3u; + e->note=(uint8_t)((note-86u)%12u); + e->r=4; + e->part=song.playing&&t->seq_pos<0x7FFFFFFFu?(uint8_t)dxo_part(t,4):0; + dxp_fire(t,e,0,0,1); + } if (cin_left) /* (the count-in keeps it for step 1) */ e->rec = 1; else if (rec_at && rec_on(t)) { @@ -1002,7 +1045,7 @@ static __attribute__((noinline)) void dxo_rec_hold(track_t *t, uint32_t idx) e->quiet = (uint8_t)(idx + 1u); continue; } - if (!rec_on(t) || !drum_track(t) || (e->half && !e->ph)) /* (p1: OCT +1, every other step) */ + if (!rec_on(t) || !drum_track(t) || (e->half==1u && !e->ph)) /* (p1: OCT +1, every other step) */ continue; if (!bak) { dxo_bak[ti] = t->step[src]; @@ -1010,13 +1053,20 @@ static __attribute__((noinline)) void dxo_rec_hold(track_t *t, uint32_t idx) dxo_bak_idx[ti] = (uint16_t)idx; bak = 1; } - dx_in_rat = e->r; - rec_drum(t, &t->step[src], e->note, e->vel, 0); - dx_in_rat = 0; + if(e->half>=2u) dxp_fire(t,e,(e->ph+(idx!=e->idx))&15u,0,2); + else { + dx_in_rat = e->r; + rec_drum(t, &t->step[src], e->note, e->vel, 0); + dx_in_rat = 0; + } e->quiet = (uint8_t)(idx + 1u); } } -static void dxo_hit(track_t *t, const dxo_t *e) { trk_note_on(t, e->note, e->vel); } +static void dxo_hit(track_t *t, const dxo_t *e) +{ + if(e->half>=2u) dxp_fire(t,e,e->ph,e->part,0); + else trk_note_on(t, e->note, e->vel); +} /* a block on (events_block, after the sequencer): the held ones' next hits */ static __attribute__((noinline)) void dxo_tick(track_t *t, uint32_t n) { @@ -1029,8 +1079,8 @@ static __attribute__((noinline)) void dxo_tick(track_t *t, uint32_t n) dxo_t *e = &dxo[ti][k]; uint32_t r = e->r ? e->r : 1u, part; if (!song.playing || t->seq_pos >= 0x7FFFFFFFu) { /* stopped: from the press */ - uint32_t per = div_samples((uint32_t)t->p[P_SDIV]) / r << e->half; - e->part = 255u; + uint32_t per = div_samples((uint32_t)t->p[P_SDIV]) / r << (e->half==1u); + if(e->half<2u) e->part = 255u; e->idx = 0xFFFFu; e->cnt += n; if (per && e->cnt >= per) { /* (ctl64: the hit at its sample) */ @@ -1038,6 +1088,10 @@ static __attribute__((noinline)) void dxo_tick(track_t *t, uint32_t n) if (e->cnt >= per) e->cnt = 0; ev_at(e->cnt >= n ? 0u : n - e->cnt); + if(e->half>=2u) { + e->part=(uint8_t)((e->part+1u)&3u); + if(!e->part) e->ph=(uint8_t)((e->ph+1u)&15u); + } dxo_hit(t, e); ev_off = 0; } @@ -1048,7 +1102,7 @@ static __attribute__((noinline)) void dxo_tick(track_t *t, uint32_t n) if (t->seq_idx != e->idx) { e->idx = t->seq_idx; e->part = 255u; - e->ph ^= 1u; + e->ph = e->half>=2u ? (uint8_t)((e->ph+1u)&15u) : e->ph^1u; } if (e->quiet == t->seq_idx + 1u) { e->part = (uint8_t)part; @@ -1059,7 +1113,7 @@ static __attribute__((noinline)) void dxo_tick(track_t *t, uint32_t n) e->part = (uint8_t)part; past = t->seq_pos - part * sl; /* (ctl64) the part's first sample in this block */ ev_at(past >= n ? 0u : n - past); - if (!(e->half & e->ph)) /* (p1: OCT +1, every other step) */ + if (e->half!=1u || !e->ph) /* (p1: OCT +1, every other step) */ dxo_hit(t, e); ev_off = 0; } @@ -1109,6 +1163,13 @@ static void latch_drop(track_t *t) static void key_next(uint32_t k, track_t *t) { uint32_t x = kb_snd[k][kb_on[k]], mc = trk_midi_ch(trk_index(t)); + if(drum_track(t)&&drum_ext(t)&&kb_oct[k] && kb_oct[k]>=-2) { + uint32_t key=(x+128u-29u)%128u; + x=kb_oct[k]==-1?key%27u:kb_oct[k]==-2?drum_fx_note(key): + 86u+12u*(uint32_t)(kb_oct[k]>1?1:0)+key%12u; + kb_snd[k][kb_on[k]]=(uint8_t)x; + kb_oct[k]=0; /* retain the exact MIDI note until release */ + } if (!midi_local_held(t, x)) { in_norec = kb_sn[k] > 1u; /* (0.6.84: the chord's notes recorded at once, key_on) */ dxo_on(t, x, kb_oct[k], 100, DXO_KEY + k); /* (0.8.5: a kit's octave; else input_on) */ @@ -1171,8 +1232,7 @@ static void key_off(uint32_t k, track_t *t) uint32_t n = kb_on[k], i, mc = trk_midi_ch(trk_index(t)); if (!n) return; - if (kb_oct[k] > 0) - dxo_off(t, DXO_KEY + k); /* (0.8.5) its ratchet ends (LATCH too) */ + dxo_off(t, DXO_KEY + k); /* the held performance ends (LATCH too) */ kb_on[k] = 0; /* (the strum's notes not in yet: never) */ kb_sn[k] = 0; if (key_latch(t)) { /* LATCH: it keeps sounding (recorded as let go) */ @@ -2365,7 +2425,7 @@ static __attribute__((noinline)) void seq_step(track_t *t, const step_t *s, uint nn[m] = (uint8_t)x; vv[m] = (uint8_t)vel; sk |= ((skip >> i) & 1u) << m; - once |= (uint32_t)(arp ? 0 : lm_once(s, kit ? drum_lane(s->note[i]) : i, kit)) << m; + once |= (uint32_t)(arp ? 0 : lm_once(s, kit ? drum_note_lane(t, s->note[i]) : i, kit)) << m; m++; } for (i = 0; i < NLANE && !arp; i++) @@ -2476,7 +2536,7 @@ static __attribute__((noinline)) void seq_step(track_t *t, const step_t *s, uint } for (i = 0; i < m; i++) if (!((sk >> i) & 1u)) { - uint32_t a0 = vage, dt0 = t->dtch, lt = kit ? lm_touch(step_lmode(s, drum_lane(nn[i]))) : 0u; + uint32_t a0 = vage, dt0 = t->dtch, lt = kit ? lm_touch(step_lmode(s, drum_note_lane(t, nn[i]))) : 0u; if (lt) t->dtch = (uint8_t)lt; seq_note_on(t, nn[i], vv[i]); @@ -2565,7 +2625,7 @@ static __attribute__((noinline)) void seq_lane_rat(track_t *t, uint32_t period, if ((s->hit >> l) & 1u) seq_note_on(t, DRUM_LANE_NOTE[l], (s->acc >> l) & 1u ? 127u : vel); for (k = 0; k < s->n && k < 4u; k++) - if (drum_lane(s->note[k]) == l) + if (drum_note_lane(t, s->note[k]) == l) seq_note_on(t, s->note[k], vel); ev_off = 0; } @@ -2612,7 +2672,7 @@ static void seq_due(track_t *t, uint32_t n) t->dtch = t->ss_tch; if (trk_kit(t)) { /* (0.8.5) its lane's TOUCH, from the step playing */ const step_t *ps = t->cv_on ? &t->cvs : shift_step(t, t->seq_idx); - uint32_t lt = lm_touch(step_lmode(ps, drum_lane(t->ss_nn[t->ss_i]))); + uint32_t lt = lm_touch(step_lmode(ps, drum_note_lane(t, t->ss_nn[t->ss_i]))); if (lt) t->dtch = (uint8_t)lt; } diff --git a/firmware/src/sing.c b/firmware/src/sing.c index 61d32e6d..dc6ca55e 100644 --- a/firmware/src/sing.c +++ b/firmware/src/sing.c @@ -47,14 +47,15 @@ static volatile uint8_t ly_en_ok = 1; /* (the host: one image) _Static_assert(PH_COUNT == 46, "sing.c PHON[]: one row a phoneme, in gen_lyrics.py's order"); #define LYR_LEN 64u /* a track's lyric: 63 characters and the 0 */ -enum { LG_OFF, LG_ES, LG_EN, LG_JA, LG_N }; -static const char *const N_LANG[] = {"OFF", "ES", "EN", "JA"}; +enum { LG_OFF, LG_ES, LG_EN, LG_JA, LG_RU, LG_DE, LG_FR, LG_ZH, LG_PT, LG_GN, LG_N }; +static const char *const N_LANG[] = {"OFF", "ES", "EN", "JA", "RU", "DE", "FR", "ZH", "PT", "GN"}; #define LYR_NW 16u /* W1..W16: words */ #define LYR_NS 8u /* S1..S8: scat */ -#define LYR_N (1u + LYR_NW + LYR_NS) +#define LYR_FIXED (1u + LYR_NW + LYR_NS) +#define LYR_N (LYR_FIXED + 1u) static const char *const N_LYRIC[LYR_N] = {"TEXT", "W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8", "W9", "W10", "W11", "W12", "W13", "W14", "W15", "W16", "S1", "S2", "S3", "S4", "S5", "S6", "S7", - "S8"}; + "S8", "TEXT FIXED"}; static const char *const N_THEME[] = {"LOVE", "NIGHT", "SEA", "SKY", "ANY", "ROAD", "DREAM", "FIRE", 0}; /* 16 a name */ #define TH_ANY 4u #define TH_FN 8u @@ -391,6 +392,18 @@ static __attribute__((noinline)) uint32_t ly_sym(ly_rd_t *r, const ly_code_t *c) ly_fill(r); return e & 255u; } +/* Pair expansion is only used for the matched word. Pairs refer to lower + * symbols, with generated depth <=8; output is independently bounded. */ +static uint32_t sy_en_expand(uint32_t s, uint8_t *out, uint32_t m) +{ + if(m>=SW_MAX) return m; + if(s<128u) out[m++]=(uint8_t)s; + else if(s-128u out (SW_MAX), its phonemes; *ns its syllables (0: none, a word to skip) */ static uint32_t sy_word(uint32_t lang, const char *w, uint32_t n, uint8_t *out, uint32_t *ns) { @@ -531,6 +545,8 @@ static uint32_t sy_word(uint32_t lang, const char *w, uint32_t n, uint8_t *out, return len; } m = sy_en_rules(w, n, tc, tk); + } else if(lang>=LG_RU && langtxt + b->off[j >> 4]; - for (j &= 15u; j; j--) - while (*q++) - ; - return q; + uint32_t byte=bit>>3; + return ((uint32_t)b->txt[byte]<<8|b->txt[byte+1u])>>(11u-(bit&7u))&31u; +} +static const char *ly_word(const ly_bank_t *b, uint32_t j, char *out) +{ + uint32_t bit=b->off[j>>4],c,m=0; + for(j&=15u;j;j--) do {c=ly_char(b,bit);bit+=5u;} while(c); + while((c=ly_char(b,bit))!=0u) { + if(m<19u) out[m++]=(char)('a'+c-1u); + bit+=5u; + } + out[m]=0; + return out; } static const ly_bank_t LY_BANK[3] = { {LY_ES_TXT, LY_ES_OFF, LY_ES_META, LY_ES_GRP}, @@ -584,7 +608,7 @@ static const ly_bank_t LY_BANK[3] = { static int32_t ly_pick(uint32_t lang, uint32_t theme, uint32_t cat, uint32_t maxs, int exact, uint32_t *r) { const ly_bank_t *b = &LY_BANK[(lang - 1u) % 3u]; - uint32_t st = b->grp[theme][cat][0], n = b->grp[theme][cat][1], k, o; + uint32_t st = b->grp[theme][cat]&511u, n = b->grp[theme][cat]>>9, k, o; if (!n) return -1; o = sy_rnd(r) % n; @@ -656,6 +680,16 @@ static uint32_t sy_norm(const char *s, uint32_t n, char *d, uint32_t max) d[m] = 0; return m; } +static uint32_t sy_norm_lang(uint32_t lang, const char *s, uint32_t n, char *d, uint32_t max) +{ + if(lang='A'&&c<='Z') c+=32; + if((c>='a'&&c<='z')||c=='~'||(c=='\''&&lang==LG_GN)) d[m++]=(char)c; + } + d[m]=0;return m; +} /* (0.9.0) English words resolved in the main loop, so the audio ISR does not search the dictionary (Huffman-coded: * ~3x the old lookup's instructions) when a word starts. sy_word's result (n phonemes, ns syllables, the bytes) for: @@ -717,7 +751,8 @@ static void sing_init(void) uint32_t k, o = 0; lyb_ok = 0; for (k = 0; k < LYB_N; k++) { - const char *q = k < LYB_SCAT ? ly_word(&LY_BANK[1], k) : k < LYB_N - 1u ? SCAT_EN[k - LYB_SCAT] : VOCABLE[1]; + char word[20]; + const char *q = k < LYB_SCAT ? ly_word(&LY_BANK[1], k, word) : k < LYB_N - 1u ? SCAT_EN[k - LYB_SCAT] : VOCABLE[1]; uint32_t m = sy_entry(q, 64u, &lyb_ph[o], LYB_PH - o); lyb_at[k] = (uint16_t)(m ? o + 1u : 0u); o += m; @@ -739,7 +774,7 @@ static __attribute__((noinline)) int sy_tok(const char *txt, uint32_t p, uint32_ if (*mel) q = p + 1u; else - while (q < LYR_LEN && (txt[q] == '_' || txt[q] == '\'' || (txt[q] >= 'a' && txt[q] <= 'z') || + while (q < LYR_LEN && (txt[q] == '~' || txt[q] == '_' || txt[q] == '\'' || (txt[q] >= 'a' && txt[q] <= 'z') || (txt[q] >= 'A' && txt[q] <= 'Z'))) q++; *a = p; @@ -783,6 +818,20 @@ static uint32_t sy_gen_word(const track_t *t, sing_t *s, uint32_t lang, uint32_t uint32_t theme = (uint32_t)clamp(t->p[P_E1], 0, 127) >> 4, f = (uint32_t)clamp(t->p[P_E1], 0, 127) & 15u, tries, pcat = 0; int32_t j = -1; + if(lang>=LG_RU && langprem) { + s->prem=(uint8_t)sy_phrase_len(t); + s->rng=(lyr*0x9E3779B1u)^(lang*0x85EBCA77u)^(theme*0xC2B2AE3Du)^s->phr++; + } + const char *q=SY_EXT_WORDS[lang-LG_RU]; + uint32_t pick=theme*2u+(sy_rnd(&s->rng)&1u); + if(theme==TH_ANY) pick=sy_rnd(&s->rng)&15u; + if(lyr>LYR_NW) q="la"; + else while(pick--) while(*q++); + str_cpy(s->w,q,sizeof s->w); + s->prem--; + return LYB_NONE; + } const ly_bank_t *b = &LY_BANK[(lang - 1u) % 3u]; uint32_t src = LYB_NONE; if (!s->prem) { /* a new phrase */ @@ -855,7 +904,7 @@ static uint32_t sy_gen_word(const track_t *t, sing_t *s, uint32_t lang, uint32_t return src; } { - const char *q = ly_word(b, j); + const char *q = ly_word(b, j, s->w); uint32_t m = 0; while (q[m] && m + 1u < sizeof s->w) { s->w[m] = q[m]; @@ -917,7 +966,7 @@ static int sy_word_next(const track_t *t, sing_t *s, uint32_t lang, uint32_t lyr e = 0; /* (the text changed meanwhile: as before) */ } if (!e) - n = sy_word(lang, nw, sy_norm(s->w, sizeof s->w, nw, sizeof nw), sw->wph, &ns); + n = sy_word(lang, nw, sy_norm_lang(lang,s->w, sizeof s->w, nw, sizeof nw), sw->wph, &ns); sw->wn = (uint8_t)n; sw->wnsy = (uint8_t)ns; sw->wlang = (uint8_t)lang; @@ -940,7 +989,7 @@ static uint32_t sy_take(uint32_t lang, const sing_t *s, const sw_t *sw, uint32_t if (sw->wok && sw->wlang == lang) /* (0.9.0) the word's, as sy_word_next resolved it */ n = sy_take_entry(&sw->wn, buf, &ns); /* (wn, wnsy, wph: an entry's layout) */ else - n = sy_word(lang, nw, sy_norm(s->w, sizeof s->w, nw, sizeof nw), buf, &ns); + n = sy_word(lang, nw, sy_norm_lang(lang,s->w, sizeof s->w, nw, sizeof nw), buf, &ns); for (a = 0; a < n; a++) /* the k-th syllable's first phoneme */ if ((buf[a] & SYB) && !k--) break; @@ -1250,6 +1299,8 @@ static void sing_block(track_t *t) s->gen = lyr_gen[ti]; s->rst = 1; } + uint32_t fixed=lyr==LYR_FIXED; + if(fixed) lyr=0; if (song.playing != s->playing) { /* PLAY: from the start */ s->playing = song.playing; s->loops = t->loops; @@ -1272,7 +1323,7 @@ static void sing_block(track_t *t) sy_reset(s); s->rst = 0; } - if (pos && pos != s->posv) + if (pos && (fixed || pos != s->posv)) sy_seek(t, s, lang, lyr, (uint32_t)pos - 1u); s->posv = (int16_t)pos; x->vb = 0; /* (a syllable: the vibrato waits again) */ @@ -1336,3 +1387,4 @@ static void lyr_dice(const track_t *t, uint32_t lang, uint32_t seed, char *out, } out[m] = 0; } + diff --git a/firmware/src/sing_ext.c b/firmware/src/sing_ext.c new file mode 100644 index 00000000..1a392ec9 --- /dev/null +++ b/firmware/src/sing_ext.c @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * Compact transliteration readers. These are deliberately phonetic singing + * approximations using VOICE's existing phonemes, not speech dictionaries. + * Mandarin takes pinyin (notes determine pitch, not lexical tones). */ +#define LR (1u<<(LG_RU-LG_RU)) +#define LD (1u<<(LG_DE-LG_RU)) +#define LF (1u<<(LG_FR-LG_RU)) +#define LZ (1u<<(LG_ZH-LG_RU)) +#define LP (1u<<(LG_PT-LG_RU)) +#define LG (1u<<(LG_GN-LG_RU)) +typedef struct { char s[5]; uint8_t langs,a,b; } sy_rule_t; +static const sy_rule_t SY_RULES[] = { + {"shch",LR,PH_SH,0}, {"sch",LD,PH_SH,0}, {"eau",LF,PH_O,0}, + {"zh",LR|LZ,PH_ZH,0}, {"kh",LR,PH_X,0}, {"sh",LR|LZ,PH_SH,0}, + {"ch",LR|LZ,PH_CH,0}, {"ch",LD,PH_X,0}, {"ch",LF|LP|LG,PH_SH,0}, + {"ts",LR|LD,PH_TS,0}, {"yu",LR,PH_Y,PH_U}, {"ya",LR,PH_Y,PH_A}, + {"yo",LR,PH_Y,PH_O}, {"ye",LR,PH_Y,PH_E}, + {"ei",LD,PH_A,PH_I}, {"ie",LD,PH_I,0}, {"eu",LD,PH_O,PH_I}, + {"ae",LD,PH_EH,0}, {"oe",LD,PH_ER,0}, {"ue",LD,PH_UJ,0}, + {"ou",LF,PH_U,0}, {"eu",LF,PH_ER,0}, {"oi",LF,PH_W,PH_A}, + {"gn",LF,PH_NY,0}, {"nh",LP,PH_NY,0}, {"lh",LP,PH_Y,0}, + {"ny",LG,PH_NY,0}, {"ng",LZ|LG,PH_NG,0}, + {"a~",LF|LP|LG,PH_A,PH_NM}, {"e~",LF|LP|LG,PH_E,PH_NM}, + {"i~",LF|LP|LG,PH_I,PH_NM}, {"o~",LF|LP|LG,PH_O,PH_NM}, + {"u~",LF|LP|LG,PH_U,PH_NM}, {"y~",LG,PH_UH,PH_NM}, + {"j",LD,PH_Y,0}, {"w",LD,PH_V,0}, {"v",LD,PH_F,0}, {"z",LD,PH_TS,0}, + {"j",LF|LP|LG,PH_ZH,0}, {"r",LF,PH_X,0}, + {"x",LP|LZ,PH_SH,0}, {"q",LZ,PH_CH,0}, {"j",LZ,PH_J,0}, + {"c",LZ,PH_TS,0}, {"z",LZ,PH_TS,0}, {"r",LZ,PH_RA,0}, + {"v",LZ,PH_UJ,0}, {"y",LR|LG,PH_UH,0}, + {"h",LR|LD|LZ|LP|LG,PH_H,0}, {"v",LR|LF|LP,PH_V,0}, + {"g",LR|LD|LZ|LG,PH_G,0}, {"j",LR,PH_Y,0}, {"z",LR|LF|LP,PH_Z,0}, + {"'",LG,PH_H,0} +}; +static uint32_t sy_ext(uint32_t lang, const char *w, uint32_t n, uint8_t *tc, uint8_t *tk) +{ + uint32_t i=0,m=0,mask=1u<<(lang-LG_RU); + while(ilangs&mask)) continue; + for(k=0;r->s[k] && i+ks[k];k++); + if(!r->s[k]) { a=r->a;b=r->b;break; } + } + if(j==NELEM(SY_RULES)) { + uint8_t c[SW_MAX],t[SW_MAX]; + /* Shared single-letter consonants and vowels. Contextual soft c/g + * and silent h follow the established Spanish reader. */ + k=1; + uint32_t z=sy_es_tok(w+i,1,c,t); + if(z) a=c[0]; + if((lang==LG_FR||lang==LG_PT) && i+1up[P_E1] < RW_BYTE); } - if (PAGES[i].graph == GR_LYRIC) /* (0.8.5) WORDS: VOICE's */ + if (PAGES[i].graph == GR_LYRIC || PAGES[i].graph == GR_LYRSTEP) return trk_engp(TSEL) == &ENG_FORMANT; if (PAGES[i].graph == GR_PATS || PAGES[i].graph == GR_CHANCE) /* (0.6.37) PHRASES, a step's CHANCE: out of the */ return !ui.home && ui.page == i; /* SEQ pages' cycle (only where code put the screen) */ @@ -1180,6 +1180,31 @@ static void cursor_fix(void) /* LEN got shorter: onto if (ui.cursor >= (uint32_t)TSEL->p[P_SLEN]) cursor_set(TSEL->p[P_SLEN] - 1); } +/* Main-loop lyric selection. All phones/counters are temporary, the result is + * an ordinary POS lock in the existing motion store, leaving both components. */ +static uint8_t lyric_word, lyric_syl=1; +static uint32_t lyric_pick(char *label) +{ + const char *txt=lyr_get(song.sel); + uint32_t p=0,a,b,mel,w=0,base=0,ns=0; + char word[20],nw[24];uint8_t ph[SW_MAX]; + label[0]=0; + while(sy_tok(txt,p,&a,&b,&mel)) { + uint32_t i,m=0; + for(i=a;ip[P_VLANG],1,LG_N-1),nw, + sy_norm_lang((uint32_t)TSEL->p[P_VLANG],word,m,nw,sizeof nw),ph,&ns); + if(w++>=lyric_word || !txt[b]) { + lyric_word=(uint8_t)(w-1u); + if(lyric_syl>ns) lyric_syl=(uint8_t)ns; + str_cpy(label,word,20); + return !lyric_syl?0u:(uint32_t)clamp((int32_t)(base+lyric_syl),1,127); + } + base+=ns;p=b; + } + return 0; +} static void note_name(char *b, uint32_t n) { @@ -1939,7 +1964,7 @@ static uint32_t act_cols(void) /* the columns that are actions if (pg->graph == GR_MOTION || pg->graph == GR_PUNCH) return 8u; /* (0.6.99) PUNCH: KNOB 4 CLEAR */ if (pg->graph == GR_EVENTS) return 16u; /* AUTO LIST: no knob is an action; OCT+ adds / toggles (ev_oct) */ if (pg->graph == GR_TOOLS) return 15u; - if (pg->graph == GR_LYRIC) return 8u; /* (0.8.5) WORDS: OCT+ TYPE (the lyric, ui_name.c) */ + if (pg->graph == GR_LYRIC || pg->graph==GR_LYRSTEP) return 8u; if (pg->graph == GR_SONG) return 1u; /* (0.8.5) ADD a row (PLAY: the song) */ if (pg->graph == GR_PATS) @@ -1967,7 +1992,7 @@ static uint32_t act_col(void) { if (!ui.home && cur_page()->graph == GR_SONG) return 1u; if (!ui.home && cur_page()->graph == GR_EVENTS) return 5u; - if (!ui.home && cur_page()->graph == GR_LYRIC) return 4u; + if (!ui.home && (cur_page()->graph == GR_LYRIC || cur_page()->graph==GR_LYRSTEP)) return 4u; return !ui.home && cur_page()->graph == GR_PATS ? 2u : ui.act; } @@ -1980,6 +2005,7 @@ static const char *act_name(uint32_t c) /* column c's action (the foote if (cur_page()->graph == GR_MOTION) return "CLEAR"; if (cur_page()->graph == GR_EVENTS) return ev_act_name(); if (cur_page()->graph == GR_LYRIC) return "TYPE"; + if (cur_page()->graph == GR_LYRSTEP) return "PLACE"; if (cur_page()->graph == GR_TOOLS) { static const char *const actions[] = {"CLEAR", "INIT", "DELETE", "CLEAR", "INIT"}; return actions[c < 5u ? c : 4u]; @@ -2006,6 +2032,7 @@ static int act_ready(void) if (cur_page()->graph == GR_MOTION) return !chain_busy() && motion_count(TSEL); if (cur_page()->graph == GR_EVENTS) return ev_act_ready(); if (cur_page()->graph == GR_LYRIC) return 1; + if (cur_page()->graph == GR_LYRSTEP) return !chain_busy() && lyr_get(song.sel)[0]; if (cur_page()->graph == GR_TOOLS) /* one case per column: CLEAR PAT, INIT, DELETE ROW, CLEAR SONG */ return !chain_busy() && (c == 0u ? !seq_is_empty(TSEL) || motion_count(TSEL) : c == 1u || c >= 4u ? 1 : c == 2u ? ui.song_row < chain_config.count : chain_config.count != 0u); diff --git a/firmware/src/ui_draw.c b/firmware/src/ui_draw.c index 26670b1f..83230a69 100644 --- a/firmware/src/ui_draw.c +++ b/firmware/src/ui_draw.c @@ -1622,6 +1622,14 @@ static void draw_columns(void) empty_column(3); return; } + if(cur_page()->graph==GR_LYRSTEP) { + char label[20];uint32_t pos=lyric_pick(label); + fmt_int(val,(int32_t)ui.cursor+1);hot_text_column(0,"STEP",val); + hot_text_column(1,"WORD",label[0]?label:"NO TEXT"); + fmt_int(val,lyric_syl);hot_text_column(2,"SYLLABLE",pos?val:"AUTO"); + draw_act_column(3,"PLACE",T_THEME,ICON_AUTO); + return; + } if (SPLIT_PAGE(cur_page())) { static const char *const labels[8] = {"SPLIT", "LOW TRK", "HIGH TRK", "KEY CUT", "LOW OCT", "HIGH OCT", "MIDI CH", "MIDI CUT"}; for (uint32_t c = 0; c < 4; c++) { diff --git a/firmware/src/ui_dx.c b/firmware/src/ui_dx.c index a09398f0..a0bca20e 100644 --- a/firmware/src/ui_dx.c +++ b/firmware/src/ui_dx.c @@ -16,7 +16,7 @@ static void dx_follow(void) { if (last_note != dx_ui_seen) { if (dx_ui_seen != 0xFFu) /* (the first look only takes note of it) */ - dx_ui_lane = (uint8_t)drum_lane(last_note); + dx_ui_lane = (uint8_t)drum_note_lane(TSEL,last_note); dx_ui_seen = last_note; } } @@ -98,7 +98,11 @@ static void dx_knob(const page_t *pg, uint32_t k, int32_t s) * 4 GLUE (the bus's, eng_drum.c dx_glue: KIT 3's free knob) */ static void dx_kit3_knob(uint32_t k, int32_t s) { - if(cur_page()->title[4]=='4') { if(!k) dx_acoustic=(uint8_t)clamp((int32_t)dx_acoustic+s,0,127); return; } + if(cur_page()->title[4]=='4') { + if(!k) dx_acoustic=(uint8_t)clamp((int32_t)dx_acoustic+s,0,127); + if(k==1u) TSEL->p[P_DKEYMODE]=(int16_t)clamp(TSEL->p[P_DKEYMODE]+s,0,1); + return; + } uint32_t bp = DX_TONE_BP(dx_tone), fb = DX_TONE_FB(dx_tone); if (k == 0u) bp = (uint32_t)clamp((int32_t)bp + (s > 0 ? 1 : -1), 0, 15); else if (k == 1u) fb = (uint32_t)clamp((int32_t)fb + (s > 0 ? 1 : -1), 0, 15); @@ -111,7 +115,8 @@ static void dx_kit3_cards(void) if(cur_page()->title[4]=='4') { char v[12];uint32_t c;fmt_int(v,dx_acoustic*100/127); hot_unit_column(0,"ACOUST",dx_acoustic?v:"OFF",dx_acoustic?"%":""); - for(c=1;c<4;c++) empty_column(c); + hot_unit_column(1,"KEY MAP",drum_ext(TSEL)?"EXTENDED":"CLASSIC",""); + for(c=2;c<4;c++) empty_column(c); return; } uint32_t bp = DX_TONE_BP(dx_tone), fb = DX_TONE_FB(dx_tone); @@ -203,7 +208,7 @@ static uint32_t dx_sig(void) const dx_lane_t *L = &dx_kit[dx_ui_lane & 7u]; uint32_t h = (uint32_t)dx_ui_lane * 31u + dx_ui_side * 977u + L->mode * 131u, i; h ^= (uint32_t)dx_mot[0] << 24 ^ (uint32_t)dx_mot[1] << 16 ^ (uint32_t)dx_mot[2] << 8 ^ dx_mot[3]; /* (X-MOD) */ - h = (h ^ (uint32_t)dx_acoustic << 16 ^ dx_tone ^ (uint32_t)dx_hands << 8 ^ (uint32_t)dx_glue << 12) * 2654435761u; /* (TONE, HANDS, GLUE) */ + h = (h ^ (uint32_t)TSEL->p[P_DKEYMODE] << 24 ^ (uint32_t)dx_acoustic << 16 ^ dx_tone ^ (uint32_t)dx_hands << 8 ^ (uint32_t)dx_glue << 12) * 2654435761u; /* (TONE, HANDS, GLUE) */ for (i = 0; i < DV_NLANE; i++) /* (0.6.48) the SENDs, (0.6.49) the LAYERs */ h = (h ^ dx_snd[i] ^ (uint32_t)dx_lay[i] << 8) * 16777619u; for (i = 0; i < DXP_N; i++) @@ -211,3 +216,4 @@ static uint32_t dx_sig(void) return h; } + diff --git a/firmware/src/ui_input.c b/firmware/src/ui_input.c index df258d64..43ef2180 100644 --- a/firmware/src/ui_input.c +++ b/firmware/src/ui_input.c @@ -1312,6 +1312,12 @@ static void edit_param(uint32_t slot, int32_t steps) dx_kit3_knob(slot, steps); return; } + if(pg->graph==GR_LYRSTEP) { + if(!slot) cursor_set((int32_t)ui.cursor+steps); + if(slot==1u) {lyric_word=(uint8_t)clamp((int32_t)lyric_word+steps,0,31);lyric_syl=1;} + if(slot==2u) lyric_syl=(uint8_t)clamp((int32_t)lyric_syl+steps,0,19); + return; + } if (pg->graph == GR_EVENTS) { /* AUTO LIST (ui_events.c) */ ev_knob(slot, steps); return; @@ -1580,6 +1586,17 @@ static void act_do(void) name_open(NK_LYRIC, song.sel); return; } + if(cur_page()->graph==GR_LYRSTEP) { + char label[20];uint32_t pos=lyric_pick(label); + if(chain_busy()) {ui_message("SONG PLAYS: STOP IT TO EDIT");return;} + if(!label[0]) {ui_message("TYPE A LYRIC FIRST");return;} + undo_mark(); + uint32_t err=motion_set_lock(TSEL,ui.cursor,P_E0,(int16_t)pos); + if(err) {ui_message(err==2u?"AUTOMATION FULL":"CANNOT PLACE LYRIC");return;} + TSEL->p[P_VLYR]=LYR_FIXED; + ui_message(pos?"SYLLABLE PLACED":"AUTO ADVANCE PLACED"); + return; + } if (cur_page()->graph == GR_PUNCH) { /* (0.6.99) the punch-in lane cleared (a dialog) */ if (chain_busy()) { ui_message("SONG PLAYS: STOP IT TO EDIT"); return; } confirm_open(CF_CLEAR_PFX, song.sel); @@ -2792,7 +2809,7 @@ static void ui_input_frame(void) else song.octave += b == B_OCTDN ? (song.octave > -3 ? -1 : 0) : (song.octave < 3 ? 1 : 0); if (drum_track(TSEL) && !song.grid) /* (0.8.5) the kit's octaves: what this one does */ - ui_message(drum_oct_name(song.octave)); + ui_message(drum_oct_label(TSEL,song.octave)); break; } default: /* page buttons (GLO SCL ENV LFO EDIT ARP): when let go */ diff --git a/firmware/src/ui_lens.c b/firmware/src/ui_lens.c index 7fca3be4..0d8b3500 100644 --- a/firmware/src/ui_lens.c +++ b/firmware/src/ui_lens.c @@ -69,7 +69,7 @@ static const nv_t CE_SEQ[] = {NV("STEP", 0, 0, LV_BAR), NV("PATTERN", "LENGTH", NV("EUCLID", 0, 2, LV_PAT), NV("MODES", 0, 2, LV_PAT), NV("MUTATE", 0, 2, LV_PAT), NV("PLAYHEADS", 0, 3, LV_PAT), NV("STRETCH", 0, 4, LV_PAT), NV("COMP", 0, 5, LV_STEP), NV("COMP 2", 0, 5, LV_STEP), NV("AUTOMATION", 0, 6, LV_BAR), - NV("AUTO LIST", 0, 6, LV_BAR)}; + NV("AUTO LIST", 0, 6, LV_BAR), NV("LYRIC STEP",0,6,LV_BAR)}; static const ng_t CG_SEQ[] = {{"STEP", 0}, {"LENGTH", "LEN"}, {"EUCLID", "EUCL"}, {"PLAYHEADS", "HEAD"}, {"STRETCH", "STR"}, {"COMP", 0}, {"AUTO", 0}}; /* (seven tabs: a short form of 4 letters at most fits one) */ enum { FXL_TRACK, FXL_BUSES, FXL_EFFECT }; diff --git a/firmware/src/voice.c b/firmware/src/voice.c index 5347f3fa..38337d4d 100644 --- a/firmware/src/voice.c +++ b/firmware/src/voice.c @@ -986,7 +986,7 @@ static void voice_begin(track_t *t, voice_t *v, uint32_t note, uint32_t vel, int v->pn_dbend = t->dbend; v->pn_dbt = t->dbt; v->pn_tch = (uint8_t)(dx_in_tch ? dx_in_tch : t->dtch); - if (e == &ENG_DRUM && drum_lane(note) == DV_KICK) + if (e == &ENG_DRUM && drum_note_lane(t, note) == DV_KICK) duck_hit = 1; /* (DUCK: the kick's, as drum_note_on tells it; this block's) */ v->active = 1; v->gate = 1; @@ -1146,7 +1146,7 @@ static void trk_note_on(track_t *t, uint32_t note, uint32_t vel) return; } if (t->p[P_MUTE] || ((trk_hush >> ((uint32_t)(t - trk) % NTRK)) & 1u) || - (t->engine == ENGI_DRUM && drum_muted(note))) /* (DRUM: its group mutes) */ + (t->engine == ENGI_DRUM && drum_muted_t(t, note))) /* (DRUM: its group mutes) */ return; if (pfx_note(t, note, vel)) /* the punch-in effects (pfx.c): a repeat holds the track */ return; @@ -1475,7 +1475,7 @@ static __attribute__((noinline)) int32_t drum_env(track_t *t) uint32_t w; if (!v->active || (int16_t)((uint16_t)v->age - seen) <= 0) continue; - w = drum_lane(v->note) <= DV_CLAP ? v->vel : v->vel * 5u / 8u; + w = drum_note_lane(t, v->note) <= DV_CLAP ? v->vel : v->vel * 5u / 8u; if (w > pk) pk = w; if ((int16_t)((uint16_t)v->age - top) > 0) top = (uint16_t)v->age; } diff --git a/tests/voice_test.c b/tests/voice_test.c index 333e8bb8..08d1e21c 100644 --- a/tests/voice_test.c +++ b/tests/voice_test.c @@ -177,7 +177,8 @@ static void check_cache(void) uint32_t k, bad_b = 0, miss = 0, used = 0, ntok = 0, bad_t = 0, nocache = 0; sing_init(); for (k = 0; k < LYB_N; k++) { - const char *q = k < LYB_SCAT ? ly_word(&LY_BANK[1], k) : k < LYB_N - 1u ? SCAT_EN[k - LYB_SCAT] : VOCABLE[1]; + char word[20]; + const char *q = k < LYB_SCAT ? ly_word(&LY_BANK[1], k, word) : k < LYB_N - 1u ? SCAT_EN[k - LYB_SCAT] : VOCABLE[1]; if (!lyb_at[k]) miss++; else { bad_b += !entry_is(&lyb_ph[lyb_at[k] - 1u], q, 64u); @@ -478,7 +479,8 @@ static void check_reading(void) for (k = 0; k < nwds; k++) { uint8_t ph[SW_MAX]; char nw2[24]; - const char *w = ly_word(bk, k); + char word[20]; + const char *w = ly_word(bk, k, word); (void)sy_word(l, nw2, sy_norm(w, (uint32_t)strlen(w), nw2, sizeof nw2), ph, &n); tot++; if (n != (bk->meta[k] & 15u)) { @@ -572,7 +574,8 @@ static void check_generator(void) n = (uint32_t)(q - p); if (!n) break; for (w = 0; w < nwds && !found; w++) { - const char *t = ly_word(bk, w); + char word[20]; + const char *t = ly_word(bk, w, word); found = strlen(t) == n && (!strncmp(t, p, n) || (l == LG_ES && !strncmp(t, p, n - 1u) && t[n - 1u] == 'o' && p[n - 1u] == 'a')); } @@ -1371,3 +1374,4 @@ int main(int argc, char **argv) printf("voice: %s\n", bad ? "FAILED" : "all checks ok"); return bad != 0; } + diff --git a/tools/gen_lyrics.py b/tools/gen_lyrics.py index 3057fa6f..0b623171 100644 --- a/tools/gen_lyrics.py +++ b/tools/gen_lyrics.py @@ -146,19 +146,50 @@ def huff_decode(table, bits, pos): raise AssertionError("no code") +def phone_pairs(recs): + """Lossless byte-pair coding of phones only. 128 recursive pairs, maximum + depth 8. Word-block size and bounded dictionary search are unchanged.""" + from collections import Counter + seq = [tuple(b & 0x7f for b in ph) for _, _, ph in recs] + pairs, depth = [], [0] * 256 + for symbol in range(128, 256): + counts = Counter(pair for row in seq for pair in zip(row, row[1:]) + if max(depth[pair[0]], depth[pair[1]]) < 8) + if not counts: + break + pair, count = max(counts.items(), key=lambda kv: (kv[1], kv[0])) + if count < 8: + break + pairs.append(pair) + depth[symbol] = 1 + max(depth[pair[0]], depth[pair[1]]) + for k, row in enumerate(seq): + out, i = [], 0 + while i < len(row): + if row[i:i+2] == pair: + out.append(symbol) + i += 2 + else: + out.append(row[i]) + i += 1 + seq[k] = tuple(out) + return seq, pairs + + def en_dict_pack(recs): """recs: [(shared, rest, phoneme bytes)] in order -> (blob, idx, tables, codes): each EN_BLK-th word (pre 0) starts a block at a byte (idx: its offset); a word is its shared count (code P), its letters then LY_END (code L, 'a' .. 'z' as 0 .. 25), its phoneme bytes & 0x7F then LY_END (code H)""" from collections import Counter + phones, pairs = phone_pairs(recs) cp, cl, ch = Counter(), Counter(), Counter() for pre, rest, ph in recs: cp[pre] += 1 cl.update(ord(c) - 97 for c in rest) cl[LY_END] += 1 - ch.update(b & 0x7F for b in ph) ch[LY_END] += 1 + for ph in phones: + ch.update(ph) (kp, tp), (kl, tl), (kh, th) = huff_code(cp), huff_code(cl), huff_code(ch) blob, idx, bits = bytearray(), [], [] @@ -179,15 +210,15 @@ def en_dict_pack(recs): for c in rest: put(kl, ord(c) - 97) put(kl, LY_END) - for b in ph: - put(kh, b & 0x7F) + for b in phones[k]: + put(kh, b) put(kh, LY_END) flush() blob += bytes(4) # (sing.c ly_fill reads up to 4 bytes ahead) - return blob, idx, (tp, tl, th), (kp, kl, kh) + return blob, idx, (tp, tl, th), (kp, kl, kh), pairs -def en_dict_unpack(blob, idx, tables, n): +def en_dict_unpack(blob, idx, tables, n, pairs): """the words back from en_dict_pack's blob, as sing.c sy_en_find reads them: [(word, phoneme bytes)]""" bits = [(b >> (7 - i)) & 1 for b in blob for i in range(8)] tp, tl, th = tables @@ -206,7 +237,13 @@ def en_dict_unpack(blob, idx, tables, n): s, pos = huff_decode(th, bits, pos) if s == LY_END: break - ph.append(0x80 | s) + def expand(v): + if v < 128: + ph.append(0x80 | v) + else: + for child in pairs[v - 128]: + expand(child) + expand(s) out.append((w, bytes(ph))) return out @@ -431,14 +468,16 @@ def main(): p16 += 1 plain += 1 + len(w) - p16 + len(ph) + 2 * (k % 16 == 0) prev = w - blob, idx, (tp, tl, th), codes = en_dict_pack(recs) - if en_dict_unpack(blob, idx, (tp, tl, th), len(words)) != [(w, r[2]) for w, r in zip(words, recs)]: + blob, idx, (tp, tl, th), codes, pairs = en_dict_pack(recs) + if en_dict_unpack(blob, idx, (tp, tl, th), len(words), pairs) != [(w, r[2]) for w, r in zip(words, recs)]: raise SystemExit("gen_lyrics: the dictionary does not decode back") assert len(blob) < 65536 L.append(f"#define LY_EN_N {len(words)}u") L.append(f"#define LY_END {LY_END}u") # (JIANT V10.15) the dictionary and its index where the includer puts them (sing.c LY_DICT_SEC: the Bluetooth segment) L.append("#ifndef LY_DICT_SEC\n#define LY_DICT_SEC\n#endif") + L.append(f"static const uint8_t LY_EN_PAIR[{len(pairs)}][2] LY_DICT_SEC = {{\n" + + ",\n".join(" {"+c_bytes(pair)+"}" for pair in pairs) + "\n};") L.append(f"static const uint8_t LY_EN_DICT[{len(blob)}] LY_DICT_SEC = {{\n {c_bytes(blob)}}};") L.append(f"static const uint16_t LY_EN_IDX[{len(idx)}] LY_DICT_SEC = {{\n {c_bytes(idx)}}};") L.append(f"#define LY_EN_BLK {EN_BLK}u") @@ -478,12 +517,19 @@ def main(): counts[lang] = n U = lang.upper() L.append(f"#define LY_{U}_NW {n}u") - L.append(f"static const char LY_{U}_TXT[{len(txt)}] = {{\n {c_bytes(txt)}}};") + # Exact alphabet packing: 0 is word terminator, 1..26 a..z. + # Sparse offsets remain every 16 words, now measured in bits. + assert all(b == 0 or 97 <= b <= 122 for b in txt) + bits = ''.join(f'{0 if b == 0 else b-96:05b}' for b in txt) + bits += '0' * (-len(bits) % 8) + packed = bytes(int(bits[i:i+8],2) for i in range(0,len(bits),8)) + b'\0' + L.append(f"static const uint8_t LY_{U}_TXT[{len(packed)}] = {{\n {c_bytes(packed)}}};") offs = offs[::16] # (0.9.0) each 16th word's place (sing.c ly_word: then the 0s) - L.append(f"static const uint16_t LY_{U}_OFF[{len(offs)}] = {{\n {c_bytes(offs)}}};") + L.append(f"static const uint16_t LY_{U}_OFF[{len(offs)}] = {{\n {c_bytes(o*5 for o in offs)}}};") L.append(f"static const uint8_t LY_{U}_META[{n}] = {{\n {c_bytes(meta)}}};") - rows_c = ",\n ".join("{" + ", ".join(f"{{{a}, {b}}}" for a, b in t) + "}" for t in grp) - L.append(f"static const uint16_t LY_{U}_GRP[{len(THEMES)}][{len(CATS)}][2] = {{\n {rows_c}}};") + assert all(a < 512 and b < 128 for t in grp for a,b in t) + rows_c = ",\n ".join("{" + ", ".join(str(a | b<<9) for a, b in t) + "}" for t in grp) + L.append(f"static const uint16_t LY_{U}_GRP[{len(THEMES)}][{len(CATS)}] = {{\n {rows_c}}};") out.write_text("\n".join(L) + "\n") print(f"lyrics: {len(PHONEMES)} phonemes; English dictionary {len(words)} words, " f"{len(blob) + 2 * len(idx) + len(tp) + len(tl) + len(th) + nlut} B (Huffman; {plain} B as bytes); " @@ -492,3 +538,4 @@ def main(): if __name__ == "__main__": main() +