diff --git a/GUIDE.md b/GUIDE.md index 3f7f6c8..a7b26df 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -154,9 +154,9 @@ The layers are **FX** (punch-in effects), **EDIT** (erase), **ARP** (note repeat | **LFO** | LFO pages (LFO, LFO DEST) | — | | **FX** | FX pages (FX, FILTER, SLICER, DLY, REV/CHO) | punch-in layer | | **SEL** | SEL pages (SEL, SEL 2) | key / chord layer | -| **EDIT** | EDIT pages (EDIT 1, EDIT 2, VOICE, VOICE 2) · on TRACKS with the drum track: the **DRUMS** screen · on DRUMS: grid ↔ kit · on the STEP page: clear the step | erase layer | +| **EDIT** | EDIT pages (EDIT 1, EDIT 2, VOICE, VOICE 2) · on TRACKS with the drum track: the **DRUMS** screen · on DRUMS: grid ↔ kit · on the NOTES page: delete the note | erase layer | | **ARP** | ARP pages (ARP, ARP 2) | note-repeat layer | -| **SEQ** | SEQ pages (STEP, PATTERN, SONG) · on TRACKS with the drum track: the **DRUMS** screen · on DRUMS: grid ↔ kit | step layer | +| **SEQ** | SEQ pages (STEP, PATTERN, SONG) · with the drum track: the **DRUMS** screen (2.7.1: from any page; it opened STEP from ARP's) · on DRUMS: grid ↔ kit | step layer | | **GLO** | GLO pages (GLOBAL, MASTER, SYSTEM, DRUMS) | mix layer | | **OCT− / OCT+** | synth track: octave down / up (−3 … +3) · both together: octave 0 | drum track: **ghost** (OCT−) / **hard** (OCT+) hits while held | | **ALGORITHM** | select track 1–4, on every screen (inside a layer it waits; not during a free take, on the SONG screen or in the menu) | — | @@ -198,7 +198,7 @@ The layers are **FX** (punch-in effects), **EDIT** (erase), **ARP** (note repeat ### Velocity and levels -The FM-1's keys have no velocity: on the drum track every hit has one of four **levels** — **GHOST**, **SOFT**, **NORM** (as played), **HARD** — chosen with OCT− / OCT+ as you play, or later in the step sequencer. On synth tracks a step can carry an **accent** (STEP page, FLAG). +The FM-1's keys have no velocity: on the drum track every hit has one of four **levels** — **GHOST**, **SOFT**, **NORM** (as played), **HARD** — chosen with OCT− / OCT+ as you play, or later in the step sequencer. On synth tracks a note has a **FORCE** too, and a step an **accent** (NOTES page, KNOB 4). --- @@ -240,12 +240,13 @@ Open it with **EDIT** or **SEQ** tapped on the TRACKS screen while the drum trac | Control | Does | | --- | --- | -| KNOB 1 **sound** | picks the sound (lane) — you hear it | -| KNOB 2 **step** | moves to a step — you hear what it holds | +| KNOB 1 **sound** | picks the sound (lane); (2.7.1) heard only with MENU → SEQ → **DRUM PREVIEW ON** (OFF by default, quiet for live) | +| KNOB 2 **step** | moves to a step (DRUM PREVIEW ON: you hear what it holds) | | KNOB 3 **hit** | right: a hit of that sound on that step (NORM) · left: clear it | | KNOB 4 **level** | the hit's level up / down (GHOST, SOFT, NORM, HARD) | -| **white keys** | the 16 steps of the sound KNOB 1 picks: press to set the step (you hear it), again to clear it; the keys light that sound's steps | -| **first four black keys** | the page of steps: 1–16, 17–32, 33–48, 49–64 | +| **white keys** | the 16 steps of the sound picked: press to set the step, again to clear it (2.7.1: silent, the pattern plays it); the keys light that sound's steps | +| **black keys** (2.7.1) | pick the sound, silently: F#3 KICK / KICK 2 · G#3 SNARE / SNARE 2 · A#3 RIM · C#4 CLAP · D#4 HAT / PEDAL · F#4 OPEN HAT · G#4 LOW TOM / HI TOM · A#4 CRASH · C#5 RIDE · D#5 SHAKER / CONGA · F#5 COWBELL (the same key again: the other sound of its pair); the black key of the sound picked is lit | +| **OCT− / OCT+** (2.7.1) | the page of steps: 1–16, 17–32, 33–48, 49–64 (round; up to the track's length). Up to 2.7: the first four black keys | | **PRESETS** | the kit | | **SAVE** | the SONG screen | | **HOME** | back to TRACKS | @@ -270,7 +271,7 @@ While the song plays in song mode, the grid's hit and level knobs wait (*STOP TH ## 8. Recording -SLOOP records live and layers every pass on top of the last (overdub). Notes go to the nearest step **as you heard it**: the ~12 ms between a key and its sound are taken back, so what you play on the beat lands on the beat. Chords are kept on the synth tracks whose VOICE is POLY (up to 4 notes a step; a MONO, LEGATO or UNISON sound, as most basses and leads, plays and records one note at a time); held notes become ties. The TRACKS page draws one mark a step; the STEP page shows a chord's other notes (*+1*, *+2*…). +SLOOP records live and layers every pass on top of the last (overdub). Notes go to the nearest step **as you heard it**: the ~12 ms between a key and its sound are taken back, so what you play on the beat lands on the beat. Chords are kept on the synth tracks whose VOICE is POLY (up to 4 notes a step; a MONO, LEGATO or UNISON sound, as most basses and leads, plays and records one note at a time); held notes become ties. (2.7.1) On a POLY track each held note goes on until its own key is let go, even while other notes start and end over it: hold a note, play others on top, and it keeps sounding in the pattern (up to 4 at once). (2.7.2) On a MONO, LEGATO or UNISON track, a note played while the one before is still held is recorded **legato** and plays back as you played it: with LEGATO the sound goes on into the new note without a new attack (it glides only with GLIDE or a SLIDE), where before the sequencer ended the note and started the next one again. It works from the FM-1's keys and from a MIDI controller alike. Let go of the second note while the first is still held: the pattern does not go back to the first one (the live sound does). The TRACKS page draws one mark a step; the NOTES page shows a chord's notes one by one (*2/3*…). **Over held notes (2.7).** On a POLY track, a note you record while held notes of the pattern ring (a pad tied over the bar) no longer cuts them: they go on under it, and your note ends where you let it go. Up to 4 notes sound at once on a track (a fifth makes the oldest held one end there). Entering steps by hand (SEQ + key) still replaces what plays, so a long note can be cut on purpose. On SLOOP 2.6 such a pattern plays the held notes again where a note was laid over them. @@ -386,12 +387,13 @@ The 16 white keys are the 16 steps of the current page; the lit ones play. | **SEQ + empty step** | sets it at once — drums: with the sound shown (KNOB 1, or the last pad you hit); synths: with the note or chord you played last (on the keys, or a MIDI keyboard: 2.6) | | **SEQ + set step (tap)** | clears it (with its nudge, locks and fill condition) | | **SEQ + several step keys held** | edit them together | -| **SEQ + first four black keys** or **SEQ + OCT− / OCT+** (no step held) | the page: steps 1–16, 17–32, 33–48, 49–64 (up to the track's length) | -| **SEQ + KNOB 1** (no step held) | the **sound** (drums, you hear it) / **note** to set | +| **SEQ + first four black keys** or **SEQ + OCT− / OCT+** (no step held) | the page: steps 1–16, 17–32, 33–48, 49–64 (up to the track's length). (2.7.1) The drum track: OCT− / OCT+ only, the black keys pick the sound | +| **SEQ + a black key** (drum track, 2.7.1) | the **sound** the steps are for, silently, as on the DRUMS grid (F#3 KICK / KICK 2 … F#5 COWBELL; the same key again: its pair). With **SEQ + HOME** (locked) both hands are free: black keys the sound, white keys its steps | +| **SEQ + KNOB 1** (no step held) | the **sound** (drums; heard with DRUM PREVIEW ON, 2.7.1) / **note** to set | | **SEQ + KNOB 2** | **DIV**: 1/4, 1/8, 1/16, 1/32, 8T, 16T, 1/2, 1BAR, 2BAR | | **SEQ + KNOB 3** | **SWING** of the track | | **SEQ + KNOB 4** | **LENGTH**: 1–64 steps | -| **SEQ + step + KNOB 1** | drums: which **sound** of the step LEVEL and RATCHET edit (you hear it) · synths: the step's **note** (every note of a chord moves together) | +| **SEQ + step + KNOB 1** | drums: which **sound** of the step LEVEL and RATCHET edit (heard with DRUM PREVIEW ON) · synths: the step's **note** (every note of a chord moves together) | | **SEQ + step + KNOB 2** | drums: **LEVEL**: ghost, soft, norm, hard · synths (2.6): **VEL**, the step's velocity 1–127 (every note of the step; an accent is taken off, as it would play at 127) | | **SEQ + step + KNOB 3** | **RATCHET**: x1–x4 | | **SEQ + step + KNOB 4** | **NUDGE**: −32 … +31 (in 1/64 of a step) | @@ -452,18 +454,23 @@ There are three ways to enter steps: 1. **Live** — REC and play (see [Recording](#8-recording)). 2. **The SEQ layer** — hold SEQ, the white keys are steps (all tracks; see [SEQ — steps](#seq--steps)). -3. **The STEP page** (synth tracks) — tap **SEQ**: the step under the cursor is written from the keys, acid style: +3. **The NOTES page** (synth tracks, 2.7.2; the STEP page before) — tap **SEQ**: the pattern as a **piano roll**, each note a bar as long as it lasts, the one you edit outlined in white with its name over it, the beats ruled, the C rows named on the left and the playhead a line. A note's **FORCE** shows as its fill: GHOST dark, SOFT hollow, NORM and HARD full, ACC a white cap; a SLIDE a dash to the next note. -| STEP page | Does | +| NOTES page | Does | | --- | --- | -| **keys** | the keys pressed together become the cursor's step (POLY: up to 4 notes; MONO, LEG and UNI: the last one); in chord mode a key writes its whole chord, CHORD+ changes included; let go of all keys and the cursor moves on · **a MIDI keyboard** too (2.6): the notes it plays together on the selected track (the track its channel plays, GLO → MIDI) become the step, as they sound; on another track's channel, stopped, the screen says *MIDI PLAYS TRACK n* (and when you record: see REC) | -| KNOB 1 **STEP** | moves the cursor | -| KNOB 2 **NOTE** | transposes the step (an empty step gets your last note) | -| KNOB 3 **TIME** / **LEN** | on an empty step, a TIE or a REST: **NOTE**, **TIE** (holds the previous note on) or **REST** · on a note (2.6): **LEN**, how many steps the note lasts: longer turns the steps after it into TIEs (it stops at the next step that has notes, and at the pattern's end: *NOTE AHEAD*, *END OF PATTERN*), shorter turns its last TIEs back into RESTs | -| KNOB 4 **FLAG** | **–**, **ACC** (accent), **SLD** (slide to the next note), **A+S** (both) | -| **EDIT (tap)** | clears the cursor's step and moves on | +| **keys** | the keys pressed together become the step under edit (POLY: up to 4 notes; MONO, LEG and UNI: the last one); in chord mode a key writes its whole chord, CHORD+ changes included; let go of all keys and it moves on to the next step (2.7.1: MENU → SEQ → **STEP ADVANCE OFF**: it stays, and the next keys write the same step again, for a chord tried twice) · **a MIDI keyboard** too (2.6): the notes it plays together on the selected track (the track its channel plays, GLO → MIDI) become the step, as they sound; on another track's channel, stopped, the screen says *MIDI PLAYS TRACK n* (and when you record: see REC) | +| KNOB 1 **NOTE** | goes from note to note: a chord's notes one by one, then the next step (the empty ones too, to put a note there); the TIEs of a note are its length, not stops | +| KNOB 2 **PITCH** | that note's pitch (a chord's others stay); an empty step gets your last note | +| KNOB 3 **LEN** | how many steps the note lasts: longer turns the steps after it into TIEs (it stops at the next step that has notes, and at the pattern's end: *NOTE AHEAD*, *END OF PATTERN*), shorter turns its last TIEs back into RESTs | +| KNOB 4 **FORCE** | **GHOST**, **SOFT**, **NORM**, **HARD**, then **ACC** (the accent: the step's, for its whole chord) | +| **PRESETS** | the zoom: 8, 16 (as it opens), 32 or 64 steps on the screen (the page with the note under edit) | +| **EDIT (tap)** | deletes the note under edit (a chord keeps its others; its last note takes the step and its TIEs) | +| **OCT−** / **OCT+** (tap) | the keys' octave, as everywhere | +| **OCT+ held** (0.4 s) | the note's **sheet**: KNOB 1 picks a row, KNOB 2 sets it, OCT+ does it, OCT− closes it — **SLIDE** (ON / OFF; OCT+ too), **NUDGE** (the step's micro timing, −32 … +31), **FILL** (NORMAL, FILL only, NO FILL), **MOVE** (KNOB 2: a step each detent, with its TIEs, nudge, fill and locks; not over another note: *NO ROOM*), **COPY** (OCT+: a copy just after it, picked, and MOVE next to place it), **DELETE** (OCT+) | -Not while recording or armed (the keys record live then). On the drum track, the STEP page shows *DRUM TRACK*: use the DRUMS grid or the SEQ layer. +EDIT + OCT− / OCT+ undo and redo the edits, as before. Not while recording or armed (the keys record live then). On the drum track, the NOTES page shows *DRUM TRACK*: use the DRUMS grid or the SEQ layer. + +**The DRUMS grid has the same sheet** (2.7.2): on the grid, **OCT+ held** opens it for the hit of KNOB 1's sound on KNOB 2's step: **RATCHET** (x1 … x4), **NUDGE** and **FILL** (the step's: every sound in it), **MOVE** (KNOB 2), **COPY** (OCT+: to the next step), **DELETE** (OCT+); OCT− closes it. OCT+ tapped still turns the page of steps. The **PATTERN** page (tap SEQ again) holds the track's **LEN**, **DIV**, **SWG** (swing) and **GATE** (how long each note lasts). @@ -670,7 +677,7 @@ Tap a button to open its first page (or the last one you used); **tap it again** | | **LFO 2** (2.6) | SYNC: OFF, 4BAR, 2BAR, 1BAR, 1/2, 1/4, 1/8, 8T, 1/16, 16T, 1/32 | TRIG: NOTE / FREE | POL: BI / UNI | — | | | **LFO DEST** | PIT: vibrato | FLT: filter wobble | SHP: shape | AMP: tremolo | | **FX** | **FX** (sends) | DST drive | CHO chorus send | DLY delay send | REV reverb send | -| | **FILTER** | FILT: one-knob filter of the track — left LP, right HP, centre OFF | — | — | — | +| | **FILTER** | FILT: one-knob filter of the track — left LP, right HP, centre OFF (the drum track too; 2.7.2: its page no longer greyed) | — | — | — | | | **SLICER** | SLCR: OFF, GATE, STUT (stutter) | PAT: pattern 1–16 | RATE: 1/8, 1/16, 1/32, 8T, 16T, 32T | DEPTH | | | **INSERT** (2.6) | INSRT: OFF, SOFT, HARD, FOLD, FUZZ, CRUSH, PHASR, FLANG, CHOR | A | B | C (what A B C are depends on the type: see [Per track](#per-track)) | | | **INSERT 2** (2.6) | MIX: dry / wet | — | — | — | @@ -711,7 +718,7 @@ Notes: - **ARP modes** (2.7, after Felucca 1.4 / 1.5.1). With C, E and G held: **UP** C E G · **DN** G E C · **UPDN** C E G E · **DNUP** G E C E · **RND** at random · **ORD** in the order you pressed them · **REPEAT** the last note you pressed, again and again (OCT ignored) · **UP+8** C E G C' (the first note again an octave above the top) · **CONV** C G E (from the outside in) · **DIVG** E G C (from the inside out) · **PINKY** C G E G (the top note between the others) · **THUMB** C E C G (the bottom note between the others) · **WALK** one step up or down at random, from the bottom · **CHORD** the held notes together (the first four), on every step, an octave higher each step through OCT. OCT spreads the list over 1–4 octaves; ARP 2 ORD PLAY keeps the order you played for the other modes. Until 2.6, ORD played as UP unless ARP 2 ORD was PLAY: now it always follows the order you pressed. - **KBD HOLD** (2.7): ARP 2 → **HOLD ON** with ARP → **MODE OFF** holds the notes you play, without an arpeggio: let go and they go on sounding (a pad, a drone, a chord to play over with one hand). The next note you play with no key down **replaces** them (a new chord); notes played while keys are still down **join** them. The keys' MIDI note-offs wait too, so gear played from the FM-1 holds with it. **HOLD OFF** (or ARP on, another project, NEW) ends them; loading another sound ends the held notes too, but HOLD stays ON. Projects saved before 2.7 open with HOLD OFF when their arp is OFF (it did nothing then), so nothing hangs by surprise. It works for MIDI notes too. Recorded as you hear it: a held note ends where it is replaced. Up to 2.6, HOLD did nothing with the arp OFF. - **ARP SWG** (2.7): the arp's swing also works with the sequencer stopped (the odd steps late), as it does while playing; until 2.6 it only worked while playing. -- **ARP and sounds** (2.7): while the arpeggiator runs (MODE not OFF), loading another sound (a preset or a user preset) keeps the arp: its settings (both ARP pages) and the notes it holds or latches go on with the new sound. With the arp OFF, a preset that has an arp of its own (8BIT ARP…) brings it, as before. +- **ARP and sounds** (2.7): while the arpeggiator runs (MODE not OFF), loading another sound (a preset or a user preset) keeps the arp: its settings (both ARP pages) and the notes it holds or latches go on with the new sound. With the arp OFF, a preset that has an arp of its own (8BIT ARP…) brings it, as before. (2.7.1) An arp that came with the sound (8BIT ARP, a user preset saved with its arp) and that you did not change goes with it: the next sound brings its own (most often OFF). Change one of its settings and it is yours: it goes on with the next sounds. - **ENV SYNC** (ENV DEST → ESYNC ON, 2.6): ATK, DEC and REL become note values of the tempo, from 0 through 1/64T … 1/4, 1/2 … to 4BAR, with triplets and dotted values; at 120 BPM an ATK of 1/4 lasts half a second, at 60 a whole one. They follow the tempo as it changes. OFF: times in milliseconds, as before. - **LFO 2** (2.6): **SYNC** locks the LFO's cycle to a note value of the tempo (RATE is then ignored; OFF: RATE, as before) · **TRIG** NOTE restarts the LFO at PHS on each new phrase (as before), FREE lets it run on · **POL** BI swings above and below the value, UNI only above it (a tremolo that only lowers the level, a wobble that only opens). - **FILTER** (EDIT, ANALOG only, 2.6): the ANALOG engine's filter as a **low-pass** (as before), **band-pass** or **high-pass**; CUT, RES and KTR are the same values as on EDIT 2. @@ -749,7 +756,7 @@ Each engine's eight parameters are on **EDIT 1** (KNOB 1–4) and **EDIT 2** (KN | **DIGITAL** | 4-operator FM | ALG algorithm 1–8 · R2 · R3 · R4 (operator ratios) | IDX FM amount · MDEC modulator decay · FB feedback · — | | **PHASE** | phase distortion (CZ style) | WAVE · WAVE2 (a second wave, or –) · DCW (the distortion amount) · ENV (its envelope) | DTN detune · LINE: MIX / RING · SUB sub-oscillator · — | | **LOFI** | 8-bit chip | CHIP: 4BIT, 4B/2, 8BIT, 1BIT, STEP · WAVE: PLS, TRI, SAW, NOIS, WRAM · DUTY (pulse width / wave table) · CRSH crush (DCY on STEP) | SWP pitch sweep · VIB vibrato · ARP: OFF, OCT, MAJ, MIN (chip arpeggio) · TONE | -| **SAMPLE** | sampler | SET: PIANO, BASS, VIBES, HORNS, STRGS, FLUTE, SCRCH, PERC, **USR1–USR4** · TUNE ±24 · BITS (bit reduction) · LOOP: OFF / ON | CUT (tone) · — · DRV drive · — | +| **SAMPLE** | sampler | SET: PIANO, BASS, VIBES, HORNS, STRGS, FLUTE, SCRCH (2.7.2: one scratch over the whole keyboard), PERC, **USR1–USR4** · TUNE ±24 · BITS (bit reduction) · LOOP: OFF / ON | CUT (tone) · — · DRV drive · — | | **VOICE** | formant voice (choirs, talkbox) | VOWL vowel · VOWL2 second vowel · TALK (time from one to the other) · SHIFT formant shift ±12 | BUZZ · BRTH breath · Q · RAND | | **TRIO** | three oscillators | WAVE (16 combinations) · INT2 · INT3 (intervals of oscillators 2 and 3, ±24) · DTN | MODE: LP, BP, HP, NOT (filter type) · CUT · RES · PW pulse width | | **WHEEL** | tonewheel organ | REG (16 drawbar registrations: FLUTE, MELLO, HOLLW, SMOOT, 3BAR, BLUES, GOSPL, ROCK…) · SUB · BODY · TOP (drawbar groups ±8) | PERC: OFF, 2ND, 3RD, 2SOFT, 3SOFT, 2SLOW, 3SLOW · CLICK · DRV · ROTR: OFF, SLOW, FAST (rotary speaker) | @@ -760,6 +767,19 @@ Each engine's eight parameters are on **EDIT 1** (KNOB 1–4) and **EDIT 2** (KN The **SAMPLE** sets are free recordings (CC0: Versilian Studios VSCO-2 CE and VCSL, Sonic Pi), coloured like a record through an old sampler. **GRAND PNO** is a Steinway recorded note by note; long notes fade as on the real one. +### Polyphony + +The three synth tracks **share one pool of 8 voices**; the drum track has its own 6. Played on its own, each engine's maximum polyphony is: + +| Voices | Engines | +| --- | --- | +| **8** | ANALOG, DIGITAL, PHASE, LOFI, SAMPLE, TRIO, WHEEL, NOISE | +| **6** | FM6 | +| **4** | VOICE | +| **3** | GRAIN, PHYS (SYMP model: **2**) | + +In **MONO** or **LEGATO** a track plays one note at a time; **UNISON** stacks detuned voices within the same cap. When more than one synth track sounds at once, the 8-voice pool is split between them: a part that needs a voice takes the oldest sounding one. + ### FM6 and DX7 patches **FM6** is msfa, the synthesis core of Dexed, as Felucca 1.0 ported it: six operators with their own four-stage envelopes, keyboard scaling, velocity, ratio or fixed frequency and detune; 32 algorithms, feedback, LFO, pitch envelope; six voices per track. The eight EDIT values above are **macros on top of the patch**; the track's FLT moves MLVL (so LFO → FLT still brightens it), SHP the feedback, PIT the pitch. @@ -875,13 +895,14 @@ The visualiser sees the mix **as if MASTER were all the way up**: with MASTER tu ## 20. The HOME menu and the lights -**Hold HOME** (0.7 s) to open the menu; hold it again to close it. The menu is in four sections: +**Hold HOME** (0.7 s) to open the menu; hold it again to close it. The menu is in five sections (2.7.1: SEQ): | Section | KNOB 1 | KNOB 2 | KNOB 3 | KNOB 4 | | --- | --- | --- | --- | --- | | **SCREEN** | **COLOR**: the screen palette (GREEN, AMBER, CYAN, RED, MONO, then [your theme](#your-theme) once you sent one) | **ZOOM**: ON shows the value you touch large and white | **KNOB ACCEL** (2.7): ON (the default) a fast turn sweeps wider; OFF one value a detent | — | | **LIGHTS** | **LIGHTS**: OFF, LOW, MID, HIGH | **KEYS**: OFF, C KEYS, WHITE KEYS, ALL KEYS | **NOTES**: OFF / ON | — | | **AUDIO** | **SPEAKER LOWCUT**: ON cuts the lows the small speaker cannot play (~110 Hz) | **USB AUDIO**: MASTER / FULL | **USB RATE** (2.7): AUTO / 44.1 KHZ / 48 KHZ (takes effect at the next start) | — | +| **SEQ** (2.7.1) | **STEP ADVANCE**: ON (the default) the NOTES page moves on when you let go of the keys; OFF it stays, so a chord you missed is played again on the same step (KNOB 1 moves the cursor) | **DRUM PREVIEW**: OFF (the default) a drum sound picked with a knob (DRUMS screen, SEQ layer) is not heard, quiet for live; ON you hear it, as up to 2.7 | — | — | | **SYSTEM** | **2ND CORE** (2.7): **ON** (the default) / OFF. ON, the sound is computed on both of the FM-1's cores: about twice the room before the CPU runs out (many voices, INSERT effects on several tracks), the same sound. ON takes effect at the next power-on; ABOUT then says *2 CORES* (*1 CORE*: the second core did not answer and SLOOP runs on one, as before). OFF: one core, as in 2.6 | **HARDWARE CALIBRATION** (the knob selects it, OCT+ opens it) | **MIDI LEARN CLEAR** (2.6): how many CCs are learned; OCT+ forgets them all | **ABOUT**, the version (the knob selects it, OCT+ opens it) | **The knobs (2.7).** A slow turn is fine tuning, one value a detent. Turn faster and the value sweeps wider, progressively (x2 up to x16 on the widest values); turning back to correct is always one value a detent, and lists of names never jump. MENU → SCREEN → KNOB ACCEL OFF keeps one value a detent everywhere. **LEVEL and PAN glide** over about 3 ms instead of stepping at each detent, on every track and the drums: no zipper on a held note. Both after JIANT FM by juanjiant-bit. @@ -966,6 +987,8 @@ The knobs of a MIDI controller set the sound (the standard CC map of Felucca 1.1 | 5 | GLIDE | | 7 | LEVEL (on the drum channel: GLO → DRUMS → LVL) | | 10 | PAN | +| 11 | (2.7.1) **EXPRESSION**: a volume pedal over the track's LEVEL (on the drum channel: over DRUMS LVL), 127 full, 0 silent, as on a GM synth. It does not change LEVEL (your mix and what you save stay as they are). Full again at power-on, when a project or section is loaded, and with CC 121 | +| 121 | (2.7.1) RESET ALL CONTROLLERS: the expression full again | | 71 | the engine's resonance (RES or Q: ANALOG, TRIO, VOICE, NOISE; the others ignore it) | | 72 · 73 · 75 | release · attack · decay | | 74 | (2.7) the engine's own cutoff or brightness, dark to bright: ANALOG / SAMPLE CUT, TRIO CUT, PHASE DCW, LOFI / GRAIN TONE, FM6 MLVL, PHYS BRIT, NOISE FREQ. DIGITAL, VOICE, WHEEL and the drum track: the track's FILTER (64 off, lower a low-pass, higher a high-pass), as before | @@ -997,7 +1020,7 @@ On USB the FM-1 is also an audio input named **Felucca**: 44.1 or 48 kHz (the co - **MASTER** (default): the recording follows the MASTER knob, as the headphones do. Keep MASTER well up while you record. - **FULL**: a fixed level, as with MASTER all the way up (kept from clipping by the limiter); MASTER then only sets the headphones. Best for a computer input with no level control of its own. -The first time, the computer sees the FM-1 as a slightly different device (MIDI + audio) and sets it up again. On macOS 13–15, keep **USB SERIAL** OFF (the default) or the audio input may not show (2.6; from 2.7 the FM-1's build has no serial console and no USB SERIAL: the flash is full, and it was a developer's tool). +The first time, the computer sees the FM-1 as a slightly different device (MIDI + audio) and sets it up again. On macOS 13–15, keep **USB SERIAL** OFF (the default) or the audio input may not show (2.6; from 2.7 the FM-1's build has no serial console and no USB SERIAL: the flash is full, and it was a developer's tool). (2.7.2) On macOS 15 and older, SLOOP up to 2.7.1 showed MIDI but no audio input: Apple's audio driver there stopped reading SLOOP's USB description before the audio part (after Felucca 1.5.1, the audio is now listed first). The FM-1 also reports a new USB version, so the Mac sets it up fresh. **HOME menu → AUDIO → USB RATE** (2.7), KNOB 3: the rates the FM-1 offers. It takes effect at the next start: turn the FM-1 off and on (the menu shows *RESTART* until then). @@ -1315,7 +1338,7 @@ On the installer page, open **Return to the official firmware (V15)**: save a ba | a track's effect (INSERT) | FX → INSERT, INSERT 2 | | tempo-synced envelope / LFO | ENV DEST → ESYNC · LFO → LFO 2 → SYNC | | ANALOG band-pass / high-pass | EDIT → FILTER → TYPE | -| a note's length in steps | SEQ → STEP page, KNOB 3 on the note (LEN) | +| a note's length in steps | SEQ → NOTES page, KNOB 3 on the note (LEN) | | drum mutes | EDIT + a black key, then the sounds' keys | | lights, colours, USB audio level | hold HOME (menu) | | the version | hold HOME → SYSTEM → ABOUT | diff --git a/README.md b/README.md index 6aa65db..9a0899d 100644 --- a/README.md +++ b/README.md @@ -463,7 +463,7 @@ The protocol is documented in [web/EDITOR_PROTOCOL.md](web/EDITOR_PROTOCOL.md). **Nothing plays from the MIDI IN jack.** Try the other adapter type (A / B); check the keyboard's channel (1–3 synths, 10 drums, the others the selected track; 2.6: GLO → MIDI sets them). -**The USB audio input does not show.** Unplug the FM-1 and plug it back in (after an install the computer must find it again). On a Mac (macOS 13–15) with 2.6, check that HOME menu → **USB SERIAL** is OFF (the default), then restart the FM-1. In Audacity: Transport → Rescan Audio Devices. On Windows: Sound settings → Recording → show disabled devices. +**The USB audio input does not show.** Unplug the FM-1 and plug it back in (after an install the computer must find it again). On a Mac with macOS 15 or older, SLOOP up to 2.7.1 shows MIDI but no audio input (Apple's driver there read SLOOP's USB description badly): update to 2.7.2, then plug the FM-1 in again. With 2.6, also check that HOME menu → **USB SERIAL** is OFF (the default), then restart the FM-1. In Audacity: Transport → Rescan Audio Devices. On Windows: Sound settings → Recording → show disabled devices. **The USB recording is too quiet, or follows the volume knob.** Set HOME menu → **USB AUDIO** to **FULL**, or turn MASTER up. @@ -483,6 +483,7 @@ Something else? [Open an issue](../../issues): what you did, what you expected, | --- | --- | | Tracks | 3 synth parts (8 voices shared) + drums (16 sounds, 6 voices) | | Sounds | 153 presets on 12 engines (browsed by kind, level-matched), 6-op FM with DX7 SysEx import and a 27-patch bank, 8 sampled sets (CC0), 4 slots for your own samples (USR1–USR4), 32 user presets | +| Polyphony | 8 voices shared across the synth tracks; per engine played alone: **8** (ANALOG, DIGITAL, PHASE, LOFI, SAMPLE, TRIO, WHEEL, NOISE), **6** (FM6), **4** (VOICE), **3** (GRAIN, PHYS — SYMP model 2); MONO / LEGATO play one note at a time; drums 6 | | Drum kits | 37 (5 sampled, 32 synthesised, 16 sounds each), level-matched, plus your own: USR1–USR4 and USR3+4 (about 15 s) | | Sequencer | 64 steps per track, own length and division each (1/32 to two bars); chords with a level and ratchet per note; drums with a level and ratchet per sound; ties, slide; per-step parameter locks (24 per track), micro timing (±½ step in 1/64) and fill conditions; swing 0 (straight) to 100 (MPC 75 %); one sample-accurate clock (no drift) | | Recording | live, quantised as heard (latency-compensated), overdub; free take (the tempo follows you) or the tempo set; start on the first note or a one-bar count-in; 1, 2 or 4 bars | diff --git a/build-sloop.ps1 b/build-sloop.ps1 index 0d833b5..066574b 100644 --- a/build-sloop.ps1 +++ b/build-sloop.ps1 @@ -1,17 +1,17 @@ -# SLOOP 2.7.1: build the firmware, then open the browser installer. +# SLOOP 2.8: build the firmware, then open the browser installer. # Uses the dependencies already prepared (WSL MinUI-Build, JieLi toolchain, SDK files in build/deps/ac79). # SLICE stays out (FELUCCA_SLICE=0): with its built-in BREAK the image does not fit the app slot. $ErrorActionPreference = 'Stop' Set-Location $PSScriptRoot Write-Host "" -Write-Host " S L O O P 2.7.1" -ForegroundColor White +Write-Host " S L O O P 2.8" -ForegroundColor White Write-Host " ---- ---- ---- ----" -ForegroundColor DarkGray Write-Host "== Building the firmware (WSL MinUI-Build)" -ForegroundColor Cyan Remove-Item Env:FELUCCA_SLICE -ErrorAction SilentlyContinue python tools/build_windows.py --distro MinUI-Build --toolchain /root/fm1-codex-deps/jieli/toolchain --sdk build/deps/ac79 --slice 0 if ($LASTEXITCODE -ne 0) { throw "The build failed" } Write-Host "== Making the installer site" -ForegroundColor Cyan -python web/make_site.py build/felucca.fwsc 2.7.1 build/sloop-site +python web/make_site.py build/felucca.fwsc 2.8 build/sloop-site if ($LASTEXITCODE -ne 0) { throw "make_site failed" } Write-Host "" Write-Host "Installer: http://localhost:8766/webapp/installer/ (Chrome or Edge, FM-1 on USB)" -ForegroundColor Green diff --git a/docs/firmware/sloop-2.7.1.fwsc b/docs/firmware/sloop-2.7.1.fwsc deleted file mode 100644 index e299867..0000000 Binary files a/docs/firmware/sloop-2.7.1.fwsc and /dev/null differ diff --git a/docs/firmware/sloop-2.8.fwsc b/docs/firmware/sloop-2.8.fwsc new file mode 100644 index 0000000..5d4f578 Binary files /dev/null and b/docs/firmware/sloop-2.8.fwsc differ diff --git a/docs/webapp/editor/index.html b/docs/webapp/editor/index.html index 8e80fa6..78234ea 100644 --- a/docs/webapp/editor/index.html +++ b/docs/webapp/editor/index.html @@ -890,7 +890,7 @@ - + @@ -2966,6 +2966,7 @@ function makeMockDevice(opt = {}) { E("DR MAP", ["GM", "1-16"], 0), /* GLO > MIDI 3 (2.7): MIDI notes -> drum sounds */ E("REMOTE", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 0), /* GLO > MIDI 3 (2.7): the buttons */ E("CLOCK", ["OFF", "OUT"], 0), /* GLO > MIDI 3 (2.7): MIDI clock, START / STOP out on USB */ + D("FADE", F.INT, 0, 15, 0), /* GLO > MASTER 2 (2.7.2): the punch-in FX fade (punch.c) */ ]; /* the drum track's P_E0: its kit (drums.c DRUM_KIT_NAMES; 5 = 808, the power-on kit) */ const KIT = E("KIT", ["ACOUSTIC", "DEEP", "TIGHT", "BRIGHT", "DUST", "808", "909", "606", "80S", "VINTAGE", "TRAP", "DRILL", "BOOMBAP", "LO-FI", "PHONK", "HOUSE", "D.HOUSE", "TECHNO", "MINIMAL", "ELECTRO", "DISCO", "GARAGE", "JUNGLE", "DUBSTEP", "DEMBOW", "AMAPIANO", "AFRO", "LATIN", "TRIBAL", "SYNTHWV", "CHIP", "ARCADE", "GLITCH", "INDUSTR", "HYPER", "AMBIENT", "JAZZ", "USR1", "USR2", "USR3", "USR4", "USR3+4", "SYN1", "SYN2", "SYN3", "SYN4"], 0); @@ -5905,7 +5906,7 @@ const stepEdit = new Map(); /* index -> time of the last edit */ /* parameter ids (firmware/src/core.h); used only when P_COUNT / G_COUNT match */ /* pcount 71 / pe0 63: 2.6's INSERT, filter TYPE, ENV SYNC, LFO 2 (P_ITYPE 53 .. P_LPOL 62, after Felucca 1.4 / 1.5) */ -const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT */ +const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49, 50], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT; 50: 2.7.2's FX FADE */ const P = { LEVEL: 0, SLEN: 29, CHORD: 49 }; const LAYOUT = (pe0) => { const v251 = pe0 >= 63; /* (2.6: the pages the device has for the new parameters) */ diff --git a/docs/webapp/editor/sloop-editor.html b/docs/webapp/editor/sloop-editor.html index 9123238..24e69e2 100644 --- a/docs/webapp/editor/sloop-editor.html +++ b/docs/webapp/editor/sloop-editor.html @@ -2964,6 +2964,7 @@ function makeMockDevice(opt = {}) { E("DR MAP", ["GM", "1-16"], 0), /* GLO > MIDI 3 (2.7): MIDI notes -> drum sounds */ E("REMOTE", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 0), /* GLO > MIDI 3 (2.7): the buttons */ E("CLOCK", ["OFF", "OUT"], 0), /* GLO > MIDI 3 (2.7): MIDI clock, START / STOP out on USB */ + D("FADE", F.INT, 0, 15, 0), /* GLO > MASTER 2 (2.7.2): the punch-in FX fade (punch.c) */ ]; /* the drum track's P_E0: its kit (drums.c DRUM_KIT_NAMES; 5 = 808, the power-on kit) */ const KIT = E("KIT", ["ACOUSTIC", "DEEP", "TIGHT", "BRIGHT", "DUST", "808", "909", "606", "80S", "VINTAGE", "TRAP", "DRILL", "BOOMBAP", "LO-FI", "PHONK", "HOUSE", "D.HOUSE", "TECHNO", "MINIMAL", "ELECTRO", "DISCO", "GARAGE", "JUNGLE", "DUBSTEP", "DEMBOW", "AMAPIANO", "AFRO", "LATIN", "TRIBAL", "SYNTHWV", "CHIP", "ARCADE", "GLITCH", "INDUSTR", "HYPER", "AMBIENT", "JAZZ", "USR1", "USR2", "USR3", "USR4", "USR3+4", "SYN1", "SYN2", "SYN3", "SYN4"], 0); @@ -5903,7 +5904,7 @@ const stepEdit = new Map(); /* index -> time of the last edit */ /* parameter ids (firmware/src/core.h); used only when P_COUNT / G_COUNT match */ /* pcount 71 / pe0 63: 2.6's INSERT, filter TYPE, ENV SYNC, LFO 2 (P_ITYPE 53 .. P_LPOL 62, after Felucca 1.4 / 1.5) */ -const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT */ +const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49, 50], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT; 50: 2.7.2's FX FADE */ const P = { LEVEL: 0, SLEN: 29, CHORD: 49 }; const LAYOUT = (pe0) => { const v251 = pe0 >= 63; /* (2.6: the pages the device has for the new parameters) */ diff --git a/docs/webapp/editor/sloop-preview.wasm b/docs/webapp/editor/sloop-preview.wasm index 1058ead..0723478 100644 Binary files a/docs/webapp/editor/sloop-preview.wasm and b/docs/webapp/editor/sloop-preview.wasm differ diff --git a/docs/webapp/installer/index.html b/docs/webapp/installer/index.html index 9e04362..8bbe050 100644 --- a/docs/webapp/installer/index.html +++ b/docs/webapp/installer/index.html @@ -90,24 +90,15 @@


   
-  

+


FM-1-transporter

-
- -

-

www.m-vave.com/download

-

-

-

-

-

-

-
+

+

www.m-vave.com/download

SLOOP is based on Felucca by Leo Kuroshita (@kurogedelic), Hügelton Instruments. Hold OCT− alone while switching on for USB rescue.
Font: Terminus (Dimitar Toshkov Zhekov, SIL OFL 1.1). Samples: Versilian Studios VSCO-2 Community Edition and VCSL (CC0 1.0), and the Hügelton Sample Pack (© Hügelton Instruments, not CC0).
@@ -258,6 +249,11 @@ class Link { } return this.q.shift() || null; } + // detach the callback only; do NOT close the MIDI ports. find()/probe() reuse the same input across + // several output candidates (e.g. the always-present "Microsoft GS Wavetable Synth" is probed before + // the FM-1's own output), and closing the input between candidates raced its re-open and broke the + // handshake with a device that is present ("FM-1 not found" with the port listed). Leaving ports open + // is the long-standing behaviour. close() { this.input.onmidimessage = null; } } @@ -282,14 +278,16 @@ class Updater { this.log = log || (() => {}); } - // every in/out pair with the same port name that answers the handshake - async find(filter) { - const outs = [...this.access.outputs.values()]; - for (const input of this.access.inputs.values()) { - if (input.state === "disconnected") continue; - if (!FM1_PORT.test(input.name || "")) continue; // never probe other gear - const output = outs.find((o) => o.name === input.name) || (outs.length === 1 ? outs[0] : null); - if (!output) continue; + // one input against its candidate outputs: the matching port first (same name, or one name contains + // the other, so input "Felucca" pairs with output "MIDIOUT2 (Felucca)" without probing unrelated + // outputs like "Microsoft GS Wavetable Synth"), then (the fallback) any live output. A pair counts + // only when it answers the FM-1 handshake and passes the filter. + async probe(input, outs, filter) { + if (input.state === "disconnected") return null; + const live = outs.filter((o) => o.state !== "disconnected"); + const nm = input.name || ""; + const named = live.filter((o) => o.name === nm || (nm && o.name && (o.name.includes(nm) || nm.includes(o.name)))); + for (const output of (named.length ? named : live)) { try { await input.open(); await output.open(); } catch (_) { continue; } const link = new Link(input, output); const id = await handshake(link, 2); @@ -299,16 +297,40 @@ class Updater { return null; } + // the FM-1 (or its update loader) among the MIDI ports. Named ports first (fast, and other gear is + // never touched). With deep=true (hunting the re-enumerated update loader only), if no named port + // matched, the remaining ports are probed too and accepted SOLELY when they answer the FM-1 handshake + // (other gear returns no valid identity). Windows often names the update loader generically (e.g. + // "USB MIDI Device"), so a name filter alone misses it and the loader seems to "not appear": this + // handshake fallback is what makes the loader reliably found, without probing other gear when looking + // for the running firmware (which always names itself). + async find(filter, deep = false) { + const outs = [...this.access.outputs.values()]; + const inputs = [...this.access.inputs.values()].filter((i) => i.state !== "disconnected"); + for (const input of inputs) + if (FM1_PORT.test(input.name || "")) { + const dev = await this.probe(input, outs, filter); + if (dev) return dev; + } + if (deep) + for (const input of inputs) + if (!FM1_PORT.test(input.name || "")) { + const dev = await this.probe(input, outs, filter); + if (dev) return dev; + } + return null; + } + // the MIDI inputs there are, for the "not found" message: " (MIDI: a, b)" (a port the installer skipped shows) seen() { const names = [...this.access.inputs.values()].filter((p) => p.state !== "disconnected").map((p) => p.name || "?"); return names.length ? ` (MIDI: ${names.join(", ")})` : " (MIDI: none)"; } - async waitFor(filter, ms) { + async waitFor(filter, ms, deep = false) { const end = Date.now() + ms; while (Date.now() < end) { - const dev = await this.find(filter); + const dev = await this.find(filter, deep); if (dev) return dev; await sleep(1000); } @@ -359,13 +381,13 @@ class Updater { if (!s1.finished) throw fail(s1.lost ? "lost" : "stopped", `the device ${s1.lost ? "was disconnected" : "stopped"} after ${s1.served} requests: nothing was written`); step("loader"); await sleep(3000); - const ota = await this.waitFor(IS_OTA, 30000); - if (!ota) throw fail("noloader", "the update loader did not appear. Replug the USB cable and press Install again: the device stays in update mode until it is finished."); + const ota = await this.waitFor(IS_OTA, 60000, true); + if (!ota) throw fail("noloader", "the update loader did not appear. Replug the USB cable and press Install again: the device stays in update mode until it is finished.", this.seen()); const s2 = await this.write(ota, image, step); if (!s2.finished) throw fail(s2.lost ? "lost" : "stopped", `the loader ${s2.lost ? "was disconnected" : "stopped"} after ${s2.served} requests. Replug and press Install again to resume.`); step("reboot"); await sleep(3000); - const back = await this.waitFor((id) => !IS_OTA(id), 40000); + const back = await this.waitFor((id) => !IS_OTA(id), 60000); if (!back) throw fail("noreturn", "the device did not come back: power-cycle it"); back.link.close(); if (back.id.text !== product) throw fail("mismatch", `installed, but the device reports ${back.id.text}`, back.id.text); @@ -387,7 +409,7 @@ class Updater { // package, its identity checked once the FM-1 is back, after Felucca 1.0): that one is the official // loader's own image, as M-UPGRADE would write it async resume(image, onStep, opts = {}) { - const ota = await this.find(IS_OTA); + const ota = await this.find(IS_OTA, true); if (!ota) return false; if (!OUR_LOADER(ota.id) && !opts.product) { ota.link.close(); @@ -398,7 +420,7 @@ class Updater { if (opts.product) { step("reboot"); await sleep(3000); - const back = await this.waitFor((id) => !IS_OTA(id), 40000); + const back = await this.waitFor((id) => !IS_OTA(id), 60000); if (!back) throw fail("noreturn", "the FM-1 did not come back after the write: power-cycle it"); back.link.close(); if (back.id.text !== opts.product) throw fail("mismatch", `written, but the FM-1 reports ${back.id.text}`, back.id.text); @@ -444,7 +466,7 @@ const TEXT = { stockValid: "公式 V15 を確認しました", stockBad: "公式 V15 ではありません: ", stockConfirm: "FM-1 に公式 V15 をインストールします。SLOOP の曲は公式ファームウェアでは開けません。バックアップは保存しましたか?", stockFinish: "FM-1 は SLOOP の書き込みモードです。先に「インストール」で SLOOP の書き込みを終えてから、公式 V15 に戻してください。", - back: "M-VAVE のアップデーター M-UPGRADE(Downloads → PC Software)でも戻せます。FM-1 が見つからない場合は、MIDI を使う他のアプリとブラウザのタブを閉じてください。", + back: "公式ファームウェアに戻すには、M-VAVE 公式のアップデーター M-UPGRADE(Downloads → PC Software → M-UPGRADE)と公式ファームウェアを使ってください。FM-1 が見つからない場合は、MIDI を使う他のアプリとブラウザのタブを閉じてください。", }, en: { intro: "Connect the FM-1 by USB. (Works in Chrome or Edge.)", @@ -480,7 +502,7 @@ const TEXT = { stockValid: "Official V15 verified", stockBad: "Not the official V15: ", stockConfirm: "Install the official V15 on the FM-1? The official firmware cannot open SLOOP's music. Did you save a backup?", stockFinish: "The FM-1 is in SLOOP's update mode. Press Install to finish the SLOOP update first, then return to the official V15.", - back: "M-VAVE's own updater, M-UPGRADE (Downloads → PC Software), works too. If it does not find the FM-1, close every other app and browser tab that uses MIDI.", + back: "To return to the official firmware, use M-VAVE's own updater, M-UPGRADE (Downloads → PC Software → M-UPGRADE), with the official firmware from M-VAVE. If it does not find the FM-1, close every other app and browser tab that uses MIDI.", }, }; let lang = (navigator.language || "en").toLowerCase().startsWith("ja") ? "ja" : "en"; @@ -514,14 +536,12 @@ const sayK = (k, arg = "") => { lastKey = k; lastArg = arg; $("status").textCont const say = (txt) => { lastKey = null; $("status").textContent = txt; }; const log = (t) => { $("log").textContent += t + "\n"; }; let image = null; -const meta = {"version": "2.7.1", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.7.1.fwsc", "sha256": "7c9d269d15d1c1a48e0ebada7ffa2c2aa196c19d51056fd3f760d322322b335f"}; +const meta = {"version": "2.8", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.8.fwsc", "sha256": "fb69b4311790eb7ec09498be16ae2b71bd681840e221c0d8cfdb26fb5f9a2928"}; -let writing = false, stock = null; +let writing = false; const lockAll = (on) => { writing = on; $("go").disabled = on || !image; - $("stock-go").disabled = on || !stock || !$("stock-saved").checked; - $("stock-file").disabled = on; }; window.addEventListener("beforeunload", (e) => { if (writing) { e.preventDefault(); e.returnValue = t("leave"); } }); @@ -574,7 +594,7 @@ $("go").addEventListener("click", async () => { catch (e) { sayK("denied"); lockAll(false); return; } try { const up = new Updater(midi, log); - const ota = await up.find((id) => /^ota-/i.test(id.model)); + const ota = await up.find((id) => /^ota-/i.test(id.model), true); if (ota) { ota.link.close(); sayK((await up.resume(image, step)) ? "done" : "stopped"); @@ -585,37 +605,8 @@ $("go").addEventListener("click", async () => { lockAll(false); }); -/* back to the official V15 (after Felucca 1.0): only the exact official file, a backup first (the editor), - through the same update path as M-UPGRADE; a device left in the official updater's mode is finished */ -$("stock-saved").addEventListener("change", () => lockAll(writing)); -$("stock-file").addEventListener("change", async () => { - const f = $("stock-file").files[0]; - stock = null; - lockAll(writing); - if (!f) return; - try { stock = await validateStockPackage(new Uint8Array(await f.arrayBuffer())); sayK("stockValid"); } - catch (e) { sayK("stockBad", e.message); } - lockAll(writing); -}); -$("stock-go").addEventListener("click", async () => { - if (writing || !stock || !$("stock-saved").checked || !confirm(t("stockConfirm"))) return; - lockAll(true); - let midi; - try { midi = await navigator.requestMIDIAccess({ sysex: true }); } - catch (e) { sayK("denied"); lockAll(false); return; } - try { - const up = new Updater(midi, log); - const ota = await up.find((id) => /^ota-/i.test(id.model)); - if (ota) { - ota.link.close(); - if (OUR_LOADER(ota.id)) sayK("stockFinish"); /* SLOOP's loader: finish SLOOP first (Install) */ - else sayK((await up.resume(stock.image, step, { product: stock.product })) ? "done" : "stopped"); - } else { - await up.install(stock.image, stock.product, step); - } - } catch (e) { failed(e); } - lockAll(false); -}); +/* Returning to the official firmware is done with M-VAVE's own updater (M-UPGRADE): the in-browser + revert was removed because it is not reliable on every system. The note under "stockTitle" points there. */ diff --git a/docs/webapp/sw.js b/docs/webapp/sw.js index 7a5b075..1188069 100644 --- a/docs/webapp/sw.js +++ b/docs/webapp/sw.js @@ -4,9 +4,9 @@ // https, so Web MIDI asks as usual (a downloaded file on Android opens as content://, where Chrome refuses MIDI). // Online the network always wins (the page as published, never an old one); the copy is only the fallback. // A new site (any file changed) is a new sw.js: the new copy replaces the old one. -const STAMP = "2.7.1-c4ebf0d8d2aa"; // version + a hash of the files +const STAMP = "2.8-37cea14972fa"; // version + a hash of the files const CACHE = "sloop-site-" + STAMP; -const FILES = ["../firmware/sloop-2.7.1.fwsc", "editor/", "editor/FUKIAI-LICENSE.txt", "editor/fukiai.ttf", "editor/preview-worklet.js", "editor/preview.js", "editor/sloop-preview.wasm", "icon-192.png", "icon-512.png", "icon-maskable-512.png", "installer/", "sloop.webmanifest"]; // relative to this file +const FILES = ["../firmware/sloop-2.8.fwsc", "editor/", "editor/FUKIAI-LICENSE.txt", "editor/fukiai.ttf", "editor/preview-worklet.js", "editor/preview.js", "editor/sloop-preview.wasm", "icon-192.png", "icon-512.png", "icon-maskable-512.png", "installer/", "sloop.webmanifest"]; // relative to this file const KEEP = new Set(FILES.map((f) => new URL(f, self.location).href)); const key = (url) => { // the copy's name of a request: no query, index.html = the folder diff --git a/firmware/hal/fm1_input.h b/firmware/hal/fm1_input.h index fd7c146..24ac28a 100644 --- a/firmware/hal/fm1_input.h +++ b/firmware/hal/fm1_input.h @@ -22,7 +22,7 @@ * sample is a closed key; two in a row keep one stray sample from playing a note), a release after * FM1_DEB_RELEASE frames open in a row (~9 ms): a contact bouncing open on the way down, or chattering * on the way up, never ends a note early or plays it twice. - * Encoders: quadrature decoder (2-sample filter, + = clockwise) with detent counting, as + * Encoders: quadrature decoder (+ = clockwise; 2.7.2: no 2-sample filter, below) with detent counting, as * Felucca 1.0 reworked it (its #23, "knobs skipping or jumping"): an FM-1 detent is one full * quadrature cycle (4 transitions) and the knob rests in one state, the one seen at power-on * (relearned only after FM1_REST_FRAMES, ~1 s, parked elsewhere). Steps are emitted on arriving @@ -246,10 +246,13 @@ static void fm1__frame(void) uint32_t cur = ((fm1_in.raw[m[0]] >> m[1]) & 1u) << 1 | ((fm1_in.raw[m[2]] >> m[3]) & 1u); uint32_t idx; volatile int8_t *sub = &fm1_in.enc_sub[e]; - if (cur != fm1_in.enc_last[e]) { + if (cur != fm1_in.enc_last[e]) { /* (2.7.2: no 2-frame filter. A state had to be seen on two frames + * running, ~2.2 ms, to count: in a fast turn the mid states of a + * click go by quicker, the click was lost and the value slowed down + * or stopped. A frame (~1.1 ms) outlasts a contact bounce, and a step + * still needs >= 2 net transitions back on the detent) */ fm1_in.enc_last[e] = (uint8_t)cur; fm1_in.enc_still[e] = 0; - continue; } if (fm1_in.enc_prev[e] == 0xFF) { /* first frame: the knob rests here */ fm1_in.enc_prev[e] = (uint8_t)cur; diff --git a/firmware/hal/fm1_lcd_hw.h b/firmware/hal/fm1_lcd_hw.h index 72e0f2d..9d399cc 100644 --- a/firmware/hal/fm1_lcd_hw.h +++ b/firmware/hal/fm1_lcd_hw.h @@ -32,10 +32,17 @@ static uint32_t fm1_lcd_timeouts; -FM1_INLINE void fm1_lcd_hw_init(void) +/* (2.7.2) drive the backlight (PA2, active low) on, on its own. SLOOP USB RESCUE needs it low before the early key + * scan (recovery.c), which runs before fm1_lcd_hw_init: the HAL register access stays in hal/ (a hal helper). */ +FM1_INLINE void fm1_lcd_backlight_on(void) { FM1_LCD_PA_OUT &= ~FM1_LCD_BL; FM1_LCD_PA_DIR &= ~FM1_LCD_BL; +} + +FM1_INLINE void fm1_lcd_hw_init(void) +{ + fm1_lcd_backlight_on(); FM1_LCD_IOMAP_CON1 |= 0x10u; FM1_LCD_PC_OUT |= FM1_LCD_CS; FM1_LCD_PC_OUT &= ~(FM1_LCD_DC | FM1_LCD_CLK | FM1_LCD_DO); diff --git a/firmware/src/core.h b/firmware/src/core.h index 5b6e21a..b204f0e 100644 --- a/firmware/src/core.h +++ b/firmware/src/core.h @@ -103,6 +103,8 @@ enum { /* global parameters */ * 1..16; seq.c remote_cc, ui_input.c remote_poll; a setting of the FM-1) */ G_CLKOUT, /* SLOOP 2.7, GLO > MIDI 3: CLK OUT, the MIDI clock (24 a beat) and START / STOP out on USB * while SYNC is INT (seq.c clkout_block; a setting of the FM-1, kept in DR MAP's byte) */ + G_FXFADE, /* SLOOP 2.7.2, the FX layer (FX held), SELECT: how fast a punch-in FX fades in and out, 0 (instant, as + * before) .. 15 (punch.c; a setting of the FM-1, kept in BEND's byte) */ G_COUNT }; @@ -190,6 +192,11 @@ enum { ST_NOTE, ST_TIE, ST_REST }; #define SF_CONT0 8u #define SF_CONT(k) (SF_CONT0 << (k)) #define SF_CONT_ALL (15u * SF_CONT0) +/* SLOOP 2.7.2: bit 7 of a NOTE step's flags (MONO / LEGATO / UNISON parts): played legato, recorded while the note + * before was still held: the note before is held to it and this one takes over as a held key does (LEGATO: the + * envelope goes on; a glide only with GLIDE or a SLIDE), not released and played again (seq.c rec_note, seq_step). + * An older SLOOP ignores it (the note plays again there) */ +#define SF_LEG 0x80u /* the dynamics of a note or a drum hit (2 bits each in the steps): played without velocity * (OCT- / OCT+ held on the drum track, the step page) or from a MIDI velocity */ enum { LV_NORM, LV_GHOST, LV_SOFT, LV_HARD }; @@ -285,6 +292,9 @@ typedef struct track { uint8_t rh_last; /* the last of them; rh_bak: what it held (an early release puts it back) */ uint32_t rh_last_abs; /* (its step of the transport grid) */ step_t rh_bak; + uint8_t rh_end; /* (2.7.1) one of them let go, others still held: the next step, only those go on */ + uint8_t rh_rs; /* (2.7.1) rh_start is such a step (rh_last, rh_last_abs: it) */ + uint8_t rh_offn, rh_off[4]; /* (2.7.1) the ones let go since the hold's last NOTE step (they end there) */ uint32_t pass; /* loops played since PLAY (a recording pass: one undo) */ /* mono */ uint8_t mono_stack[8]; @@ -364,6 +374,14 @@ static uint32_t dly_samples(uint32_t d) { return dly_units(d) / (uint32_t)song.g * up to 70 % if it is lower. The song's values never change, nothing is saved or recorded. thr_req: bit 0 the reverb, * bit 1 the echo (the UI); thr_rev, thr_dly: the glide now, Q15 (fx.c mix_block, a block at a time) */ static volatile uint8_t thr_req; +/* (2.7.1) MIDI CC 11, EXPRESSION, per track: 127 - its value (0, the default: full). A gain over the track's LEVEL (the + * drums': GLO > DRUMS LVL), 40 log10(v / 127) dB as GM's: the mix is not touched. CC 121 and a project loaded reset it */ +static volatile uint8_t ex_off[NTRK]; +static inline int32_t expr_gain(int32_t lvl, uint32_t k) +{ + uint32_t e = 127u - ex_off[k % NTRK]; + return e >= 127u ? lvl : (int32_t)(((uint32_t)lvl * ((e * e * 16384u + 8064u) / 16129u)) >> 14); +} static volatile uint8_t thr_ed; /* (2.7) the editor's LIVE page: its own THROWs (editor_live.c), with thr_req's */ /* (2.7) the editor's LIVE page: the master level from there (0: the MASTER knob; 1..127: its level + 1). The knob takes * it back when it is turned (main.c); ed_master_k: the knob's reading when the page set it (0xFFFF: not read yet) */ diff --git a/firmware/src/drum_synth.c b/firmware/src/drum_synth.c index 775a3f4..303d4e0 100644 --- a/firmware/src/drum_synth.c +++ b/firmware/src/drum_synth.c @@ -163,9 +163,18 @@ static void ds_on(dsv_t *s, const dsnd_t *snd, uint32_t crush, uint32_t note, ui s->fk = 8192 - (int32_t)(d->flt >> 3) * 245; /* damping 2.0 .. ~0.15 (Q12), as tsvf_coef */ /* softer hits are darker: about an octave from the hardest to a ghost note */ s->cut = ((int32_t)d->fcut << 8) + ((int32_t)vel - 110) * 40; + s->ahp = d->hpf ? ds_onepole(d->hpf) : 0; + if (!d->wave && tune16) { /* (2.7.2) a tone-less sound (closed hat, shaker, clap): TUNE + * shifts its brightness too, so it reacts like resampling a + * sample kit (~1.168 CUTOFF_HZ steps a semitone). The tonal + * sounds and the metal cymbals already track TUNE via base16. */ + int32_t co8 = tune16 * 1197 / 64; /* the TUNE as a CUTOFF_HZ index offset, Q8 */ + s->cut += co8; + if (d->hpf) + s->ahp = ds_onepole((uint32_t)clamp((int32_t)d->hpf + co8 / 256, 1, 127)); + } if (s->fmode & 3u) ds_filter(s); - s->ahp = d->hpf ? ds_onepole(d->hpf) : 0; s->rnd = (int32_t)(0x9E3779B9u ^ (note * 2654435761u) ^ rng()); s->lfsr = 0x4001u; { /* CHIP clock: 8x that note; saturated (the top notes would wrap 32 bits: a dull noise) */ diff --git a/firmware/src/drums.c b/firmware/src/drums.c index 7648013..ac49bd5 100644 --- a/firmware/src/drums.c +++ b/firmware/src/drums.c @@ -356,7 +356,7 @@ static void drum_on(uint32_t note, uint32_t vel) static inline void drums_mix(int32_t *ml, int32_t *mr, int32_t *rev, int32_t *dly, int32_t *mono, uint32_t n) { uint32_t k, i; - int32_t lvl = song.g[G_DRLVL] * 200, send = send_thr(song.g[G_DRREV] * 258, thr_rev), + int32_t lvl = expr_gain(song.g[G_DRLVL] * 200, TRK_DRUM), send = send_thr(song.g[G_DRREV] * 258, thr_rev), dsend = send_thr(song.g[G_DRDLY] * 258, thr_dly), pk = drums.peak; /* (2.6: the THROWs) */ int32_t pan = trk[TRK_DRUM].p[P_PAN], gl = 4096 - (pan > 0 ? pan * 64 : 0), gr = 4096 + (pan < 0 ? pan * 64 : 0); if (!drums.gon) /* (2.7) LEVEL and PAN glide, block by block (mix_glide) */ diff --git a/firmware/src/fx.c b/firmware/src/fx.c index db69782..bfb0599 100644 --- a/firmware/src/fx.c +++ b/firmware/src/fx.c @@ -117,6 +117,8 @@ static void lim_block(lim_t *s, int32_t *l, int32_t *r, uint32_t n) s->w = w; } static volatile uint8_t fx_lowcut; /* settings: 12 dB/oct ~110 Hz for the small speaker */ +static uint8_t flt_reso; /* (2.7.2) menu AUDIO > FILTER RESO: 0..10, the track filter's resonance (fx.c + * tflt_reso); 0 = the clean filter as before. One setting for every track's filter */ static int32_t lc_l1, lc_l2, lc_r1, lc_r2, dc_l, dc_r, dce_l, dce_r; /* DC blocker (~2 Hz), always on: a leaky integrator of the input (Q6 state) subtracted from it. @@ -364,8 +366,12 @@ typedef struct { } djf_t; static djf_t djf, tflt[NTRK]; -/* the knob v -> this block's coefficients in *c; 0 = bypassed (nothing to do) */ -static int djf_block(djf_t *f, int32_t v, tsvf_t *c) +/* (2.7.2) the track filter's SVF resonance (tsvf_coef's reso) for the FILTER RESO setting: 40 (clean, as the filter + * always was) at 0, up to 110 at 10 (a strong but still stable peak; tflt_run leaves 4x headroom for it). The master + * DJ filter (G_FILT) and the tape TONE keep the fixed 40. */ +static int32_t tflt_reso(void) { return 40 + (int32_t)(flt_reso > 10u ? 10u : flt_reso) * 7; } +/* the knob v -> this block's coefficients in *c; 0 = bypassed (nothing to do). reso: tsvf_coef's resonance */ +static int djf_block(djf_t *f, int32_t v, tsvf_t *c, int32_t reso) { int32_t to; if (v < 0 && f->mode >= 0) { /* (switching side: from open) */ @@ -387,7 +393,7 @@ static int djf_block(djf_t *f, int32_t v, tsvf_t *c) f->mode = 0; /* fully open again: off */ return 0; } - tsvf_coef(c, f->cut, 40); + tsvf_coef(c, f->cut, reso); return 1; } /* n samples of channel ch through the filter (x within +-140000) */ @@ -680,7 +686,7 @@ static void mix_part_run(track_t *t, uint32_t n, mixacc_t *mx, int32_t *b) return; } { - int32_t lvl = LEVEL_Q12[t->p[P_LEVEL] ? clamp(t->p[P_LEVEL] + t->p[P_ED_FX], 1, 127) : 0], pan = t->p[P_PAN]; /* (+ the sound's trim: 1/2 dB steps, as LEVEL's) */ + int32_t lvl = expr_gain(LEVEL_Q12[t->p[P_LEVEL] ? clamp(t->p[P_LEVEL] + t->p[P_ED_FX], 1, 127) : 0], (uint32_t)(t - trk)), pan = t->p[P_PAN]; /* (+ the sound's trim: 1/2 dB steps, as LEVEL's) */ int32_t gl = 4096 - (pan > 0 ? pan * 64 : 0), gr = 4096 + (pan < 0 ? pan * 64 : 0); int32_t c = t->p[P_CHOR] * 258, d = send_thr(t->p[P_DLY] * 258, thr_dly), r = send_thr(t->p[P_REV] * 258, thr_rev); int32_t pk = t->peak; @@ -697,7 +703,7 @@ static void mix_part_run(track_t *t, uint32_t n, mixacc_t *mx, int32_t *b) { tsvf_t fc; /* the track's FILTER (P_TFLT), after the SLICER */ djf_t *f = &tflt[(uint32_t)(t - trk) % NTRK]; - if (djf_block(f, t->p[P_TFLT], &fc)) + if (djf_block(f, t->p[P_TFLT], &fc, tflt_reso())) tflt_run(f, &fc, b, n, 0); } int32_t lvl0, dl, gl0, dgl, gr0, dgr; /* (2.7) LEVEL (and a new sound's trim) and PAN glide (drums.c @@ -791,7 +797,7 @@ static void dust_process(int32_t *l, int32_t *r, uint32_t n) static void djf_process(int32_t *l, int32_t *r, uint32_t n) { tsvf_t c; - if (!djf_block(&djf, song.g[G_FILT], &c)) + if (!djf_block(&djf, song.g[G_FILT], &c, 40)) return; djf_run(&djf, &c, l, n, 0); djf_run(&djf, &c, r, n, 1); @@ -833,7 +839,7 @@ static void mix_drums(uint32_t n, mixacc_t *mx) int flt; drums.a0 = TDRUM->att; /* the drum track's mute / solo fade */ drums.a1 = 32767 - gain_next(TDRUM); - flt = n <= CTL && djf_block(f, TDRUM->p[P_TFLT], &fc); /* the drum track's FILTER */ + flt = n <= CTL && djf_block(f, TDRUM->p[P_TFLT], &fc, tflt_reso()); /* the drum track's FILTER */ if (flt || (n <= CTL && (TDRUM->p[P_ITYPE] | TDRUM->ins_run))) { /* .. or its INSERT: left, right, the sends */ int32_t *dl = drum_buf[0], *dr = drum_buf[1], *dv = drum_buf[2], *dd = drum_buf[3]; for (i = 0; i < n; i++) @@ -1148,7 +1154,7 @@ static void texture_mix(int32_t *l, int32_t *r, uint32_t n) tx.lpm[1] += ((((tr[i] * sc) >> 8) - tx.lpm[1]) >> 2) * (k0 >> 2) >> 11; tl[i] = tx.lpm[0], tr[i] = tx.lpm[1]; } - if (djf_block(&tx.f, clamp(song.g[G_TXTONE], -64, 63), &fc)) { + if (djf_block(&tx.f, clamp(song.g[G_TXTONE], -64, 63), &fc, 40)) { djf_run(&tx.f, &fc, tl, n, 0); djf_run(&tx.f, &fc, tr, n, 1); } diff --git a/firmware/src/icons.c b/firmware/src/icons.c index 7249977..a5272b1 100644 --- a/firmware/src/icons.c +++ b/firmware/src/icons.c @@ -65,7 +65,7 @@ static const icon_map_t ICON_MAP[] = { {"VOWL", ICON_VOICE}, {"VOWL2", ICON_VOICE}, {"TALK", ICON_SWEEP}, {"SHIFT", ICON_TRANSPOSE}, {"BUZZ", ICON_PULSE}, {"BRTH", ICON_NOISE}, {"Q", ICON_RESO}, {"RAND", ICON_PROB}, /* fixed columns drawn by ui_draw.c (STEP page, preset browser, SYSTEM) */ - {"NOTE", ICON_PITCH}, {"STEP", ICON_STEPS}, {"FLAG", ICON_ACCENT}, {"ACC", ICON_ACCENT}, {"SLD", ICON_SLIDE}, {"USB", ICON_MIDI}, + {"NOTE", ICON_PITCH}, {"PITCH", ICON_PITCH}, {"FORCE", ICON_ACCENT}, {"STEP", ICON_STEPS}, {"FLAG", ICON_ACCENT}, {"ACC", ICON_ACCENT}, {"SLD", ICON_SLIDE}, {"USB", ICON_MIDI}, {"TRACK", ICON_MIX}, /* TRACKS page (LEVEL, LEN, PAN: above) */ {"SLCR", ICON_SLICE}, {"PAT", ICON_STEPS}, {"DEPTH", ICON_MIX}, /* SLICER page (RATE: param_icon) */ }; diff --git a/firmware/src/main.c b/firmware/src/main.c index fe3de9a..7c9df5a 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -188,7 +188,8 @@ UI_SMALL static void felucca_init(void) song.g[G_FXCH] = midi_set[6]; song.g[G_DRMAP] = midi_set[7]; /* (2.7) GLO > MIDI 3: DR MAP */ song.g[G_CLKOUT] = midi_set[9]; /* (2.7) GLO > MIDI 3: CLK OUT */ - song.g[G_RMCH] = midi_set[8]; /* (2.7) GLO > MIDI 3: REMOTE */ /* (2.7) GLO > MIDI 3: FX CH */ /* settings of the FM-1) */ + song.g[G_RMCH] = midi_set[8]; /* (2.7) GLO > MIDI 3: REMOTE */ + song.g[G_FXFADE] = fxfade; /* (2.7.2) GLO > MASTER 2: the punch-in FX fade */ /* (2.7) GLO > MIDI 3: FX CH */ /* settings of the FM-1) */ layers_init(); /* the panel's layer buttons for the keys (ui_layers.c) */ go_home(); ui.force = 1; diff --git a/firmware/src/panel.c b/firmware/src/panel.c index e6db962..e447fac 100644 --- a/firmware/src/panel.c +++ b/firmware/src/panel.c @@ -87,6 +87,8 @@ static uint8_t lights_min; /* GLO > SYSTEM > IN (G_ROUTE): 0 #define MIDI_SET_DEF {1, 2, 3, 10, 0, 2, 0, 0, 0, 0} /* CH1 CH2 CH3, drums, OTHER, (2.6) BEND, (2.7) FX CH, DR MAP, REMOTE, * CLK OUT */ static uint8_t midi_set[10] = MIDI_SET_DEF; +static uint8_t fxfade; /* (2.7.2) FX layer SELECT (FX held): the punch-in FX fade, 0..15 (punch.c); + * a setting of the FM-1, mirrored in song.g[G_FXFADE], kept in BEND's byte */ static const uint16_t LIGHTS_NS[LIGHTS_N] = {0u, 500u, 1000u, 2000u}; /* the backlight pulse a frame (ns): a lit * LED ~95 us, the glow (landmarks) 4 us (fm1_input.h) */ static uint8_t usb_serial; /* menu USB SERIAL: 1 = the serial console presented (usb.c) */ @@ -95,6 +97,10 @@ static uint8_t cpu1_off; /* menu 2ND CORE: 1 = OFF, every * 2.7: ON by default (bit 26 set = OFF); core 1 starts at power-on only when ON */ static uint8_t vis_style; /* the visualiser's style, 0..11 (ui_vis.c) */ static uint8_t knob_accel_off; /* menu KNOB ACCEL (2.7): 1 = OFF, one value a detent however fast (ui_input.c accel) */ +static uint8_t step_adv_off; /* menu SEQ > STEP ADVANCE (2.7.1): 1 = OFF, the STEP page's cursor stays where it + * is when the keys are let go (KNOB 1 moves it); kept in the MIDI part */ +static uint8_t drum_preview; /* menu DRUM PREVIEW (2.7.1): 1 = ON, a drum sound picked with a knob is heard; OFF (the + * default): silent, for live (ui_studio.c). Kept in the MIDI part (project.c) */ UI_SMALL static uint32_t lights_word(void) { return (uint32_t)lights_lvl | (uint32_t)lights_keys << 4 | (uint32_t)(lights_notes != 0u) << 8 | diff --git a/firmware/src/params.c b/firmware/src/params.c index b2bbe27..6e26146 100644 --- a/firmware/src/params.c +++ b/firmware/src/params.c @@ -203,6 +203,7 @@ static const param_desc_t GP[G_COUNT] = { [G_CLKOUT] = PE("CLOCK", N_CLKOUT, 0), /* 2.7, GLO > MIDI 3: MIDI clock and START / STOP out on USB (seq.c) */ [G_RMCH] = PE("REMOTE", N_MCH, 0), /* 2.7, GLO > MIDI 3: the buttons over MIDI (CC 102..115, seq.c remote_cc) */ /* 2.7, GLO > MIDI 3: MIDI notes -> drum sounds (seq.c midi_drum_lane) */ /* 2.7, GLO > MIDI 3: the punch-in FX's channel (seq.c midi_fx) */ [G_BEND] = PD("BEND", F_SEMI, 1, 12, 2), /* 2.6, GLO > MIDI 2: MIDI pitch bend's range (a setting of the FM-1) */ + [G_FXFADE] = PD("FADE", F_INT, 0, 15, 0), /* 2.7.2: the punch-in FX fade (FX layer SELECT), 0 off .. 15 (punch.c) */ }; static const param_desc_t DRUM_KIT_DESC = PE("KIT", DRUM_KIT_NAMES, 0); @@ -429,9 +430,10 @@ static const page_t PAGES[] = { {"USER", FAM_SAVE, SC_GLOBAL, GR_USER, {0xFF, 0xFF, 0xFF, 0xFF}}, /* user presets: SLOT LOAD ERASE SAVE */ {"SECTION", FAM_SAVE, SC_GLOBAL, GR_SLOTS, {G_SLOT, 0xFF, G_LOAD, G_SAVE}}, /* ("PROJECT" before 2.7) */ /* (KNOB 2: ERASE, 2.6: ui_input.c) */ {"TOOLS", FAM_SAVE, SC_GLOBAL, GR_NONE, {G_CLRSEQ, G_INITSND, 0xFF, G_NEWPRJ}}, - {"ARP", FAM_ARP, SC_TRACK, GR_ARP, {P_AMODE, P_ARATE, P_AOCT, P_AGATE}}, + {"ARP", FAM_ARP, SC_TRACK, GR_NONE, {P_AMODE, P_ARATE, P_AOCT, P_AGATE}}, /* (2.7.2: its values large, as ARP 2: + * GR_ARP was never drawn, the middle stayed empty) */ {"ARP 2", FAM_ARP, SC_TRACK, GR_NONE, {P_ASWING, P_APROB, P_AHOLD, P_AORDER}}, - {"STEP", FAM_SEQ, SC_STEP, GR_ROLL, {0, 1, 2, 3}}, + {"NOTES", FAM_SEQ, SC_STEP, GR_ROLL, {0, 1, 2, 3}}, /* (2.7.2: the NOTES editor; "STEP" before) */ {"PATTERN", FAM_SEQ, SC_TRACK, GR_STEPS, {P_SLEN, P_SDIV, P_SSWING, P_SGATE}}, {"SONG", FAM_SEQ, SC_SONG, GR_NONE, {0xFF, 0xFF, 0xFF, 0xFF}}, {"TRACKS", FAM_TRK, SC_TRK, GR_TRK, {0, 1, 2, 3}}, /* REC button; TRACK LEVEL LEN PAN */ @@ -449,7 +451,9 @@ static int page_for_drum(const page_t *pg) if (pg->scope == SC_GLOBAL) return pg->graph != GR_BROWSE && pg->graph != GR_USER; return pg->scope != SC_ENGINE && (pg->scope != SC_TRACK || pg->fam == FAM_SEQ || pg->graph == GR_SLCR || - pg->graph == GR_INS); + pg->graph == GR_INS || pg->id[0] == P_TFLT); /* (2.7.2: FX > FILTER too, the + * track's filter: the drums have it since 2.4, the page was + * greyed "DRUM TRACK") */ } /* a page the buttons and SELECT reach on the selected track: EDIT > FILTER (TYPE) on ANALOG only */ static int page_shown(const page_t *pg) diff --git a/firmware/src/project.c b/firmware/src/project.c index 9d4551e..20c4eda 100644 --- a/firmware/src/project.c +++ b/firmware/src/project.c @@ -39,8 +39,9 @@ #define PROJ_NG 32u /* the globals of formats 4 and 5 (G_COUNT until 2.4). SLOOP 2.5's * G_DRDLY rides in the byte after sel (0 in older projects: off), * so the format and its size do not change */ -_Static_assert(G_DRDLY == PROJ_NG && G_TXSRC == PROJ_NG + 5u && G_COUNT == G_CLKOUT + 1u, +_Static_assert(G_DRDLY == PROJ_NG && G_TXSRC == PROJ_NG + 5u, "the globals a project holds, then G_DRDLY (then 2.6's GLO > MIDI: settings of the FM-1)"); +_Static_assert(G_FXFADE == G_CLKOUT + 1u && G_COUNT == G_FXFADE + 1u, "G_FXFADE (2.7.2) is the last global, a setting of the FM-1"); #define PROJ_NC6 ((uint32_t)P_ITYPE) /* format 6: the parameters kept in 16 bits, P_LEVEL .. P_VLEAD (as 5), */ #define PROJ_NX6 ((uint32_t)(P_E0 - P_ITYPE)) /* the 2.6 ones in a byte (0..127), then P_E0 .. P_E7 */ _Static_assert(PROJ_NC6 == PROJ_NP_V5 - 8u && PROJ_NX6 == 10u, "format 6: format 5's parameters, then ten bytes"); @@ -637,6 +638,8 @@ UI_SMALL static void project_apply(const project_t *p) transport_req = 2; panic_req = (1u << NTRK) - 1u; drum_mute = 0; /* (the live mutes: a performance's, not the project's) */ + for (k = 0; k < NTRK; k++) + ex_off[k] = 0; /* (2.7.1) MIDI EXPRESSION: full again, as after CC 121 */ fm1_irq_off(); /* the audio ISR must not see half a project */ proj_apply(p, 1); song.sel = (uint8_t)(p->sel < NTRK ? p->sel : 0u); @@ -865,11 +868,14 @@ UI_SMALL static void midi_part_fill(uint8_t *b) for (k = 0; k < ML_N; k++) b[2u * k] = (uint8_t)ml_tab[k], b[2u * k + 1u] = (uint8_t)(ml_tab[k] >> 8); b[2u * ML_N] = midi_set[0], b[2u * ML_N + 1u] = midi_set[1], b[2u * ML_N + 2u] = midi_set[2]; - b[2u * ML_N + 3u] = (uint8_t)(midi_set[3] | midi_set[4] << 7); - b[2u * ML_N + 4u] = midi_set[5]; + b[2u * ML_N + 3u] = (uint8_t)(midi_set[3] | (drum_preview != 0u) << 5 | (step_adv_off != 0u) << 6 | midi_set[4] << 7); + /* (2.7.1: bit 5 DRUM PREVIEW, bit 6 STEP ADVANCE OFF: bits 2.7 does not read) */ + b[2u * ML_N + 4u] = (uint8_t)(midi_set[5] | (fxfade > 15u ? 15u : fxfade) << 4); /* BEND (bits 0-3); 2.7.2: FX FADE bits 4-7 (0 = none: the byte reads as 2.6's BEND) */ b[2u * ML_N + 5u] = midi_set[6]; /* (2.7) GLO > MIDI 3: FX CH (2.6 read this spare byte as nothing) */ - b[2u * ML_N + 6u] = (uint8_t)(midi_set[7] | midi_set[9] << 1); /* (2.7) GLO > MIDI 3: DR MAP, bit 1 CLK OUT (a spare - * byte to 2.6) */ + b[2u * ML_N + 6u] = (uint8_t)(midi_set[7] | midi_set[9] << 1 | + (flt_reso > 10u ? 10u : flt_reso) << 2); /* (2.7) GLO > MIDI 3: DR MAP, bit 1 CLK OUT + * (a spare byte to 2.6); 2.7.2: FILTER RESO in bits + * 2..5 (0 = none: the byte then reads as 2.7's) */ b[2u * ML_N + 7u] = midi_set[8]; /* (2.7) GLO > MIDI 3: REMOTE (the last spare byte) */ } UI_SMALL static int midi_part_default(const uint8_t *b) @@ -898,16 +904,23 @@ UI_SMALL static void midi_part_read(const uint8_t *b, uint32_t n) midi_set[k] = (uint8_t)(b[2u * ML_N + k] <= 16u ? b[2u * ML_N + k] : k + 1u); midi_set[3] = (uint8_t)((b[2u * ML_N + 3u] & 31u) <= 16u ? b[2u * ML_N + 3u] & 31u : 10u); midi_set[4] = (uint8_t)(b[2u * ML_N + 3u] >> 7); + drum_preview = (uint8_t)((b[2u * ML_N + 3u] >> 5) & 1u); /* (2.7.1) menu DRUM PREVIEW; older: OFF */ + step_adv_off = (uint8_t)((b[2u * ML_N + 3u] >> 6) & 1u); /* (2.7.1) menu STEP ADVANCE; older: ON */ song.g[G_CH1] = midi_set[0], song.g[G_CH2] = midi_set[1], song.g[G_CH3] = midi_set[2]; song.g[G_DRCH] = midi_set[3], song.g[G_CHOTH] = midi_set[4]; } if (n >= MIDI_PART) { - midi_set[5] = (uint8_t)(b[2u * ML_N + 4u] >= 1u && b[2u * ML_N + 4u] <= 12u ? b[2u * ML_N + 4u] : 2u); + midi_set[5] = (uint8_t)((b[2u * ML_N + 4u] & 15u) >= 1u && (b[2u * ML_N + 4u] & 15u) <= 12u ? b[2u * ML_N + 4u] & 15u : 2u); song.g[G_BEND] = midi_set[5]; + fxfade = (uint8_t)((b[2u * ML_N + 4u] >> 4) & 15u); /* (2.7.2) FX FADE (bits 4-7); older: 0 */ + song.g[G_FXFADE] = fxfade; midi_set[6] = (uint8_t)(b[2u * ML_N + 5u] <= 16u ? b[2u * ML_N + 5u] : 0u); /* (2.7) FX CH */ song.g[G_FXCH] = midi_set[6]; - midi_set[7] = (uint8_t)(b[2u * ML_N + 6u] <= 3u ? b[2u * ML_N + 6u] & 1u : 0u); /* (2.7) DR MAP */ - midi_set[9] = (uint8_t)(b[2u * ML_N + 6u] <= 3u ? b[2u * ML_N + 6u] >> 1 : 0u); /* (2.7) CLK OUT */ + midi_set[7] = (uint8_t)(b[2u * ML_N + 6u] & 1u); /* (2.7) DR MAP */ + midi_set[9] = (uint8_t)((b[2u * ML_N + 6u] >> 1) & 1u); /* (2.7) CLK OUT */ + flt_reso = (uint8_t)((b[2u * ML_N + 6u] >> 2) & 15u); /* (2.7.2) FILTER RESO (bits 2..5); older: 0 */ + if (flt_reso > 10u) + flt_reso = 10u; song.g[G_DRMAP] = midi_set[7]; song.g[G_CLKOUT] = midi_set[9]; midi_set[8] = (uint8_t)(b[2u * ML_N + 7u] <= 16u ? b[2u * ML_N + 7u] : 0u); /* (2.7) REMOTE */ @@ -1169,6 +1182,10 @@ UI_SMALL static void sections_flush(void) /* main loop */ midi_set[k] = (uint8_t)song.g[gid[k]]; settings_later = 1; } + if ((uint32_t)song.g[G_FXFADE] != fxfade) { /* (2.7.2) GLO > MASTER 2 > FADE: a setting of the FM-1 */ + fxfade = (uint8_t)song.g[G_FXFADE]; + settings_later = 1; + } } if (settings_later) { /* the menu closed while playing */ settings_later = 0; diff --git a/firmware/src/punch.c b/firmware/src/punch.c index 256f484..4149e17 100644 --- a/firmware/src/punch.c +++ b/firmware/src/punch.c @@ -232,7 +232,7 @@ static void punch_freeze_feed(int32_t *rev, const int32_t *l, const int32_t *r, static void punch_process(int32_t *l, int32_t *r, uint32_t n) { uint32_t i; - int32_t want = punch.req; + int32_t want = punch.req, pstep; uint32_t beat, step, echo_d, binc, fdec; static int32_t kl[CTL], kr[CTL]; /* (static: the ISR stack is small) */ tsvf_t c1, c2; @@ -292,6 +292,13 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n) tsvf_coef(&c2, 58 << 8, 40); /* PHONE: low cut ~ 500 Hz */ } } + { /* (2.7.2) GLO > MASTER 2 > FADE: the wet gain's ramp when an effect is engaged / released. 512 (0, ~1.5 ms, as + * before, just anti-click) down to ~2 at 15 (~0.37 s): a slow fade in and out of the effect */ + int32_t f = (int32_t)song.g[G_FXFADE]; + pstep = 512 / (1 + (f < 0 ? 0 : f > 15 ? 15 : f) * 17); + if (pstep < 1) + pstep = 1; + } for (i = 0; i < n; i++) { int32_t x = l[i], y = r[i], wl = x, wr = y, m = (x + y) >> 1; int32_t fx = punch.cur; @@ -423,9 +430,9 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n) break; } if ((uint32_t)punch.g < target) - punch.g = punch.g + 512 > 32767 ? 32767 : punch.g + 512; + punch.g = punch.g + pstep > 32767 ? 32767 : punch.g + pstep; else if ((uint32_t)punch.g > target) - punch.g = punch.g < 512 ? 0 : punch.g - 512; + punch.g = punch.g < pstep ? 0 : punch.g - pstep; l[i] = x + ((((wl - x) >> 3) * (punch.g >> 3)) >> 9); /* (no 32-bit overflow) */ r[i] = y + ((((wr - y) >> 3) * (punch.g >> 3)) >> 9); punch.w++; diff --git a/firmware/src/recovery.c b/firmware/src/recovery.c index 992e232..8337f6a 100644 --- a/firmware/src/recovery.c +++ b/firmware/src/recovery.c @@ -38,9 +38,17 @@ static void recovery_step(void) } } +/* (2.7.2) the key matrix reads only while PA2, the backlight (active low), is driven low: the ROM and the bootloaders + * leave it undriven, and lcd_init (fm1_lcd_hw_init) comes after this scan, so OCT- was never seen and SLOOP USB RESCUE + * never opened (measured on an FM-1 and reported in a YouTube comment; the fix there was the same). The backlight comes + * on ~50 ms earlier */ +#ifndef RECOVERY_KEYS_ON +#define RECOVERY_KEYS_ON() fm1_lcd_backlight_on() /* (2.7.2) the PA register access lives in hal/ (fm1_lcd_hw.h) */ +#endif static int recovery_key(void) { uint32_t start = fm1_ticks(); + RECOVERY_KEYS_ON(); fm1_input_init(); do { fm1_wdt_feed(); diff --git a/firmware/src/seq.c b/firmware/src/seq.c index c04fb84..cbb4201 100644 --- a/firmware/src/seq.c +++ b/firmware/src/seq.c @@ -59,6 +59,7 @@ static volatile uint32_t step_in_w; static volatile uint8_t step_in_lost; static uint32_t step_in_r; static volatile uint8_t pc_req[NTRK]; /* (2.6) a MIDI Program Change for the track: number + 1 (ui.c pc_poll) */ +static volatile uint8_t pc_bank[NTRK]; /* (2.7.2) the Bank Select (CC 0) latched when that PC came (ui.c pc_poll) */ static void step_in_push(uint32_t ev) { if (step_in_w - step_in_r >= STEP_IN_Q) { @@ -531,6 +532,9 @@ static void step_add(track_t *t, uint32_t idx, uint32_t note, uint32_t vel, uint s->vel = (uint8_t)vel; } +#ifndef UI_SMALL +#define UI_SMALL /* (gfx.c: minsize; the host tests: nothing) */ +#endif /* ---- SLOOP 2.7: overdub over held notes ---- * A pattern holds its notes with TIE steps (the notes of the NOTE step before them go on). A note recorded into a TIE * used to make that step a NOTE of its own, which ends the held notes there. Now (POLY parts) the step becomes a NOTE @@ -538,7 +542,7 @@ static void step_add(track_t *t, uint32_t idx, uint32_t note, uint32_t vel, uint * oldest held one makes room); the step after it, when a TIE, becomes the new note's end: a NOTE of the held notes * only, all going on (step_pure_cont). While the new note is held, rec_hold moves that end along. Step entry (SEQ + * key) still replaces what plays. */ -static uint32_t chain_notes(const track_t *t, uint32_t idx, uint8_t *out) /* what goes on into TIE step idx */ +UI_SMALL static uint32_t chain_notes(const track_t *t, uint32_t idx, uint8_t *out) /* what goes on into TIE step idx */ { uint32_t len = trk_len(t), k; for (k = 1; k < len; k++) { @@ -553,11 +557,11 @@ static uint32_t chain_notes(const track_t *t, uint32_t idx, uint8_t *out) /* w } return 0; } -static int step_pure_cont(const step_t *s) /* a NOTE whose notes all go on: the end of an overdubbed note */ +UI_SMALL static int step_pure_cont(const step_t *s) /* a NOTE whose notes all go on: the end of an overdubbed note */ { return s->time == ST_NOTE && s->n && s->n <= 4u && ((s->flags & SF_CONT_ALL) / SF_CONT0) == (1u << s->n) - 1u; } -static void chain_end(track_t *t, uint32_t j, const uint8_t *keep, uint32_t n) /* TIE j: only keep goes on */ +UI_SMALL static void chain_end(track_t *t, uint32_t j, const uint8_t *keep, uint32_t n) /* TIE j: only keep goes on */ { step_t *s = &t->step[j % NSTEP]; uint32_t i; @@ -571,7 +575,7 @@ static void chain_end(track_t *t, uint32_t j, const uint8_t *keep, uint32_t n) s->n = (uint8_t)i; s->time = ST_NOTE; } -static uint32_t cont_notes(const step_t *s, uint32_t except, uint8_t *out) /* its notes going on, but except */ +UI_SMALL static uint32_t cont_notes(const step_t *s, uint32_t except, uint8_t *out) /* its notes going on, but except */ { uint32_t i, n = 0; for (i = 0; i < s->n && i < 4u; i++) @@ -580,22 +584,94 @@ static uint32_t cont_notes(const step_t *s, uint32_t except, uint8_t *out) /* return n; } +/* (2.7.1) several notes held while recording (POLY): each goes on until its own key is let go. A note recorded over a + * held one makes its step a NOTE of the held ones going on + the new one (as over a pattern's held notes, above); one let + * go while others are held ends there: the step it ends on becomes a NOTE of the others only, all going on (hold_restart), + * and TIEs carry them on. Before, the hold followed the newest note only and the others ended with it */ +UI_SMALL static int rh_has(const track_t *t, uint32_t note) /* a note of this hold: held, or let go since its last NOTE */ +{ + uint32_t i; + for (i = 0; i < t->rh_n; i++) + if (t->rh_note[i] == note) + return 1; + for (i = 0; i < t->rh_offn; i++) + if (t->rh_off[i] == note) + return 1; + return 0; +} +UI_SMALL static int rh_held(const track_t *t, uint32_t note) +{ + uint32_t i; + for (i = 0; i < t->rh_n; i++) + if (t->rh_note[i] == note) + return 1; + return 0; +} +UI_SMALL static void hold_marker_clear(track_t *t, uint32_t j, uint32_t also) /* an end marker of only this hold's notes: gone */ +{ + step_t *s = &t->step[j % NSTEP]; + uint32_t i; + if (!step_pure_cont(s)) + return; + for (i = 0; i < s->n; i++) + if (!rh_has(t, s->note[i]) && s->note[i] != also) + return; + memset(s, 0, sizeof *s); + s->time = ST_REST; +} +UI_SMALL static void hold_restart(track_t *t, uint32_t j, uint32_t len, uint32_t abs) /* step j: only the notes still held go on */ +{ + step_t *s = &t->step[j % NSTEP]; + uint8_t c[4]; + uint32_t n = chain_notes(t, j, c), i, k, m = 0; + for (i = 0; i < n; i++) { /* (what sounded into j, but the ones let go) */ + for (k = 0; k < t->rh_offn && t->rh_off[k] != c[i]; k++) + ; + if (k == t->rh_offn) + c[m++] = c[i]; + } + hold_marker_clear(t, (j + 1u) % len, 0x100u); + memset(s, 0, sizeof *s); + for (i = 0; i < m; i++) { + s->note[i] = c[i]; + s->flags |= (uint8_t)SF_CONT(i); + } + s->n = (uint8_t)m; + s->time = m ? ST_NOTE : ST_REST; + t->rh_start = (uint8_t)j; + t->rh_last = (uint8_t)j; + t->rh_last_abs = abs; + t->rh_ties = 0; + t->rh_rs = 1; + t->rh_end = 0; + t->rh_offn = 0; +} + /* live recording into a synth part: the nearest step (rec_target). Held on: each further step the * sequencer enters while the note is held becomes a TIE (rec_hold), up to the pattern length and * never over a step with notes (overdub keeps them); a release before the middle of the last one * puts that step back (rec_release), so a short note stays one step. A note recorded into another * step ends the hold before (the step model ties the notes of one step only). */ -static void rec_note(track_t *t, uint32_t note, uint32_t vel, uint32_t rat, int hold) +UI_SMALL static void rec_note(track_t *t, uint32_t note, uint32_t vel, uint32_t rat, int hold) { uint32_t len = trk_len(t), later, abs = rec_target(t, &later), idx = abs % len, k; int was_empty = !(t->step[idx % NSTEP].time == ST_NOTE && t->step[idx % NSTEP].n); step_t *st = &t->step[idx % NSTEP]; uint8_t ch[4], keep[4]; - uint32_t nc, nk = 0; + uint32_t nc = 0, nk = 0, merged = 0; undo_mark(t, UNDO_REC(t)); - if (t->p[P_VOICE] == V_POLY && !rat && st->time == ST_TIE && (nc = chain_notes(t, idx, ch)) != 0) { + if (t->p[P_VOICE] == V_POLY && !rat && hold && t->rh_n && st->time != ST_TIE && !(st->time == ST_NOTE && st->n) && + idx == ((t->rh_ties || t->rh_rs ? t->rh_last : t->rh_start) + 1u) % len) { + nc = t->rh_n; /* (2.7.1) the step the hold goes on into, not tied yet: as a TIE */ + memcpy(ch, t->rh_note, nc); + st->time = ST_TIE; + } else if (t->p[P_VOICE] == V_POLY && !rat && st->time == ST_TIE) { + nc = chain_notes(t, idx, ch); + } + if (nc) { + merged = hold != 0; for (k = 0; k < nc; k++) /* (2.7) over held notes: they go on, this one starts */ - if (ch[k] != note) + if (ch[k] != note && !(t->rh_n && rh_has(t, ch[k]) && !rh_held(t, ch[k]))) /* (2.7.1: not one let go) */ keep[nk++] = ch[k]; while (nk > 3u) { /* (four at most: the oldest one ends here) */ for (k = 0; k + 1u < nk; k++) @@ -615,7 +691,13 @@ static void rec_note(track_t *t, uint32_t note, uint32_t vel, uint32_t rat, int if ((idx + 1u) % len != idx) chain_end(t, (idx + 1u) % len, keep, nk); } else { + uint32_t last = t->rh_ties || t->rh_rs ? t->rh_last : t->rh_start; + int leg = t->p[P_VOICE] != V_POLY && !rat && hold && t->rh_n && !(t->rh_n == 1u && t->rh_note[0] == note) && + idx != t->rh_start && (idx == (last + 1u) % len || (t->rh_ties && idx == last && st->time == ST_TIE)); step_add(t, idx, note, vel, vel_lvl(vel), rat); + if (leg) /* (2.7.2) MONO / LEGATO: played over the note before, still held + * into this step (or to it): legato, as it sounded */ + st->flags |= (uint8_t)SF_LEG; for (k = 0; k < st->n; k++) /* (2.7) played again: it starts here */ if (st->note[k] == note) st->flags &= (uint8_t)~SF_CONT(k); @@ -634,10 +716,15 @@ static void rec_note(track_t *t, uint32_t note, uint32_t vel, uint32_t rat, int } if (!hold) return; - if (!t->rh_n || t->rh_start != idx) { /* a new hold (one in another step ends) */ + if (merged) { /* (2.7.1) over held ones: they stay held, from this step on */ + t->rh_start = (uint8_t)idx; + t->rh_ties = 0; + t->rh_rs = t->rh_end = t->rh_offn = 0; + } else if (!t->rh_n || t->rh_start != idx) { /* a new hold (one in another step ends) */ t->rh_n = 0; t->rh_start = (uint8_t)idx; t->rh_ties = 0; + t->rh_rs = t->rh_end = t->rh_offn = 0; } for (k = 0; k < t->rh_n && t->rh_note[k] != note; k++) ; @@ -665,7 +752,7 @@ static void rec_hit(track_t *t, uint32_t lane, uint32_t lvl, uint32_t rat) } /* the sequencer enters step idx (before playing it): a recorded note still held ties into it */ -static void rec_hold(track_t *t, uint32_t idx, uint32_t len, uint32_t abs) +UI_SMALL static void rec_hold(track_t *t, uint32_t idx, uint32_t len, uint32_t abs) { step_t *s; if (!t->rh_n) @@ -677,6 +764,10 @@ static void rec_hold(track_t *t, uint32_t idx, uint32_t len, uint32_t abs) if (idx == t->rh_start) return; /* (recorded ahead into the step now starting) */ s = &t->step[idx]; + if (t->rh_end && (s->time == ST_TIE || s->time == ST_REST || !s->n || step_pure_cont(s))) { + hold_restart(t, idx, len, abs); /* (2.7.1) one let go: from here the others only */ + return; + } if (step_pure_cont(s)) { /* (2.7) the end of a note over held ones: it goes on, the end moves */ uint8_t keep[4]; uint32_t nk = cont_notes(s, 0x100u, keep); @@ -703,19 +794,41 @@ static void rec_hold(track_t *t, uint32_t idx, uint32_t len, uint32_t abs) } /* a key of a recorded note is up: the hold ends with the last one */ -static void rec_release(track_t *t, uint32_t note) +UI_SMALL static void rec_release(track_t *t, uint32_t note) { - uint32_t i, k = 0, into, slen, half, lat; + uint32_t i, k = 0, into, slen, half, lat, early, len = trk_len(t); for (i = 0; i < t->rh_n; i++) if (t->rh_note[i] != note) t->rh_note[k++] = t->rh_note[i]; - if (k == t->rh_n || (t->rh_n = (uint8_t)k)) - return; /* not one of them, or others still held */ - if (!t->rh_ties || trk_grid(t, &into, &slen) != t->rh_last_abs) - return; + if (k == t->rh_n) + return; /* not one of them */ + early = trk_grid(t, &into, &slen) == t->rh_last_abs; half = slen / 2u; lat = REC_LAT * (uint32_t)song.g[G_BPM]; - if (into <= half + (lat < half ? lat : half) && t->step[t->rh_last].time == ST_TIE) + early = early && into <= half + (lat < half ? lat : half); /* (let go early in the hold's last step) */ + if (k) { /* (2.7.1) others still held: this one ends, they go on */ + t->rh_n = (uint8_t)k; + if (t->p[P_VOICE] != V_POLY) + return; + if (t->rh_offn < 4u) + t->rh_off[t->rh_offn++] = (uint8_t)note; + if (t->rh_ties && early && t->step[t->rh_last].time == ST_TIE) + hold_restart(t, t->rh_last, len, t->rh_last_abs); /* (not held into this step: it ends before it) */ + else + t->rh_end = 1; /* (held into this step: it ends with it) */ + return; + } + t->rh_n = 0; + hold_marker_clear(t, ((t->rh_ties || t->rh_rs ? t->rh_last : t->rh_start) + 1u) % len, note); /* (2.7.1) an end left + * ahead of notes all let go */ + if (t->rh_rs && !t->rh_ties && early && step_pure_cont(&t->step[t->rh_last])) { + memset(&t->step[t->rh_last], 0, sizeof t->step[t->rh_last]); /* (2.7.1) let go early in a step the others went on */ + t->step[t->rh_last].time = ST_REST; /* into: not held into it */ + } + t->rh_end = t->rh_rs = t->rh_offn = 0; + if (!t->rh_ties || !early) + return; + if (t->step[t->rh_last].time == ST_TIE) t->step[t->rh_last] = t->rh_bak; /* released early in it: not held into this step */ } @@ -2243,8 +2356,9 @@ static void seq_step(track_t *t, const step_t *s, uint32_t slen, uint32_t skip) uint32_t i, j, gate = slen * (uint32_t)t->p[P_SGATE] / 128u; uint32_t slide_in = t->seq_hold && t->seq_n; const step_t *nx = &t->step[(t->seq_idx + 1u) % trk_len(t)]; - uint32_t next_tie = nx->time == ST_TIE || (nx->time == ST_NOTE && (nx->flags & SF_CONT_ALL)); /* (2.7: notes going on - * into the next step: held to it, it says which end) */ + uint32_t next_tie = nx->time == ST_TIE || (nx->time == ST_NOTE && (nx->flags & (SF_CONT_ALL | SF_LEG))); /* (2.7: notes + * going on into the next step: held to it, it says which end; + * 2.7.2: a legato note next: held to it) */ if (s->time == ST_TIE) { if (t->seq_n) { t->seq_off = gate + slen / 2u; @@ -2291,7 +2405,8 @@ static void seq_step(track_t *t, const step_t *s, uint32_t slen, uint32_t skip) hits = 1u + ((s->rat >> (2u * i)) & 3u); gate /= hits; } - t->slide_glide = (uint8_t)slide_in; + t->slide_glide = (uint8_t)(slide_in && (!(s->flags & SF_LEG) || /* (2.7.2: legato alone: no glide of its own) */ + (t->step[(t->seq_idx + trk_len(t) - 1u) % trk_len(t)].flags & SF_SLIDE))); if (!slide_in) seq_release(t); for (i = 0; i < s->n; i++) @@ -2536,6 +2651,7 @@ static track_t *midi_route(uint32_t ch, uint32_t note, int on) /* (2.6) the pedal and the wheel of a channel: the track they act on is remembered (track + 1), so a pedal let up or a * wheel let go after another track got selected (a SEL channel, IN = CH n) still lets go of the one they held */ static uint8_t ch_sus[16], ch_bend[16]; +static uint8_t ch_bank[16]; /* (2.7.2) MIDI Bank Select (CC 0) per channel, latched for the next Program Change */ static void sus_set(track_t *t, int on); static void midi_pedal(uint32_t ch, track_t *t, uint32_t value) { @@ -2559,7 +2675,8 @@ static void midi_bend(uint32_t ch, track_t *t, uint32_t d1, uint32_t d2) * range, 64 the middle of a bipolar one. 5 GLIDE, 7 LEVEL, 10 PAN, 71 the engine's resonance (RES or Q; * an engine without one ignores it), 72 / 73 / 75 release / attack / decay, 74 the track's FILTER (64 off, * below a low-pass, above a high-pass: on every engine and the drums), 91 / 93 / 94 the reverb, chorus and - * delay sends. The drum track takes 7, 91 and 94 as GLO > DRUMS LVL, REV and DLY (2.5), and 10 and 74. */ + * delay sends. The drum track takes 7, 91 and 94 as GLO > DRUMS LVL, REV and DLY (2.5), and 10 and 74. + * 2.7.1: 11 EXPRESSION, a gain over the LEVEL (core.h ex_off, every track and the drums), 121 sets it back to full. */ #define MCC_RES 0xFFu #define MCC_CUT 0xFEu /* (2.7) CC 74: the engine's own cutoff / brightness, else FILTER */ static const uint8_t MIDI_CC_MAP[][2] = { @@ -2664,6 +2781,10 @@ static void __attribute__((noinline)) midi_cc(track_t *t, uint32_t cc, uint32_t sus_set(t, value >= 64u); return; } + if (cc == 11u || cc == 121u) { /* (2.7.1) EXPRESSION; RESET ALL CONTROLLERS: full again */ + ex_off[trk_index(t) % NTRK] = (uint8_t)(cc == 11u ? 127u - (value & 127u) : 0u); + return; + } for (i = 0; i < NELEM(MIDI_CC_MAP); i++) if (MIDI_CC_MAP[i][0] == cc) id = MIDI_CC_MAP[i][1]; @@ -2711,12 +2832,15 @@ static void __attribute__((noinline)) midi_cc(track_t *t, uint32_t cc, uint32_t * (the slicer, delay and arp follow it). START restarts from the top, CONTINUE carries on where it * stopped, STOP stops. With no pulse for 0.5 s, the internal tempo takes over (PLAY works as ever). */ #define MCLK_PULSE_U (BEAT_U / 24u) +#define MCLK_NB 8u /* (2.7.2) the tempo: the mean of the last 8 beats */ static struct { uint32_t pos, done; /* units: the master's position (pulses since START), ours */ uint32_t last_ms, iv_ms; /* the last pulse, the interval between pulses (smoothed) */ uint32_t beat_ms; /* when pulse 0 of the last 24 came: the tempo */ uint8_t have, n24; /* a pulse since START; pulses towards the next tempo reading */ uint8_t alive; /* pulses are coming (from the SYNC source) */ + uint8_t nb, bi; /* (2.7.2) the last beats' lengths (bdt[], up to MCLK_NB, bi the next) */ + uint16_t bdt[MCLK_NB]; } mclk; static int mclk_on(void) /* the clock drives the sequencer */ @@ -2724,6 +2848,28 @@ static int mclk_on(void) /* the clock drives the sequen return song.g[G_SYNC] && mclk.alive && fm1_ms - mclk.last_ms < 500u; } +/* (2.7.2) the tempo from a beat of dt ms. A beat timed to the millisecond reads +-1 BPM at random (140: 428.6 ms; the + * computer, USB and our blocks move a pulse by a few ms), so: the mean of the last 8 beats, in tenths of a BPM; once + * there are 8, BPM changes only when the mean is 0.8 away (a steady 140 stays 140; a tempo ramp still goes through). A + * beat 5 BPM or more away is a new tempo: taken at once (the 8 start again). The sequencer follows the pulses either + * way: this is the BPM shown (and what follows it: delay, slicer, arp) */ +static void mclk_tempo(uint32_t dt) +{ + uint32_t k, sum = 0, t10; + int32_t one = (int32_t)((60000u + dt / 2u) / dt), cur = song.g[G_BPM]; + if (mclk.nb && (one - cur >= 5 || cur - one >= 5)) + mclk.nb = 0; + mclk.bdt[mclk.bi] = (uint16_t)dt; + mclk.bi = (uint8_t)((mclk.bi + 1u) % MCLK_NB); + if (mclk.nb < MCLK_NB) + mclk.nb++; + for (k = 0; k < mclk.nb; k++) + sum += mclk.bdt[(mclk.bi + MCLK_NB - 1u - k) % MCLK_NB]; + t10 = (600000u * mclk.nb + sum / 2u) / sum; /* (<= 8 x 600000 + 6000: fits 32 bits) */ + if (mclk.nb < MCLK_NB || (int32_t)t10 - cur * 10 >= 8 || cur * 10 - (int32_t)t10 >= 8) + song.g[G_BPM] = (int16_t)clamp((int32_t)((t10 + 5u) / 10u), 40, 240); +} + static void mclk_event(uint32_t st, uint32_t src) /* a realtime message; src 1 USB, 2 TRS */ { uint32_t now = fm1_ms; @@ -2750,13 +2896,14 @@ static void mclk_event(uint32_t st, uint32_t src) /* a realtime message; src 1 } if (!mclk.alive || now - mclk.last_ms >= 500u) { /* (re)started: count a fresh beat */ mclk.n24 = 0; + mclk.nb = 0; mclk.beat_ms = now; } else if (++mclk.n24 == 24u) { /* a beat: the tempo */ uint32_t dt = now - mclk.beat_ms; mclk.n24 = 0; mclk.beat_ms = now; if (dt >= 250u && dt <= 1500u) /* 40..240 BPM */ - song.g[G_BPM] = (int16_t)clamp((int32_t)((60000u + dt / 2u) / dt), 40, 240); + mclk_tempo(dt); } mclk.alive = 1; mclk.last_ms = now; @@ -3006,6 +3153,10 @@ static void events_block(uint32_t n) if (ch != (uint32_t)song.g[G_ROUTE] - 2u) continue; if (st == 0xB0u) { + if (d1 == 0u) { /* (2.7.2) Bank Select: latched for the next Program Change */ + ch_bank[ch & 15u] = (uint8_t)d2; + continue; + } if (d1 == 64u) midi_pedal(ch, TSEL, d2); midi_cc(TSEL, d1, d2); @@ -3018,6 +3169,7 @@ static void events_block(uint32_t n) } if (st == 0xC0u) { /* Program Change (2.6): the selected track's sound */ pc_req[song.sel % NTRK] = (uint8_t)(d1 + 1u); + pc_bank[song.sel % NTRK] = ch_bank[ch & 15u]; /* (2.7.2) with its Bank Select */ continue; } if (st != 0x90u && st != 0x80u) @@ -3031,6 +3183,10 @@ static void events_block(uint32_t n) } } else { if (st == 0xB0u) { /* a CC (IN = CLOCK: none) */ + if (d1 == 0u) { /* (2.7.2) Bank Select: latched for the next Program Change */ + ch_bank[ch & 15u] = (uint8_t)d2; + continue; + } if (!song.g[G_ROUTE] && (t = midi_track(ch)) != 0) { if (d1 == 64u) midi_pedal(ch, t, d2); @@ -3042,8 +3198,10 @@ static void events_block(uint32_t n) } if (st == 0xC0u) { /* Program Change (2.6): the sound of the track its channel * plays (IN = CLOCK, OTHER = OFF and nobody's channel: none) */ - if (!song.g[G_ROUTE] && (t = midi_track(ch)) != 0) + if (!song.g[G_ROUTE] && (t = midi_track(ch)) != 0) { pc_req[trk_index(t) % NTRK] = (uint8_t)(d1 + 1u); + pc_bank[trk_index(t) % NTRK] = ch_bank[ch & 15u]; /* (2.7.2) with its Bank Select */ + } continue; } if (st == 0xE0u) { /* pitch bend (2.6): the track its channel plays (IN = CLOCK: diff --git a/firmware/src/ui.c b/firmware/src/ui.c index f635141..7cb22cb 100644 --- a/firmware/src/ui.c +++ b/firmware/src/ui.c @@ -3,7 +3,7 @@ /* Felucca user interface. Four columns map to KNOB 1..4. Rendering is lazy: * every element remembers what it last drew and is redrawn only on change. */ #ifndef FELUCCA_VERSION -#define FELUCCA_VERSION "SLOOP 2.7.1" /* the beat machine firmware for the FM-1 (based on Felucca) */ +#define FELUCCA_VERSION "SLOOP 2.8" /* the beat machine firmware for the FM-1 (based on Felucca) */ #endif static void project_save(uint32_t slot); static void arrangement_save(void); @@ -12,6 +12,7 @@ static void project_load(uint32_t slot); static void project_erase(uint32_t slot); /* SAVE > PROJECT > ERASE (2.6) */ static int project_used(uint32_t slot); static int up_used(uint32_t k); /* user presets: upreset.c */ +static int up_arp_of(uint32_t k, int16_t *a); /* (2.7.1) user preset k's arp, MODE … ORDER: upreset.c */ static int up_load(uint32_t k); static int up_load_to(track_t *t, uint32_t k); static uint32_t up_count(void); @@ -51,6 +52,9 @@ static struct { uint8_t bank; /* SEQ: 16-step bank (follows the cursor) */ uint8_t cursor; /* SEQ: step being edited (STEP page KNOB 1 moves it) */ uint8_t entry_open; /* SEQ: keys held since the first press of this entry */ + uint8_t note_k; /* (2.7.2) NOTES: the note of the cursor's chord (0..n-1) */ + uint8_t zoom; /* (2.7.2) NOTES: the steps shown, NV_ZOOM[zoom] (PRESETS) */ + uint8_t sheet; /* (2.7.2) NOTES / DRUMS grid: the sheet (OCT+ held) open: 1 + its row; 0 closed */ uint8_t hot_col, hot_t; /* column whose knob was just turned (drawn white) */ uint8_t menu; /* 0 off, 1 list, 2 about (HOME held) */ uint8_t menu_sel; @@ -263,12 +267,178 @@ UI_SMALL static void cursor_set(int32_t c) ui.cursor = (uint8_t)((c % len + len) % len); ui.bank = (uint8_t)(ui.cursor / 16u); ui.entry_open = 0; + ui.note_k = 0; } UI_SMALL static void cursor_fix(void) /* LEN got shorter: onto the last step */ { if (ui.cursor >= (uint32_t)TSEL->p[P_SLEN]) cursor_set(TSEL->p[P_SLEN] - 1); + if (ui.note_k && ui.note_k >= TSEL->step[ui.cursor].n) + ui.note_k = (uint8_t)(TSEL->step[ui.cursor].n ? TSEL->step[ui.cursor].n - 1u : 0u); +} + +/* ---- SLOOP 2.7.2: SEQ > NOTES, the synth tracks' note editor (after Melodee's NOTES page, keremimo, GPL-3.0: the + * idea, not its code; SLOOP keeps its steps). The note under edit: step ui.cursor, note ui.note_k of its chord. KNOB 1 + * walks the notes (a chord's one by one) and the empty steps; a note's TIEs are its length, not stops. KNOB 2 its + * pitch, KNOB 3 its length (note_set_len), KNOB 4 its FORCE, PRESETS the zoom; OCT+ held its sheet (SLIDE, NUDGE, + * FILL, MOVE, COPY, DELETE). The drum grid (ui_studio.c) has the same sheet for a hit */ +static const uint8_t NV_ZOOM[4] = {8, 16, 32, 64}; +static const char *const FORCE_N[5] = {"GHOST", "SOFT", "NORM", "HARD", "ACC"}; +static const uint8_t F_LVL[4] = {LV_GHOST, LV_SOFT, LV_NORM, LV_HARD}; +static const char *const SHEET_N[6] = {"SLIDE", "NUDGE", "FILL", "MOVE", "COPY", "DELETE"}; +static const char *const FILL_N[3] = {"NORMAL", "FILL", "NO FILL"}; +static const char *const DSHEET_N[6] = {"RATCHET", "NUDGE", "FILL", "MOVE", "COPY", "DELETE"}; +UI_SMALL static void note_walk(int32_t dir) +{ + track_t *t = TSEL; + uint32_t len = trk_len(t), i = ui.cursor % len, guard = len; + const step_t *st = &t->step[i]; + if (dir > 0 && step_on(st) && ui.note_k + 1u < st->n) { + ui.note_k++; + return; + } + if (dir < 0 && step_on(st) && ui.note_k) { + ui.note_k--; + return; + } + do /* (the TIEs belong to the note before them) */ + i = dir > 0 ? (i + 1u) % len : (i + len - 1u) % len; + while (--guard && t->step[i].time == ST_TIE); + cursor_set((int32_t)i); + if (dir < 0 && step_on(&t->step[i])) + ui.note_k = (uint8_t)(t->step[i].n - 1u); /* (back: the chord's last note) */ +} +UI_SMALL static uint32_t note_force(const step_t *st, uint32_t k) /* 0 GHOST .. 3 HARD, 4 ACC (the step's accent) */ +{ + uint32_t l = (st->lvl >> (2u * k)) & 3u; + if (st->flags & SF_ACCENT) + return 4u; + return l == LV_GHOST ? 0u : l == LV_SOFT ? 1u : l == LV_HARD ? 3u : 2u; +} +UI_SMALL static void note_force_set(step_t *st, uint32_t k, uint32_t f) +{ + uint32_t sh = 2u * k; + st->lvl = (uint8_t)((st->lvl & ~(3u << sh)) | (uint32_t)F_LVL[f > 3u ? 3u : f] << sh); + st->flags = (uint8_t)((st->flags & ~SF_ACCENT) | (f == 4u ? SF_ACCENT : 0u)); +} +static uint8_t drop2(uint32_t v, uint32_t k) /* a 2-bit field per note: note k's taken out */ +{ + return (uint8_t)((v & ((1u << (2u * k)) - 1u)) | ((v >> (2u * k + 2u)) << (2u * k))); +} +UI_SMALL static void note_del(track_t *t, uint32_t i, uint32_t k) /* one note of a chord; the last one: the step */ +{ + step_t *st = &t->step[i]; + uint32_t j, c; + if (!step_on(st)) + return; + if (st->n <= 1u) { + note_set_len(t, i, 1); /* (its TIEs: RESTs) */ + step_clear(st); + return; + } + for (j = k; j + 1u < st->n; j++) + st->note[j] = st->note[j + 1u]; + st->lvl = drop2(st->lvl, k); + st->rat = drop2(st->rat, k); + c = (st->flags & SF_CONT_ALL) / SF_CONT0; + c = (c & ((1u << k) - 1u)) | ((c >> (k + 1u)) << k); + st->flags = (uint8_t)((st->flags & ~SF_CONT_ALL) | c * SF_CONT0); + st->n--; +} +UI_SMALL static int step_free(const track_t *t, uint32_t i) /* nothing there: no note, no TIE */ +{ + return !step_on(&t->step[i]) && t->step[i].time != ST_TIE; +} +/* a note (its step, TIEs, nudge, fill, locks) one step on or back (copy: to just after it, the original stays); + * the steps it goes to must be free, inside the pattern. Returns where it is now, or -1 */ +UI_SMALL static int32_t note_shift(track_t *t, uint32_t i, int32_t dir, int copy) +{ + uint32_t len = trk_len(t), n = note_len(t, i), j, to; + if (!step_on(&t->step[i])) + return -1; + to = copy ? i + n : dir > 0 ? i + 1u : i - 1u; + if ((!copy && dir < 0 && i == 0u) || to + n > len) + return -1; + for (j = 0; j < n; j++) + if ((to + j < i || to + j >= i + n) && !step_free(t, to + j)) + return -1; + fm1_irq_off(); + if (copy) { + for (j = 0; j < n; j++) + t->step[to + j] = t->step[i + j]; + } else if (dir > 0) { + for (j = n; j > 0; j--) + t->step[i + j] = t->step[i + j - 1u]; + step_clear(&t->step[i]); + } else { + for (j = 0; j < n; j++) + t->step[i - 1u + j] = t->step[i + j]; + step_clear(&t->step[i + n - 1u]); + } + t->micro[to] = t->micro[i]; + step_fill_set(t, to, step_fill(t, i)); + for (j = 0; j < NLOCK; j++) + if (t->lock[j].step == i) { + if (!copy) + t->lock[j].step = (uint8_t)to; + else { + int k = lock_find(t, to, t->lock[j].param, 1); + if (k >= 0) { + t->lock[k].step = (uint8_t)to; + t->lock[k].param = t->lock[j].param; + t->lock[k].val = t->lock[j].val; + } + } + } + if (!copy) { + t->micro[i] = 0; + step_fill_set(t, i, FC_NORM); + } + fm1_irq_on(); + return (int32_t)to; +} +/* (2.7.2) OCT+ on the NOTES page and the drum grid: a tap acts on release (its job until now), a hold (0.4 s) opens the + * sheet. Returns pressed without OCT+ while it is down; *ev: 1 tapped, 2 held. OCT- pressed meanwhile: OCT+ as before */ +static uint8_t octp; +static uint32_t octp_t; +UI_SMALL static uint32_t octp_filter(uint32_t pressed, uint32_t *ev) +{ + uint32_t ub = 1u << panel.btn[B_OCTUP]; + *ev = 0; + if (pressed & ub) { + octp = 1; + octp_t = fm1_ms; + pressed &= ~ub; + } + if (octp == 1u && (fm1_in.buttons & (1u << panel.btn[B_OCTDN]))) { + octp = 0; + return pressed | ub; /* (both: the octave back to 0, as before) */ + } + if (octp && !(fm1_in.buttons & ub)) { + *ev = octp == 1u; + octp = 0; + } else if (octp == 1u && fm1_ms - octp_t >= 400u) { + octp = 2; + *ev = 2; + } + return pressed; +} +/* the sheet over a screen (NOTES, the drum grid): six rows, the one KNOB 1 picks lit, values on the right */ +UI_SMALL static void sheet_draw(int32_t x, int32_t y, const char *const *lab, const char *const *val, uint32_t sel, + uint16_t acc) +{ + int32_t w = 124, k; + cv_rect(x - 1, y - 1, w + 2, 6 * 16 + 4, C_LINE); + cv_rect(x, y, w, 6 * 16 + 2, C_BLACK); + for (k = 0; k < 6; k++) { + int32_t ry = y + 2 + k * 16; + if ((uint32_t)k == sel) + cv_rect(x + 1, ry - 1, w - 2, 15, acc); + cv_text(x + 5, ry, &FONT_S, lab[k], (uint32_t)k == sel ? C_WHITE : C_HI); + if (val[k] && val[k][0]) + cv_text(x + w - 5 - text_w(&FONT_S, val[k]), ry, &FONT_S, val[k], (uint32_t)k == sel ? C_WHITE : C_AMB); + } } UI_SMALL static void note_name(char *b, uint32_t n) @@ -377,13 +547,38 @@ UI_SMALL static int param_kept(uint32_t i) /* preset pi of the engine the track asked for: the whole sound (not the pattern parameters) */ /* SLOOP 2.7: a sound loaded while the track's arpeggiator runs keeps it: its settings (MODE … ORDER, never written: the * audio ISR never sees them change) and the notes it holds (seq.c arp_keep_req: the panic of this track leaves them). - * With the arp OFF, a preset brings its own arp, as before */ + * With the arp OFF, or the arp the old sound brought (2.7.1), a preset brings its own arp, as before */ UI_SMALL static int arp_param(uint32_t i) { return i >= P_AMODE && i <= P_AORDER; } +/* 2.7.1: is the arp that runs the sound's own, as the sound brought it (8BIT ARP, a user preset with an arp)? Then the + * next sound replaces it with its own (most often OFF), as up to 2.6: only an arp you turned on or changed goes on. + * (2.7 kept any running arp: after 8BIT ARP, every sound arpeggiated.) The sound loaded: t->engine (not eng_req, + * already the new one when the ENGINE changes), t->preset, or user_of(t) */ +UI_SMALL static int arp_is_sounds(const track_t *t) +{ + int16_t a[8]; + uint32_t i, k = user_of(t); + if (k < UP_SLOTS) { + if (up_arp_of(k, a)) + return 0; + } else { + const engine_t *e = ENGINES[t->engine % NENGINES]; + const preset_t *pr; + if (t->user || !e->npresets) + return 0; + pr = &e->presets[t->preset % e->npresets]; + for (i = 0; i < 8u; i++) + a[i] = (int16_t)(i < 4u && pr->arp[i] ? pr->arp[i] - 1 : TP[P_AMODE + i].def); + } + for (i = 0; i < 8u; i++) + if (t->p[P_AMODE + i] != a[i]) + return 0; + return 1; +} UI_SMALL static void apply_preset_to(track_t *t, uint32_t pi) { const engine_t *e = ENGINES[t->eng_req % NENGINES]; uint32_t i; - int keep_arp = t->p[P_AMODE] != 0, kbd_hold = !t->p[P_AMODE] && t->p[P_AHOLD]; /* (2.7: KBD HOLD stays on) */ + int keep_arp = t->p[P_AMODE] != 0 && !arp_is_sounds(t), kbd_hold = !t->p[P_AMODE] && t->p[P_AHOLD]; /* (2.7: KBD HOLD stays on) */ if (is_drum(t)) return; if (keep_arp) @@ -708,13 +903,18 @@ UI_SMALL static int preset_go_to(track_t *t, uint32_t n) } /* MIDI Program Change (2.6, after Felucca 1.5.1, PR #179 by @renebohne): seq.c queues it per track (the track its * channel plays, GLO > MIDI); here, in the main loop (a flash read, a sound loaded): a synth track takes the n-th sound - * of the PRESETS list (0 the first factory sound, the user presets after the 153), the drum track kit n. A number past - * the end does nothing (no wrap) */ + * of the PRESETS list (0 the first factory sound, the user presets after the factory ones), the drum track kit n. A + * number past the end does nothing (no wrap). + * (2.7.2) a Program Change is only 7 bits (0..127), too few for the whole list (the factory sounds plus the user + * presets). Bank Select (CC 0) before it extends the reach: bank 0 the sounds 0..127, bank 1 the sounds 128..255 (the + * rest of the factory list, then the user presets), and PC_USER_BANK the user presets straight (PC n = user preset n). + * Bank 0 and no CC 0 are the old behaviour. The drum track ignores the bank (one GM kit). */ +#define PC_USER_BANK 8u UI_SMALL static void pc_poll(void) { uint32_t i; for (i = 0; i < NTRK; i++) { - uint32_t r = pc_req[i], n; + uint32_t r = pc_req[i], n, bank = pc_bank[i]; char b[12]; if (!r) continue; @@ -726,8 +926,13 @@ UI_SMALL static void pc_poll(void) trk[i].p[P_E0] = (int16_t)n; if (&trk[i] == TSEL) sync_reload = 1; - } else if (preset_go_to(&trk[i], n)) { - continue; + } else if (bank == PC_USER_BANK) { /* (2.7.2) user presets straight: PC n = user slot n (0..31) */ + if (!up_load_to(&trk[i], n)) /* (an empty slot or past the end: nothing) */ + continue; + } else { /* (2.7.2) linear: bank 0 the sounds 0..127, bank 1 128..255 */ + n = bank * 128u + (r - 1u); + if (preset_go_to(&trk[i], n)) + continue; } str_cpy(b, "T1 PROG ", sizeof b); b[1] = (char)('1' + i); diff --git a/firmware/src/ui_draw.c b/firmware/src/ui_draw.c index 138eefb..537a174 100644 --- a/firmware/src/ui_draw.c +++ b/firmware/src/ui_draw.c @@ -247,50 +247,108 @@ UI_SMALL static void graph_steps(const track_t *t, uint16_t c) } } /* STEP page: the cursor's 16-step bank as a little piano roll */ +/* (2.7.2) SEQ > NOTES: the pattern as a piano roll (cv_oy 0, the whole strip). Each note a bar as long as its + * step and TIEs, its FORCE as its fill (GHOST dark, SOFT hollow, NORM / HARD full, ACC a white cap), a SLIDE's line to + * the next; the note under edit outlined in white, its name over it; the C rows named on the left, the beats ruled; + * the playhead a line. The rows follow the note under edit when the pattern spans more than 18 semitones */ UI_SMALL static void graph_roll(const track_t *t, uint16_t c) { - uint32_t i, j, len = (uint32_t)t->p[P_SLEN], base = ui.bank * 16u; - int32_t lo = 127, hi = 0, prev_y = -1; + uint32_t len = trk_len(t), nv = NV_ZOOM[clamp(1 + (int8_t)ui.zoom, 0, 3)], v0, i, j; + int32_t lo = 127, hi = 0, x0 = 22, w = 240 - 22 - 2, top = 14, bot = H_GRAPH - 4, rh, sel_note = last_note, cx; + const step_t *cs = &t->step[ui.cursor]; + char b[12]; + if (nv > len) + nv = len; + v0 = ui.cursor / nv * nv; for (i = 0; i < len; i++) for (j = 0; j < t->step[i].n; j++) { - if (t->step[i].note[j] < lo) - lo = t->step[i].note[j]; - if (t->step[i].note[j] > hi) - hi = t->step[i].note[j]; + if (t->step[i].note[j] < lo) lo = t->step[i].note[j]; + if (t->step[i].note[j] > hi) hi = t->step[i].note[j]; } - if (lo > hi) { - lo = 48; - hi = 72; + if (step_on(cs)) + sel_note = cs->note[ui.note_k % cs->n]; + if (lo > hi) + lo = hi = sel_note; + if (hi - lo < 11) { /* (an octave at least: rows of a sane height) */ + lo = clamp((lo + hi) / 2 - 6, 0, 115); + hi = lo + 11; } - if (hi - lo < 12) - hi = lo + 12; - for (i = 0; i < 16u; i++) { - uint32_t si = base + i; - const step_t *st = &t->step[si]; - int32_t x = (int32_t)i * 15, yb = 86; - if (si >= len) - break; - if (si == ui.cursor) - cv_rect(x + 5, 92, 3, 3, C_WHITE); - if (song.playing && si == t->seq_idx) - cv_rect(x + 1, 97, 12, 1, C_WHITE); - if (st->time == ST_TIE && prev_y >= 0) { - cv_rect(x, prev_y, 14, 1, C_GRAY); - continue; + if (hi - lo > 17) { /* (a wide pattern: 18 rows around the note under edit) */ + lo = clamp(sel_note - 8, lo, hi - 17); + hi = lo + 17; + } + lo = clamp(lo - 1, 0, 127), hi = clamp(hi + 1, 0, 127); + rh = (bot - top) / (hi - lo + 1); + fmt_int(b, (int32_t)v0 + 1); + str_cpy(b + str_len(b), "-", 2); + fmt_int(b + str_len(b), (int32_t)(v0 + nv > len ? len : v0 + nv)); + cv_text(2, 0, &FONT_S, b, C_GRAY); + str_cpy(b, "ZOOM ", 12); + fmt_int(b + 5, (int32_t)nv); + cv_text(238 - text_w(&FONT_S, b), 0, &FONT_S, b, C_DIM); + for (i = (uint32_t)lo; i <= (uint32_t)hi; i++) { /* rows: the black keys' bands, the C's ruled and named */ + int32_t y = bot - ((int32_t)i - lo + 1) * rh; + uint32_t pc = i % 12u; + if ((0x54Au >> pc) & 1u) + cv_rect(x0, y, w, rh, TE_G1); + if (!pc) { + note_name(b, i); + cv_text(0, y + rh / 2 - 6, &FONT_S, b, C_DIM); + cv_rect(x0, y + rh - 1, w, 1, C_GRAY); } - if (!step_on(st)) { - cv_rect(x + 6, yb, 2, 1, C_DIM); - prev_y = -1; + } + for (i = 0; i <= nv; i++) /* the beats (4 steps), a tick on each step */ + if (i % 4u == 0u) + cv_rect(x0 + (int32_t)i * w / (int32_t)nv, top, 1, bot - top, i % 16u ? C_DIM : C_GRAY); + else if (nv <= 32u) + cv_rect(x0 + (int32_t)i * w / (int32_t)nv, bot + 1, 1, 2, C_DIM); + for (i = 0; i < len; i++) { /* the notes (one starting before the view: its part in it) */ + const step_t *st = &t->step[i]; + uint32_t n = note_len(t, i), f; + int32_t xa, xb, y; + if (!step_on(st) || i + n <= v0 || i >= v0 + nv) continue; - } + xa = x0 + ((int32_t)i - (int32_t)v0) * w / (int32_t)nv + 1; + xb = x0 + ((int32_t)(i + n) - (int32_t)v0) * w / (int32_t)nv - 1; + xa = xa < x0 ? x0 : xa; + xb = xb > x0 + w ? x0 + w : xb; for (j = 0; j < st->n; j++) { - int32_t y = 80 - (st->note[j] - lo) * 74 / (hi - lo); - cv_rect(x + 2, y, 10, 1, (st->flags & SF_ACCENT) ? C_WHITE : c); - if (j == 0) - prev_y = y; + if (st->note[j] < lo || st->note[j] > hi) + continue; + y = bot - ((int32_t)st->note[j] - lo + 1) * rh + 1; + f = note_force(st, j); + cv_rect(xa, y, xb - xa, rh - 1, f ? c : TE_DIM[song.sel & 3u]); + if (f == 1u && rh > 4) /* SOFT: hollow */ + cv_rect(xa + 1, y + 1, xb - xa - 2, rh - 3, C_BLACK); + if (f == 4u) /* ACC: a white cap */ + cv_rect(xa, y, xb - xa, 2, C_WHITE); + if ((st->flags & SF_SLIDE) && j == 0u) + cv_rect(xb, y + rh / 2 - 1, 4, 2, c); + if (i == ui.cursor && j == ui.note_k % st->n) { /* the note under edit */ + cv_rect(xa - 2, y - 2, xb - xa + 4, 1, C_WHITE), cv_rect(xa - 2, y + rh - 1, xb - xa + 4, 1, C_WHITE); + cv_rect(xa - 2, y - 2, 1, rh + 2, C_WHITE), cv_rect(xb + 1, y - 2, 1, rh + 2, C_WHITE); + note_name(b, st->note[j]); + cv_text(xa, y - 15 < top ? y + rh + 1 : y - 15, &FONT_S, b, C_WHITE); + } } - if (st->flags & SF_SLIDE) - cv_line(x + 11, prev_y, x + 17, prev_y + 2, c); + } + cx = x0 + ((int32_t)ui.cursor - (int32_t)v0) * w / (int32_t)nv; + if (!step_on(cs) && sel_note >= lo && sel_note <= hi) { /* an empty step: a frame where a note would go */ + int32_t y = bot - (sel_note - lo + 1) * rh + 1, xw = w / (int32_t)nv - 2; + cv_rect(cx + 1, y - 1, xw, 1, C_WHITE), cv_rect(cx + 1, y + rh - 1, xw, 1, C_WHITE); + cv_rect(cx + 1, y - 1, 1, rh, C_WHITE), cv_rect(cx + xw, y - 1, 1, rh, C_WHITE); + } + if (song.playing && t->seq_idx >= v0 && t->seq_idx < v0 + nv) { /* the playhead */ + int32_t x = x0 + ((int32_t)t->seq_idx - (int32_t)v0) * w / (int32_t)nv; + cv_rect(x, top, 1, bot - top, C_HI); + cv_rect(x - 2, top, 5, 2, C_HI); + } + if (ui.sheet) { /* OCT+ held: the note's sheet */ + char nu[8]; + const char *val[6] = {cs->flags & SF_SLIDE ? "ON" : "OFF", nu, FILL_N[step_fill(t, ui.cursor) % 3u], "", "", ""}; + fmt_int(nu, t->micro[ui.cursor]); + if (t->micro[ui.cursor] > 0) { nu[0] = '+'; fmt_int(nu + 1, t->micro[ui.cursor]); } + sheet_draw(112, 6, SHEET_N, val, ui.sheet - 1u, TE_DIM[song.sel & 3u]); } } UI_SMALL static void graph_scale(const track_t *t, uint16_t c) @@ -390,8 +448,9 @@ UI_SMALL static uint32_t graph_signature(void) h ^= (uint32_t)project_used(i) << (20u + i); if (pg->graph == GR_STEPS || pg->graph == GR_ROLL) { uint32_t ph = song.playing ? t->seq_idx : 0xFFFFu; - if (pg->graph == GR_ROLL && ph / 16u != ui.bank) - ph = 0xFFFFu; /* the roll shows the cursor's bank only */ + if (pg->graph == GR_ROLL) /* (2.7.2 NOTES: the note under edit, the zoom, the sheet) */ + h ^= ui.note_k * 104729u + ui.zoom * 7u + ui.sheet * 977u + (uint32_t)t->micro[ui.cursor] * 31337u + + step_fill(t, ui.cursor) * 3u + last_note * 65537u; h ^= steps_hash(t) + ph * 31u + ui.cursor * 7919u; } return h; @@ -711,6 +770,7 @@ UI_SMALL static void draw_graph(void) graph_steps(t, c); break; case GR_ROLL: + cv_oy = 0; graph_roll(t, c); break; case GR_SCALE: @@ -743,9 +803,9 @@ UI_SMALL static void draw_graph(void) } } top = !ui.home && !drum_note && (pg->graph == GR_BROWSE || pg->graph == GR_SLOTS || pg->graph == GR_USER || - big_page(pg)); /* these draw from the top */ + pg->graph == GR_ROLL || big_page(pg)); /* these draw from the top */ cv_oy = 0; - if (ui.hot_t && settings.zoom && !(top && big_page(pg) && !drum_note)) { /* (the big values show it already) */ /* focus (menu ZOOM): the touched value, large and white */ + if (ui.hot_t && settings.zoom && !(top && (big_page(pg) || pg->graph == GR_ROLL) && !drum_note)) { /* (the big values show it already) */ /* focus (menu ZOOM): the touched value, large and white */ int32_t x; top = 1; cv_rect(0, 0, 150, 50, C_BLACK); @@ -913,39 +973,33 @@ UI_SMALL static void draw_columns(void) draw_column(3, "SAVE", "--", "", C_HI, -1, ICON_AUTO); return; } - if (cur_page()->scope == SC_STEP) { - static const char *const TIME_N[3] = {"NOTE", "TIE", "REST"}; + if (cur_page()->scope == SC_STEP) { /* (2.7.2) NOTES: NOTE PITCH LEN FORCE of the note under edit */ const step_t *st = &TSEL->step[ui.cursor]; - char u[8]; - if (st->n) { - note_name(val, st->note[0]); - u[0] = 0; - if (st->n > 1) { - str_cpy(u, "+", 8); - fmt_int(u + 1, st->n - 1); + char sn[8], sl[8], u[8], ln[8]; + int on = step_on(st); + uint32_t k = on ? ui.note_k % st->n : 0u; + fmt_int(sn, (int32_t)ui.cursor + 1); + str_cpy(sl, "/", 8); + fmt_int(sl + 1, TSEL->p[P_SLEN]); + draw_column(0, "NOTE", sn, sl, VAL(0u), -1, ICON_AUTO); + u[0] = 0; + if (on) { + note_name(val, st->note[k]); + if (st->n > 1u) { /* a chord: which of its notes */ + fmt_int(u, (int32_t)k + 1); + str_cpy(u + str_len(u), "/", 2); + fmt_int(u + str_len(u), st->n); } } else { str_cpy(val, "--", 12); - u[0] = 0; - } - { - static const char *const FLAG_N[4] = {"-", "ACC", "SLD", "A+S"}; - char sn[8], sl[8]; - fmt_int(sn, (int32_t)ui.cursor + 1); - str_cpy(sl, "/", 8); - fmt_int(sl + 1, TSEL->p[P_SLEN]); - draw_column(0, "STEP", sn, sl, VAL(0u), -1, ICON_AUTO); - draw_column(1, "NOTE", val, u, step_on(st) ? VAL(1u) : C_DIM, -1, ICON_AUTO); - if (step_on(st)) { /* a note: its LEN (2.6), steps with the TIEs after it */ - char ln[8]; - fmt_int(ln, (int32_t)note_len(TSEL, ui.cursor)); - draw_column(2, "LEN", ln, "STEP", VAL(2u), -1, ICON_AUTO); - } else { - draw_column(2, "TIME", TIME_N[st->time % 3u], "", VAL(2u), -1, ICON_AUTO); - } - draw_column(3, "FLAG", FLAG_N[(st->flags & SF_ACCENT ? 1u : 0u) | (st->flags & SF_SLIDE ? 2u : 0u)], "", - VAL(3u), -1, ICON_AUTO); } + draw_column(1, "PITCH", val, u, on ? VAL(1u) : C_DIM, -1, ICON_AUTO); + if (on) + fmt_int(ln, (int32_t)note_len(TSEL, ui.cursor)); + else + str_cpy(ln, "--", 8); + draw_column(2, "LEN", ln, on ? "STEP" : "", on ? VAL(2u) : C_DIM, -1, ICON_AUTO); + draw_column(3, "FORCE", on ? FORCE_N[note_force(st, k)] : "--", "", on ? VAL(3u) : C_DIM, -1, ICON_AUTO); return; } for (c = 0; c < 4u; c++) { diff --git a/firmware/src/ui_input.c b/firmware/src/ui_input.c index 1335bb6..36a1888 100644 --- a/firmware/src/ui_input.c +++ b/firmware/src/ui_input.c @@ -120,6 +120,8 @@ UI_SMALL static uint32_t keys_lit(void) if (on) m |= 1u << key_of_white(i); } + if (is_drum(t)) + m |= 1u << drum_black_key(pen_lane); /* (2.7.1) the black key of the sound the steps are for */ return m | fm1_in.notes; } case LY_SCALE: /* the keys in the scale; the root blinks */ @@ -157,7 +159,7 @@ UI_SMALL static uint32_t keys_lit(void) if (on) m |= 1u << key_of_white(i); } - return m | fm1_in.notes; + return m | fm1_in.notes | 1u << drum_black_key(drum_lane); /* (2.7.1) its sound's black key */ } m = fm1_in.notes; if (is_drum(t) || lights_notes) /* the drum track: each hit lights its key; NOTES: the synths too */ @@ -318,54 +320,140 @@ UI_SMALL static void tracks_edit(uint32_t slot, int32_t steps) ml_knob(t, vp == &t->p[P_LEVEL] ? P_LEVEL : P_PAN); /* MIDI LEARN: LEVEL, PAN (2.6) */ } +/* (2.7.2) NOTES: one undo per note edited (its pitch, length, force: EDIT + OCT- brings them back) */ +UI_SMALL static void note_mark(void) +{ + static uint32_t sess, at = 0xFFFFu; + uint32_t here = ui.cursor | (uint32_t)song.sel << 8; + if (here != at || !undo.valid || undo.undone || undo.sess != sess) { + sess = (undo_sess += 4u) | 3u; + at = here; + } + undo_mark(TSEL, sess); +} +UI_SMALL static int on_notes_page(void) +{ + return !ui.home && song.seq_mode && cur_page()->scope == SC_STEP && !is_drum(TSEL); +} +/* the note's sheet (OCT+ held): KNOB 1 the row, KNOB 2 its value (MOVE: a step a detent); OCT+ acts (SLIDE on / off, + * COPY: just after it, then MOVE moves the copy; DELETE), OCT- closes */ +UI_SMALL static void note_sheet_knob(uint32_t slot, int32_t steps) +{ + track_t *t = TSEL; + step_t *st = &t->step[ui.cursor]; + uint32_t row = ui.sheet - 1u; + if (slot == 0u) { + ui.sheet = (uint8_t)(1 + clamp((int32_t)row + steps, 0, 5)); + return; + } + if (slot != 1u) + return; + note_mark(); + switch (row) { + case 0: + st->flags = (uint8_t)(steps > 0 ? st->flags | SF_SLIDE : st->flags & ~SF_SLIDE); + break; + case 1: + t->micro[ui.cursor] = (int8_t)clamp(t->micro[ui.cursor] + steps, MICRO_MIN, MICRO_MAX); + break; + case 2: + step_fill_set(t, ui.cursor, (uint32_t)clamp((int32_t)step_fill(t, ui.cursor) % 3 + (steps > 0 ? 1 : -1), 0, 2)); + break; + case 3: { + int32_t n = steps; + while (n) { + int32_t to = note_shift(t, ui.cursor, n, 0), k = ui.note_k; + if (to < 0) { + ui_message(step_on(st) ? "NO ROOM" : "NO NOTE"); + break; + } + cursor_set(to); + ui.note_k = (uint8_t)k; + n += n > 0 ? -1 : 1; + } + break; + } + default: + break; + } + sync_reload = 1; +} +UI_SMALL static void note_sheet_do(void) /* OCT+ tapped in the sheet */ +{ + track_t *t = TSEL; + uint32_t row = ui.sheet - 1u; + note_mark(); + if (row == 0u) { + t->step[ui.cursor].flags ^= SF_SLIDE; + } else if (row == 4u) { + int32_t to = note_shift(t, ui.cursor, 1, 1), k = ui.note_k; + if (to < 0) { + ui_message(step_on(&t->step[ui.cursor]) ? "NO ROOM" : "NO NOTE"); + return; + } + cursor_set(to); + ui.note_k = (uint8_t)k; + ui.sheet = 4; /* (MOVE: KNOB 2 moves the copy) */ + ui_message("COPIED"); + } else if (row == 5u) { + note_del(t, ui.cursor, ui.note_k); + cursor_fix(); + ui.sheet = 0; + ui_message("NOTE DELETED"); + } + sync_reload = 1; +} +/* the NOTES page's knobs (SEQ > NOTES, synth tracks; the drum track has its grid) */ UI_SMALL static void step_edit(uint32_t slot, int32_t steps) { - step_t *st = &TSEL->step[ui.cursor]; - uint32_t i; - if (is_drum(TSEL)) - return; /* (the drum track: its grid) */ + track_t *t = TSEL; + step_t *st = &t->step[ui.cursor]; + uint32_t k = ui.note_k; + if (is_drum(t)) + return; + if (ui.sheet) { + note_sheet_knob(slot, steps); + return; + } switch (slot) { - case 0: /* STEP: the cursor */ - cursor_set(ui.cursor + steps); + case 0: /* NOTE: the notes, a chord's one by one, and the empty steps */ + for (; steps > 0; steps--) + note_walk(1); + for (; steps < 0; steps++) + note_walk(-1); break; - case 1: /* NOTE: transpose the step */ - if (!st->n) { + case 1: /* PITCH: the note's; an empty step gets your last note */ + note_mark(); + if (!step_on(st)) { + memset(st, 0, sizeof *st); st->note[0] = last_note; st->n = 1; st->time = ST_NOTE; + ui.note_k = 0; break; } - for (i = 0; i < st->n; i++) - st->note[i] = (uint8_t)clamp(st->note[i] + steps, 1, 127); - st->time = ST_NOTE; - st->flags &= (uint8_t)~SF_CONT_ALL; /* (2.7: new pitches start here, not held over from before) */ - last_note = st->note[0]; + st->note[k] = (uint8_t)clamp(st->note[k] + steps, 1, 127); + st->flags &= (uint8_t)~SF_CONT(k); /* (2.7: a new pitch starts here, not held over from before) */ + last_note = st->note[k]; break; - case 2: /* TIME; on a note its LEN (2.6: ui.c note_set_len) */ + case 2: /* LEN: the note and the TIEs after it (2.6: ui.c note_set_len) */ if (step_on(st)) { - static uint32_t len_sess, len_cur = 0xFFFFu; /* the turns of LEN on one step: one undo */ - uint32_t was = note_len(TSEL, ui.cursor), n; - if (len_cur != ui.cursor || !undo.valid || undo.undone || undo.sess != len_sess) { - len_sess = (undo_sess += 4u) | 3u; - len_cur = ui.cursor; - } - undo_mark(TSEL, len_sess); /* (EDIT + OCT- brings the steps back) */ + uint32_t was = note_len(t, ui.cursor), n; + note_mark(); fm1_irq_off(); - n = note_set_len(TSEL, ui.cursor, (uint32_t)clamp((int32_t)was + steps, 1, NSTEP)); + n = note_set_len(t, ui.cursor, (uint32_t)clamp((int32_t)was + steps, 1, NSTEP)); fm1_irq_on(); if (steps > 0 && n == was) - ui_message(ui.cursor + n < (uint32_t)clamp(TSEL->p[P_SLEN], 1, NSTEP) ? "NOTE AHEAD" : "END OF PATTERN"); - break; + ui_message(ui.cursor + n < (uint32_t)clamp(t->p[P_SLEN], 1, NSTEP) ? "NOTE AHEAD" : "END OF PATTERN"); } - st->time = (uint8_t)clamp((int32_t)st->time + (steps > 0 ? 1 : -1), ST_NOTE, ST_REST); break; - default: { /* FLAG: - / ACC / SLD / A+S */ - uint32_t f = (st->flags & SF_ACCENT ? 1u : 0u) | (st->flags & SF_SLIDE ? 2u : 0u); - f = (uint32_t)clamp((int32_t)f + (steps > 0 ? 1 : -1), 0, 3); - st->flags = (uint8_t)((st->flags & ~(SF_ACCENT | SF_SLIDE)) | (f & 1u ? SF_ACCENT : 0u) | (f & 2u ? SF_SLIDE : 0u)); + default: /* FORCE: GHOST SOFT NORM HARD, ACC (the step's accent) */ + if (step_on(st)) { + note_mark(); + note_force_set(st, k, (uint32_t)clamp((int32_t)note_force(st, k) + (steps > 0 ? 1 : -1), 0, 4)); + } break; } - } } /* a new project: every track empty, the default sounds, 90 BPM (TOOLS > NEW) */ @@ -393,7 +481,7 @@ UI_SMALL static void project_new(void) drum_mute = 0; /* (2.6: the live mutes) */ for (i = 0; i < G_COUNT; i++) if (i != G_SLOT && i != G_DRCH && i != G_SYNC && i != G_MIDI && i != G_ROUTE && (i < G_CH1 || i > G_CHOTH) && - i != G_BEND && i != G_FXCH && i != G_DRMAP && i != G_RMCH && i != G_CLKOUT) /* (the + i != G_BEND && i != G_FXCH && i != G_DRMAP && i != G_RMCH && i != G_CLKOUT && i != G_FXFADE) /* (the * FM-1's settings: GLO > MIDI 2.6) */ song.g[i] = GP[i].def; song.solo = 0; @@ -586,7 +674,7 @@ UI_SMALL static void midi_entry(void) /* (top of ui undo_mark(t, (undo_sess += 4u) | 3u); st->n = 0; st->lvl = st->rat = 0; - st->flags &= (uint8_t)~SF_CONT_ALL; /* (2.7: step entry: the step's own notes only) */ + st->flags &= (uint8_t)~(SF_CONT_ALL | SF_LEG); /* (2.7: step entry: the step's own notes only) */ st->time = ST_NOTE; } if (t->p[P_VOICE]) { @@ -623,7 +711,7 @@ UI_SMALL static void seq_entry(uint32_t pressed) undo_mark(t, (undo_sess += 4u) | 3u); st->n = 0; st->lvl = st->rat = 0; - st->flags &= (uint8_t)~SF_CONT_ALL; /* (2.7: step entry: the step's own notes only) */ + st->flags &= (uint8_t)~(SF_CONT_ALL | SF_LEG); /* (2.7: step entry: the step's own notes only) */ st->time = ST_NOTE; } if (t->p[P_CHORD] && !t->p[P_VOICE]) { /* chord mode (2.4.1): the chord as it sounded (CHORD+, @@ -646,8 +734,13 @@ UI_SMALL static void seq_entry(uint32_t pressed) } last_note = (uint8_t)note; } - if (ui.entry_open && !fm1_in.notes && !midi_held()) - cursor_set(ui.cursor + 1); + if (ui.entry_open && !fm1_in.notes && !midi_held()) { + if (step_adv_off) + ui.entry_open = 0; /* (2.7.1) STEP ADVANCE OFF: the cursor stays, the next keys + * write the step again (a chord tried again) */ + else + cursor_set(ui.cursor + 1); + } } /* HOME: tap on release, hold 0.7 s fires once. t0 = press time | 1, @@ -684,15 +777,20 @@ UI_SMALL static void layer_tap(uint32_t layer) ui.force = 1; break; } - if (!ui.home && cur_page()->scope == SC_TRK && is_drum(TSEL)) { - studio_open(SC_DRUM); + if (is_drum(TSEL) && (layer == LY_STEP || (!ui.home && cur_page()->scope == SC_TRK))) { + studio_open(SC_DRUM); /* (2.7.1: SEQ from any page, ARP's too: up to 2.7 there it + * opened the synths' STEP page, not the drum grid) */ break; } - if (layer == LY_ERASE && song.seq_mode && cur_page()->scope == SC_STEP && !is_drum(TSEL)) { - undo_mark(TSEL, (undo_sess += 4u) | 3u); /* STEP page: EDIT clears the step */ - step_clear(&TSEL->step[ui.cursor]); - cursor_set(ui.cursor + 1); - ui_message("STEP CLEARED"); + if (layer == LY_ERASE && on_notes_page()) { /* NOTES (2.7.2): EDIT deletes the note (a chord's others stay) */ + undo_mark(TSEL, (undo_sess += 4u) | 3u); + if (!step_on(&TSEL->step[ui.cursor])) + ui_message("NO NOTE"); + else { + note_del(TSEL, ui.cursor, ui.note_k); + cursor_fix(); + ui_message("NOTE DELETED"); + } break; } open_family(layer == LY_STEP ? FAM_SEQ : FAM_EDIT); @@ -1027,6 +1125,8 @@ UI_SMALL static void ui_input(void) menu_input(pressed); return; } + if (!on_notes_page() && !on_drum_page()) + ui.sheet = 0; /* (2.7.2: the sheet is the NOTES page's and the grid's) */ layered = layers_input(notes, &pressed, home); if (home_eat && !((fm1_in.buttons >> panel.btn[B_HOME]) & 1u)) { /* (the HOME that unlocked: let go) */ if (home == BT_TAP) @@ -1083,6 +1183,22 @@ UI_SMALL static void ui_input(void) } } cursor_fix(); /* LEN may have changed (knob, editor, load) */ + if (on_notes_page()) { /* (2.7.2) OCT+ held: the note's sheet; tapped: as before */ + uint32_t ev, ob = 1u << panel.btn[B_OCTDN]; + pressed = octp_filter(pressed, &ev); + if (ev == 2u && !ui.sheet) + ui.sheet = 1; + else if (ev == 1u && ui.sheet) + note_sheet_do(); + else if (ev == 1u) + pressed |= 1u << panel.btn[B_OCTUP]; + if (ui.sheet && (pressed & ob)) { + ui.sheet = 0; + pressed &= ~ob; + } + if (ev) + ui.force = 1; + } for (id = 0; id < 14u; id++) { if (!((pressed >> id) & 1u)) continue; @@ -1119,9 +1235,13 @@ UI_SMALL static void ui_input(void) break; } } - if (song.seq_mode && cur_page()->scope == SC_STEP) + if (song.seq_mode && cur_page()->scope == SC_STEP && !ui.sheet) seq_entry(notes); /* (and the MIDI keyboard's: midi_entry) */ + if (on_notes_page() && (s = panel_enc(EN_PRESET)) != 0) { /* (2.7.2) NOTES: PRESETS zooms, 8 .. 64 steps */ + ui.zoom = (uint8_t)(clamp((int32_t)(int8_t)ui.zoom + (s > 0 ? 1 : -1), -1, 2)); + ui.force = 1; + } if ((s = panel_enc(EN_PRESET)) != 0 && (ui.home || cur_page()->graph == GR_BROWSE || cur_fam() == FAM_TRK)) { /* PRESETS browses the selected part's presets (all engines, then user presets) on HOME, the PRESETS * page and TRACKS only (the drum track: its kits); elsewhere a stray turn would throw away the sound diff --git a/firmware/src/ui_layers.c b/firmware/src/ui_layers.c index 758c600..7117b20 100644 --- a/firmware/src/ui_layers.c +++ b/firmware/src/ui_layers.c @@ -6,7 +6,8 @@ * EDIT erase that sound / note (seq.c) knobs: SHIFT LENGTH x2 / half TRANSPOSE OCT- undo OCT+ redo * ARP note repeat (seq.c roll) knobs: RATE * SEQ steps 1..16 of the page knobs: SOUND / NOTE DIV SWING LENGTH; a step key held: - * (black keys 1..4: pages) SOUND / NOTE LEVEL RATCHET NUDGE, PRESETS the value of a + * (black keys 1..4 or OCT- / OCT+: pages; SOUND / NOTE LEVEL RATCHET NUDGE, PRESETS the value of a + * 2.7.1, the drum track: the black keys pick the sound, ui_studio.c drum_black_pick, OCT the pages) * parameter lock, ALGORITHM its parameter (the sound parameter * last touched first); OCT+ cycles the step's fill condition * (normal, fill only, no fill), OCT- clears its nudge, locks and @@ -174,7 +175,7 @@ UI_SMALL static void pen_lane_move(int32_t s) { uint8_t l = (uint8_t)clamp(pen_lane + s, 0, DRUM_LANES - 1); if (l != pen_lane) - audition_lane(l); + drum_hear(l); /* (2.7.1: menu DRUM PREVIEW ON only) */ pen_lane = l; } /* KNOB 1..4 with step keys held: their sound / note (drums: the sound's lane; synth: every note), level, @@ -340,7 +341,13 @@ UI_SMALL static void layer_key(uint32_t layer, uint32_t k, uint32_t down) } switch (layer) { case LY_STEP: - if (w < 0) { /* the first four black keys: pages 1..4 */ + if (w < 0 && is_drum(TSEL)) { /* (2.7.1) the drum track: a black key picks the sound, unheard */ + int32_t b = drum_black_of(k); + if (b >= 0) + drum_black_pick((uint32_t)b); + return; + } + if (w < 0) { /* the first four black keys: pages 1..4 (OCT- / OCT+ too) */ static const int8_t PG[12] = {-1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, -1}; if (k < 12u && PG[k] >= 0 && (uint32_t)PG[k] * 16u < trk_len(TSEL)) ui.step_page = (uint8_t)PG[k]; @@ -560,6 +567,11 @@ UI_SMALL static void layer_knobs(uint32_t layer) break; } } + if (layer == LY_FX && (s = panel_enc(EN_SELECT)) != 0) { /* (2.7.2) SELECT: the punch-in FX fade (GLO > ... ), not the + * tempo while FX is held; shown top right (layer_screen_draw) */ + song.g[G_FXFADE] = (int16_t)clamp(song.g[G_FXFADE] + s, 0, 15); + ui.layer_used = 1; + } } /* --------------------------------------------------------- drawing --- */ @@ -648,10 +660,12 @@ UI_SMALL static void punch_tiles_draw(const tile_t *tl, uint32_t *cache) } } +static char hdr_r[12] = ""; /* (2.7.2) a value shown top right of a layer's header (FX: the fade) */ UI_SMALL static void layer_title(const char *name, const char *sub, uint16_t col, uint32_t *cache) { uint32_t locked = ly_lock != LY_PLAY; - uint32_t sig = studio_hash(studio_hash(col, name), sub) + (ui.msg_t ? studio_hash(3u, ui.msg) : 0u) + locked * 7919u; + uint32_t sig = studio_hash(studio_hash(col, name), sub) + (ui.msg_t ? studio_hash(3u, ui.msg) : 0u) + locked * 7919u + + (locked ? 0u : studio_hash(104729u, hdr_r)); if (!ui.force && sig == *cache) return; *cache = sig; @@ -662,6 +676,8 @@ UI_SMALL static void layer_title(const char *name, const char *sub, uint16_t col int32_t w = (int32_t)text_w(&FONT_S, "LOCK") + 8; cv_rect(236 - w, 4, w, 15, C_WHITE); cv_text(240 - w, 4, &FONT_S, "LOCK", C_BLACK); + } else if (hdr_r[0]) { /* (2.7.2) a right-aligned readout (FX: the fade), like a knob's */ + cv_text(236 - text_w(&FONT_S, hdr_r), 4, &FONT_S, hdr_r, TE_G3); } cv_rect(0, 38, 240, 1, TE_G1); cv_blit(0, 0); @@ -693,6 +709,7 @@ UI_SMALL static void layer_screen_draw(void) } for (i = 0; i < 4u; i++) v[i][0] = 0; + hdr_r[0] = 0; /* (2.7.2) no header readout unless a layer sets one (FX: the fade) */ memset(tl, 0, sizeof tl); for (i = 0; i < 16u; i++) { tl[i].bg = TE_G1; @@ -718,6 +735,8 @@ UI_SMALL static void layer_screen_draw(void) tl[i].top = on || black ? 0 : TE_DIM[i / 4u]; } lab[0] = "filter", lab[1] = "dust", lab[2] = "duck", lab[3] = "trk flt"; + str_cpy(hdr_r, "fade ", sizeof hdr_r); /* (2.7.2) SELECT sets the fade; shown top right */ + fmt_int(hdr_r + 5, song.g[G_FXFADE]); { const char *u; param_format(&GP[G_FILT], song.g[G_FILT], v[0], &u); @@ -831,6 +850,10 @@ UI_SMALL static void layer_screen_draw(void) p[2] = (char)('0' + (len + 15u) / 16u); str_cpy(sub, "page ", sizeof sub); str_cpy(sub + 5, p, 4); + if (is_drum(t)) + str_cpy(sub + 8, " oct: page", sizeof sub - 8u); /* (2.7.1: the black keys are the sounds) */ + } else if (is_drum(t)) { + str_cpy(sub, "black keys: sound", sizeof sub); } lab[0] = is_drum(t) ? "sound" : "note"; if (is_drum(t)) diff --git a/firmware/src/ui_menu.c b/firmware/src/ui_menu.c index a0d96bc..ff8b1e1 100644 --- a/firmware/src/ui_menu.c +++ b/firmware/src/ui_menu.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */ /* SLOOP menu (HOME held), in sections as the pages are (2.4): SCREEN (COLOR, ZOOM, KNOB ACCEL (2.7)), LIGHTS (LIGHTS, KEYS, NOTES), - * AUDIO (LOWCUT, USB AUDIO, USB SERIAL (FELUCCA_CDC builds only), USB RATE (2.7 beta)), SYSTEM (2ND CORE (dualcore), HARDWARE CALIBRATION, LEARN CLEAR (2.6), ABOUT). + * AUDIO (LOWCUT, USB AUDIO, USB SERIAL (FELUCCA_CDC builds only), USB RATE (2.7 beta)), SEQ (2.7.1: STEP ADVANCE, DRUM PREVIEW), SYSTEM (2ND CORE (dualcore), HARDWARE CALIBRATION, LEARN CLEAR (2.6), ABOUT). * SELECT goes to the section before / after (stopping at the ends), KNOB 1..4 set the section's settings in order (the knob's colour marks * its row), PRESETS moves the cursor; OCT+ steps the cursor's setting round or opens it (CALIBRATION, ABOUT), * OCT- closes (from ABOUT: back to the section). */ @@ -11,15 +11,15 @@ enum { MI_COLOR, MI_ZOOM, MI_ACCEL, MI_LIGHTS, MI_KEYS, MI_NOTES, MI_LOWCUT, MI_ #if FELUCCA_CDC MI_SERIAL, #endif - MI_RATE, MI_CPU1, MI_PANEL, MI_LCLEAR, MI_ABOUT, MI_COUNT }; + MI_RATE, MI_FRESO, MI_ADV, MI_DPREV, MI_CPU1, MI_PANEL, MI_LCLEAR, MI_ABOUT, MI_COUNT }; static const char *const MI_NAME[MI_COUNT] = {"COLOR", "ZOOM", "KNOB ACCEL", "LIGHTS", "KEYS", "NOTES", "SPEAKER LOWCUT", "USB AUDIO", #if FELUCCA_CDC "USB SERIAL", #endif - "USB RATE", "2ND CORE", "HARDWARE CALIBRATION", "MIDI LEARN CLEAR", "ABOUT"}; -enum { MS_SCREEN, MS_LIGHTS, MS_AUDIO, MS_SYSTEM, MS_COUNT }; -static const char *const MS_NAME[MS_COUNT] = {"SCREEN", "LIGHTS", "AUDIO", "SYSTEM"}; /* (AUDIO: and USB) */ -static const uint8_t MS_FIRST[MS_COUNT + 1] = {MI_COLOR, MI_LIGHTS, MI_LOWCUT, MI_CPU1, MI_COUNT}; /* rows of each */ + "USB RATE", "FILTER RESO", "STEP ADVANCE", "DRUM PREVIEW", "2ND CORE", "HARDWARE CALIBRATION", "MIDI LEARN CLEAR", "ABOUT"}; +enum { MS_SCREEN, MS_LIGHTS, MS_AUDIO, MS_SEQ, MS_SYSTEM, MS_COUNT }; /* (2.7.1: SEQ) */ +static const char *const MS_NAME[MS_COUNT] = {"SCREEN", "LIGHTS", "AUDIO", "SEQ", "SYSTEM"}; /* (AUDIO: and USB) */ +static const uint8_t MS_FIRST[MS_COUNT + 1] = {MI_COLOR, MI_LIGHTS, MI_LOWCUT, MI_ADV, MI_CPU1, MI_COUNT}; /* rows of each */ UI_SMALL static int mi_cpu1_have(void) /* the second core is running (cpu1.c; the host tests have no cpu1.c) */ { @@ -60,6 +60,8 @@ UI_SMALL static const char *mi_value(uint32_t i, uint16_t *c) return PALETTES[settings.palette % NPALETTES].name; case MI_ZOOM: return settings.zoom ? "ON" : "OFF"; case MI_ACCEL: return knob_accel_off ? "OFF" : "ON"; /* (2.7) the knobs speed up with a fast turn */ + case MI_ADV: return step_adv_off ? "OFF" : "ON"; /* (2.7.1) the STEP page's cursor moves on when the keys are let go */ + case MI_DPREV: return drum_preview ? "ON" : "OFF"; /* (2.7.1) a drum sound picked with a knob is heard */ case MI_LIGHTS: return LIGHTS_NAME[lights_lvl % LIGHTS_N]; case MI_KEYS: *c = lights_lvl ? C_HI : C_DIM; /* (needs LIGHTS) */ @@ -74,6 +76,15 @@ UI_SMALL static const char *mi_value(uint32_t i, uint16_t *c) static const char *const R[3] = {"AUTO", "44.1 KHZ", "48 KHZ"}; return R[usb_rate % 3u]; } + case MI_FRESO: { /* (2.7.2) the track filter's resonance, 0 (clean) .. 10 (fx.c) */ + static char b[4]; + if (!flt_reso) { + *c = C_DIM; + return "OFF"; + } + fmt_int(b, flt_reso > 10u ? 10 : flt_reso); + return b; + } case MI_CPU1: /* the render on both cores (fx.c); live, the sound is the same */ *c = mi_cpu1_have() ? C_HI : C_DIM; return cpu1_off ? "OFF" : "ON"; @@ -100,7 +111,7 @@ UI_SMALL static void draw_menu(void) uint32_t sig = ui.menu * 7u + ui.menu_sel * 131u + settings.palette * 1009u + settings.lowcut * 7919u + settings.zoom * 104729u + lights_lvl * 1299709u + lights_keys * 15485863u + ml_count() * 2654435u + lights_notes * 32452843u + usb_full * 49979687u + usb_serial * 86028121u + usb_rate * 15486719u + theme_shown() * 32452867u + theme.crc + cpu1_off * 122949829u + - knob_accel_off * 179424673u; + knob_accel_off * 179424673u + drum_preview * 236887691u + step_adv_off * 373587883u + flt_reso * 512927357u; if (!ui.force && sig == ui.menu_sig) return; ui.menu_sig = sig; @@ -156,7 +167,7 @@ UI_SMALL static void draw_menu(void) if (i == sec) cv_rect(x - 2, 3, w + 4, 18, C_LINE); cv_text(x, 4, &FONT_S, MS_NAME[i], i == sec ? C_WHITE : C_DIM); - x += w + 10; + x += w + 6; /* (2.7.1: five sections: 6, the last ends at 236) */ } for (i = MS_FIRST[sec]; i < MS_FIRST[sec + 1u]; i++) { uint32_t r = i - MS_FIRST[sec]; @@ -237,6 +248,12 @@ UI_SMALL static void mi_set(uint32_t i, int32_t s) case MI_ACCEL: /* (2.7) right ON, left OFF; OCT+ toggles (ui_input.c accel) */ knob_accel_off = (uint8_t)(s > 0 ? 0u : s < 0 ? 1u : !knob_accel_off); break; + case MI_ADV: /* (2.7.1) right ON, left OFF; OCT+ toggles (ui_input.c seq_entry) */ + step_adv_off = (uint8_t)(s > 0 ? 0u : s < 0 ? 1u : !step_adv_off); + break; + case MI_DPREV: /* (2.7.1) right ON, left OFF; OCT+ toggles (ui_studio.c drum_hear) */ + drum_preview = (uint8_t)(s > 0 ? 1u : s < 0 ? 0u : !drum_preview); + break; case MI_ZOOM: case MI_LOWCUT: { /* right ON, left OFF; OCT+ toggles */ uint32_t *v = i == MI_LOWCUT ? &settings.lowcut : &settings.zoom; @@ -261,6 +278,14 @@ UI_SMALL static void mi_set(uint32_t i, int32_t s) else if (!s) usb_rate = (uint8_t)((usb_rate + 1u) % 3u); break; + case MI_FRESO: /* (2.7.2) 0 (OFF/clean) .. 10, stops at the ends; OCT+ steps round */ + if (s > 0 && flt_reso < 10u) + flt_reso++; + else if (s < 0 && flt_reso > 0u) + flt_reso--; + else if (!s) + flt_reso = (uint8_t)((flt_reso >= 10u ? 0u : flt_reso + 1u)); + break; case MI_CPU1: /* right ON, left OFF; at once (the next block renders so) */ cpu1_off = (uint8_t)(s > 0 ? 0u : s < 0 ? 1u : !cpu1_off); cpu1_units = cpu1_off ? 0 : -1; diff --git a/firmware/src/ui_song.c b/firmware/src/ui_song.c index 088d5c6..56923c7 100644 --- a/firmware/src/ui_song.c +++ b/firmware/src/ui_song.c @@ -21,7 +21,7 @@ UI_SMALL static void song_screen_draw(void) song_sane(); uint32_t i, start = song_cursor > 3u ? song_cursor - 3u : 0u; static uint32_t previous; - static const uint16_t SC[4] = {RGB(40, 124, 255), RGB(30, 204, 112), RGB(255, 198, 24), RGB(255, 98, 26)}; + const uint16_t *SC = TE_COL; /* the tracks' colours (2.7.2: your theme's, when it is on) */ uint32_t sig = song_cursor + 17u * arrangement_enabled + 37u * song.playing + 71u * arrangement_clock.index + 127u * arrangement_clock.bar + 257u * arrangement.count + 509u * song.g[G_BPM]; diff --git a/firmware/src/ui_studio.c b/firmware/src/ui_studio.c index d5ef0ec..20813ff 100644 --- a/firmware/src/ui_studio.c +++ b/firmware/src/ui_studio.c @@ -6,7 +6,38 @@ * LAYERS (a function button held: what the 16 white keys and the knobs do now), HOLD (a hold to * confirm: clear, save), REC (armed / free take). Every band is drawn into the canvas only when its * signature changed. */ -static uint8_t drum_page, drum_lane, drum_cursor; /* drum_page: 0 GRID, 1 KIT, 2 SOUND (2.7: a sound's TUNE, DECAY) */ +static uint8_t drum_page, drum_cursor; /* drum_page: 0 GRID, 1 KIT, 2 SOUND (2.7: a sound's TUNE, DECAY) */ +#define drum_lane pen_lane /* (2.7.1) one drum sound picked everywhere: the GRID, SOUND, the SEQ layer, a pad + * played (seq.c pen_lane) */ +/* (2.7.1) the black keys pick the drum sound on the GRID page and in the SEQ layer (the pages: OCT- / OCT+), never heard; + * the same key again: the other sound of its pair. F#3 .. F#5: KICK / KICK 2, SNARE / SNARE 2, RIM, CLAP, HAT / PEDAL, + * OPEN HAT, LOW TOM / HI TOM, CRASH, RIDE, SHAKER / CONGA, COWBELL */ +static const uint8_t DRUM_BLACK[11][2] = {{0, 1}, {2, 8}, {7, 7}, {3, 3}, {4, 6}, {5, 5}, {9, 10}, {11, 11}, {12, 12}, + {13, 14}, {15, 15}}; +UI_SMALL static int32_t drum_black_of(uint32_t k) /* key k: its black key 0..10, -1 a white key */ +{ + uint32_t i; + for (i = 0; i < 11u; i++) + if (PUNCH_BLACK[i] == k) + return (int32_t)i; + return -1; +} +UI_SMALL static uint32_t drum_black_key(uint32_t lane) /* the key of the black key a sound is on */ +{ + uint32_t i; + for (i = 0; i < 11u; i++) + if (DRUM_BLACK[i][0] == lane || DRUM_BLACK[i][1] == lane) + return PUNCH_BLACK[i]; + return PUNCH_BLACK[0]; +} +UI_SMALL static void drum_black_pick(uint32_t b) /* black key b: its sound, or the other of its pair */ +{ + const uint8_t *g = DRUM_BLACK[b % 11u]; + pen_lane = pen_lane == g[0] && g[1] != g[0] ? g[1] : g[0]; + ui_say("SOUND ", LANE_NAME[pen_lane]); + ui.force = 1; +} +UI_SMALL static void drum_hear(uint32_t lane) { if (drum_preview) audition_lane(lane); } /* (2.7.1) menu DRUM PREVIEW */ static void trk_short_name(uint32_t c, char *b); UI_SMALL static int on_drum_page(void) { return !ui.home && cur_page()->scope == SC_DRUM; } @@ -147,7 +178,7 @@ UI_SMALL static void loop_pos(const track_t *t, char *b) } /* the header of the live screens: BPM, transport, the loop position, the beat lights, REC */ -UI_SMALL static void te_header(const char *title, uint16_t tc, uint32_t *cache) +UI_SMALL static void te_header(const char *title, uint16_t tc, uint32_t *cache, int32_t sect) { char b[12]; uint32_t beat = clk_beat, k, playing = song.playing; @@ -155,6 +186,7 @@ UI_SMALL static void te_header(const char *title, uint16_t tc, uint32_t *cache) (playing ? beat * 131u + TSEL->seq_idx * 7919u : 0u) + (uint32_t)song.g[G_CLOCK] * 77u + arrangement_enabled * 5u + (ui.bpm_t != 0) * 104729u + song.solo * 37u, title); sig = sig * 31u + tc; + sig = sig * 31u + (uint32_t)(sect + 1) * 211u; /* (2.7.2) the section A..D badge */ if (!ui.force && sig == *cache) return; *cache = sig; @@ -177,7 +209,14 @@ UI_SMALL static void te_header(const char *title, uint16_t tc, uint32_t *cache) if (song.g[G_CLOCK] != 0) /* the click is on */ cv_text(168, 22, &FONT_S, "click", TE_G3); } else { - cv_text(240 - text_w(&FONT_S, title) - 4, 5, &FONT_S, title, tc); + int32_t tx = 240 - text_w(&FONT_S, title) - 4; + cv_text(tx, 5, &FONT_S, title, tc); + if (sect >= 0) { /* (2.7.2) which section (A..D) is playing, SONG-layer colours */ + char sb[2] = {(char)('A' + (sect & 3)), 0}; + int32_t bw = text_w(&FONT_S, sb) + 8, bx = tx - bw - 6; + cv_rect(bx, 3, bw, 14, playing ? TE_COL[sect & 3] : TE_DIM[sect & 3]); + cv_text(bx + 4, 5, &FONT_S, sb, C_BLACK); + } if (song.solo) cv_text(236 - text_w(&FONT_S, "solo"), 22, &FONT_S, "solo", C_WHITE); } @@ -196,7 +235,8 @@ UI_SMALL static void studio_tracks_draw(void) { static uint32_t head, rows[NTRK], footer; uint32_t i, j; - te_header("tracks", TE_G3, &head); + int32_t sect = song.playing && live_sec >= 0 ? live_sec : (int32_t)song.g[G_SLOT] - 1; /* (2.7.2) the section playing */ + te_header("tracks", TE_G3, &head, sect); for (i = 0; i < NTRK; i++) { track_t *t = &trk[i]; char b[24], e[16]; @@ -340,7 +380,7 @@ UI_SMALL static void drum_screen_draw(void) } te_lower(st, style, sizeof st); st[12] = 0; - te_header(st, TE_DRUM, &head); + te_header(st, TE_DRUM, &head, -1); } sig = kit * 131u + drum_page * 7u + drum_lane * 977u + bank * 31u + len + (uint32_t)drum_tweaked() * 7919u; /* title band */ if (ui.force || sig != title_sig) { @@ -357,7 +397,8 @@ UI_SMALL static void drum_screen_draw(void) cv_rect(188, 5 + (int32_t)drum_page * 14, 3, 9, TE_DRUM); cv_blit(0, 40); } - sig = drum_page + drum_lane * 7u + drum_cursor * 101u + song.playing * 71u + len * 3u; + sig = drum_page + drum_lane * 7u + drum_cursor * 101u + song.playing * 71u + len * 3u + ui.sheet * 7919u + + (uint32_t)(TDRUM->micro[drum_cursor] + 64) * 104729u + step_fill(TDRUM, drum_cursor) * 13u; for (i = 0; i < DRUM_LANES; i++) sig = sig * 5u + (uint32_t)(drum_tune[i] + 8) * 9u + (uint32_t)(drum_dec[i] + 4); if (song.playing) sig = sig * 31u + TDRUM->seq_idx; for (i = 0; i < DRUM_LANES; i++) sig = sig * 3u + (pad_lit[i] != 0); @@ -393,6 +434,18 @@ UI_SMALL static void drum_screen_draw(void) } } } + if (ui.sheet) { /* (2.7.2) OCT+ held: the hit's sheet */ + const dstep_t *s = &TDRUM->dstep[drum_cursor]; + char r[4], nu[8]; + const char *val[6] = {r, nu, FILL_N[step_fill(TDRUM, drum_cursor) % 3u], "", "", ""}; + int8_t m = TDRUM->micro[drum_cursor]; + str_cpy(r, dstep_has(s, drum_lane) ? "x1" : "--", 4); + if (dstep_has(s, drum_lane)) + r[1] = (char)('1' + dstep_rat(s, drum_lane)); + fmt_int(nu, m); + if (m > 0) { nu[0] = '+'; fmt_int(nu + 1, m); } + sheet_draw(112, 1, DSHEET_N, val, ui.sheet - 1u, TE_DIM[3]); + } } else { /* KIT: 16 pads, lit on each hit; SOUND (2.7): the one KNOB 1 picks * framed, a tuned or shortened / lengthened one marked */ for (i = 0; i < DRUM_LANES; i++) { @@ -458,22 +511,18 @@ static const uint8_t LV_UP[4] = {LV_GHOST, LV_SOFT, LV_NORM, LV_HARD}; UI_SMALL static uint32_t lvl_rank(uint32_t lvl) { return lvl == LV_GHOST ? 0u : lvl == LV_SOFT ? 1u : lvl == LV_NORM ? 2u : 3u; } /* the GRID page shown, no layer held: its keys are steps (seq.c kb_grid) */ -UI_SMALL static int grid_keys_on(void) { return on_drum_page() && !drum_page && song.sel == TRK_DRUM && !ui.menu; } +UI_SMALL static int grid_keys_on(void) { return on_drum_page() && !drum_page && song.sel == TRK_DRUM && !ui.menu && !ui.sheet; } /* a key down on the GRID page: the white keys are the 16 steps of this page of steps for the sound of - * KNOB 1 — an empty one is set (NORM, the sound heard), a set one cleared; the first four black keys - * pick the page (steps 1-16, 17-32, 33-48, 49-64), as in the SEQ layer. The cursor follows */ + * KNOB 1 — an empty one is set (NORM; 2.7.1: silent, for live), a set one cleared. 2.7.1: the black keys pick the sound + * (drum_black_pick), OCT- / OCT+ the page (steps 1-16, 17-32, 33-48, 49-64), as in the SEQ layer. The cursor follows */ UI_SMALL static void grid_key(uint32_t k) { - static const int8_t PG[12] = {-1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, -1}; uint32_t len = trk_len(TDRUM), idx; - int32_t w = punch_key(k); + int32_t w = punch_key(k), b = drum_black_of(k); dstep_t *st; if (w < 0) { - if (k < 12u && PG[k] >= 0 && (uint32_t)PG[k] * 16u < len) { - idx = (uint32_t)PG[k] * 16u + drum_cursor % 16u; - drum_cursor = (uint8_t)(idx < len ? idx : len - 1u); - ui.force = 1; - } + if (b >= 0) + drum_black_pick((uint32_t)b); return; } idx = drum_cursor / 16u * 16u + (uint32_t)w; @@ -499,8 +548,71 @@ UI_SMALL static void grid_key(uint32_t k) TDRUM->seq_active = 1; } fm1_irq_on(); - if (dstep_has(st, drum_lane)) - audition_lane(drum_lane); + sync_reload = 1; /* (2.7.1: not heard: the pattern plays it) */ +} + +/* (2.7.2) the GRID's sheet (OCT+ held), as the NOTES page's: the hit of KNOB 1's sound on KNOB 2's step. RATCHET (its + * hits in the step), NUDGE and FILL (the step's, every sound in it), MOVE (KNOB 2: a step a detent), COPY (OCT+: to the + * next step, then MOVE moves the copy), DELETE (OCT+) */ +UI_SMALL static int drum_hit_shift(int32_t dir, int copy) /* the hit a step on / back (copy: the next step); 0: no room */ +{ + uint32_t len = trk_len(TDRUM), to = (uint32_t)((int32_t)drum_cursor + (copy ? 1 : dir)); + dstep_t *st = &TDRUM->dstep[drum_cursor]; + if (!dstep_has(st, drum_lane) || (!copy && dir < 0 && !drum_cursor) || to >= len || + dstep_has(&TDRUM->dstep[to], drum_lane)) + return 0; + fm1_irq_off(); + dstep_set(&TDRUM->dstep[to], drum_lane, dstep_lvl(st, drum_lane), dstep_rat(st, drum_lane)); + if (!copy) + dstep_clr(st, drum_lane); + fm1_irq_on(); + drum_cursor = (uint8_t)to; + return 1; +} +UI_SMALL static void drum_sheet_knob(uint32_t k, int32_t s) +{ + dstep_t *st = &TDRUM->dstep[drum_cursor]; + uint32_t row = ui.sheet - 1u; + if (k == 0u) { + ui.sheet = (uint8_t)(1 + clamp((int32_t)row + s, 0, 5)); + return; + } + if (k != 1u) + return; + undo_mark(TDRUM, (undo_sess += 4u) | 3u); + fm1_irq_off(); + if (row == 0u && dstep_has(st, drum_lane)) + dstep_set(st, drum_lane, dstep_lvl(st, drum_lane), (uint32_t)clamp((int32_t)dstep_rat(st, drum_lane) + s, 0, 3)); + else if (row == 1u) + TDRUM->micro[drum_cursor] = (int8_t)clamp(TDRUM->micro[drum_cursor] + s, MICRO_MIN, MICRO_MAX); + else if (row == 2u) + step_fill_set(TDRUM, drum_cursor, (uint32_t)clamp((int32_t)step_fill(TDRUM, drum_cursor) % 3 + (s > 0 ? 1 : -1), 0, 2)); + fm1_irq_on(); + if (row == 3u) + for (; s; s += s > 0 ? -1 : 1) + if (!drum_hit_shift(s > 0 ? 1 : -1, 0)) { + ui_message(dstep_has(&TDRUM->dstep[drum_cursor], drum_lane) ? "NO ROOM" : "NO HIT"); + break; + } + sync_reload = 1; +} +UI_SMALL static void drum_sheet_do(void) /* OCT+ tapped in the sheet */ +{ + undo_mark(TDRUM, (undo_sess += 4u) | 3u); + if (ui.sheet == 5u) { + if (drum_hit_shift(1, 1)) { + ui.sheet = 4; /* (MOVE: KNOB 2 moves the copy) */ + ui_message("COPIED"); + } else { + ui_message(dstep_has(&TDRUM->dstep[drum_cursor], drum_lane) ? "NO ROOM" : "NO HIT"); + } + } else if (ui.sheet == 6u) { + fm1_irq_off(); + dstep_clr(&TDRUM->dstep[drum_cursor], drum_lane); + fm1_irq_on(); + ui.sheet = 0; + ui_message("HIT DELETED"); + } sync_reload = 1; } @@ -512,8 +624,34 @@ UI_SMALL static void drum_screen_input(uint32_t pressed, uint32_t home, uint32_t go_home(); return; } + if (!drum_page) { /* (2.7.2) OCT+ held: the hit's sheet; tapped: the page */ + uint32_t ev, ob = 1u << panel.btn[B_OCTDN]; + pressed = octp_filter(pressed, &ev); + if (ev == 2u && !ui.sheet) + ui.sheet = 1; + else if (ev == 1u && ui.sheet) + drum_sheet_do(); + else if (ev == 1u) + pressed |= 1u << panel.btn[B_OCTUP]; + if (ui.sheet && (pressed & ob)) { + ui.sheet = 0; + pressed &= ~ob; + } + if (ev) + ui.force = 1; + } else { + ui.sheet = 0; + } for (k = 0; k < NB; k++) if ((pressed >> panel.btn[k]) & 1u) { b = k; + if ((b == B_OCTDN || b == B_OCTUP) && !drum_page) { /* (2.7.1) GRID: OCT- / OCT+ the page of steps */ + uint32_t len = trk_len(TDRUM), pages = (len + 15u) / 16u, pg = drum_cursor / 16u, idx; + pg = (pg + (b == B_OCTUP ? 1u : pages - 1u)) % pages; + idx = pg * 16u + drum_cursor % 16u; + drum_cursor = (uint8_t)(idx < len ? idx : len - 1u); + ui.force = 1; + continue; + } if (b == B_PLAY) { if (ft_owns_press()) ; else if (!song.playing && arrangement_enabled && !arr_valid(&arrangement, arrangement_ready())) ui_message("EMPTY SECTION: REC"); @@ -552,16 +690,18 @@ UI_SMALL static void drum_screen_input(uint32_t pressed, uint32_t home, uint32_t for (k = 0; k < 4u; k++) if ((s = panel_enc(EN_K1 + k))) { ui.hot_col = (uint8_t)k; ui.hot_t = 40; - if (!drum_page) { + if (!drum_page && ui.sheet) { + drum_sheet_knob(k, s); + } else if (!drum_page) { dstep_t *st = &TDRUM->dstep[drum_cursor]; - if (k == 0) { /* the sound: heard */ + if (k == 0) { /* the sound (heard: DRUM PREVIEW ON, 2.7.1) */ uint8_t l = (uint8_t)clamp(drum_lane + s, 0, DRUM_LANES - 1); - if (l != drum_lane) audition_lane(l); + if (l != drum_lane) drum_hear(l); drum_lane = l; } - if (k == 1) { /* the step: what it holds, heard */ + if (k == 1) { /* the step: what it holds, heard (2.7.1: DRUM PREVIEW ON) */ uint8_t c = (uint8_t)clamp(drum_cursor + s, 0, TDRUM->p[P_SLEN] - 1); - if (c != drum_cursor) audition_step(&TDRUM->dstep[c]); + if (c != drum_cursor && drum_preview) audition_step(&TDRUM->dstep[c]); drum_cursor = c; } if (k >= 2) { @@ -581,7 +721,7 @@ UI_SMALL static void drum_screen_input(uint32_t pressed, uint32_t home, uint32_t } else if (drum_page == 2u) { /* SOUND (2.7) */ if (k == 0) { uint8_t l = (uint8_t)clamp(drum_lane + s, 0, DRUM_LANES - 1); - if (l != drum_lane) audition_lane(l); + if (l != drum_lane) drum_hear(l); drum_lane = l; } if (k == 1 || k == 2) { /* TUNE, DECAY: the next hit has them (heard at once) */ @@ -676,7 +816,7 @@ UI_SMALL static void rec_screen_draw(void) } rec_shown = 1; layout = (uint8_t)lay; - te_header(take ? "free take" : count ? "count-in" : "rec ready", TE_RED, &head); + te_header(take ? "free take" : count ? "count-in" : "rec ready", TE_RED, &head, -1); if (take) { /* free take: the time, the loop it makes */ sig = 1000003u + rt * 7919u + blink * 31u + secs * 131u + bars * 17u + bpm * 3u; if (ui.force || sig != body) { diff --git a/firmware/src/upreset.c b/firmware/src/upreset.c index 44eaa45..96e53c9 100644 --- a/firmware/src/upreset.c +++ b/firmware/src/upreset.c @@ -181,6 +181,22 @@ UI_SMALL static const param_desc_t *up_desc(uint32_t e, uint32_t i) return i >= P_E0 ? &ENGINES[e]->edit[i - P_E0] : &TP[i]; } +UI_SMALL static int up_arp_of(uint32_t k, int16_t *a) /* (2.7.1) its arp, MODE … ORDER, as up_values: 1 = no preset */ +{ + const up_rec_t *r; + uint32_t i, nc; + if (!up_used(k)) + return 1; + r = up_rec(k); + nc = r->np - 8u; + for (i = 0; i < 8u; i++) { + uint32_t id = P_AMODE + i; + const param_desc_t *d = up_desc(r->engine, id); + a[i] = (int16_t)clamp(id < nc ? r->p[id] : d->def, d->min, d->max); + } + return 0; +} + UI_SMALL static void up_values(const up_rec_t *r, int16_t *v) /* mapped and clamped for its engine */ { int16_t def[P_COUNT]; @@ -278,19 +294,21 @@ UI_SMALL static int up_load_to(track_t *t, uint32_t k) /* user preset k in const up_rec_t *r; int16_t v[P_COUNT]; uint32_t i; + int keep_arp; if (!up_used(k) || is_drum(t)) return 1; + keep_arp = t->p[P_AMODE] && !arp_is_sounds(t); /* (2.7.1: not the arp the old sound brought) */ r = up_rec(k); up_values(r, v); for (i = 0; i < P_COUNT; i++) /* (LEN etc. of a kept pattern changed too, and */ - if (param_kept(i) || (t->p[P_AMODE] && i >= P_AMODE && i <= P_AORDER) || /* a preset pattern then counted as */ + if (param_kept(i) || (keep_arp && i >= P_AMODE && i <= P_AORDER) || /* a preset pattern then counted as */ (i == P_AHOLD && !t->p[P_AMODE] && t->p[P_AHOLD])) /* (2.7: KBD HOLD stays on) */ v[i] = t->p[i]; /* edited; 2.7: the arp that runs goes on, ui.c apply_preset_to) */ if (!v[P_AMODE] && !t->p[P_AMODE]) v[P_AHOLD] = t->p[P_AHOLD]; /* (2.7) KBD HOLD (HOLD with the arp OFF) is the track's, not the * preset's: as it was (a 2.6 preset's HOLD meant nothing there) */ sound_change(t); /* (2.6: what sounds fades out with the old sound, no click) */ - if (t->p[P_AMODE]) + if (keep_arp) arp_keep_req |= (uint8_t)(1u << trk_index(t)); /* (2.7: its notes too) */ panic_req |= (uint8_t)(1u << trk_index(t)); fm1_irq_off(); /* the audio ISR must not see half a sound */ diff --git a/firmware/src/usb.c b/firmware/src/usb.c index 0615acf..6133eab 100644 --- a/firmware/src/usb.c +++ b/firmware/src/usb.c @@ -170,15 +170,16 @@ static void midi_out_event(uint32_t pkt) /* from the audio ISR */ /* ------------------------------------------------------- descriptors --- */ /* interfaces: 0 audio control, 1 MIDI streaming, 2 audio streaming (FELUCCA_UAC), then CDC's two. - * bcdDevice: 3.00 MIDI, +0.01 CDC, +0.10 the audio input, +0.20 more with 48 kHz (2.5) (hosts cache descriptors - * per version) */ + * bcdDevice: 3.00 MIDI, +0.01 CDC, +0.10 the audio input, +0.20 more with 48 kHz (2.5), +0.08 the audio + * streaming interface first in the AC collection (2.7.2, UAC_BCD_AS) (hosts cache descriptors per version) */ +#define UAC_BCD_AS (0x08 * FELUCCA_UAC) #define CDC_IF (2 + FELUCCA_UAC) #define UAC_AS_IF 2u #define CFG_LEN (101 + 74 * FELUCCA_CDC + 74 * FELUCCA_UAC + 3 * FELUCCA_UAC_48K) #define USB_NIF (2 + FELUCCA_UAC + 2 * FELUCCA_CDC) #if FELUCCA_CDC static const uint8_t DEV_DESC[18] = {18, 1, 0x00, 0x02, 0xEF, 0x02, 0x01, 64, 0x09, 0x12, 0x01, 0x00, - 0x01 + 0x10 * (FELUCCA_UAC + FELUCCA_UAC_48K), 0x03, 1, 2, 0, 1}; /* misc/IAD */ + 0x01 + 0x10 * (FELUCCA_UAC + FELUCCA_UAC_48K) + UAC_BCD_AS, 0x03, 1, 2, 0, 1}; /* misc/IAD */ static const uint8_t CFG_DESC[] = { 9, 2, CFG_LEN & 0xFF, CFG_LEN >> 8, USB_NIF, 1, 0, 0x80, 50, 8, 0x0B, 0, 2 + FELUCCA_UAC, 1, 1, 0, 0, /* IAD: audio + MIDI (IF 0-1, 0-2) */ @@ -187,14 +188,20 @@ static const uint8_t CFG_DESC[] = { #define FELUCCA_USB_PID 0x0001 /* the update loader is 0x0002 */ #endif static const uint8_t DEV_DESC[18] = {18, 1, 0x10, 0x01, 0, 0, 0, 64, 0x09, 0x12, FELUCCA_USB_PID & 0xFF, - FELUCCA_USB_PID >> 8, 0x00 + 0x10 * (FELUCCA_UAC + FELUCCA_UAC_48K), 0x03, + FELUCCA_USB_PID >> 8, 0x00 + 0x10 * (FELUCCA_UAC + FELUCCA_UAC_48K) + UAC_BCD_AS, 0x03, 1, 2, 0, 1}; static const uint8_t CFG_DESC[] = { 9, 2, CFG_LEN & 0xFF, CFG_LEN >> 8, USB_NIF, 1, 0, 0x80, 50, #endif 9, 4, 0, 0, 0, 1, 1, 0, 0, #if FELUCCA_UAC - 10, 0x24, 1, 0x00, 0x01, 31, 0, 2, 1, UAC_AS_IF, /* AC header 1.00: MIDI + audio streaming */ + /* AC header 1.00, its collection: the audio streaming interface first, then the MIDI one (2.7.2, after + * Felucca 1.5.1, #67). macOS up to 15 (the kernel's AppleUSBAudio, parseConfigurationDescriptor) drops the + * MIDI streaming interface from the collection while it walks it with bInCollection's count: MIDI listed + * first, the walk runs past the shortened list and gives up before the audio streaming interface, and no + * audio input appears (MIDI still works). Listed last, MIDI is dropped at the end. The class spec gives the + * order no meaning (Windows, Linux, macOS 26 take each listed interface on its own) */ + 10, 0x24, 1, 0x00, 0x01, 31, 0, 2, UAC_AS_IF, 1, 12, 0x24, 2, 1, 0x03, 0x06, 0, 2, 0x03, 0x00, 0, 0, /* input terminal 1: line, 2 ch (L R) */ 9, 0x24, 3, 2, 0x01, 0x01, 0, 1, 0, /* output terminal 2: USB streaming, from 1 */ #else @@ -246,7 +253,7 @@ typedef char cfg_len_ok[sizeof CFG_DESC == CFG_LEN ? 1 : -1]; * are loaded first), so the host sees one device from the start */ static uint8_t usb_cdc_on; static const uint8_t DEV_DESC_PLAIN[18] = {18, 1, 0x10, 0x01, 0, 0, 0, 64, 0x09, 0x12, 0x01, 0x00, - 0x00 + 0x10 * (FELUCCA_UAC + FELUCCA_UAC_48K), 0x03, 1, 2, 0, 1}; + 0x00 + 0x10 * (FELUCCA_UAC + FELUCCA_UAC_48K) + UAC_BCD_AS, 0x03, 1, 2, 0, 1}; #define CFG_PLAIN_LEN (CFG_LEN - 74) /* without the audio IAD (8) and the CDC block (66) */ static uint8_t cfg_plain[CFG_PLAIN_LEN]; static const uint8_t *cfg_plain_get(void) @@ -278,8 +285,9 @@ static const uint8_t STR2[] = {16, 3, 'F', 0, 'e', 0, 'l', 0, 'u', 0, 'c', 0, 'c /* SLOOP 2.7 beta: menu AUDIO > USB RATE, for the hosts that record the stream badly (reports: Android phones, * distorted, while a computer records clean). main.c sets usb_rate_mode before usb_start; a change takes effect * at the next start, as USB SERIAL does (the host reads the descriptors when the FM-1 appears). - * 0 AUTO 44.1 and 48 kHz, the host picks: the descriptors of 2.5 / 2.6, byte for byte; - * 1 44.1 44.1 kHz only: the descriptors of SLOOP 2.4 (a FELUCCA_UAC_48K=0 build) byte for byte: the format + * 0 AUTO 44.1 and 48 kHz, the host picks: the descriptors of 2.5 / 2.6 (2.7.2: with the AC collection's new + * order, bcdDevice x.28); + * 1 44.1 44.1 kHz only: the descriptors of a FELUCCA_UAC_48K=0 build (SLOOP 2.4's) byte for byte: the format * of one rate, packets of 46 frames at most, bcdDevice x.1x; the resampler never runs, the samples * go out as rendered; * 2 48 48 kHz only (bcdDevice x.3x, a version of its own: hosts cache descriptors per version). diff --git a/tests/dsyn_test.c b/tests/dsyn_test.c index 9206d8f..a5a7361 100644 --- a/tests/dsyn_test.c +++ b/tests/dsyn_test.c @@ -288,6 +288,22 @@ int main(void) check(z1 == z0 && t1 == t0, "SOUND page: the snare's TUNE and DECAY leave the kick as it is"); } } + { /* 2.7.2: a tone-less noise sound (the 808 closed hat, note 42) now answers TUNE too, by its brightness + * (more / fewer zero crossings), the way resampling a sampled kit would. Before 2.7.2 it did nothing. */ + uint32_t kk, kit = 0; + double z0, zu, zd; + for (kk = 0; kk < DRUM_KITS; kk++) if (!strcmp(DRUM_KIT_NAMES[kk], "808")) kit = kk; + TDRUM->p[P_E0] = (int16_t)kit; + hit_win = 2205u; /* 0.1 s: the hat's burst */ + memset(drum_tune, 0, sizeof drum_tune); memset(drum_dec, 0, sizeof drum_dec); + hit_render(42, &z0, 0); + drum_tune[lane_of_note(42)] = 7; hit_render(42, &zu, 0); + drum_tune[lane_of_note(42)] = -8; hit_render(42, &zd, 0); + drum_tune[lane_of_note(42)] = 0; + hit_win = 22050u; + printf(" 808 closed hat: crossings %.0f / TUNE +7 %.0f / -8 %.0f\n", z0, zu, zd); + check(zu > z0 * 1.03 && zd < z0 * 0.97, "SOUND page (2.7.2): TUNE shifts a noise sound's brightness (the 808 hat)"); + } TDRUM->p[P_E0] = DRUM_DEFAULT_KIT; } printf(fails ? "dsyn: FAILED\n" : "dsyn: all checks ok\n"); diff --git a/tests/encoder_test.c b/tests/encoder_test.c index cc9a275..0ef3916 100644 --- a/tests/encoder_test.c +++ b/tests/encoder_test.c @@ -50,6 +50,16 @@ int main(void) for (k = 0; k < 24u; k++) click(e, 1, 2); frames(e, 30); check("24 fast clicks (2 frames a transition): +24", take(e) == 24); + for (k = 0; k < 24u; k++) { /* 2.7.2: a fast turn: the mid states one frame each */ + move(e, 1, 1); move(e, 1, 1); move(e, 1, 1); move(e, 1, 6); + } + frames(e, 30); + check("2.7.2: 24 fast clicks, mid states 1 frame each (~1.1 ms): +24", take(e) == 24); + for (k = 0; k < 24u; k++) { + move(e, -1, 1); move(e, -1, 1); move(e, -1, 1); move(e, -1, 6); + } + frames(e, 30); + check("2.7.2: the same anticlockwise: -24", take(e) == -24); for (k = 0; k < 5u; k++) { /* a slow turn that stops mid-click (50 ms) */ move(e, 1, 6); move(e, 1, 45); move(e, 1, 6); move(e, 1, 30); } diff --git a/tests/golden.txt b/tests/golden.txt index 30a8b62..9ad58d9 100644 --- a/tests/golden.txt +++ b/tests/golden.txt @@ -66,7 +66,7 @@ preset/SAMPLE/02_VIBES b990857c2a729642 preset/SAMPLE/03_HORN_STAB f2b3917cde0d0110 preset/SAMPLE/04_STRING_STB 131105f7f10785fe preset/SAMPLE/05_LOFI_FLUTE 79c66528bf0b1c74 -preset/SAMPLE/06_SCRATCH 3d6567bb372be864 +preset/SAMPLE/06_SCRATCH e64ad5d2d779891c preset/SAMPLE/07_GM_KIT 13999abe5e115815 preset/SAMPLE/08_DUSTY_PNO 3918c5839bb7a848 preset/SAMPLE/09_LOFI_KEYS 6fa2f6b1e30b1f3d diff --git a/tests/hostsim.c b/tests/hostsim.c index 2b6e9dc..f230de8 100644 --- a/tests/hostsim.c +++ b/tests/hostsim.c @@ -572,7 +572,8 @@ static int rec_test(void) input_off(t1, 64); rec_run_to(t1, 12, 50); ok_half = rec_step_is(t1, 10, ST_NOTE, 1, 64) && rec_step_is(t1, 11, ST_TIE, 0, 0) && rec_step_is(t1, 12, ST_REST, 0, 0); - /* (d) a two-key chord held 2.6 steps: ties until the last key is up */ + /* (d) a two-key chord, one key up early in step 15, the other held 2.6 steps: 2.7.1, each note to its own end: step 15 the + * one still held going on (a NOTE of it, CONT), step 16 a TIE (up to 2.7 the chord tied until its last key) */ rec_run_to(t1, 13, 5); input_on(t1, 67, 100); input_on(t1, 71, 100); @@ -581,7 +582,8 @@ static int rec_test(void) rec_run_to(t1, 15, 60); input_off(t1, 71); rec_run_to(t1, 0, 10); - ok_chord = t1->step[13].n == 2u && rec_step_is(t1, 14, ST_TIE, 0, 0) && rec_step_is(t1, 15, ST_TIE, 0, 0) && + ok_chord = t1->step[13].n == 2u && t1->step[14].time == ST_NOTE && t1->step[14].n == 1u && t1->step[14].note[0] == 71u && + (t1->step[14].flags & SF_CONT(0)) && rec_step_is(t1, 15, ST_TIE, 0, 0) && t1->step[0].time != ST_TIE; /* (e) LEN 4, held for 10 steps: the note fills the pattern (3 TIEs), not more */ rec_run_to(t2, 1, 10); @@ -617,7 +619,7 @@ static int rec_test(void) printf("tracks: recording lengths: held 3.3 steps -> NOTE TIE TIE (the 4th step put back) %s; 0.3 step -> one " "step %s; past the middle of the next -> NOTE TIE %s\n", ok_len ? "ok" : "FAIL", ok_short ? "ok" : "FAIL", ok_half ? "ok" : "FAIL"); - printf("tracks: recording lengths: a chord ties until its last key %s; capped at LEN 4 %s; MONO legato A..B -> " + printf("tracks: recording lengths: a chord, each note to its own key-up (2.7.1) %s; capped at LEN 4 %s; MONO legato A..B -> " "A TIE B TIE %s\n", ok_chord ? "ok" : "FAIL", ok_cap ? "ok" : "FAIL", ok_mono ? "ok" : "FAIL"); printf("tracks: recording with SWING 50 %%: nearest swung step, as heard (0.55 into a long step stays, 0.56 into a " "short one moves on) %s\n", ok_swing ? "ok" : "FAIL"); diff --git a/tests/punch_test.c b/tests/punch_test.c index bf1da53..eb551ae 100644 --- a/tests/punch_test.c +++ b/tests/punch_test.c @@ -234,9 +234,34 @@ static void punch_new_fx(void) printf("black keys: KILL LOW / MID / HIGH, REWIND, OCT UP, FLANGER, AUTO-PAN, FREEZE, LOOP 8T, MONO, FADE OUT do what they say PASS\n"); } +/* (2.7.2) GLO > MASTER 2 > FADE: the wet gain ramps in / out faster or slower. The blocks to reach full wet when an + * effect is engaged: 0 is ~2 (the old anti-click fade), 15 is much slower (punch.c pstep) */ +static uint32_t fade_blocks(int32_t fxfade) +{ + int32_t l[CTL], r[CTL]; + uint32_t b, i; + beat_setup(); + song.playing = 1; + song.g[G_FXFADE] = fxfade; + punch.req = PX_LPF; /* engage a filter: target full */ + for (b = 0; b < 3000u; b++) { + for (i = 0; i < CTL; i++) l[i] = r[i] = 8000; + punch_process(l, r, CTL); + if (punch.g >= 32767) break; + } + punch.req = -1; + song.g[G_FXFADE] = 0; + return b; +} + int main(int argc, char **argv) { setvbuf(stdout, 0, _IONBF, 0); + { + uint32_t f0 = fade_blocks(0), f15 = fade_blocks(15); + printf("punch: FX FADE: blocks to full wet, fade 0 = %u, fade 15 = %u\n", f0, f15); + assert(f0 <= 3u && f15 > 40u * f0 && f15 < 3000u); /* (2.7.2) a higher FADE ramps in much slower */ + } uint32_t fx, i, b, on = FS / CTL, off = on + FS / 2u / CTL; /* held from 1 s to 1.5 s */ FILE *f = argc > 1 ? fopen(argv[1], "wb") : 0; for (fx = 0; fx < PUNCH_NFX; fx++) { diff --git a/tests/recovery_test.c b/tests/recovery_test.c index 50139ad..f981234 100644 --- a/tests/recovery_test.c +++ b/tests/recovery_test.c @@ -40,7 +40,9 @@ static int ota_session(void) return -13; /* failed update must leave rescue available for another try */ } static void fm1_input_init(void) { fm1_in.buttons = 0; } -static void fm1_input_scan(void) { scans++; ticks += 24000u; fm1_in.buttons = input_buttons; } +static unsigned keys_on, scans_before_on; +#define RECOVERY_KEYS_ON() (keys_on++, scans_before_on += scans) /* (2.7.2: PA2 driven low before the scan) */ +static void fm1_input_scan(void) { scans++; ticks += 24000u; fm1_in.buttons = keys_on ? input_buttons : 0u; } static uint32_t fl_jedec_ram(void) { jedec_reads++; return jedec; } static void lcd_init(void) { lcd_calls++; } static void lcd_fill(int x, int y, int w, int h, int c) { (void)x;(void)y;(void)w;(void)h;(void)c; } @@ -67,6 +69,7 @@ int main(void) assert(bootguard_manual(1) && !bootguard_manual(0) && !bootguard_manual(2) && !bootguard_manual(3)); input_buttons = 1; assert(recovery_key()); + assert(keys_on == 1 && scans_before_on == 0); /* (2.7.2) the matrix powered (PA2 low) before the first scan */ input_buttons = 3; assert(!recovery_key()); input_buttons = 0; assert(!recovery_key()); assert(scans >= 150); diff --git a/tests/seq2_test.c b/tests/seq2_test.c index b4aa0ec..55862df 100644 --- a/tests/seq2_test.c +++ b/tests/seq2_test.c @@ -603,6 +603,74 @@ static void t_mclk(void) mi_r = mi_w; } +/* (2.7.2) a master at a steady 140 whose pulses come a few ms early or late (a computer, USB): BPM shows 140, not + * 139 / 140 / 141 by turns; a master at 139.5 shows one value; a tempo ramp and a jump are still followed */ +static void mclk_jrun(double *t, uint32_t *np, double bpm, double until, uint32_t *seen, uint32_t *changes) +{ + static uint32_t rng = 12345u; + double per = 60000.0 / bpm / 24.0; + int32_t last = song.g[G_BPM]; + while (*t < until) { + for (;;) { /* pulse n at n * per, +-2.5 ms (not adding up) */ + double at; + rng = rng * 1103515245u + 12345u; + at = (double)*np * per + ((double)((rng >> 16) % 51u) - 25.0) / 10.0; + if (at > *t) + break; + mclk_push(0xF80Fu); + (*np)++; + } + fm1_ms = (uint32_t)*t; + run_block(); + if (seen && song.g[G_BPM] >= 100 && song.g[G_BPM] < 200) + seen[song.g[G_BPM] - 100] = 1; + if (changes && song.g[G_BPM] != last) + (*changes)++; + last = song.g[G_BPM]; + *t += (double)CTL * 1000.0 / FS; + } +} +static void t_mclk_jitter(void) +{ + double t = 0; + uint32_t np = 0, seen[100], k, n, ch = 0; + reset(90); + mi_r = mi_w; + song.g[G_SYNC] = 1; + mclk_jrun(&t, &np, 140.0, 2000.0, 0, 0); /* settle (the first beats) */ + memset(seen, 0, sizeof seen); + mclk_jrun(&t, &np, 140.0, 62000.0, seen, &ch); /* a minute at 140 */ + for (n = 0, k = 0; k < 100u; k++) + n += seen[k]; + printf("seq2: 140 +-2.5 ms: %u value(s), %u change(s), BPM %d\n", n, ch, song.g[G_BPM]); + check(n == 1u && seen[40] && ch == 0u, "MIDI clock (2.7.2): a steady 140 with jittery pulses shows 140, steady"); + { /* the master at 139.5 (between two): one value for a minute */ + double t0 = t; + np = (uint32_t)(t / (60000.0 / 139.5 / 24.0)) + 1u; + mclk_jrun(&t, &np, 139.5, t0 + 3000.0, 0, 0); + ch = 0; + mclk_jrun(&t, &np, 139.5, t + 60000.0, 0, &ch); + check(ch == 0u && (song.g[G_BPM] == 139 || song.g[G_BPM] == 140), + "MIDI clock (2.7.2): a master at 139.5 shows one value, steady"); + } + { /* a ramp 140 -> 146 over 16 beats, then a jump to 100: followed */ + double bpm = 140.0; + np = (uint32_t)(t / (60000.0 / bpm / 24.0)) + 1u; + for (k = 0; k < 16u; k++, bpm += 6.0 / 16.0) { + np = (uint32_t)(t / (60000.0 / bpm / 24.0)) + 1u; + mclk_jrun(&t, &np, bpm, t + 60000.0 / bpm, 0, 0); + } + mclk_jrun(&t, &np, 146.0, t + 3000.0, 0, 0); + check(song.g[G_BPM] >= 145 && song.g[G_BPM] <= 146, "MIDI clock (2.7.2): a ramp to 146 is followed"); + np = (uint32_t)(t / (60000.0 / 100.0 / 24.0)) + 1u; + mclk_jrun(&t, &np, 100.0, t + 1500.0, 0, 0); + check(song.g[G_BPM] == 100, "MIDI clock (2.7.2): a jump to 100 is taken within two beats"); + } + song.g[G_SYNC] = 0; + mi_r = mi_w; + fm1_ms = (uint32_t)t + 1000u; /* (the master gone) */ +} + /* the REC screen's MODE and START (SLOOP 2.3): an empty project records at the tempo set (TEMPO) or * takes it from the playing (FREE); COUNT: PLAY clicks one bar, then the loop and the recording start */ static void t_recmode(void) @@ -670,6 +738,24 @@ static void t_recmode(void) /* SLOOP 2.4 fixes: a MIDI START cuts a count-in short (the master counts); swing is off on the * triplet grids; a DIV change in the first beat after PLAY does not lose a step */ +/* (2.7.2) menu AUDIO > FILTER RESO: the track filter's SVF gains resonance (fx.c tflt_reso -> dsp.c tsvf_coef), and the + * setting rides in spare bits of the settings object (project.c midi_part), transparent at 0 */ +static void t_filt_reso(void) +{ + tsvf_t c0, c1; + int32_t z0[2] = {0, 0}, z1[2] = {0, 0}, i, p0 = 0, p1 = 0, x = 10000; + tsvf_coef(&c0, 60 << 8, 40); /* the clean filter, as the track filter always was (FILTER RESO 0) */ + tsvf_coef(&c1, 60 << 8, 40 + 10 * 7); /* FILTER RESO 10 (fx.c tflt_reso: 40 + 10 * 7 = 110) */ + for (i = 0; i < 400; i++) { /* a step in: a resonant filter overshoots and rings, a clean one does not */ + int32_t y0 = tsvf_lp(&c0, x, &z0[0], &z0[1]); + int32_t y1 = tsvf_lp(&c1, x, &z1[0], &z1[1]); + if (y0 > p0) p0 = y0; + if (y1 > p1) p1 = y1; + } + check(p1 > x + x / 4 && p0 < x + x / 10, "FILTER RESO (2.7.2): resonance makes the track filter overshoot a step; clean (40) barely does"); + /* the setting's persistence (project.c midi_part) is checked in fm6_test (the full build has panel.c and project.c) */ +} + static void t_fixes24(void) { uint32_t k, i, bpb = (uint32_t)((double)FS * 60.0 / 100.0 / CTL + 0.5), n0; @@ -951,6 +1037,32 @@ static void t_midifix(void) check(ok, "2.6: MIDI Program Change: queued for the track its channel plays (ch 2: track 2, ch 10: drums); " "OTHER = OFF / IN = CLOCK: none"); } + mf_prep(); /* (2.7.2) Bank Select (CC 0) before a Program Change: pc_bank */ + pc_req[0] = pc_req[1] = pc_req[2] = pc_req[3] = 0; + pc_bank[0] = pc_bank[1] = pc_bank[2] = pc_bank[3] = 0; + { + int ok; + mf_cc(1, 0, 1); /* ch 2 (track 2): Bank Select = 1 */ + mclk_push(0x0Cu | (0xC0u | 1u) << 8 | 10u << 16); /* then Program Change 10 */ + run_block(); + ok = pc_req[1] == 11u && pc_bank[1] == 1u; + pc_req[1] = 0; /* the bank stays latched on the channel */ + mf_cc(1, 0, 8); /* Bank 8 (the user-preset bank) */ + mclk_push(0x0Cu | (0xC0u | 1u) << 8 | 5u << 16); + run_block(); + ok &= pc_req[1] == 6u && pc_bank[1] == 8u; + pc_req[1] = 0; + mclk_push(0x0Cu | (0xC0u | 1u) << 8 | 3u << 16); /* a later PC keeps the latched bank */ + run_block(); + ok &= pc_req[1] == 4u && pc_bank[1] == 8u; + pc_req[1] = 0; pc_bank[1] = 0; + mf_cc(1, 0, 0); /* bank back to 0: the old behaviour */ + mclk_push(0x0Cu | (0xC0u | 1u) << 8 | 7u << 16); + run_block(); + ok &= pc_req[1] == 8u && pc_bank[1] == 0u; + pc_req[1] = 0; pc_bank[1] = 0; + check(ok, "2.7.2: MIDI Bank Select (CC 0) latches per channel and a Program Change carries it (pc_bank)"); + } mf_prep(); /* a channel changed with a note held */ song.sel = 0; mf_on(1, 70), run_block(), run_block(); @@ -1293,6 +1405,178 @@ static void t_overdub(void) song.rec = 0; } +/* SLOOP 2.7.1 (a YouTube comment): several notes held while recording, on a POLY part. Each goes on until its own key is let + * go: "hit record, hold a note, play another one on top" used to end the first one with the second */ +typedef struct { uint8_t t; uint8_t n; uint8_t a, b, c; uint8_t cont; } want_t; /* time, n, notes, CONT bits */ +static int steps_are(const track_t *t, const want_t *w, uint32_t nw) +{ + uint32_t i, ok = 1; + for (i = 0; i < nw; i++) { + const step_t *st = &t->step[i]; + uint32_t good = st->time == w[i].t; + if (good && w[i].t == ST_NOTE) + good = st->n == w[i].n && st->note[0] == w[i].a && (w[i].n < 2u || st->note[1] == w[i].b) && + (w[i].n < 3u || st->note[2] == w[i].c) && ((st->flags & SF_CONT_ALL) / SF_CONT0) == w[i].cont; + if (!good) { + printf("seq2: step %u: time %u n %u notes %u %u %u cont %x\n", i + 1, st->time, st->n, st->note[0], st->note[1], + st->note[2], (st->flags & SF_CONT_ALL) / SF_CONT0); + ok = 0; + } + } + return (int)ok; +} +static void rec_go_to(track_t *t, uint32_t step, double frac) /* the transport onto step (0-based), frac of it */ +{ + double sb = (double)FS * 60.0 / 120.0 / 4.0 / CTL; + uint32_t into, slen, k; + while (trk_grid(t, &into, &slen) != step) run_block(); + for (k = 0; k < (uint32_t)(sb * frac); k++) run_block(); +} +static void rec_start16(track_t *t) +{ + reset(120); + t->p[P_VOICE] = V_POLY; + t->p[P_SLEN] = 16; + song.sel = 0; + song.rec = 1u; + transport_req = 1; + run_block(); +} +static void t_hold2(void) +{ + track_t *t = &trk[0]; + int ok; + enum { N = ST_NOTE, T = ST_TIE, R = ST_REST }; + { /* note 1 held, note 2 on top and let go first: note 1 goes on to its own end */ + static const want_t W[16] = {{N, 1, 60, 0, 0, 0}, {T}, {T}, {T}, {N, 2, 60, 64, 0, 1}, {T}, {T}, {T}, + {N, 1, 60, 0, 0, 1}, {T}, {T}, {T}, {R}, {R}, {R}, {R}}; + int32_t a; + uint32_t into, slen; + rec_start16(t); + rec_go_to(t, 0, 0.2); input_on(t, 60, 100); + rec_go_to(t, 4, 0.3); input_on(t, 64, 100); + rec_go_to(t, 8, 0.3); input_off(t, 64); + rec_go_to(t, 12, 0.3); input_off(t, 60); + song.rec = 0; + ok = steps_are(t, W, 16); + while (trk_grid(t, &into, &slen) != 16u + 2u) run_block(); + a = voice_of(t, 60); + rec_go_to(t, 16 + 6, 0.5); + ok &= a >= 0 && voice_of(t, 60) == a && voice_of(t, 64) >= 0; + rec_go_to(t, 16 + 10, 0.5); + ok &= voice_of(t, 60) == a && voice_of(t, 64) < 0; + rec_go_to(t, 16 + 13, 0.5); + ok &= voice_of(t, 60) < 0; + check(ok, "2.7.1 recording: hold a note, play another on top, let it go: the first goes on (one voice) to its own end"); + transport_req = 2; run_block(); + } + { /* note 1 let go first: note 2 goes on alone */ + static const want_t W[12] = {{N, 1, 60, 0, 0, 0}, {T}, {T}, {T}, {N, 2, 60, 64, 0, 1}, {T}, {N, 1, 64, 0, 0, 1}, {T}, + {T}, {T}, {R}, {R}}; + rec_start16(t); + rec_go_to(t, 0, 0.2); input_on(t, 60, 100); + rec_go_to(t, 4, 0.3); input_on(t, 64, 100); + rec_go_to(t, 6, 0.3); input_off(t, 60); + rec_go_to(t, 10, 0.3); input_off(t, 64); + song.rec = 0; + check(steps_are(t, W, 12), "2.7.1 recording: the first let go first: it ends there, the second goes on to its end"); + transport_req = 2; run_block(); + } + { /* a chord built note by note, all let go together */ + static const want_t W[10] = {{N, 1, 60, 0, 0, 0}, {T}, {N, 2, 60, 64, 0, 1}, {T}, {N, 3, 60, 64, 67, 3}, {T}, {T}, {T}, + {R}, {R}}; + rec_start16(t); + rec_go_to(t, 0, 0.2); input_on(t, 60, 100); + rec_go_to(t, 2, 0.3); input_on(t, 64, 100); + rec_go_to(t, 4, 0.3); input_on(t, 67, 100); + rec_go_to(t, 8, 0.2); input_off(t, 60); input_off(t, 64); input_off(t, 67); + song.rec = 0; + check(steps_are(t, W, 10), "2.7.1 recording: a chord built note by note: each note starts on its step, all held to the end"); + transport_req = 2; run_block(); + } + { /* note 2 played late in a step (it goes into the next one, not tied yet) */ + static const want_t W[12] = {{N, 1, 60, 0, 0, 0}, {T}, {T}, {T}, {T}, {N, 2, 60, 64, 0, 1}, {T}, {N, 1, 60, 0, 0, 1}, + {T}, {T}, {R}, {R}}; + rec_start16(t); + rec_go_to(t, 0, 0.2); input_on(t, 60, 100); + rec_go_to(t, 4, 0.85); input_on(t, 64, 100); + rec_go_to(t, 7, 0.3); input_off(t, 64); + rec_go_to(t, 10, 0.3); input_off(t, 60); + song.rec = 0; + check(steps_are(t, W, 12), "2.7.1 recording: the second note played late in a step (into the next): the first goes on"); + transport_req = 2; run_block(); + } + { /* 2.7.2: LEGATO, a note played over the one held: recorded legato, played back legato (no new attack) */ + static const want_t W[10] = {{N, 1, 48, 0, 0, 0}, {T}, {T}, {T}, {N, 1, 55, 0, 0, 0}, {T}, {T}, {T}, {R}, {R}}; + uint32_t into, slen, st1; + rec_start16(t); + t->p[P_VOICE] = V_LEGATO; + t->p[P_ATK] = 30; /* (an attack of some length: a new one shows as stage 1) */ + t->p[P_SUS] = 100; + t->p[P_GLIDE] = 0; + rec_go_to(t, 0, 0.1); input_on(t, 48, 100); + rec_go_to(t, 3, 0.9); input_on(t, 55, 100); /* (into step 5: the first still held there) */ + rec_go_to(t, 5, 0.3); input_off(t, 48); + rec_go_to(t, 8, 0.2); input_off(t, 55); + song.rec = 0; + ok = steps_are(t, W, 10) && (t->step[4].flags & SF_LEG) && !(t->step[0].flags & SF_LEG); + check(ok, "2.7.2 recording LEGATO: a note played over the held one is marked legato (SF_LEG), the first is not"); + while (trk_grid(t, &into, &slen) != 16u + 3u) run_block(); + rec_go_to(t, 16 + 3, 0.9); + st1 = t->v[0].stage; + while (trk_grid(t, &into, &slen) != 16u + 4u) run_block(); + { /* (a new attack: stage 1 and the envelope up to its peak; legato: it stays at the sustain level) */ + int32_t e1 = t->v[0].env, emax = 0; + int b, att = 0; + for (b = 0; b < 6; b++) { + run_block(); + att |= t->v[0].stage == 1u; + if (t->v[0].env > emax) + emax = t->v[0].env; + } + ok = st1 == 2u && !att && emax <= e1 && t->v[0].gate && t->v[0].note == 55 && t->slide_glide == 0; + } + check(ok, "2.7.2 playback: the legato note takes over, the envelope goes on (no new attack, no glide of its own)"); + rec_go_to(t, 16 + 9, 0.5); + check(!t->v[0].gate, "2.7.2 playback: the legato note ends where it was let go"); + transport_req = 2; run_block(); + } + { /* 2.7.2: LEGATO, the second pressed early in a step the first is already held into (a TIE): legato too */ + rec_start16(t); + t->p[P_VOICE] = V_LEGATO; + rec_go_to(t, 0, 0.1); input_on(t, 48, 100); + rec_go_to(t, 4, 0.2); input_on(t, 55, 100); + rec_go_to(t, 5, 0.3); input_off(t, 48); + rec_go_to(t, 8, 0.2); input_off(t, 55); + song.rec = 0; + check(t->step[3].time == ST_TIE && t->step[4].time == ST_NOTE && t->step[4].note[0] == 55 && + (t->step[4].flags & SF_LEG), "2.7.2 recording LEGATO: over the held note early in a step it was tied into: legato"); + transport_req = 2; run_block(); + } + { /* 2.7.2: MONO, the first let go before the second: not legato */ + rec_start16(t); + t->p[P_VOICE] = V_MONO; + rec_go_to(t, 0, 0.1); input_on(t, 48, 100); + rec_go_to(t, 2, 0.3); input_off(t, 48); + rec_go_to(t, 4, 0.1); input_on(t, 55, 100); + rec_go_to(t, 6, 0.3); input_off(t, 55); + song.rec = 0; + check(t->step[4].time == ST_NOTE && t->step[4].note[0] == 55 && !(t->step[4].flags & SF_LEG), + "2.7.2 recording MONO: a note played after the first was let go is not legato"); + transport_req = 2; run_block(); + } + { /* 2.7.2: POLY over a held note: as 2.7.1 (both go on), never SF_LEG */ + rec_start16(t); + rec_go_to(t, 0, 0.1); input_on(t, 48, 100); + rec_go_to(t, 4, 0.1); input_on(t, 55, 100); + rec_go_to(t, 6, 0.3); input_off(t, 48); input_off(t, 55); + song.rec = 0; + check(!(t->step[4].flags & SF_LEG) && t->step[4].n == 2, "2.7.2 recording POLY: over a held note, both go on (no SF_LEG)"); + transport_req = 2; run_block(); + } + song.rec = 0; +} + /* SLOOP 2.4: parameter locks. A lock on P_E0 at step 3 sets t->p[P_E0] for that step, the base is back at * step 4; a knob turned during the locked step is kept as the new base; STOP restores; a lock on a parameter * that is not lockable is refused */ @@ -1688,6 +1972,39 @@ static void t_midicc(void) check(song.g[G_DRLVL] == 0 && song.g[G_DRREV] == 127 && song.g[G_DRDLY] == 64 && TDRUM->p[P_PAN] == -64 && TDRUM->p[P_TFLT] == 63 && TDRUM->p[P_ATK] == before[P_ATK] && TDRUM->p[P_DLY] == before[P_DLY], "2.5: the drum channel: 7 / 91 / 94 = DRUMS LVL / REV / DLY, 10 PAN, 74 FILTER; 73 ignored"); + { /* 2.7.1: CC 11 EXPRESSION, a gain over the LEVEL (the mix untouched); CC 121 full again */ + int32_t o[CTL * 2], pk[3] = {0, 0, 0}; + uint32_t ph, j, lv = song.g[G_DRLVL]; + a->p[P_LEVEL] = 100, a->p[P_ATK] = 0, a->p[P_SUS] = 127, a->p[P_MUTE] = 0; + a->p[P_E0 + 4] = ENGINES[0]->edit[4].max, a->p[P_TFLT] = 0, a->p[P_REV] = a->p[P_DLY] = a->p[P_CHOR] = 0; /* (CUT open)*/ + mclk_push(0x09u | 0x90u << 8 | 60u << 16 | 100u << 24); /* ch 1: a held C4 */ + for (j = 0; j < 60u; j++) run_block(); + for (ph = 0; ph < 3u; ph++) { + if (ph) { cc_push(0, 11, ph == 1u ? 64u : 0u); for (j = 0; j < 20u; j++) run_block(); } + for (j = 0; j < 40u; j++) { + uint32_t q; + mix_block(o, CTL); + for (q = 0; q < 2u * CTL; q++) + pk[ph] = o[q] > pk[ph] ? o[q] : -o[q] > pk[ph] ? -o[q] : pk[ph]; + } + } + if (!(pk[0] > 2000 && pk[1] * 100 > pk[0] * 19 && pk[1] * 100 < pk[0] * 33 && pk[2] * 100 < pk[0])) + printf(" CC 11 peaks: full %d, 64 %d, 0 %d\n", (int)pk[0], (int)pk[1], (int)pk[2]); + check(pk[0] > 2000 && pk[1] * 100 > pk[0] * 19 && pk[1] * 100 < pk[0] * 33 && pk[2] * 100 < pk[0] && + a->p[P_LEVEL] == 100 && ex_off[0] == 127u, + "2.7.1: CC 11 on ch 1: track 1 at 64 about -12 dB, at 0 silent, its LEVEL untouched"); + cc_push(drch, 11, 0); cc_push(1, 11, 100); + run_block(); run_block(); + check(ex_off[TRK_DRUM] == 127u && song.g[G_DRLVL] == (int16_t)lv && ex_off[1] == 27u && expr_gain(25400, TRK_DRUM) == 0, + "2.7.1: CC 11 on the drum channel: the drums' expression (DRUMS LVL untouched); ch 2: track 2's"); + cc_push(0, 121, 0); cc_push(drch, 121, 0); cc_push(1, 121, 0); + run_block(); run_block(); + check(!ex_off[0] && !ex_off[1] && !ex_off[TRK_DRUM] && expr_gain(4096, 0) == 4096, + "2.7.1: CC 121 (reset all controllers): the expression full again"); + mclk_push(0x09u | 0x80u << 8 | 60u << 16); + for (j = 0; j < 40u; j++) run_block(); + a->p[P_LEVEL] = 127; /* (as the CCs above left it) */ + } song.g[G_DRDLY] = 0; song.g[G_ROUTE] = 1; cc_push(0, 7, 55); @@ -1817,11 +2134,14 @@ int main(void) t_micro(); t_recquant(); t_overdub(); + t_hold2(); t_plock(); t_fill(); t_chain(); t_recmode(); t_mclk(); + t_mclk_jitter(); + t_filt_reso(); t_fixes24(); t_longdiv(); t_midiout(); diff --git a/tests/uac_test.c b/tests/uac_test.c index 0480357..0d0dc6d 100644 --- a/tests/uac_test.c +++ b/tests/uac_test.c @@ -77,6 +77,7 @@ static void test_descriptors(void) check(RATES == 0 ? "bcdDevice bumped for the audio input at 44.1 / 48 kHz (x.2x)" : RATES == 1 ? "bcdDevice of the audio input at 44.1 only (x.1x, as 2.4)" : "bcdDevice of 48 kHz only (x.3x)", (dv[12] & 0xF0u) == (RATES == 0 ? 0x20u : RATES == 1 ? 0x10u : 0x30u) && dv[13] == 3); + check("bcdDevice +0.08: the AC collection's order of 2.7.2 (the audio streaming interface first)", (dv[12] & 0x0Eu) == 0x08u); check(CDC_SHOWN ? "device class misc / IAD (EF 02 01)" : "device class 0 (per interface)", CDC_SHOWN ? dv[4] == 0xEF && dv[5] == 2 && dv[6] == 1 : dv[4] == 0); check("configuration: type 2, wTotalLength = the bytes sent", c[1] == 2 && total == n); @@ -166,7 +167,8 @@ static void test_descriptors(void) } if (cur_if >= 0 && got_eps != cur_neps) eps_ok = 0; - coll_ok = ncoll == 2; + coll_ok = ncoll == 2 && if_sub[coll[0]] == 2 && if_sub[coll[1]] == 3; /* (2.7.2: audio streaming first, for + * macOS up to 15; usb.c, the AC header) */ for (i = 0; i < ncoll && i < sizeof coll; i++) if (coll[i] >= 16 || if_class[coll[i]] != 1 || (if_sub[coll[i]] != 2 && if_sub[coll[i]] != 3)) coll_ok = 0; diff --git a/tests/ui_pages_test.c b/tests/ui_pages_test.c index 9252ce9..82bf02f 100644 --- a/tests/ui_pages_test.c +++ b/tests/ui_pages_test.c @@ -69,6 +69,7 @@ static void section_load(uint32_t s) { sec_loads++; live_sec = (int8_t)s; } static int up_used(uint32_t k) { return k < 2; } static int up_load(uint32_t k) { (void)k; return 0; } static int up_load_to(track_t *t, uint32_t k) { (void)t; (void)k; return 0; } +static int up_arp_of(uint32_t k, int16_t *a) { (void)k; (void)a; return 1; } static uint32_t up_count(void) { return 2; } static uint32_t up_nth(uint32_t n) { return n; } static uint32_t up_rank(uint32_t s) { return s; } @@ -174,6 +175,20 @@ int main(int argc, char **argv) ui.menu = 2; ui.force = 1; frame(); ppm("page-about"); ui.menu = 0; go_home(); ui.force = 1; frame(); ppm("page-tracks"); open_family(FAM_ENV); ui.force = 1; ui.hot_col = 1; ui.hot_t = 30; frame(); ppm("page-env"); + open_family(FAM_ARP); ui.force = 1; frame(); ppm("page-arp"); + check(big_page(cur_page()) && !strcmp(cur_page()->title, "ARP"), "ARP (2.7.2): page 1 shows its values large, as ARP 2"); + { /* 2.7.2 (a YouTube comment): FX > FILTER on the drum track: the track's filter, not "DRUM TRACK" */ + uint32_t j, sel = song.sel; + int16_t f0 = TDRUM->p[P_TFLT]; + uint8_t lp = ui.lock_par; + for (j = 0; j < NPAGES; j++) if (!strcmp(PAGES[j].title, "FILTER") && PAGES[j].fam == FAM_FX) break; + song.sel = TRK_DRUM; + check(j < NPAGES && page_for_drum(&PAGES[j]), "FX > FILTER (2.7.2): a page of the drum track (its filter)"); + ui.page = (uint8_t)j; ui.home = 0; ui.force = 1; frame(); + encs[panel.enc[EN_K1]] = 5; frame(); + check(TDRUM->p[P_TFLT] == f0 + 5, "FX > FILTER on the drum track: KNOB 1 turns the drum track's FILT"); + TDRUM->p[P_TFLT] = f0; song.sel = (uint8_t)sel; ui.lock_par = lp; go_home(); frame(); + } open_family(FAM_EDIT); ui.force = 1; frame(); ppm("page-edit"); open_family(FAM_FX); ui.force = 1; frame(); ppm("page-fx"); open_family(FAM_SEQ); ui.force = 1; frame(); ppm("page-step"); @@ -245,6 +260,18 @@ int main(int argc, char **argv) encs[panel.enc[EN_K1]] = -10; frame(); check(song.g[G_FILT] < 0, "FX + KNOB 1: the filter (low-pass)"); encs[panel.enc[EN_K4]] = 12; frame(); check(TSEL->p[P_TFLT] > 0 && song.g[G_FILT] < 0, "FX + KNOB 4: the selected track's FILTER (high-pass)"); ui.force = 1; frame(); ppm("layer-punch-trkflt"); + { /* (2.7.2) SELECT in the FX layer sets the punch-in FX fade (not the tempo); shown top right */ + int16_t bpm0 = song.g[G_BPM]; + song.g[G_FXFADE] = 0; + encs[panel.enc[EN_SELECT]] = 5; frame(); + check(song.g[G_FXFADE] == 5 && song.g[G_BPM] == bpm0, "FX + SELECT (2.7.2): the punch-in FX fade, not the tempo"); + encs[panel.enc[EN_SELECT]] = 99; frame(); + check(song.g[G_FXFADE] == 15, "FX + SELECT: the fade stops at 15"); + encs[panel.enc[EN_SELECT]] = -99; frame(); + check(song.g[G_FXFADE] == 0 && song.g[G_BPM] == bpm0, "FX + SELECT: and down to 0 (tempo untouched)"); + song.g[G_FXFADE] = 6; ui.force = 1; frame(); ppm("layer-punch-fade"); /* (the top-right readout)*/ + song.g[G_FXFADE] = 0; + } TSEL->p[P_TFLT] = 0; release(B_FX); check(cur_page()->scope == SC_TRK && ui.layer == LY_PLAY, "FX used then let go: no FX page"); song.g[G_DUST] = 0; song.g[G_FILT] = 0; @@ -297,6 +324,22 @@ int main(int argc, char **argv) "step 5 held + KNOB 2 / 3: hard, x3"); key(0); check(!dstep_has(&TDRUM->dstep[0], 2), "step 1 again: off"); release(B_SEQ); check(ui.layer == LY_PLAY && !on_drum_page(), "SEQ used then let go: no page change"); + { /* 2.7.1: the drum track, ARP (or any button's pages) tapped, then SEQ tapped: the DRUMS screen, as from TRACKS */ + static const uint8_t FROM[] = {B_ARP, B_ENV, B_LFO, B_FX, B_GLO, B_SCL}; + uint32_t i; + int ok = 1; + for (i = 0; i < sizeof FROM; i++) { + go_home(); frame(); + tap(FROM[i]); frames(2); + ok &= !on_drum_page(); + tap(B_SEQ); frames(2); + ok &= on_drum_page(); + if (!on_drum_page()) + printf("ui: drum track, button %u then SEQ: page %s\n", (unsigned)FROM[i], ui.home ? "HOME" : cur_page()->title); + } + go_home(); frame(); + check(ok, "drum track (2.7.1): ARP, ENV, LFO, FX, GLO or SEL tapped, then SEQ: the DRUMS screen"); + } /* ---- EDIT: undo / redo, erase, length */ press(B_EDIT); frames(10); @@ -515,6 +558,7 @@ int main(int argc, char **argv) /* ---- the drum screen */ song.sel = TRK_DRUM; studio_open(SC_DRUM); ui.force = 1; frames(16); /* (after SAVE: the knobs quiet, #39) */ check(on_drum_page(), "the drum screen"); + drum_lane = 0; /* (2.7.1: the sound picked is the SEQ layer's too: the snare above) */ encs[panel.enc[EN_K3]] = 1; frame(); check(dstep_has(&TDRUM->dstep[0], 0), "DRUMS: KNOB 3 adds the kick on step 1"); encs[panel.enc[EN_K4]] = -1; frame(); check(dstep_lvl(&TDRUM->dstep[0], 0) == LV_SOFT, "DRUMS: KNOB 4 softer"); encs[panel.enc[EN_K1]] = 100; encs[panel.enc[EN_K2]] = 100; frame(); @@ -675,9 +719,28 @@ int main(int argc, char **argv) tap(B_OCTUP); check(usb_serial == 0u && ui.menu == 1, "menu USB SERIAL: OCT+ toggles back to OFF"); #else - check(MS_FIRST[MS_AUDIO + 1] - MS_FIRST[MS_AUDIO] == 3u && MI_RATE == MI_USB + 1, - "2.7: no USB SERIAL in the FM-1's build (FELUCCA_CDC 0): AUDIO is LOWCUT, USB AUDIO, USB RATE"); + check(MS_FIRST[MS_AUDIO + 1] - MS_FIRST[MS_AUDIO] == 4u && MI_RATE == MI_USB + 1 && MI_FRESO == MI_RATE + 1, + "2.7.2: FM-1 build AUDIO is LOWCUT, USB AUDIO, USB RATE, FILTER RESO (no USB SERIAL: FELUCCA_CDC 0)"); #endif + { /* (2.7.2) menu AUDIO > FILTER RESO: 0 (OFF) .. 10, its knob steps and stops, OCT+ wraps, read back (fx.c) */ + uint16_t col; + uint32_t j; + int ok; + flt_reso = 0; + ui.menu = 1; ui.menu_sel = MI_FRESO; ui.force = 1; frame(); + ok = !strcmp(mi_value(MI_FRESO, &col), "OFF"); + encs[panel.enc[EN_K1 + mi_row(ui.menu_sel)]] = 1; frame(); /* its knob (KNOB 4) right */ + ok &= flt_reso == 1u && !strcmp(mi_value(MI_FRESO, &col), "1"); + ppm("menu-freso"); + for (j = 0; j < 20; j++) { encs[panel.enc[EN_K1 + mi_row(ui.menu_sel)]] = 1; frame(); } + ok &= flt_reso == 10u; /* stops at 10 */ + tap(B_OCTUP); /* OCT+ wraps 10 -> 0 */ + ok &= flt_reso == 0u; + for (j = 0; j < 3; j++) { encs[panel.enc[EN_K1 + mi_row(ui.menu_sel)]] = -1; frame(); } + ok &= flt_reso == 0u; /* stops at 0 going down */ + check(ok, "menu FILTER RESO (2.7.2): OFF..10, knob steps and stops, OCT+ wraps"); + ui.menu = 0; go_home(); + } { /* 2.7: your theme (the editor's Theme page): checked, then MENU > COLOR after MONO, by its name */ theme_t th; int ok = 1, k; @@ -747,6 +810,11 @@ int main(int argc, char **argv) ui.force = 1; frame(); ppm("menu-theme"); ui.menu = 0; go_home(); ui.force = 1; frame(); frame(); ppm("tracks-theme"); /* (a page in the theme) */ open_family(FAM_EDIT); ui.force = 1; frame(); frame(); ppm("edit-theme"); + studio_open(SC_SONG); ui.force = 1; frame(); frame(); ppm("song-theme"); + check(PAGES[ui.page].scope == SC_SONG && swap16(screen[179 * 240 + 10]) == th.trk[0] && + swap16(screen[179 * 240 + 190]) == th.trk[3], + "theme (2.7.2): the SONG screen's sections in the theme's track colours"); + go_home(); { /* a light theme (the editor's Light <-> dark on GREEN: the five the other way, white, a black accent): * the same pages, to look at (build/host/*-light.ppm) */ theme_t l = th, keep = th; @@ -783,7 +851,7 @@ int main(int argc, char **argv) int ok = 1; ui.menu = 0; go_home(); frame(); open_family(FAM_SEQ); frame(); - while (strcmp(PAGES[ui.page].title, "STEP")) { open_family(FAM_SEQ); frame(); } + while (strcmp(PAGES[ui.page].title, "NOTES")) { open_family(FAM_SEQ); frame(); } k1 = page_pos(&n1); open_family(FAM_SEQ); frame(); ok &= !strcmp(PAGES[ui.page].title, "PATTERN"); @@ -833,6 +901,31 @@ int main(int argc, char **argv) } frame(); check(ok, "ARP (2.7): a preset loaded while it runs keeps its settings and notes; arp OFF: the preset's arp"); + if (eng < NENGINES) { /* 2.7.1: the arp 8BIT ARP brought goes with it; one you changed stays */ + uint8_t er = t->eng_req, e0 = t->engine; + int ok2 = 1; + t->eng_req = t->engine = (uint8_t)eng; + apply_preset_to(t, pi); /* 8BIT ARP: its arp on */ + ok2 &= t->p[P_AMODE] == 1; + apply_preset_to(t, (pi + 1u) % ENGINES[eng]->npresets); /* the next sound: its own arp, OFF */ + frame(); frame(); + ok2 &= t->p[P_AMODE] == 0 && t->p[P_ARATE] == TP[P_ARATE].def && t->p[P_AGATE] == TP[P_AGATE].def; + apply_preset_to(t, pi); /* 8BIT ARP again, then its RATE turned: the arp is yours now */ + t->p[P_ARATE] = 4; + apply_preset_to(t, (pi + 1u) % ENGINES[eng]->npresets); + frame(); frame(); + ok2 &= t->p[P_AMODE] == 1 && t->p[P_ARATE] == 4; + t->p[P_AMODE] = 1, t->p[P_ARATE] = 3; /* an arp turned on over a sound without one: stays */ + apply_preset_to(t, pi); + ok2 &= t->p[P_AMODE] == 1 && t->p[P_ARATE] == 3; + t->p[P_AMODE] = 0, t->p[P_AHOLD] = 0, t->nheld = 0; + t->eng_req = er, t->engine = e0; + apply_preset_to(t, 0); + frame(); + if (!ok2) + printf("ui: arp after 8BIT ARP: MODE %d RATE %d\n", t->p[P_AMODE], t->p[P_ARATE]); + check(ok2, "ARP (2.7.1): the next sound replaces the arp 8BIT ARP brought; an arp you turned on or changed goes on"); + } } { /* 2.7: REMOTE: the buttons held over MIDI become the panel's (the debounce reads them as closed) */ uint32_t pb = 1u << panel.btn[B_PLAY], hb = 1u << panel.btn[B_HOME], keep = fm1_in.buttons; @@ -970,6 +1063,20 @@ int main(int argc, char **argv) check(knob_accel_off == 0u && !(lights_word() >> 27 & 1u), "menu SCREEN: KNOB 3 right: KNOB ACCEL ON"); lights_from_word(0); check(knob_accel_off == 0u, "menu SCREEN: a settings word from before 2.7 reads KNOB ACCEL ON"); + { /* (2.7.1) the SEQ section: STEP ADVANCE (ON), DRUM PREVIEW (OFF); between AUDIO and SYSTEM */ + uint32_t m0 = ui.menu_sel; + check(!drum_preview && !step_adv_off && mi_sec(MI_ADV) == MS_SEQ && mi_sec(MI_DPREV) == MS_SEQ && + mi_sec(MI_RATE) == MS_AUDIO && mi_sec(MI_CPU1) == MS_SYSTEM, + "menu (2.7.1): a SEQ section: STEP ADVANCE ON, DRUM PREVIEW OFF by default"); + ui.menu_sel = MI_ADV; ui.force = 1; frame(); ppm("menu-seq"); + encs[panel.enc[EN_K1]] = -1; frame(); + encs[panel.enc[EN_K2]] = 1; frame(); + check(step_adv_off == 1u && drum_preview == 1u, "menu SEQ: KNOB 1 left STEP ADVANCE OFF, KNOB 2 right DRUM PREVIEW ON"); + encs[panel.enc[EN_K1]] = 1; frame(); + encs[panel.enc[EN_K2]] = -1; frame(); + check(!step_adv_off && !drum_preview, "menu SEQ: and back (ON, OFF)"); + ui.menu_sel = (uint8_t)m0; frame(); + } ui.menu_sel = 0; frame(); encs[panel.enc[EN_SELECT]] = 1; frame(); check(mi_sec(ui.menu_sel) == MS_LIGHTS && ui.menu_sel == MI_LIGHTS, "menu: SELECT right: LIGHTS, the cursor on its first row"); @@ -985,6 +1092,9 @@ int main(int argc, char **argv) encs[panel.enc[EN_SELECT]] = 1; frame(); ui.force = 1; frame(); ppm("menu-audio"); check(mi_sec(ui.menu_sel) == MS_AUDIO, "menu: SELECT right: AUDIO (LOWCUT, USB AUDIO, USB RATE)"); encs[panel.enc[EN_SELECT]] = 5; frame(); + check(mi_sec(ui.menu_sel) == MS_SEQ, "menu (2.7.1): SELECT right: SEQ (STEP ADVANCE, DRUM PREVIEW)"); + encs[panel.enc[EN_SELECT]] = 5; frame(); + encs[panel.enc[EN_SELECT]] = 5; frame(); sec = mi_sec(ui.menu_sel); check(sec == MS_SYSTEM, "menu: SELECT stops at the last section, SYSTEM"); encs[panel.enc[EN_K1]] = -1; frame(); /* (dualcore) row 1: 2ND CORE; the render split (fx.c cpu1_units) */ @@ -1109,24 +1219,50 @@ int main(int argc, char **argv) studio_open(SC_DRUM); drum_page = 0; drum_lane = 0; drum_cursor = 0; frames(2); memset(pad_lit, 0, sizeof pad_lit); key(key_of_white(2)); frame(); - check(dstep_has(&TDRUM->dstep[2], 0) && drum_cursor == 2 && pad_lit[0], "grid: white key 3 sets step 3 of the sound (heard), the cursor on it"); + check(dstep_has(&TDRUM->dstep[2], 0) && drum_cursor == 2 && !pad_lit[0], + "grid: white key 3 sets step 3 of the sound (2.7.1: not heard, for live), the cursor on it"); check((keys_lit() >> key_of_white(2)) & 1u, "grid: its key lit"); key(key_of_white(2)); check(!dstep_mask(&TDRUM->dstep[2]), "grid: the key again clears it"); - key(3); /* (G#3: the second black key) */ - check(drum_cursor / 16u == 1u, "grid: the black keys pick the page of steps (17-32)"); + { /* 2.7.1: the black keys pick the sound, unheard, the same key again its pair; OCT- / OCT+ the page */ + int ok = 1; + memset(pad_lit, 0, sizeof pad_lit); + key(1); ok &= drum_lane == 1; /* F#3: KICK -> KICK 2 (KICK was picked) */ + key(1); ok &= drum_lane == 0; /* .. and back */ + key(3); ok &= drum_lane == 2; /* G#3: SNARE */ + key(3); ok &= drum_lane == 8; /* .. SNARE 2 */ + key(13); ok &= drum_lane == 5; /* F#4: OPEN HAT */ + key(25); ok &= drum_lane == 15; /* F#5: COWBELL */ + frame(); + for (i = 0; i < 16u; i++) ok &= !pad_lit[i]; + ok &= drum_cursor / 16u == 0u && ((keys_lit() >> 25) & 1u); /* (no page change; its black key lit) */ + check(ok, "grid (2.7.1): the black keys pick the sound (F#3 kick / kick 2 ... F#5 cowbell), unheard, lit"); + key(1); /* (back to the kick) */ + check(drum_lane == 0, "grid: F#3 again: the kick"); + } + tap(B_OCTUP); frame(); + check(drum_cursor / 16u == 1u, "grid (2.7.1): OCT+ the next page of steps (17-32)"); key(key_of_white(0)); check(dstep_has(&TDRUM->dstep[16], 0), "grid: ... and the white keys are its steps (step 17)"); - key(8); /* (C#4: the fourth: steps 49-64, none) */ - check(drum_cursor / 16u == 1u, "grid: a page past LENGTH is not picked"); + tap(B_OCTUP); frame(); + check(drum_cursor / 16u == 0u, "grid: OCT+ past LENGTH (32 steps): back to the first page"); + tap(B_OCTDN); frame(); + check(drum_cursor / 16u == 1u, "grid: OCT- the page before (round)"); memset(pad_lit, 0, sizeof pad_lit); encs[panel.enc[EN_K1]] = 3; frames(2); - check(drum_lane == 3 && pad_lit[3], "grid: KNOB 1 picks the sound and plays it"); + check(drum_lane == 3 && !pad_lit[3], "grid: KNOB 1 picks the sound, unheard (menu DRUM PREVIEW OFF, 2.7.1)"); + drum_preview = 1; + encs[panel.enc[EN_K1]] = 1; frames(2); encs[panel.enc[EN_K1]] = -1; frames(2); + check(drum_lane == 3 && pad_lit[3], "grid: DRUM PREVIEW ON: KNOB 1 plays the sound picked"); dstep_set(&TDRUM->dstep[20], 5, LV_NORM, 0); dstep_set(&TDRUM->dstep[20], 7, LV_SOFT, 0); memset(pad_lit, 0, sizeof pad_lit); drum_cursor = 19; encs[panel.enc[EN_K2]] = 1; frames(2); - check(drum_cursor == 20 && pad_lit[5] && pad_lit[7] && !pad_lit[3], "grid: KNOB 2 onto a step plays what it holds"); + check(drum_cursor == 20 && pad_lit[5] && pad_lit[7] && !pad_lit[3], "grid: KNOB 2 onto a step plays what it holds (PREVIEW ON)"); + drum_preview = 0; + memset(pad_lit, 0, sizeof pad_lit); + drum_cursor = 19; encs[panel.enc[EN_K2]] = 1; frames(2); + check(drum_cursor == 20 && !pad_lit[5] && !pad_lit[7], "grid: PREVIEW OFF: KNOB 2 silent"); encs[panel.enc[EN_SELECT]] = 1; frame(); check(drum_page == 1, "DRUMS: SELECT right: kit"); frame(); @@ -1158,8 +1294,42 @@ int main(int argc, char **argv) pen_lane = 0; press(B_SEQ); frames(3); encs[panel.enc[EN_K1]] = 2; frames(2); - check(pen_lane == 2 && pad_lit[2], "SEQ layer, drum track: KNOB 1 picks the sound and plays it"); + check(pen_lane == 2 && !pad_lit[2], "SEQ layer, drum track: KNOB 1 picks the sound (2.7.1: unheard, PREVIEW OFF)"); + { /* 2.7.1: SEQ held on the drum track: a black key the sound (no page), OCT the page, the white keys its steps */ + int ok = 1; + TDRUM->p[P_SLEN] = 32; + ui.step_page = 0; + key(8); /* C#4 (was page 4): CLAP */ + ok &= pen_lane == 3 && ui.step_page == 0u && ((keys_lit() >> 8) & 1u); + key(10); /* D#4: HI HAT */ + ok &= pen_lane == 4 && ui.step_page == 0u; + key(10); /* .. PEDAL */ + ok &= pen_lane == 6 && ((keys_lit() >> 10) & 1u); + key(key_of_white(4)); /* step 5: the pedal hat */ + ok &= dstep_has(&TDRUM->dstep[4], 6); + edges_btn |= BT(B_OCTUP); fm1_in.buttons |= BT(B_OCTUP); frame(); fm1_in.buttons &= ~BT(B_OCTUP); frame(); + ok &= ui.step_page == 1u; + key(key_of_white(0)); /* step 17 */ + ok &= dstep_has(&TDRUM->dstep[16], 6); + for (i = 0; i < 16u; i++) ok &= !pad_lit[i]; + check(ok, "SEQ layer, drum track (2.7.1): black keys the sound (unheard, lit), OCT+ the page, white keys its steps"); + ui.step_page = 0; + } release(B_SEQ); frames(2); + { /* 2.7.1, the comment's workflow: SEQ held + HOME, locked; then black keys the sound, white keys its steps */ + int ok; + memset(TDRUM->dstep, 0, sizeof TDRUM->dstep); + press(B_SEQ); frames(3); tap(B_HOME); release(B_SEQ); frames(3); + ok = ly_lock == LY_STEP; + key(1); key(key_of_white(0)); key(key_of_white(8)); /* the kick on steps 1 and 9 */ + key(3); key(key_of_white(4)); key(key_of_white(12)); /* the snare on 5 and 13 */ + ok &= dstep_has(&TDRUM->dstep[0], 0) && dstep_has(&TDRUM->dstep[8], 0) && dstep_has(&TDRUM->dstep[4], 2) && + dstep_has(&TDRUM->dstep[12], 2) && !dstep_has(&TDRUM->dstep[4], 0); + tap(B_HOME); frames(2); + check(ok && ly_lock == LY_PLAY, "SEQ locked (HOME), drum track (2.7.1): F#3 kick, white keys 1 / 9; G#3 snare, 5 / 13"); + memset(TDRUM->dstep, 0, sizeof TDRUM->dstep); + go_home(); frame(); + } song.sel = 1; go_home(); frame(); trk[1].p[P_SDIV] = 5; press(B_SEQ); frames(3); @@ -1174,11 +1344,11 @@ int main(int argc, char **argv) uint32_t j, b0; song.sel = 0; go_home(); frames(2); for (j = 0; j < NSTEP; j++) dstep_set(&TDRUM->dstep[j], j % 16u, LV_NORM, 3); - for (j = 0; j < NPAGES; j++) if (!strcmp(PAGES[j].title, "STEP")) break; + for (j = 0; j < NPAGES; j++) if (!strcmp(PAGES[j].title, "NOTES")) break; open_family(FAM_SEQ); ui.page = (uint8_t)j; ui.fam_last[FAM_SEQ] = (uint8_t)j; page_entered(); ui.force = 1; frames(2); b0 = ui.page; for (j = 0; j < 3u; j++) { encs[panel.enc[EN_ALGO]] = 1; frames(2); } - check(song.sel == TRK_DRUM && ui.page == b0 && !page_for_drum(cur_page()) && !strcmp(PAGES[ui.page].title, "STEP"), + check(song.sel == TRK_DRUM && ui.page == b0 && !page_for_drum(cur_page()) && !strcmp(PAGES[ui.page].title, "NOTES"), "STEP on the drum track: not a page for the drums (DRUM TRACK shown, no piano roll of the drum steps)"); for (j = 0; j < NSTEP; j++) memset(&TDRUM->dstep[j], 0, sizeof(dstep_t)); song.sel = 0; go_home(); frames(4); @@ -1190,7 +1360,7 @@ int main(int argc, char **argv) song.sel = 1; go_home(); frames(2); steps_clear(t); t->p[P_SLEN] = 16; t->p[P_VOICE] = V_POLY; t->p[P_ROOT] = 0; t->p[P_SCALE] = 1; t->p[P_QUANT] = 0; t->p[P_CHORD] = 1; /* C major, TRIAD */ - for (j = 0; j < NPAGES; j++) if (!strcmp(PAGES[j].title, "STEP")) break; + for (j = 0; j < NPAGES; j++) if (!strcmp(PAGES[j].title, "NOTES")) break; open_family(FAM_SEQ); ui.page = (uint8_t)j; ui.fam_last[FAM_SEQ] = (uint8_t)j; page_entered(); ui.force = 1; frames(2); cursor_set(0); frames(1); key(k5); frames(2); @@ -1293,7 +1463,7 @@ int main(int argc, char **argv) ui.force = 1; frame(); ppm("layer-steps-vel"); fm1_in.notes = 0; frame(); release(B_SEQ); frames(16); open_family(FAM_SEQ); frame(); - check(!strcmp(PAGES[ui.page].title, "STEP"), "SEQ: the STEP page first"); + check(!strcmp(PAGES[ui.page].title, "NOTES"), "SEQ: the NOTES page first (2.7.2: STEP before)"); ui.cursor = 4; ui.force = 1; frame(); K(EN_K3, 1); K(EN_K3, 1); check(note_len(&trk[0], 4) == 3u && trk[0].step[5].time == ST_TIE && trk[0].step[6].time == ST_TIE && @@ -1342,6 +1512,26 @@ int main(int argc, char **argv) MIN(1, 70, 100); MIN(1, 70, 0); frame(); check(!memcmp(&s9, &trk[0].step[11], sizeof s9) && ui.cursor == 11u && !strcmp(ui.msg, "MIDI PLAYS TRACK 2"), " a note on CH 2 (track 2's): nothing written, \"MIDI PLAYS TRACK 2\""); + { /* 2.7.1 (a YouTube comment): MENU > SEQ > STEP ADVANCE OFF: let go, the cursor stays; a chord tried again + * writes the same step anew; KNOB 1 still moves the cursor */ + int ok; + step_adv_off = 1; + ui.cursor = 12; memset(&trk[0].step[12], 0, sizeof trk[0].step[12]); frame(); + MIN(0, 60, 100); MIN(0, 65, 100); frame(); MIN(0, 60, 0); MIN(0, 65, 0); frame(); /* a wrong chord */ + ok = ui.cursor == 12u && trk[0].step[12].n == 2u && trk[0].step[12].note[1] == 65u; + MIN(0, 60, 100); MIN(0, 64, 100); MIN(0, 67, 100); frame(); MIN(0, 60, 0); MIN(0, 64, 0); MIN(0, 67, 0); frame(); + ok &= ui.cursor == 12u && trk[0].step[12].n == 3u && trk[0].step[12].note[0] == 60u && + trk[0].step[12].note[1] == 64u && trk[0].step[12].note[2] == 67u; /* the chord again: the step anew */ + encs[panel.enc[EN_K1]] = 1; frame(); /* (2.7.2 NOTES: KNOB 1 walks the chord's notes first) */ + ok &= ui.cursor == 12u && ui.note_k == 1u; + encs[panel.enc[EN_K1]] = 2; frame(); + ok &= ui.cursor == 13u && ui.note_k == 0u; + step_adv_off = 0; + MIN(0, 62, 100); MIN(0, 62, 0); frame(); + ok &= ui.cursor == 14u && trk[0].step[13].note[0] == 62u; + check(ok, "STEP page (2.7.1): STEP ADVANCE OFF: the cursor stays, a chord again rewrites the step, KNOB 1 moves; ON: on"); + ui.cursor = 11; + } go_home(); frame(); s9 = trk[0].step[11]; MIN(0, 72, 100); frame(); MIN(0, 72, 0); frame(); @@ -1599,7 +1789,18 @@ int main(int argc, char **argv) e = preset_at(1, &kk); ok &= preset_go_to(&trk[2], 0) == 0 && trk[2].eng_req == base_at(0, &kk); } - check(ok, "favourites (2.7): PRESETS page KNOB 4 adds / removes, at the top of the list in order; Program Change as before"); + { /* (2.7.2) Bank Select: bank 1 + PC 0 loads list index 128, past the 7-bit Program Change range (pc_poll) */ + uint32_t e128, p128; + preset_go_to(&trk[2], 128); + e128 = trk[2].eng_req; p128 = trk[2].preset; + preset_go_to(&trk[2], 0); + pc_bank[2] = 1; pc_req[2] = 1; + pc_poll(); + ok &= trk[2].eng_req == e128 && trk[2].preset == p128; + pc_bank[2] = 0; pc_req[2] = 0; + preset_go_to(&trk[2], 0); + } + check(ok, "favourites (2.7): PRESETS page KNOB 4 adds / removes, at the top of the list in order; Program Change as before, Bank Select reaches index 128 (2.7.2)"); for (k = 0; k < FAV_N; k++) fav[k] = FAV_NONE; fav_at = -1; fav_dirty = 0; go_home(); frames(2); @@ -1707,6 +1908,125 @@ int main(int argc, char **argv) transport_req = 0; song.playing = 0; live_req = -1; ui.msg_t = 0; go_home(); frames(2); } + { /* 2.7.2: SEQ > NOTES, the synth tracks' note editor; the sheet (OCT+ held) there and on the drum grid */ + track_t *t = &trk[0]; + uint32_t j; + int ok; + transport_req = 2; frames(2); + song.rec = 0; rec_wait = 0; song.sel = 0; song.octave = 0; layer_unlock(); + go_home(); frame(); + t->p[P_SLEN] = 16; + for (j = 0; j < NSTEP; j++) step_clear(&t->step[j]); + memset(t->micro, 0, sizeof t->micro); memset(t->fill, 0, sizeof t->fill); + t->step[0].n = 1; t->step[0].note[0] = 48; t->step[0].time = ST_NOTE; /* C3, 2 steps */ + t->step[1].time = ST_TIE; + t->step[4].n = 3; t->step[4].note[0] = 60; t->step[4].note[1] = 64; t->step[4].note[2] = 67; + t->step[4].time = ST_NOTE; /* a chord on step 5 */ + t->step[8].n = 1; t->step[8].note[0] = 55; t->step[8].time = ST_NOTE; + while (strcmp(PAGES[ui.page].title, "NOTES")) { open_family(FAM_SEQ); frame(); } + cursor_set(0); ui.force = 1; frame(); + encs[panel.enc[EN_K1]] = 1; frame(); + ok = ui.cursor == 2u && ui.note_k == 0u; /* (step 2 is the note's TIE: passed) */ + encs[panel.enc[EN_K1]] = 2; frame(); + ok &= ui.cursor == 4u && ui.note_k == 0u; + encs[panel.enc[EN_K1]] = 2; frame(); + ok &= ui.cursor == 4u && ui.note_k == 2u; /* the chord's notes one by one */ + encs[panel.enc[EN_K1]] = -1; frame(); + ok &= ui.cursor == 4u && ui.note_k == 1u; + check(ok, "NOTES (2.7.2): KNOB 1 walks the notes, a chord's one by one, past a note's TIEs"); + encs[panel.enc[EN_K2]] = 1; frame(); + check(t->step[4].note[0] == 60u && t->step[4].note[1] == 65u && t->step[4].note[2] == 67u, + "NOTES: KNOB 2 changes that note's pitch only (E4 -> F4, the chord's others stay)"); + encs[panel.enc[EN_K3]] = 2; frame(); + check(note_len(t, 4) == 3u && t->step[5].time == ST_TIE && t->step[6].time == ST_TIE, "NOTES: KNOB 3 its length (3 steps: two TIEs)"); + encs[panel.enc[EN_K4]] = 1; frame(); + ok = note_force(&t->step[4], 1) == 3u && ((t->step[4].lvl >> 2) & 3u) == LV_HARD && !(t->step[4].flags & SF_ACCENT); + encs[panel.enc[EN_K4]] = 1; frame(); + ok &= note_force(&t->step[4], 1) == 4u && (t->step[4].flags & SF_ACCENT); + encs[panel.enc[EN_K4]] = -4; frame(); + encs[panel.enc[EN_K4]] = -1; frame(); encs[panel.enc[EN_K4]] = -1; frame(); encs[panel.enc[EN_K4]] = -1; frame(); + ok &= note_force(&t->step[4], 1) == 0u && ((t->step[4].lvl >> 2) & 3u) == LV_GHOST && !(t->step[4].flags & SF_ACCENT); + check(ok, "NOTES: KNOB 4 its FORCE: HARD, ACC (the step's accent), down to GHOST"); + encs[panel.enc[EN_PRESET]] = 1; frame(); + ok = (int8_t)ui.zoom == 1; + encs[panel.enc[EN_PRESET]] = -1; frame(); encs[panel.enc[EN_PRESET]] = -1; frame(); + ok &= (int8_t)ui.zoom == -1; + encs[panel.enc[EN_PRESET]] = 1; frame(); + check(ok && (int8_t)ui.zoom == 0 && t->preset == t->preset, "NOTES: PRESETS zooms (16 -> 32, then 8; the sound stays)"); + ui.force = 1; frame(); ppm("notes-chord"); + tap(B_OCTUP); frame(); + check(song.octave == 1 && !ui.sheet, "NOTES: OCT+ tapped: the octave up, as before (on release)"); + song.octave = 0; + press(B_OCTUP); frames(30); + ok = ui.sheet == 1u && song.octave == 0; + release(B_OCTUP); frame(); + check(ok && ui.sheet == 1u && song.octave == 0, "NOTES: OCT+ held 0.4 s: the note's sheet (the octave stays)"); + ui.force = 1; frame(); ppm("notes-sheet"); + tap(B_OCTUP); frame(); + ok = (t->step[4].flags & SF_SLIDE) != 0; + encs[panel.enc[EN_K1]] = 1; frame(); + encs[panel.enc[EN_K2]] = 3; frame(); + ok &= ui.sheet == 2u && t->micro[4] == 3; + encs[panel.enc[EN_K1]] = 1; frame(); + encs[panel.enc[EN_K2]] = 1; frame(); + ok &= step_fill(t, 4) == FC_FILL; + check(ok, "NOTES sheet: SLIDE (OCT+), NUDGE +3, FILL (KNOB 1 the row, KNOB 2 its value)"); + encs[panel.enc[EN_K1]] = 1; frame(); + encs[panel.enc[EN_K2]] = -1; frame(); + ok = ui.cursor == 3u && t->step[3].n == 3u && t->step[3].note[1] == 65u && note_len(t, 3) == 3u && !step_on(&t->step[4]) && + t->step[6].time == ST_REST && t->micro[3] == 3 && t->micro[4] == 0 && step_fill(t, 3) == FC_FILL; + encs[panel.enc[EN_K2]] = -2; frame(); + ok &= ui.cursor == 2u && t->step[2].n == 3u; /* (step 2 free: the C3's TIE? no: step 1 is) */ + encs[panel.enc[EN_K2]] = -1; frame(); + ok &= ui.cursor == 2u && !strcmp(ui.msg, "NO ROOM"); /* (step 1: the C3's TIE) */ + check(ok, "NOTES sheet: MOVE, KNOB 2 a step a detent (with its TIEs, nudge, fill); not over another note"); + encs[panel.enc[EN_K1]] = 1; frame(); + tap(B_OCTUP); frame(); + ok = step_on(&t->step[2]) && step_on(&t->step[5]) && t->step[5].note[1] == 65u && ui.cursor == 5u && ui.sheet == 4u; + check(ok, "NOTES sheet: COPY (OCT+): just after it, the copy picked, MOVE next"); + encs[panel.enc[EN_K1]] = 2; frame(); + tap(B_OCTUP); frame(); + ok = step_on(&t->step[5]) && t->step[5].n == 2u && ui.sheet == 0u; + check(ok, "NOTES sheet: DELETE (OCT+): that note (the chord keeps its others), the sheet closes"); + press(B_OCTUP); frames(30); release(B_OCTUP); frame(); + tap(B_OCTDN); frame(); + check(!ui.sheet && song.octave == 0, "NOTES: OCT- closes the sheet (the octave stays)"); + press(B_EDIT); release(B_EDIT); frames(2); + check(t->step[5].n == 1u && step_on(&t->step[5]), "NOTES: EDIT tapped deletes the note under edit only"); + press(B_EDIT); release(B_EDIT); frames(2); + check(!step_on(&t->step[5]) && t->step[6].time == ST_REST, "NOTES: the chord's last note: the step and its TIEs go"); + press(B_EDIT); press(B_OCTDN); release(B_OCTDN); release(B_EDIT); frames(2); + check(step_on(&t->step[5]), "NOTES: EDIT + OCT- brings it back (undo)"); + cursor_set(0); ui.force = 1; frame(); ppm("notes-main"); + go_home(); frame(); + /* the drum grid's sheet */ + song.sel = TRK_DRUM; studio_open(SC_DRUM); drum_page = 0; frames(2); + for (j = 0; j < NSTEP; j++) memset(&TDRUM->dstep[j], 0, sizeof(dstep_t)); + TDRUM->p[P_SLEN] = 32; + drum_lane = 2; drum_cursor = 4; + dstep_set(&TDRUM->dstep[4], 2, LV_HARD, 0); + tap(B_OCTUP); frame(); + ok = drum_cursor == 20u && !ui.sheet; /* (a tap: the next page) */ + drum_cursor = 4; + press(B_OCTUP); frames(30); release(B_OCTUP); frame(); + ok &= ui.sheet == 1u; + encs[panel.enc[EN_K2]] = 2; frame(); + ok &= dstep_rat(&TDRUM->dstep[4], 2) == 2u && dstep_lvl(&TDRUM->dstep[4], 2) == LV_HARD; + check(ok, "DRUMS grid (2.7.2): OCT+ tapped the page, held the hit's sheet; RATCHET x3"); + ui.force = 1; frame(); ppm("drums-sheet"); + encs[panel.enc[EN_K1]] = 3; frame(); + encs[panel.enc[EN_K2]] = 2; frame(); + ok = drum_cursor == 6u && dstep_has(&TDRUM->dstep[6], 2) && !dstep_has(&TDRUM->dstep[4], 2) && dstep_rat(&TDRUM->dstep[6], 2) == 2u; + encs[panel.enc[EN_K1]] = 1; frame(); + tap(B_OCTUP); frame(); + ok &= dstep_has(&TDRUM->dstep[6], 2) && dstep_has(&TDRUM->dstep[7], 2) && drum_cursor == 7u && ui.sheet == 4u; + encs[panel.enc[EN_K1]] = 2; frame(); + tap(B_OCTUP); frame(); + ok &= !dstep_has(&TDRUM->dstep[7], 2) && dstep_has(&TDRUM->dstep[6], 2) && !ui.sheet; + check(ok, "DRUMS sheet: MOVE (KNOB 2), COPY (OCT+: the next step), DELETE (OCT+)"); + TDRUM->p[P_SLEN] = 16; + go_home(); song.sel = 0; frame(); + } { /* fuzz: 20000 frames of random buttons (held or tapped), knobs and keys, with the audio running * between frames; every draw stays on the screen (lcd_blit / lcd_fill assert it) */ uint32_t f, seed = 777, held = 0; diff --git a/tools/gen_samples.py b/tools/gen_samples.py index f3e100f..a2affba 100644 --- a/tools/gen_samples.py +++ b/tools/gen_samples.py @@ -128,9 +128,16 @@ def name_note(name): return (int(m.group(2)), NOTE[m.group(1)]) if m else None +# SLOOP 2.7.2: sets that keep their first sound only, over the whole keyboard (SCRCH: the scratch, 3 KB; the backspin +# and the rewind, 20 KB, made room for the NOTES editor). The set and its number stay: projects and presets unchanged +ONE_SOUND = {"SCRCH"} + + def cc0_entries(setname, kind): """-> [(file name, int16 samples at TR, loop or None, root)]""" files = sorted((CC0 / setname).glob("*.wav")) + if setname in ONE_SOUND: + files = files[:1] out, conv = [], 1 if kind != "kit" and not all(re.search(r"_m\d+\.wav$", p.name) for p in files): # octave convention of this set (C4 = 60 or C3 = 60): YIN votes, the names give the notes diff --git a/web/editor.html b/web/editor.html index ad9b46b..1086c9c 100644 --- a/web/editor.html +++ b/web/editor.html @@ -2966,6 +2966,7 @@ function makeMockDevice(opt = {}) { E("DR MAP", ["GM", "1-16"], 0), /* GLO > MIDI 3 (2.7): MIDI notes -> drum sounds */ E("REMOTE", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 0), /* GLO > MIDI 3 (2.7): the buttons */ E("CLOCK", ["OFF", "OUT"], 0), /* GLO > MIDI 3 (2.7): MIDI clock, START / STOP out on USB */ + D("FADE", F.INT, 0, 15, 0), /* GLO > MASTER 2 (2.7.2): the punch-in FX fade (punch.c) */ ]; /* the drum track's P_E0: its kit (drums.c DRUM_KIT_NAMES; 5 = 808, the power-on kit) */ const KIT = E("KIT", ["ACOUSTIC", "DEEP", "TIGHT", "BRIGHT", "DUST", "808", "909", "606", "80S", "VINTAGE", "TRAP", "DRILL", "BOOMBAP", "LO-FI", "PHONK", "HOUSE", "D.HOUSE", "TECHNO", "MINIMAL", "ELECTRO", "DISCO", "GARAGE", "JUNGLE", "DUBSTEP", "DEMBOW", "AMAPIANO", "AFRO", "LATIN", "TRIBAL", "SYNTHWV", "CHIP", "ARCADE", "GLITCH", "INDUSTR", "HYPER", "AMBIENT", "JAZZ", "USR1", "USR2", "USR3", "USR4", "USR3+4", "SYN1", "SYN2", "SYN3", "SYN4"], 0); @@ -5905,7 +5906,7 @@ const stepEdit = new Map(); /* index -> time of the last edit */ /* parameter ids (firmware/src/core.h); used only when P_COUNT / G_COUNT match */ /* pcount 71 / pe0 63: 2.6's INSERT, filter TYPE, ENV SYNC, LFO 2 (P_ITYPE 53 .. P_LPOL 62, after Felucca 1.4 / 1.5) */ -const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT */ +const EXPECT = { pcount: [61, 71], gcount: [32, 33, 45, 46, 47, 48, 49, 50], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND; 46: 2.7's FX CH; 47: DR MAP; 48: REMOTE; 49: CLK OUT; 50: 2.7.2's FX FADE */ const P = { LEVEL: 0, SLEN: 29, CHORD: 49 }; const LAYOUT = (pe0) => { const v251 = pe0 >= 63; /* (2.6: the pages the device has for the new parameters) */ diff --git a/web/fm1ota.js b/web/fm1ota.js index 8c54e18..692bdd8 100644 --- a/web/fm1ota.js +++ b/web/fm1ota.js @@ -96,6 +96,11 @@ class Link { } return this.q.shift() || null; } + // detach the callback only; do NOT close the MIDI ports. find()/probe() reuse the same input across + // several output candidates (e.g. the always-present "Microsoft GS Wavetable Synth" is probed before + // the FM-1's own output), and closing the input between candidates raced its re-open and broke the + // handshake with a device that is present ("FM-1 not found" with the port listed). Leaving ports open + // is the long-standing behaviour. close() { this.input.onmidimessage = null; } } @@ -120,14 +125,16 @@ export class Updater { this.log = log || (() => {}); } - // every in/out pair with the same port name that answers the handshake - async find(filter) { - const outs = [...this.access.outputs.values()]; - for (const input of this.access.inputs.values()) { - if (input.state === "disconnected") continue; - if (!FM1_PORT.test(input.name || "")) continue; // never probe other gear - const output = outs.find((o) => o.name === input.name) || (outs.length === 1 ? outs[0] : null); - if (!output) continue; + // one input against its candidate outputs: the matching port first (same name, or one name contains + // the other, so input "Felucca" pairs with output "MIDIOUT2 (Felucca)" without probing unrelated + // outputs like "Microsoft GS Wavetable Synth"), then (the fallback) any live output. A pair counts + // only when it answers the FM-1 handshake and passes the filter. + async probe(input, outs, filter) { + if (input.state === "disconnected") return null; + const live = outs.filter((o) => o.state !== "disconnected"); + const nm = input.name || ""; + const named = live.filter((o) => o.name === nm || (nm && o.name && (o.name.includes(nm) || nm.includes(o.name)))); + for (const output of (named.length ? named : live)) { try { await input.open(); await output.open(); } catch (_) { continue; } const link = new Link(input, output); const id = await handshake(link, 2); @@ -137,16 +144,40 @@ export class Updater { return null; } + // the FM-1 (or its update loader) among the MIDI ports. Named ports first (fast, and other gear is + // never touched). With deep=true (hunting the re-enumerated update loader only), if no named port + // matched, the remaining ports are probed too and accepted SOLELY when they answer the FM-1 handshake + // (other gear returns no valid identity). Windows often names the update loader generically (e.g. + // "USB MIDI Device"), so a name filter alone misses it and the loader seems to "not appear": this + // handshake fallback is what makes the loader reliably found, without probing other gear when looking + // for the running firmware (which always names itself). + async find(filter, deep = false) { + const outs = [...this.access.outputs.values()]; + const inputs = [...this.access.inputs.values()].filter((i) => i.state !== "disconnected"); + for (const input of inputs) + if (FM1_PORT.test(input.name || "")) { + const dev = await this.probe(input, outs, filter); + if (dev) return dev; + } + if (deep) + for (const input of inputs) + if (!FM1_PORT.test(input.name || "")) { + const dev = await this.probe(input, outs, filter); + if (dev) return dev; + } + return null; + } + // the MIDI inputs there are, for the "not found" message: " (MIDI: a, b)" (a port the installer skipped shows) seen() { const names = [...this.access.inputs.values()].filter((p) => p.state !== "disconnected").map((p) => p.name || "?"); return names.length ? ` (MIDI: ${names.join(", ")})` : " (MIDI: none)"; } - async waitFor(filter, ms) { + async waitFor(filter, ms, deep = false) { const end = Date.now() + ms; while (Date.now() < end) { - const dev = await this.find(filter); + const dev = await this.find(filter, deep); if (dev) return dev; await sleep(1000); } @@ -197,13 +228,13 @@ export class Updater { if (!s1.finished) throw fail(s1.lost ? "lost" : "stopped", `the device ${s1.lost ? "was disconnected" : "stopped"} after ${s1.served} requests: nothing was written`); step("loader"); await sleep(3000); - const ota = await this.waitFor(IS_OTA, 30000); - if (!ota) throw fail("noloader", "the update loader did not appear. Replug the USB cable and press Install again: the device stays in update mode until it is finished."); + const ota = await this.waitFor(IS_OTA, 60000, true); + if (!ota) throw fail("noloader", "the update loader did not appear. Replug the USB cable and press Install again: the device stays in update mode until it is finished.", this.seen()); const s2 = await this.write(ota, image, step); if (!s2.finished) throw fail(s2.lost ? "lost" : "stopped", `the loader ${s2.lost ? "was disconnected" : "stopped"} after ${s2.served} requests. Replug and press Install again to resume.`); step("reboot"); await sleep(3000); - const back = await this.waitFor((id) => !IS_OTA(id), 40000); + const back = await this.waitFor((id) => !IS_OTA(id), 60000); if (!back) throw fail("noreturn", "the device did not come back: power-cycle it"); back.link.close(); if (back.id.text !== product) throw fail("mismatch", `installed, but the device reports ${back.id.text}`, back.id.text); @@ -225,7 +256,7 @@ export class Updater { // package, its identity checked once the FM-1 is back, after Felucca 1.0): that one is the official // loader's own image, as M-UPGRADE would write it async resume(image, onStep, opts = {}) { - const ota = await this.find(IS_OTA); + const ota = await this.find(IS_OTA, true); if (!ota) return false; if (!OUR_LOADER(ota.id) && !opts.product) { ota.link.close(); @@ -236,7 +267,7 @@ export class Updater { if (opts.product) { step("reboot"); await sleep(3000); - const back = await this.waitFor((id) => !IS_OTA(id), 40000); + const back = await this.waitFor((id) => !IS_OTA(id), 60000); if (!back) throw fail("noreturn", "the FM-1 did not come back after the write: power-cycle it"); back.link.close(); if (back.id.text !== opts.product) throw fail("mismatch", `written, but the FM-1 reports ${back.id.text}`, back.id.text); diff --git a/web/index_pkg.html b/web/index_pkg.html index 0981aee..ca2eae6 100644 --- a/web/index_pkg.html +++ b/web/index_pkg.html @@ -80,17 +80,8 @@

FM-1-transporter

-
- -

-

www.m-vave.com/download

-

-

-

-

-

-

-
+

+

www.m-vave.com/download

SLOOP is based on Felucca by Leo Kuroshita (@kurogedelic), Hügelton Instruments. Hold OCT− alone while switching on for USB rescue.
Font: Terminus (Dimitar Toshkov Zhekov, SIL OFL 1.1). Samples: Versilian Studios VSCO-2 Community Edition and VCSL (CC0 1.0), and the Hügelton Sample Pack (© Hügelton Instruments, not CC0).
@@ -135,7 +126,7 @@ const TEXT = { stockValid: "公式 V15 を確認しました", stockBad: "公式 V15 ではありません: ", stockConfirm: "FM-1 に公式 V15 をインストールします。SLOOP の曲は公式ファームウェアでは開けません。バックアップは保存しましたか?", stockFinish: "FM-1 は SLOOP の書き込みモードです。先に「インストール」で SLOOP の書き込みを終えてから、公式 V15 に戻してください。", - back: "M-VAVE のアップデーター M-UPGRADE(Downloads → PC Software)でも戻せます。FM-1 が見つからない場合は、MIDI を使う他のアプリとブラウザのタブを閉じてください。", + back: "公式ファームウェアに戻すには、M-VAVE 公式のアップデーター M-UPGRADE(Downloads → PC Software → M-UPGRADE)と公式ファームウェアを使ってください。FM-1 が見つからない場合は、MIDI を使う他のアプリとブラウザのタブを閉じてください。", }, en: { intro: "Connect the FM-1 by USB. (Works in Chrome or Edge.)", @@ -171,7 +162,7 @@ const TEXT = { stockValid: "Official V15 verified", stockBad: "Not the official V15: ", stockConfirm: "Install the official V15 on the FM-1? The official firmware cannot open SLOOP's music. Did you save a backup?", stockFinish: "The FM-1 is in SLOOP's update mode. Press Install to finish the SLOOP update first, then return to the official V15.", - back: "M-VAVE's own updater, M-UPGRADE (Downloads → PC Software), works too. If it does not find the FM-1, close every other app and browser tab that uses MIDI.", + back: "To return to the official firmware, use M-VAVE's own updater, M-UPGRADE (Downloads → PC Software → M-UPGRADE), with the official firmware from M-VAVE. If it does not find the FM-1, close every other app and browser tab that uses MIDI.", }, }; let lang = (navigator.language || "en").toLowerCase().startsWith("ja") ? "ja" : "en"; @@ -207,12 +198,10 @@ const log = (t) => { $("log").textContent += t + "\n"; }; let image = null; const meta = /*META*/; -let writing = false, stock = null; +let writing = false; const lockAll = (on) => { writing = on; $("go").disabled = on || !image; - $("stock-go").disabled = on || !stock || !$("stock-saved").checked; - $("stock-file").disabled = on; }; window.addEventListener("beforeunload", (e) => { if (writing) { e.preventDefault(); e.returnValue = t("leave"); } }); @@ -265,7 +254,7 @@ $("go").addEventListener("click", async () => { catch (e) { sayK("denied"); lockAll(false); return; } try { const up = new Updater(midi, log); - const ota = await up.find((id) => /^ota-/i.test(id.model)); + const ota = await up.find((id) => /^ota-/i.test(id.model), true); if (ota) { ota.link.close(); sayK((await up.resume(image, step)) ? "done" : "stopped"); @@ -276,37 +265,8 @@ $("go").addEventListener("click", async () => { lockAll(false); }); -/* back to the official V15 (after Felucca 1.0): only the exact official file, a backup first (the editor), - through the same update path as M-UPGRADE; a device left in the official updater's mode is finished */ -$("stock-saved").addEventListener("change", () => lockAll(writing)); -$("stock-file").addEventListener("change", async () => { - const f = $("stock-file").files[0]; - stock = null; - lockAll(writing); - if (!f) return; - try { stock = await validateStockPackage(new Uint8Array(await f.arrayBuffer())); sayK("stockValid"); } - catch (e) { sayK("stockBad", e.message); } - lockAll(writing); -}); -$("stock-go").addEventListener("click", async () => { - if (writing || !stock || !$("stock-saved").checked || !confirm(t("stockConfirm"))) return; - lockAll(true); - let midi; - try { midi = await navigator.requestMIDIAccess({ sysex: true }); } - catch (e) { sayK("denied"); lockAll(false); return; } - try { - const up = new Updater(midi, log); - const ota = await up.find((id) => /^ota-/i.test(id.model)); - if (ota) { - ota.link.close(); - if (OUR_LOADER(ota.id)) sayK("stockFinish"); /* SLOOP's loader: finish SLOOP first (Install) */ - else sayK((await up.resume(stock.image, step, { product: stock.product })) ? "done" : "stopped"); - } else { - await up.install(stock.image, stock.product, step); - } - } catch (e) { failed(e); } - lockAll(false); -}); +/* Returning to the official firmware is done with M-VAVE's own updater (M-UPGRADE): the in-browser + revert was removed because it is not reliable on every system. The note under "stockTitle" points there. */ diff --git a/web/test_web.mjs b/web/test_web.mjs index e196311..cfb7336 100644 --- a/web/test_web.mjs +++ b/web/test_web.mjs @@ -643,7 +643,7 @@ async function editorV5() { const C = E.CMD; const { m, rq, ev, done } = attachMock({ watchMs: 1000 }); const info = E.parse[C.INFO](await rq(E.req.info())); - ok(info.proto === 12 && /SLOOP/.test(info.version) && info.pcount === 71 && info.gcount === 49 && info.pe0 === 63, "v5..v12: INFO ends with the protocol version (12: LIVE); 49 globals (2.5: drum DLY; 2.6: GLO > MIDI, TEXTURE, BEND; 2.7: FX CH, DR MAP, REMOTE, CLK OUT)"); + ok(info.proto === 12 && /SLOOP/.test(info.version) && info.pcount === 71 && info.gcount === 50 && info.pe0 === 63, "v5..v12: INFO ends with the protocol version (12: LIVE); 50 globals (2.5: drum DLY; 2.6: GLO > MIDI, TEXTURE, BEND; 2.7: FX CH, DR MAP, REMOTE, CLK OUT; 2.7.2: FX FADE)"); /* the firmware says the same: ED_DRUM_STEP is command 33, INFO sends 5, P_CHORD / the master globals as the mock has them */ const ec = readFileSync(join(HERE, "../firmware/src/editor.c"), "utf8"), pc = readFileSync(join(HERE, "../firmware/src/params.c"), "utf8"); const en = (/enum \{ ED_INFO = 1,([^}]*)\}/.exec(ec) || [])[1] || ""; @@ -1631,9 +1631,9 @@ const UPGRADE = [0xF0, 0x22, 0x24, 0x35, 0x7F, 0xF7]; /* an FM-1 on WebMIDI: identity, then "device asks, host answers" reads of the image */ class FakeFM1 { - constructor(image, { unplugAfter = Infinity, finalIdentity = "FM-1_900", name = "FM-1", identity = "FM-1_015" } = {}) { + constructor(image, { unplugAfter = Infinity, finalIdentity = "FM-1_900", name = "FM-1", identity = "FM-1_015", loaderName = "Felucca Update" } = {}) { this.image = image; this.unplugAfter = unplugAfter; this.served = 0; this.bad = 0; - this.finalIdentity = finalIdentity; + this.finalIdentity = finalIdentity; this.loaderName = loaderName; this.access = { inputs: new Map(), outputs: new Map() }; this.boot(identity, name); } @@ -1669,7 +1669,7 @@ class FakeFM1 { this.waiting = null; this.served++; if (this.served >= this.unplugAfter) { this.input.state = this.output.state = "disconnected"; return; } - if (addr === 0xE0000000) setTimeout(() => this.boot("ota-FM-1_900", "Felucca Update"), 300); + if (addr === 0xE0000000) setTimeout(() => this.boot("ota-FM-1_900", this.loaderName), 300); else if (addr === 0xF0000000) setTimeout(() => this.boot(this.finalIdentity, "Felucca"), 300); else this.next(); } @@ -1695,6 +1695,21 @@ async function updater() { ok(got === "FM-1_900" && dev.bad === 0 && steps.includes("write") && steps.at(-1) === "done", `fm1ota.js: install: running firmware -> loader -> Felucca (${dev.served} reads)`); + { /* Windows names the re-enumerated update loader generically ("USB MIDI Device"): the name filter + misses it, so the installer must find it by its handshake or the loader "does not appear" (#loader) */ + const win = new FakeFM1(image, { loaderName: "USB MIDI Device" }); + const ws = []; + const g = await new Updater(win.access).install(image, "FM-1_900", (k) => ws.push(k)); + ok(g === "FM-1_900" && win.bad === 0 && ws.at(-1) === "done" && !FM1_PORT.test("USB MIDI Device"), + "fm1ota.js: a generically-named update loader (USB MIDI Device) is still found by the handshake"); + } + { /* the same loader, but the device is already stuck in update mode: resume must find it too */ + const win2 = new FakeFM1(image, { loaderName: "USB MIDI Device" }); + win2.boot("ota-FM-1_900", "USB MIDI Device"); + const done = await new Updater(win2.access).resume(image); + ok(done === true && win2.bad === 0, "fm1ota.js: resume finds a generically-named loader already in update mode"); + } + const rescue = new FakeFM1(image); rescue.boot("FM-1_000", "Felucca"); const recovered = await new Updater(rescue.access).install(image, "FM-1_900");