-# SLOOP 2.5 — démarrage rapide
+# SLOOP 2.6 — démarrage rapide
-**SLOOP** transforme le M-VAVE FM-1 en groovebox à jouer en live, pour tous les styles : trois synthés et une batterie de 16 sons sur les touches blanches, 12 moteurs de synthèse (dont la FM à six opérateurs avec les patchs DX7, les modèles physiques et le bruit), 153 sons rangés par famille (basses, claviers, orgues, nappes, leads, plucks, stabs), 37 kits de batterie (808, 909, trap, phonk, house, techno, UK garage, jungle, amapiano, synthwave, chiptune, ambient…) et tes propres kits, tes propres samples, ghost notes et ratchets, verrous de paramètre, décalage des pas et fills, note repeat, accords sur une touche, 16 effets punch-in, et un écran à la teenage engineering qui montre toujours ce que tes mains peuvent faire. Aucun motif d'usine : tout ce que tu entends, tu le joues.
+**SLOOP** transforme le M-VAVE FM-1 en groovebox à jouer en live, pour tous les styles : trois synthés et une batterie de 16 sons sur les touches blanches, 12 moteurs de synthèse (dont la FM à six opérateurs avec les patchs DX7, les modèles physiques et le bruit), 153 sons rangés par famille (basses, claviers, orgues, nappes, leads, plucks, stabs), 37 kits de batterie (808, 909, trap, phonk, house, techno, UK garage, jungle, amapiano, synthwave, chiptune, ambient…) et tes propres kits, tes propres samples, ghost notes et ratchets, verrous de paramètre, décalage des pas et fills, note repeat, accords sur une touche, 27 effets punch-in, et un écran à la teenage engineering qui montre toujours ce que tes mains peuvent faire. Aucun motif d'usine : tout ce que tu entends, tu le joues.
Le guide complet, chaque bouton, combinaison et page, avec un aide-mémoire d'une page (en anglais) : [GUIDE.md](GUIDE.md). Le manuel (en anglais) : [SLOOP.md](SLOOP.md).
+**Nouveau dans la 2.6 :** **27 effets punch-in** (11 de plus sur les touches noires, voir FX plus bas) ; un **écran plus lisible** (police Terminus en gras, tout en majuscules) ; repris de **Felucca 1.4 / 1.5** (Leo Kuroshita) : un effet **INSERT** sur chaque piste, la batterie comprise (SOFT, HARD, FOLD, FUZZ, CRUSH, PHASR, FLANG, CHOR, avec MIX sec / traité ; FX → INSERT et INSERT 2), le **LFO 2** (LFO → LFO 2 : **SYNC** calé sur le tempo, de 4 mesures à 1/32, **TRIG** NOTE / FREE, **POL** BI / UNI), l'**ENV SYNC** (ENV DEST → ESYNC : attaque, decay et release en valeurs de note), le filtre **ANALOG** en passe-bas, passe-bande ou passe-haut (EDIT → FILTER, sur une piste ANALOG), la **durée d'une note en pas** (page STEP, KNOB 3 sur une note : LEN) et la **vélocité de chaque pas** (SEQ + pas de synthé + KNOB 2 : VEL), le **MIDI LEARN** (GLO + F#3) et la correction de l'arpège verrouillé qui suit maintenant TRN, ROOT, SCALE et KEYS (#191) ; **TEXTURE**, une nappe de fond qui boucle sous le mix sans prendre de piste (GLO → TEXTURE : VINYL, TAPE, RAIN, WIND, RADIO, ROOM ou un de tes samples, avec LEVEL, TONE et MOVE, une respiration lente sur 1 à 16 mesures ; sauvée avec le projet et chaque section) ; les **mutes de batterie en direct** (EDIT + une touche noire) ; **un canal MIDI au choix pour chaque piste** et tous les réglages MIDI regroupés (GLO → MIDI : CH1 à CH4 ; MIDI 2 : IN, OTHER, OUT, BEND) ; le **Program Change** MIDI (charge le n-ième son de la liste PRESETS, le kit n sur le canal batterie), le délai **1/4D** et les **REV THROW / ECHO THROW** (FX + OCT− ou OCT+ tenus : départs reverb ou écho à fond tant qu'on tient) repris de Felucca 1.5.1 ; la **saisie des pas depuis un clavier MIDI** (page STEP : les notes jouées sur la piste sélectionnée écrivent le pas) ; la **pédale de sustain** (CC 64) et le **pitch bend** (amplitude : GLO → MIDI 2 → BEND, 1 à 12 demi-tons) ; le **MIDI IN sur un seul canal** (GLO → MIDI 2 → IN = CH 1 … CH 16) ; plus de **craquement** en changeant de son pendant que des notes sonnent, ni quand un filtre (piste, batterie FX + KNOB 4, FILT du master) commence à fermer ; une **sortie plus propre** : le limiteur du master anticipe de 0,7 ms, les kicks et les basses fortes ne craquent plus avec MASTER au maximum (surtout au casque), et FREEZE garde le niveau du mix ; dans l'**éditeur web**, une valeur déjà réglée sur une piste puis la même sur une autre (DIV 1/8 sur la batterie, puis sur la piste 1) est bien envoyée ; et l'installateur trouve une FM-1 sous **CLIPPER**. Les projets de la 2.5 se chargent tels quels ; un projet sauvé en 2.6 ne s'ouvre pas en 2.5 (fais une sauvegarde avant la mise à jour).
+
**Nouveau dans la 2.5 :** deux moteurs de plus, **PHYS** (modèles physiques : guitares, koto, banjo, sitar et tanpura, harpe, cloches, vibraphone, steel pan, violoncelle à l'archet, tabla, conga, timbales…) et **NOISE** (vent, pluie, océan, vinyle, souffle, riser, bitcrush, radio…), et **153 sons** d'usine (77 nouveaux, tous au même volume). Ils ne prennent pas de mémoire en plus : GRAIN, FM6 et PHYS partagent la même place par piste. Le **swing** s'affiche de 0 (droit) à 100 (le plus fort) au lieu de 50–75 % : le swing lui-même ne change pas. La batterie a maintenant un **envoi delay** : GLO → DRUMS → **DLY** (à côté de REV). Sur la page DRUMS, le cadran **level** va de ghost (à gauche) à hard (à droite). Corrigés (le correctif 2.4.1, inclus) : les patchs DX7 importés avec de l'**AMS** ne font plus de bruit ; le **click** s'entend avec tous les kits, même batterie coupée ou une autre piste en solo ; en mode accord, une touche de la page **STEP** écrit l'accord entier. Les projets de la 2.4 se chargent tels quels.
-**Nouveau dans la 2.4 :** le moteur **FM6** (FM à six opérateurs, import des patchs DX7 dans l'éditeur web), les **verrous de paramètre** et le **décalage** des pas, les **fills**, la **chaîne de sections**, le séquenceur vers la **sortie MIDI** (GLO → SYSTEM → MIDI = SEQ), des pas de **1/2, 1 ou 2 mesures**, les délais **pointés** (TIME = 1/8D, 1/16D), **KEYS = ALL KEYS** (toutes les touches éclairées), et avec **NOTES** les notes courtes du séquenceur allument enfin leur touche. Corrigés : un START MIDI pendant le décompte de REC démarre maintenant l'enregistrement ; le swing ne décale plus les triolets ; tourner DIV juste après PLAY ne saute plus de pas ; l'éditeur n'écrit plus en flash pendant la lecture. Les projets et sauvegardes de la 2.3 se chargent tels quels.
+**Nouveau dans la 2.4 :** le moteur **FM6** (FM à six opérateurs, import des patchs DX7 dans l'éditeur web), les **verrous de paramètre** et le **décalage** des pas, les **fills**, la **chaîne de sections**, le séquenceur vers la **sortie MIDI** (GLO → MIDI 2 → OUT = SEQ), des pas de **1/2, 1 ou 2 mesures**, les délais **pointés** (TIME = 1/8D, 1/16D), **KEYS = ALL KEYS** (toutes les touches éclairées), et avec **NOTES** les notes courtes du séquenceur allument enfin leur touche. Corrigés : un START MIDI pendant le décompte de REC démarre maintenant l'enregistrement ; le swing ne décale plus les triolets ; tourner DIV juste après PLAY ne saute plus de pas ; l'éditeur n'écrit plus en flash pendant la lecture. Les projets et sauvegardes de la 2.3 se chargent tels quels.
---
@@ -18,7 +20,7 @@ Le guide complet, chaque bouton, combinaison et page, avec un aide-mémoire d'un
2. Dans **Chrome ou Edge**, branche le FM-1 en USB (câble de données, directement, sans hub).
3. **INSTALL**, autorise le MIDI, attends *Done*. Garde la fenêtre noire ouverte jusque-là.
-L'éditeur web : `http://localhost:8766/webapp/editor/` (ou **`OPEN-EDITOR.bat`**).
+L'éditeur web : `http://localhost:8766/webapp/editor/` (ou **`OPEN-EDITOR.bat`**). Hors ligne (2.6) : le lien *Download the editor* (sous Connect, ou sur la page de l'installateur) enregistre l'éditeur en un seul fichier ; double-clique-le, il s'ouvre dans Chrome ou Edge sans internet (Chrome demande une fois d'autoriser le MIDI).
## Un beat en soixante secondes
@@ -27,7 +29,7 @@ L'éditeur web : `http://localhost:8766/webapp/editor/` (ou **`OPEN-EDITOR.bat`*
3. **Appuie sur REC sur le « 1 » qui suit ta dernière mesure** : la boucle se ferme, sa durée fixe le tempo, les frappes se calent sur la grille et la boucle joue aussitôt.
4. **REC** pendant la lecture : tu enregistres par-dessus (overdub). Maintiens **ARP** et garde la touche du charley : un roulement en 1/16, enregistré en ratchets.
5. **ALGORITHM** sur la piste **1** (bleue, *808 BOOM*), **REC**, joue une basse. Maintiens **SEL** et appuie sur la tonalité du morceau (ex. ré) ; sur la piste 2, maintiens SEL et tourne **KNOB 1** sur *7TH* : chaque touche blanche joue un accord de la gamme.
-6. Maintiens **FX** + une touche blanche : un effet punch-in. Toujours FX enfoncé : **KNOB 2** = DUST (vinyle), **KNOB 3** = DUCK (pompe).
+6. Maintiens **FX** + une touche (blanche ou noire) : un effet punch-in. Toujours FX enfoncé : **KNOB 2** = DUST (vinyle), **KNOB 3** = DUCK (pompe).
7. Une erreur ? Maintiens **EDIT** et appuie sur **OCT−** : annuler.
## Les couleurs
@@ -109,15 +111,18 @@ Les notes vont au pas le plus proche **tel que tu l'as entendu** (la latence de
## Les calques en détail
-**FX — punch.** Les 16 touches blanches = les 16 effets (boucles 1/4 à 1/32, stutter, reverse, tape stop, demi-vitesse, filtres, téléphone, bit crush, alias, gate, écho, wobble), tant que la touche est tenue. KNOB 1 = filtre DJ (gauche passe-bas, droite passe-haut, centre OFF), KNOB 2 = DUST, KNOB 3 = DUCK, KNOB 4 = le même filtre sur la piste sélectionnée seulement (2.4 : aussi sur la page FX → FILTER, verrouillable sur un pas).
+**FX — punch.** Les 16 touches blanches = 16 effets (boucles 1/4 à 1/32, stutter, reverse, tape stop, demi-vitesse, filtres, téléphone, bit crush, alias, gate, écho, wobble), tant que la touche est tenue. Les 11 touches noires (2.6) = 11 de plus : KILL LOW / MID / HIGH (coupe-bandes façon DJ), REWIND (le disque tiré en arrière), OCT UP (une octave plus haut), FLANGER, AUTO-PAN, FREEZE (le mix figé dans la reverb tant que la touche est tenue), LOOP 8T (boucle 1/8 triolet), MONO, FADE OUT (fondu à zéro en deux temps). KNOB 1 = filtre DJ (gauche passe-bas, droite passe-haut, centre OFF), KNOB 2 = DUST, KNOB 3 = DUCK, KNOB 4 = le même filtre sur la piste sélectionnée seulement (2.4 : aussi sur la page FX → FILTER, verrouillable sur un pas).
**EDIT — effacer.** EDIT + une touche : ce son (batterie) ou cette note (synthé) quitte le motif — **en lecture**, de chaque pas que la tête de lecture traverse tant que tu tiens la touche (façon MPC : garde le charley une mesure et les charleys de cette mesure disparaissent) ; **à l'arrêt**, de tout le motif. KNOB 1 décale le motif d'un pas, KNOB 2 le double (×2, copie) ou le coupe en deux, KNOB 3 transpose (synthés). **EDIT + OCT−** annule, **EDIT + OCT+** rétablit.
+**Mutes de batterie (2.6).** Sur la piste batterie, **EDIT + une touche noire** passe en mode **MUTE** : les touches blanches coupent et rallument leur son dans le séquenceur, en direct, sans rien effacer (un son coupé affiche *OFF* en rouge). Une touche noire à nouveau, ou EDIT relâché, revient à l'effacement. Les sons restent coupés jusqu'à ce que tu les rallumes ; un projet chargé repart avec tous les sons.
+
**ARP — roll (note repeat).** ARP + une touche tenue : elle se répète sur la grille à la vitesse de KNOB 1 (1/8, 1/16, 1/32, 32T, 1/64), toujours en rythme. En enregistrement, un roll s'écrit en ratchets.
**SEQ — pas (séquenceur pas à pas).** Les 16 touches blanches = les 16 pas de la page ; les quatre premières touches noires (F#3, G#3, A#3, C#4) ou OCT− / OCT+ = pages 1–4.
- Pas vide : appuie, il est posé (batterie : avec le son affiché, le dernier pad frappé ou KNOB 1 ; synthé : avec la dernière note ou le dernier accord joué).
-- Pas posé : appuie et relâche, il s'efface (avec son décalage et ses verrous). Tiens-le et tourne un bouton : il est modifié et gardé — KNOB 1 son / note, **KNOB 2 niveau**, **KNOB 3 ratchet**, **KNOB 4 décalage** ; **PRESETS** un verrou de paramètre, **ALGORITHM** quel paramètre. Plusieurs pas tenus se modifient ensemble. **OCT−** avec un pas tenu efface son décalage et ses verrous.
+- Pas posé : appuie et relâche, il s'efface (avec son décalage et ses verrous). Tiens-le et tourne un bouton : il est modifié et gardé — KNOB 1 son / note, **KNOB 2 niveau** (sur un pas de synthé, 2.6 : **VEL**, sa vélocité 1–127), **KNOB 3 ratchet**, **KNOB 4 décalage** ; **PRESETS** un verrou de paramètre, **ALGORITHM** quel paramètre. Plusieurs pas tenus se modifient ensemble. **OCT−** avec un pas tenu efface son décalage et ses verrous.
+- **Page STEP** (SEQ tapé, pistes synthé) : sur une note, **KNOB 3 = LEN** (2.6), le nombre de pas que dure la note (les pas suivants deviennent des TIE ; plus court, ses derniers TIE redeviennent des REST). Un **clavier MIDI** écrit aussi le pas (2.6), comme les touches : les notes tenues ensemble sur la piste sélectionnée (son canal : GLO → MIDI) ; tout relâché, le curseur avance. Sur le canal d'une autre piste, à l'arrêt, l'écran affiche *MIDI PLAYS TRACK n* ; pareil, une fois par prise, quand tu enregistres (REC) et que ton clavier joue une autre piste que celle qui enregistre.
- Sans pas tenu : KNOB 2 = DIV (1/4 … 1/32, triolets, et depuis la 2.4 **1/2**, **1BAR**, **2BAR** : des pas d'une ou deux mesures, pour les nappes et les changements d'accords lents), KNOB 3 = swing de la piste (sans effet sur les triolets), KNOB 4 = longueur (1–64 pas ; chaque piste boucle sur sa longueur).
**Décalage (micro-timing).** Un pas tenu + KNOB 4 le sort de la grille : −32 … +31 en 1/64 de pas, moins = en avance (il joue avant son temps, dans le pas précédent), plus = en retard. Ses ratchets suivent ; l'enregistrement et le swing restent sur la grille. Sur la batterie, tout le pas se décale, tous les sons. Un pas décalé porte un point dans le coin de sa tuile.
@@ -148,6 +153,8 @@ Les notes vont au pas le plus proche **tel que tu l'as entendu** (la latence de
Réglables avec FX maintenu (KNOB 1–3) ou GLO → MASTER.
+**TEXTURE (2.6)** : GLO → TEXTURE, une nappe de fond qui boucle sous tout le mix, sans prendre de piste. **SRC** : VINYL (souffle, grondement, craquements), TAPE (souffle de bande qui dérive), RAIN (pluie), WIND (vent), RADIO (parasites), ROOM (ambiance de pièce) ou un de tes samples (USR1–4, en boucle) ; **LEVEL** ; **TONE** (à gauche passe-bas, à droite passe-haut) ; **MOVE** : elle respire (volume et brillance). Page TEXTURE 2 : **RATE** (la respiration sur 1 à 16 mesures), **WHEN** (PLAY : avec la lecture, ALWAYS : tout le temps), **DUCK** (le kick la fait pomper). Sauvée avec le projet, et chaque section A–D a la sienne.
+
## Mode chanson
Une chanson enchaîne 4 sections, **A–D** (chacune garde les 4 pistes : sons, motifs, kit). Elle se construit en jouant :
@@ -180,10 +187,14 @@ Chrome ou Edge, FM-1 en USB, **Connect**. Il suit l'appareil en direct. Depuis l
- **Prise MIDI IN** (jack 3,5 mm TRS du FM-1) : un clavier ou des pads avec une sortie MIDI, via un adaptateur TRS ↔ DIN MIDI. Si rien ne joue, essaie l'autre type d'adaptateur (type A / type B).
- **USB** : depuis un ordinateur ou un téléphone (DAW, appli de routage MIDI) ou un boîtier « USB MIDI host ». Un clavier USB branché directement sur le FM-1 ne peut pas marcher : ce sont deux appareils USB, il faut un hôte.
- **Canaux :** 1, 2, 3 = pistes synth 1, 2, 3 · 10 = la batterie · 4 à 16 = **la piste sélectionnée** (règle ton clavier sur le canal 4 et il suit ALGORITHM).
+- **Tes propres canaux (2.6) :** GLO → **MIDI** règle le canal de chaque piste (**CH1**, **CH2**, **CH3**, **CH4** la batterie : OFF ou 1–16, en entrée et en sortie ; deux pistes ne partagent jamais un canal, le bouton saute ceux déjà pris et dit à qui ils sont). GLO → **MIDI 2** : **IN**, **OTHER** (ce que font les canaux qu'aucune piste n'a : **SEL** la piste sélectionnée, comme avant ; **OFF** ignorés), **OUT**, **BEND**. Notes, CC et sortie MIDI suivent : un séquenceur externe joue la batterie sur 10, la basse sur 2, la nappe sur 11 et le lead sur 8. Réglages de la FM-1, gardés à l'extinction (le canal batterie aussi, désormais : un projet ne le change plus).
- **Horloge MIDI :** GLO → SYSTEM → **SYNC** = **USB** ou **TRS**. SLOOP suit le tempo, START, CONTINUE et STOP du maître, sans jamais dériver. Sans horloge pendant une demi-seconde, PLAY rejoue au tempo du FM-1. SYNC est un réglage de la FM-1 : il reste quand tu charges un projet.
- **Horloge seule :** GLO → SYSTEM → **IN** = **CLOCK** : SLOOP suit l'horloge (et START / STOP) mais ignore les notes qui arrivent, pratique quand la DAW envoie aussi des notes à d'autres appareils. **NOTES** (par défaut) : notes et horloge. Un réglage de la FM-1, comme SYNC.
-- **Sortie MIDI :** ce que tu joues aux touches sort toujours en MIDI USB (chaque piste sur son canal, la batterie sur 10). GLO → SYSTEM → **MIDI** = **SEQ** envoie aussi ce que jouent le séquenceur, l'arpégiateur et les rolls : pilote un autre synthé, ou enregistre le motif en notes dans ta DAW. Les notes venues d'un ordinateur ou du jack ne sont jamais renvoyées (pas de boucle MIDI). C'est un réglage de la FM-1, comme SYNC.
+- **Sortie MIDI :** ce que tu joues aux touches sort toujours en MIDI USB (chaque piste sur son canal, la batterie sur 10). GLO → MIDI 2 → **OUT** = **SEQ** envoie aussi ce que jouent le séquenceur, l'arpégiateur et les rolls : pilote un autre synthé, ou enregistre le motif en notes dans ta DAW. Les notes venues d'un ordinateur ou du jack ne sont jamais renvoyées (pas de boucle MIDI). C'est un réglage de la FM-1, comme SYNC.
- **Les CC MIDI (2.5)** : les potards d'un contrôleur MIDI règlent le son de la piste que joue leur canal (comme les notes) : CC 7 volume, 10 panoramique, 74 le FILTRE de la piste (64 = coupé, en dessous passe-bas, au-dessus passe-haut), 71 résonance (ANALOG, TRIO, VOICE, NOISE), 73 / 75 / 72 attaque / decay / release, 5 glide, 91 / 93 / 94 les envois reverb / chorus / delay. Sur le canal de la batterie : 7, 91 et 94 = GLO → DRUMS → LVL, REV et DLY. Avec IN = CLOCK, les CC sont ignorés. La carte vient de Felucca 1.1.5.
+- **Sustain et pitch bend (2.6)** : la pédale de sustain (CC 64) garde les notes relâchées tant qu'elle est enfoncée (enregistrées comme entendues) ; le pitch bend fait glisser la hauteur de la piste du canal, jusqu'à BEND demi-tons (GLO → MIDI 2 : 1 à 12, 2 par défaut).
+- **Un seul canal (2.6) :** GLO → SYSTEM → **IN** = **CH 1 … CH 16** : SLOOP ne répond qu'à ce canal, sur la piste sélectionnée (notes et CC), pour un séquenceur dont les autres canaux pilotent d'autres appareils.
+- **MIDI LEARN (2.6, d'après Felucca 1.5) :** **GLO + F#3** (la ligne du haut affiche *LEARN*), tourne le bouton de SLOOP voulu (*T1 CUT: SEND A CC*), puis le potard de ton contrôleur (*CC 21 = T1 CUT*) ; d'autres si tu veux ; **GLO + F#3** pour finir. Un CC appris règle ce paramètre de cette piste sur n'importe quel canal, à la place de la carte ci-dessus (16 au plus ; gardés à l'extinction). Menu (tiens HOME) → SYSTEM → **MIDI LEARN CLEAR**, OCT+ : tout est oublié.
- Le MIDI Bluetooth n'est pas pris en charge (la radio reste éteinte).
## Le visualiseur
diff --git a/GUIDE.md b/GUIDE.md
index 5b73066..bfafe19 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -1,6 +1,6 @@
-# SLOOP 2.5 — The Complete Guide
+# SLOOP 2.6 — The Complete Guide
Everything SLOOP does, every button, every combination, every page, in one place. This guide is written to be read from the top the first time, then used as a reference: the [cheat sheet](#26-cheat-sheet) at the end has every combination on one page.
@@ -137,7 +137,7 @@ The layers are **FX** (punch-in effects), **EDIT** (erase), **ARP** (note repeat
4. Press **REC** again while it plays: you record on top (overdub). Hold **ARP** and hold the hat key (C4): a 1/16 hat roll, recorded as ratchets.
5. Turn **ALGORITHM** to track **1** (blue, *808 BOOM*), press **REC**, play a bass line.
6. Hold **SEL** and press the key of your song (for example D). Select track 2, hold **SEL** and turn **KNOB 1** to *7TH*: every white key is now a chord of the key, one finger each.
-7. Hold **FX** and hold a white key for a punch-in effect; still holding FX, turn **KNOB 2** for DUST, **KNOB 3** for DUCK.
+7. Hold **FX** and hold a key (white or black) for a punch-in effect; still holding FX, turn **KNOB 2** for DUST, **KNOB 3** for DUCK.
8. A mistake? **EDIT + OCT−**: undo.
---
@@ -262,7 +262,9 @@ 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 (up to 4 notes a step); held notes become ties.
+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*…).
+
+**With a MIDI keyboard:** REC records the **selected** track. A keyboard on channel 1, 2 or 3 always plays track 1, 2 or 3 (2.6: the channels of GLO → MIDI), whatever track is selected: set it to channel 4 (or 4–16) to play and record the selected track. From 2.6, if your keyboard plays another track than the one recording, the screen says *MIDI PLAYS TRACK n* (once a take).
### What REC does
@@ -324,11 +326,13 @@ All seven layers at a glance:
| Control | Does |
| --- | --- |
-| **FX + key 1–16** | the [punch-in effect](#punch-in-effects) of that key, on the whole mix, for as long as the key is held |
+| **FX + a key** | the [punch-in effect](#punch-in-effects) of that key (16 white keys, and 11 black keys, 2.6), on the whole mix, for as long as the key is held |
| **FX + KNOB 1** | master **FILTER**: left a low-pass, right a high-pass, centre off |
| **FX + KNOB 2** | master **DUST** (old sampler and vinyl) |
| **FX + KNOB 3** | master **DUCK** (sidechain pump from the kick) |
| **FX + KNOB 4** | **TRK FILT**: the same one-knob filter on the **selected track only** (any track, the drums too) |
+| **FX + OCT−** (held, 2.6) | **REV THROW**: every track's reverb send (the drums' too) goes full while held, gliding in and out (~12 ms); with a punch-in key too. The song's REV values never change, nothing is saved or recorded |
+| **FX + OCT+** (held, 2.6) | **ECHO THROW**: the same for the delay sends, and FDBK at least 70 % while held. Both together: both throws |
| **FX + HOME** | lock the FX layer open (both hands free) |
Keys pressed while FX is held never play or record notes.
@@ -344,9 +348,12 @@ Keys pressed while FX is held never play or record notes.
| **EDIT + KNOB 3** | **TRANSPOSE**: every note a semitone up / down (synth tracks) |
| **EDIT + OCT−** | **undo** |
| **EDIT + OCT+** | **redo** |
+| **EDIT + a black key** (drum track, 2.6) | **MUTE mode**: the white keys now **mute / unmute their sound** in the sequencer, live, without erasing anything (the muted sounds show *OFF* in red). A black key again, or letting go of EDIT, goes back to erasing |
All the knob turns of one EDIT hold count as one change for undo.
+The drum mutes stay on until you unmute the sound (EDIT + a black key, then its key again); they are a performance tool, not part of the pattern: a project loaded or a new one starts with every sound playing. A muted sound still plays from the keys and from MIDI, and its ratchets are muted too.
+
### ARP — roll (note repeat)
| Control | Does |
@@ -363,7 +370,7 @@ The 16 white keys are the 16 steps of the current page; the lit ones play.
| Control | Does |
| --- | --- |
-| **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 |
+| **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) |
@@ -372,7 +379,7 @@ The 16 white keys are the 16 steps of the current page; the lit ones play.
| **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 2** | **LEVEL**: ghost, soft, norm, hard |
+| **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) |
| **SEQ + step + PRESETS** | a **parameter lock** on that step: the first click makes it one click away from the track's value, the next ones move it |
@@ -403,6 +410,7 @@ Details in [Key, scales, chords and CHORD+](#11-key-scales-chords-and-chord).
| **GLO + key 9 (held)** | **fill** for as long as the key is held |
| **GLO + key 10** | **fill bar**: the whole next bar plays as a fill (press again before the bar to cancel) |
| **GLO + key 16** | **tap tempo** (two taps or more) |
+| **GLO + F#3** (the first black key, 2.6) | **MIDI LEARN** on / off; see [MIDI LEARN](#midi-learn-26) |
| **GLO + KNOB 1–4** | the **levels** of tracks 1–4 |
| **GLO + SELECT** | the tempo (also inside the visualiser) |
@@ -435,10 +443,10 @@ There are three ways to enter steps:
| STEP 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 |
+| **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** | **NOTE**, **TIE** (holds the previous note on) or **REST** |
+| 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 |
@@ -560,6 +568,7 @@ A muted track fades out in a few milliseconds and plays no new notes; its patter
| **New project** | SAVE → TOOLS → **NEW** (GO): the four tracks back to their power-on sounds, empty patterns, 90 BPM (stop the song first in song mode; undo brings back only the last track's pattern, so save a section first if in doubt) |
| **Save the loop as a section / project** | **SAVE + key 5–8** (A–D = project slots 1–4) |
| **Save / load a project** | SAVE → PROJECT: **SLOT** 1–4, **LOAD** (GO), **SAVE** (GO) |
+| **Erase a saved project / section** (2.6) | SAVE → PROJECT: **SLOT** 1–4 (= sections A–D), **ERASE** on KNOB 2 (GO), the song stopped: the slot is *EMPTY* again and its section key goes dark. The steps of the song that played it are taken out (the others keep their order; none left: the default song A B C D). Your working loop is not touched. No undo: save it into another slot first if in doubt |
| **Save a sound** | SAVE → USER: **SLOT** (1–32), **SAVE** (GO) |
| **Autosave** | automatic: when the transport is stopped and you have not touched anything for 2.5 s (at most every 20 s), the working project is kept in flash; at power-on SLOOP comes back exactly as you left it |
@@ -571,7 +580,7 @@ A **project** keeps the four tracks (sounds, patterns, kit, locks, nudges, fill
| --- | --- | --- | --- | --- |
| **PRESETS** | the sound (factory by kind, then user presets) | the engine (next / previous) | — | — |
| **USER** | **SLOT** 1–32 | **LOAD** (GO) | **ERASE** (GO) | **SAVE** (GO) |
-| **PROJECT** | **SLOT** 1–4 | — | **LOAD** (GO) | **SAVE** (GO) |
+| **PROJECT** | **SLOT** 1–4 | **ERASE** (GO, 2.6) | **LOAD** (GO) | **SAVE** (GO) |
| **TOOLS** | **CLRSQ** (GO) | **INIT** (GO) | — | **NEW** (GO) |
GO: one click shows *AGAIN: SAVE* (or LOAD…), a second click within about 1.5 s does it. Presets and projects are written to flash only while the song is stopped.
@@ -628,6 +637,8 @@ The song's settings can only be edited while it is stopped (*STOP FIRST*). An em
The **title line** of every screen also carries short messages: *KEY D*, *ERASED*, *AGAIN: SAVE*, *NEXT: B*, *chain A B B C*, *lock flt 12*…
+The lettering (2.6) is Terminus **Bold**, all in **capitals**: thicker strokes, easier to read on the small screen at arm's length; the layout is the same as before (same 8 × 16 cell).
+
---
## 16. Every page, knob by knob
@@ -637,32 +648,40 @@ Tap a button to open its first page (or the last one you used); **tap it again**
| Button | Page | KNOB 1 | KNOB 2 | KNOB 3 | KNOB 4 |
| --- | --- | --- | --- | --- | --- |
| **ENV** | **ENV** | ATK attack | DEC decay | SUS sustain | REL release |
-| | **ENV DEST** | FLT: envelope → brightness (±) | PIT: envelope → pitch (±, the 808 punch) | SHP: envelope → the engine's shape (±) | — |
+| | **ENV DEST** | FLT: envelope → brightness (±) | PIT: envelope → pitch (±, the 808 punch) | SHP: envelope → the engine's shape (±) | ESYNC (2.6): OFF / ON, ATK DEC REL as note values |
| **LFO** | **LFO** | RATE (Hz) | WAVE: SIN, TRI, SAW, SQR, S&H | PHS phase | FADE (fade-in time) |
+| | **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 | — | — | — |
| | **SLICER** | SLCR: OFF, GATE, STUT (stutter) | PAT: pattern 1–16 | RATE: 1/8, 1/16, 1/32, 8T, 16T, 32T | DEPTH |
-| | **DLY** (global) | TIME: 1/4, 1/8, 1/16, 1/32, 8T, 16T, 1/8D, 1/16D | FDBK feedback | COLR colour (tone of the repeats) | MIX |
+| | **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 | — | — | — |
+| | **DLY** (global) | TIME: 1/4, 1/8, 1/16, 1/32, 8T, 16T, 1/8D, 1/16D, 1/4D (2.6; at 60 BPM and below it stops at 1.49 s) | FDBK feedback | COLR colour (tone of the repeats) | MIX |
| | **REV/CHO** (global) | SIZE reverb size | DAMP reverb damping | CRT chorus rate | CDP chorus depth |
| **SEL** | **SEL** | ROOT (the track's key) | SCL: the track's scale (SEL + KNOB 2 sets all three) | QNT keys: OFF, SNAP, WHITE | CHORD: OFF, TRIAD, 7TH, 9TH, SUS4, POWER |
| | **SEL 2** | TRN transpose ±24 | STRUM ±60 ms | VLEAD: OFF / ON | — |
| **EDIT** | **EDIT 1** | engine parameter 1 | 2 | 3 | 4 (see [the engines](#the-twelve-engines)) |
| | **EDIT 2** | engine parameter 5 | 6 | 7 | 8 |
+| | **FILTER** (ANALOG only, 2.6) | TYPE: LP, BP, HP | CUT cutoff | RES resonance | KTR key tracking |
| | **VOICE** | VCE: POLY, MONO, LEG (legato), UNI (unison) | GLD glide | GLMOD: RATE / TIME | PRIO: LAST, LOW, HIGH (mono note priority) |
| | **VOICE 2** | ALLOC: ROT (rotate) / REUSE | DTUNE (unison detune) | PAN | MUTE |
| **ARP** | **ARP** | MODE: OFF, UP, DN, UPDN, RND, ORD | RATE: 1/4 … 16T | OCT: 1–4 octaves | GATE |
| | **ARP 2** | SWG swing | PROB probability of each note | HOLD: OFF / ON (latch) | ORD: NOTE (pitch order) / PLAY (the order you played) |
-| **SEQ** | **STEP** | STEP (cursor) | NOTE | TIME: NOTE, TIE, REST | FLAG: –, ACC, SLD, A+S |
+| **SEQ** | **STEP** | STEP (cursor) | NOTE | TIME: NOTE, TIE, REST · on a note: LEN (2.6) | FLAG: –, ACC, SLD, A+S |
| | **PATTERN** | LEN 1–64 steps | DIV 1/4 … 2BAR | SWG track swing | GATE note length |
| | **SONG** | the SONG screen | | | |
| **GLO** | **GLOBAL** | BPM 40–240 | SWING (all tracks) | CLICK: OFF, REC, ON | TUNE ±50 cents |
| | **MASTER** | DUST | DUCK | FILT (DJ filter) | ROLL (note-repeat rate) |
-| | **SYSTEM** | MIDI out: KEYS / SEQ | SYNC: INT, USB, TRS | IN: NOTES / CLOCK | CPU load (USB link state when no computer is connected) |
-| | **DRUMS** | CH: the drum track's MIDI input channel (0 = off, default 10) | LVL drum level | REV drum reverb | DLY drum delay (2.5): the drums into the tempo delay (FX → DLY sets its time, feedback and tone), saved with the project |
+| | **SYSTEM** | OUT (MIDI out): KEYS / SEQ (also on MIDI 2) | SYNC: INT, USB, TRS | IN: NOTES / CLOCK / CH 1–16 (also on MIDI 2) | CPU load (USB link state when no computer is connected) |
+| | **DRUMS** | CH4: the drum track's MIDI channel (OFF, 1–16, default 10; the same setting as GLO → MIDI → CH4; 2.6: a setting of the FM-1) | LVL drum level | REV drum reverb | DLY drum delay (2.5): the drums into the tempo delay (FX → DLY sets its time, feedback and tone), saved with the project |
+| | **TEXTURE** (2.6) | SRC: OFF, VINYL, TAPE, RAIN, WIND, RADIO, ROOM, USR1–4 | LEVEL | TONE (LP ← OFF → HP) | MOVE |
+| | **TEXTURE 2** (2.6) | RATE: 1–16 bars | WHEN: PLAY / ALWAYS | DUCK: OFF / ON | — |
+| | **MIDI** (2.6) | CH1: track 1's MIDI channel (OFF, 1–16) | CH2: track 2's | CH3: track 3's | CH4: the drum track's (default 10) |
+| | **MIDI 2** (2.6) | IN: NOTES / CLOCK / CH 1–16 | OTHER: the channels no track has: SEL (the selected track) / OFF | OUT: KEYS / SEQ | BEND: the pitch bend's range, 1–12 semitones |
| **SAVE** | **PRESETS** | the sound | the engine | — | — |
| | **USER** | SLOT 1–32 | LOAD (GO) | ERASE (GO) | SAVE (GO) |
-| | **PROJECT** | SLOT 1–4 | — | LOAD (GO) | SAVE (GO) |
+| | **PROJECT** | SLOT 1–4 | ERASE (GO) | LOAD (GO) | SAVE (GO) |
| | **TOOLS** | CLRSQ: clear the pattern (GO) | INIT: reset the sound (GO) | — | NEW project (GO) |
Notes:
@@ -671,6 +690,9 @@ Notes:
- **SYNC**, **MIDI** and **IN** are settings of the FM-1, kept when you load a project.
- On the **drum track**, the pages that work are SLICER, PATTERN (SEQ), the SONG screen and the global pages; its kit, level, reverb and pan are on the DRUMS kit page, and its filter is **FX + KNOB 4**.
- FM6 tracks ignore the ENV page and ENV DEST (each operator has its own envelope).
+- **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.
- On the screen, EDIT 1 and EDIT 2 carry the engine's own page names: ANALOG *OSC / FLT*, DIGITAL *OPS / MOD*, PHASE *PHS / LINE*, LOFI *CHIP / MOTN*, SAMPLE *SET / TONE*, VOICE *VOWL / TONE*, TRIO *OSC / TONE*, WHEEL *BARS / TONE*, GRAIN *GRAN / SPRY*, FM6 *OPS / PATCH*, PHYS *BODY / EXCT*, NOISE *SRC / MOVE*.
- Any sound parameter on these pages can be **locked** on a step (see [Parameter locks](#parameter-locks)), except the pattern, arp, key and voice-mode ones.
@@ -728,7 +750,7 @@ Edit full patches in the web editor's **FM6** panel (Sound page, on an FM6 track
### Signal path
-Each synth track: engine → **drive** (DST) → **SLICER** → **FILTER** (the track's own) → level (and DUCK) → pan and **sends** to the stereo chorus, the tempo delay and the reverb. The drum track has its own slicer, filter, level, pan, reverb send and (2.5) delay send. Then the whole mix, with the effect returns: **DUST** → **punch-in effects** → **FILT** (the DJ filter) → **MASTER** volume → limiter.
+Each synth track: engine → **drive** (DST) → **INSERT** (2.6) → **SLICER** → **FILTER** (the track's own) → level (and DUCK) → pan and **sends** to the stereo chorus, the tempo delay and the reverb. The drum track has its own INSERT (2.6), slicer, filter, level, pan, reverb send and (2.5) delay send. Then the whole mix, with the effect returns (and, 2.6, the **TEXTURE** bed): **DUST** → **punch-in effects** → **FILT** (the DJ filter) → **MASTER** volume → limiter (2.6: it looks one block, 0.7 ms, ahead: a loud hit is already turned down when it comes, never pushed into the output's soft clipper).
### Master: DUST, DUCK, FILT, ROLL
@@ -756,11 +778,46 @@ On FX + KNOB 1–3, or GLO → MASTER:
| 7 · E4 | tape stop | 15 · F5 | echo (dotted 1/8) |
| 8 · F4 | half speed | 16 · G5 | tape wobble |
+**FX + black key** (2.6): eleven more, on the black keys from the lowest F# to the highest.
+
+| Key | Effect | Key | Effect |
+| --- | --- | --- | --- |
+| F#3 | **KILL LOW**: the lows gone (below ~250 Hz, 24 dB/oct, DJ style) | F#4 | **FLANGER**: a jet sweep over a bar, left and right apart |
+| G#3 | **KILL MID**: the mids gone (~250 Hz – 2.5 kHz) | G#4 | **AUTO-PAN**: the mix in mono, left and right once a beat |
+| A#3 | **KILL HIGH**: the highs gone (above ~2.5 kHz) | A#4 | **FREEZE**: the mix poured into the reverb and held there for as long as you hold the key; let go and it dies away with the reverb's SIZE |
+| C#4 | **REWIND**: the record pulled back: it slows, stops and spins backwards faster and faster (about a third of a second of the past), then silence until you let go | C#5 | **LOOP 8T**: loop 1/8 triplet |
+| D#4 | **OCT UP**: the mix an octave up | D#5 | **MONO**: left and right in one |
+| | | F#5 | **FADE OUT**: the mix fades to nothing over two beats |
+
+The screen shows the 27 keys as a keyboard: the white keys in four rows of four, as on the other layers, the black keys above them, each between the two white keys it sits between on the FM-1 (the one after a row's last white key at the right end of that row). The effect held is lit white.
+
+### Texture (2.6)
+
+**GLO → TEXTURE** (and TEXTURE 2): a looping bed under the whole mix, the glue of lo-fi and ambient tracks, without taking a track. It goes into the dry mix (not the sends), before DUST, the punch-ins and the master filter.
+
+| Knob | TEXTURE | TEXTURE 2 |
+| --- | --- | --- |
+| 1 | **SRC**: OFF, **VINYL** (hiss, rumble, crackle), **TAPE** (dark hiss, drifting), **RAIN** (a bed and droplets), **WIND** (resonant gusts), **RADIO** (bursts of static), **ROOM** (room tone), **USR1–USR4** (your sample slot, its first sound looped at its own pitch) | **RATE**: how long MOVE's breath takes: 1, 2, 4, 8 or 16 bars of the tempo |
+| 2 | **LEVEL** | **WHEN**: PLAY (it fades in and out with the transport) / ALWAYS |
+| 3 | **TONE**: left a low-pass, right a high-pass, centre open | **DUCK**: ON, the kick pumps it too (GLO → MASTER → DUCK) |
+| 4 | **MOVE**: how much it breathes over RATE (its level and brightness) | — |
+
+The texture is saved with the project, and each song section (A–D) has its own. The generated sources use no memory; at SRC OFF nothing runs.
+
### Per track
- **FILTER** (FX → FILTER, or **FX + KNOB 4** for the selected track): one knob, left a low-pass, right a high-pass, centre off. It stays when you change the sound, can be locked on a step, and is saved with the project.
- **Sends** (FX page): DST drive, CHO chorus, DLY delay, REV reverb. The delay and the reverb / chorus settings are global (DLY and REV/CHO pages). The delay's TIME includes dotted 1/8 and 1/16.
- **SLICER** (FX → SLICER): a tempo gate (GATE) or stutter (STUT), 16 patterns, 1/8 to 32T, with a depth.
+- **INSERT** (FX → INSERT and INSERT 2, 2.6, after Felucca 1.5): one effect on the track alone, right after its drive; the drum track has one too, on the whole kit and its sends. MIX sets dry / wet. A, B and C change with the type:
+
+| Type | A | B | C |
+| --- | --- | --- | --- |
+| **SOFT** (soft clip), **HARD** (hard clip), **FOLD** (wavefolder), **FUZZ** | DRIVE | TONE | LEVEL |
+| **CRUSH** | BITS 1–16 | RATE (the sample rate, 689 Hz – 44 kHz) | LPF |
+| **PHASR** (phaser), **FLANG** (flanger), **CHOR** (chorus) | RATE | DEPTH | FDBK feedback |
+
+ A, B, C and MIX can be locked on a step. TYPE OFF (or MIX at 0) costs nothing: the track sounds exactly as without it.
---
@@ -803,7 +860,7 @@ The visualiser sees the mix **as if MASTER were all the way up**: with MASTER tu
| **SCREEN** | **COLOR**: the screen palette (GREEN, AMBER, CYAN, RED, MONO…) | **ZOOM**: ON shows the value you touch large and white | — |
| **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 SERIAL**: OFF / ON (developers; takes effect at the next start) |
-| **SYSTEM** | **HARDWARE CALIBRATION** (the knob selects it, OCT+ opens it) | **ABOUT**, the version (the knob selects it, OCT+ opens it) | — |
+| **SYSTEM** | **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) |
| Control in the menu | Does |
| --- | --- |
@@ -838,33 +895,42 @@ If a button or knob does the wrong thing, HOME menu → SYSTEM → **HARDWARE CA
Both work at once.
-### Channels
+### All the MIDI settings: GLO → MIDI and MIDI 2 (2.6)
-| MIDI channel | Plays |
-| --- | --- |
-| **1, 2, 3** | synth tracks 1, 2, 3 |
-| **10** | the drum track (the nearest of its 16 sounds; GLO → DRUMS → **CH** changes it, 0 = no drum input; the drums still go out on 10) |
-| **4–16** | the **selected** track: set your keyboard to channel 4 and it follows ALGORITHM |
+Every MIDI setting is on two pages of GLO (tap GLO until **MIDI**). They are settings of the FM-1: kept through power-off, not changed by a project, and in the web editor's backups.
-### MIDI settings (GLO → SYSTEM)
+| Page | KNOB 1 | KNOB 2 | KNOB 3 | KNOB 4 |
+| --- | --- | --- | --- | --- |
+| **MIDI**: which channel each track uses, in and out | **CH1** track 1 (default 1) | **CH2** track 2 (2) | **CH3** track 3 (3) | **CH4** the drum track (10) |
+| **MIDI 2**: how MIDI comes in and goes out | **IN** | **OTHER** | **OUT** | **BEND** |
+
+- **CH1–CH4:** OFF or 1–16. A track's channel plays it (notes, CCs, sustain, pitch bend, Program Change) and its keys and sequence go out on it. **OFF**: nothing in, nothing out for that track. Two tracks never share a channel: turn a channel onto one another track has and it goes on to the next free one, and the screen says whose it was (*CH 3 = TRACK 3*). Changing a channel ends whatever was still sounding on it, here and on the other gear. CH4 is also on GLO → DRUMS (the same setting).
+- **IN:** **NOTES** (notes, CCs and the clock: normal) · **CLOCK** (only the clock and START / CONTINUE / STOP; every note and CC ignored) · **CH 1 … CH 16** (only that one channel, always on the selected track; CH1–CH4 and OTHER are set aside, the clock still followed). Opening GLO → MIDI while IN is not NOTES says so on the screen (*IN CH 5: SEL TRK ONLY*, *IN = CLOCK: NO NOTES*).
+- **OTHER:** what a channel that no track has does: **SEL** plays the selected track (set your keyboard to channel 4 and it follows ALGORITHM) · **OFF** ignores it (a sequencer's channels for other gear on the same cable).
+- **OUT:** **KEYS** only what you play on the keys goes out · **SEQ** the sequencer, the arp and the rolls go out too.
+- **BEND:** the pitch bend's range, 1–12 semitones (default 2).
+
+IN and OUT are also on GLO → SYSTEM, next to SYNC (the clock), where they were before 2.6.
+
+**Examples.** A keyboard on channel 1 plays track 1; select another track and play it from channel 4 (OTHER = SEL). An external sequencer with drums on 10, bass on 2, pad on 11, lead on 8: CH1 = 2, CH2 = 11, CH3 = 8, CH4 = 10, OTHER = OFF. A KeyStep Pro whose other channels drive other gear: IN = CH n, and that channel plays the selected track.
+
+### MIDI out, clock in (GLO → SYSTEM)
| Knob | Setting | Choices |
| --- | --- | --- |
-| KNOB 1 | **MIDI** (out) | **KEYS**: only what you play on the keys goes out · **SEQ**: the sequencer, the arp and the rolls go out too |
+| KNOB 1 | **OUT** (MIDI out) | as on MIDI 2 |
| KNOB 2 | **SYNC** (clock in) | **INT**: SLOOP's own tempo · **USB** or **TRS**: follow that MIDI clock |
-| KNOB 3 | **IN** | **NOTES**: notes, CCs and clock · **CLOCK**: only the clock and START / CONTINUE / STOP, every incoming note and CC ignored |
+| KNOB 3 | **IN** | as on MIDI 2 |
| KNOB 4 | **CPU** | the processor load (or the USB link state while no computer is connected) |
-All three are settings of the FM-1, kept when you load a project.
-
-- **MIDI out:** each track on its channel (1–3 synths, 10 drums). With **SEQ**, set a DAW track to record the FM-1's MIDI and you get the pattern as notes, or let SLOOP drive another synth. Every note is ended, STOP ends whatever was still on, and notes that came in are never sent back (no MIDI loop).
+- **MIDI out:** each track on its channel (CH1–CH4). With **SEQ**, set a DAW track to record the FM-1's MIDI and you get the pattern as notes, or let SLOOP drive another synth. Every note is ended, STOP ends whatever was still on, and notes that came in are never sent back (no MIDI loop).
- **Clock in:** START plays from the top, CONTINUE carries on, STOP stops; the tempo follows the master pulse by pulse (24 a beat), so SLOOP cannot drift. When the clock stops for half a second, PLAY on the FM-1 plays at its own tempo again. A MIDI START during the REC count-in starts and records at once.
-- **Clock only (IN = CLOCK):** for a DAW or sequencer that sends notes to other gear on the same cable. A note-off still gets through, so nothing held when you switch is left hanging.
+- Switching IN, or a channel, releases any note still held: nothing is left hanging.
- **Bluetooth MIDI** is not supported: SLOOP never switches the radio on.
### MIDI CCs (2.5)
-The knobs of a MIDI controller set the sound (the standard CC map of Felucca 1.1.5). A CC acts on the track its channel plays, as the notes do (1–3 the synths, the drum channel the drum track, 4–16 the selected track), and sets its parameter as a knob would: 0–127 over the parameter's range, 64 the middle of PAN and FILTER. It changes the sound's value itself (as a knob, so saving keeps it); the screen and the web editor follow.
+The knobs of a MIDI controller set the sound (the standard CC map of Felucca 1.1.5). A CC acts on the track its channel plays, as the notes do (each synth track's channel, the drum channel the drum track, the others the selected track), and sets its parameter as a knob would: 0–127 over the parameter's range, 64 the middle of PAN and FILTER. It changes the sound's value itself (as a knob, so saving keeps it); the screen and the web editor follow.
| CC | Sets |
| --- | --- |
@@ -876,7 +942,20 @@ The knobs of a MIDI controller set the sound (the standard CC map of Felucca 1.1
| 74 | the track's FILTER: 64 off, lower a low-pass, higher a high-pass (every engine, the drums too) |
| 91 · 93 · 94 | the reverb, chorus and delay sends (on the drum channel 91 and 94 are GLO → DRUMS → REV and DLY) |
-Other CCs (mod wheel, sustain, pitch bend…) are ignored.
+**Sustain and pitch bend (2.6).** The **sustain pedal** (CC 64, on the track its channel plays): while it is down, a note you let go keeps sounding until the pedal comes up (the arp keeps it, a recording holds it as you hear it; a note played again meanwhile ends with its key). **Pitch bend** bends the track its channel plays, smoothly, by up to **BEND** semitones (GLO → MIDI 2: 1–12, default 2); the drum track ignores it. Other CCs (mod wheel…) are ignored, unless you map them with MIDI LEARN.
+
+**Program Change (2.6, after Felucca 1.5.1 and @renebohne's PR #179).** A Program Change on a track's channel loads its sound: on a synth track, number *n* is the *n*-th sound of the PRESETS list (0 the first: 808 BOOM; the 153 factory sounds by kind, then your user presets in order), on the drum channel kit *n*. A number past the end is ignored. The screen says *T2 PROG 5*. IN = CLOCK ignores it; IN = CH n sends it to the selected track.
+
+### MIDI LEARN (2.6)
+
+Any knob of your controller onto any parameter of a track (after Felucca 1.5):
+
+1. **GLO + F#3** (the first black key): *LEARN: TURN A KNOB*; the top line shows **LEARN**.
+2. Turn the knob of SLOOP you want (any page of the track, or LEVEL / PAN on TRACKS): *T1 CUT: SEND A CC*.
+3. Move the knob on your controller: *CC 21 = T1 CUT*. Go on with other knobs, as many as you like.
+4. **GLO + F#3** again: *LEARN DONE*.
+
+A learned CC sets that track's parameter whatever channel it comes on, and no longer does what the standard map gave it (a CC learned for one parameter is taken off the one it had before; up to 16 CCs). The CCs with a meaning of their own are never learned: bank select (0, 32), mod wheel (1), data entry (6, 38), expression (11), sustain (64), 96–101 and the channel modes (120–127). What is learned is a setting of the FM-1, kept through power-off and projects, and in the web editor's backups (restored with them, on this FM-1 or another); **HOME menu → SYSTEM → MIDI LEARN CLEAR**, OCT+, forgets it all.
---
@@ -961,6 +1040,8 @@ SLOOP 2.5: the editor's **Drum synth** page changes every value of a synthesised
Open it from the [installer page](https://isod89.github.io/sloop-fm1/), the [editor link](https://isod89.github.io/sloop-fm1/webapp/editor/), or **`OPEN-EDITOR.bat`**, in **Chrome or Edge** with the FM-1 on USB, and press **Connect** (allow MIDI). It follows the device live: turn a knob on the FM-1, the editor moves. It looks like the FM-1: the black screen, the four track colours, the FM-1's own pixel font. The language button switches English / Japanese.
+**Offline (2.6).** *Download the editor* (under Connect, or on the installer page) saves the whole editor as one file, `sloop-editor-2.6.html`, also attached to each [release](https://github.com/isod89/sloop-fm1/releases). Double-click it: it opens in Chrome or Edge without internet (Chrome asks once to allow MIDI) and works as the online one. Its sound library (kept in the browser) is its own, apart from the online editor's: move sounds between them with Export / Import, or a backup.
+
**Layout:** the side bar has the pages in three groups — **Track** (Sound, Sequencer, Tracks, Song), **Sounds** (Library, Samples, Drum kit, Drum synth), **Device** (Projects, Settings) — and the connection. On top: the page title, the messages, and on the Track pages the **four tracks** (number, sound, engine): click one to select it. With the side bar focused, the arrow keys move between pages.
**Values:** each value is a tile you **drag up or down like a knob** (Shift: fine), or a bar: click it, then the wheel or the arrow keys (Shift: steps of 10); **double-click** resets it.
@@ -1028,7 +1109,7 @@ On the installer page, open **Return to the official firmware (V15)**: save a ba
| The black keys are silent on a synth track | it plays chords or the scale: SEL → CHORD OFF and KEYS OFF (with a chord on, the black keys change the chord: CHORD+) |
| Recorded notes move | SLOOP quantises to the track's DIV: use 1/32, or nudge the step (SEQ + step + KNOB 4) |
| Notes fade out on a dense part | the processor is at its limit; SLOOP fades one voice at a time (never the bass or lead) rather than glitching. Fewer held notes or a lighter engine help |
-| Nothing from the MIDI IN jack | try the other adapter type (A / B); check the channel (1–3, 10, 4–16) and that GLO → SYSTEM → IN is NOTES |
+| Nothing from the MIDI IN jack | try the other adapter type (A / B); check the channel (GLO → MIDI: CH1–CH4; MIDI 2: OTHER) and that GLO → MIDI 2 → IN is NOTES |
| The USB audio input does not show | replug the FM-1; on a Mac keep USB SERIAL OFF and restart the FM-1; in Audacity: Transport → Rescan Audio Devices |
| The USB recording is quiet | HOME menu → USB AUDIO = FULL, or MASTER up |
| An FM6 sound changed after loading a project | store the edited patch in the bank (editor → FM6 → Store in bank) and set PTCH to it |
@@ -1061,13 +1142,13 @@ On the installer page, open **Return to the official firmware (V15)**: save a ba
| Hold + | Keys | KNOB 1 | KNOB 2 | KNOB 3 | KNOB 4 | Other |
| --- | --- | --- | --- | --- | --- | --- |
-| **FX** | punch-in effects 1–16 | master FILTER | DUST | DUCK | track FILTER | + HOME: lock |
-| **EDIT** | erase sound / note | SHIFT | LENGTH ×2 / ½ | TRANSPOSE | — | OCT− undo · OCT+ redo |
+| **FX** | punch-in effects: 16 white keys, 11 black keys | master FILTER | DUST | DUCK | track FILTER | + HOME: lock |
+| **EDIT** | erase sound / note · black key: drum MUTE mode (white keys mute / unmute) | SHIFT | LENGTH ×2 / ½ | TRANSPOSE | — | OCT− undo · OCT+ redo |
| **ARP** | note repeat | RATE | — | — | — | OCT− / OCT+: ghost / hard (drums) |
| **SEQ** | steps · black keys 1–4: page | SOUND / NOTE | DIV | SWING | LENGTH | OCT− / OCT+: page |
-| **SEQ + step** | more steps | drums: which sound · synths: NOTE | LEVEL | RATCHET | NUDGE | PRESETS lock · ALGORITHM lock parameter · OCT+ fill condition · OCT− clear nudge, locks, condition |
+| **SEQ + step** | more steps | drums: which sound · synths: NOTE | drums: LEVEL · synths: VEL | RATCHET | NUDGE | PRESETS lock · ALGORITHM lock parameter · OCT+ fill condition · OCT− clear nudge, locks, condition |
| **SEL** | key of the song | CHORD | SCALE | KEYS | TRANSPOSE | — |
-| **GLO** | 1–4 mute · 5–8 solo · 9 fill · 10 fill bar · 16 tap tempo | level 1 | level 2 | level 3 | level 4 | SELECT: tempo |
+| **GLO** | 1–4 mute · 5–8 solo · 9 fill · 10 fill bar · 16 tap tempo · F#3 MIDI LEARN | level 1 | level 2 | level 3 | level 4 | SELECT: tempo |
| **SAVE** | 1–4 play A–D (several: chain) · 5–8 save A–D · 13 loop / song · 14 SONG REC · 16 song screen | — | — | — | — | — |
| **any layer + HOME** | lock it open | | | | | any other button unlocks |
@@ -1109,9 +1190,18 @@ On the installer page, open **Return to the official firmware (V15)**: save a ba
| delay time | FX → DLY → TIME |
| chords | SEL + KNOB 1 · SEL page |
| STRUM, VLEAD | SEL 2 |
-| your projects | SAVE + keys 1–4 (play) / 5–8 (save) · SAVE → PROJECT |
+| your projects | SAVE + keys 1–4 (play) / 5–8 (save) · SAVE → PROJECT (LOAD, SAVE, ERASE) |
| your sounds | SAVE → USER · PRESETS (after the factory sounds) |
| MIDI out / clock / clock only | GLO → SYSTEM: MIDI · SYNC · IN |
+| each track's MIDI channel | GLO → MIDI (CH1 CH2 CH3 CH4) |
+| MIDI in / out, the other channels, the bend | GLO → MIDI 2 (IN OTHER OUT BEND) |
+| a vinyl / tape / rain bed under the mix | GLO → TEXTURE (2.6) |
+| MIDI LEARN | GLO + F#3 · forget: hold HOME → SYSTEM → MIDI LEARN CLEAR |
+| 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) |
+| 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/LICENSING.md b/LICENSING.md
index 34aca58..eb4d0e9 100644
--- a/LICENSING.md
+++ b/LICENSING.md
@@ -45,7 +45,7 @@ assets, is entirely governed by the GPL.
| What | Licence | Where |
| --- | --- | --- |
| Instrument and drum samples (Versilian Studios VSCO-2 CE, VCSL; Sonic Pi: SCRCH) | CC0 1.0 | `assets/samples-cc0/`, provenance in `ATTRIBUTION.txt` there |
-| Terminus font 8x16 (ter-u16n): the FM-1's screen, and the web editor's font (`tools/gen_webfont.py` makes it a TrueType font inlined in `web/editor.html`) | SIL OFL 1.1 | `assets/fonts/ter-u16n.bdf`, `assets/fonts/Terminus-LICENSE.txt` |
+| Terminus font 8x16: the FM-1's screen (Terminus Bold, ter-u16b, SLOOP 2.6), and the web editor's font (the regular ter-u16n; `tools/gen_webfont.py` makes it a TrueType font inlined in `web/editor.html`) | SIL OFL 1.1 | `assets/fonts/ter-u16b.bdf`, `assets/fonts/ter-u16n.bdf`, `assets/fonts/Terminus-LICENSE.txt` |
| Fukiai icon font (Hügelton Instruments), web editor only | MIT | `web/fukiai.ttf`, `web/FUKIAI-LICENSE.txt` |
| CrispyZebra by Leo Kuroshita (): the PHASE engine's waveforms are a C port of its oscillator | GPL-3.0 | `firmware/src/eng_phase.c` |
| klattsch by Tony Gies (): design reference for the VOICE (formant) engine; no code copied. Formant data from Klatt (1980) / Hillenbrand et al. (1995) | MIT (klattsch) | credit only |
diff --git a/README.md b/README.md
index 1955b29..8e32ec8 100644
--- a/README.md
+++ b/README.md
@@ -17,11 +17,11 @@ Free and open source (GPL-3.0), based on
+
A groovebox you play live: four tracks — three synths and a drum machine — 12 synth engines (with six-operator FM and DX7 patches), 153 sounds, 37 drum kits from 808 to techno, amapiano and ambient, your own samples and drum kits, 16 punch-in effects. House, techno, hip-hop, drum & bass, synthwave, lo-fi, ambient: make what you want. No factory patterns, nothing to load: everything you hear, you play.
+
A groovebox you play live: four tracks — three synths and a drum machine — 12 synth engines (with six-operator FM and DX7 patches), 153 sounds, 37 drum kits from 808 to techno, amapiano and ambient, your own samples and drum kits, 27 punch-in effects. House, techno, hip-hop, drum & bass, synthwave, lo-fi, ambient: make what you want. No factory patterns, nothing to load: everything you hear, you play.
153sounds, 12 engines, your samples
37drum kits, 909 to afro, + your own
-
16punch-in fx: hold fx + key
+
27punch-in fx: hold fx + key
recno click: the loop follows you
@@ -87,6 +87,7 @@
+
@@ -171,6 +172,10 @@ const IS_OTA = (id) => /^ota-/i.test(id.model);
// the update loader of SLOOP / Felucca packages ("ota-FM-1_9XX"). A device left in the update mode of another
// firmware (the stock updater's loader) is never written: its loader may lay the image out differently.
const OUR_LOADER = (id) => /^ota-FM-1_9\d\d$/i.test(id.text);
+// the MIDI ports the installer may probe (never other gear): the FM-1 under SLOOP / Felucca ("Felucca"), under
+// CLIPPER ("Clipper", its sister firmware), under a firmware named after itself ("SLOOP"), the update loaders, and
+// the names Windows / macOS give the stock firmware
+const FM1_PORT = /fm-1|felucca|sloop|clipper|ota|composite|sinco|usb-midi/i;
// errors carry a code the pages translate: notfound, model, stopped, noloader, lost, noreturn,
// mismatch (detail: the identity the device reports), badreq, foreign (detail: the loader's identity)
@@ -278,7 +283,7 @@ class Updater {
const outs = [...this.access.outputs.values()];
for (const input of this.access.inputs.values()) {
if (input.state === "disconnected") continue;
- if (!/fm-1|felucca|ota|composite|sinco|usb-midi/i.test(input.name || "")) continue; // never probe other gear
+ 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;
try { await input.open(); await output.open(); } catch (_) { continue; }
@@ -290,6 +295,12 @@ class Updater {
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) {
const end = Date.now() + ms;
while (Date.now() < end) {
@@ -333,7 +344,7 @@ class Updater {
async install(image, product, onStep) {
const step = onStep || (() => {});
const dev = await this.find((id) => !IS_OTA(id));
- if (!dev) throw fail("notfound", "FM-1 not found (USB cable, and no other app using it?)");
+ if (!dev) throw fail("notfound", "FM-1 not found (USB cable, and no other app using it?)", this.seen());
const [model] = product.split("_");
if (dev.id.model !== model) { dev.link.close(); throw fail("model", `the device is ${dev.id.text}, the package is for ${product}`); }
step("start", dev.id.text);
@@ -400,6 +411,7 @@ const TEXT = {
warn: "書き込み中は USB を抜かないでください。",
install: "インストール", other: "English",
editor: "エディタ(インストール後、パソコンから音色やシーケンスを編集)",
+ edOffline: "エディタをダウンロード(インターネットなしで使う:ファイルを Chrome / Edge で開く)",
direct: "USB ケーブルはパソコンに直接つないでください。Probe や Transporter などの機材は不要です。",
brick: "万一インストールに失敗して起動しなくなった場合は、復旧に Transporter が必要です:",
beta: "これはベータ版で、不安定な場合があります。このカスタムファームウェアを使ったことで FM-1 が壊れたり不具合が起きたりしても、作者は一切の責任を負いません。自己責任でお使いください。",
@@ -434,6 +446,7 @@ const TEXT = {
warn: "Do not unplug the USB cable while writing.",
install: "Install", other: "日本語",
editor: "Editor (after installing: edit sounds and sequences from the computer)",
+ edOffline: "Download the editor to use it without internet (open the file in Chrome or Edge)",
direct: "Connect the USB cable directly to the computer. No probe or Transporter is needed.",
brick: "If an install fails and the FM-1 no longer starts, recovering it needs a Transporter:",
beta: "This is a beta and may be unstable. The author accepts no responsibility if your FM-1 is damaged or misbehaves because of this custom firmware. Use it at your own risk.",
@@ -479,7 +492,7 @@ 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.5", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.5.fwsc", "sha256": "b23f95c40ab9ba9e3f3a1dbfc30f7f693d7ebe323b613c0f87d7b433048c741f"};
+const meta = {"version": "2.6", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.6.fwsc", "sha256": "199829bb5b892feae9058158dfed7a137c83ec4d8dfc1223761be1f5614ad6a2"};
let writing = false, stock = null;
const lockAll = (on) => {
diff --git a/firmware/src/arranger.h b/firmware/src/arranger.h
index b6b4cf1..f4f5470 100644
--- a/firmware/src/arranger.h
+++ b/firmware/src/arranger.h
@@ -65,6 +65,25 @@ static int arr_next(arr_clock_t *r, const arr_config_t *c, uint32_t sample_rate)
}
return result;
}
+/* (SLOOP 2.6) a section erased: the song's steps that played it taken out, the others kept in order; none left: the
+ * default song. 1 if the song changed */
+static int arr_drop_scene(arr_config_t *c, uint32_t scene)
+{
+ uint32_t i, n = 0, count = c->count > ARR_STEPS ? ARR_STEPS : c->count;
+ for (i = 0; i < count; i++)
+ if (c->entry[i].scene != scene)
+ c->entry[n++] = c->entry[i];
+ if (n == count)
+ return 0;
+ for (i = n; i < ARR_STEPS; i++) {
+ c->entry[i].scene = (uint8_t)(i % ARR_SCENES);
+ c->entry[i].bars = 4;
+ }
+ c->count = (uint8_t)n;
+ if (!n)
+ arr_defaults(c);
+ return 1;
+}
static void arr_elapse(arr_clock_t *r, uint32_t samples, uint32_t bpm)
{
if (r->running) r->phase += samples * bpm;
diff --git a/firmware/src/core.h b/firmware/src/core.h
index 33c30d9..8ebf90c 100644
--- a/firmware/src/core.h
+++ b/firmware/src/core.h
@@ -65,6 +65,11 @@ enum { /* per-track parameters */
P_TFLT, /* SLOOP 2.4: the track's filter, < 0 low-pass, > 0 high-pass (fx.c) */
P_STRUM, /* SLOOP 2.4: a chord's notes one after the other, ms each (> 0 down, < 0 up) */
P_VLEAD, /* SLOOP 2.4: chord mode, each chord voiced nearest the last (seq.c) */
+ /* SLOOP 2.6, after Felucca 1.5 / 1.4 (Leo Kuroshita). Projects (format 6) keep them in a byte each: 0..127 */
+ P_ITYPE, P_IA, P_IB, P_IC, P_IMIX, /* the track's INSERT after DIST: TYPE, its three values, dry / wet (fx.c) */
+ P_FTYPE, /* ANALOG's filter TYPE: LP (as before) / BP / HP (eng_analog.c) */
+ P_ESYNC, /* ENV SYNC: ATK DEC REL as note values of the tempo (voice.c) */
+ P_LSYNC, P_LTRIG, P_LPOL, /* LFO 2: SYNC to the tempo, TRIG (NOTE / FREE), POL (BI / UNI) (voice.c) */
P_E0, P_E1, P_E2, P_E3, P_E4, P_E5, P_E6, P_E7,
P_COUNT
};
@@ -82,6 +87,13 @@ enum { /* global parameters */
G_ROLL, /* note repeat rate (ARP + key, seq.c) */
G_NEWPRJ, /* TOOLS > NEW: a new project (GO) */
G_DRDLY, /* SLOOP 2.5: the drums' delay send (GLO > DRUMS; a project keeps it in its own byte) */
+ G_CH1, G_CH2, G_CH3, /* SLOOP 2.6: GLO > MIDI, the MIDI channel of synth tracks 1..3 (0 OFF, 1..16; in and out) */
+ G_CHOTH, /* .. and what the other channels play: 0 SEL (the selected track), 1 OFF. Settings of
+ * the FM-1 (with G_DRCH): not in a project (project.c, panel.c midi_set) */
+ G_TXSRC, G_TXLVL, G_TXTONE, G_TXMOVE, /* SLOOP 2.6, GLO > TEXTURE: a looping bed under the mix (fx.c texture_*): */
+ G_TXRATE, G_TXWHEN, G_TXDUCK, /* its source, level, tone, movement; its rate, when it plays, the DUCK pump.
+ * In a project (project.c: the spare bytes) */
+ G_BEND, /* SLOOP 2.6, GLO > MIDI 2: the pitch bend's range, 1..12 semitones (a setting of the FM-1) */
G_COUNT
};
@@ -232,6 +244,7 @@ typedef struct track {
int16_t lk_base[NLOCK];
int16_t lk_set[NLOCK];
uint32_t seq_abs; /* the step of the transport grid last played (seq.c trk_grid), SEQ_NONE */
+ int16_t bend, bend_s; /* 2.6: MIDI pitch bend -8192..8191 (seq.c), and as it glides (voice.c, a block at a time) */
uint16_t seq_idx; /* its index in the pattern */
uint8_t seq_den; /* the DIV it was played on (a DIV change waits for the next step) */
uint8_t arp_den; /* the same for the arp's RATE */
@@ -266,11 +279,16 @@ typedef struct track {
int32_t dist_hp, dist_lp1, dist_lp2; /* DIST insert state (fx.c) */
int32_t att; /* mute / solo fade: attenuation, Q15 (0 = heard; fx.c mix_part, drums_mix) */
uint8_t dist_on; /* DIST was on in the last block (its states restart when it comes on) */
- uint8_t tail; /* blocks to mix after the last voice (the DIST tail) */
+ uint8_t tail; /* blocks to mix after the last voice (the DIST / INSERT tail) */
+ uint8_t ins_run; /* 2.6: the INSERT runs (or fades out) (fx.c track_insert) */
int16_t armp, aholdp; /* P_AMODE / P_AHOLD as last seen by the ISR */
/* engine switch (voice.c engine_block): the old engine's voices fade out, then it switches */
uint8_t xf_on, xf; /* fading; blocks of the fade still to render */
int16_t pe_old[8]; /* P_E0..P_E7 of the sounding engine: the fade renders with these */
+ int16_t p_old[P_COUNT]; /* 2.6: the whole sound before a preset loaded (voice.c sound_change): the fade's */
+ uint8_t pold; /* 1: a preset loaded, the sounding voices fade out with p_old first */
+ uint16_t ins_res; /* 2.6: |the INSERT's last output| (fx.c: its tail runs until it is ~0) */
+ uint8_t ins_xt; /* 2.6: the blocks it ran past its tail for that (at most 255) */
uint8_t xp_n, xp_note[4], xp_vel[4]; /* note-ons during the fade, played on the new engine */
} track_t;
@@ -314,12 +332,20 @@ static uint32_t div_units(uint32_t div)
/* the delay's TIME in clock units (N_DLY order) */
static uint32_t dly_units(uint32_t d)
{
- return d < NDIV_SHORT ? BEAT_U / DIV_DEN[d] : d == NDIV_SHORT ? BEAT_U * 3u / 4u : BEAT_U * 3u / 8u;
+ return d < NDIV_SHORT ? BEAT_U / DIV_DEN[d] : d == NDIV_SHORT ? BEAT_U * 3u / 4u : d == NDIV_SHORT + 1u ? BEAT_U * 3u / 8u
+ : BEAT_U * 3u / 2u; /* 1/4D (2.6) */
}
/* length of one step (N_SDIV order) in samples at the song tempo (rounded down) */
static uint32_t div_samples(uint32_t div) { return div_units(div) / (uint32_t)song.g[G_BPM]; }
/* length of the delay's TIME (N_DLY order) in samples at the song tempo (rounded down) */
static uint32_t dly_samples(uint32_t d) { return dly_units(d) / (uint32_t)song.g[G_BPM]; }
+/* SLOOP 2.6, after Felucca 1.5.1: REV THROW / ECHO THROW (FX held + OCT- / OCT+, ui_input.c): while held, every
+ * track's send to the reverb / the delay goes full, gliding in and out (~12 ms); ECHO THROW also takes the delay's FDBK
+ * 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;
+static int32_t thr_rev, thr_dly;
+static inline int32_t send_thr(int32_t s, int32_t g) { return g ? s + (((127 * 258 - s) * g) >> 15) : s; } /* s 0..32766 */
#define TSEL (&trk[song.sel]) /* the selected track */
#define TDRUM (&trk[TRK_DRUM])
static int is_drum(const track_t *t) { return t == TDRUM; }
diff --git a/firmware/src/drum_synth.c b/firmware/src/drum_synth.c
index fb831a4..b48c036 100644
--- a/firmware/src/drum_synth.c
+++ b/firmware/src/drum_synth.c
@@ -206,8 +206,10 @@ static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
{
const dsnd_t *d = s->d;
uint32_t i, src = d->src & 15u, wave = d->wave, fmode = s->fmode & 3u, fall = s->fmode & DF_ALL;
- int32_t da = (s->amp_to - s->amp) >> CTL_LOG2, dn = (s->nz_to - s->nz) >> CTL_LOG2; /* (no divide) */
- int32_t dc = (s->ck_to - s->ck) >> CTL_LOG2;
+ /* (2.6, a whistle on the kicks) the levels glide to their targets exactly: a0 + r (i + 1) / CTL. A step of
+ * r >> CTL_LOG2 a sample fell up to CTL - 1 short and jumped the rest at every block: a click 1378 times a
+ * second under the kick's long sine (tones at 1.4 / 2.8 kHz). The pitch keeps its step (a frequency, no jump) */
+ int32_t a0 = s->amp, ra = s->amp_to - s->amp, z0 = s->nz, rn = s->nz_to - s->nz, c0 = s->ck, rc = s->ck_to - s->ck;
int32_t di = (int32_t)(s->inc_to - s->inc) >> CTL_LOG2;
int32_t a = s->amp, z = s->nz, c = s->ck, inc = (int32_t)s->inc;
int32_t drive = 16 + d->drive, bits = s->crush & 15, hold = (s->crush >> 4) + 1;
@@ -294,9 +296,9 @@ static int ds_render(dsv_t *s, int32_t *out, uint32_t n)
x = s->held;
}
out[i] = ((mulq15(x, s->gain) >> 2) * s->lg) >> 8;
- a += da;
- z += dn;
- c += dc;
+ a = a0 + ((ra * (int32_t)(i + 1u)) >> CTL_LOG2); /* (|r| < 2^17: no overflow) */
+ z = z0 + ((rn * (int32_t)(i + 1u)) >> CTL_LOG2);
+ c = c0 + ((rc * (int32_t)(i + 1u)) >> CTL_LOG2);
inc += di;
}
s->t += n;
diff --git a/firmware/src/drums.c b/firmware/src/drums.c
index f673fd7..6ce645c 100644
--- a/firmware/src/drums.c
+++ b/firmware/src/drums.c
@@ -313,7 +313,8 @@ 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 = song.g[G_DRREV] * 258, dsend = song.g[G_DRDLY] * 258, pk = drums.peak;
+ int32_t lvl = song.g[G_DRLVL] * 200, 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);
for (i = 0; i < n && drums.tail; i++) { /* declick tail, ~0.4 ms */
if (mono) {
diff --git a/firmware/src/editor.c b/firmware/src/editor.c
index 01c2650..387e601 100644
--- a/firmware/src/editor.c
+++ b/firmware/src/editor.c
@@ -398,6 +398,7 @@ static const param_desc_t *ed_desc(uint32_t scope, uint32_t id, int16_t **vp)
_Static_assert(sizeof proj_tmp >= sizeof(project_t) && sizeof proj_tmp >= sizeof(up_bank_t) &&
sizeof proj_tmp >= sizeof(persist_t), "backup staging");
static persist_t ed_bk_set; /* LIST's snapshot of the settings */
+static uint8_t ed_bk_ml[MIDI_PART]; /* .. and of the MIDI part (2.6, object 10: project.c) */
static uint8_t ed_bk_valid, ed_bk_put, ed_bk_id;
static uint32_t ed_bk_len, ed_bk_crc, ed_bk_pos, ed_bk_ms;
static void ed_bk_u32(uint32_t v) { uint32_t i; for (i = 0; i < 5u; i++) ed_b((v >> (7u * i)) & 127u); }
@@ -437,6 +438,14 @@ static const uint8_t *ed_bk_obj(uint32_t id, uint32_t *len) /* 0 = no such obj
*len = sizeof dsu;
return (const uint8_t *)&dsu;
}
+ if (id == 10u) { /* SLOOP 2.6: the MIDI part (the MIDI LEARN map, GLO > MIDI's
+ * channels): listed only while it is not the default (a backup
+ * without it stays one an older editor reads; its restore leaves
+ * them as they are) */
+ if (!midi_part_default(ed_bk_ml))
+ *len = sizeof ed_bk_ml;
+ return ed_bk_ml;
+ }
if (id >= 32u && id < 32u + SMP_USER_SLOTS) {
const smp_user_hdr_t *h = (const smp_user_hdr_t *)smp_user_xip(id - 32u);
if (h->magic == SMP_USER_MAGIC && h->version == 1u && h->nz && h->nz <= 16u &&
@@ -446,7 +455,8 @@ static const uint8_t *ed_bk_obj(uint32_t id, uint32_t *len) /* 0 = no such obj
}
return 0;
}
-static const uint8_t ED_BK_IDS[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 32, 33, 34, 35}; /* 35: USR4 (2.4), 9: SYN kits (2.5) */
+static const uint8_t ED_BK_IDS[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 32, 33, 34, 35}; /* 35: USR4 (2.4), 9: SYN kits (2.5),
+ * 10: MIDI LEARN (2.6) */
/* a flash erase silences the audio for ~50 ms and stalls USB: only while stopped (as the panel) */
static uint32_t ed_flash_busy(void) { return song.playing || transport_req; }
@@ -503,6 +513,19 @@ static uint32_t ed_bk_commit(void)
persist_saved = p;
return 0;
}
+ if (id == 10u) { /* SLOOP 2.6: the MIDI part, written with the settings */
+ persist_t p;
+ if (ed_flash_busy())
+ return 3;
+ if (n != MIDI_PART && n != 2u * ML_N && n != 2u * ML_N + 4u)
+ return 2;
+ midi_part_read(raw, n); /* (every entry and channel checked) */
+ persist_fill(&p);
+ if (!flash_ok || settings_write(&p))
+ return 4;
+ persist_saved = p;
+ return 0;
+ }
return 1;
}
@@ -515,13 +538,16 @@ static int ed_backup(uint32_t cmd, const uint8_t *a, uint32_t na) /* 1: a back
if (!rc) {
proj_capture((project_t *)ED_BK_RAW); /* the working project, as it is now */
persist_fill(&ed_bk_set);
+ midi_part_fill(ed_bk_ml);
ed_bk_valid = 1;
ed_bk_put = 0;
}
ed_b(rc);
- ed_b(rc ? 0u : (uint32_t)sizeof ED_BK_IDS);
+ ed_b(rc ? 0u : (uint32_t)sizeof ED_BK_IDS - (ed_bk_obj(10u, &len) && !len ? 1u : 0u));
for (i = 0; !rc && i < sizeof ED_BK_IDS; i++) {
p = ed_bk_obj(ED_BK_IDS[i], &len);
+ if (ED_BK_IDS[i] == 10u && !len)
+ continue; /* (nothing learned: not in the list) */
ed_b(ED_BK_IDS[i]);
ed_bk_u32(len);
ed_bk_u32(st_crc32(p, len));
@@ -548,7 +574,7 @@ static int ed_backup(uint32_t cmd, const uint8_t *a, uint32_t na) /* 1: a back
rc = 1;
if (!flash_ok) {
rc = 4;
- } else if (op == 0u && na == 12u && (id <= 9u)) { /* begin: id, length (5), CRC-32 (5) */
+ } else if (op == 0u && na == 12u && (id <= 10u)) { /* begin: id, length (5), CRC-32 (5) */
len = ed_bk_r32(a + 2);
if (id >= 2u || len) { /* (the working project and the settings are never empty) */
if (len <= sizeof proj_tmp) {
diff --git a/firmware/src/eng_analog.c b/firmware/src/eng_analog.c
index e680630..210d348 100644
--- a/firmware/src/eng_analog.c
+++ b/firmware/src/eng_analog.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
/* ANALOG: two band-limited oscillators (saw / square / tri / sine / PWM),
- * noise, drive and a trapezoidal low-pass. */
+ * noise, drive and a trapezoidal state-variable filter: low-pass, or (2.6, TYPE) band-pass / high-pass. */
static const char *const N_ANALOG_WAVE[] = {"SAW", "SQR", "TRI", "SIN", "PWM"};
static void analog_note_on(track_t *t, voice_t *v)
@@ -15,7 +15,26 @@ static void analog_note_on(track_t *t, voice_t *v)
v->s[2] = 0x1234567 + (int32_t)v->age; /* noise state */
}
-static void analog_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
+/* the filter's TYPE (SLOOP 2.6, after Felucca 1.5 by Leo Kuroshita, #104: track parameter P_FTYPE, EDIT > FILTER):
+ * the SVF's outputs (dsp.c tsvf_lp, written out here with the taps: Simper's trapezoidal state-variable filter), 0 LP
+ * the low-pass as always (tsvf_lp itself: the same steps, bit for bit), 1 BP its band-pass v1, 2 HP in - k v1 - v2. At
+ * the cutoff the three peak alike (1/k, k the damping RES sets: 2 at RES 0, ~0.15 at 127), so the soft knee after them
+ * and the level stay as LP's */
+static inline int32_t analog_tap(const tsvf_t *c, int32_t k, int32_t in, int32_t *ic1, int32_t *ic2, uint32_t ft)
+{
+ int32_t v3 = in - *ic2;
+ int32_t v1 = (c->a1 * *ic1 + c->a2 * v3) >> 13;
+ int32_t v2 = *ic2 + ((c->a2 * *ic1 + c->a3 * v3) >> 13);
+ *ic1 = clamp(2 * v1 - *ic1, -150000, 150000);
+ *ic2 = clamp(2 * v2 - *ic2, -150000, 150000);
+ return ft == 1u ? v1 : in - ((k * v1) >> 12) - v2;
+}
+#define ANALOG_K(res) (8192 - (res) * 7600 / 127) /* tsvf_coef's damping, Q12 */
+
+/* the voice through the filter TYPE ft: analog_render's loop with ft 0 (a constant: LP, the code as it always was),
+ * analog_render_f's with BP / HP (its own copy: the LP loop gains nothing) */
+static inline __attribute__((always_inline)) void analog_body(track_t *t, voice_t *v, int32_t *out, uint32_t n,
+ const vmod_t *m, uint32_t ft)
{
const int16_t *p = t->p;
uint32_t wave = (uint32_t)p[P_E0], i;
@@ -34,6 +53,7 @@ static void analog_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, cons
int32_t nz = noise * 200, drv = p[P_E6];
uint32_t ph0 = v->ph[0], ph1 = v->ph[1]; /* state in locals: out[] may alias v->s[] */
int32_t ic1 = v->s[0], ic2 = v->s[1], nst = v->s[2];
+ int32_t fk = ft ? ANALOG_K(p[P_E5]) : 0;
tsvf_coef(&flt, cut, p[P_E5]);
if (det == 0)
inc2 = inc1;
@@ -74,7 +94,7 @@ static void analog_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, cons
if (drv) /* pre-shifts: drive is up to 4x, no overflow */
s += mulq15(softclip(((s >> 2) * (drive >> 2)) >> 11) - s, dw);
{ /* filter: linear up to half scale, then a soft knee (only resonance peaks saturate) */
- int32_t y = tsvf_lp(&flt, s >> 1, &ic1, &ic2), a = y < 0 ? -y : y;
+ int32_t y = ft ? analog_tap(&flt, fk, s >> 1, &ic1, &ic2, ft) : tsvf_lp(&flt, s >> 1, &ic1, &ic2), a = y < 0 ? -y : y;
if (a > 16000) {
a = 16000 + (softclip((a - 16000) * 2) >> 1);
y = y < 0 ? -a : a;
@@ -89,6 +109,18 @@ static void analog_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, cons
v->s[1] = ic2;
v->s[2] = nst;
}
+static __attribute__((noinline)) void analog_render_f(track_t *t, voice_t *v, int32_t *out, uint32_t n,
+ const vmod_t *m)
+{
+ analog_body(t, v, out, n, m, t->p[P_FTYPE] == 1 ? 1u : 2u);
+}
+static void analog_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
+{
+ if (t->p[P_FTYPE]) /* BP / HP (2.6) */
+ analog_render_f(t, v, out, n, m);
+ else
+ analog_body(t, v, out, n, m, 0);
+}
static const preset_t ANALOG_PRESETS[] = {
/* SLOOP hip-hop / drum & bass bank. {WAVE, DTN, MIX, NOIS, CUT, RES, DRV, KTR}, {A D S R}, fenv, mono */
diff --git a/firmware/src/eng_fm6.c b/firmware/src/eng_fm6.c
index 5903b4c..ba95144 100644
--- a/firmware/src/eng_fm6.c
+++ b/firmware/src/eng_fm6.c
@@ -177,11 +177,20 @@ static void fm6_load_slot(uint32_t tr, uint32_t s)
}
/* a sound load put a PTCH value in (a preset, a user preset, a project, an engine change): its patch */
+static uint8_t fm6_pend; /* (2.6) bit per part: a preset's patch waiting for the fade */
static void fm6_track_loaded(const track_t *t)
{
uint32_t tr = (uint32_t)(t - trk);
- if (tr < NPART && t->eng_req == ENGI_FM6)
+ if (tr < NPART && t->eng_req == ENGI_FM6) {
+ uint32_t i, any = 0;
+ for (i = 0; i < NVOICE; i++)
+ any |= t->v[i].active;
+ if (any && (t->pold || t->xf_on)) { /* the old sound still fading out (voice.c sound_change): */
+ fm6_pend |= (uint8_t)(1u << tr); /* its patch stays until then (fm6_poll; engine_block holds */
+ return; /* the new notes for it) */
+ }
fm6_load_slot(tr, (uint32_t)clamp(t->p[P_E7], 0, FM6_NSLOT - 1));
+ }
}
/* power-on: every part the init voice */
@@ -200,9 +209,14 @@ static void fm6_init(void)
static void fm6_poll(void)
{
uint32_t tr;
- for (tr = 0; tr < NPART; tr++)
- if (trk[tr].eng_req == ENGI_FM6 && trk[tr].p[P_E7] != fm6_slot[tr])
+ for (tr = 0; tr < NPART; tr++) {
+ if ((trk[tr].pold || trk[tr].xf_on) && !(trk[tr].xf_on && !trk[tr].xf))
+ continue; /* (a fade under way: the patch after it; faded out, the
+ * notes wait for it: voice.c engine_block) */
+ if (trk[tr].eng_req == ENGI_FM6 && (trk[tr].p[P_E7] != fm6_slot[tr] || ((fm6_pend >> tr) & 1u)))
fm6_load_slot(tr, (uint32_t)clamp(trk[tr].p[P_E7], 0, FM6_NSLOT - 1));
+ fm6_pend &= (uint8_t)~(1u << tr);
+ }
}
/* -------------------------------------------------------------- macros --- */
diff --git a/firmware/src/fx.c b/firmware/src/fx.c
index 0b1c4d6..47db40a 100644
--- a/firmware/src/fx.c
+++ b/firmware/src/fx.c
@@ -2,7 +2,7 @@
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
/* Effects: per-track DIST insert, then sends into three shared buses (chorus, tempo delay, reverb).
* Stereo dry mix; the chorus and the reverb come back in stereo, the delay in the middle. */
-#define DLY_LEN 65536u /* 1.49 s: 1/4 down to 41 BPM, 1/8 dotted down to 31 (clamped below) */
+#define DLY_LEN 65536u /* 1.49 s: 1/4 down to 41 BPM, 1/8 dotted down to 31, 1/4 dotted down to 61 (clamped below) */
#define CHO_LEN 2048u
static int16_t dly_buf[DLY_LEN] __attribute__((section(".pool")));
static int16_t cho_buf[CHO_LEN] __attribute__((section(".pool")));
@@ -20,6 +20,8 @@ static struct {
uint16_t line_i[4], ap_i[2];
int32_t line_lp[4];
} fx;
+static volatile uint8_t rev_frz; /* punch-in FREEZE (punch.c): the reverb holds, no loss, no damping */
+static int32_t rev_l[CTL], rev_r[CTL]; /* the reverb's own return of this block (FREEZE plays it) */
/* DIST: low cut -> drive (1x..8x, exponential) -> asymmetric soft clip
* (a little bias = even harmonics) -> tone low-pass that closes with drive ->
@@ -51,11 +53,68 @@ static void track_dist(track_t *t, int32_t *b, uint32_t n)
}
}
-/* master: peak limiter in front of the soft clipper. Fast attack (~0.1 ms),
- * ~150 ms release, threshold where tanh is still nearly linear, so chords
- * get quieter instead of crushed. */
+/* master: peak limiter in front of the soft clipper, a 35 ms hold then ~46 ms release (2.6), threshold where tanh is still nearly linear,
+ * so chords get quieter instead of crushed. SLOOP 2.6: it looks one block ahead (lim_block): the output is the mix
+ * CTL samples late (0.73 ms) and the gain glides over each block to what the loudest sample of it and of the next one
+ * needs, so a hot kick or bass is already turned down when it comes. Before, the gain caught up in ~4 samples and the
+ * first ones went through the tanh knee at up to 4x: a crackle on the beats with the MASTER up (in headphones most) */
#define LIM_T 18000
-static int32_t lim_env = LIM_T;
+typedef struct {
+ int32_t dl[CTL], dr[CTL]; /* the mix of the last block (the delay) */
+ uint32_t w; /* its oldest sample (the next out) */
+ int32_t env; /* the peak the gain fits under LIM_T (LIM_T: none) */
+ int32_t g; /* the gain at the end of the last block, Q15 (32768: 1) */
+ uint32_t hold; /* blocks before the release starts (LIM_HOLD after a peak near env) */
+} lim_t;
+/* (2.6, a whistle on loud basses) the release waits LIM_HOLD blocks after the last peak near the envelope: a held bass
+ * (down to ~29 Hz, a period under 35 ms) keeps one gain, instead of the gain dipping and creeping back at every cycle
+ * (a sawtooth at the bass's pitch with a corner at every block: tones around 1.4 kHz and up) */
+#define LIM_HOLD 48u
+#define LIM_REL 11 /* the release after the hold: ~46 ms (12 before the hold: ~93 ms; the same loudness) */
+static lim_t lim_dac = {.env = LIM_T, .g = 32768}, lim_usb = {.env = LIM_T, .g = 32768};
+/* l, r: n (<= CTL) samples in; out: the n samples of CTL before, limited (before the knee) */
+static void lim_block(lim_t *s, int32_t *l, int32_t *r, uint32_t n)
+{
+ uint32_t i, w = s->w;
+ int32_t pk = 0, a, g0 = s->g, g1, dg, e = s->env;
+ for (i = 0; i < CTL; i++) { /* the samples going out now and the ones after them (the
+ * rest of the delay, then this block): CTL ahead */
+ a = s->dl[i] < 0 ? -s->dl[i] : s->dl[i], pk = a > pk ? a : pk;
+ a = s->dr[i] < 0 ? -s->dr[i] : s->dr[i], pk = a > pk ? a : pk;
+ }
+ for (i = 0; i < n; i++) {
+ a = l[i] < 0 ? -l[i] : l[i], pk = a > pk ? a : pk;
+ a = r[i] < 0 ? -r[i] : r[i], pk = a > pk ? a : pk;
+ }
+ if ((int64_t)pk * 17 >= (int64_t)e * 16) /* a peak within ~0.5 dB of the envelope: the hold again */
+ s->hold = LIM_HOLD;
+ if (s->hold)
+ s->hold--;
+ else if (e > LIM_T) /* the release (after the hold), a block at a time */
+ e -= (int32_t)((((int64_t)(e - LIM_T) * (int32_t)n) >> LIM_REL) + 1);
+ if (e < LIM_T)
+ e = LIM_T;
+ if (pk > e)
+ e = pk, s->hold = LIM_HOLD;
+ s->env = e;
+ g1 = e > LIM_T ? (int32_t)(((uint32_t)LIM_T << 15) / (uint32_t)e) : 32768;
+ s->g = g1;
+ dg = (g1 - g0) / (int32_t)(n ? n : 1u); /* (towards 0: the gain never above both ends' bound) */
+ for (i = 0; i < n; i++) {
+ int32_t xl = s->dl[w], xr = s->dr[w], g = g0 + dg * (int32_t)(i + 1u);
+ s->dl[w] = l[i], s->dr[w] = r[i];
+ w = (w + 1u) & (CTL - 1u);
+ if (i + 1u == n)
+ g = g1;
+ if (g < 32768) { /* (64-bit: |x| may be far above Q15. 2.6 fix: x >> 4 first cut
+ * the limited signal to 12 bits, a whistle on loud basses) */
+ xl = (int32_t)(((int64_t)xl * g) >> 15);
+ xr = (int32_t)(((int64_t)xr * g) >> 15);
+ }
+ l[i] = xl, r[i] = xr;
+ }
+ s->w = w;
+}
static volatile uint8_t fx_lowcut; /* settings: 12 dB/oct ~110 Hz for the small speaker */
static int32_t lc_l1, lc_l2, lc_r1, lc_r2, dc_l, dc_r, dce_l, dce_r;
@@ -95,17 +154,16 @@ static inline int32_t knee(int32_t x)
/* the USB audio input at full level (menu USB AUDIO = FULL): the same output stage with its own state,
* fed as if MASTER were all the way up, so the recording level does not follow the knob. The DAC path
- * (master_out) is untouched. audio.c sets usb_full_now for a render while the computer records. */
+ * (master_pre, lim_dac) is untouched. audio.c sets usb_full_now for a render while the computer records. */
static uint8_t usb_full; /* menu USB AUDIO: 0 MASTER (follows the knob), 1 FULL (panel.c lights_word) */
static uint8_t usb_full_now; /* this render fills usb_out (audio.c) */
static int32_t usb_out[2u * CTL];
/* the visualiser's input (audio.c fills the scope with it): the mix as if MASTER were all the way up, so the
* picture does not follow the volume knob, even at 0 (2.4). The same soft knee as the output, no limiter state */
static int16_t vis_tap[2u * CTL];
-static struct { int32_t lim, dc[2], dce[2], lc[4], lce[4]; } uo = {LIM_T, {0, 0}, {0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
-static void master_out_usb(int32_t *l, int32_t *r)
+static struct { int32_t dc[2], dce[2], lc[4], lce[4]; } uo;
+static void master_pre_usb(int32_t *l, int32_t *r) /* (USB AUDIO = FULL: its own state) */
{
- int32_t al, ar, a;
*l = dc_block(*l, &uo.dc[0], &uo.dce[0]);
*r = dc_block(*r, &uo.dc[1], &uo.dce[1]);
if (fx_lowcut) {
@@ -114,25 +172,11 @@ static void master_out_usb(int32_t *l, int32_t *r)
*r = lowcut1(*r, &uo.lc[2], &uo.lce[2]);
*r = lowcut1(*r, &uo.lc[3], &uo.lce[3]);
}
- al = *l < 0 ? -*l : *l;
- ar = *r < 0 ? -*r : *r;
- a = al > ar ? al : ar;
- if (a > uo.lim)
- uo.lim += (a - uo.lim) >> 2;
- else if (uo.lim > LIM_T)
- uo.lim -= ((uo.lim - LIM_T) >> 12) + 1;
- if (uo.lim > LIM_T) {
- int32_t g = (int32_t)(((uint32_t)LIM_T << 15) / (uint32_t)uo.lim);
- *l = ((*l >> 4) * g) >> 11;
- *r = ((*r >> 4) * g) >> 11;
- }
- *l = knee(*l);
- *r = knee(*r);
}
-static inline void master_out(int32_t *l, int32_t *r)
+/* the output stage before the limiter: the DC blocker, the low cut */
+static inline void master_pre(int32_t *l, int32_t *r)
{
- int32_t al, ar, a;
*l = dc_block(*l, &dc_l, &dce_l);
*r = dc_block(*r, &dc_r, &dce_r);
if (fx_lowcut) { /* two one-pole high-passes, error feedback as dc_block (the */
@@ -141,20 +185,6 @@ static inline void master_out(int32_t *l, int32_t *r)
*r = lowcut1(*r, &lc_r1, &lce[2]);
*r = lowcut1(*r, &lc_r2, &lce[3]);
}
- al = *l < 0 ? -*l : *l;
- ar = *r < 0 ? -*r : *r;
- a = al > ar ? al : ar;
- if (a > lim_env)
- lim_env += (a - lim_env) >> 2;
- else if (lim_env > LIM_T)
- lim_env -= ((lim_env - LIM_T) >> 12) + 1;
- if (lim_env > LIM_T) {
- int32_t g = (int32_t)(((uint32_t)LIM_T << 15) / (uint32_t)lim_env); /* < 32768 */
- *l = ((*l >> 4) * g) >> 11; /* >> 4 first: |l| may be far above Q15 */
- *r = ((*r >> 4) * g) >> 11;
- }
- *l = knee(*l);
- *r = knee(*r);
}
@@ -167,13 +197,18 @@ static uint32_t delay_samples(void)
/* process the three buses for one block; sends in, wet out (stereo). The LFOs (chorus, reverb line)
* are computed per block and ramped: no sine per sample */
+#define HALF0(v) ((v) >= 0 ? (v) >> 1 : -(-(v) >> 1)) /* v / 2 towards zero */
static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t *rev_in, int32_t *wet_l,
int32_t *wet_r, uint32_t n)
{
uint32_t i, k, dl = delay_samples();
int32_t fb = song.g[G_DFDBK] * 230, col = 2000 + song.g[G_DCOLOR] * 240;
+ if (thr_dly && fb < 89 * 230) /* ECHO THROW: FDBK at least 70 %, gliding with it (2.6) */
+ fb += ((89 * 230 - fb) * thr_dly) >> 15;
int32_t dmix = song.g[G_DMIX] * 258;
int32_t g = 17000 + song.g[G_RSIZE] * 104, lpk = 32767 - song.g[G_RDAMP] * 200; /* loop gain (RT60 ~0.4..4 s), damping */
+ int32_t frnd = rev_frz ? 128 : 0; /* FREEZE: what is in the lines stays there (below: no
+ * loss, rounded to nearest; 0: as always, bit for bit) */
int32_t cdepth = song.g[G_CDEPTH] * 6;
int32_t ca0, ca1, cb0, cb1, ma, mb, dca, dcb;
const uint32_t L0 = REV_LINE[0] + REV_MOD + 2u, B1 = L0, B2 = B1 + REV_LINE[1], B3 = B2 + REV_LINE[2];
@@ -230,19 +265,30 @@ static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t
if (ri >= L0) /* (the oldest sample is at line_i: reading */
ri -= L0; /* past it shortens line 0 by 0..2 REV_MOD) */
rj = ri + 1u >= L0 ? 0u : ri + 1u;
- o0 = c[ri] + (((c[rj] - c[ri]) * (r & 255)) >> 8);
+ o0 = c[ri] + (((c[rj] - c[ri]) * (r & 255) + frnd) >> 8);
o1 = c[B1 + fx.line_i[1]];
o2 = c[B2 + fx.line_i[2]];
o3 = c[B3 + fx.line_i[3]];
s0 = o0 + o1, d0 = o0 - o1, s1 = o2 + o3, d1 = o2 - o3; /* Hadamard / 2: each feeds all four */
- fx.line_lp[0] += mulq15(((s0 + s1) >> 1) - fx.line_lp[0], lpk);
- fx.line_lp[1] += mulq15(((d0 + d1) >> 1) - fx.line_lp[1], lpk);
- fx.line_lp[2] += mulq15(((s0 - s1) >> 1) - fx.line_lp[2], lpk);
- fx.line_lp[3] += mulq15(((d0 - d1) >> 1) - fx.line_lp[3], lpk);
- c[fx.line_i[0]] = (int16_t)clamp(mulq15(fx.line_lp[0], g) + a, -32768, 32767);
- c[B1 + fx.line_i[1]] = (int16_t)clamp(mulq15(fx.line_lp[1], g) - a, -32768, 32767);
- c[B2 + fx.line_i[2]] = (int16_t)clamp(mulq15(fx.line_lp[2], g) + a, -32768, 32767);
- c[B3 + fx.line_i[3]] = (int16_t)clamp(mulq15(fx.line_lp[3], g) - a, -32768, 32767);
+ if (!frnd) {
+ fx.line_lp[0] += mulq15(((s0 + s1) >> 1) - fx.line_lp[0], lpk);
+ fx.line_lp[1] += mulq15(((d0 + d1) >> 1) - fx.line_lp[1], lpk);
+ fx.line_lp[2] += mulq15(((s0 - s1) >> 1) - fx.line_lp[2], lpk);
+ fx.line_lp[3] += mulq15(((d0 - d1) >> 1) - fx.line_lp[3], lpk);
+ c[fx.line_i[0]] = (int16_t)clamp(mulq15(fx.line_lp[0], g) + a, -32768, 32767);
+ c[B1 + fx.line_i[1]] = (int16_t)clamp(mulq15(fx.line_lp[1], g) - a, -32768, 32767);
+ c[B2 + fx.line_i[2]] = (int16_t)clamp(mulq15(fx.line_lp[2], g) + a, -32768, 32767);
+ c[B3 + fx.line_i[3]] = (int16_t)clamp(mulq15(fx.line_lp[3], g) - a, -32768, 32767);
+ } else { /* FREEZE: a loop gain of exactly 1, so no rounding that
+ * leans one way (a DC that would grow while held): the
+ * halves towards zero, no damping or gain multiply */
+ fx.line_lp[0] = HALF0(s0 + s1), fx.line_lp[1] = HALF0(d0 + d1);
+ fx.line_lp[2] = HALF0(s0 - s1), fx.line_lp[3] = HALF0(d0 - d1);
+ c[fx.line_i[0]] = (int16_t)clamp(fx.line_lp[0] + a, -32768, 32767);
+ c[B1 + fx.line_i[1]] = (int16_t)clamp(fx.line_lp[1] - a, -32768, 32767);
+ c[B2 + fx.line_i[2]] = (int16_t)clamp(fx.line_lp[2] + a, -32768, 32767);
+ c[B3 + fx.line_i[3]] = (int16_t)clamp(fx.line_lp[3] - a, -32768, 32767);
+ }
if (++fx.line_i[0] >= L0) fx.line_i[0] = 0;
if (++fx.line_i[1] >= REV_LINE[1]) fx.line_i[1] = 0;
if (++fx.line_i[2] >= REV_LINE[2]) fx.line_i[2] = 0;
@@ -250,6 +296,8 @@ static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t
}
wet_l[i] = yl + o0 + o2;
wet_r[i] = yr + o1 - o3;
+ rev_l[i] = o0 + o2;
+ rev_r[i] = o1 - o3;
}
}
@@ -301,6 +349,7 @@ static void duck_block(uint32_t adv)
typedef struct {
int32_t cut; /* now, 0..127 << 8 (CUTOFF_HZ index) */
int8_t mode; /* -1 LP, 1 HP, 0 off */
+ uint8_t seed; /* (2.6) bit per channel: the LP's state from its next sample */
int32_t z[4][2]; /* the SVF states, per channel */
} djf_t;
static djf_t djf, tflt[NTRK];
@@ -313,6 +362,8 @@ static int djf_block(djf_t *f, int32_t v, tsvf_t *c)
f->mode = -1;
f->cut = 127 << 8;
memset(f->z, 0, sizeof f->z);
+ f->seed = 15; /* (2.6) the low-pass starts where the signal is: from rest
+ * its output began at 0 under a sounding note (a click) */
} else if (v > 0 && f->mode <= 0) {
f->mode = 1;
f->cut = 0;
@@ -334,6 +385,13 @@ static void djf_run(djf_t *f, const tsvf_t *c, int32_t *b, uint32_t n, uint32_t
{
uint32_t i;
int32_t *z = f->z[ch];
+ if ((f->seed >> ch) & 1u) {
+ f->seed &= (uint8_t)~(1u << ch);
+ if (f->mode < 0 && n) {
+ z[0] = 0; /* at rest on this input: the output is it (DC: exact) */
+ z[1] = clamp(b[0], -140000, 140000);
+ }
+ }
for (i = 0; i < n; i++) {
int32_t x = clamp(b[i], -140000, 140000), y = tsvf_lp(c, x, &z[0], &z[1]);
b[i] = f->mode < 0 ? y : x - y;
@@ -350,17 +408,260 @@ static void tflt_run(djf_t *f, const tsvf_t *c, int32_t *b, uint32_t n, uint32_t
b[i] <<= 2;
}
+/* INSERT (SLOOP 2.6, after Felucca 1.5 by Leo Kuroshita, Discussions #78 and #177): one effect per track, after DIST
+ * and before the SLICER, with a dry / wet MIX. TYPE (P_ITYPE, N_ITYPE; stored, append-only) and its three values A B C
+ * (P_IA .. P_IC, what they mean: params.c ins_desc):
+ * SOFT HARD FOLD FUZZ DRIVE (1x .. ~13x, squared), TONE (two one-pole low-passes at F_CUTOFF), LEVEL (F_DB, as the
+ * track's LEVEL: 112 is 0 dB). A slow low cut in front (~27 Hz), a DC blocker after (FUZZ is
+ * lopsided). SOFT tanh, HARD a flat clip at a voice's level, FOLD a triangle folder (the wave
+ * reflected at +-16384: every fold more harmonics), FUZZ a hard top and a soft, halved bottom;
+ * CRUSH BITS (1 .. 16, of a voice's full scale), RATE (a held sample, 689 Hz .. 44.1 kHz, INS_HOLD:
+ * aliasing as the old samplers), LPF (two one-pole low-passes at F_CUTOFF after them);
+ * PHASR RATE (F_LFOHZ), DEPTH (the sweep around ~850 Hz: 0 still .. the whole 150 Hz .. 4.8 kHz),
+ * FDBK (0 .. 0.7): four all-pass stages, mono, per track;
+ * FLANG CHOR RATE, DEPTH, FDBK: a 256-sample line per track (5.8 ms); FLANG swept 0.25 .. 5 ms (a squared
+ * triangle), feedback 0 .. 0.85; CHOR a sine around 3.2 ms (+-2.3 ms at DEPTH 127), feedback
+ * 0 .. 0.4. A DC blocker on the swept copy (a clipped loud input is lopsided).
+ * The swept ones are the pedals': their wet is (dry + swept) / 2, the notches need both, so MIX 100 % is the whole
+ * effect and less a lighter one. MIX (P_IMIX) blends dry and wet linearly; MIX 0 or TYPE OFF: the track bit for bit
+ * as before (nothing runs). MIX glides (2.9 ms, SL_SLOPE); a TYPE change fades the old one out, clears the state,
+ * fades the new one in; so does a start from MIX 0 (no stale line or filter).
+ * The drum track (SLOOP): its left, right, reverb send and delay send each through their own state, the same settings
+ * (fx.c mix_block). State in RAM (.bss): 580 B a channel; noinline, its own loops */
+enum { IT_OFF, IT_SOFT, IT_HARD, IT_FOLD, IT_FUZZ, IT_CRUSH, IT_PHASER, IT_FLANGER, IT_CHORUS, IT_N };
+_Static_assert(IT_N == sizeof N_ITYPE / sizeof N_ITYPE[0], "the INSERT's types as params.c names them");
+#define IL_LEN 256u /* FLANG / CHOR: the line, samples (a power of 2: masked) */
+#define PH_ST 4u /* PHASR: all-pass stages (two notches, the classic pedal's) */
+static const uint8_t INS_HOLD[16] = {64, 48, 40, 32, 24, 20, 16, 12, 10, 8, 6, 5, 4, 3, 2, 1}; /* CRUSH RATE */
+/* PHASR: the stages' coefficient over the sweep (Q14), 33 points */
+static const int16_t PH_A[33] = {
+ -16038, -15998, -15955, -15906, -15853, -15793, -15727, -15653, -15572, -15481, -15381, -15270, -15147, -15012,
+ -14862, -14696, -14514, -14313, -14092, -13849, -13582, -13290, -12970, -12621, -12240, -11825, -11375, -10886,
+ -10356, -9784, -9166, -8500, -7783,
+};
+typedef struct {
+ int32_t w; /* the wet share now, Q15 */
+ uint8_t type; /* the type running */
+ uint8_t cnt; /* CRUSH: samples left of the held one */
+ uint16_t wp; /* FLANG / CHOR: the line's next write */
+ uint32_t ph; /* the sweep's phase */
+ int32_t hp, lp1, lp2, dc, hold; /* low cut (Q8), the two low-passes, DC blocker (Q8), CRUSH's held sample */
+ int32_t px[PH_ST], py[PH_ST], fb; /* PHASR: each stage's last input and output, the fed back */
+ int16_t line[IL_LEN]; /* FLANG / CHOR, at a quarter (headroom) */
+} ins_t;
+/* (in .bss, not the pool: tools/build.py keeps 8 KiB of the pool spare; RAM has room) */
+static ins_t ins[NPART + 4u]; /* the parts; the drum track's L, R, REV, DLY */
+
+static inline int32_t ins_mixq(int32_t m) { return m >= 127 ? 32768 : m <= 0 ? 0 : m * 258; } /* MIX -> Q15 */
+static inline int32_t ins_mix(int32_t x, int32_t y, int32_t w) { return w == 32768 ? y : x + mulq16(y - x, (uint32_t)w << 1); }
+static inline uint32_t ins_tri(uint32_t q) { uint32_t t = q >> 16; return t < 32768u ? t << 1 : (65535u - t) << 1; }
+/* the one-pole low-pass (topology-preserving) coefficient of cutoff index c, Q16: G = g / (1 + g), g = tan(pi fc / FS) */
+static int32_t ins_lpk(int32_t c)
+{
+ uint32_t g = SVF_G[clamp(c, 0, 127)];
+ return (int32_t)((g << 16) / (4096u + g));
+}
+/* the drives' and CRUSH's shape of v (a voice's full scale 32768; v already through DRIVE) */
+static inline int32_t ins_shape(uint32_t ty, int32_t v, uint32_t sh)
+{
+ switch (ty) {
+ case IT_SOFT:
+ return softclip(v);
+ case IT_HARD:
+ return clamp(v, -24000, 24000);
+ case IT_FOLD: {
+ int32_t u = (int32_t)((uint32_t)(v + 16384) & 0xFFFFu) - 32768; /* a triangle of period 65536: +-16384 */
+ u = 16384 - (u < 0 ? -u : u);
+ return u + (u >> 1); /* x 1.5 (no divide) */
+ }
+ case IT_FUZZ:
+ return v > 0 ? (v > 20000 ? 20000 : v) : softclip(v) >> 1;
+ case IT_CRUSH: /* sh: 16 - BITS; to the nearest step */
+ return sh ? ((v + (1 << (sh - 1u))) >> sh) << sh : v;
+ default:
+ return v;
+ }
+}
+static inline uint32_t ins_bits_sh(int32_t a) { return 15u - (uint32_t)(clamp(a, 0, 127) >> 3); } /* BITS 1..16 */
+
+/* SOFT .. FUZZ: low cut -> DRIVE -> shape -> TONE -> LEVEL -> DC blocker; CRUSH: held sample -> bits -> LPF. The state
+ * in locals for the block (b may alias it as far as the compiler knows: no load / store a sample), written back */
+static __attribute__((noinline)) void ins_drive(ins_t *s, const int16_t *p, int32_t *b, uint32_t n, int32_t tw)
+{
+ uint32_t i, ty = s->type, sh = ins_bits_sh(p[P_IA]);
+ uint32_t hold = INS_HOLD[clamp(p[P_IB], 0, 127) >> 3];
+ int32_t a = clamp(p[P_IA], 0, 127), g = 4096 + a * a * 3; /* DRIVE, Q12: 1x .. 12.8x, gentle at first */
+ int32_t w = s->w, lp1 = s->lp1, lp2 = s->lp2, x, y, v;
+ if (ty == IT_CRUSH) {
+ uint32_t k = (uint32_t)ins_lpk(p[P_IC]), cnt = s->cnt;
+ int32_t hd = s->hold;
+ for (i = 0; i < n; i++) {
+ x = b[i];
+ w += clamp(tw - w, -SL_SLOPE, SL_SLOPE);
+ if (!cnt) {
+ hd = ins_shape(IT_CRUSH, clamp(x, -262144, 262143), sh);
+ cnt = hold;
+ }
+ cnt--;
+ y = hd << 4; /* (x16: the low cutoffs' rounding leaves no offset) */
+ v = mulq16(y - lp1, k); /* LPF: two one-pole low-passes */
+ y = v + lp1;
+ lp1 = y + v;
+ v = mulq16(y - lp2, k);
+ y = v + lp2;
+ lp2 = y + v;
+ b[i] = ins_mix(x, (y + 8) >> 4, w);
+ }
+ s->cnt = (uint8_t)cnt;
+ s->hold = hd;
+ } else {
+ uint32_t k = (uint32_t)ins_lpk(p[P_IB]);
+ int32_t lvl = LEVEL_Q12[p[P_IC] & 127], hp = s->hp, dc = s->dc;
+ for (i = 0; i < n; i++) {
+ x = b[i];
+ w += clamp(tw - w, -SL_SLOPE, SL_SLOPE);
+ hp += ((x << 8) - hp) >> 8; /* ~27 Hz low cut (Q8: no offset left by the rounding) */
+ v = clamp(x - (hp >> 8), -230000, 230000);
+ y = ins_shape(ty, ((v >> 3) * g) >> 9, 0) << 4; /* (>> 3 first: 32 bits; x16 as CRUSH) */
+ v = mulq16(y - lp1, k); /* TONE: two one-pole low-passes */
+ y = v + lp1;
+ lp1 = y + v;
+ v = mulq16(y - lp2, k);
+ y = v + lp2;
+ lp2 = y + v;
+ y = (((y + 8) >> 4) * lvl) >> 12; /* LEVEL */
+ dc += ((y << 8) - dc) >> 9; /* DC blocker, ~14 Hz (FUZZ's lopsided halves) */
+ b[i] = ins_mix(x, y - (dc >> 8), w);
+ }
+ s->hp = hp;
+ s->dc = dc;
+ }
+ s->w = w;
+ s->lp1 = lp1;
+ s->lp2 = lp2;
+}
+
+/* PHASR, FLANG, CHOR: the sweep at RATE (one LFO per state), DEPTH, FDBK; the state in locals for the block */
+static __attribute__((noinline)) void ins_swept(ins_t *s, const int16_t *p, int32_t *b, uint32_t n, int32_t tw)
+{
+ uint32_t i, inc = LFO_INC[clamp(p[P_IA], 0, 127)] / CTL, dep = (uint32_t)clamp(p[P_IB], 0, 127);
+ int32_t c = clamp(p[P_IC], 0, 127), w = s->w, dc = s->dc;
+ if (s->type == IT_PHASER) { /* the coefficients a block at a time (at its middle) */
+ uint32_t tr = ins_tri(s->ph + (n >> 1) * inc), q = 32768u + (uint32_t)(((int32_t)tr - 32768) * (int32_t)dep / 127);
+ int32_t a = PH_A[q >> 11] + (((PH_A[(q >> 11) + 1u] - PH_A[q >> 11]) * (int32_t)(q & 2047u)) >> 11);
+ int32_t fbk = c * 180, fb = s->fb; /* 0 .. 0.7, Q15 */
+ int32_t x0 = s->px[0], x1 = s->px[1], x2 = s->px[2], x3 = s->px[3];
+ int32_t y0 = s->py[0], y1 = s->py[1], y2 = s->py[2], y3 = s->py[3];
+ _Static_assert(PH_ST == 4u, "ins_swept: four all-pass stages");
+ for (i = 0; i < n; i++) {
+ int32_t x = b[i], u = clamp((x + 4) >> 3, -16383, 16383) + ((fb * fbk + 16384) >> 15), y;
+ w += clamp(tw - w, -SL_SLOPE, SL_SLOPE);
+ /* y = a (u - y1) + u1, four times */
+ y = clamp(x0 + ((a * (u - y0) + 8192) >> 14), -65535, 65535), x0 = u, y0 = y, u = y;
+ y = clamp(x1 + ((a * (u - y1) + 8192) >> 14), -65535, 65535), x1 = u, y1 = y, u = y;
+ y = clamp(x2 + ((a * (u - y2) + 8192) >> 14), -65535, 65535), x2 = u, y2 = y, u = y;
+ y = clamp(x3 + ((a * (u - y3) + 8192) >> 14), -65535, 65535), x3 = u, y3 = y;
+ fb = clamp(y, -32767, 32767);
+ y <<= 2; /* (y: at an eighth) */
+ dc += ((y << 8) - dc) >> 9; /* DC blocker, ~14 Hz (a clipped loud input is lopsided) */
+ b[i] = ins_mix(x, (x >> 1) + y - (dc >> 8), w); /* (dry + all-passed) / 2 */
+ }
+ s->px[0] = x0, s->px[1] = x1, s->px[2] = x2, s->px[3] = x3;
+ s->py[0] = y0, s->py[1] = y1, s->py[2] = y2, s->py[3] = y3;
+ s->fb = fb;
+ s->ph += n * inc;
+ } else {
+ int32_t chorus = s->type == IT_CHORUS, fbk = c * (chorus ? 103 : 219); /* 0 .. 0.4 / 0 .. 0.85, Q15 */
+ uint32_t dq = dep * 516u, ph = s->ph, wp = s->wp; /* DEPTH, Q16 */
+ int16_t *line = s->line;
+ for (i = 0; i < n; i++, ph += inc) {
+ int32_t x = b[i], r0, r1, v, fr;
+ uint32_t d; /* the delay, Q16 samples */
+ w += clamp(tw - w, -SL_SLOPE, SL_SLOPE);
+ if (chorus) {
+ d = (uint32_t)((140 << 16) + ((osc_sine(ph) * (int32_t)dep * 50) >> 5)); /* 3.2 +- 2.3 ms */
+ } else {
+ uint32_t tr = ins_tri(ph), sw = (tr * tr) >> 16; /* longer near the short end */
+ d = (11u << 16) + 209u * (((sw >> 1) * dq) >> 15); /* 0.25 .. 5 ms */
+ }
+ r0 = (int32_t)(wp - (d >> 16)) & (int32_t)(IL_LEN - 1u);
+ r1 = (r0 - 1) & (int32_t)(IL_LEN - 1u);
+ fr = (int32_t)((d >> 1) & 0x7FFFu);
+ v = line[r0] + (((line[r1] - line[r0]) * fr) >> 15);
+ line[wp] = (int16_t)clamp((x >> 2) + softclip(mulq15(v, fbk)), -32767, 32767);
+ wp = (wp + 1u) & (IL_LEN - 1u);
+ v <<= 1; /* (v: at a quarter) */
+ dc += ((v << 8) - dc) >> 9; /* DC blocker (the line's clip on a loud lopsided wave) */
+ b[i] = ins_mix(x, (x >> 1) + v - (dc >> 8), w); /* (dry + delayed) / 2 */
+ }
+ s->ph = ph;
+ s->wp = (uint16_t)wp;
+ }
+ s->w = w;
+ s->dc = dc;
+}
+
+/* the INSERT of the settings p on one channel b through state s: 1 while it runs (or fades out); 0: dry, bit for bit */
+static __attribute__((noinline)) int ins_run(ins_t *s, const int16_t *p, int32_t *b, uint32_t n)
+{
+ int32_t ty = clamp(p[P_ITYPE], 0, IT_N - 1), tw;
+ if (s->type != ty && !s->w) /* faded out: the new type from rest */
+ s->type = (uint8_t)ty;
+ tw = s->type == ty && ty ? ins_mixq(p[P_IMIX]) : 0;
+ if (!s->w) {
+ if (!tw)
+ return 0; /* dry: bit for bit */
+ memset(s, 0, sizeof *s); /* starting: no stale line or filter */
+ s->type = (uint8_t)ty;
+ }
+ if (s->type >= IT_PHASER)
+ ins_swept(s, p, b, n, tw);
+ else
+ ins_drive(s, p, b, n, tw);
+ return s->w != 0;
+}
+/* a part's INSERT on its block b (mix_part): nothing while TYPE is OFF or MIX is 0 and faded */
+static void track_insert(track_t *t, int32_t *b, uint32_t n)
+{
+ t->ins_run = (uint8_t)ins_run(&ins[(uint32_t)(t - trk) % NPART], t->p, b, n);
+}
+/* the INSERT at rest at once (mix_part: TYPE turned OFF while the part was silent, its fade never ran) */
+static __attribute__((noinline)) void ins_rest(track_t *t)
+{
+ memset(&ins[(uint32_t)(t - trk) % NPART], 0, sizeof(ins_t));
+ t->ins_run = 0;
+}
+
/* one synth part into the dry mix and the sends; a part with no voice sounding costs
* the LFO tick and a cleared buffer only (after the DIST tail has run out) */
+static void mix_part_run(track_t *t, uint32_t n);
+/* (2.6) a preset's fade (voice.c sound_change): the whole part rendered with the sound it had, then the new one back */
static void mix_part(track_t *t, uint32_t n)
+{
+ static int16_t pnew[P_COUNT];
+ if (!(t->pold && t->xf_on && t->xf)) {
+ mix_part_run(t, n);
+ return;
+ }
+ memcpy(pnew, t->p, sizeof pnew);
+ memcpy(t->p, t->p_old, sizeof t->p);
+ mix_part_run(t, n);
+ memcpy(t->p, pnew, sizeof pnew);
+}
+static void mix_part_run(track_t *t, uint32_t n)
{
int32_t *b = part_buf;
uint32_t i;
int32_t g0 = 32767 - t->att, g1 = gain_next(t);
if (track_render(t, b, n))
- t->tail = 16; /* blocks of DIST state to run out after the last voice */
- else if ((!t->tail || !t->p[P_DIST] || !--t->tail) && !slicer_busy(t)) {
+ t->tail = t->p[P_ITYPE] ? 64 : 16, t->ins_xt = 0; /* blocks of DIST / INSERT state to run out after the last
+ * voice (the INSERT's: 46 ms, a flanger's feedback) */
+ else if ((!t->tail || !(t->p[P_DIST] | t->p[P_ITYPE]) || !--t->tail) && !slicer_busy(t) &&
+ !(t->ins_run && t->ins_res > 16u && t->ins_xt < 255u && ++t->ins_xt)) { /* (2.6: the INSERT's DC
+ * blocker run out first, up to 255 blocks more: no step) */
slicer_track(t, 0, n); /* (the SLICER's step clock runs on) */
+ if (t->ins_run && !t->p[P_ITYPE])
+ ins_rest(t); /* TYPE OFF while silent: no fade-out left for the next note */
return;
}
if (!g0 && !g1) { /* silent (MUTE / SOLO): the voices run, nothing is heard */
@@ -370,11 +671,17 @@ static void mix_part(track_t *t, uint32_t n)
{
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 gl = 4096 - (pan > 0 ? pan * 64 : 0), gr = 4096 + (pan < 0 ? pan * 64 : 0);
- int32_t c = t->p[P_CHOR] * 258, d = t->p[P_DLY] * 258, r = t->p[P_REV] * 258, pk = t->peak;
+ 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;
int32_t xmax = c > d ? c : d;
int32_t ga = mulq15(g0, duck.g0), gb = mulq15(g1, duck.g1); /* mute x duck, ramped over the block */
xmax = 0x7FFFFFFF / ((xmax > r ? xmax : r) | 1); /* sends: loud chords at a high LEVEL */
track_dist(t, b, n);
+ if (t->p[P_ITYPE] | t->ins_run) {
+ track_insert(t, b, n); /* the INSERT (2.6): off, nothing */
+ t->ins_res = (uint16_t)(b[n - 1u] < 0 ? (-b[n - 1u] > 65535 ? 65535 : -b[n - 1u])
+ : (b[n - 1u] > 65535 ? 65535 : b[n - 1u])); /* (its tail's end) */
+ }
slicer_track(t, b, n); /* slicer.c: before the level, pan and sends */
{
tsvf_t fc; /* the track's FILTER (P_TFLT), after the SLICER */
@@ -475,12 +782,277 @@ static void djf_process(int32_t *l, int32_t *r, uint32_t n)
#include "punch.c" /* PUNCH-IN FX on the whole mix (FX held + a white key) */
static int32_t master_cur = -1; /* the volume knob, ramped per sample (no zipper) */
+/* the drum track's INSERT (2.6): its left, right and the two sends, each through its own state, the same settings */
+static void drum_insert(int32_t *l, int32_t *r, int32_t *v, int32_t *d, uint32_t n)
+{
+ track_t *t = TDRUM;
+ int run;
+ if (!(t->p[P_ITYPE] | t->ins_run))
+ return;
+ run = ins_run(&ins[NPART], t->p, l, n);
+ run |= ins_run(&ins[NPART + 1u], t->p, r, n);
+ run |= ins_run(&ins[NPART + 2u], t->p, v, n);
+ run |= ins_run(&ins[NPART + 3u], t->p, d, n);
+ t->ins_run = (uint8_t)run;
+}
+/* ---- TEXTURE (SLOOP 2.6, GLO > TEXTURE): a looping bed under the mix, the glue of lo-fi and ambient tracks, without
+ * taking a track. SRC: a generated noise (no memory, nothing to load) or a user sample slot looped (USR1..4, its first
+ * zone at its own pitch; a looped zone from its loop, else whole), LEVEL, TONE (the DJ filter: left a low-pass, right a
+ * high-pass), MOVE: how much it breathes over RATE (1 .. 16 bars of the tempo; its level and brightness, a sine from the
+ * transport's start), WHEN: PLAY (fades in and out with the transport) or ALWAYS, DUCK: the kick pumps it as the
+ * parts (GLO > MASTER > DUCK). Into the dry mix (no sends), before DUST, the punch-ins and the master filter.
+ * VINYL hiss, rumble, crackle and the odd pop, each crackle somewhere left to right
+ * TAPE hiss tilted dark, its level drifting slowly (flutter)
+ * RAIN a soft bed and droplets, left and right apart
+ * WIND noise through two resonant low-passes wandering slowly, gusts
+ * RADIO a band of static (500 Hz .. 3 kHz), coarse, in bursts that come and go
+ * ROOM room tone: a low rumble and a little air
+ * Its level: x * LEVEL^2 / 16384 into the mix (the sources at about 8000 rms: LEVEL 64 about -30 dBFS rms out, 127
+ * about -18). Off (and faded out): nothing runs, the mix bit for bit as without */
+enum { TX_OFF, TX_VINYL, TX_TAPE, TX_RAIN, TX_WIND, TX_RADIO, TX_ROOM, TX_USR1, TX_N = TX_USR1 + 4 };
+static struct {
+ int32_t rnd; /* noise state (never 0) */
+ int32_t g; /* gain now (Q15 of the LEVEL target), ramped a block */
+ uint8_t src, play; /* the source running; the transport as last seen */
+ uint32_t ph; /* MOVE's phase (a turn per RATE) */
+ int32_t a[2], b[2], c[2], d[2], e[2]; /* per side: the sources' states (see texture_gen) */
+ int32_t lpm[2]; /* MOVE's brightness (one-pole) */
+ int32_t t0, t1, t2; /* slow random walks / timers */
+ tsvf_t wc[2]; /* WIND: this block's filters */
+ int32_t wz[2][2];
+ uint32_t upos, ufrac; /* USR: the read position, Q16 fraction */
+ int32_t up, ui, us0, us1; /* USR: ADPCM predictor, step index, the two samples interpolated */
+ uint32_t ugen; /* USR: the slots' scan count (an upload restarts it) */
+ int32_t ulast, uoff; /* USR: the last value out; the step at a wrap, gliding to 0
+ * (a sample that does not end where it starts: no click) */
+ uint8_t uwrap; /* USR: tx_usr_next went round */
+ djf_t f; /* TONE */
+} tx = {.rnd = 0x2545F491};
+static inline int32_t tx_n16(void) { return (int32_t)(noise32(&tx.rnd) >> 16) - 32768; } /* -32768 .. 32767 */
+static void texture_reset(uint32_t src)
+{
+ int32_t rnd = tx.rnd, g = tx.g;
+ uint32_t ph = tx.ph;
+ uint8_t play = tx.play;
+ memset(&tx, 0, sizeof tx);
+ tx.rnd = rnd ? rnd : 0x2545F491;
+ tx.g = g, tx.ph = ph, tx.play = play;
+ tx.src = (uint8_t)src;
+ tx.t0 = 50 << 8, tx.t1 = 60 << 8; /* (WIND: the two cutoffs, RADIO / TAPE: the level) */
+ tx.ugen = smp_user_gen - 1u; /* (USR: the zone looked up on the first block) */
+}
+/* USR k: the next sample of its first zone, looped (sample_next's decoder, its own state) */
+static inline int32_t tx_usr_next(const smp_zone_t *z)
+{
+ uint32_t pos = tx.upos, b = SMP_DATA[z->off + (pos >> 1)];
+ uint32_t code = (pos & 1u) ? (b >> 4) : (b & 15u);
+ int32_t step = IMA_STEP[(uint32_t)tx.ui <= 88u ? tx.ui : 88], vd = step >> 3;
+ if (code & 4u) vd += step;
+ if (code & 2u) vd += step >> 1;
+ if (code & 1u) vd += step >> 2;
+ tx.up = clamp(tx.up + ((code & 8u) ? -vd : vd), -32768, 32767);
+ tx.ui = clamp(tx.ui + IMA_IDX[code & 7u], 0, 88);
+ if (++pos > (z->looped ? z->le : z->n - 1u)) { /* round again: from the loop (its state), or the top */
+ pos = z->looped ? z->ls : 0u;
+ tx.up = z->looped ? z->pred : 0;
+ tx.ui = z->looped ? z->idx : 0;
+ tx.uwrap = 1;
+ }
+ tx.upos = pos;
+ return tx.up;
+}
+/* n samples of source src (both sides) into l, r, at about 8000 rms */
+static void texture_gen(uint32_t src, int32_t *l, int32_t *r, uint32_t n)
+{
+ uint32_t i, k;
+ if (src >= TX_USR1) {
+ uint32_t s = src - TX_USR1;
+ const smp_zone_t *z = usr_nz[s] ? &usr_zone[s][0] : 0;
+ if (!z || !z->n) {
+ for (i = 0; i < n; i++)
+ l[i] = r[i] = 0;
+ return;
+ }
+ if (tx.ugen != smp_user_gen) { /* a new upload (or the first block): from the top */
+ tx.ugen = smp_user_gen;
+ tx.upos = 0, tx.ufrac = 0, tx.up = tx.ui = 0;
+ tx.us0 = 0, tx.us1 = tx_usr_next(z);
+ tx.uwrap = 1; /* (from where the old one was: no click) */
+ }
+ for (i = 0; i < n; i++) {
+ int32_t v;
+ tx.ufrac += z->rate; /* (its own rate: Q16 of 44.1 kHz) */
+ while (tx.ufrac >= 65536u) {
+ tx.ufrac -= 65536u;
+ tx.us0 = tx.us1;
+ tx.us1 = tx_usr_next(z);
+ }
+ v = (tx.us0 + (((tx.us1 - tx.us0) * (int32_t)(tx.ufrac >> 1)) >> 15)) >> 1;
+ if (tx.uwrap) { /* (2.6) round again: from the value it was at */
+ tx.uwrap = 0;
+ tx.uoff = tx.ulast - v;
+ }
+ tx.uoff -= (tx.uoff >> 6) + (tx.uoff > 0) - (tx.uoff < 0); /* (~1.5 ms) */
+ l[i] = r[i] = tx.ulast = v + tx.uoff;
+ }
+ return;
+ }
+ switch (src) {
+ case TX_VINYL: /* a: rumble, b: crackle, c: its decay, d: hiss tilt */
+ for (i = 0; i < n; i++) {
+ uint32_t z = noise32(&tx.rnd);
+ int32_t w = (int32_t)(z >> 16) - 32768, h;
+ tx.a[0] += (w >> 5) - (tx.a[0] >> 7); /* rumble: integrated, leaky */
+ if ((z & 0xFFFFu) < 60u) { /* crackle, ~40 a second, anywhere left to right */
+ int32_t amp = 6000 + (int32_t)((z >> 8) & 0x3FFFu) + ((z & 1u) ? 0 : 12000 * ((z & 0x30u) == 0u));
+ int32_t pan = (int32_t)((z >> 20) & 0xFFu);
+ amp = (z & 0x100u) ? -amp : amp;
+ tx.b[0] = (amp * (256 - pan)) >> 8;
+ tx.b[1] = (amp * pan) >> 8;
+ }
+ for (k = 0; k < 2u; k++) {
+ h = (k ? (int32_t)(noise32(&tx.rnd) >> 16) - 32768 : w);
+ tx.d[k] += (h - tx.d[k]) >> 2; /* the hiss: dark, low (the crackle on top) */
+ (k ? r : l)[i] = (tx.d[k] >> 4) + (tx.a[0] >> 2) + tx.b[k];
+ tx.b[k] -= tx.b[k] >> 2; /* (a click: a few samples) */
+ }
+ }
+ break;
+ case TX_TAPE: /* t0: the level drifting (Q8), t2: its next target */
+ if (!(tx.t1++ & 31))
+ tx.t2 = (24 << 8) + (int32_t)((noise32(&tx.rnd) >> 20) & 0x7FFu) * 4;
+ tx.t0 += (tx.t2 - tx.t0) >> 6;
+ for (i = 0; i < n; i++)
+ for (k = 0; k < 2u; k++) {
+ int32_t w = tx_n16();
+ tx.a[k] += (w - tx.a[k]) >> 2; /* tilted dark: mostly the low-passed part */
+ (k ? r : l)[i] = (((tx.a[k] >> 1) + (w >> 3)) * (tx.t0 >> 8)) >> 5;
+ }
+ break;
+ case TX_RAIN: /* a: the bed's low-pass, b: a droplet's level, c: its noise */
+ for (i = 0; i < n; i++)
+ for (k = 0; k < 2u; k++) {
+ uint32_t z = noise32(&tx.rnd);
+ int32_t w = (int32_t)(z >> 16) - 32768;
+ tx.a[k] += (w - tx.a[k]) >> 4; /* the bed: ~450 Hz */
+ if ((z & 0xFFFFu) < 420u) /* a droplet: ~280 a second a side */
+ tx.b[k] = 4000 + (int32_t)((z >> 4) & 0x3FFFu);
+ tx.c[k] += (w - tx.c[k]) >> 1;
+ (k ? r : l)[i] = (tx.a[k] >> 1) + (((w - tx.c[k]) * tx.b[k]) >> 14);
+ tx.b[k] -= tx.b[k] >> 5;
+ }
+ break;
+ case TX_WIND: { /* t0, t1: the cutoffs wandering (Q8 index), t2: their targets */
+ if (!(noise32(&tx.rnd) & 31u))
+ tx.t2 = (int32_t)(noise32(&tx.rnd) & 0xFFFFu); /* new targets now and then: 34 .. 78 */
+ tx.t0 += (((34 << 8) + (tx.t2 & 0xFF) * 44) - tx.t0) >> 7;
+ tx.t1 += (((34 << 8) + (tx.t2 >> 8) * 44) - tx.t1) >> 7;
+ tsvf_coef(&tx.wc[0], tx.t0, 95);
+ tsvf_coef(&tx.wc[1], tx.t1, 95);
+ for (i = 0; i < n; i++)
+ for (k = 0; k < 2u; k++) {
+ int32_t y = tsvf_lp(&tx.wc[k], tx_n16() >> 2, &tx.wz[k][0], &tx.wz[k][1]);
+ (k ? r : l)[i] = clamp(y, -32767, 32767);
+ }
+ break;
+ }
+ case TX_RADIO: /* a, b: the band's two low-passes, t0: the burst level (Q8),
+ * t1: samples left of the burst, c: the held sample */
+ if ((tx.t1 -= (int32_t)n) <= 0) {
+ uint32_t z = noise32(&tx.rnd);
+ tx.t1 = 1500 + (int32_t)((z >> 8) & 0x3FFFu); /* 35 .. 400 ms */
+ tx.t2 = (z & 3u) == 0u ? 40 << 8 : (110 + (int32_t)((z >> 24) & 0x7Fu)) << 8; /* (a gap now and then) */
+ }
+ tx.t0 += (tx.t2 - tx.t0) >> 2;
+ for (i = 0; i < n; i++) {
+ int32_t w = tx_n16(), y;
+ if (!(i & 3u))
+ tx.c[0] = w; /* coarse: held four samples */
+ tx.a[0] += (tx.c[0] - tx.a[0]) >> 1; /* < ~3 kHz */
+ tx.b[0] += (tx.a[0] - tx.b[0]) >> 4; /* the lows taken out: > ~500 Hz */
+ y = (((tx.a[0] - tx.b[0]) >> 1) * (tx.t0 >> 8)) >> 6;
+ l[i] = y;
+ r[i] = y - (y >> 2);
+ }
+ break;
+ case TX_ROOM: /* a: the rumble, b: its low-pass, c: air */
+ for (i = 0; i < n; i++)
+ for (k = 0; k < 2u; k++) {
+ int32_t w = tx_n16();
+ tx.a[k] += (w >> 4) - (tx.a[k] >> 8);
+ tx.b[k] += (tx.a[k] - tx.b[k]) >> 5;
+ (k ? r : l)[i] = (tx.b[k] >> 1) + (w >> 6);
+ }
+ break;
+ default:
+ for (i = 0; i < n; i++)
+ l[i] = r[i] = 0;
+ break;
+ }
+}
+static void texture_mix(int32_t *l, int32_t *r, uint32_t n)
+{
+ static int32_t tl[CTL], tr[CTL];
+ static const uint8_t BARS[5] = {1, 2, 4, 8, 16};
+ uint32_t src = (uint32_t)clamp(song.g[G_TXSRC], 0, TX_N - 1), i, bar;
+ /* the sources to about 8000 rms (VINYL ~5000: its crackle peaks), Q8; the user slots as they are (/ 2) */
+ static const int16_t TX_SCALE[TX_USR1 + 1] = {0, 800, 301, 693, 1918, 149, 343, 256};
+ int32_t lvl = clamp(song.g[G_TXLVL], 0, 127), on, g0, g1, mv, depth, u, lfo, k0, k1, sc;
+ tsvf_t fc;
+ if (song.playing && !tx.play)
+ tx.ph = 0; /* MOVE from the transport's start */
+ tx.play = (uint8_t)song.playing;
+ on = src && src == tx.src && (song.playing || song.g[G_TXWHEN]) && lvl;
+ if (!tx.g && !on) { /* silent: nothing runs (and a new source starts from rest) */
+ if (src != tx.src)
+ texture_reset(src);
+ return;
+ }
+ if (n > CTL)
+ return;
+ g0 = tx.g; /* fades over ~0.1 s (238 a block), as DUST's bed */
+ g1 = tx.g = clamp(tx.g + (on ? 238 : -238), 0, 32767);
+ bar = (uint32_t)FS * 240u / (uint32_t)clamp(song.g[G_BPM], 20, 300); /* a bar of 4/4, samples */
+ tx.ph += (uint32_t)((0xFFFFFFFFu / (bar * BARS[clamp(song.g[G_TXRATE], 0, 4)])) * n);
+ lfo = sine_i(tx.ph - 0x40000000u); /* (from its top: a start at full) */
+ depth = clamp(song.g[G_TXMOVE], 0, 127) * 258;
+ u = mulq15(depth, (32767 - lfo) >> 1); /* 0 .. depth, the dip */
+ mv = 32767 - mulq15(u, 21000); /* the level breathing: down to ~36 % */
+ k0 = 32767 - mulq15(u, 28000); /* the brightness: a one-pole closing */
+ texture_gen(tx.src, tl, tr, n);
+ sc = TX_SCALE[tx.src < TX_USR1 ? tx.src : TX_USR1];
+ for (i = 0; i < n; i++) { /* each source to its level, MOVE's colour (Q13: no overflow */
+ tx.lpm[0] += ((((tl[i] * sc) >> 8) - tx.lpm[0]) >> 2) * (k0 >> 2) >> 11; /* up to +-260000) */
+ 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)) {
+ djf_run(&tx.f, &fc, tl, n, 0);
+ djf_run(&tx.f, &fc, tr, n, 1);
+ }
+ k1 = mulq15(lvl * lvl * 2, mv); /* LEVEL^2 (x 2: Q15 of 4096 at 127 .. ) x MOVE */
+ for (i = 0; i < n; i++) {
+ int32_t g = g0 + (((g1 - g0) * (int32_t)i) >> CTL_LOG2), gk = mulq15(g, k1);
+ if (song.g[G_TXDUCK])
+ gk = mulq15(gk, duck.g0 + (((duck.g1 - duck.g0) * (int32_t)i) >> CTL_LOG2));
+ l[i] += (tl[i] * (gk >> 4)) >> 11; /* x LEVEL^2 / 16384: (x * gk / 32768) at full */
+ r[i] += (tr[i] * (gk >> 4)) >> 11;
+ }
+ if (!g1 && src != tx.src)
+ texture_reset(src); /* faded out: the new source from rest */
+}
+
static void mix_block(int32_t *out, uint32_t n)
{
uint32_t i;
int32_t m0, m1;
for (i = 0; i < n; i++)
send_c[i] = send_d[i] = send_r[i] = mix_l[i] = mix_r[i] = 0;
+ { /* REV / ECHO THROW (2.6): the sends glide to full and back over ~12 ms (17 blocks) */
+ uint32_t q = thr_req;
+ thr_rev = (q & 1u) ? (thr_rev + 1928 > 32767 ? 32767 : thr_rev + 1928) : (thr_rev > 1928 ? thr_rev - 1928 : 0);
+ thr_dly = (q & 2u) ? (thr_dly + 1928 > 32767 ? 32767 : thr_dly + 1928) : (thr_dly > 1928 ? thr_dly - 1928 : 0);
+ }
events_block(n);
duck_block(n * (uint32_t)song.g[G_BPM]);
for (i = 0; i < NPART; i++)
@@ -495,6 +1067,7 @@ static void mix_block(int32_t *out, uint32_t n)
for (i = 0; i < n; i++)
dl[i] = dr[i] = dv[i] = dd[i] = 0;
slicer_drums(dl, dr, dv, dd, n);
+ drum_insert(dl, dr, dv, dd, n);
tflt_run(f, &fc, dl, n, 0);
tflt_run(f, &fc, dr, n, 1);
tflt_run(f, &fc, dv, n, 2);
@@ -505,11 +1078,24 @@ static void mix_block(int32_t *out, uint32_t n)
send_r[i] += dv[i];
send_d[i] += dd[i];
}
+ } else if (n <= CTL && (TDRUM->p[P_ITYPE] | TDRUM->ins_run)) { /* the INSERT (2.6), no FILTER */
+ for (i = 0; i < n; i++)
+ dl[i] = dr[i] = dv[i] = dd[i] = 0;
+ slicer_drums(dl, dr, dv, dd, n);
+ drum_insert(dl, dr, dv, dd, n);
+ for (i = 0; i < n; i++) {
+ mix_l[i] += dl[i];
+ mix_r[i] += dr[i];
+ send_r[i] += dv[i];
+ send_d[i] += dd[i];
+ }
} else {
slicer_drums(mix_l, mix_r, send_r, send_d, n); /* drums_render, through the SLICER when on */
}
}
click_render(mix_l, mix_r, n); /* the metronome: its own voice (drums.c), any kit, any mute */
+ texture_mix(mix_l, mix_r, n); /* GLO > TEXTURE (2.6): the bed, dry */
+ punch_freeze_feed(send_r, mix_l, mix_r, n); /* punch-in FREEZE: the dry mix into the held reverb */
fx_buses(send_c, send_d, send_r, wet_l, wet_r, n);
for (i = 0; i < n; i++) {
mix_l[i] += wet_l[i];
@@ -521,22 +1107,41 @@ static void mix_block(int32_t *out, uint32_t n)
m1 = (int32_t)song.master_q12;
m0 = master_cur < 0 ? m1 : master_cur;
master_cur = m1;
- for (i = 0; i < n; i++) {
- int32_t m = m0 + (((m1 - m0) * (int32_t)i) >> CTL_LOG2);
- int32_t l = ((mix_l[i] >> 2) * m) >> 10;
- int32_t r = ((mix_r[i] >> 2) * m) >> 10;
- master_out(&l, &r);
- out[2u * i] = l;
- out[2u * i + 1u] = r;
- if ((i & 1u) && i < CTL) { /* the visualiser: every other sample, as audio.c reads it */
- vis_tap[2u * i] = (int16_t)knee(mix_l[i]);
- vis_tap[2u * i + 1u] = (int16_t)knee(mix_r[i]);
+ if (n > CTL)
+ n = CTL; /* (the buffers' size) */
+ {
+ static int32_t ol[CTL], orr[CTL], ul[CTL], ur[CTL];
+ static uint8_t usb_was;
+ for (i = 0; i < n; i++) {
+ int32_t m = m0 + (((m1 - m0) * (int32_t)i) >> CTL_LOG2);
+ ol[i] = ((mix_l[i] >> 2) * m) >> 10;
+ orr[i] = ((mix_r[i] >> 2) * m) >> 10;
+ master_pre(&ol[i], &orr[i]);
+ if ((i & 1u)) { /* the visualiser: every other sample, as audio.c reads it */
+ vis_tap[2u * i] = (int16_t)knee(mix_l[i]);
+ vis_tap[2u * i + 1u] = (int16_t)knee(mix_r[i]);
+ }
+ if (usb_full_now) { /* USB AUDIO = FULL: MASTER all the way up (4096) */
+ ul[i] = (mix_l[i] >> 2) << 2, ur[i] = (mix_r[i] >> 2) << 2;
+ master_pre_usb(&ul[i], &ur[i]);
+ }
}
- if (usb_full_now && i < CTL) { /* USB AUDIO = FULL: MASTER all the way up (4096) */
- int32_t ul = (mix_l[i] >> 2) << 2, ur = (mix_r[i] >> 2) << 2;
- master_out_usb(&ul, &ur);
- usb_out[2u * i] = ul;
- usb_out[2u * i + 1u] = ur;
+ lim_block(&lim_dac, ol, orr, n);
+ for (i = 0; i < n; i++) {
+ out[2u * i] = knee(ol[i]);
+ out[2u * i + 1u] = knee(orr[i]);
+ }
+ if (usb_full_now && !usb_was) { /* (a new recording: no old block in its delay) */
+ memset(&lim_usb, 0, sizeof lim_usb);
+ lim_usb.env = LIM_T, lim_usb.g = 32768, lim_usb.hold = 0;
+ }
+ usb_was = usb_full_now;
+ if (usb_full_now) {
+ lim_block(&lim_usb, ul, ur, n);
+ for (i = 0; i < n; i++) {
+ usb_out[2u * i] = knee(ul[i]);
+ usb_out[2u * i + 1u] = knee(ur[i]);
+ }
}
}
}
diff --git a/firmware/src/gfx.c b/firmware/src/gfx.c
index 58509d0..acda5cc 100644
--- a/firmware/src/gfx.c
+++ b/firmware/src/gfx.c
@@ -12,6 +12,8 @@ typedef struct { /* proportional, see tools/gen_font.py */
const uint8_t *bw; /* bitmap width per glyph (starts FONT_PAD left of the pen) */
const uint16_t *off; /* byte offset of each glyph */
const uint8_t *data;
+ uint8_t bits; /* SLOOP 2.6: 1 = 1 bit a pixel (a pixel font: glyph rows one after the other, high
+ * bit first, each glyph from a whole byte); 0 = 2 pixels a byte, alpha 0..15 */
} felucca_font_t;
#include "felucca_font.h"
@@ -121,11 +123,12 @@ static void cv_line(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint16_t c)
}
}
-/* glyph index of a character: lower case folds to upper case when the font
- * has none, anything missing (and C1 controls) draws as '?' */
+/* glyph index of a character: the screen shows capitals only (SLOOP 2.6: bold capitals read better on the
+ * small screen), so lower case folds to upper case, Latin-1 too (\xfc -> \xdc; not the division sign, nor sharp
+ * s and y diaeresis, which have none); anything missing (and C1 controls) draws as '?' */
static uint32_t glyph(const felucca_font_t *f, uint32_t ch)
{
- if (ch >= 'a' && ch <= 'z' && f->last < 'a')
+ if ((ch >= 'a' && ch <= 'z') || (ch >= 0xE0u && ch <= 0xFEu && ch != 0xF7u))
ch -= 32u;
if (ch < f->first || ch > f->last || (ch >= 127u && ch < 160u))
ch = '?';
@@ -143,8 +146,19 @@ static int32_t cv_text(int32_t x, int32_t y, const felucca_font_t *f, const char
uint32_t gi = glyph(f, (uint8_t)*s), gx, gy, w, bpr;
const uint8_t *gd;
w = f->bw[gi];
- bpr = ((w >> f->sh) + 1u) / 2u;
gd = f->data + f->off[gi];
+ if (f->bits == 1u) { /* on / off pixels: full colour where a bit is set */
+ uint32_t sw = w >> f->sh;
+ for (gy = 0; gy < f->h; gy++)
+ for (gx = 0; gx < w; gx++) {
+ uint32_t i = (gy >> f->sh) * sw + (gx >> f->sh);
+ if ((gd[i >> 3] >> (7u - (i & 7u))) & 1u)
+ cv_pset(x - f->pad + (int32_t)gx, y + (int32_t)gy, ramp[15]);
+ }
+ x += f->adv[gi];
+ continue;
+ }
+ bpr = ((w >> f->sh) + 1u) / 2u;
for (gy = 0; gy < f->h; gy++)
for (gx = 0; gx < w; gx++) {
uint32_t sx = gx >> f->sh, v = gd[(gy >> f->sh) * bpr + sx / 2u];
diff --git a/firmware/src/icons.c b/firmware/src/icons.c
index 4f9808d..9d914ac 100644
--- a/firmware/src/icons.c
+++ b/firmware/src/icons.c
@@ -45,6 +45,9 @@ static const icon_map_t ICON_MAP[] = {
{"SYNC", ICON_TEMPO}, {"ROUT", ICON_MIX}, {"CPU", ICON_CHIP}, {"SLOT", ICON_SAVE},
{"LOAD", ICON_LOAD}, {"SAVE", ICON_SAVE}, {"ENG", ICON_WAVE}, {"CLRSQ", ICON_CLEAR},
{"INIT", ICON_CLEAR}, {"ERASE", ICON_CLEAR}, {"CH", ICON_MIDI}, {"LEVEL", ICON_LEVEL},
+ {"OUT", ICON_MIDI}, {"IN", ICON_MIDI}, {"CH1", ICON_MIDI}, {"CH2", ICON_MIDI}, {"CH3", ICON_MIDI}, {"CH4", ICON_MIDI}, /* (2.6:
+ * GLO > MIDI, MIDI 2) */
+ {"OTHER", ICON_MIDI}, {"BEND", ICON_TUNE},
/* engines (eng_*.c edit[] labels) */
{"DTN", ICON_DETUNE}, {"NOIS", ICON_NOISE}, {"CUT", ICON_CUTOFF}, {"RES", ICON_RESO},
{"DRV", ICON_DRIVE}, {"KTR", ICON_KEYTRACK}, {"ALG", ICON_ALGORITHM}, {"R2", ICON_RATIO},
diff --git a/firmware/src/main.c b/firmware/src/main.c
index 321b595..35989df 100644
--- a/firmware/src/main.c
+++ b/firmware/src/main.c
@@ -120,6 +120,8 @@ static void felucca_init(void)
song.g[G_SYNC] = (int16_t)lights_sync; /* a setting of the FM-1 (panel.c) */
song.g[G_MIDI] = (int16_t)lights_mout;
song.g[G_ROUTE] = (int16_t)lights_min;
+ song.g[G_CH1] = midi_set[0], song.g[G_CH2] = midi_set[1], song.g[G_CH3] = midi_set[2]; /* (2.6: GLO > MIDI, */
+ song.g[G_DRCH] = midi_set[3], song.g[G_CHOTH] = midi_set[4], song.g[G_BEND] = midi_set[5]; /* 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 6b7ca54..54813f8 100644
--- a/firmware/src/panel.c
+++ b/firmware/src/panel.c
@@ -81,7 +81,11 @@ static uint8_t lights_lvl, lights_keys;
static uint8_t lights_notes; /* 1: on a synth track the sounding notes light their keys */
static uint8_t lights_sync; /* GLO > SYSTEM > SYNC (G_SYNC), kept here: 0 INT, 1 USB, 2 TRS */
static uint8_t lights_mout; /* GLO > SYSTEM > MIDI (G_MIDI): 1 = the sequencer goes to MIDI OUT too */
-static uint8_t lights_min; /* GLO > SYSTEM > IN (G_ROUTE): 1 = MIDI in takes the clock only, no notes */
+static uint8_t lights_min; /* GLO > SYSTEM > IN (G_ROUTE): 0 NOTES, 1 CLOCK only, 2..17 (2.6) CH 1..16 only */
+/* 2.6: GLO > MIDI CH1 CH2 CH3, GLO > DRUMS > CH, GLO > MIDI > OTHER: settings of the FM-1 (kept with the MIDI LEARN map
+ * after the SYN kits: project.c midi_part), mirrored in song.g (felucca_init) */
+#define MIDI_SET_DEF {1, 2, 3, 10, 0, 2} /* CH1 CH2 CH3, drums, OTHER, (2.6) BEND */
+static uint8_t midi_set[6] = MIDI_SET_DEF;
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) */
@@ -90,8 +94,9 @@ static uint32_t lights_word(void)
{
return (uint32_t)lights_lvl | (uint32_t)lights_keys << 4 | (uint32_t)(lights_notes != 0u) << 8 |
(uint32_t)(rec_tempo != 0u) << 9 | (uint32_t)(rec_count != 0u) << 10 | (uint32_t)(usb_full != 0u) << 11 |
- (uint32_t)(lights_sync % 3u) << 12 | (uint32_t)(lights_mout != 0u) << 14 | (uint32_t)(lights_min != 0u) << 15 |
- (uint32_t)(usb_serial != 0u) << 16 | (uint32_t)(vis_style % 12u) << 17;
+ (uint32_t)(lights_sync % 3u) << 12 | (uint32_t)(lights_mout != 0u) << 14 | (uint32_t)(lights_min == 1u) << 15 |
+ (uint32_t)(usb_serial != 0u) << 16 | (uint32_t)(vis_style % 12u) << 17 |
+ (uint32_t)(lights_min >= 2u && lights_min <= 17u ? lights_min - 1u : 0u) << 21; /* 2.6: CH n (n 1..16; 0 none) */
}
static void lights_from_word(uint32_t w)
{
@@ -104,6 +109,8 @@ static void lights_from_word(uint32_t w)
lights_sync = (uint8_t)(((w >> 12) & 3u) % 3u);
lights_mout = (uint8_t)((w >> 14) & 1u); /* GLO > SYSTEM > MIDI (seq.c) */
lights_min = (uint8_t)((w >> 15) & 1u); /* GLO > SYSTEM > IN (seq.c) */
+ if (((w >> 21) & 31u) >= 1u && ((w >> 21) & 31u) <= 16u)
+ lights_min = (uint8_t)(((w >> 21) & 31u) + 1u); /* 2.6: CH n (an older SLOOP reads NOTES) */
usb_serial = (uint8_t)((w >> 16) & 1u);
vis_style = (uint8_t)(((w >> 17) & 15u) % 12u); /* the visualiser (ui_vis.c); 0 in 2.3 = OSCILLOSCOPE */ /* menu USB SERIAL (usb.c usb_cdc_on, at the next start); 0 in 2.3 = OFF */
}
diff --git a/firmware/src/params.c b/firmware/src/params.c
index fdcfad2..01e610f 100644
--- a/firmware/src/params.c
+++ b/firmware/src/params.c
@@ -2,12 +2,46 @@
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
/* Parameter descriptors, formatting and the page table. */
static const char *const N_LWAVE[] = {"SIN", "TRI", "SAW", "SQR", "S&H"};
+/* SLOOP 2.6, after Felucca 1.4 / 1.5 (Leo Kuroshita) ----------------------------------------------------------------
+ * LFO 2. SYNC: OFF (RATE), or one cycle per note value of the tempo, longest first (LSYNC_UNITS: in core.h div_units'
+ * units); TRIG: NOTE restarts it at PHS on a fresh phrase (as before), FREE never; POL: BI -1..+1 (as before), UNI 0..+1 */
+static const char *const N_LSYNC[] = {"OFF", "4BAR", "2BAR", "1BAR", "1/2", "1/4", "1/8", "8T", "1/16", "16T", "1/32"};
+static const char *const N_LTRIG[] = {"NOTE", "FREE"};
+static const char *const N_LPOL[] = {"BI", "UNI"};
+/* GLO > MIDI (2.6): a synth track's MIDI channel, and the other channels */
+static const char *const N_MCH[] = {"OFF", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"};
+static const char *const N_MOTH[] = {"SEL", "OFF"};
+/* GLO > TEXTURE (2.6, fx.c texture_*): the bed's sources (the user slots last), its movement's length, when it plays */
+static const char *const N_TXSRC[] = {"OFF", "VINYL", "TAPE", "RAIN", "WIND", "RADIO", "ROOM", "USR1", "USR2", "USR3", "USR4"};
+static const char *const N_TXRATE[] = {"1BAR", "2BAR", "4BAR", "8BAR", "16BAR"};
+static const char *const N_TXWHEN[] = {"PLAY", "ALWAYS"};
+/* ANALOG's filter TYPE (eng_analog.c): the SVF's low-pass (as always), band-pass, high-pass output */
+static const char *const N_FTYPE[] = {"LP", "BP", "HP"};
+/* ENV SYNC (voice.c): ATK DEC REL as note values of the tempo, shortest first. 0..127 split evenly over these 25
+ * (param_format's F_INT name list: value v is ESYNC_NAMES[v * 25 / 128]); ESYNC_UNITS: each in 1/384 of a bar of
+ * 4/4 (a quarter 96), 0 = the shortest time ATK / DEC / REL 0 has. 0-terminated (param_format) */
+#define ESYNC_N 25u
+static const char *const ESYNC_NAMES[ESYNC_N + 1u] = {
+ "0", "1/64T", "1/64", "1/32T", "1/64D", "1/32", "1/16T", "1/32D", "1/16", "1/8T", "1/16D", "1/8", "1/4T", "1/8D",
+ "1/4", "1/2T", "1/4D", "1/2", "1/1T", "1/2D", "1/1", "1/1D", "2BAR", "3BAR", "4BAR", 0};
+static const uint16_t ESYNC_UNITS[ESYNC_N] = {0, 4, 6, 8, 9, 12, 16, 18, 24, 32, 36, 48, 64, 72,
+ 96, 128, 144, 192, 256, 288, 384, 576, 768, 1152, 1536};
+static uint32_t esync_idx(int32_t v) { return (uint32_t)(v & 127) * ESYNC_N >> 7; } /* (param_format's split) */
+/* the INSERT's types (fx.c IT_*; append-only: stored). Its three values A B C mean what the type says (ins_desc) */
+static const char *const N_ITYPE[] = {"OFF", "SOFT", "HARD", "FOLD", "FUZZ", "CRUSH", "PHASR", "FLANG", "CHOR"};
+/* CRUSH: BITS 1..16 and RATE (the held sample's rate) over the range in 16 even parts (0-terminated) */
+static const char *const N_IBITS[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
+ "16", 0};
+static const char *const N_IRATE[] = {"689", "919", "1.1k", "1.4k", "1.8k", "2.2k", "2.8k", "3.7k", "4.4k", "5.5k",
+ "7.4k", "8.8k", "11k", "15k", "22k", "44k", 0};
static const char *const N_AMODE[] = {"OFF", "UP", "DN", "UPDN", "RND", "ORD"};
static const char *const N_MOUT[] = {"KEYS", "SEQ"};
-static const char *const N_MIN[] = {"NOTES", "CLOCK"}; /* G_ROUTE: MIDI in, notes and clock, or the clock only (seq.c) */ /* G_MIDI: what goes to MIDI OUT (seq.c seq_out_on) */
+static const char *const N_MIN[] = {"NOTES", "CLOCK", "CH 1", "CH 2", "CH 3", "CH 4", "CH 5", "CH 6", "CH 7", "CH 8", "CH 9",
+ "CH 10", "CH 11", "CH 12", "CH 13", "CH 14", "CH 15", "CH 16"}; /* G_ROUTE: MIDI in, notes and clock, the clock only, or (2.6) one channel only, on the selected track (seq.c) */ /* G_MIDI: what goes to MIDI OUT (seq.c seq_out_on) */
static const char *const N_DIV[] = {"1/4", "1/8", "1/16", "1/32", "8T", "16T"};
static const char *const N_SDIV[] = {"1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/2", "1BAR", "2BAR"}; /* core.h div_units */
-static const char *const N_DLY[] = {"1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/8D", "1/16D"}; /* core.h dly_units */
+static const char *const N_DLY[] = {"1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/8D", "1/16D", "1/4D"}; /* core.h dly_units
+ * (2.6: 1/4D, after Felucca 1.5.1) */
static const char *const N_SCALE[] = {"CHR", "MAJ", "MIN", "DOR", "MIX", "PEN", "MPEN", "HARM",
"PHRY", "LYD", "LOC", "MEL", "BLUES", "WHOLE", "DIMHW", "DIMWH"};
static const char *const N_ONOFF[] = {"OFF", "ON"};
@@ -90,6 +124,18 @@ static const param_desc_t TP[P_COUNT] = {
[P_TFLT] = PD("FILT", F_FILT, -64, 63, 0),
[P_STRUM] = PD("STRUM", F_INT, -60, 60, 0), /* ms a note: > 0 low to high (down), < 0 high to low */
[P_VLEAD] = PE("VLEAD", N_ONOFF, 0),
+ /* 2.6, after Felucca 1.5 / 1.4. The INSERT (fx.c track_insert): TYPE OFF = as before. A B C as the editor
+ * protocol names them; the device shows the type's own labels (ins_desc) */
+ [P_ITYPE] = PE("INSRT", N_ITYPE, 0),
+ [P_IA] = PD("INS A", F_PCT, 0, 127, 64),
+ [P_IB] = PD("INS B", F_PCT, 0, 127, 96),
+ [P_IC] = PD("INS C", F_PCT, 0, 127, 96),
+ [P_IMIX] = PD("MIX", F_PCT, 0, 127, 127),
+ [P_FTYPE] = PE("TYPE", N_FTYPE, 0), /* ANALOG's filter, LP = as before (eng_analog.c) */
+ [P_ESYNC] = PE("ESYNC", N_ONOFF, 0), /* OFF = ATK DEC REL in ms, as before (voice.c) */
+ [P_LSYNC] = PE("SYNC", N_LSYNC, 0), /* LFO 2: OFF = RATE, as before */
+ [P_LTRIG] = PE("TRIG", N_LTRIG, 0),
+ [P_LPOL] = PE("POL", N_LPOL, 0),
};
/* a preset's extra parameters (preset_t.x) into p, each clamped to its range */
static void preset_extras(int16_t *p, const preset_t *pr)
@@ -116,9 +162,9 @@ static const param_desc_t GP[G_COUNT] = {
[G_RDAMP] = PD("DAMP", F_PCT, 0, 127, 60),
[G_CRATE] = PD("CRT", F_LFOHZ, 0, 127, 40),
[G_CDEPTH] = PD("CDP", F_PCT, 0, 127, 60),
- [G_MIDI] = PE("MIDI", N_MOUT, 0), /* MIDI OUT: the keys, or the sequencer too (a setting of the FM-1) */
+ [G_MIDI] = PE("OUT", N_MOUT, 0), /* MIDI OUT: the keys, or the sequencer too (a setting of the FM-1) */
[G_SYNC] = PE("SYNC", N_SYNC, 0), /* a setting of the FM-1, not of a project (panel.c lights_sync) */
- [G_ROUTE] = PE("IN", N_MIN, 0), /* MIDI IN: NOTES (and the clock) or CLOCK only (a setting of the FM-1) */
+ [G_ROUTE] = PE("IN", N_MIN, 0), /* MIDI IN: NOTES (and the clock), CLOCK only, or CH n: that channel only (a setting of the FM-1) */
[G_INFO] = PD("CPU", F_INT, 0, 0, 0),
[G_SLOT] = PD("SLOT", F_INT, 1, 4, 1),
[G_NAME] = PE("NAME", N_DASH, 0),
@@ -128,7 +174,7 @@ static const param_desc_t GP[G_COUNT] = {
[G_ENGGO] = PE("SET", N_GO, 0),
[G_CLRSEQ] = PE("CLRSQ", N_GO, 0),
[G_INITSND] = PE("INIT", N_GO, 0),
- [G_DRCH] = PD("CH", F_INT, 0, 16, 10), /* GM drum part MIDI channel, 0 = off */
+ [G_DRCH] = PE("CH4", N_MCH, 10), /* GM drum part (track 4) MIDI channel, 0 = OFF (2.6: as GLO > MIDI's CH1..3) */
[G_DRLVL] = PD("LVL", F_INT, 0, 127, 100),
[G_DRREV] = PD("REV", F_INT, 0, 127, 16),
[G_DUST] = PD("DUST", F_PCT, 0, 127, 0),
@@ -137,12 +183,49 @@ static const param_desc_t GP[G_COUNT] = {
[G_ROLL] = PE("ROLL", N_ROLL, 1),
[G_NEWPRJ] = PE("NEW", N_GO, 0),
[G_DRDLY] = PD("DLY", F_INT, 0, 127, 0),
+ [G_CH1] = PE("CH1", N_MCH, 1), /* 2.6, GLO > MIDI: synth track 1's channel, in and out (OFF: */
+ [G_CH2] = PE("CH2", N_MCH, 2), /* no MIDI in; out on its old one) */
+ [G_CH3] = PE("CH3", N_MCH, 3),
+ [G_CHOTH] = PE("OTHER", N_MOTH, 0), /* the channels no track has: SEL the selected track, OFF none */
+ [G_TXSRC] = PE("SRC", N_TXSRC, 0), /* 2.6, GLO > TEXTURE: the bed under the mix (OFF: none) */
+ [G_TXLVL] = PD("LEVEL", F_PCT, 0, 127, 64),
+ [G_TXTONE] = PD("TONE", F_FILT, -64, 63, 0), /* left a low-pass, right a high-pass, centre open */
+ [G_TXMOVE] = PD("MOVE", F_PCT, 0, 127, 40), /* how much it breathes (level and colour), over RATE */
+ [G_TXRATE] = PE("RATE", N_TXRATE, 2),
+ [G_TXWHEN] = PE("WHEN", N_TXWHEN, 0), /* PLAY: while the transport runs (fades in / out); ALWAYS */
+ [G_TXDUCK] = PE("DUCK", N_ONOFF, 0), /* ON: the kick pumps it too (GLO > MASTER > DUCK) */
+ [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) */
};
static const param_desc_t DRUM_KIT_DESC = PE("KIT", DRUM_KIT_NAMES, 0);
+/* the INSERT's A B C as its TYPE means them (TP's ranges and defaults): the drives DRIVE TONE LEVEL, CRUSH BITS RATE
+ * LPF, the swept ones RATE DEPTH FDBK; OFF TP's own */
+#define PU(l, f, df, n, u) {l, f, 0, 127, df, n, u}
+static const param_desc_t INS_DESC[3][3] = {
+ {PU("DRIVE", F_PCT, 64, 0, 0), PU("TONE", F_CUTOFF, 96, 0, 0), PU("LEVEL", F_DB, 96, 0, 0)},
+ {PU("BITS", F_INT, 64, N_IBITS, 0), PU("RATE", F_INT, 96, N_IRATE, "Hz"), PU("LPF", F_CUTOFF, 96, 0, 0)},
+ {PU("RATE", F_LFOHZ, 64, 0, 0), PU("DEPTH", F_PCT, 96, 0, 0), PU("FDBK", F_PCT, 96, 0, 0)},
+};
+#undef PU
+static const param_desc_t *ins_desc(int32_t type, uint32_t k)
+{
+ if (type <= 0 || type >= (int32_t)NELEM(N_ITYPE))
+ return &TP[P_IA + k];
+ return &INS_DESC[type < 5 ? 0 : type == 5 ? 1 : 2][k % 3u]; /* (SOFT .. FUZZ, CRUSH, the swept ones) */
+}
+static const param_desc_t ESYNC_DESC[3] = { /* ATK DEC REL with ENV SYNC on: the range and defaults as ever */
+ {"ATK", F_INT, 0, 127, 10, ESYNC_NAMES, 0},
+ {"DEC", F_INT, 0, 127, 70, ESYNC_NAMES, 0},
+ {"REL", F_INT, 0, 127, 60, ESYNC_NAMES, 0},
+};
+
static const param_desc_t *track_desc(const track_t *t, uint32_t id)
{
if(is_drum(t) && id==P_E0) return &DRUM_KIT_DESC;
+ if (id >= P_IA && id <= P_IC) /* the INSERT's values as its TYPE names them */
+ return ins_desc(t->p[P_ITYPE], id - P_IA);
+ if (t->p[P_ESYNC] && (id == P_ATK || id == P_DEC || id == P_REL)) /* ENV SYNC: note values */
+ return &ESYNC_DESC[id == P_ATK ? 0 : id == P_DEC ? 1 : 2];
if (id >= P_E0 && id <= P_E7) { /* the engine asked for (t->engine follows after a fade) */
const engine_t *e = ENGINES[t->eng_req % NENGINES];
const param_desc_t *d = e->desc ? e->desc(t, id - P_E0) : 0; /* a mode-dependent label / names */
@@ -151,6 +234,17 @@ static const param_desc_t *track_desc(const track_t *t, uint32_t id)
return &TP[id];
}
+/* a knob turned `steps` on an F_INT with a 0-terminated name list (ENV SYNC's note values, the INSERT's BITS and
+ * RATE): a name a detent, landing on the first value that shows it (2.6, as Felucca 1.5's ENV SYNC) */
+static int32_t names_turn(const param_desc_t *d, int32_t v, int32_t steps)
+{
+ int32_t n = 0, range = d->max - d->min + 1, k;
+ while (d->names[n])
+ n++;
+ k = clamp((clamp(v, d->min, d->max) - d->min) * n / range + steps, 0, n - 1);
+ return d->min + (k * range + n - 1) / n;
+}
+
/* value string (<= 5 chars) and unit for a parameter value */
static void param_format(const param_desc_t *d, int32_t v, char *val, const char **unit)
{
@@ -282,7 +376,7 @@ enum { FAM_HOME, FAM_ENV, FAM_LFO, FAM_FX, FAM_SCL, FAM_EDIT, FAM_GLO, FAM_SAVE,
FAM_COUNT };
enum { SC_TRACK, SC_GLOBAL, SC_ENGINE, SC_STEP, SC_TRK, SC_SONG, SC_DRUM };
enum { GR_NONE, GR_ADSR, GR_LFO, GR_STEPS, GR_ARP, GR_SCALE, GR_FX, GR_ROLL, GR_BROWSE, GR_SLOTS, GR_USER, GR_TRK,
- GR_SLCR };
+ GR_SLCR, GR_INS };
typedef struct {
const char *title;
@@ -292,27 +386,39 @@ typedef struct {
static const page_t PAGES[] = {
{"ENV", FAM_ENV, SC_TRACK, GR_ADSR, {P_ATK, P_DEC, P_SUS, P_REL}},
- {"ENV DEST", FAM_ENV, SC_TRACK, GR_NONE, {P_ED_FLT, P_ED_PIT, P_ED_SHP, 0xFF}}, /* (P_ED_FX: the level trim, no page) */
+ {"ENV DEST", FAM_ENV, SC_TRACK, GR_NONE, {P_ED_FLT, P_ED_PIT, P_ED_SHP, P_ESYNC}}, /* (P_ED_FX: the level trim, no
+ * page); 2.6: ESYNC, ENV's times as note values */
{"LFO", FAM_LFO, SC_TRACK, GR_LFO, {P_LRATE, P_LWAVE, P_LPHASE, P_LFADE}},
+ {"LFO 2", FAM_LFO, SC_TRACK, GR_LFO, {P_LSYNC, P_LTRIG, P_LPOL, 0xFF}}, /* 2.6 (Felucca 1.4): SYNC TRIG POL */
{"LFO DEST", FAM_LFO, SC_TRACK, GR_NONE, {P_LD_PIT, P_LD_FLT, P_LD_SHP, P_LD_AMP}},
{"FX", FAM_FX, SC_TRACK, GR_FX, {P_DIST, P_CHOR, P_DLY, P_REV}},
{"FILTER", FAM_FX, SC_TRACK, GR_NONE, {P_TFLT, 0xFF, 0xFF, 0xFF}}, /* the track's filter (drum track too) */
{"SLICER", FAM_FX, SC_TRACK, GR_SLCR, {P_SLCR, P_SLPAT, P_SLRATE, P_SLDEPTH}}, /* drum track too */
+ {"INSERT", FAM_FX, SC_TRACK, GR_INS, {P_ITYPE, P_IA, P_IB, P_IC}}, /* 2.6 (Felucca 1.5): the track's INSERT (fx.c), */
+ {"INSERT 2", FAM_FX, SC_TRACK, GR_INS, {P_IMIX, 0xFF, 0xFF, 0xFF}}, /* .. its dry / wet; the drum track too */
{"DLY", FAM_FX, SC_GLOBAL, GR_NONE, {G_DTIME, G_DFDBK, G_DCOLOR, G_DMIX}},
{"REV/CHO", FAM_FX, SC_GLOBAL, GR_NONE, {G_RSIZE, G_RDAMP, G_CRATE, G_CDEPTH}},
{"SEL", FAM_SCL, SC_TRACK, GR_SCALE, {P_ROOT, P_SCALE, P_QUANT, P_CHORD}},
{"SEL 2", FAM_SCL, SC_TRACK, GR_SCALE, {P_TRANS, P_STRUM, P_VLEAD, 0xFF}}, /* (2.4: the chords played) */
{"EDIT 1", FAM_EDIT, SC_ENGINE, GR_NONE, {P_E0, P_E1, P_E2, P_E3}},
{"EDIT 2", FAM_EDIT, SC_ENGINE, GR_NONE, {P_E4, P_E5, P_E6, P_E7}},
+ {"FILTER", FAM_EDIT, SC_TRACK, GR_NONE, {P_FTYPE, P_E4, P_E5, P_E7}}, /* ANALOG only (2.6, Felucca 1.5): TYPE CUT
+ * RES KTR (page_shown) */
{"VOICE", FAM_EDIT, SC_TRACK, GR_NONE, {P_VOICE, P_GLIDE, P_GLMODE, P_PRIO}},
{"VOICE 2", FAM_EDIT, SC_TRACK, GR_NONE, {P_ALLOC, P_DETUNE, P_PAN, P_MUTE}},
{"GLOBAL", FAM_GLO, SC_GLOBAL, GR_NONE, {G_BPM, G_SWING, G_CLOCK, G_TUNE}},
{"MASTER", FAM_GLO, SC_GLOBAL, GR_NONE, {G_DUST, G_DUCK, G_FILT, G_ROLL}},
{"SYSTEM", FAM_GLO, SC_GLOBAL, GR_NONE, {G_MIDI, G_SYNC, G_ROUTE, G_INFO}},
{"DRUMS", FAM_GLO, SC_GLOBAL, GR_NONE, {G_DRCH, G_DRLVL, G_DRREV, G_DRDLY}}, /* GM kit on MIDI ch 10 */
+ {"MIDI", FAM_GLO, SC_GLOBAL, GR_NONE, {G_CH1, G_CH2, G_CH3, G_DRCH}}, /* 2.6: each track's channel, the drums' too */
+ {"MIDI 2", FAM_GLO, SC_GLOBAL, GR_NONE, {G_ROUTE, G_CHOTH, G_MIDI, G_BEND}}, /* 2.6: IN, OTHER, OUT, BEND: every MIDI
+ * setting in these two pages (IN and OUT on
+ * SYSTEM too, the drums' channel on DRUMS) */
+ {"TEXTURE", FAM_GLO, SC_GLOBAL, GR_NONE, {G_TXSRC, G_TXLVL, G_TXTONE, G_TXMOVE}}, /* 2.6: the bed under the mix */
+ {"TEXTURE 2", FAM_GLO, SC_GLOBAL, GR_NONE, {G_TXRATE, G_TXWHEN, G_TXDUCK, 0xFF}},
{"PRESETS", FAM_SAVE, SC_GLOBAL, GR_BROWSE, {0xFF, 0xFF, 0xFF, 0xFF}}, /* browser: PRESETS knob / KNOB 1 */
{"USER", FAM_SAVE, SC_GLOBAL, GR_USER, {0xFF, 0xFF, 0xFF, 0xFF}}, /* user presets: SLOT LOAD ERASE SAVE */
- {"PROJECT", FAM_SAVE, SC_GLOBAL, GR_SLOTS, {G_SLOT, 0xFF, G_LOAD, G_SAVE}},
+ {"PROJECT", FAM_SAVE, SC_GLOBAL, GR_SLOTS, {G_SLOT, 0xFF, G_LOAD, G_SAVE}}, /* (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 2", FAM_ARP, SC_TRACK, GR_NONE, {P_ASWING, P_APROB, P_AHOLD, P_AORDER}},
@@ -333,7 +439,13 @@ static int page_for_drum(const page_t *pg)
return 0; /* by ALGO from a synth track, it drew the drum steps as notes */
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);
+ return pg->scope != SC_ENGINE && (pg->scope != SC_TRACK || pg->fam == FAM_SEQ || pg->graph == GR_SLCR ||
+ pg->graph == GR_INS);
+}
+/* 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)
+{
+ return pg->id[0] != P_FTYPE || (!is_drum(TSEL) && TSEL->eng_req % NENGINES == 0u);
}
static const param_desc_t *page_desc(const page_t *pg, uint32_t slot, int16_t **valp)
diff --git a/firmware/src/project.c b/firmware/src/project.c
index d8a9da8..a7566c7 100644
--- a/firmware/src/project.c
+++ b/firmware/src/project.c
@@ -6,9 +6,12 @@
* the transport is stopped and nothing sounds) and comes back at power-on: SLOOP starts where you
* left it.
*
- * Formats: 5 ("FUN5", written, SLOOP 2.4): format 4 plus, per track, the nudge of each step (micro), NLOCK
- * parameter locks, the steps' fill conditions (2 bits each) and P_TFLT (one parameter more, just before P_E0).
- * Read and converted: 4 ("FUN4", SLOOP 2.0 .. 2.3: PROJ_NP_V4 parameters, today's G_COUNT, 10-byte
+ * Formats: 6 ("FUN6", written, SLOOP 2.6): format 5 with the ten parameters of 2.6 (P_ITYPE .. P_LPOL, just
+ * before P_E0: the INSERT, the ANALOG filter TYPE, ENV SYNC, LFO 2) in a byte each, and each step's nudge (6 bits)
+ * and fill condition (2 bits) in one byte: format 5 was full (3840 bytes, one flash object), this is 3816.
+ * Read and converted: 5 ("FUN5", SLOOP 2.4 .. 2.5: format 4 plus, per track, the nudge of each step (micro), NLOCK
+ * parameter locks, the steps' fill conditions (2 bits each) and P_TFLT, one parameter more just before P_E0;
+ * converted by id, the 2.6 parameters at their defaults, a lock on P_E0.. moved with it), 4 ("FUN4", SLOOP 2.0 .. 2.3: PROJ_NP_V4 parameters, today's G_COUNT, 10-byte
* steps with levels and ratchets, the drum track's 16 lanes; no nudge, no lock), 3 ("FUN3", SLOOP 1.x: 8-byte
* steps, the drum track's notes become its lanes, the swings x 0.8 for the MPC scale), 2 ("FUN2") and 1
* ("FUN1"), which held PROJ_NP_V2 parameters per track, mapped by count as user presets are (the first
@@ -18,11 +21,13 @@
*
* Built on the host too (tests/project_test.c, -DPROJ_HOST): the part above the #ifndef
* PROJ_HOST needs core.h, params.c (TP), drums.c (the lanes), the engines and trk_def_engine (ui.c). */
-#define PROJ_MAGIC 0x46554E35u /* "FUN5": format 4 + per-step nudge, parameter locks, fill conditions (SLOOP 2.4) */
+#define PROJ_MAGIC 0x46554E36u /* "FUN6": format 5 + the 2.6 parameters, nudge and condition in a byte */
+#define PROJ_MAGIC_V5 0x46554E35u /* "FUN5": format 4 + per-step nudge, parameter locks, fill conditions (SLOOP 2.4) */
#define PROJ_MAGIC_V4 0x46554E34u /* "FUN4": four tracks, P_COUNT parameters each, 10-byte steps; read only */
#define PROJ_MAGIC_V3 0x46554E33u /* "FUN3": SLOOP 1.x; read only */
#define PROJ_MAGIC_V2 0x46554E32u /* "FUN2": four tracks, PROJ_NP_V2 parameters; read only */
#define PROJ_MAGIC_V1 0x46554E31u /* "FUN1": one instrument; loads into track 1 */
+#define PROJ_NP_V5 61u /* P_COUNT of format 5 (P_E0 was 53) */
#define PROJ_NP_V4 58u /* P_COUNT of format 4 (P_E0 was 50) */
#define PROJ_NP_V3 57u /* P_COUNT of format 3 (P_E0 was 49) */
#define PROJ_NG_V3 27u /* G_COUNT of formats 1..3 */
@@ -31,17 +36,22 @@
#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_COUNT == PROJ_NG + 1u, "the globals a project holds, then G_DRDLY");
+_Static_assert(G_DRDLY == PROJ_NG && G_TXSRC == PROJ_NG + 5u && G_COUNT == G_BEND + 1u,
+ "the globals a project holds, then G_DRDLY (then 2.6's GLO > MIDI: settings 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");
typedef struct { /* one track; the drum track ignores engine / preset */
- int16_t p[P_COUNT];
+ int16_t p[PROJ_NC6]; /* P_LEVEL .. P_VLEAD (pt_get, pt_set) */
+ int16_t e[8]; /* P_E0 .. P_E7 */
+ uint8_t x[PROJ_NX6]; /* P_ITYPE .. P_LPOL (2.6) */
uint8_t engine, preset;
union {
step_t step[NSTEP];
dstep_t dstep[NSTEP]; /* (the drum track: 16 lanes, the same size) */
};
- int8_t micro[NSTEP]; /* SLOOP 2.4: each step's nudge (core.h) */
+ uint8_t mf[NSTEP]; /* each step's nudge (core.h MICRO_*, 6 bits) | its fill condition << 6 */
plock_t lock[NLOCK]; /* and its parameter locks (step LOCK_FREE = none) */
- uint8_t fill[NSTEP / 4]; /* and its fill condition, 2 bits a step (FC_*) */
} proj_trk_t;
typedef struct {
uint32_t magic, size;
@@ -50,6 +60,43 @@ typedef struct {
proj_trk_t t[NTRK];
uint32_t sum;
} project_t;
+static int16_t pt_get(const proj_trk_t *t, uint32_t id) /* p[id] of a stored track */
+{
+ return id < PROJ_NC6 ? t->p[id] : id < P_E0 ? (int16_t)t->x[id - PROJ_NC6] : t->e[(id - P_E0) & 7u];
+}
+static void pt_set(proj_trk_t *t, uint32_t id, int32_t v)
+{
+ if (id < PROJ_NC6)
+ t->p[id] = (int16_t)v;
+ else if (id < P_E0)
+ t->x[id - PROJ_NC6] = (uint8_t)clamp(v, 0, 255);
+ else
+ t->e[(id - P_E0) & 7u] = (int16_t)v;
+}
+static int32_t pt_micro(const proj_trk_t *t, uint32_t i) { int32_t m = t->mf[i] & 63; return m >= 32 ? m - 64 : m; }
+static uint32_t pt_fill(const proj_trk_t *t, uint32_t i) { return (uint32_t)t->mf[i] >> 6; }
+static void pt_set_mf(proj_trk_t *t, uint32_t i, int32_t micro, uint32_t fill)
+{
+ t->mf[i] = (uint8_t)(((uint32_t)micro & 63u) | (fill & 3u) << 6);
+}
+typedef struct { /* a track of format 5 (SLOOP 2.4 .. 2.5), read only */
+ int16_t p[PROJ_NP_V5];
+ uint8_t engine, preset;
+ union {
+ step_t step[NSTEP];
+ dstep_t dstep[NSTEP];
+ };
+ int8_t micro[NSTEP]; /* each step's nudge (core.h) */
+ plock_t lock[NLOCK]; /* and its parameter locks (step LOCK_FREE = none) */
+ uint8_t fill[NSTEP / 4]; /* and its fill condition, 2 bits a step (FC_*) */
+} proj_trk_v5_t;
+typedef struct { /* format 5, read only */
+ uint32_t magic, size;
+ int16_t g[PROJ_NG];
+ uint8_t sel, drdly, rsv[2];
+ proj_trk_v5_t t[NTRK];
+ uint32_t sum;
+} project_v5_t;
typedef struct { /* a track of format 4 (SLOOP 2.0 .. 2.3), read only */
int16_t p[PROJ_NP_V4];
uint8_t engine, preset;
@@ -97,8 +144,8 @@ typedef struct { /* format 1 (until 0.5 beta), rea
uint32_t sum;
} project_v1_t;
_Static_assert(sizeof(project_v2_t) == 2552u && sizeof(project_v1_t) == 688u && sizeof(project_v3_t) == 2584u &&
- sizeof(project_v4_t) == 3112u, "formats 1 / 2 / 3 / 4 as they were stored");
-_Static_assert(sizeof(project_t) <= 3840u, "format 5 fits one flash object (storage.c ST_PAYLOAD_MAX)");
+ sizeof(project_v4_t) == 3112u && sizeof(project_v5_t) == 3840u, "formats 1 / 2 / 3 / 4 / 5 as they were stored");
+_Static_assert(sizeof(project_t) <= 3840u, "format 6 fits one flash object (storage.c ST_PAYLOAD_MAX)");
project_t proj_slot[4] __attribute__((section(".noinit")));
static uint32_t proj_hash(const void *p, uint32_t n) /* FNV-1a over n bytes */
@@ -144,12 +191,13 @@ static void proj_g_from_old(int16_t *g, const int16_t *g2)
g[G_SWING] = swing_from_v3(g[G_SWING]);
}
-/* no nudge, no lock, no condition (formats 1..4) */
+/* no nudge, no lock, no condition (formats 1..4); the 2.6 parameters at their defaults (formats 1..5) */
static void proj_trk_plain(proj_trk_t *d)
{
uint32_t k;
- memset(d->micro, 0, sizeof d->micro);
- memset(d->fill, 0, sizeof d->fill);
+ memset(d->mf, 0, sizeof d->mf);
+ for (k = PROJ_NC6; k < P_E0; k++)
+ pt_set(d, k, TP[k].def);
for (k = 0; k < NLOCK; k++) {
d->lock[k].step = LOCK_FREE;
d->lock[k].param = 0;
@@ -162,10 +210,10 @@ static void proj_trk_from_v3(proj_trk_t *d, const proj_trk_v3_t *s, int drum)
{
uint32_t k, nc = PROJ_NP_V3 - 8u;
proj_trk_plain(d);
- for (k = 0; k < P_E0; k++)
+ for (k = 0; k < PROJ_NC6; k++)
d->p[k] = k < nc ? s->p[k] : TP[k].def;
for (k = 0; k < 8u; k++)
- d->p[P_E0 + k] = s->p[nc + k];
+ d->e[k] = s->p[nc + k];
d->p[P_SSWING] = swing_from_v3(d->p[P_SSWING]);
d->p[P_ASWING] = swing_from_v3(d->p[P_ASWING]);
d->engine = drum ? 0u : s->engine;
@@ -191,7 +239,7 @@ static void proj_trk_v2_to_v3(proj_trk_v3_t *d, const proj_trk_v2_t *s, int drum
memcpy(d->step, s->step, sizeof d->step);
}
-/* a format 4 project (n bytes in *v4) -> slot q as format 5: the same, no nudge, no lock, no condition, no FILTER */
+/* a format 4 project (n bytes in *v4) -> slot q as format 6: the same, no nudge, no lock, no condition, no FILTER */
static int proj_from_v4(project_t *q, const project_v4_t *v4, int n)
{
uint32_t i;
@@ -205,20 +253,57 @@ static int proj_from_v4(project_t *q, const project_v4_t *v4, int n)
q->sel = v4->sel;
for (i = 0; i < NTRK; i++) {
uint32_t k;
- for (k = 0; k < P_E0; k++) /* by id up to P_CHORD, the parameters added since: */
+ proj_trk_plain(&q->t[i]);
+ for (k = 0; k < PROJ_NC6; k++) /* by id up to P_CHORD, the parameters added since: */
q->t[i].p[k] = k < PROJ_NP_V4 - 8u ? v4->t[i].p[k] : TP[k].def; /* their defaults; P_E0.. moved */
for (k = 0; k < 8u; k++)
- q->t[i].p[P_E0 + k] = v4->t[i].p[PROJ_NP_V4 - 8u + k];
+ q->t[i].e[k] = v4->t[i].p[PROJ_NP_V4 - 8u + k];
q->t[i].engine = v4->t[i].engine;
q->t[i].preset = v4->t[i].preset;
memcpy(q->t[i].step, v4->t[i].step, sizeof q->t[i].step);
- proj_trk_plain(&q->t[i]);
}
q->sum = proj_sum(q);
return 1;
}
-/* a format 3 project -> slot q as format 5 */
+/* a format 5 project (n bytes in *v5) -> slot q as format 6: by id, the 2.6 parameters at their defaults, each step's
+ * nudge and condition into its byte, the locks as they were (a lock on P_E0.. follows its parameter's new id) */
+static int proj_from_v5(project_t *q, const project_v5_t *v5, int n)
+{
+ uint32_t i, k;
+ if (n != (int)sizeof *v5 || v5->magic != PROJ_MAGIC_V5 || v5->size != sizeof *v5 ||
+ v5->sum != proj_hash(v5, sizeof *v5 - 4u))
+ return 0;
+ memset(q, 0, sizeof *q);
+ q->magic = PROJ_MAGIC;
+ q->size = sizeof *q;
+ memcpy(q->g, v5->g, sizeof q->g);
+ q->sel = v5->sel;
+ q->drdly = v5->drdly;
+ for (i = 0; i < NTRK; i++) {
+ const proj_trk_v5_t *s = &v5->t[i];
+ proj_trk_t *d = &q->t[i];
+ proj_trk_plain(d);
+ for (k = 0; k < PROJ_NC6; k++)
+ d->p[k] = s->p[k];
+ for (k = 0; k < 8u; k++)
+ d->e[k] = s->p[PROJ_NP_V5 - 8u + k];
+ d->engine = s->engine;
+ d->preset = s->preset;
+ memcpy(d->step, s->step, sizeof d->step);
+ for (k = 0; k < NSTEP; k++)
+ pt_set_mf(d, k, clamp(s->micro[k], MICRO_MIN, MICRO_MAX), (uint32_t)s->fill[k / 4u] >> (2u * (k % 4u)));
+ for (k = 0; k < NLOCK; k++) {
+ d->lock[k] = s->lock[k];
+ if (s->lock[k].step != LOCK_FREE && s->lock[k].param >= PROJ_NP_V5 - 8u) /* P_E0.. of format 5 */
+ d->lock[k].param = (uint8_t)(s->lock[k].param - (PROJ_NP_V5 - 8u) + P_E0);
+ }
+ }
+ q->sum = proj_sum(q);
+ return 1;
+}
+
+/* a format 3 project -> slot q as format 6 */
static void proj_from_v3_ok(project_t *q, const project_v3_t *v3)
{
uint32_t i;
@@ -274,7 +359,7 @@ static int proj_from_v1(project_t *q, const project_v1_t *v1, int n)
for (i = 1; i < NTRK; i++) { /* the other tracks: their defaults, no steps */
uint32_t k;
for (k = 0; k < P_COUNT; k++)
- q->t[i].p[k] = k >= P_E0 ? ENGINES[trk_def_engine(i)]->edit[k - P_E0].def : TP[k].def;
+ pt_set(&q->t[i], k, k >= P_E0 ? ENGINES[trk_def_engine(i)]->edit[k - P_E0].def : TP[k].def);
q->t[i].engine = (uint8_t)trk_def_engine(i);
q->t[i].preset = 0xFF; /* 0xFF: its default preset (project_load) */
memset(q->t[i].step, 0, sizeof q->t[i].step);
@@ -294,11 +379,40 @@ static int proj_import(project_t *q, const void *b, int n)
memcpy(q, b, sizeof *q);
return 1;
}
- return proj_from_v4(q, (const project_v4_t *)b, n) || proj_from_v3(q, (const project_v3_t *)b, n) ||
+ return proj_from_v5(q, (const project_v5_t *)b, n) || proj_from_v4(q, (const project_v4_t *)b, n) ||
+ proj_from_v3(q, (const project_v3_t *)b, n) ||
proj_from_v2(q, (const project_v2_t *)b, n) || proj_from_v1(q, (const project_v1_t *)b, n);
}
/* ---- the working project <-> a project_t */
+/* 2.6: GLO > TEXTURE in a project (a song section has its own): in the slots of two globals a project no longer
+ * applies (G_DRCH: a setting of the FM-1 now; G_INFO: the CPU readout) and the spare bytes. rsv[0]: 0x80 (there) | SRC
+ * | WHEN << 4 | DUCK << 5, rsv[1]: RATE, g[G_DRCH]: LEVEL | (TONE + 64) << 7, g[G_INFO]: MOVE. Without the 0x80 (a
+ * project before it, converted): the defaults, OFF */
+static void proj_tx_put(project_t *p)
+{
+ p->rsv[0] = (uint8_t)(0x80u | ((uint32_t)song.g[G_TXSRC] & 15u) | ((uint32_t)song.g[G_TXWHEN] & 1u) << 4 |
+ ((uint32_t)song.g[G_TXDUCK] & 1u) << 5);
+ p->rsv[1] = (uint8_t)song.g[G_TXRATE];
+ p->g[G_DRCH] = (int16_t)((song.g[G_TXLVL] & 127) | ((song.g[G_TXTONE] + 64) & 127) << 7);
+ p->g[G_INFO] = song.g[G_TXMOVE];
+}
+static void proj_tx_get(const project_t *p)
+{
+ static const uint8_t ID[7] = {G_TXSRC, G_TXLVL, G_TXTONE, G_TXMOVE, G_TXRATE, G_TXWHEN, G_TXDUCK};
+ int32_t v[7];
+ uint32_t i;
+ if (!(p->rsv[0] & 0x80u)) {
+ for (i = 0; i < 7u; i++)
+ v[i] = GP[ID[i]].def;
+ } else {
+ v[0] = p->rsv[0] & 15u, v[5] = (p->rsv[0] >> 4) & 1u, v[6] = (p->rsv[0] >> 5) & 1u, v[4] = p->rsv[1];
+ v[1] = p->g[G_DRCH] & 127, v[2] = ((p->g[G_DRCH] >> 7) & 127) - 64, v[3] = p->g[G_INFO];
+ }
+ for (i = 0; i < 7u; i++)
+ song.g[ID[i]] = (int16_t)clamp(v[i], GP[ID[i]].min, GP[ID[i]].max);
+}
+
static void proj_capture(project_t *p) /* what is playing now, as a project */
{
uint32_t i;
@@ -309,14 +423,17 @@ static void proj_capture(project_t *p) /* what is playing now, as a proje
p->g[i] = song.g[i];
p->sel = song.sel;
p->drdly = (uint8_t)song.g[G_DRDLY];
+ proj_tx_put(p);
for (i = 0; i < NTRK; i++) {
- memcpy(p->t[i].p, trk[i].p, sizeof trk[i].p);
+ uint32_t k;
+ for (k = 0; k < P_COUNT; k++)
+ pt_set(&p->t[i], k, trk[i].p[k]);
p->t[i].engine = trk[i].eng_req;
p->t[i].preset = trk[i].preset;
memcpy(p->t[i].step, trk[i].step, sizeof trk[i].step);
- memcpy(p->t[i].micro, trk[i].micro, sizeof trk[i].micro);
+ for (k = 0; k < NSTEP; k++)
+ pt_set_mf(&p->t[i], k, trk[i].micro[k], (uint32_t)trk[i].fill[k / 4u] >> (2u * (k % 4u)));
memcpy(p->t[i].lock, trk[i].lock, sizeof trk[i].lock);
- memcpy(p->t[i].fill, trk[i].fill, sizeof trk[i].fill);
}
p->sum = proj_sum(p);
}
@@ -328,9 +445,13 @@ static void proj_apply(const project_t *p, int all)
{
uint32_t i, k;
for (i = 0; i < PROJ_NG; i++)
- if (all ? i != G_SLOT && i != G_LOAD && i != G_SAVE && i != G_SYNC && i != G_MIDI && i != G_ROUTE : i == G_DRLVL || i == G_DRREV)
+ if (all ? i != G_SLOT && i != G_LOAD && i != G_SAVE && i != G_SYNC && i != G_MIDI && i != G_ROUTE && i != G_DRCH &&
+ i != G_INFO
+ : i == G_DRLVL || i == G_DRREV) /* (2.6: the drum channel a setting of the FM-1, GLO > MIDI;
+ * its slot and G_INFO's hold the TEXTURE) */
song.g[i] = (int16_t)clamp(p->g[i], GP[i].min, GP[i].max);
song.g[G_DRDLY] = (int16_t)clamp(p->drdly, GP[G_DRDLY].min, GP[G_DRDLY].max); /* (a load and a section, as REV) */
+ proj_tx_get(p); /* GLO > TEXTURE (2.6): a load and a section */
for (k = 0; k < NTRK; k++) {
track_t *t = &trk[k];
const proj_trk_t *s = &p->t[k];
@@ -341,18 +462,16 @@ static void proj_apply(const project_t *p, int all)
for (i = 0; i < P_COUNT; i++) { /* every value back inside its range */
const param_desc_t *d = k == TRK_DRUM && i == P_E0 ? &DRUM_KIT_DESC : /* the drum kit */
i >= P_E0 && i <= P_E7 ? &ENGINES[e]->edit[i - P_E0] : &TP[i];
- t->p[i] = (int16_t)clamp(s->p[i], d->min, d->max);
+ t->p[i] = (int16_t)clamp(pt_get(s, i), d->min, d->max);
}
t->preset = (uint8_t)(ENGINES[e]->npresets ? (s->preset == 0xFFu ? 0u : s->preset) % ENGINES[e]->npresets : 0u);
memcpy(t->step, s->step, sizeof t->step);
- for (i = 0; i < NSTEP; i++) /* the nudges and locks, each inside its range */
- t->micro[i] = (int8_t)clamp(s->micro[i], MICRO_MIN, MICRO_MAX);
- for (i = 0; i < NSTEP / 4u; i++) { /* the conditions: 3 means normal (0) */
- uint32_t b = s->fill[i], j;
- for (j = 0; j < 4u; j++)
- if (((b >> (2u * j)) & 3u) == 3u)
- b &= ~(3u << (2u * j));
- t->fill[i] = (uint8_t)b;
+ memset(t->fill, 0, sizeof t->fill);
+ for (i = 0; i < NSTEP; i++) { /* the nudges and conditions (3 means normal: 0) */
+ uint32_t c = pt_fill(s, i);
+ t->micro[i] = (int8_t)clamp(pt_micro(s, i), MICRO_MIN, MICRO_MAX);
+ if (c != 3u)
+ t->fill[i / 4u] |= (uint8_t)(c << (2u * (i % 4u)));
}
for (i = 0; i < NLOCK; i++) {
const plock_t *l = &s->lock[i];
@@ -392,7 +511,8 @@ static uint8_t sec_dirty, song_dirty; /* live sections / the song: in
#if FELUCCA_FLASH
/* slot from flash into RAM (format 5, or an old one converted) */
static union {
- project_t v5;
+ project_t v6;
+ project_v5_t v5;
project_v4_t v4;
project_v3_t v3;
project_v2_t v2;
@@ -424,12 +544,46 @@ static void project_save(uint32_t slot)
ui_message("SAVED (RAM)");
}
+/* SAVE > PROJECT > ERASE (SLOOP 2.6, after a YouTube comment): the slot (section A..D) empty again. In flash as the
+ * editor's restore leaves an empty slot (project_restore): an object of no bytes, which proj_fetch (older SLOOP too)
+ * reads as no project. The song's steps that played that section are taken out (the default song if none is left),
+ * so song mode still plays. Stopped only: a flash erase stops the audio ~50 ms */
+static void project_erase(uint32_t slot)
+{
+ slot &= 3u;
+#if FELUCCA_ARRANGER
+ if (song.playing || transport_req) { ui_message("STOP BEFORE ERASE"); return; }
+#endif
+ if (!proj_ok(&proj_slot[slot])) {
+ ui_message("EMPTY SLOT");
+ return;
+ }
+#if FELUCCA_FLASH
+ if (flash_ok && st_save(OBJ_PROJECT0 + slot, &proj_slot[slot], 0)) {
+ ui_message("ERASE ERROR");
+ return;
+ }
+#endif
+ fm1_irq_off();
+ memset(&proj_slot[slot], 0, sizeof proj_slot[slot]);
+ sec_dirty &= (uint8_t)~(1u << slot);
+ if (live_sec == (int8_t)slot)
+ live_sec = -1;
+#if FELUCCA_ARRANGER
+ if (arr_drop_scene(&arrangement, slot))
+ song_dirty = 1; /* (saved with the settings, when quiet) */
+#endif
+ fm1_irq_on();
+ ui_message("ERASED");
+}
+
/* a project into the working one: the transport stops, everything sounding is released */
static void project_apply(const project_t *p)
{
uint32_t k;
transport_req = 2;
panic_req = (1u << NTRK) - 1u;
+ drum_mute = 0; /* (the live mutes: a performance's, not the project's) */
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);
@@ -500,6 +654,8 @@ static void autosave_tick(void) /* main loop */
#endif
}
+static uint8_t drch_seed; /* a settings object as 2.5 wrote it: the drum channel was the
+ * project's then (autosave_resume takes it from a 2.5 autosave) */
static void autosave_resume(void) /* power-on: the project as it was left (felucca_init) */
{
#if FELUCCA_FLASH
@@ -511,6 +667,12 @@ static void autosave_resume(void) /* power-on: the project as it wa
if (!proj_import(q, &proj_tmp, n))
return;
autosave_hash = q->sum;
+ if (drch_seed && !(q->rsv[0] & 0x80u) && q->g[G_DRCH] >= 0 && q->g[G_DRCH] <= 16 && q->g[G_DRCH] != midi_set[3]) {
+ midi_set[3] = (uint8_t)q->g[G_DRCH]; /* (2.6) updated from 2.5: GLO > DRUMS > CH as it was there (a
+ * project's then, a setting of the FM-1 now), kept in the settings */
+ settings_later = 1;
+ }
+ drch_seed = 0;
proj_apply(q, 1);
song.sel = (uint8_t)(q->sel < NTRK ? q->sel : 0u);
for (n = 0; n < NPART; n++)
@@ -611,7 +773,7 @@ static void persist_boot(void) /* before settings_init / pane
proj_fetch(i);
} else {
int n = st_load(OBJ_PROJECT0 + i, &proj_tmp, sizeof proj_tmp);
- if (n != (int)sizeof proj_slot[i] || memcmp(&proj_tmp.v5, &proj_slot[i], sizeof proj_slot[i]))
+ if (n != (int)sizeof proj_slot[i] || memcmp(&proj_tmp.v6, &proj_slot[i], sizeof proj_slot[i]))
sec_dirty |= (uint8_t)(1u << i);
}
}
@@ -625,27 +787,94 @@ static int project_used(uint32_t slot) { return proj_ok(&proj_slot[slot & 3u]);
#if FELUCCA_FLASH
/* SLOOP 2.5: the settings object holds the SYN kits after persist_t (drum_synth.c dsu): firmware before 2.5 reads
- * its persist_t and leaves the rest (st_load cuts at its size); its own next save drops them */
+ * its persist_t and leaves the rest (st_load cuts at its size); its own next save drops them. 2.6: then the MIDI LEARN
+ * map (seq.c ml_tab, ML_N entries), only while something is learned; 2.5 reads an object with the map as one without
+ * its SYN kits (their defaults), one without it as its own */
+/* the settings object's third part (2.6): the MIDI LEARN map (seq.c ml_tab, ML_N entries, 2 bytes each, low first),
+ * then GLO > MIDI: CH1 CH2 CH3, the drum channel | OTHER << 7, GLO > MIDI 2's BEND, 3 spare. Written only while it is not
+ * the default (nothing learned, channels 1 2 3 10, OTHER SEL, BEND 2): else the object is exactly 2.5's. 2.6 test
+ * builds wrote 32 (the map) or 36 bytes (and the channels) */
+#define MIDI_PART (2u * ML_N + 8u)
+_Static_assert(sizeof(persist_t) + sizeof(dsu_bank_t) + MIDI_PART <= ST_PAYLOAD_MAX, "the settings object fits its sector");
+static uint8_t midi_saved[MIDI_PART];
+static uint8_t drch_seed; /* a settings object as 2.5 wrote it: the drum channel was the
+ * project's then (autosave_resume takes it from a 2.5 autosave) */ /* the part as flash has it (settings_save: written when it differs) */
+static void midi_part_fill(uint8_t *b)
+{
+ uint32_t k;
+ 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 + 5u] = b[2u * ML_N + 6u] = b[2u * ML_N + 7u] = 0;
+}
+static int midi_part_default(const uint8_t *b)
+{
+ static const uint8_t def[6] = MIDI_SET_DEF;
+ uint32_t k;
+ for (k = 0; k < 2u * ML_N; k++)
+ if (b[k])
+ return 0;
+ return b[2u * ML_N] == def[0] && b[2u * ML_N + 1u] == def[1] && b[2u * ML_N + 2u] == def[2] &&
+ b[2u * ML_N + 3u] == (uint8_t)(def[3] | def[4] << 7) && b[2u * ML_N + 4u] == def[5];
+}
+/* n: 32 (the map), 36 (and the channels) or MIDI_PART; every entry checked (a CC that learns, a parameter this knows, a
+ * channel 0..16, a range 1..12) */
+static void midi_part_read(const uint8_t *b, uint32_t n)
+{
+ uint32_t k, e;
+ fm1_irq_off(); /* (the ISR reads the map and the channels: never half of them) */
+ for (k = 0; k < ML_N; k++) {
+ e = (uint32_t)b[2u * k] | (uint32_t)b[2u * k + 1u] << 8;
+ ml_tab[k] = (uint16_t)((e >> 9) && ml_free_cc(e & 127u) && ml_id(e >> 9) < P_COUNT ? e : 0u);
+ }
+ if (n >= 2u * ML_N + 4u) {
+ for (k = 0; k < 3u; k++)
+ 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);
+ 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);
+ song.g[G_BEND] = midi_set[5];
+ }
+ fm1_irq_on();
+}
static int settings_write(const persist_t *p)
{
+ uint8_t mp[MIDI_PART];
if (!dsu_valid(&dsu))
dsu_defaults();
- if (st_save2(OBJ_SETTINGS, p, sizeof *p, &dsu, sizeof dsu))
+ midi_part_fill(mp);
+ /* the third part only when it is not the default: without, the object is exactly 2.5's (2.5 reads it whole, SYN
+ * kits included; with it, it takes the object for one without them) */
+ if (st_save3(OBJ_SETTINGS, p, sizeof *p, &dsu, sizeof dsu, mp, midi_part_default(mp) ? 0u : sizeof mp))
return -1;
dsu_dirty = 0;
+ memcpy(midi_saved, mp, sizeof midi_saved);
return 0;
}
-static void dsu_boot(void) /* the SYN kits from the settings object, else the defaults */
-{
+static void dsu_boot(void) /* the SYN kits (and the MIDI part) from the settings object, else */
+{ /* the defaults */
st_hdr_t h;
+ uint32_t len = sizeof(persist_t) + sizeof(dsu_bank_t), k;
dsu_defaults();
- if (st_current(OBJ_SETTINGS, &h) >= 0 && h.len == sizeof(persist_t) + sizeof(dsu_bank_t) &&
+ for (k = 0; k < ML_N; k++)
+ ml_tab[k] = 0;
+ if (st_current(OBJ_SETTINGS, &h) >= 0 &&
+ (h.len == len || h.len == len + 2u * ML_N || h.len == len + 2u * ML_N + 4u || h.len == len + MIDI_PART) &&
dsu_valid((const dsu_bank_t *)(st_buf + sizeof(persist_t)))) {
- uint32_t k;
memcpy(&dsu, st_buf + sizeof(persist_t), sizeof dsu);
for (k = 0; k < DSU_N; k++)
dsu_fix_kit(&dsu.k[k]);
+ if (h.len > len)
+ midi_part_read(st_buf + len, h.len - len);
+ drch_seed = h.len == len;
}
+ midi_part_fill(midi_saved);
dsu_dirty = 0;
}
#endif
@@ -671,8 +900,12 @@ static void settings_save(void)
if (!flash_ok)
return;
persist_fill(&p);
- if (!memcmp(&p, &persist_saved, sizeof p))
- return; /* unchanged: no erase cycle */
+ {
+ uint8_t mp[MIDI_PART];
+ midi_part_fill(mp);
+ if (!memcmp(&p, &persist_saved, sizeof p) && !memcmp(mp, midi_saved, sizeof mp))
+ return; /* unchanged: no erase cycle */
+ }
if (settings_write(&p) == 0)
persist_saved = p;
#endif
@@ -845,10 +1078,19 @@ static void sections_flush(void) /* main loop */
lights_mout = (uint8_t)(song.g[G_MIDI] != 0);
settings_later = 1;
}
- if ((uint32_t)(song.g[G_ROUTE] != 0) != lights_min) { /* GLO > SYSTEM > IN: the same */
- lights_min = (uint8_t)(song.g[G_ROUTE] != 0);
+ if ((uint32_t)song.g[G_ROUTE] != lights_min) { /* GLO > SYSTEM > IN: the same (2.6: CH n too) */
+ lights_min = (uint8_t)song.g[G_ROUTE];
settings_later = 1;
}
+ { /* 2.6: GLO > MIDI (CH1 CH2 CH3 OTHER) and GLO > DRUMS > CH: the same */
+ static const uint8_t gid[6] = {G_CH1, G_CH2, G_CH3, G_DRCH, G_CHOTH, G_BEND};
+ uint32_t k;
+ for (k = 0; k < 6u; k++)
+ if ((uint32_t)song.g[gid[k]] != midi_set[k]) {
+ midi_set[k] = (uint8_t)song.g[gid[k]];
+ settings_later = 1;
+ }
+ }
if (settings_later) { /* the menu closed while playing */
settings_later = 0;
song_dirty = 1; /* (settings_save when quiet, with the song) */
diff --git a/firmware/src/punch.c b/firmware/src/punch.c
index afe898d..256f484 100644
--- a/firmware/src/punch.c
+++ b/firmware/src/punch.c
@@ -1,19 +1,28 @@
/* SPDX-License-Identifier: GPL-3.0-only */
-/* PUNCH-IN FX, pocket-operator style: hold FX, press a white key (16 of them, F3..G5) and the
- * whole mix goes through that effect while the key is held; release it and the mix comes
- * back. Beat-synced to the tempo; loops start on the grid of the running transport.
- * A mono ring of the mix (PUNCH_N samples, 0.74 s) feeds the loops, reverse, tape stop,
- * half speed, wobble and echo; the filters, crush and gate run in stereo. Every change
- * crossfades over 64 samples. Runs in the audio ISR (mix_block, fx.c). */
+/* PUNCH-IN FX, pocket-operator style: hold FX, press a key (the 16 white ones, F3..G5, and,
+ * 2.6, the 11 black ones) and the whole mix goes through that effect while the key is held;
+ * release it and the mix comes back. Beat-synced to the tempo; loops start on the grid of the
+ * running transport. A mono ring of the mix (PUNCH_N samples, 0.74 s) feeds the loops, reverse,
+ * tape stop, half speed, wobble, echo, rewind, octave up and the flanger; the filters, kills,
+ * crush and gate run in stereo. FREEZE holds the reverb (fx.c). Every change crossfades over
+ * 64 samples. Runs in the audio ISR (mix_block, fx.c). */
#define PUNCH_N 32768u /* power of two */
/* the transport clock (core.h clk_pos) places the loops and the gate on the grid */
static uint32_t clk_samples(void) { return clk_pos / (uint32_t)song.g[G_BPM]; } /* samples into the beat */
-#define PUNCH_NFX 16u
+#define PUNCH_NFX 27u /* 16 on the white keys, 11 on the black keys (2.6) */
enum { PX_LOOP4, PX_LOOP8, PX_LOOP16, PX_LOOP32, PX_STUT, PX_REV, PX_STOP, PX_HALF,
- PX_LPF, PX_HPF, PX_TEL, PX_CRUSH, PX_DOWN, PX_GATE, PX_ECHO, PX_WOBBLE };
+ PX_LPF, PX_HPF, PX_TEL, PX_CRUSH, PX_DOWN, PX_GATE, PX_ECHO, PX_WOBBLE,
+ /* the black keys, F#3 .. F#5 */
+ PX_KLOW, PX_KMID, PX_KHIGH, PX_RWD, PX_OCT, PX_FLANGE, PX_PAN, PX_FREEZE, PX_LOOP8T, PX_MONO, PX_FADE };
static const char *const PUNCH_NAME[PUNCH_NFX] = {
"LOOP 4", "LOOP 8", "LOOP 16", "LOOP 32", "STUTTER", "REVERSE", "STOP", "HALF",
- "LOW", "HIGH", "PHONE", "CRUSH", "ALIAS", "GATE", "ECHO", "WOBBLE"};
+ "LOW", "HIGH", "PHONE", "CRUSH", "ALIAS", "GATE", "ECHO", "WOBBLE",
+ "KILL LOW", "KILL MID", "KILL HIGH", "REWIND", "OCT UP", "FLANGER", "AUTO-PAN", "FREEZE", "LOOP 8T", "MONO",
+ "FADE OUT"};
+#define PX_OCT_W 2048u /* OCT UP: the window of its two read taps (46 ms) */
+#define PX_FRZ_CAP 8192u /* FREEZE: samples of the mix poured into the held reverb (186 ms) */
+#define PX_RWD_ACC 17 /* REWIND: speed change per sample (Q16): +1 to -3 in 0.35 s */
+#define PX_RWD_MAX (3 << 16)
static int16_t punch_ring[PUNCH_N] __attribute__((section(".pool")));
static struct {
volatile int8_t req; /* effect asked for by the keys (-1 none), ISR keyboard_block */
@@ -33,7 +42,15 @@ static struct {
int32_t held_l, held_r, hn; /* downsample */
int32_t f1l, f2l, f1r, f2r, f3l, f4l, f3r, f4r; /* filter states */
int32_t cut; /* sweep, 0..127 << 8 */
-} punch = {.req = -1, .cur = -1};
+ int32_t z[8][2]; /* kills: the SVF states (left 0..3, right 4..7) */
+ int32_t v; /* REWIND: speed Q16 (signed) */
+ uint32_t fv; /* FADE OUT: level Q23 */
+ int32_t mabs; /* the mix's mean level, |l| + |r| (FREEZE's target), ~0.2 s */
+ int32_t fg; /* FREEZE: the held reverb's gain, Q10 */
+} punch = {.req = -1, .cur = -1, .fg = 8192};
+
+static int px_loop(int32_t fx) { return fx <= PX_STUT || fx == PX_LOOP8T; } /* on the grid */
+static int px_replay(int32_t fx) { return fx <= PX_HALF || fx == PX_LOOP8T; } /* replays a span of the ring */
static uint32_t beat_samples(void) { return (uint32_t)FS * 60u / (uint32_t)song.g[G_BPM]; }
@@ -51,7 +68,7 @@ static void punch_start(int32_t fx)
static const uint8_t DIV[8] = {1, 2, 4, 8, 6, 1, 1, 2}; /* loops: beat / DIV */
punch.cur = (int8_t)fx;
punch.t = 0;
- len = fx <= PX_HALF ? beat / DIV[fx] : beat;
+ len = fx <= PX_HALF ? beat / DIV[fx] : fx == PX_LOOP8T ? beat / 3u : beat;
if (len > PUNCH_N - 1024u)
len = PUNCH_N - 1024u;
if (len < 64u)
@@ -59,7 +76,7 @@ static void punch_start(int32_t fx)
punch.len = len;
punch.pre = 0;
punch.start = punch.w;
- if (fx <= PX_STUT && song.playing) { /* on the grid: */
+ if (px_loop(fx) && song.playing) { /* on the grid: */
uint32_t back = ph % len;
if (len - back <= 1536u) { /* just before a division: from that one */
punch.pre = len - back;
@@ -77,6 +94,13 @@ static void punch_start(int32_t fx)
punch.hn = 0;
punch.cut = 127 << 8;
punch.f1l = punch.f2l = punch.f1r = punch.f2r = punch.f3l = punch.f4l = punch.f3r = punch.f4r = 0;
+ memset(punch.z, 0, sizeof punch.z);
+ punch.v = 65536;
+ punch.fv = 32767u << 8;
+ if (fx == PX_PAN && song.playing) /* AUTO-PAN: a turn a beat, on the grid */
+ punch.lfo = ph * (0xFFFFFFFFu / beat);
+ if (fx == PX_FLANGE) /* FLANGER: the sweep starts at its shortest delay */
+ punch.lfo = 0xC0000000u;
}
/* the wet sample for the mono ring effects (after the ring got this sample); no divide per
@@ -116,20 +140,122 @@ static int32_t punch_ring_fx(int32_t fx)
static int punch_owns(int32_t fx, uint32_t w)
{
uint32_t d = w - punch.start, len = punch.len;
- if (fx < 0 || fx > PX_HALF || fx == PX_STOP || punch.pre)
+ if (fx < 0 || !px_replay(fx) || fx == PX_STOP || punch.pre)
return 0;
if (fx == PX_REV)
return d >= 1u && ((d + len - 1u) & (PUNCH_N - 1u)) < len;
return d >= len && (d & (PUNCH_N - 1u)) < len;
}
+/* the kills: the SVF of dsp.c tsvf_lp with its high-pass out too (Butterworth: tsvf_coef reso 40, damping 5799
+ * Q12), two of them in a row (Linkwitz-Riley, 24 dB/oct) */
+/* a kill on one channel for the block, in -> out (in at the mix's level), z: its four SVFs. One loop per
+ * kill: no choice per sample. The states and coefficients in locals for the block (registers), each SVF step
+ * inline, its high-pass made only where it is used: the same numbers as px_svf, step for step */
+#define PX_SVF(A1, A2, A3, Z0, Z1, IN, LP, HP) do { \
+ int32_t v3_ = (IN) - Z1, v1_ = ((A1) * Z0 + (A2) * v3_) >> 13; \
+ int32_t v2_ = Z1 + (((A2) * Z0 + (A3) * v3_) >> 13); \
+ HP; \
+ Z0 = clamp(2 * v1_ - Z0, -150000, 150000); \
+ Z1 = clamp(2 * v2_ - Z1, -150000, 150000); \
+ LP = v2_; \
+ } while (0)
+#define PX_HPOUT(H, IN) (H = (IN) - ((v1_ * 5799) >> 12) - v2_)
+static void px_kill_run(int32_t fx, const tsvf_t *lo, const tsvf_t *hi, const int32_t *in, int32_t *out, uint32_t n,
+ int32_t (*z)[2])
+{
+ uint32_t i;
+ int32_t x, a, b, h, t;
+ int32_t a1 = lo->a1, a2 = lo->a2, a3 = lo->a3, b1 = hi->a1, b2 = hi->a2, b3 = hi->a3;
+ int32_t z00 = z[0][0], z01 = z[0][1], z10 = z[1][0], z11 = z[1][1];
+ int32_t z20 = z[2][0], z21 = z[2][1], z30 = z[3][0], z31 = z[3][1];
+ if (fx == PX_KLOW) { /* above ~250 Hz */
+ for (i = 0; i < n; i++) {
+ x = clamp(in[i], -280000, 280000) >> 1;
+ PX_SVF(a1, a2, a3, z00, z01, x, t, PX_HPOUT(h, x));
+ PX_SVF(a1, a2, a3, z10, z11, h, t, PX_HPOUT(b, h));
+ out[i] = b << 1;
+ }
+ } else if (fx == PX_KHIGH) { /* below ~2.5 kHz */
+ for (i = 0; i < n; i++) {
+ x = clamp(in[i], -280000, 280000) >> 1;
+ PX_SVF(b1, b2, b3, z00, z01, x, t, (void)0);
+ PX_SVF(b1, b2, b3, z10, z11, t, a, (void)0);
+ out[i] = a << 1;
+ }
+ } else { /* KILL MID: below ~250 Hz + above ~2.5 kHz */
+ for (i = 0; i < n; i++) {
+ x = clamp(in[i], -280000, 280000) >> 1;
+ PX_SVF(a1, a2, a3, z00, z01, x, t, (void)0);
+ PX_SVF(a1, a2, a3, z10, z11, t, a, (void)0);
+ PX_SVF(b1, b2, b3, z20, z21, x, t, PX_HPOUT(h, x));
+ PX_SVF(b1, b2, b3, z30, z31, h, t, PX_HPOUT(b, h));
+ out[i] = (a + b) << 1;
+ }
+ }
+ z[0][0] = z00, z[0][1] = z01, z[1][0] = z10, z[1][1] = z11;
+ z[2][0] = z20, z[2][1] = z21, z[3][0] = z30, z[3][1] = z31;
+}
+#undef PX_HPOUT
+#undef PX_SVF
+static int32_t ring_raw_q16(uint32_t p) /* ring_q16 without the x 8 (the stored scale) */
+{
+ int32_t a = ring_raw(p >> 16), b = ring_raw((p >> 16) + 1u);
+ return a + (((b - a) * (int32_t)((p >> 1) & 0x7FFFu)) >> 15);
+}
+
+/* FREEZE, before the buses (fx.c mix_block): while it plays the reverb holds (no loss); for its first
+ * PX_FRZ_CAP samples the dry mix pours into it, then nothing does (the sends too: a held reverb fed
+ * for ever would only get louder). rev: the reverb send; l, r: the dry mix */
+static void punch_freeze_feed(int32_t *rev, const int32_t *l, const int32_t *r, uint32_t n)
+{
+ uint32_t i;
+ int frz = punch.cur == PX_FREEZE;
+ if (frz && !rev_frz) { /* (2.6) held from now on: the lines at half, their gain
+ * doubled (no step), so the loop's peaks have room (a big
+ * reverb held hard clipped on its int16 lines, losing level) */
+ for (i = 0; i < sizeof rev_line / sizeof rev_line[0]; i++)
+ rev_line[i] = (int16_t)HALF0(rev_line[i]);
+ for (i = 0; i < 4u; i++)
+ fx.line_lp[i] = HALF0(fx.line_lp[i]);
+ punch.fg = 8192; /* x 8: the old x 4 on the full lines */
+ }
+ rev_frz = (uint8_t)frz;
+ if (!rev_frz)
+ return;
+ for (i = 0; i < n; i++)
+ rev[i] = punch.t + i < PX_FRZ_CAP ? clamp(HALF0(rev[i]) + ((l[i] + r[i]) >> 4), -165000, 165000) : 0; /* (fx_buses'
+ * mulq15(rev_in, 13000): no overflow) */
+}
+
/* l, r: the mix before the master (fx.c mix_block), n samples, in place */
static void punch_process(int32_t *l, int32_t *r, uint32_t n)
{
uint32_t i;
int32_t want = punch.req;
- uint32_t beat, step, echo_d;
+ 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;
+ if (punch.cur != PX_FREEZE) { /* (2.6) the mix's level, for FREEZE (every 4th sample) */
+ int32_t a = 0;
+ for (i = 0; i < n; i += 4u)
+ a += (l[i] < 0 ? -l[i] : l[i]) + (r[i] < 0 ? -r[i] : r[i]);
+ a = a / (int32_t)((n + 3u) / 4u);
+ punch.mabs += (a - punch.mabs) >> 7;
+ } else { /* FREEZE: the held level follows the mix's before it (a big
+ * reverb held at x 4 jumped up to +11 dB); while it is fed,
+ * only down (it grows) */
+ int32_t a = 0;
+ for (i = 0; i < n; i += 4u)
+ a += (rev_l[i & (CTL - 1u)] < 0 ? -rev_l[i & (CTL - 1u)] : rev_l[i & (CTL - 1u)]) +
+ (rev_r[i & (CTL - 1u)] < 0 ? -rev_r[i & (CTL - 1u)] : rev_r[i & (CTL - 1u)]);
+ a = (int32_t)(((int64_t)(a / (int32_t)((n + 3u) / 4u)) * punch.fg) >> 10);
+ if (a > punch.mabs + (punch.mabs >> 4))
+ punch.fg -= punch.fg >> 6;
+ else if (a < punch.mabs - (punch.mabs >> 4) && punch.t >= PX_FRZ_CAP)
+ punch.fg += (punch.fg >> 6) + 1;
+ punch.fg = clamp(punch.fg, 1024, 16384);
+ }
if (punch.cur < 0 && want < 0) { /* idle: only the ring */
for (i = 0; i < n; i++)
punch_ring[punch.w++ & (PUNCH_N - 1u)] = (int16_t)clamp((l[i] + r[i]) >> 4, -32768, 32767);
@@ -141,6 +267,8 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n)
step = beat / 4u ? beat / 4u : 1u;
echo_d = beat * 3u / 4u;
if (echo_d > PUNCH_N - 64u) echo_d = PUNCH_N - 64u;
+ binc = 0xFFFFFFFFu / beat; /* a turn a beat */
+ fdec = (32767u << 8) / (2u * beat); /* FADE OUT: to nothing in two beats */
if (punch.cur == PX_GATE)
punch.gp = (song.playing ? clk_samples() : punch.t) % step;
{ /* filter sweeps: per block */
@@ -149,8 +277,20 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n)
punch.cut = punch.cut > (34 << 8) ? punch.cut - 96 : 34 << 8; /* closes over ~1 s */
if (fx == PX_HPF && punch.g > 0)
punch.cut = punch.cut > (88 << 8) ? punch.cut - 64 : 88 << 8;
- tsvf_coef(&c1, fx == PX_LPF ? punch.cut : fx == PX_HPF ? (127 << 8) - punch.cut + (40 << 8) : 96 << 8, 90);
- tsvf_coef(&c2, 58 << 8, 40); /* PHONE: low cut ~ 500 Hz */
+ if (fx >= PX_KLOW && fx <= PX_KHIGH) {
+ static tsvf_t klo, khi; /* the kills: 251 Hz, 2.44 kHz (Butterworth); made once */
+ if (!klo.a1) {
+ tsvf_coef(&klo, 43 << 8, 40);
+ tsvf_coef(&khi, 89 << 8, 40);
+ }
+ if (n <= CTL) {
+ px_kill_run(fx, &klo, &khi, l, kl, n, &punch.z[0]);
+ px_kill_run(fx, &klo, &khi, r, kr, n, &punch.z[4]);
+ }
+ } else {
+ tsvf_coef(&c1, fx == PX_LPF ? punch.cut : fx == PX_HPF ? (127 << 8) - punch.cut + (40 << 8) : 96 << 8, 90);
+ tsvf_coef(&c2, 58 << 8, 40); /* PHONE: low cut ~ 500 Hz */
+ }
}
for (i = 0; i < n; i++) {
int32_t x = l[i], y = r[i], wl = x, wr = y, m = (x + y) >> 1;
@@ -196,6 +336,70 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n)
wr = ((y >> 3) * gg) >> 12;
break;
}
+ case PX_KLOW:
+ case PX_KMID:
+ case PX_KHIGH:
+ wl = kl[i & (CTL - 1u)]; /* (px_kill_run, for the block) */
+ wr = kr[i & (CTL - 1u)];
+ break;
+ case PX_RWD: { /* the record pulled back: slows, stops, spins backwards */
+ uint32_t back = (uint16_t)(punch.w - (punch.rp >> 16)); /* samples behind the writer */
+ int32_t room = (int32_t)PUNCH_N - 512 - (int32_t)back, e; /* before the writer's overwritten past */
+ if (room <= 0) { /* all of it heard: silence until the key is up */
+ wl = wr = 0;
+ break;
+ }
+ e = room < 1024 ? room * 32 : 32767;
+ wl = wr = (((ring_raw_q16(punch.rp) * e) >> 15) << 3);
+ punch.rp += (uint32_t)punch.v;
+ if (punch.v > -PX_RWD_MAX)
+ punch.v -= PX_RWD_ACC;
+ break;
+ }
+ case PX_OCT: { /* two taps read at twice the speed, half a window apart */
+ uint32_t d1 = PX_OCT_W - punch.k, d2 = d1 > PX_OCT_W / 2u ? d1 - PX_OCT_W / 2u : d1 + PX_OCT_W / 2u;
+ int32_t g1 = (int32_t)(d1 <= PX_OCT_W / 2u ? d1 : PX_OCT_W - d1) << 5; /* triangles: g1 + g2 = 1 */
+ int32_t g2 = 32768 - g1;
+ punch.k = punch.k + 1u >= PX_OCT_W ? 0u : punch.k + 1u;
+ wl = wr = (ring_raw(punch.w - d1) * g1 + ring_raw(punch.w - d2) * g2) >> 12;
+ break;
+ }
+ case PX_FLANGE: { /* 0.6..6 ms, swept over a bar, left and right a quarter apart */
+ uint32_t dl = (26u << 16) + (uint32_t)((sine_i(punch.lfo) + 32768) * 240),
+ dr = (26u << 16) + (uint32_t)((sine_i(punch.lfo + 0x40000000u) + 32768) * 240);
+ int32_t el = ring_raw_q16((punch.w << 16) - dl), er = ring_raw_q16((punch.w << 16) - dr);
+ punch.lfo += binc >> 2;
+ punch_ring[punch.w & (PUNCH_N - 1u)] = /* feedback (the ring is the delay line) */
+ (int16_t)clamp((m >> 3) + (((el + er) * 9000) >> 15), -32768, 32767);
+ wl = ((x + (el << 3)) * 5) >> 3;
+ wr = ((y + (er << 3)) * 5) >> 3;
+ break;
+ }
+ case PX_PAN: { /* the mix in mono, left to right and back once a beat */
+ uint32_t a = (uint32_t)(((sine_i(punch.lfo) * 28000) >> 15) + 32768) << 14; /* 0..a quarter turn */
+ int32_t gl = (sine_i(a + 0x40000000u) * 46341) >> 15, gr = (sine_i(a) * 46341) >> 15; /* x sqrt 2 */
+ punch.lfo += binc;
+ wl = ((m >> 4) * gl) >> 11; /* (>> 4: no overflow on a hot mix, gl up to 46341) */
+ wr = ((m >> 4) * gr) >> 11;
+ break;
+ }
+ case PX_FREEZE: { /* the held reverb (rev_l / rev_r), the dry mix fading under it */
+ int32_t c = punch.t < PX_FRZ_CAP ? (int32_t)(punch.t << 2) : 32767; /* PX_FRZ_CAP << 2 = 32768 */
+ int32_t fl = (rev_l[i & (CTL - 1u)] * punch.fg) >> 10, fr = (rev_r[i & (CTL - 1u)] * punch.fg) >> 10;
+ wl = x + ((((fl - x) >> 3) * (c >> 3)) >> 9);
+ wr = y + ((((fr - y) >> 3) * (c >> 3)) >> 9);
+ break;
+ }
+ case PX_MONO:
+ wl = wr = m;
+ break;
+ case PX_FADE: {
+ int32_t v = (int32_t)(punch.fv >> 8), gq = (v * v) >> 15; /* squared: the ear hears it even */
+ punch.fv = punch.fv > fdec ? punch.fv - fdec : 0u;
+ wl = ((x >> 3) * gq) >> 12;
+ wr = ((y >> 3) * gq) >> 12;
+ break;
+ }
case PX_ECHO: {
uint32_t d = echo_d;
int32_t e;
@@ -226,19 +430,37 @@ static void punch_process(int32_t *l, int32_t *r, uint32_t n)
r[i] = y + ((((wr - y) >> 3) * (punch.g >> 3)) >> 9);
punch.w++;
punch.t++;
- if (punch.g == 0 && want != fx) { /* faded out: the next one, or none */
- if (want >= 0)
- punch_start(want);
- else
- punch.cur = -1;
- }
+ if (punch.g == 0 && want != fx) /* faded out: none until the next block, which starts the
+ * next one with its own set-up (kills, filters, gate:
+ * made per block); at most 31 samples dry */
+ punch.cur = -1;
}
}
-/* the keyboard (seq.c keyboard_block) while FX is held: white key index 0..15, -1 = black */
+/* a key (0..26, from F3) -> its white key index 0..15, -1 = a black key (the layers' steps use it too) */
static int32_t punch_key(uint32_t k)
{
static const int8_t W[12] = {0, -1, 1, -1, 2, -1, 3, 4, -1, 5, -1, 6}; /* from F */
int32_t i = W[k % 12u];
return i < 0 ? -1 : (int32_t)(k / 12u) * 7 + i;
}
+/* the black keys, F#3 .. F#5, and their effects 16..26 */
+static const uint8_t PUNCH_BLACK[PUNCH_NFX - 16u] = {1, 3, 5, 8, 10, 13, 15, 17, 20, 22, 25};
+/* the keyboard (seq.c keyboard_block) while FX is held: a key -> its effect (-1 none) */
+static int32_t punch_fx_of_key(uint32_t k)
+{
+ int32_t w = punch_key(k);
+ uint32_t i;
+ if (w >= 0)
+ return w;
+ for (i = 0; i < PUNCH_NFX - 16u; i++)
+ if (PUNCH_BLACK[i] == k)
+ return (int32_t)(16u + i);
+ return -1;
+}
+static uint32_t punch_key_of_fx(uint32_t fx) /* an effect -> its key (the lit key) */
+{
+ static const uint8_t K[7] = {0, 2, 4, 6, 7, 9, 11}; /* the white keys of an octave, from F */
+ fx %= PUNCH_NFX;
+ return fx < 16u ? fx / 7u * 12u + K[fx % 7u] : PUNCH_BLACK[fx - 16u];
+}
diff --git a/firmware/src/seq.c b/firmware/src/seq.c
index bf021a4..26b2415 100644
--- a/firmware/src/seq.c
+++ b/firmware/src/seq.c
@@ -45,33 +45,63 @@ static uint32_t kb_prev;
/* per key: what its press started, so its release ends the same (whatever the layer or track is now) */
enum { KS_NONE, KS_NOTE, KS_DRUM, KS_ROLL, KS_ERASE, KS_FX, KS_UI, KS_MOD }; /* KS_MOD: a chord modifier (2.4) */
static uint8_t kb_kind[27], kb_trk[27], kb_n[27], kb_nt[27][4], kb_root[27]; /* kb_root: a chord key's note (CHORD+) */
+static int8_t kb_oct[27]; /* the octave buttons when the key went down (arp_add: held_key, #191) */
static uint8_t last_note = 60;
static uint8_t pen_n = 1, pen_note[4] = {60}; /* the last chord / note played: the SEQ layer writes it */
static uint8_t pen_lane; /* the last drum lane played: the SEQ layer's lane */
+/* SLOOP 2.6: the MIDI keyboard's notes. mi_pen: the notes held on the selected track (its pen, as the keys: the notes
+ * down together are a chord). step_in_q: every synth note-on / note-off from MIDI, note | on << 7 | track << 8, for the
+ * STEP page's entry (ui_input.c midi_entry): the audio side writes, the UI reads; a full queue drops and says so */
+static uint32_t mi_pen[4];
+#define STEP_IN_Q 32u
+static volatile uint16_t step_in_q[STEP_IN_Q];
+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 void step_in_push(uint32_t ev)
+{
+ if (step_in_w - step_in_r >= STEP_IN_Q) {
+ step_in_lost = 1;
+ return;
+ }
+ step_in_q[step_in_w % STEP_IN_Q] = (uint16_t)ev;
+ step_in_w++;
+}
static volatile uint8_t transport_req; /* 1 start, 2 stop (from the UI); 3 start from a MIDI START */
static volatile uint8_t panic_req; /* bit per track: release every sounding note (preset / engine change) */
static uint32_t trk_index(const track_t *t) { return (uint32_t)(t - trk); }
-static uint32_t trk_midi_ch(uint32_t i) /* MIDI channel 0..15 of track i (keys -> MIDI out) */
+static uint32_t trk_midi_ch(uint32_t i) /* MIDI channel 0..15 of track i (keys -> MIDI out); 2.6: GLO > MIDI */
+{ /* (2.6: OFF is OFF, in and out: 0xFF, nothing sent) */
+ int32_t c = i < NPART ? song.g[G_CH1 + i] : song.g[G_DRCH];
+ return c >= 1 && c <= 16 ? (uint32_t)c - 1u : 0xFFu;
+}
+/* a note on (vel > 0) / off to MIDI OUT on channel ch (trk_midi_ch: 0xFF, the track's MIDI OFF: nothing) */
+static void midi_out_note(uint32_t ch, uint32_t note, uint32_t vel)
{
- if (i < NPART)
- return i;
- return song.g[G_DRCH] ? (uint32_t)song.g[G_DRCH] - 1u : 9u;
+ if (ch > 15u)
+ return;
+ midi_out_event(vel ? 0x09u | (0x90u | ch) << 8 | (note & 127u) << 16 | (vel & 127u) << 24
+ : 0x08u | (0x80u | ch) << 8 | (note & 127u) << 16);
}
/* MIDI OUT of what the sequencer, the arp and the rolls play (GLO > SYSTEM > MIDI = SEQ; the keys always
* go out: key_down / key_up). Notes from a computer or the jack are never echoed (no MIDI loop). A set per
* track of the notes sent on, so a note is ended once, and STOP or MIDI = KEYS end them all */
static uint32_t mo_set[NTRK][4];
+static uint8_t mo_ch[NTRK]; /* (2.6) the channel the notes of mo_set went out on: their note-offs too,
+ * whatever GLO > MIDI says now (no note left hanging on the other gear) */
static void seq_out_off(const track_t *t, uint32_t note)
{
uint32_t i = trk_index(t) % NTRK;
if (note > 127u || !(mo_set[i][note >> 5] & (1u << (note & 31u))))
return;
mo_set[i][note >> 5] &= ~(1u << (note & 31u));
- midi_out_event(0x08u | (0x80u | trk_midi_ch(i)) << 8 | note << 16);
+ midi_out_note(mo_ch[i], note, 0);
}
+static void seq_out_track_off(const track_t *t);
static uint8_t mo_any; /* something was sent on since the last check (events_block) */
static void seq_out_on(const track_t *t, uint32_t note, uint32_t vel)
{
@@ -79,9 +109,15 @@ static void seq_out_on(const track_t *t, uint32_t note, uint32_t vel)
if (!song.g[G_MIDI] || note > 127u)
return;
seq_out_off(t, note); /* played again while on: off first */
+ if (trk_midi_ch(i) != mo_ch[i]) { /* (its channel changed: what is on ends where it started) */
+ seq_out_track_off(t);
+ mo_ch[i] = (uint8_t)trk_midi_ch(i);
+ }
+ if (mo_ch[i] > 15u)
+ return; /* (MIDI OFF: nothing goes out, nothing to end) */
mo_set[i][note >> 5] |= 1u << (note & 31u);
mo_any = 1;
- midi_out_event(0x09u | (0x90u | trk_midi_ch(i)) << 8 | note << 16 | (vel ? vel & 127u : 1u) << 24);
+ midi_out_note(mo_ch[i], note, (vel ? vel & 127u : 1u));
}
static void seq_out_track_off(const track_t *t) /* every note of the track still on */
{
@@ -90,7 +126,7 @@ static void seq_out_track_off(const track_t *t) /* every note of the track
for (b = 0; mo_set[i][w]; b++)
if (mo_set[i][w] & (1u << b)) {
mo_set[i][w] &= ~(1u << b);
- midi_out_event(0x08u | (0x80u | trk_midi_ch(i)) << 8 | (w * 32u + b) << 16);
+ midi_out_note(mo_ch[i], (w * 32u + b), 0);
}
}
static void seq_out_all_off(void)
@@ -141,12 +177,64 @@ static void lk_push(uint32_t layer, uint32_t k, uint32_t down)
}
/* ------------------------------------------------------------- keys --- */
-/* key k -> note on a synth part (KB_SILENT: none). WHITE (and chord mode): the white keys walk the
- * scale from C4 = the root, the black keys are silent; SNAP: every key, rounded down into the scale */
-static uint32_t kb_map(const track_t *t, uint32_t k)
+/* the keys of track t play through its scale (kb_pitch): not the drum track, not the GM kit, not SLICE (their own maps) */
+static int kb_scaled(const track_t *t)
+{
+ if (is_drum(t))
+ return 0;
+ if (ENGINES[t->eng_req % NENGINES] == &ENG_SAMPLE && drum_set() >= 0 && /* (the engine it switches to) */
+ (uint32_t)t->p[P_E0] % SMP_NSETS == (uint32_t)drum_set())
+ return 0;
+#if FELUCCA_SLICE
+ if (ENGINES[t->eng_req % NENGINES] == &ENG_SLICE)
+ return 0;
+#endif
+ return 1;
+}
+/* key k's note on a scaled track with the octave buttons at oct (KB_SILENT: none): QNT, ROOT, SCALE, TRN as they are
+ * now. WHITE (and chord mode): the white keys walk the scale from C4 = the root, the black keys are silent; SNAP: every
+ * key, rounded down into the scale. The keys (kb_map), and the notes the arp holds (arp_next, 2.6 after Felucca 1.5
+ * #191: a latched chord follows TRN, ROOT, SCALE and QNT, in the octave its keys were pressed in) */
+static uint32_t kb_pitch(const track_t *t, uint32_t k, int32_t oct)
{
static const int8_t DEGREE[12] = {0, -1, 1, -1, 2, 3, -1, 4, -1, 5, -1, 6};
int32_t n = 53 + (int32_t)k;
+ if (t->p[P_QUANT] == 1 && !t->p[P_CHORD]) { /* SNAP: every key, rounded down to the scale (the old ON) */
+ uint32_t mask = scale_mask(t), guard = 12;
+ n += 12 * oct + t->p[P_TRANS];
+ while (guard-- && !((mask >> (uint32_t)((n - t->p[P_ROOT] + 120) % 12)) & 1u))
+ n--;
+ return (uint32_t)clamp(n, 0, 127);
+ }
+ if (t->p[P_QUANT] == 2 || t->p[P_CHORD]) { /* WHITE: white keys walk the scale, black keys are silent */
+ uint32_t mask = t->p[P_CHORD] && !t->p[P_SCALE] ? SCALE_MASK[2] : scale_mask(t), i;
+ int32_t count = 0, degree = DEGREE[n % 12], wo;
+ if (degree < 0)
+ return KB_SILENT;
+ /* C4 is the root. Walk scale degrees on successive white keys, including
+ * below C4; scales with 5, 6, 8 or 12 notes still have no duplicated degrees. */
+ degree += (n / 12 - 5) * 7;
+ for (i = 0; i < 12u; i++)
+ count += (mask >> i) & 1u;
+ wo = degree / count;
+ degree %= count;
+ if (degree < 0) {
+ degree += count;
+ wo--;
+ }
+ for (i = 0; i < 12u; i++)
+ if ((mask >> i) & 1u) {
+ if (!degree)
+ break;
+ degree--;
+ }
+ n = 60 + t->p[P_ROOT] + 12 * wo + (int32_t)i;
+ }
+ return (uint32_t)clamp(n + 12 * oct + t->p[P_TRANS], 0, 127);
+}
+/* key k -> note on track t (KB_SILENT: none) */
+static uint32_t kb_map(const track_t *t, uint32_t k)
+{
if (is_drum(t))
return LANE_NOTE[lane_of_key(k)];
if (ENGINES[t->eng_req % NENGINES] == &ENG_SAMPLE && drum_set() >= 0 && /* (the engine it switches to) */
@@ -156,38 +244,7 @@ static uint32_t kb_map(const track_t *t, uint32_t k)
if (ENGINES[t->eng_req % NENGINES] == &ENG_SLICE) /* SLICE: lowest key = slice 0 (C4 + ROOT), no scale */
return (uint32_t)clamp(SLC_BASE + t->p[P_ROOT] + 12 * song.octave + (int32_t)k, 0, 127);
#endif
- if (t->p[P_QUANT] == 1 && !t->p[P_CHORD]) { /* SNAP: every key, rounded down to the scale (the old ON) */
- uint32_t mask = scale_mask(t), guard = 12;
- n += 12 * song.octave + t->p[P_TRANS];
- while (guard-- && !((mask >> (uint32_t)((n - t->p[P_ROOT] + 120) % 12)) & 1u))
- n--;
- return (uint32_t)clamp(n, 0, 127);
- }
- if (t->p[P_QUANT] == 2 || t->p[P_CHORD]) { /* WHITE: white keys walk the scale, black keys are silent */
- uint32_t mask = t->p[P_CHORD] && !t->p[P_SCALE] ? SCALE_MASK[2] : scale_mask(t), i;
- int32_t count = 0, degree = DEGREE[n % 12], oct;
- if (degree < 0)
- return KB_SILENT;
- /* C4 is the root. Walk scale degrees on successive white keys, including
- * below C4; scales with 5, 6, 8 or 12 notes still have no duplicated degrees. */
- degree += (n / 12 - 5) * 7;
- for (i = 0; i < 12u; i++)
- count += (mask >> i) & 1u;
- oct = degree / count;
- degree %= count;
- if (degree < 0) {
- degree += count;
- oct--;
- }
- for (i = 0; i < 12u; i++)
- if ((mask >> i) & 1u) {
- if (!degree)
- break;
- degree--;
- }
- n = 60 + t->p[P_ROOT] + 12 * oct + (int32_t)i;
- }
- return (uint32_t)clamp(n + 12 * song.octave + t->p[P_TRANS], 0, 127);
+ return kb_pitch(t, k, song.octave);
}
/* chord mode (P_CHORD): the chord of the scale built on note n (in the scale; CHR: minor), into c[];
@@ -612,7 +669,8 @@ static int project_empty(void)
static int p_lockable(uint32_t id)
{
return id <= P_LD_AMP || id == P_SGATE || (id >= P_DIST && id <= P_REV) || id == P_GLIDE || id == P_PAN ||
- id == P_DETUNE || (id >= P_SLCR && id <= P_SLDEPTH) || (id >= P_E0 && id <= P_E7) || id == P_TFLT;
+ id == P_DETUNE || (id >= P_SLCR && id <= P_SLDEPTH) || (id >= P_E0 && id <= P_E7) || id == P_TFLT ||
+ (id >= P_IA && id <= P_IMIX); /* 2.6: the INSERT's values and MIX */
}
/* the range of p[id] on track t (the engine that renders: t->engine; the drum track's P_E0: the kit) */
static const param_desc_t *lock_desc(const track_t *t, uint32_t id)
@@ -903,6 +961,12 @@ static void ft_block(void)
* every step the sequencer enters while the key is held (MPC style); stopped: from every step. */
static uint8_t er_trk;
static uint16_t er_lanes; /* drums: lanes held */
+/* the drum track's live mutes (SLOOP 2.6, after Felucca 1.4.1): EDIT + a black key turns the white keys from erasing
+ * into muting (er_mute; back to erasing with a black key again, and when EDIT is let go and not locked), and a white
+ * key then mutes / unmutes its sound: the sequencer skips it (its ratchets too), the keys still play it. Performance
+ * state: never saved, not undone; a project load or NEW clears it */
+static volatile uint16_t drum_mute;
+static volatile uint8_t er_mute;
static uint32_t er_notes[4]; /* synth: notes held (bit per MIDI note) */
static volatile uint8_t er_flash; /* something was erased (the UI flashes) */
@@ -955,6 +1019,14 @@ static void erase_now(track_t *t) /* a key just went down */
static int erasing(const track_t *t) { return trk_index(t) == er_trk && (er_lanes || er_notes[0] || er_notes[1] || er_notes[2] || er_notes[3]); }
/* ------------------------------------------------------------- arp --- */
+/* 2.6 (after Felucca 1.5, #191): where each track's held[i] came from, so the arp maps it again as it plays (arp_next:
+ * TRN, ROOT, SCALE, QNT as they are now). held_key: the key + 1 (bits 0..4) and the octave buttons then + 3 (bits
+ * 5..7); 0: not a key of the track's scale (MIDI IN, the drum track, the GM kit, SLICE), held[i] plays as it is.
+ * held_dt: held[i] above the key's own note (a chord's other notes). in_key: the key (+ 1) whose notes go into
+ * input_on now (key_down, chord_revoice), 0: none */
+static uint8_t held_key[NTRK][16];
+static int8_t held_dt[NTRK][16];
+static uint8_t in_key;
static void arp_add(track_t *t, uint32_t note)
{
uint32_t i;
@@ -964,8 +1036,13 @@ static void arp_add(track_t *t, uint32_t note)
for (i = 0; i < t->nheld; i++)
if (t->held[i] == note)
return; /* repeated note-on: not a new note */
- if (t->nheld < 16u)
+ if (t->nheld < 16u) {
+ uint32_t k = in_key - 1u, ti = trk_index(t);
+ held_key[ti][t->nheld] = in_key && kb_scaled(t) ? (uint8_t)(in_key | (uint32_t)(kb_oct[k % 27u] + 3) << 5) : 0u; /* (the
+ * key's octave: a CHORD+ note added after OCT moved, too) */
+ held_dt[ti][t->nheld] = (int8_t)(held_key[ti][t->nheld] ? (int32_t)note - kb_root[k % 27u] : 0);
t->held[t->nheld++] = (uint8_t)note;
+ }
if (t->nheld == 1u) {
t->arp_new = 1; /* the first note: now (or on the grid just ahead) */
t->arp_idx = 0xFFFFFFFFu;
@@ -980,18 +1057,33 @@ static void arp_remove(track_t *t, uint32_t note)
if (t->p[P_AHOLD])
return;
for (i = 0; i < t->nheld; i++)
- if (t->held[i] != note)
+ if (t->held[i] != note) {
+ held_key[trk_index(t)][k] = held_key[trk_index(t)][i];
+ held_dt[trk_index(t)][k] = held_dt[trk_index(t)][i];
t->held[k++] = t->held[i];
+ }
t->nheld = (uint8_t)k;
}
/* the next note of the arp: the held notes (sorted or as played) over OCT octaves, by MODE */
static uint32_t arp_next(track_t *t)
{
- uint32_t cnt, list[64], len = 0, i, j, o;
- for (i = 0; i < t->nheld; i++)
- list[i] = t->held[i];
- cnt = t->nheld;
+ uint32_t cnt = 0, list[64], len = 0, i, j, o, ti = trk_index(t);
+ for (i = 0; i < t->nheld; i++) { /* the notes as they play now (#191), each once */
+ uint32_t x = t->held[i], s = held_key[ti][i];
+ if (s) { /* a key: through the scale as it is now */
+ x = kb_pitch(t, (s & 31u) - 1u, (int32_t)(s >> 5) - 3);
+ if (x == KB_SILENT)
+ continue; /* (silent now: a black key under WHITE) */
+ x = (uint32_t)clamp((int32_t)x + held_dt[ti][i], 0, 127);
+ }
+ for (j = 0; j < cnt && list[j] != x; j++)
+ ;
+ if (j == cnt)
+ list[cnt++] = x;
+ }
+ if (!cnt)
+ return KB_SILENT; /* (every key silent now: a black key under WHITE since) */
if (!t->p[P_AORDER])
for (i = 1; i < cnt; i++)
for (j = i; j > 0 && list[j - 1] > list[j]; j--) {
@@ -1080,6 +1172,8 @@ static void arp_tick(track_t *t, uint32_t adv)
t->arp_note = 0;
if ((uint32_t)(rng() & 127u) <= (uint32_t)t->p[P_APROB]) {
uint32_t n = arp_next(t);
+ if (n == KB_SILENT)
+ return;
t->arp_note = (uint8_t)n;
t->arp_off = slen * (uint32_t)t->p[P_AGATE] / 128u;
trk_note_on(t, n, 100);
@@ -1113,6 +1207,12 @@ static void arm_start(track_t *t)
static void drum_input(uint32_t lane, uint32_t lvl, uint32_t rat, int rec);
static const uint8_t *in_chord; /* input_on's note is note in_chord_i of in_chord (CHORD+) */
static uint32_t in_chord_n, in_chord_i;
+/* SLOOP 2.6: the sustain pedal (MIDI CC 64, on the track its channel plays): while it is down, a synth track's notes let
+ * go keep sounding (their note-off waits: the arp keeps them, a recording holds them) until it is up; a note played
+ * again meanwhile is held by its key again. Per track: the pedal, the notes waiting */
+static uint8_t sus_on[NTRK];
+static uint32_t sus_wait[NTRK][4];
+static void input_off_now(track_t *t, uint32_t note);
static void input_on(track_t *t, uint32_t note, uint32_t vel)
{
if (is_drum(t)) { /* (a GM note on the drum track: its lane) */
@@ -1120,6 +1220,14 @@ static void input_on(track_t *t, uint32_t note, uint32_t vel)
return;
}
last_note = (uint8_t)note;
+ { /* (2.6) played again under the pedal: the note-off it waited with first (the arp's key count, a recording's
+ * note end), then this one held by its key */
+ uint32_t *w = &sus_wait[trk_index(t) % NTRK][(note >> 5) & 3u], bit = 1u << (note & 31u);
+ if (*w & bit) {
+ *w &= ~bit;
+ input_off_now(t, note);
+ }
+ }
arm_start(t);
if (ft_on && t == &trk[ft_trk % NTRK])
ft_note_on(note, vel);
@@ -1142,6 +1250,14 @@ static void input_off(track_t *t, uint32_t note)
ft_note_off(lane_of_note(note));
return;
}
+ if (sus_on[trk_index(t) % NTRK]) { /* the pedal down: it waits for the pedal (2.6) */
+ sus_wait[trk_index(t) % NTRK][(note >> 5) & 3u] |= 1u << (note & 31u);
+ return;
+ }
+ input_off_now(t, note);
+}
+static void input_off_now(track_t *t, uint32_t note)
+{
if (ft_on && t == &trk[ft_trk % NTRK])
ft_note_off(note);
rec_release(t, note);
@@ -1325,15 +1441,17 @@ static void chord_revoice(uint32_t sel)
;
if (j == nn) {
input_off(t, kb_nt[k][i]);
- midi_out_event(0x08u | (0x80u | mc) << 8 | (uint32_t)kb_nt[k][i] << 16);
+ midi_out_note(mc, (uint32_t)kb_nt[k][i], 0);
}
}
for (j = 0; j < nn; j++) { /* the notes it gains */
for (i = 0; i < kb_n[k] && kb_nt[k][i] != nw[j]; i++)
;
if (i == kb_n[k]) {
+ in_key = (uint8_t)(k + 1u); /* (a chord's new note: of this key, #191) */
input_on(t, nw[j], 100);
- midi_out_event(0x09u | (0x90u | mc) << 8 | (uint32_t)nw[j] << 16 | 100u << 24);
+ in_key = 0;
+ midi_out_note(mc, (uint32_t)nw[j], 100u);
}
}
memcpy(kb_nt[k], nw, nn);
@@ -1349,8 +1467,8 @@ static void key_down(uint32_t k)
kb_trk[k] = (uint8_t)sel;
kb_n[k] = 0;
switch (layer) {
- case LY_FX: { /* FX held: the white keys pick a punch-in effect */
- int32_t fx = punch_key(k);
+ case LY_FX: { /* FX held: the keys pick a punch-in effect (white and black) */
+ int32_t fx = punch_fx_of_key(k);
kb_kind[k] = KS_FX;
if (fx >= 0 && fx < (int32_t)PUNCH_NFX) {
punch.req = (int8_t)fx;
@@ -1367,6 +1485,14 @@ static void key_down(uint32_t k)
lk_push(layer, k, 1);
return;
case LY_ERASE:
+ if (is_drum(t) && punch_key(k) < 0) { /* (2.6) a black key: erase <-> mute */
+ er_mute = (uint8_t)!er_mute;
+ return;
+ }
+ if (is_drum(t) && er_mute) { /* MUTE: the white key's sound off / on in the sequencer */
+ drum_mute ^= (uint16_t)(1u << lane_of_key(k));
+ return;
+ }
kb_kind[k] = KS_ERASE;
if (!erasing(t) || er_trk != sel)
undo_erase_sess = (undo_sess += 4u) | 2u; /* a new erase: one undo */
@@ -1412,7 +1538,7 @@ static void key_down(uint32_t k)
kb_kind[k] = KS_DRUM;
drum_input(lane, lvl, 0, 1);
mc = trk_midi_ch(sel);
- midi_out_event(0x09u | (0x90u | mc) << 8 | (uint32_t)LANE_NOTE[lane] << 16 | lvl_vel(lvl, 100) << 24);
+ midi_out_note(mc, (uint32_t)LANE_NOTE[lane], lvl_vel(lvl, 100));
return;
}
{
@@ -1433,6 +1559,7 @@ static void key_down(uint32_t k)
}
kb_kind[k] = KS_NOTE;
kb_root[k] = (uint8_t)n;
+ kb_oct[k] = (int8_t)song.octave;
if (t->p[P_CHORD]) {
kb_n[k] = (uint8_t)chord_play_notes(t, n, chord_mods(), kb_nt[k]); /* (the modifiers held, voiced) */
} else {
@@ -1440,14 +1567,16 @@ static void key_down(uint32_t k)
kb_n[k] = 1;
}
mc = trk_midi_ch(sel);
+ in_key = (uint8_t)(k + 1u); /* (the arp keeps the key: arp_add, #191) */
for (i = 0; i < kb_n[k]; i++) {
in_chord = kb_n[k] > 1u ? kb_nt[k] : 0;
in_chord_n = kb_n[k];
in_chord_i = i;
input_on(t, kb_nt[k][i], 100);
in_chord = 0;
- midi_out_event(0x09u | (0x90u | mc) << 8 | (uint32_t)kb_nt[k][i] << 16 | 100u << 24);
+ midi_out_note(mc, (uint32_t)kb_nt[k][i], 100u);
}
+ in_key = 0;
/* the pen of the SEQ layer: the keys down now (a chord), else this note */
if (!(kb_prev & ~(1u << k)) || pen_n >= 4u)
pen_n = 0;
@@ -1490,14 +1619,14 @@ static void key_up(uint32_t k)
mc = trk_midi_ch(kb_trk[k] % NTRK);
for (i = 0; i < kb_n[k]; i++) {
input_off(t, kb_nt[k][i]);
- midi_out_event(0x08u | (0x80u | mc) << 8 | (uint32_t)kb_nt[k][i] << 16);
+ midi_out_note(mc, (uint32_t)kb_nt[k][i], 0);
}
return;
case KS_DRUM:
if (ft_on && ft_trk == TRK_DRUM)
ft_note_off(kb_nt[k][0]);
mc = trk_midi_ch(TRK_DRUM);
- midi_out_event(0x08u | (0x80u | mc) << 8 | (uint32_t)LANE_NOTE[kb_nt[k][0] & 15u] << 16);
+ midi_out_note(mc, (uint32_t)LANE_NOTE[kb_nt[k][0] & 15u], 0);
return;
default:
return;
@@ -1538,6 +1667,8 @@ static void keyboard_block(void)
{
uint32_t cur = fm1_in.notes, ch = cur ^ kb_prev, k, r;
audition_block();
+ if (er_mute && layer_now() != LY_ERASE)
+ er_mute = 0; /* EDIT let go: its keys erase again (2.6) */
if (!(layer_buttons() & ly_bit[LY_ROLL])) /* ARP up (and not locked): the rolls end (the keys stay silent) */
for (r = 0; r < NROLL; r++)
if (roll[r].on)
@@ -1835,7 +1966,7 @@ static void seq_step(track_t *t, const step_t *s, uint32_t slen, uint32_t skip)
/* play one drum step: each lane a hit (skip: lanes already played by live recording, or rolling) */
static void drum_step(track_t *t, const dstep_t *s, uint32_t skip)
{
- uint32_t l, m = dstep_mask(s) & ~skip & ~roll_lanes(t);
+ uint32_t l, m = dstep_mask(s) & ~skip & ~roll_lanes(t) & ~(uint32_t)drum_mute;
seq_out_track_off(t); /* the last step's hits end here */
for (l = 0; m; l++, m >>= 1)
if (m & 1u) {
@@ -1852,7 +1983,7 @@ static void seq_ratchets(track_t *t, uint32_t into, uint32_t slen)
return; /* (its condition failed: no hit at all) */
if (is_drum(t)) {
const dstep_t *s = &t->dstep[t->seq_idx % NSTEP];
- uint32_t m = dstep_mask(s) & ~roll_lanes(t);
+ uint32_t m = dstep_mask(s) & ~roll_lanes(t) & ~(uint32_t)drum_mute;
for (i = 0; m; i++, m >>= 1) {
uint32_t hits = 1u + dstep_rat(s, i), h, done;
if (!(m & 1u) || hits == 1u)
@@ -1991,12 +2122,23 @@ static void seq_tick(track_t *t, uint32_t adv)
seq_ratchets(t, rel < 0 ? 0u : (uint32_t)rel, slen);
}
-/* MIDI in: the track a channel plays (0..15) */
-static track_t *midi_track(uint32_t ch)
+/* MIDI in: the track that has channel ch (0..15) as its own: the drum track's GLO > DRUMS > CH, synth track i's
+ * GLO > MIDI > CHi (2.6; 1, 2, 3 as before; a channel two tracks have: the first of them), else 0 */
+static track_t *midi_own(uint32_t ch)
{
+ uint32_t i;
if (song.g[G_DRCH] && ch + 1u == (uint32_t)song.g[G_DRCH])
return TDRUM;
- return ch < NPART ? &trk[ch] : TSEL;
+ for (i = 0; i < NPART; i++)
+ if (ch + 1u == (uint32_t)song.g[G_CH1 + i])
+ return &trk[i];
+ return 0;
+}
+/* the track a channel plays: its own, or (GLO > MIDI > OTHER = SEL) the selected one; 0: none (OTHER = OFF) */
+static track_t *midi_track(uint32_t ch)
+{
+ track_t *t = midi_own(ch);
+ return t ? t : song.g[G_CHOTH] ? 0 : TSEL;
}
/* a channel that plays the selected track: its note-off goes to the track its note-on went to,
@@ -2004,9 +2146,13 @@ static track_t *midi_track(uint32_t ch)
static uint8_t midi_sel_on[16][128]; /* per channel and note: track + 1, 0 = none */
static track_t *midi_route(uint32_t ch, uint32_t note, int on)
{
- track_t *t = midi_track(ch);
- if (ch < NPART || (song.g[G_DRCH] && ch + 1u == (uint32_t)song.g[G_DRCH]))
- return t; /* a part's own channel, or the drum channel */
+ track_t *t = midi_own(ch);
+ if (t)
+ return t; /* a track's own channel (GLO > MIDI, GLO > DRUMS > CH) */
+ if (song.g[G_CHOTH] && (on || !midi_sel_on[ch & 15u][note & 127u]))
+ return 0; /* OTHER = OFF: nothing (a note-off only ends what a note-on of
+ * that channel started on the selected track, before) */
+ t = TSEL;
if (on)
midi_sel_on[ch & 15u][note & 127u] = (uint8_t)(song.sel + 1u);
else if (midi_sel_on[ch & 15u][note & 127u]) {
@@ -2016,6 +2162,26 @@ static track_t *midi_route(uint32_t ch, uint32_t note, int on)
return t;
}
+/* (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 void sus_set(track_t *t, int on);
+static void midi_pedal(uint32_t ch, track_t *t, uint32_t value)
+{
+ uint32_t was = ch_sus[ch & 15u];
+ if (was && was - 1u != trk_index(t))
+ sus_set(&trk[(was - 1u) % NTRK], 0); /* (the pedal's other track: let go there) */
+ ch_sus[ch & 15u] = (uint8_t)(value >= 64u ? trk_index(t) + 1u : 0u);
+}
+static void midi_bend(uint32_t ch, track_t *t, uint32_t d1, uint32_t d2)
+{
+ uint32_t was = ch_bend[ch & 15u];
+ if (was && was - 1u != trk_index(t))
+ trk[(was - 1u) % NTRK].bend = 0; /* (the wheel's other track: back to its pitch, gliding) */
+ t->bend = (int16_t)((int32_t)(d1 | d2 << 7) - 8192);
+ ch_bend[ch & 15u] = (uint8_t)(trk_index(t) + 1u);
+}
+
/* SLOOP 2.5: MIDI CCs set track parameters, after Felucca 1.1.5's standard CC map (#103, Leo Kuroshita).
* A CC acts on the track its channel plays, as the notes do (1-3 the synths, the drum channel the drum
* track, 4-16 the selected track), and sets its parameter as a knob would: 0..127 over the parameter's
@@ -2028,11 +2194,88 @@ static const uint8_t MIDI_CC_MAP[][2] = {
{5, P_GLIDE}, {7, P_LEVEL}, {10, P_PAN}, {71, MCC_RES}, {72, P_REL}, {73, P_ATK}, {74, P_TFLT}, {75, P_DEC},
{91, P_REV}, {93, P_CHOR}, {94, P_DLY},
};
+/* MIDI LEARN (SLOOP 2.6, after Felucca 1.5 by Leo Kuroshita, Discussion #170): up to ML_N CCs, each set to one
+ * parameter of one track, whatever channel it comes on (a channel IN ignores stays ignored) and whichever track that
+ * channel plays. Kept with the settings (project.c settings_write, after the SYN kits), an entry 16 bits: bits 0..6
+ * the CC, 7..8 the track, 9..15 the parameter's code, 0 = an empty entry: a common parameter its P_* id + 1 (their
+ * ids never move, new ones go before P_E0), an engine parameter ML_E0 + k for P_E0 + k (P_E0 moves when common ones
+ * are added). A learned CC no longer reaches the standard map on any channel: the controller is the user's now. The
+ * CCs with a meaning of their own (0 / 32 bank select, 1 mod wheel, 6 / 38 data entry, 11 expression, 64 sustain,
+ * 96..101, 120..127 the channel modes) are never learned. The UI (ui_input.c ml_*) writes the entries with the
+ * interrupts off; ml_arm / ml_heard hand it a CC heard while learning */
+#define ML_N 16u
+#define ML_E0 120u
+_Static_assert(P_E0 < ML_E0 && P_COUNT - P_E0 == 8, "MIDI LEARN: a code per parameter");
+static volatile uint16_t ml_tab[ML_N];
+static volatile uint8_t ml_arm, ml_heard; /* the UI waits for a CC; the CC that came meanwhile + 1 (0 none) */
+static uint32_t ml_id(uint32_t code) /* an entry's code -> P_* id, P_COUNT: none this firmware knows */
+{
+ return code >= ML_E0 ? (code - ML_E0 < 8u ? P_E0 + code - ML_E0 : P_COUNT) : code && code <= P_E0 ? code - 1u : P_COUNT;
+}
+static int ml_free_cc(uint32_t cc)
+{
+ return cc && cc < 120u && cc != 1u && cc != 6u && cc != 11u && cc != 32u && cc != 38u && cc != 64u &&
+ (cc < 96u || cc > 101u);
+}
+/* parameter id of track t from a CC value, as a knob over its range */
+/* the pedal on track t: up, its waiting notes end now */
+static void sus_set(track_t *t, int on)
+{
+ uint32_t ti = trk_index(t) % NTRK, n;
+ if (is_drum(t))
+ return;
+ sus_on[ti] = (uint8_t)(on != 0);
+ if (on)
+ return;
+ for (n = 0; n < 128u; n++)
+ if ((sus_wait[ti][n >> 5] >> (n & 31u)) & 1u) {
+ sus_wait[ti][n >> 5] &= ~(1u << (n & 31u));
+ input_off(t, n);
+ }
+}
+static void midi_cc_set(track_t *t, uint32_t id, uint32_t value)
+{
+ const param_desc_t *d = is_drum(t) && id == P_E0 ? &DRUM_KIT_DESC
+ : id >= P_E0 ? &ENGINES[t->eng_req % NENGINES]->edit[(id - P_E0) & 7u] : &TP[id % P_COUNT];
+ if (d->max > d->min)
+ t->p[id % P_COUNT] = (int16_t)(d->min + ((int32_t)(value & 127u) * (d->max - d->min) + 63) / 127);
+}
+/* 1: cc is learned (set here) or taken by MIDI LEARN waiting for one */
+static int __attribute__((noinline)) midi_learned(uint32_t cc, uint32_t value)
+{
+ uint32_t i, e, id, hit = 0;
+ if (!ml_free_cc(cc)) {
+ if (ml_arm && !ml_heard)
+ ml_heard = (uint8_t)(cc + 1u); /* (the UI says CC NOT LEARNABLE; the CC does its own job) */
+ return 0;
+ }
+ if (ml_arm) {
+ if (!ml_heard)
+ ml_heard = (uint8_t)(cc + 1u);
+ return 1;
+ }
+ for (i = 0; i < ML_N; i++) {
+ e = ml_tab[i];
+ if ((e >> 9) && (e & 127u) == cc) {
+ if ((id = ml_id(e >> 9)) < P_COUNT)
+ midi_cc_set(&trk[(e >> 7) & 3u], id, value);
+ hit = 1;
+ }
+ }
+ return hit;
+}
+
static void __attribute__((noinline)) midi_cc(track_t *t, uint32_t cc, uint32_t value)
{
const param_desc_t *d = 0;
int16_t *slot = 0;
uint32_t i, id = 0xFFFFu;
+ if (midi_learned(cc, value)) /* (a learned CC is the user's: not the map's) */
+ return;
+ if (cc == 64u) { /* the sustain pedal (2.6): >= 64 down */
+ sus_set(t, value >= 64u);
+ return;
+ }
for (i = 0; i < NELEM(MIDI_CC_MAP); i++)
if (MIDI_CC_MAP[i][0] == cc)
id = MIDI_CC_MAP[i][1];
@@ -2230,12 +2473,50 @@ static void events_block(uint32_t n)
fill_arm = 0;
}
fill_now = (uint8_t)(fill_held || fill_bar_on);
+ { /* GLO > SYSTEM > IN changed to or from CH n, or a channel of GLO > MIDI / DRUMS (2.6): what the other routing
+ * started is released (its note-offs would go elsewhere now: stuck notes), the pedals and wheels too */
+ static uint8_t route_was;
+ static uint32_t chans_was = 0xFFFFFFFFu;
+ uint32_t rt = (uint32_t)song.g[G_ROUTE];
+ uint32_t chans = (uint32_t)(song.g[G_CH1] & 31) | (uint32_t)(song.g[G_CH2] & 31) << 5 |
+ (uint32_t)(song.g[G_CH3] & 31) << 10 | (uint32_t)(song.g[G_CHOTH] & 1) << 15 |
+ (uint32_t)(song.g[G_DRCH] & 31) << 16;
+ if ((rt != route_was && (rt >= 2u || route_was >= 2u)) || (chans != chans_was && chans_was != 0xFFFFFFFFu)) {
+ panic_req = (uint8_t)((1u << NTRK) - 1u);
+ seq_out_all_off(); /* (MIDI OUT: the notes on end on the channels they went out on) */
+ memset(midi_sel_on, 0, sizeof midi_sel_on);
+ memset(ch_sus, 0, sizeof ch_sus);
+ memset(ch_bend, 0, sizeof ch_bend);
+ for (i = 0; i < NTRK; i++)
+ trk[i].bend = 0;
+ }
+ route_was = (uint8_t)rt;
+ chans_was = chans;
+ }
pr = panic_req;
panic_req = 0;
+ if (pr)
+ mi_pen[0] = mi_pen[1] = mi_pen[2] = mi_pen[3] = 0; /* (the MIDI pen's notes held: never stuck either) */
+ if (pr == (1u << NTRK) - 1u) { /* (2.6) all of it (a project, NEW, the MIDI routing): the
+ * wheels back to the middle too */
+ memset(ch_bend, 0, sizeof ch_bend);
+ memset(ch_sus, 0, sizeof ch_sus);
+ for (i = 0; i < NTRK; i++)
+ trk[i].bend = 0;
+ }
for (i = 0; i < NTRK; i++) {
track_t *t = &trk[i];
if ((pr >> i) & 1u) {
- trk_all_off(t);
+ if (t->pold) { /* (2.6) a preset loaded: the notes keep sounding as they are
+ * and fade out with the old sound (voice.c sound_change):
+ * no release cut short (an organ's key-off) under the fade */
+ strum_cancel(t, 0, 1);
+ t->nmono = 0, t->mono_note = 0, t->xp_n = 0;
+ } else {
+ trk_all_off(t);
+ }
+ sus_wait[i][0] = sus_wait[i][1] = sus_wait[i][2] = sus_wait[i][3] = 0; /* (what the pedal held: gone too, */
+ sus_on[i] = 0; /* and the pedal: never stuck) */
t->nheld = 0;
t->arp_phys = 0;
t->arp_note = 0;
@@ -2268,23 +2549,81 @@ static void events_block(uint32_t n)
mclk_event((pkt >> 8) & 0xFFu, ((pkt >> 4) & 15u) ? 2u : 1u);
continue;
}
- if (st == 0xB0u) { /* a CC (IN = CLOCK: none) */
- if (!song.g[G_ROUTE])
- midi_cc(midi_track(ch), d1, d2);
- continue;
+ if (song.g[G_ROUTE] >= 2) { /* 2.6: IN = CH n: that channel only, on the selected
+ * track (notes and CCs); every other channel ignored */
+ if (ch != (uint32_t)song.g[G_ROUTE] - 2u)
+ continue;
+ if (st == 0xB0u) {
+ if (d1 == 64u)
+ midi_pedal(ch, TSEL, d2);
+ midi_cc(TSEL, d1, d2);
+ continue;
+ }
+ if (st == 0xE0u) { /* pitch bend (2.6) */
+ if (!is_drum(TSEL))
+ midi_bend(ch, TSEL, d1, d2);
+ continue;
+ }
+ if (st == 0xC0u) { /* Program Change (2.6): the selected track's sound */
+ pc_req[song.sel % NTRK] = (uint8_t)(d1 + 1u);
+ continue;
+ }
+ if (st != 0x90u && st != 0x80u)
+ continue;
+ if (st == 0x90u && d2) {
+ midi_sel_on[ch][d1] = (uint8_t)(song.sel + 1u);
+ t = TSEL;
+ } else { /* the note-off: the track its note-on went to */
+ t = midi_sel_on[ch][d1] ? &trk[(midi_sel_on[ch][d1] - 1u) % NTRK] : TSEL;
+ midi_sel_on[ch][d1] = 0;
+ }
+ } else {
+ if (st == 0xB0u) { /* a CC (IN = CLOCK: none) */
+ if (!song.g[G_ROUTE] && (t = midi_track(ch)) != 0) {
+ if (d1 == 64u)
+ midi_pedal(ch, t, d2);
+ midi_cc(t, d1, d2);
+ }
+ else if (!song.g[G_ROUTE])
+ (void)midi_learned(d1, d2); /* (OTHER = OFF: a learned CC still works, on any channel) */
+ continue;
+ }
+ 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)
+ pc_req[trk_index(t) % NTRK] = (uint8_t)(d1 + 1u);
+ continue;
+ }
+ if (st == 0xE0u) { /* pitch bend (2.6): the track its channel plays (IN = CLOCK:
+ * none) */
+ if (!song.g[G_ROUTE] && (t = midi_track(ch)) != 0 && !is_drum(t))
+ midi_bend(ch, t, d1, d2);
+ continue;
+ }
+ if (st != 0x90u && st != 0x80u)
+ continue;
+ if (song.g[G_ROUTE] && st == 0x90u && d2)
+ continue; /* GLO > SYSTEM > IN = CLOCK: no notes (the note-offs still
+ * end what was held when it was set) */
+ t = midi_route(ch, d1, st == 0x90u && d2);
+ if (!t)
+ continue; /* (GLO > MIDI > OTHER = OFF: a channel no track has) */
}
- if (st != 0x90u && st != 0x80u)
- continue;
- if (song.g[G_ROUTE] && st == 0x90u && d2)
- continue; /* GLO > SYSTEM > IN = CLOCK: no notes (the note-offs still
- * end what was held when it was set) */
- t = midi_route(ch, d1, st == 0x90u && d2);
if (is_drum(t)) {
if (st == 0x90u && d2)
drum_input(lane_of_note(d1), vel_lvl(d2), 0, 1);
} else if (st == 0x90u && d2) {
+ if (t == TSEL) { /* the SEQ layer's pen: this note, or the chord held (2.6) */
+ if (!(mi_pen[0] | mi_pen[1] | mi_pen[2] | mi_pen[3]) || pen_n >= 4u)
+ pen_n = 0;
+ pen_note[pen_n++] = (uint8_t)d1;
+ mi_pen[d1 >> 5] |= 1u << (d1 & 31u);
+ }
+ step_in_push(d1 | 0x80u | trk_index(t) << 8);
input_on(t, d1, d2);
} else {
+ mi_pen[d1 >> 5] &= ~(1u << (d1 & 31u));
+ step_in_push(d1 | trk_index(t) << 8);
input_off(t, d1);
}
}
diff --git a/firmware/src/slicer.c b/firmware/src/slicer.c
index 8da2ff0..9a29497 100644
--- a/firmware/src/slicer.c
+++ b/firmware/src/slicer.c
@@ -191,7 +191,7 @@ static void slicer_drums(int32_t *ml, int32_t *mr, int32_t *rev, int32_t *dly, u
drums_render_mono(sl_dbuf, n);
slicer_track(t, sl_dbuf, n);
{
- int32_t send = song.g[G_DRREV] * 258, dsend = song.g[G_DRDLY] * 258, pan = t->p[P_PAN];
+ int32_t send = send_thr(song.g[G_DRREV] * 258, thr_rev), dsend = send_thr(song.g[G_DRDLY] * 258, thr_dly), pan = t->p[P_PAN];
int32_t gl = 4096 - (pan > 0 ? pan * 64 : 0), gr = 4096 + (pan < 0 ? pan * 64 : 0);
for (i = 0; i < n; i++) {
int32_t x = sl_dbuf[i];
diff --git a/firmware/src/storage.c b/firmware/src/storage.c
index 2680e51..1d3fd16 100644
--- a/firmware/src/storage.c
+++ b/firmware/src/storage.c
@@ -123,13 +123,15 @@ static int st_load(uint32_t obj, void *dst, uint32_t max)
return (int)h.len;
}
-/* an object in two parts, src then src2 (SLOOP 2.5: the settings and the SYN kits after them) */
-static int st_save2(uint32_t obj, const void *src, uint32_t len, const void *src2, uint32_t len2)
+/* an object in up to three parts, src then src2 then src3 (SLOOP 2.5: the settings and the SYN kits after them;
+ * 2.6: then the MIDI LEARN map) */
+static int st_save3(uint32_t obj, const void *src, uint32_t len, const void *src2, uint32_t len2, const void *src3,
+ uint32_t len3)
{
uint32_t seq, base, off;
int cur, rc;
st_hdr_t h;
- if (obj >= OBJ_COUNT || len + len2 > ST_PAYLOAD_MAX)
+ if (obj >= OBJ_COUNT || len + len2 + len3 > ST_PAYLOAD_MAX)
return -1;
cur = st_current(obj, &h);
seq = cur < 0 ? 0u : h.seq;
@@ -139,6 +141,9 @@ static int st_save2(uint32_t obj, const void *src, uint32_t len, const void *src
for (off = 0; off < len2; off++)
st_buf[len + off] = ((const uint8_t *)src2)[off];
len += len2;
+ for (off = 0; off < len3; off++)
+ st_buf[len + off] = ((const uint8_t *)src3)[off];
+ len += len3;
if ((rc = st_erase(base)) != 0)
return rc;
for (off = 0; off < len; off += 256u) {
@@ -164,4 +169,8 @@ static int st_save2(uint32_t obj, const void *src, uint32_t len, const void *src
}
return 0;
}
+static int st_save2(uint32_t obj, const void *src, uint32_t len, const void *src2, uint32_t len2)
+{
+ return st_save3(obj, src, len, src2, len2, 0, 0);
+}
static int st_save(uint32_t obj, const void *src, uint32_t len) { return st_save2(obj, src, len, 0, 0); }
diff --git a/firmware/src/ui.c b/firmware/src/ui.c
index 04b9dd0..6a21ea0 100644
--- a/firmware/src/ui.c
+++ b/firmware/src/ui.c
@@ -3,15 +3,17 @@
/* 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.5" /* the beat machine firmware for the FM-1 (based on Felucca) */
+#define FELUCCA_VERSION "SLOOP 2.6" /* the beat machine firmware for the FM-1 (based on Felucca) */
#endif
static void project_save(uint32_t slot);
static void arrangement_save(void);
static void panel_setup(void);
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_load(uint32_t k);
+static int up_load_to(track_t *t, uint32_t k);
static uint32_t up_count(void);
static uint32_t up_nth(uint32_t n);
static uint32_t up_rank(uint32_t slot);
@@ -118,12 +120,100 @@ static void page_entered(void)
{
const page_t *pg = cur_page();
song.seq_mode = !ui.home && pg->fam == FAM_SEQ;
+ if (!ui.home && pg->fam == FAM_GLO && pg->id[0] == G_CH1 && song.g[G_ROUTE]) { /* (2.6) GLO > MIDI while MIDI 2 >
+ * IN sets the channels aside */
+ if (song.g[G_ROUTE] == 1)
+ ui_message("IN = CLOCK: NO NOTES");
+ else {
+ char b[10];
+ str_cpy(b, "IN CH ", sizeof b);
+ fmt_int(b + 6, song.g[G_ROUTE] - 1);
+ ui_say(b, ": SEL TRK ONLY");
+ }
+ }
ui.entry_open = 0;
ui.hot_t = 0; /* the white value / focus box was the old page's */
ui.force = 1;
}
+/* (2.6) GLO > MIDI: two tracks never share a channel (it would play the first only, the other silent): a channel
+ * turned (a knob, the editor, a backup) onto one another track has goes on to the next free one, the way it was
+ * turned, and says whose it was. Every frame (ui_input) */
+static void midi_chan_fix(void)
+{
+ static const uint8_t ID[4] = {G_CH1, G_CH2, G_CH3, G_DRCH};
+ static int16_t was[4] = {-1, -1, -1, -1};
+ uint32_t k, j;
+ for (k = 0; k < 4u; k++) {
+ int32_t v = song.g[ID[k]], dir, owner = -1;
+ if (was[k] < 0 || v == was[k] || !v) {
+ was[k] = (int16_t)v;
+ continue;
+ }
+ dir = v > was[k] ? 1 : -1;
+ for (;;) {
+ int32_t o = -1;
+ for (j = 0; j < 4u; j++)
+ if (j != k && song.g[ID[j]] == v)
+ o = (int32_t)j;
+ if (o < 0)
+ break;
+ if (owner < 0)
+ owner = o;
+ v += dir;
+ if (v < 1) { /* (down past 1: OFF, never taken) */
+ v = 0;
+ break;
+ }
+ if (v > 16) { /* (none free up there: as it was) */
+ v = was[k];
+ break;
+ }
+ }
+ if (owner >= 0) {
+ char b[8];
+ str_cpy(b, "CH ", sizeof b);
+ fmt_int(b + 3, song.g[ID[k]]);
+ ui_say(b, owner == 3 ? " = DRUMS" : owner == 0 ? " = TRACK 1" : owner == 1 ? " = TRACK 2" : " = TRACK 3");
+ song.g[ID[k]] = (int16_t)v;
+ }
+ was[k] = (int16_t)v;
+ }
+}
+
static int step_on(const step_t *st) { return st->time == ST_NOTE && st->n; }
+/* LEN (SLOOP 2.6, after Felucca 1.5 by Leo Kuroshita, Discussions #178, #173): a NOTE step's length is the step and
+ * the TIE steps after it (inside LEN, no wrap); SEQ > STEP's KNOB 3 on a note sets it (ui_input.c step_edit). Longer:
+ * the steps after it become clean TIEs (a REST or an empty step; it stops at the next step holding notes, which stays,
+ * and at LEN); shorter: its last TIEs become RESTs (one holding notes keeps them). The steps' locks and nudges stay;
+ * the turns on one step are one undo (ui_input.c). Returns the length it got */
+static uint32_t note_len(const track_t *t, uint32_t i)
+{
+ uint32_t len = (uint32_t)clamp(t->p[P_SLEN], 1, NSTEP), n = 1;
+ while (i + n < len && t->step[i + n].time == ST_TIE)
+ n++;
+ return n;
+}
+static uint32_t note_set_len(track_t *t, uint32_t i, uint32_t want)
+{
+ uint32_t len = (uint32_t)clamp(t->p[P_SLEN], 1, NSTEP), n = note_len(t, i);
+ for (; n > want && n > 1u; n--) {
+ if (!t->step[i + n - 1u].n) /* (a TIE holding notes, from TIME or an older SLOOP, */
+ memset(&t->step[i + n - 1u], 0, sizeof(step_t)); /* keeps them, as TIME would) */
+ t->step[i + n - 1u].time = ST_REST;
+ }
+ for (; n < want && i + n < len && !t->step[i + n].n; n++) {
+ memset(&t->step[i + n], 0, sizeof(step_t));
+ t->step[i + n].time = ST_TIE;
+ }
+ return n;
+}
+/* a synth step's velocity as it plays (seq.c step_vel: ACC 127, else its VEL, 96 when 0, through its first note's level) */
+static uint32_t step_vel_shown(const step_t *st)
+{
+ uint32_t base = (st->flags & SF_ACCENT) ? 127u : (st->vel ? st->vel : 96u);
+ return lvl_vel(st->lvl & 3u, base);
+}
/* step i of track t has something to play (synth: notes, drums: a lane) */
static int trk_step_on(const track_t *t, uint32_t i)
{
@@ -188,12 +278,14 @@ static void open_family(uint32_t fam)
{
if (!ui.home && cur_page()->fam == fam) { /* same button again: next page */
uint32_t i = ui.page + 1u;
+ while (i < NPAGES && PAGES[i].fam == fam && !page_shown(&PAGES[i]))
+ i++; /* (not a page of another engine: EDIT > FILTER) */
if (i >= NPAGES || PAGES[i].fam != fam)
i = page_first(fam);
ui.page = (uint8_t)i;
} else {
- ui.page = ui.fam_last[fam] && PAGES[ui.fam_last[fam]].fam == fam ? ui.fam_last[fam]
- : (uint8_t)page_first(fam);
+ ui.page = ui.fam_last[fam] && PAGES[ui.fam_last[fam]].fam == fam && page_shown(&PAGES[ui.fam_last[fam]])
+ ? ui.fam_last[fam] : (uint8_t)page_first(fam);
}
ui.fam_last[fam] = ui.page;
ui.home = 0;
@@ -212,7 +304,7 @@ static int page_walk(int32_t s)
if (ui.home || pg->scope == SC_SONG || pg->scope == SC_DRUM)
return 0;
for (i = 0; i < NPAGES && n < 8u; i++) {
- if (PAGES[i].fam != fam || PAGES[i].scope == SC_SONG || PAGES[i].scope == SC_DRUM)
+ if (PAGES[i].fam != fam || PAGES[i].scope == SC_SONG || PAGES[i].scope == SC_DRUM || !page_shown(&PAGES[i]))
continue;
if (i == ui.page)
cur = (int32_t)n;
@@ -229,6 +321,20 @@ static int page_walk(int32_t s)
return 1;
}
+/* the page shown is one the selected track has (2.6: EDIT > FILTER, ANALOG only): after a track or engine change,
+ * from the previous page of the family that it has (a hidden page is never the first one), once a frame */
+static void page_fix(void)
+{
+ uint32_t i = ui.page, fam = PAGES[i].fam;
+ if (ui.home || page_shown(&PAGES[i]))
+ return;
+ while (i > 0u && PAGES[i - 1u].fam == fam && !page_shown(&PAGES[i - 1u]))
+ i--;
+ ui.page = (uint8_t)(i > 0u && PAGES[i - 1u].fam == fam ? i - 1u : page_first(fam));
+ ui.fam_last[fam] = ui.page;
+ page_entered();
+}
+
static void go_home(void)
{
#if FELUCCA_ARRANGER
@@ -272,6 +378,7 @@ static void apply_preset_to(track_t *t, uint32_t pi)
uint32_t i;
if (is_drum(t))
return;
+ sound_change(t); /* (2.6: what sounds fades out with the old sound, no click) */
panic_req |= (uint8_t)(1u << trk_index(t)); /* MONO/POLY may change: release what sounds */
t->user = 0;
if (t == TSEL)
@@ -314,6 +421,7 @@ static void set_engine_of(track_t *t, uint32_t ei)
return;
fm1_irq_off();
locks_restore(t); /* (a lock in force: its base first, then the new sound) */
+ sound_change(t); /* (2.6: the sound as it is, before anything new is written) */
t->eng_req = (uint8_t)(ei % NENGINES);
for (i = 0; i < 8u; i++)
t->p[P_E0 + i] = e->edit[i].def;
@@ -441,6 +549,56 @@ static uint32_t preset_at(uint32_t n, uint32_t *k)
}
static const char *preset_kind(uint32_t n) { return n < NBANK ? BANK_KIND[BANK[n].kind] : "USER"; }
+/* list index n into track t (2.6: MIDI Program Change, any track); 0 done, 1 no such sound */
+static int preset_go_to(track_t *t, uint32_t n)
+{
+ uint32_t k, total, e;
+ if (is_drum(t))
+ return 1;
+ if (!bank_ready)
+ bank_resolve();
+ total = NBANK + up_count();
+ if (n >= total)
+ return 1;
+ e = preset_at(n, &k);
+ if (e == NENGINES)
+ return up_load_to(t, k);
+ if (e != t->eng_req)
+ set_engine_of(t, e);
+ apply_preset_to(t, k);
+ ui.force = 1;
+ return 0;
+}
+/* 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) */
+static void pc_poll(void)
+{
+ uint32_t i;
+ for (i = 0; i < NTRK; i++) {
+ uint32_t r = pc_req[i], n;
+ char b[12];
+ if (!r)
+ continue;
+ pc_req[i] = 0;
+ n = r - 1u;
+ if (is_drum(&trk[i])) {
+ if (n >= DRUM_KITS)
+ continue;
+ trk[i].p[P_E0] = (int16_t)n;
+ if (&trk[i] == TSEL)
+ sync_reload = 1;
+ } else if (preset_go_to(&trk[i], n)) {
+ continue;
+ }
+ str_cpy(b, "T1 PROG ", sizeof b);
+ b[1] = (char)('1' + i);
+ fmt_int(b + 8, (int32_t)n);
+ ui_message(b);
+ ui.force = 1;
+ }
+}
static void preset_go(uint32_t n) /* load list index n into the selected track */
{
uint32_t k, e = preset_at(n, &k);
@@ -489,3 +647,105 @@ static void track_select(uint32_t i)
sync_reload = 1;
ui.force = 1;
}
+
+/* ------------------------------------------------------- MIDI LEARN --- */
+/* MIDI LEARN (SLOOP 2.6, after Felucca 1.5 by Leo Kuroshita, Discussion #170; the map: seq.c ml_tab). GLO held +
+ * the black key F#3 turns it on and off. On: a knob turned on a track's page (the sound's pages, HOME, TRACKS' LEVEL
+ * and PAN) picks its parameter on the selected track as it edits it; the next CC that comes (any channel IN hears) is
+ * set to it, and stays until something else is learned on it or HOME > SYSTEM > LEARN CLEAR. Then turn the next knob.
+ * One CC sets one parameter, a parameter has one CC: learning one again replaces both. The settings keep the map */
+static struct { uint8_t on, pick, trk, id; } mlu;
+static uint32_t ml_code(uint32_t id) { return id >= P_E0 ? ML_E0 + id - P_E0 : id + 1u; }
+static void ml_put(uint32_t i, uint32_t e) /* (the ISR reads the entry: never half of one) */
+{
+ fm1_irq_off();
+ ml_tab[i % ML_N] = (uint16_t)e;
+ fm1_irq_on();
+}
+static uint32_t ml_count(void)
+{
+ uint32_t i, n = 0;
+ for (i = 0; i < ML_N; i++)
+ n += (ml_tab[i] >> 9) != 0u;
+ return n;
+}
+/* cc -> parameter id of track k, in place of what either had; 0 = no room, 2 = a CC that is never learned */
+static uint32_t ml_learn(uint32_t cc, uint32_t k, uint32_t id)
+{
+ uint32_t i, e;
+ if (!ml_free_cc(cc) || k >= NTRK || id >= P_COUNT)
+ return 2;
+ for (i = 0; i < ML_N; i++)
+ if ((e = ml_tab[i]) >> 9 && ((e & 127u) == cc || ((e >> 9) == ml_code(id) && ((e >> 7) & 3u) == k)))
+ ml_put(i, 0);
+ for (i = 0; i < ML_N; i++)
+ if (!(ml_tab[i] >> 9)) {
+ ml_put(i, cc | k << 7 | ml_code(id) << 9);
+ return 1;
+ }
+ return 0;
+}
+static int ml_clear_all(void) /* HOME > SYSTEM > LEARN CLEAR; 1 = there were */
+{
+ uint32_t i, n = ml_count();
+ for (i = 0; i < ML_N; i++)
+ ml_put(i, 0);
+ if (n)
+ settings_later = 1; /* (saved when quiet) */
+ return n != 0u;
+}
+static void ml_toggle(void) /* GLO + F#3 */
+{
+ mlu.on = (uint8_t)!mlu.on;
+ mlu.pick = 0;
+ ml_arm = 0;
+ ml_heard = 0;
+ ui_message(mlu.on ? "LEARN: TURN A KNOB" : "LEARN DONE");
+ ui.force = 1;
+}
+/* a knob turned parameter id of track t: picked while learning (ui_input.c) */
+static void ml_knob(const track_t *t, uint32_t id)
+{
+ char b[16];
+ if (!mlu.on || id >= P_COUNT)
+ return;
+ if (!mlu.pick || mlu.id != id || mlu.trk != (uint8_t)trk_index(t)) {
+ mlu.trk = (uint8_t)trk_index(t);
+ mlu.id = (uint8_t)id;
+ b[0] = 'T';
+ b[1] = (char)('1' + mlu.trk);
+ b[2] = ' ';
+ str_cpy(b + 3, track_desc(t, id)->label, 9);
+ ui_say(b, ": SEND A CC");
+ }
+ mlu.pick = 1;
+ ml_heard = 0;
+ ml_arm = 1;
+}
+/* each frame: a CC heard for the picked parameter is learned */
+static void ml_poll(void)
+{
+ uint32_t cc = ml_heard, r;
+ char a[16], b[16];
+ if (!cc)
+ return;
+ ml_heard = 0;
+ if (!mlu.on || !mlu.pick)
+ return;
+ cc--;
+ r = ml_learn(cc, mlu.trk, mlu.id);
+ if (r != 1u) {
+ ui_message(r ? "CC NOT LEARNABLE" : "LEARN FULL");
+ return;
+ }
+ str_cpy(a, "CC", 4);
+ fmt_int(a + 2, (int32_t)cc);
+ str_cpy(a + str_len(a), " = T", 5);
+ b[0] = (char)('1' + mlu.trk);
+ b[1] = ' ';
+ str_cpy(b + 2, track_desc(&trk[mlu.trk % NTRK], mlu.id)->label, 9);
+ ui_say(a, b);
+ mlu.pick = 0;
+ ml_arm = 0;
+ settings_later = 1; /* (saved when quiet) */
+}
diff --git a/firmware/src/ui_draw.c b/firmware/src/ui_draw.c
index e7ee15b..33802f0 100644
--- a/firmware/src/ui_draw.c
+++ b/firmware/src/ui_draw.c
@@ -45,7 +45,7 @@ static void draw_head(void)
uint32_t rec = (song.rec >> song.sel) & 1u ? 2u : song.rec != 0u; /* 2 the selected track armed, 1 another */
uint32_t sig = (uint32_t)song.playing * 3u + rec * 5u + (uint32_t)(song.octave + 8) * 11u + song.sel * 13131u +
(ui.msg_t ? str_hash(7u, ui.msg) : 0u) + (uint32_t)song.g[G_BPM] * 101u + (ui.bpm_t != 0) * 31u +
- (uint32_t)batt_shown() * 7777u + (usb.config && !usb.suspended) * 99991u;
+ (uint32_t)batt_shown() * 7777u + (usb.config && !usb.suspended) * 99991u + mlu.on * 7919u;
if (!ui.force && sig == ui.head_sig)
return;
ui.head_sig = sig;
@@ -70,7 +70,9 @@ static void draw_head(void)
x += 14;
}
x = cv_text(x, 1, &FONT_S, b, ui.bpm_t ? C_WHITE : C_HI); /* white while SELECT turns it */
- if (song.octave) {
+ if (mlu.on) { /* MIDI LEARN on (2.6, GLO + F#3): in the octave's place */
+ cv_text(x + 12, 1, &FONT_S, "LEARN", C_AMB);
+ } else if (song.octave) {
str_cpy(b, song.octave > 0 ? "+" : "", 4);
fmt_int(b + str_len(b), song.octave);
cv_text(x + 12, 1, &FONT_S, "OCT", C_GRAY);
@@ -357,7 +359,10 @@ static uint32_t str_hash(uint32_t h, const char *s)
}
/* a page drawn with its values large (graph_big) */
-static int big_page(const page_t *pg) { return pg->graph == GR_NONE && pg->scope != SC_SONG && pg->scope != SC_DRUM; }
+static int big_page(const page_t *pg) /* (2.6: the INSERT pages too: their middle stayed empty) */
+{
+ return (pg->graph == GR_NONE || pg->graph == GR_INS) && pg->scope != SC_SONG && pg->scope != SC_DRUM;
+}
static uint32_t graph_signature(void)
{
const page_t *pg = cur_page();
@@ -769,7 +774,7 @@ static void draw_foot(void)
uint32_t i, n = 0, k = 0;
const char *pt = pg->scope == SC_ENGINE ? e->page_title[pg->id[0] != P_E0] : 0; /* EDIT: the engine's */
for (i = 0; i < NPAGES; i++)
- if (PAGES[i].fam == pg->fam) {
+ if (PAGES[i].fam == pg->fam && (page_shown(&PAGES[i]) || i == ui.page)) { /* (the pages it has) */
n++;
if (i == ui.page)
k = n;
@@ -914,7 +919,13 @@ static void draw_columns(void)
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);
- draw_column(2, "TIME", TIME_N[st->time % 3u], "", VAL(2u), -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);
}
@@ -923,6 +934,10 @@ static void draw_columns(void)
for (c = 0; c < 4u; c++) {
int16_t *vp;
const param_desc_t *d = page_desc(cur_page(), c, &vp);
+ if (cur_page()->graph == GR_SLOTS && c == 1u) { /* 2.6: ERASE, lit while the slot holds a project */
+ draw_column(1, "ERASE", "--", "", project_used((uint32_t)song.g[G_SLOT] - 1u) ? C_HI : C_DIM, -1, ICON_AUTO);
+ continue;
+ }
if (!d || !d->label || d->label[0] == '-') {
draw_column(c, "", "", "", C_HI, -1, ICON_AUTO);
continue;
diff --git a/firmware/src/ui_input.c b/firmware/src/ui_input.c
index 0e3a270..90af341 100644
--- a/firmware/src/ui_input.c
+++ b/firmware/src/ui_input.c
@@ -107,7 +107,7 @@ static uint32_t keys_lit(void)
track_t *t = TSEL;
switch (ui.layer) {
case LY_FX:
- return punch.req >= 0 ? 1u << key_of_white((uint32_t)punch.req) : 0u;
+ return punch.req >= 0 ? 1u << punch_key_of_fx((uint32_t)punch.req) : 0u;
case LY_STEP: { /* the steps that play; the playhead blinks */
uint32_t len = trk_len(t);
for (i = 0; i < 16u; i++) {
@@ -224,7 +224,10 @@ static void ui_leds(void)
(ci_on && ci_u % BEAT_U < BEAT_U / 4u)); /* (the count-in's beats) */
led_put(nl, panel.btn[B_REC], song.rec != 0u || ft_on || (rec_wait && ((fm1_ms / 125u) & 1u)) ||
(ui.hold_kind == 1u && ((fm1_ms / 60u) & 1u))); /* blinks: armed; fast: clearing */
- if (is_drum(TSEL)) { /* the drum track: OCT- / OCT+ lit while ghost / hard */
+ if (ui.layer == LY_FX) { /* FX: OCT- / OCT+ lit while REV / ECHO THROW (2.6) */
+ led_put(nl, panel.btn[B_OCTDN], (thr_req & 1u) != 0u);
+ led_put(nl, panel.btn[B_OCTUP], (thr_req & 2u) != 0u);
+ } else if (is_drum(TSEL)) { /* the drum track: OCT- / OCT+ lit while ghost / hard */
led_put(nl, panel.btn[B_OCTDN], (fm1_in.buttons & dyn_bit[0]) != 0u);
led_put(nl, panel.btn[B_OCTUP], (fm1_in.buttons & dyn_bit[1]) != 0u);
} else {
@@ -291,6 +294,8 @@ static void tracks_edit(uint32_t slot, int32_t steps)
break;
}
*vp = (int16_t)clamp(*vp + accel(EN_K1 + slot, steps, d->max - d->min), d->min, d->max);
+ if (!is_drum(t) && (vp == &t->p[P_LEVEL] || vp == &t->p[P_PAN]))
+ ml_knob(t, vp == &t->p[P_LEVEL] ? P_LEVEL : P_PAN); /* MIDI LEARN: LEVEL, PAN (2.6) */
}
static void step_edit(uint32_t slot, int32_t steps)
@@ -315,7 +320,22 @@ static void step_edit(uint32_t slot, int32_t steps)
st->time = ST_NOTE;
last_note = st->note[0];
break;
- case 2:
+ case 2: /* TIME; on a note its LEN (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) */
+ fm1_irq_off();
+ n = note_set_len(TSEL, 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;
+ }
st->time = (uint8_t)clamp((int32_t)st->time + (steps > 0 ? 1 : -1), ST_NOTE, ST_REST);
break;
default: { /* FLAG: - / ACC / SLD / A+S */
@@ -337,6 +357,8 @@ static void project_new(void)
track_t *t = &trk[i];
undo_mark(t, (undo_sess += 4u) | 3u);
fm1_irq_off();
+ if (i < NPART)
+ sound_change(t); /* (2.6: what sounds fades out with its own sound) */
track_defaults(t);
if (i < NPART) {
set_engine_of(t, TRK_DEF[i][0]);
@@ -345,8 +367,11 @@ static void project_new(void)
fm1_irq_on();
}
TDRUM->p[P_E0] = DRUM_DEFAULT_KIT;
+ 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)
+ 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) /* (the
+ * FM-1's settings: GLO > MIDI 2.6) */
song.g[i] = GP[i].def;
song.solo = 0;
song.octave = 0;
@@ -400,13 +425,29 @@ static void edit_param(uint32_t slot, int32_t steps)
up_ui(slot - 1u, ui.uslot);
return;
}
+ if (pg->graph == GR_SLOTS && slot == 1u) { /* 2.6: KNOB 2 ERASE, a GO button (the slot KNOB 1 picks) */
+ if (steps <= 0)
+ return;
+ if (ui.arm != 0xE8u) { /* one detent arms, a second one within ~1.5 s acts */
+ ui.arm = 0xE8u;
+ ui.arm_t = 90;
+ ui_say("AGAIN: ", "ERASE");
+ return;
+ }
+ ui.arm = 0;
+ project_erase((uint32_t)song.g[G_SLOT] - 1u);
+ return;
+ }
d = page_desc(pg, slot, &vp);
if (!d || !vp || d->max == d->min)
return;
- v = clamp(*vp + accel(EN_K1 + slot, steps, d->max - d->min), d->min, d->max);
+ v = d->names == ESYNC_NAMES || d->names == N_IBITS || d->names == N_IRATE ? names_turn(d, *vp, steps) /* (a name a detent) */
+ : clamp(*vp + accel(EN_K1 + slot, steps, d->max - d->min), d->min, d->max);
*vp = (int16_t)v;
if (pg->scope != SC_GLOBAL && p_lockable(id))
ui.lock_par = (uint8_t)id; /* the SEQ layer's lock parameter: the last one touched */
+ if (pg->scope != SC_GLOBAL)
+ ml_knob(TSEL, id); /* MIDI LEARN: this parameter (2.6) */
if (!v)
return;
if (pg->scope == SC_GLOBAL && (id == G_LOAD || id == G_SAVE || id == G_CLRSEQ || id == G_INITSND || id == G_NEWPRJ) &&
@@ -459,6 +500,80 @@ static void edit_param(uint32_t slot, int32_t steps)
}
}
+/* SLOOP 2.6: the STEP page's entry from a MIDI keyboard, as from the keys (seq_entry): the notes played together on the
+ * selected track (the one its channel plays: GLO > MIDI) become the cursor step, as they sounded (no chord built: the
+ * keyboard plays the notes it sends); letting them all go moves on. Called every frame (the queue is read even off the
+ * page). Stopped, a note for another track says which one it plays: the STEP page writes the selected one. Returns
+ * whether notes of the entry are still held */
+static uint32_t mi_held[4];
+static uint8_t mi_ok; /* the last frame reached the STEP page's entry (seq_entry: no
+ * layer, hold, menu, SONG or DRUMS page in the way) */
+static uint32_t midi_held(void) { return mi_held[0] | mi_held[1] | mi_held[2] | mi_held[3]; }
+static void midi_entry(void) /* (top of ui_input: every frame) */
+{
+ track_t *t = TSEL;
+ int on_page = mi_ok && song.seq_mode && cur_page()->scope == SC_STEP && !is_drum(t) && !song.rec && !rec_wait && !ft_on;
+ int rec_arm = song.rec || rec_wait || ft_on; /* (2.6) recording, armed or a free take: on which track */
+ uint32_t rec_trk = ft_on ? ft_trk % NTRK : song.sel % NTRK;
+ static uint8_t rh_st, rh_trk; /* its hint: 0 off, 1 not said yet, 2 said (or not needed) */
+ if (!rec_arm)
+ rh_st = 0;
+ else if (!rh_st || rh_trk != rec_trk)
+ rh_st = 1, rh_trk = (uint8_t)rec_trk;
+ mi_ok = 0;
+ if (step_in_lost) { /* (the queue overflowed: what is in it and what is held are
+ * unknown: all dropped) */
+ step_in_lost = 0;
+ step_in_r = step_in_w;
+ mi_held[0] = mi_held[1] = mi_held[2] = mi_held[3] = 0;
+ }
+ while (step_in_r != step_in_w) {
+ uint32_t ev = step_in_q[step_in_r % STEP_IN_Q], note = ev & 127u, tr = (ev >> 8) % NTRK;
+ step_t *st = &t->step[ui.cursor];
+ step_in_r++;
+ if (!(ev & 0x80u)) {
+ mi_held[note >> 5] &= ~(1u << (note & 31u));
+ continue;
+ }
+ if (!on_page) {
+ if (rh_st == 1u && tr != rec_trk) { /* (2.6, a YouTube comment) the keyboard plays another track
+ * than the one recording: nothing is recorded, say why (once a
+ * take, and not when MIDI plays that track too: an external
+ * sequencer on the other tracks does not flash it) */
+ char b[2] = {(char)('1' + tr), 0};
+ ui_say("MIDI PLAYS TRACK ", b);
+ rh_st = 2;
+ } else if (rec_arm && tr == rec_trk) {
+ rh_st = 2;
+ }
+ continue;
+ }
+ if (&trk[tr] != t) {
+ if (!song.playing) {
+ char b[2] = {(char)('1' + tr), 0};
+ ui_say("MIDI PLAYS TRACK ", b);
+ }
+ continue;
+ }
+ mi_held[note >> 5] |= 1u << (note & 31u);
+ if (!ui.entry_open) {
+ ui.entry_open = 1;
+ undo_mark(t, (undo_sess += 4u) | 3u);
+ st->n = 0;
+ st->lvl = st->rat = 0;
+ st->time = ST_NOTE;
+ }
+ if (t->p[P_VOICE]) {
+ st->note[0] = (uint8_t)note;
+ st->n = 1;
+ } else if (st->n < 4u) {
+ st->note[st->n++] = (uint8_t)note;
+ }
+ }
+ if (!on_page)
+ mi_held[0] = mi_held[1] = mi_held[2] = mi_held[3] = 0;
+}
+
/* SEQ step entry, acid style: the keys pressed together (POLY: up to 4, MONO:
* the last one) become the cursor step; releasing all keys moves on. Not while recording or armed:
* the keys record live then (they would be written twice) */
@@ -467,6 +582,7 @@ static void seq_entry(uint32_t pressed)
track_t *t = TSEL;
step_t *st = &t->step[ui.cursor];
uint32_t k;
+ mi_ok = 1; /* (next frame, midi_entry may write) */
if (is_drum(t) || song.rec || rec_wait || ft_on)
return;
for (k = 0; k < 27u; k++) {
@@ -503,7 +619,7 @@ static void seq_entry(uint32_t pressed)
}
last_note = (uint8_t)note;
}
- if (ui.entry_open && !fm1_in.notes)
+ if (ui.entry_open && !fm1_in.notes && !midi_held())
cursor_set(ui.cursor + 1);
}
@@ -647,6 +763,7 @@ static int layers_input(uint32_t note_edges, uint32_t *pressed, uint32_t home)
if (held != LY_PLAY && held != ui.layer && ui.layer != LY_PLAY)
ui.layer = (uint8_t)held; /* (from one layer straight to another) */
if (held == LY_PLAY) {
+ thr_req = 0; /* (the THROWs: FX let go) */
while (lk_r != lk_w) { /* a key let go after its layer: its release only */
uint32_t e = lk_q[lk_r % LKQ];
lk_r++;
@@ -681,6 +798,17 @@ static int layers_input(uint32_t note_edges, uint32_t *pressed, uint32_t home)
if (held == LY_STEP && (uint32_t)ui.step_page * 16u >= trk_len(TSEL))
ui.step_page = 0;
}
+ { /* FX + OCT- / OCT+, held (2.6, after Felucca 1.5.1): REV THROW / ECHO THROW (fx.c); with punch-ins too */
+ uint32_t q = 0;
+ if (held == LY_FX) {
+ q = ((fm1_in.buttons >> panel.btn[B_OCTDN]) & 1u) | ((fm1_in.buttons >> panel.btn[B_OCTUP]) & 1u) << 1;
+ if (q)
+ used[held] = 1;
+ }
+ if (q != thr_req)
+ ui.force = 1; /* (the layer's sub line says it) */
+ thr_req = (uint8_t)q;
+ }
if (held == LY_ERASE) { /* EDIT + OCT- / OCT+: undo / redo */
uint32_t ob = 1u << panel.btn[B_OCTDN], pb = 1u << panel.btn[B_OCTUP];
static uint32_t prev;
@@ -808,7 +936,12 @@ static void ui_input(void)
enc_hold = 0; /* (panel.c: every knob readable again this pass) */
if (pressed || notes)
ui_input_ms = fm1_ms;
+ pc_poll(); /* MIDI Program Change: a sound (2.6, ui.c) */
+ midi_chan_fix(); /* GLO > MIDI: no channel on two tracks (2.6, ui.c) */
fm6_poll(); /* FM6: PTCH turned -> its patch */
+ ml_poll(); /* MIDI LEARN: a CC came for the picked parameter (2.6) */
+ page_fix(); /* (a page the track does not have: its neighbour, 2.6) */
+ midi_entry(); /* (the STEP page's MIDI notes: read every frame, 2.6) */
if (home == BT_HOLD) { /* HOME held: open the menu, or leave it */
if (ui.menu) {
menu_close();
@@ -824,6 +957,7 @@ static void ui_input(void)
kb_grid = (uint8_t)grid_keys_on(); /* (seq.c: the keys are the grid's steps) */
if (ui.menu) { /* HOME / REC taps do nothing here */
punch.hold = 0;
+ thr_req = 0;
if (!ui.home_t0)
menu_input(pressed);
return;
@@ -921,7 +1055,7 @@ static void ui_input(void)
}
}
if (song.seq_mode && cur_page()->scope == SC_STEP)
- seq_entry(notes);
+ seq_entry(notes); /* (and the MIDI keyboard's: midi_entry) */
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
@@ -963,6 +1097,8 @@ static void ui_input(void)
*vp = (int16_t)clamp(*vp + accel(EN_K1 + k, s, d->max - d->min), d->min, d->max);
if (!is_drum(TSEL) && p_lockable(ENGINES[TSEL->eng_req % NENGINES]->macro[k & 3u]))
ui.lock_par = ENGINES[TSEL->eng_req % NENGINES]->macro[k & 3u];
+ if (!is_drum(TSEL))
+ ml_knob(TSEL, ENGINES[TSEL->eng_req % NENGINES]->macro[k & 3u]); /* MIDI LEARN (2.6) */
} else {
edit_param(k, s);
}
diff --git a/firmware/src/ui_layers.c b/firmware/src/ui_layers.c
index c541b51..cd8d031 100644
--- a/firmware/src/ui_layers.c
+++ b/firmware/src/ui_layers.c
@@ -184,6 +184,10 @@ static void steps_held_edit(uint32_t knob, int32_t s)
{
track_t *t = TSEL;
uint32_t w, i;
+ /* the accelerated turn once for every step held (a second call would see no time pass: x3 on the others) */
+ int32_t sv = knob == 1u && !is_drum(t) ? accel(EN_K2, s, 126) : 0;
+ int32_t sk = knob == 4u ? accel(EN_PRESET, s, lock_desc(t, ui.lock_par % P_COUNT)->max -
+ lock_desc(t, ui.lock_par % P_COUNT)->min) : 0;
layer_undo_mark(t);
step_pend_off &= (uint16_t)~ui.step_held; /* (edited: kept when let go) */
fm1_irq_off();
@@ -198,9 +202,8 @@ static void steps_held_edit(uint32_t knob, int32_t s)
if (knob == 4u) { /* LOCK (PRESETS): ui.lock_par on this step */
uint32_t id = ui.lock_par % P_COUNT;
int k = lock_find(t, idx, id, 0);
- const param_desc_t *d = lock_desc(t, id);
int32_t v = k >= 0 ? t->lock[k].val : t->p[id];
- if (!lock_set(t, idx, id, v + accel(EN_PRESET, s, d->max - d->min)))
+ if (!lock_set(t, idx, id, v + sk))
ui_message(p_lockable(id) ? "NO LOCK LEFT" : "NOT LOCKABLE");
continue;
}
@@ -218,6 +221,13 @@ static void steps_held_edit(uint32_t knob, int32_t s)
step_t *st = &t->step[idx];
if (!step_on(st))
continue;
+ if (knob == 1u) { /* VEL (2.6): the step's velocity, 1..127; every note */
+ int32_t v = clamp((int32_t)step_vel_shown(st) + sv, 1, 127); /* at it (NORM) */
+ st->vel = (uint8_t)v;
+ st->lvl = 0;
+ st->flags &= (uint8_t)~SF_ACCENT; /* (ACC would play it at 127) */
+ continue;
+ }
for (i = 0; i < st->n; i++) {
uint32_t sh = 2u * i, lv = (st->lvl >> sh) & 3u, rt = (st->rat >> sh) & 3u;
if (knob == 0u) {
@@ -408,7 +418,9 @@ static void layer_key(uint32_t layer, uint32_t k, uint32_t down)
return;
}
case LY_MIX:
- if (w >= 0 && w < 4) {
+ if (k == 1u) { /* (2.6) the black key F#3: MIDI LEARN on / off */
+ ml_toggle();
+ } else if (w >= 0 && w < 4) {
trk[w].p[P_MUTE] = (int16_t)!trk[w].p[P_MUTE];
} else if (w >= 4 && w < 8) {
song.solo ^= (uint8_t)(1u << (w - 4));
@@ -599,6 +611,43 @@ static void tiles_draw(const tile_t *tl, uint32_t *cache)
}
}
+/* the punch layer (2.6): the 27 keys as a keyboard, four rows of four white keys (as the other layers' 16
+ * tiles) with the black keys over them, between the white keys they sit between (the one after the
+ * row's last white key at its right end); a held effect lit white */
+#define PT_BW 52 /* a black key's tile */
+static void punch_tiles_draw(const tile_t *tl, uint32_t *cache)
+{
+ uint32_t r, c, i, sig = 11u;
+ for (i = 0; i < PUNCH_NFX; i++)
+ sig = studio_hash(sig * 31u + tl[i].bg * 3u + tl[i].fg * 5u + tl[i].top * 7u, tl[i].lab);
+ if (!ui.force && sig == *cache)
+ return;
+ *cache = sig;
+ for (r = 0; r < 4u; r++) {
+ cv_begin(240, 36, C_BLACK);
+ for (c = 0; c < 4u; c++) { /* the white keys */
+ const tile_t *t = &tl[r * 4u + c];
+ int32_t x = 2 + (int32_t)c * 60;
+ cv_rect(x, 19, 56, 17, t->bg);
+ if (t->top)
+ cv_rect(x, 19, 56, 2, t->top);
+ te_text_c(x + 28, 20, t->lab, t->fg);
+ }
+ for (i = 16u; i < PUNCH_NFX; i++) { /* the black keys of this row */
+ const tile_t *t = &tl[i];
+ int32_t w = punch_key(PUNCH_BLACK[i - 16u] - 1u), x; /* the white key before it */
+ if ((uint32_t)w / 4u != r)
+ continue;
+ x = w % 4 < 3 ? 60 * (w % 4 + 1) - PT_BW / 2 : 238 - PT_BW;
+ if (t->bg == C_BLACK)
+ cv_rect(x, 0, PT_BW, 17, TE_G2); /* an outline: a black key on the black screen */
+ cv_rect(x + 1, 1, PT_BW - 2, 15, t->bg);
+ te_text_c(x + PT_BW / 2, 1, t->lab, t->fg);
+ }
+ cv_blit(0, 40 + r * 36);
+ }
+}
+
static void layer_title(const char *name, const char *sub, uint16_t col, uint32_t *cache)
{
uint32_t locked = ly_lock != LY_PLAY;
@@ -630,7 +679,7 @@ static const char *layer_sub_shown = ""; /* the sub line last dr
static void layer_screen_draw(void)
{
static uint32_t head, tiles, foot;
- static tile_t tl[16];
+ static tile_t tl[PUNCH_NFX]; /* 16 (the punch layer: 27) */
static char v[4][10], sub[24];
const char *lab[4] = {"", "", "", ""}, *val[4] = {v[0], v[1], v[2], v[3]};
int32_t ratio[4] = {-1, -1, -1, -1};
@@ -653,17 +702,20 @@ static void layer_screen_draw(void)
sub[6] = (char)('1' + sel);
sub[7] = 0;
switch (layer) {
- case LY_FX: /* the 16 punch-in effects */
+ case LY_FX: /* the 27 punch-in effects: 16 white keys, 11 black */
col = TE_DRUM;
- str_cpy(sub, "hold + key", sizeof sub);
- for (i = 0; i < 16u; i++) {
- static const char *const PSHORT[16] = {"loop 4", "loop 8", "loop16", "loop32", "stutt", "rev", "stop", "half",
- "low", "high", "phone", "crush", "alias", "gate", "echo", "wobble"};
- int on = punch.req == (int8_t)i;
+ str_cpy(sub, thr_req == 3u ? "rev + echo throw" : thr_req == 2u ? "echo throw" : thr_req ? "rev throw" : "hold + key",
+ sizeof sub);
+ for (i = 0; i < PUNCH_NFX; i++) {
+ static const char *const PSHORT[PUNCH_NFX] = {"loop 4", "loop 8", "loop16", "loop32", "stutt", "rev", "stop",
+ "half", "low", "high", "phone", "crush", "alias", "gate", "echo",
+ "wobble", "k low", "k mid", "k high", "rewind", "oct up", "flange",
+ "pan", "freeze", "loop8t", "mono", "fade"};
+ int on = punch.req == (int8_t)i, black = i >= 16u;
str_cpy(tl[i].lab, PSHORT[i], 8);
- tl[i].bg = on ? C_WHITE : TE_G1;
- tl[i].fg = on ? C_BLACK : TE_G4;
- tl[i].top = on ? 0 : TE_DIM[i / 4u];
+ tl[i].bg = on ? C_WHITE : black ? C_BLACK : TE_G1;
+ tl[i].fg = on ? C_BLACK : black ? TE_G3 : TE_G4;
+ tl[i].top = on || black ? 0 : TE_DIM[i / 4u];
}
lab[0] = "filter", lab[1] = "dust", lab[2] = "duck", lab[3] = "trk flt";
{
@@ -683,8 +735,9 @@ static void layer_screen_draw(void)
case LY_ERASE:
case LY_ROLL: { /* the keys' sounds: lit = held */
uint32_t held = fm1_in.notes;
+ int mute = layer == LY_ERASE && is_drum(t) && er_mute; /* (2.6) EDIT + a black key: the mutes */
col = layer == LY_ERASE ? TE_RED : col;
- str_cpy(sub, layer == LY_ERASE ? (song.playing ? "as it plays" : "every step") : "hold + key", sizeof sub);
+ str_cpy(sub, mute ? "mute: key = sound" : layer == LY_ERASE ? (song.playing ? "as it plays" : "every step") : "hold + key", sizeof sub);
for (i = 0; i < 16u; i++) {
uint32_t k = key_of_white(i), down = (held >> k) & 1u, present = 0, j;
if (is_drum(t)) {
@@ -708,13 +761,24 @@ static void layer_screen_draw(void)
tl[i].bg = down ? (layer == LY_ERASE ? TE_RED : C_WHITE) : TE_G1;
tl[i].fg = down ? C_BLACK : present ? C_WHITE : TE_G3;
tl[i].top = present && !down ? (layer == LY_ERASE ? TE_RED : col) : 0;
+ if (mute) { /* MUTE: a muted sound white on red, "off" */
+ uint32_t off = (drum_mute >> i) & 1u;
+ tl[i].bg = off ? TE_RED : TE_G1;
+ tl[i].fg = off ? C_WHITE : present ? C_WHITE : TE_G3;
+ tl[i].top = 0;
+ if (off)
+ str_cpy(tl[i].lab, "off", 8);
+ }
}
+ if (layer == LY_ERASE && is_drum(t) && !mute && !undo.valid)
+ str_cpy(sub, "black key: mute", sizeof sub);
if (layer == LY_ERASE) {
lab[0] = "shift", lab[1] = "length", lab[2] = is_drum(t) ? "" : "transp";
str_cpy(v[0], "< >", 8);
fmt_int(v[1], t->p[P_SLEN]);
str_cpy(v[2], is_drum(t) ? "" : "- +", 8);
- str_cpy(sub, undo.valid ? (undo.undone ? "oct+ redo" : "oct- undo") : sub, sizeof sub);
+ if (!mute)
+ str_cpy(sub, undo.valid ? (undo.undone ? "oct+ redo" : "oct- undo") : sub, sizeof sub);
} else {
lab[0] = "rate";
str_cpy(v[0], N_ROLL[clamp(song.g[G_ROLL], 0, 4)], 8);
@@ -780,8 +844,17 @@ static void layer_screen_draw(void)
for (w = 0; w < 16u && !((ui.step_held >> w) & 1u); w++)
;
idx = (page * 16u + w) % NSTEP;
- lab[1] = "level", lab[2] = "ratchet", lab[3] = "nudge";
+ lab[1] = is_drum(t) ? "level" : "vel", lab[2] = "ratchet", lab[3] = "nudge";
str_cpy(v[1], "- +", 8);
+ if (!is_drum(t)) { /* (2.6) the first held step's velocity */
+ const step_t *st = &t->step[idx];
+ if (step_on(st)) {
+ fmt_int(v[1], (int32_t)step_vel_shown(st));
+ ratio[1] = (int32_t)step_vel_shown(st) * 1000 / 127;
+ } else {
+ str_cpy(v[1], "--", 8);
+ }
+ }
str_cpy(v[2], "x1 x4", 8);
{
int32_t m = t->micro[idx];
@@ -940,7 +1013,10 @@ static void layer_screen_draw(void)
}
layer_sub_shown = sub;
layer_title(LAYER_NAME[layer % LY_COUNT], sub, col, &head);
- tiles_draw(tl, &tiles);
+ if (layer == LY_FX)
+ punch_tiles_draw(tl, &tiles);
+ else
+ tiles_draw(tl, &tiles);
{ /* (a message shows in the title: the dials stay) */
uint8_t m = ui.msg_t;
ui.msg_t = 0;
diff --git a/firmware/src/ui_menu.c b/firmware/src/ui_menu.c
index e1571f0..f6ad91a 100644
--- a/firmware/src/ui_menu.c
+++ b/firmware/src/ui_menu.c
@@ -1,14 +1,15 @@
/* 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), LIGHTS (LIGHTS, KEYS, NOTES),
- * AUDIO (LOWCUT, USB AUDIO, USB SERIAL), SYSTEM (HARDWARE CALIBRATION, ABOUT). SELECT goes to the section
+ * AUDIO (LOWCUT, USB AUDIO, USB SERIAL), SYSTEM (HARDWARE CALIBRATION, LEARN CLEAR (2.6), ABOUT). SELECT goes to the section
* before / after (stopping at the ends), KNOB 1..3 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). */
/* ------------------------------------------------------------ menu --- */
-enum { MI_COLOR, MI_ZOOM, MI_LIGHTS, MI_KEYS, MI_NOTES, MI_LOWCUT, MI_USB, MI_SERIAL, MI_PANEL, MI_ABOUT, MI_COUNT };
+enum { MI_COLOR, MI_ZOOM, MI_LIGHTS, MI_KEYS, MI_NOTES, MI_LOWCUT, MI_USB, MI_SERIAL, MI_PANEL, MI_LCLEAR, MI_ABOUT,
+ MI_COUNT };
static const char *const MI_NAME[MI_COUNT] = {"COLOR", "ZOOM", "LIGHTS", "KEYS", "NOTES", "SPEAKER LOWCUT", "USB AUDIO",
- "USB SERIAL", "HARDWARE CALIBRATION", "ABOUT"};
+ "USB SERIAL", "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_PANEL, MI_COUNT}; /* rows of each */
@@ -41,6 +42,17 @@ static const char *mi_value(uint32_t i, uint16_t *c)
case MI_LOWCUT: return settings.lowcut ? "ON" : "OFF";
case MI_USB: return usb_full ? "FULL" : "MASTER";
case MI_SERIAL: return usb_serial ? "ON" : "OFF";
+ case MI_LCLEAR: { /* (2.6) the CCs MIDI LEARN holds; OCT+ clears them */
+ static char b[8];
+ uint32_t n = ml_count();
+ if (!n) {
+ *c = C_DIM;
+ return "NONE";
+ }
+ fmt_int(b, (int32_t)n);
+ str_cpy(b + str_len(b), " CC", 4);
+ return b;
+ }
default:
*c = C_DIM;
return ""; /* (an action: OCT+ opens it) */
@@ -51,7 +63,7 @@ static void draw_menu(void)
{
uint32_t i, pass, sec = mi_sec(ui.menu_sel % MI_COUNT);
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 +
+ settings.zoom * 104729u + lights_lvl * 1299709u + lights_keys * 15485863u + ml_count() * 2654435u +
lights_notes * 32452843u + usb_full * 49979687u + usb_serial * 86028121u;
if (!ui.force && sig == ui.menu_sig)
return;
@@ -189,6 +201,10 @@ static void mi_set(uint32_t i, int32_t s)
lights_lvl = LIGHTS_LOW; /* keys lit need a level: the lowest */
break;
}
+ case MI_LCLEAR: /* (2.6) every learned CC: OCT+ */
+ if (!s)
+ ui_message(ml_clear_all() ? "LEARN CLEARED" : "NOTHING LEARNED");
+ break;
case MI_PANEL: /* actions: OCT+ only */
if (!s) {
panel_setup();
diff --git a/firmware/src/upreset.c b/firmware/src/upreset.c
index fa2b198..ceb9e52 100644
--- a/firmware/src/upreset.c
+++ b/firmware/src/upreset.c
@@ -237,12 +237,11 @@ static int up_store(uint32_t k, const char *name)
* PAN, MUTE: the TRACKS faders) and its pattern parameters (param_kept). LIVE: the pattern
* stored in the record is not loaded: changing the sound never changes the sequence.
* 0 ok, 1 empty (or the drum track is selected) */
-static int up_load(uint32_t k)
+static int up_load_to(track_t *t, uint32_t k) /* user preset k into track t (2.6: any track, MIDI PC) */
{
const up_rec_t *r;
int16_t v[P_COUNT];
uint32_t i;
- track_t *t = TSEL;
if (!up_used(k) || is_drum(t))
return 1;
r = up_rec(k);
@@ -250,7 +249,8 @@ static int up_load(uint32_t k)
for (i = 0; i < P_COUNT; i++) /* (LEN etc. of a kept pattern changed too, and */
if (param_kept(i)) /* a preset pattern then counted as edited) */
v[i] = t->p[i];
- panic_req |= (uint8_t)(1u << song.sel);
+ sound_change(t); /* (2.6: what sounds fades out with the old sound, no click) */
+ panic_req |= (uint8_t)(1u << trk_index(t));
fm1_irq_off(); /* the audio ISR must not see half a sound */
t->eng_req = r->engine;
for (i = 0; i < P_COUNT; i++)
@@ -259,10 +259,12 @@ static int up_load(uint32_t k)
fm1_irq_on();
fm6_track_loaded(t); /* FM6: a user preset holds the PTCH and the macros */
t->user = (uint8_t)(k + 1u);
- sync_reload = 1;
+ if (t == TSEL)
+ sync_reload = 1;
ui.force = 1;
return 0;
}
+static int up_load(uint32_t k) { return up_load_to(TSEL, k); } /* into the selected track */
static uint32_t up_count(void) /* used slots */
{
diff --git a/firmware/src/voice.c b/firmware/src/voice.c
index b0c47ac..918c61b 100644
--- a/firmware/src/voice.c
+++ b/firmware/src/voice.c
@@ -34,13 +34,31 @@ static int32_t lfo_wave(track_t *t, uint32_t ph)
}
}
+/* LFO 2 (SLOOP 2.6, after Felucca 1.4 by Leo Kuroshita, #154; params.c N_LSYNC): with SYNC on, one cycle lasts the
+ * note value of the tempo, whatever RATE says: the phase advances 2^32 x CTL / cycle a block (two 32-bit divides; the
+ * 1-bit truncation of 0xFFFFFFFF drifts by less than a millionth of a cycle a cycle). OFF: RATE's table, as before.
+ * LSYNC_PULSES: a cycle in 24ths of a beat (4BAR .. 1/32) */
+static const uint16_t LSYNC_PULSES[11] = {0, 384, 192, 96, 48, 24, 12, 8, 6, 4, 3};
+static __attribute__((noinline)) uint32_t lfo_sync_inc(const track_t *t) /* (not inlined: its divides stay out of
+ * the audio ISR's loop over the tracks) */
+{
+ uint32_t beat = (uint32_t)FS * 60u / (uint32_t)clamp(song.g[G_BPM], 20, 300), cyc, q, r;
+ cyc = beat * LSYNC_PULSES[(uint32_t)t->p[P_LSYNC] % NELEM(LSYNC_PULSES)] / 24u;
+ cyc = cyc ? cyc : 1u;
+ q = 0xFFFFFFFFu / cyc;
+ r = 0xFFFFFFFFu % cyc;
+ return q * CTL + (r * CTL + CTL) / cyc;
+}
+
static void track_lfo_tick(track_t *t)
{
uint32_t old = t->lfo_ph;
- t->lfo_ph += LFO_INC[t->p[P_LRATE] & 127];
+ t->lfo_ph += t->p[P_LSYNC] ? lfo_sync_inc(t) : LFO_INC[t->p[P_LRATE] & 127];
if (t->lfo_ph < old)
t->lfo_rnd = rng();
t->lfo_val = lfo_wave(t, t->lfo_ph);
+ if (t->p[P_LPOL]) /* UNI: 0..+1 (the depths reach as far, one way only) */
+ t->lfo_val = (t->lfo_val + 32768) >> 1;
if (t->lfo_fade < 32767) {
int32_t step = (int32_t)(ENV_LIN[t->p[P_LFADE] & 127] >> 9);
t->lfo_fade = t->p[P_LFADE] ? clamp(t->lfo_fade + (step ? step : 1), 0, 32767) : 32767;
@@ -390,7 +408,7 @@ static void trk_note_on(track_t *t, uint32_t note, uint32_t vel)
}
if ((uint32_t)(t - trk) < NPART && note < 128u)
note_hits[t - trk][note >> 5] |= 1u << (note & 31u);
- if (t->xf_on || t->eng_req != t->engine) { /* engine switch under way: after the fade */
+ if (t->xf_on || t->eng_req != t->engine || t->pold) { /* engine switch / preset under way: after the fade */
for (i = 0; i < t->xp_n && t->xp_note[i] != note; i++)
;
if (i == t->xp_n && t->xp_n < 4u)
@@ -402,8 +420,9 @@ static void trk_note_on(track_t *t, uint32_t note, uint32_t vel)
}
for (i = 0; i < NVOICE; i++)
any |= t->v[i].gate;
- if (!any) { /* fresh phrase: LFO retrigger and fade */
- t->lfo_ph = (uint32_t)t->p[P_LPHASE] << 25;
+ if (!any) { /* fresh phrase: LFO retrigger (TRIG NOTE) and fade */
+ if (!t->p[P_LTRIG])
+ t->lfo_ph = (uint32_t)t->p[P_LPHASE] << 25;
t->lfo_fade = 0;
}
if (mode == V_POLY) {
@@ -544,11 +563,27 @@ static void strum_block(uint32_t n)
* parameters (pe_old: an engine never reads another engine's values, which index its tables); only
* then the engine switches and the notes that came during the fade start on it. A part with nothing
* sounding switches at once. */
-#define XF_BLOCKS 4u /* 4 x 32 samples: 2.9 ms */
+#define XF_BLOCKS 8u /* 8 x 32 samples: 5.8 ms (2.6, as Clipper: a bass fades
+ * without a thump; 2.9 ms before) */
+/* SLOOP 2.6: a preset (factory or user) about to load on t: the sound as it is now kept for the fade (UI, before the
+ * new values; IRQ off). The voices sounding then fade out over XF_BLOCKS rendered with these values, the part's DIST,
+ * INSERT, level trim and sends included (fx.c mix_part), as for an engine switch: no jump of a filter, a drive or a
+ * release in the middle of a note (a click). A fade under way keeps the sound it started from */
+static void sound_change(track_t *t)
+{
+ if (!t->pold) { /* (the ISR reads p_old only once pold is set: no IRQ-off
+ * here, the caller's own IRQ-off section stays whole; an
+ * engine fade without a preset takes it too, never an old
+ * p_old) */
+ memcpy(t->p_old, t->p, sizeof t->p_old);
+ __asm__ volatile("" ::: "memory");
+ t->pold = 1;
+ }
+}
static void engine_block(track_t *t)
{
uint32_t i, any = 0;
- if (t->xf_on || t->eng_req != t->engine) {
+ if (t->xf_on || t->eng_req != t->engine || t->pold) {
if (!t->xf_on) {
for (i = 0; i < NVOICE; i++)
any |= t->v[i].active;
@@ -566,8 +601,12 @@ static void engine_block(track_t *t)
v->stage = 0;
v->env = v->env_out = 0;
}
+ if (t->xf_on && t->eng_req == ENGI_FM6 && ((fm6_pend >> ((uint32_t)(t - trk) % NPART)) & 1u))
+ return; /* (2.6) FM6: the new notes wait for the preset's patch
+ * (eng_fm6.c fm6_poll, main loop): not a note of the old */
t->engine = t->eng_req % NENGINES;
t->xf_on = 0;
+ t->pold = 0;
t->nmono = 0;
t->mono_note = 0;
{
@@ -581,6 +620,48 @@ static void engine_block(track_t *t)
t->pe_old[i] = t->p[P_E0 + i];
}
+/* ENV SYNC (SLOOP 2.6, after Felucca 1.5 by Leo Kuroshita, #175; P_ESYNC, params.c ESYNC_NAMES): ATK DEC REL as
+ * note values of the tempo. The part's three steps, made once a block before its voices (track_render; the parts
+ * render one at a time), as gen_tables.py makes ENV_LIN / ENV_EXP for a time in ms: the attack's linear step
+ * 2^24 CTL / T (rounded), the decay's and release's 1 - e^-x (x = 4.6 CTL / T: ~99 % of the way after T), here as
+ * x - x^2/2 + x^3/6 - x^4/24 (x <= 0.33 at the shortest, 1/64T at 240 BPM: under 0.04 % off). The coefficient is Q16 as
+ * ENV_EXP's: past ~2 s it is a few units, the time within half of one (4BAR at 90 BPM: 2.5 %). Value 0 (and a time
+ * below a block) takes the tables' 0, as with SYNC OFF. OFF: the tables' values, as before (looked up once a block here
+ * instead of once a voice in env_tick: the same numbers) */
+_Static_assert(CTL == 32, "esync_one: 4.6 CTL in Q16 is 9646899");
+static uint32_t esync_k[3]; /* ATK's step, DEC's and REL's coefficient (Q16): the part's, this block (env_tick) */
+static uint32_t esync_one(uint32_t quarter, int32_t v, uint32_t i)
+{
+ uint32_t u = ESYNC_UNITS[esync_idx(v)], T = quarter * u / 96u, x, x2, x3, x4; /* T: samples */
+ if (T < CTL)
+ return i ? ENV_EXP[0] : ENV_LIN[0];
+ if (!i)
+ return ((1u << 24) * CTL + T / 2u) / T;
+ x = (9646899u + T / 2u) / T; /* 4.6 CTL (CTL 32), Q16, rounded */
+ if (x > 49152u) /* (below ~200 samples: 0.75, the series 0.3 % low) */
+ x = 49152u;
+ x2 = x * x >> 16;
+ x3 = x2 * x >> 16;
+ x4 = x3 * x >> 16;
+ x = x - x2 / 2u + x3 / 6u - x4 / 24u;
+ return x < 1u ? 1u : x > 65535u ? 65535u : x;
+}
+static __attribute__((noinline)) void esync_coef(const track_t *t) /* (not inlined: its divides stay out of the
+ * audio ISR's loop over the voices) */
+{
+ const int16_t *p = t->p;
+ if (p[P_ESYNC]) {
+ uint32_t q = (uint32_t)FS * 60u / (uint32_t)clamp(song.g[G_BPM], 20, 300); /* a beat (a quarter), samples */
+ esync_k[0] = esync_one(q, p[P_ATK], 0);
+ esync_k[1] = esync_one(q, p[P_DEC], 1);
+ esync_k[2] = esync_one(q, p[P_REL], 2);
+ } else { /* OFF: the tables, as always */
+ esync_k[0] = ENV_LIN[p[P_ATK] & 127];
+ esync_k[1] = ENV_EXP[p[P_DEC] & 127];
+ esync_k[2] = ENV_EXP[p[P_REL] & 127];
+ }
+}
+
/* one control tick (CTL samples) of the amplitude envelope; returns Q15 */
static int32_t env_tick(track_t *t, voice_t *v)
{
@@ -588,17 +669,17 @@ static int32_t env_tick(track_t *t, voice_t *v)
int32_t sus = (int32_t)p[P_SUS] << 17; /* Q24 */
switch (v->stage) {
case 1:
- v->env += (int32_t)ENV_LIN[p[P_ATK] & 127];
+ v->env += (int32_t)esync_k[0]; /* ATK's step (esync_coef: the table's, or ENV SYNC's) */
if (v->env >= (1 << 24)) {
v->env = 1 << 24;
v->stage = 2;
}
break;
case 2:
- v->env += mulq16(sus - v->env, ENV_EXP[p[P_DEC] & 127]);
+ v->env += mulq16(sus - v->env, esync_k[1]);
break;
case 3:
- v->env -= mulq16(v->env, ENV_EXP[p[P_REL] & 127]);
+ v->env -= mulq16(v->env, esync_k[2]);
if (v->env < (1 << 12)) {
v->env = 0;
v->stage = 0;
@@ -634,6 +715,7 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
int32_t tune = song.g[G_TUNE] >= 0 ? song.g[G_TUNE] * 16 / 100 : -((-song.g[G_TUNE] * 16 + 99) / 100);
int32_t tune_fine = (song.g[G_TUNE] * 16 - tune * 100) * 2367 / 16000; /* rest, in 1/4096 (1 ct = 2.367) */
uint32_t nr = 0, fade = t->xf_on && t->xf;
+ int32_t bendq;
int16_t pe_new[8];
for (i = 0; i < n; i++)
out[i] = 0;
@@ -643,6 +725,10 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
t->p[P_E0 + i] = t->pe_old[i];
}
track_lfo_tick(t);
+ esync_coef(t); /* this block's envelope steps for env_tick (ENV SYNC) */
+ t->bend_s = (int16_t)(t->bend_s + ((t->bend - t->bend_s) >> 2) + (t->bend > t->bend_s) - (t->bend < t->bend_s));
+ bendq = ((int32_t)t->bend_s * clamp(song.g[G_BEND], 1, 12)) >> 1; /* MIDI pitch bend (2.6): 1/4096 semitone,
+ * gliding (a quarter of the way a block) */
if (e->block) /* the engine's per-part work (DRAWBAR: bars, rotor) */
e->block(t);
for (i = 0; i < NVOICE; i++) {
@@ -672,7 +758,7 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
m.envq15 = e->ownenv ? 0 : env;
m.amp1 = e->ownenv ? env : mulq15(env, v->vel * 258);
if (p[P_LD_AMP])
- m.amp1 = mulq15(m.amp1, 32767 - mulq15((lfo + 32768) >> 1, p[P_LD_AMP] * 258));
+ m.amp1 = mulq15(m.amp1, 32767 - mulq15(p[P_LPOL] ? lfo : (lfo + 32768) >> 1, p[P_LD_AMP] * 258));
if (fade) /* linear to 0 over the fade */
m.amp1 = m.amp1 * (int32_t)(t->xf - 1u) / (int32_t)XF_BLOCKS;
m.amp0 = v->env_out;
@@ -693,7 +779,7 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
continue; /* held at a silent sustain (SUS 0): nothing to render */
{ /* the pitch in 1/4096 semitone: glide, LFO, the pitch envelope; the fraction goes into the increment */
int32_t q = (v->pitch_cur << 8) + v->pitch_frac + ((lfo * p[P_LD_PIT] * 3) >> 7) +
- ((v->penv * p[P_ED_PIT] * 3) >> 7);
+ ((v->penv * p[P_ED_PIT] * 3) >> 7) + bendq;
pitch = (q >> 8) + tune;
m.pitch16 = clamp(pitch, 0, 2047);
m.inc = pitch_inc(m.pitch16);
diff --git a/tests/_cap26.c b/tests/_cap26.c
new file mode 100644
index 0000000..eb8f7f0
--- /dev/null
+++ b/tests/_cap26.c
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: GPL-3.0-only */
+/* SLOOP 2.6 screenshots for the README (not a test): the UI test's harness, a pattern, then the new pages as RGB888
+ * 240x240 frames into DIR/.rgb */
+#define UI_PAGES_HARNESS_ONLY 1
+#include "ui_pages_test.c"
+static void shot(const char *name)
+{
+ char p[512];
+ FILE *f;
+ if (ui.msg_t) { ui.msg_t = 0; ui.force = 1; frame(); }
+ snprintf(p, sizeof p, "%s/%s.rgb", outdir, name);
+ f = fopen(p, "wb");
+ for (unsigned i = 0; i < 240 * 240; i++) {
+ uint16_t q = swap16(screen[i]);
+ uint8_t rgb[3] = {(uint8_t)((q >> 11) * 255 / 31), (uint8_t)(((q >> 5) & 63) * 255 / 63), (uint8_t)((q & 31) * 255 / 31)};
+ fwrite(rgb, 1, 3, f);
+ }
+ fclose(f);
+}
+static void shot_keep(const char *name)
+{
+ char p[512];
+ FILE *f;
+ snprintf(p, sizeof p, "%s/%s.rgb", outdir, name);
+ f = fopen(p, "wb");
+ for (unsigned i = 0; i < 240 * 240; i++) {
+ uint16_t q = swap16(screen[i]);
+ uint8_t rgb[3] = {(uint8_t)((q >> 11) * 255 / 31), (uint8_t)(((q >> 5) & 63) * 255 / 63), (uint8_t)((q & 31) * 255 / 31)};
+ fwrite(rgb, 1, 3, f);
+ }
+ fclose(f);
+}
+static int find_preset_g(const char *n, uint32_t *e, uint32_t *p)
+{ for (uint32_t i = 0; i < NENGINES; i++) for (uint32_t k = 0; k < ENGINES[i]->npresets; k++) if (!strcmp(ENGINES[i]->presets[k].name, n)) { *e = i; *p = k; return 1; } return 0; }
+static int find_kit_g(const char *n) { for (int k = 0; k < DRUM_KITS; k++) if (!strcmp(DRUM_KIT_NAMES[k], n)) return k; return 0; }
+static void load(int t, const char *n) { uint32_t e, p; if (find_preset_g(n, &e, &p)) { set_engine_of(&trk[t], e); apply_preset_to(&trk[t], p); trk[t].engine = trk[t].eng_req; } else { fprintf(stderr, "? %s\n", n); exit(1); } }
+static void put(int t, int st, int n, const uint8_t *notes) { step_t *s = &trk[t].step[st]; memset(s, 0, sizeof *s); s->n = (uint8_t)n; memcpy(s->note, notes, (size_t)n); s->time = ST_NOTE; s->vel = 100; }
+static void open_page(const char *title)
+{
+ uint32_t i;
+ for (i = 0; i < NPAGES; i++) if (!strcmp(PAGES[i].title, title)) break;
+ if (i == NPAGES) { fprintf(stderr, "? page %s\n", title); exit(1); }
+ open_family(PAGES[i].fam); ui.page = (uint8_t)i; ui.fam_last[PAGES[i].fam] = (uint8_t)i; page_entered(); ui.force = 1; frames(2);
+}
+int main(int argc, char **argv)
+{
+ uint32_t i, j;
+ outdir = argc > 1 ? argv[1] : "/tmp";
+ panel = PANEL_DEFAULT; layers_init(); settings.palette = 4; palette_set(4);
+ host_tracks_init();
+ for (i = 0; i < NPART; i++) { set_engine_of(&trk[i], TRK_DEF[i][0]); apply_preset_to(&trk[i], TRK_DEF[i][1]); trk[i].engine = trk[i].eng_req; }
+ load(0, "ACID 303"); load(1, "RHODES"); load(2, "KALIMBA");
+ TDRUM->p[P_E0] = (int16_t)find_kit_g("BOOMBAP");
+ song.g[G_BPM] = 92;
+ for (j = 0; j < NTRK; j++) { steps_clear(&trk[j]); trk[j].p[P_SLEN] = 32; }
+ {
+ static const uint8_t R[2] = {43, 41};
+ static const uint8_t EP[2][4] = {{59, 62, 66, 69}, {57, 60, 64, 67}};
+ static const uint8_t MEL[32] = {83,0,81,0,78,0,74,0, 0,0,76,0,0,0,0,0, 84,0,81,0,79,0,76,0, 0,0,0,0,0,0,0,0};
+ for (j = 0; j < 32u; j++) {
+ uint32_t h = j / 16u; uint8_t n;
+ if ((j % 4u) == 0u || (j % 8u) == 3u) { n = (uint8_t)(R[h] + ((j % 8u) == 3u ? 12 : 0)); put(0, (int)j, 1, &n); }
+ if ((j % 16u) == 0u || (j % 16u) == 10u) put(1, (int)j, 4, EP[h]);
+ if (MEL[j]) { n = MEL[j]; put(2, (int)j, 1, &n); }
+ memset(&TDRUM->dstep[j], 0, sizeof(dstep_t));
+ if ((j % 16u) == 0u || (j % 16u) == 7u || (j % 16u) == 10u) dstep_set(&TDRUM->dstep[j], 0, LV_NORM, 0);
+ if ((j % 8u) == 4u) dstep_set(&TDRUM->dstep[j], 2, LV_NORM, 0);
+ if (!(j & 1u)) dstep_set(&TDRUM->dstep[j], 4, (j & 2u) ? LV_SOFT : LV_NORM, 0);
+ }
+ }
+ for (j = 0; j < NTRK; j++) trk[j].seq_active = 1;
+ song.g[G_TXSRC] = 1, song.g[G_TXLVL] = 80, song.g[G_TXTONE] = -12, song.g[G_TXMOVE] = 70, song.g[G_TXRATE] = 2;
+ transport_req = 1; frames(150);
+ song.sel = 0; go_home(); frames(3); shot("tracks");
+ /* punch-in FX: FREEZE on a black key, REV THROW (FX + OCT-) */
+ press(B_FX); frames(12);
+ punch.req = PX_FREEZE;
+ fm1_in.buttons |= BT(B_OCTDN); edges_btn |= BT(B_OCTDN); frames(3);
+ ui.force = 1; frames(2); shot("punch");
+ fm1_in.buttons &= ~BT(B_OCTDN); punch.req = -1; frames(2); release(B_FX); frames(6);
+ /* INSERT on the ACID 303 */
+ trk[0].p[P_ITYPE] = 6, trk[0].p[P_IA] = 40, trk[0].p[P_IB] = 90, trk[0].p[P_IC] = 70, trk[0].p[P_IMIX] = 100;
+ open_page("INSERT"); frames(4); shot("insert");
+ /* LFO 2 */
+ song.sel = 1;
+ trk[1].p[P_LSYNC] = 5, trk[1].p[P_LTRIG] = 1, trk[1].p[P_LPOL] = 1;
+ open_page("LFO 2"); frames(4); shot("lfo2");
+ /* the STEP page, LEN on a note */
+ song.sel = 2;
+ open_page("STEP"); ui.cursor = 0; note_set_len(&trk[2], 0, 2); ui.force = 1; frames(3); shot("step_len");
+ /* TEXTURE */
+ song.sel = 0;
+ open_page("TEXTURE"); frames(4); shot("texture");
+ /* GLO > MIDI, MIDI 2 */
+ song.g[G_CH1] = 2, song.g[G_CH2] = 11, song.g[G_CH3] = 8, song.g[G_DRCH] = 10, frames(2);
+ open_page("MIDI"); frames(4); shot("midi");
+ song.g[G_CHOTH] = 1, song.g[G_MIDI] = 1, song.g[G_BEND] = 12;
+ open_page("MIDI 2"); frames(4); shot("midi2");
+ /* MIDI LEARN */
+ for (i = 0; i < ML_N; i++) ml_tab[i] = 0;
+ song.sel = 0;
+ open_page("FX"); frames(2);
+ press(B_GLO); frames(10); key(1); release(B_GLO); frames(16);
+ encs[panel.enc[EN_K1]] = 1; frames(4);
+ ui.force = 1; frame();
+ { /* (the message kept: "T1 DST: SEND A CC") */
+ char p[512]; FILE *f;
+ snprintf(p, sizeof p, "%s/learn.rgb", outdir); f = fopen(p, "wb");
+ for (unsigned k = 0; k < 240 * 240; k++) { uint16_t q = swap16(screen[k]);
+ uint8_t rgb[3] = {(uint8_t)((q >> 11) * 255 / 31), (uint8_t)(((q >> 5) & 63) * 255 / 63), (uint8_t)((q & 31) * 255 / 31)}; fwrite(rgb, 1, 3, f); }
+ fclose(f);
+ }
+ press(B_GLO); frames(10); key(1); release(B_GLO); frames(16); /* (LEARN off) */
+ /* the second sheet: what came before 2.6, in today's look */
+ song.sel = 0; go_home(); frames(4);
+ song.sel = TRK_DRUM; studio_open(SC_DRUM); frames(4);
+ drum_page = 0; drum_lane = 0; drum_cursor = 0; ui.force = 1; frames(2); shot("b_drums_grid");
+ drum_page = 1; ui.force = 1; frames(2); shot("b_drums_kit");
+ drum_page = 0; song.sel = 0; go_home(); frames(4);
+ ui.lock_par = P_E4;
+ press(B_SEQ); frames(10);
+ fm1_in.notes = 1u << key_of_white(4); frames(2);
+ encs[panel.enc[EN_PRESET]] = -9; frame(); encs[panel.enc[EN_PRESET]] = -9; frame();
+ ui.force = 1; frames(2); shot_keep("b_steps_lock");
+ fm1_in.notes = 0; frames(2); release(B_SEQ); frames(4);
+ press(B_GLO); frames(10); ui.force = 1; frames(2); shot("b_mix");
+ release(B_GLO); frames(4);
+ press(B_SAVE); frames(15);
+ key(key_of_white(0)); key(key_of_white(1)); key(key_of_white(1)); ui.force = 1; frame(); shot("b_chain");
+ release(B_SAVE); frames(4);
+ song.sel = 2; load(2, "KOTO"); open_page("EDIT 1"); frames(3); shot("b_phys");
+ song.sel = 1; load(1, "TINE EP"); open_page("EDIT 1"); frames(3); shot("b_fm6");
+ trk[1].p[P_CHORD] = 3; trk[1].p[P_ROOT] = 2;
+ go_home(); frames(2);
+ press(B_SCL); frames(12); ui.force = 1; frames(2); shot("b_scl"); release(B_SCL); frames(4);
+ trk[1].p[P_CHORD] = 0;
+ go_home(); frames(2); vis_open(); frames(4); vis_style = 3; ui.force = 1; frames(90); shot("b_vis");
+ vis_on = 0; go_home(); frames(4);
+ return 0;
+}
diff --git a/tests/arranger_test.c b/tests/arranger_test.c
index eebc6d0..35a8cbb 100644
--- a/tests/arranger_test.c
+++ b/tests/arranger_test.c
@@ -42,6 +42,20 @@ int main(void)
c.entry[0].bars = 65; assert(!arr_valid(&c, 15));
c.entry[0].bars = 1; c.entry[0].scene = 4; assert(!arr_valid(&c, 15));
c.entry[0].scene = 0; c.count = 17; assert(!arr_valid(&c, 15));
- puts("arranger: order, repeats, stop, loop, tempo change, fractional timing and invalid scenes PASS");
+ { /* 2.6: a section erased (SAVE > PROJECT > ERASE): the song's steps that played it out, the rest in order */
+ arr_config_t d;
+ arr_defaults(&d);
+ d.count = 5;
+ d.entry[0] = (arr_entry_t){0, 2}; d.entry[1] = (arr_entry_t){1, 4}; d.entry[2] = (arr_entry_t){0, 1};
+ d.entry[3] = (arr_entry_t){2, 8}; d.entry[4] = (arr_entry_t){1, 3};
+ assert(arr_drop_scene(&d, 1) == 1 && d.count == 3);
+ assert(d.entry[0].scene == 0 && d.entry[0].bars == 2 && d.entry[1].scene == 0 && d.entry[1].bars == 1 &&
+ d.entry[2].scene == 2 && d.entry[2].bars == 8);
+ assert(arr_valid(&d, 1u | 4u)); /* plays without the erased B */
+ assert(arr_drop_scene(&d, 3) == 0 && d.count == 3); /* not in the song: unchanged */
+ d.count = 2; d.entry[0] = (arr_entry_t){3, 2}; d.entry[1] = (arr_entry_t){3, 4};
+ assert(arr_drop_scene(&d, 3) == 1 && d.count == 4 && d.entry[0].scene == 0 && d.entry[3].scene == 3); /* none left: the default song */
+ }
+ puts("arranger: order, repeats, stop, loop, tempo change, fractional timing, invalid scenes, erased section PASS");
return 0;
}
diff --git a/tests/dsyn_test.c b/tests/dsyn_test.c
index 77cbef6..00a5315 100644
--- a/tests/dsyn_test.c
+++ b/tests/dsyn_test.c
@@ -214,6 +214,28 @@ int main(void)
}
check(pk > 0 && pk < (1 << 24), "2000 random kits (any byte the editor could send): bounded, finite");
}
+ { /* 2.6 (a whistle on the kicks): the levels glide into the next block without a step. The kick of every
+ * factory kit (not the square-wave ones), alone: its curvature (third difference) across the block edges no bigger than inside the
+ * blocks (a step of up to 31 at every edge, before: 2 to 5 times) */
+ uint32_t kk, worst_k = 0;
+ double worst = 0;
+ for (kk = 0; kk < DS_NKITS; kk++) {
+ double edge = 0, in = 0;
+ uint32_t ne = 0, ni = 0, j;
+ if (DS_KITS[kk].s[0].wave == DW_SQUARE || DS_KITS[kk].s[0].wave == DW_BELL)
+ continue; /* (square waves: their own edges everywhere) */
+ voice_render(outbuf[0], DS_KITS[kk].s, 0, 0); /* (no crush: its hold is a step of its own) */
+ for (j = 10u * CTL; j < 110u * CTL; j++) {
+ double d3 = fabs((double)outbuf[0][j] - 3.0 * outbuf[0][j - 1] + 3.0 * outbuf[0][j - 2] - outbuf[0][j - 3]);
+ if (j % CTL < 3u) edge += d3, ne++;
+ else in += d3, ni++;
+ }
+ if (in > 0 && edge / ne / (in / ni) > worst)
+ worst = edge / ne / (in / ni), worst_k = kk;
+ }
+ printf(" kick, curvature at the block edges / inside: at most %.2f (%s)\n", worst, DS_KITS[worst_k].name);
+ check(worst < 1.6, "the kicks of the synthesised kits: no step at the block edges (no whistle at 1.4 / 2.8 kHz)");
+ }
printf(fails ? "dsyn: FAILED\n" : "dsyn: all checks ok\n");
return fails;
}
diff --git a/tests/font_test.c b/tests/font_test.c
new file mode 100644
index 0000000..c9a55de
--- /dev/null
+++ b/tests/font_test.c
@@ -0,0 +1,126 @@
+/* SPDX-License-Identifier: GPL-3.0-only */
+/* The screen font (gfx.c cv_text, tools/gen_font.py). SLOOP 2.6: Terminus Bold, in capitals only, stored at 1 bit a
+ * pixel (5376 bytes instead of 21504). Checked: every character 32..255 draws exactly the BDF's pixels of its capital
+ * (assets/fonts/ter-u16b.bdf, read here); every glyph of FONT_S (1x, Latin-1) and FONT_L (2x) in several colours, at
+ * several offsets (clipped at every edge of the canvas, and with a graph y offset), hashed, and the same through the
+ * 4-bit format (anti-aliased fonts); the advance and bitmap widths (text_w: the layout of 2.5, unchanged); the data
+ * size. Exit status: the number of failed checks. */
+#include
+#define FONT_S_HASH 0x1c34aa9cu /* Terminus Bold, capitals (2.6) */
+#define FONT_L_HASH 0x730ceccbu
+#define FONT_W_HASH 0x6840d800u /* the widths of 2.5 (the regular font's): the same */
+#include
+#include
+#include
+static void lcd_sync(void) {}
+static void lcd_blit(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const uint16_t *p) { (void)x; (void)y; (void)w; (void)h; (void)p; }
+#include "../firmware/src/gfx.c"
+static int bad;
+static void check(int ok, const char *what) { printf("font: %-70s %s\n", what, ok ? "ok" : "FAIL"); bad += !ok; }
+static uint32_t hash_cv(uint32_t h)
+{
+ uint32_t i;
+ for (i = 0; i < cv_w * cv_h; i++)
+ h = (h ^ cv_px[i]) * 16777619u;
+ return h;
+}
+static uint32_t render_all(const felucca_font_t *f, uint32_t ch_hi)
+{
+ static const uint16_t COL[4] = {0xFFFFu, 0x07E0u, 0xF81Fu, 0x39E7u};
+ static const int32_t XY[6][3] = {{0, 0, 0}, {5, 3, 0}, {-3, 0, 0}, {50, -5, 0}, {52, 30, 0}, {10, 4, -9}};
+ uint32_t h = 0x811C9DC5u, c, k, i;
+ char s[2] = {0, 0};
+ for (c = f->first; c <= ch_hi; c++)
+ for (k = 0; k < 4u; k++)
+ for (i = 0; i < 6u; i++) {
+ cv_begin(64, 48, 0);
+ cv_oy = XY[i][2];
+ s[0] = (char)c;
+ cv_text(XY[i][0], XY[i][1], f, s, COL[k]);
+ cv_oy = 0;
+ h = hash_cv(h);
+ }
+ cv_begin(240, 40, 0); /* a line of text, as the pages draw it */
+ cv_text(2, 2, &FONT_S, "SLOOP 2.5 HUGELTON BPM 96 -12.5 dB", 0xFFFFu);
+ cv_text(2, 18, &FONT_S, "\xdc\xe9\xb0\xb1 kick snare", 0x07E0u);
+ return hash_cv(h);
+}
+/* the BDF's bitmaps, 16 rows of 8 pixels a character */
+static uint8_t bdf[256][16], bdf_has[256];
+static int bdf_read(const char *path)
+{
+ FILE *f = fopen(path, "r");
+ char ln[128];
+ int enc = -1, row = -1;
+ if (!f) return 0;
+ while (fgets(ln, sizeof ln, f)) {
+ unsigned v;
+ if (!strncmp(ln, "ENCODING ", 9)) enc = atoi(ln + 9), row = -1;
+ else if (!strncmp(ln, "BITMAP", 6)) row = 0;
+ else if (!strncmp(ln, "ENDCHAR", 7)) { if (enc >= 0 && enc < 256 && row == 16) bdf_has[enc] = 1; row = -1; }
+ else if (row >= 0 && row < 16 && enc >= 0 && enc < 256 && sscanf(ln, "%x", &v) == 1) bdf[enc][row++] = (uint8_t)v;
+ }
+ fclose(f);
+ return 1;
+}
+static uint32_t capital(uint32_t c) { return (c >= 'a' && c <= 'z') || (c >= 0xE0u && c <= 0xFEu && c != 0xF7u) ? c - 32u : c; }
+
+int main(int argc, char **argv)
+{
+ uint32_t hs = render_all(&FONT_S, 255u), hl = render_all(&FONT_L, 95u), wsum = 0, c;
+ for (c = 0; c < 224u; c++) wsum = wsum * 31u + FONT_S.adv[c] * 7u + FONT_S.bw[c];
+ for (c = 0; c < 64u; c++) wsum = wsum * 31u + FONT_L.adv[c] * 7u + FONT_L.bw[c];
+ if (argc > 1) {
+ printf("%08x %08x %08x %u\n", hs, hl, wsum, (unsigned)sizeof FONT_S_DATA);
+ return 0;
+ }
+ { /* every character: the BDF's pixels of its capital, nothing else in its 12 x 16 box */
+ uint32_t c, x, y, wrong = 0, n = 0;
+ char s[2] = {0, 0};
+ int got = bdf_read("assets/fonts/ter-u16b.bdf");
+ for (c = 32; got && c < 256u; c++) {
+ uint32_t k = capital(c);
+ if (c >= 127u && c < 160u) continue; /* (C1 controls: '?') */
+ if (!bdf_has[k]) k = '?';
+ cv_begin(12, 16, 0);
+ s[0] = (char)c;
+ cv_text(FONT_PAD, 0, &FONT_S, s, 0xFFFFu);
+ for (y = 0; y < 16u; y++)
+ for (x = 0; x < 12u; x++) {
+ int on = x >= FONT_PAD && x < FONT_PAD + 8u && ((bdf[k][y] >> (7u - (x - FONT_PAD))) & 1u);
+ wrong += (cv_px[y * 12u + x] != 0) != on;
+ }
+ n++;
+ }
+ check(got && n == 191u && wrong == 0, "every character 32..255: the Terminus Bold pixels of its capital (ter-u16b.bdf)");
+ cv_begin(240, 16, 0); cv_text(0, 0, &FONT_S, "kick snare h\xfcgelton", 0xFFFFu); x = hash_cv(1u);
+ cv_begin(240, 16, 0); cv_text(0, 0, &FONT_S, "KICK SNARE H\xdcGELTON", 0xFFFFu);
+ check(x == hash_cv(1u) && text_w(&FONT_S, "kick") == text_w(&FONT_S, "KICK"), "lower case shows as capitals, in the same place");
+ }
+ check(hs == FONT_S_HASH, "FONT_S: every glyph, 4 colours, 6 places (clipped)");
+ check(hl == FONT_L_HASH, "FONT_L (2x): every glyph, 4 colours, 6 places (clipped): S's bitmaps at 2x");
+ check(wsum == FONT_W_HASH, "advance and bitmap widths unchanged (the layout)");
+ { /* the 4-bit path (anti-aliased fonts) still draws: FONT_S unpacked to 2 pixels a byte, the same pixels */
+ static uint8_t d4[21504];
+ static uint16_t off4[224];
+ felucca_font_t s4 = FONT_S, l4 = FONT_L;
+ uint32_t g, n = 0, y, xx;
+ for (g = 0; g < 224u; g++) {
+ uint32_t w = FONT_S.bw[g], bpr = (w + 1u) / 2u;
+ off4[g] = (uint16_t)n;
+ for (y = 0; y < FONT_S.h; y++)
+ for (xx = 0; xx < w; xx++) {
+ uint32_t i = y * w + xx, on = (FONT_S_DATA[FONT_S_OFF[g] + i / 8u] >> (7u - i % 8u)) & 1u;
+ if (on)
+ d4[n + y * bpr + xx / 2u] |= (uint8_t)(xx & 1u ? 15u : 15u << 4);
+ }
+ n += FONT_S.h * bpr;
+ }
+ s4.data = l4.data = d4; s4.off = l4.off = off4; s4.bits = l4.bits = 0;
+ check(n == 21504u && render_all(&s4, 255u) == FONT_S_HASH && render_all(&l4, 95u) == FONT_L_HASH,
+ "the 4-bit format (anti-aliased fonts) still draws the same pixels");
+ }
+ check(sizeof FONT_S_DATA == 5376u && FONT_S.bits == 1u, "the Terminus bitmaps at 1 bit a pixel: 5376 bytes (21504 at 4 bits)");
+ printf("%s\n", bad ? "FONT TEST FAILED" : "font test passed");
+ return bad;
+}
diff --git a/tests/fx251_test.c b/tests/fx251_test.c
new file mode 100644
index 0000000..92af7e5
--- /dev/null
+++ b/tests/fx251_test.c
@@ -0,0 +1,633 @@
+/* SPDX-License-Identifier: GPL-3.0-only */
+/* SLOOP 2.6, after Felucca 1.4 / 1.5 (Leo Kuroshita): the sound side of what came from there.
+ * insert each INSERT type changes a part and stays bounded; TYPE OFF and MIX 0 leave it bit for bit; TYPE OFF
+ * again: dry once its fade ran; the drum track's INSERT works on its left, right and sends
+ * filter ANALOG's TYPE: LP keeps the lows, HP the highs, BP the middle
+ * esync ENV SYNC: ATK as a note value of the tempo (a quarter at 120 BPM: 0.5 s; at 60: 1 s)
+ * lfo 2 SYNC: a cycle a note value; TRIG FREE: a new phrase does not restart it; POL UNI: 0..+1
+ * mutes the drum track's live mutes: the sequencer skips a muted sound (and its ratchets), the others play
+ * learn MIDI LEARN's map: a learned CC sets its track's parameter on any channel, not the standard map; while
+ * learning a CC is handed to the UI; the CCs with a meaning of their own are never learned
+ * Exit status: the number of failed checks. */
+#include
+static uint32_t host_slots[4u * 0x14000u / 4u]; /* the user sample slots (a RAM image of the flash) */
+#define SMP_USER_XIP(k) ((const uint8_t *)host_slots + (k) * SMP_USER_SIZE)
+#define main hostsim_main
+#include "hostsim.c"
+#undef main
+#include
+static int fails;
+static void check(int ok, const char *what)
+{
+ printf("fx251: %-88s %s\n", what, ok ? "ok" : "FAIL");
+ fails += !ok;
+}
+#define NB 2000u /* blocks rendered (1.45 s) */
+static int32_t out_l[NB * CTL];
+static void render(uint32_t nb)
+{
+ static int32_t o[2u * CTL];
+ uint32_t b, i;
+ for (b = 0; b < nb; b++) {
+ mix_block(o, CTL);
+ for (i = 0; i < CTL; i++)
+ out_l[b * CTL + i] = o[2u * i];
+ }
+}
+static double rms(uint32_t a, uint32_t b)
+{
+ double e = 0;
+ uint32_t i;
+ for (i = a; i < b; i++) e += (double)out_l[i] * out_l[i];
+ return sqrt(e / (double)(b - a));
+}
+static double tone(uint32_t a, uint32_t b, double hz) /* Goertzel power */
+{
+ double w = 2 * M_PI * hz / FS, c = 2 * cos(w), s1 = 0, s2 = 0, s0;
+ uint32_t i;
+ for (i = a; i < b; i++) s0 = out_l[i] + c * s1 - s2, s2 = s1, s1 = s0;
+ return s1 * s1 + s2 * s2 - c * s1 * s2;
+}
+/* the dry reference from this very state: a child process renders nb blocks as things are (the whole state copied:
+ * the voices' phases, the buses, the random numbers) and leaves them in shared memory; this one goes on from the
+ * same state */
+static int32_t *shared_dry;
+static void fork_dry(uint32_t nb)
+{
+ pid_t pid;
+ if (!shared_dry)
+ shared_dry = mmap(0, NB * CTL * 4u, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ fflush(stdout);
+ pid = fork();
+ if (!pid) {
+ render(nb);
+ memcpy(shared_dry, out_l, nb * CTL * 4u);
+ _exit(0);
+ }
+ waitpid(pid, 0, 0);
+}
+/* a tone's level, Hann-windowed (the neighbouring harmonics leak far less than through a plain window) */
+static double tonew(uint32_t a, uint32_t b, double hz)
+{
+ double w = 2 * M_PI * hz / FS, c = 2 * cos(w), s1 = 0, s2 = 0, s0, n = (double)(b - a), h;
+ uint32_t i;
+ for (i = a; i < b; i++) {
+ h = 0.5 - 0.5 * cos(2 * M_PI * (double)(i - a) / n);
+ s0 = h * out_l[i] + c * s1 - s2, s2 = s1, s1 = s0;
+ }
+ return s1 * s1 + s2 * s2 - c * s1 * s2;
+}
+/* a clean start: the defaults, the INSERT states at rest, track 1 an ANALOG saw (no filter, no drive), nothing else */
+static void setup(void)
+{
+ uint32_t i;
+ host_tracks_init();
+ memset(ins, 0, sizeof ins);
+ for (i = 0; i < NTRK; i++) {
+ trk[i].ins_run = 0;
+ trk[i].tail = 0;
+ trk[i].p[P_REV] = trk[i].p[P_CHOR] = trk[i].p[P_DLY] = 0;
+ trk[i].p[P_LEVEL] = 100;
+ }
+ host_preset(&trk[0], 0, 0);
+ trk[0].p[P_E0] = 0, trk[0].p[P_E1] = 0, trk[0].p[P_E2] = 0, trk[0].p[P_E3] = 0; /* SAW, one oscillator */
+ trk[0].p[P_E4] = 127, trk[0].p[P_E5] = 0, trk[0].p[P_E6] = 0, trk[0].p[P_E7] = 0; /* open, no RES, DRV, KTR */
+ trk[0].p[P_ATK] = 0, trk[0].p[P_DEC] = 0, trk[0].p[P_SUS] = 127, trk[0].p[P_REL] = 0;
+ trk[0].p[P_ED_FLT] = trk[0].p[P_ED_PIT] = trk[0].p[P_ED_SHP] = 0;
+ trk[0].p[P_LD_PIT] = trk[0].p[P_LD_FLT] = trk[0].p[P_LD_SHP] = trk[0].p[P_LD_AMP] = 0;
+ trk[0].p[P_VOICE] = V_POLY, trk[0].p[P_GLIDE] = 0, trk[0].p[P_DIST] = 0, trk[0].p[P_TRANS] = 0;
+ trk[0].p[P_ED_FX] = 0;
+ for (i = 0; i < NVOICE; i++)
+ trk[0].v[i].active = 0;
+ song.playing = 0;
+ song.master_q12 = 2048;
+ texture_reset(0); /* (GLO > TEXTURE off, at rest) */
+ memset(&lim_dac, 0, sizeof lim_dac); /* (the master's one-block delay: nothing of the last render) */
+ lim_dac.env = LIM_T, lim_dac.g = 32768, lim_dac.hold = 0;
+ tx.g = 0;
+ song.g[G_TXSRC] = 0;
+}
+
+static void t_insert(void)
+{
+ static int32_t dry[NB * CTL];
+ uint32_t ty, i, same;
+ setup();
+ trk_note_on(&trk[0], 45, 100); /* A2 */
+ fork_dry(400); /* the same start (voices, buses, random numbers), TYPE OFF */
+ memcpy(dry, shared_dry, 400u * CTL * 4u);
+ trk[0].p[P_ITYPE] = 1, trk[0].p[P_IMIX] = 0; /* SOFT at MIX 0: nothing runs */
+ render(400);
+ check(!memcmp(dry, out_l, 400u * CTL * 4u) && !trk[0].ins_run, "INSERT at MIX 0: the part bit for bit as with TYPE OFF");
+ for (ty = 1; ty < IT_N; ty++) {
+ double d = 0, r;
+ int32_t mx = 0;
+ setup();
+ trk[0].p[P_ITYPE] = (int16_t)ty, trk[0].p[P_IMIX] = 127;
+ trk[0].p[P_IA] = 100, trk[0].p[P_IB] = 96, trk[0].p[P_IC] = 96;
+ trk_note_on(&trk[0], 45, 100);
+ render(400);
+ for (i = 0; i < 400u * CTL; i++) {
+ d += fabs((double)out_l[i] - dry[i]);
+ mx = abs(out_l[i]) > mx ? abs(out_l[i]) : mx;
+ }
+ r = rms(100u * CTL, 400u * CTL);
+ printf(" %-5s: rms %.0f, mean |diff| %.0f, peak %d\n", N_ITYPE[ty], r, d / (400.0 * CTL), mx);
+ check(d / (400.0 * CTL) > 50.0 && mx < 32767 && r > 200.0 && trk[0].ins_run,
+ ty == 1 ? "each INSERT type (SOFT .. CHOR) changes the part, bounded, heard" : N_ITYPE[ty]);
+ trk[0].p[P_ITYPE] = 0; /* OFF: it fades out, then the part is dry again */
+ render(4);
+ same = !trk[0].ins_run;
+ check(same, ty == 1 ? "TYPE OFF: the INSERT stops after its fade" : " (fade out)");
+ }
+ { /* the drum track: a kick on every beat through FUZZ, its left, right and sends */
+ double a, b;
+ setup();
+ song.g[G_BPM] = 120;
+ for (i = 0; i < 16u; i++)
+ if (!(i & 3u)) dstep_set(&TDRUM->dstep[i], 0, LV_NORM, 0);
+ TDRUM->p[P_SLEN] = 16;
+ TDRUM->p[P_REV] = 60;
+ transport_req = 1;
+ render(1400);
+ a = rms(0, 1400u * CTL);
+ setup();
+ for (i = 0; i < 16u; i++)
+ if (!(i & 3u)) dstep_set(&TDRUM->dstep[i], 0, LV_NORM, 0);
+ TDRUM->p[P_SLEN] = 16;
+ TDRUM->p[P_REV] = 60;
+ TDRUM->p[P_ITYPE] = 4, TDRUM->p[P_IA] = 127, TDRUM->p[P_IMIX] = 127; /* FUZZ, full drive */
+ transport_req = 1;
+ render(1400);
+ b = rms(0, 1400u * CTL);
+ printf(" drums: rms dry %.0f, FUZZ %.0f\n", a, b);
+ check(a > 100 && fabs(b - a) > 0.05 * a && TDRUM->ins_run && ins[NPART].type == 4u && ins[NPART + 2u].w,
+ "the drum track's INSERT (FUZZ): the kick changed, left / right / sends through it");
+ transport_req = 2;
+ render(4);
+ }
+}
+
+static void t_filter(void)
+{
+ /* each type's gain at 55 Hz (A1's fundamental), 660 Hz (the 12th harmonic, about the cutoff) and 3.3 kHz (the
+ * 60th) against the same saw unfiltered (TYPE LP, cutoff fully open), from the same start (fork_dry) */
+ static const double HZ[3] = {55, 660, 3300};
+ double g[3][3], d[3];
+ uint32_t a = 200u * CTL, b = 600u * CTL, ty, k;
+ for (ty = 0; ty < 3u; ty++) {
+ setup();
+ trk[0].p[P_E4] = 127;
+ trk_note_on(&trk[0], 33, 100); /* A1 (55 Hz): a saw, every harmonic */
+ fork_dry(600);
+ trk[0].p[P_E4] = 64, trk[0].p[P_FTYPE] = (int16_t)ty; /* cutoff ~ 650 Hz; LP BP HP */
+ render(600);
+ for (k = 0; k < 3u; k++)
+ g[ty][k] = 10 * log10(tonew(a, b, HZ[k]));
+ memcpy(out_l, shared_dry, 600u * CTL * 4u);
+ for (k = 0; k < 3u; k++) {
+ d[k] = 10 * log10(tonew(a, b, HZ[k]));
+ g[ty][k] -= d[k];
+ }
+ printf(" %s: 55 Hz %+.1f dB, 660 Hz %+.1f dB, 3.3 kHz %+.1f dB\n", N_FTYPE[ty], g[ty][0], g[ty][1], g[ty][2]);
+ }
+ /* two poles: 12 dB an octave (LP, HP), 6 on each side (BP); 3.3 kHz is 2.3 octaves over the cutoff, 55 Hz 3.6 under */
+ check(g[0][2] < -20 && g[2][0] < -30 && g[2][2] > -3,
+ "ANALOG filter TYPE: LP keeps the lows (3.3 kHz 20 dB down), HP the highs (55 Hz 30 dB down)");
+ check(g[1][1] > g[1][0] + 12 && g[1][1] > g[1][2] + 6, "ANALOG filter TYPE BP: the middle over both ends");
+ check(g[0][0] > -1.5 && g[0][0] < 1.5, " (LP below its cutoff: as the open filter, within 1.5 dB)");
+}
+
+static void t_esync(void)
+{
+ uint32_t b, k, vi, bpm, want[2] = {0, 0}, got[2] = {0, 0};
+ for (k = 0; k < 2u; k++) {
+ bpm = k ? 60u : 120u;
+ setup();
+ song.g[G_BPM] = (int16_t)bpm;
+ trk[0].p[P_ESYNC] = 1;
+ trk[0].p[P_ATK] = (int16_t)((14 * 128 + 24) / 25); /* 1/4 */
+ trk_note_on(&trk[0], 57, 100);
+ for (vi = 0; vi + 1u < NVOICE && !(trk[0].v[vi].active && trk[0].v[vi].note == 57u); vi++)
+ ;
+ for (b = 0; b < 3000u && trk[0].v[vi].stage == 1u; b++)
+ render(1);
+ got[k] = b;
+ want[k] = (uint32_t)FS * 60u / bpm / CTL;
+ }
+ printf(" ENV SYNC ATK 1/4: %u blocks at 120 BPM (%u), %u at 60 (%u)\n", got[0], want[0], got[1], want[1]);
+ check(esync_idx((14 * 128 + 24) / 25) == 14u && !strcmp(ESYNC_NAMES[14], "1/4"), "ENV SYNC: value 72 is 1/4");
+ check(abs((int)got[0] - (int)want[0]) <= 2 && abs((int)got[1] - (int)want[1]) <= 2,
+ "ENV SYNC: the attack lasts a quarter note at 120 BPM and at 60");
+}
+
+static void t_lfo2(void)
+{
+ uint32_t b, wraps = 0, old;
+ int32_t lo = 99999;
+ setup();
+ song.g[G_BPM] = 120;
+ trk[0].p[P_LSYNC] = 5; /* 1/4: a cycle a beat (0.5 s) */
+ trk[0].p[P_LRATE] = 0;
+ trk_note_on(&trk[0], 57, 100);
+ old = trk[0].lfo_ph;
+ for (b = 0; b < (uint32_t)FS * 2u / CTL; b++) { /* 2 s */
+ render(1);
+ wraps += trk[0].lfo_ph < old;
+ old = trk[0].lfo_ph;
+ }
+ check(wraps == 4u, "LFO 2 SYNC 1/4: four cycles in two seconds at 120 BPM, whatever RATE");
+ setup();
+ trk[0].p[P_LTRIG] = 1; /* FREE */
+ trk[0].lfo_ph = 0x12345678u;
+ trk_note_on(&trk[0], 57, 100);
+ check(trk[0].lfo_ph == 0x12345678u, "LFO 2 TRIG FREE: a new phrase leaves the phase where it is");
+ trk[0].p[P_LTRIG] = 0;
+ trk_note_off(&trk[0], 57);
+ render(20);
+ for (b = 0; b < NVOICE; b++) trk[0].v[b].active = trk[0].v[b].gate = 0;
+ trk_note_on(&trk[0], 57, 100);
+ check(trk[0].lfo_ph == (uint32_t)trk[0].p[P_LPHASE] << 25, "LFO TRIG NOTE (as before): a new phrase restarts it");
+ trk[0].p[P_LPOL] = 1; /* UNI */
+ trk[0].p[P_LRATE] = 100;
+ for (b = 0; b < 3000u; b++) {
+ render(1);
+ lo = trk[0].lfo_val < lo ? trk[0].lfo_val : lo;
+ }
+ check(lo >= 0, "LFO 2 POL UNI: the LFO stays 0..+1");
+}
+
+static uint32_t snare;
+static uint32_t kick_hits(uint32_t blocks) /* drum voices started on the kick's note (the snare's: snare) */
+{
+ uint32_t b, k, n = 0, a;
+ for (b = 0; b < blocks; b++) {
+ a = drums.age;
+ render(1);
+ if (drums.age != a)
+ for (k = 0; k < NDRUM; k++)
+ n += drums.v[k].age > a && drums.v[k].note == LANE_NOTE[0],
+ snare += drums.v[k].age > a && drums.v[k].note == LANE_NOTE[2];
+ }
+ return n;
+}
+static void t_mutes(void)
+{
+ uint32_t i, on, off, sn;
+ setup();
+ memset(&drums, 0, sizeof drums);
+ drums.set = -2;
+ for (i = 0; i < 16u; i++) {
+ dstep_set(&TDRUM->dstep[i], 0, LV_NORM, i == 4u ? 1u : 0u); /* the kick on every step, a ratchet on 5 */
+ dstep_set(&TDRUM->dstep[i], 2, LV_NORM, 0); /* the snare too */
+ }
+ TDRUM->p[P_SLEN] = 16;
+ transport_req = 1;
+ on = kick_hits(2800); /* 2 s at 120 BPM: 16 steps, one with a ratchet */
+ drum_mute = 1u << 0;
+ snare = 0;
+ off = kick_hits(2800);
+ sn = snare;
+ drum_mute = 0;
+ printf(" kick hits: %u, muted %u (the snare meanwhile: %u)\n", on, off, sn);
+ check(on >= 17u && off == 0u && sn >= 15u,
+ "the drum track's live mute: the sequencer skips the muted sound (ratchets too), the others play");
+ transport_req = 2;
+ render(4);
+}
+
+static void cc_in(uint32_t ch, uint32_t cc, uint32_t v)
+{
+ midi_in_q[mi_w % MQ] = 0x0Bu | (0xB0u | ch) << 8 | cc << 16 | v << 24;
+ mi_w++;
+ render(2);
+}
+static void t_learn(void)
+{
+ int16_t f0;
+ setup();
+ mi_r = mi_w;
+ song.g[G_ROUTE] = 0;
+ ml_tab[0] = (uint16_t)(20u | 1u << 7 | (P_DIST + 1u) << 9); /* CC 20 -> track 2 DST */
+ ml_tab[1] = (uint16_t)(74u | 0u << 7 | (ML_E0 + 4u) << 9); /* CC 74 -> track 1 E5 (ANALOG CUT) */
+ trk[1].p[P_DIST] = 0;
+ cc_in(5, 20, 127); /* channel 6 (the selected track's): anywhere */
+ check(trk[1].p[P_DIST] == TP[P_DIST].max, "MIDI LEARN: CC 20 on any channel sets track 2's DST (the learned one)");
+ f0 = trk[0].p[P_TFLT];
+ cc_in(0, 74, 0);
+ check(trk[0].p[P_E4] == ENGINES[0]->edit[4].min && trk[0].p[P_TFLT] == f0,
+ "MIDI LEARN: a learned CC 74 sets its parameter, not the standard map's FILTER");
+ ml_arm = 1, ml_heard = 0;
+ trk[1].p[P_DIST] = 5;
+ cc_in(0, 20, 99);
+ check(ml_heard == 21u && trk[1].p[P_DIST] == 5, "while learning: the CC goes to the UI (ml_heard), nothing is set");
+ ml_arm = 0, ml_heard = 0;
+ check(!ml_free_cc(1) && !ml_free_cc(64) && !ml_free_cc(0) && !ml_free_cc(121) && ml_free_cc(20) && ml_free_cc(74),
+ "MIDI LEARN: mod wheel, sustain, bank select, the channel modes never learned");
+ check(ml_id(P_DIST + 1u) == P_DIST && ml_id(ML_E0 + 7u) == P_E7 && ml_id(ML_E0 + 8u) == P_COUNT && ml_id(0) == P_COUNT,
+ "MIDI LEARN: an entry's code -> its parameter (an unknown one: none)");
+ memset((void *)ml_tab, 0, sizeof ml_tab);
+ mi_r = mi_w;
+}
+
+/* TEXTURE (GLO > TEXTURE): off it changes nothing; each source heard, bounded, no offset; WHEN; MOVE; TONE; a user slot
+ * looped */
+static void tx_set(int32_t src, int32_t lvl, int32_t tone, int32_t move, int32_t rate, int32_t when, int32_t duck)
+{
+ song.g[G_TXSRC] = (int16_t)src, song.g[G_TXLVL] = (int16_t)lvl, song.g[G_TXTONE] = (int16_t)tone;
+ song.g[G_TXMOVE] = (int16_t)move, song.g[G_TXRATE] = (int16_t)rate, song.g[G_TXWHEN] = (int16_t)when;
+ song.g[G_TXDUCK] = (int16_t)duck;
+}
+static void t_texture(void)
+{
+ uint32_t s, i, ok = 1, b;
+ double r, m;
+ int32_t pk;
+ setup();
+ tx_set(0, 64, 0, 0, 2, 1, 0);
+ trk_note_on(&trk[0], 45, 100);
+ fork_dry(300);
+ tx_set(1, 0, 0, 0, 2, 1, 0); /* VINYL at LEVEL 0: nothing either */
+ render(300);
+ check(!memcmp(shared_dry, out_l, 300u * CTL * 4u) && !tx.g, "TEXTURE OFF (or LEVEL 0): the mix bit for bit as without");
+ for (s = 1; s <= 6u; s++) { /* each source alone, ALWAYS (stopped), LEVEL 64, no MOVE */
+ setup();
+ tx_set((int32_t)s, 64, 0, 0, 2, 1, 0);
+ render(NB);
+ r = rms(400u * CTL, NB * CTL);
+ for (m = 0, pk = 0, i = 400u * CTL; i < NB * CTL; i++)
+ m += out_l[i], pk = abs(out_l[i]) > pk ? abs(out_l[i]) : pk;
+ m /= (double)(NB - 400u) * CTL;
+ printf(" TEXTURE %-6s: rms %.0f (%.1f dBFS), mean %.0f, peak %d\n", N_TXSRC[s], r, 20 * log10(r / 32768), m, pk);
+ ok &= r > 250 && r < 2500 && fabs(m) < 0.2 * r + 30 && pk < 30000;
+ }
+ check(ok, "TEXTURE: VINYL TAPE RAIN WIND RADIO ROOM heard (LEVEL 64: -40 .. -22 dBFS rms), bounded, no offset");
+ setup();
+ fork_dry(200); /* (the same start, TEXTURE off) */
+ tx_set(2, 127, 0, 0, 2, 0, 0); /* TAPE, WHEN PLAY, stopped: nothing; ALWAYS: heard */
+ render(200);
+ ok = !memcmp(shared_dry, out_l, 200u * CTL * 4u);
+ song.g[G_TXWHEN] = 1;
+ render(200);
+ printf(" TEXTURE WHEN ALWAYS (stopped): rms %.0f\n", rms(100u * CTL, 200u * CTL));
+ check(ok && rms(100u * CTL, 200u * CTL) > 500, "TEXTURE WHEN PLAY: nothing while stopped; ALWAYS: plays");
+ { /* MOVE 127 over 1BAR at 120 BPM (2 s): the level breathes */
+ double lo = 1e9, hi = 0, q;
+ setup();
+ song.g[G_BPM] = 120;
+ tx_set(2, 100, 0, 127, 0, 1, 0);
+ render(NB);
+ for (b = 0; b + 172u <= NB; b += 172u) { /* (a quarter of a second) */
+ q = rms(b * CTL, (b + 172u) * CTL);
+ lo = q < lo ? q : lo, hi = q > hi ? q : hi;
+ }
+ printf(" TEXTURE MOVE 127: a quarter second's rms %.0f .. %.0f\n", lo, hi);
+ check(hi > 2.0 * lo, "TEXTURE MOVE: the level breathes over RATE (x2 and more at MOVE 127)");
+ }
+ { /* TONE: left a low-pass, right a high-pass (TAPE: its 8 kHz vs 200 Hz) */
+ double hl[3], ll[3];
+ int32_t T[3] = {-50, 0, 50};
+ for (s = 0; s < 3u; s++) {
+ setup();
+ tx_set(2, 100, T[s], 0, 2, 1, 0);
+ render(800);
+ hl[s] = tonew(200u * CTL, 800u * CTL, 8000), ll[s] = tonew(200u * CTL, 800u * CTL, 150);
+ }
+ printf(" TEXTURE TONE -50 / 0 / +50: 8 kHz %.1f / 0 / %.1f dB, 150 Hz %.1f / 0 / %.1f dB\n", 10 * log10(hl[0] / hl[1]),
+ 10 * log10(hl[2] / hl[1]), 10 * log10(ll[0] / ll[1]), 10 * log10(ll[2] / ll[1]));
+ check(hl[0] < 0.1 * hl[1] && ll[2] < 0.1 * ll[1], "TEXTURE TONE: left closes the highs, right the lows");
+ }
+ { /* USR1: a zone of 2000 samples looped (it goes on), a slot without one silent */
+ uint8_t *img = (uint8_t *)host_slots, *d = img + SMP_USER_DATA;
+ smp_user_hdr_t *h = (smp_user_hdr_t *)img;
+ memset(img, 0xFF, SMP_USER_SIZE);
+ memset(h, 0, sizeof *h);
+ h->magic = SMP_USER_MAGIC, h->version = 1, h->nz = 1;
+ for (i = 0; i < 1000u; i++)
+ d[i] = (i / 8u) & 1u ? 0xFFu : 0x77u; /* up a while, then down */
+ h->zone[0].off = 0, h->zone[0].n = 2000, h->zone[0].ls = 0, h->zone[0].le = 1999;
+ h->zone[0].rate = 0x8000u, h->zone[0].root16 = 60 * 16, h->zone[0].lo = 0, h->zone[0].hi = 127;
+ h->data_len = 1000;
+ smp_user_scan(0);
+ memset((uint8_t *)host_slots + SMP_USER_SIZE, 0xFF, 512);
+ smp_user_scan(1);
+ setup();
+ tx_set(TX_USR1, 100, 0, 0, 2, 1, 0);
+ render(NB);
+ r = rms((NB - 300u) * CTL, NB * CTL); /* (2000 samples at half rate: ~0.09 s; long after) */
+ setup();
+ tx_set(TX_USR1 + 1, 100, 0, 0, 2, 1, 0);
+ render(300);
+ printf(" TEXTURE USR1 looped: rms %.0f after 1.4 s; USR2 (empty) %.0f\n", r, rms(0, 300u * CTL));
+ check(r > 300 && rms(0, 300u * CTL) < 30, "TEXTURE USR1: a user slot's sample looped; an empty slot silent");
+ }
+ tx_set(0, 64, 0, 40, 2, 0, 0);
+ render(20);
+}
+
+/* 2.6: MIDI pitch bend: full up with BEND 2 is two semitones up, at BEND 12 an octave (the pitch from the waveform's
+ * period: a saw's zero crossings going down) */
+static double period_of(uint32_t a, uint32_t b)
+{
+ uint32_t i, n = 0, first = 0, last = 0;
+ for (i = a + 1u; i < b; i++)
+ if (out_l[i - 1] >= 0 && out_l[i] < 0) {
+ if (!n) first = i;
+ last = i, n++;
+ }
+ return n > 1u ? (double)(last - first) / (n - 1u) : 0;
+}
+static void t_bend(void)
+{
+ double p0, p2, p12;
+ setup();
+ trk[0].p[P_E4] = 50; /* (a darker saw: clean crossings) */
+ trk_note_on(&trk[0], 45, 100);
+ render(400);
+ p0 = period_of(100u * CTL, 400u * CTL);
+ song.g[G_BEND] = 2, trk[0].bend = 8191;
+ render(400);
+ p2 = period_of(100u * CTL, 400u * CTL);
+ song.g[G_BEND] = 12;
+ render(400);
+ p12 = period_of(100u * CTL, 400u * CTL);
+ trk[0].bend = 0;
+ render(100);
+ printf(" bend: period %.2f, full up at BEND 2 %.2f (x%.3f), at 12 %.2f (x%.3f)\n", p0, p2, p0 / p2, p12, p0 / p12);
+ check(fabs(p0 / p2 - 1.1225) < 0.01 && fabs(p0 / p12 - 2.0) < 0.02, "MIDI pitch bend: full up = BEND semitones (2: a tone, 12: an octave)");
+ song.g[G_BEND] = 2;
+}
+
+/* 2.6, clicks: a preset loaded over held notes fades them out with the old sound (voice.c sound_change); the track's
+ * FILTER and the master FILT engaging their low-pass start where the signal is (fx.c djf: the state seeded) */
+static double d2_of(uint32_t a, uint32_t b)
+{
+ double m = 0, d;
+ uint32_t i;
+ for (i = a + 2u; i < b; i++)
+ if ((d = fabs((double)out_l[i] - 2.0 * out_l[i - 1] + out_l[i - 2])) > m)
+ m = d;
+ return m;
+}
+/* 2.6: the master limiter looks one block ahead: below LIM_T the mix comes out exactly, CTL samples late; a jump to
+ * 6x is already turned down when it comes out (never above LIM_T, so never into the tanh knee hard), and the gain glides
+ * (no step from one sample to the next bigger than the signal's own); it comes back to 1 */
+static void t_limiter(void)
+{
+ static lim_t s;
+ static int32_t l[CTL], r[CTL], hist[CTL * 2500];
+ uint32_t b, i, nh = 0, exact = 1;
+ int32_t pk = 0, pre = 0;
+ memset(&s, 0, sizeof s), s.env = LIM_T, s.g = 32768;
+ for (b = 0; b < 2500u; b++) {
+ for (i = 0; i < CTL; i++) {
+ uint32_t k = b * CTL + i;
+ int32_t x = (int32_t)(10000.0 * sin(k * 0.05));
+ if (b >= 100u && b < 140u)
+ x *= 10; /* 100000: 5.5x LIM_T */
+ l[i] = x, r[i] = -x;
+ hist[nh++] = x;
+ }
+ lim_block(&s, l, r, CTL);
+ for (i = 0; i < CTL; i++) {
+ uint32_t k = b * CTL + i;
+ int32_t want = k >= CTL ? hist[k - CTL] : 0, a = l[i] < 0 ? -l[i] : l[i];
+ if (b < 99u && (l[i] != want || r[i] != -want))
+ exact = 0;
+ if (a > pk)
+ pk = a;
+ if (b == 100u && i == CTL - 1u)
+ pre = a; /* (the last sample before the loud ones come out) */
+ }
+ }
+ printf(" limiter: peak out %d (LIM_T %d), before the jump %d, gain at the end %d\n", pk, LIM_T, pre, s.g);
+ check(exact && pk <= LIM_T + 8 && s.g == 32768,
+ "master limiter: below LIM_T exact (one block late); a 5.5x jump never above LIM_T; back to 1 after");
+}
+/* 2.6 (a whistle on loud basses): a held bass over LIM_T, 41 Hz (a period of 34 blocks): once it has settled, one
+ * gain for the whole note (the hold), and each sample exactly x * g >> 15 (no 12-bit cut) */
+static void t_limiter_bass(void)
+{
+ static lim_t s;
+ static int32_t l[CTL], r[CTL], hist[CTL * 600];
+ uint32_t b, i, nh = 0, exact = 1, gmin = 32768, gmax = 0;
+ int32_t g0;
+ memset(&s, 0, sizeof s), s.env = LIM_T, s.g = 32768;
+ for (b = 0; b < 600u; b++) {
+ for (i = 0; i < CTL; i++) {
+ uint32_t k = b * CTL + i;
+ int32_t x = (int32_t)(36000.0 * sin(k * 2.0 * 3.14159265358979 * 41.0 / FS) + 377.0 * sin(k * 0.9));
+ l[i] = x, r[i] = x;
+ hist[nh++] = x;
+ }
+ g0 = s.g;
+ lim_block(&s, l, r, CTL);
+ if (b >= 200u) {
+ if ((uint32_t)s.g < gmin) gmin = (uint32_t)s.g;
+ if ((uint32_t)s.g > gmax) gmax = (uint32_t)s.g;
+ for (i = 0; i < CTL && g0 == s.g; i++) { /* (a block at one gain) */
+ int32_t x = hist[b * CTL + i - CTL];
+ if (l[i] != (int32_t)(((int64_t)x * s.g) >> 15))
+ exact = 0;
+ }
+ }
+ }
+ printf(" limiter, held bass 2x LIM_T: gain %u..%u over 400 blocks\n", gmin, gmax);
+ check(gmax - gmin <= 4u && gmin < 32768u && exact,
+ "master limiter: a held loud bass keeps its gain (within 0.01 %: the hold), samples at full precision");
+}
+/* 2.6, after Felucca 1.5.1: REV THROW / ECHO THROW. Every send at 0: the tail after a short note is the dry release
+ * only; with the THROW held, the reverb (the echo) rings on after it; the song's sends and FDBK never change */
+static void t_throw(void)
+{
+ double dry, rv, ec;
+ int16_t fb0 = song.g[G_DFDBK];
+ setup();
+ song.g[G_DFDBK] = 0;
+ thr_req = 0, thr_rev = thr_dly = 0;
+ trk_note_on(&trk[0], 45, 100), render(60), trk_note_off(&trk[0], 45), render(400);
+ dry = rms(300u * CTL, 400u * CTL); /* (the release is 0: what rings after it is the sends') */
+ setup();
+ song.g[G_DFDBK] = 0;
+ thr_req = 1;
+ trk_note_on(&trk[0], 45, 100), render(60), trk_note_off(&trk[0], 45), render(400);
+ rv = rms(300u * CTL, 400u * CTL);
+ setup();
+ song.g[G_DFDBK] = 0;
+ thr_req = 2;
+ trk_note_on(&trk[0], 45, 100), render(60), trk_note_off(&trk[0], 45), render(400);
+ ec = rms(300u * CTL, 400u * CTL);
+ thr_req = 0;
+ render(100);
+ printf(" THROW: tail rms dry %.0f, REV THROW %.0f, ECHO THROW %.0f; the glide back %d %d\n", dry, rv, ec, thr_rev, thr_dly);
+ check(rv > 5 * dry + 50 && ec > 5 * dry + 50 && !thr_rev && !thr_dly && trk[0].p[P_REV] == 0 && trk[0].p[P_DLY] == 0 &&
+ song.g[G_DFDBK] == 0, "REV / ECHO THROW: the sends full while held (a tail rings), back after; nothing changed");
+ song.g[G_DFDBK] = fb0;
+}
+static void t_clicks(void)
+{
+ static const uint8_t E[5][3] = {{0, 2, 7}, {7, 0, 3}, {2, 3, 1}, {3, 4, 1}, {9, 7, 2}}; /* engine, from, to */
+ double worst = 0, base, sw;
+ uint32_t k;
+ for (k = 0; k < 5u; k++) {
+ setup();
+ host_preset(&trk[0], E[k][0], E[k][1]);
+ trk[0].p[P_LEVEL] = 100;
+ trk_note_on(&trk[0], 48, 110), trk_note_on(&trk[0], 55, 110), trk_note_on(&trk[0], 60, 110);
+ render(360);
+ base = d2_of(260u * CTL, 360u * CTL);
+ sound_change(&trk[0]); /* as ui.c apply_preset_to */
+ host_preset_req(&trk[0], E[k][0], E[k][2]);
+ panic_req |= 1u;
+ for (sw = 0, k = k; sw == 0; ) {
+ uint32_t b;
+ for (b = 0; b < 20u; b++) {
+ fm6_poll();
+ render(1);
+ sw = d2_of(0, CTL) > sw ? d2_of(0, CTL) : sw;
+ }
+ }
+ if (sw / (base + 50) > worst)
+ worst = sw / (base + 50);
+ }
+ printf(" a preset over held notes: the switch's worst sample step %.1f x the note's own\n", worst);
+ check(worst < 1.5, "a preset loaded over held notes: they fade out with their own sound (no click: WHEEL, PHASE, FM6..)");
+ {
+ double lp, ms;
+ setup();
+ host_preset(&trk[0], 0, 2);
+ trk[0].p[P_LEVEL] = 110;
+ trk_note_on(&trk[0], 40, 120);
+ render(360);
+ base = d2_of(260u * CTL, 360u * CTL);
+ trk[0].p[P_TFLT] = -1;
+ render(5);
+ lp = d2_of(0, 5u * CTL);
+ song.g[G_FILT] = -1;
+ render(5);
+ ms = d2_of(0, 5u * CTL);
+ trk[0].p[P_TFLT] = 0, song.g[G_FILT] = 0;
+ render(200);
+ printf(" low-pass engaged under a note: track FILTER %.0f, master FILT %.0f (the note's own %.0f)\n", lp, ms, base);
+ check(lp < 1.5 * base + 100 && ms < 1.5 * base + 100, "track FILTER / master FILT engaging their low-pass: no click");
+ }
+}
+
+int main(void)
+{
+ setvbuf(stdout, 0, _IONBF, 0);
+ t_insert();
+ t_filter();
+ t_esync();
+ t_lfo2();
+ t_mutes();
+ t_learn();
+ t_texture();
+ t_bend();
+ t_clicks();
+ t_limiter();
+ t_limiter_bass();
+ t_throw();
+ printf("fx251: %s\n", fails ? "FAILED" : "all checks ok");
+ return fails;
+}
diff --git a/tests/golden.txt b/tests/golden.txt
index e4e446d..30a8b62 100644
--- a/tests/golden.txt
+++ b/tests/golden.txt
@@ -1,184 +1,184 @@
# FELUCCA golden renders (tests/regress.c): name, FNV-1a 64 of the output samples.
# Rewritten by GOLDEN_UPDATE=1 tests/run_tests.sh -- only for an intended change of the sound.
-preset/ANALOG/00_808_BOOM 95160965e9586d4c
-preset/ANALOG/01_808_DIRTY a9a68b98f7821730
-preset/ANALOG/02_SUB_BASS 723f001d6d398860
-preset/ANALOG/03_808_SLIDE 38193b88b06ada48
-preset/ANALOG/04_ACID_303 43cd57593ffbfbfb
-preset/ANALOG/05_PLUGG_BASS c20971a9ad127518
-preset/ANALOG/06_REESE 6122d47f12248ac2
-preset/ANALOG/07_WOBBLE 0f4beb06428ee2a4
-preset/ANALOG/08_FUNK_BASS 0c905d65e474fa04
-preset/ANALOG/09_G-FUNK_LD 1c0f60add93a7eb2
-preset/ANALOG/10_TRAP_PLUCK 5d4f83b0d8723ba0
-preset/ANALOG/11_SYN_BRASS d202ddcdd3787e1d
-preset/ANALOG/12_SUPERSAW 56effbfc36757523
-preset/ANALOG/13_WARM_PAD c8b16c5c9663e8fb
-preset/ANALOG/14_DARK_STR 07934394fc75a7ea
-preset/ANALOG/15_ATMOS_PAD fed64f53196e6eea
-preset/ANALOG/16_PAN_FLUTE 48bf8d7238f6d9fe
-preset/ANALOG/17_FAT_LEAD 296c6ebfa7d3d06e
-preset/ANALOG/18_MONO_BASS 05e7a0e2b483e595
-preset/ANALOG/19_PWM_LEAD 7d2d0a932d107a18
-preset/ANALOG/20_SAW_BASS 108034111b2622c2
-preset/ANALOG/21_SINE_PAD e72bbcbe4987db3a
-preset/DIGITAL/00_RHODES 60c189088df3e06e
-preset/DIGITAL/01_DX_RHODES d9546039e9e7f550
-preset/DIGITAL/02_WURLI fe95c9da00cf943b
-preset/DIGITAL/03_CLAV e94654f2708debf3
-preset/DIGITAL/04_M1_PIANO fd16f31fb42b2e59
-preset/DIGITAL/05_AFRO_KEYS 99570fa6592d9c32
-preset/DIGITAL/06_TRAP_BELL 94294084a843bd23
-preset/DIGITAL/07_MUSIC_BOX 0d9ad76322596f92
-preset/DIGITAL/08_MARIMBA cf4718d7419a19a6
-preset/DIGITAL/09_KALIMBA fc91fb9d133474a9
-preset/DIGITAL/10_PLUGG_BELL 804da7b2183e88eb
-preset/DIGITAL/11_GLASS_PAD 2bee019d27328b53
-preset/DIGITAL/12_FM_BASS 12442f05f823cd72
-preset/DIGITAL/13_STEEL_DRUM d26049899cf1ffd3
-preset/DIGITAL/14_GLOCKEN 7f170a123cbb3f77
-preset/DIGITAL/15_CELESTA c42bc241c8b520cb
-preset/DIGITAL/16_XYLOPHONE a04a5bce18744882
-preset/DIGITAL/17_HARP 4ca911b8af15d220
-preset/DIGITAL/18_BASS_GTR e70897f50f4ebe8d
-preset/DIGITAL/19_TUBE_BELL 85c8d695ea6f1377
-preset/DIGITAL/20_FM_PLUCK 21efe70b62f0d8cf
-preset/DIGITAL/21_FM_GRAND 520ceead3c5ed6bd
-preset/PHASE/00_CZ_BASS 61834880fd4c62c1
-preset/PHASE/01_SOFT_KEYS 7bd6564d4a467922
-preset/PHASE/02_CZ_STRING 94bfd104e47ad00a
-preset/PHASE/03_RESO_PLUCK 0f46c3e6fb6a0c15
-preset/PHASE/04_CZ_BRASS 976932290260ba88
-preset/PHASE/05_CZ_LEAD d7eca410c2b2b875
-preset/PHASE/06_CZ_PAD 80e0363b9b65e426
-preset/PHASE/07_CZ_RESO 1e72f7045df2251b
-preset/LOFI/00_GAME_LEAD 08bf06c453f8d75d
-preset/LOFI/01_GB_BASS 6166ea163b947d30
-preset/LOFI/02_8BIT_ARP d8b0cdf87adf86fd
-preset/LOFI/03_NES_BASS 4fe086b54fc061da
-preset/LOFI/04_CHIP_CHORD a00104dd4ab07cda
-preset/LOFI/05_1BIT_BEEP b30212a195a3bfc2
-preset/LOFI/06_WAVE_LEAD 1171da4749eb93ad
-preset/LOFI/07_CHIP_NOISE 90f12d512d8b311a
-preset/SAMPLE/00_GRAND_PNO 1d423f0196760b62
-preset/SAMPLE/01_UP_BASS acc2343761723048
-preset/SAMPLE/02_VIBES e9fbb6e77e6ea323
-preset/SAMPLE/03_HORN_STAB 86ad5792a6a14110
-preset/SAMPLE/04_STRING_STB 3571698fc2d40575
-preset/SAMPLE/05_LOFI_FLUTE 6e8af43ec7b7eb5a
-preset/SAMPLE/06_SCRATCH 8a8ea8f053f6b12c
-preset/SAMPLE/07_GM_KIT 93cf54cc9ce1b3eb
-preset/SAMPLE/08_DUSTY_PNO 09e1054d55016792
-preset/SAMPLE/09_LOFI_KEYS b8b2f34b7c13a74c
-preset/SAMPLE/10_DEEP_BASS 2ed98556d0c8f8c0
-preset/VOICE/00_CHOIR_AAH a18a3302a4262df3
-preset/VOICE/01_SOUL_OOH 3a32f3f98bb7c53c
-preset/VOICE/02_TALKBOX 63391ec983ba555a
-preset/VOICE/03_WOW_BASS a5c7eb7d5c72c7c4
-preset/VOICE/04_HARMONICA cc90831f2dd680c6
-preset/VOICE/05_ROBOT a58e5ff2eef39f3d
-preset/VOICE/06_VOX_PAD 3cf3a2e867fdc499
-preset/TRIO/00_FAT_BASS 80cd6f01bea4a7e8
-preset/TRIO/01_MIN_STAB ce74ef867fc8519a
-preset/TRIO/02_MIN7_STAB 947232b904129296
-preset/TRIO/03_RAVE_STAB 1f62d8cf9f7f965b
-preset/TRIO/04_DUB_CHORD c438b86f5e8a9e95
-preset/TRIO/05_SAW_PAD bc9484fb7c387adc
-preset/TRIO/06_SYNC_LEAD 4c3eeee5b8473807
-preset/TRIO/07_HOOVER f9f00233fbbc0f0c
-preset/TRIO/08_ACCORDION 24ceb1be2b930b0c
-preset/TRIO/09_ENSEMBLE 7674ef43d854ba18
-preset/TRIO/10_80S_POLY be002624eb5cb55f
-preset/TRIO/11_SQR_LEAD 227ba26cc8f3d775
-preset/TRIO/12_POWER_STAB d15994e3165f5715
-preset/TRIO/13_PULSE_PAD f0530040b325665c
-preset/WHEEL/00_SOUL_ORGAN 06b0cf5ac4107e68
-preset/WHEEL/01_GOSPEL e4b4015b89a37000
-preset/WHEEL/02_JAZZ_ORGAN 3ee1dbcf0e3f697d
-preset/WHEEL/03_DIRTY_B3 596a084ed7f260b7
-preset/WHEEL/04_HOUSE_ORGN 2472aa521901c9a0
-preset/WHEEL/05_ROCK_ORGAN 8ce659f9eb7bf0d5
-preset/WHEEL/06_CHAPEL ddacdc3676893e56
-preset/WHEEL/07_REGGAE_ORG 538338278050b0ef
-preset/GRAIN/00_LOFI_CLOUD ec0140076bcf40e0
-preset/GRAIN/01_VIBE_HAZE e06f202f34953a04
-preset/GRAIN/02_FLUTE_DUST d30fce9db59ccf8a
-preset/GRAIN/03_STR_CLOUD 8bc4ea9460b42213
-preset/GRAIN/04_SHIMMER 4de23e1f658d5aed
-preset/GRAIN/05_DRONE 4443fd28f498455d
-preset/GRAIN/06_PNO_FREEZE b329ed272c1d4f5b
-preset/GRAIN/07_HORN_CLOUD 0fc861c395f0d41c
-preset/FM6/00_TINE_EP 88ca19323e344957
-preset/FM6/01_GLASS_BELL f8dc8b413f02de3a
-preset/FM6/02_ROUND_BASS a5dd890e76dfd172
-preset/FM6/03_BRASS_SECT f694d1e371f5c3b6
-preset/FM6/04_SOFT_PAD 1599c46e2d666958
-preset/FM6/05_WOOD_BARS 139331704d47b85d
-preset/FM6/06_DRAWBARS 30ee2b55320be934
-preset/FM6/07_NYLON_PICK 3186e4cb1ae97ed9
-preset/PHYS/00_BELL_TREE 1456e969dbef4753
-preset/PHYS/01_MODAL_BAR 9b4b026bbf3d9f2c
-preset/PHYS/02_STR_PLUCK e5fbd0a9d1f447ed
-preset/PHYS/03_BOWED_MTL 536387efd33267fe
-preset/PHYS/04_THUMB_PNO c148fd94b955c9c1
-preset/PHYS/05_HAND_DRUM 1334679dd508bcc7
-preset/PHYS/06_MEMB_TOMS 881cb8f7e390c86d
-preset/PHYS/07_SITAR 563c92d305689a8e
-preset/PHYS/08_PHYS_HARP f0caf7b85f0762f6
-preset/PHYS/09_NYLON_GTR 56b74c5fb86a2cfe
-preset/PHYS/10_STEEL_GTR 3b0ff36037db336b
-preset/PHYS/11_MUTED_GTR 2a7fea642bc76746
-preset/PHYS/12_PLUCK_BASS 08abba734e9f35e6
-preset/PHYS/13_KOTO 6b165fddad624a9b
-preset/PHYS/14_BANJO e2c22463b028c0c3
-preset/PHYS/15_CELLO_BOW 9b85fec65f6b9bc8
-preset/PHYS/16_TANPURA 56ae64bf1c8093a3
-preset/PHYS/17_CHIMES c13e1c00b497280b
-preset/PHYS/18_BIG_BELL 868fa1a2ad281905
-preset/PHYS/19_VIBRA_BAR 9be5d1616e6a02f5
-preset/PHYS/20_GLASS_BOWL ae46f05f97948cf5
-preset/PHYS/21_STEEL_PAN dfafab4d3182134e
-preset/PHYS/22_WOOD_BLOCK 861a548a6a999ef6
-preset/PHYS/23_TABLA 42121f8de526cbbb
-preset/PHYS/24_CONGA 649674a025262a7a
-preset/PHYS/25_TIMPANI ceef2611b1b143c6
-preset/NOISE/00_WIND 4d3dc4d036b6332c
-preset/NOISE/01_RAIN 254a59e62f9b53c3
-preset/NOISE/02_NZ_ARCADE fded62b6719fdfa6
-preset/NOISE/03_NZ_METAL 9c958347e0d294a3
-preset/NOISE/04_OCEAN fba7d9780c6ba260
-preset/NOISE/05_VINYL 331b2c3f5559b7f7
-preset/NOISE/06_HISS 6b50b9cd1669b6ec
-preset/NOISE/07_RISER af6488ea9659039c
-preset/NOISE/08_NZ_SNARE 29faa76deaa2443f
-preset/NOISE/09_BITCRUSH efa3600f873fae02
-preset/NOISE/10_RADIO 848fd72c2dbe5b86
-drums/gm_kit b51b89a528da79c7
-mode/ANALOG/POLY 3d9bbe2cb28d705c
-mode/ANALOG/MONO 3775a85c90883abc
-mode/ANALOG/LEGATO 49927654920f65f8
-mode/ANALOG/UNISON f035d80622447198
-mode/DIGITAL/POLY d9546039e9e7f550
-mode/DIGITAL/MONO d8129b68bb60ee92
-mode/DIGITAL/LEGATO 7c3f9eabad671fa7
-mode/DIGITAL/UNISON 743092e219854716
-mode/VOICE/POLY a18a3302a4262df3
-mode/VOICE/MONO 430eec2a58fd4d90
-mode/VOICE/LEGATO c8065a27bdca0c69
-mode/VOICE/UNISON 2dc030880e86b6fc
-sends/ANALOG/dry eee81cb2d99648b8
-sends/ANALOG/chorus 4dc2250ab294f9a7
-sends/ANALOG/delay 3d4baec7927bd404
-sends/ANALOG/reverb f6278748dc48a949
-sends/ANALOG/all 149ef37416fe6a98
-sends/ANALOG/dist 618edc8cd906629f
-sends/DIGITAL/dry 84749584116410f8
-sends/DIGITAL/chorus 1ef915ae6a05b9a6
-sends/DIGITAL/delay 0c203f92207a92d4
-sends/DIGITAL/reverb 853d7de0c203815a
-sends/DIGITAL/all e9b66dd46add69ab
-sends/DIGITAL/dist bab5bf3705781a3d
-song/4track_mix f6a061deed818d16
-slicer/gate/ANALOG_DARK_STR d0f4d0ea68d3f777
-slicer/stut/DIGITAL_RHODES 1c3201824cef5c15
-slicer/song_gate_stut 05eb8ac7b2c736f4
+preset/ANALOG/00_808_BOOM 69d0901c64773d4c
+preset/ANALOG/01_808_DIRTY 13baa79fb0755730
+preset/ANALOG/02_SUB_BASS abdebef79fb80860
+preset/ANALOG/03_808_SLIDE 4ffca0e08379ba48
+preset/ANALOG/04_ACID_303 7b34a7bbb4d84c82
+preset/ANALOG/05_PLUGG_BASS da4ffb25aa27adf8
+preset/ANALOG/06_REESE 12bae0ba2bf32215
+preset/ANALOG/07_WOBBLE ccd93c7fac93b59c
+preset/ANALOG/08_FUNK_BASS 1d2f05993423676b
+preset/ANALOG/09_G-FUNK_LD f311076810b13436
+preset/ANALOG/10_TRAP_PLUCK 97c18830fddd545c
+preset/ANALOG/11_SYN_BRASS 763e5d7c6fccdf86
+preset/ANALOG/12_SUPERSAW 7b011debfd85e923
+preset/ANALOG/13_WARM_PAD 2d52f18b6ece5992
+preset/ANALOG/14_DARK_STR 28ced2ee15a9e75e
+preset/ANALOG/15_ATMOS_PAD 3aa962707a591993
+preset/ANALOG/16_PAN_FLUTE 286c0db55fead3cc
+preset/ANALOG/17_FAT_LEAD ef3e7318d99fb312
+preset/ANALOG/18_MONO_BASS 561f16f5eda2940c
+preset/ANALOG/19_PWM_LEAD 52b45468d9501a18
+preset/ANALOG/20_SAW_BASS 345c4dd1f0f310ec
+preset/ANALOG/21_SINE_PAD bdacce6c70aa91dc
+preset/DIGITAL/00_RHODES 421fe16e43b750a8
+preset/DIGITAL/01_DX_RHODES 6eaf3fe5e76d0308
+preset/DIGITAL/02_WURLI 766b59505a188766
+preset/DIGITAL/03_CLAV cc3238f92a9137a2
+preset/DIGITAL/04_M1_PIANO 562df51d78c2c270
+preset/DIGITAL/05_AFRO_KEYS fd9d3c8fdd2a7276
+preset/DIGITAL/06_TRAP_BELL 7a43417bb95c66e3
+preset/DIGITAL/07_MUSIC_BOX ae7dd85ba48c5c19
+preset/DIGITAL/08_MARIMBA 1afed4d945973f8c
+preset/DIGITAL/09_KALIMBA b6d7e2d695868e50
+preset/DIGITAL/10_PLUGG_BELL b2a99d2ad75cd688
+preset/DIGITAL/11_GLASS_PAD c2742b8b784fd907
+preset/DIGITAL/12_FM_BASS 52862e1e7445f4e2
+preset/DIGITAL/13_STEEL_DRUM d1eb74682165e643
+preset/DIGITAL/14_GLOCKEN 0636919143151a78
+preset/DIGITAL/15_CELESTA 1a5bad30d3f37955
+preset/DIGITAL/16_XYLOPHONE 7e6660fa87085d14
+preset/DIGITAL/17_HARP 5db832f89080cf58
+preset/DIGITAL/18_BASS_GTR 9aa5cd6c12eaa870
+preset/DIGITAL/19_TUBE_BELL 6072767f1d183b76
+preset/DIGITAL/20_FM_PLUCK 1a82523e312bcc4d
+preset/DIGITAL/21_FM_GRAND 6d3520e310a5265b
+preset/PHASE/00_CZ_BASS 0af10af70faa24f1
+preset/PHASE/01_SOFT_KEYS 1302c3907079f4a4
+preset/PHASE/02_CZ_STRING 09e82139f1fdcf12
+preset/PHASE/03_RESO_PLUCK 652f45b6e999a4e3
+preset/PHASE/04_CZ_BRASS 66aa186da039bbdd
+preset/PHASE/05_CZ_LEAD e1b036cb5107ba6a
+preset/PHASE/06_CZ_PAD 753c31dfd4e86885
+preset/PHASE/07_CZ_RESO 0899ebc55106697d
+preset/LOFI/00_GAME_LEAD 2b0101cbd336635d
+preset/LOFI/01_GB_BASS d2baabc5474103d4
+preset/LOFI/02_8BIT_ARP 806922784ebe92fd
+preset/LOFI/03_NES_BASS 45488b0a033b5ce8
+preset/LOFI/04_CHIP_CHORD e55424ac13f3ece1
+preset/LOFI/05_1BIT_BEEP e1742bf68ea67ad1
+preset/LOFI/06_WAVE_LEAD 23a2f1e11d67dfad
+preset/LOFI/07_CHIP_NOISE ca1058917a10b3b0
+preset/SAMPLE/00_GRAND_PNO d923a2cd58dd6c07
+preset/SAMPLE/01_UP_BASS ab929b7cd01d615c
+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/07_GM_KIT 13999abe5e115815
+preset/SAMPLE/08_DUSTY_PNO 3918c5839bb7a848
+preset/SAMPLE/09_LOFI_KEYS 6fa2f6b1e30b1f3d
+preset/SAMPLE/10_DEEP_BASS d68154cf4ef76038
+preset/VOICE/00_CHOIR_AAH d71bac99365842d0
+preset/VOICE/01_SOUL_OOH 54efb0da8718978f
+preset/VOICE/02_TALKBOX 21c8a39e3ffaed5a
+preset/VOICE/03_WOW_BASS 2b3e7f74138ae8a0
+preset/VOICE/04_HARMONICA 2b0c12b4331d68c6
+preset/VOICE/05_ROBOT 25af475d3031ab3d
+preset/VOICE/06_VOX_PAD f11e65a2934657c3
+preset/TRIO/00_FAT_BASS aae2a8d886288062
+preset/TRIO/01_MIN_STAB eea67a68ea470e80
+preset/TRIO/02_MIN7_STAB 3c04ebffb1f9b66b
+preset/TRIO/03_RAVE_STAB 12f9334768fa999e
+preset/TRIO/04_DUB_CHORD 5b1db563ceeab2e6
+preset/TRIO/05_SAW_PAD c3671956d48a22f5
+preset/TRIO/06_SYNC_LEAD ba69a3efce95f6dc
+preset/TRIO/07_HOOVER 1740917f80172506
+preset/TRIO/08_ACCORDION c3e77a567b85a75c
+preset/TRIO/09_ENSEMBLE 11022ca584ec6a67
+preset/TRIO/10_80S_POLY b8ad1b14065de51e
+preset/TRIO/11_SQR_LEAD d98536f9d4590375
+preset/TRIO/12_POWER_STAB aff37a8b7ce92421
+preset/TRIO/13_PULSE_PAD 30a1990d9db892cb
+preset/WHEEL/00_SOUL_ORGAN cef2bd90f0e1c34c
+preset/WHEEL/01_GOSPEL 65c1181e19719dd8
+preset/WHEEL/02_JAZZ_ORGAN 559525673e373810
+preset/WHEEL/03_DIRTY_B3 02ffafecc2a084b7
+preset/WHEEL/04_HOUSE_ORGN 1e676ba00c8e2be9
+preset/WHEEL/05_ROCK_ORGAN b1c318b9361b9cd5
+preset/WHEEL/06_CHAPEL 05ff719df9583b1b
+preset/WHEEL/07_REGGAE_ORG 2be04c3f7b04d4da
+preset/GRAIN/00_LOFI_CLOUD bda40c6aad4f1319
+preset/GRAIN/01_VIBE_HAZE 0a76ecddbe3e2211
+preset/GRAIN/02_FLUTE_DUST 5d640471862bfabd
+preset/GRAIN/03_STR_CLOUD 4bf449a155919813
+preset/GRAIN/04_SHIMMER f247719d39436922
+preset/GRAIN/05_DRONE d66c0c2ae68a36aa
+preset/GRAIN/06_PNO_FREEZE e64d7776f4704a51
+preset/GRAIN/07_HORN_CLOUD 76c412766bd79821
+preset/FM6/00_TINE_EP d140f3fe55e42633
+preset/FM6/01_GLASS_BELL 659b1cdce56b7af2
+preset/FM6/02_ROUND_BASS daf611066fa95457
+preset/FM6/03_BRASS_SECT b73c24e3c390d538
+preset/FM6/04_SOFT_PAD f1605fea2af19078
+preset/FM6/05_WOOD_BARS b8bc4acff797552b
+preset/FM6/06_DRAWBARS c731dba26e816787
+preset/FM6/07_NYLON_PICK 08f20f5ef9e920ac
+preset/PHYS/00_BELL_TREE edc6ba7c5a18080e
+preset/PHYS/01_MODAL_BAR f1efdb63f9fb7d78
+preset/PHYS/02_STR_PLUCK 9a8d92d71a1e5361
+preset/PHYS/03_BOWED_MTL e0b35c074ce5e89a
+preset/PHYS/04_THUMB_PNO 2d0f1bae79e0ca6f
+preset/PHYS/05_HAND_DRUM c63514883fe1e9df
+preset/PHYS/06_MEMB_TOMS c4bf65287922da13
+preset/PHYS/07_SITAR 9c5e4177782304b2
+preset/PHYS/08_PHYS_HARP 016d601ec02d1623
+preset/PHYS/09_NYLON_GTR 0c0c6581fccfb380
+preset/PHYS/10_STEEL_GTR 644f4d2ed5e018d6
+preset/PHYS/11_MUTED_GTR 9ff8ea386c541b51
+preset/PHYS/12_PLUCK_BASS 4574b89266e09213
+preset/PHYS/13_KOTO 35273505b119cdb7
+preset/PHYS/14_BANJO 09002b8927701730
+preset/PHYS/15_CELLO_BOW 42550aeaf1f47bc8
+preset/PHYS/16_TANPURA f2b8c85ed6ffd9cb
+preset/PHYS/17_CHIMES 1449edbcafaacf7b
+preset/PHYS/18_BIG_BELL 9b4e849f930e3473
+preset/PHYS/19_VIBRA_BAR 0ec323cb72fde185
+preset/PHYS/20_GLASS_BOWL c9cf505ecea3b8f5
+preset/PHYS/21_STEEL_PAN 50d84bb716aaa718
+preset/PHYS/22_WOOD_BLOCK 8fe5f920d2efe9e5
+preset/PHYS/23_TABLA 67b4b8b89b8f041b
+preset/PHYS/24_CONGA f8da9d4b3c9bd3c7
+preset/PHYS/25_TIMPANI b4cab8352e46bad3
+preset/NOISE/00_WIND 1b7c905854ade21e
+preset/NOISE/01_RAIN 9baef5e15ae337cb
+preset/NOISE/02_NZ_ARCADE 2e2d7b4eeaff3af6
+preset/NOISE/03_NZ_METAL 2edc99e81ffc69f9
+preset/NOISE/04_OCEAN 6d626b093f874d1d
+preset/NOISE/05_VINYL adccb64a58d666fe
+preset/NOISE/06_HISS 2bddccebfba286de
+preset/NOISE/07_RISER fcea3ada4f424206
+preset/NOISE/08_NZ_SNARE b0fe837467457eee
+preset/NOISE/09_BITCRUSH 57785f07c4efb016
+preset/NOISE/10_RADIO 7bdab4709d2209ac
+drums/gm_kit 97750328f0896d25
+mode/ANALOG/POLY 8469751e1f620a8c
+mode/ANALOG/MONO 9583d8d67d814abc
+mode/ANALOG/LEGATO 688683752bbf85f8
+mode/ANALOG/UNISON 8bb858f31b261198
+mode/DIGITAL/POLY 6eaf3fe5e76d0308
+mode/DIGITAL/MONO 05ef3c10b54c76a1
+mode/DIGITAL/LEGATO a7613f98364ceb26
+mode/DIGITAL/UNISON 762ab1e50571e207
+mode/VOICE/POLY d71bac99365842d0
+mode/VOICE/MONO 9450adb85fb70d90
+mode/VOICE/LEGATO 1a04dbc937476869
+mode/VOICE/UNISON 1fbb5b94bb4ec6fc
+sends/ANALOG/dry 8bd8ed5fdef461b8
+sends/ANALOG/chorus 54db3f297abe1ef6
+sends/ANALOG/delay b7b81d709bc097c4
+sends/ANALOG/reverb 0b9eca45667b05f9
+sends/ANALOG/all 041a19e59e693ea0
+sends/ANALOG/dist 9f8d9c59091192da
+sends/DIGITAL/dry 8dbda764d41b9db8
+sends/DIGITAL/chorus 392d686336b442c7
+sends/DIGITAL/delay a7796f5483684590
+sends/DIGITAL/reverb 054e0968f4fe10af
+sends/DIGITAL/all 89200ffa1d59426f
+sends/DIGITAL/dist 175553bf51b61037
+song/4track_mix ff4ab83a67ee9a84
+slicer/gate/ANALOG_DARK_STR 35d6d06a168b40d2
+slicer/stut/DIGITAL_RHODES 2272d80d58109e6b
+slicer/song_gate_stut 59e22f92ed7d4a31
diff --git a/tests/install_test.py b/tests/install_test.py
index a0c27e7..4fc3ab0 100644
--- a/tests/install_test.py
+++ b/tests/install_test.py
@@ -208,6 +208,10 @@ def installs():
rc, out, err = cli([p, "--yes"], dev)
ok(rc == 0 and dev.bad == 0 and dev.upgrades == 2 and dev.served == 11 and "done: the FM-1 runs FM-1_900" in out
and "100%" in out, f"install: running -> loader -> Felucca ({dev.served} reads)")
+ dev = FakeFM1(image, identity="FM-1_901", name="Clipper")
+ rc, out, err = cli([p, "--yes"], dev)
+ ok(rc == 0 and dev.bad == 0 and "done: the FM-1 runs FM-1_900" in out,
+ "install: an FM-1 under CLIPPER (port 'Clipper') -> found, SLOOP installed")
dev = FakeFM1(image, identity="ota-FM-1_900", name="Felucca Update")
rc, out, err = cli([p, "--yes"], dev)
diff --git a/tests/project_test.c b/tests/project_test.c
index 7cf96b3..394e2af 100644
--- a/tests/project_test.c
+++ b/tests/project_test.c
@@ -102,7 +102,9 @@ static int track_ok_v2(const proj_trk_t *n, const proj_trk_v2_t *o, uint32_t t)
ok &= n->p[P_SLCR] == 0 && n->p[P_SLPAT] == TP[P_SLPAT].def && n->p[P_SLRATE] == TP[P_SLRATE].def &&
n->p[P_SLDEPTH] == TP[P_SLDEPTH].def && n->p[P_CHORD] == 0;
for (k = 0; k < 8u; k++)
- ok &= n->p[P_E0 + k] == oldv(t, 45u + k);
+ ok &= pt_get(n, P_E0 + k) == oldv(t, 45u + k);
+ for (k = P_ITYPE; k < P_E0; k++)
+ ok &= pt_get(n, k) == TP[k].def;
return ok;
}
@@ -113,8 +115,10 @@ int main(void)
static project_v1_t v1;
static project_v4_t v4;
static project_t q, q2;
+ static project_v5_t v5;
static union {
- project_t v5;
+ project_t v6;
+ project_v5_t v5;
project_v4_t v4;
project_v3_t v3;
project_v2_t v2;
@@ -123,11 +127,17 @@ int main(void)
uint32_t i, t;
int bad = 0, ok;
- bad += check("layout: P_CHORD, P_TFLT, P_STRUM, P_VLEAD just before P_E0 (53), P_COUNT = format 4's + 3",
- P_CHORD + 1 == P_TFLT && P_TFLT + 1 == P_STRUM && P_STRUM + 1 == P_VLEAD && P_VLEAD + 1 == P_E0 &&
- P_E0 == 53 && P_COUNT == PROJ_NP_V4 + 3u && PROJ_NP_V4 == PROJ_NP_V3 + 1u && P_SLDEPTH + 1 == P_CHORD);
- bad += check("format 5 fits one flash object; 4 slots fit .noinit (with panel, settings, dbg, bootguard)",
- sizeof(project_t) <= 3840u && 4u * sizeof(project_t) <= 0x3D50u - 256u && sizeof(project_t) == 3840u); /* (full: a parameter more needs a new layout) */
+ bad += check("layout: P_CHORD, P_TFLT, P_STRUM, P_VLEAD, then the ten of 2.6 just before P_E0 (63), P_COUNT = format 5's + 10",
+ P_CHORD + 1 == P_TFLT && P_TFLT + 1 == P_STRUM && P_STRUM + 1 == P_VLEAD && P_VLEAD + 1 == P_ITYPE &&
+ P_LPOL + 1 == P_E0 && P_E0 == 63 && P_COUNT == PROJ_NP_V5 + 10u && PROJ_NP_V5 == PROJ_NP_V4 + 3u &&
+ PROJ_NP_V4 == PROJ_NP_V3 + 1u && P_SLDEPTH + 1 == P_CHORD);
+ bad += check("format 6 fits one flash object (3816 of 3840 bytes); 4 slots fit .noinit (with panel, settings, dbg, bootguard)",
+ sizeof(project_t) <= 3840u && 4u * sizeof(project_t) <= 0x3D50u - 256u && sizeof(project_t) == 3816u);
+ { /* every 2.6 parameter's range fits its byte */
+ uint32_t k, fits = 1;
+ for (k = P_ITYPE; k < P_E0; k++) fits &= TP[k].min >= 0 && TP[k].max <= 255;
+ bad += check("format 6: the 2.6 parameters fit a byte each (0..255)", fits);
+ }
/* format 3 (SLOOP 1.x) */
memset(&v3, 0, sizeof v3);
@@ -142,14 +152,14 @@ int main(void)
v3.sum = proj_hash(&v3, sizeof v3 - 4u);
memcpy(&buf, &v3, sizeof v3);
ok = proj_import(&q, &buf, (int)sizeof v3);
- bad += check("FUN3 -> FUN5: converted, valid format 5 slot", ok && proj_ok(&q) && q.magic == PROJ_MAGIC);
+ bad += check("FUN3 -> FUN6: converted, valid format 6 slot", ok && proj_ok(&q) && q.magic == PROJ_MAGIC);
ok = q.sel == 3 && q.g[G_SWING] == 40;
for (i = 0; i < PROJ_NG_V3; i++)
ok &= i == G_SWING || q.g[i] == (int16_t)(300 + i);
for (i = PROJ_NG_V3; i < PROJ_NG; i++)
ok &= q.g[i] == GP[i].def;
ok &= q.drdly == 0;
- bad += check("FUN3 -> FUN5: globals (swing 50 -> 40: the MPC scale), the new ones default", ok);
+ bad += check("FUN3 -> FUN6: globals (swing 50 -> 40: the MPC scale), the new ones default", ok);
ok = 1;
for (t = 0; t < NTRK; t++) {
const proj_trk_t *n = &q.t[t];
@@ -160,15 +170,15 @@ int main(void)
ok &= n->p[k] == oldv(t, k);
ok &= n->p[P_SSWING] == 40 && n->p[P_ASWING] == 80 && n->p[P_CHORD] == 0;
for (k = 0; k < 8u; k++)
- ok &= n->p[P_E0 + k] == oldv(t, PROJ_NP_V3 - 8u + k);
+ ok &= pt_get(n, P_E0 + k) == oldv(t, PROJ_NP_V3 - 8u + k);
for (k = 0; k < NLOCK; k++)
ok &= n->lock[k].step == LOCK_FREE;
for (k = 0; k < NSTEP; k++)
- ok &= n->micro[k] == 0;
- for (k = 0; k < NSTEP / 4u; k++)
- ok &= n->fill[k] == 0;
+ ok &= n->mf[k] == 0;
+ for (k = P_ITYPE; k < P_E0; k++)
+ ok &= pt_get(n, k) == TP[k].def;
}
- bad += check("FUN3 -> FUN5: parameters (P_E0.. moved), steps, drum notes -> lanes, no lock, no fill", ok);
+ bad += check("FUN3 -> FUN6: parameters (P_E0.. moved), steps, drum notes -> lanes, no lock, no fill", ok);
/* format 2, as written before the SLICER */
memset(&v2, 0, sizeof v2);
@@ -183,16 +193,16 @@ int main(void)
bad += check("FUN2 image is 2552 bytes (as stored)", sizeof v2 == 2552u);
memcpy(&buf, &v2, sizeof v2);
ok = proj_import(&q, &buf, (int)sizeof v2);
- bad += check("FUN2 -> FUN5: converted, valid format 5 slot", ok && proj_ok(&q) && q.magic == PROJ_MAGIC);
+ bad += check("FUN2 -> FUN6: converted, valid format 6 slot", ok && proj_ok(&q) && q.magic == PROJ_MAGIC);
ok = q.sel == 2;
for (i = 0; i < PROJ_NG_V2; i++)
ok &= i == G_SWING || q.g[i] == (int16_t)(500 + i);
- bad += check("FUN2 -> FUN5: globals and selected track", ok);
+ bad += check("FUN2 -> FUN6: globals and selected track", ok);
ok = 1;
for (t = 0; t < NTRK; t++)
ok &= track_ok_v2(&q.t[t], &v2.t[t], t);
- bad += check("FUN2 -> FUN5: every parameter mapped, SLICER OFF, CHORD OFF (4 tracks)", ok);
- bad += check("FUN2 -> FUN5: engine bytes kept (WHEEL 7, ANALOG 0, TRIO 6), drum 0",
+ bad += check("FUN2 -> FUN6: every parameter mapped, SLICER OFF, CHORD OFF (4 tracks)", ok);
+ bad += check("FUN2 -> FUN6: engine bytes kept (WHEEL 7, ANALOG 0, TRIO 6), drum 0",
q.t[0].engine == 7 && q.t[1].engine == 0 && q.t[2].engine == 6 && q.t[3].engine == 0 &&
str_eq(ENGINES[7]->name, "WHEEL") && str_eq(ENGINES[6]->name, "TRIO") && NENGINES > 8);
@@ -204,7 +214,7 @@ int main(void)
v4.sel = 1;
for (t = 0; t < NTRK; t++) {
for (i = 0; i < PROJ_NP_V4; i++) /* (format 4's ids: P_E0 was P_TFLT) */
- v4.t[t].p[i] = i < P_TFLT ? q.t[t].p[i] : q.t[t].p[P_E0 + i - P_TFLT];
+ v4.t[t].p[i] = i < P_TFLT ? q.t[t].p[i] : pt_get(&q.t[t], P_E0 + i - P_TFLT);
v4.t[t].engine = q.t[t].engine;
v4.t[t].preset = q.t[t].preset;
memcpy(v4.t[t].step, q.t[t].step, sizeof v4.t[t].step);
@@ -220,42 +230,89 @@ int main(void)
q2.t[0].step[3].lvl == 0x9C && q2.t[0].step[3].rat == 0x27 && dstep_lvl(&q2.t[TRK_DRUM].dstep[5], 13) == LV_GHOST &&
dstep_rat(&q2.t[TRK_DRUM].dstep[5], 13) == 2u && !memcmp(q2.g, v4.g, sizeof q2.g);
for (t = 0; t < NTRK; t++) {
- ok &= !memcmp(q2.t[t].p, v4.t[t].p, P_TFLT * 2u) && !memcmp(q2.t[t].p + P_E0, v4.t[t].p + P_TFLT, 16u) &&
+ ok &= !memcmp(q2.t[t].p, v4.t[t].p, P_TFLT * 2u) && !memcmp(q2.t[t].e, v4.t[t].p + P_TFLT, 16u) &&
q2.t[t].p[P_TFLT] == 0 && q2.t[t].p[P_STRUM] == 0 && q2.t[t].p[P_VLEAD] == 0 &&
!memcmp(q2.t[t].step, v4.t[t].step, sizeof q2.t[t].step);
for (i = 0; i < NLOCK; i++)
ok &= q2.t[t].lock[i].step == LOCK_FREE;
for (i = 0; i < NSTEP; i++)
- ok &= q2.t[t].micro[i] == 0;
- for (i = 0; i < NSTEP / 4u; i++)
- ok &= q2.t[t].fill[i] == 0;
+ ok &= q2.t[t].mf[i] == 0;
+ for (i = P_ITYPE; i < P_E0; i++)
+ ok &= pt_get(&q2.t[t], i) == TP[i].def;
}
- bad += check("FUN4 -> FUN5: as stored (levels, ratchets, lanes, engine 8; P_E0.. moved, FILTER off), zero nudges, locks free, no fill condition", ok);
+ bad += check("FUN4 -> FUN6: as stored (levels, ratchets, lanes, engine 8; P_E0.. moved, FILTER off), zero nudges, locks free, no fill condition", ok);
v4.t[2].step[1].vel ^= 1u;
memcpy(&buf, &v4, sizeof v4);
bad += check("FUN4 with a bad checksum: refused", !proj_import(&q2, &buf, (int)sizeof v4));
v4.t[2].step[1].vel ^= 1u;
- /* a FUN5 round trip: stored as is (nudges, locks, an engine added since: 8) */
+ /* a FUN5 image (SLOOP 2.4 .. 2.5, as stored) -> FUN6: by id, the 2.6 ten at their defaults, the nudges and
+ * conditions into a byte a step, a lock on P_E0.. moved with it (format 5's 53.. -> 63..) */
+ memset(&v5, 0, sizeof v5);
+ v5.magic = PROJ_MAGIC_V5;
+ v5.size = sizeof v5;
+ memcpy(v5.g, q.g, sizeof v5.g);
+ v5.sel = 2;
+ v5.drdly = 55;
+ for (t = 0; t < NTRK; t++) {
+ for (i = 0; i < PROJ_NP_V5; i++)
+ v5.t[t].p[i] = i < PROJ_NP_V5 - 8u ? (int16_t)(t * 10 + i) : (int16_t)(100 + t * 10 + i);
+ v5.t[t].engine = (uint8_t)t;
+ v5.t[t].preset = (uint8_t)(3 + t);
+ memcpy(v5.t[t].step, q.t[t].step, sizeof v5.t[t].step);
+ for (i = 0; i < NLOCK; i++)
+ v5.t[t].lock[i].step = LOCK_FREE;
+ }
+ v5.t[0].micro[3] = -32, v5.t[0].micro[4] = 31, v5.t[TRK_DRUM].micro[9] = -7;
+ v5.t[0].fill[0] = 0x09; /* steps 1 and 2: FILL ONLY, NO FILL */
+ v5.t[TRK_DRUM].fill[15] = 0x40; /* step 64: FILL ONLY */
+ v5.t[1].lock[0].step = 3, v5.t[1].lock[0].param = 53 + 1, v5.t[1].lock[0].val = 9; /* format 5's P_E1 */
+ v5.t[1].lock[1].step = 4, v5.t[1].lock[1].param = P_DIST, v5.t[1].lock[1].val = 100;
+ v5.sum = proj_hash(&v5, sizeof v5 - 4u);
+ memcpy(&buf, &v5, sizeof v5);
+ ok = proj_import(&q2, &buf, (int)sizeof v5) && proj_ok(&q2) && q2.magic == PROJ_MAGIC && q2.sel == 2 && q2.drdly == 55 &&
+ !memcmp(q2.g, v5.g, sizeof q2.g);
+ for (t = 0; t < NTRK; t++) {
+ for (i = 0; i < PROJ_NP_V5 - 8u; i++)
+ ok &= pt_get(&q2.t[t], i) == (int16_t)(t * 10 + i);
+ for (i = 0; i < 8u; i++)
+ ok &= pt_get(&q2.t[t], P_E0 + i) == (int16_t)(100 + t * 10 + PROJ_NP_V5 - 8u + i);
+ for (i = P_ITYPE; i < P_E0; i++)
+ ok &= pt_get(&q2.t[t], i) == TP[i].def;
+ ok &= q2.t[t].engine == t && q2.t[t].preset == 3 + t && !memcmp(q2.t[t].step, v5.t[t].step, sizeof v5.t[t].step);
+ }
+ ok &= pt_micro(&q2.t[0], 3) == -32 && pt_micro(&q2.t[0], 4) == 31 && pt_micro(&q2.t[TRK_DRUM], 9) == -7 &&
+ pt_micro(&q2.t[0], 5) == 0 && pt_fill(&q2.t[0], 0) == FC_FILL && pt_fill(&q2.t[0], 1) == FC_NOFILL &&
+ pt_fill(&q2.t[0], 2) == FC_NORM && pt_fill(&q2.t[TRK_DRUM], 63) == FC_FILL &&
+ q2.t[1].lock[0].param == P_E1 && q2.t[1].lock[0].val == 9 && q2.t[1].lock[1].param == P_DIST &&
+ q2.t[1].lock[2].step == LOCK_FREE;
+ bad += check("FUN5 -> FUN6: by id, the 2.6 parameters default, nudges and conditions kept, a lock on E2 moved with it", ok);
+ v5.t[3].micro[0] ^= 1;
+ memcpy(&buf, &v5, sizeof v5);
+ bad += check("FUN5 with a bad checksum: refused", !proj_import(&q2, &buf, (int)sizeof v5));
+
+ /* a FUN6 round trip: stored as is (nudges, locks, the 2.6 parameters, an engine added since: 8) */
q.t[1].engine = 8;
q.t[0].step[3].lvl = 0x9C;
q.t[0].step[3].rat = 0x27;
dstep_set(&q.t[TRK_DRUM].dstep[5], 13, LV_GHOST, 2);
- q.t[0].micro[3] = -32;
- q.t[0].micro[4] = 31;
- q.t[TRK_DRUM].micro[9] = -7;
+ pt_set_mf(&q.t[0], 3, -32, FC_FILL);
+ pt_set_mf(&q.t[0], 4, 31, FC_NOFILL);
+ pt_set_mf(&q.t[TRK_DRUM], 9, -7, 0);
q.t[0].lock[0].step = 3, q.t[0].lock[0].param = P_E0, q.t[0].lock[0].val = 2;
q.t[0].lock[1].step = 3, q.t[0].lock[1].param = P_DIST, q.t[0].lock[1].val = 100;
q.t[2].lock[23].step = 63, q.t[2].lock[23].param = P_LEVEL, q.t[2].lock[23].val = 50;
q.t[2].p[P_TFLT] = -30; /* a track FILTER (2.4) */
- q.t[0].fill[0] = 0x09; /* steps 1 and 2: FILL ONLY, NO FILL */
- q.t[TRK_DRUM].fill[15] = 0x40; /* step 64: FILL ONLY */
+ pt_set(&q.t[1], P_ITYPE, 4), pt_set(&q.t[1], P_IMIX, 90), pt_set(&q.t[TRK_DRUM], P_ITYPE, 2);
+ pt_set(&q.t[0], P_LSYNC, 5), pt_set(&q.t[0], P_ESYNC, 1), pt_set(&q.t[0], P_FTYPE, 2);
q.sum = proj_sum(&q);
memcpy(&buf, &q, sizeof q);
- bad += check("FUN5 -> FUN5: as stored (levels, ratchets, lanes, nudges, locks, fill conditions, engine 8)",
+ bad += check("FUN6 -> FUN6: as stored (levels, ratchets, lanes, nudges, locks, fill conditions, INSERT, SYNC, engine 8)",
proj_import(&q2, &buf, (int)sizeof q) && !memcmp(&q, &q2, sizeof q) && q2.t[1].engine == 8 &&
- q2.t[0].micro[3] == -32 && q2.t[0].lock[1].val == 100 && q2.t[2].lock[23].step == 63 &&
- q2.t[0].fill[0] == 0x09 && q2.t[TRK_DRUM].fill[15] == 0x40 && q2.t[2].p[P_TFLT] == -30);
+ pt_micro(&q2.t[0], 3) == -32 && pt_fill(&q2.t[0], 3) == FC_FILL && pt_micro(&q2.t[0], 4) == 31 &&
+ q2.t[0].lock[1].val == 100 && q2.t[2].lock[23].step == 63 && q2.t[2].p[P_TFLT] == -30 &&
+ pt_get(&q2.t[1], P_ITYPE) == 4 && pt_get(&q2.t[1], P_IMIX) == 90 && pt_get(&q2.t[TRK_DRUM], P_ITYPE) == 2 &&
+ pt_get(&q2.t[0], P_LSYNC) == 5 && pt_get(&q2.t[0], P_ESYNC) == 1 && pt_get(&q2.t[0], P_FTYPE) == 2);
/* damaged / wrong size */
v2.t[1].p[3]++;
@@ -266,10 +323,10 @@ int main(void)
bad += check("FUN2 with a wrong length: refused", !proj_import(&q2, &buf, (int)sizeof v2 - 2));
memcpy(&buf, &q, sizeof q);
buf.v4.magic = PROJ_MAGIC_V3;
- bad += check("FUN5 size with a FUN3 magic: refused", !proj_import(&q2, &buf, (int)sizeof q));
+ bad += check("FUN6 size with a FUN3 magic: refused", !proj_import(&q2, &buf, (int)sizeof q));
memcpy(&buf, &q, sizeof q);
- buf.v5.magic = PROJ_MAGIC_V4;
- bad += check("FUN5 size with a FUN4 magic: refused", !proj_import(&q2, &buf, (int)sizeof q));
+ buf.v6.magic = PROJ_MAGIC_V5;
+ bad += check("FUN6 size with a FUN5 magic: refused", !proj_import(&q2, &buf, (int)sizeof q));
memcpy(&buf, &v3, sizeof v3);
buf.v3.t[2].step[7].vel ^= 1u;
bad += check("FUN3 with a bad checksum: refused", !proj_import(&q2, &buf, (int)sizeof v3));
@@ -286,9 +343,9 @@ int main(void)
ok = proj_import(&q, &buf, (int)sizeof v1) && proj_ok(&q) && track_ok_v2(&q.t[0], &v1.t, 0) && q.g[5] == 705;
for (t = 1; t < NTRK; t++)
ok &= q.t[t].preset == 0xFF && q.t[t].p[P_SLCR] == 0 && q.t[t].p[P_LEVEL] == TP[P_LEVEL].def &&
- q.t[t].p[P_E0] == ENGINES[trk_def_engine(t)]->edit[0].def && q.t[t].lock[0].step == LOCK_FREE &&
+ pt_get(&q.t[t], P_E0) == ENGINES[trk_def_engine(t)]->edit[0].def && q.t[t].lock[0].step == LOCK_FREE &&
(t == TRK_DRUM ? dstep_mask(&q.t[t].dstep[0]) == 0u : q.t[t].step[0].time == ST_REST);
- bad += check("FUN1 -> FUN5: track 1 mapped, tracks 2..4 defaults", ok);
+ bad += check("FUN1 -> FUN6: track 1 mapped, tracks 2..4 defaults", ok);
/* capture / apply: the working project round trip (nudges and locks too) */
host_tracks_init();
@@ -307,6 +364,8 @@ int main(void)
step_fill_set(&trk[1], 2, FC_FILL);
step_fill_set(TDRUM, 9, FC_NOFILL);
step_fill_set(TDRUM, 63, FC_FILL);
+ trk[2].p[P_ITYPE] = 7, trk[2].p[P_IA] = 11, trk[2].p[P_IMIX] = 77, TDRUM->p[P_ITYPE] = 4; /* 2.6 */
+ trk[0].p[P_LSYNC] = 6, trk[0].p[P_LTRIG] = 1, trk[0].p[P_LPOL] = 1, trk[0].p[P_ESYNC] = 1, trk[0].p[P_FTYPE] = 1;
proj_capture(&q);
host_tracks_init();
song.g[G_DRDLY] = 0;
@@ -317,8 +376,11 @@ int main(void)
lock_find(&trk[1], 2, P_ED_FLT, 0) >= 0 && trk[1].lock[lock_find(&trk[1], 2, P_ED_FLT, 0)].val == -30 &&
lock_find(&trk[1], 2, P_E1, 0) >= 0 && lock_find(TDRUM, 9, P_DIST, 0) >= 0 && lock_find(TDRUM, 9, P_E0, 0) < 0 &&
step_fill(&trk[1], 2) == FC_FILL && step_fill(&trk[1], 3) == FC_NORM && step_fill(TDRUM, 9) == FC_NOFILL &&
- step_fill(TDRUM, 63) == FC_FILL && step_fill(TDRUM, 8) == FC_NORM;
- bad += check("the working project: capture -> apply round trip (levels, lanes, DUST, drum DLY, nudges, locks, fill conditions)", ok);
+ step_fill(TDRUM, 63) == FC_FILL && step_fill(TDRUM, 8) == FC_NORM &&
+ trk[2].p[P_ITYPE] == 7 && trk[2].p[P_IA] == 11 && trk[2].p[P_IMIX] == 77 && TDRUM->p[P_ITYPE] == 4 &&
+ trk[0].p[P_LSYNC] == 6 && trk[0].p[P_LTRIG] == 1 && trk[0].p[P_LPOL] == 1 && trk[0].p[P_ESYNC] == 1 &&
+ trk[0].p[P_FTYPE] == 1;
+ bad += check("the working project: capture -> apply round trip (levels, lanes, DUST, drum DLY, nudges, locks, fill conditions, the 2.6 parameters)", ok);
q2 = q;
q2.drdly = 0; /* a 2.4 project: the byte was 0 */
proj_apply(&q2, 0); /* (as a song section) */
@@ -326,24 +388,58 @@ int main(void)
q2.drdly = 200;
proj_apply(&q2, 1);
ok &= song.g[G_DRDLY] == 127;
- bad += check("2.5 drum DLY: kept in the byte after sel (format 5 unchanged), a 2.4 project: 0, a section sets it, 200 -> 127",
+ bad += check("2.5 drum DLY: kept in the byte after sel, a 2.4 project: 0, a section sets it, 200 -> 127",
ok && G_DRDLY == PROJ_NG && offsetof(project_t, drdly) == 8u + 2u * PROJ_NG + 1u);
+ { /* 2.6: GLO > TEXTURE in the project (and in a section); a project before it: OFF; the drum channel (a setting of
+ * the FM-1 now, GLO > MIDI) not taken from a project */
+ song.g[G_TXSRC] = 5, song.g[G_TXLVL] = 101, song.g[G_TXTONE] = -37, song.g[G_TXMOVE] = 90;
+ song.g[G_TXRATE] = 3, song.g[G_TXWHEN] = 1, song.g[G_TXDUCK] = 1, song.g[G_DRCH] = 4;
+ proj_capture(&q2);
+ song.g[G_TXSRC] = 0, song.g[G_TXLVL] = 0, song.g[G_TXTONE] = 0, song.g[G_TXMOVE] = 0;
+ song.g[G_TXRATE] = 0, song.g[G_TXWHEN] = 0, song.g[G_TXDUCK] = 0;
+ proj_apply(&q2, 1);
+ ok = song.g[G_TXSRC] == 5 && song.g[G_TXLVL] == 101 && song.g[G_TXTONE] == -37 && song.g[G_TXMOVE] == 90 &&
+ song.g[G_TXRATE] == 3 && song.g[G_TXWHEN] == 1 && song.g[G_TXDUCK] == 1 && song.g[G_DRCH] == 4;
+ song.g[G_DRCH] = 9;
+ song.g[G_TXSRC] = 0;
+ proj_apply(&q2, 0); /* a section: its texture too */
+ ok &= song.g[G_TXSRC] == 5 && song.g[G_DRCH] == 9;
+ q2.rsv[0] = 0; /* a project before 2.6 (converted): no texture */
+ proj_apply(&q2, 1);
+ ok &= song.g[G_TXSRC] == 0 && song.g[G_TXLVL] == GP[G_TXLVL].def && song.g[G_TXMOVE] == GP[G_TXMOVE].def && song.g[G_DRCH] == 9;
+ bad += check("2.6 TEXTURE: kept in a project (SRC LEVEL TONE MOVE RATE WHEN DUCK), a section sets it, an older one: OFF; "
+ "the drum channel not taken from a project", ok);
+ }
+ { /* what format 6 packs in fewer bits holds every value: the byte parameters (P_ITYPE .. P_LPOL: 0..255), TEXTURE's
+ * SRC (4 bits), WHEN and DUCK (1), RATE (a byte), LEVEL and TONE + 64 (7 bits each) */
+ uint32_t k;
+ int ok = 1;
+ for (k = PROJ_NC6; k < P_E0; k++)
+ ok &= TP[k].min >= 0 && TP[k].max <= 255;
+ ok &= GP[G_TXSRC].min >= 0 && GP[G_TXSRC].max <= 15 && GP[G_TXWHEN].min >= 0 && GP[G_TXWHEN].max <= 1 &&
+ GP[G_TXDUCK].min >= 0 && GP[G_TXDUCK].max <= 1 && GP[G_TXRATE].min >= 0 && GP[G_TXRATE].max <= 255 &&
+ GP[G_TXLVL].min >= 0 && GP[G_TXLVL].max <= 127 && GP[G_TXTONE].min >= -64 && GP[G_TXTONE].max <= 63;
+ bad += check("format 6: the byte parameters and TEXTURE's packed fields hold every value of their range", ok);
+ }
/* a damaged image: a nudge out of range, a lock on a parameter that cannot lock, on a step past the end,
* with a value past the range: clamped, freed, freed, clamped */
- q.t[1].micro[7] = 100;
- q.t[1].micro[8] = -100;
q.t[1].lock[5].step = 4, q.t[1].lock[5].param = P_SLEN, q.t[1].lock[5].val = 8;
q.t[1].lock[6].step = 64, q.t[1].lock[6].param = P_E0, q.t[1].lock[6].val = 1;
q.t[1].lock[7].step = 4, q.t[1].lock[7].param = P_LEVEL, q.t[1].lock[7].val = 999;
q.t[1].lock[8].step = 4, q.t[1].lock[8].param = 200, q.t[1].lock[8].val = 1;
- q.t[1].fill[1] = 0xF9; /* steps 5, 6: fill only, no fill; 7, 8: 3 (-> normal) */
+ pt_set_mf(&q.t[1], 4, 0, FC_FILL), pt_set_mf(&q.t[1], 5, 0, FC_NOFILL); /* steps 5, 6: fill only, no fill; */
+ pt_set_mf(&q.t[1], 6, 0, 3), pt_set_mf(&q.t[1], 7, 0, 3); /* 7, 8: 3 (-> normal) */
+ pt_set(&q.t[1], P_ITYPE, 200); /* an INSERT type past the list: clamped */
proj_apply(&q, 1);
- ok = trk[1].micro[7] == MICRO_MAX && trk[1].micro[8] == MICRO_MIN && trk[1].lock[5].step == LOCK_FREE &&
+ ok = trk[1].p[P_ITYPE] == TP[P_ITYPE].max && trk[1].lock[5].step == LOCK_FREE &&
trk[1].lock[6].step == LOCK_FREE && trk[1].lock[8].step == LOCK_FREE && trk[1].lock[7].step == 4 &&
trk[1].lock[7].val == 127 && lock_find(&trk[1], 2, P_ED_FLT, 0) >= 0 &&
step_fill(&trk[1], 4) == FC_FILL && step_fill(&trk[1], 5) == FC_NOFILL && trk[1].fill[1] == 0x09;
- bad += check("apply: a nudge past the range is clamped, a lock on LEN / step 64 / param 200 is freed, LEVEL 999 -> 127, condition 3 -> normal", ok);
+ bad += check("apply: INSERT 200 -> the last type, a lock on LEN / step 64 / param 200 is freed, LEVEL 999 -> 127, condition 3 -> normal", ok);
+ q2 = q;
+ bad += check("2.6 SAVE > PROJECT > ERASE: an object of no bytes is no project (an empty slot, older SLOOP too)",
+ !proj_import(&q2, &q, 0));
printf("%s\n", bad ? "PROJECT FORMAT TEST FAILED" : "project format test passed");
return bad != 0;
}
diff --git a/tests/punch_test.c b/tests/punch_test.c
index 3bc306c..bf1da53 100644
--- a/tests/punch_test.c
+++ b/tests/punch_test.c
@@ -1,12 +1,14 @@
/* SPDX-License-Identifier: GPL-3.0-only */
-/* PUNCH-IN FX (punch.c): each of the 16 effects changes the mix while held, stays bounded,
+/* PUNCH-IN FX (punch.c): each of the 27 effects changes the mix while held, stays bounded,
* and the mix is exactly the dry one again once its key is up (after the 64-sample fade).
- * The FX-held keyboard picks effects with the white keys and never plays or records a note.
+ * The FX-held keyboard picks effects with every key (white 1-16, black 17-27) and never plays or
+ * records a note. The black keys' effects (2.6) each do what their name says (punch_new_fx).
* argv[1]: a WAV demo (a beat, then every effect for one beat). */
#define main hostsim_main
#include "hostsim.c"
#undef main
#include
+#include
#define BLOCKS (FS * 3u / CTL) /* 3 s at 120 BPM */
static int32_t got[CTL * 2u];
@@ -56,8 +58,185 @@ static void test_mix(uint32_t b, int32_t *l, int32_t *r)
}
}
+/* ---- the black keys' effects (2.6): each does what its name says ---- */
+#define NS (FS * 8u) /* up to 8 s */
+static int32_t ol[NS], or_[NS];
+typedef int32_t (*gen_f)(uint32_t t, int ch);
+static double sweep_hz; /* the generators' tone */
+static int32_t g_sine(uint32_t t, int ch) { (void)ch; return (int32_t)(100000.0 * sin(2 * M_PI * sweep_hz * t / FS)); }
+static int32_t g_left(uint32_t t, int ch) { return ch ? 0 : g_sine(t, 0); }
+static int32_t g_burst(uint32_t t, int ch) /* a chord for 0.5 s, then nothing */
+{
+ double x = 0;
+ if (t >= FS / 2u) return 0;
+ x += sin(2 * M_PI * 220 * t / FS) + sin(2 * M_PI * 277.2 * t / FS + ch) + sin(2 * M_PI * 329.6 * t / FS) + 0.5 * sin(2 * M_PI * 880 * t / FS);
+ return (int32_t)(10000.0 * x);
+}
+/* fx held from sample `on` to `off`, through the buses as mix_block runs them (FREEZE needs the reverb) */
+static void run_fx(int32_t fx, gen_f g, uint32_t ns, uint32_t on, uint32_t off, int playing)
+{
+ uint32_t b, i;
+ beat_setup();
+ song.playing = (uint8_t)playing;
+ song.g[G_RSIZE] = 64, song.g[G_RDAMP] = 40;
+ clk_pos = 0;
+ for (b = 0; b < ns / CTL; b++) {
+ int32_t l[CTL], r[CTL], sc[CTL] = {0}, sd[CTL] = {0}, sr[CTL] = {0}, wl[CTL], wr[CTL];
+ uint32_t t0 = b * CTL;
+ for (i = 0; i < CTL; i++) l[i] = g(t0 + i, 0), r[i] = g(t0 + i, 1);
+ punch.req = (int8_t)(t0 >= on && t0 < off ? fx : -1);
+ punch_freeze_feed(sr, l, r, CTL);
+ fx_buses(sc, sd, sr, wl, wr, CTL);
+ for (i = 0; i < CTL; i++) l[i] += wl[i], r[i] += wr[i];
+ punch_process(l, r, CTL);
+ clk_pos = (clk_pos + CTL * (uint32_t)song.g[G_BPM]) % BEAT_U;
+ for (i = 0; i < CTL; i++) {
+ assert(l[i] > -(1 << 22) && l[i] < (1 << 22) && r[i] > -(1 << 22) && r[i] < (1 << 22));
+ ol[t0 + i] = l[i], or_[t0 + i] = r[i];
+ }
+ }
+ punch.req = -1;
+}
+static double rms(const int32_t *x, uint32_t a, uint32_t b)
+{
+ double e = 0;
+ uint32_t i;
+ for (i = a; i < b; i++) e += (double)x[i] * x[i];
+ return sqrt(e / (double)(b - a));
+}
+static double tone_pow(const int32_t *x, uint32_t a, uint32_t b, double hz) /* Goertzel */
+{
+ double w = 2 * M_PI * hz / FS, c = 2 * cos(w), s1 = 0, s2 = 0, s0;
+ uint32_t i;
+ for (i = a; i < b; i++) s0 = x[i] + c * s1 - s2, s2 = s1, s1 = s0;
+ return s1 * s1 + s2 * s2 - c * s1 * s2;
+}
+/* the held effect's level on a tone, from 0.3 s into the hold (the filters settled) */
+static double kill_ratio(int32_t fx, double hz)
+{
+ sweep_hz = hz;
+ run_fx(fx, g_sine, FS * 2u, FS / 2u, FS * 3u / 2u, 0);
+ return rms(ol, FS * 4u / 5u, FS * 7u / 5u) / rms(ol, FS / 10u, FS * 2u / 5u);
+}
+static void punch_new_fx(void)
+{
+ uint32_t beat = FS / 2u, i, t;
+ double a, b2;
+ /* the kills: 24 dB/oct at 250 Hz and 2.5 kHz */
+ assert(kill_ratio(PX_KLOW, 60) < 0.05 && fabs(kill_ratio(PX_KLOW, 1000) - 1) < 0.12);
+ assert(kill_ratio(PX_KHIGH, 9000) < 0.05 && fabs(kill_ratio(PX_KHIGH, 500) - 1) < 0.12);
+ assert(kill_ratio(PX_KMID, 900) < 0.08);
+ assert(fabs(kill_ratio(PX_KMID, 50) - 1) < 0.12 && fabs(kill_ratio(PX_KMID, 10000) - 1) < 0.12);
+ printf("kills: low 60 Hz %.3f, high 9 kHz %.3f, mid 900 Hz %.3f (1 kHz through KILL LOW %.2f)\n",
+ kill_ratio(PX_KLOW, 60), kill_ratio(PX_KHIGH, 9000), kill_ratio(PX_KMID, 900), kill_ratio(PX_KLOW, 1000));
+ /* OCT UP: 220 Hz in, 440 Hz out */
+ sweep_hz = 220;
+ run_fx(PX_OCT, g_sine, FS * 2u, FS / 2u, FS * 3u / 2u, 0);
+ a = tone_pow(ol, FS * 3u / 5u, FS * 7u / 5u, 440), b2 = tone_pow(ol, FS * 3u / 5u, FS * 7u / 5u, 220);
+ printf("oct up: 440 Hz / 220 Hz power %.1f, level %.2f\n", a / b2, rms(ol, FS * 3u / 5u, FS * 7u / 5u) / rms(ol, 0, FS / 2u));
+ assert(a > 30 * b2 && fabs(rms(ol, FS * 3u / 5u, FS * 7u / 5u) / rms(ol, 0, FS / 2u) - 1) < 0.25);
+ /* MONO: a left-only tone comes out on both sides */
+ sweep_hz = 440;
+ run_fx(PX_MONO, g_left, FS, FS / 4u, FS * 3u / 4u, 0);
+ for (t = FS / 4u + 128u; t < FS * 3u / 4u; t++) assert(abs(ol[t] - or_[t]) <= 64); /* (the wet gain tops at 4095 / 4096) */
+ assert(rms(or_, FS / 4u + 128u, FS * 3u / 4u) > 0.4 * rms(ol, 0, FS / 4u));
+ /* AUTO-PAN: once a beat the mix goes left, then right */
+ run_fx(PX_PAN, g_sine, FS * 2u, FS / 2u, FS * 3u / 2u, 0);
+ {
+ uint32_t lw = 0, rw = 0, q = beat / 8u;
+ for (t = FS / 2u; t + q < FS * 3u / 2u; t += q) {
+ double el = rms(ol, t, t + q), er = rms(or_, t, t + q);
+ lw += el > 4 * er, rw += er > 4 * el;
+ }
+ printf("auto-pan: %u eighths of a beat hard left, %u hard right (of 16)\n", lw, rw);
+ assert(lw >= 3 && rw >= 3);
+ assert(fabs(rms(ol, FS / 2u, FS * 3u / 2u) / rms(ol, 0, FS / 2u) - 1) < 0.2); /* as loud overall */
+ }
+ /* FADE OUT: a quarter at one beat (squared), nothing at two */
+ run_fx(PX_FADE, g_sine, FS * 3u, FS / 2u, FS * 5u / 2u, 0);
+ a = rms(ol, FS / 2u + beat - 400u, FS / 2u + beat + 400u) / rms(ol, 0, FS / 2u);
+ printf("fade out: %.3f at a beat, %.4f at two\n", a, rms(ol, FS / 2u + 2u * beat, FS / 2u + 2u * beat + 2000u) / rms(ol, 0, FS / 2u));
+ assert(a > 0.18 && a < 0.32 && rms(ol, FS / 2u + 2u * beat + 64u, FS * 5u / 2u) < 0.001 * rms(ol, 0, FS / 2u)); /* (-72 dB: the wet gain tops at 4095 / 4096) */
+ /* REWIND: the past backwards and faster, then silence until the key is up */
+ sweep_hz = 330;
+ run_fx(PX_RWD, g_sine, FS * 2u, FS / 2u, FS * 3u / 2u, 0);
+ for (t = FS / 2u + 64u, i = 0; t < FS * 3u / 2u; t++)
+ if (abs(ol[t]) > 100000 / 2000) i = t; /* (the dry under it: -72 dB) */
+ printf("rewind: sound for %.2f s, then silence\n", (double)(i - FS / 2u) / FS);
+ assert(i > FS / 2u + FS / 4u && i < FS / 2u + FS / 2u);
+ assert(tone_pow(ol, FS / 2u + FS / 5u, FS / 2u + FS * 3u / 10u, 330 * 2.5) > tone_pow(ol, FS / 2u + FS / 5u, FS / 2u + FS * 3u / 10u, 330)); /* pitched up going back */
+ /* LOOP 8T: a third of a beat, over and over */
+ sweep_hz = 97;
+ run_fx(PX_LOOP8T, g_burst, FS * 2u, FS / 4u, FS * 3u / 2u, 0);
+ for (t = FS * 3u / 5u; t < FS * 3u / 5u + beat; t++) assert(ol[t] == ol[t + beat / 3u]); /* (the chord has stopped) */
+ assert(rms(ol, FS * 3u / 5u, FS * 3u / 5u + beat) > 0.3 * rms(ol, FS / 10u, FS / 5u));
+ /* FLANGER: stereo, bounded, different */
+ run_fx(PX_FLANGE, g_burst, FS, FS / 10u, FS * 9u / 10u, 0);
+ for (t = FS / 5u, i = 0; t < FS * 2u / 5u; t++) i += ol[t] != or_[t];
+ assert(i > FS / 10u);
+ /* FREEZE: the chord stops at 0.5 s; held from 0.4 s, it rings on, steady (it beats a little), then decays
+ * once let go (at 5 s) */
+ run_fx(PX_FREEZE, g_burst, FS * 8u, FS * 2u / 5u, FS * 5u, 0);
+ {
+ double dry = rms(ol, FS / 10u, FS * 2u / 5u), h1 = rms(ol, FS, FS * 3u), h2 = rms(ol, FS * 3u, FS * 5u),
+ tail = rms(ol, FS * 7u, FS * 8u), lr = rms(or_, FS, FS * 3u);
+ printf("freeze: held %.2f then %.2f of the dry level (right %.2f), %.4f 2 s after release\n", h1 / dry, h2 / dry, lr / dry, tail / dry);
+ assert(h1 > 0.4 * dry && h1 < 1.6 * dry && lr > 0.4 * dry && fabs(h2 / h1 - 1) < 0.08 && tail < 0.05 * dry);
+ }
+ assert(!rev_frz);
+ { /* (2.6) a FREEZE held long: the reverb's level stays put, no DC creeping in (a loop gain of 1 adds up any
+ * rounding that leans one way: it went -33 a second, a thump at release) */
+ static int32_t c0[CTL], d0[CTL], rv[CTL], w0[CTL], w1[CTL];
+ uint32_t bk, k, seed = 1;
+ double m[3] = {0, 0, 0};
+ for (bk = 0; bk < 31u * FS / CTL; bk++) {
+ for (k = 0; k < CTL; k++)
+ c0[k] = d0[k] = 0, rv[k] = bk < 300u ? (int32_t)((seed = seed * 1664525u + 1013904223u) >> 16) - 32768 : 0;
+ rev_frz = bk >= 300u;
+ fx_buses(c0, d0, rv, w0, w1, CTL);
+ if (bk >= FS / CTL)
+ for (k = 0; k < CTL; k++)
+ m[(bk - FS / CTL) / (10u * FS / CTL) % 3u] += rev_l[k] + rev_r[k];
+ }
+ rev_frz = 0;
+ for (k = 0; k < 3u; k++) m[k] /= 2.0 * 10 * FS;
+ printf("freeze held 30 s: the reverb's mean %.0f, %.0f, %.0f (10 s each)\n", m[0], m[1], m[2]);
+ assert(fabs(m[2] - m[0]) < 60 && fabs(m[2]) < 600);
+ }
+ { /* (2.6) a quick switch (an effect starts on a block's first sample right after another): it starts with its
+ * own set-up, not the last one's (a kill replayed its old block over a silent input) */
+ static int32_t L[CTL], R[CTL];
+ uint32_t bk, k;
+ int32_t mx = 0;
+ beat_setup();
+ for (bk = 0; bk < 50u; bk++) {
+ for (k = 0; k < CTL; k++) L[k] = R[k] = (int32_t)(150000.0 * sin(2 * M_PI * 80 * (bk * CTL + k) / FS));
+ punch.req = PX_KLOW;
+ punch_process(L, R, CTL);
+ }
+ punch.req = PX_MONO;
+ for (bk = 0; bk < 2u; bk++) {
+ for (k = 0; k < CTL; k++) L[k] = R[k] = (int32_t)(150000.0 * sin(2 * M_PI * 80 * (bk * CTL + k) / FS));
+ punch_process(L, R, CTL);
+ }
+ punch.req = PX_KMID;
+ for (bk = 0; bk < 10u; bk++) {
+ for (k = 0; k < CTL; k++) L[k] = R[k] = 0;
+ punch_process(L, R, CTL);
+ for (k = 0; k < CTL; k++) mx = abs(L[k]) > mx ? abs(L[k]) : mx;
+ }
+ printf("quick switch KILL LOW -> MONO -> KILL MID over silence: peak %d\n", mx);
+ assert(mx == 0);
+ punch.req = -1;
+ for (bk = 0; bk < 4u; bk++) punch_process(L, R, CTL);
+ }
+ song.playing = 0;
+ 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");
+}
+
int main(int argc, char **argv)
{
+ setvbuf(stdout, 0, _IONBF, 0);
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++) {
@@ -95,22 +274,29 @@ int main(int argc, char **argv)
mix_block(got, CTL);
ly_bit[LY_FX] = 1u << 2; /* FX held (seq.c layer_now) */
fm1_in.buttons = ly_bit[LY_FX];
+ uint32_t seen = 0;
for (k = 0; k < 27u; k++) {
- int32_t w = punch_key(k);
+ int32_t w = punch_fx_of_key(k);
fm1_in.notes = 1u << k;
events_block(CTL);
- assert(w < 0 ? 1 : punch.req == w);
+ assert(w >= 0 && w < (int32_t)PUNCH_NFX && punch.req == w);
+ assert(punch_key_of_fx((uint32_t)w) == k); /* (the key that lights) */
+ assert(punch_key(k) < 0 ? w >= 16 : w == punch_key(k));
+ seen |= 1u << w;
assert(!trk[0].step[0].n && !trk[0].v[0].active);
fm1_in.notes = 0;
events_block(CTL);
assert(punch.req == -1);
}
+ assert(seen == (1u << PUNCH_NFX) - 1u); /* every effect on a key of its own */
assert(punch_key(0) == 0 && punch_key(26) == 15);
+ assert(punch_fx_of_key(1) == PX_KLOW && punch_fx_of_key(25) == PX_FADE);
fm1_in.buttons = 0;
song.rec = 0;
transport_req = 2;
events_block(CTL);
}
+ punch_new_fx();
if (f) { /* demo: one beat dry, then each effect for one beat with a beat dry between */
uint32_t beat = FS / 2u / CTL, b, total = beat * (1u + 2u * PUNCH_NFX);
static int32_t blk[CTL * 2u];
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 73d1270..cab80d5 100644
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -60,8 +60,12 @@ $CC -O2 -w -Ibuild/gen -Ifirmware/src -Ifirmware/hal -o "$OUT/userkit_test" test
run "user drum kits (KIT USR1..USR3): a user slot's sounds on the drum lanes" "$OUT/userkit_test"
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/dsyn_test" tests/dsyn_test.c -lm
run "SYN1..SYN4 drum kits and the editor's DRUM SYNTH commands (v10)" "$OUT/dsyn_test"
+$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/font_test" tests/font_test.c
+run "the screen font at 1 bit a pixel: every glyph, the same pixels as 2.5" "$OUT/font_test"
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/punch_test" tests/punch_test.c -lm
-run "punch-in FX: 16 effects, bounded, dry after release, FX-held keys" "$OUT/punch_test" "$OUT/punch-fx.wav"
+run "punch-in FX: 27 effects (11 on the black keys), bounded, dry after release, FX-held keys" "$OUT/punch_test" "$OUT/punch-fx.wav"
+$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/fx251_test" tests/fx251_test.c -lm
+run "after Felucca 1.4 / 1.5: INSERT, filter TYPE, ENV SYNC, LFO 2, drum mutes, MIDI LEARN" "$OUT/fx251_test"
$CC -O2 -w -Ibuild/gen -Ifirmware/src -Ifirmware/hal -o "$OUT/ui_pages_test" tests/ui_pages_test.c -lm
run "live UI: pages, layers (punch, steps, erase, roll, key, mix), holds, drums, REC, fuzz" "$OUT/ui_pages_test" "$OUT"
@@ -139,6 +143,7 @@ run "regression: target cost of the render loops" python3 tests/target_budget.py
build/felucca.dis tests/target_budget.txt
run "installer CLI (fm1_install.py) against a simulated FM-1" python3 tests/install_test.py
+run "the offline editor (one file, nothing next to it)" python3 tests/site_test.py
if command -v node >/dev/null 2>&1; then
run "web pages: editor protocol, samples, packages, update protocol" node web/test_web.mjs
diff --git a/tests/seq2_test.c b/tests/seq2_test.c
index 9de0756..01a9282 100644
--- a/tests/seq2_test.c
+++ b/tests/seq2_test.c
@@ -763,6 +763,8 @@ static void t_longdiv(void)
song.g[G_BPM] = 120;
check(dly_samples(6) == (uint32_t)FS * 60u / 120u * 3u / 4u && dly_samples(7) == (uint32_t)FS * 60u / 120u * 3u / 8u,
"2.4: delay TIME 1/8D = 3/4 beat, 1/16D = 3/8 beat");
+ check(dly_samples(8) == (uint32_t)FS * 60u / 120u * 3u / 2u && GP[G_DTIME].max == 8 && !strcmp(GP[G_DTIME].names[8], "1/4D"),
+ "2.6: delay TIME 1/4D = 1.5 beats, after 1/16D (older projects keep their value)");
check(div_units(7) == BEAT_U * 4u && div_units(8) == BEAT_U * 8u && div_units(2) == BEAT_U / 4u,
"2.4: div_units: 1BAR = 4 beats, 2BAR = 8, 1/16 = a quarter beat");
}
@@ -778,6 +780,241 @@ static void mo_drain(uint32_t *on, uint32_t *off, uint32_t *onDrum, uint32_t *la
else if (st == 0x80u || st == 0x90u) (*off)++;
}
}
+/* 2.6: GLO > MIDI: each synth track's own channel (in and out), and OTHER: SEL / OFF */
+static int sounding(const track_t *t, uint32_t note)
+{
+ uint32_t v;
+ for (v = 0; v < NVOICE; v++)
+ if (t->v[v].active && t->v[v].gate && t->v[v].note == note)
+ return 1;
+ return 0;
+}
+static void cc_push(uint32_t ch, uint32_t cc, uint32_t v);
+static void t_midichan(void)
+{
+ uint32_t i, ch = 99;
+ uint8_t eng[NPART], amode[NPART];
+ reset(120);
+ mi_r = mi_w;
+ uint8_t cfg = usb.config;
+ for (i = 0; i < NPART; i++) eng[i] = trk[i].eng_req, amode[i] = (uint8_t)trk[i].p[P_AMODE];
+ usb.config = 1;
+ song.g[G_ROUTE] = 0;
+ song.g[G_CH1] = 2, song.g[G_CH2] = 11, song.g[G_CH3] = 8, song.g[G_DRCH] = 10, song.g[G_CHOTH] = 0; /* bass 2, pad 11, lead 8 */
+ for (i = 0; i < NPART; i++) trk[i].p[P_AMODE] = 0, trk[i].eng_req = trk[i].engine = 0;
+ song.sel = 2;
+ mclk_push(0x09u | (0x90u | 1u) << 8 | 40u << 16 | 100u << 24); /* ch 2 */
+ mclk_push(0x09u | (0x90u | 10u) << 8 | 64u << 16 | 100u << 24); /* ch 11 */
+ mclk_push(0x09u | (0x90u | 7u) << 8 | 76u << 16 | 100u << 24); /* ch 8 */
+ mclk_push(0x09u | (0x90u | 0u) << 8 | 50u << 16 | 100u << 24); /* ch 1: no track has it: the selected one (3) */
+ run_block(); run_block();
+ check(sounding(&trk[0], 40) && sounding(&trk[1], 64) && sounding(&trk[2], 76) && sounding(&trk[2], 50) &&
+ !sounding(&trk[0], 50), "2.6: GLO > MIDI: ch 2, 11, 8 play tracks 1, 2, 3; ch 1 (nobody's): the selected track");
+ cc_push(10, 93, 127); cc_push(1, 93, 5);
+ run_block(); run_block();
+ check(trk[1].p[P_CHOR] == 127 && trk[0].p[P_CHOR] == 5, "2.6: a CC follows the track's channel too");
+ for (i = 0; i < 128u; i++) {
+ mclk_push(0x08u | (0x80u | 1u) << 8 | i << 16); mclk_push(0x08u | (0x80u | 10u) << 8 | i << 16);
+ mclk_push(0x08u | (0x80u | 7u) << 8 | i << 16); mclk_push(0x08u | (0x80u | 0u) << 8 | i << 16);
+ if (i % 16u == 15u) run_block();
+ }
+ run_block(); run_block();
+ check(!sounding(&trk[0], 40) && !sounding(&trk[1], 64) && !sounding(&trk[2], 76) && !sounding(&trk[2], 50), "2.6: their note-offs end them");
+ song.g[G_CHOTH] = 1; /* OTHER = OFF */
+ mclk_push(0x09u | (0x90u | 3u) << 8 | 55u << 16 | 100u << 24); /* ch 4: nobody's */
+ cc_push(3, 93, 33);
+ run_block(); run_block();
+ check(!sounding(&trk[0], 55) && !sounding(&trk[1], 55) && !sounding(&trk[2], 55) && trk[2].p[P_CHOR] != 33,
+ "2.6: OTHER = OFF: a channel no track has plays nothing (notes and CCs)");
+ mo_r = mo_w;
+ song.sel = 1;
+ keys(1u << 7); keys(0); /* a key on track 2: MIDI out on its channel, 11 */
+ while (mo_r != mo_w) {
+ uint32_t p = midi_out_q[mo_r % MQ];
+ mo_r++;
+ if (((p >> 8) & 0xF0u) == 0x90u && (p >> 24)) ch = (p >> 8) & 15u;
+ }
+ check(ch == 10u, "2.6: MIDI out: a track's keys on its own channel (track 2 on 11)");
+ song.g[G_CH1] = 1, song.g[G_CH2] = 2, song.g[G_CH3] = 3, song.g[G_CHOTH] = 0;
+ song.sel = 0;
+ mi_r = mi_w;
+ usb.config = cfg;
+ for (i = 0; i < NPART; i++) { /* (as it was for the tests after: engines, no voice) */
+ uint32_t v;
+ trk[i].eng_req = trk[i].engine = eng[i], trk[i].p[P_AMODE] = amode[i];
+ for (v = 0; v < NVOICE; v++) trk[i].v[v].active = trk[i].v[v].gate = 0, trk[i].v[v].stage = 0;
+ }
+}
+/* 2.6: the sustain pedal (CC 64): a note let go keeps sounding while it is down, ends when it is up; a note played
+ * again meanwhile is held by its key */
+static void t_sustain(void)
+{
+ uint8_t eng0 = trk[0].eng_req;
+ uint32_t v;
+ reset(120);
+ mi_r = mi_w;
+ song.g[G_ROUTE] = 0, song.g[G_CH1] = 1, song.g[G_CHOTH] = 0;
+ trk[0].p[P_AMODE] = 0, trk[0].eng_req = trk[0].engine = 0, trk[0].p[P_REL] = 0;
+ mclk_push(0x09u | 0x90u << 8 | 60u << 16 | 100u << 24);
+ mclk_push(0x0Bu | 0xB0u << 8 | 64u << 16 | 127u << 24); /* pedal down */
+ mclk_push(0x08u | 0x80u << 8 | 60u << 16);
+ run_block(); run_block(); run_block();
+ check(sounding(&trk[0], 60), "2.6: sustain down: a note let go keeps sounding");
+ mclk_push(0x09u | 0x90u << 8 | 64u << 16 | 100u << 24); /* E4 held through the pedal's release */
+ run_block();
+ mclk_push(0x0Bu | 0xB0u << 8 | 64u << 16 | 0u << 24); /* pedal up */
+ for (v = 0; v < 30u; v++) run_block();
+ check(!sounding(&trk[0], 60) && sounding(&trk[0], 64), "2.6: sustain up: the waiting note ends, the one still held by its key stays");
+ mclk_push(0x08u | 0x80u << 8 | 64u << 16);
+ for (v = 0; v < 30u; v++) run_block();
+ check(!sounding(&trk[0], 64), "2.6: (and ends with its key)");
+ trk[0].eng_req = trk[0].engine = eng0;
+ for (v = 0; v < NVOICE; v++) trk[0].v[v].active = trk[0].v[v].gate = 0, trk[0].v[v].stage = 0;
+ mi_r = mi_w;
+}
+/* 2.6 review: the pedal and the wheel follow the track they acted on; OTHER = OFF ignores an unknown note-off; a
+ * channel changed with a note held does not leave it stuck; a note played again under the pedal keeps the arp's count */
+static void mf_on(uint32_t ch, uint32_t n) { mclk_push(0x09u | (0x90u | ch) << 8 | n << 16 | 100u << 24); }
+static void mf_off(uint32_t ch, uint32_t n) { mclk_push(0x08u | (0x80u | ch) << 8 | n << 16); }
+static void mf_cc(uint32_t ch, uint32_t c, uint32_t v) { mclk_push(0x0Bu | (0xB0u | ch) << 8 | c << 16 | v << 24); }
+static void mf_prep(void)
+{
+ uint32_t i, v;
+ reset(120);
+ mi_r = mi_w;
+ song.g[G_ROUTE] = 0, song.g[G_CH1] = 1, song.g[G_CH2] = 2, song.g[G_CH3] = 3, song.g[G_CHOTH] = 0, song.g[G_DRCH] = 10;
+ for (i = 0; i < NPART; i++) {
+ trk[i].p[P_AMODE] = 0, trk[i].p[P_AHOLD] = 0, trk[i].eng_req = trk[i].engine = 0, trk[i].p[P_REL] = 0;
+ for (v = 0; v < NVOICE; v++)
+ trk[i].v[v].active = trk[i].v[v].gate = 0, trk[i].v[v].stage = 0;
+ sus_on[i] = 0, trk[i].bend = trk[i].bend_s = 0, trk[i].nheld = 0, trk[i].arp_phys = 0;
+ }
+ run_block();
+}
+static void t_midifix(void)
+{
+ uint8_t eng[NPART];
+ uint32_t v, i;
+ for (i = 0; i < NPART; i++)
+ eng[i] = trk[i].eng_req;
+ mf_prep(); /* the pedal on a SEL channel, the track changed while it is down */
+ song.sel = 0;
+ mf_on(4, 60), mf_cc(4, 64, 127), mf_off(4, 60);
+ run_block(), run_block();
+ song.sel = 1;
+ mf_cc(4, 64, 0);
+ for (v = 0; v < 30u; v++) run_block();
+ check(!sounding(&trk[0], 60) && !sus_on[0], "2.6: pedal up after another track was selected: the first one's note ends");
+ mf_on(0, 67), run_block(), mf_off(0, 67);
+ for (v = 0; v < 30u; v++) run_block();
+ check(!sounding(&trk[0], 67), "2.6: and its later notes end with their keys (no pedal stuck)");
+ mf_prep(); /* the wheel */
+ song.sel = 0;
+ mclk_push(0x0Eu | (0xE0u | 4u) << 8 | 127u << 16 | 127u << 24);
+ run_block();
+ song.sel = 1;
+ mclk_push(0x0Eu | (0xE0u | 4u) << 8 | 0u << 16 | 64u << 24);
+ run_block();
+ check(trk[0].bend == 0 && trk[1].bend == 0, "2.6: the wheel let go after another track was selected: the first one back too");
+ mclk_push(0x0Eu | (0xE0u | 0u) << 8 | 127u << 16 | 127u << 24);
+ run_block();
+ panic_req = 15, run_block();
+ check(trk[0].bend == 0, "2.6: a project / NEW (every track released): the bends back to the middle");
+ mf_prep(); /* OTHER = OFF */
+ song.sel = 0, song.g[G_CHOTH] = 1;
+ mf_on(0, 62), run_block(), run_block();
+ mf_off(6, 62), run_block(), run_block();
+ check(sounding(&trk[0], 62), "2.6: OTHER = OFF: a note-off on an ignored channel does not end the selected track's note");
+ mf_off(0, 62);
+ for (v = 0; v < 30u; v++) run_block();
+ mf_prep(); /* re-struck under the pedal, ARP HOLD */
+ song.sel = 0;
+ trk[0].p[P_AMODE] = 1, trk[0].p[P_AHOLD] = 1;
+ mf_cc(0, 64, 127), mf_on(0, 60), mf_off(0, 60), mf_on(0, 60), mf_off(0, 60), mf_cc(0, 64, 0);
+ run_block(), run_block();
+ check(trk[0].arp_phys == 0u, "2.6: a note played again under the pedal: no key left counted by the arp");
+ trk[0].p[P_AMODE] = 0, trk[0].p[P_AHOLD] = 0, trk[0].nheld = 0;
+ mf_prep(); /* Program Change (after Felucca 1.5.1): the track the channel plays */
+ pc_req[0] = pc_req[1] = pc_req[2] = pc_req[3] = 0;
+ mclk_push(0x0Cu | (0xC0u | 1u) << 8 | 5u << 16), mclk_push(0x0Cu | (0xC0u | 9u) << 8 | 2u << 16);
+ run_block();
+ {
+ int ok = pc_req[1] == 6u && pc_req[3] == 3u && !pc_req[0] && !pc_req[2];
+ pc_req[1] = pc_req[3] = 0;
+ song.g[G_CHOTH] = 1, run_block();
+ mclk_push(0x0Cu | (0xC0u | 6u) << 8 | 7u << 16); /* ch 7: nobody's, OTHER = OFF */
+ song.g[G_ROUTE] = 1; /* (and IN = CLOCK: none) */
+ mclk_push(0x0Cu | (0xC0u | 0u) << 8 | 7u << 16);
+ run_block();
+ ok &= !pc_req[0] && !pc_req[1] && !pc_req[2] && !pc_req[3];
+ song.g[G_ROUTE] = 0, song.g[G_CHOTH] = 0;
+ 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(); /* a channel changed with a note held */
+ song.sel = 0;
+ mf_on(1, 70), run_block(), run_block();
+ song.g[G_CH2] = 5;
+ mf_off(1, 70);
+ for (v = 0; v < 30u; v++) run_block();
+ check(!sounding(&trk[1], 70), "2.6: GLO > MIDI CH2 changed with a note held on it: the note does not stay stuck");
+ song.g[G_CH2] = 2;
+ for (i = 0; i < NPART; i++) {
+ trk[i].eng_req = trk[i].engine = eng[i];
+ for (v = 0; v < NVOICE; v++)
+ trk[i].v[v].active = trk[i].v[v].gate = 0, trk[i].v[v].stage = 0;
+ }
+ run_block();
+ mi_r = mi_w;
+}
+/* 2.6: a track's MIDI OFF is off out too; a channel changed while the sequencer's note is on: its note-off goes out on
+ * the channel the note went out on (no note left hanging on the other synth) */
+static void t_midiout_ch(void)
+{
+ uint32_t k, i, ons = 0, chon = 0xFF, choff = 0xFF, bpb = (uint32_t)((double)FS * 60.0 / 120.0 / CTL + 0.5);
+ reset(120);
+ usb.config = 1;
+ mo_r = mo_w;
+ song.g[G_MIDI] = 1, song.g[G_CH1] = 0;
+ trk[0].p[P_SDIV] = 0, trk[0].p[P_SLEN] = 4, trk[0].p[P_SGATE] = 120;
+ for (i = 0; i < 4u; i++) { trk[0].step[i].time = ST_NOTE; trk[0].step[i].n = 1; trk[0].step[i].note[0] = 60; trk[0].step[i].vel = 100; }
+ TDRUM->p[P_SLEN] = 4;
+ transport_req = 1;
+ for (k = 0; k < 2u * bpb; k++) run_block();
+ while (mo_r != mo_w) {
+ uint32_t p = midi_out_q[mo_r % MQ];
+ mo_r++;
+ ons += ((p >> 8) & 0xF0u) == 0x90u && ((p >> 8) & 15u) != 9u;
+ }
+ check(ons == 0u, "2.6: GLO > MIDI CH1 = OFF: track 1 sends nothing to MIDI OUT either");
+ song.g[G_CH1] = 5;
+ for (k = 0; k < bpb && chon == 0xFF; k++) {
+ run_block();
+ while (mo_r != mo_w) {
+ uint32_t p = midi_out_q[mo_r % MQ];
+ mo_r++;
+ if (((p >> 8) & 0xF0u) == 0x90u && (p >> 24) && ((p >> 8) & 15u) != 9u)
+ chon = (p >> 8) & 15u;
+ }
+ }
+ song.g[G_CH1] = 6; /* the note still on */
+ for (k = 0; k < 4u; k++) {
+ run_block();
+ while (mo_r != mo_w) {
+ uint32_t p = midi_out_q[mo_r % MQ];
+ mo_r++;
+ if ((((p >> 8) & 0xF0u) == 0x80u || (((p >> 8) & 0xF0u) == 0x90u && !(p >> 24))) && ((p >> 16) & 127u) == 60u)
+ choff = (p >> 8) & 15u;
+ }
+ }
+ check(chon == 4u && choff == 4u, "2.6: CH1 changed with a sequencer note on: its note-off on the channel it went out on (5)");
+ transport_req = 2, run_block();
+ song.g[G_CH1] = 1, song.g[G_MIDI] = 0;
+ usb.config = 0;
+ mo_r = mo_w;
+ for (k = 0; k < (uint32_t)(FS / CTL); k++)
+ run_block();
+}
static void t_midiout(void)
{
uint32_t k, i, on = 0, off = 0, od = 0, ln = 0, bpb = (uint32_t)((double)FS * 60.0 / 120.0 / CTL + 0.5);
@@ -1117,6 +1354,104 @@ static void t_midiin(void)
}
/* SLOOP 2.5: MIDI CCs set track parameters (Felucca 1.1.5's CC map), on the track the channel plays */
+static void cc_push(uint32_t ch, uint32_t cc, uint32_t v);
+/* SLOOP 2.6: GLO > SYSTEM > IN = CH n: only that channel, on the selected track; the others ignored */
+static uint32_t gates(const track_t *t, uint32_t note)
+{
+ uint32_t k, on = 0;
+ for (k = 0; k < NVOICE; k++) on += t->v[k].active && t->v[k].gate && (note > 127u || t->v[k].note == note);
+ return on;
+}
+static void t_midich(void)
+{
+ reset(120);
+ mi_r = mi_w;
+ song.g[G_ROUTE] = 2 + 11; /* CH 12 */
+ run_block();
+ song.sel = 2;
+ mclk_push(0x643C9009u); /* C4 on ch 1: ignored (track 1 would play it) */
+ mclk_push(0x6440900Fu); /* E4 on ch 10 (the drums): ignored */
+ mclk_push(0x64409509u); /* E4 on ch 6 (the selected track): ignored */
+ run_block(); run_block();
+ check(!gates(&trk[0], 200) && !gates(&trk[2], 200), "2.6: IN = CH 12: notes on other channels play nothing");
+ mclk_push(0x64439B09u); /* G4 on ch 12 */
+ run_block(); run_block();
+ check(gates(&trk[2], 67) == 1u, "2.6: IN = CH 12: a note on channel 12 plays the selected track (3)");
+ song.sel = 1;
+ mclk_push(0x00438B08u); /* G4 off ch 12, track 2 selected meanwhile */
+ mclk_push(0x00438008u); /* (G4 off on ch 1: ignored) */
+ run_block(); run_block();
+ check(!gates(&trk[2], 67) && !gates(&trk[1], 200), "2.6: its note-off ends it on track 3, where it started");
+ {
+ int16_t l1 = trk[1].p[P_LEVEL], l0 = trk[0].p[P_LEVEL];
+ cc_push(11, 7, 20); cc_push(0, 7, 127);
+ run_block(); run_block();
+ check(trk[1].p[P_LEVEL] != l1 && trk[1].p[P_LEVEL] < 40 && trk[0].p[P_LEVEL] == l0,
+ "2.6: a CC on channel 12 sets the selected track; on channel 1 it is ignored");
+ }
+ mclk_push(0x64409B09u); /* E4 on ch 12, held, then IN back to NOTES: released */
+ run_block(); run_block();
+ song.g[G_ROUTE] = 0;
+ run_block(); run_block();
+ check(!gates(&trk[1], 64), "2.6: IN changed while a note is held: it is released (no hanging note)");
+ song.sel = 0;
+ mi_r = mi_w;
+}
+/* 2.6 (after Felucca 1.5, #191): a latched arp follows TRN, ROOT, SCALE and QNT changed after its keys */
+static uint32_t arp_notes(const track_t *t, uint32_t blocks) /* the notes the arp played, as a bit set over 128 */
+{
+ static uint32_t m[4];
+ uint32_t b, r = 0;
+ m[0] = m[1] = m[2] = m[3] = 0;
+ for (b = 0; b < blocks; b++) {
+ run_block();
+ if (t->arp_note) m[t->arp_note >> 5] |= 1u << (t->arp_note & 31u);
+ }
+ for (b = 0; b < 128u; b++) if ((m[b >> 5] >> (b & 31u)) & 1u) r = r * 131u + b + 1u;
+ return r;
+}
+static uint32_t set2(uint32_t a, uint32_t b) { return (a + 1u) * 131u + b + 1u; }
+static void t_arp191(void)
+{
+ track_t *t = &trk[0];
+ reset(120);
+ song.sel = 0; song.octave = 0;
+ t->p[P_AMODE] = 1; t->p[P_AHOLD] = 1; t->p[P_AOCT] = 1; t->p[P_APROB] = 127;
+ t->p[P_QUANT] = 0; t->p[P_TRANS] = 0; t->p[P_ROOT] = 0; t->p[P_SCALE] = 1; t->p[P_CHORD] = 0;
+ keys(1u << 7 | 1u << 11); keys(0); /* C4 and E4, latched */
+ check(arp_notes(t, 1500) == set2(60, 64), "#191: the latched arp plays its keys (C4 E4)");
+ t->p[P_TRANS] = 2;
+ arp_notes(t, 700);
+ check(arp_notes(t, 1500) == set2(62, 66), "#191: TRN +2 after the keys: the latched arp follows (D4 F#4)");
+ t->p[P_TRANS] = 0; t->p[P_QUANT] = 2; t->p[P_SCALE] = 2; /* WHITE, minor: E4 is the 3rd degree, Eb4 */
+ arp_notes(t, 700);
+ check(arp_notes(t, 1500) == set2(60, 63), "#191: QNT WHITE, SCALE MIN after the keys: C4 Eb4");
+ t->p[P_ROOT] = 2; /* D minor */
+ arp_notes(t, 700);
+ check(arp_notes(t, 1500) == set2(62, 65), "#191: ROOT D after the keys: D4 F4");
+ mclk_push(0x64409009u); run_block(); /* a MIDI note: it plays as it came, whatever the scale */
+ t->p[P_AHOLD] = 0; keys(0); run_block(); run_block();
+ t->p[P_AMODE] = 0; t->nheld = 0; t->arp_phys = 0;
+ t->p[P_QUANT] = 0; t->p[P_SCALE] = 0; t->p[P_ROOT] = 0;
+ mi_r = mi_w;
+ { /* (2.6) chord mode + ARP: a CHORD+ note added after OCT moved is in the key's octave (kb_oct) */
+ uint32_t want = 0;
+ reset(120);
+ song.sel = 0; song.octave = 0;
+ t->p[P_AMODE] = 1; t->p[P_AHOLD] = 0; t->p[P_AOCT] = 1; t->p[P_APROB] = 127; t->p[P_QUANT] = 0;
+ t->p[P_TRANS] = 0; t->p[P_ROOT] = 0; t->p[P_SCALE] = 0; t->p[P_CHORD] = 1; t->p[P_VLEAD] = 0;
+ keys(1u << 7); /* C4 held: C minor triad (chromatic: 60 63 67) */
+ arp_notes(t, 300);
+ song.octave = 1; /* OCT+ while it is held */
+ keys(1u << 7 | 1u << 3); /* + G# (the 7th) */
+ arp_notes(t, 300);
+ want = ((((60u + 1u) * 131u + 63u + 1u) * 131u + 67u + 1u) * 131u) + 70u + 1u;
+ check(arp_notes(t, 1500) == want, "#191: CHORD+ 7th added after OCT+: in the key's octave (60 63 67 70, not 82)");
+ keys(0); run_block(); run_block();
+ song.octave = 0;
+ t->p[P_AMODE] = 0; t->p[P_CHORD] = 0; t->nheld = 0; t->arp_phys = 0;
+ }
+}
static void cc_push(uint32_t ch, uint32_t cc, uint32_t v) { mclk_push(0x0Bu | (0xB0u | ch) << 8 | cc << 16 | v << 24); }
static void t_midicc(void)
{
@@ -1147,6 +1482,8 @@ static void t_midicc(void)
run_block(); run_block();
for (i = 0; i < P_COUNT; i++) same &= b->p[i] == before[i];
check(res < 8u && a->p[P_E0 + res] == 127 && same, "2.5: CC71 = the engine's RES; an engine without one, and unmapped CCs, change nothing");
+ check(sus_on[1] == 1u, "2.6: CC 64 (sustain) on ch 2: track 2's pedal down (no parameter changed)");
+ cc_push(1, 64, 0); run_block(); /* (the pedal up again) */
song.sel = 2;
cc_push(6, 93, 127); /* ch 7: the selected track */
run_block(); run_block();
@@ -1281,6 +1618,8 @@ static void t_drdly(void)
int main(void)
{
+ t_midich();
+ t_arp191();
t_drdly();
t_tflt();
t_usbfull();
@@ -1295,6 +1634,10 @@ int main(void)
t_midiout();
t_midiin();
t_midicc();
+ t_midichan();
+ t_sustain();
+ t_midifix();
+ t_midiout_ch();
t_shed();
t_drift();
t_burst();
diff --git a/tests/site_test.py b/tests/site_test.py
new file mode 100644
index 0000000..331f257
--- /dev/null
+++ b/tests/site_test.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-3.0-only
+"""SLOOP 2.6: the offline editor (web/make_site.py offline_editor): one file that needs nothing next to it."""
+import re
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(ROOT / "web"))
+import make_site # noqa: E402
+
+src = (ROOT / "web" / "editor.html").read_text(encoding="utf-8")
+off = make_site.offline_editor(src)
+bad = 0
+
+
+def check(what, ok):
+ global bad
+ print(f"site: {what:<70} {'ok' if ok else 'FAIL'}")
+ bad += not ok
+
+
+check("the editor links the offline file (download)", src.count('download="sloop-editor.html"') == 1)
+check("the installer page links it too",
+ (ROOT / "web" / "index_pkg.html").read_text(encoding="utf-8").count('href="../editor/sloop-editor.html"') == 1)
+check("offline: the icon font inlined", 'url("fukiai.ttf")' not in off and "font/ttf;base64," in off)
+check("offline: no download link to itself", "" not in off and 'id="offline"' not in off)
+check("offline: the installer and the font licence online",
+ 'href="../installer/"' not in off and make_site.ONLINE + "webapp/installer/" in off
+ and 'href="FUKIAI-LICENSE.txt"' not in off)
+rel = [m for m in re.findall(r'(?:src|href)="([^"#]+)"', off) if not re.match(r"(https?:|data:|mailto:)", m)]
+check("offline: no other file next to it (no relative src / href)", not rel)
+check("offline: no url() to a file", not re.search(r'url\((?!data:)["\']?[A-Za-z]', off))
+print("site:", "FAILED" if bad else "offline editor test passed")
+sys.exit(1 if bad else 0)
diff --git a/tests/storage_test.c b/tests/storage_test.c
index 40da4eb..97125e5 100644
--- a/tests/storage_test.c
+++ b/tests/storage_test.c
@@ -123,6 +123,17 @@ int main(void)
bad += check("2.5: ... a torn save keeps the last one", n == (int)sizeof all && !memcmp(got2, all, sizeof all));
bad += check("2.5: ... too big for a sector: refused", st_save2(OBJ_SETTINGS, p2, 3000, p2, 1000) == -1);
}
+ { /* 2.6: SAVE > PROJECT > ERASE (project.c project_erase), as the editor's restore of an empty slot: an object
+ * of no bytes; a load reads 0 bytes (proj_fetch: no project), the next save works as ever */
+ static uint8_t a2[3816], got3[3816];
+ memset(a2, 'P', sizeof a2);
+ bad += check("2.6 erase: a project saved", st_save(OBJ_PROJECT0 + 2u, a2, sizeof a2) == 0);
+ bad += check("2.6 erase: the empty object written", st_save(OBJ_PROJECT0 + 2u, a2, 0) == 0);
+ n = st_load(OBJ_PROJECT0 + 2u, got3, sizeof got3);
+ bad += check("2.6 erase: loads 0 bytes (an empty slot)", n == 0);
+ bad += check("2.6 erase: saved again", st_save(OBJ_PROJECT0 + 2u, a2, sizeof a2) == 0 &&
+ st_load(OBJ_PROJECT0 + 2u, got3, sizeof got3) == (int)sizeof a2 && !memcmp(got3, a2, sizeof a2));
+ }
printf("%s\n", bad ? "STORAGE TEST FAILED" : "storage test passed");
return bad != 0;
}
diff --git a/tests/stress_test.c b/tests/stress_test.c
index ac5b271..3d50b5a 100644
--- a/tests/stress_test.c
+++ b/tests/stress_test.c
@@ -40,8 +40,14 @@ static void font_ref_build(void)
big_off[gi] = (uint16_t)o;
for (y = 0; y < 32u; y++)
for (x = 0; x < wb; x++) {
- uint32_t sx = x / 2u, v = s[(y / 2u) * bs + sx / 2u];
- v = (sx & 1u) ? (v & 15u) : (v >> 4);
+ uint32_t sx = x / 2u, v;
+ if (FONT_S.bits == 1u) { /* (2.6: S at 1 bit a pixel) */
+ uint32_t i = (y / 2u) * ws + sx;
+ v = (s[i >> 3] >> (7u - (i & 7u))) & 1u ? 15u : 0u;
+ } else {
+ v = s[(y / 2u) * bs + sx / 2u];
+ v = (sx & 1u) ? (v & 15u) : (v >> 4);
+ }
if (x & 1u) big_data[o + y * bb + x / 2u] |= (uint8_t)v;
else big_data[o + y * bb + x / 2u] = (uint8_t)(v << 4);
}
@@ -50,6 +56,7 @@ static void font_ref_build(void)
}
FONT_L2X = FONT_L;
FONT_L2X.sh = 0;
+ FONT_L2X.bits = 0; /* (the reference: 4-bit, stored at 2x) */
FONT_L2X.off = big_off;
FONT_L2X.data = big_data;
}
diff --git a/tests/ui_pages_test.c b/tests/ui_pages_test.c
index 34b49a5..1468721 100644
--- a/tests/ui_pages_test.c
+++ b/tests/ui_pages_test.c
@@ -52,10 +52,11 @@ static int16_t scope_buf[SCOPE_N], scope_bufr[SCOPE_N];
static uint32_t scope_w;
#include "../firmware/src/panel.c"
#include "../firmware/src/ui.c"
-static uint32_t saves, loads;
+static uint32_t saves, loads, erases;
static int project_used(uint32_t i) { return i < 2; }
static void project_save(uint32_t i) { (void)i; saves++; ui_message("SAVED"); }
static void project_load(uint32_t i) { (void)i; loads++; }
+static void project_erase(uint32_t i) { (void)i; erases++; ui_message("ERASED"); }
static void arrangement_save(void) {}
static uint32_t arrangement_ready(void) { return 3; }
static void arrangement_apply(uint32_t s) { (void)s; }
@@ -67,6 +68,7 @@ static void section_store(uint32_t s) { sec_stores++; live_sec = (int8_t)s; }
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 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; }
@@ -166,7 +168,7 @@ int main(int argc, char **argv)
char val[12]; const char *unit = "";
int16_t *vp; const param_desc_t *d = page_desc(cur_page(), 0, &vp);
param_format(d, *vp, val, &unit);
- check(d && !strcmp(d->label, "MIDI") && !strcmp(val, "SEQ"), "GLO > SYSTEM: the first column reads MIDI SEQ");
+ check(d && !strcmp(d->label, "OUT") && !strcmp(val, "SEQ"), "GLO > SYSTEM: the first column reads OUT SEQ (MIDI OUT)");
}
ui.force = 1; frame(); ppm("page-system");
{ /* (2.4) KNOB 3: IN = CLOCK (notes ignored), kept in the settings word; back to NOTES */
@@ -180,7 +182,19 @@ int main(int argc, char **argv)
check((lights_word() >> 15 & 1u) == 1u, "IN = CLOCK kept in the settings word (bit 15)");
lights_from_word(lights_word() & ~(1u << 15));
check(lights_min == 0u, "IN read back from the settings word");
- encs[panel.enc[EN_K3]] = -1; frame();
+ encs[panel.enc[EN_K3]] = 12; frame(); /* (2.6) on to CH 12 */
+ param_format(d, *vp, val, &unit);
+ lights_min = (uint8_t)song.g[G_ROUTE];
+ {
+ uint32_t w = lights_word();
+ lights_min = 0;
+ lights_from_word(w);
+ check(song.g[G_ROUTE] == 13 && !strcmp(val, "CH 12") && lights_min == 13u && !(w >> 15 & 1u) && (w >> 21 & 31u) == 12u
+ && d->max == 17, "2.6: IN = CH 12 (CH 1..16 after CLOCK), kept in the settings word (bits 21-25), read back");
+ lights_from_word(w & ~(31u << 21));
+ check(lights_min == 0u, "2.6: a settings word from 2.5 (no channel bits): IN = NOTES");
+ }
+ encs[panel.enc[EN_K3]] = -13; frame();
song.g[G_ROUTE] = r0;
}
song.g[G_MIDI] = (int16_t)m0; go_home(); frame();
@@ -200,6 +214,10 @@ int main(int argc, char **argv)
fm1_in.notes = 1u << 4; frame(); check(punch.req == 2, "FX + the 3rd white key: punch effect 3");
ppm("layer-punch-on");
fm1_in.notes = 0; frame(); check(punch.req == -1, "key up: the mix comes back");
+ fm1_in.notes = 1u << 17; frame(); check(punch.req == PX_FREEZE, "FX + the black key A#4: FREEZE (2.6: 11 black-key effects)");
+ check(keys_lit() == 1u << 17, "its key lights");
+ ppm("layer-punch-black");
+ fm1_in.notes = 0; frame(); check(punch.req == -1, "black key up: the mix comes back");
encs[panel.enc[EN_K2]] = 10; frame(); check(song.g[G_DUST] > 0, "FX + KNOB 2: DUST");
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)");
@@ -693,6 +711,9 @@ int main(int argc, char **argv)
sec = mi_sec(ui.menu_sel);
check(sec == MS_SYSTEM, "menu: SELECT stops at the last section, SYSTEM");
encs[panel.enc[EN_K2]] = 1; frame();
+ check(ui.menu == 1 && ui.menu_sel == MI_LCLEAR, "menu SYSTEM: KNOB 2 is MIDI LEARN CLEAR (2.6), nothing cleared by a turn");
+ ui.force = 1; frame(); ppm("menu-system");
+ encs[panel.enc[EN_K3]] = 1; frame();
check(ui.menu == 1 && ui.menu_sel == MI_ABOUT, "menu SYSTEM: a knob does not open ABOUT, it moves the cursor");
tap(B_OCTUP);
check(ui.menu == 2, "menu SYSTEM: OCT+ on ABOUT opens it");
@@ -716,11 +737,16 @@ int main(int argc, char **argv)
tap(B_LFO);
check(!strcmp(PT(), "LFO"), "SELECT: LFO opens its first page");
SEL(1);
- check(!strcmp(PT(), "LFO DEST") && song.g[G_BPM] == bpm, "SELECT on LFO: next page LFO DEST, the tempo untouched");
+ check(!strcmp(PT(), "LFO 2") && song.g[G_BPM] == bpm, "SELECT on LFO: next page LFO 2 (2.6), the tempo untouched");
+ ui.force = 1; frame(); ppm("page-lfo2");
+ SEL(1);
+ check(!strcmp(PT(), "LFO DEST") && song.g[G_BPM] == bpm, "SELECT: then LFO DEST");
SEL(1);
check(!strcmp(PT(), "LFO DEST") && song.g[G_BPM] == bpm, "SELECT: stops at the last page of the family");
SEL(-1);
- check(!strcmp(PT(), "LFO"), "SELECT left: the page before");
+ check(!strcmp(PT(), "LFO 2"), "SELECT left: the page before");
+ SEL(-1);
+ check(!strcmp(PT(), "LFO"), "SELECT left: LFO");
tap(B_FX); SEL(1);
check(!strcmp(PT(), "FILTER"), "SELECT on FX: next page, the track FILTER");
TSEL->p[P_TFLT] = -32; ui.force = 1; frames(2); ppm("page-filter");
@@ -939,6 +965,278 @@ int main(int argc, char **argv)
vis_style = 0; song.sel = 0; go_home(); frames(20);
}
+ { /* 2.6, after Felucca 1.4 / 1.5 (Leo Kuroshita): STEP LEN, SEQ VEL, the drum mutes (EDIT + a black key), MIDI
+ * LEARN (GLO + F#3, a knob, a CC; LEARN CLEAR in the menu), the INSERT pages (the drum track too), ANALOG's FILTER */
+ uint32_t j, w, ins_d = 0, flt_a = 0, flt_o = 0;
+ #define K(n, v) do { encs[panel.enc[n]] = (v); frames(5); } while (0)
+ #define WALK(fa_, ti_, hit_) do { open_family(fa_); frame(); \
+ for (j = 0; j < 12u; j++) { encs[panel.enc[EN_SELECT]] = -1; frame(); } \
+ for (j = 0; j < 12u; j++) { if (PAGES[ui.page].fam == (fa_) && !strcmp(PAGES[ui.page].title, ti_)) hit_ = 1; \
+ encs[panel.enc[EN_SELECT]] = 1; frame(); } } while (0)
+ song.playing = 0;
+ song.sel = 0; steps_clear(&trk[0]); trk[0].p[P_SLEN] = 16; go_home(); frames(16);
+ press(B_SEQ); frames(10);
+ key(7); /* step 5 */
+ fm1_in.notes = 1u << 7; frame();
+ w = step_vel_shown(&trk[0].step[4]);
+ K(EN_K2, 1);
+ check(trk[0].step[4].vel == w + 1u && !trk[0].step[4].lvl, "SEQ: step 5 held + KNOB 2: its velocity one up (VEL)");
+ 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");
+ 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 &&
+ trk[0].step[7].time != ST_TIE, "STEP page, KNOB 3 on a note: LEN 1 -> 3 (two TIEs after it)");
+ ui.force = 1; frame(); ppm("page-step-len");
+ K(EN_K3, -1);
+ check(note_len(&trk[0], 4) == 2u && trk[0].step[6].time == ST_REST, "KNOB 3 back: LEN 2 (its last TIE a REST)");
+ trk[0].step[5].n = 1, trk[0].step[5].note[0] = 64; /* a TIE holding a note (TIME, or an older SLOOP) */
+ K(EN_K3, -1);
+ check(note_len(&trk[0], 4) == 1u && trk[0].step[5].time == ST_REST && trk[0].step[5].n == 1u &&
+ trk[0].step[5].note[0] == 64u, "LEN shorter over a TIE holding a note: a REST, the note kept (as TIME)");
+ go_home(); frames(16);
+ press(B_EDIT); frames(10);
+ edges_btn |= BT(B_OCTDN); fm1_in.buttons |= BT(B_OCTDN); frame(); fm1_in.buttons &= ~BT(B_OCTDN); frame();
+ release(B_EDIT); frames(4);
+ check(note_len(&trk[0], 4) == 1u && trk[0].step[5].n == 0u && trk[0].step[4].n == 1u,
+ "EDIT + OCT-: the LEN turns on that step undone at once (the steps as before the first)");
+ { /* 2.6: the STEP page takes a MIDI keyboard's notes as the keys (a YouTube comment): the notes played together
+ * (CH 1 = track 1, selected) the cursor step, all let go: on to the next; the SEQ layer's pen too; a note for
+ * another track (stopped): which track it plays, nothing written; off the page: nothing written */
+ #define MIN(c, n, v) (midi_in_q[mi_w++ % MQ] = ((v) ? 0x09u | (0x90u | (c)) << 8 : 0x08u | (0x80u | (c)) << 8) | \
+ (uint32_t)(n) << 16 | (uint32_t)(v) << 24)
+ step_t s9;
+ uint32_t k9;
+ int16_t v0 = trk[0].p[P_VOICE];
+ open_family(FAM_SEQ); frame();
+ trk[0].p[P_VOICE] = V_POLY;
+ ui.cursor = 8; memset(&trk[0].step[8], 0, sizeof trk[0].step[8]); ui.force = 1; frame();
+ MIN(0, 50, 100); MIN(0, 54, 90); frame();
+ check(trk[0].step[8].n == 2u && trk[0].step[8].note[0] == 50u && trk[0].step[8].note[1] == 54u &&
+ trk[0].step[8].time == ST_NOTE && ui.cursor == 8u, "STEP page: two MIDI notes held (CH 1): step 9 the chord");
+ check(pen_n == 2u && pen_note[0] == 50u && pen_note[1] == 54u, " and the SEQ layer's pen: that chord");
+ MIN(0, 50, 0); frame();
+ check(ui.cursor == 8u, " one let go: still on step 9");
+ MIN(0, 54, 0); frame();
+ check(ui.cursor == 9u, " both let go: on to step 10");
+ MIN(0, 62, 100); MIN(0, 62, 0); frame();
+ check(trk[0].step[9].n == 1u && trk[0].step[9].note[0] == 62u && ui.cursor == 10u && pen_n == 1u && pen_note[0] == 62u,
+ " a MIDI note tapped (on and off in one frame): step 10, on to step 11; the pen that note");
+ fm1_in.notes = 1u << 7; frame(); MIN(0, 67, 100); frame(); fm1_in.notes = 0; frame();
+ check(ui.cursor == 10u && trk[0].step[10].n == 2u && trk[0].step[10].note[1] == 67u,
+ " a key and a MIDI note together: one step; the MIDI note still held: no move");
+ MIN(0, 67, 0); frame();
+ check(ui.cursor == 11u, " let go: on");
+ s9 = trk[0].step[11]; ui.msg[0] = 0;
+ 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\"");
+ go_home(); frame();
+ s9 = trk[0].step[11];
+ MIN(0, 72, 100); frame(); MIN(0, 72, 0); frame();
+ check(!memcmp(&s9, &trk[0].step[11], sizeof s9) && step_in_r == step_in_w, " off the STEP page: nothing written, the queue read");
+ ui.msg[0] = 0; song.rec = 1; /* (2.6) recording track 1: a keyboard on track 2's channel */
+ MIN(1, 60, 100); MIN(1, 60, 0); frame();
+ check(!strcmp(ui.msg, "MIDI PLAYS TRACK 2"), "REC on track 1, a MIDI note on CH 2: \"MIDI PLAYS TRACK 2\" (not recorded)");
+ ui.msg[0] = 0;
+ MIN(1, 62, 100); MIN(1, 62, 0); frame();
+ check(!ui.msg[0], " said once a take (an external sequencer on track 2 does not flash it)");
+ song.rec = 0; frame(); song.rec = 1; ui.msg[0] = 0; /* a new take; the keyboard on track 1's channel */
+ MIN(0, 60, 100); MIN(0, 60, 0); frame();
+ MIN(1, 62, 100); MIN(1, 62, 0); frame();
+ check(!ui.msg[0], " a new take, a note on CH 1 (track 1's) first: no message, even with CH 2 after");
+ song.rec = 0; ui.msg[0] = 0;
+ for (k9 = 0; k9 < NSTEP; k9++) if (trk[0].step[k9].time == ST_NOTE && trk[0].step[k9].note[0] == 60) { trk[0].step[k9].time = ST_REST; trk[0].step[k9].n = 0; }
+ trk[0].p[P_VOICE] = v0;
+ #undef MIN
+ }
+ { /* 2.6, after Felucca 1.5.1: MIDI Program Change (queued by seq.c, loaded here) and FX + OCT- / OCT+: the THROWs */
+ uint8_t e0 = trk[1].eng_req, p0 = trk[1].preset;
+ int16_t k0 = TDRUM->p[P_E0];
+ uint32_t k, tot = NBANK + up_count();
+ go_home(); frame();
+ pc_req[1] = 1; /* PC 0 on track 2's channel: the first sound of the list */
+ frame();
+ check(trk[1].eng_req == BANK[0].e && trk[1].preset == bank_pi[0] && !strncmp(ui.msg, "T2 PROG 0", 9),
+ "MIDI Program Change 0: track 2 takes the first sound of the PRESETS list (T2 PROG 0)");
+ pc_req[3] = 3; /* PC 2 on the drum channel: kit 2 */
+ frame();
+ check(TDRUM->p[P_E0] == 2, "MIDI Program Change on the drum channel: kit 2");
+ pc_req[1] = (uint8_t)(tot + 1u); /* past the end: nothing */
+ k = trk[1].eng_req;
+ frame();
+ check(trk[1].eng_req == k && trk[1].preset == bank_pi[0], "MIDI Program Change past the list: ignored (no wrap)");
+ TDRUM->p[P_E0] = k0;
+ set_engine_of(&trk[1], e0); apply_preset_to(&trk[1], p0); trk[1].engine = trk[1].eng_req;
+ frames(4);
+ press(B_FX); frames(10);
+ fm1_in.buttons |= BT(B_OCTDN); edges_btn |= BT(B_OCTDN); frame(); frame();
+ k = thr_req;
+ ui.force = 1; frame(); ppm("layer-fx-throw");
+ fm1_in.buttons &= ~BT(B_OCTDN); frame();
+ fm1_in.buttons |= BT(B_OCTUP); edges_btn |= BT(B_OCTUP); frame(); frame();
+ check(k == 1u && thr_req == 2u && !strcmp(sub_line(), "echo throw"), "FX + OCT-: REV THROW while held, FX + OCT+: ECHO THROW");
+ fm1_in.buttons &= ~BT(B_OCTUP); frame();
+ release(B_FX); frames(4);
+ check(thr_req == 0u && song.octave == 0, " let go: no THROW, the octave untouched");
+ }
+ steps_clear(&trk[0]); go_home(); frames(16);
+ { /* SEQ: two steps held + KNOB 2: both one up (the turn accelerated once, not once a step) */
+ uint32_t v0, v1;
+ song.sel = 0; trk[0].p[P_SLEN] = 16; go_home(); frames(16);
+ press(B_SEQ); frames(10);
+ key(0); key(7);
+ fm1_in.notes = 1u << 0 | 1u << 7; frame();
+ v0 = step_vel_shown(&trk[0].step[0]), v1 = step_vel_shown(&trk[0].step[4]);
+ K(EN_K2, 1);
+ check(trk[0].step[0].vel == v0 + 1u && trk[0].step[4].vel == v1 + 1u, "SEQ: two steps held + KNOB 2: both one up");
+ fm1_in.notes = 0; frame(); release(B_SEQ); frames(16);
+ steps_clear(&trk[0]); go_home(); frames(16);
+ }
+
+ song.sel = TRK_DRUM; go_home(); frames(16);
+ dstep_set(&TDRUM->dstep[0], 0, LV_NORM, 0);
+ press(B_EDIT); frames(10);
+ key(1); /* a black key: mute mode */
+ check(er_mute == 1u, "EDIT + a black key (drum track): MUTE mode");
+ key(0); /* the kick's key */
+ check(drum_mute == 1u && dstep_has(&TDRUM->dstep[0], 0), "MUTE mode + the kick's key: the kick muted, its steps kept");
+ ui.force = 1; frame(); ppm("layer-erase-mute");
+ key(0);
+ check(drum_mute == 0u, "the kick's key again: unmuted");
+ key(0);
+ release(B_EDIT); frames(2);
+ check(er_mute == 0u && drum_mute == 1u, "EDIT let go: out of MUTE mode, the mute stays");
+ drum_mute = 0;
+ TDRUM->dstep[0] = (dstep_t){0};
+ WALK(FAM_FX, "INSERT", ins_d);
+ check(ins_d, "the drum track: the INSERT page in FX");
+ go_home(); frames(16);
+
+ song.sel = 0; set_engine_of(&trk[0], 0); trk[0].engine = trk[0].eng_req; go_home(); frame();
+ WALK(FAM_EDIT, "FILTER", flt_a);
+ open_family(FAM_EDIT); frame();
+ for (j = 0; j < 30u && strcmp(PAGES[ui.page].title, "FILTER"); j++) { encs[panel.enc[EN_SELECT]] = 1; frame(); }
+ ui.force = 1; frame(); ppm("page-filter");
+ { /* on EDIT > FILTER, ALGORITHM to a track that is not ANALOG: not left on a page it does not have */
+ int16_t bpm0 = song.g[G_BPM];
+ encs[panel.enc[EN_ALGO]] = 1; frames(2);
+ check(song.sel == 1u && trk[1].eng_req != 0u && PAGES[ui.page].fam == FAM_EDIT &&
+ strcmp(PAGES[ui.page].title, "FILTER") && page_shown(cur_page()),
+ "EDIT > FILTER, then a track that is not ANALOG: the page before (EDIT 2), not FILTER");
+ encs[panel.enc[EN_SELECT]] = 1; frame();
+ check(song.g[G_BPM] == bpm0, " and SELECT turns pages there, not the tempo");
+ song.sel = 0; go_home(); frame();
+ }
+ set_engine_of(&trk[0], 1); trk[0].engine = trk[0].eng_req; go_home(); frame();
+ WALK(FAM_EDIT, "FILTER", flt_o);
+ check(flt_a && !flt_o, "EDIT: the FILTER page (TYPE) with ANALOG only");
+ set_engine_of(&trk[0], TRK_DEF[0][0]); apply_preset_to(&trk[0], TRK_DEF[0][1]); trk[0].engine = trk[0].eng_req;
+ go_home(); frames(16);
+
+ for (w = 0; w < ML_N; w++) ml_tab[w] = 0;
+ press(B_GLO); frames(10);
+ key(1); /* F#3 */
+ release(B_GLO); frames(16);
+ check(mlu.on == 1u && !mlu.pick, "GLO + F#3: MIDI LEARN on");
+ open_family(FAM_FX); frame();
+ for (j = 0; j < 12u; j++) { encs[panel.enc[EN_SELECT]] = -1; frame(); } /* the FX page: KNOB 1 = DIST */
+ frames(16);
+ ui.force = 1; frame(); ppm("header-learn");
+ K(EN_K1, 1);
+ check(mlu.pick && mlu.id == P_DIST && mlu.trk == 0u && ml_arm, "LEARN: a knob turned picks its parameter (DIST)");
+ midi_cc(&trk[0], 74, 10); frame();
+ check(ml_count() == 1u && (ml_tab[0] & 127u) == 74u && (ml_tab[0] >> 9) == ml_code(P_DIST) && !mlu.pick,
+ "LEARN: a CC sent: CC 74 = track 1 DIST");
+ go_home(); frames(16);
+ press(B_GLO); frames(10); key(1); release(B_GLO); frames(4);
+ check(!mlu.on, "GLO + F#3 again: LEARN off");
+ midi_cc(&trk[1], 74, 127);
+ check(trk[0].p[P_DIST] == TP[P_DIST].max, "CC 74 (any channel): track 1's DIST to its top");
+ trk[0].p[P_DIST] = 0;
+ ui.menu = 1; ui.menu_sel = 0; ui.force = 1; frame();
+ for (j = 0; j < 6u; j++) { encs[panel.enc[EN_SELECT]] = 1; frame(); }
+ encs[panel.enc[EN_K2]] = 1; frame();
+ tap(B_OCTUP);
+ check(ui.menu_sel == MI_LCLEAR && ml_count() == 0u, "menu SYSTEM > MIDI LEARN CLEAR, OCT+: nothing learned any more");
+ ui.menu = 0; ui.force = 1; go_home(); frames(16);
+ { /* GLO > MIDI: CH1 CH2 CH3 OTHER (2.6) */
+ uint32_t hit = 0;
+ WALK(FAM_GLO, "MIDI", hit);
+ open_family(FAM_GLO); frame();
+ for (j = 0; j < 12u && strcmp(PAGES[ui.page].title, "MIDI"); j++) { encs[panel.enc[EN_SELECT]] = 1; frame(); }
+ frames(16);
+ K(EN_K2, 9); /* CH2: 2 -> 11 */
+ check(hit && !strcmp(PAGES[ui.page].title, "MIDI") && song.g[G_CH2] == 11, "GLO > MIDI: the page, KNOB 2 sets track 2's channel (11)");
+ ui.force = 1; frame(); ppm("page-midi");
+ { /* 2.6: every MIDI setting in MIDI and MIDI 2; no channel on two tracks */
+ const page_t *m = cur_page(), *m2 = &PAGES[ui.page + 1u];
+ const char *u;
+ char vv[12];
+ param_format(&GP[G_DRCH], 0, vv, &u);
+ check(m->id[0] == G_CH1 && m->id[1] == G_CH2 && m->id[2] == G_CH3 && m->id[3] == G_DRCH && !strcmp(m2->title, "MIDI 2") &&
+ m2->id[0] == G_ROUTE && m2->id[1] == G_CHOTH && m2->id[2] == G_MIDI && m2->id[3] == G_BEND &&
+ !strcmp(GP[G_DRCH].label, "CH4") && !strcmp(vv, "OFF"),
+ "GLO > MIDI: CH1 CH2 CH3 CH4 (the drums); MIDI 2: IN OTHER OUT BEND; CH4 0 reads OFF");
+ song.g[G_CH2] = 2, frame();
+ K(EN_K2, 1); /* CH2 2 -> 3: track 3's: on to 4 */
+ check(song.g[G_CH2] == 4 && !strcmp(ui.msg, "CH 3 = TRACK 3"), "GLO > MIDI: CH2 turned onto track 3's channel: on to 4, \"CH 3 = TRACK 3\"");
+ K(EN_K2, -1); /* back: 3 taken, on to 2 */
+ check(song.g[G_CH2] == 2, " turned back: over 3 again, to 2");
+ K(EN_K4, -7); /* DR CH 10 -> 3: track 3's, then 2, 1 (taken): OFF */
+ check(song.g[G_DRCH] == 0, " the drums turned down onto 3, 2, 1 (all taken): OFF");
+ song.g[G_DRCH] = 10, frame();
+ song.g[G_ROUTE] = 6; /* IN = CH 5 */
+ go_home(); frame();
+ open_family(FAM_GLO); frame();
+ for (j = 0; j < 12u && strcmp(PAGES[ui.page].title, "MIDI"); j++) { encs[panel.enc[EN_SELECT]] = 1; frame(); }
+ check(!strcmp(ui.msg, "IN CH 5: SEL TRK ONLY"), "GLO > MIDI with IN = CH 5: says the channels are set aside");
+ song.g[G_ROUTE] = 0;
+ }
+ song.g[G_CH2] = 2;
+ go_home(); frames(16);
+ }
+ { /* GLO > TEXTURE, TEXTURE 2 (2.6) */
+ uint32_t h1 = 0, h2 = 0;
+ WALK(FAM_GLO, "TEXTURE", h1);
+ WALK(FAM_GLO, "TEXTURE 2", h2);
+ open_family(FAM_GLO); frame();
+ for (j = 0; j < 12u && strcmp(PAGES[ui.page].title, "TEXTURE"); j++) { encs[panel.enc[EN_SELECT]] = 1; frame(); }
+ frames(16);
+ K(EN_K1, 1); /* SRC: OFF -> VINYL */
+ check(h1 && h2 && song.g[G_TXSRC] == 1, "GLO > TEXTURE, TEXTURE 2: the pages; KNOB 1 the source (VINYL)");
+ ui.force = 1; frame(); ppm("page-texture");
+ song.g[G_TXSRC] = 0;
+ go_home(); frames(16);
+ }
+ #undef K
+ #undef WALK
+ }
+
+ { /* 2.6 (a YouTube comment): SAVE > PROJECT, KNOB 2 ERASE, a GO button: one detent arms (AGAIN: ERASE), a second
+ * one erases the slot KNOB 1 picks; a turn to the left does nothing */
+ uint32_t i, e0 = erases;
+ song.playing = 0;
+ go_home(); frame();
+ for (i = 0; i < NPAGES; i++) if (!strcmp(PAGES[i].title, "PROJECT")) break;
+ open_family(PAGES[i].fam); ui.page = (uint8_t)i; ui.fam_last[PAGES[i].fam] = (uint8_t)i; page_entered(); ui.force = 1; frame();
+ check(PAGES[ui.page].graph == GR_SLOTS && PAGES[ui.page].id[1] == 0xFFu, "SAVE > PROJECT: KNOB 2 free for ERASE (no parameter)");
+ song.g[G_SLOT] = 2;
+ encs[panel.enc[EN_K2]] = -1; frames(2);
+ check(erases == e0 && ui.arm != 0xE8u, "PROJECT, KNOB 2 left: nothing");
+ encs[panel.enc[EN_K2]] = 1; frames(2);
+ check(erases == e0 && ui.arm == 0xE8u && !strcmp(ui.msg, "AGAIN: ERASE"), "PROJECT, KNOB 2 one detent: AGAIN: ERASE, nothing erased");
+ ui.force = 1; frame(); ppm("page-project-erase");
+ encs[panel.enc[EN_K2]] = 1; frames(2);
+ check(erases == e0 + 1u && !ui.arm && !strcmp(ui.msg, "ERASED"), "PROJECT, KNOB 2 again: the slot erased");
+ encs[panel.enc[EN_K2]] = 1; frames(100);
+ encs[panel.enc[EN_K2]] = 1; frames(2);
+ check(erases == e0 + 1u && ui.arm == 0xE8u, " the arm runs out (~1.5 s): a detent after it arms again");
+ ui.arm = 0; song.g[G_SLOT] = 1;
+ go_home(); frames(4);
+ }
{ /* 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/tests/upreset_test.c b/tests/upreset_test.c
index 39d392d..7cc411b 100644
--- a/tests/upreset_test.c
+++ b/tests/upreset_test.c
@@ -139,10 +139,11 @@ int main(void)
for (i = 0; i < 53u; i++)
r.p[i] = (int16_t)(2000 + i);
up_params(&r, v, def);
- ok = P_SLCR == 45 && P_SLDEPTH + 1 == P_CHORD && P_CHORD == 49 && P_TFLT == 50 && P_VLEAD == 52 && P_E0 == 53;
+ ok = P_SLCR == 45 && P_SLDEPTH + 1 == P_CHORD && P_CHORD == 49 && P_TFLT == 50 && P_VLEAD == 52 && P_ITYPE == 53 &&
+ P_E0 == 63;
for (i = 0; i < 45u; i++)
ok &= v[i] == (int16_t)(2000 + i);
- for (i = P_SLCR; i <= P_VLEAD; i++)
+ for (i = P_SLCR; i < P_E0; i++)
ok &= v[i] == def[i];
for (i = 0; i < 8u; i++)
ok &= v[P_E0 + i] == (int16_t)(2000 + 45 + i);
@@ -155,10 +156,24 @@ int main(void)
ok = 1;
for (i = 0; i < P_TFLT; i++)
ok &= v[i] == (int16_t)(3000 + i);
- ok &= v[P_TFLT] == def[P_TFLT] && v[P_STRUM] == def[P_STRUM] && v[P_VLEAD] == def[P_VLEAD];
+ for (i = P_TFLT; i < P_E0; i++)
+ ok &= v[i] == def[i];
for (i = 0; i < 8u; i++)
ok &= v[P_E0 + i] == (int16_t)(3000 + 50 + i);
- bad += check("2.3 record (np 58): FILTER, STRUM, VLEAD defaults, CHORD and E0..E7 kept", ok);
+ bad += check("2.3 record (np 58): FILTER, STRUM, VLEAD and the 2.6 ten defaults, CHORD and E0..E7 kept", ok);
+ /* a record of SLOOP 2.4 .. 2.5 (P_COUNT 61, P_E0 53): the ten of 2.6 (INSERT, FTYPE, ESYNC, LFO 2) default */
+ r.np = 61;
+ for (i = 0; i < 61u; i++)
+ r.p[i] = (int16_t)(4000 + i);
+ up_params(&r, v, def);
+ ok = 1;
+ for (i = 0; i < P_ITYPE; i++)
+ ok &= v[i] == (int16_t)(4000 + i);
+ for (i = P_ITYPE; i < P_E0; i++)
+ ok &= v[i] == def[i];
+ for (i = 0; i < 8u; i++)
+ ok &= v[P_E0 + i] == (int16_t)(4000 + 53 + i);
+ bad += check("2.5 record (np 61): the 2.6 parameters (INSERT, FTYPE, ESYNC, LFO 2) default, the rest and E0..E7 kept", ok);
/* a record of SLOOP 1.0 (P_COUNT 57, P_E0 49): CHORD (SLOOP 2.0) takes its default */
r.np = 57;
for (i = 0; i < 57u; i++)
diff --git a/tools/fm1_install.py b/tools/fm1_install.py
index abd675a..f11033b 100644
--- a/tools/fm1_install.py
+++ b/tools/fm1_install.py
@@ -33,7 +33,8 @@ FINISH_CHECK, FINISH_WRITE = 0xE0000000, 0xF0000000
MAXDATA = 512
BLOCKS, BLK, KEEP = 20, 0x30, 0x2F
LOADER_MARK = b"FELUCCA-LOADER-1"
-PORT_RE = re.compile(r"fm-1|felucca|ota|composite|sinco|usb-midi", re.I) # never probe other gear
+PORT_RE = re.compile(r"fm-1|felucca|sloop|clipper|ota|composite|sinco|usb-midi", re.I) # never probe other gear
+# (the FM-1 under SLOOP / Felucca, under CLIPPER, the update loaders, the stock firmware: as web/fm1ota.js FM1_PORT)
# seconds; the tests shorten them
DELAY = {"open": 0.3, "start": 2.0, "reply": 0.01, "loader": 3.0, "reboot": 3.0, "retry": 1.0,
diff --git a/tools/gen_font.py b/tools/gen_font.py
index 66d45e6..9fe3a53 100644
--- a/tools/gen_font.py
+++ b/tools/gen_font.py
@@ -4,13 +4,16 @@
"""Render the bitmap fonts to a C header (assets/fonts/):
S labels / units / status Latin-1 32..255 at 1x
L large values / titles 32..95 (digits, signs, capitals), the same glyphs at 2x
-Terminus 8x16 (BDF, SIL OFL 1.1). TTF fonts also work through render()
+Terminus Bold 8x16 (BDF, SIL OFL 1.1). TTF fonts also work through render()
(anti-aliased, tabular figures via the OpenType `tnum` feature).
Glyph format: per glyph an advance width, a bitmap width and an offset; the
bitmap starts FONT_PAD pixels left of the pen position (room for side
-bearings); rows top to bottom, 2 pixels per byte (high nibble first),
-alpha 0..15.
+bearings); rows top to bottom. A font whose pixels are all on or off (the
+Terminus pixel font) is stored at 1 bit a pixel (SLOOP 2.6: 5376 bytes
+instead of 21504), the glyph's rows one after the other, high bit first, each
+glyph from a whole byte, and marked bits = 1; an anti-aliased one (TTF) stays at
+2 pixels per byte (high nibble first), alpha 0..15, bits = 0 (gfx.c cv_text).
"""
import sys
from pathlib import Path
@@ -20,8 +23,10 @@ from PIL import Image, ImageDraw, ImageFont
FONTS = Path(__file__).resolve().parents[1] / "assets" / "fonts"
# (name, file, px, scale, pixel, first, last): pixel fonts are rendered without
# anti-aliasing at their design size and enlarged by an integer factor
-SIZES = [("S", "ter-u16n.bdf", 16, 1, True, 32, 255), # Latin-1 (Hügelton needs the umlaut)
- ("L", "ter-u16n.bdf", 16, 2, True, 32, 95)] # values / titles: digits, signs, capitals
+# SLOOP 2.6: Terminus Bold (the same 8 x 16 cell and advances as the regular one: no layout moves), drawn in
+# capitals only (gfx.c glyph); the regular ter-u16n.bdf stays for the web editor's font (gen_webfont.py)
+SIZES = [("S", "ter-u16b.bdf", 16, 1, True, 32, 255), # Latin-1 (Hügelton needs the umlaut)
+ ("L", "ter-u16b.bdf", 16, 2, True, 32, 95)] # values / titles: digits, signs, capitals
PAD = 2
@@ -126,7 +131,7 @@ def main(out):
if scale > 1 and pixel and base is not None:
# SLOOP 2.4: a pixel font at 2x is the 1x font's own bitmaps, enlarged while drawing (gfx.c
# cv_text): no second copy in flash (24 KB). Same glyphs, same pixels: checked here.
- bname, bfirst, bh, bglyphs = base
+ bname, bfirst, bh, bglyphs, bone = base
assert scale == 2 and first == bfirst and h == bh * 2, "L must be S at 2x, same first glyph"
for (adv, bw, g), (badv, bbw, bg) in zip(glyphs, bglyphs):
assert adv == badv * 2 and bw == bbw * 2 and g == upscale(bg, bbw, bh, 2)
@@ -135,14 +140,25 @@ def main(out):
lines.append(f"static const uint8_t FONT_{name}_BW[{len(glyphs)}] = {{" +
", ".join(str(b) for _, b, _ in glyphs) + "};")
lines.append(f"static const felucca_font_t FONT_{name} = {{ {h}, {PAD * scale}, {first}, {last}, 1, "
- f"FONT_{name}_ADV, FONT_{name}_BW, FONT_{bname}_OFF, FONT_{bname}_DATA }};")
+ f"FONT_{name}_ADV, FONT_{name}_BW, FONT_{bname}_OFF, FONT_{bname}_DATA, {1 if bone else 0} }};")
lines.append("")
print(f"font {name}: {ttf} {px}px h {h}, digit adv {glyphs[ord('0') - first][0]}, "
f"the {bname} bitmaps at {scale}x (0 B)")
continue
data, offs = [], []
+ one = all(v in (0, 15) for _, _, g in glyphs for v in g) # on / off only: 1 bit a pixel
for adv, bw, g in glyphs:
offs.append(len(data))
+ if one:
+ acc = 0
+ for i, v in enumerate(g + [0] * (-len(g) % 8)):
+ acc = (acc << 1) | (v != 0)
+ if i % 8 == 7:
+ data.append(acc)
+ acc = 0
+ unp = [15 if data[offs[-1] + i // 8] >> (7 - i % 8) & 1 else 0 for i in range(len(g))]
+ assert unp == g, "1-bit packing must give the glyph back"
+ continue
for y in range(h):
row = g[y * bw:(y + 1) * bw] + [0]
for x in range(0, bw, 2):
@@ -158,10 +174,10 @@ def main(out):
lines.append(f"static const uint8_t FONT_{name}_BW[{len(glyphs)}] = {{" +
", ".join(str(b) for _, b, _ in glyphs) + "};")
lines.append(f"static const felucca_font_t FONT_{name} = {{ {h}, {PAD * scale}, {first}, {last}, 0, "
- f"FONT_{name}_ADV, FONT_{name}_BW, FONT_{name}_OFF, FONT_{name}_DATA }};")
+ f"FONT_{name}_ADV, FONT_{name}_BW, FONT_{name}_OFF, FONT_{name}_DATA, {1 if one else 0} }};")
lines.append("")
if scale == 1:
- base = (name, first, h, glyphs)
+ base = (name, first, h, glyphs, one)
print(f"font {name}: {ttf} {px}px h {h}, digit adv {glyphs[ord('0') - first][0]}, {len(data)} B")
Path(out).write_text("\n".join(lines))
diff --git a/web/EDITOR_PROTOCOL.md b/web/EDITOR_PROTOCOL.md
index 212bbf7..f308fe9 100644
--- a/web/EDITOR_PROTOCOL.md
+++ b/web/EDITOR_PROTOCOL.md
@@ -184,7 +184,13 @@ parameters (SLCR, PAT, RATE, DEPTH: ids 45..48) went in just before P_E0: P_COUN
added CHORD (id 49): P_COUNT 58, P_E0 50 (and G_COUNT 32: DUST, DUCK, FILT, ROLL, NEW at 27..31). An
editor takes them from `INFO`; older records load with the SLICER off and CHORD off. SLOOP 2.5 adds `G_DRDLY` (id 32,
GLO > DRUMS DLY, the drums' delay send): G_COUNT 33 (a 2.4 device says 32; the editor takes both). A project keeps it in
-the byte after `sel` (format 5 unchanged; 0 in older projects).
+the byte after `sel` (format 5 unchanged; 0 in older projects). SLOOP 2.4 had grown P_COUNT to 61 (P_E0 53: TFLT, STRUM,
+VLEAD and the others before it). SLOOP 2.6 adds ten track parameters just before P_E0 (ids 53..62: the INSERT's TYPE, A, B,
+C, MIX; ANALOG's filter FTYPE; ESYNC; LFO 2's LSYNC, LTRIG, LPOL): P_COUNT 71, P_E0 63; and twelve globals (ids 33..44: CH1, CH2,
+CH3, OTHER for GLO > MIDI; SRC, LEVEL, TONE, MOVE, RATE, WHEN, DUCK for GLO > TEXTURE; BEND for GLO > MIDI 2):
+G_COUNT 45. An editor reads both from `INFO` and maps a patch file by its own count (61 or 71 values; `pCount`,
+`pE0` in the file). User preset records of 61 values load with the new parameters at their defaults. Backup object
+10 holds the MIDI LEARN map and the GLO > MIDI settings (40 bytes; listed only when not the default).
## v2: live sync
@@ -413,6 +419,14 @@ Backup object **9** is the four kits (`dsu_bank_t`, 1464 bytes: "DSU1", version
crush, src, 2 reserved, 16 x 22). Its commit answers rc 3 while the song plays. A device before v10 answers the
begin of object 9 with rc 5: the editor skips it (as object 8 on a v8 device).
+Backup object **10** (SLOOP 2.6) is the MIDI part, 40 bytes: the MIDI LEARN map, 16 entries of 2 bytes (little-endian),
+each `cc | track << 7 | code << 9` (0: empty; code: a common parameter its id + 1, an engine parameter 120 + k for E k),
+then GLO > MIDI: CH1, CH2, CH3 (0 OFF, 1..16) and the drum channel | OTHER << 7, GLO > MIDI 2's BEND (1..12), 3 spare (a
+restore takes 32 and 36 bytes too: the map alone, the map and the channels). BK_LIST names it only while it is not the default (nothing learned, channels 1 2 3 10, OTHER SEL, BEND 2), so such a
+backup is one an older editor reads. Its commit checks every entry
+(a CC that learns, a parameter the firmware knows; the others become empty), writes it with the settings, and answers rc 3
+while the song plays. A device before 2.6 answers its begin with rc 5: the editor skips it.
+
## Notes for the editor
- **One request at a time.** Wait for the reply, about 10–50 ms, before sending the next.
diff --git a/web/editor.html b/web/editor.html
index 4b75183..ad10056 100644
--- a/web/editor.html
+++ b/web/editor.html
@@ -470,6 +470,7 @@
+
@@ -706,8 +707,10 @@ const CMD = { INFO: 1, GET: 2, SET: 3, DUMP: 4, DESC: 5, STEP_GET: 6, STEP_SET:
FM6_GET: 68, FM6_PUT: 69, FM6_LIST: 70, FM6_ERASE: 71, /* v9 (SLOOP 2.4): the FM6 engine's patches (Felucca 1.0's numbers) */
DSYN_LIST: 72, DSYN_GET: 73, DSYN_PUT: 74, DSYN_STORE: 75, DSYN_PLAY: 76 }; /* v10 (SLOOP 2.5): the SYN drum kits */
/* v7: the parameters a step can lock (firmware seq.c p_lockable: the sound, not the sequencer / arp / key / voice
- mode); ids as core.h: LEVEL .. LFO dests, GATE, the sends, GLIDE, PAN, DETUNE, the SLICER, the engine's 8 */
-const lockable = (id) => id <= 16 || id === 32 || (id >= 33 && id <= 36) || id === 38 || id === 39 || id === 44 || (id >= 45 && id <= 48) || id === 50 || (id >= 53 && id <= 60);
+ mode); ids as core.h: LEVEL .. LFO dests, GATE, the sends, GLIDE, PAN, DETUNE, the SLICER, FILTER, the engine's 8;
+ from 2.6 (pe0 63) also the INSERT's A B C and MIX (54..57). pe0: the device's (the newest when none) */
+const lockable = (id, pe0 = typeof dev !== "undefined" && dev && dev.info ? dev.info.pe0 : 63) => id <= 16 || id === 32 || (id >= 33 && id <= 36) || id === 38 || id === 39
+ || id === 44 || (id >= 45 && id <= 48) || id === 50 || (pe0 >= 63 && id >= 54 && id <= 57) || (id >= pe0 && id <= pe0 + 7);
const MICRO = { MIN: -32, MAX: 31 }; /* a step's nudge in 1/64 of a step (- early, + late), sent + 64 */
/* v8: a step's fill condition (firmware core.h FC_*): 0 normal, 1 plays only during a fill, 2 silent during one; 2 bits a
step, 4 steps a byte (step i: byte i >> 2, bits 2 (i & 3)..), the 16 bytes sent pack7 */
@@ -1605,6 +1608,18 @@ function libraryFile(kind, patches, ctx) {
}),
};
}
+/* a sound's values (p, the device or file layout: the common parameters, then the engine's 8 from pe0) in another
+ layout of n values, as the firmware maps user presets (up_params): new common parameters come just before the
+ engine's, so the common ones by position, the engine's 8 by their own place; what the source lacks is null */
+function patchByCount(p, pe0, n) {
+ const src = Number.isInteger(pe0) && pe0 >= 0 && pe0 + 8 <= p.length ? pe0 : p.length - 8;
+ if (!(n > 8) || src < 0 || (p.length === n && src === n - 8)) return p.slice(0, n);
+ const out = new Array(n).fill(null);
+ for (let i = 0; i < Math.min(src, n - 8); i++) out[i] = p[i];
+ for (let k = 0; k < 8; k++) out[n - 8 + k] = p[src + k] ?? null;
+ return out;
+}
+
/* -> {patches, skipped, keys (the file's, for a library that has none yet)}; throws on a file it cannot read */
function readLibraryFile(obj, ctx) {
if (!obj || typeof obj !== "object") throw new Error("not JSON");
@@ -1621,7 +1636,7 @@ function readLibraryFile(obj, ctx) {
const e = engIndex(obj.engineName, obj.engine);
if (e < 0) return { patches: [], skipped: 1, keys: null };
return { patches: [cleanPatch({ name: obj.presetName || obj.engineName || "PATCH", engine: e, engineName: obj.engineName,
- p: obj.p.slice(0, ctx.keys ? ctx.keys.length : obj.p.length), pattern: Array.isArray(obj.steps) ? patternFromSteps(obj.steps) : null, tags: ["file"] })],
+ p: ctx.keys ? patchByCount(obj.p, obj.pE0, ctx.keys.length) : obj.p.slice(), pattern: Array.isArray(obj.steps) ? patternFromSteps(obj.steps) : null, tags: ["file"] })],
skipped: 0, keys: null };
}
if (obj.format !== LIB.FORMAT) throw new Error("unknown format");
@@ -1689,7 +1704,7 @@ function b64dec(s) {
6..7 the user preset banks, 32..35 the sample slots USR1..4 (35, USR4: SLOOP 2.4) */
/* RESTORE: the objects in the order they are written back (banks first; 8 = the FM6 patch bank, firmware v9: a
file without it restores fine, a v8 device gets no object 8 sent; 9 = the SYN drum kits, firmware v10, likewise) */
-const BK = { FORMAT: "sloop-backup", VERSION: 1, SAMPLES: [32, 33, 34, 35], RESTORE: [6, 7, 8, 9, 2, 3, 4, 5, 0, 1] };
+const BK = { FORMAT: "sloop-backup", VERSION: 1, SAMPLES: [32, 33, 34, 35], RESTORE: [6, 7, 8, 9, 10, 2, 3, 4, 5, 0, 1] }; /* 10: MIDI LEARN (2.6) */
class BackupError extends Error { constructor(code, msg) { super(msg); this.code = code; } }
/* read everything; progress(done, total bytes) */
async function backupCapture(rq, info, progress = () => {}) {
@@ -1727,16 +1742,41 @@ function backupObjects(file) {
return m;
}
/* write it back: banks, projects, the working project, the settings, then the samples */
+/* the project format of a backup object ("FUN6" .. as stored, low byte first: 6 ..), 0 not a project */
+const bkProjFormat = (d) => (d && d.length >= 4 && d[1] === 0x4E && d[2] === 0x55 && d[3] === 0x46 ? d[0] - 0x30 : 0);
+/* the newest project format a device reads, from its INFO: 2.6 (71 parameters) 6, 2.4 .. 2.5 (61) 5, older 4 */
+const bkDevFormat = (info) => (info.pcount >= 71 ? 6 : info.pcount >= 61 ? 5 : 4);
+/* "SLOOP 2.6" -> true when at least maj.min.patch */
+const bkFwAtLeast = (v, want) => {
+ const m = /(\d+)\.(\d+)(?:\.(\d+))?/.exec(String(v || ""));
+ if (!m) return false;
+ const a = [+m[1], +m[2], +(m[3] || 0)];
+ for (let i = 0; i < 3; i++) if (a[i] !== want[i]) return a[i] > want[i];
+ return true;
+};
async function backupRestore(rq, file, progress = () => {}) {
const m = backupObjects(file);
+ /* (2.6) projects newer than the device reads (a 2.6 backup into 2.5): stop before anything is written (it stopped at
+ the first project, the preset banks already replaced) */
+ const info = parse[CMD.INFO](await rq(req.info(), { timeout: 1000, retries: 2 }));
+ const newest = Math.max(0, ...[0, 2, 3, 4, 5].filter((id) => m.has(id)).map((id) => bkProjFormat(m.get(id))));
+ if (newest > bkDevFormat(info)) throw new BackupError("bkNewer", `${file.firmware || "?"} > ${info.version}`);
+ /* (2.6) a backup of a 2.6 FM-1 without object 10 had the MIDI settings at their defaults (nothing learned, channels
+ 1 2 3, drums 10, OTHER SEL, BEND 2): restored as such, not left as the device has them now */
+ if (!m.has(10) && bkFwAtLeast(file.firmware, [2, 5, 1])) {
+ const d = new Uint8Array(40);
+ d.set([1, 2, 3, 10, 2], 32);
+ m.set(10, d);
+ }
const total = [...m.values()].reduce((s, d) => s + d.length, 0) || 1;
let done = 0;
for (const id of BK.RESTORE) {
if (!m.has(id)) continue;
const d = m.get(id);
let r = parse[CMD.BK_PUT](await rq(req.bkBegin(id, d.length, crc32(d)), { timeout: 1500, retries: 1 }));
- if ((r.rc === 1 || r.rc === 5) && (id === 8 || id === 9)) continue; /* a device without the FM6 bank (v8) / the SYN kits
- * (v9): skipped (its BK_PUT answers an unknown id's begin with 5) */
+ if ((r.rc === 1 || r.rc === 5) && (id === 8 || id === 9 || id === 10)) continue; /* a device without the FM6 bank (v8) /
+ * the SYN kits (v9) / MIDI LEARN (2.6): skipped (its BK_PUT answers
+ * an unknown id's begin with 5) */
if (r.rc) throw new BackupError("bkWrite", `begin ${id} rc ${r.rc}`);
for (let off = 0; off < d.length; off += 256) {
r = parse[CMD.BK_PUT](await rq(req.bkData(id, off, d.subarray(off, off + 256)), { timeout: 1500, retries: 1 }));
@@ -2075,9 +2115,12 @@ function mockSettings() {
b.set([0x33, 0x52, 0x45, 0x50]);
return ARR.encode(b, { loop: false, entries: [0, 1, 2, 3].map((scene) => ({ scene, bars: 4 })) });
}
+/* backup object 10 at its default: nothing learned, CH1-3 = 1 2 3, drums 10, OTHER SEL, BEND 2 (a 32 / 36-byte one: the
+ map, the map and the channels) */
+const mlDefault = (b) => b.every((x, i) => i < 32 ? !x : i === 32 ? x === 1 : i === 33 ? x === 2 : i === 34 ? x === 3 : i === 35 ? x === 10 : i === 36 ? x === 2 : !x);
function makeMockDevice(opt = {}) {
const NONOFF = ["OFF", "ON"], NDIV = ["1/4", "1/8", "1/16", "1/32", "8T", "16T"], NGO = ["--", "GO"], NDASH = ["--"];
- const NSDIV = [...NDIV, "1/2", "1BAR", "2BAR"], NDLY = [...NDIV, "1/8D", "1/16D"]; /* SLOOP 2.4: long steps, dotted delays */
+ const NSDIV = [...NDIV, "1/2", "1BAR", "2BAR"], NDLY = [...NDIV, "1/8D", "1/16D", "1/4D"]; /* SLOOP 2.4: long steps, dotted delays */
const D = (label, fmt, min, max, def, names = null, unit = "") => ({ label, fmt, min, max, def, names, unit });
const E = (label, names, def) => D(label, F.ENUM, 0, names.length - 1, def, names);
const TP = [
@@ -2096,19 +2139,32 @@ function makeMockDevice(opt = {}) {
E("SLCR", ["OFF", "GATE", "STUT"], 0), D("PAT", F.INT, 1, 16, 1), E("RATE", ["1/8", "1/16", "1/32", "8T", "16T", "32T"], 1), D("DEPTH", F.PCT, 0, 127, 127),
E("CHORD", ["OFF", "TRIAD", "7TH", "9TH", "SUS4", "POWER"], 0),
D("FILT", F.FILT, -64, 63, 0), D("STRUM", F.INT, -60, 60, 0), E("VLEAD", NONOFF, 0),
+ /* SLOOP 2.6 (after Felucca 1.4 / 1.5): INSERT, ANALOG's filter TYPE, ENV SYNC, LFO 2 */
+ E("INSRT", ["OFF", "SOFT", "HARD", "FOLD", "FUZZ", "CRUSH", "PHASR", "FLANG", "CHOR"], 0),
+ D("INS A", F.PCT, 0, 127, 64), D("INS B", F.PCT, 0, 127, 96), D("INS C", F.PCT, 0, 127, 96), D("MIX", F.PCT, 0, 127, 127),
+ E("TYPE", ["LP", "BP", "HP"], 0), E("ESYNC", NONOFF, 0),
+ E("SYNC", ["OFF", "4BAR", "2BAR", "1BAR", "1/2", "1/4", "1/8", "8T", "1/16", "16T", "1/32"], 0),
+ E("TRIG", ["NOTE", "FREE"], 0), E("POL", ["BI", "UNI"], 0),
];
const GP = [
D("BPM", F.BPM, 40, 240, 90), D("SWING", F.SWING, 0, 100, 0), E("CLICK", ["OFF", "REC", "ON"], 0), D("TUNE", F.INT, -50, 50, 0),
E("TIME", NDLY, 1), D("FDBK", F.PCT, 0, 120, 60), D("COLR", F.PCT, 0, 127, 70), D("MIX", F.PCT, 0, 127, 90),
D("SIZE", F.PCT, 0, 127, 90), D("DAMP", F.PCT, 0, 127, 60), D("CRT", F.LFOHZ, 0, 127, 40), D("CDP", F.PCT, 0, 127, 60),
- E("MIDI", ["KEYS", "SEQ"], 0), E("SYNC", ["INT", "USB", "TRS"], 0), E("IN", ["NOTES", "CLOCK"], 0), D("CPU", F.INT, 0, 0, 0),
+ E("OUT", ["KEYS", "SEQ"], 0), E("SYNC", ["INT", "USB", "TRS"], 0), E("IN", ["NOTES", "CLOCK", ...Array.from({ length: 16 }, (_, k) => `CH ${k + 1}`)], 0), D("CPU", F.INT, 0, 0, 0),
D("SLOT", F.INT, 1, 4, 1), E("NAME", NDASH, 0), E("LOAD", NGO, 0), E("SAVE", NGO, 0),
E("ENG", ["ANALOG", "DIGITAL", "PHASE", "LOFI", "SAMPLE", "VOICE", "TRIO", "WHEEL",
"GRAIN", "FM6", "PHYS", "NOISE"], 0), E("SET", NGO, 0),
E("CLRSQ", NGO, 0), E("INIT", NGO, 0),
- D("CH", F.INT, 0, 16, 10), D("LVL", F.INT, 0, 127, 100), D("REV", F.INT, 0, 127, 16),
+ E("CH4", ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], 10), D("LVL", F.INT, 0, 127, 100), D("REV", F.INT, 0, 127, 16),
D("DUST", F.PCT, 0, 127, 0), D("DUCK", F.PCT, 0, 127, 0), D("FILT", F.FILT, -64, 63, 0),
E("ROLL", ["1/8", "1/16", "1/32", "32T", "1/64"], 1), E("NEW", NGO, 0), D("DLY", F.INT, 0, 127, 0),
+ /* SLOOP 2.6: GLO > MIDI, each synth track's channel (OFF, 1..16) and the other channels (SEL / OFF) */
+ ...[1, 2, 3].map((k) => E("CH" + k, ["OFF", ...Array.from({ length: 16 }, (_, i) => String(i + 1))], k)), E("OTHER", ["SEL", "OFF"], 0),
+ /* GLO > TEXTURE (2.6): the bed under the mix */
+ E("SRC", ["OFF", "VINYL", "TAPE", "RAIN", "WIND", "RADIO", "ROOM", "USR1", "USR2", "USR3", "USR4"], 0), D("LEVEL", F.PCT, 0, 127, 64),
+ D("TONE", F.FILT, -64, 63, 0), D("MOVE", F.PCT, 0, 127, 40),
+ E("RATE", ["1BAR", "2BAR", "4BAR", "8BAR", "16BAR"], 2), E("WHEN", ["PLAY", "ALWAYS"], 0), E("DUCK", NONOFF, 0),
+ D("BEND", F.SEMI, 1, 12, 2), /* GLO > MIDI 2 (2.6): the pitch bend's range */
];
/* 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);
@@ -2275,7 +2331,7 @@ function makeMockDevice(opt = {}) {
[[60, 60, 61, 61, 62, 0, 63, 63, 64, 65, 65, 0, 66, 66, 66, 67], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]],
[[60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]],
];
- const P_COUNT = 61, G_COUNT = 33, NSTEP = 64, P_E0 = 53, G_ENGSEL = 20, P_SLCR = 45, P_CHORD = 49;
+ const P_E0 = TP.length, P_COUNT = P_E0 + 8, G_COUNT = GP.length, NSTEP = 64, G_ENGSEL = 20, P_SLCR = 45, P_CHORD = 49;
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
/* four tracks (firmware v3); engine / preset / p / step below are the selected track's */
const NTRK = 4, TRK_DRUM = 3;
@@ -2295,6 +2351,7 @@ function makeMockDevice(opt = {}) {
fm6bank: new Array(FM6_BANK).fill(null), /* the FM6 patch bank (fm6_bank.c): packed records */
settings: mockSettings(), /* v6: the settings object (2.5: a PER3 with a song order) */
dsyn: null, dsynStored: null, dsynPlayed: [], /* v10: the SYN kits (RAM, flash), the auditions heard */
+ ml: null, /* 2.6: the MIDI LEARN map (seq.c ml_tab, 16 x 2 bytes), null: none */
bkSnap: null, bkPut: null,
watch: false, v4: false, lastReq: 0, playing: false,
};
@@ -2459,7 +2516,7 @@ function makeMockDevice(opt = {}) {
b(0);
break;
case CMD.INFO:
- s(opt.legacy ? "FELUCCA 0.4 BETA (MOCK)" : opt.v3 ? "FELUCCA 0.8 (MOCK)" : "FELUCCA SLOOP 2.0 (MOCK)"); b(ENG.length); b(P_COUNT); b(G_COUNT); b(NSTEP); b(P_E0);
+ s(opt.legacy ? "FELUCCA 0.4 BETA (MOCK)" : opt.v3 ? "FELUCCA 0.8 (MOCK)" : "FELUCCA SLOOP 2.6 (MOCK)"); b(ENG.length); b(P_COUNT); b(G_COUNT); b(NSTEP); b(P_E0);
ENG.forEach((e) => s(e.name));
if (!opt.legacy) b(NTRK);
if (v5) b(opt.noBackup ? 5 : opt.v7 ? 7 : opt.v8 ? 8 : opt.v9 ? 9 : 10); /* v10: SYN kits (v9: FM6 patches, v8: fill conditions, v7: nudges and locks, v6: backup) */
@@ -2535,7 +2592,7 @@ function makeMockDevice(opt = {}) {
case CMD.LOCK_SET: {
if (a.length < 3 || a[0] >= NTRK) return null;
const t = st.tracks[a[0]], step = a[1], param = a[2];
- let rc = step >= NSTEP || param >= P_COUNT ? 1 : !lockable(param) ? 2 : 0;
+ let rc = step >= NSTEP || param >= P_COUNT ? 1 : !lockable(param, P_E0) ? 2 : 0;
if (!rc) {
const k = t.locks.findIndex((l) => l.step === step && l.param === param);
if (a.length >= 5) {
@@ -2677,6 +2734,8 @@ function makeMockDevice(opt = {}) {
st.bkSnap = new Map([[0, enc(project())], [1, st.settings.slice()], ...[0, 1, 2, 3].map((k) => [2 + k, st.slots[k] ? enc(st.slots[k]) : new Uint8Array(0)]),
[6, bankOf(0)], [7, bankOf(1)], ...(v9 ? [[8, st.fm6bank.some(Boolean) ? FM6.bankObj(st.fm6bank) : new Uint8Array(0)]] : []),
...(v10 ? [[9, DSYN.bankEncode(dsynKits())]] : []),
+ ...(v10 && st.ml && !mlDefault(st.ml) ? [[10, st.ml.slice()]] : []), /* MIDI LEARN (2.6): only when not the
+ * default (editor.c, project.c midi_part_default) */
...st.smp.map((_, k) => [32 + k, st.smp[k].zones ? st.smp[k].flash.slice(0, SMP.DATA_OFF + st.smp[k].len) : new Uint8Array(0)])]);
st.bkPut = null;
b(0); b(st.bkSnap.size);
@@ -2696,7 +2755,7 @@ function makeMockDevice(opt = {}) {
if (opt.noBackup || a.length < 2) return null;
const op = a[0], id = a[1], r = new Reader(a.slice(2));
let rc = 1;
- if (op === 0 && a.length === 12 && [0, 1, 2, 3, 4, 5, 6, 7, ...(v9 ? [8] : []), ...(v10 ? [9] : [])].includes(id)) {
+ if (op === 0 && a.length === 12 && [0, 1, 2, 3, 4, 5, 6, 7, ...(v9 ? [8] : []), ...(v10 ? [9, 10] : [])].includes(id)) {
const len = u35dec(r), crc = u35dec(r);
if ((id >= 2 || len) && len <= 1 << 20) { st.bkPut = { id, len, crc, pos: 0, buf: new Uint8Array(len) }; st.bkSnap = null; rc = 0; }
} else if (!st.bkPut || st.bkPut.id !== id) rc = 5;
@@ -2716,6 +2775,12 @@ function makeMockDevice(opt = {}) {
}
else if (id === 0) { const o = js(); st.tracks = o.tracks; st.sel = o.sel; st.g = o.g; }
else if (id <= 5) st.slots[id - 2] = P.len ? js() : null;
+ else if (id === 10) { /* the MIDI part (2.6; editor.c: stopped only): the LEARN
+ map (16 x 2 bytes), then GLO > MIDI's channels (4 bytes) */
+ if (P.len !== 32 && P.len !== 36 && P.len !== 40) throw 0;
+ if (st.playing) rc = 3;
+ else st.ml = P.buf.slice();
+ }
else if (id === 9) { /* the SYN kits (with the settings: stopped only) */
const k = DSYN.bankDecode(P.buf);
if (!k) throw 0;
@@ -3369,6 +3434,22 @@ const DSYN = {
const DSYN_MOCK_NAMES = ["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"];
const DSYN_MOCK_KITS = "AAEAHwYMIwRhfAAAGgAALAB/AAAACIgBATYAAxQAPGA5XBZkAEMjUgAAAAB7ABErBgAaADkAAAAAegBJYkoAPQAAsQACNwwAGgA5AAAACnYAKGp0AG0AAM4AAjcMABoAOQAAAAByClJicwBsAAC4AQErAAYvBVR2MCgQEgAiGVUAAAAAfwEBMgAGLwVRdDAoEBIAIhlaAAAAAH0AAzcMABoAOQAAAABsBXA7ZgAAAAB/AAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGAGLkpvAAAAAIcBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFcBgAAABxcL0YoKAADZloAAAAAnQUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAcBQcvI298AAAOAAAsAH8AAAAifgIBOwMEDQAyVDA8HmAAPEpoAAAAAJUAAQEgAB4eB1B8AABAKAADGWcAAAAkgAIBNgcHFQA7XDNGHnQASBtHAAAAFocAESsGABoAOQAAAAB8AE1qTABAAACrAAM5DAAaADkAAAAMcgAuQ3EAbgAArgADOQwAGgA5AAAAAG4KVkNwAG4AAJMBAS0ACigFT3YwJBYaACIZXQAAAACBAQE0AAooBUx0MCQWGgAiGWEAAAAAgAADOwMAGgA5AAAAAG4FcTNnAAAAAH4AAz4GABoAOQAAAA5sAGxybABjAACOAAErBgAaADkAAAAAYAYuSm8AAAAAhgEAPg8DHwJJdDAeGAAALAB/AAAAAH8CAV4FAgAAGGAvPDA8AANmXQAAAACUBQBICQAAA01sAAAAAAAshloAAAAAlQEAYwEAAAArbAAADAAALAB/AAAAAIcBACEKJBgESHwAAFQAACwAfwAAAEh/AgE5DAYNADJWMzwobgA/SmwAAAAAkwABACIIEh8DRnwAACIAACwAfwAAAAqJAgE5AAMNADJQNjIYaAA8K1kAAAAAjAARKwYAGgA5AAAAAHoASWJKAD0AALQAAjsOABoAOQAAAAh0ACJydQByAADSAAI7DgAaADkAAAAAbgVHcnUAcQAAxAEAMgYEIgNFcgAADAAALAB/AAAAAIkBADkABCIDQ3AAAAwAACwAfwAAAACIAAI+BgAaADkAAAAAaABjS2sAAAAAnQACPAAAGgA5AAAADGgAappoAF0AAJIAASsGABoAOQAAAABgBi5KbwAAAACHAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXAYAAAAcXC9GKCgAA2ZaAAAAAJgFAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAIAAOIgVPfAAAGAAALAB/AAAAFIcCATsDBA0AMlQwPB5gADxKaAAAAACTAAEBIQ8UHAVLfAAAOCgAAxllAAAAFocCATcGBhUDPlg0RiRwBUwrRQAAAB58ABErBgAaADkAAAAAfABPck4APQAApgADOggAGgA5AAAACmoAKEtxAG4AALIAAzoIABoAOQAAAABmCk9LcABuAACYAQEpCAw1B1h4MCgYFgAoGVkAAAAAegEBMQMMNQdVdjAoGBYAKBldAAAAAHkAAzcMABoAOQAAAABsBXA7ZgAAAAB/AAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGAGLkpvAAAAAIkBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFcBgAAABxcL0YoKAADZloAAAAAmQUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAfBhAfB1J8AAAoAAAsAH8AAAAeggIBOQAGEQA3VDQ8KHAARkpnAAAAAJEAAQAjDggaAkN4AAAKAAAsNVMAAAAAiAEBOggCDQAvSjMyCkwAOEpeAAAAAJEAASsGABoAOQAAAABcBD9abABjAAC/AAI9AwAaADkAAAAAagAfgnYAcwAA0QACPQMAGgA5AAAAAGQDQoJ1AHIAAMkBADUIAhoCQ3AAAAgAACwAfwAAAACKAQA7DgIaAkFuAAAIAAAsAH8AAAAAigADNwwAGgA5AAAAAGwFcDtmAAAAAH0AAjwAABoAOQAAAAxoAGqaaABdAACQAAErBgAaADkAAAAAXAMiWnEAAAAAkAEAQwYCFQI+cAAADgAALAB/AAAAAIYBAFsGAAAAImQwMh4AACwAfwAAAACFBQBPBgAAAkJoAAAAAAAshl0AAAAAlwEAYwEAAAArbAAADAAALAB/AAAAAIUBACEPBhoCSngAAAgAACw1TgAAAACIAQE+BgIJAChGMCgMRgAvSmQAAAAAkwABACAAEh8FWHwAADIAACwAfwAAAB6AAgE4AwYNADdQNjwodANBM1gAAAAahwARKwYAGgA5AAAAAH4AQ2JPAEkAAKsAAjcMABoAOQAAAAp2AB9ydgBzAADQAAI3DAAaADkAAAAAcgpLYnMAbAAAuwEBKwAGLwVUdjAoEBIAIhlVAAAAAH8BATIABi8FUXQwKBASACIZWgAAAAB9AAM3DAAaADkAAAAAbAVwO2YAAAAAgAACPAAAGgA5AAAADGgAappoAF0AAJIAASsGABoAOQAAAABgBi5KbwAAAACIAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXAYAAAAcXC9GKCgAA2ZaAAAAAJ0FAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAHQ8MKChxfAAAFAAALAB/AAAAMHoCATsDBA0AMlQwPB5gADxKaAAAAACRAAEAHwYOIgRSfAAALAAALAB/AAAAGoUCATwJCAkAL1QzPC5sAjtDWgAAAB6HABErBgAaADkAAAAAegBJYkoAPQAApgACNwwAGgA5AAAACnYAIYJ1AHIAAMsAAjcMABoAOQAAAAByClJicwBsAAC4AQErAAYvBVR2MCgQEgAiGVUAAAAAfwEBMgAGLwVRdDAoEBIAIhlaAAAAAH0AAzcMABoAOQAAAABsBXA7ZgAAAAB/AAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGAGLkpvAAAAAIcBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFfAwAAACJoL0YoKAADZloAAAAAkgUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAdAgxIFHF8AAAQAAAsAH8AAAAseQIBQAAGAwAoUDAyMmQANWJpAAAAAJcTAQEhBQ4cBkx8AAAoRgANKV0AAABGfQIBNQEFFQQ/YDZGInAFRkJeAAAAMoIAESsGABoAOQAAAAB8AE1qTABAAACuAAM5DAAaADkAAAAMcgAoWm4AawAAwQADOQwAGgA5AAAAAG4KS1puAGkAAKYBAS0ACigFT3YwJBYaACIZXQAAAACBAQE0AAooBUx0MCQWGgAiGWEAAAAAgAADOwMAGgA5AAAAAG4FcTNnAAAAAIAAAz4GABoAOQAAAA5sAGxybABjAACPAAErBgAaADkAAAAAYAYuSm8AAAAAiAEAPg8DHwJJdDAeGAAALAB/AAAAAH8CAV4FAgAAGGAvPDA8AANmXQAAAACXBQBICQAAA01sAAAAAAAshloAAAAAlgEAYwEAAAArbAAADAAALAB/AAAAAIcBAB8GCh8IUXwAAB4AACwdUwAAAFB7AgE3BgURADdaNjweaAA/SloAAAAohzQBACALCiIFVHgAABIAACwtTAAAABiDAQE2AAMUADxgOVwKZABCQlkAAAAAhQARKwYAGgA5AAAAAHoASUpHAD0AALQAAjcMABoAOQAAAApgAChKaABiAADLAAI3DAAaADkAAAAAXApSSmcAYQAAtAEBKwAGLwVUdjAoEBIAIhlVAAAAAH8BATIABi8FUXQwKBASACIZWgAAAAB9AAM3DAAaADkAAAAAWAVwMmMAAAAAmgACPAAAGgA5AAAADFAAaoJkAFwAAJ4AASsGABoAOQAAAABgBi5KbwAAAACKAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXAYAAAAcXC9GKCgAA2ZaAAAAAJ0FAEgJAAADTWwAAAAAACyGWgAAAACWAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAHgoIIgdaeAAACgAALC1FAAAAHoECATsDBA0AMlQwPB5gADxKUwAAAACTAgEAIAAUHgVXfAAAPAAALAB/AAAAWnkCATkMCA0ANVQzPCx0Az9DVQAAADx9ABErBgAaADkAAAAAfgBBYkoASwAAuAACNwwAGgA5AAAACnYAImp0AG0AANEAAjcMABoAOQAAAAByCkhicwBsAAC8AQErAAYvBVR2MCgQEgAiGVUAAAAAfwEBMgAGLwVRdDAoEBIAIhlaAAAAAH0AAzcMABoAOQAAAABsBXA7ZgAAAAB/AAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGAGLkpvAAAAAIgBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFcBgAAABxcL0YoKAADZloAAAAAmwUASQMAAA9YdAAAAAAALI5ZAAAAKGYBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAdCAwsHm58AAAeAAAsAH8AAABueAIBOwMEDQAyVDA8HmAAPEpoAAAAAJQAAQEgAB4eCVJ8AABAKAADGWcAAAAegAIBNgcHFQA7XDNGHnQASBtHAAAAFocAESsGABoAOQAAAAB+AFBqTABAAACpAAM5DAAaADkAAAAMcgAuQ3EAbgAArwADOQwAGgA5AAAAAHAKT0NwAG4AAJYBAS0ACigFT3YwJBYaACIZXQAAAACBAQE0AAooBUx0MCQWGgAiGWEAAAAAgAADOwMAGgA5AAAAAG4FcTNnAAAAAH8AAz4GABoAOQAAAA5sAGxybABjAACOAAErBgAaADkAAAAAYgYySm8AAAAAhgEAPg8DHwJJdDAeGAAALAB/AAAAAH8CAV4FAgAAGGAvPDA8AANmXQAAAACZBQBICQAAA01sAAAAAAAshloAAAAAlQEAYwEAAAArbAAADAAALAB/AAAAAIcBACEKJBgESHwAAFQAACwAfwAAAEh/AgE5DAYNADJWMzwobgA/SmwAAAAAkwABAB8GFh8KVnwAACQAACwdXQAAABKDAgE2BwcVADtQM0YQdABESlcAAAAWiQARKwYAGgA5AAAAAHYAVGJJAEAAALUAAzkMABoAOQAAAAxkACtycABsAADBAAM5DAAaADkAAAAAZApOcm8AawAApgEBLQAKKAVPdjAkFhoAIhldAAAAAIEBATQACigFTHQwJBYaACIZYQAAAACAAAM7AwAaADkAAAAAbgVxM2cAAAAAfwADPgYAGgA5AAAADmwAbHJsAGMAAI4AASsGABoAOQAAAABkBjVKawAAAACFAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXgUCAAAYYC88MDwAA4ZXAAAAAJIFAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAIQokGARIfAAAVAAALAB/AAAASH8CATkMBg0AMlYzPChuAD9KbAAAAACUAAEBHwYcHAlUfAAARjIACTFjAAAAYHkCATYHBxUAO1wzRh50AEgbRwAAABaHABErBgAaADkAAAAAfABHclQAQAAAogADOQwAGgA5AAAADHIAJEt0AHMAALsAAzkMABoAOQAAAABuCkxLcwBuAACYAQEtAAooBU92MCQWGgAiGV0AAAAAgQEBNAAKKAVMdDAkFhoAIhlhAAAAAIAAAzsDABoAOQAAAABuBXEzZwAAAAB/AAM+BgAaADkAAAAOZABjcmwAYwAAlgABKwYAGgA5AAAAAGAGLkpvAAAAAIcBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFeBQIAABhgLzwwPAADZl0AAAAohwUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAdDxIiD2N8AAAoAAAsTUUAAABueAIBOQwGDQAyVjM8KG4AP0psAAAAAI8AAQAhDxIRA0J8AAAsAAAsAH8AAAAMiAIBVA4AAAAYWjAyKDwAH0tdAAAAAIsAESsGABoAOQAAAAB6ADdiSgA9AACyAAI3DAAaADkAAAAKdgAYS3UAdAAAwgACNwwAGgA5AAAAAHIKPGJzAGwAAMABASsABi8FVHYwKBASACIZVQAAAAB/AQEyAAYvBVF0MCgQEgAiGVoAAAAAfQADNwwAGgA5AAAAAGwFcDtmAAAAAIAAAjwAABoAOQAAAAxoAGqaaABdAACSAAErBgAaADkAAAAAYAYuSm8AAAAAhwEARAMDHwI3dDAeGAAALAB/AAAAAIECAVwGAAAAEVwvRigoAANmWgAAAACeBQBICQAAA01sAAAAAAAshloAAAAAlQEAYwEAAAArbAAADAAALAB/AAAAAIcBACAAChQESnwAAB4AACwAfwAAAACHAgE7AwQNADJUMDweYAA8SmgAAAAAkwABACAAGDIFWHwAACgAACwAfwAAABh/AQE2AAMUADxgOVwkZAA8M1UAAAAAegARKwYAGgA5AAAAAHoASWJKAD0AALYAAjsOABoAOQAAAAh0ACJydQByAADRAAI7DgAaADkAAAAAbgVHcnUAcQAAxAQALw4ePARKcAAAAAAALAB/AAAAAIIEADkAHjwERm4AAAAAACwAfwAAAAB/AAM3DAAaADkAAAAAbAVwO2YAAAAAgAACPAAAGgA5AAAADGgAappoAF0AAJIAASsGABoAOQAAAABgBi5KbwAAAACHAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXAYAAAAcXC9GKCgAA2ZaAAAAAJsFAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAHAUHLyNvfAAADgAALAB/AAAAIn4CATsDBA0AMlQwPB5gADxKaAAAAACSAAEBIAAeHgdLfAAAQCgAAxlnAAAAFIcCATYHBxUAO1wzRh50AEgbRwAAABaHABErBgAaADkAAAAAfABNakwAQAAArQADOQwAGgA5AAAADHIALkNxAG4AAK8AAzkMABoAOQAAAAByClhDcABuAACSAQAuCBhOBVt2MB4AAAAsAH8AAAAAeQEANQgYTgVYdDAeAAAALAB/AAAAAHgAAzsDABoAOQAAAABuBXEzZwAAAACAAAM+BgAaADkAAAAObABscmwAYwAAjgABKwYAGgA5AAAAAGAGLkpvAAAAAIgBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFeBQIAABhgLzwwPAADZl0AAAAAlQUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAhCiQYBEh8AABUAAAsAH8AAABIfwIBOQwGDQAyVjM8KG4AP0psAAAAAJAAAQAgCxoaBUt8AAA8AAAsAH8AAAAogwIBOggIDQA1WDM8MnACPENXAAAAGIcAESsGABoAOQAAAAB8AE1qTABAAACkAAM5DAAaADkAAAAMcgAmS3QAbgAAtQADOQwAGgA5AAAAAG4KVkNwAG4AAJQBAS0ACigFT3YwJBYaACIZXQAAAACBAQE0AAooBUx0MCQWGgAiGWEAAAAAgAADOwMAGgA5AAAAAG4FcTNnAAAAAH8AAz4GABoAOQAAAA5sAGxybABjAACOAAErBgAaADkAAAAAZAYvSm8AAAAAhQEAPg8DHwJJdDAeGAAALAB/AAAAAH8CAWABAgAAHmAvPDA8AANmXQAAAACUBQBICQAAA01sAAAAAAAshloAAAAAlQEAYwEAAAArbAAADAAALAB/AAAAAIcBACEKJBgESHwAAFQAACwAfwAAAEh/AgE9AwYJACxUMDIyZAA1YmsAAAAAkAABACEPEBgDRnwAADgAACwAfwAAADKFAgE7DgkNAjleM0YycgNDQ08AAAAofwARKwYAGgA5AAAAAHwATWpMAEAAAKsAAzkMABoAOQAAAAxyACJDcQBuAACyAAM5DAAaADkAAAAAbgpWQ3AAbgAAkwEBLQAKKAVPdjAkFhoAIhldAAAAAIEBATQACigFTHQwJBYaACIZYQAAAACAAAM7AwAaADkAAAAAbgVxM2cAAAAAfwADPgYAGgA5AAAADmQAbHJsAGMAAJEAASsGABoAOQAAAABgBi5KbwAAAACHAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXgUCAAAYYC88MDwAA2ZdAAAAAJcFAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAIQokGARIfAAAVAAALAB/AAAASH8CAT4GBwkAL1ozPDJqADtaZwAAAB6HAAEAHgoaHghUfAAARgAALAB/AAAAQHwCATQJCBoFQ2I2RjJ6D1QzPQAAAEBnABErBgAaADkAAAAAfABSakwAQAAAqgADOQwAGgA5AAAADHIALkNxAG4AAKwAAzkMABoAOQAAAABuCk5DcABuAACXAQEtAAooBU92MCQWGgAiGV0AAAAAgQEBNAAKKAVMdDAkFhoAIhlhAAAAAIAAAzsDABoAOQAAAABuBXEzZwAAAAB/AAM+BgAaADkAAAAObABscmwAYwAAjwABKwYAGgA5AAAAAGAGLkpvAAAAAIcBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFeBQIAABhgLzwwPAADZl0AAAAAmgUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAhCiQYBEh8AABUAAAsAH8AAABIfwIBOQwGDQAyVjM8KG4AP0psAAAAAJIAAQAfBgwjBFh8AAAoAAAsAH8AAAAUhAIBOQwFDQA1VDY8JGQCPjNTAAAAFIcAESsGABoAOQAAAAB6AEJiSgA9AACtAAI3DAAaADkAAAAKdgAoanQAbQAA0gACNwwAGgA5AAAAAHIKUmJzAGwAALgBASsABi8FVHYwKBASACIZVQAAAAB/AQEyAAYvBVF0MCgQEgAiGVoAAAAAfQADNwwAGgA5AAAAAGwFcDtmAAAAAIAAAjwAABoAOQAAAAxoAGqaaABdAACSAAErBgAaADkAAAAAYgYySm8AAAAAhQEAPg8DHwJJdDAeGAAALAB/AAAAAH8CAVwGAAAAHGgvRigoAANmWgAAAACWBQBICQAAA01sAAAAAAAshloAAAAAlQEAYwEAAAArbAAADAAALAB/AAAAAIcBABwFBy8jb3wAAA4AACwAfwAAACJ+AgE7AwQNADJUMDweYAA8SmgAAAAAlAABACALDhoETnwAACgAACwAfwAAABCHAQE2AAMUADxgOVwWZABDI1IAAAAAfgARKwYAGgA5AAAAAHoAS2JKAD0AAKsAAjcMABoAOQAAAAp2AChqdABtAADPAAI3DAAaADkAAAAAcgpSYnMAbAAAuAEBKwAGLwVUdjAoEBIAIhlVAAAAAH8BATIABi8FUXQwKBASACIZWgAAAAB9AAM3DAAaADkAAAAAbAVwO2YAAAAAgAACPAAAGgA5AAAADGgAappoAF0AAJIAASsGABoAOQAAAABoCDJabQAAAAB+AQA+DwMfAkt0MB4YAAAsAH8AAAAAfgIBXAYAAAAcXC9GKCgAA2ZaAAAAAJsFAFEGAAADQmwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAIQAYPApefEAyHgAALIVOFQAAOHcCATsDBA0AMlQwPB5gADxKaAAAAACTAAEAIggKIgNLeAAAFAAALB1VAAAAAIgCAUAAAw0AL1wwMh5GAC9KZwAAAACTABErBgAaADkAAAAAegBJYkoAPQAAqQACNwwAGgA5AAAACnYAKGp0AG0AANIAAjcMABoAOQAAAAByClJicwBsAAC4AQAzCAIaA0tyAAAUAAAsAH8AAAAAhgEAOQwCGgNIcAAAFAAALAB/AAAAAIYAAzcMABoAOQAAAABsBXA7ZgAAAACAAAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGQGNUpvAAAAAIMBAD4PAh8CS3QwHhgAACwAfwAAAAB+AgFcBgAAABxcL0YoKAADZloAAAAAmAUAUQYAAANEbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAcBQcvI298AAAOAAAsAH8AAAAifgIBOwMEDQAyVDA8HmAAPEpoAAAAAJgAAQAjAQYaA0l0AAAQAAAsHVMAAAAAiQEBOggCDQAvSjMyCkwAOEpeAAAAAJEAASsGABoAOQAAAABcBD9abABjAADCAAI9AwAaADkAAAAAagAfgnYAcwAA0QACPQMAGgA5AAAAAGQDQoJ1AHIAAMkBATcGAxUCRnIzKCgaABVKYwAAAACDAQE+BgMVAkRyMygoGgAVSmUAAAAAgwADNwwAGgA5AAAAAGwFcDtmAAAAAH4AAjwAABoAOQAAAAxoAGqaaABdAACQAAErBgAaADkAAAAAXAMiWnEAAAAAjwEAQAACFQJKcAAAHgAALAB/AAAAAH4BAFsGAAAAImQwMh4AACwAfwAAAACHBQBLDAAAAkpoAAAAAAAshl0AAAAAmQEAYgYAAAAubAAADAAALAB/AAAAAIMBACEPBhoCSngAAAgAACw1TgAAAACIAQE+BgIJAChGMCgMRgAvSmQAAAAAkQABASAADi8FW3wAAB4eAA0xTwAAAACHAQEzCAYiA0twMzIeKAAvMV0AAAAAggARKwYAGgA5AAAAAHoASWJKAD0AAKwAASsGABoAOQAAAABaAChKawBnAAC7AAErBgAaADkAAAAAXAVCSmcAYwAApwEBJgYINwVbeDAoHhoAIjFPAAAAAH0BAS0MCDcFWHYwKB4aACIxVQAAAAB5AAM3DAAaADkAAAAAbAVwO2YAAAAAgAACPAAAGgA5AAAADGgAappoAF0AAJIAASsGABoAOQAAAABgBi5KbwAAAACIAQA+DwMfAk90MB4YAAAsAH8AAAAAewIBXAYAAAAcXC9GKCgAA2ZaAAAAAJkFAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAHAUHLyNvfAAADgAALAB/AAAAIn4CATsDBA0AMlQwPB5gADxKaAAAAACUAAEBIQ8UHAVLfAAAOCgAAxllAAAAFocCATcGBhUFPlg0RiR4BVErRQAAADJxABErBgAaADkAAAAAfABPck4APQAArAADOggAGgA5AAAACmoAKEtxAG4AALUAAzoIABoAOQAAAABmCk9LcABuAACYAQEoCRJCB1t4MCgYGAAsGVkAAAAAeQEBLw4SQgdYdjAoGBgALBldAAAAAHYAAzcMABoAOQAAAABsBXA7ZgAAAAB/AAI8AAAaADkAAAAMaABqmmgAXQAAkgABKwYAGgA5AAAAAGAGLkpvAAAAAIYBAD4PAx8CSXQwHhgAACwAfwAAAAB/AgFcBgAAABxcL0YoKAADZloAAAAAmgUASAkAAANNbAAAAAAALIZaAAAAAJUBAGMBAAAAK2wAAAwAACwAfwAAAACHAQAfBhAfB1J8AAAoAAAsAH8AAAAeggIBOQAGEQA3VDQ8KHAARkpnAAAAAI0EAwAlAx4oAj5oAAAAAAAsAH8AAAAAmAMEOQAMGgAoPAAAAGoDPgB/AABcAIwABCsGABoAOQAAAABsBTsAfwAAZQCKAAQrBgAaADkAAAAAYAAiAH8AAH0AegAEKwYAGgA5AAAAAFwFSAB/AAB7AF8DAC0ADjUCQmQAAAAAACwAfwAAAACQAwA0AA41Aj9kAAAAAAAsAH8AAAAAjwAEKwYAGgA5AAAAAGAKYwB/AABsAFUDBFoEAAAATjIAAAA8AEYAfwAAfwBmAAQrBgAaADkAAAAAVAAqAH8AAH8AcAIAQAAFIgI8bgAAAAAALAB/AAAAAIsDAFYGAAAAH1oAAAAAACwAfwAAAACdAwBNAQAAAkFaAAAAAAAsAH8AAAAAhAMAXwMAAAAlWgAAAAAALAB/AAAAAJICACIIJCwFSHQAAAAAACwAfwAAAACJAAQrBgAaADkAAAAAbAI3AH8AAGkAkAIEACEAKCIESHgAAB4AACwAfwAAAB6DBAE3BhIaADdaAAAAWgA/SmMAAAAAjQARKwYAGgA5AAAAAHYARGJPAEcAAK8EAWwBAAAAIkYAAABGACIzcQAAAAB6BAFsAQAAAEhAAAAAQABIM24AAAAAawQALggePANLbgAAAAAALAB/AAAAAIQEADcGHjwDSGwAAAAAACwAfwAAAACBBANRBgAAAGgyAAAAWgBqM2MAAAAAagQCVwwAAABjPAAAADIAXoJrAAAAAF0AASsGABoAOQAAAABQBCxKbgAAAACTBABAAAwoAkJsAAAAAAAsAH8AAAAAggQAWgQEAAAfYAAAHgAALAB/AAAAAIwEAEoGAAACRmAAAAAAACwAfwAAAAB+BABhCgAAAChkAAAAAAAsAH8AAAAAjgQAHgoeKApUeAAAAAAALAB/AAAAMngEAUAADA0AL1oAAABQADdLXQAAAACJJQQAIQAoEQQ8eAAAHgAALAB/AAAAHocABCsGABoAOQAAAABwADIAfwAAWACcABErBgAaADkAAAAAdgA1Yk8ARwAArwAEKwYAGgA5AAAAAGQAFQB/AAB/AH8ABCsGABoAOQAAAABgADcAfwAAfQB0BAAuCB4oAzxuAAAAAAAsAH8AAAAAiwQANwYeKAM5bAAAAAAALAB/AAAAAIoEA1EGAAAAaDIAAABaAGozYwAAAABrBAJXDAAAAGM8AAAAMgBegmsAAAAAXQABKwYAGgA5AAAAAFAELEpuAAAAAJMEAEAADCgCQmwAAAAAACwAfwAAAACCBABaBAQAAB9gAAAeAAAsAH8AAAAAjgQASgYAAAJGYAAAAAAALAB/AAAAAH4EAGEKAAAAKGQAAAAAACwAfwAAAACOBAAeCh4oClR4AAAAAAAsAH8AAAAyeAQBQAAMDQAvWgAAAFAAN0tdAAAAAIUCAQEgAB4eB1J8AABaKAADGWcAAAB/eAIBNgcHFQA7XDNGHnQASxtHAAAAbm8AESsGABoAOQAAAAB/AExqTABAAACrAAI5DAAaADkAAAAMcgAvQ3EAbgAAxQACOQwAGgA5AAAAAG4KV0NwAG4AALAEACkIGEYFU3YAAAAAACwAfwAAAGRkBAAxAxhGBVB0AAAAAAAsAH8AAABkYQACOwMAGgA5AAAAAHYFdDNnAAAAAJIAAz4GABoAOQAAAA5sAGxybABjAACPAAErBgAaADkAAAAAYAYuSm8AAAAAhwEAPg8DHwJJdDAeGAAALAB/AAAAAH8CAV4FAgAAGGAvPDA8AANmXQAAAACVBQBICQAAA01sAAAAAAAshloAAAAAlQEAYwEAAAArbAAADAAALAB/AAAAAIcBACEKJBgESHwAAFQAACwAfwAAAEh/AgE5DAYNADJWMzwobgA/SmwAAAAAkQABACALKBoFUnwAAFoAACwAfwAAAG54AgE+BgoNADdkMzw8egNES1UAAABQdQARKwYAGgA5AAAAAH8ASmpMAEwAAKUAAzkMABoAOQAAAAxyACJLdQBuAAC2AAM5DAAaADkAAAAAbgpWS3QAbgAAlQEBLQAKKAVPdjAkFhoAIhldAAAAAIEBATQACigFTHQwJBYaACIZYQAAAACAAAM7AwAaADkAAAAAbgVxM2cAAAAAfgADPgYAGgA5AAAADmwAbHJsAGMAAI8AASsGABoAOQAAAABgBi5KbwAAAACHAQA+DwMfAkl0MB4YAAAsAH8AAAAAfwIBXgUCAAAYYC88MDwAA2ZdAAAAAJcFAEgJAAADTWwAAAAAACyGWgAAAACVAQBjAQAAACtsAAAMAAAsAH8AAAAAhwEAIQokGARIfAAAVAAALAB/AAAASH8CATkMBg0AMlYzPChuAD9KbAAAAACSAAEAHgoIKAVjaAAAAAAALB1AAAAAAI0BATYAAxQAPDw5XABGAFQxYAAAAACXABErBgAaADkAAAAAWgBXSkUAPQAAvwACNwwAGgA5AAAACkgAMkpuAGsAANUAAjcMABoAOQAAAABICmNicwBsAAC8AQErAAYvBVR2MCgQEgAiGVUAAAAAeQEBMgAGLwVRdDAoEBIAIhlaAAAAAHcAAzcMABoAOQAAAABUBXw7ZgAAAACBAAI8AAAaADkAAAAMQAB2gmsAXQAAoAABKwYAGgA5AAAAAGAGLkpvAAAAAIABAD4PAx8CSXQwHhgAACwAfwAAAAB5AgFcBgAAABxcL0YoKAADZloAAAAAmgUASAkAAANNbAAAAAAALIZaAAAAAJQBAGMBAAAAK2wAAAwAACwAfwAAAACBAQAcBQcvI298AAAOAAAsAH8AAAAieAIBOwMEDQAyVDA8HmAAPEpoAAAAAJIAAQEjAQgaAklkAAAYHgAJGUsAAAAAjgIBOAMCDQAvKAAAAFwPTzJgAAAAAKkAESsGABoAOQAAAAB6AEliSgA9AACrAAM+BgAaADkAAAAAUgAvSnEAZwAAuwADPgYAGgA5AAAAAFIFV0pwAGUAAKQBAS0AAyIDU2owKBQQACgZVQAAAAB/AQEzCAMiA1BoMCgUEAAoGVkAAAAAfgADNwwAGgA5AAAAAGwFcDtmAAAAAHoAAz8IABoAOQAAABBaAHVabQBgAACOAAErBgAaADkAAAAAYAYuSm8AAAAAgAEAPg8DHwJJdDAeGAAALAB/AAAAAHkCAVwGAAAAHFwvRigoAANmWgAAAACYBQBICQAAA01sAAAAAAAshloAAAAAlAEAYwEAAAArbAAADAAALAB/AAAAAIEBASUDBhYCQmAAAB4eAAMZTgAAAACQAgE5AAMNADdQMzIoZABBQlwAAAAAlw==";
+/* SET coalescing (userSet), per control key: last = when the user last changed it (touched()), sent = the value last
+ requested. A value equal to the last request is skipped only while that request is still pending (queued or in
+ flight): it carries it already. Once answered, the device may hold something else under the same key (another track
+ or sound under the controls, a knob turned on the FM-1), so the same value is sent again (2.6: setting DIV 1/8 on
+ one track, then 1/8 on another, sent nothing the second time). clear(): another track / sound / device */
+class SetGate {
+ constructor() { this.m = new Map(); }
+ get(k) { return this.m.get(k); }
+ user(k, v, pending, now) {
+ let st = this.m.get(k);
+ if (!st) this.m.set(k, (st = { last: 0, sent: null }));
+ st.last = now;
+ return !(pending && v === st.sent);
+ }
+ clear() { this.m.clear(); }
+}
/*PROTO-END*/
/* ===================================================================== UI === */
@@ -3486,6 +3567,7 @@ const TEXT = {
loadedUser: "読み込みました: ", reloaded: "本体で音色が変わったので読み直しました", readingBank: "スロットを読み込み中",
badEngine: "このファームウェアにないエンジンです: ", flashFail: "書き込みに失敗しました(rc {rc})",
installer: "SLOOP インストーラー",
+ offline: "エディタをダウンロード(オフライン用:Chrome / Edge で開く)",
tabSeq: "シーケンサー", tabTracks: "トラック", tabSettings: "設定",
navTrack: "トラック", navSounds: "サウンド", navDevice: "本体", tabKits: "ドラムキット", fm1: "FM-1",
stepList: "ステップ一覧(音名を入力)", stepsOf: "{n} ステップ", fontCredit: "フォント: Terminus(SIL OFL 1.1)",
@@ -3518,6 +3600,7 @@ const TEXT = {
bkRestoring: "復元中 ", bkRestored: "復元しました", bkConfirm: "FM-1 の今の内容をすべてこのバックアップで置き換えます。続けますか?",
bkBad: "SLOOP のバックアップファイルではないか、壊れています: ", bkStop: "FM-1 の再生を止めてから、もう一度復元してください。",
bkStale: "本体の内容が途中で変わりました。もう一度バックアップしてください: ", bkRead: "読み取りエラー: ", bkWrite: "書き込みエラー: ", bkRc4: "フラッシュがありません",
+ bkNewer: "新しい SLOOP のバックアップです。先に FM-1 をアップデートしてから復元してください(何も変更していません): ",
system: "システム", firmware: "ファームウェア", sync: "同期", tracksN: "トラック", stepsN: "ステップ数", enginesL: "エンジン",
smpSlots: "サンプルスロット", userBank: "ユーザープリセット", none: "なし",
fm6Title: "FM6 の音色(6 オペレーター)", fm6Help: "FM6 エンジンの音色をまるごと編集します。本体のノブ(EDIT の 8 つ)はこの音色の上にかかるマクロです。トラックへ送るとすぐ鳴り、PTCH を回すか別の音を読み込むまでそのトラックの音色になります(プロジェクトは PTCH だけを保存します)。バンク(B1〜B27)に保存すると PTCH で呼び出せます(本体を停止してから)。",
@@ -3684,6 +3767,7 @@ const TEXT = {
loadedUser: "Loaded ", reloaded: "The sound changed on the device: read again", readingBank: "Reading the slots",
badEngine: "This firmware has no such engine: ", flashFail: "Write failed (rc {rc})",
installer: "SLOOP installer",
+ offline: "Download the editor (offline: open it in Chrome or Edge)",
tabSeq: "Sequencer", tabTracks: "Tracks", tabSettings: "Settings",
navTrack: "Track", navSounds: "Sounds", navDevice: "Device", tabKits: "Drum kit", fm1: "FM-1",
stepList: "Step list (type note names)", stepsOf: "{n} steps", fontCredit: "Font: Terminus (SIL OFL 1.1)",
@@ -3716,6 +3800,7 @@ const TEXT = {
bkRestoring: "Restoring ", bkRestored: "Restored", bkConfirm: "Replace everything on the FM-1 with this backup?",
bkBad: "Not a SLOOP backup, or damaged: ", bkStop: "Stop the FM-1 (PLAY), then restore again.",
bkStale: "The FM-1 changed during the backup; back up again: ", bkRead: "Read error: ", bkWrite: "Write error: ", bkRc4: "No flash",
+ bkNewer: "This backup comes from a newer SLOOP: update the FM-1 first, then restore. Nothing was changed: ",
system: "System", firmware: "Firmware", sync: "Sync", tracksN: "Tracks", stepsN: "Steps", enginesL: "Engines",
smpSlots: "Sample slots", userBank: "User presets", none: "none",
fm6Title: "FM6 patch (six operators)", fm6Help: "Edit the whole patch of the FM6 engine. The device's knobs (the eight EDIT values) are macros on top of it. Sent to a track it plays at once and stays that track's patch until PTCH turns or another sound loads (a project keeps PTCH only); stored in the bank (B1..B27) it is a PTCH value (stop the device first).",
@@ -3926,7 +4011,7 @@ let busy = 0; /* multi-request operations in progress: no polling */
let dragging = null; /* key of the slider being dragged */
let wantConnected = false;
const ctl = new Map(); /* key "s:id" -> {input, out, desc, scope, id, row} */
-const sets = new Map(); /* key -> {last: time of the user's last change, sent: the value last requested} */
+const sets = new SetGate(); /* key -> {last: time of the user's last change, sent: the value last requested} */
let needReload = false; /* a RELOAD push came: re-read DESC, DUMP and steps when free */
let lastDump = 0; /* Date.now() of the last DUMP */
/* the device also pushes RELOAD after loads the editor asked for (SET of G_ENGSEL, PRESET, PROJECT load,
@@ -3941,23 +4026,33 @@ function selfLoad() {
const stepEdit = new Map(); /* index -> time of the last edit */
/* parameter ids (firmware/src/core.h); used only when P_COUNT / G_COUNT match */
-const EXPECT = { pcount: 61, gcount: [32, 33], pe0: 53 }; /* gcount 33: 2.5's drum DLY (G_DRDLY) */
+/* 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], pe0: [53, 63] }; /* gcount 33: 2.5's drum DLY (G_DRDLY); 45: 2.6's GLO > MIDI, TEXTURE, BEND */
const P = { LEVEL: 0, SLEN: 29, CHORD: 49 };
-const LAYOUT = (pe0) => [
- { t: "ENV", pages: [["ENV", 0, [1, 2, 3, 4]], ["ENV DEST", 0, [5, 6, 7, 8]]] },
- { t: "LFO", pages: [["LFO", 0, [9, 10, 11, 12]], ["LFO DEST", 0, [13, 14, 15, 16]]] },
- { t: "EDIT", engine: true, pages: [["EDIT 1", 0, [pe0, pe0 + 1, pe0 + 2, pe0 + 3]], ["EDIT 2", 0, [pe0 + 4, pe0 + 5, pe0 + 6, pe0 + 7]]] },
- { t: "VOICE", pages: [["LEVEL", 0, [0]], ["VOICE", 0, [37, 38, 41, 42]], ["VOICE 2", 0, [43, 44, 39, 40]]] },
- { t: "FX", pages: [["FX", 0, [33, 34, 35, 36]], ["FILTER", 0, [50]], ["SLICER", 0, [45, 46, 47, 48]], ["DLY", 1, [4, 5, 6, 7]], ["REV/CHO", 1, [8, 9, 10, 11]]] },
- { t: "SEL", pages: [["SEL", 0, [25, 26, 27, 49]], ["SEL 2", 0, [28, 51, 52]]] },
- { t: "ARP", pages: [["ARP", 0, [17, 18, 19, 20]], ["ARP 2", 0, [21, 22, 23, 24]]] },
- { t: "SEQ PATTERN", tab: "seqgroups", pages: [["PATTERN", 0, [29, 30, 31, 32]]] },
- { t: "GLOBAL", tab: "setgroups", pages: [["GLOBAL", 1, [0, 1, 2, 3]]] },
- { t: "MASTER", tab: "setgroups", pages: [["MASTER", 1, [27, 28, 29, 30]]] },
- { t: "DRUMS", tab: "setgroups", pages: [["DRUMS", 1, [24, 25, 26, 32]]] },
-];
+const LAYOUT = (pe0) => {
+ const v251 = pe0 >= 63; /* (2.6: the pages the device has for the new parameters) */
+ const opt = (yes, ...pages) => (yes ? pages : []);
+ return [
+ { t: "ENV", pages: [["ENV", 0, [1, 2, 3, 4]], ["ENV DEST", 0, [5, 6, 7, 8]], ...opt(v251, ["ENV SYNC", 0, [59]])] },
+ { t: "LFO", pages: [["LFO", 0, [9, 10, 11, 12]], ...opt(v251, ["LFO 2", 0, [60, 61, 62]]), ["LFO DEST", 0, [13, 14, 15, 16]]] },
+ { t: "EDIT", engine: true, pages: [["EDIT 1", 0, [pe0, pe0 + 1, pe0 + 2, pe0 + 3]], ["EDIT 2", 0, [pe0 + 4, pe0 + 5, pe0 + 6, pe0 + 7]],
+ ...opt(v251, ["FILTER", 0, [58], 0])] }, /* (4th: the engine it is shown with: ANALOG's filter TYPE) */
+ { t: "VOICE", pages: [["LEVEL", 0, [0]], ["VOICE", 0, [37, 38, 41, 42]], ["VOICE 2", 0, [43, 44, 39, 40]]] },
+ { t: "FX", pages: [["FX", 0, [33, 34, 35, 36]], ["FILTER", 0, [50]], ["SLICER", 0, [45, 46, 47, 48]],
+ ...opt(v251, ["INSERT", 0, [53, 54, 55, 56]], ["INSERT 2", 0, [57]]), ["DLY", 1, [4, 5, 6, 7]], ["REV/CHO", 1, [8, 9, 10, 11]]] },
+ { t: "SEL", pages: [["SEL", 0, [25, 26, 27, 49]], ["SEL 2", 0, [28, 51, 52]]] },
+ { t: "ARP", pages: [["ARP", 0, [17, 18, 19, 20]], ["ARP 2", 0, [21, 22, 23, 24]]] },
+ { t: "SEQ PATTERN", tab: "seqgroups", pages: [["PATTERN", 0, [29, 30, 31, 32]]] },
+ { t: "GLOBAL", tab: "setgroups", pages: [["GLOBAL", 1, [0, 1, 2, 3]]] },
+ { t: "MASTER", tab: "setgroups", pages: [["MASTER", 1, [27, 28, 29, 30]]] },
+ { t: "DRUMS", tab: "setgroups", pages: [["DRUMS", 1, [24, 25, 26, 32]]] },
+ ...opt(v251, { t: "MIDI", tab: "setgroups", pages: [["MIDI", 1, [33, 34, 35, 24]], ["MIDI 2", 1, [14, 36, 12, 44]]] }), /* CH1 CH2 CH3 CH4 (drums);
+ * IN OTHER OUT BEND (settings of the FM-1; IN and OUT: the FM-1 only, G_SKIP) */
+ ...opt(v251, { t: "TEXTURE", tab: "setgroups", pages: [["TEXTURE", 1, [37, 38, 39, 40]], ["TEXTURE 2", 1, [41, 42, 43]]] }), /* the bed */
+ ];
+};
/* globals that are actions or placeholders on the device: buttons instead, or hidden */
-const G_SKIP = new Set(["SLOT", "NAME", "LOAD", "SAVE", "ENG", "SET", "CLRSQ", "INIT", "MIDI", "SYNC", "ROUT", "IN", "CPU", "NEW"]);
+const G_SKIP = new Set(["SLOT", "NAME", "LOAD", "SAVE", "ENG", "SET", "CLRSQ", "INIT", "MIDI", "OUT", "SYNC", "ROUT", "IN", "CPU", "NEW"]);
const key = (s, id) => s + ":" + id;
const gEng = () => { const i = dev.gdesc.findIndex((d) => d && d.label === "ENG"); return i >= 0 ? i : 20; };
const pSlen = () => { const i = dev.pdesc.findIndex((d) => d && d.fmt === F.STEPS); return i >= 0 ? i : P.SLEN; };
@@ -3999,6 +4094,7 @@ async function connect() {
if (input.open) await input.open().catch(() => {});
dev = { link, input, output, info: null, pdesc: [], gdesc: [], names: [], dump: null, steps: [], slotUsed: [null, null, null, null],
keys: null, watch: false, bank: null };
+ sets.clear(); /* (another FM-1, maybe) */
setLabel($("connect"), t("disconnect"));
renderLive();
await load(dev);
@@ -4238,13 +4334,15 @@ function buildGroups() {
/* Sound: the selected track's parameters; Sequencer: its pattern settings; Settings: globals and drums */
const groups = { groups: [], seqgroups: [], setgroups: [] };
const { info } = dev;
- if (info.pcount === EXPECT.pcount && EXPECT.gcount.includes(info.gcount) && info.pe0 === EXPECT.pe0) {
+ const known = EXPECT.pcount.indexOf(info.pcount);
+ if (known >= 0 && EXPECT.gcount.includes(info.gcount) && info.pe0 === EXPECT.pe0[known]) {
for (const g of LAYOUT(info.pe0)) {
/* a card per button of the device (ENV, LFO, EDIT ...), its pages as rows of four knobs, one colour per knob */
const div = el("div", { class: "group" }, el("h2", { ic: HEAD_IC[g.t] },
g.engine ? `EDIT ${info.engines[dev.dump.engine] || ""}` : g.t));
let pages = 0;
- for (const [title, s, ids] of g.pages) {
+ for (const [title, s, ids, onlyEng] of g.pages) {
+ if (onlyEng != null && dev.dump.engine !== onlyEng) continue;
const rows = ids.map((id) => paramRow(s, id)).filter(Boolean);
if (!rows.length) continue;
const tt = g.engine && (dev.titles[dev.dump.engine] || [])[g.pages.findIndex((x) => x[0] === title)];
@@ -4357,13 +4455,15 @@ function showValue(k, v, force) {
c.input.style.setProperty("--p", Math.max(p, z).toFixed(1) + "%");
}
}
+/* a SET of this control queued or in flight */
+function pendingSet(k) { return !!dev && (dev.link.hasQueued(k) || (!!dev.link.cur && dev.link.cur.key === k)); }
/* the user is working on this control: polling and pushes must not move it */
function touched(k) {
const c = ctl.get(k), st = sets.get(k);
if (dragging === k) return true;
if (c && c.input.tagName === "SELECT" && document.activeElement === c.input) return true;
if (st && performance.now() - st.last < 600) return true;
- return !!dev && (dev.link.hasQueued(k) || (!!dev.link.cur && dev.link.cur.key === k));
+ return pendingSet(k);
}
window.addEventListener("pointerup", () => { if (dragging) { const k = dragging; dragging = null; const c = ctl.get(k); if (c) userSet(c.scope, c.id, +c.input.value, true); } });
@@ -4378,10 +4478,7 @@ function userSet(s, id, v, final) {
showValue(k, v, false);
mixFromDump();
if (!s && id === pSlen()) lenChanged(); /* (2.5: the grid follows LEN at once) */
- let st = sets.get(k);
- if (!st) sets.set(k, (st = { last: 0, sent: null }));
- st.last = performance.now();
- if (v === st.sent) return; /* the last request already carries it */
+ if (!sets.user(k, v, pendingSet(k), performance.now())) return; /* the pending request already carries it */
sendSet(s, id, k);
}
async function sendSet(s, id, k) {
@@ -4415,6 +4512,8 @@ async function choosePreset(e, p) {
}
async function afterSoundChange(msg = "ready") {
needReload = false; /* this re-reads everything a RELOAD asks for */
+ sets.clear(); /* another track / sound under the controls: a value equal to the one
+ sent before is sent again, and they show the device's at once */
dev.dump = await getDump();
await rereadEngineDesc();
updateBrowser();
@@ -6728,6 +6827,7 @@ $("savefile").addEventListener("click", () => {
if (!dev) return;
const engine = dev.dump.engine, preset = dev.dump.preset;
const data = { format: "felucca-patch", version: 1, firmware: dev.info.version,
+ pCount: dev.info.pcount, pE0: dev.info.pe0, /* (2.6: read by count on another version, patchByCount) */
engineName: dev.info.engines[engine], presetName: (dev.names[engine] || [])[preset],
engine, preset, p: dev.dump.p.slice(), g: dev.dump.g.slice(),
steps: dev.steps.map((s) => ({ n: s.n, notes: s.notes.slice(), time: s.time, flags: s.flags, vel: s.vel })) };
@@ -6749,12 +6849,12 @@ $("file").addEventListener("change", async () => {
await rq(req.preset(data.engine, data.preset));
dev.dump = await getDump();
await rereadEngineDesc();
- const n = Math.min(data.p.length, dev.info.pcount);
+ const pv = patchByCount(data.p, data.pE0, dev.info.pcount), n = pv.length; /* (a file of another version) */
for (let i = 0; i < n; i++) {
const d = dev.pdesc[i];
- if (!visible(d) || !Number.isFinite(data.p[i])) continue;
+ if (!visible(d) || !Number.isFinite(pv[i])) continue;
if (i % 8 === 0) sayK("applying", `${i}/${n}`);
- await rq(req.set(0, i, data.p[i]));
+ await rq(req.set(0, i, pv[i]));
}
if (Array.isArray(data.steps)) {
const m = Math.min(data.steps.length, dev.info.nstep);
diff --git a/web/fm1ota.js b/web/fm1ota.js
index 14a9857..8c54e18 100644
--- a/web/fm1ota.js
+++ b/web/fm1ota.js
@@ -14,6 +14,10 @@ const IS_OTA = (id) => /^ota-/i.test(id.model);
// the update loader of SLOOP / Felucca packages ("ota-FM-1_9XX"). A device left in the update mode of another
// firmware (the stock updater's loader) is never written: its loader may lay the image out differently.
export const OUR_LOADER = (id) => /^ota-FM-1_9\d\d$/i.test(id.text);
+// the MIDI ports the installer may probe (never other gear): the FM-1 under SLOOP / Felucca ("Felucca"), under
+// CLIPPER ("Clipper", its sister firmware), under a firmware named after itself ("SLOOP"), the update loaders, and
+// the names Windows / macOS give the stock firmware
+export const FM1_PORT = /fm-1|felucca|sloop|clipper|ota|composite|sinco|usb-midi/i;
// errors carry a code the pages translate: notfound, model, stopped, noloader, lost, noreturn,
// mismatch (detail: the identity the device reports), badreq, foreign (detail: the loader's identity)
@@ -121,7 +125,7 @@ export class Updater {
const outs = [...this.access.outputs.values()];
for (const input of this.access.inputs.values()) {
if (input.state === "disconnected") continue;
- if (!/fm-1|felucca|ota|composite|sinco|usb-midi/i.test(input.name || "")) continue; // never probe other gear
+ 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;
try { await input.open(); await output.open(); } catch (_) { continue; }
@@ -133,6 +137,12 @@ export class Updater {
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) {
const end = Date.now() + ms;
while (Date.now() < end) {
@@ -176,7 +186,7 @@ export class Updater {
async install(image, product, onStep) {
const step = onStep || (() => {});
const dev = await this.find((id) => !IS_OTA(id));
- if (!dev) throw fail("notfound", "FM-1 not found (USB cable, and no other app using it?)");
+ if (!dev) throw fail("notfound", "FM-1 not found (USB cable, and no other app using it?)", this.seen());
const [model] = product.split("_");
if (dev.id.model !== model) { dev.link.close(); throw fail("model", `the device is ${dev.id.text}, the package is for ${product}`); }
step("start", dev.id.text);
diff --git a/web/index_pkg.html b/web/index_pkg.html
index 790a7ec..5ca35a6 100644
--- a/web/index_pkg.html
+++ b/web/index_pkg.html
@@ -56,11 +56,11 @@
Firmware for the M-VAVE FM-1
-
A groovebox you play live: four tracks — three synths and a drum machine — 12 synth engines (with six-operator FM and DX7 patches), 153 sounds, 37 drum kits from 808 to techno, amapiano and ambient, your own samples and drum kits, 16 punch-in effects. House, techno, hip-hop, drum & bass, synthwave, lo-fi, ambient: make what you want. No factory patterns, nothing to load: everything you hear, you play.
+
A groovebox you play live: four tracks — three synths and a drum machine — 12 synth engines (with six-operator FM and DX7 patches), 153 sounds, 37 drum kits from 808 to techno, amapiano and ambient, your own samples and drum kits, 27 punch-in effects. House, techno, hip-hop, drum & bass, synthwave, lo-fi, ambient: make what you want. No factory patterns, nothing to load: everything you hear, you play.
153sounds, 12 engines, your samples
37drum kits, 909 to afro, + your own
-
16punch-in fx: hold fx + key
+
27punch-in fx: hold fx + key
recno click: the loop follows you
@@ -70,6 +70,7 @@
+
@@ -101,6 +102,7 @@ const TEXT = {
warn: "書き込み中は USB を抜かないでください。",
install: "インストール", other: "English",
editor: "エディタ(インストール後、パソコンから音色やシーケンスを編集)",
+ edOffline: "エディタをダウンロード(インターネットなしで使う:ファイルを Chrome / Edge で開く)",
direct: "USB ケーブルはパソコンに直接つないでください。Probe や Transporter などの機材は不要です。",
brick: "万一インストールに失敗して起動しなくなった場合は、復旧に Transporter が必要です:",
beta: "これはベータ版で、不安定な場合があります。このカスタムファームウェアを使ったことで FM-1 が壊れたり不具合が起きたりしても、作者は一切の責任を負いません。自己責任でお使いください。",
@@ -135,6 +137,7 @@ const TEXT = {
warn: "Do not unplug the USB cable while writing.",
install: "Install", other: "日本語",
editor: "Editor (after installing: edit sounds and sequences from the computer)",
+ edOffline: "Download the editor to use it without internet (open the file in Chrome or Edge)",
direct: "Connect the USB cable directly to the computer. No probe or Transporter is needed.",
brick: "If an install fails and the FM-1 no longer starts, recovering it needs a Transporter:",
beta: "This is a beta and may be unstable. The author accepts no responsibility if your FM-1 is damaged or misbehaves because of this custom firmware. Use it at your own risk.",
diff --git a/web/make_site.py b/web/make_site.py
index 2d044df..c16e201 100644
--- a/web/make_site.py
+++ b/web/make_site.py
@@ -7,6 +7,9 @@
firmware/felucca-VER.fwsc the package
webapp/installer/index.html index_pkg.html with fm1pkg.js, fm1ota.js and the metadata inlined
webapp/editor/index.html editor.html (+ fukiai.ttf, FUKIAI-LICENSE.txt)
+ webapp/editor/sloop-editor.html the editor in one file, for offline use (SLOOP 2.6): its icon font inlined,
+ its links to the installer and the font licence online; opened from the disk in
+ Chrome / Edge (file:// is a secure context: Web MIDI asks for permission)
src/ not touched
web/make_site.py build/felucca-X.Y.fwsc X.Y OUT_DIR [--beta]
@@ -15,6 +18,7 @@
The package identity (FM-1_9xx) is read from the package; the device reports it
after the install.
"""
+import base64
import hashlib
import json
import re
@@ -23,6 +27,22 @@ import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
+ONLINE = "https://isod89.github.io/sloop-fm1/" # (the offline editor's links)
+
+
+def offline_editor(html):
+ """editor.html as one file for the disk: the icon font inlined, the download link out, the relative links online"""
+ font = base64.b64encode((HERE / "fukiai.ttf").read_bytes()).decode()
+ for a, b in (('url("fukiai.ttf")', 'url(data:font/ttf;base64,' + font + ')'),
+ ('href="../installer/"', 'href="' + ONLINE + 'webapp/installer/" target="_blank" rel="noopener"'),
+ ('href="FUKIAI-LICENSE.txt"', 'href="' + ONLINE + 'webapp/editor/FUKIAI-LICENSE.txt" target="_blank" rel="noopener"')):
+ if html.count(a) != 1:
+ raise SystemExit(f"editor.html must contain {a} once; update make_site.py")
+ html = html.replace(a, b)
+ html, n = re.subn(r".*?", "", html, flags=re.S)
+ if n != 1:
+ raise SystemExit("editor.html must contain ... once; update make_site.py")
+ return html
BLOCKS, BLK, KEEP = 20, 0x30, 0x2F
@@ -72,9 +92,14 @@ def main(pkg, version, out):
html = html.replace("", banner)
for old in list(fw.glob("felucca-*.fwsc")) + list(fw.glob("sloop-*.fwsc")): # one package: the current one
old.unlink()
- (inst / "index.html").write_text(html, encoding="utf-8")
shutil.copy(pkg, fw / name)
- shutil.copy(HERE / "editor.html", ed / "index.html")
+ ed_html = (HERE / "editor.html").read_text(encoding="utf-8")
+ dl = f'download="sloop-editor-{re.sub(r"[^A-Za-z0-9.-]", "-", version)}.html"'
+ if ed_html.count('download="sloop-editor.html"') != 1 or html.count('download="sloop-editor.html"') != 1:
+ raise SystemExit('editor.html and index_pkg.html must link download="sloop-editor.html" once; update make_site.py')
+ (ed / "index.html").write_text(ed_html.replace('download="sloop-editor.html"', dl), encoding="utf-8")
+ (ed / "sloop-editor.html").write_text(offline_editor(ed_html), encoding="utf-8")
+ (inst / "index.html").write_text(html.replace('download="sloop-editor.html"', dl), encoding="utf-8")
for f in ("fukiai.ttf", "FUKIAI-LICENSE.txt"):
if (HERE / f).exists():
shutil.copy(HERE / f, ed / f)
diff --git a/web/test_web.mjs b/web/test_web.mjs
index 5c8caa4..bf2d97a 100644
--- a/web/test_web.mjs
+++ b/web/test_web.mjs
@@ -17,7 +17,7 @@ import { join } from "node:path";
import { fileURLToPath } from "node:url";
import vm from "node:vm";
import { logicalImage, productOf } from "./fm1pkg.js";
-import { Updater, pack7, unpack7 } from "./fm1ota.js";
+import { Updater, pack7, unpack7, FM1_PORT } from "./fm1ota.js";
let failed = 0;
const ok = (cond, what) => { console.log(`${what.padEnd(64)} ${cond ? "ok" : "FAIL"}`); if (!cond) failed++; };
@@ -34,7 +34,7 @@ const E = vm.runInNewContext(proto + `
CHOP, chopNovelty, chopHits, chopSnap, chopGrid, chopEqual, chopList, chopPick, chopFit, chopZones, wavFile, zipStore, crc32,
UP, bank, capturePatch, auditionPatch, startWatch, libraryFile, readLibraryFile, paramKeys, patternFromSteps, stepsFromPattern, upName,
mixer, GM_DRUM, drumName, parseNotes, fmtValue, F, DRUM_LANES, LV_NAMES, emptyDrum, lockable, MICRO, FC, fillGet, fillSet, pack7, unpack7,
- backupCapture, backupRestore, backupObjects, b64enc, b64dec, FM6, KIT, kitPad, kitZones, kitLen, kitBytes, kitFit, kitSplit, kitLaneOf, kitPlace, zipRead, ROLL, SMF, ARR, mockSettings, fm6CartWrite, fm6CartPreset, fm6CartSlots, fm6CartPresets, DSYN, DSYN_MOCK_NAMES, DSYN_MOCK_KITS })`,
+ backupCapture, backupRestore, backupObjects, b64enc, b64dec, FM6, KIT, kitPad, kitZones, kitLen, kitBytes, kitFit, kitSplit, kitLaneOf, kitPlace, zipRead, ROLL, SMF, ARR, mockSettings, fm6CartWrite, fm6CartPreset, fm6CartSlots, fm6CartPresets, DSYN, DSYN_MOCK_NAMES, DSYN_MOCK_KITS, SetGate, bkProjFormat, bkDevFormat, bkFwAtLeast })`,
{ setTimeout, clearTimeout, setInterval, clearInterval, console, TextEncoder, TextDecoder, Blob, Response, DecompressionStream });
async function editorMock() {
@@ -44,7 +44,7 @@ async function editorMock() {
inp.onmidimessage = (e) => link.receive(e.data);
const rq = async (r, o) => link.request(r, o);
const info = E.parse[E.CMD.INFO](await rq(E.req.info()));
- ok(info.nengines === 12 && info.engines[9] === "FM6" && info.engines[10] === "PHYS" && info.engines[11] === "NOISE" && info.engines[5] === "VOICE" && info.engines[6] === "TRIO" && info.engines[7] === "WHEEL" && info.engines[8] === "GRAIN" && info.pcount === 61 && info.pe0 === 53 && info.engines[4] === "SAMPLE",
+ ok(info.nengines === 12 && info.engines[9] === "FM6" && info.engines[10] === "PHYS" && info.engines[11] === "NOISE" && info.engines[5] === "VOICE" && info.engines[6] === "TRIO" && info.engines[7] === "WHEEL" && info.engines[8] === "GRAIN" && info.pcount === 71 && info.pe0 === 63 && info.engines[4] === "SAMPLE",
"editor: INFO");
let descs = 0;
for (let i = 0; i < info.pcount; i++) if (E.parse[E.CMD.DESC](await rq(E.req.desc(0, i))).label) descs++;
@@ -198,7 +198,7 @@ async function editorLibrarian() {
const ctx = { keys, engines: info.engines, firmware: info.version, pe0: info.pe0 };
const pts = [cap, { ...bass, engineName: info.engines[bass.engine], tags: ["bass", "device"] }];
const file = JSON.parse(JSON.stringify(E.libraryFile("library", pts, ctx)));
- ok(file.format === "felucca-library" && file.version === 1 && file.pCount === 61 && file.paramLabels.length === 61 && file.engines.length === 12,
+ ok(file.format === "felucca-library" && file.version === 1 && file.pCount === 71 && file.paramLabels.length === 71 && file.engines.length === 12,
"library file: versioned, with P_COUNT, labels and engines");
const back = E.readLibraryFile(file, ctx);
ok(back.patches.length === 2 && !back.skipped && eq(back.patches[0].p, cap.p) && eq(back.patches[1].p, bass.p)
@@ -209,14 +209,30 @@ async function editorLibrarian() {
const eng2 = ["PHASE", "ANALOG", "SAMPLE"];
const fut = E.readLibraryFile(file, { keys: keys2, engines: eng2 });
const p0 = fut.patches[0].p;
- ok(fut.patches.length === 2 && p0.length === 62 && p0[5] === null && p0[6] === cap.p[5] && p0[61] === cap.p[60]
+ ok(fut.patches.length === 2 && p0.length === 72 && p0[5] === null && p0[6] === cap.p[5] && p0[71] === cap.p[70]
&& fut.patches[0].engine === 1 && fut.patches[1].engine === 0, "library file: other ids / engine order mapped by label and name");
+ /* a library written by 2.5 (61 parameters, the engine's from 53) read by 2.6 (71, from 63): the engine's values
+ * land on the new ids, the 2.6 parameters stay unset (their defaults) */
+ const keysOld = [...keys.slice(0, 53), ...keys.slice(63)];
+ const oldFile = JSON.parse(JSON.stringify(E.libraryFile("old", [{ ...cap, p: [...cap.p.slice(0, 53), ...cap.p.slice(63)] }],
+ { keys: keysOld, engines: info.engines, firmware: "SLOOP 2.5", pe0: 53 })));
+ const up = E.readLibraryFile(oldFile, ctx), pu = up.patches[0].p;
+ ok(oldFile.pCount === 61 && pu.length === 71 && pu.slice(63).join() === cap.p.slice(63).join() && pu[52] === cap.p[52]
+ && pu.slice(53, 63).every((x) => x == null), "library file: a 2.5 one (61 parameters) read by 2.6: E1..E8 at 63..70, the new ones unset");
const lost = E.readLibraryFile({ ...file, patches: [{ ...file.patches[0], engineName: "WAVETABLE" }] }, ctx);
ok(lost.patches.length === 0 && lost.skipped === 1, "library file: a patch for an unknown engine is skipped");
const bankFile = E.libraryFile("bank", [{ ...g, engineName: "ANALOG", slot: 10 }], ctx);
ok(bankFile.kind === "bank" && bankFile.patches[0].slot === 10 && E.readLibraryFile(bankFile, ctx).patches[0].slot === 10, "library file: bank export keeps slot numbers");
const old = E.readLibraryFile({ format: "felucca-patch", version: 1, engine: 0, preset: 4, engineName: "ANALOG", presetName: "ACID", p: d2.p, steps: E.stepsFromPattern(cap.pattern) }, ctx);
ok(old.patches.length === 1 && eq(old.patches[0].p, d2.p) && js(old.patches[0].pattern) === js(cap.pattern), "library file: reads the old \"Save to file\" format");
+ /* a "Save to file" of 2.5 (61 values, the engine's from 53, no pCount) on 2.6: the engine's 8 at 63..70 */
+ const p61 = [...d2.p.slice(0, 53), ...d2.p.slice(63)];
+ const o61 = E.readLibraryFile({ format: "felucca-patch", version: 1, engine: 0, preset: 4, engineName: "ANALOG", p: p61 }, ctx).patches[0].p;
+ const p71 = E.readLibraryFile({ format: "felucca-patch", version: 1, engine: 0, preset: 4, engineName: "ANALOG", p: d2.p, pCount: 71, pE0: 63 },
+ { ...ctx, keys: keys.slice(0, 53).concat(keys.slice(63)) }).patches[0].p;
+ ok(o61.length === 71 && o61.slice(63).join() === d2.p.slice(63).join() && o61.slice(53, 63).every((x) => x == null) && o61[52] === d2.p[52]
+ && p71.length === 61 && p71.slice(53).join() === d2.p.slice(63).join(),
+ "library file: a \"Save to file\" of another version is read by count (the engine's 8 in their place, 61 <-> 71)");
let threw = false;
try { E.readLibraryFile({ format: "something" }, ctx); } catch (e) { threw = true; }
ok(threw, "library file: unknown format -> error");
@@ -235,7 +251,7 @@ async function editorLive() {
const dump = E.parse[C.DUMP](await pend, info);
const ch = ev.pushes.find((f) => f.cmd === C.CHANGED);
const cv = ch && E.parse[C.CHANGED](ch.a);
- ok(dump.p.length === 61 && ch && ch.pending === C.DUMP && cv.scope === 0 && cv.id === 9 && cv.value === kn.value && !ev.unknown.length,
+ ok(dump.p.length === 71 && ch && ch.pending === C.DUMP && cv.scope === 0 && cv.id === 9 && cv.value === kn.value && !ev.unknown.length,
"live: CHANGED while DUMP waits -> push handler, reply still matched");
const rl = m.sim.reload();
m.sim.step(3);
@@ -343,6 +359,44 @@ async function editorTracks() {
done();
}
+/* ------------------------------- editor 2.6: SET coalescing per control (SetGate) --- */
+/* a user report: DIV 1/8 on the drum track, then 1/8 on a synth track: the second SET never left (the coalescing kept the
+ last value sent per control, whatever the track). userSet as editor.html has it, on the mock */
+async function editorSetGate() {
+ const C = E.CMD;
+ const { link, rq, sent, done } = attachMock({});
+ const info = E.parse[C.INFO](await rq(E.req.info()));
+ let div = -1;
+ for (let i = 0; i < info.pcount && div < 0; i++) if (E.parse[C.DESC](await rq(E.req.desc(0, i))).label === "DIV") div = i;
+ const gate = new E.SetGate(), k = "0:" + div;
+ const pending = (key) => link.hasQueued(key) || (!!link.cur && link.cur.key === key);
+ const user = (v) => { /* editor.html userSet / sendSet */
+ if (!gate.user(k, v, pending(k), Date.now())) return null;
+ gate.get(k).sent = v;
+ return rq(E.req.set(0, div, v), { key: k });
+ };
+ const divOf = async (t) => E.parse[C.TRACK_DUMP](await rq(E.req.trackDump(t)), info).p[div];
+ await rq(E.req.track(3));
+ const d0 = await divOf(0), want = d0 === 1 ? 2 : 1;
+ await user(want);
+ await rq(E.req.track(0)); /* (selectTrack -> afterSoundChange: gate.clear()) */
+ const n0 = sent[C.SET] || 0;
+ const p = user(want); /* the same value, track 1: sent, even without the clear */
+ if (p) await p;
+ ok(div >= 0 && (await divOf(3)) === want && (await divOf(0)) === want && sent[C.SET] === n0 + 1,
+ "SetGate: DIV set on the drum track, then the same DIV on track 1: sent, both set");
+ gate.clear();
+ ok(gate.get(k) === undefined, "SetGate: clear() forgets every control (another track / sound / FM-1)");
+ /* a drag: while a SET is pending, the same value is not queued again; a new one replaces the queued one */
+ const a = user(5), b = user(5), c = user(6), d = user(6);
+ ok(a && b === null && c && d === null, "SetGate: pending: the same value skipped, a new value sent (queued)");
+ await Promise.all([a, c]);
+ ok((await divOf(0)) === 6, "SetGate: the last value wins");
+ ok(user(6) !== null, "SetGate: answered: the same value sent again (a knob may have moved it on the FM-1)");
+ await rq(E.req.set(0, div, d0));
+ done();
+}
+
/* ------------------------------------------------ editor v3: the mixer (Tracks tab) --- */
async function editorMixer() {
const C = E.CMD;
@@ -524,7 +578,8 @@ async function editorBackup() {
const info = E.parse[C.INFO](await rq(E.req.info()));
ok(info.proto >= 6, "backup: INFO protocol v6 or later");
const ec = readFileSync(join(HERE, "../firmware/src/editor.c"), "utf8");
- ok(/ED_BK_IDS\[\] = \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 32, 33, 34, 35\}/.test(ec), "backup: the object ids == editor.c ED_BK_IDS (35: USR4, 9: SYN kits)");
+ ok(/ED_BK_IDS\[\] = \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 32, 33, 34, 35\}/.test(ec) && E.backupObjects && [10].every((id) => ec.includes("id == 10u")),
+ "backup: the object ids == editor.c ED_BK_IDS (35: USR4, 9: SYN kits, 10: MIDI LEARN)");
await rq(E.req.upStore(3, "BACKUP ME"));
await rq(E.req.project(1, 2), { timeout: 4000, retries: 0 });
const s = Int16Array.from({ length: 3000 }, (_, i) => Math.round(8000 * Math.sin(i / 7)));
@@ -560,7 +615,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 === 10 && /SLOOP/.test(info.version) && info.pcount === 61 && info.gcount === 33 && info.pe0 === 53, "v5..v10: INFO ends with the protocol version (10: SYN kits); 33 globals (2.5: drum DLY)");
+ ok(info.proto === 10 && /SLOOP/.test(info.version) && info.pcount === 71 && info.gcount === 45 && info.pe0 === 63, "v5..v10: INFO ends with the protocol version (10: SYN kits); 45 globals (2.5: drum DLY; 2.6: GLO > MIDI, TEXTURE, BEND)");
/* 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] || "";
@@ -647,9 +702,11 @@ async function editorV7() {
const ids = {}; let n = 0;
for (const nm of (/enum \{\s*\/\* per-track parameters \*\/([^}]*)\}/.exec(ch) || [])[1].replace(/\/\*[\s\S]*?\*\//g, "").split(",").map((x) => x.trim()).filter(Boolean)) ids[nm] = n++;
const lockableC = (id) => id <= ids.P_LD_AMP || id === ids.P_SGATE || (id >= ids.P_DIST && id <= ids.P_REV) || id === ids.P_GLIDE || id === ids.P_PAN
- || id === ids.P_DETUNE || (id >= ids.P_SLCR && id <= ids.P_SLDEPTH) || (id >= ids.P_E0 && id <= ids.P_E7) || id === ids.P_TFLT;
- let same = ids.P_COUNT === 61;
- for (let id = 0; id < 61; id++) same = same && !!E.lockable(id) === !!lockableC(id);
+ || id === ids.P_DETUNE || (id >= ids.P_SLCR && id <= ids.P_SLDEPTH) || (id >= ids.P_E0 && id <= ids.P_E7) || id === ids.P_TFLT
+ || (id >= ids.P_IA && id <= ids.P_IMIX); /* 2.6: the INSERT's values */
+ let same = ids.P_COUNT === 71 && ids.P_E0 === 63;
+ for (let id = 0; id < 71; id++) same = same && !!E.lockable(id, 63) === !!lockableC(id);
+ for (let id = 0; id < 61; id++) same = same && !!E.lockable(id, 53) === (id >= 53 || !!lockableC(id)); /* (older firmware: E 53..60) */
ok(same && /id <= P_LD_AMP \|\| id == P_SGATE \|\| \(id >= P_DIST && id <= P_REV\) \|\| id == P_GLIDE \|\| id == P_PAN/.test(sc)
&& !E.lockable(ids.P_SLEN) && !E.lockable(ids.P_AMODE) && !E.lockable(ids.P_VOICE) && !E.lockable(ids.P_CHORD) && E.lockable(ids.P_E7),
"v7: the lockable parameters (editor == seq.c p_lockable; LEN, ARP, VOICE, CHORD are not)");
@@ -991,6 +1048,53 @@ async function editorDsyn() {
await E.backupRestore(rq, JSON.parse(JSON.stringify(A)));
const g2 = E.parse[C.DSYN_GET](await rq(E.req.dsynGet(DSYN.USER)));
ok(A.objects.some((x) => x.id === 9 && x.len === 1464) && g2.name === "BOOM", "dsyn: a backup holds the SYN kits (object 9); a restore puts them back");
+ /* 2.6: the MIDI LEARN map, object 10, in a backup only while something is learned */
+ const ml = new Uint8Array(40); /* (2.6: the map, then GLO > MIDI: 2, 11, 8, drums 10, BEND) */
+ ml[0] = 21, ml[1] = (1 << 1) | (34 << 1); /* CC 21 -> track 1 (bits 7..8), code 34 (bits 9..15) */
+ ml[32] = 2, ml[33] = 11, ml[34] = 8, ml[35] = 10, ml[36] = 2;
+ m.state.ml = ml.slice();
+ const M = await E.backupCapture(rq, info);
+ m.state.ml = new Uint8Array(32);
+ const N = await E.backupCapture(rq, info);
+ m.state.ml = new Uint8Array(40);
+ await E.backupRestore(rq, JSON.parse(JSON.stringify(M)));
+ ok(M.objects.some((x) => x.id === 10 && x.len === 40) && !N.objects.some((x) => x.id === 10) && m.state.ml[0] === 21 && m.state.ml[1] === ml[1]
+ && m.state.ml[33] === 11, "midi learn: a backup holds the learned CCs and GLO > MIDI (object 10, only when not the default); a restore puts them back");
+ { /* 2.6: a 2.6 backup without object 10 (the defaults then): restored as the defaults, not left as they are now */
+ const N1 = JSON.parse(JSON.stringify(N));
+ N1.firmware = "SLOOP 2.6";
+ await E.backupRestore(rq, N1);
+ ok(m.state.ml.length === 40 && m.state.ml.slice(0, 32).every((x) => x === 0) && m.state.ml[32] === 1 && m.state.ml[33] === 2
+ && m.state.ml[34] === 3 && m.state.ml[35] === 10 && m.state.ml[36] === 2,
+ "backup: a 2.6 one without object 10 resets MIDI LEARN and GLO > MIDI to the defaults (they were then)");
+ }
+ { /* 2.6: a backup with projects newer than the device reads: refused before anything is written */
+ const f6 = Uint8Array.of(0x36, 0x4E, 0x55, 0x46, 1), f5 = Uint8Array.of(0x35, 0x4E, 0x55, 0x46);
+ ok(E.bkProjFormat(f6) === 6 && E.bkProjFormat(f5) === 5 && E.bkProjFormat(Uint8Array.of(1, 2, 3, 4)) === 0
+ && E.bkDevFormat({ pcount: 71 }) === 6 && E.bkDevFormat({ pcount: 61 }) === 5 && E.bkDevFormat({ pcount: 53 }) === 4
+ && E.bkFwAtLeast("SLOOP 2.6", [2, 5, 1]) && E.bkFwAtLeast("SLOOP 2.6", [2, 5, 1]) && !E.bkFwAtLeast("SLOOP 2.5", [2, 5, 1])
+ && !E.bkFwAtLeast("FELUCCA SLOOP 2.0 (MOCK)", [2, 5, 1]),
+ "backup: the project format of an object, what a device reads (INFO), the firmware compared");
+ let err = null, writes = 0;
+ const rq25 = async (r, o) => { /* a 2.5 FM-1 (INFO: 61 parameters); anything else counts as a write */
+ if (r[0] === C.INFO) return { info25: { ...E.parse[C.INFO](await rq(r, o)), pcount: 61, pe0: 53 } };
+ writes++;
+ return rq(r, o);
+ };
+ const B6 = JSON.parse(JSON.stringify(M));
+ const p2 = B6.objects.find((x) => x.id === 2);
+ if (p2) {
+ const d = E.b64dec(p2.data);
+ d.set([0x36, 0x4E, 0x55, 0x46], 0);
+ p2.data = E.b64enc(d);
+ p2.crc = E.crc32(d) >>> 0;
+ }
+ const parse0 = E.parse[C.INFO];
+ E.parse[C.INFO] = (a) => (a && a.info25 ? a.info25 : parse0(a));
+ try { await E.backupRestore(rq25, B6); } catch (e) { err = e; }
+ E.parse[C.INFO] = parse0;
+ ok(!!p2 && err && err.code === "bkNewer" && writes === 0, "backup: 2.6 projects into a 2.5 FM-1: refused (bkNewer), nothing written");
+ }
done();
const old = attachMock({ v9: true });
const oi = E.parse[C.INFO](await old.rq(E.req.info()));
@@ -998,6 +1102,8 @@ async function editorDsyn() {
ok(oi.proto === 9 && !B.objects.some((x) => x.id === 9), "dsyn: a v9 device says 9 (the page says it needs 2.5), no object 9");
await E.backupRestore(old.rq, JSON.parse(JSON.stringify(A))); /* a 2.5 backup into a v9 device: object 9 skipped */
ok(true, "dsyn: a 2.5 backup restores into a v9 device (object 9 skipped)");
+ await E.backupRestore(old.rq, JSON.parse(JSON.stringify(M))); /* a 2.6 backup with CCs learned into an older device */
+ ok(true, "midi learn: a 2.6 backup with learned CCs restores into an older device (object 10 skipped)");
old.done();
}
@@ -1049,7 +1155,7 @@ async function editorCart() {
"cart: preset slots: the first free ones, or from a slot; null when they do not fit");
const base = Array.from({ length: info.pcount }, (_, i) => i % 3);
const pr = E.fm6CartPreset(info, base, 8, 4, " BRASS 1 "), pr0 = E.fm6CartPreset(info, base, 8, 0, "");
- ok(pr.engine === 9 && pr.name === "BRASS 1" && pr.p.length === 61 && pr.p[info.pe0 + 7] === 12 && pr.p[info.pe0 + 6] === base[info.pe0 + 6]
+ ok(pr.engine === 9 && pr.name === "BRASS 1" && pr.p.length === 71 && pr.p[info.pe0 + 7] === 12 && pr.p[info.pe0 + 6] === base[info.pe0 + 6]
&& pr.p[0] === base[0] && pr0.name === "FM6 B1" && pr0.p[info.pe0 + 7] === 8, "cart: a preset = FM6, the voice's name, PTCH = its B slot, the rest as given");
const ul = await E.bank.list(rq);
const free = E.fm6CartSlots(ul, 3, "free");
@@ -1247,11 +1353,11 @@ 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" } = {}) {
+ constructor(image, { unplugAfter = Infinity, finalIdentity = "FM-1_900", name = "FM-1", identity = "FM-1_015" } = {}) {
this.image = image; this.unplugAfter = unplugAfter; this.served = 0; this.bad = 0;
this.finalIdentity = finalIdentity;
this.access = { inputs: new Map(), outputs: new Map() };
- this.boot("FM-1_015", "FM-1");
+ this.boot(identity, name);
}
boot(identity, name) {
this.identity = identity; this.waiting = null; this.queue = [];
@@ -1331,6 +1437,19 @@ async function updater() {
ok(e && e.code === "lost", "fm1ota.js: unplugged in step 1 -> error code 'lost'");
const e2 = await new Updater({ inputs: new Map(), outputs: new Map() }).install(image, "FM-1_900").then(() => null, (x) => x);
ok(e2 && e2.code === "notfound", "fm1ota.js: no device -> error code 'notfound'");
+ { /* an FM-1 running CLIPPER (USB name "Clipper", SLOOP's sister firmware) installs SLOOP like any FM-1 */
+ const cl = new FakeFM1(image, { name: "Clipper", identity: "FM-1_901" });
+ const g = await new Updater(cl.access).install(image, "FM-1_900");
+ ok(g === "FM-1_900" && cl.bad === 0, "fm1ota.js: an FM-1 under CLIPPER (port 'Clipper') -> found and installed");
+ /* other gear is never probed, and "not found" names the MIDI ports there are */
+ const other = new FakeFM1(image, { name: "Arturia KeyStep Pro" });
+ const e6 = await new Updater(other.access).install(image, "FM-1_900").then(() => null, (x) => x);
+ ok(e6 && e6.code === "notfound" && other.served === 0 && /Arturia KeyStep Pro/.test(e6.detail),
+ `fm1ota.js: a port of other gear is left alone; 'not found' lists it${e6 ? e6.detail : ""}`);
+ ok(["FM-1", "Felucca", "Felucca Update", "Clipper", "SLOOP", "MIDIIN2 (Clipper)", "USB-MIDI"].every((n) => FM1_PORT.test(n)) &&
+ !["Arturia KeyStep Pro", "loopMIDI Port", "Microsoft GS Wavetable Synth"].some((n) => FM1_PORT.test(n)),
+ "fm1ota.js: FM1_PORT takes the FM-1's names (SLOOP, CLIPPER, the loader, the stock firmware), not other gear");
+ }
const stock = new FakeFM1(image);
stock.boot("ota-FM-1_015", "FM-1 Update");
const e3 = await new Updater(stock.access).resume(image).then(() => null, (x) => x);
@@ -1354,6 +1473,7 @@ await editorMock();
await editorLibrarian();
await editorLive();
await editorTracks();
+await editorSetGate();
await editorMixer();
await editorTrackParam();
await editorV5();