V10.7.69: divisiones por constante como multiplicaciones en las fórmulas de MATH (pase de compilación de JIANT BYTE), ramas muertas de la capa MACRO fuera

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
Claude committed 2026-11-21 03:14:29 +00:00
1 parent 872b9cd41d
commit 6944d3f59c
4 files changed
+1102 -1060

No files matched your search

+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.7.68" /* (2026-11-21) V10.7.68: EUCLID MODES > ROLE (MELODY CHORDS BASS ARP, was CHORD) on the harmony the other melodic tracks play, bar by bar (four bars when it changes), else SCL's key; a recorded melody EUCLID takes: its notes as they were; LFO / FX dice leftovers out (flash). V10.7.67: GEN and EUCLID MUTATE fuse two seeds (the owner: never one as it is; the second far from the first), A+B in the name; FX + OCT+ opens the punch-in editor again (as OCT+ on FX > PUNCH IN). V10.7.66: SCL > HARMONY (PROG LENGTH EVOLVE SKIP: every melodic sequence follows a progression); GEN 8 progressions more (neo-soul, jazz, IDM, progressive); EUCLID's melody CONTOUR RANGE MOTIF CHORD; macros FX > PUNCH IN's only (LFO's layer, HOME > ROUTES gone, MACROS in FX), GLO's layer says G4 UNDO; the PUNCH-IN EDITOR redone (the owner): a key WHAT (an effect, or PARAM: M1..M4, CUT PITCH TIMBRE VOLUME PAN DIST CHORUS DELAY REVERB VIBRATO on every track), HOW (an effect HOLD LATCH QUANT; PARAM HOLD RAMP UP RAMP DN SINE STUTTER S&H), AMOUNT (-100..+100 %; an effect its TARGET), TIME (1/16 .. 8 BARS); two slots A B; FX > PUNCH IN its knobs M1..M4 (PUNCH LANE: LEN RES); the layers MAP only (KNOBS STATE gone, ALGORITHM nothing held), the FX cards "M1 CUT"; FX + SELECT the FX pages (its dice gone). GENE while it plays waits for the bar to end (Hollusion); GENE 4: KEY NEW / KEEP (the first melodic track's key and mode kept), ENTRY ALL / BUILD (the new piece in a track a bar, the kit first); the old DIGITAL / NOISE / retired engines' conversions out (flash), the songs 7-8 notice out; voices past V10.6c's budget: tails first, FM6's quarter rate gone. V10.7.65: the PUNCH-IN EDITOR (the owner): OCT+ on FX > PUNCH IN opens it (the FX layer locked open; an ERASE picked on KNOB 4: OCT+ does it), DICE gone; the COMB / COMB- cut-off moved by the LFO and the ENV as the other filters; a key held and KNOB 1..4 its EFFECT (any, MOD a macro moved) TARGET (ALL SYN DRM T1..T6; MOD M1..M4) AMOUNT (MOD 1 BEAT .. 4 BARS) MODE (HOLD LATCH QUANT; MOD RAMP UP / DOWN SINE S&H), the mode said in the header; SELECT a slot (four, in the settings), OCT+ saves and plays it, OCT- leaves. V10.7.64: SCENE's LEADER PRESS (a key's note on every live track at once, each its own sound); SCENE on the live tracks only (it opened on T6, asleep with four: nothing heard, nothing drawn), every role with the key: a kit's DRUM loops its beat while a key is held, stopped too; the engines as the kit (the owner): FILTER TYPE CUT RES IMAGE (DIST the SENDS' only), PLAY POLY GLIDE UNISON VEL (the plain MORE gone, GL MODE off the panel), GAIN 0..+12 dB clean where a DRIVE was (ANALOG's MORE, WHEEL's COLOR; their DRIVE off the panel, kept), saved ('T' 'G'); FUGA's subject and answer on live tracks (the continuo after: with four tracks it began unheard); DUBSTEP's bass the wobble (a resonant low-pass on an LFO on the 1/8s, kept: not slowed to a breath); DRUM-X KIT's SNAP (was ATTACK), SOUND 3's SHORT (a filter's quick noise, was SNAP). V10.7.63: GENE: DUBSTEP SHOEGAZE METALCORE, each genre its FX STYLE (the drive where it belongs: GRIT FUZZ GROWL METAL LOFI WARM); the chord SETS (SCL > CHORD: POP JAZZ SOUL DREAM QUART, each degree its colour); GEN out of SCENE; GLO > SYSTEM the scope; the song's pages HOME's (SONG: TIMELINE ARRANGE PARTS CLIPS), SAVE saves and loads; SCENE's LEADER: the keys or a track's notes (its sequence) play the roles, each role said in words; KIT 4 gone, a kit's KEY MAP on PLAY (its modes named); labels that fit their cards (GL TYPE RIGHT ALL TRK FEEDBK BARS SKEW HH CL / OP ERASE BUSY). DRUM-X in 8 pages: KIT (MORPH SNAP TONE DECAY), KIT 2 (NOISE BODY GLUE GAIN), SOUND (PITCH DECAY LEVEL), SOUND 2 (NOISE COLOR PMOD; the CLAP's HANDS), SOUND 3 (WAVE FILTER P.ENV), SOUND 4 (SIDE SEND KEY MAP), CROSS MOD, FILTER (IMAGE); BODY the shell's resonator (was FOLD), GAIN 0..+12 dB clean; FEEDBK, BP, BUS, PLAY, LEVELS, STEREO gone (LAYER, TUNE off the panel, a kit's own). V10.7.62: LIFE (HOME > LIFE): the tracks move each other (FILTER TIMBRE PUMP FX, a block late, ~1 % of the CPU); RAMP's END (BACK HOLD PING); SEQ > STEP FX OCT- clears the track's; FX + OCT+ DICE (a punch-in at random each beat); the matrix's STEP source is MSEQ. V10.7.61: EDIT redesigned: the engine's pages by their names, its extras and UNISON VEL on one MORE (ALLOC NOTE PRIO off the panel), clearer labels. V10.7.60: a knob's meaning in the header (MENU > HELP), PRESETS a bar at a time on SEQ, IMAGE on PLAY and on a mono part (a spread). V10.7.59: FX > SENDS with DIST again (KNOB 4); GLO LIVE one page, KEYS shown as RAILS; FX punch-ins REVERSE FREEZE TAPE STOP PITCH UP / DOWN STRETCH; the FX layer's knobs the MACROS, their own matrix (LFO > MACROS); FILL (LOCK's place); clearer names; the punch-in STUT on the grid. V10.7.58: the half rate decided at a note's start by the prediction (HALF_PRED); ROOM's MOD / WIDE network (CLOUD's too) at half the rate. V10.7.57: STRING, WEST and VLine truncated
#define FELUCCA_VERSION "V10.7.69" /* (2026-11-21) V10.7.69: MATH's formulas (lofi_float, lofi_byte) their 14 divisions by a constant as multiplies (JIANT BYTE 0.16's build pass, tools/build.py const_divs: exact, less CPU a sample); the MACRO layer's dead branches out (flash). V10.7.68: EUCLID MODES > ROLE (MELODY CHORDS BASS ARP, was CHORD) on the harmony the other melodic tracks play, bar by bar (four bars when it changes), else SCL's key; a recorded melody EUCLID takes: its notes as they were; LFO / FX dice leftovers out (flash). V10.7.67: GEN and EUCLID MUTATE fuse two seeds (the owner: never one as it is; the second far from the first), A+B in the name; FX + OCT+ opens the punch-in editor again (as OCT+ on FX > PUNCH IN). V10.7.66: SCL > HARMONY (PROG LENGTH EVOLVE SKIP: every melodic sequence follows a progression); GEN 8 progressions more (neo-soul, jazz, IDM, progressive); EUCLID's melody CONTOUR RANGE MOTIF CHORD; macros FX > PUNCH IN's only (LFO's layer, HOME > ROUTES gone, MACROS in FX), GLO's layer says G4 UNDO; the PUNCH-IN EDITOR redone (the owner): a key WHAT (an effect, or PARAM: M1..M4, CUT PITCH TIMBRE VOLUME PAN DIST CHORUS DELAY REVERB VIBRATO on every track), HOW (an effect HOLD LATCH QUANT; PARAM HOLD RAMP UP RAMP DN SINE STUTTER S&H), AMOUNT (-100..+100 %; an effect its TARGET), TIME (1/16 .. 8 BARS); two slots A B; FX > PUNCH IN its knobs M1..M4 (PUNCH LANE: LEN RES); the layers MAP only (KNOBS STATE gone, ALGORITHM nothing held), the FX cards "M1 CUT"; FX + SELECT the FX pages (its dice gone). GENE while it plays waits for the bar to end (Hollusion); GENE 4: KEY NEW / KEEP (the first melodic track's key and mode kept), ENTRY ALL / BUILD (the new piece in a track a bar, the kit first); the old DIGITAL / NOISE / retired engines' conversions out (flash), the songs 7-8 notice out; voices past V10.6c's budget: tails first, FM6's quarter rate gone. V10.7.65: the PUNCH-IN EDITOR (the owner): OCT+ on FX > PUNCH IN opens it (the FX layer locked open; an ERASE picked on KNOB 4: OCT+ does it), DICE gone; the COMB / COMB- cut-off moved by the LFO and the ENV as the other filters; a key held and KNOB 1..4 its EFFECT (any, MOD a macro moved) TARGET (ALL SYN DRM T1..T6; MOD M1..M4) AMOUNT (MOD 1 BEAT .. 4 BARS) MODE (HOLD LATCH QUANT; MOD RAMP UP / DOWN SINE S&H), the mode said in the header; SELECT a slot (four, in the settings), OCT+ saves and plays it, OCT- leaves. V10.7.64: SCENE's LEADER PRESS (a key's note on every live track at once, each its own sound); SCENE on the live tracks only (it opened on T6, asleep with four: nothing heard, nothing drawn), every role with the key: a kit's DRUM loops its beat while a key is held, stopped too; the engines as the kit (the owner): FILTER TYPE CUT RES IMAGE (DIST the SENDS' only), PLAY POLY GLIDE UNISON VEL (the plain MORE gone, GL MODE off the panel), GAIN 0..+12 dB clean where a DRIVE was (ANALOG's MORE, WHEEL's COLOR; their DRIVE off the panel, kept), saved ('T' 'G'); FUGA's subject and answer on live tracks (the continuo after: with four tracks it began unheard); DUBSTEP's bass the wobble (a resonant low-pass on an LFO on the 1/8s, kept: not slowed to a breath); DRUM-X KIT's SNAP (was ATTACK), SOUND 3's SHORT (a filter's quick noise, was SNAP). V10.7.63: GENE: DUBSTEP SHOEGAZE METALCORE, each genre its FX STYLE (the drive where it belongs: GRIT FUZZ GROWL METAL LOFI WARM); the chord SETS (SCL > CHORD: POP JAZZ SOUL DREAM QUART, each degree its colour); GEN out of SCENE; GLO > SYSTEM the scope; the song's pages HOME's (SONG: TIMELINE ARRANGE PARTS CLIPS), SAVE saves and loads; SCENE's LEADER: the keys or a track's notes (its sequence) play the roles, each role said in words; KIT 4 gone, a kit's KEY MAP on PLAY (its modes named); labels that fit their cards (GL TYPE RIGHT ALL TRK FEEDBK BARS SKEW HH CL / OP ERASE BUSY). DRUM-X in 8 pages: KIT (MORPH SNAP TONE DECAY), KIT 2 (NOISE BODY GLUE GAIN), SOUND (PITCH DECAY LEVEL), SOUND 2 (NOISE COLOR PMOD; the CLAP's HANDS), SOUND 3 (WAVE FILTER P.ENV), SOUND 4 (SIDE SEND KEY MAP), CROSS MOD, FILTER (IMAGE); BODY the shell's resonator (was FOLD), GAIN 0..+12 dB clean; FEEDBK, BP, BUS, PLAY, LEVELS, STEREO gone (LAYER, TUNE off the panel, a kit's own). V10.7.62: LIFE (HOME > LIFE): the tracks move each other (FILTER TIMBRE PUMP FX, a block late, ~1 % of the CPU); RAMP's END (BACK HOLD PING); SEQ > STEP FX OCT- clears the track's; FX + OCT+ DICE (a punch-in at random each beat); the matrix's STEP source is MSEQ. V10.7.61: EDIT redesigned: the engine's pages by their names, its extras and UNISON VEL on one MORE (ALLOC NOTE PRIO off the panel), clearer labels. V10.7.60: a knob's meaning in the header (MENU > HELP), PRESETS a bar at a time on SEQ, IMAGE on PLAY and on a mono part (a spread). V10.7.59: FX > SENDS with DIST again (KNOB 4); GLO LIVE one page, KEYS shown as RAILS; FX punch-ins REVERSE FREEZE TAPE STOP PITCH UP / DOWN STRETCH; the FX layer's knobs the MACROS, their own matrix (LFO > MACROS); FILL (LLine truncated
#endif
#if FELUCCA_OTA && !FELUCCA_FLASH
#error "FELUCCA_OTA needs FELUCCA_FLASH"
+2 -25
View File
@@ -123,8 +123,6 @@ static const char *layer_head(void) /* FX: LATCH, and the MI
static const char *const H[3][3] = {{"[FX] HOLD", "[FX] HOLD", "[FX] HOLD"}, /* (V10.7.59: every track, no SYN DRM) */
{"[FX] LATCH", "[FX] LATCH", "[FX] LATCH"},
{"[FX] LOCKED", "[FX] LOCKED", "[FX] LOCKED"}};
if (ui.layer == LAYER_MACRO && !layer_open()) /* (JIANT 0.4) the MACRO layer latched */
return "[LFO] LATCH";
return ui.layer == LAYER_FX ? H[fx_lock && !ui.ly ? 2 : perf_latch_on ? 1 : 0][pfx_tgt % 3u] : LAYERS[ui.layer % LAYER_N].head;
}
static uint32_t layer_open(void)
@@ -839,8 +837,6 @@ static void layer_knob(uint32_t k, int32_t s)
if (k == 0u)
lys.song = (uint8_t)(clamp((int32_t)(lys.song ? lys.song - 1u : song_cur) + (s > 0 ? 1 : -1), 0,
NSONG - 1) + 1);
} else if (l == LAYER_MACRO) { /* M1..M4 (the project's; the MOD slots that name them) */
macro_v[k] = (uint8_t)clamp(macro_v[k] + accel(EN_K1 + k, s, 127), 0, 127);
} else if (l == LAYER_REC) { /* K1 CLICK, K2 REC Q */
if (k == 1u)
TSEL->p[P_HRQ] = (int16_t)clamp(TSEL->p[P_HRQ] + accel(EN_K2, s, 127), 0, 127);
@@ -1151,10 +1147,6 @@ static uint32_t ly_keyname(uint32_t l, int blk, uint32_t p, char *nm)
return !ui.home && (cur_page()->graph == GR_USER || cur_page()->graph == GR_SLOTS) ? LS_OFF : LS_DIM;
return p == SK_MODE && live.mode ? LS_SEL : p == SK_REC ? (live.srec == 2u ? LS_HELD : live.srec ? LS_WAIT : LS_OFF) : LS_OFF;
}
if (l == LAYER_MACRO && !blk && p < 2u) { /* F3 DICE, G3 CLEAR */
str_cpy(nm, p ? "CLEAR" : "DICE", 12);
return busy;
}
return LS_OFF;
}
/* a key's fill and its name's ink by its state (named: n) */
@@ -1451,12 +1443,6 @@ static __attribute__((noinline)) void layer_cards(uint32_t l)
text_column(1, "PART", val, live.cur >= 0 ? VAL(1u) : T_DIM);
hot_text_column(2, "PLAY", live.mode ? "SONG" : "LOOP");
text_column(3, "REC", live.srec == 2u ? "ON" : live.srec ? "ARM" : "OFF", live.srec ? VAL(3u) : T_DIM);
} else if (l == LAYER_MACRO) { /* M1..M4, 0..100 % */
static const char *const M[4] = {"M1", "M2", "M3", "M4"};
for (c = 0; c < 4u; c++) {
fmt_int(val, macro_v[c] * 100 / 127);
draw_column(c, M[c], val, "%", macro_routes(c, 0, 0) ? VAL(c) : T_DIM, macro_v[c] * 1000 / 127, ICON_MIX);
}
} else if (l == LAYER_REC) { /* CLICK, then empty cards */
rec_columns();
} else if (l == LAYER_EDIT) { /* (0.9.9-seq2f) ENG, No. (PRESETS), FAV (ui_draw.c) */
@@ -1480,7 +1466,7 @@ static __attribute__((noinline)) void layer_cards(uint32_t l)
* on. The header "[FX] HELD"; the breadcrumb "LENTE . MAP . FX" */
static const khint_t *layer_foot(uint32_t l)
{
return l == LAYER_FX && perf_latch_on ? FX_LATCH_FOOT : l == LAYER_MACRO && !layer_open() ? MAC_LATCH_FOOT : LAYERS[l].foot;
return l == LAYER_FX && perf_latch_on ? FX_LATCH_FOOT : LAYERS[l].foot;
}
static void layer_knobs(uint32_t l) /* the four as gauges in their knobs' colours, the keys' words */
{
@@ -1537,7 +1523,7 @@ static __attribute__((noinline)) void layer_state(uint32_t l)
uint32_t k, e;
char b[48], v[8];
str_cpy(b, LN[l], sizeof b);
str_cpy(b + str_len(b), l == LAYER_MACRO && !layer_open() ? " \xB7 LATCHED" : " \xB7 HELD", sizeof b - str_len(b));
str_cpy(b + str_len(b), " \xB7 HELD", sizeof b - str_len(b));
cv_text(6, 5 - AF_X_CAP_Y, &AF_X, b, T_THEME);
if (l == LAYER_FX && fx_lock)
cv_text_r(234, 5 - AF_X_CAP_Y, &AF_X, "[FX] LOCKED", T_ACCENT, T_SURF);
@@ -1560,13 +1546,6 @@ static __attribute__((noinline)) void layer_state(uint32_t l)
for (k = 0; glo_drums() && k < 4u; k++)
lst_chip(GLO_GROUP[k], (dx_mute >> k) & 1u ? "MUTE" : "ON", !((dx_mute >> k) & 1u));
lst_chip("UNDO", undo_ok ? "READY" : "-", undo_ok);
} else if (l == LAYER_MACRO) { /* the latch, each macro's routes */
lst_chip("LATCH", mac_latch ? "ON" : "OFF", mac_latch);
for (k = 0; k < 4u; k++) {
char m[3] = {'M', (char)('1' + k), 0};
uint32_t n = macro_routes(k, b, sizeof b);
lst_chip(m, n ? b : "NO ROUTE", n != 0u);
}
} else if (l == LAYER_REC) {
b[0] = 'T'; b[1] = (char)('1' + song.sel); b[2] = 0;
lst_chip("ARMED", b, (song.rec >> song.sel) & 1u);
@@ -1624,8 +1603,6 @@ static __attribute__((noinline)) void draw_layer(void)
sig += (uint32_t)(live.cur + 1) * 31u + (uint32_t)(live.req + 1) * 131u + live.srec * 7u + live.mode * 11u +
live.dirty * 977u + lys.nqc * 4099u + (chain.running ? chain.row * 13u + chain.remaining * 17u : 0u) +
(lys.song * 8u + song_cur) * 65537u;
else if (l == LAYER_MACRO)
sig += macro_sig();
else if (l == LAYER_SEQ)
sig += (uint32_t)drum_track(TSEL) * 31u + ui.lane * 5u + (uint32_t)chain_busy() * 3u + (uint32_t)TSEL->p[P_E0] * 131u + song.sel * 977u;
else
+1033 -1034
View File
File diff suppressed because it is too large. Load diff
+66
View File
@@ -229,6 +229,69 @@ def share_strings(ir, keep=()):
return ir, n, saved
# (BYTE 0.16, CPU) this clang's pi32v2 back end lowers a division by a constant to its divide instruction (iterative,
# slow), never to a multiply: FORM alone filled the FM-1 (its oscillator 51 of them, called ~10 times a sample). In the
# audio's hottest functions each i32 udiv / urem / sdiv / srem by a constant becomes the multiply (one 32x32->64
# instruction) by floor((2^32-1)/d) and one correction: exact for every input (the estimate is at most one low)
DIV_FNS = ("lofi_float", "lofi_byte") # (V10.7.69, from JIANT BYTE 0.16, GPL-3.0: MATH's formulas, a sample each; not
# the RAM code's, mix_part_m0 ..: its room)
def const_divs(ir, names=DIV_FNS):
"""(the IR, how many divisions turned into multiplies)"""
k = [0]
def udiv(x, d, p, rem):
m = (2**32 - 1) // d
o = [f"{p}a = zext i32 {x} to i64", f"{p}b = mul i64 {p}a, {m}", f"{p}c = lshr i64 {p}b, 32",
f"{p}q = trunc i64 {p}c to i32", f"{p}m = mul i32 {p}q, {d}", f"{p}r = sub i32 {x}, {p}m",
f"{p}g = icmp uge i32 {p}r, {d}"]
if rem: # (only what is used: no optimiser after this)
return o + [f"{p}s = select i1 {p}g, i32 {d}, i32 0", f"{p}ur = sub i32 {p}r, {p}s"]
return o + [f"{p}i = zext i1 {p}g to i32", f"{p}uq = add i32 {p}q, {p}i"]
def line(m):
ind, dst, op, x, d = m[1], m[2], m[3], m[5], int(m[6])
if d in (0, 1, -1) or (op[0] == "u" and d < 0):
return m[0]
a = abs(d)
if op[0] == "u" and a & (a - 1) == 0:
return m[0]
k[0] += 1
p = f"%dvq{k[0]}."
out = []
if op[0] == "s":
out += [f"{p}n = icmp slt i32 {x}, 0", f"{p}ng = sub i32 0, {x}", f"{p}ax = select i1 {p}n, i32 {p}ng, i32 {x}"]
ux = f"{p}ax"
else:
ux = x
if a & (a - 1) == 0:
sh = a.bit_length() - 1
out += [f"{p}ur = and i32 {ux}, {a - 1}"] if op.endswith("rem") else [f"{p}uq = lshr i32 {ux}, {sh}"]
else:
out += udiv(ux, a, p, op.endswith("rem"))
if op == "udiv":
out += [f"{dst} = add i32 {p}uq, 0"]
elif op == "urem":
out += [f"{dst} = add i32 {p}ur, 0"]
elif op == "sdiv":
q = f"{p}uq"
if d < 0:
out += [f"{p}nq = sub i32 0, {p}uq", f"{dst} = select i1 {p}n, i32 {p}uq, i32 {p}nq"]
else:
out += [f"{p}nq = sub i32 0, {q}", f"{dst} = select i1 {p}n, i32 {p}nq, i32 {q}"]
else: # srem: the sign of x
out += [f"{p}nr = sub i32 0, {p}ur", f"{dst} = select i1 {p}n, i32 {p}nr, i32 {p}ur"]
return "\n".join(ind + o for o in out)
body = re.compile(r"^(\s+)(%[\w.]+) = (udiv|urem|sdiv|srem)( exact)? i32 ([%\w.]+), (-?\d+)\s*$", re.M)
def fn(m):
return body.sub(line, m[0])
ir = re.sub(r"^define [^\n]*?@(" + "|".join(names) + r")\([^\n]*\{\n.*?^\}$", fn, ir, flags=re.M | re.S)
return ir, k[0]
def hot_sections(ir):
"""HOT_FNS' definitions in the optimised IR given section ".hot_text.<name>"; (the IR, how many found)"""
found = 0
@@ -516,6 +579,9 @@ def build_app():
aligns[m.group(2)] = int(m.group(4))
return f'{m.group(1)}, section ".rodata.n.{m.group(2)}"{m.group(3)}'
ir, n, saved = share_strings(hot_ir)
if os.environ.get("FELUCCA_CONSTDIV") != "0":
ir, nd = const_divs(ir)
print(f"divisions: {nd} by a constant turned into multiplies (DIV_FNS)", flush=True)
print(f"strings: {n} shared with a longer one ({saved} B)", flush=True)
ir = re.sub(r'^(@"?([\w.]+)"? = [^\n]*? constant [^\n]*?)(, align (\d+))$', const, ir, flags=re.M)
(OUT / "felucca_hot.ll").write_text(ir)