diff --git a/docs/MODULATION-SONG-BETA.md b/docs/MODULATION-SONG-BETA.md index 8b976af4..87af499e 100644 --- a/docs/MODULATION-SONG-BETA.md +++ b/docs/MODULATION-SONG-BETA.md @@ -5,20 +5,22 @@ Only the preview installer is intended to receive this candidate after target ch ## Song generator -GEN 1 now displays the actual arrangement when it exists: sections, bar lengths, +All three GEN pages display the actual arrangement when it exists: sections, bar lengths, current row, remaining bars and play position. The display refreshes at bar boundaries. A generated SONG can have 16- or 32-bar sections, so hearing the same phrase for several bars does not itself mean the arranger is stuck. -SAVE from GEN opens SAVE SONG AS. Choose a destination project, confirm an -existing destination if needed, then name it. This uses the existing complete -song save path: sections A–D, arrangement, scenes and per-track source/variation -metadata are copied together. Stop playback before saving. +SAVE from GEN opens SAVE SONG AS. Choose LOOP or SONG and a destination project, confirm an +existing destination if needed, then name it. SONG copies sections A–D, arrangement, +scenes and per-track source/variation metadata. LOOP writes the current music to A, +clearing B–D and the arrangement at that destination. The current project can be +overwritten explicitly. Stop playback before saving. -If A–D contain protected user sections, PARTS/SONG generation now refuses before -changing the music or clearing the arrangement. It reports A-D SAVED / USE AN -EMPTY PROJECT. Previously the guard ran after making a loop and clearing the -arrangement, which could silently leave a requested SONG as a loop. +GEN now uses a RAM draft; saved A–D no longer block generation. Subsequent +generations do not overwrite saved projects. MAKE during playback stops, +regenerates and resumes the new draft. Projects and individual sections can be +erased explicitly from SAVE. See [draft and save behavior](GENERATOR-DRAFT-SAVE.md) +for the complete flow and persistence limits. Explicit SONG/LOOP mode is restored from the existing tagged project index field; legacy projects without the tag retain their default behavior. @@ -58,9 +60,8 @@ is displayed as IN ENV to distinguish it from track envelopes. sources selectable without trying to stack 24 source labels on the screen. - Loading a project clears previous track envelope state. -Decorative pseudo-note previews are replaced with density bars. This reduces -display work and flash use -without removing sound controls or the actual arrangement display. +Decorative pseudo-note previews are replaced by real stored sections or the +actual arrangement on every GEN page, without removing sound controls. No existing matrix source was removed. No new step-component opcode is added: the existing component encoding is full. Resonance was not appended as a matrix @@ -69,9 +70,9 @@ destination because the existing 32-bit destination masks are now full. ## Validation Host checks cover generated parts across 45 genre choices, traversal through all -six arrangement rows and wrap, real playhead invalidation, SAVE entry, protected -sections and saved playback mode. Separate NOR/persistence tests cover complete -song saves, rollback and round-tripping the new matrix IDs. +six arrangement rows and wrap, real playhead invalidation, SAVE entry, regeneration +during playback and saved playback mode. Separate NOR/persistence tests cover both +save scopes, draft preservation, failure/retry, erase and round-tripping matrix IDs. The matrix tests cover inactive INPUT, ended FM6 ENV2, cutoff mappings, restored parameters, silent tracks, opposite-polarity stereo signals, one-block snapshots, diff --git a/firmware/src/song_main.c b/firmware/src/song_main.c index 2fcd3604..e94760b8 100644 --- a/firmware/src/song_main.c +++ b/firmware/src/song_main.c @@ -410,6 +410,7 @@ static int song_draft_begin(void) song_save_target = song_cur; } song_draft = 1; + dice_secs = 0; live.dirty = 0; live.cur = live.req = -1; sec_stage.ready = 0; proj_cur = PROJ_NO_SLOT; proj_name[0] = 0; memset(proj_slot, 0, sizeof proj_slot); diff --git a/firmware/src/ui.c b/firmware/src/ui.c index af42cd4a..6f8c1622 100644 --- a/firmware/src/ui.c +++ b/firmware/src/ui.c @@ -2017,6 +2017,8 @@ static int act_ready(void) return c == 3u ? !song.playing : up_used(ui.uslot) && (c == 1u || !song.playing); if (cur_page()->graph == GR_SLOTS && c == 1u) /* (V10.17) SECTIONS: ERASE a stored section, stopped */ return !transport_busy() && (save_level() == SV_LIB || project_used((uint32_t)song.g[G_SLOT] - 1u)); + if (cur_page()->graph == GR_SLOTS && c == 2u && save_level() == SV_LIB && song_draft) + return !transport_busy(); id = cur_page()->id[c & 3u]; if (id == G_LOAD) return project_used((uint32_t)song.g[G_SLOT] - 1u); diff --git a/firmware/src/ui_draw.c b/firmware/src/ui_draw.c index 963d35b1..26670b1f 100644 --- a/firmware/src/ui_draw.c +++ b/firmware/src/ui_draw.c @@ -1660,7 +1660,7 @@ static void draw_columns(void) hot_gauge_column(0, "PROJECT", val, (int32_t)(song_draft ? song_save_target : song_cur) * 1000 / (int32_t)(NSONG - 1u)); draw_act_column(1, "ERASE", T_THEME, ICON_AUTO); } - draw_act_column(2, "LOAD", used ? T_THEME : T_DIM, ICON_AUTO); + draw_act_column(2, "LOAD", used || (save_level() == SV_LIB && song_draft) ? T_THEME : T_DIM, ICON_AUTO); draw_act_column(3, "SAVE", T_THEME, ICON_AUTO); return; } diff --git a/tests/song_generator_test.c b/tests/song_generator_test.c index 78b09d59..194bdd97 100644 --- a/tests/song_generator_test.c +++ b/tests/song_generator_test.c @@ -81,6 +81,12 @@ int main(void) nav_put(SEC_SAVE,"SAVE SONG AS");frame();turn(EN_K2,1);frame(); bad += check("SAVE scope selects LOOP without changing the live song", song_save_loop && chain_config.count>=4); song_save_loop=0; + seq_stop(); song_poll(); + gp.form = 0; gen_go(); + bad += check("SONG to LOOP generation leaves only draft A and no old arrangement", + song_draft && !live.mode && !chain_config.count && dice_secs == 1 && project_used(0) && + !project_used(1) && !project_used(2) && !project_used(3)); + gp.form = 2; gen_go(); /* Draft arrangements intentionally do not overwrite the saved boot index. */ song_draft=0;song_poll(); live.mode=0;song_index_boot(); diff --git a/tests/song_save_ui_cases.h b/tests/song_save_ui_cases.h index 211b8b22..e3cd55ec 100644 --- a/tests/song_save_ui_cases.h +++ b/tests/song_save_ui_cases.h @@ -54,5 +54,33 @@ static int test_song_save_ui(void) ui.force = 1; frame(); } + ui_power_on(); + nav_put(SEC_SAVE, "SAVE SONG AS"); frame(); + turn(EN_K2, 1); frame(); + song_idx.rows[song_save_target].count = 1; + press(B_OCTUP); frame(); + confirm_text(a, b); + bad += check("LOOP overwrite explains replacement of A and clearing B-D", + song_save_loop && ui.confirm == CF_OVR_SONG && strstr(b, "CLEAR B-D") != 0); + press(B_OCTDN); frame(); + ui_power_on(); + song_draft = 1; song_save_target = song_cur; + nav_put(SEC_SAVE, "PROJECTS"); frame(); + target = song_cur; + turn(EN_K1, 1); frame(); + bad += check("PROJECTS destination browsing preserves the playing draft buffers", + song_draft && song_cur == target && song_save_target == target + 1u); + turn(EN_K3, 1); frame(); + bad += check("PROJECTS LOAD availability depends on transport, not the draft's selected part", act_ready()); + turn(EN_K2, 1); press(B_OCTUP); frame(); + bad += check("PROJECTS ERASE targets the selected saved project and can be cancelled", + ui.confirm == CF_ERASE_SONG && ui.confirm_trk == song_save_target); + press(B_OCTDN); frame(); + song.playing = 1; + turn(EN_K2, 1); press(B_OCTUP); frame(); + bad += check("PROJECTS ERASE refuses during playback without discarding the draft", + !ui.confirm && song_draft && strstr(ui.msg, "STOP TO ERASE") != 0); + song.playing = 0; + song_draft = 0; return bad; } diff --git a/tools/build.py b/tools/build.py index 06c45b36..585a3835 100644 --- a/tools/build.py +++ b/tools/build.py @@ -297,7 +297,7 @@ def late_fns(): # REC arming is UI-only; keep its undo checkpoint out of the pinned DSP gaps. names = {"rec_tap", "ly_keyname", # Only the overflowing UI gaps move: keep all audio addresses pinned without wasting large holes. - "fm1_irq_on", "large_kind", "draw_confirm", "vx_analog", "toast_clear"} + "fm1_irq_on", "large_kind", "draw_confirm", "vx_analog", "toast_clear", "draw_text_box"} for f in LATE_SRC: names |= set(re.findall(r"^static [^;=()]*?\b(\w+)\((?![^)]*\)\s*;)", (FW / "src" / f).read_text(), flags=re.M)) return names