Master EQ / TAPE kept by SAVE SONG AS and RESTORE LAST

A Discord report: saving a project "resets" the master's 4-band EQ, and a
loaded project sometimes forgets it.

- song_save.c song_copy_section: SAVE SONG AS wrote the live globals into
  every section but left each section's own stored EQ and TAPE. Loading the
  project opens section A (song_switch -> section_load), so when another
  section was playing at save time, or A was stored before the EQ was set,
  the EQ came back flat or stale. Every section now gets the master's EQ
  and TAPE (proj_master_put, shared with project_capture).
- project.c autosave_sig: the EQ and TAPE were not in the signature, so a
  change to only them was never autosaved and RESTORE LAST brought back
  older values at power-on.

The format does not change ('E' 'Q' / 'T' 'P' blocks as before), so old
projects load the same way.

Tests: tests/eq_save_cases.h (persistence_test): SAVE SONG AS while on
section C, then reload / section changes / another project / project
section save+load / UNDO / NEW PROJECT / autosave + power-on.
cpu_vg: song/cputest.eq section; target_budget: eq_block (cost 355).
Image +48 B (164 -> 116 B free), BT segment +8 B.

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-09 19:26:49 +00:00
1 parent dfb9635163
commit b06a64ebe3
9 files changed
+1788 -1700

No files matched your search

+12 -5
View File
@@ -1341,6 +1341,15 @@ static void proj_fetch(uint32_t slot)
}
#endif
/* (V10.58) the master's EQ and TAPE playing -> p (no sum). project_capture; SAVE SONG AS (song_save.c
* song_copy_section): every section stored with them, as the song's globals, so loading the project (its section A) or
* changing section gives them back, whichever section was playing when it was saved */
static __attribute__((noinline)) void proj_master_put(project_t *p)
{
uint32_t k;
for (k = 0; k < 4u; k++) p->eq[k] = (int8_t)eq_v[k];
p->tp[0] = (uint8_t)tape_v[0]; p->tp[1] = (uint8_t)tape_v[1];
}
static void project_capture(project_t *p)
{
uint32_t i;
@@ -1369,11 +1378,7 @@ static void project_capture(project_t *p)
memcpy(p->dx, dx_kit, sizeof p->dx);
p->dx_mute = dx_mute;
memcpy(p->dx_mot, dx_mot, sizeof p->dx_mot);
{ /* (V10.58) the master's EQ and TAPE */
uint32_t k;
for (k = 0; k < 4u; k++) p->eq[k] = (int8_t)eq_v[k];
p->tp[0] = (uint8_t)tape_v[0]; p->tp[1] = (uint8_t)tape_v[1];
}
proj_master_put(p); /* (V10.58) the master's EQ and TAPE */
{ /* (V10.31) SCENE */
uint32_t i;
memset(p->scene, 0, sizeof p->scene);
@@ -2002,6 +2007,8 @@ static uint32_t autosave_sig(void)
h = as_mix(h, &scn_on, 1);
h = as_mix(h, scn_role, sizeof scn_role); /* (V10.31) SCENE */
h = as_mix(h, scn_pat, sizeof scn_pat);
h = as_mix(h, eq_v, sizeof eq_v); /* the master's EQ and TAPE (an EQ change alone: */
h = as_mix(h, tape_v, sizeof tape_v); /* autosaved, RESTORE LAST gives it back) */
return as_mix(h, proj_name, sizeof proj_name);
}
+2 -1
View File
@@ -5,7 +5,7 @@
* storage layer's A/B protection; the four sections and index are NOT one atomic transaction. On an
* interrupted overwrite the source remains available to retry the complete copy. */
/* Normalize a source section into proj_wire, including current song-wide globals. 0 empty, 1 ready,
/* Normalize a source section into proj_wire, including current song-wide globals (and the master EQ, TAPE). 0 empty, 1 ready,
* -1 cannot serialize. song_keep holds the unsaved live section for the duration of this operation. */
BTAPP_FN static int song_copy_section(uint32_t section, uint32_t current, const char *name)
{
@@ -19,6 +19,7 @@ BTAPP_FN static int song_copy_section(uint32_t section, uint32_t current, const
for (uint32_t i = 0; i < G_COUNT; i++)
p->g[i] = mom_base(MOM_G, i, song.g[i]);
p->g[G_DJF] = mom_base(MOM_G, G_DJF, motion_djf_value());
proj_master_put(p); /* the master's EQ and TAPE, song-wide too */
if (song_save_loop) chain_defaults(&p->chain); else p->chain = chain_config;
p->chain.rsv[1] = 0; /* saved sections belong to the player, not GEN */
p->chain.rsv[2] = SONG_MODE_TAG | (!song_save_loop && live.mode ? 1u : 0u);
+1
View File
@@ -41,3 +41,4 @@ seqtick/live 89
seqtick/plain 79
song/cputest 2981
song/cputest.djf 3063
song/cputest.eq 3221
+4
View File
@@ -20,6 +20,7 @@
* seqtick/live .. every track under GLO > LIVE's modifiers (seq_live.c: x2, a LOOP of 4, REV, THIN 30 %, GIRO +1)
* song/cputest SAVE > TOOLS 6 CPU TEST's song (song_dice.c cpu_test_song), playing: what the device is measured on
* song/cputest.djf (0.9.1) .. with the master DJ FILTER on (GLO > MIXER KNOB 4 at -24, a low-pass): its cost on top
* song/cputest.eq (p9) .. with the master's EQ on (FX > EQ, the four bands 6 -3 3 -6 dB): its cost on top
* mix/idle (0.9.9 ctl64) nothing sounding, stopped: the fixed cost of a block (the events, the split, the buses,
* the buffers, the master)
* seq/mono4 (0.9.9 ctl64) four MONO tracks (ANALOG FM6 VOICE WHEEL) at 1/16, 150 BPM, one note a step, each
@@ -270,6 +271,9 @@ int main(void)
song.g[G_DJF] = -24; /* (0.9.1) the same song through the DJ FILTER (a low-pass, ~1.4 kHz) */
vg_section("song/cputest.djf");
song.g[G_DJF] = 0;
eq_v[0] = 6; eq_v[1] = -3; eq_v[2] = 3; eq_v[3] = -6; /* (p9) .. through the master's EQ, every band off 0 */
vg_section("song/cputest.eq");
eq_v[0] = eq_v[1] = eq_v[2] = eq_v[3] = 0;
{ /* (cpu5) the idle floor: mix/idle the power-on state 2 s on, nothing played (the buses never excited: cpu4's
* certificates); mix/idle.tail after a chord into CLOUD, the delay and the chorus has rung out and the buses'
* gate has shut (fx.c fx_rest), 6 s after the keys went up (the delay's FEEDBK holds the gate ~4 s) */
+70
View File
@@ -0,0 +1,70 @@
/* SPDX-License-Identifier: GPL-3.0-only */
/* The master's EQ and TAPE (params.c eq_v tape_v) through the save flows (Discord: "saving a project resets the
* master EQ; sometimes it won't remember it on loading"). */
static void eq_set(int a, int b, int c, int d) { eq_v[0] = (int16_t)a; eq_v[1] = (int16_t)b; eq_v[2] = (int16_t)c; eq_v[3] = (int16_t)d; }
static int eq_is(int a, int b, int c, int d) { return eq_v[0] == a && eq_v[1] == b && eq_v[2] == c && eq_v[3] == d; }
static int eq_save_test(void)
{
int bad = 0, ok;
/* a song of four sections stored flat, the music on C, then the EQ set (and TAPE) */
song_fixture();
eq_set(0, 0, 0, 0); tape_v[0] = tape_v[1] = 0;
for (uint32_t s = 0; s < 4; s++) section_store(s);
section_load(2);
eq_set(5, -3, 0, 12); tape_v[0] = 40; tape_v[1] = 7;
ok = !song_save_as(song_cur, "EQ SONG");
bad += check("EQ: SAVE SONG AS over the open project: the live EQ and TAPE kept", ok && eq_is(5, -3, 0, 12) && tape_v[0] == 40 && tape_v[1] == 7);
ok = !song_open(1) && eq_is(5, -3, 0, 12); /* SAVE > PROJECT's KNOB 1: the music stays */
eq_set(0, 0, 0, 0); tape_v[0] = tape_v[1] = 0;
ok &= !song_select(0);
bad += check("EQ: the saved project loaded again (section A): its EQ and TAPE", ok && eq_is(5, -3, 0, 12) && tape_v[0] == 40 && tape_v[1] == 7);
ok = 1;
for (uint32_t s = 0; s < 4; s++) {
eq_set(0, 0, 0, 0);
ok &= !section_load(s) && eq_is(5, -3, 0, 12);
}
bad += check("EQ: every section of it holds the master's EQ (a section change keeps it)", ok);
ok = !song_open(2) && eq_is(5, -3, 0, 12); /* another (empty) project picked: the music, its EQ, stays */
ok &= !song_select(0) && eq_is(5, -3, 0, 12);
bad += check("EQ: another project picked, then this one loaded: the EQ as saved", ok);
/* a section saved alone (SAVE > PROJECT's slot) and loaded; UNDO; NEW PROJECT */
eq_set(-2, 4, -6, 8);
ok = !project_save_as(1, "B") && eq_is(-2, 4, -6, 8);
eq_set(1, 1, 1, 1);
undo_mark();
project_load(1);
ok &= eq_is(-2, 4, -6, 8);
ok &= !undo_do() && eq_is(1, 1, 1, 1); /* UNDO: the EQ before the load .. */
ok &= !undo_do() && eq_is(-2, 4, -6, 8); /* .. and again: the loaded one */
bad += check("EQ: a section saved and loaded; UNDO over the load and back", ok);
system_init();
bad += check("EQ: NEW PROJECT (INIT SYSTEM): flat, TAPE out", eq_is(0, 0, 0, 0) && !tape_v[0] && !tape_v[1]);
/* RESTORE LAST: an EQ / TAPE change alone is music the autosave keeps (autosave_sig) */
reset();
ui_prefs |= PREF_RESTORE_ON;
as_power_on();
eq_set(0, 0, 0, 0); tape_v[0] = tape_v[1] = 0;
autosave_boot(1);
as_edit(0);
as_run(20000u);
{
uint32_t w = as.writes;
eq_set(-4, 2, 6, -12);
as_run(80000u);
ok = as.writes == w + 1u;
w = as.writes;
tape_v[1] = 9;
as_run(80000u);
ok &= as.writes == w + 1u;
}
bad += check("EQ: an EQ change alone autosaved, a TAPE change alone too", ok);
as_power_on();
eq_set(0, 0, 0, 0); tape_v[0] = tape_v[1] = 0;
ok = autosave_boot(1) == 1 && eq_is(-4, 2, 6, -12) && tape_v[1] == 9;
bad += check("EQ: power-on (RESTORE LAST): the EQ and TAPE as left", ok);
eq_set(0, 0, 0, 0); tape_v[0] = tape_v[1] = 0;
ui_prefs &= ~PREF_RESTORE_ON;
return bad;
}
+2
View File
@@ -476,6 +476,7 @@ static int songs_test(void)
#include "fit_storage_cases.h"
#include "voice_user_cases.h"
#include "split_storage_cases.h"
#include "eq_save_cases.h"
#ifndef PERSISTENCE_TEST_NO_MAIN
int main(void)
@@ -850,6 +851,7 @@ int main(void)
bad += fit_storage_test();
bad += voice_user_test();
bad += split_storage_test();
bad += eq_save_test();
{
static project_store_t follow_store;
song.playing = 0; transport_req = 0; chain.armed = chain.running = 0;
+1
View File
@@ -35,6 +35,7 @@ FUNCS = ["analog_render", "digital_render", "digital_render_legacy", "digital_re
"string_render", "add_render", # (0.9.9-snd5) STRING (its loop at 1 / 2^d), ADD (nine partials)
"formant_word_render", "formant_block", # (JIANT 0.8.5) VOICE singing words (eng_formant.c, sing.c)
"djf_block", # (0.9.1) the master DJ FILTER (fx.c), while it is off the middle
"eq_block", # (p9) the master EQ (fx.c), while a band is off 0
"track_comb", "tf_run", "tf_ms20"] # (0.9.9-snd1) the FILTER after the voices: COMB / COMB-, the SVF, MS20
# built only with FELUCCA_FM4=1 (DIGITAL, src/eng_digital.c; not in the default build, so not in BUDGET): absent,
# they are skipped; present, checked against these (their budget lines until the engine was retired in 1.0)
+1
View File
@@ -49,6 +49,7 @@ add_render 297
formant_word_render 553
formant_block 99
djf_block 199
eq_block 355
track_comb 115
tf_run 124
tf_ms20 94
+1695 -1694
View File
File diff suppressed because it is too large. Load diff