diff --git a/.github/workflows/voice-user-check.yml b/.github/workflows/voice-user-check.yml index d5525411..fa2a5ecb 100644 --- a/.github/workflows/voice-user-check.yml +++ b/.github/workflows/voice-user-check.yml @@ -45,6 +45,8 @@ jobs: run: | cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/song_generator_test.c -lm -o build/song-check/generator build/song-check/generator | tee build/song-check/generator.log + cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/song_draft_test.c -lm -o build/song-check/draft + build/song-check/draft | tee build/song-check/draft.log - name: Matrix and track follower regression run: | cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/mod_test.c -lm -o build/song-check/mod diff --git a/docs/GENERATOR-DRAFT-SAVE.md b/docs/GENERATOR-DRAFT-SAVE.md new file mode 100644 index 00000000..db3e0813 --- /dev/null +++ b/docs/GENERATOR-DRAFT-SAVE.md @@ -0,0 +1,39 @@ +# Generated songs and explicit project saves (ADD beta) + +GEN works in a RAM draft. Existing A–D sections do not prevent generation. +The first generation checkpoints pending saved-project sections and its index, +then borrows the existing four section buffers. Further generations, section +edits and idle autosave do not write that draft over a saved project. + +MAKE can regenerate while playback runs: transport stops, the next draft is +generated, and playback resumes in the new draft's mode. This is not a gapless +transition. GEN 1, 2 and 3 all show real sections and arrangement progress. + +SAVE > SAVE SONG AS selects a destination and SCOPE: + +- SONG saves A–D and the complete arrangement, scenes, track sources and variations. +- LOOP saves the currently loaded music in A and clears B–D and the arrangement + at that destination. + +The current project is a valid destination. Occupied destinations require an +overwrite confirmation, then naming. Saving requires stopped transport. Saving +keeps the draft available for more generations; power-off discards an unsaved +draft. SAVE > PROJECTS selects saved destinations without loading them during a +draft; LOAD opens the selected saved project and discards the draft. + +SAVE > PROJECTS > ERASE clears all saved parts and arrangement at the selected +destination after confirmation. SAVE > SECTIONS > ERASE clears the selected +part and removes arrangement rows referencing it, including per-track sources. +Erasing a draft part is RAM-only. Erasing a saved destination does not erase +the active draft. + +Each storage object retains its existing A/B commit protection. A multi-part +save or erase is not atomic across all four parts and the index: retry an +interrupted operation. Failed saves retain the draft for retry. No flash map, +loader, project format or audio buffer changes are involved. + +Validation: native NOR tests cover source preservation, both scopes, same-project +overwrite, failure/retry, project erase and dependent-row cleanup. Generator UI +tests cover 45 genre choices, distinct parts, playback traversal, regeneration +during playback and all GEN pages. Target memory checks and the ordinary pinned +audio layout must pass before publication. This release goes to beta only. diff --git a/firmware/src/felucca.c b/firmware/src/felucca.c index 63136d22..ba4b3806 100644 --- a/firmware/src/felucca.c +++ b/firmware/src/felucca.c @@ -44,7 +44,7 @@ #define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */ #endif #ifndef FELUCCA_VERSION -#define FELUCCA_VERSION "V10.6c-matrix" /* (2026-11-03) V10.61: PROX tuned (the user: it works with the phone, but the phone had to go far away for PROX to let go; a narrower field, a quicker response): the PROX page's KNOB 1 MIN (0 .. 90 %: under it PROX is 0), KNOB 2 MAX (100 .. 10 %: over it PROX is full), both over the calibrated FAR .. NEAR, 10 % apart at least; KNOB 3 SPEED 1..5 (the level's smoothing 1/32 as before .. 1/2: quicker, noisier); saved as FAR / NEAR; 0, 100 and 1 as V10.60. (2026-11-03) V10.60: room (the user's ask): the conversion of DIGITAL's sounds to FM6 (fm4_convert.c) and the read of JIANT 0.1-0.5's projects (FUNB..FUN7, project.c proj_unpack) moved into the Bluetooth segment (without it: a DIGITAL sound loads as the FM6 factory preset that covers it, those old projects are not read); the app slot 4.3 KB free (was 0.8), the segment 2.7 KB; BTAPP_FN / BTAPP_RO in core.h. (2026-11-03) V10.59: FX > RPT 1/8 at slow tempos (the user: dimmed at 61 BPM): a REPEAT longer than the loop at 22 kHz (371 ms) records at 11 kHz, lo-fi (the effect's), up to 742 ms: 1/8 from 41 BPM (was 81), 1/16 from 21 (was 41); the faster ones as before, bit for bit. (2026-11-03) V10.58: users' reports: the master EQ (and TAPE) went back to flat on its own (going to GLO's pages, since V10.44): every read of a stored project or section (a slot checked, a section listed) set the EQ and TAPE playing; they now live in the project read and are applied only when it is loaded; MENU in BOTTOM and HUD showed its four cards under the panel (a blank band over it): the panel right under the tabs there, the cards at the foot as on every page of theirs; AIR's HOME: the beings swim under its cards (they crossed the tabs and the values); FX > EQ with SCOPE ON: the master's scope behind the curve. (2026-11-03) V10.57: USB > HOST takes an audio interface at 48 kHz too (the user's OP-Z, and the many interfaces with no 44,100): set to 48,000 when it has no 44,100, read at the I2S clock from a step of 48 / 44.1 (the reader's interpolation, its drift steering as before); packets of up to 50 frames taken. (2026-11-03) V10.56: USB IN+OUT no longer mixes the computer's or the phone's audio into the last track by itself (the user: recording from KOALA with IN+OUT on looped into a digital feedback, the app sending the FM-1's own output back): the input sounds where an INPUT track takes it; STEMS+IN keeps its own stem as before. (2026-11-03) V10.55: GEN's sounds right again: V10.42 replaced FM6 presets 8..12 and 14 and WHEEL 5, 6, and GEN still picked them by number for its roles (a SUB BASS played the bells, leads the electric pianos and plucks, a pedal bass the organs): its BELL EP PLUCK STRINGS SINE KEYS ORGAN DUB CHORD and KEYS take today's nearest (BELL MARIMBA TINE EP PLUCK PAD WAVE ORGAN GOSPEL JAZZ PERC); INPUT's meters keep FOLLOW's frame with the input silent; the host tests brought up to date with the UI (the DJ FILTER on LIVE > MANO, the roll's 13 px columns, INPUT in the engine lists). (2026-11-03) V10.54: the INPUT engine (the user's ask: the audio input routed, the track in an audio mode, an envelope follower): engine 15 plays the USB audio input (an interface on HOST, or the computer's USB IN+OUT) on its track: SOURCE IN 1 / IN 2 / 1+2 / STEREO (two tracks can take IN 1 and IN 2; STEREO keeps the image through the part's chain as IMAGE does), GAIN, GATE, PLAY THRU / KEYS (only while a note plays, at its envelope: a trance gate from the steps), WIDTH, RING (KEYS: a sine at the note), BITS, RATE; the track's FILTER DIST LEVEL PAN sends as any part's; EDIT INPUT shows both inputs' meters, GATE's level and FOLLOW; while a track is INPUT the last track's IN+OUT mix steps aside; MOD SRC FOLLOW, the input's envelope, on any track and any destination. (2026-11-03) V10.53: USB > HOST takes an audio interface too, an experiment (the user's ask: a USB audio input into the synth): a class compliant USB audio 1.0 capture (16-bit, mono or stereo, 44,1 kHz among its rates: Behringer UM2 / UCA and the like), alone or behind a powered hub, set to 44,1 kHz (SET_CUR) and read each frame (isochronous IN) into IN+OUT's ring: it plays through the last track (its LEVEL PAN and sends, as USB IN+OUT's host audio); usb_host_desc.h uh_parse_uac, tested; not yet on hardware. (2026-11-03) V10.52: a synth's STEREO page shows IMAGE at work (the user: no visual feedback): the field L .. R, each voice sounding a blob at its place, its size its level now, its note over it (IMAGE 0: the notes in a row), the silent ones a tick where they would sit, the span IMAGE opens as a bar. (2026-11-03) V10.51: the roll follows the playhead for real (the user: V10.47's did not): the bar playing was chosen in the roll's drawing, and a playhead out of the bar shown changed nothing the panel's redraw looks at (graph_signature): never drawn, never followed; now chosen there. (2026-11-03) V10.50: the user's fixes to V10.49: a synth's STEREO IMAGE its own parameter (P_SIMG, the lane-1 level's slot, stored inverted: every part's 127 = 0 %; on VOICE V10.49's showed and moved LYRIC, the slot VOICE uses), its own STEREO page; EDIT's order: the sound's pages first, VOICE and VOICE 2 last in a group of their own (SOUND TONE FOCUS VOICE; FM6: SOUND TONE OPS VOICE). (2026-11-03) V10.49: users' asks: FX > DLY 3 KNOB 4 R TIME, the right echo its own time as a ratio of TIME (=L as before, x1/2 x2/3 x3/4 x4/3 x3/2 x2; not with PING-PONG or the grains; saved, project block DR); EDIT > STEREO IMAGE on synth parts in POLY: each voice its own place across the stereo field (DRUM-X's way: what each side gives up, through the part's filter, narrowed by DIST), the page shows the eight voices' places. (2026-11-03) V10.48: room: LOFI's, ANIMAL's and STRING's creatures (ui_engvis.c, ~6 KB) moved into the Bluetooth segment (without it: the being, as other engines); the app slot ~6 KB free again, the segment ~7 KB. (2026-11-03) V10.47: the roll and the drum grid follow the playhead (a user's ask): while it plays and nothing was touched for 3 s, the bar shown is the one playing; a key or a knob holds it 3 s. (2026-11-02) V10.46: a safe start (reports of FM-1s that stay dark after installing; the cause not known): a start that hangs between the supply setup (V10.11, hal/fm1_power.h) and the UI is reset by the watchdog, and the next start skips that setup (the boot loader's supplies, as up to V10.10) until the power goes off, and says SAFE START. (2026-11-02) V10.45: LIVE > MANO KNOB 4 the DJ FILTER again (a user's report: V10.37 turned it into the tempo, MIXER's new KNOB 4); EDIT > MORPH on ANALOG PWM SYNC RING SAW3 PLS3 draws the wave as MORPH bends it (the user: a ramp), in the Bluetooth segment. (2026-11-02) V10.44: the rest of the mock-up's pictures, in the Bluetooth segment (the app slot full; without the segment the page keeps its old picture): FX > MASTER > EQ the four bands' curve (LOW / HIGH shelves, the mids bells, a dot each, 60 250 2K 8K); GLO > SYSTEM 2 the three ports as boxes (USB TRS BT, their state), a light each way flashing as MIDI passes, PROX's bar when Bluetooth is linked or in AIR; LEVELS' picture moved there too. (2026-11-02) V10.43: pictures that show what the page does (the user's picks from the mock-up): EDIT > LEVELS / LEVELS 2 a column a DRUM-X sound, its LEVEL the height, lit as it plays, the page's four framed (was the scope); FX > MASTER the CLIP curve (in -> out, the level now a dot), PUNCH's push as a bar, the duck's gain now a line over its curve; FX > PUNCH the lane 16 steps a row, every step a box, a recorded one its punch's colour, the playhead framed (an empty lane drew nothing). (2026-11-02) V10.42: the factory presets less alike, the basics there (the user's ask): FM6's seven near copies (ICE BELL DX KEYS FM PLUCK SOFT BELL FM STRINGS WOOD, the first eight bent a little) are other instruments through the macros: FM LEAD SQR LEAD SAW LEAD, SLAP BASS SUB BASS, BELL PAD (program numbers kept, HARD BASS stays); WHEEL PEDAL BASS and DRIVE LEAD where DUB ORGAN and SOFT KEYS were; LOFI PULSE BASS appended. (2026-11-02) V10.41: MENU > SYSTEM > USB > HOST (a user's ask, an experiment): the port as the host of a class compliant USB-MIDI keyboard or controller, alone or behind a hub, what it plays in as USB-MIDI (CLK USB+BT, LEARN, MAP alike); Melodee's host (usb_host.c, recursivefieldinstruments' enumeration), input only, its main-loop side in the Bluetooth segment (the app slot full); never saved (every power-on a device); the port is not powered: a keyboard on its own power or a powered hub. (2026-11-02) V10.40: the editor sees a mode's own knobs (ANALOG SAW3 / PLS3 INT 3 -24..24, STRING FDBK's, NOISE LFSR's: editor.c ed_tdesc as the panel, a WAVE / EXCITE set from the editor resets the knobs that change meaning, the page re-reads them); HOME's lazy redraw mends a missed cell within ~10 s (a strip's n / 128 + 1 cells sent anyway a frame, was one: up to ~95 s on HOME's panel; ~4 % more sent). (2026-11-02) V10.39: ANALOG SAW3 and PLS3, each oscillator its own interval (the user's ask): NOISE's knob (EDIT 1 KNOB 4) reads INT 3 there, osc 3's interval in semitones (-24..24; INT stays osc 2's), no noise in those two WAVEs (every factory SAW3 has NOISE 0: the same sound); turning WAVE into or out of them sets that knob to 0. (2026-11-02) V10.38: intervals in tune at random (the user: GEN's ANALOG sounds took a random INT, the song out of tune): whatever chooses an engine's interval by chance (GEN and EXPLORE, the sound dice EDIT + SELECT) picks 0, a fourth, a fifth or an octave, up or down (ANALOG INT, VOICE SHIFT; GEN keeps a preset's, snapped to the nearest: GLASS KEYS' 19 kept); the random macros never aim at an interval. (2026-11-02) V10.37: GLO > MIXER KNOB 4 BPM (the DJ FILTER on LIVE > MANO), GLO's pages LIVE MIX COMPS GLOBAL SYSTEM; Bluetooth named where MIDI is (the user's ask): GLOBAL > CLOCK reads USB +BT (USB's source follows Bluetooth's clock too), GLO > SYSTEM 2 KNOB 3 shows BT's state (OFF, ADV, CONN n, AIR) beside USB and TRS IN. (2026-11-02) V10.36: LFO WAVE DRIFT (a user's ask, ambient drones and pads that breathe): a smooth random wander, each cycle a new value within half the range of the last, reached on a smoothstep (no step, no corner; with RATE 4BAR..16BAR a slow drift); the factory pads breathe by themselves (BREATHE in the presets' spare byte: DRIFT on FILTER, some a little on PITCH, over 4 or 16 bars): ANALOG SOFT PAD STRINGS JUNO PAD DARK PAD, FM6 PAD FM STRINGS, PHASE GLASS PAD VOX PAD, NOISE HISS PAD, LOFI CHIP PAD. (2026-11-02) V10.35: MENU > SYSTEM > BLUETOOTH AIR, an experiment: the radio listens instead of advertising (passive scan, nothing sent, no MIDI) and every Bluetooth packet heard around (phones, watches, headphones, TVs) feeds PROX: a body near the antenna shadows them, PROX's page and the MS_PROX source as with a phone (Optimist's scanner, fm1-base 4039a8b, minimal central level 3, in the segment: 56 KB of 72). (2026-11-02) V10.34: DRUM-X kit HIP HOP (a user's ask: boom bap, a round kick with a knock, a fat cracking snare, a tight clap, dusty band-passed hats, a woody rim, a shaker in the BELL's place) and the pattern BOOM BAP it suggests (SEQ > PATTERNS 14). (2026-11-02) V10.33: the MIDI clock steady. Out (MIDI OUT CLOCK / ALL): each of the 24 pulses at its own sample, sent at its own time (USB: usb.c ep1_tx holds it to its TIMER4 tick; Bluetooth: stamped with it), no longer a burst each 2.9 ms render, and no rounding in the pulse length (a follower read 105.1 for 104). In (CLK USB / TRS, Bluetooth too): the tempo over two beats, smoothed, a whole BPM held within 0.6 (it was six pulses raw: 103 105 104..), the interpolation at the steady tempo. (2026-11-02) V10.32: Bluetooth MIDI pairs: Just Works (no PIN) with bonding and the link encrypted when a central asks (Windows, some Macs and Androids refused "Pairing Not Supported" before); the bond's key made again from EDIV / Rand (bt/ble ble_smp_ltk_of), nothing stored, every bonded computer back after a power-off; Optimist's AES / CCM (ble_aes.c, fm1-base 4039a8b) in the Bluetooth segment (51 KB of its 72). (2026-11-02) V10.31: EUCLID reversible: the sequence it took is kept whole (the last track taken, 1.5 KB in RAMTEXT's room: notes, chords, velocities, components, micro), put back when its settings are at rest again (VARY and MODES 0, its own rhythm) or HITS / DENSITY go to 0; another track's taken since: its rhythm and notes come back from what EUCLID took. SCL > SCENE kept with the project (FUNC 'S' 'C': ON and the six roles; none: OFF, all KEEP). (2026-11-02) V10.30: flash by hand: a parameter card in one place (pf_column: eleven cards of ui_draw.c), "a/n" in one place (fmt_frac: eight); every screen pixel for pixel as before (9250 renders hashed): ~0.6 KB more free. (2026-11-02) V10.29: flash: the files added since 0.9.7 (EUCLID, SCENE, LIVE, MIDI LEARN, the song player, PERFORM, PLAYHEADS, SLICER) and the engines' main-loop side built for size (tools/size_fns.py; what the interrupts reach keeps -Os): ~1.8 KB more free, the sound as it was. (2026-11-02) V10.28: EUCLID starts at 0 (no HITS, no DENSITY, MODES and VARY 0: built from nothing); a sequence the track has (recorded, edited, a song's; not a factory pattern) is transformed: its rhythm and holds until HITS STEPS or ROTATE are turned, its notes always (a kit: its lanes); VARY in two halves: up to 50 the one cycle moved, each value its own (one hit at least), above 50 the four turns A A' A'' B. (2026-11-02) V10.27: testers' fixes: the CHORD page no longer writes VOICING LEAD's last chord (a key played another inversion after the page was shown: chord_peek); MENU: KNOB k edits its card's row (all four edited the selected row); TAPE WOW wobbles like a warped record (a smoothed random drift, ~+-45 cents at 100; its noise source was stuck at 0: the hiss and drift were dead); slower: LFO RATE 8BAR 16BAR, PLAYHEADS 1/8 1/16, STRUM past 64 up to ~1 s. (2026-11-02) V10.26: SCENE starts with every track KEEP (OFF, as before); OCT+ on SCENE dices the roles (each role one track at most: never two doing the same, never two playing chords), OCT- all KEEP; turned ON with none set, it dices; a role picked by hand that another track has sends that one to KEEP. (2026-11-02) V10.25: SEQ > STRETCH's NUDGE in two modes: OCT- the whole sequence a step (blue, as before), OCT+ the cursor step's MICRO timing (red, 64ths of a step; PRESETS moves the cursor), MICRO back on a knob (a tester's ask). (2026-11-02) V10.24: the user's picks from the redesign mock: SEQ > EUCLID the lanes as concentric rings (heat colours, VARY's turns under the ring); SEQ > MUTATE the anchor above, the pattern playing below (changed steps lit), an arc to the next mutation; SAVE > PRESETS two columns (the engines, their presets), OCT+ keeps the sound browsed to, OCT- brings back the one before; SAVE > TOOLS by scope (KNOB 1 TRACK SOUND SONG SYSTEM, KNOB 2 the action), OCT+ held a second does it (no dialog); SCL > SCENE, the multitimbral mode: one key plays every track given a role (KEEP CHORD ARP BASS LEAD; the kit keeps its sequence), REC records each into its own steps. (2026-11-01) V10.23: STRING FDBK heard (its BLOOM level was applied twice, -15 dB); EXCITE into / out of FDBK keeps each side's EDIT 2 knobs (GAIN no longer starts at STRETCH's 0), FDBK's defaults audible. (2026-11-01) V10.22: testers' asks: ENV > ENV 2 (a second ADSR, MOD SRC ENV2, any DEST), FILTER TYPE LP24 (4 poles), ANALOG WAVE PLS3 (three pulses, SHAPE the width). (2026-11-01) V10.21: EUCLID's lane rows named right (they were one off: ALL's name on BD's row); the ring shows one cycle (the lane's, ALL's, the melody's) and the turn playing, its playhead going round; PROX's page says the phone, not the hand. (2026-11-01) V10.20: PROX smooth: the RSSI reading fixed on word 0 as the level (V10.18's widest range picked a noisy byte: a random sample and hold), the median of nine and ~0.3 s; FAR and NEAR too close (under 4 levels) refused. (2026-10-31) V10.19: the PROX page redraws when a reading arrives (all-zero words left it on NOT CONNECTED) and shows the link as seen: L (link), the RSSI hook's packets / the good packets. (2026-10-31) V10.18: PROX finds the RSSI reading that moves (the four RSSI words of each packet, twelve readings, the widest range on the link; kept once FAR / NEAR is stored), the page shows the four words. (2026-10-31) V10.17: SAVE > SECTIONS KNOB 2 ERASE (the section empty again, RAM and flash; the music stays). (2026-10-31) V10.16: SEQ > EUCLID's VARY in four turns (A A' A'' B, each moved anew, the motif answered); SEQ > MUTATE (EVERY 1..16 bars, AMOUNT, MODE ORBIT / DRIFT / PULSE, WHAT GROOVE / RHYTHM / FEEL / ALL; OCT+ a mutation now, OCT- back to the anchor). (2026-10-31) V10.15: VOICE's English dictionary in the Bluetooth segment (without it: the letter rules). (2026-10-31) V10.14: PROX, a modulation source from the Bluetooth signal (a hand near the antenna), calibrated on MENU > SYSTEM > BLUETOOTH ON + OCT+ (OCT- FAR, OCT+ NEAR). (2026-10-31) V10.13: BLE-MIDI in and out (what a central sends plays as USB-MIDI, MIDI OUT goes to it too); ABOUT's credits in the Bluetooth segment (the app slot had 128 B free). (2026-10-31) V10.12: MENU > SYSTEM > BLUETOOTH OFF / ON: a BLE-MIDI peripheral "JIANT FM-1" (advertising, connectable; MIDI not routed yet), Optimist's stack in the Bluetooth segment at 0xEA000 (written by the update loader from the package's bt.bin), live RF calibration, a boot guard. (2026-10-31) V10.11: the supplies set up as stock V15 does (the DC-DC on, hal/fm1_power.h from Melodee), the radio's prerequisite; 0xEA000..0xFBFFF reserved for the Bluetooth segment. (2026-10-31) V10.10: the radio's calibration kept: the update loader keeps the stock VM sector (0xE8000: RF trims, BT address) but its record's 256 B; VM_READ (editor 80) reads that area for web/btcheck. (2026-10-31) V10.9: MENU > LARGE shows the animations (HOME: the six tracks' creatures in the strip; EDIT: the engine's). (2026-10-31) V10.8: testers' fixes: GEN parts set OFF stay off; GEN keeps its GENRE between visits; SEQ > STEP KNOB 4 VEL (1..127, then ACC SLD A+S); delay 1/4D 1/8D 1/16D; less pitch wobble from the generators (no macro on PITCH, pitched delay seldom, octaves); STOP TO EDIT says SONG PLAYS. (2026-10-31) V10.7: SEQ > EUCLID on a kit: LANE ALL first (DENSITY: a whole usable kit), a lane picked writes that lane alone; EDIT + PRESETS jumps between engines; the kit's SEQ dice plays in every genre; EUCLID's HITS exact (VARY moved them only); REC held alone and let go: UNDO (again: REDO). (2026-10-31) V10.6: SEQ > EUCLID and MODES (a euclidean pattern generator, melodies in the key) in MUTATE's place; MUTATE and SEQ TOOLS' RANDOM COOK BEAT gone. (2026-10-31) V10.5: automation thinned (a recording at the stop, the 64 when full) into holds and RAMPs. (2026-10-31) V10.4: ARRANGE / TIMELINE: OCT- deletes the row picked (DELETE ROW?). (2026-10-31) V10.3: TIMELINE: the lines between lanes soft (the block's colour, darker), the rows' edges stronger. (2026-10-31) V10.2: TIMELINE keeps the black line between lanes (only the rows touch); SAVE composes first: TIMELINE SECTIONS PROJECTS ARRANGE TOOLS USER PRESETS. (2026-10-30) V10.1: TIMELINE blocks fill the lanes (no black gaps between rows or tracks). (2026-10-30) JIANT FM V10: add15-beta6 as the new base (TIMELINE, VAR, ADD, official V16 both ways); the version history before it: the git log of the add15 line (codex/add15-private) */ +#define FELUCCA_VERSION "V10.6c-draft" /* (2026-11-03) V10.61: PROX tuned (the user: it works with the phone, but the phone had to go far away for PROX to let go; a narrower field, a quicker response): the PROX page's KNOB 1 MIN (0 .. 90 %: under it PROX is 0), KNOB 2 MAX (100 .. 10 %: over it PROX is full), both over the calibrated FAR .. NEAR, 10 % apart at least; KNOB 3 SPEED 1..5 (the level's smoothing 1/32 as before .. 1/2: quicker, noisier); saved as FAR / NEAR; 0, 100 and 1 as V10.60. (2026-11-03) V10.60: room (the user's ask): the conversion of DIGITAL's sounds to FM6 (fm4_convert.c) and the read of JIANT 0.1-0.5's projects (FUNB..FUN7, project.c proj_unpack) moved into the Bluetooth segment (without it: a DIGITAL sound loads as the FM6 factory preset that covers it, those old projects are not read); the app slot 4.3 KB free (was 0.8), the segment 2.7 KB; BTAPP_FN / BTAPP_RO in core.h. (2026-11-03) V10.59: FX > RPT 1/8 at slow tempos (the user: dimmed at 61 BPM): a REPEAT longer than the loop at 22 kHz (371 ms) records at 11 kHz, lo-fi (the effect's), up to 742 ms: 1/8 from 41 BPM (was 81), 1/16 from 21 (was 41); the faster ones as before, bit for bit. (2026-11-03) V10.58: users' reports: the master EQ (and TAPE) went back to flat on its own (going to GLO's pages, since V10.44): every read of a stored project or section (a slot checked, a section listed) set the EQ and TAPE playing; they now live in the project read and are applied only when it is loaded; MENU in BOTTOM and HUD showed its four cards under the panel (a blank band over it): the panel right under the tabs there, the cards at the foot as on every page of theirs; AIR's HOME: the beings swim under its cards (they crossed the tabs and the values); FX > EQ with SCOPE ON: the master's scope behind the curve. (2026-11-03) V10.57: USB > HOST takes an audio interface at 48 kHz too (the user's OP-Z, and the many interfaces with no 44,100): set to 48,000 when it has no 44,100, read at the I2S clock from a step of 48 / 44.1 (the reader's interpolation, its drift steering as before); packets of up to 50 frames taken. (2026-11-03) V10.56: USB IN+OUT no longer mixes the computer's or the phone's audio into the last track by itself (the user: recording from KOALA with IN+OUT on looped into a digital feedback, the app sending the FM-1's own output back): the input sounds where an INPUT track takes it; STEMS+IN keeps its own stem as before. (2026-11-03) V10.55: GEN's sounds right again: V10.42 replaced FM6 presets 8..12 and 14 and WHEEL 5, 6, and GEN still picked them by number for its roles (a SUB BASS played the bells, leads the electric pianos and plucks, a pedal bass the organs): its BELL EP PLUCK STRINGS SINE KEYS ORGAN DUB CHORD and KEYS take today's nearest (BELL MARIMBA TINE EP PLUCK PAD WAVE ORGAN GOSPEL JAZZ PERC); INPUT's meters keep FOLLOW's frame with the input silent; the host tests brought up to date with the UI (the DJ FILTER on LIVE > MANO, the roll's 13 px columns, INPUT in the engine lists). (2026-11-03) V10.54: the INPUT engine (the user's ask: the audio input routed, the track in an audio mode, an envelope follower): engine 15 plays the USB audio input (an interface on HOST, or the computer's USB IN+OUT) on its track: SOURCE IN 1 / IN 2 / 1+2 / STEREO (two tracks can take IN 1 and IN 2; STEREO keeps the image through the part's chain as IMAGE does), GAIN, GATE, PLAY THRU / KEYS (only while a note plays, at its envelope: a trance gate from the steps), WIDTH, RING (KEYS: a sine at the note), BITS, RATE; the track's FILTER DIST LEVEL PAN sends as any part's; EDIT INPUT shows both inputs' meters, GATE's level and FOLLOW; while a track is INPUT the last track's IN+OUT mix steps aside; MOD SRC FOLLOW, the input's envelope, on any track and any destination. (2026-11-03) V10.53: USB > HOST takes an audio interface too, an experiment (the user's ask: a USB audio input into the synth): a class compliant USB audio 1.0 capture (16-bit, mono or stereo, 44,1 kHz among its rates: Behringer UM2 / UCA and the like), alone or behind a powered hub, set to 44,1 kHz (SET_CUR) and read each frame (isochronous IN) into IN+OUT's ring: it plays through the last track (its LEVEL PAN and sends, as USB IN+OUT's host audio); usb_host_desc.h uh_parse_uac, tested; not yet on hardware. (2026-11-03) V10.52: a synth's STEREO page shows IMAGE at work (the user: no visual feedback): the field L .. R, each voice sounding a blob at its place, its size its level now, its note over it (IMAGE 0: the notes in a row), the silent ones a tick where they would sit, the span IMAGE opens as a bar. (2026-11-03) V10.51: the roll follows the playhead for real (the user: V10.47's did not): the bar playing was chosen in the roll's drawing, and a playhead out of the bar shown changed nothing the panel's redraw looks at (graph_signature): never drawn, never followed; now chosen there. (2026-11-03) V10.50: the user's fixes to V10.49: a synth's STEREO IMAGE its own parameter (P_SIMG, the lane-1 level's slot, stored inverted: every part's 127 = 0 %; on VOICE V10.49's showed and moved LYRIC, the slot VOICE uses), its own STEREO page; EDIT's order: the sound's pages first, VOICE and VOICE 2 last in a group of their own (SOUND TONE FOCUS VOICE; FM6: SOUND TONE OPS VOICE). (2026-11-03) V10.49: users' asks: FX > DLY 3 KNOB 4 R TIME, the right echo its own time as a ratio of TIME (=L as before, x1/2 x2/3 x3/4 x4/3 x3/2 x2; not with PING-PONG or the grains; saved, project block DR); EDIT > STEREO IMAGE on synth parts in POLY: each voice its own place across the stereo field (DRUM-X's way: what each side gives up, through the part's filter, narrowed by DIST), the page shows the eight voices' places. (2026-11-03) V10.48: room: LOFI's, ANIMAL's and STRING's creatures (ui_engvis.c, ~6 KB) moved into the Bluetooth segment (without it: the being, as other engines); the app slot ~6 KB free again, the segment ~7 KB. (2026-11-03) V10.47: the roll and the drum grid follow the playhead (a user's ask): while it plays and nothing was touched for 3 s, the bar shown is the one playing; a key or a knob holds it 3 s. (2026-11-02) V10.46: a safe start (reports of FM-1s that stay dark after installing; the cause not known): a start that hangs between the supply setup (V10.11, hal/fm1_power.h) and the UI is reset by the watchdog, and the next start skips that setup (the boot loader's supplies, as up to V10.10) until the power goes off, and says SAFE START. (2026-11-02) V10.45: LIVE > MANO KNOB 4 the DJ FILTER again (a user's report: V10.37 turned it into the tempo, MIXER's new KNOB 4); EDIT > MORPH on ANALOG PWM SYNC RING SAW3 PLS3 draws the wave as MORPH bends it (the user: a ramp), in the Bluetooth segment. (2026-11-02) V10.44: the rest of the mock-up's pictures, in the Bluetooth segment (the app slot full; without the segment the page keeps its old picture): FX > MASTER > EQ the four bands' curve (LOW / HIGH shelves, the mids bells, a dot each, 60 250 2K 8K); GLO > SYSTEM 2 the three ports as boxes (USB TRS BT, their state), a light each way flashing as MIDI passes, PROX's bar when Bluetooth is linked or in AIR; LEVELS' picture moved there too. (2026-11-02) V10.43: pictures that show what the page does (the user's picks from the mock-up): EDIT > LEVELS / LEVELS 2 a column a DRUM-X sound, its LEVEL the height, lit as it plays, the page's four framed (was the scope); FX > MASTER the CLIP curve (in -> out, the level now a dot), PUNCH's push as a bar, the duck's gain now a line over its curve; FX > PUNCH the lane 16 steps a row, every step a box, a recorded one its punch's colour, the playhead framed (an empty lane drew nothing). (2026-11-02) V10.42: the factory presets less alike, the basics there (the user's ask): FM6's seven near copies (ICE BELL DX KEYS FM PLUCK SOFT BELL FM STRINGS WOOD, the first eight bent a little) are other instruments through the macros: FM LEAD SQR LEAD SAW LEAD, SLAP BASS SUB BASS, BELL PAD (program numbers kept, HARD BASS stays); WHEEL PEDAL BASS and DRIVE LEAD where DUB ORGAN and SOFT KEYS were; LOFI PULSE BASS appended. (2026-11-02) V10.41: MENU > SYSTEM > USB > HOST (a user's ask, an experiment): the port as the host of a class compliant USB-MIDI keyboard or controller, alone or behind a hub, what it plays in as USB-MIDI (CLK USB+BT, LEARN, MAP alike); Melodee's host (usb_host.c, recursivefieldinstruments' enumeration), input only, its main-loop side in the Bluetooth segment (the app slot full); never saved (every power-on a device); the port is not powered: a keyboard on its own power or a powered hub. (2026-11-02) V10.40: the editor sees a mode's own knobs (ANALOG SAW3 / PLS3 INT 3 -24..24, STRING FDBK's, NOISE LFSR's: editor.c ed_tdesc as the panel, a WAVE / EXCITE set from the editor resets the knobs that change meaning, the page re-reads them); HOME's lazy redraw mends a missed cell within ~10 s (a strip's n / 128 + 1 cells sent anyway a frame, was one: up to ~95 s on HOME's panel; ~4 % more sent). (2026-11-02) V10.39: ANALOG SAW3 and PLS3, each oscillator its own interval (the user's ask): NOISE's knob (EDIT 1 KNOB 4) reads INT 3 there, osc 3's interval in semitones (-24..24; INT stays osc 2's), no noise in those two WAVEs (every factory SAW3 has NOISE 0: the same sound); turning WAVE into or out of them sets that knob to 0. (2026-11-02) V10.38: intervals in tune at random (the user: GEN's ANALOG sounds took a random INT, the song out of tune): whatever chooses an engine's interval by chance (GEN and EXPLORE, the sound dice EDIT + SELECT) picks 0, a fourth, a fifth or an octave, up or down (ANALOG INT, VOICE SHIFT; GEN keeps a preset's, snapped to the nearest: GLASS KEYS' 19 kept); the random macros never aim at an interval. (2026-11-02) V10.37: GLO > MIXER KNOB 4 BPM (the DJ FILTER on LIVE > MANO), GLO's pages LIVE MIX COMPS GLOBAL SYSTEM; Bluetooth named where MIDI is (the user's ask): GLOBAL > CLOCK reads USB +BT (USB's source follows Bluetooth's clock too), GLO > SYSTEM 2 KNOB 3 shows BT's state (OFF, ADV, CONN n, AIR) beside USB and TRS IN. (2026-11-02) V10.36: LFO WAVE DRIFT (a user's ask, ambient drones and pads that breathe): a smooth random wander, each cycle a new value within half the range of the last, reached on a smoothstep (no step, no corner; with RATE 4BAR..16BAR a slow drift); the factory pads breathe by themselves (BREATHE in the presets' spare byte: DRIFT on FILTER, some a little on PITCH, over 4 or 16 bars): ANALOG SOFT PAD STRINGS JUNO PAD DARK PAD, FM6 PAD FM STRINGS, PHASE GLASS PAD VOX PAD, NOISE HISS PAD, LOFI CHIP PAD. (2026-11-02) V10.35: MENU > SYSTEM > BLUETOOTH AIR, an experiment: the radio listens instead of advertising (passive scan, nothing sent, no MIDI) and every Bluetooth packet heard around (phones, watches, headphones, TVs) feeds PROX: a body near the antenna shadows them, PROX's page and the MS_PROX source as with a phone (Optimist's scanner, fm1-base 4039a8b, minimal central level 3, in the segment: 56 KB of 72). (2026-11-02) V10.34: DRUM-X kit HIP HOP (a user's ask: boom bap, a round kick with a knock, a fat cracking snare, a tight clap, dusty band-passed hats, a woody rim, a shaker in the BELL's place) and the pattern BOOM BAP it suggests (SEQ > PATTERNS 14). (2026-11-02) V10.33: the MIDI clock steady. Out (MIDI OUT CLOCK / ALL): each of the 24 pulses at its own sample, sent at its own time (USB: usb.c ep1_tx holds it to its TIMER4 tick; Bluetooth: stamped with it), no longer a burst each 2.9 ms render, and no rounding in the pulse length (a follower read 105.1 for 104). In (CLK USB / TRS, Bluetooth too): the tempo over two beats, smoothed, a whole BPM held within 0.6 (it was six pulses raw: 103 105 104..), the interpolation at the steady tempo. (2026-11-02) V10.32: Bluetooth MIDI pairs: Just Works (no PIN) with bonding and the link encrypted when a central asks (Windows, some Macs and Androids refused "Pairing Not Supported" before); the bond's key made again from EDIV / Rand (bt/ble ble_smp_ltk_of), nothing stored, every bonded computer back after a power-off; Optimist's AES / CCM (ble_aes.c, fm1-base 4039a8b) in the Bluetooth segment (51 KB of its 72). (2026-11-02) V10.31: EUCLID reversible: the sequence it took is kept whole (the last track taken, 1.5 KB in RAMTEXT's room: notes, chords, velocities, components, micro), put back when its settings are at rest again (VARY and MODES 0, its own rhythm) or HITS / DENSITY go to 0; another track's taken since: its rhythm and notes come back from what EUCLID took. SCL > SCENE kept with the project (FUNC 'S' 'C': ON and the six roles; none: OFF, all KEEP). (2026-11-02) V10.30: flash by hand: a parameter card in one place (pf_column: eleven cards of ui_draw.c), "a/n" in one place (fmt_frac: eight); every screen pixel for pixel as before (9250 renders hashed): ~0.6 KB more free. (2026-11-02) V10.29: flash: the files added since 0.9.7 (EUCLID, SCENE, LIVE, MIDI LEARN, the song player, PERFORM, PLAYHEADS, SLICER) and the engines' main-loop side built for size (tools/size_fns.py; what the interrupts reach keeps -Os): ~1.8 KB more free, the sound as it was. (2026-11-02) V10.28: EUCLID starts at 0 (no HITS, no DENSITY, MODES and VARY 0: built from nothing); a sequence the track has (recorded, edited, a song's; not a factory pattern) is transformed: its rhythm and holds until HITS STEPS or ROTATE are turned, its notes always (a kit: its lanes); VARY in two halves: up to 50 the one cycle moved, each value its own (one hit at least), above 50 the four turns A A' A'' B. (2026-11-02) V10.27: testers' fixes: the CHORD page no longer writes VOICING LEAD's last chord (a key played another inversion after the page was shown: chord_peek); MENU: KNOB k edits its card's row (all four edited the selected row); TAPE WOW wobbles like a warped record (a smoothed random drift, ~+-45 cents at 100; its noise source was stuck at 0: the hiss and drift were dead); slower: LFO RATE 8BAR 16BAR, PLAYHEADS 1/8 1/16, STRUM past 64 up to ~1 s. (2026-11-02) V10.26: SCENE starts with every track KEEP (OFF, as before); OCT+ on SCENE dices the roles (each role one track at most: never two doing the same, never two playing chords), OCT- all KEEP; turned ON with none set, it dices; a role picked by hand that another track has sends that one to KEEP. (2026-11-02) V10.25: SEQ > STRETCH's NUDGE in two modes: OCT- the whole sequence a step (blue, as before), OCT+ the cursor step's MICRO timing (red, 64ths of a step; PRESETS moves the cursor), MICRO back on a knob (a tester's ask). (2026-11-02) V10.24: the user's picks from the redesign mock: SEQ > EUCLID the lanes as concentric rings (heat colours, VARY's turns under the ring); SEQ > MUTATE the anchor above, the pattern playing below (changed steps lit), an arc to the next mutation; SAVE > PRESETS two columns (the engines, their presets), OCT+ keeps the sound browsed to, OCT- brings back the one before; SAVE > TOOLS by scope (KNOB 1 TRACK SOUND SONG SYSTEM, KNOB 2 the action), OCT+ held a second does it (no dialog); SCL > SCENE, the multitimbral mode: one key plays every track given a role (KEEP CHORD ARP BASS LEAD; the kit keeps its sequence), REC records each into its own steps. (2026-11-01) V10.23: STRING FDBK heard (its BLOOM level was applied twice, -15 dB); EXCITE into / out of FDBK keeps each side's EDIT 2 knobs (GAIN no longer starts at STRETCH's 0), FDBK's defaults audible. (2026-11-01) V10.22: testers' asks: ENV > ENV 2 (a second ADSR, MOD SRC ENV2, any DEST), FILTER TYPE LP24 (4 poles), ANALOG WAVE PLS3 (three pulses, SHAPE the width). (2026-11-01) V10.21: EUCLID's lane rows named right (they were one off: ALL's name on BD's row); the ring shows one cycle (the lane's, ALL's, the melody's) and the turn playing, its playhead going round; PROX's page says the phone, not the hand. (2026-11-01) V10.20: PROX smooth: the RSSI reading fixed on word 0 as the level (V10.18's widest range picked a noisy byte: a random sample and hold), the median of nine and ~0.3 s; FAR and NEAR too close (under 4 levels) refused. (2026-10-31) V10.19: the PROX page redraws when a reading arrives (all-zero words left it on NOT CONNECTED) and shows the link as seen: L (link), the RSSI hook's packets / the good packets. (2026-10-31) V10.18: PROX finds the RSSI reading that moves (the four RSSI words of each packet, twelve readings, the widest range on the link; kept once FAR / NEAR is stored), the page shows the four words. (2026-10-31) V10.17: SAVE > SECTIONS KNOB 2 ERASE (the section empty again, RAM and flash; the music stays). (2026-10-31) V10.16: SEQ > EUCLID's VARY in four turns (A A' A'' B, each moved anew, the motif answered); SEQ > MUTATE (EVERY 1..16 bars, AMOUNT, MODE ORBIT / DRIFT / PULSE, WHAT GROOVE / RHYTHM / FEEL / ALL; OCT+ a mutation now, OCT- back to the anchor). (2026-10-31) V10.15: VOICE's English dictionary in the Bluetooth segment (without it: the letter rules). (2026-10-31) V10.14: PROX, a modulation source from the Bluetooth signal (a hand near the antenna), calibrated on MENU > SYSTEM > BLUETOOTH ON + OCT+ (OCT- FAR, OCT+ NEAR). (2026-10-31) V10.13: BLE-MIDI in and out (what a central sends plays as USB-MIDI, MIDI OUT goes to it too); ABOUT's credits in the Bluetooth segment (the app slot had 128 B free). (2026-10-31) V10.12: MENU > SYSTEM > BLUETOOTH OFF / ON: a BLE-MIDI peripheral "JIANT FM-1" (advertising, connectable; MIDI not routed yet), Optimist's stack in the Bluetooth segment at 0xEA000 (written by the update loader from the package's bt.bin), live RF calibration, a boot guard. (2026-10-31) V10.11: the supplies set up as stock V15 does (the DC-DC on, hal/fm1_power.h from Melodee), the radio's prerequisite; 0xEA000..0xFBFFF reserved for the Bluetooth segment. (2026-10-31) V10.10: the radio's calibration kept: the update loader keeps the stock VM sector (0xE8000: RF trims, BT address) but its record's 256 B; VM_READ (editor 80) reads that area for web/btcheck. (2026-10-31) V10.9: MENU > LARGE shows the animations (HOME: the six tracks' creatures in the strip; EDIT: the engine's). (2026-10-31) V10.8: testers' fixes: GEN parts set OFF stay off; GEN keeps its GENRE between visits; SEQ > STEP KNOB 4 VEL (1..127, then ACC SLD A+S); delay 1/4D 1/8D 1/16D; less pitch wobble from the generators (no macro on PITCH, pitched delay seldom, octaves); STOP TO EDIT says SONG PLAYS. (2026-10-31) V10.7: SEQ > EUCLID on a kit: LANE ALL first (DENSITY: a whole usable kit), a lane picked writes that lane alone; EDIT + PRESETS jumps between engines; the kit's SEQ dice plays in every genre; EUCLID's HITS exact (VARY moved them only); REC held alone and let go: UNDO (again: REDO). (2026-10-31) V10.6: SEQ > EUCLID and MODES (a euclidean pattern generator, melodies in the key) in MUTATE's place; MUTATE and SEQ TOOLS' RANDOM COOK BEAT gone. (2026-10-31) V10.5: automation thinned (a recording at the stop, the 64 when full) into holds and RAMPs. (2026-10-31) V10.4: ARRANGE / TIMELINE: OCT- deletes the row picked (DELETE ROW?). (2026-10-31) V10.3: TIMELINE: the lines between lanes soft (the block's colour, darker), the rows' edges stronger. (2026-10-31) V10.2: TIMELINE keeps the black line between lanes (only the rows touch); SAVE composes first: TIMELINE SECTIONS PROJECTS ARRANGE TOOLS USER PRESETS. (2026-10-30) V10.1: TIMELINE blocks fill the lanes (no black gaps between rows or tracks). (2026-10-30) JIANT FM V10: add15-beta6 as the new base (TIMELINE, VAR, ADD, official V16 both ways); the version history before it: the git log of the add15 line (codex/add15-private) */ #endif #if FELUCCA_OTA && !FELUCCA_FLASH #error "FELUCCA_OTA needs FELUCCA_FLASH" diff --git a/firmware/src/gen.c b/firmware/src/gen.c index 79b10a86..46fc698b 100644 --- a/firmware/src/gen.c +++ b/firmware/src/gen.c @@ -1745,7 +1745,7 @@ static void gen_parts(void) uint8_t pdeg[4], pq[4], pn = gs.pn; const uint8_t *ord; uint32_t nord; - if (form == FM_LOOP) return; + if (form == FM_LOOP) { section_store(0); dice_secs |= 1u; return; } gseed(GS_FORM); live.cur = -1; section_store(0); /* A: the whole piece */ @@ -2463,18 +2463,17 @@ static void gen_go(void) { uint32_t k; char b[8]; + uint32_t play = song.playing || chain_busy() || seq_counting(); + if (play) { + fm1_irq_off(); seq_stop(); transport_req = 0; fm1_irq_on(); + song_poll(); + } gform_kept = 0; - /* Refuse before gen_clean: a requested SONG must not silently become a loop - * while also erasing the current arrangement. Never overwrite saved A-D. */ - if (gp.form) - for (k = 0; k < 4u; k++) - if (project_used(k) && !((dice_secs >> k) & 1u)) { - gform_kept = 1; - ui_message("A-D SAVED"); - str_cpy(ui.msg2, "USE AN EMPTY PROJECT", sizeof ui.msg2); - return; - } undo_mark(); + if (song_draft_begin()) { + if (play) { if (live.mode) chain_play_ui(); else transport_req = 1; } + return; + } gen_make(); str_cpy(gp.last, gs.g->name, sizeof gp.last); k = str_len(gp.last); @@ -2483,6 +2482,7 @@ static void gen_go(void) str_cpy(gp.last + k, b, sizeof gp.last - k); ui_say("GEN: ", gp.last); str_cpy(ui.msg2, live.mode ? "PLAY: SONG / SAVE: ALL PARTS" : "UNDO: GLO + G4", sizeof ui.msg2); + if (play) { if (live.mode) chain_play_ui(); else transport_req = 1; } ui.force = 1; } static uint32_t gen_sig(void) /* the settings that make the piece */ @@ -2653,9 +2653,9 @@ static const char *dice_seq(track_t *t) } /* ------------------------------------------------------------------------------------------- the GEN screen --- */ -static const char *const GEN_LBL[3][4] = {{"GENRE", "SEED", "ENERGY", "FORM"}, {"DRUMS", "BASS", "CHORDS", "ARP"}, +static const char *const GEN_LBL[3][4] BTAPP_RO = {{"GENRE", "SEED", "ENERGY", "FORM"}, {"DRUMS", "BASS", "CHORDS", "ARP"}, {"LEAD", "COMPLEX", "SWING", "HUMAN"}}; -static const char *const GEN_FORM[3] = {"LOOP", "PARTS", "SONG"}; +static const char *const GEN_FORM[3] BTAPP_RO = {"LOOP", "PARTS", "SONG"}; static uint8_t gen_fresh; /* (0.6.96) the screen's first frame: the body cleared once */ static void gen_open(void) { @@ -2705,7 +2705,7 @@ static void gen_page_put(uint32_t p) /* (0.9.2) GEN 1..3: HO gp.page = (uint8_t)(p % 3u); ui.force = 1; } -static void gen_value(uint32_t p, uint32_t k, char *b) +BTAPP_FN static void gen_value(uint32_t p, uint32_t k, char *b) { uint32_t v; b[0] = 0; @@ -2727,7 +2727,7 @@ static void gen_value(uint32_t p, uint32_t k, char *b) /* (0.8.5) GEN in HOME's lens (ui_lens.c, the mock-up's GEN level): its four settings on the cards, the panel the five * parts as rows (the ones the page's knobs weigh lit), each a preview of its density (its amount) and heat (ENERGY) * from the seed, the FORM's sections as chips, the last piece and OCT+ MAKE */ -static void gen_cards(void) +BTAPP_FN static void gen_cards_bt(void) { uint32_t k; char v[16]; @@ -2744,18 +2744,21 @@ static void gen_cards(void) draw_column(k, GEN_LBL[p][k], v, "", VAL(k), r, ICON_NONE); } } +static void gen_cards(void) +{ + if (bt_hw_seg()) gen_cards_bt(); +} static uint32_t gen_draw_sig(void) { return gen_sig() * 31u + gp.page * 7u + str_hash(gp.hot * 977u, gp.last) + ux.gen + chain_config.count * 7919u + live.mode * 13u + song.playing * 29u + (chain.running ? (chain.row + 1u) * 104729u + chain.remaining * 1299709u : 0u); } -static void gen_panel(void) +BTAPP_FN static void gen_panel_bt(void) { - static const char *const ROLE[5] = {"DRUMS", "BASS", "CHORDS", "ARP", "LEAD"}; - uint32_t k, p = gp.page % 3u; + uint32_t k; char v[24]; - if (p == 0u && chain_config.count) { + if (chain_config.count) { /* Reuse the actual arrangement, not FORM's illustrative BCADCA chips. * Progress refreshes per bar; no new high-rate animation or DSP work. */ graph_proj(2); @@ -2768,22 +2771,17 @@ static void gen_panel(void) fmt_int(v + str_len(v), chain.remaining); } else str_cpy(v, song.playing ? "PLAYING LOOP" : live.mode ? "SONG READY" : "LOOP MODE", sizeof v); cv_text(4, 128, &AF_X, v, T_TEXT); - cv_text_r(236, 128, &AF_X, "SAVE: SONG", T_ACCENT, T_SURF); + cv_text_r(236, 128, &AF_X, song_draft ? "DRAFT / SAVE" : "SAVE: SONG", T_ACCENT, T_SURF); return; } - /* Settings are shown numerically by the knob cards. The panel needs only - * their density bars; FORM is already labelled on GEN 1. */ - for (k = 0; k < 5u; k++) { - int32_t y = 8 + (int32_t)k * 21; - uint32_t a = gp.amt[k] == GA_AUTO ? 55u : gp.amt[k]; - uint16_t c = ((p == 1u && k < 4u) || (p == 2u && k == 4u)) ? T_THEME : T_MID; - cv_text(8, y, &AF_X, ROLE[k], c); - cv_rect(60, y + 3, 166, 4, T_LINE); - if (a) cv_rect(60, y + 3, (int32_t)a * 166 / 100, 4, c); - } - str_cpy(v, "LAST: ", sizeof v); - str_cpy(v + 6, gp.last[0] ? gp.last : "-", sizeof v - 6); - cv_clip_text(6, 126, &AF_X, v, T_MID, T_SURF, 150); - cv_text_r(234, 126, &AF_X, "OCT+ MAKE", T_ACCENT, T_SURF); + graph_proj(0); + cv_rect(0, 124, 240, 16, T_SURF); + cv_text(4, 128, &AF_X, song_draft ? "DRAFT LOOP" : "SAVED PARTS", T_TEXT); + cv_text_r(236, 128, &AF_X, "SAVE: LOOP/SONG", T_ACCENT, T_SURF); } + +static void gen_panel(void) +{ + if (bt_hw_seg()) gen_panel_bt(); else graph_proj(chain_config.count ? 2 : 0); +} diff --git a/firmware/src/project.c b/firmware/src/project.c index 945257d5..b7f105a2 100644 --- a/firmware/src/project.c +++ b/firmware/src/project.c @@ -1752,7 +1752,7 @@ static int project_save_as(uint32_t slot, const char *name) if (!proj_pack(&proj_wire, p)) { ui_message(proj_full ? "SECTION FULL" : "SAVE FORMAT ERROR"); return 2; } #if FELUCCA_FLASH - if (flash_ok) { + if (flash_ok && !song_draft) { if (st_save(proj_obj(slot), &proj_wire, sizeof proj_wire)) { ui_message("SAVE ERROR"); return 2; @@ -1770,7 +1770,7 @@ static int project_save_as(uint32_t slot, const char *name) proj_name_get(proj_name, (const uint8_t *)p->name); proj_cur = (uint8_t)(slot & 3u); live.cur = (int8_t)(slot & 3u); - ui_message("SAVED (NO FLASH)"); + ui_message(song_draft ? "PART STORED IN DRAFT" : "SAVED (NO FLASH)"); return 0; } static int project_save(uint32_t slot) { return project_save_as(slot, 0); } @@ -2193,23 +2193,7 @@ static int project_used(uint32_t slot) { return proj_import(&proj_scratch, &proj * erase). 0 done */ static int project_erase(uint32_t slot) { - char b[8] = "SECT A"; - slot &= 3u; - b[5] = (char)('A' + slot); - if (transport_busy()) { ui_message("STOP TO ERASE"); return 1; } - memset(&proj_slot[slot], 0, sizeof proj_slot[slot]); - live.dirty &= (uint8_t)~(1u << slot); /* (nothing left to write) */ - if (live.cur == (int8_t)slot) live.cur = -1; - proj_wire_gen++; /* (the LIBRARY's picture again) */ -#if FELUCCA_FLASH - if (flash_ok && (st_erase(st_sector(proj_obj(slot), 0)) || st_erase(st_sector(proj_obj(slot), 1)))) { - ui_message("ERASE ERROR"); - return 2; - } -#endif - ui_say("ERASED ", b); - ui.force = 1; - return 0; + return song_erase_parts(song_cur, 1u << (slot & 3u)); } /* (0.8.5) SAVE > LIBRARY: project n's sections stored (a bit each) and its section A's name (b, PROJ_NAME_LEN + 1), @@ -2220,7 +2204,7 @@ static uint32_t lib_scan(uint32_t n, char *b) { uint32_t k, m = 0; b[0] = 0; - if (n == song_cur) { + if (n == song_cur && !song_draft) { for (k = 0; k < 4u; k++) m |= (uint32_t)project_used(k) << k; if (m & 1u) @@ -2401,7 +2385,7 @@ static void autosave_poll(void) } #if FELUCCA_FLASH uint32_t sig; - if (!flash_ok || fm1_ms - as.poll < AS_POLL_MS) + if (song_draft || !flash_ok || fm1_ms - as.poll < AS_POLL_MS) return; as.poll = fm1_ms; sig = autosave_sig(); diff --git a/firmware/src/song_chain.c b/firmware/src/song_chain.c index 245e9af2..9d1228a7 100644 --- a/firmware/src/song_chain.c +++ b/firmware/src/song_chain.c @@ -67,6 +67,7 @@ static void scene_capture(scene_t *s) memcpy(s->mac, macro_v, sizeof s->mac); } static song_index_t song_idx; +static uint8_t song_draft; /* Generated workspace: never auto-written to project slots. */ static uint8_t song_cur; /* the song whose sections proj_slot holds (0: the four project slots) */ /* track k of the current song's row r: the section it plays (the row's own unless ARRANGE 2 gave it another) */ static uint32_t row_src(uint32_t r, uint32_t k, uint32_t s) diff --git a/firmware/src/song_main.c b/firmware/src/song_main.c index 9fba6367..2fcd3604 100644 --- a/firmware/src/song_main.c +++ b/firmware/src/song_main.c @@ -363,6 +363,7 @@ static void song_rec_toggle(void) static int song_flush(void) { uint32_t k; + if (song_draft) return 0; #if FELUCCA_FLASH if (!flash_ok) return 0; @@ -384,6 +385,7 @@ static void song_idx_touch(void) /* the index into flash (the songs' rows, the current song): 0 done (or no flash) */ static int song_index_save(void) { + if (song_draft) return 0; song_idx.rows[song_cur] = chain_config; song_idx.cur = song_cur; #if FELUCCA_FLASH @@ -394,6 +396,27 @@ static int song_index_save(void) return 0; } +/* Commit the old project before borrowing its four RAM buffers. All later + * generations are drafts until an explicit SAVE; no new audio storage. */ +static int song_draft_begin(void) +{ + if (!bt_hw_seg()) { ui_message("UPDATE PACKAGE"); return 1; } + if (transport_busy()) { ui_message("STOP TO GENERATE"); return 1; } +#if FELUCCA_FLASH + if (!flash_ok) { ui_message("NO FLASH"); return 1; } +#endif + if (!song_draft) { + if (song_flush() || song_index_save()) { ui_message("SAVE ERROR"); return 1; } + song_save_target = song_cur; + } + song_draft = 1; + 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); + proj_wire_gen++; + return 0; +} + #include "song_save.c" /* song n (0..NSONG - 1) in, stopped only: the current one kept first, then n's sections and rows; load_a: its @@ -403,17 +426,20 @@ static int song_switch(uint32_t n, int load_a) { char nm[PROJ_NAME_LEN + 1u]; uint32_t k; - if (n >= NSONG || n == song_cur) + if (n >= NSONG || (n == song_cur && !song_draft)) return 1; if (transport_busy()) { ui_message(load_a ? "STOP TO CHANGE SONG" : "STOP TO CHANGE PROJECT"); return 1; } - if (song_flush()) { - ui_message("SAVE ERROR"); - return 1; + if (song_draft) { + song_draft = 0; live.dirty = 0; + song_index_load(); + } else { + if (song_flush()) { ui_message("SAVE ERROR"); return 1; } + song_idx.rows[song_cur] = chain_config; } - song_idx.rows[song_cur] = chain_config; /* (the rows of the song left) */ + /* The original index is restored before opening another saved project. */ song_cur = (uint8_t)n; chain_config = song_idx.rows[n]; if (song_index_save()) { /* (failed: written again by song_poll) */ @@ -504,6 +530,7 @@ static void song_poll(void) ui_message("SONG END"); } } + if (song_draft) return; chain_config.rsv[2] = SONG_MODE_TAG | (live.mode ? 1u : 0u); if (memcmp(&chain_config, &song_idx.rows[song_cur], sizeof chain_config)) { /* the rows or PLAY mode changed */ song_idx.rows[song_cur] = chain_config; diff --git a/firmware/src/song_save.c b/firmware/src/song_save.c index 25f60793..4916af9e 100644 --- a/firmware/src/song_save.c +++ b/firmware/src/song_save.c @@ -10,15 +10,18 @@ static int song_copy_section(uint32_t section, uint32_t current, const char *name) { project_t *p = &proj_scratch; - if (!proj_import(p, section == current ? &song_keep : &proj_slot[section], sizeof(project_store_t))) { + if (song_save_loop) { + if (section) return 0; + if (!proj_import(p, &song_keep, sizeof song_keep)) return -1; + } else if (!proj_import(p, section == current ? &song_keep : &proj_slot[section], sizeof(project_store_t))) { if (section || !proj_import(p, &song_keep, sizeof song_keep)) return 0; } 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()); - p->chain = chain_config; + 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 | (live.mode ? 1u : 0u); + p->chain.rsv[2] = SONG_MODE_TAG | (!song_save_loop && live.mode ? 1u : 0u); if (section == 0u && name) { memset(p->name, 0, sizeof p->name); memcpy(p->name, name, str_len(name) < PROJ_NAME_LEN ? str_len(name) : PROJ_NAME_LEN); @@ -27,6 +30,24 @@ static int song_copy_section(uint32_t section, uint32_t current, const char *nam return proj_pack(&proj_wire, p) ? 1 : -1; } +/* Saved index and one destination's metadata; the live draft keeps its own row data. */ +static int song_saved_index(song_index_t *index) +{ +#if FELUCCA_FLASH + if (song_draft) return st_load(OBJ_SONGIDX, index, sizeof *index) != sizeof *index || index->magic != SONG_MAGIC; +#endif + memcpy(index, &song_idx, sizeof *index); + index->rows[song_cur] = chain_config; + return 0; +} +BTAPP_FN static void song_index_target(const song_index_t *index, uint32_t target) +{ + song_idx.rows[target] = index->rows[target]; + memcpy(song_idx.scene[target], index->scene[target], sizeof index->scene[target]); + memcpy(song_idx.tsrc[target], index->tsrc[target], sizeof index->tsrc[target]); + memcpy(song_idx.tvar[target], index->tvar[target], sizeof index->tvar[target]); +} + static int song_save_as(uint32_t target, const char *name) { #if FELUCCA_FLASH @@ -34,7 +55,8 @@ static int song_save_as(uint32_t target, const char *name) song_index_t *index = (song_index_t *)proj_wire_u.raw; _Static_assert(sizeof(song_index_t) <= sizeof proj_wire_u.raw, "song index fits existing staging RAM"); if (transport_busy()) { ui_message("STOP TO SAVE"); return 1; } - if (target >= NSONG || target == song_cur) { ui_message("CHOOSE ANOTHER PROJECT"); return 1; } + if (!bt_hw_seg()) { ui_message("UPDATE PACKAGE"); return 1; } + if (target >= NSONG) { ui_message("CHOOSE ANOTHER PROJECT"); return 1; } if (!flash_ok) { ui_message("NO FLASH: NOT SAVED"); return 1; } current = live.cur >= 0 && live.cur < 4 ? (uint32_t)live.cur : proj_cur < 4u ? proj_cur : 0u; project_capture(&proj_scratch); @@ -48,14 +70,15 @@ static int song_save_as(uint32_t target, const char *name) if (rc < 0) { ui_message("SECTION FULL"); return 2; } if (rc) mask |= 1u << section; } - if (!chain_valid(&chain_config)) { ui_message("INVALID ARRANGEMENT"); return 2; } - for (uint32_t row = 0; row < chain_config.count; row++) { + if (!song_save_loop && !chain_valid(&chain_config)) { ui_message("INVALID ARRANGEMENT"); return 2; } + for (uint32_t row = 0; !song_save_loop && row < chain_config.count; row++) { if (!(mask & (1u << chain_config.row[row].slot))) { ui_message("MISSING SECTION"); return 2; } for (uint32_t track = 0; track < NTRK; track++) if (!(mask & (1u << row_src(row, track, chain_config.row[row].slot)))) { ui_message("MISSING SECTION"); return 2; } } + if (song_saved_index(index)) { ui_message("SAVE INDEX ERROR"); return 2; } proj_wire_gen++; /* invalidate editor staging and the library, even on failure */ for (section = 0; section < 4u; section++) { uint32_t obj = target ? OBJ_SONG1 + (target - 1u) * 4u + section : OBJ_PROJECT0 + section; @@ -66,18 +89,36 @@ static int song_save_as(uint32_t target, const char *name) ui_message("SAVE ERROR: RETRY"); return 2; } } - memcpy(index, &song_idx, sizeof *index); - index->rows[song_cur] = chain_config; - index->rows[target] = chain_config; + if (song_saved_index(index)) { ui_message("SAVE INDEX ERROR"); return 2; } + if (song_save_loop) { + chain_defaults(&index->rows[target]); + memset(index->scene[target], 0, sizeof index->scene[target]); + memset(index->tsrc[target], 0, sizeof index->tsrc[target]); + memset(index->tvar[target], 0, sizeof index->tvar[target]); + } else { + index->rows[target] = chain_config; + memcpy(index->scene[target], song_idx.scene[song_cur], sizeof index->scene[target]); + memcpy(index->tsrc[target], song_idx.tsrc[song_cur], sizeof index->tsrc[target]); + memcpy(index->tvar[target], song_idx.tvar[song_cur], sizeof index->tvar[target]); + } index->rows[target].rsv[1] = 0; - index->rows[target].rsv[2] = SONG_MODE_TAG | (live.mode ? 1u : 0u); - memcpy(index->scene[target], song_idx.scene[song_cur], sizeof index->scene[target]); - memcpy(index->tsrc[target], song_idx.tsrc[song_cur], sizeof index->tsrc[target]); - memcpy(index->tvar[target], song_idx.tvar[song_cur], sizeof index->tvar[target]); + index->rows[target].rsv[2] = SONG_MODE_TAG | (!song_save_loop && live.mode ? 1u : 0u); if (st_save(OBJ_SONGIDX, index, sizeof *index)) { ui_message("SAVE ERROR: RETRY"); return 2; } - memcpy(&song_idx, index, sizeof song_idx); + /* Keep the live draft metadata while updating the destination's library entry. */ + if (!song_draft || target != song_cur) song_index_target(index, target); + if (!song_draft && target == song_cur) { + for (section = 0; section < 4u; section++) { + int rc = song_copy_section(section, current, name); + if (rc > 0) memcpy(&proj_slot[section], &proj_wire, sizeof proj_wire); + else memset(&proj_slot[section], 0, sizeof proj_slot[section]); + } + chain_config = song_idx.rows[target]; + live.mode = !song_save_loop && live.mode; + if (song_save_loop) live.cur = proj_cur = 0; + live.dirty = 0; + } song_idx_dirty = 0; - { char b[4]; fmt_int(b, (int32_t)target + 1); ui_say("SAVED SONG ", b); } + { char b[4]; fmt_int(b, (int32_t)target + 1); ui_say(song_save_loop ? "SAVED LOOP " : "SAVED SONG ", b); } ui.force = 1; return 0; #else @@ -86,3 +127,75 @@ static int song_save_as(uint32_t target, const char *name) return 1; #endif } + +/* Drop rows which would reference an erased part, moving scene/source/variation together. */ +BTAPP_FN static void song_remove_parts(song_index_t *index, uint32_t target, uint32_t mask) +{ + chain_config_t *c = &index->rows[target]; + uint32_t r, w = 0, k; + for (r = 0; r < c->count; r++) { + uint32_t used = 1u << c->row[r].slot; + for (k = 0; k < NTRK; k++) { + uint32_t src = index->tsrc[target][r] >> (3u * k) & 7u; + if (src && src <= 4u) used |= 1u << (src - 1u); + } + if (used & mask) continue; + c->row[w] = c->row[r]; + index->scene[target][w] = index->scene[target][r]; + index->tsrc[target][w] = index->tsrc[target][r]; + index->tvar[target][w++] = index->tvar[target][r]; + } + c->count = (uint8_t)w; c->rsv[1] &= (uint8_t)~mask; + if (!w) c->rsv[2] = SONG_MODE_TAG; + for (; w < CHAIN_ROWS; w++) { + c->row[w] = (chain_row_t){0,1}; + memset(&index->scene[target][w], 0, sizeof(scene_t)); + index->tsrc[target][w] = index->tvar[target][w] = 0; + } +} +/* parts=0 erases a saved project; a part in a draft is RAM-only. Tombstone + * commits preserve each object's previous copy on a failed write. Multi-part + * erasure is not atomic across a power failure; a failed current-project erase + * keeps its RAM and queues completed parts for restoration. */ +static int song_erase_parts(uint32_t target, uint32_t parts) +{ + song_index_t *index = (song_index_t *)proj_wire_u.raw; + uint32_t mask = parts ? parts : 15u, done = 0, k; + int draft = parts && song_draft && target == song_cur; + if (!bt_hw_seg()) { ui_message("UPDATE PACKAGE"); return 1; } + if (target >= NSONG || transport_busy()) { ui_message("STOP TO ERASE"); return 1; } + if (draft) { memcpy(index, &song_idx, sizeof *index); index->rows[target] = chain_config; } + else if (song_saved_index(index)) { ui_message("SAVE INDEX ERROR"); return 1; } + song_remove_parts(index, target, mask); +#if FELUCCA_FLASH + if (!draft && !flash_ok) { ui_message("NO FLASH: NOT ERASED"); return 1; } + if (!draft && flash_ok) { + for (k = 0; k < 4u; k++) if ((mask >> k) & 1u) { + uint32_t obj = target ? OBJ_SONG1 + (target - 1u) * 4u + k : OBJ_PROJECT0 + k; + if (st_save(obj, 0, 0)) goto failed; + done |= 1u << k; + } + if (!parts && target == song_cur && st_save(OBJ_AUTOSAVE, 0, 0)) goto failed; + if (st_save(OBJ_SONGIDX, index, sizeof *index)) goto failed; + } +#endif + if (!song_draft || target != song_cur || draft) song_index_target(index, target); + if (target == song_cur && (!song_draft || draft)) { + chain_config = song_idx.rows[target]; + for (k = 0; k < 4u; k++) if ((mask >> k) & 1u) memset(&proj_slot[k], 0, sizeof proj_slot[k]); + live.dirty &= (uint8_t)~mask; + if (live.cur >= 0 && ((mask >> live.cur) & 1u)) live.cur = -1; + if (!chain_config.count) live.mode = 0; + if (!parts) { system_init(); proj_cur = PROJ_NO_SLOT; live.cur = -1; } + ui.song_row = 0; + } + proj_wire_gen++; ui.force = 1; + ui_message(parts ? "PART ERASED" : "PROJECT ERASED"); + return 0; +#if FELUCCA_FLASH +failed: + if (target == song_cur && !song_draft) live.dirty |= (uint8_t)done; + proj_wire_gen++; + ui_message("ERASE ERROR: RETRY"); return 2; +#endif +} diff --git a/firmware/src/ui.c b/firmware/src/ui.c index b5aaf985..af42cd4a 100644 --- a/firmware/src/ui.c +++ b/firmware/src/ui.c @@ -13,6 +13,10 @@ static uint32_t trk_eng(const track_t *t) { return t->eng_req % NENGINES; } /* static const engine_t *trk_engp(const track_t *t) { return ENGINES[trk_eng(t)]; } /* .. its engine's table */ static int project_save(uint32_t slot); static int song_save_as(uint32_t target, const char *name); +static int song_draft_begin(void); +static int song_erase_parts(uint32_t target, uint32_t parts); +static void song_poll(void); +static uint8_t song_save_loop; static void song_name(char *b); static uint8_t song_save_target __attribute__((section(".pool"))); /* destination picker: never opens the project */ static void panel_setup(void); @@ -349,7 +353,7 @@ static uint16_t val_col(uint32_t c) { return c == ui.hot_col && ui.hot_t ? T_ACC enum { CF_NONE, CF_CLEAR_SEQ, CF_CLEAR_TRK, CF_OVR_PROJ, CF_OVR_USER, CF_LOAD_PAT, CF_DEL_ROW, CF_CLEAR_SONG, CF_INIT_SOUND, CF_CLEAR_MOTION, CF_ERASE_USER, CF_CLEAR_PFX, CF_RECALL_SOUND, CF_CLEAR_ALL, CF_DICE_ALL, CF_INIT_SYS, CF_DICE_SOUND, CF_DICE_SEQ, CF_DICE_LFO, - CF_DICE_FX, CF_CPU_TEST, CF_MUT_BACK, CF_LIVE_COMMIT, CF_ERASE_SECT, CF_OVR_SONG }; /* ui.confirm: TOOLS' clears; (0.6.21) HOME + SELECT: + CF_DICE_FX, CF_CPU_TEST, CF_MUT_BACK, CF_LIVE_COMMIT, CF_ERASE_SECT, CF_OVR_SONG, CF_ERASE_SONG }; /* ui.confirm: TOOLS' clears; (0.6.21) HOME + SELECT: * everything diced; (0.6.65) EDIT + SELECT: keep the diced sound?; (0.6.67) SEQ / LFO / FX + SELECT: * keep the diced sequence / LFO / effects?; * SAVE over a used slot; a pattern over the user's steps; @@ -802,8 +806,7 @@ static void page_entered(void) { const page_t *pg = cur_page(); br_armed = 0; - if (pg->graph == GR_SONGSAVE && song_save_target == song_cur) - song_save_target = (uint8_t)((song_cur + 1u) % NSONG); + if (pg->graph == GR_SONGSAVE && !song_draft) song_save_target = song_cur; ui.knob_ms = fm1_ms; /* (0.9.0) HUD: the knob row whole again on a new page */ if (!ui.home && pg->fam == FAM_FX && fx_trk_k(ui.page) < 0 && pg->graph != GR_BUSES) ui.fxmod = (uint8_t)fx_mod_of(ui.page); /* (FX: the effect shown, BUSES' tile lit) */ @@ -1944,7 +1947,7 @@ static uint32_t act_cols(void) /* the columns that are actions if (pg->graph == GR_SONGSAVE) return 8u; if (pg->graph == GR_USER) return 14u; /* LOAD ERASE SAVE */ - if (pg->graph == GR_SLOTS && save_on() && save_level() == SV_PROJ) + if (pg->graph == GR_SLOTS && save_on()) return 14u; /* (V10.17) SECTIONS: ERASE LOAD SAVE */ if (pg->scope == SC_GLOBAL) for (c = 0; c < 4u; c++) @@ -1999,7 +2002,7 @@ static int act_ready(void) uint32_t c = act_col(), s = song.sel, id; if (!c--) return 0; - if (cur_page()->graph == GR_SONGSAVE) return !transport_busy() && song_save_target != song_cur; + if (cur_page()->graph == GR_SONGSAVE) return !transport_busy(); 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; @@ -2013,7 +2016,7 @@ static int act_ready(void) if (cur_page()->graph == GR_USER) 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 project_used((uint32_t)song.g[G_SLOT] - 1u) && !transport_busy(); + return !transport_busy() && (save_level() == SV_LIB || project_used((uint32_t)song.g[G_SLOT] - 1u)); 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 cddd96bb..963d35b1 100644 --- a/firmware/src/ui_draw.c +++ b/firmware/src/ui_draw.c @@ -1643,9 +1643,9 @@ static void draw_columns(void) if (cur_page()->graph == GR_SONGSAVE) { fmt_int(val, (int32_t)song_save_target + 1); hot_gauge_column(0, "DEST", val, song_save_target * 1000 / (NSONG - 1u)); - empty_column(1); + text_column(1, "SCOPE", song_save_loop ? "LOOP" : "SONG", T_TEXT); empty_column(2); - draw_act_column(3, "SAVE SONG", T_THEME, ICON_AUTO); + draw_act_column(3, "SAVE", T_THEME, ICON_AUTO); return; } if (cur_page()->graph == GR_SLOTS) { /* (0.6.12) PROJECT, SECT A-D, then LOAD and SAVE */ @@ -1656,10 +1656,9 @@ static void draw_columns(void) hot_gauge_column(0, "SECT", val, (int32_t)(k & 3u) * 1000 / 3); draw_act_column(1, "ERASE", used ? T_THEME : T_DIM, ICON_AUTO); /* (V10.17; the name: the card) */ } else { - fmt_int(val, (int32_t)song_cur + 1); - hot_gauge_column(0, "PROJECT", val, (int32_t)song_cur * 1000 / (int32_t)(NSONG - 1u)); - val[0] = (char)('A' + (k & 3u)); val[1] = 0; - hot_gauge_column(1, "SECT", val, (int32_t)(k & 3u) * 1000 / 3); + fmt_int(val, (int32_t)(song_draft ? song_save_target : song_cur) + 1); + 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(3, "SAVE", T_THEME, ICON_AUTO); @@ -2130,10 +2129,10 @@ static void confirm_text(char *a, char *b) a[12] = (char)('1' + k % NTRK); break; case CF_OVR_SONG: - str_cpy(a, "REPLACE WHOLE SONG ", 24); + str_cpy(a, "OVERWRITE PROJECT ", 24); fmt_int(a + str_len(a), (int32_t)k + 1); str_cpy(a + str_len(a), "?", 2); - str_cpy(b, "ALL A-D + ARRANGEMENT", 24); + str_cpy(b, song_save_loop ? "LOOP A; CLEAR B-D" : "ALL A-D + ARRANGEMENT", 24); break; case CF_OVR_PROJ: str_cpy(a, "OVERWRITE PROJECT A?", 24); @@ -2192,6 +2191,10 @@ static void confirm_text(char *a, char *b) str_cpy(a + str_len(a), "?", 2); up_name(k, b); /* the sound stored there */ break; + case CF_ERASE_SONG: + str_cpy(a, "ERASE PROJECT ", 24); fmt_int(a + str_len(a), (int32_t)k + 1); str_cpy(a + str_len(a), "?", 2); + str_cpy(b, "ALL A-D + ARRANGEMENT", 24); + break; case CF_ERASE_SECT: /* (V10.17) SAVE > SECTIONS > ERASE */ str_cpy(a, "ERASE SECT A?", 24); a[11] = (char)('A' + (k & 3u)); diff --git a/firmware/src/ui_input.c b/firmware/src/ui_input.c index 332b28df..df258d64 100644 --- a/firmware/src/ui_input.c +++ b/firmware/src/ui_input.c @@ -1444,6 +1444,9 @@ static void edit_param(uint32_t slot, int32_t steps) ui.force = 1; return; } + if (pg->graph == GR_SONGSAVE && slot == 1u) { + song_save_loop = (uint8_t)clamp((int32_t)song_save_loop + steps, 0, 1); return; + } if (pg->graph == GR_SONGSAVE && slot == 0u) { song_save_target = (uint8_t)clamp((int32_t)song_save_target + steps, 0, NSONG - 1); return; @@ -1466,8 +1469,9 @@ static void edit_param(uint32_t slot, int32_t steps) } sect: if (pg->graph == GR_SLOTS && slot == 0u) { /* (0.6.12) KNOB 1 the project: its sections, the music kept */ - int32_t n = clamp((int32_t)song_cur + (steps > 0 ? 1 : -1), 0, (int32_t)NSONG - 1); - if ((uint32_t)n != song_cur) (void)song_open((uint32_t)n); + int32_t n = clamp((int32_t)(song_draft ? song_save_target : song_cur) + (steps > 0 ? 1 : -1), 0, (int32_t)NSONG - 1); + if (song_draft) song_save_target = (uint8_t)n; + else if ((uint32_t)n != song_cur) (void)song_open((uint32_t)n); return; } if (pg->graph == GR_USER) { /* KNOB 1 the slot */ @@ -1632,19 +1636,30 @@ static void act_do(void) char title[13]; ui.act = 0; if (transport_busy()) ui_message("STOP TO SAVE"); - else if (song_save_target == song_cur) ui_message("CHOOSE ANOTHER PROJECT"); - else if (lib_scan(song_save_target, title) || song_idx.rows[song_save_target].count) + else if (lib_scan(song_save_target, title) || ((!song_draft || song_save_target != song_cur) && song_idx.rows[song_save_target].count)) confirm_open(CF_OVR_SONG, song_save_target); else name_open(NK_SONG_SAVE, song_save_target); return; } + if (cur_page()->graph == GR_SLOTS && save_level() == SV_LIB) { + uint32_t target = song_draft ? song_save_target : song_cur; + if (c == 1u) { + ui.act = 0; + if (transport_busy()) ui_message("STOP TO ERASE"); + else confirm_open(CF_ERASE_SONG, target); + } else if (c == 2u && song_draft) (void)song_select(target); + else if (c == 3u) nav_put(SEC_SAVE, "SAVE SONG AS"); + else goto slot_action; + return; + } if (cur_page()->graph == GR_SLOTS && c == 1u) { /* (V10.17) SECTIONS: ERASE, the dialog first */ ui.act = 0; if (transport_busy()) ui_message("STOP TO ERASE"); else if (!project_used(k)) ui_message("EMPTY SECTION"); - else confirm_open(CF_ERASE_SECT, k); + else confirm_open(CF_ERASE_SECT, (song_cur << 2u) | (k & 3u)); return; } +slot_action: id = cur_page()->id[c & 3u]; if (id != G_LOAD) ui.act = 0; @@ -2563,7 +2578,7 @@ static void ui_input_frame(void) uint32_t kind = ui.confirm; ui.confirm = 0; ui.force = 1; - if (kind != CF_OVR_PROJ && kind != CF_OVR_USER && kind != CF_ERASE_USER && kind != CF_ERASE_SECT && kind != CF_OVR_SONG && kind != CF_DICE_ALL && + if (kind != CF_OVR_PROJ && kind != CF_OVR_USER && kind != CF_ERASE_USER && kind != CF_ERASE_SECT && kind != CF_OVR_SONG && kind != CF_ERASE_SONG && kind != CF_DICE_ALL && !dice_kind(kind) && kind != CF_DEL_ROW && kind != CF_CLEAR_SONG && !chain_busy()) undo_mark(); /* (0.6.21) the music before a clear, INIT, RECALL, pattern */ if (kind == CF_OVR_PROJ) { /* overwrite: the NAME screen writes it */ @@ -2574,8 +2589,11 @@ static void ui_input_frame(void) name_open(NK_USER_SAVE, ui.confirm_trk); } else if (kind == CF_ERASE_USER) { up_ui(1u, ui.confirm_trk); + } else if (kind == CF_ERASE_SONG) { + song_erase_parts(ui.confirm_trk, 0); } else if (kind == CF_ERASE_SECT) { - project_erase(ui.confirm_trk & 3u); + if ((ui.confirm_trk >> 2u) == song_cur) project_erase(ui.confirm_trk & 3u); + else ui_message("PROJECT CHANGED"); } else if (dice_kind(kind)) { /* (0.6.65) OK: the diced part stays */ ui_message(dk.msg); } else if (kind == CF_LOAD_PAT) { @@ -2798,7 +2816,7 @@ static void ui_input_frame(void) if (b & 1u) page_tap(panel_btn_of(id)); if (gen_on() && (oct & 2u)) { /* (0.9.2) GEN, HOME's pages: OCT+ the piece (the screen stays, */ - if (!chain_busy()) gen_press(); /* OCT+ again: another), OCT- back to ECO */ + gen_press(); /* OCT+ again: another), OCT- back to ECO */ } else if (gen_on() && (oct & 1u)) { nav_go(SEC_HOME, 0, 0); } else if (act_cols() && (oct & 2u)) { /* action pages: OCT+ does the picked action, */ diff --git a/firmware/src/ui_lens.c b/firmware/src/ui_lens.c index e78d2ada..7fca3be4 100644 --- a/firmware/src/ui_lens.c +++ b/firmware/src/ui_lens.c @@ -220,10 +220,6 @@ static void nav_go(uint32_t sec, uint32_t e, int outside) if (sec == SEC_HOME) { if (e >= 4u) { /* GEN: the generator's screen, HOME's last group */ if (!gen_on()) { - if (chain_busy()) { - ui_message("SONG PLAYS: STOP IT TO EDIT"); - return; - } confirm_open(CF_DICE_ALL, song.sel); gen_open(); } diff --git a/firmware/src/ui_lzsave.c b/firmware/src/ui_lzsave.c index e1e30afe..0f701566 100644 --- a/firmware/src/ui_lzsave.c +++ b/firmware/src/ui_lzsave.c @@ -28,8 +28,8 @@ static void graph_lib(void) uint32_t i, j; for (i = 0; i < NSONG; i++) { int32_t x = LZ_TX(i % 4u), y = (int32_t)(i / 4u) * 70; - int cur = i == song_cur; - int pick = cur_page()->graph == GR_SONGSAVE ? i == song_save_target : cur; + int cur = i == song_cur && !song_draft; + int pick = cur_page()->graph == GR_SONGSAVE || song_draft ? i == song_save_target : cur; uint16_t bg = pick ? T_TINT : T_RAISE; char b[4], nm[13]; cv_rect(x, y, 56, 66, bg); diff --git a/firmware/src/ui_name.c b/firmware/src/ui_name.c index 686d0c63..81b410fd 100644 --- a/firmware/src/ui_name.c +++ b/firmware/src/ui_name.c @@ -94,7 +94,7 @@ static void name_open(uint32_t kind, uint32_t slot) return; } if (kind == NK_SONG_SAVE) { - str_cpy(nm.ph, "SONG", sizeof nm.ph); + str_cpy(nm.ph, song_save_loop ? "LOOP" : "SONG", sizeof nm.ph); song_name(b); } else if (kind == NK_USER_SAVE || kind == NK_USER_RENAME) { uint32_t e = kind == NK_USER_RENAME ? up_engine(slot) : TSEL->eng_req; @@ -327,7 +327,7 @@ static uint32_t name_leds(void) static void nm_title(char *b) { if (nm.kind == NK_SONG_SAVE) { - str_cpy(b, "SAVE SONG TO PROJECT ", 24); + str_cpy(b, song_save_loop ? "SAVE LOOP TO PROJECT " : "SAVE SONG TO PROJECT ", 24); fmt_int(b + str_len(b), (int32_t)nm.slot + 1); return; } diff --git a/tests/gen_test.c b/tests/gen_test.c index 99cec855..bba2cbd8 100644 --- a/tests/gen_test.c +++ b/tests/gen_test.c @@ -521,8 +521,8 @@ int main(void) ok = live.mode == 1 && chain_config.count == 6u && (dice_secs & 15u) == 15u; section_store(1); gen_with(1, 33, 60, 2); - ok &= live.mode == 1 && chain_config.count == 6u && str_eq(ui.msg2, "USE AN EMPTY PROJECT"); - bad += gcheck("FORM after a power cycle: the song written again; a section of the player's kept, and said", ok); + ok &= live.mode == 1 && chain_config.count == 6u && song_draft && !gform_kept; + bad += gcheck("FORM generates a complete draft even when prior parts were stored", ok); } } /* ---- (0.6.97) the kit's space, the top end's variety, Hook's register, the lead's envelope */ diff --git a/tests/persistence_test.c b/tests/persistence_test.c index 4757bb95..d8efa2e0 100644 --- a/tests/persistence_test.c +++ b/tests/persistence_test.c @@ -76,6 +76,7 @@ static int check(const char *what, int ok) static void reset(void) { + song_draft = song_save_loop = 0; memset(nor, 0xFF, sizeof nor); memset(&song, 0, sizeof song); memset(trk, 0, sizeof trk); @@ -506,6 +507,7 @@ static int songs_test(void) #include "voice_user_cases.h" #include "split_storage_cases.h" +#ifndef PERSISTENCE_TEST_NO_MAIN int main(void) { int bad = 0, ok; @@ -860,3 +862,5 @@ int main(void) return bad != 0; } + +#endif diff --git a/tests/song_draft_test.c b/tests/song_draft_test.c new file mode 100644 index 00000000..e525bc4d --- /dev/null +++ b/tests/song_draft_test.c @@ -0,0 +1,76 @@ +/* Generated RAM workspace and explicit LOOP/SONG saves against real NOR model. */ +#define PERSISTENCE_TEST_NO_MAIN 1 +#include "persistence_test.c" +#include +static uint8_t old_flash[8*ST_SECTOR]; +static song_index_t saved_index; +static project_store_t draft_before[4]; +static uint32_t object(unsigned n,unsigned s){return n?OBJ_SONG1+(n-1)*4+s:OBJ_PROJECT0+s;} +static void draft_music(unsigned note) +{ + for(unsigned s=0;s<4;s++) { + trk[0].step[0]=(step_t){{note+s},1,ST_NOTE,0,100};section_store(s); + } + chain_defaults(&chain_config);chain_config.count=4;live.mode=1; + for(unsigned s=0;s<4;s++)chain_config.row[s]=(chain_row_t){s,1}; + dice_secs=15;section_load(0); +} +static int saved_note(unsigned n,unsigned s) +{ + int z=st_load(object(n,s),&proj_wire,sizeof proj_wire); + if(z<=0)return -1; + assert(proj_import(&proj_scratch,&proj_wire,sizeof proj_wire));return proj_scratch.t[0].step[0].note[0]; +} +int main(void) +{ + song_fixture(); + assert(!song_draft_begin()&&song_draft); + memcpy(old_flash,nor+0x97000,sizeof old_flash); + assert(st_load(OBJ_SONGIDX,&saved_index,sizeof saved_index)==sizeof saved_index); + unsigned writes=erases; + draft_music(64);song_poll();fm1_ms+=100000;autosave_poll(); + assert(erases==writes&&!memcmp(old_flash,nor+0x97000,sizeof old_flash)); + for(unsigned n=0;n<4;n++)assert(saved_note(0,n)==48+(int)n); + assert(!song_draft_begin());draft_music(72);song_poll(); + assert(erases==writes&&!memcmp(old_flash,nor+0x97000,sizeof old_flash)); + puts("draft: regeneration and idle polling never write saved projects or autosave"); + assert(!song_save_as(1,"FULL SONG")); + for(unsigned n=0;n<4;n++)assert(saved_note(1,n)==72+(int)n); + assert(st_load(OBJ_SONGIDX,&proj_wire,sizeof saved_index)==sizeof saved_index); + assert(!memcmp(&((song_index_t*)&proj_wire)->rows[0],&saved_index.rows[0],sizeof(chain_config_t))); + assert(!memcmp(old_flash,nor+0x97000,sizeof old_flash)); + assert(song_draft&&chain_config.count==4); + puts("draft: saving a full song elsewhere preserves the original project and current draft"); + song_save_loop=1;assert(!section_load(2));assert(!song_save_as(2,"JUST LOOP")); + assert(saved_note(2,0)==74);for(unsigned n=1;n<4;n++)assert(saved_note(2,n)==-1); + assert(song_idx.rows[2].count==0&&chain_config.count==4&&song_draft); + puts("draft: LOOP writes current music to A, empties B-D and saves no arrangement"); + song_save_loop=0;assert(!song_save_as(0,"OVERWRITE")); + for(unsigned n=0;n<4;n++)assert(saved_note(0,n)==(n==2?74:72+(int)n)); + assert(song_draft&&chain_config.count==4); + memcpy(draft_before,proj_slot,sizeof draft_before); + erase_error=1;assert(song_save_as(3,"FAIL")&&song_draft&&!memcmp(draft_before,proj_slot,sizeof draft_before));erase_error=0; + assert(!song_save_as(3,"RETRY")); + puts("draft: same-project overwrite is explicit; failed saves retain the draft for retry"); + assert(!song_erase_parts(1,0));for(unsigned n=0;n<4;n++)assert(saved_note(1,n)==-1); + assert(song_draft&&!memcmp(draft_before,proj_slot,sizeof draft_before)); + writes=erases;assert(!project_erase(1));assert(!project_used(1)&&erases==writes); + for(unsigned r=0;rgraph == GR_SONGSAVE && song_save_target != song_cur && !name_on()); + cur_page()->graph == GR_SONGSAVE && song_save_target == song_cur && !name_on()); - /* Saved user sections must never cause SONG generation to degrade silently - * into a new loop while erasing the arrangement. */ + /* A saved/non-generated section is no longer a dead end. GEN owns only + * the draft buffers and may replace them, even while the previous song plays. */ make_song(1, 31); - section_store(1); - chain_config_t rows = chain_config; - uint32_t slots = proj_hash(proj_slot, sizeof proj_slot), music = dice_print(); - gp.seed = 32; gen_go(); - bad += check("protected A-D refuses before changing music, sections, mode or arrangement", - gform_kept && live.mode && !memcmp(&rows, &chain_config, sizeof rows) && - music == dice_print() && slots == proj_hash(proj_slot, sizeof proj_slot) && - str_eq(ui.msg2, "USE AN EMPTY PROJECT")); - - song_poll(); - live.mode = 0; song_index_boot(); - bad += check("saved SONG mode survives boot of the same project", live.mode == 1); - live.mode = 0; song_poll(); - live.mode = 1; song_index_boot(); - bad += check("explicit LOOP mode also survives boot", live.mode == 0); + section_store(1); live.mode = 1; + nav_put(SEC_HOME, "GEN 2"); frame(); + press(B_PLAY); events_block(CTL); song_poll(); + uint32_t before_seed = gp.seed; gp.sig = gen_sig(); + press(B_OCTUP); events_block(CTL); song_poll(); frame(); + bad += check("GEN 2 rerolls a playing song as a draft and resumes arrangement playback", + song_draft && !gform_kept && chain_config.count >= 4 && song.playing && chain.running && gp.seed != before_seed); + screen_save("build/song-check", "generator-draft-page2"); + nav_put(SEC_HOME, "GEN 3"); frame(); + bad += check("GEN 3 keeps real parts visible while editing generator settings", gen_page()==2 && chain_config.count>=4); + screen_save("build/song-check", "generator-draft-page3"); + seq_stop();song_poll(); + 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; + /* Draft arrangements intentionally do not overwrite the saved boot index. */ + song_draft=0;song_poll(); + live.mode=0;song_index_boot(); + bad += check("committed SONG mode survives boot", live.mode==1); + live.mode=0;song_poll();live.mode=1;song_index_boot(); + bad += check("committed LOOP mode survives boot", live.mode==0); chain_config_t old = chain_config; old.rsv[2] = 0; song_idx.rows[song_cur] = old; live.mode = 0; song_index_boot(); diff --git a/tests/song_save_cases.h b/tests/song_save_cases.h index f2b272ae..d4711fba 100644 --- a/tests/song_save_cases.h +++ b/tests/song_save_cases.h @@ -78,10 +78,10 @@ static int song_save_test(void) before = erases; song.playing = 1; ok = song_save_as(1, "X") != 0; song.playing = 0; transport_req = 1; ok &= song_save_as(1, "X") != 0; transport_req = 0; - ok &= song_save_as(0, "X") != 0 && song_save_as(8, "X") != 0; + ok &= song_save_as(8, "X") != 0; flash_ok = 0; ok &= song_save_as(1, "X") != 0; flash_ok = 1; ok &= erases == before; - bad += check("playing, pending PLAY, same slot, invalid slot and no flash refuse without writing", ok); + bad += check("playing, pending PLAY, invalid slot and no flash refuse without writing", ok); song_fixture(); memset(&proj_slot[3], 0, sizeof proj_slot[3]); diff --git a/tests/song_save_ui_cases.h b/tests/song_save_ui_cases.h index d9f67483..211b8b22 100644 --- a/tests/song_save_ui_cases.h +++ b/tests/song_save_ui_cases.h @@ -11,8 +11,8 @@ static int test_song_save_ui(void) live.cur = -1; name_close(); nav_put(SEC_SAVE, "SAVE SONG AS"); frame(); - ok = cur_page()->graph == GR_SONGSAVE && save_level() == SV_PROJ && ui.act == 4u && song_save_target != song_cur; - bad += check("SAVE SONG AS is a PROJECT page with SAVE armed and another destination", ok); + ok = cur_page()->graph == GR_SONGSAVE && save_level() == SV_PROJ && ui.act == 4u && song_save_target == song_cur; + bad += check("SAVE SONG AS is a PROJECT page with SAVE armed and the current destination", ok); target = song_save_target; turn(EN_K1, 1); frame(); ok = song_save_target == target + 1u && song_cur == 0 && live.cur == -1; @@ -28,7 +28,7 @@ static int test_song_save_ui(void) turn(EN_K4, 1); press(B_OCTUP); frame(); ok = ui.confirm == CF_OVR_SONG && !name_on(); confirm_text(a, b); - ok &= strstr(a, "REPLACE WHOLE SONG") != 0 && !strcmp(b, "ALL A-D + ARRANGEMENT"); + ok &= strstr(a, "OVERWRITE PROJECT") != 0 && !strcmp(b, "ALL A-D + ARRANGEMENT"); press(B_OCTDN); frame(); ok &= !ui.confirm && !name_on(); bad += check("occupied destination asks whole-song overwrite; cancel writes nothing", ok); @@ -41,7 +41,9 @@ static int test_song_save_ui(void) bad += check("overwrite confirmation leads to naming; failed save keeps the name open", ok); song_save_target = song_cur; turn(EN_K4, 1); press(B_OCTUP); frame(); - bad += check("current project is refused, so SAVE AS cannot overwrite its source", !name_on() && !ui.confirm && strstr(ui.msg, "ANOTHER PROJECT") != 0); + bad += check("current project is available as an explicit save destination", name_on() || ui.confirm == CF_OVR_SONG); + if (name_on()) { press(B_OCTDN); frame(); } + else if (ui.confirm) { press(B_OCTDN); frame(); } song_save_target = 2; song.playing = 1; turn(EN_K4, 1); press(B_OCTUP); frame(); diff --git a/tests/ui_test.c b/tests/ui_test.c index 09de8eba..c0bb2c02 100644 --- a/tests/ui_test.c +++ b/tests/ui_test.c @@ -175,6 +175,7 @@ static int check(const char *what, int ok) static void ui_power_on(void) { uint32_t i; + song_draft = song_save_loop = 0; memset(split_cfg, 0, sizeof split_cfg); memset(&midi_map, 0, sizeof midi_map); if (!lyb_ok) sing_init(); /* (0.9.0: as felucca_init, VOICE's English generator words) */ @@ -7565,7 +7566,9 @@ static int test_save_lens(void) ok &= song_cur == 0u && (TSEL->preset != pr || TSEL->eng_req != trk_def_engine(0)) && cur_page()->graph == GR_SLOTS; bad += check("0.9.2 SAVE > PROJECTS: KNOB 1 the project; PRESETS a sound (was the project)", ok); ok = 1; - turn(EN_K4, 1); press(B_OCTUP); frame(); /* SAVE: the NAME screen, its own layout */ + turn(EN_K4, 1); press(B_OCTUP); frame(); /* PROJECTS opens explicit save scope first. */ + ok &= cur_page()->graph == GR_SONGSAVE && !name_on(); + press(B_OCTUP); frame(); ok &= name_on() && !lz_on(); press(B_OCTDN); frame(); ok &= !name_on() && lz_on(); @@ -8815,11 +8818,11 @@ static int test_project_page(void) ok = song_cur == 1 && trk[0].step[0].note[0] == 80 && live.cur < 0 && !chain_config.count && msg_is("PROJECT 2"); bad += check(" KNOB 1: project 2 in (its sections, its song), the music kept", ok); song.g[G_SLOT] = 1; - turn(EN_K2, 1); frame(); /* LIBRARY: KNOB 2 the section */ - ok = song.g[G_SLOT] == 2 && save_level() == SV_LIB; + turn(EN_K2, 1); frame(); /* PROJECTS: KNOB 2 selects ERASE, never a different part. */ + ok = song.g[G_SLOT] == 1 && save_level() == SV_LIB && ui.act == 2; turn(EN_SELECT, -1); frame(); /* (V10.1) SONG's SECTIONS (one back): KNOB 1 */ ok &= save_level() == SV_PROJ && cur_page()->graph == GR_SLOTS; - turn(EN_K1, 1); frame(); + turn(EN_K1, 2); frame(); ok &= song.g[G_SLOT] == 3; turn(EN_K1, 1); frame(); ok &= song.g[G_SLOT] == 4 && song_cur == 1; @@ -8829,7 +8832,7 @@ static int test_project_page(void) ok &= ui.act == 0u; turn(EN_K1, -1); frame(); ok &= song.g[G_SLOT] == 3; - bad += check(" LIBRARY's KNOB 2, SECTIONS' KNOB 1: the section (C); SECTIONS' KNOB 2 ERASE (V10.17)", ok); + bad += check(" PROJECTS KNOB 2 ERASE; SECTIONS KNOB 1 selects C, KNOB 2 erases the part", ok); turn(EN_K4, 1); press(B_OCTUP); frame(); /* SAVE into project 2's C: the NAME screen, then OK */ for (k = 0; k < 8u && name_on(); k++) { press(B_OCTUP); frame(); } ok = project_used(2) && live.cur == 2; @@ -8843,7 +8846,7 @@ static int test_project_page(void) press(B_OCTDN); frame(); ok &= !ui.confirm && project_used(2); turn(EN_K2, 1); press(B_OCTUP); frame(); press(B_OCTUP); frame(); /* .. OCT+ erases it */ - ok &= !ui.confirm && !project_used(2) && live.cur < 0 && msg_is("ERASED SECT C") && trk[0].step[0].note[0] == 80; + ok &= !ui.confirm && !project_used(2) && live.cur < 0 && msg_is("PART ERASED") && trk[0].step[0].note[0] == 80; turn(EN_K2, 1); press(B_OCTUP); frame(); /* (empty now: no dialog) */ ok &= !ui.confirm; bad += check("V10.17 SECTIONS KNOB 2 ERASE: the dialog (ERASE SECT C?), then EMPTY; the music stays; not playing", ok); diff --git a/tools/size_fns.py b/tools/size_fns.py index cda21cb8..d8173f57 100644 --- a/tools/size_fns.py +++ b/tools/size_fns.py @@ -103,7 +103,9 @@ def main(src, dst): # Sparse MIDI control dispatch runs per received message, never per rendered sample. # Keep synthesis, clocks, DMA, note release and ownership queries at -Os. input_size = {"midi_event", "midi_control", "midi_cc_map", "midi_cc_set", "midi_learned", "midi_route_ch14"} - names, hit = (size_names() - isr) | input_size, set() + cold_ui = {"mod_dst_ok", "mod_dst_offer_bt", "mod_dst_name_bt", "gen_value", "gen_cards_bt", "gen_panel_bt", + "song_index_target", "song_remove_parts"} + names, hit = ((size_names() | cold_ui) - isr) | input_size, set() def mark(m): if m.group(2) not in names: