mirror of
https://github.com/isod89/clipper-fm1.git
synced 2026-12-05 12:24:32 +01:00
Clipper 1.3 (FM-1): the bug-fix release (GitHub issues and a full audit)
Clean fades (the mix rounded to the nearest); UNISON spread on every engine (FMX, MACRO too) and FMX's unison level; PHYS strings in tune; NOISE LFSR clock past the sample rate (#10) and its pink / brown filter bounded; SAMPLE and GRAIN follow the top keys, GRAIN no longer starved by a released note; a firm press on a layer button opens its pages (TAP 1 s, #24); REC READY's knobs read once; VECTOR's filter states cleared on a MODEL change (no click); FMX: a voice given up starts from rest; Clipper 1.0's values kept beside every project (proj_x10_t, backup object 14); backups keep user wavetables and the user presets' side records and tails (objects 12, 13); TRACK_MIX's EQ LOW bounded; the way back accepts the official V16 (sloop-fm1 #8); a user kit's root, a project's velocities bounded. Version 1.3 (ui.c, build-clipper.ps1, publish_github.ps1, the installer page, docs/release-1.3.md, the guides). New tests for each, goldens updated (the mix's rounding: every render). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AgC1EFHrYDcX1kyyeDW9sw
This commit is contained in:
61 files changed
+4261
-376
No files matched your search
+2
-2
@@ -123,8 +123,8 @@ starts, recovery needs [FM-1-transporter](https://github.com/kurogedelic/FM-1-tr
|
||||
## Publishing a release on GitHub
|
||||
|
||||
`PUBLISH-GITHUB.bat` (Windows, after `INSTALL-CLIPPER.bat` has built the firmware) publishes from the CLIPPER folder with
|
||||
your own Git and GitHub CLI login: the source from `clipper-1.2.bundle` to `YOUR-NAME/clipper-fm1` (created if needed;
|
||||
your own Git and GitHub CLI login: the source from `clipper-1.3.bundle` to `YOUR-NAME/clipper-fm1` (created if needed;
|
||||
an existing repository with another history stops it, nothing is forced on `main`), the tag and the release
|
||||
`v1.2` (notes: `docs/release-1.2.md`, the `.fwsc` package and the demo WAV attached), and the installer and
|
||||
`v1.3` (notes: `docs/release-1.3.md`, the `.fwsc` package and the demo WAV attached), and the installer and
|
||||
the editor (`build/clipper-site`) on GitHub Pages (branch `gh-pages`, replaced each time):
|
||||
`https://YOUR-NAME.github.io/clipper-fm1/webapp/installer/`. `PUBLISH-GITHUB.bat -Repo another-name` for another name.
|
||||
@@ -1,4 +1,4 @@
|
||||
# Clipper — démarrage rapide (version 1.2)
|
||||
# Clipper — démarrage rapide (version 1.3)
|
||||
|
||||
**Clipper** est un firmware de **synthétiseur** pour le M-VAVE FM-1 : un seul instrument, comme le firmware d'origine, Felucca ou Baudgirl. Ce n'est plus une groovebox : pas de pistes, pas de boîte à rythmes, pas de mode song, pas de samples intégrés. Il garde de SLOOP les 12 moteurs, les effets, l'arpégiateur, le séquenceur de pas, l'audio USB et le MIDI. Il ajoute **HYBRID**, une voix à 3 oscillateurs, 2 filtres et une matrice de modulation de 16 slots, avec 32 sons d'usine. Il ajoute aussi le pitch bend, la molette, l'aftertouch et la pédale de sustain sur tous les moteurs.
|
||||
|
||||
@@ -39,7 +39,7 @@ Clipper vit dans son propre dossier, **`CLIPPER`**, à côté de celui de SLOOP.
|
||||
| Adresse | http://localhost:**8766** | http://localhost:**8767** |
|
||||
| Écran de démarrage | voilier, « sloop » | trois-mâts, « clipper » |
|
||||
|
||||
Sur la FM-1, Clipper se reconnaît à son écran de démarrage (**1.2** sous le logo) et à HOME (maintenu) → SYS → ABOUT, qui affiche **CLIPPER 1.2**.
|
||||
Sur la FM-1, Clipper se reconnaît à son écran de démarrage (**1.3** sous le logo) et à HOME (maintenu) → SYS → ABOUT, qui affiche **CLIPPER 1.3**.
|
||||
|
||||
## 1. Compiler et installer
|
||||
|
||||
@@ -256,4 +256,4 @@ Certains entendent un craquement ou un bruit dans le canal gauche, avec la réve
|
||||
## Revenir en arrière
|
||||
|
||||
- **Vers SLOOP** : lance `INSTALL-SLOOP.bat` depuis le dossier de SLOOP. Un son réglé sur HYBRID y jouera un autre moteur.
|
||||
- **Vers le firmware officiel** : passe par la page d'installation (« Revenir au firmware officiel (V15) »), après avoir fait une sauvegarde.
|
||||
- **Vers le firmware officiel** : passe par la page d'installation (« Revenir au firmware officiel », avec le FM-1.fwsc officiel de M-VAVE : V16, ou V15), après avoir fait une sauvegarde.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
@echo off
|
||||
title Clipper - publish on GitHub
|
||||
rem Publishes Clipper 1.2 on your GitHub: the source, the release, the installer (GitHub Pages).
|
||||
rem Publishes Clipper 1.3 on your GitHub: the source, the release, the installer (GitHub Pages).
|
||||
rem Run INSTALL-CLIPPER.bat first (it builds the firmware the release and the installer publish).
|
||||
rem Usage: PUBLISH-GITHUB.bat (the repository YOUR-NAME/clipper-fm1)
|
||||
rem PUBLISH-GITHUB.bat -Repo another-name
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
# Clipper — quick start (1.2)
|
||||
# Clipper — quick start (1.3)
|
||||
|
||||
**Clipper** is a **synthesizer** firmware for the M-VAVE FM-1: one instrument, like the original firmware, Felucca or Baudgirl's FM-1+VA. It is not a groovebox: no tracks, no drum machine, no song mode, no built-in samples. It keeps SLOOP's engines, effects, arpeggiator, step sequencer, USB audio and MIDI, and adds **HYBRID** (three oscillators, two filters, a 16-slot matrix) and many more engines. Pitch bend, mod wheel, aftertouch and the sustain pedal work on every engine. *(En français : [DEMARRAGE-RAPIDE-FR.md](DEMARRAGE-RAPIDE-FR.md).)*
|
||||
|
||||
> **Version 1.2.** Clipper runs on the FM-1; 1.2 brings SLOOP 2.8.3's fixes (see [New in 1.2](README.md#new-in-12-sloop-283s-fixes-a-steadier-second-core-the-ewi-as-one-voice)), and there is still a lot to do (see [What is left to do](README.md#what-is-left-to-do)). **Before installing, make a backup** with the editor (Clipper's or SLOOP's, whichever is installed): the Backup tab (Projects → Backup in SLOOP or an older version) → *Save a backup*.
|
||||
|
||||
On the FM-1, Clipper shows its boot screen (**1.2** under the logo), and HOME (held) → SYS → ABOUT reads **CLIPPER 1.2**.
|
||||
On the FM-1, Clipper shows its boot screen (**1.3** under the logo), and HOME (held) → SYS → ABOUT reads **CLIPPER 1.3**.
|
||||
|
||||
## 1. Install
|
||||
|
||||
@@ -78,4 +78,4 @@ Some players hear a crackle or a noise on the left channel, with the reverb on a
|
||||
## Going back
|
||||
|
||||
- **To SLOOP**: run `INSTALL-SLOOP.bat` from SLOOP's folder. A sound set to HYBRID plays another engine there.
|
||||
- **To the official firmware**: use the installer page ("Return to the official firmware (V15)"), after making a backup.
|
||||
- **To the official firmware**: use the installer page ("Return to the official firmware", with M-VAVE's official FM-1.fwsc: V16, or V15), after making a backup.
|
||||
@@ -7,7 +7,7 @@ Free and open source (GPL-3.0). It grew out of <a href="https://github.com/isod8
|
||||
|
||||
---
|
||||
|
||||
> **Status: 1.2.** Clipper runs on the FM-1, and 1.2 brings SLOOP 2.8.3's fixes (see [New in 1.2](#new-in-12-sloop-283s-fixes-a-steadier-second-core-the-ewi-as-one-voice)). It passes its whole test suite on a computer. There is still a lot to do (see [What is left to do](#what-is-left-to-do)). Install it at your own risk, and keep a backup made with the editor. You can go back to the official V15 from the installer page, or to SLOOP with its own `INSTALL-SLOOP.bat`.
|
||||
> **Status: 1.3.** Clipper runs on the FM-1. 1.3 is a bug-fix release (see [New in 1.3](#new-in-13-a-bug-fix-release)); 1.2 brought SLOOP 2.8.3's fixes (see [New in 1.2](#new-in-12-sloop-283s-fixes-a-steadier-second-core-the-ewi-as-one-voice)). It passes its whole test suite on a computer. There is still a lot to do (see [What is left to do](#what-is-left-to-do)). Install it at your own risk, and keep a backup made with the editor. You can go back to the official firmware (V16 or V15) from the installer page, or to SLOOP with its own `INSTALL-SLOOP.bat`.
|
||||
|
||||
SLOOP is a groovebox. **Clipper is a synthesizer** with 23 engines and 407 sounds, one instrument (two in MULTI) like the original FM-1 firmware, Felucca and Baudgirl's FM-1+VA. It has no tracks, no drum machine, no song mode and no built-in samples. It keeps SLOOP's 12 sound engines, effects, arpeggiator, step sequencer, USB audio and MIDI, and adds **HYBRID**: one voice built from three oscillators, two filters and a modulation matrix, with the whole patch editable in the browser.
|
||||
|
||||
@@ -52,6 +52,34 @@ SLOOP is a groovebox. **Clipper is a synthesizer** with 23 engines and 407 sound
|
||||
|
||||
**The web editor** (Chrome or Edge, nothing to install): every parameter live; a pro step sequencer (tools, generators, velocity lanes, a pattern library); the whole HYBRID and FMX patches; the MOD SEQ's lanes; the tuning and `.scl` files; DX7 banks; your own wavetables; a sound library, undo / compare / A-B / randomize tools; backups of the whole FM-1.
|
||||
|
||||
## New in 1.3: a bug-fix release
|
||||
|
||||
A bug-fix release. Thanks to everyone who reported issues on GitHub: every fix below has its own test, and the whole firmware was checked again (the editor's protocol, MIDI in and a damaged flash fuzzed, every engine, sound and key measured).
|
||||
|
||||
**Cleaner sound**
|
||||
- No more distortion at the end of notes. The mix rounded every part down to 16 steps of the 16-bit output, so a fading note carried a buzz that followed it, on the 3.5 mm output and on USB. The mix now rounds properly: about 10 times less error, the quiet tails are clean.
|
||||
- UNISON no longer stacks its voices in phase. Most engines started every unison voice at the same phase, up to +18 dB louder than POLY on some sounds, and FMX and MACRO peaked far over full scale. Each voice now starts apart, as a unison should, and the level matches POLY.
|
||||
- PHYS strings are in tune. They played sharp, by up to a semitone on the low notes of HARPSICH (STR PLUCK, BANJO, PLUCK BASS, the guitars). Now within 2 cents; KOTO, SITAR and TANPURA bend with their curved bridge, as designed.
|
||||
- The top of the keyboard follows the keys. NOISE's NZ ARCADE, SAMPLE and GRAIN played one pitch over the upper keys (SAMPLE CHOIR from A6, VOX CLOUD from G6); they now go on rising. A GRAIN note played while the one before is fading out is no longer almost silent.
|
||||
- VECTOR: changing the FILTER MODEL while a note plays no longer gives a loud click.
|
||||
- FMX: a voice taken back from another note now starts clean (before, it kept the old note's state: a DC offset and a changing timbre).
|
||||
|
||||
**Controls**
|
||||
- A firm press on a layer button (GLO, EDIT, ARP, SEQ, SEL) opens its pages. Before, a press longer than 0.45 s opened nothing; now up to one second counts as a tap.
|
||||
- On REC READY, a knob changes only its own value: KNOB 3 (START) no longer moves the loop LENGTH too. The same fix covers every page: a knob turned alone changes one value.
|
||||
|
||||
**Your data**
|
||||
- Projects loaded from SLOOP keep Clipper's own values (SPREAD, LFO 3, ENV 2 LOOP, the macros, matrix slots 7 to 12, the delay MODE) across a power cycle.
|
||||
- Editor backups now include your user wavetables (WAVE USR1..4), which a restore used to erase, and every value of your user presets.
|
||||
- Safer loading: a user drum kit with an odd root note, or a project file with out-of-range velocities, plays normally.
|
||||
|
||||
**Install and go back**
|
||||
- Return to the official firmware accepts M-VAVE's new V16 (and V15). M-VAVE now offers only V16, which the installer refused.
|
||||
|
||||
**Compatibility**
|
||||
- Projects, presets, samples and settings are kept when you update, and the project format is unchanged.
|
||||
- A few sounds change a little on purpose: the PHYS strings (now in tune), the unison sounds, NZ ARCADE.
|
||||
|
||||
## New in 1.2: SLOOP 2.8.3's fixes, a steadier second core, the EWI as one voice
|
||||
|
||||
- **A note held under others keeps sounding** (after SLOOP 2.8.2 and 2.8.3): a key held while you play or record over it is never restarted nor cut by the sequencer, live, in a free take or an overdub, on POLY and on UNI2 / UNI4; a hold overdubbed over a recorded melody goes on through its notes, and the notes the sustain pedal holds are left alone too. Recording a key over a held one on a MONO or LEGATO sound says **MONO: SET VOICE POLY** (once).
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
# Clipper 1.2: build the firmware, then open the browser installer.
|
||||
# Clipper 1.3: build the firmware, then open the browser installer.
|
||||
# Uses the same tools as SLOOP (WSL MinUI-Build, the JieLi toolchain) and the three AC79 SDK files in
|
||||
# build\deps\ac79 (copied from the SLOOP folder the first time if they are not here yet).
|
||||
# Port 8767 (SLOOP uses 8766): a SLOOP window left open does not get mixed up with this one.
|
||||
@@ -6,7 +6,7 @@ param([string]$Voices = "8")
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-Location $PSScriptRoot
|
||||
Write-Host ""
|
||||
Write-Host " C L I P P E R 1.2 ($Voices voices)" -ForegroundColor White
|
||||
Write-Host " C L I P P E R 1.3 ($Voices voices)" -ForegroundColor White
|
||||
Write-Host " ---- ---- ---- ----" -ForegroundColor DarkGray
|
||||
if ($Voices -notin @("8", "12", "16")) { throw "Voices: 8, 12 or 16" }
|
||||
$sdk = "build\deps\ac79"
|
||||
@@ -29,7 +29,7 @@ Remove-Item Env:FELUCCA_SLICE -ErrorAction SilentlyContinue
|
||||
python tools/build_windows.py --distro MinUI-Build --toolchain /root/fm1-codex-deps/jieli/toolchain --sdk $sdk --slice 0 --nvoice $Voices
|
||||
if ($LASTEXITCODE -ne 0) { throw "The build failed" }
|
||||
Write-Host "== Making the installer site" -ForegroundColor Cyan
|
||||
python web/make_site.py build/felucca.fwsc 1.2 build/clipper-site
|
||||
python web/make_site.py build/felucca.fwsc 1.3 build/clipper-site
|
||||
if ($LASTEXITCODE -ne 0) { throw "make_site failed" }
|
||||
Write-Host ""
|
||||
Write-Host "Installer: http://localhost:8767/webapp/installer/ (Chrome or Edge, FM-1 on USB)" -ForegroundColor Green
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# Clipper 1.3
|
||||
|
||||
**A free, open-source synthesizer firmware for the M-VAVE FM-1.** It grew out of [SLOOP](https://github.com/isod89/sloop-fm1) and, like SLOOP, it is based on [Felucca](https://github.com/hugelton/Felucca) by Leo Kuroshita / Hügelton Instruments.
|
||||
|
||||
> **Make a backup with the editor before installing.** You can always go back to the official firmware (V16 or V15) from the installer page.
|
||||
|
||||
## What it is
|
||||
|
||||
- **23 engines, 407 sounds**: HYBRID (three oscillators, two filters, a 16-slot matrix), FMX (six operators after the opsix), FM6 (DX7, loads `.syx` banks), DIGITAL, WAVE (wavetables, and your own), WSEQ (wave sequencing), VECTOR, JUNO (with its chorus), ANALOG (eight filter models), ACID, STRINGS, MACRO, PHASE, VPS, TERRAIN, PHYS (physical models), TRIO, LOFI, WHEEL, VOICE, NOISE, GRAIN and SAMPLE (on Clipper's own synthesized sources).
|
||||
- **On every engine**: a 12-slot modulation matrix, LFO 2 and 3, ENV 2 (one-shot or looping), the MOD SEQ, four macros (BRITE, TIMBR, MOTN, SPACE, also on CC 16-19), SPREAD (each voice its own place in the stereo field), VINTAGE, an insert effect.
|
||||
- **Effects**: distortion, chorus, a tempo-synced delay (mono, ping-pong, tape), room, plate, hall and shimmer reverbs, a master EQ, compressor and limiter.
|
||||
- **Playing**: 8 voices on both cores (12 / 16 as a build option), poly unison, layer / split / multi, a 15-mode arpeggiator with a Turing machine, a step sequencer, MPE, MIDI over USB and TRS (omni or one channel, program changes, expression, panic, the bend range, local control, CC out, a breath controller), microtuning with Scala scales; the FM-1 is a USB audio interface too.
|
||||
- **A web editor** (Chrome or Edge, nothing to install) for every parameter, the HYBRID and FMX patches, DX7 banks, wavetables, the tuning, and full backups.
|
||||
|
||||
## New in 1.3: a bug-fix release
|
||||
|
||||
A bug-fix release. Thanks to everyone who reported issues on GitHub: every fix below has its own test, and the whole firmware was checked again (the editor's protocol, MIDI in and a damaged flash fuzzed, every engine, sound and key measured).
|
||||
|
||||
**Cleaner sound**
|
||||
- No more distortion at the end of notes. The mix rounded every part down to 16 steps of the 16-bit output, so a fading note carried a buzz that followed it, on the 3.5 mm output and on USB. The mix now rounds properly: about 10 times less error, the quiet tails are clean.
|
||||
- UNISON no longer stacks its voices in phase. Most engines started every unison voice at the same phase, up to +18 dB louder than POLY on some sounds, and FMX and MACRO peaked far over full scale. Each voice now starts apart, as a unison should, and the level matches POLY.
|
||||
- PHYS strings are in tune. They played sharp, by up to a semitone on the low notes of HARPSICH (STR PLUCK, BANJO, PLUCK BASS, the guitars). Now within 2 cents; KOTO, SITAR and TANPURA bend with their curved bridge, as designed.
|
||||
- The top of the keyboard follows the keys. NOISE's NZ ARCADE, SAMPLE and GRAIN played one pitch over the upper keys (SAMPLE CHOIR from A6, VOX CLOUD from G6); they now go on rising. A GRAIN note played while the one before is fading out is no longer almost silent.
|
||||
- VECTOR: changing the FILTER MODEL while a note plays no longer gives a loud click.
|
||||
- FMX: a voice taken back from another note now starts clean (before, it kept the old note's state: a DC offset and a changing timbre).
|
||||
|
||||
**Controls**
|
||||
- A firm press on a layer button (GLO, EDIT, ARP, SEQ, SEL) opens its pages. Before, a press longer than 0.45 s opened nothing; now up to one second counts as a tap.
|
||||
- On REC READY, a knob changes only its own value: KNOB 3 (START) no longer moves the loop LENGTH too. The same fix covers every page: a knob turned alone changes one value.
|
||||
|
||||
**Your data**
|
||||
- Projects loaded from SLOOP keep Clipper's own values (SPREAD, LFO 3, ENV 2 LOOP, the macros, matrix slots 7 to 12, the delay MODE) across a power cycle.
|
||||
- Editor backups now include your user wavetables (WAVE USR1..4), which a restore used to erase, and every value of your user presets.
|
||||
- Safer loading: a user drum kit with an odd root note, or a project file with out-of-range velocities, plays normally.
|
||||
|
||||
**Install and go back**
|
||||
- Return to the official firmware accepts M-VAVE's new V16 (and V15). M-VAVE now offers only V16, which the installer refused.
|
||||
|
||||
**Compatibility**
|
||||
- Projects, presets, samples and settings are kept when you update, and the project format is unchanged.
|
||||
- A few sounds change a little on purpose: the PHYS strings (now in tune), the unison sounds, NZ ARCADE.
|
||||
|
||||
The full list is in the [README](https://github.com/isod89/clipper-fm1/blob/main/README.md#new-in-13-a-bug-fix-release).
|
||||
|
||||
## Install
|
||||
|
||||
- **From the browser**: open the [installer page](https://isod89.github.io/clipper-fm1/webapp/installer/) (Chrome or Edge, the FM-1 on USB; the [editor](https://isod89.github.io/clipper-fm1/webapp/editor/) is next to it), make a backup with the editor first, then click Install.
|
||||
- **From the source, on Windows**: see [QUICKSTART.md](https://github.com/isod89/clipper-fm1/blob/main/QUICKSTART.md) (French: [DEMARRAGE-RAPIDE-FR.md](https://github.com/isod89/clipper-fm1/blob/main/DEMARRAGE-RAPIDE-FR.md)) — `INSTALL-CLIPPER.bat` builds the firmware (WSL and the JieLi toolchain, as SLOOP) and opens the installer.
|
||||
|
||||
On the SMK-37 (Pro, Elite, MKE-P37, Starrykey 37 Play), the same synthesizer is [Clipper Pro](https://github.com/isod89/clipper-pro).
|
||||
|
||||
**Please report what you find** in the [Issues](https://github.com/isod89/clipper-fm1/issues): bugs, crashes (photograph the FELUCCA CRASH screen), stuck notes, crackles, CPU readings (GLO → SYSTEM).
|
||||
|
||||
Custom firmware with no warranty. Clipper is not affiliated with M-VAVE. GPL-3.0.
|
||||
@@ -305,7 +305,8 @@ static void drum_on(uint32_t note, uint32_t vel)
|
||||
{
|
||||
const smp_zone_t *z = drum_zone_of(v);
|
||||
v->s[3] = sample_next(z, v, 0);
|
||||
v->s[5] = (int32_t)((pow2_q16((int32_t)note * 16 - z->root16) >> 8) * (z->rate >> 8));
|
||||
/* (after Clipper 1.2) clamped: a user kit zone's root is not checked (a typed root of 300 shifted by 2^20) */
|
||||
v->s[5] = (int32_t)((pow2_q16(clamp((int32_t)note * 16 - z->root16, -1536, 2047)) >> 8) * (z->rate >> 8));
|
||||
}
|
||||
{
|
||||
uint32_t vi = (uint32_t)(v - drums.v);
|
||||
|
||||
@@ -12,6 +12,13 @@ static inline int32_t mulq16(int32_t a, uint32_t k)
|
||||
return (int32_t)(((a >> 16) * (int32_t)k) + (int32_t)(((uint32_t)(a & 0xFFFF) * k) >> 16));
|
||||
}
|
||||
static inline int32_t clamp(int32_t v, int32_t lo, int32_t hi) { return v < lo ? lo : v > hi ? hi : v; }
|
||||
/* x * g / 4096 rounded to the nearest, in 32 bits wherever ((x >> k) * g) >> (12 - k) fits (the same bound): the k low
|
||||
* bits of x go in apart instead of being dropped. The mix's gains (fx.c: a part's LEVEL, mute / duck, the MASTER, DIST's
|
||||
* drive) took x >> k first and lost them: a floor to steps of 2^k x the gain (a part's sum to 16 LSB of the output at
|
||||
* MASTER 4096), signal-correlated distortion that stays as loud while a note fades out (SLOOP Pro #4). k, a constant:
|
||||
* ~6 ops */
|
||||
#define MULQ12R(x, g, k) \
|
||||
((((x) >> (k)) * (g) + ((((x) & ((1 << (k)) - 1)) * (g) + (1 << ((k) - 1))) >> (k)) + (1 << (11 - (k)))) >> (12 - (k)))
|
||||
|
||||
/* sine, linearly interpolated between the 1024 table points (plain lookup: THD -55 dB) */
|
||||
static inline int32_t sine_i(uint32_t ph)
|
||||
|
||||
+107
-3
@@ -463,16 +463,38 @@ UI_SMALL static const uint8_t *ed_bk_obj(uint32_t id, uint32_t *len) /* 0 = no
|
||||
*len = sizeof dsu;
|
||||
return (const uint8_t *)&dsu;
|
||||
}
|
||||
#if CLIPPER_SYNTH
|
||||
if (id == 12u || id == 13u) { /* each user preset's Clipper values the records have no room for:
|
||||
* 12 the banks' side records (MOD SEQ, SPICE, VINTAGE...), 13 their
|
||||
* tails (SPREAD .. matrix slot 12, the macros); restored after 6, 7 */
|
||||
*len = id == 12u ? sizeof up_side : sizeof up_tail;
|
||||
return id == 12u ? (const uint8_t *)up_side : (const uint8_t *)up_tail;
|
||||
}
|
||||
if (id == 14u) { /* (after Clipper 1.2) the projects' 1.0 blocks (project.c
|
||||
* proj_x10_t): the slots A..D and LIST's snapshot of the working
|
||||
* project (proj_x10s 0..4), each bound to its project by its sum */
|
||||
*len = 5u * sizeof proj_x10s[0];
|
||||
return (const uint8_t *)proj_x10s;
|
||||
}
|
||||
#endif
|
||||
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 &&
|
||||
h->data_len <= SMP_USER_SIZE - SMP_USER_DATA)
|
||||
*len = SMP_USER_DATA + h->data_len;
|
||||
#if CLIPPER_SYNTH
|
||||
else if (wt_user_hdr_ok((const wt_user_hdr_t *)h)) /* a wavetable for WAVE: backed up as a sample is */
|
||||
*len = SMP_USER_DATA + WT_USER_LEN;
|
||||
#endif
|
||||
return smp_user_xip(id - 32u);
|
||||
}
|
||||
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,
|
||||
#if CLIPPER_SYNTH
|
||||
12, 13, 14,
|
||||
#endif
|
||||
32, 33, 34, 35}; /* 35: USR4 (2.4), 9: SYN kits (2.5) */
|
||||
|
||||
/* a flash erase silences the audio for ~50 ms and stalls USB: only while stopped (as the panel) */
|
||||
UI_SMALL static uint32_t ed_flash_busy(void) { return song.playing || transport_req; }
|
||||
@@ -495,14 +517,36 @@ UI_SMALL static uint32_t ed_bk_commit(void)
|
||||
if (n == 8u + UP_PER_BANK * UP_RSIZE_04 && b->magic == UP_BANK_MAGIC && b->rsize == UP_RSIZE_04 &&
|
||||
b->nslot == UP_PER_BANK) { /* a Clipper 0.4 backup's bank: made today's, then stored */
|
||||
up_bank_import(id - 6u, raw, (int)n);
|
||||
memset(&up_side[id - 6u], 0, sizeof up_side[0]); /* (after Clipper 1.2: another bank's) */
|
||||
memset(&up_tail[id - 6u], 0, sizeof up_tail[0]);
|
||||
up_gen++;
|
||||
return !flash_ok || st_save(OBJ_UPRESET0 + id - 6u, &up_bank[id - 6u], sizeof up_bank[0]) ? 4u : 0u;
|
||||
}
|
||||
#endif
|
||||
if (n && (n != sizeof *b || b->magic != UP_BANK_MAGIC || b->rsize != sizeof(up_rec_t) || b->nslot != UP_PER_BANK))
|
||||
return 2;
|
||||
#if CLIPPER_SYNTH
|
||||
{ /* (after Clipper 1.2) the bank's side record and tail: kept with the same bank (a backup from before objects
|
||||
* 12, 13, restored over the presets it was made from), else cleared (another bank's: 12, 13 bring this one's) */
|
||||
int same = n == sizeof up_bank[0] && !memcmp(&up_bank[id - 6u], raw, n), rc;
|
||||
if (!same) {
|
||||
memset(&up_side[id - 6u], 0, sizeof up_side[0]);
|
||||
memset(&up_tail[id - 6u], 0, sizeof up_tail[0]);
|
||||
}
|
||||
st_side = up_side[id - 6u].magic ? &up_side[id - 6u] : 0;
|
||||
st_side_len = sizeof(up_side_t);
|
||||
st_tail = up_tail[id - 6u].magic ? &up_tail[id - 6u] : 0;
|
||||
st_tail_len = sizeof(up_tail_t);
|
||||
rc = !flash_ok || st_save(OBJ_UPRESET0 + id - 6u, raw, n);
|
||||
st_side = 0;
|
||||
st_tail = 0;
|
||||
if (rc)
|
||||
return 4;
|
||||
}
|
||||
#else
|
||||
if (!flash_ok || st_save(OBJ_UPRESET0 + id - 6u, raw, n))
|
||||
return 4;
|
||||
#endif
|
||||
memset(&up_bank[id - 6u], 0, sizeof up_bank[0]);
|
||||
if (n)
|
||||
memcpy(&up_bank[id - 6u], raw, n);
|
||||
@@ -510,6 +554,66 @@ UI_SMALL static uint32_t ed_bk_commit(void)
|
||||
up_gen++;
|
||||
return 0;
|
||||
}
|
||||
#if CLIPPER_SYNTH
|
||||
if (id == 12u || id == 13u) { /* the user presets' side records / tails: each bank's whole or none */
|
||||
uint32_t b, rc = 0;
|
||||
if (ed_flash_busy())
|
||||
return 3;
|
||||
if (n != (id == 12u ? sizeof up_side : sizeof up_tail))
|
||||
return 2;
|
||||
for (b = 0; b < UP_SLOTS / UP_PER_BANK; b++) {
|
||||
if (id == 12u) {
|
||||
const up_side_t *x = (const up_side_t *)raw + b;
|
||||
up_side[b] = *x;
|
||||
if (x->magic != UP_SIDE_MAGIC || x->crc != st_crc32(x, sizeof *x - 4u))
|
||||
memset(&up_side[b], 0, sizeof up_side[b]);
|
||||
} else {
|
||||
const up_tail_t *x = (const up_tail_t *)raw + b;
|
||||
up_tail[b] = *x;
|
||||
if (x->magic != UP_TAIL_MAGIC || x->crc != st_crc32(x, sizeof *x - 4u))
|
||||
memset(&up_tail[b], 0, sizeof up_tail[b]);
|
||||
}
|
||||
if (up_bank[b].magic != UP_BANK_MAGIC)
|
||||
continue;
|
||||
st_side = up_side[b].magic ? &up_side[b] : 0;
|
||||
st_side_len = sizeof(up_side_t);
|
||||
st_tail = up_tail[b].magic ? &up_tail[b] : 0;
|
||||
st_tail_len = sizeof(up_tail_t);
|
||||
if (!flash_ok || st_save(OBJ_UPRESET0 + b, &up_bank[b], sizeof up_bank[b]))
|
||||
rc = 4; /* (the other bank is written still) */
|
||||
st_side = 0;
|
||||
st_tail = 0;
|
||||
}
|
||||
up_gen++;
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
#if CLIPPER_SYNTH
|
||||
if (id == 14u) { /* (after Clipper 1.2) the projects' 1.0 blocks, after 0 and 2..5:
|
||||
* each to the project it belongs to (its sum), written with it */
|
||||
uint32_t b, i, rc = 0;
|
||||
if (ed_flash_busy())
|
||||
return 3;
|
||||
if (n != 5u * sizeof(proj_x10_t))
|
||||
return 2;
|
||||
for (b = 0; b < 5u; b++) {
|
||||
proj_x10_t x;
|
||||
memcpy(&x, raw + b * sizeof x, sizeof x);
|
||||
if (!proj_x10_valid(&x))
|
||||
continue;
|
||||
for (i = 0; i < 4u; i++)
|
||||
if (proj_ok(&proj_slot[i]) && proj_slot[i].sum == x.sum) {
|
||||
proj_x10s[i] = x;
|
||||
if (!flash_ok || proj_st_save(OBJ_PROJECT0 + i, &proj_slot[i]))
|
||||
rc = 4;
|
||||
}
|
||||
if (proj_restored_sum && x.sum == proj_restored_sum)
|
||||
proj_x10_set(x.m); /* (the working project restored: its sounds' values) */
|
||||
}
|
||||
proj_restored_sum = 0;
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
if (id == 8u) { /* the FM6 patch bank (n 0: empty) */
|
||||
if (ed_flash_busy())
|
||||
return 3;
|
||||
@@ -582,7 +686,7 @@ UI_SMALL static int ed_backup(uint32_t cmd, const uint8_t *a, uint32_t na) /*
|
||||
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 <= 9u || (CLIPPER_SYNTH && (id == 12u || id == 13u || id == 14u)))) { /* 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) {
|
||||
@@ -979,7 +1083,7 @@ UI_SMALL static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes b
|
||||
t = &trk[a[0]];
|
||||
lv = a[0] == TRK_DRUM ? &song.g[G_DRLVL] : &t->p[P_LEVEL];
|
||||
if (na >= 4u) {
|
||||
*lv = (int16_t)clamp(ed_rv(a + 1), 0, 127);
|
||||
*lv = (int16_t)clamp(ed_rv(a + 1), a[0] == TRK_DRUM ? GP[G_DRLVL].min : 0, a[0] == TRK_DRUM ? GP[G_DRLVL].max : 127);
|
||||
t->p[P_MUTE] = (int16_t)(a[3] ? 1 : 0);
|
||||
if (a[0] == TRK_DRUM) /* the editor's own change: no push */
|
||||
ed_w.v[P_COUNT + G_DRLVL] = *lv;
|
||||
|
||||
@@ -151,6 +151,14 @@ static const preset_t ANALOG_PRESETS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): both oscillators moved by r (Q32) of a turn of the note,
|
||||
* each by its share: as if started that much sooner (osc 2 took its phase from ph[0] before the spread: in phase) */
|
||||
static void analog_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += uni_turns(r, v->pitch16, t->p[P_E1] * 16 / 100);
|
||||
}
|
||||
|
||||
static const engine_t ENG_ANALOG = {
|
||||
"ANALOG", {"OSC", "FLT"},
|
||||
{
|
||||
|
||||
@@ -181,6 +181,17 @@ static const preset_t DIGITAL_PRESETS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the four operators moved together by r (Q32) of a turn of
|
||||
* the note, each by its ratio's share (phases 0 at each note: every voice in phase) */
|
||||
static void digital_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += (uint32_t)(((uint64_t)r * RATIO_Q8[p[P_E1] % 15]) >> 8);
|
||||
v->ph[2] += (uint32_t)(((uint64_t)r * RATIO_Q8[p[P_E2] % 15]) >> 8);
|
||||
v->s[7] = (int32_t)((uint32_t)v->s[7] + (uint32_t)(((uint64_t)r * RATIO_Q8[p[P_E3] % 15]) >> 8));
|
||||
}
|
||||
|
||||
static const engine_t ENG_DIGITAL = {
|
||||
"DIGITAL", {"OPS", "MOD"},
|
||||
{
|
||||
|
||||
@@ -347,6 +347,10 @@ static void fm6_render(track_t *t, voice_t *v, int32_t *out, uint32_t len, const
|
||||
return; /* every carrier below the threshold */
|
||||
/* the voice's amplitude ramp x VOICE_FS (one carrier at full: VOICE_FS / 2), six voices in unison ~ one */
|
||||
k = t->p[P_VOICE] == V_UNISON ? VOICE_FS * 2 / 5 : VOICE_FS;
|
||||
#if CLIPPER_SYNTH /* (after Clipper 1.2) UNI4 / UNI2 as well: 4 (2) voices at random phases ~ one (they had 2 (1.4)) */
|
||||
if (t->p[P_VOICE] == V_PUNI4 || t->p[P_VOICE] == V_PUNI2)
|
||||
k = t->p[P_VOICE] == V_PUNI4 ? VOICE_FS / 2 : VOICE_FS * 7 / 10;
|
||||
#endif
|
||||
a = mulq15(m->amp0, k);
|
||||
da = (mulq15(m->amp1, k) - a) >> FM6_LG_N;
|
||||
for (i = 0; i < FM6_N; i++) {
|
||||
@@ -380,6 +384,26 @@ static const preset_t FM6_PRESETS[] = {
|
||||
{"NYLON PICK", {0, 0, 0, 0, 0, 0, 0, 7}, {0, 0, 127, 0}, 0, 0, FX(0, 20, 35, 30)},
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the six operators moved together by r (Q32) of a turn of
|
||||
* the note, each by its own frequency's share (fixed ones too): the relative phases, the timbre, kept (phases 0 from
|
||||
* silence: every voice in phase) */
|
||||
static void fm6_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
fm6_note_t *nt = fm6_note_of(t, v);
|
||||
uint32_t tr = (uint32_t)(t - trk), k;
|
||||
int32_t lf, f0;
|
||||
if (!nt || tr >= NPART)
|
||||
return;
|
||||
lf = fm6_note_logfreq(v->pitch16 + (fm6_eff[tr].p[FP_TRNSP] - 24) * 16, v->fine);
|
||||
f0 = fm6_freq(lf);
|
||||
if (f0 <= 0)
|
||||
return;
|
||||
for (k = 0; k < 6u; k++) {
|
||||
int32_t fk = fm6_freq((nt->fixed >> k) & 1u ? nt->base[k] : lf + nt->base[k]); /* Q24 cycles a sample */
|
||||
nt->op[k].phase = (int32_t)((uint32_t)nt->op[k].phase + (uint32_t)(((uint64_t)(r >> 8) * (uint32_t)fk) / (uint32_t)f0));
|
||||
}
|
||||
}
|
||||
|
||||
static const engine_t ENG_FM6 = {
|
||||
"FM6", {"OPS", "PATCH"},
|
||||
{
|
||||
|
||||
+16
-1
@@ -381,7 +381,8 @@ static void fmx_note_on(track_t *t, voice_t *v)
|
||||
return;
|
||||
if (tr < NPART)
|
||||
fmx_block(t); /* (the patch of its sound: a note can come before a block) */
|
||||
if (!x->live) { /* a fresh voice: from rest; a retrigger keeps its phases */
|
||||
if (!x->live || (!v->env && !v->env_out)) { /* a fresh voice: from rest; a retrigger keeps its phases (a voice
|
||||
* given up, voice.c voice_kill, ended without fmx_done: as FM6) */
|
||||
memset(x, 0, sizeof *x);
|
||||
x->rnd = 0x9E3779B9u * ((uint32_t)v->note + 1u);
|
||||
}
|
||||
@@ -391,6 +392,20 @@ static void fmx_note_on(track_t *t, voice_t *v)
|
||||
x->peg = tr < NPART ? ((int32_t)fmx_cur[tr].peg - 64) * 3 * 4096 / 8 : 0; /* +-24 semitones at 0 / 127 */
|
||||
}
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the voice's operators moved together by r (Q32) of a turn of its
|
||||
* note, each by its own increment's share: the relative phases, the timbre, kept */
|
||||
static void fmx_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
fmx_voice_t *x = fmx_voice(t, v);
|
||||
uint32_t tr = (uint32_t)(t - trk), k, base;
|
||||
if (!x || tr >= NPART)
|
||||
return;
|
||||
base = pitch_inc((uint32_t)clamp(v->pitch16, 0, 2047));
|
||||
for (k = 0; k < FMX_NOP; k++) /* (FIX: r / base samples of its own increment; per note) */
|
||||
x->ph[k] += fmx_eff[tr].mode[k] & FXM_FIX ? (uint32_t)(((uint64_t)r * fmx_eff[tr].ratio[k]) / (base ? base : 1u))
|
||||
: (uint32_t)(((uint64_t)r * fmx_eff[tr].ratio[k]) >> 16);
|
||||
}
|
||||
|
||||
static int fmx_done(track_t *t, voice_t *v)
|
||||
{
|
||||
fmx_voice_t *x = fmx_voice(t, v);
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
* share of reversed grains (up to 50 %). TONE: a one-pole low-pass (+ the track's FLT
|
||||
* modulation), as SAMPLE's CUT. A grain is fitted into its zone (shortened if the zone is short).
|
||||
*
|
||||
* Cost bound: the grain rate is capped at 2 source samples per output sample (max 2 decodes, 4
|
||||
* for a reverse grain); a grain only starts while the part's grains decode at most GR_LOAD_MAX
|
||||
* Cost bound: a grain's rate is capped at GR_LOAD_MAX source samples per output sample (it was 2: the high
|
||||
* keys of a low-rate source all played one pitch); a grain only starts while the part's grains decode at most GR_LOAD_MAX
|
||||
* (8) source samples per output sample in all (a reverse grain counts twice); at most one grain
|
||||
* start per voice and block (<= 255 skipped decodes), one index entry per block. Host count, one
|
||||
* part, worst settings: ~1050 instructions / sample (~1170 while the PERC index builds), against
|
||||
@@ -48,8 +48,9 @@
|
||||
#define GR_NIDX 1024 /* seek index entries per part (PERC: 1001) */
|
||||
#define GR_MAXZ 32 /* zones per set (PERC has 24, a user slot <= 16) */
|
||||
#define GR_RB 128 /* reverse window, source samples */
|
||||
#define GR_STEP_MAX (2u << 16) /* grain rate cap: 2 source samples per output sample */
|
||||
#define GR_LOAD_MAX (8u << 16) /* decodes per output sample of all a part's grains (a reverse grain counts twice) */
|
||||
#define GR_STEP_MAX GR_LOAD_MAX /* grain rate cap: as much as the part's load allows (it was 2 source samples an output
|
||||
* sample: a 16 kHz source went flat 2.5 octaves over its root, VOX CLOUD above G6) */
|
||||
|
||||
/* sin^2(pi i / 256), Q15: the grain window */
|
||||
static const int16_t GR_HANN[257] = {
|
||||
@@ -219,6 +220,11 @@ static void gr_fill(const gr_part_t *P, gr_grain_t *g, int16_t *rb, uint32_t zl,
|
||||
g->rlo = lo;
|
||||
}
|
||||
|
||||
/* (after Clipper 1.2) a held note's grain refused for the part's load: the released notes start none until one of the
|
||||
* held notes' grains starts (their grains end on their own): a note played in the release of the note before was
|
||||
* starved of grains (SCAN PAD 86 -> 88: -29 dB) while the fading one kept the load */
|
||||
static uint8_t gr_wait[NPART];
|
||||
|
||||
/* start a grain of voice vi (zone zl) */
|
||||
static void gr_spawn(gr_part_t *P, const track_t *t, uint32_t vi, uint32_t zl, uint32_t iv, const vmod_t *m)
|
||||
{
|
||||
@@ -237,10 +243,10 @@ static void gr_spawn(gr_part_t *P, const track_t *t, uint32_t vi, uint32_t zl, u
|
||||
/* rate: the note against the zone's root, PITCH, the random detune (RAND^2, up to +-1 oct) */
|
||||
amt = p[P_E6] * p[P_E6] * 192 / (127 * 127);
|
||||
d16 = m->pitch16 - z->root16 + p[P_E4] * 16 + (((int32_t)(r1 & 0xFFFFu) - 32768) * amt >> 15);
|
||||
step = (pow2_q16(clamp(d16, -1536, 576)) >> 8) * (z->rate >> 8);
|
||||
step = (pow2_q16(clamp(d16, -1536, 1536)) >> 8) * (z->rate >> 8);
|
||||
step = step > GR_STEP_MAX ? GR_STEP_MAX : step < 256u ? 256u : step;
|
||||
rev = ((r1 >> 16) & 255u) < (uint32_t)p[P_E6]; /* RAND 127: half of them */
|
||||
span = (len * step) >> 16; /* source samples the grain reads */
|
||||
span = (uint32_t)(((uint64_t)len * step) >> 16); /* source samples the grain reads */
|
||||
if (span + 3u > n) { /* a short zone: shorter grain */
|
||||
span = n - 3u;
|
||||
len = (span << 8) / (step >> 8);
|
||||
@@ -261,8 +267,13 @@ static void gr_spawn(gr_part_t *P, const track_t *t, uint32_t vi, uint32_t zl, u
|
||||
for (i = 0, c = step << rev; i < GR_NG; i++) /* the part's decode load: a cap on the cost */
|
||||
if (P->g[i].owner)
|
||||
c += P->g[i].step << P->g[i].rev;
|
||||
if (c > GR_LOAD_MAX)
|
||||
if (c > GR_LOAD_MAX) {
|
||||
if (t->v[vi].gate)
|
||||
gr_wait[(uint32_t)(t - trk) % NPART] = 1;
|
||||
return;
|
||||
}
|
||||
if (t->v[vi].gate)
|
||||
gr_wait[(uint32_t)(t - trk) % NPART] = 0;
|
||||
g->z = z;
|
||||
g->step = step;
|
||||
g->frac = 0;
|
||||
@@ -369,7 +380,7 @@ static void grain_note_on(track_t *t, voice_t *v)
|
||||
static void grain_block(track_t *t)
|
||||
{
|
||||
gr_part_t *P = (gr_part_t *)eng_arena_of(t, ENGI_GRAIN);
|
||||
uint32_t src = (uint32_t)t->p[P_E0] % SMP_NALL, st = gr_stamp(src), i;
|
||||
uint32_t src = (uint32_t)t->p[P_E0] % SMP_NALL, st = gr_stamp(src), i, held = 0;
|
||||
if (!P->rng)
|
||||
P->rng = 0x2545F491;
|
||||
if (P->src != src + 1u || P->stamp != st) {
|
||||
@@ -381,6 +392,10 @@ static void grain_block(track_t *t)
|
||||
for (i = 0; i < GR_NG; i++)
|
||||
if (P->g[i].owner && !t->v[(P->g[i].owner - 1u) % NVOICE].active)
|
||||
P->g[i].owner = 0;
|
||||
for (i = 0; i < NVOICE; i++)
|
||||
held |= t->v[i].active && t->v[i].gate;
|
||||
if (!held && (uint32_t)(t - trk) < NPART)
|
||||
gr_wait[t - trk] = 0; /* (no note held: none waits) */
|
||||
gr_build(P, t);
|
||||
}
|
||||
|
||||
@@ -413,7 +428,8 @@ static void grain_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
v->s[1] += (int32_t)iv + mulq15((int32_t)iv, j);
|
||||
if (v->s[1] < 0)
|
||||
v->s[1] = 0;
|
||||
if (mine < (nact > 1u ? (GR_NG / nact > 2u ? GR_NG / nact : 2u) : GR_NG))
|
||||
if (mine < (nact > 1u ? (GR_NG / nact > 2u ? GR_NG / nact : 2u) : GR_NG) &&
|
||||
(v->gate || !gr_wait[(uint32_t)(t - trk) % NPART]))
|
||||
gr_spawn(P, t, vi, (uint32_t)zl, iv, m);
|
||||
}
|
||||
lp = 4000 + ((clamp((p[P_E7] << 8) + m->cutoff, 0, 127 << 8) * 28767) >> 15);
|
||||
|
||||
@@ -871,6 +871,25 @@ static void hybrid_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, cons
|
||||
}
|
||||
|
||||
/* EDIT */
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the oscillators set to phase 0 at each note (RESET) moved
|
||||
* by r (Q32) of a turn of the note, each by its share (its interval; FIXED: C4's): the others' phases are random
|
||||
* each note already */
|
||||
static void hybrid_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
const hy_patch_t *P = &hy_cur[(uint32_t)(t - trk) % NPART];
|
||||
hy_voice_t *hv = hy_voice(t, v);
|
||||
uint32_t k, b;
|
||||
if (!hv)
|
||||
return;
|
||||
b = hy_inc(v->pitch16, 0, 0);
|
||||
for (k = 0; k < HY_NOSC; k++)
|
||||
if ((P->osc[k].flags & HOF_RESET) && b) {
|
||||
const hy_osc_t *o = &P->osc[k];
|
||||
uint32_t ik = hy_inc((o->flags & HOF_FIXED) ? 60 * 16 : v->pitch16, 0, o->coarse * 4096 + o->fine * 41);
|
||||
hv->ph[k] += (uint32_t)(((uint64_t)r * ik) / b);
|
||||
}
|
||||
}
|
||||
|
||||
static const engine_t ENG_HYBRID = {
|
||||
"HYBRID", {"FILT", "MACRO"},
|
||||
{
|
||||
|
||||
@@ -114,6 +114,16 @@ static const preset_t JUNO_PRESETS[] = {
|
||||
XP(P_SPICE + 1, 16, P_SLOOP + 1, 8, P_VINT + 1, 30)},
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the DCO and the sub (an octave down) moved by r (Q32) of a
|
||||
* turn of the note, the noise from its own place (the note's seed: every voice the same) */
|
||||
static void juno_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
(void)t;
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += r >> 1;
|
||||
v->ph[2] ^= r;
|
||||
}
|
||||
|
||||
static const engine_t ENG_JUNO = {
|
||||
"JUNO", {"DCO", "VCF"},
|
||||
{
|
||||
|
||||
@@ -223,6 +223,17 @@ static const preset_t LOFI_PRESETS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the oscillator moved by r (Q32) of a turn of the note and
|
||||
* the noise register from its own place (every note's from 0x7FFF: every voice the same noise) */
|
||||
static void lofi_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
(void)t;
|
||||
v->ph[0] += r;
|
||||
v->s[2] = (int32_t)(((uint32_t)v->s[2] ^ (r >> 17)) & 0x7FFFu);
|
||||
if (!v->s[2])
|
||||
v->s[2] = 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_LOFI = {
|
||||
"LOFI", {"CHIP", "MOTN"},
|
||||
{
|
||||
|
||||
@@ -59,6 +59,30 @@ static void macro_note_on(track_t *t, voice_t *v)
|
||||
static inline uint32_t *mac_ph(voice_t *v, uint32_t k) { return k < 3u ? &v->ph[k] : (uint32_t *)&v->s[k - 1u]; }
|
||||
static inline uint32_t mac_inc(uint32_t inc, int32_t semi) { return (uint32_t)(((uint64_t)inc * MAC_SEMI[clamp(semi, -12, 36) + 12]) >> 16); }
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the voice's oscillators moved by r (Q32) of a turn of its note,
|
||||
* each by its own pitch's share (CHORD: its interval; SWARM: the note's), as if started that much sooner */
|
||||
static void macro_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
uint32_t j;
|
||||
switch ((uint32_t)p[P_E0] % 4u) {
|
||||
case 0: {
|
||||
const int8_t *c = MAC_CHORD[p[P_E1] * 11 / 128];
|
||||
int32_t inv = p[P_E2] * 5 / 128;
|
||||
for (j = 0; j < 4u; j++)
|
||||
*mac_ph(v, j) += (uint32_t)(((uint64_t)r * MAC_SEMI[clamp(c[j] + ((int32_t)j < inv ? 12 : 0), -12, 36) + 12]) >> 16);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
for (j = 0; j < 8u; j++)
|
||||
*mac_ph(v, j) += r;
|
||||
break;
|
||||
default: /* ADDTV, SPEECH: ph[0] */
|
||||
v->ph[0] += r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mac_chord(voice_t *v, int32_t *acc, uint32_t n, uint32_t inc, int32_t harm, int32_t timb, int32_t morph)
|
||||
{
|
||||
const int8_t *c = MAC_CHORD[harm * 11 / 128];
|
||||
|
||||
@@ -63,6 +63,20 @@ static uint32_t noise_inc(int32_t p)
|
||||
inc = pitch_inc((uint32_t)clamp(p, 0, 2047));
|
||||
return sh && inc >= 0x80000000u >> (sh - 1u) ? 0xFFFFFFFFu : inc << sh;
|
||||
}
|
||||
/* (after Clipper 1.2) the same, unbounded (Q32: 2^32 = one clock a sample). LFSR: a clock past the sample rate steps the
|
||||
* register more than once a sample (the sequence read further on, as the register would be at that time): its pitch
|
||||
* goes on rising with the keys. It used to stop at one step a sample, so every note above it played the same pitch
|
||||
* (NZ ARCADE: TONE +84 semitones, the whole upper half of the keyboard; clipper-fm1 #10) */
|
||||
static uint64_t noise_inc64(int32_t p)
|
||||
{
|
||||
uint32_t sh = 0;
|
||||
while (p > 2047) {
|
||||
p -= 192;
|
||||
sh++;
|
||||
}
|
||||
return (uint64_t)pitch_inc((uint32_t)clamp(p, 0, 2047)) << (sh < 20u ? sh : 20u);
|
||||
}
|
||||
#define NZ_STEPS_MAX 64u /* register steps a sample at most (64 x 44.1 kHz) */
|
||||
|
||||
static uint32_t isqrt32(uint32_t x)
|
||||
{
|
||||
@@ -103,6 +117,7 @@ static void noise_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
uint32_t ph = v->ph[0], reg = v->ph[1]; /* state in locals: out[] may alias v->s[] */
|
||||
int32_t drift = (int32_t)v->ph[2], d16 = 0, gain = 32767, gq, colr, cut, k, a1, a2, a3, g, bpg, mix, cf, thr = 0;
|
||||
uint32_t inc = 0, taps = NOISE_TAPS[sel];
|
||||
uint64_t inc64 = 0; /* (after 1.2) LFSR: its clock, Q32, past the sample rate too */
|
||||
/* drift: a new random target every 0.7..3 s, followed with a 0.7 s lag */
|
||||
if (drft) {
|
||||
int32_t tg = v->s[3] >> 16, cnt = v->s[3] & 0xFFFF;
|
||||
@@ -149,7 +164,7 @@ static void noise_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
}
|
||||
if (mode == NZ_LFSR) {
|
||||
uint32_t mask = taps; /* the register's own bits (MODE / LEN changes) */
|
||||
inc = noise_inc(m->pitch16 + p[P_E7] * 16 + d16);
|
||||
inc64 = noise_inc64(m->pitch16 + p[P_E7] * 16 + d16);
|
||||
mask |= mask >> 1;
|
||||
mask |= mask >> 2;
|
||||
mask |= mask >> 4;
|
||||
@@ -175,9 +190,10 @@ static void noise_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
break;
|
||||
}
|
||||
case NZ_LFSR: {
|
||||
uint32_t o = ph;
|
||||
ph += inc;
|
||||
if (ph < o)
|
||||
uint64_t a = (uint64_t)ph + inc64;
|
||||
uint32_t ns = (uint32_t)(a >> 32) < NZ_STEPS_MAX ? (uint32_t)(a >> 32) : NZ_STEPS_MAX;
|
||||
ph = (uint32_t)a;
|
||||
while (ns--) /* (after 1.2: as many steps as clocks in this sample) */
|
||||
reg = (reg >> 1) ^ (-(reg & 1u) & taps);
|
||||
w = (reg & 1u) ? 12000 : -12000;
|
||||
break;
|
||||
@@ -192,14 +208,14 @@ static void noise_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
x = w;
|
||||
if (colr) { /* pink: three leaky poles (Kellet), brown: a leaky integrator */
|
||||
int32_t pk;
|
||||
b0 = ((b0 * 32690) >> 15) + ((w * 3245) >> 15);
|
||||
b1 = ((b1 * 31555) >> 15) + ((w * 9716) >> 15);
|
||||
b0 = clamp(((b0 * 32690) >> 15) + ((w * 3245) >> 15), -65535, 65535); /* (after Clipper 1.2: bounded: a held */
|
||||
b1 = clamp(((b1 * 31555) >> 15) + ((w * 9716) >> 15), -65535, 65535); /* LFSR level grew them past 2^31 / 32690) */
|
||||
b2 = ((b2 * 18678) >> 15) + ((w * 17247) >> 14);
|
||||
pk = (b0 + b1 + b2 + ((w * 6055) >> 15)) >> 2;
|
||||
if (colr <= (64 << 8)) {
|
||||
x = w + mulq15(pk - w, cf);
|
||||
} else {
|
||||
br = ((br * 32580) >> 15) + ((w * 3480) >> 15);
|
||||
br = clamp(((br * 32580) >> 15) + ((w * 3480) >> 15), -65535, 65535);
|
||||
x = pk + mulq15(br - pk, cf);
|
||||
}
|
||||
}
|
||||
@@ -262,6 +278,17 @@ static const preset_t NOISE_PRESETS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the phase moved by r (Q32) and the noise from its own
|
||||
* seed (the note's: every voice the same noise at DTUNE 0) */
|
||||
static void noise_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
(void)t;
|
||||
v->ph[0] += r;
|
||||
v->s[2] = (int32_t)((uint32_t)v->s[2] ^ r);
|
||||
if (!v->s[2])
|
||||
v->s[2] = 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_NOISE = {
|
||||
.name = "NOISE",
|
||||
.page_title = {"SRC", "MOVE"},
|
||||
|
||||
@@ -193,6 +193,15 @@ static const preset_t PHASE_PRESETS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): line 1, line 2 (DTN cents up) and the sub (an octave
|
||||
* down) moved by r (Q32) of a turn of the note, each by its share (lines 2 and the sub from 0 at each note) */
|
||||
static void phase_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += uni_turns(r, v->pitch16, t->p[P_E4] * 16 / 100);
|
||||
v->ph[2] += r >> 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_PHASE = {
|
||||
"PHASE", {"PHS", "LINE"},
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ static inline const smp_zone_t *smp_zone(uint32_t zi)
|
||||
}
|
||||
|
||||
/* voice: ph[0] position (samples), ph[1] fraction Q16, s[0] predictor, s[1] step
|
||||
* index, s[2] previous sample, s[3] current sample, s[4] zone, s[5] step Q16 */
|
||||
* index, s[2] previous sample, s[3] current sample, s[4] zone, s[5] (UNISON) output samples before it starts */
|
||||
static inline int32_t sample_next(const smp_zone_t *z, voice_t *v, int loop)
|
||||
{
|
||||
uint32_t pos = v->ph[0], b = SMP_DATA[z->off + (pos >> 1)];
|
||||
@@ -179,23 +179,47 @@ static void sample_note_on(track_t *t, voice_t *v)
|
||||
v->s[0] = 0;
|
||||
v->s[1] = 0;
|
||||
v->s[2] = v->s[3] = 0;
|
||||
v->s[5] = 0; /* (after Clipper 1.2) no start delay (UNISON: sample_spread) */
|
||||
v->s[6] = zi == 0xFFFFu; /* 1 = sample ended (one-shot); a kit key with no sound stays silent */
|
||||
v->s[7] = 0; /* lo-pass state */
|
||||
}
|
||||
|
||||
#ifndef SMP_STEP_MAX
|
||||
#define SMP_STEP_MAX (8u << 16) /* decodes an output sample at most (a 44.1 kHz zone 3 octaves up: 8, the cost bound as before) */
|
||||
#endif
|
||||
static void sample_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
const smp_zone_t *z = smp_zone((uint32_t)v->s[4]);
|
||||
uint32_t i, frac = v->ph[1];
|
||||
int32_t d16 = clamp(m->pitch16 + p[P_E1] * 16 - z->root16, -1536, 576); /* <= 3 octaves up: bounded decode load */
|
||||
int32_t d16 = clamp(m->pitch16 + p[P_E1] * 16 - z->root16, -1536, 1536);
|
||||
uint32_t r = pow2_q16(d16), stepq = (r >> 8) * (z->rate >> 8); /* Q16 samples per output */
|
||||
uint32_t lim = (pow2_q16(576) >> 8) * (z->rate >> 8); /* the decode load bounded: 3 octaves up, or SMP_STEP_MAX
|
||||
* source samples an output sample if that is more (a 16 kHz
|
||||
* set, one zone: its pitch went flat 3 octaves over its root) */
|
||||
int32_t bits = p[P_E2], lp = 4000 + ((clamp((p[P_E4] << 8) + m->cutoff, 0, 127 << 8) * 28767) >> 15);
|
||||
int32_t drv = p[P_E6], sh = bits / 10;
|
||||
vmod_t m0;
|
||||
if (stepq > (lim > SMP_STEP_MAX ? lim : SMP_STEP_MAX))
|
||||
stepq = lim > SMP_STEP_MAX ? lim : SMP_STEP_MAX;
|
||||
if (v->s[6] || !z->n) {
|
||||
v->active = 0;
|
||||
return;
|
||||
}
|
||||
if (v->s[5]) { /* (after Clipper 1.2) UNISON: this voice starts later */
|
||||
if ((uint32_t)v->s[5] >= n) {
|
||||
v->s[5] -= (int32_t)n;
|
||||
return;
|
||||
}
|
||||
i = (uint32_t)v->s[5]; /* within this block: the rest of it, its level ramp as it was */
|
||||
v->s[5] = 0;
|
||||
m0 = *m;
|
||||
m0.amp0 = amp_at(m, i);
|
||||
m0.amp1 = m0.amp0 + (m->amp1 - m->amp0);
|
||||
m = &m0;
|
||||
out += i;
|
||||
n -= i;
|
||||
}
|
||||
if (v->ph[0] == 0 && v->ph[1] == 0 && v->s[3] == 0)
|
||||
v->s[3] = sample_next(z, v, p[P_E3]); /* prime the interpolator */
|
||||
for (i = 0; i < n; i++) {
|
||||
@@ -225,6 +249,26 @@ static void sample_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, cons
|
||||
}
|
||||
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the voice starts r (Q32) of four periods of the pitch it
|
||||
* sounds later (s[5]: output samples of silence first; nothing decoded, per note): every voice read the same samples
|
||||
* from the same start, in phase (+9 dB over POLY). Four: a sample may sound lower than its key says (UP BASS: two
|
||||
* octaves). At most the time of 256 source samples (~6 .. 12 ms at its root) and of a quarter of the zone */
|
||||
static void sample_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
const smp_zone_t *z = smp_zone((uint32_t)v->s[4]);
|
||||
int32_t d16 = clamp(v->pitch16 + p[P_E1] * 16 - z->root16, -1536, 1536);
|
||||
uint32_t stepq = (pow2_q16(d16) >> 8) * (z->rate >> 8); /* Q16 source samples an output sample */
|
||||
uint32_t b = pitch_inc((uint32_t)clamp(v->pitch16 + p[P_E1] * 16, 0, 2047)); /* the pitch it sounds (TUNE) */
|
||||
uint32_t d, q; /* (32-bit divides: two a voice, per note) */
|
||||
if (v->s[6] || !z->n || !b || !stepq || v->ph[0] || v->ph[1])
|
||||
return;
|
||||
d = (0xFFFFFFFFu / b) << 2; /* four periods (output samples; < 21600 at pitch 0) */
|
||||
q = ((z->n >> 2 < 256u ? z->n >> 2 : 256u) << 16) / stepq; /* the time of 256 source samples */
|
||||
v->s[5] = (int32_t)(((d < q ? d : q) * (r >> 16)) >> 16); /* x r (the span shortened, not clamped: a clamp */
|
||||
/* gave many voices the same start) */
|
||||
}
|
||||
|
||||
static const engine_t ENG_SAMPLE = {
|
||||
"SAMPLE", {"SET", "TONE"},
|
||||
{
|
||||
|
||||
@@ -99,6 +99,16 @@ static const preset_t STRINGS_PRESETS[] = {
|
||||
{"TAPE STR", {60, 127, 50, 127, 80, 20, 0, 10}, {60, 100, 120, 80}, 0, 0, FX(0, 0, 10, 55), XP(P_LRATE + 1, 30, P_LD_PIT + 1, 2)},
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the three taps (at the 16' pitch, an octave down) moved by
|
||||
* r (Q32) of a turn of the note (they start together at each note: every voice in phase) */
|
||||
static void strings_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
(void)t;
|
||||
v->ph[0] += r >> 1;
|
||||
v->ph[1] += r >> 1;
|
||||
v->ph[2] += r >> 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_STRINGS = {
|
||||
"STRINGS", {"REG", "TONE"},
|
||||
{
|
||||
|
||||
@@ -386,6 +386,16 @@ static const preset_t TRIO_PRESETS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the three oscillators moved by r (Q32) of a turn of the
|
||||
* note, each by its share (its interval, DTN): as if started that much sooner (2 and 3 from fixed phases at each note) */
|
||||
static void trio_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
const int16_t *p = t->p;
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += uni_turns(r, v->pitch16, p[P_E1] * 16 + p[P_E3] * 16 / 100);
|
||||
v->ph[2] += uni_turns(r, v->pitch16, p[P_E2] * 16 - p[P_E3] * 16 / 100);
|
||||
}
|
||||
|
||||
static const engine_t ENG_TRIO = {
|
||||
"TRIO", {"OSC", "TONE"},
|
||||
{
|
||||
|
||||
@@ -121,6 +121,15 @@ static const preset_t VPS_PRESETS[] = {
|
||||
{"VPS CHOIR", {64, 80, 10, 100, 96, 10, 40, 0}, {80, 100, 120, 100}, 0, 0, FX(0, 30, 10, 70), XP(P_LRATE + 1, 25, P_LD_SHP + 1, 8)},
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): oscillators 1, 2 (DTN up) and the sub moved by r (Q32)
|
||||
* of a turn of the note, each by its share (fixed phases at each note: every voice in phase) */
|
||||
static void vps_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += r + (uint32_t)(((uint64_t)r * (uint32_t)(t->p[P_E6] * 30)) >> 16);
|
||||
v->ph[2] += r >> 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_VPS = {
|
||||
"VPS", {"VECTOR", "TONE"},
|
||||
{
|
||||
|
||||
@@ -356,6 +356,15 @@ static const preset_t WAVE_PRESETS[] = {
|
||||
{"HARM PAD", {2, 40, 8, 30, 110, 0, 0, 40}, {70, 100, 120, 95}, 0, 0, FX(0, 40, 20, 60), XP(P_LRATE + 1, 20, P_LD_SHP + 1, 30)},
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): oscillators 1, 2 (DTN cents up) and the sub moved by r
|
||||
* (Q32) of a turn of the note, each by its share (fixed phases at each note: every voice in phase) */
|
||||
static void wave_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += r + (uint32_t)(((uint64_t)r * (uint32_t)(t->p[P_E2] * 38)) >> 16);
|
||||
v->ph[2] += r >> 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_WAVE = {
|
||||
"WAVE", {"WAVE", "FLT"},
|
||||
{
|
||||
|
||||
+18
-3
@@ -83,7 +83,8 @@ static void wseq_note_on(track_t *t, voice_t *v)
|
||||
v->s[3] = 1;
|
||||
v->s[5] = q->st[v->s[2]].lvl * 2184; /* (the level smoothed: from the first step's) */
|
||||
if (!v->env && !v->env_out)
|
||||
v->s[0] = v->s[1] = 0;
|
||||
v->s[0] = v->s[1] = v->s[6] = 0; /* (after Clipper 1.2, s[6]: each step's start phase; UNISON: */
|
||||
/* its own, kept as its phases are when sounding) */
|
||||
if (!v->s[4])
|
||||
v->s[4] = (int32_t)(0x2545F491u ^ ((uint32_t)v->note * 2654435761u));
|
||||
}
|
||||
@@ -97,7 +98,7 @@ static void wseq_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
uint32_t xf, xinv = 0, pos = v->ph[2], into;
|
||||
int32_t k = v->s[2], dir = v->s[3] & 0x80 ? -1 : 1, stopped = (v->s[3] & WSEQ_STOP) != 0;
|
||||
int32_t pscale = clamp(p[P_E5], 0, 127), ic1 = v->s[0], ic2 = v->s[1], nk, gs = v->s[5];
|
||||
uint32_t pa = v->ph[0], pb = v->ph[1], ia, ib, rnd = (uint32_t)v->s[4];
|
||||
uint32_t pa = v->ph[0], pb = v->ph[1], ia, ib, rnd = (uint32_t)v->s[4], p0 = (uint32_t)v->s[6];
|
||||
int hia, hib;
|
||||
tsvf_t flt;
|
||||
if (len < 64u)
|
||||
@@ -144,7 +145,7 @@ static void wseq_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const
|
||||
pa = pb;
|
||||
gs = q->st[k].lvl * 2184; /* (faded in: at its level) */
|
||||
}
|
||||
pb = 0;
|
||||
pb = p0; /* (after Clipper 1.2: UNISON's spread, else 0) */
|
||||
ia = ib;
|
||||
hia = hib;
|
||||
{
|
||||
@@ -192,6 +193,20 @@ static const preset_t WSEQ_PRESETS[] = {
|
||||
{"PING PONG", {15, 40, 30, WL_PING, 0, 64, 110, 10}, {0, 90, 110, 50}, 0, 0, FX(0, 20, 40, 50)},
|
||||
};
|
||||
|
||||
/* (after Clipper 1.2) UNISON (voice.c unison_spread): the step's oscillator and the next one's moved by r
|
||||
* (Q32) of a turn of the note, every next step's start too, and the noise from its own seed (from 0 at each note and
|
||||
* step: every voice in phase) */
|
||||
static void wseq_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
(void)t;
|
||||
v->ph[0] += r;
|
||||
v->ph[1] += r;
|
||||
v->s[6] = (int32_t)r; /* (each step starts from 0: every voice in phase from the second) */
|
||||
v->s[4] = (int32_t)((uint32_t)v->s[4] ^ r); /* (NOISE: the note's seed) */
|
||||
if (!v->s[4])
|
||||
v->s[4] = 1;
|
||||
}
|
||||
|
||||
static const engine_t ENG_WSEQ = {
|
||||
"WSEQ", {"SEQUENCE", "TONE"},
|
||||
{
|
||||
|
||||
@@ -36,6 +36,14 @@ static inline int32_t fm_model(const track_t *t)
|
||||
#endif
|
||||
}
|
||||
/* (pitch_inc: felucca_tables.h, SLOOP 2.5: from the top octave) */
|
||||
/* (after Clipper 1.2) UNISON's start-phase spread (voice.c unison_spread): r (Q32: a turn of the note at pitch p16,
|
||||
* 1/16 semitone) in turns of an oscillator d16 (1/16 semitone) above it, the share of the same time; per note */
|
||||
static uint32_t uni_turns(uint32_t r, int32_t p16, int32_t d16)
|
||||
{
|
||||
uint32_t b = pitch_inc((uint32_t)clamp(p16, 0, 2047));
|
||||
return b ? (uint32_t)(((uint64_t)r * pitch_inc((uint32_t)clamp(p16 + d16, 0, 2047))) / b) : r;
|
||||
}
|
||||
|
||||
#include "eng_analog.c"
|
||||
#include "eng_digital.c"
|
||||
#include "eng_phase.c"
|
||||
|
||||
+31
-16
@@ -78,7 +78,8 @@ static void track_dist(track_t *t, int32_t *b, uint32_t n, uint32_t fresh)
|
||||
int32_t x = b[i], y;
|
||||
t->dist_hp += (x - t->dist_hp + 64) >> 7; /* ~55 Hz low cut: keep the bass out of the clipper */
|
||||
x = clamp(x - t->dist_hp, -230000, 230000); /* (x >> 2) * g fits 32 bits; the clip is flat out there */
|
||||
y = softclip((((x >> 2) * g) >> 10) + bias) - b0; /* >> 2 first: no overflow for loud poly */
|
||||
y = softclip(MULQ12R(x, g, 2) + bias) - b0; /* (as (x >> 2) * g >> 10 in 32 bits: no overflow for loud
|
||||
* poly; SLOOP Pro #4: rounded, no step of 4 x the drive) */
|
||||
t->dist_lp1 += mulq15(y - t->dist_lp1, k); /* two poles: tames the fizz */
|
||||
t->dist_lp2 += mulq15(t->dist_lp1 - t->dist_lp2, k);
|
||||
y = mulq15(t->dist_lp2, mk);
|
||||
@@ -1136,6 +1137,13 @@ static uint32_t part_pending(track_t *t, int32_t fmw)
|
||||
static void part_apply(track_t *t, int32_t fmw)
|
||||
{
|
||||
uint32_t k = (uint32_t)(t - trk) % NPART;
|
||||
if (t->fm_eff && t->fm_eff != fmw && ENGINES[t->engine % NENGINES] == &ENG_VECTOR) {
|
||||
uint32_t i; /* (after Clipper 1.2) VECTOR keeps one set of filter states for
|
||||
* every MODEL (eng_vector.c s[0..3]): a ladder's (x 4096) read by
|
||||
* an SVF burst at full scale; cleared while the part is silent */
|
||||
for (i = 0; i < NVOICE; i++)
|
||||
t->v[i].s[0] = t->v[i].s[1] = t->v[i].s[2] = t->v[i].s[3] = 0;
|
||||
}
|
||||
t->fm_eff = (uint8_t)fmw;
|
||||
if (ENGINES[t->engine % NENGINES] == &ENG_WAVE)
|
||||
wt_tab_eff[k] = (int16_t)((uint32_t)t->p[P_E0] % WT_NALL + 1u);
|
||||
@@ -1323,15 +1331,19 @@ static void mix_part1(track_t *t, uint32_t n)
|
||||
t->lvl = mix_glide(lvl0, lvl), t->gpl = mix_glide(gl0, gl), t->gpr = mix_glide(gr0, gr);
|
||||
dl = (t->lvl - lvl0) >> CTL_LOG2, dgl = t->gpl - gl0, dgr = t->gpr - gr0;
|
||||
for (i = 0; i < n; i++) {
|
||||
int32_t lv = lvl0 + dl * (int32_t)i; /* (SLOOP Pro #4: rounded, all of b, in 32 bits as the >> 3 / >> 2
|
||||
* first were: they floored the part to 2..9 LSB) */
|
||||
#if NVOICE > 8 /* Clipper: 12 / 16 loud voices: one more bit of headroom */
|
||||
int32_t x = ((clamp(b[i], -PART_MAX * 2, PART_MAX * 2) >> 3) * (lvl0 + dl * (int32_t)i)) >> 9, a;
|
||||
int32_t bi = clamp(b[i], -PART_MAX * 2, PART_MAX * 2), x = MULQ12R(bi, lv, 3), a;
|
||||
#else
|
||||
int32_t x = ((clamp(b[i], -PART_MAX, PART_MAX) >> 2) * (lvl0 + dl * (int32_t)i)) >> 10, a; /* pre-shift: 8
|
||||
* loud voices (1.0: bounded: x LEVEL 127 within 32 bits) */
|
||||
int32_t bi = clamp(b[i], -PART_MAX, PART_MAX), x = MULQ12R(bi, lv, 2), a; /* (pre-shift: 8 loud voices,
|
||||
* 1.0: bounded: x LEVEL 127 within 32 bits) */
|
||||
#endif
|
||||
int32_t xs, g = ga + (((gb - ga) * (int32_t)i) >> CTL_LOG2);
|
||||
if (g < 32767)
|
||||
x = (x >> 4) * (g >> 3) >> 8; /* (Q15 in two halves: no 32-bit overflow) */
|
||||
if (g < 32767) { /* (always, at rest: mulq15(32767, 32767) is 32766) */
|
||||
g >>= 3; /* (Q12: no 32-bit overflow) */
|
||||
x = MULQ12R(x, g, 4);
|
||||
}
|
||||
a = x < 0 ? -x : x;
|
||||
xs = clamp(x, -xmax, xmax); /* sends: mulq15 would overflow */
|
||||
if (a > pk)
|
||||
@@ -1347,20 +1359,22 @@ static void mix_part1(track_t *t, uint32_t n)
|
||||
gl = gl0 + ((dgl * (int32_t)i) >> CTL_LOG2), gr = gr0 + ((dgr * (int32_t)i) >> CTL_LOG2); /* (0.7) */
|
||||
#if CLIPPER_SYNTH
|
||||
if (side) { /* the chorus's left - right, through the same level */
|
||||
int32_t si = side[i];
|
||||
#if NVOICE > 8
|
||||
int32_t sd = ((side[i] >> 3) * (lvl0 + dl * (int32_t)i)) >> 9;
|
||||
int32_t sd = MULQ12R(si, lv, 3);
|
||||
#else
|
||||
int32_t sd = ((side[i] >> 2) * (lvl0 + dl * (int32_t)i)) >> 10;
|
||||
int32_t sd = MULQ12R(si, lv, 2);
|
||||
#endif
|
||||
if (g < 32767)
|
||||
sd = (sd >> 4) * (g >> 3) >> 8;
|
||||
mix_l[i] += (((x + sd) >> 4) * gl) >> 8;
|
||||
mix_r[i] += (((x - sd) >> 4) * gr) >> 8;
|
||||
sd = MULQ12R(sd, g, 4); /* (g: Q12 above) */
|
||||
mix_l[i] += ((x + sd) * (gl >> 4) + 128) >> 8;
|
||||
mix_r[i] += ((x - sd) * (gr >> 4) + 128) >> 8;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
mix_l[i] += ((x >> 4) * gl) >> 8; /* (x may pass 2^19: >> 4 first) */
|
||||
mix_r[i] += ((x >> 4) * gr) >> 8;
|
||||
mix_l[i] += (x * (gl >> 4) + 128) >> 8; /* (x may pass 2^19: PAN's Q12 to Q8, exact at rest: 64 a step;
|
||||
* #4: x >> 4 floored the part to 16 LSB) */
|
||||
mix_r[i] += (x * (gr >> 4) + 128) >> 8;
|
||||
}
|
||||
t->peak = pk;
|
||||
}
|
||||
@@ -1514,15 +1528,16 @@ static void mix_block(int32_t *out, uint32_t n)
|
||||
static uint8_t usb_was;
|
||||
for (i = 0; i < n; i++) {
|
||||
int32_t m = m0 + (((m1 - m0) * (int32_t)i) >> CTL_LOG2);
|
||||
ol[i] = ((clamp(mix_l[i], -MIX_MAX, MIX_MAX) >> 2) * m) >> 10; /* (1.0: bounded first: x MASTER in 32 bits) */
|
||||
orr[i] = ((clamp(mix_r[i], -MIX_MAX, MIX_MAX) >> 2) * m) >> 10;
|
||||
int32_t xl = clamp(mix_l[i], -MIX_MAX, MIX_MAX), xr = clamp(mix_r[i], -MIX_MAX, MIX_MAX);
|
||||
ol[i] = MULQ12R(xl, m, 2); /* (1.0: bounded first: x MASTER in 32 bits; #4: rounded, */
|
||||
orr[i] = MULQ12R(xr, m, 2); /* (x >> 2) * m >> 10 floored to 4 LSB) */
|
||||
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;
|
||||
ul[i] = mix_l[i], ur[i] = mix_r[i]; /* (#4: x 4096 / 4096, every bit; it was floored to 4 LSB) */
|
||||
master_pre_usb(&ul[i], &ur[i]);
|
||||
}
|
||||
}
|
||||
|
||||
+54
-17
@@ -138,6 +138,22 @@ static int32_t px_atan(int32_t x)
|
||||
return px_m(x, p, 30);
|
||||
}
|
||||
|
||||
/* atan2(y, x) in turns, Q32 (-1/2 .. 1/2 turn); y, x Q30 (|.| <= 2); one 64 / 32 division (per block only) */
|
||||
static int64_t px_atan2t(int32_t y, int32_t x)
|
||||
{
|
||||
int32_t ay = y < 0 ? -y : y, ax = x < 0 ? -x : x;
|
||||
int64_t t;
|
||||
if (!ay)
|
||||
t = 0;
|
||||
else if (ay <= ax)
|
||||
t = px_m(px_atan((int32_t)(((int64_t)ay << 30) / ax)), 683565276, 30); /* rad / 2 pi */
|
||||
else
|
||||
t = (1 << 30) - px_m(px_atan((int32_t)(((int64_t)ax << 30) / ay)), 683565276, 30);
|
||||
if (x < 0)
|
||||
t = ((int64_t)1 << 31) - t;
|
||||
return y < 0 ? -t : t;
|
||||
}
|
||||
|
||||
static uint32_t px_isqrt64(uint64_t v) /* floor(sqrt(v)) */
|
||||
{
|
||||
uint64_t r = 0, b = (uint64_t)1 << 62;
|
||||
@@ -473,11 +489,10 @@ typedef struct {
|
||||
} px_string_t;
|
||||
|
||||
typedef struct { /* per block */
|
||||
uint32_t delay; /* samples, Q16 */
|
||||
int32_t src_ratio; /* Q30, 1.0 = no resampling */
|
||||
int32_t comp; /* damping compensation, Q30 */
|
||||
uint32_t dl; /* the delay line's read delay, steps Q16 (no all-pass) */
|
||||
int32_t G; /* OnePole: g / (1 + g), Q30 */
|
||||
int32_t m_ap, m_main; /* ap / main delay out of the delay, Q30 */
|
||||
uint32_t ap, mn; /* with the dispersion all-pass: its delay and the line's, Q16 */
|
||||
int32_t ap_gain; /* Q30 */
|
||||
int32_t noise_amt, noise_flt; /* Q30 */
|
||||
int32_t curving; /* bridge curving, Q30 */
|
||||
@@ -498,7 +513,7 @@ static __attribute__((noinline)) void px_string_block(px_string_blk_t *B, px_str
|
||||
{
|
||||
int32_t b = brightness + px_m(accent >> 2, 65536 - brightness, 16);
|
||||
int32_t d = damping + px_m(accent >> 2, 65536 - damping, 16);
|
||||
int32_t nl, dcut, sp, sc, x;
|
||||
int32_t nl, dcut, sp;
|
||||
uint32_t f = f0 > 0x40000000u ? 0x40000000u : f0, delay, df, ratio;
|
||||
if (f < 65536u) /* 0.67 Hz */
|
||||
f = 65536u;
|
||||
@@ -543,7 +558,6 @@ static __attribute__((noinline)) void px_string_block(px_string_blk_t *B, px_str
|
||||
B->src_ratio = ratio >= 1073634406u ? 1 << 30 : (int32_t)ratio; /* >= 0.9999: none */
|
||||
if (B->src_ratio == 1 << 30)
|
||||
S->src = 1u << 30;
|
||||
B->delay = delay;
|
||||
dcut = 786432 + px_m(px_m(d, d, 16), 3932160, 16) + b * 24; /* 12 + 60 d^2 + 24 b semitones, Q16 */
|
||||
if (dcut > 84 << 16)
|
||||
dcut = 84 << 16;
|
||||
@@ -567,14 +581,7 @@ static __attribute__((noinline)) void px_string_block(px_string_blk_t *B, px_str
|
||||
int32_t s = px_sin(df >> 1), c = px_sin((df >> 1) + 0x40000000u);
|
||||
B->G = (int32_t)(((int64_t)s << 30) / (s + c));
|
||||
}
|
||||
/* damping compensation 1 - 2 atan(1 / ratio) / 2 pi, ratio = 2^(dcut / 12) >= 2 */
|
||||
x = (int32_t)(((uint64_t)1 << 46) / px_exp2(dcut / 12)); /* 1 / ratio, Q30 */
|
||||
B->comp = (1 << 30) - px_m(px_atan(x), 341782638, 30); /* * 1 / pi */
|
||||
sp = px_m(px_m(nl, 131072 - nl, 16), 14746, 16); /* nl (2 - nl) 0.225, Q16 */
|
||||
sc = (int32_t)(((uint64_t)delay * 238) >> 16); /* 160 / sr * delay, Q16 */
|
||||
sc = px_clamp(sc, 65536, 137626);
|
||||
B->m_ap = sp << 14;
|
||||
B->m_main = (1 << 30) - px_m(sp, px_m(26739 - px_m(sp, 20185, 16), sc, 16), 2);
|
||||
{
|
||||
int32_t na = nl > 49152 ? (nl - 49152) * 4 : 0; /* 4 (nl - 0.75) */
|
||||
B->noise_amt = px_m(px_m(na, na, 16), 107374182, 16); /* ^2 * 0.1, Q30 */
|
||||
@@ -582,6 +589,35 @@ static __attribute__((noinline)) void px_string_block(px_string_blk_t *B, px_str
|
||||
B->curving = px_m(px_m(nl, nl, 16), 10737418, 16); /* nl^2 0.01 */
|
||||
B->ap_gain = -(int32_t)(((int64_t)663568203 * nl) / (9830 + nl)); /* -0.618 nl / (0.15 + nl) */
|
||||
}
|
||||
{ /* (after Clipper 1.2) the loop in tune: its delays and the phase lags of its filters at the fundamental add up
|
||||
* to one period. DaisySP takes 2 atan(1 / ratio) / 2 pi of a period off for the damping filter (twice the lag
|
||||
* of its OnePole: the compensation of Rings' two-pole Svf) and shortens the line for the dispersion all-pass
|
||||
* by a rule of thumb that grows with the delay: the strings were sharp, by up to +20 cents high and +100 below
|
||||
* F2. Here: the OnePole's lag atan(tan(pi f) / g), the DcBlock's lead, the all-pass's lag at its integer
|
||||
* delay and the linear read's at its fraction, exactly; turns Q32, per block */
|
||||
uint32_t ph = (uint32_t)(((uint64_t)1 << 48) / delay); /* the fundamental, turns per string step, Q32 */
|
||||
int32_t sn = px_sin(ph), cs = px_sin(ph + 0x40000000u);
|
||||
int32_t s = px_sin(df >> 1), c = px_sin((df >> 1) + 0x40000000u); /* sin, cos (pi df) */
|
||||
int64_t lag = px_atan2t(px_m(px_sin(ph >> 1), c, 30), px_m(px_sin((ph >> 1) + 0x40000000u), s, 30))
|
||||
- ((1 << 30) - (int64_t)(ph >> 1)
|
||||
- px_atan2t(px_m(1073498345, sn, 30), (1 << 30) - px_m(1073498345, cs, 30))); /* - DcBlock */
|
||||
uint32_t ap = (uint32_t)(((uint64_t)delay * (uint32_t)sp) >> 16), mn;
|
||||
B->dl = delay - (uint32_t)((lag * delay) >> 32);
|
||||
if (ap >= 4u << 16) {
|
||||
uint32_t psi = (ap >> 16) * ph, a; /* the all-pass: lag psi + 2 atan2(g sin, 1 - g cos) */
|
||||
int64_t lap = psi + 2 * px_atan2t(px_m(B->ap_gain, px_sin(psi), 30),
|
||||
(1 << 30) - px_m(B->ap_gain, px_sin(psi + 0x40000000u), 30));
|
||||
mn = delay - (uint32_t)(((lag + lap) * delay) >> 32);
|
||||
a = (mn & 0xFFFFu) << 14; /* the linear read: lag atan2(a sin, 1 - a + a cos) */
|
||||
lap = px_atan2t(px_m((int32_t)a, sn, 30), (1 << 30) - (int32_t)a + px_m((int32_t)a, cs, 30)) -
|
||||
(int64_t)(((uint64_t)(mn & 0xFFFFu) * ph) >> 16);
|
||||
mn -= (uint32_t)((lap * delay) >> 32);
|
||||
} else {
|
||||
mn = 0;
|
||||
}
|
||||
B->ap = ap;
|
||||
B->mn = mn;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int32_t px_hermite(const int32_t *l, uint32_t wp, uint32_t delay) /* DelayLine::ReadHermite */
|
||||
@@ -642,16 +678,17 @@ static void px_string_run(const px_string_blk_t *B, px_string_t *S, const int32_
|
||||
/* the string */
|
||||
src += (uint32_t)B->src_ratio;
|
||||
if (src > 1u << 30) {
|
||||
uint32_t dl = (uint32_t)(((uint64_t)B->delay * (uint32_t)B->comp) >> 30);
|
||||
uint32_t dl = B->dl;
|
||||
int32_t s;
|
||||
src -= 1u << 30;
|
||||
if (!B->curved) {
|
||||
int32_t nz = (int32_t)(px_rand(&rs) >> 12) - (1 << 19); /* rand - 0.5 */
|
||||
uint32_t q;
|
||||
disp += px_m(B->noise_flt, nz - disp, 30);
|
||||
dl = (uint32_t)(((uint64_t)dl * (uint32_t)((1 << 30) + px_m(disp, B->noise_amt, 20))) >> 30);
|
||||
q = (uint32_t)((1 << 30) + px_m(disp, B->noise_amt, 20)); /* the dispersion noise */
|
||||
{
|
||||
uint32_t ap = (uint32_t)(((uint64_t)dl * (uint32_t)B->m_ap) >> 30);
|
||||
uint32_t mn = (uint32_t)(((uint64_t)dl * (uint32_t)B->m_main) >> 30);
|
||||
uint32_t ap = (uint32_t)(((uint64_t)B->ap * q) >> 30);
|
||||
uint32_t mn = (uint32_t)(((uint64_t)B->mn * q) >> 30);
|
||||
if (ap >= 4u << 16 && mn >= 4u << 16) {
|
||||
uint32_t t = wp + (mn >> 16);
|
||||
int32_t a = S->line[t & PX_LMASK], bb = S->line[(t + 1u) & PX_LMASK], rd, w;
|
||||
@@ -662,7 +699,7 @@ static void px_string_run(const px_string_blk_t *B, px_string_t *S, const int32_
|
||||
swp = (swp - 1u) & PX_SMASK;
|
||||
s = rd - px_m(w, B->ap_gain, 30);
|
||||
} else {
|
||||
s = px_hermite(S->line, wp, dl);
|
||||
s = px_hermite(S->line, wp, (uint32_t)(((uint64_t)dl * q) >> 30));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+173
-24
@@ -201,7 +201,8 @@ typedef struct { /* one track; the drum track igno
|
||||
#if CLIPPER_SYNTH
|
||||
/* 1.0: SPREAD .. the matrix's slot 12 of both (PROJ_X10 each, value - its minimum) and G_DMODE, in track 3's nudges
|
||||
* (micro: SLOOP plays them on track 3's steps; Clipper writes them only while track 3 has none, so they nudge nothing
|
||||
* there): byte 0 CLIPPER_PROJ_MARK_10, then track 1's, track 2's, G_DMODE, a check byte */
|
||||
* there): byte 0 CLIPPER_PROJ_MARK_10, then track 1's, track 2's, G_DMODE, a check byte. After Clipper 1.2 the same
|
||||
* block also goes beside every project (proj_x10_t below), so it is kept when track 3 has steps too */
|
||||
#define PROJ_X10 ((uint32_t)(P_E0 - P_SPREAD))
|
||||
#define PROJ_X10_DM (1u + 2u * PROJ_X10)
|
||||
#define PROJ_X10_CK (PROJ_X10_DM + 1u)
|
||||
@@ -214,14 +215,9 @@ UI_SMALL static uint32_t proj_x10_ck(const int8_t *m)
|
||||
c = ((c << 1) | (c >> 7)) ^ (uint8_t)m[i];
|
||||
return c & 255u;
|
||||
}
|
||||
UI_SMALL static void proj_x10_put(proj_trk_t *d, const step_t *st) /* (track 3's own steps: none, or nothing put) */
|
||||
UI_SMALL static void proj_x10_fill(int8_t *m) /* the block of the working sounds into m[0 .. PROJ_X10_CK] */
|
||||
{
|
||||
uint32_t j, n;
|
||||
int8_t *m = d->micro;
|
||||
for (n = 0; n < NSTEP; n++)
|
||||
if (st[n].n)
|
||||
return;
|
||||
memset(m, 0, NSTEP);
|
||||
m[0] = (int8_t)CLIPPER_PROJ_MARK_10;
|
||||
for (j = 0; j < 2u; j++)
|
||||
for (n = 0; n < PROJ_X10; n++)
|
||||
@@ -229,6 +225,15 @@ UI_SMALL static void proj_x10_put(proj_trk_t *d, const step_t *st) /* (track 3
|
||||
m[PROJ_X10_DM] = (int8_t)(uint8_t)clamp(song.g[G_DMODE], GP[G_DMODE].min, GP[G_DMODE].max);
|
||||
m[PROJ_X10_CK] = (int8_t)proj_x10_ck(m);
|
||||
}
|
||||
UI_SMALL static void proj_x10_put(proj_trk_t *d, const step_t *st) /* (track 3's own steps: none, or nothing put) */
|
||||
{
|
||||
uint32_t n;
|
||||
for (n = 0; n < NSTEP; n++)
|
||||
if (st[n].n)
|
||||
return;
|
||||
memset(d->micro, 0, NSTEP);
|
||||
proj_x10_fill(d->micro);
|
||||
}
|
||||
UI_SMALL static int proj_x10_ok(const int8_t *m)
|
||||
{
|
||||
return (uint8_t)m[0] == CLIPPER_PROJ_MARK_10 && (uint8_t)m[PROJ_X10_CK] == proj_x10_ck(m);
|
||||
@@ -578,6 +583,59 @@ UI_SMALL static int proj_import(project_t *q, const void *b, int n)
|
||||
proj_from_v2(q, (const project_v2_t *)b, n) || proj_from_v1(q, (const project_v1_t *)b, n);
|
||||
}
|
||||
|
||||
#if CLIPPER_SYNTH
|
||||
/* (after Clipper 1.2) the 1.0 block of every project, out of the project: with steps on track 3 (a SLOOP project loaded)
|
||||
* its nudges are its own, and the block had nowhere to go (its values came back at their defaults). Kept beside each
|
||||
* project in RAM (proj_x10s, bound to its project by the project's sum), in flash in the project object's side record
|
||||
* (storage.c st_side: SLOOP never reads a project's, its own save drops it), and in the editor's backup as object 14
|
||||
* (editor.c). Track 3's nudges still hold it when it has no steps, as 1.0 .. 1.2 wrote it (they read it only there) */
|
||||
#define PROJ_X10_MAGIC 0x30315850u /* "PX10" */
|
||||
typedef struct {
|
||||
uint32_t magic, sum; /* the project it belongs to: its sum */
|
||||
int8_t m[PROJ_X10_CK + 1u]; /* as in track 3's nudges */
|
||||
uint8_t rsv[3];
|
||||
uint32_t chk; /* proj_hash of the bytes before */
|
||||
} proj_x10_t;
|
||||
#define PROJ_X10_N 7u /* 0..3 the slots, 4 any other (the backup's snapshot), 5 the
|
||||
* autosave, 6 the loop song mode put aside (proj_x10_at) */
|
||||
_Static_assert(sizeof(proj_x10_t) == 72u, "the 1.0 block beside a project");
|
||||
/* (in .pool, zeroed at boot: .noinit, which keeps proj_slot over a warm reset, has not 504 B left. So a live section
|
||||
* stored while playing and not yet written to flash comes back from a warm reset without its block: with steps on
|
||||
* track 3, its 1.0 values at their defaults) */
|
||||
static proj_x10_t proj_x10s[PROJ_X10_N] __attribute__((section(".pool")));
|
||||
static uint32_t proj_x10_at(const project_t *p);
|
||||
UI_SMALL static int proj_x10_valid(const proj_x10_t *x)
|
||||
{
|
||||
return x->magic == PROJ_X10_MAGIC && x->chk == proj_hash(x, sizeof *x - 4u) && proj_x10_ok(x->m);
|
||||
}
|
||||
UI_SMALL static void proj_x10_seal(proj_x10_t *x, uint32_t sum)
|
||||
{
|
||||
x->magic = PROJ_X10_MAGIC;
|
||||
x->sum = sum;
|
||||
x->rsv[0] = x->rsv[1] = x->rsv[2] = 0;
|
||||
x->chk = proj_hash(x, sizeof *x - 4u);
|
||||
}
|
||||
UI_SMALL static const int8_t *proj_x10_of(const project_t *p) /* p's 1.0 block: in track 3's nudges, else beside it, else 0 */
|
||||
{
|
||||
const proj_x10_t *x = &proj_x10s[proj_x10_at(p)];
|
||||
if (p->rsv[0] != CLIPPER_PROJ_MARK)
|
||||
return 0;
|
||||
if (proj_x10_ok(p->t[2].micro))
|
||||
return p->t[2].micro;
|
||||
return proj_x10_valid(x) && x->sum == p->sum ? x->m : 0;
|
||||
}
|
||||
#ifdef PROJ_HOST
|
||||
static uint32_t proj_x10_at(const project_t *p) /* (host tests: the slots, else 4) */
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < 4u; i++)
|
||||
if (p == &proj_slot[i])
|
||||
return i;
|
||||
return 4u;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ---- the working project <-> a project_t */
|
||||
UI_SMALL static void proj_capture(project_t *p) /* what is playing now, as a project */
|
||||
{
|
||||
@@ -617,6 +675,13 @@ UI_SMALL static void proj_capture(project_t *p) /* what is playing now, a
|
||||
#endif
|
||||
}
|
||||
p->sum = proj_sum(p);
|
||||
#if CLIPPER_SYNTH
|
||||
{ /* (after 1.2) and beside it, whatever track 3 holds */
|
||||
proj_x10_t *x = &proj_x10s[proj_x10_at(p)];
|
||||
proj_x10_fill(x->m);
|
||||
proj_x10_seal(x, p->sum);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* a project's tracks (and its globals, all: a load; or only the drum level / reverb / delay: a song
|
||||
@@ -625,6 +690,9 @@ UI_SMALL static void proj_capture(project_t *p) /* what is playing now, a
|
||||
UI_SMALL static void proj_apply(const project_t *p, int all)
|
||||
{
|
||||
uint32_t i, k;
|
||||
#if CLIPPER_SYNTH
|
||||
const int8_t *xm = proj_x10_of(p); /* (1.0's values: track 3's nudges, or beside the project) */
|
||||
#endif
|
||||
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 :
|
||||
!CLIPPER_SYNTH && (i == G_DRLVL || i == G_DRREV)) /* (Clipper: the master EQ, not a section's) */
|
||||
@@ -643,9 +711,8 @@ UI_SMALL static void proj_apply(const project_t *p, int all)
|
||||
i >= P_E0 && i <= P_E7 ? &ENGINES[e]->edit[i - P_E0] : &TP[i];
|
||||
int32_t v = i < PROJ_E0 ? s->p[i] : i >= P_E0 ? s->p[PROJ_E0 + i - P_E0] : d->def;
|
||||
#if CLIPPER_SYNTH
|
||||
if (i >= P_SPREAD && i < P_E0 && k < 2u) { /* (1.0: in track 3's nudges) */
|
||||
v = p->rsv[0] == CLIPPER_PROJ_MARK && proj_x10_ok(p->t[2].micro) ?
|
||||
(uint8_t)p->t[2].micro[1u + PROJ_X10 * k + (i - P_SPREAD)] + d->min : d->def;
|
||||
if (i >= P_SPREAD && i < P_E0 && k < 2u) { /* (1.0: in track 3's nudges, or beside the project) */
|
||||
v = xm ? (uint8_t)xm[1u + PROJ_X10 * k + (i - P_SPREAD)] + d->min : d->def;
|
||||
} else if (i >= P_VINT && i < P_E0 && k < 2u && p->rsv[0] == CLIPPER_PROJ_MARK) {
|
||||
int x = proj_x9_get(p->t[3].lock, k, i - P_VINT); /* (0.9: in track 4) */
|
||||
v = x < 0 ? d->def : x + d->min;
|
||||
@@ -669,13 +736,10 @@ UI_SMALL static void proj_apply(const project_t *p, int all)
|
||||
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);
|
||||
#if CLIPPER_SYNTH
|
||||
if (k == 2u && p->rsv[0] == CLIPPER_PROJ_MARK && proj_x10_ok(s->micro)) {
|
||||
if (k == 2u && p->rsv[0] == CLIPPER_PROJ_MARK && proj_x10_ok(s->micro))
|
||||
memset(t->micro, 0, sizeof t->micro); /* (1.0's values, not nudges) */
|
||||
if (all)
|
||||
song.g[G_DMODE] = (int16_t)clamp((uint8_t)s->micro[PROJ_X10_DM], GP[G_DMODE].min, GP[G_DMODE].max);
|
||||
} else if (k == 2u && all) {
|
||||
song.g[G_DMODE] = GP[G_DMODE].def;
|
||||
}
|
||||
if (k == 2u && all)
|
||||
song.g[G_DMODE] = xm ? (int16_t)clamp((uint8_t)xm[PROJ_X10_DM], GP[G_DMODE].min, GP[G_DMODE].max) : GP[G_DMODE].def;
|
||||
#endif
|
||||
for (i = 0; i < NSTEP / 4u; i++) { /* the conditions: 3 means normal (0) */
|
||||
uint32_t b = s->fill[i], j;
|
||||
@@ -707,6 +771,7 @@ UI_SMALL static void proj_apply(const project_t *p, int all)
|
||||
st->n = 4;
|
||||
if (st->time > ST_REST)
|
||||
st->time = ST_REST;
|
||||
st->vel &= 127u; /* (after Clipper 1.2: past 127 from a file, up to twice as loud) */
|
||||
for (j = 0; j < 4u; j++)
|
||||
st->note[j] &= 127u;
|
||||
}
|
||||
@@ -727,6 +792,8 @@ UI_SMALL static void proj_apply(const project_t *p, int all)
|
||||
#include "arranger_scene.c"
|
||||
#endif
|
||||
static uint8_t sec_dirty, song_dirty; /* live sections / the song: in RAM, not yet in flash */
|
||||
static int proj_st_save(uint32_t obj, const project_t *p);
|
||||
static void proj_x10_load(uint32_t obj, const project_t *q);
|
||||
#if FELUCCA_FLASH
|
||||
/* slot from flash into RAM (format 5, or an old one converted) */
|
||||
static union {
|
||||
@@ -743,6 +810,8 @@ UI_SMALL static void proj_fetch(uint32_t slot)
|
||||
int n = st_load(OBJ_PROJECT0 + (slot & 3u), &proj_tmp, sizeof proj_tmp);
|
||||
if (!proj_import(q, &proj_tmp, n))
|
||||
q->magic = 0;
|
||||
else
|
||||
proj_x10_load(OBJ_PROJECT0 + (slot & 3u), q); /* (after Clipper 1.2) its 1.0 block */
|
||||
}
|
||||
#include "fm6_bank.c" /* the FM6 patch bank (eng_fm6.c PTCH B1..B27): staged in proj_tmp */
|
||||
#endif
|
||||
@@ -756,7 +825,7 @@ UI_SMALL static void project_save(uint32_t slot)
|
||||
proj_capture(p);
|
||||
#if FELUCCA_FLASH
|
||||
if (flash_ok) {
|
||||
ui_message(st_save(OBJ_PROJECT0 + (slot & 3u), p, sizeof *p) ? "SAVE ERROR" : "SAVED");
|
||||
ui_message(proj_st_save(OBJ_PROJECT0 + (slot & 3u), p) ? "SAVE ERROR" : "SAVED");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -808,6 +877,68 @@ UI_SMALL static void project_load(uint32_t slot)
|
||||
#define AUTOSAVE_GAP 20000u /* ms between two saves at least */
|
||||
static project_t autosave_buf __attribute__((section(".pool")));
|
||||
static uint32_t autosave_hash, autosave_ms, autosave_checked;
|
||||
#if CLIPPER_SYNTH
|
||||
_Static_assert(sizeof(proj_x10_t) <= ST_SIDE_MAX, "the 1.0 block in a project object's side record");
|
||||
static uint32_t proj_x10_at(const project_t *p) /* the 1.0 block beside project p (PROJ_X10_N) */
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < 4u; i++)
|
||||
if (p == &proj_slot[i])
|
||||
return i;
|
||||
return p == &autosave_buf ? 5u : p == &song_keep ? 6u : 4u;
|
||||
}
|
||||
#endif
|
||||
/* what the autosave compares: the project's sum and (after Clipper 1.2) its 1.0 block's, which is not in the project
|
||||
* while track 3 has steps (a change of SPREAD then changes no byte of the project) */
|
||||
UI_SMALL static uint32_t proj_sig(const project_t *p)
|
||||
{
|
||||
#if CLIPPER_SYNTH
|
||||
const proj_x10_t *x = &proj_x10s[proj_x10_at(p)];
|
||||
if (proj_x10_valid(x) && x->sum == p->sum)
|
||||
return p->sum ^ x->chk;
|
||||
#endif
|
||||
return p->sum;
|
||||
}
|
||||
/* a project into flash (OBJ_PROJECT0 + k, OBJ_AUTOSAVE): (after Clipper 1.2) its 1.0 block in the side record */
|
||||
UI_SMALL static int proj_st_save(uint32_t obj, const project_t *p)
|
||||
{
|
||||
int rc;
|
||||
#if CLIPPER_SYNTH
|
||||
const proj_x10_t *x = &proj_x10s[proj_x10_at(p)];
|
||||
st_side = proj_x10_valid(x) && x->sum == p->sum ? x : 0;
|
||||
st_side_len = sizeof *x;
|
||||
#endif
|
||||
rc = st_save(obj, p, sizeof *p);
|
||||
st_side = 0;
|
||||
return rc;
|
||||
}
|
||||
#if CLIPPER_SYNTH
|
||||
static uint32_t proj_restored_sum; /* the working project a backup restored last (object 0): its sum */
|
||||
UI_SMALL static void proj_x10_set(const int8_t *m) /* a 1.0 block's values into the working sounds (backup object 14) */
|
||||
{
|
||||
uint32_t k, i;
|
||||
fm1_irq_off();
|
||||
for (k = 0; k < 2u; k++)
|
||||
for (i = 0; i < PROJ_X10; i++)
|
||||
trk[k].p[P_SPREAD + i] = (int16_t)clamp((uint8_t)m[1u + PROJ_X10 * k + i] + TP[P_SPREAD + i].min,
|
||||
TP[P_SPREAD + i].min, TP[P_SPREAD + i].max);
|
||||
song.g[G_DMODE] = (int16_t)clamp((uint8_t)m[PROJ_X10_DM], GP[G_DMODE].min, GP[G_DMODE].max);
|
||||
fm1_irq_on();
|
||||
}
|
||||
#endif
|
||||
/* q just read from obj: its 1.0 block from the side record, when it is q's */
|
||||
UI_SMALL static void proj_x10_load(uint32_t obj, const project_t *q)
|
||||
{
|
||||
#if CLIPPER_SYNTH
|
||||
proj_x10_t x, *y = &proj_x10s[proj_x10_at(q)];
|
||||
if (st_side_load(obj, &x, sizeof x) == 0 && proj_x10_valid(&x) && x.sum == q->sum)
|
||||
*y = x;
|
||||
else if (!proj_x10_valid(y) || y->sum != q->sum)
|
||||
memset(y, 0, sizeof *y);
|
||||
#else
|
||||
(void)obj, (void)q;
|
||||
#endif
|
||||
}
|
||||
|
||||
UI_SMALL static int audio_quiet(void)
|
||||
{
|
||||
@@ -831,10 +962,10 @@ UI_SMALL static void autosave_tick(void) /* main loop */
|
||||
return;
|
||||
autosave_checked = now;
|
||||
proj_capture(&autosave_buf);
|
||||
h = autosave_buf.sum;
|
||||
h = proj_sig(&autosave_buf);
|
||||
if (h == autosave_hash || !audio_quiet())
|
||||
return;
|
||||
if (st_save(OBJ_AUTOSAVE, &autosave_buf, sizeof autosave_buf) == 0)
|
||||
if (proj_st_save(OBJ_AUTOSAVE, &autosave_buf) == 0)
|
||||
autosave_hash = h;
|
||||
autosave_ms = fm1_ms;
|
||||
#endif
|
||||
@@ -850,7 +981,8 @@ UI_SMALL static void autosave_resume(void) /* power-on: the project
|
||||
n = st_load(OBJ_AUTOSAVE, &proj_tmp, sizeof proj_tmp);
|
||||
if (!proj_import(q, &proj_tmp, n))
|
||||
return;
|
||||
autosave_hash = q->sum;
|
||||
proj_x10_load(OBJ_AUTOSAVE, q); /* (after Clipper 1.2) its 1.0 block */
|
||||
autosave_hash = proj_sig(q);
|
||||
proj_apply(q, 1);
|
||||
song.sel = (uint8_t)(q->sel < NTRK && !CLIPPER_SYNTH ? q->sel : 0u);
|
||||
for (n = 0; n < NPART; n++)
|
||||
@@ -1031,6 +1163,8 @@ UI_SMALL static void persist_boot(void) /* before settings_in
|
||||
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]))
|
||||
sec_dirty |= (uint8_t)(1u << i);
|
||||
else
|
||||
proj_x10_load(OBJ_PROJECT0 + i, &proj_slot[i]); /* (Clipper: its 1.0 block, from flash) */
|
||||
}
|
||||
}
|
||||
dsu_boot(); /* SLOOP 2.5: the SYN kits (after the settings) */
|
||||
@@ -1187,13 +1321,28 @@ UI_SMALL static uint32_t project_restore(uint32_t slot, const void *raw, uint32_
|
||||
}
|
||||
if (!proj_import(&autosave_buf, raw, (int)n))
|
||||
return 2;
|
||||
#if CLIPPER_SYNTH
|
||||
{ /* (its 1.0 block until object 14 brings it: the backup snapshot's, LIST's, when it is that project) */
|
||||
proj_x10_t *x = &proj_x10s[proj_x10_at(&autosave_buf)];
|
||||
if (proj_x10_valid(&proj_x10s[4]) && proj_x10s[4].sum == autosave_buf.sum)
|
||||
*x = proj_x10s[4];
|
||||
else
|
||||
memset(x, 0, sizeof *x);
|
||||
}
|
||||
#endif
|
||||
if (slot == 4u) {
|
||||
project_apply(&autosave_buf);
|
||||
#if CLIPPER_SYNTH
|
||||
proj_restored_sum = autosave_buf.sum; /* (object 14 may bring its 1.0 block next) */
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if (!flash_ok || st_save(OBJ_PROJECT0 + slot, &autosave_buf, sizeof autosave_buf))
|
||||
if (!flash_ok || proj_st_save(OBJ_PROJECT0 + slot, &autosave_buf))
|
||||
return 4;
|
||||
memcpy(&proj_slot[slot], &autosave_buf, sizeof proj_slot[slot]);
|
||||
#if CLIPPER_SYNTH
|
||||
proj_x10s[slot] = proj_x10s[proj_x10_at(&autosave_buf)]; /* (its 1.0 block, when it has one: object 14 brings it) */
|
||||
#endif
|
||||
proj_v6_ins_ok[slot] = proj_v6_ins_ok[4]; /* (a SLOOP 2.6 project's INSERT goes with it) */
|
||||
memcpy(proj_v6_ins[slot], proj_v6_ins[4], sizeof proj_v6_ins[slot]);
|
||||
sec_dirty &= (uint8_t)~(1u << slot);
|
||||
@@ -1238,7 +1387,7 @@ UI_SMALL static void sections_write(void) /* the dirty se
|
||||
#if FELUCCA_FLASH
|
||||
if (flash_ok)
|
||||
for (i = 0; i < 4u; i++)
|
||||
if (((sec_dirty >> i) & 1u) && st_save(OBJ_PROJECT0 + i, &proj_slot[i], sizeof proj_slot[i]) == 0)
|
||||
if (((sec_dirty >> i) & 1u) && proj_st_save(OBJ_PROJECT0 + i, &proj_slot[i]) == 0)
|
||||
sec_dirty &= (uint8_t)~(1u << i); /* (a failed write stays dirty: tried again later) */
|
||||
if (!flash_ok)
|
||||
#endif
|
||||
@@ -1257,8 +1406,8 @@ UI_SMALL static void persist_flush_now(void)
|
||||
#if FELUCCA_FLASH
|
||||
if (flash_ok && !arrangement_clock.running) { /* (a song playing: the tracks hold a section) */
|
||||
proj_capture(&autosave_buf);
|
||||
if (autosave_buf.sum != autosave_hash && st_save(OBJ_AUTOSAVE, &autosave_buf, sizeof autosave_buf) == 0)
|
||||
autosave_hash = autosave_buf.sum;
|
||||
if (proj_sig(&autosave_buf) != autosave_hash && proj_st_save(OBJ_AUTOSAVE, &autosave_buf) == 0)
|
||||
autosave_hash = proj_sig(&autosave_buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#define UI_SMALL /* (gfx.c: minsize on the device; a test alone: nothing) */
|
||||
#endif
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "CLIPPER 1.2" /* the synthesizer firmware for the FM-1 (from SLOOP 2.5, based on Felucca) */
|
||||
#define FELUCCA_VERSION "CLIPPER 1.3" /* the synthesizer firmware for the FM-1 (from SLOOP 2.5, based on Felucca) */
|
||||
#endif
|
||||
static void project_save(uint32_t slot);
|
||||
static void arrangement_save(void);
|
||||
|
||||
@@ -1092,9 +1092,13 @@ UI_SMALL static void ui_input(void)
|
||||
}
|
||||
if (rec_wait && !ft_on && !ci_on) { /* the REC screen, armed: how it records */
|
||||
rec_knobs(); /* (tempo and sound still work; the track too: */
|
||||
enc_hold |= 15u << EN_K1; /* (after Clipper 1.2, sloop-pro #6) KNOB 1..4 are the REC screen's this
|
||||
* pass: a detent counted after rec_knobs read it never reaches
|
||||
* the page under it too (K3 START also moved TRACKS' LEN) */
|
||||
} else if (rec_wait || ft_on) { /* the arm follows) */
|
||||
for (k = 0; k < 4u; k++) /* a take / the count-in: KNOB 1..4 edit nothing */
|
||||
panel_enc(EN_K1 + k);
|
||||
enc_hold |= 15u << EN_K1;
|
||||
}
|
||||
#if FELUCCA_ARRANGER
|
||||
if (on_song_page()) {
|
||||
|
||||
@@ -31,7 +31,9 @@ static uint8_t sec_armed; /* store over a used sec
|
||||
static uint32_t sec_armed_ms;
|
||||
static uint8_t chain_tap[CHAIN_MAX], chain_taps; /* the section keys tapped in this SAVE hold (the first
|
||||
* is asked for at once; two or more: a chain on release) */
|
||||
#define TAP_MS 450u /* a press shorter than this, untouched: a tap */
|
||||
#define TAP_MS 1000u /* a press shorter than this, untouched: a tap (after Clipper 1.2: was
|
||||
* 0.45 s: a firm press of GLO, EDIT, ARP, SEQ or SEL opened nothing,
|
||||
* the layer flashed and HOME stayed; clipper-fm1 #24) */
|
||||
#define SHOW_MS 350u /* the layer shows after this (a tap does not flash it; SLOOP 2.8.3: was 0.14 s,
|
||||
* a quick tap flashed it; a key or knob used shows it at once) */
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define UI_SMALL /* (gfx.c: minsize on the device; a test alone: nothing) */
|
||||
#endif
|
||||
static uint8_t song_cursor, song_store_armed, song_load_armed;
|
||||
static uint32_t song_store_deadline;
|
||||
static uint32_t song_store_t; /* when REC or OCT+ asked for its confirmation (ms) */
|
||||
UI_SMALL static int on_song_page(void) { return !ui.home && cur_page()->scope == SC_SONG; }
|
||||
UI_SMALL static void song_sane(void) /* a bad chain (blank / damaged settings): defaults */
|
||||
{
|
||||
@@ -114,19 +114,19 @@ UI_SMALL static void song_screen_input(uint32_t pressed, uint32_t home)
|
||||
arrangement_enabled ^= 1u;
|
||||
ui_message(arrangement_enabled ? "SONG MODE" : "LOOP MODE");
|
||||
} else if (b == B_OCTUP) { /* load: a second press within 3 s (unsaved work goes) */
|
||||
if (song_load_armed && (int32_t)(fm1_ms - song_store_deadline) <= 0) {
|
||||
if (song_load_armed && fm1_ms - song_store_t <= 3000u) {
|
||||
song_load_armed = 0;
|
||||
project_load(scene);
|
||||
} else {
|
||||
song_load_armed = 1;
|
||||
song_store_armed = 0;
|
||||
song_store_deadline = fm1_ms + 3000u;
|
||||
song_store_t = fm1_ms;
|
||||
ui_message("OCT+ AGAIN: LOAD");
|
||||
}
|
||||
} else if (project_used(scene) &&
|
||||
(!song_store_armed || (int32_t)(fm1_ms - song_store_deadline) > 0)) {
|
||||
(!song_store_armed || fm1_ms - song_store_t > 3000u)) {
|
||||
song_store_armed = 1;
|
||||
song_store_deadline = fm1_ms + 3000u;
|
||||
song_store_t = fm1_ms;
|
||||
ui_message("REC AGAIN: REPLACE");
|
||||
} else {
|
||||
project_save(scene);
|
||||
|
||||
+79
-6
@@ -314,6 +314,7 @@ static void glide_set(track_t *t, voice_t *v, int glide)
|
||||
#define VP_ON 1u
|
||||
#define VP_OFF 2u
|
||||
#define VP_GLIDE 4u
|
||||
#define VP_UNI 8u /* (after Clipper 1.2) an extra UNISON voice: its start spread (unison_spread) */
|
||||
static void voice_start(track_t *t, voice_t *v, uint32_t note, uint32_t vel, int glide)
|
||||
{
|
||||
const engine_t *e = ENGINES[t->engine];
|
||||
@@ -399,6 +400,57 @@ static void voice_start(track_t *t, voice_t *v, uint32_t note, uint32_t vel, int
|
||||
}
|
||||
}
|
||||
|
||||
/* a UNISON voice's start phases moved by r (Q32: a turn of its note), as if it had started that much of a period
|
||||
* sooner: in phase the voices stack, spread they sum as noise. Each engine moves its own oscillators (after Clipper
|
||||
* 1.2: FMX and MACRO took nothing here, every voice in phase: FMX +12 dB over POLY, peaks of 4 full scales; MACRO's
|
||||
* chords +7 dB peaks) */
|
||||
static void unison_spread(track_t *t, voice_t *v, uint32_t r)
|
||||
{
|
||||
const engine_t *e = ENGINES[t->engine];
|
||||
/* (after Clipper 1.2) each engine moves all its oscillators (and reseeds its noise): ph[0] alone left the others in
|
||||
* phase (ANALOG's osc 2, TRIO's 2 and 3, DIGITAL's and FM6's operators, the subs, SAMPLE's start...) */
|
||||
if (e == &ENG_ANALOG)
|
||||
analog_spread(t, v, r);
|
||||
else if (e == &ENG_DIGITAL)
|
||||
digital_spread(t, v, r);
|
||||
else if (e == &ENG_PHASE)
|
||||
phase_spread(t, v, r);
|
||||
else if (e == &ENG_LOFI)
|
||||
lofi_spread(t, v, r);
|
||||
else if (e == &ENG_TRIO)
|
||||
trio_spread(t, v, r);
|
||||
else if (e == &ENG_NOISE)
|
||||
noise_spread(t, v, r);
|
||||
else if (e == &ENG_FM6)
|
||||
fm6_spread(t, v, r);
|
||||
else if (e == &ENG_SAMPLE)
|
||||
sample_spread(t, v, r);
|
||||
else if (e == &ENG_HYBRID)
|
||||
hybrid_spread(t, v, r);
|
||||
#if CLIPPER_SYNTH
|
||||
else if (e == &ENG_FMX)
|
||||
fmx_spread(t, v, r);
|
||||
else if (e == &ENG_MACRO)
|
||||
macro_spread(t, v, r);
|
||||
else if (e == &ENG_STRINGS)
|
||||
strings_spread(t, v, r);
|
||||
else if (e == &ENG_WAVE)
|
||||
wave_spread(t, v, r);
|
||||
else if (e == &ENG_VPS)
|
||||
vps_spread(t, v, r);
|
||||
else if (e == &ENG_JUNO)
|
||||
juno_spread(t, v, r);
|
||||
else if (e == &ENG_WSEQ)
|
||||
wseq_spread(t, v, r);
|
||||
#endif
|
||||
#if FELUCCA_SLICE
|
||||
else if (e == &ENG_SLICE)
|
||||
; /* (slices: as played) */
|
||||
#endif
|
||||
else
|
||||
v->ph[0] += r;
|
||||
}
|
||||
|
||||
/* MONO / LEGATO / UNISON: one note on one voice (eight for UNISON, or the
|
||||
* engine's voice cap, spread by DETUNE over the same width) */
|
||||
static void mono_play(track_t *t, uint32_t note, uint32_t vel, int retrig, int glide)
|
||||
@@ -416,11 +468,12 @@ static void mono_play(track_t *t, uint32_t note, uint32_t vel, int retrig, int g
|
||||
continue; /* no room for this extra UNISON voice */
|
||||
/* level: about the same sum for 8 or 4 voices at random phases */
|
||||
voice_start(t, v, note, nv >= NVOICE ? vel * 36u / 100u : nv > 1u ? vel / 2u : vel, glide);
|
||||
if (nv > 1u && i && !eng_sampled(ENGINES[t->engine]) && !was_sounding) { /* random start phases: */
|
||||
if (nv > 1u && i && !was_sounding) { /* random start phases (SAMPLE: its start; not SLICE): */
|
||||
static uint32_t seed = 0x1234567u; /* in phase they stack, evenly spread they cancel */
|
||||
seed = seed * 1664525u + 1013904223u;
|
||||
v->ph[0] += seed;
|
||||
}
|
||||
unison_spread(t, v, seed);
|
||||
} else if (nv > 1u && i && (v->pend & VP_ON))
|
||||
v->pend |= VP_UNI; /* (a sample's, after its fade: spread as it starts) */
|
||||
} else { /* legato: new pitch, same envelope */
|
||||
v->note = (uint8_t)note;
|
||||
#if CLIPPER_SYNTH
|
||||
@@ -517,10 +570,11 @@ static void puni_on(track_t *t, uint32_t note, uint32_t vel)
|
||||
int32_t s = n > 1u ? (2 * (int32_t)j - (int32_t)(n - 1u)) * 7 : 0; /* -7 .. 7 (x (n - 1)) */
|
||||
v->fine = n > 1u ? s * t->p[P_DETUNE] * 56 / (889 * (int32_t)(n - 1u)) : 0;
|
||||
voice_start(t, v, note, n >= 4u ? vel / 2u : n > 1u ? vel * 70u / 100u : vel, t->p[P_GLIDE] != 0);
|
||||
if (j && !was && !eng_sampled(ENGINES[t->engine])) { /* random start phases (in phase they stack) */
|
||||
if (j && !was) { /* random start phases (in phase they stack) */
|
||||
seed = seed * 1664525u + 1013904223u;
|
||||
v->ph[0] += seed;
|
||||
}
|
||||
unison_spread(t, v, seed);
|
||||
} else if (j && (v->pend & VP_ON))
|
||||
v->pend |= VP_UNI; /* (a sample's, after its fade: spread as it starts) */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1215,6 +1269,16 @@ static void vs_finish(track_t *t, const engine_t *e, int32_t *out, uint32_t n)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CLIPPER_SYNTH
|
||||
/* (after Clipper 1.2) the level of a voice of UNISON (UNI2, UNI4) against POLY's, Q15, as mono_play and puni_on set it
|
||||
* through the velocity (about the same sum at random phases): for FMX, whose envelopes are the voice's level (no
|
||||
* velocity there: its unison came out +6 dB over POLY with the phases spread, +12 before) */
|
||||
static int32_t uni_level(const track_t *t)
|
||||
{
|
||||
uint32_t vm = voice_mode(t);
|
||||
return vm == V_UNISON ? (trk_nvoice(t) >= NVOICE ? 11796 : 16384) : vm == V_PUNI4 ? 16384 : vm == V_PUNI2 ? 22938 : 32767;
|
||||
}
|
||||
#endif
|
||||
static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
|
||||
{
|
||||
const engine_t *e = ENGINES[t->engine];
|
||||
@@ -1312,6 +1376,11 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
|
||||
v->pend = 0;
|
||||
if (voice_room(t, 0)) { /* (it was not counted while fading: within the budget) */
|
||||
voice_start(t, v, v->pend_note, v->pend_vel, (pf & VP_GLIDE) != 0);
|
||||
if (pf & VP_UNI) { /* (after Clipper 1.2) UNISON: not in phase with the others */
|
||||
static uint32_t seed = 0x13579BDu;
|
||||
seed = seed * 1664525u + 1013904223u;
|
||||
unison_spread(t, v, seed);
|
||||
}
|
||||
if (pf & VP_OFF) { /* let go within the fade (~1.5 ms): released as it starts, */
|
||||
if (voice_poly((int)voice_mode(t)) && /* or held by the sustain pedal */
|
||||
part_ctl[CLIPPER_SYNTH ? ctl_part(t) : (uint32_t)(t - trk) % NPART].sus)
|
||||
@@ -1408,6 +1477,10 @@ static uint32_t track_render(track_t *t, int32_t *out, uint32_t n)
|
||||
env = e->amp(t, v, env);
|
||||
m.envq15 = e->ownenv ? 0 : env;
|
||||
m.amp1 = e->ownenv ? env : mulq15(env, v->vel * 258);
|
||||
#if CLIPPER_SYNTH
|
||||
if (e == &ENG_FMX && t->p[P_VOICE] >= V_UNISON) /* (after Clipper 1.2) FMX: UNISON's level per voice */
|
||||
m.amp1 = mulq15(m.amp1, uni_level(t));
|
||||
#endif
|
||||
if (p[P_LD_AMP])
|
||||
m.amp1 = mulq15(m.amp1, 32767 - mulq15((lfo + 32768) >> 1, p[P_LD_AMP] * 258));
|
||||
#if CLIPPER_SYNTH
|
||||
|
||||
@@ -512,6 +512,25 @@ int main(int argc, char **argv)
|
||||
check(t->p[P_SLEN] == 16 && t->step[0].note[0] == 60u && ui.home, "EDIT + OCT-: the whole hold's turns undone at once");
|
||||
tap(B_EDIT); frames(2);
|
||||
check(!ui.home && cur_page()->fam == FAM_EDIT, "EDIT tapped: its pages");
|
||||
{ /* (after 1.2, clipper-fm1 #24) a firm press, let go untouched within a second, opens the pages too: GLO
|
||||
* pressed for 0.6 s from HOME or from the NOTES page used to open nothing (TAP 0.45 s) */
|
||||
static const uint32_t LB[5] = {B_GLO, B_EDIT, B_ARP, B_SEQ, B_SCL};
|
||||
static const uint8_t LF[5] = {FAM_GLO, FAM_EDIT, FAM_ARP, FAM_SEQ, FAM_SCL};
|
||||
uint32_t q;
|
||||
ok = 1;
|
||||
for (q = 0; q < 5u; q++) {
|
||||
go_home(); frames(2);
|
||||
press(LB[q]); frames(37); release(LB[q]); frames(3); /* (0.6 s) */
|
||||
ok &= !ui.home && cur_page()->fam == LF[q];
|
||||
}
|
||||
go_home(); frames(2); tap(B_SEQ); frames(2);
|
||||
press(B_GLO); frames(37); release(B_GLO); frames(3);
|
||||
ok &= !ui.home && cur_page()->fam == FAM_GLO;
|
||||
go_home(); frames(2);
|
||||
press(B_GLO); frames(80); release(B_GLO); frames(3); /* (1.3 s: a look at the layer, no page) */
|
||||
ok &= ui.home;
|
||||
check(ok, "GLO, EDIT, ARP, SEQ, SEL pressed 0.6 s untouched (HOME, NOTES): their pages; held 1.3 s: none");
|
||||
}
|
||||
go_home(); frames(2);
|
||||
press(B_GLO); frames(24); /* (SLOOP 2.8.3: the layer after 0.35 s) */
|
||||
ok = ui.layer == LY_MIX;
|
||||
|
||||
+1105
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
# The editor protocol / external input fuzz (tests/editor_fuzz.c, tests/editor_host.c) of Clipper's synth build
|
||||
# (CLIPPER_SYNTH=1) under AddressSanitizer + UBSan, then the reproducers of what it found (tests/editor_repro.c).
|
||||
# sh tests/editor_fuzz.sh [ITER] [SEED] (from the repo root; needs build/gen)
|
||||
# KNOWN_DRLVL=1: tolerate the EQ LOW written past its range by TRACK_MIX (editor_repro 2) until that fix is in
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
OUT=build/host/edfz
|
||||
mkdir -p "$OUT/gen"
|
||||
# SMP_DATA read through a pointer: the user sample slots are addressed as offsets from it (one flash), which
|
||||
# -fsanitize=bounds would take for an overflow of the array; AddressSanitizer still checks every byte
|
||||
{ echo '#define SMP_DATA (smp_data_v)'; sed 's/^static const uint8_t SMP_DATA\[/static const uint8_t SMP_DATA_ARR[/' build/gen/felucca_samples.h;
|
||||
echo 'static const uint8_t *volatile smp_data_v = SMP_DATA_ARR;'; } > "$OUT/gen/felucca_samples.h"
|
||||
CCF="${CC:-cc} -DCLIPPER_SYNTH=1 ${BOARD:-} -DKNOWN_DRLVL=${KNOWN_DRLVL:-0} -O1 -g -w -fsanitize=address,undefined \
|
||||
-fno-sanitize=shift-base,signed-integer-overflow -fno-sanitize-recover=all -I$OUT/gen -Ibuild/gen -Ifirmware/src -Ifirmware/hal"
|
||||
$CCF -o "$OUT/editor_fuzz" tests/editor_fuzz.c -lm
|
||||
N=${1:-20000}
|
||||
S=${2:-1}
|
||||
"$OUT/editor_fuzz" 0 $((N * 10)) "$S" # single frames, every command (HYBRID, FMX, MOD SEQ, TUNING too), edges
|
||||
"$OUT/editor_fuzz" 1 "$N" "$S" # sequences: uploads (samples, wavetables), restores, presets, patches, UI, audio
|
||||
"$OUT/editor_fuzz" 2 "$N" "$S" # USB-MIDI (MPE, RPN, CC 16..20, program change) and TRS bytes in
|
||||
"$OUT/editor_fuzz" 3 $((N / 20)) "$S" # boots from a damaged flash (a child each)
|
||||
"$OUT/editor_fuzz" 4 1 "$S" # every command over every engine / track / id / step
|
||||
"$OUT/editor_fuzz" 5 "$N" "$S" # MIDI in only, then no note may be left held
|
||||
"$OUT/editor_fuzz" 6 $((N / 100)) "$S" # backup / section / autosave round trips give the project and the sound back
|
||||
# the reproducers: all must pass
|
||||
$CCF -o "$OUT/editor_repro" tests/editor_repro.c -lm
|
||||
for r in 1 2 3 4; do "$OUT/editor_repro" $r; done
|
||||
@@ -0,0 +1,322 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Host harness for the web editor's SysEx protocol (firmware/src/editor.c, editor_fm6.c, editor_dsyn.c,
|
||||
* editor_live.c) with the real storage.c / upreset.c / project.c (fm6_bank.c, arranger_scene.c) on a RAM image
|
||||
* of the 1 MiB NOR, the real usb.c SysEx assembly (FELUCCA_OTA), the real UI (as tests/ui_pages_test.c) and the
|
||||
* audio (mix_block) between frames. Included by tests/editor_fuzz.c. Same include order as felucca.c. */
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#define FELUCCA_ARRANGER 1
|
||||
#define FELUCCA_FLASH 1
|
||||
#define FELUCCA_OTA 1
|
||||
/* the flash: a RAM image, read where it is (the XIP window) */
|
||||
static uint8_t nor[0x100000] __attribute__((aligned(4096)));
|
||||
#define SMP_USER_XIP(k) ((const uint8_t *)nor + SMP_USER_OFF((uint32_t)(k)))
|
||||
#define FM6_BANK_XIP(copy) ((const uint8_t *)nor + st_sector(OBJ_FM6BANK, copy) + ST_PAYLOAD_OFF)
|
||||
#define ST_XIP_PTR(off) ((const uint8_t *)nor + (off))
|
||||
/* (the user slots' zones are rebased onto SMP_DATA, eng_sample.c smp_user_scan: one 32-bit offset space, as the flash
|
||||
* is on the FM-1, so their reads index SMP_DATA past its own size into the flash image. Under -fsanitize=bounds, build
|
||||
* with -I to a copy of build/gen/felucca_samples.h whose SMP_DATA is read through a pointer: tests/editor_fuzz.sh) */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
static uint16_t screen[240*240];
|
||||
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)
|
||||
{ uint32_t i,j; assert(x+w<=240 && y+h<=240); for(j=0;j<h;j++) for(i=0;i<w;i++) screen[(y+j)*240+x+i]=p[j*w+i]; }
|
||||
#include "../firmware/src/gfx.c"
|
||||
static void lcd_fill(uint32_t x,uint32_t y,uint32_t w,uint32_t h,uint16_t c)
|
||||
{ uint32_t i,j; assert(x+w<=240&&y+h<=240); for(j=0;j<h;j++)for(i=0;i<w;i++)screen[(y+j)*240+x+i]=swap16(c); }
|
||||
static int32_t encs[7];
|
||||
static uint32_t fm1_ticks(void) { return fm1_ms * 1000u * 24u; }
|
||||
#define FM1_TICKS_PER_US 24u
|
||||
static int32_t fm1_enc_take(uint32_t e) { int32_t s = encs[e]; encs[e] = 0; return s; }
|
||||
static uint8_t fm1_led[16], fm1_led_dim[16], fm1_led_bg[16];
|
||||
static volatile uint16_t fm1_led_bg_ns;
|
||||
#define FM1_NCOL 16u
|
||||
static const int8_t FM1_KEYMAP[5][16];
|
||||
static void fm1_led_key(uint32_t id, int on) { (void)id; (void)on; }
|
||||
static uint32_t edges_btn, notes_seen;
|
||||
static uint32_t fm1_input_edges(int x) { uint32_t e = edges_btn; (void)x; edges_btn = 0; return e; }
|
||||
static uint32_t fm1_input_note_edges(void) { uint32_t e = fm1_in.notes & ~notes_seen; notes_seen = fm1_in.notes; return e; }
|
||||
static void fm1_wdt_feed(void) {}
|
||||
static int32_t fm1_adc_read(int c) { (void)c; return -1; }
|
||||
static struct { uint32_t magic, stage, page, home, ui_frames; } felucca_dbg;
|
||||
#define FELUCCA_ICONS 1
|
||||
#define SCOPE_N 512u
|
||||
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"
|
||||
#include "../firmware/src/ui_song.c"
|
||||
#include "../firmware/src/ui_studio.c"
|
||||
#include "../firmware/src/icons.c"
|
||||
#include "../firmware/src/ui_draw.c"
|
||||
#include "../firmware/src/ui_vis.c"
|
||||
#include "../firmware/src/ui_layers.c"
|
||||
#include "../firmware/src/ui_menu.c"
|
||||
#include "../firmware/src/ui_input.c"
|
||||
/* ---- felucca.c's flash part, on the RAM image (as hal/fm1_flash.h: ranges, one page a program) */
|
||||
#define FL_DATA_LO 0x00097000u
|
||||
#define FL_DATA_HI 0x000E0000u
|
||||
#define FL_GLOB_LO 0x000FC000u
|
||||
#define FL_GLOB_HI 0x000FF000u
|
||||
#define FL_OTA_LO 0x000E0000u
|
||||
#define FL_OTA_HI 0x000E5000u
|
||||
#define FL_FM6_LO 0x000E5000u
|
||||
#define FL_FM6_HI 0x000E7000u
|
||||
#define FL_USR4_LO 0x000E7000u
|
||||
#define FL_USR4_HI 0x000FB000u
|
||||
#define FL_IN(off, n, lo, hi) ((uint32_t)(off) >= (lo) && (uint32_t)(off) <= (hi) && (uint32_t)(n) <= (hi) - (uint32_t)(off))
|
||||
#define FL_STORE_OK(off, n) (FL_IN(off, n, FL_DATA_LO, FL_DATA_HI) || FL_IN(off, n, FL_GLOB_LO, FL_GLOB_HI) || \
|
||||
FL_IN(off, n, FL_FM6_LO, FL_FM6_HI) || FL_IN(off, n, FL_USR4_LO, FL_USR4_HI))
|
||||
#define FL_RANGE_OK(off, n) (FL_STORE_OK(off, n) || FL_IN(off, n, FL_OTA_LO, FL_OTA_HI))
|
||||
#define FL_FAR(fn) fn
|
||||
static uint32_t fl_erases, fl_progs, fl_bad; /* counters; fl_bad: a refused (out of range) access */
|
||||
static int fl_fail_at = -1; /* > 0: the n-th program from now fails (a torn write) */
|
||||
static uint32_t fl_jedec_ram(void) { return 0x856014u; }
|
||||
static void fl_plain_window_init(void) {}
|
||||
static uint32_t irq_save(void) { return 0; }
|
||||
static void irq_restore(uint32_t f) { (void)f; }
|
||||
static void fl_inval(uint32_t off, uint32_t n) { (void)off; (void)n; }
|
||||
static int fl_erase4k_ram(uint32_t off, uint32_t *took)
|
||||
{
|
||||
*took = 0;
|
||||
if ((off & 0xFFFu) || !FL_RANGE_OK(off, 0x1000u)) { fl_bad++; return -1; }
|
||||
memset(nor + off, 0xFF, 0x1000u);
|
||||
fl_erases++;
|
||||
return 0;
|
||||
}
|
||||
static int fl_prog_ram(uint32_t off, const uint8_t *src, uint32_t n, uint32_t *took)
|
||||
{
|
||||
uint32_t i;
|
||||
*took = 0;
|
||||
if (!FL_RANGE_OK(off, n) || n == 0 || n > 256u || ((off & 0xFFu) + n) > 256u) { fl_bad++; return -1; }
|
||||
if (fl_fail_at > 0 && --fl_fail_at == 0) { fl_fail_at = -1; return -3; }
|
||||
for (i = 0; i < n; i++)
|
||||
nor[off + i] &= src[i];
|
||||
fl_progs++;
|
||||
return 0;
|
||||
}
|
||||
static int fl_read_ram(uint32_t off, uint8_t *dst, uint32_t n)
|
||||
{
|
||||
if (off >= sizeof nor || n > sizeof nor - off) { fl_bad++; return -1; }
|
||||
memcpy(dst, nor + off, n);
|
||||
return 0;
|
||||
}
|
||||
static int fl_write(uint32_t off, const uint8_t *src_ram, uint32_t n)
|
||||
{
|
||||
uint32_t took;
|
||||
while (n) {
|
||||
uint32_t chunk = 256u - (off & 0xFFu);
|
||||
int rc;
|
||||
if (chunk > n) chunk = n;
|
||||
rc = fl_prog_ram(off, src_ram, chunk, &took);
|
||||
if (rc) return rc;
|
||||
off += chunk; src_ram += chunk; n -= chunk;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static uint8_t flash_ok;
|
||||
static int st_read(uint32_t off, void *dst, uint32_t n)
|
||||
{
|
||||
uint8_t *d = dst;
|
||||
while (n) {
|
||||
uint32_t k = n > 256u ? 256u : n;
|
||||
int rc = fl_read_ram(off, d, k);
|
||||
if (rc) return rc;
|
||||
off += k; d += k; n -= k;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static void audio_silence(void) {}
|
||||
static int fl_erase4k_quiet(uint32_t off, uint32_t *took) { audio_silence(); return fl_erase4k_ram(off, took); }
|
||||
static int st_erase(uint32_t off) { uint32_t took; if (!FL_STORE_OK(off, 0x1000u)) return -8; return fl_erase4k_quiet(off, &took); }
|
||||
static int st_prog(uint32_t off, const void *src, uint32_t n) { if (!FL_STORE_OK(off, n)) return -8; return fl_write(off, src, n); }
|
||||
#include "../firmware/src/storage.c"
|
||||
#include "../firmware/src/upreset.c"
|
||||
#include "../firmware/src/project.c"
|
||||
/* ---- the ota hooks usb.c needs (felucca.c) */
|
||||
static uint32_t ota_now_ms(void) { return fm1_ms; }
|
||||
static void rx_take(void);
|
||||
static void ota_idle(void) { rx_take(); } /* the host takes the replies */
|
||||
#include "../firmware/src/editor.c"
|
||||
#include "../firmware/src/splash.c"
|
||||
|
||||
/* ---- the harness: frames, replies */
|
||||
static uint8_t rx_last[1024];
|
||||
static uint32_t rx_n; /* the last reply (F0..F7), from the SysEx ring */
|
||||
static void rx_take(void)
|
||||
{
|
||||
while (so_r != so_w) {
|
||||
uint32_t pkt = sx_out_q[so_r % SXQ], cin = pkt & 15u, k, nb = cin == 4u || cin == 7u ? 3u : cin == 6u ? 2u : 1u;
|
||||
so_r++;
|
||||
for (k = 0; k < nb; k++) {
|
||||
uint8_t b = (uint8_t)(pkt >> (8u * (k + 1u)));
|
||||
if (b == 0xF0u) rx_n = 0;
|
||||
if (rx_n < sizeof rx_last) rx_last[rx_n++] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* a frame of n bytes (between F0 and F7) straight into the frame buffer, as usb.c leaves it: ed_service */
|
||||
static void ed_inject(const uint8_t *f, uint32_t n)
|
||||
{
|
||||
if (n > sizeof sx_frame) n = sizeof sx_frame;
|
||||
memcpy(sx_frame, f, n);
|
||||
sx_frame_len = n;
|
||||
sx_ready = 1;
|
||||
rx_n = 0;
|
||||
ed_service();
|
||||
rx_take();
|
||||
sx_ready = 0; /* (ota_service would take one that is not the editor's) */
|
||||
}
|
||||
/* the same through USB-MIDI packets (usb.c midi_in_event / sysex_byte) */
|
||||
static void usb_sysex(const uint8_t *f, uint32_t n)
|
||||
{
|
||||
uint8_t b[700];
|
||||
uint32_t m = 0, i;
|
||||
b[m++] = 0xF0;
|
||||
for (i = 0; i < n && m < sizeof b - 1; i++) b[m++] = f[i];
|
||||
b[m++] = 0xF7;
|
||||
for (i = 0; i < m; i += 3) {
|
||||
uint32_t k = m - i >= 3 ? 3 : m - i, cin = k == 3 && i + 3 < m ? 4u : k == 3 ? 7u : 4u + k;
|
||||
uint32_t pkt = cin | (uint32_t)b[i] << 8 | (k > 1 ? (uint32_t)b[i + 1] << 16 : 0) | (k > 2 ? (uint32_t)b[i + 2] << 24 : 0);
|
||||
midi_in_event(pkt);
|
||||
}
|
||||
rx_n = 0;
|
||||
ed_service();
|
||||
rx_take();
|
||||
sx_ready = 0;
|
||||
}
|
||||
static int32_t audio_peak;
|
||||
static uint32_t audio_bad;
|
||||
static void audio_blocks(uint32_t nb)
|
||||
{
|
||||
static int32_t o[CTL * 2];
|
||||
uint32_t q, i;
|
||||
for (q = 0; q < nb; q++) {
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < 2u * CTL; i++) {
|
||||
int32_t a = o[i] < 0 ? -o[i] : o[i];
|
||||
if (a > audio_peak) audio_peak = a;
|
||||
if (a > 40000) audio_bad++;
|
||||
}
|
||||
for (i = 1; i < CTL; i += 2u) {
|
||||
scope_bufr[scope_w & (SCOPE_N - 1u)] = vis_tap[2u * i + 1u];
|
||||
scope_buf[scope_w++ & (SCOPE_N - 1u)] = vis_tap[2u * i];
|
||||
}
|
||||
}
|
||||
}
|
||||
static void ui_frame(void)
|
||||
{
|
||||
audio_blocks(22);
|
||||
ed_service();
|
||||
ui_input(); ui_leds(); ui_draw();
|
||||
autosave_tick();
|
||||
sections_flush();
|
||||
fm1_ms += 16;
|
||||
}
|
||||
|
||||
static void harness_init(void)
|
||||
{
|
||||
uint32_t i;
|
||||
memset(nor, 0xFF, sizeof nor);
|
||||
if ((uintptr_t)nor < (uintptr_t)SMP_DATA || (uintptr_t)nor - (uintptr_t)SMP_DATA > 0xF0000000u) {
|
||||
printf("editor: the flash image must lie above SMP_DATA within 4 GiB (32-bit offsets)\n");
|
||||
exit(2);
|
||||
}
|
||||
panel = PANEL_DEFAULT;
|
||||
layers_init();
|
||||
settings.palette = 4;
|
||||
palette_set(4);
|
||||
host_tracks_init();
|
||||
persist_boot();
|
||||
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; }
|
||||
TDRUM->p[P_E0] = DRUM_DEFAULT_KIT;
|
||||
usb.config = 1;
|
||||
}
|
||||
|
||||
/* every parameter of every track inside its range (as the editor / a load must leave them) */
|
||||
#ifndef KNOWN_DRLVL /* 1: TRACK_MIX of track 4 writes EQ LOW past its range (reported) */
|
||||
#define KNOWN_DRLVL 0
|
||||
#endif
|
||||
static uint32_t vel_over; /* steps with a velocity > 127 seen (a restored project) */
|
||||
static int params_check(char *why, size_t nw)
|
||||
{
|
||||
uint32_t k, i;
|
||||
for (k = 0; k < NTRK; k++) {
|
||||
const track_t *t = &trk[k];
|
||||
for (i = 0; i < P_COUNT; i++) {
|
||||
const param_desc_t *d = k == TRK_DRUM && i == P_E0 ? &DRUM_KIT_DESC :
|
||||
i >= P_E0 && i <= P_E7 ? &ENGINES[t->eng_req % NENGINES]->edit[i - P_E0] : &TP[i];
|
||||
if (k == TRK_DRUM && i > P_E0 && i <= P_E7)
|
||||
continue; /* (the drum track has no engine values) */
|
||||
if (k != TRK_DRUM && i >= P_E0 && t->engine != t->eng_req)
|
||||
continue; /* (an engine switch fading: the values are the next one's) */
|
||||
if (t->p[i] < d->min || t->p[i] > d->max) {
|
||||
snprintf(why, nw, "trk %u p[%u] (%s) = %d outside %d..%d (eng %u)", k, i, d->label, t->p[i], d->min, d->max,
|
||||
t->eng_req);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (t->eng_req >= NENGINES) { snprintf(why, nw, "trk %u eng_req %u", k, t->eng_req); return 0; }
|
||||
for (i = 0; i < NLOCK; i++) {
|
||||
const plock_t *l = &t->lock[i];
|
||||
const param_desc_t *d;
|
||||
if (l->step == LOCK_FREE) continue;
|
||||
if (l->step >= NSTEP || l->param >= P_COUNT) { snprintf(why, nw, "trk %u lock %u step %u param %u", k, i, l->step, l->param); return 0; }
|
||||
d = k == TRK_DRUM && l->param == P_E0 ? &DRUM_KIT_DESC :
|
||||
l->param >= P_E0 && l->param <= P_E7 ? 0 : &TP[l->param];
|
||||
if (d && (l->val < d->min || l->val > d->max)) { /* (an engine value: clamped when it plays, seq.c lock_write) */
|
||||
snprintf(why, nw, "trk %u lock %u (step %u, %s) = %d outside %d..%d", k, i, l->step, d->label, l->val, d->min, d->max);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!is_drum(t))
|
||||
for (i = 0; i < NSTEP; i++) {
|
||||
const step_t *s = &t->step[i];
|
||||
uint32_t j;
|
||||
if (s->vel > 127u) vel_over++;
|
||||
if (s->n > 4u || s->time > ST_REST) { snprintf(why, nw, "trk %u step %u n %u time %u vel %u", k, i, s->n, s->time, s->vel); return 0; }
|
||||
for (j = 0; j < 4u; j++)
|
||||
if (s->note[j] > 127u) { snprintf(why, nw, "trk %u step %u note %u", k, i, s->note[j]); return 0; }
|
||||
}
|
||||
for (i = 0; i < NSTEP; i++)
|
||||
if (t->micro[i] < MICRO_MIN || t->micro[i] > MICRO_MAX) { snprintf(why, nw, "trk %u micro[%u] %d", k, i, t->micro[i]); return 0; }
|
||||
}
|
||||
for (i = 0; i < G_COUNT; i++)
|
||||
if ((song.g[i] < GP[i].min || song.g[i] > GP[i].max) && !(KNOWN_DRLVL && i == G_DRLVL)) {
|
||||
snprintf(why, nw, "g[%u] (%s) = %d outside %d..%d", i, GP[i].label, song.g[i], GP[i].min, GP[i].max);
|
||||
return 0;
|
||||
}
|
||||
if (song.sel >= NTRK) { snprintf(why, nw, "sel %u", song.sel); return 0; }
|
||||
#if CLIPPER_SYNTH
|
||||
for (k = 0; k < NPART; k++) { /* Clipper: the patches the audio plays, every byte in range */
|
||||
fmx_patch_t f = fmx_cur[k];
|
||||
hy_patch_t h = hy_cur[k], hi = hy_in[k];
|
||||
fmx_sanitize(&f);
|
||||
hy_sanitize(&h);
|
||||
hy_sanitize(&hi);
|
||||
memcpy(f.name, fmx_cur[k].name, sizeof f.name); /* (the name: a 0 in it shows as a space, nothing reads it) */
|
||||
if (memcmp(&f, &fmx_cur[k], sizeof f)) {
|
||||
uint32_t q; for (q = 0; q < sizeof f && ((uint8_t *)&f)[q] == ((const uint8_t *)&fmx_cur[k])[q]; q++) ;
|
||||
snprintf(why, nw, "part %u: fmx_cur byte %u = %u not sanitized (-> %u)", k, q, ((const uint8_t *)&fmx_cur[k])[q], ((uint8_t *)&f)[q]); return 0; }
|
||||
memcpy(h.name, hy_cur[k].name, sizeof h.name);
|
||||
memcpy(hi.name, hy_in[k].name, sizeof hi.name);
|
||||
if (memcmp(&h, &hy_cur[k], sizeof h)) {
|
||||
uint32_t q; for (q = 0; q < sizeof h && ((uint8_t *)&h)[q] == ((const uint8_t *)&hy_cur[k])[q]; q++) ;
|
||||
snprintf(why, nw, "part %u: hy_cur byte %u = %u not sanitized (-> %u)", k, q, ((const uint8_t *)&hy_cur[k])[q], ((uint8_t *)&h)[q]); return 0; }
|
||||
if (memcmp(&hi, &hy_in[k], sizeof hi)) {
|
||||
uint32_t q; for (q = 0; q < sizeof hi && ((uint8_t *)&hi)[q] == ((const uint8_t *)&hy_in[k])[q]; q++) ;
|
||||
snprintf(why, nw, "part %u: hy_in byte %u = %u not sanitized (-> %u)", k, q, ((const uint8_t *)&hy_in[k])[q], ((uint8_t *)&hi)[q]); return 0; }
|
||||
for (i = 0; i < MSEQ_LANES * MSEQ_STEPS; i++)
|
||||
if (trk[k].ms[i / MSEQ_STEPS][i % MSEQ_STEPS] < -8 || trk[k].ms[i / MSEQ_STEPS][i % MSEQ_STEPS] > 7) {
|
||||
snprintf(why, nw, "part %u: mod seq step %u = %d", k, i, trk[k].ms[i / MSEQ_STEPS][i % MSEQ_STEPS]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Reproducers of what tests/editor_fuzz.c found in Clipper (CLIPPER_SYNTH=1), on tests/editor_host.c. Each case
|
||||
* returns 0 (passes) once fixed, 1 on the code as it was:
|
||||
* editor_repro 1 a user wavetable (WAVE's USR1..4, an FWTB header in a sample slot) is left out of the backup: BK_LIST
|
||||
* lists the slot with 0 bytes, so the editor's restore of that backup erases the slot (SMP_ERASE)
|
||||
* editor_repro 2 TRACK_MIX of track 4 (the groovebox's drum level) writes 0..127 into G_DRLVL, which Clipper uses as the
|
||||
* master EQ's LOW (88..112): the value goes past its range (the EQ reads up to +-12 dB, the page shows it)
|
||||
* editor_repro 4 the backup of the user preset banks (objects 6, 7) holds the records only: each preset's Clipper 0.8+ values
|
||||
* (MOD SEQ RATE LEN SMTH START, SPICE, DICE, VINTAGE, LOOP: the bank's side record) and 1.0 values
|
||||
* (SPREAD .. matrix slot 12, the macros: its tail) are not in it, and a restore keeps the side / tail of
|
||||
* what the bank held before in RAM: a preset comes back with another preset's values (and its defaults
|
||||
* after the next power-on)
|
||||
* editor_repro 3 with any step on track 3 (an old SLOOP project loaded, the editor's TRACK_STEP), a project did not keep
|
||||
* Clipper 1.0's values (SPREAD, LFO 3, ENV 2 LOOP, the MACROS, matrix slots 7..12, the delay MODE): a
|
||||
* section saved and loaded (RAM, flash), a power cycle, the autosave, a backup restored all brought them
|
||||
* back at their defaults; track 3's own nudges must stay its own
|
||||
* Build as tests/editor_fuzz.sh builds editor_fuzz.c (CLIPPER_SYNTH=1). */
|
||||
#include "editor_host.c"
|
||||
|
||||
static void ed(uint32_t cmd, const uint8_t *a, uint32_t na)
|
||||
{
|
||||
uint8_t f[700];
|
||||
f[0] = ED_HDR0; f[1] = ED_HDR1; f[2] = ED_HDR2; f[3] = (uint8_t)cmd;
|
||||
memcpy(f + 4, a, na);
|
||||
usb_sysex(f, 4 + na); /* through usb.c's SysEx assembly, as the editor sends it */
|
||||
}
|
||||
static uint32_t pack7(uint8_t *o, const uint8_t *p, uint32_t n)
|
||||
{
|
||||
uint32_t w = 0;
|
||||
while (n) {
|
||||
uint32_t k = n > 7u ? 7u : n, m = 0, i;
|
||||
for (i = 0; i < k; i++) m |= (uint32_t)(p[i] >> 7) << i;
|
||||
o[w++] = (uint8_t)m;
|
||||
for (i = 0; i < k; i++) o[w++] = p[i] & 127u;
|
||||
p += k; n -= k;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
static uint32_t v14(uint8_t *o, int32_t v) { uint32_t u = (uint32_t)(v + 8192); o[0] = u & 127u; o[1] = (u >> 7) & 127u; return 2; }
|
||||
|
||||
static int repro_wt_backup(void)
|
||||
{
|
||||
uint8_t a[700], hdr[sizeof(smp_user_hdr_t)];
|
||||
wt_user_hdr_t *h = (wt_user_hdr_t *)hdr;
|
||||
uint32_t n, off, i, len = 99, pos;
|
||||
a[0] = 0; ed(ED_SMP_BEGIN, a, 1); /* a wavetable into USR1, as the editor's Samples page sends it */
|
||||
for (off = 0; off < WT_USER_LEN; off += 256) {
|
||||
uint8_t d[256];
|
||||
uint32_t o = SMP_USER_DATA + off;
|
||||
for (i = 0; i < 256; i++) d[i] = (uint8_t)(off / 256 + i * 7);
|
||||
n = 0; a[n++] = 0; a[n++] = o & 127u; a[n++] = (o >> 7) & 127u; a[n++] = (o >> 14) & 127u;
|
||||
n += pack7(a + n, d, 256);
|
||||
ed(ED_SMP_WRITE, a, n);
|
||||
}
|
||||
memset(hdr, 0xFF, sizeof hdr);
|
||||
memset(h, 0, sizeof *h);
|
||||
h->magic = WT_USER_MAGIC; h->version = 1; h->nf = WT_NF; h->nh = WT_NH; memcpy(h->name, "MYTABLE", 7);
|
||||
h->data_len = WT_USER_LEN; h->crc = st_crc32(nor + SMP_USER_OFF(0) + SMP_USER_DATA, WT_USER_LEN);
|
||||
n = 0; a[n++] = 0; n += pack7(a + n, hdr, sizeof hdr);
|
||||
ed(ED_SMP_END, a, n);
|
||||
printf("SMP_END rc %u; wt_user_ok[0] %u\n", rx_n > 6 ? rx_last[6] : 99u, wt_user_ok[0]);
|
||||
ed(ED_SMP_INFO, a, 0);
|
||||
printf("SMP_INFO: USR1 zones %u (127 = a wavetable)\n", rx_n > 7 ? rx_last[7] : 99u);
|
||||
ed(ED_BK_LIST, a, 0); /* -> rc, count, per object: id, len (5), crc (5) */
|
||||
for (pos = 7; pos + 11 <= rx_n; pos += 11)
|
||||
if (rx_last[pos] == 32u) {
|
||||
len = 0;
|
||||
for (i = 0; i < 5; i++) len |= (uint32_t)rx_last[pos + 1 + i] << (7 * i);
|
||||
}
|
||||
printf("BK_LIST: object 32 (USR1) %u bytes (the slot holds %u)\n", len, SMP_USER_DATA + WT_USER_LEN);
|
||||
if (len != SMP_USER_DATA + WT_USER_LEN)
|
||||
return 1; /* (the editor's restore then sends SMP_ERASE: the table is gone) */
|
||||
{ /* read it as the editor's backup does, erase the slot, write it back as its restore does: the same table */
|
||||
static uint8_t img[SMP_USER_DATA + WT_USER_LEN], was[SMP_USER_DATA + WT_USER_LEN];
|
||||
memcpy(was, nor + SMP_USER_OFF(0) + SMP_USER_DATA, WT_USER_LEN);
|
||||
for (off = 0; off < len; off += 256) {
|
||||
uint32_t k, w;
|
||||
n = 0; a[n++] = 32; for (i = 0; i < 5; i++) a[n++] = (off >> (7 * i)) & 127u; a[n++] = 0; a[n++] = 2;
|
||||
ed(ED_BK_GET, a, n);
|
||||
if (rx_n < 13 || rx_last[6]) { printf("BK_GET rc %u\n", rx_n > 6 ? rx_last[6] : 99u); return 1; }
|
||||
for (k = 14, w = 0; w < 256 && k < rx_n - 1; ) {
|
||||
uint32_t m = rx_last[k++], j;
|
||||
for (j = 0; j < 7 && w < 256 && k < rx_n - 1; j++) img[off + w++] = (uint8_t)(rx_last[k++] | ((m >> j) & 1u) << 7);
|
||||
}
|
||||
}
|
||||
a[0] = 0; ed(ED_SMP_ERASE, a, 1);
|
||||
a[0] = 0; ed(ED_SMP_BEGIN, a, 1);
|
||||
for (off = SMP_USER_DATA; off < len; off += 256) {
|
||||
n = 0; a[n++] = 0; a[n++] = off & 127u; a[n++] = (off >> 7) & 127u; a[n++] = (off >> 14) & 127u;
|
||||
n += pack7(a + n, img + off, 256);
|
||||
ed(ED_SMP_WRITE, a, n);
|
||||
}
|
||||
n = 0; a[n++] = 0; n += pack7(a + n, img, sizeof(smp_user_hdr_t));
|
||||
ed(ED_SMP_END, a, n);
|
||||
printf("restored: SMP_END rc %u, wt_user_ok[0] %u, the spectra %s\n", rx_n > 6 ? rx_last[6] : 99u, wt_user_ok[0],
|
||||
memcmp(was, nor + SMP_USER_OFF(0) + SMP_USER_DATA, WT_USER_LEN) ? "differ" : "the same");
|
||||
return !wt_user_ok[0] || memcmp(was, nor + SMP_USER_OFF(0) + SMP_USER_DATA, WT_USER_LEN) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int repro_eq_low(void)
|
||||
{
|
||||
uint8_t a[8];
|
||||
a[0] = TRK_DRUM; v14(a + 1, 127); a[3] = 0;
|
||||
ed(ED_TRACK_MIX, a, 4);
|
||||
printf("TRACK_MIX track 4 level 127: g[G_DRLVL] (%s) = %d, its range %d..%d\n", GP[G_DRLVL].label, song.g[G_DRLVL],
|
||||
GP[G_DRLVL].min, GP[G_DRLVL].max);
|
||||
return song.g[G_DRLVL] < GP[G_DRLVL].min || song.g[G_DRLVL] > GP[G_DRLVL].max;
|
||||
}
|
||||
|
||||
/* read backup object id (n bytes) as the editor's backup does */
|
||||
static int bk_read(uint32_t id, uint8_t *img, uint32_t n)
|
||||
{
|
||||
uint8_t a[16];
|
||||
uint32_t off, i;
|
||||
ed(ED_BK_LIST, a, 0);
|
||||
for (off = 0; off < n; off += 256) {
|
||||
uint32_t c = n - off > 256 ? 256 : n - off, k, w, m;
|
||||
m = 0; a[m++] = (uint8_t)id; for (i = 0; i < 5; i++) a[m++] = (off >> (7 * i)) & 127u; a[m++] = c & 127u; a[m++] = (uint8_t)(c >> 7);
|
||||
ed(ED_BK_GET, a, m);
|
||||
if (rx_n < 13 || rx_last[6]) return 1;
|
||||
for (k = 14, w = 0; w < c && k < rx_n - 1; ) {
|
||||
uint32_t mm = rx_last[k++], j;
|
||||
for (j = 0; j < 7 && w < c && k < rx_n - 1; j++) img[off + w++] = (uint8_t)(rx_last[k++] | ((mm >> j) & 1u) << 7);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int bk_write(uint32_t id, const uint8_t *img, uint32_t n)
|
||||
{
|
||||
uint8_t a[700];
|
||||
uint32_t off, i, m, crc = st_crc32(img, n);
|
||||
m = 0; a[m++] = 0; a[m++] = (uint8_t)id; for (i = 0; i < 5; i++) a[m++] = (n >> (7 * i)) & 127u; for (i = 0; i < 5; i++) a[m++] = (crc >> (7 * i)) & 127u;
|
||||
ed(ED_BK_PUT, a, m);
|
||||
for (off = 0; off < n; off += 256) {
|
||||
uint32_t c = n - off > 256 ? 256 : n - off;
|
||||
m = 0; a[m++] = 1; a[m++] = (uint8_t)id; for (i = 0; i < 5; i++) a[m++] = (off >> (7 * i)) & 127u;
|
||||
m += pack7(a + m, img + off, c);
|
||||
ed(ED_BK_PUT, a, m);
|
||||
}
|
||||
a[0] = 2; a[1] = (uint8_t)id; ed(ED_BK_PUT, a, 2);
|
||||
return rx_n > 7 ? rx_last[7] : 99;
|
||||
}
|
||||
static int bk_listed(uint32_t id) /* the length BK_LIST gives object id, -1: not listed */
|
||||
{
|
||||
uint8_t a[2];
|
||||
uint32_t pos, i, len;
|
||||
ed(ED_BK_LIST, a, 0);
|
||||
for (pos = 7; pos + 11 <= rx_n; pos += 11)
|
||||
if (rx_last[pos] == id) {
|
||||
for (len = 0, i = 0; i < 5; i++) len |= (uint32_t)rx_last[pos + 1 + i] << (7 * i);
|
||||
return (int)len;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
static int repro_up_backup(void)
|
||||
{
|
||||
static uint8_t img[4][4096];
|
||||
static const uint8_t OBJ[4] = {6, 7, 12, 13}; /* (12, 13: the presets' side records and tails, once fixed) */
|
||||
int len[4];
|
||||
uint8_t a[16];
|
||||
static const uint8_t ID[3] = {P_SPREAD, P_MSRATE, P_VINT};
|
||||
int16_t want[3];
|
||||
uint32_t i, o;
|
||||
int bad = 0, rc;
|
||||
for (i = 0; i < 3; i++) { /* the sound: these three away from their defaults */
|
||||
const param_desc_t *d = &TP[ID[i]];
|
||||
want[i] = (int16_t)(d->def == d->max ? d->min : d->max);
|
||||
a[0] = 0; a[1] = ID[i]; v14(a + 2, want[i]); ed(ED_SET, a, 4);
|
||||
}
|
||||
a[0] = 0; memcpy(a + 1, "KEEP ME", 8); ed(ED_UP_STORE, a, 9); /* -> user preset 1 */
|
||||
printf("UP_STORE rc %u\n", rx_n > 6 ? rx_last[6] : 99u);
|
||||
for (o = 0; o < 4; o++) { /* the editor's backup: every user preset object LIST gives */
|
||||
len[o] = bk_listed(OBJ[o]);
|
||||
if (len[o] > 0 && bk_read(OBJ[o], img[o], (uint32_t)len[o])) { printf("BK_GET %u failed\n", OBJ[o]); return 1; }
|
||||
printf("backup: object %u, %d bytes\n", OBJ[o], len[o]);
|
||||
}
|
||||
for (i = 0; i < 3; i++) { a[0] = 0; a[1] = ID[i]; v14(a + 2, TP[ID[i]].def); ed(ED_SET, a, 4); }
|
||||
a[0] = 0; memcpy(a + 1, "OTHER", 6); ed(ED_UP_STORE, a, 7); /* another sound into slot 1 meanwhile */
|
||||
for (o = 0; o < 4; o++) /* the restore, in the editor's order (BK.RESTORE) */
|
||||
if (len[o] >= 0) {
|
||||
rc = bk_write(OBJ[o], img[o], (uint32_t)len[o]);
|
||||
printf("restore of object %u: rc %d\n", OBJ[o], rc);
|
||||
}
|
||||
a[0] = 0; ed(ED_UP_LOAD, a, 1);
|
||||
for (i = 0; i < 3; i++) {
|
||||
printf("%-6s stored %d, after the backup's restore %d (%s)\n", TP[ID[i]].label, want[i], trk[0].p[ID[i]], up_rec(0)->name);
|
||||
bad |= trk[0].p[ID[i]] != want[i];
|
||||
}
|
||||
up_boot(); /* the next power-on: the banks, their side records, tails from flash */
|
||||
a[0] = 0; ed(ED_UP_LOAD, a, 1);
|
||||
for (i = 0; i < 3; i++) {
|
||||
printf("%-6s after a power-on %d\n", TP[ID[i]].label, trk[0].p[ID[i]]);
|
||||
bad |= trk[0].p[ID[i]] != want[i];
|
||||
}
|
||||
return bad;
|
||||
}
|
||||
|
||||
/* ---- 3: Clipper 1.0's values with steps on track 3 (an old SLOOP project loaded): a save, its load from RAM and from
|
||||
* flash, a power cycle, the autosave and its resume, the editor's backup and restore must all give them back, and track
|
||||
* 3's own nudges must stay its own (SLOOP plays them) */
|
||||
static const uint8_t X10_ID[4] = {P_SPREAD, P_MAC3, P_E2LOOP, P_M7AMT};
|
||||
static int16_t x10_want[4];
|
||||
static void x10_set(int want) /* the four values and the delay MODE: wanted, or the defaults */
|
||||
{
|
||||
uint8_t a[8];
|
||||
uint32_t i;
|
||||
for (i = 0; i < 4; i++) { a[0] = 0; a[1] = X10_ID[i]; v14(a + 2, want ? x10_want[i] : TP[X10_ID[i]].def); ed(ED_SET, a, 4); }
|
||||
a[0] = 1; a[1] = G_DMODE; v14(a + 2, want ? GP[G_DMODE].max : GP[G_DMODE].def); ed(ED_SET, a, 4);
|
||||
}
|
||||
static int x10_check(const char *when)
|
||||
{
|
||||
uint32_t i;
|
||||
int bad = 0;
|
||||
printf("%-34s", when);
|
||||
for (i = 0; i < 4; i++) {
|
||||
printf(" %s %d/%d", TP[X10_ID[i]].label, trk[0].p[X10_ID[i]], x10_want[i]);
|
||||
bad |= trk[0].p[X10_ID[i]] != x10_want[i];
|
||||
}
|
||||
printf(" MODE %d/%d, track 3: step %u nudge %d", song.g[G_DMODE], GP[G_DMODE].max, trk[2].step[1].n, trk[2].micro[1]);
|
||||
bad |= song.g[G_DMODE] != GP[G_DMODE].max || trk[2].step[1].n != 1u || trk[2].micro[1] != -7;
|
||||
printf(" %s\n", bad ? "LOST" : "ok");
|
||||
return bad;
|
||||
}
|
||||
static void proj_op_on(uint32_t op, uint32_t slot) /* ED_PROJECT op, then the audio a moment (its transport_req done) */
|
||||
{
|
||||
uint8_t a[2];
|
||||
a[0] = (uint8_t)op; a[1] = (uint8_t)slot; ed(ED_PROJECT, a, 2);
|
||||
audio_blocks(8);
|
||||
}
|
||||
static void proj_op(uint32_t op) { proj_op_on(op, 0); } /* .. on A */
|
||||
static void power_cycle(void) /* a cold start: RAM's projects gone, the boot as main.c runs it */
|
||||
{
|
||||
uint32_t i;
|
||||
memset(proj_slot, 0, sizeof proj_slot);
|
||||
#ifdef PROJ_X10_MAGIC
|
||||
memset(proj_x10s, 0, sizeof proj_x10s); /* (.pool: zeroed at boot) */
|
||||
#endif
|
||||
for (i = 0; i < NTRK; i++) { /* the sounds as before the autosave resumes */
|
||||
uint32_t k;
|
||||
for (k = P_SPREAD; k < P_E0; k++) trk[i].p[k] = TP[k].def;
|
||||
memset(trk[i].step, 0, sizeof trk[i].step);
|
||||
memset(trk[i].micro, 0, sizeof trk[i].micro);
|
||||
}
|
||||
song.g[G_DMODE] = GP[G_DMODE].def;
|
||||
persist_boot();
|
||||
audio_blocks(8);
|
||||
}
|
||||
static int repro_x10(void)
|
||||
{
|
||||
static uint8_t img[6][4096];
|
||||
static const uint8_t OBJ[6] = {2, 3, 4, 5, 0, 14}; /* (the editor's restore order; 14 once fixed) */
|
||||
int len[6], bad = 0;
|
||||
uint8_t a[16];
|
||||
uint32_t i;
|
||||
a[0] = 2; a[1] = 1; a[2] = 1; a[3] = 60; a[4] = a[5] = a[6] = 0; a[7] = ST_NOTE; a[8] = 0; a[9] = 100;
|
||||
ed(ED_TRACK_STEP, a, 10); /* track 3, step 2: a note (as an old SLOOP project has them) */
|
||||
a[0] = 2; a[1] = 1; a[2] = 64 - 7; ed(ED_MICRO_SET, a, 3); /* .. nudged early */
|
||||
for (i = 0; i < 4; i++) {
|
||||
const param_desc_t *d = &TP[X10_ID[i]];
|
||||
x10_want[i] = (int16_t)(d->def == d->max ? d->min : d->max);
|
||||
}
|
||||
x10_set(1);
|
||||
proj_op(1); /* save into A */
|
||||
x10_set(0);
|
||||
proj_op(0); /* load A (from RAM) */
|
||||
bad |= x10_check("section A saved, loaded");
|
||||
x10_set(0);
|
||||
proj_slot[0].magic ^= 1u; /* (RAM's copy gone: from flash) */
|
||||
proj_op(0);
|
||||
bad |= x10_check("loaded from flash");
|
||||
power_cycle();
|
||||
proj_op(0);
|
||||
bad |= x10_check("after a power cycle, loaded");
|
||||
x10_set(0); /* live section B (SAVE + B), written when quiet */
|
||||
section_store(1);
|
||||
sections_write();
|
||||
x10_set(1); /* stored again with the values (the project's bytes the */
|
||||
section_store(1); /* same: they are only beside it), written when quiet */
|
||||
sections_write();
|
||||
#ifdef PROJ_X10_MAGIC
|
||||
memset(proj_x10s, 0, sizeof proj_x10s); /* a warm reset: the sections kept in RAM (.noinit), the */
|
||||
#endif /* blocks not (.pool) */
|
||||
sec_dirty = 0;
|
||||
persist_boot();
|
||||
audio_blocks(8);
|
||||
x10_set(0);
|
||||
proj_op_on(0, 1);
|
||||
bad |= x10_check("live section B, warm reset, B");
|
||||
power_cycle();
|
||||
x10_set(0);
|
||||
proj_op_on(0, 1);
|
||||
bad |= x10_check("live section B, power cycle, B");
|
||||
proj_op(0);
|
||||
fm1_ms += 60000u; /* idle long enough: the autosave */
|
||||
ui_input_ms = fm1_ms - 10000u;
|
||||
autosave_tick();
|
||||
power_cycle();
|
||||
autosave_resume();
|
||||
audio_blocks(8);
|
||||
bad |= x10_check("after a power cycle, autosave resumed");
|
||||
for (i = 0; i < 6; i++) { /* the editor's backup: every listed project object (and 14) */
|
||||
len[i] = bk_listed(OBJ[i]);
|
||||
if (len[i] > 0 && bk_read(OBJ[i], img[i], (uint32_t)len[i])) { printf("BK_GET %u failed\n", OBJ[i]); return 1; }
|
||||
}
|
||||
for (i = 0; i < 5; i++) { /* restored into another unit: no section, no autosave in it */
|
||||
uint32_t c, obj = i < 4 ? OBJ_PROJECT0 + i : OBJ_AUTOSAVE;
|
||||
for (c = 0; c < 2; c++) st_erase(st_sector(obj, c));
|
||||
}
|
||||
power_cycle();
|
||||
x10_set(0);
|
||||
for (i = 0; i < 6; i++)
|
||||
if (len[i] >= 0)
|
||||
{
|
||||
printf("restore of object %u (%d bytes): rc %d\n", OBJ[i], len[i], bk_write(OBJ[i], img[i], (uint32_t)len[i]));
|
||||
audio_blocks(8);
|
||||
}
|
||||
bad |= x10_check("backup restored: the working sound");
|
||||
x10_set(0);
|
||||
proj_op(0);
|
||||
bad |= x10_check("backup restored: A loaded");
|
||||
power_cycle();
|
||||
proj_op(0);
|
||||
bad |= x10_check("backup restored, power cycle, A");
|
||||
return bad;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int which = argc > 1 ? atoi(argv[1]) : 1, r;
|
||||
harness_init();
|
||||
r = which == 1 ? repro_wt_backup() : which == 2 ? repro_eq_low() : which == 3 ? repro_x10() : repro_up_backup();
|
||||
printf("editor_repro %d: %s\n", which, r ? "FAIL (the bug is there)" : "ok");
|
||||
return r;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* SLOOP Pro #4: "3.5mm & USB audio output has distorted noise while notes fading out". The mix floored each part to
|
||||
* 16 LSB of the output (fx.c mix_part_run: x >> 4 at the mute / duck gain, always applied at rest since
|
||||
* mulq15(32767, 32767) is 32766, and again at the PAN gain; b >> 2 at LEVEL), the MASTER to 4 LSB (mix >> 2), USB AUDIO =
|
||||
* FULL to 4 LSB, DIST's drive to 4 x its gain: an error of ~5.5 LSB rms whatever the level, all of it on the note's
|
||||
* harmonics (distortion, not hiss), so a note fading out turned into a buzz (THD+N -8 dB at -60 dBFS). Now rounded
|
||||
* (dsp.c MULQ12R): the error is the 16-bit output's own rounding.
|
||||
* Each case holds a note that decays slowly (SUS 0), renders the output as the codec (and USB) gets it and, over
|
||||
* windows of 8192 samples, fits the note (its harmonics, amplitudes moving as a quadratic) by least squares: what is
|
||||
* left is the error. Checked between -70 and -30 dBFS (808 SLIDE: -40): its rms under 1 LSB (an ideal 16-bit rounding:
|
||||
* 0.29; it was 5 to 6.5), and the THD+N of the window nearest -60 dBFS under -28 dB (it was -12 to -19). Cases: a
|
||||
* clean sine (no drive, no FX) at MASTER 4096 and at 2048 (the power-on level), the same through USB AUDIO = FULL
|
||||
* (MASTER ignored), and 808 SLIDE (sine, DRV, DIST 30) at 4096.
|
||||
* Exit status: the number of failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
|
||||
#define NBLK 13000u /* ~9.4 s: the sine from -6 to below -80 dBFS */
|
||||
#define WIN 8192
|
||||
static int32_t cap[NBLK * CTL];
|
||||
static double incq[NBLK]; /* the note's phase step a block (2^32 a turn) */
|
||||
static int fails;
|
||||
static void check(int ok, const char *what) { printf("fade: %-96s %s\n", what, ok ? "ok" : "FAIL"); fails += !ok; }
|
||||
|
||||
/* least squares fit of H harmonics of w (each with a constant, linear and quadratic amplitude) and a line; returns the
|
||||
* rms of what is left, *sig the fit's rms */
|
||||
static double fit_left(const double *y, double w, int H, double *sig)
|
||||
{
|
||||
enum { KMAX = 6 * 16 + 2 };
|
||||
static double A[KMAX][KMAX], bv[KMAX], phi[KMAX], c[KMAX];
|
||||
int K = 6 * H + 2, i, j, k, n;
|
||||
double e2 = 0, s2 = 0;
|
||||
memset(A, 0, sizeof A), memset(bv, 0, sizeof bv);
|
||||
for (n = 0; n < WIN; n++) {
|
||||
double t = (n - WIN / 2.0) / WIN;
|
||||
for (i = 1, k = 0; i <= H; i++) {
|
||||
double s = sin(i * w * n), cs = cos(i * w * n);
|
||||
phi[k++] = s, phi[k++] = cs, phi[k++] = s * t, phi[k++] = cs * t, phi[k++] = s * t * t, phi[k++] = cs * t * t;
|
||||
}
|
||||
phi[k++] = 1, phi[k++] = t;
|
||||
for (i = 0; i < K; i++) {
|
||||
bv[i] += phi[i] * y[n];
|
||||
for (j = 0; j <= i; j++)
|
||||
A[i][j] += phi[i] * phi[j];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < K; i++) /* Cholesky, then the two triangular solves */
|
||||
for (j = 0; j <= i; j++) {
|
||||
double s = A[i][j];
|
||||
for (k = 0; k < j; k++)
|
||||
s -= A[i][k] * A[j][k];
|
||||
A[i][j] = i == j ? sqrt(s > 1e-30 ? s : 1e-30) : s / A[j][j];
|
||||
}
|
||||
for (i = 0; i < K; i++) {
|
||||
double s = bv[i];
|
||||
for (k = 0; k < i; k++)
|
||||
s -= A[i][k] * c[k];
|
||||
c[i] = s / A[i][i];
|
||||
}
|
||||
for (i = K - 1; i >= 0; i--) {
|
||||
double s = c[i];
|
||||
for (k = i + 1; k < K; k++)
|
||||
s -= A[k][i] * c[k];
|
||||
c[i] = s / A[i][i];
|
||||
}
|
||||
for (n = 0; n < WIN; n++) {
|
||||
double t = (n - WIN / 2.0) / WIN, f = 0;
|
||||
for (i = 1, k = 0; i <= H; i++, k += 6) {
|
||||
double s = sin(i * w * n), cs = cos(i * w * n);
|
||||
f += (c[k] + c[k + 2] * t + c[k + 4] * t * t) * s + (c[k + 1] + c[k + 3] * t + c[k + 5] * t * t) * cs;
|
||||
}
|
||||
e2 += (y[n] - f - c[K - 2] - c[K - 1] * t) * (y[n] - f - c[K - 2] - c[K - 1] * t);
|
||||
s2 += f * f;
|
||||
}
|
||||
*sig = sqrt(s2 / WIN);
|
||||
return sqrt(e2 / WIN);
|
||||
}
|
||||
|
||||
/* sine: the analog engine's SIN, no drive, no FX; else 808 SLIDE as it comes (its DIST), dry (no sends). usb: capture
|
||||
* USB AUDIO = FULL's stream instead of the codec's */
|
||||
static void run(const char *name, int sine, int32_t master, int usb, int H, int top)
|
||||
{
|
||||
static int32_t o[2 * CTL];
|
||||
static double y[WIN];
|
||||
track_t *t = &trk[0];
|
||||
uint32_t b, i, n;
|
||||
double worst = 0, wlev = 0, at60 = 1e9, thdn60 = 0, d60 = 1e9;
|
||||
char s[240];
|
||||
host_tracks_init();
|
||||
for (i = 0; i < NVOICE; i++) /* (the case before: its note, held, gone) */
|
||||
memset(&t->v[i], 0, sizeof t->v[i]);
|
||||
t->nmono = 0, t->mono_note = 0;
|
||||
song.master_q12 = (uint32_t)master;
|
||||
host_preset(t, 0, 3); /* ANALOG 808 SLIDE */
|
||||
if (sine) {
|
||||
t->p[P_E0] = 3, t->p[P_E1] = 0, t->p[P_E2] = 0, t->p[P_E3] = 0, t->p[P_E4] = 127, t->p[P_E5] = 0;
|
||||
t->p[P_E6] = 0, t->p[P_DIST] = 0, t->p[P_ED_PIT] = 0;
|
||||
t->p[P_ATK] = 0, t->p[P_DEC] = 118, t->p[P_SUS] = 0, t->p[P_REL] = 60;
|
||||
}
|
||||
t->p[P_CHOR] = t->p[P_DLY] = t->p[P_REV] = 0;
|
||||
usb_full_now = (uint8_t)usb;
|
||||
for (b = 0; b < 4; b++)
|
||||
mix_block(o, CTL);
|
||||
trk_note_on(t, 60, 100);
|
||||
for (b = 0; b < NBLK; b++) {
|
||||
uint32_t ph = t->v[0].ph[0];
|
||||
mix_block(o, CTL);
|
||||
incq[b] = (double)(uint32_t)(t->v[0].ph[0] - ph) / CTL;
|
||||
for (i = 0; i < CTL; i++)
|
||||
cap[b * CTL + i] = usb ? usb_out[2 * i] : o[2 * i];
|
||||
}
|
||||
usb_full_now = 0;
|
||||
for (n = 0; n + WIN <= NBLK * CTL; n += WIN) {
|
||||
double rms = 0, lev, left, sig;
|
||||
for (i = 0; i < WIN; i++)
|
||||
rms += (double)cap[n + i] * cap[n + i];
|
||||
lev = 20 * log10(sqrt(rms / WIN) * sqrt(2.0) / 32767 + 1e-12); /* dBFS of a sine as loud */
|
||||
if (lev > top || lev < -70)
|
||||
continue;
|
||||
for (i = 0; i < WIN; i++)
|
||||
y[i] = cap[n + i];
|
||||
left = fit_left(y, 2 * M_PI * incq[(n + WIN / 2) / CTL] / 4294967296.0, H, &sig);
|
||||
if (left > worst)
|
||||
worst = left, wlev = lev;
|
||||
if (fabs(lev + 60) < d60)
|
||||
d60 = fabs(lev + 60), at60 = lev, thdn60 = 20 * log10(left / sig);
|
||||
}
|
||||
snprintf(s, sizeof s, "%s: error while it fades (-70..%d dBFS) at most %.2f LSB rms (at %.0f dBFS), bound 1",
|
||||
name, top, worst, wlev);
|
||||
check(worst > 0 && worst < 1.0, s);
|
||||
snprintf(s, sizeof s, "%s: THD+N at %.0f dBFS %.1f dB, bound -28", name, at60, thdn60);
|
||||
check(d60 < 5 && thdn60 < -28, s);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
run("sine, MASTER 4096", 1, 4096, 0, 1, -30);
|
||||
run("sine, MASTER 2048 (power-on)", 1, 2048, 0, 1, -30);
|
||||
run("sine, USB AUDIO = FULL", 1, 2048, 1, 1, -30);
|
||||
run("808 SLIDE (DRV, DIST 30), MASTER 4096", 0, 4096, 0, 15, -40); /* (from -40: its drive's own grit, -58 dB under
|
||||
* the note, follows the note: eng_analog.c, not the fade) */
|
||||
printf("fade: %d failed\n", fails);
|
||||
return fails;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* FMX: a voice given up (voice.c voice_kill: another part needed it, or the overload shed it) ends at the end of its
|
||||
* fade without fmx_done, so its fmx_voice_t stayed "live": the next note on it was taken for a retrigger and kept
|
||||
* the old note's operator phases, envelopes and feedback samples. The operators' relative phases then differ from
|
||||
* note to note: FMX BRASS's carrier took a DC offset of up to half its level (+-7000 on an rms of 13000) and its
|
||||
* timbre changed with every such note. FM6 starts such a voice from rest (its note_on: !v->env && !v->env_out).
|
||||
* The check: a note on each voice given up sounds as the same note on a fresh voice (their difference under -12 dB), and its DC
|
||||
* stays as small. Exit status: failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#define NS 8192u
|
||||
static int fails;
|
||||
static void ok(int c, const char *what)
|
||||
{
|
||||
printf("fmx_kill: %-90s %s\n", what, c ? "ok" : "FAIL");
|
||||
fails += !c;
|
||||
}
|
||||
static void load(uint32_t e, uint32_t pi)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < P_E0; i++) /* as ui.c apply_preset_to */
|
||||
trk[0].p[i] = TP[i].def;
|
||||
host_preset(&trk[0], e, pi);
|
||||
trk[0].p[P_DLY] = trk[0].p[P_REV] = 0;
|
||||
trk[0].p[P_SPREAD] = 0; /* (each voice the same: in the middle, no VINTAGE) */
|
||||
trk[0].p[P_VINT] = 0;
|
||||
}
|
||||
/* note 60 for 46 ms + NS samples: the samples after the first 46 ms into x, returns the DC */
|
||||
static double play(int32_t *x)
|
||||
{
|
||||
static int32_t o[CTL * 2];
|
||||
uint32_t b, i;
|
||||
double s = 0;
|
||||
trk_note_on(&trk[0], 60, 100);
|
||||
for (b = 0; b < 64; b++)
|
||||
mix_block(o, CTL);
|
||||
for (b = 0; b < NS / CTL; b++) {
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < CTL; i++)
|
||||
s += x[b * CTL + i] = mix_l[i] + mix_r[i];
|
||||
}
|
||||
trk_note_off(&trk[0], 60);
|
||||
for (b = 0; b < 3000; b++) /* (released, rung out: fmx_done ends the voice) */
|
||||
mix_block(o, CTL);
|
||||
return s / NS / 2;
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
static int32_t o[CTL * 2], ref[NS], x[NS];
|
||||
uint32_t pi = 0, k, b, same = 0, dcok = 0;
|
||||
double dc0, dc, worst = 0;
|
||||
char msg[128];
|
||||
const engine_t *en = ENGINES[ENGI_FMX];
|
||||
host_tracks_init();
|
||||
for (k = 0; k < en->npresets; k++)
|
||||
if (!strcmp(en->presets[k].name, "FMX BRASS"))
|
||||
pi = k;
|
||||
ok(!strcmp(en->presets[pi].name, "FMX BRASS"), "FMX BRASS found");
|
||||
load(ENGI_FMX, pi);
|
||||
for (b = 0; b < 32; b++)
|
||||
mix_block(o, CTL);
|
||||
dc0 = play(ref);
|
||||
load(ENGI_FMX, 0); /* FMX EP: eight notes, every voice given up while it sounds */
|
||||
for (k = 0; k < NVOICE; k++)
|
||||
trk_note_on(&trk[0], 48 + k * 3, 100);
|
||||
for (b = 0; b < 200; b++)
|
||||
mix_block(o, CTL);
|
||||
for (k = 0; k < NVOICE; k++)
|
||||
if (trk[0].v[k].active)
|
||||
voice_kill(&trk[0].v[k]);
|
||||
for (b = 0; b < 16; b++)
|
||||
mix_block(o, CTL);
|
||||
trk_all_off(&trk[0]);
|
||||
load(ENGI_FMX, pi);
|
||||
for (b = 0; b < 32; b++)
|
||||
mix_block(o, CTL);
|
||||
for (k = 0; k < NVOICE; k++) { /* (ROTATE: each note on the next voice) */
|
||||
dc = play(x);
|
||||
{
|
||||
uint32_t i;
|
||||
double d = 0, r = 0;
|
||||
for (i = 0; i < NS; i++)
|
||||
d += (double)(x[i] - ref[i]) * (x[i] - ref[i]), r += (double)ref[i] * ref[i];
|
||||
same += d < r * 0.063; /* (under -12 dB: the same sound; fresh notes on other voices differ by
|
||||
* -16 .. -36 dB, the old retriggered ones by -1.4 .. +6 dB) */
|
||||
if (getenv("V")) printf("voice %u: difference %.1f dB, dc %.0f\n", k, 10 * log10(d / r + 1e-12), dc);
|
||||
}
|
||||
dcok += fabs(dc) < fabs(dc0) + 500;
|
||||
if (fabs(dc) > worst)
|
||||
worst = fabs(dc);
|
||||
}
|
||||
snprintf(msg, sizeof msg, "FMX BRASS C4 on a voice given up = on a fresh voice, within -12 dB (%u of %u)", same, NVOICE);
|
||||
ok(same == NVOICE, msg);
|
||||
snprintf(msg, sizeof msg, " .. its DC as a fresh note's (%.0f; worst %.0f, of %u voices %u)", dc0, worst, NVOICE, dcok);
|
||||
ok(dcok == NVOICE, msg);
|
||||
printf("fmx_kill: %d failed\n", fails);
|
||||
return fails;
|
||||
}
|
||||
+211
-211
@@ -1,213 +1,213 @@
|
||||
# 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 69d0901c64773d4c
|
||||
preset/ANALOG/01_808_DIRTY 13baa79fb0755730
|
||||
preset/ANALOG/02_SUB_BASS abdebef79fb80860
|
||||
preset/ANALOG/03_808_SLIDE 4ffca0e08379ba48
|
||||
preset/ANALOG/04_ACID_303 2ac9f8b41e0666dd
|
||||
preset/ANALOG/05_PLUGG_BASS 38ae9e1d79a8630c
|
||||
preset/ANALOG/06_REESE 5cfd48a652276095
|
||||
preset/ANALOG/07_WOBBLE 6bf621c9829a9ea2
|
||||
preset/ANALOG/08_FUNK_BASS b3ede207b908d705
|
||||
preset/ANALOG/09_G-FUNK_LD ed970730e5e7c14f
|
||||
preset/ANALOG/10_TRAP_PLUCK 0373876d84f74bc7
|
||||
preset/ANALOG/11_SYN_BRASS dbc08613c198e607
|
||||
preset/ANALOG/12_SUPERSAW 7b011debfd85e923
|
||||
preset/ANALOG/13_WARM_PAD b534a0816bca3880
|
||||
preset/ANALOG/14_DARK_STR 8adcecd67c4258c3
|
||||
preset/ANALOG/15_ATMOS_PAD 57563c8864e7e358
|
||||
preset/ANALOG/16_PAN_FLUTE 25de841ba44cb5de
|
||||
preset/ANALOG/17_FAT_LEAD 6e9a1cf730c5ea0d
|
||||
preset/ANALOG/18_MONO_BASS b12ab80892b98cfa
|
||||
preset/ANALOG/19_PWM_LEAD 52b45468d9501a18
|
||||
preset/ANALOG/20_SAW_BASS 647eb690094b0b06
|
||||
preset/ANALOG/21_SINE_PAD 225be334e8cf72a7
|
||||
preset/ANALOG/22_MINI_BASS cb40c9b848c2d80b
|
||||
preset/ANALOG/23_MINI_LEAD 3f6c3247b4e038f1
|
||||
preset/DIGITAL/00_RHODES f7254fef6dbfe89e
|
||||
preset/DIGITAL/01_DX_RHODES b3e11ac32c635a74
|
||||
preset/DIGITAL/02_WURLI 9394537d7f061bb1
|
||||
preset/DIGITAL/03_CLAV dcea84e34c6a7f80
|
||||
preset/DIGITAL/04_M1_PIANO a8dd45927ce42a74
|
||||
preset/DIGITAL/05_AFRO_KEYS 01f1715ad85b2efa
|
||||
preset/DIGITAL/06_TRAP_BELL 4dee306a492459dd
|
||||
preset/DIGITAL/07_MUSIC_BOX 3d8ec11511247465
|
||||
preset/DIGITAL/08_MARIMBA 7529b44f60f28622
|
||||
preset/DIGITAL/09_KALIMBA cb8e5deeb0d07631
|
||||
preset/DIGITAL/10_PLUGG_BELL d5b4291ac17ac596
|
||||
preset/DIGITAL/11_GLASS_PAD a4daa58074964bf9
|
||||
preset/DIGITAL/12_FM_BASS 25c7bb8546717bc7
|
||||
preset/DIGITAL/13_STEEL_DRUM b56752a03118f544
|
||||
preset/DIGITAL/14_GLOCKEN 7f7fbf491a3a4c97
|
||||
preset/DIGITAL/15_CELESTA 9f128432693e9bc4
|
||||
preset/DIGITAL/16_XYLOPHONE 55e9b99c4faca223
|
||||
preset/DIGITAL/17_HARP 3b1739b1ca299551
|
||||
preset/DIGITAL/18_BASS_GTR d10a78e5027f1830
|
||||
preset/DIGITAL/19_TUBE_BELL 9f13b4a739281c77
|
||||
preset/DIGITAL/20_FM_PLUCK e43dcb4120bd6e50
|
||||
preset/DIGITAL/21_FM_GRAND 3aabba535f98be01
|
||||
preset/PHASE/00_CZ_BASS e96706957d91ecae
|
||||
preset/PHASE/01_SOFT_KEYS 5f0e4fe55c4ce76a
|
||||
preset/PHASE/02_CZ_STRING 7db0fca714217b45
|
||||
preset/PHASE/03_RESO_PLUCK 5edc4850b8ef18f9
|
||||
preset/PHASE/04_CZ_BRASS 3b1b3a35657223f3
|
||||
preset/PHASE/05_CZ_LEAD 62abe54518ba2c60
|
||||
preset/PHASE/06_CZ_PAD 72c55108745a95b7
|
||||
preset/PHASE/07_CZ_RESO a8f173ac48ac2fa3
|
||||
preset/LOFI/00_GAME_LEAD 2b0101cbd336635d
|
||||
preset/LOFI/01_GB_BASS 2b2caf1131d2d8e4
|
||||
preset/LOFI/02_8BIT_ARP 806922784ebe92fd
|
||||
preset/LOFI/03_NES_BASS 01a313ed161d6fe0
|
||||
preset/LOFI/04_CHIP_CHORD 4e6ab9a7c33dba09
|
||||
preset/LOFI/05_1BIT_BEEP f3a51c96983395f1
|
||||
preset/LOFI/06_WAVE_LEAD 23a2f1e11d67dfad
|
||||
preset/LOFI/07_CHIP_NOISE 5ea9e47a5dcf7009
|
||||
preset/SAMPLE/00_GRAND_PNO 13a80ba7c68f1469
|
||||
preset/SAMPLE/01_UP_BASS 275f44a5ceb4bae5
|
||||
preset/SAMPLE/02_VIBES 0da1e602b0cda64c
|
||||
preset/SAMPLE/03_HORN_STAB f2b3917cde0d0110
|
||||
preset/SAMPLE/04_STRING_STB 4eb6f02ad09952c4
|
||||
preset/SAMPLE/05_LOFI_FLUTE 6243cfad777ae0a4
|
||||
preset/SAMPLE/06_SCRATCH 35a7220a647b2484
|
||||
preset/SAMPLE/07_GM_KIT a5f9d22f362a8e8f
|
||||
preset/SAMPLE/08_DUSTY_PNO 5aa693c7bc54b9bb
|
||||
preset/SAMPLE/09_LOFI_KEYS c7490ed11639db24
|
||||
preset/SAMPLE/10_DEEP_BASS 525d8bf07ed99c20
|
||||
preset/VOICE/00_CHOIR_AAH 9d631818998e4fcf
|
||||
preset/VOICE/01_SOUL_OOH 1cfb47ddc13d0b75
|
||||
preset/VOICE/02_TALKBOX 21c8a39e3ffaed5a
|
||||
preset/VOICE/03_WOW_BASS a750d27f4575a85c
|
||||
preset/VOICE/04_HARMONICA 2b0c12b4331d68c6
|
||||
preset/VOICE/05_ROBOT 25af475d3031ab3d
|
||||
preset/VOICE/06_VOX_PAD 23f7da887166dd0c
|
||||
preset/TRIO/00_FAT_BASS 6c4ca500c885adaf
|
||||
preset/TRIO/01_MIN_STAB 7c609fa0356ab9fa
|
||||
preset/TRIO/02_MIN7_STAB 9083129c0afc94fe
|
||||
preset/TRIO/03_RAVE_STAB ec9b260d62db03e0
|
||||
preset/TRIO/04_DUB_CHORD db50e8240f26fcce
|
||||
preset/TRIO/05_SAW_PAD ae99310d2e14e892
|
||||
preset/TRIO/06_SYNC_LEAD 0999a6f155b975e9
|
||||
preset/TRIO/07_HOOVER 02ae0d2869d47945
|
||||
preset/TRIO/08_ACCORDION 0cb3b5f9d1c85908
|
||||
preset/TRIO/09_ENSEMBLE 1ba3d7ed3a974533
|
||||
preset/TRIO/10_80S_POLY f9420daaa779141d
|
||||
preset/TRIO/11_SQR_LEAD d98536f9d4590375
|
||||
preset/TRIO/12_POWER_STAB fc9419b8903c46fd
|
||||
preset/TRIO/13_PULSE_PAD 19adfe2b8444803a
|
||||
preset/WHEEL/00_SOUL_ORGAN a5caf2722c71adb1
|
||||
preset/WHEEL/01_GOSPEL d56aff974860dd4d
|
||||
preset/WHEEL/02_JAZZ_ORGAN 2b8aa903bb77bd7f
|
||||
preset/WHEEL/03_DIRTY_B3 02ffafecc2a084b7
|
||||
preset/WHEEL/04_HOUSE_ORGN 60f1ebb29ba38794
|
||||
preset/WHEEL/05_ROCK_ORGAN b1c318b9361b9cd5
|
||||
preset/WHEEL/06_CHAPEL 830bb9caf5d7c03a
|
||||
preset/WHEEL/07_REGGAE_ORG 209bb98ac036737e
|
||||
preset/GRAIN/00_LOFI_CLOUD 32c2a3affa0d2120
|
||||
preset/GRAIN/01_VIBE_HAZE 5f0a50654df5a4d7
|
||||
preset/GRAIN/02_FLUTE_DUST 6963d1906fc56e07
|
||||
preset/GRAIN/03_STR_CLOUD 1b78cfdccd6e19bd
|
||||
preset/GRAIN/04_SHIMMER 47aa5d4b0921110a
|
||||
preset/GRAIN/05_DRONE 41a57c92fdc81da3
|
||||
preset/GRAIN/06_PNO_FREEZE 3ef812ae36115efd
|
||||
preset/GRAIN/07_HORN_CLOUD ada77277790d8603
|
||||
preset/FM6/00_TINE_EP 830b6dcf069c0460
|
||||
preset/FM6/01_GLASS_BELL 2b2167d31b505d12
|
||||
preset/FM6/02_ROUND_BASS 65d55cb431504a25
|
||||
preset/FM6/03_BRASS_SECT 80fa6513518eb2bc
|
||||
preset/FM6/04_SOFT_PAD ddd4b535aa6a47fd
|
||||
preset/FM6/05_WOOD_BARS 65e7aadc87e84b54
|
||||
preset/FM6/06_DRAWBARS 3287628c0375f4e2
|
||||
preset/FM6/07_NYLON_PICK 5ad8bdcded17b15c
|
||||
preset/PHYS/00_BELL_TREE 5e3894c1adf715be
|
||||
preset/PHYS/01_MODAL_BAR cb34ccb73e216eb2
|
||||
preset/PHYS/02_STR_PLUCK bb6198b747b463df
|
||||
preset/PHYS/03_BOWED_MTL 21c9c360be27e476
|
||||
preset/PHYS/04_THUMB_PNO 6aacd82db2c43880
|
||||
preset/PHYS/05_HAND_DRUM 565818d14a566c4a
|
||||
preset/PHYS/06_MEMB_TOMS f77a44ba92e940a2
|
||||
preset/PHYS/07_SITAR 49d88197aa85c7c2
|
||||
preset/PHYS/08_PHYS_HARP 3e3cc4f7293aca9f
|
||||
preset/PHYS/09_NYLON_GTR 5c03f6ee765aabca
|
||||
preset/PHYS/10_STEEL_GTR 4b324bdaa17c5b1c
|
||||
preset/PHYS/11_MUTED_GTR 5a5fcc3778369b65
|
||||
preset/PHYS/12_PLUCK_BASS bca731c0f700e1b1
|
||||
preset/PHYS/13_KOTO 3d6077bc5afa22cb
|
||||
preset/PHYS/14_BANJO 15954160a1890df9
|
||||
preset/PHYS/15_CELLO_BOW 42550aeaf1f47bc8
|
||||
preset/PHYS/16_TANPURA a49c707d3b46177d
|
||||
preset/PHYS/17_CHIMES c53b78a4e11e55c9
|
||||
preset/PHYS/18_BIG_BELL 7858493e86c9c8ff
|
||||
preset/PHYS/19_VIBRA_BAR 15f7a6ee4a9649cf
|
||||
preset/PHYS/20_GLASS_BOWL c9cf505ecea3b8f5
|
||||
preset/PHYS/21_STEEL_PAN 20cc90225187294c
|
||||
preset/PHYS/22_WOOD_BLOCK 21cbac659a119354
|
||||
preset/PHYS/23_TABLA 23672362da5f6357
|
||||
preset/PHYS/24_CONGA 3917b67a7347a740
|
||||
preset/PHYS/25_TIMPANI 56cea6c5bb4f1a0e
|
||||
preset/NOISE/00_WIND cf9a262e84230d48
|
||||
preset/NOISE/01_RAIN 4673a1b05bb8b9eb
|
||||
preset/NOISE/02_NZ_ARCADE 05970d2a5744e9d4
|
||||
preset/NOISE/03_NZ_METAL 0cf292216c75a128
|
||||
preset/NOISE/04_OCEAN 7910fc9bb9cee400
|
||||
preset/NOISE/05_VINYL 307c6f895056eb78
|
||||
preset/NOISE/06_HISS 5d57fdb54063c64e
|
||||
preset/NOISE/07_RISER b8e0509b00f7ef07
|
||||
preset/NOISE/08_NZ_SNARE 536f9e93124264dc
|
||||
preset/NOISE/09_BITCRUSH 7e1be7ae2abcde73
|
||||
preset/NOISE/10_RADIO 9b013ea0fc8d5384
|
||||
preset/HYBRID/00_CLIPPER 741fb28d3267be9a
|
||||
preset/HYBRID/01_POLY_PAD 92555bf4c344c890
|
||||
preset/HYBRID/02_STRINGS 55d11dc70494e177
|
||||
preset/HYBRID/03_ACID e0d2d59df102db19
|
||||
preset/HYBRID/04_SYNC_LEAD bdef2b7a2aafe7b5
|
||||
preset/HYBRID/05_FM_BELL 80215624e8784222
|
||||
preset/HYBRID/06_FM_KEYS 3f7e7f2e84ed1ed0
|
||||
preset/HYBRID/07_WOBBLE 8556127b8695c3b0
|
||||
preset/HYBRID/08_REESE 09686c46edc86f92
|
||||
preset/HYBRID/09_HOOVER db86e3d54abc5047
|
||||
preset/HYBRID/10_BRASS 602c2fa72e9d7e9e
|
||||
preset/HYBRID/11_VOX a392a4e7e7aeef9f
|
||||
preset/HYBRID/12_PLUCK bfffc18fdcb2201d
|
||||
preset/HYBRID/13_RISER 5af006d19006c33b
|
||||
preset/HYBRID/14_METAL 68ba9e49fc480827
|
||||
preset/HYBRID/15_FOLD_BASS 72f3d64b523b998d
|
||||
preset/HYBRID/16_CHIP_LEAD d68a293ceff88da5
|
||||
preset/HYBRID/17_GLASS_PAD 04cc93cc4bdf2744
|
||||
preset/HYBRID/18_DRONE 7d1b01f4353798ae
|
||||
preset/HYBRID/19_808_SUB 00cd8308d878c854
|
||||
preset/HYBRID/20_TRANCE 03ee2c39bb0a7e51
|
||||
preset/HYBRID/21_SAW_PLUCK e3de9666dd9d2c70
|
||||
preset/HYBRID/22_SPACE_BEL e2cbfd8444c10df4
|
||||
preset/HYBRID/23_INIT 1da3dff6e6ccdd90
|
||||
preset/HYBRID/24_MOOG_BASS 9717bf9d01bea154
|
||||
preset/HYBRID/25_MOOG_LEAD b1fe3b045a96a455
|
||||
preset/HYBRID/26_LADDER_PAD d94b87816b9fbc4d
|
||||
drums/gm_kit 5c554c3b853cb633
|
||||
mode/ANALOG/POLY a7a9ef2a2e63290c
|
||||
mode/ANALOG/MONO 9583d8d67d814abc
|
||||
mode/ANALOG/LEGATO 688683752bbf85f8
|
||||
mode/ANALOG/UNISON 8bb858f31b261198
|
||||
mode/DIGITAL/POLY b3e11ac32c635a74
|
||||
mode/DIGITAL/MONO 259a9063e578f0f3
|
||||
mode/DIGITAL/LEGATO af2ac0d2e697b81e
|
||||
mode/DIGITAL/UNISON c623eda546eb4034
|
||||
mode/VOICE/POLY 9d631818998e4fcf
|
||||
mode/VOICE/MONO 9450adb85fb70d90
|
||||
mode/VOICE/LEGATO 1a04dbc937476869
|
||||
mode/VOICE/UNISON 1fbb5b94bb4ec6fc
|
||||
sends/ANALOG/dry deabf8b98f7ab640
|
||||
sends/ANALOG/chorus 121c8d78aaa247d6
|
||||
sends/ANALOG/delay afca9fa890650d3c
|
||||
sends/ANALOG/reverb 7a9ee7a261797e1e
|
||||
sends/ANALOG/all a392a524049f8e91
|
||||
sends/ANALOG/dist 917a9fdf6aa27763
|
||||
sends/DIGITAL/dry 25f613bc779a9c24
|
||||
sends/DIGITAL/chorus 52c8d28f04b3cc3a
|
||||
sends/DIGITAL/delay 820d0499a03b854c
|
||||
sends/DIGITAL/reverb 14246300e567c350
|
||||
sends/DIGITAL/all d45af383afcc168a
|
||||
sends/DIGITAL/dist 873e64bb5e5d9d2c
|
||||
song/4track_mix 7790b3cf8db30236
|
||||
slicer/gate/ANALOG_DARK_STR 23376a6defb8ab6f
|
||||
slicer/stut/DIGITAL_RHODES 8918a6dcb14114e9
|
||||
slicer/song_gate_stut ce6b4ce66d669330
|
||||
preset/ANALOG/00_808_BOOM 0b447c66765e1780
|
||||
preset/ANALOG/01_808_DIRTY 402ad42574c9a7ac
|
||||
preset/ANALOG/02_SUB_BASS e2923181844810dc
|
||||
preset/ANALOG/03_808_SLIDE 5dff1c7d531ee278
|
||||
preset/ANALOG/04_ACID_303 ff32fde3dae69b36
|
||||
preset/ANALOG/05_PLUGG_BASS cfca53f9b39e3e59
|
||||
preset/ANALOG/06_REESE c2b5036f6a6e3dd7
|
||||
preset/ANALOG/07_WOBBLE 8632c64a94ad50fe
|
||||
preset/ANALOG/08_FUNK_BASS db34a30e3253ae35
|
||||
preset/ANALOG/09_G-FUNK_LD a2b3884c5f290558
|
||||
preset/ANALOG/10_TRAP_PLUCK 460a6e1addb936ae
|
||||
preset/ANALOG/11_SYN_BRASS f72fe10148dbe30b
|
||||
preset/ANALOG/12_SUPERSAW 0cc1745ddf9a6816
|
||||
preset/ANALOG/13_WARM_PAD bc32310c30ad3e09
|
||||
preset/ANALOG/14_DARK_STR c2262d180f589ac1
|
||||
preset/ANALOG/15_ATMOS_PAD 33486ac8aa9e74e8
|
||||
preset/ANALOG/16_PAN_FLUTE c058d6e1833de80d
|
||||
preset/ANALOG/17_FAT_LEAD 8eead41edbcfdc61
|
||||
preset/ANALOG/18_MONO_BASS f1c602e82e3b08a9
|
||||
preset/ANALOG/19_PWM_LEAD 22e1b90b9afc14e6
|
||||
preset/ANALOG/20_SAW_BASS 98c3170010dccfcb
|
||||
preset/ANALOG/21_SINE_PAD 42b2cdef499c91d1
|
||||
preset/ANALOG/22_MINI_BASS 4b5fe3926ca3c5b4
|
||||
preset/ANALOG/23_MINI_LEAD d6a4dd71aa9c1fe1
|
||||
preset/DIGITAL/00_RHODES ad184ebe26aa945d
|
||||
preset/DIGITAL/01_DX_RHODES 11b6fb9e67ee1f3d
|
||||
preset/DIGITAL/02_WURLI fb7bb85dd8a36528
|
||||
preset/DIGITAL/03_CLAV 4e3b8c8bc43a2fd4
|
||||
preset/DIGITAL/04_M1_PIANO 83e8fc82edca8c54
|
||||
preset/DIGITAL/05_AFRO_KEYS 8269ad51d4510c2c
|
||||
preset/DIGITAL/06_TRAP_BELL c4661d69deb78bfc
|
||||
preset/DIGITAL/07_MUSIC_BOX d4eb5de122e1e65b
|
||||
preset/DIGITAL/08_MARIMBA 61789c92c0d0bc4d
|
||||
preset/DIGITAL/09_KALIMBA ef42cd69ad310543
|
||||
preset/DIGITAL/10_PLUGG_BELL 3c929e492160530c
|
||||
preset/DIGITAL/11_GLASS_PAD 2525d060d73787dd
|
||||
preset/DIGITAL/12_FM_BASS a4c4da8cdc8d26bf
|
||||
preset/DIGITAL/13_STEEL_DRUM cdee0c4600c178af
|
||||
preset/DIGITAL/14_GLOCKEN b61b482ee24cf907
|
||||
preset/DIGITAL/15_CELESTA 019c882ab69103ca
|
||||
preset/DIGITAL/16_XYLOPHONE 27758ac901c596a3
|
||||
preset/DIGITAL/17_HARP 87c789bb52b280e1
|
||||
preset/DIGITAL/18_BASS_GTR 6b8983458c99e55a
|
||||
preset/DIGITAL/19_TUBE_BELL 65ab46fca208aa84
|
||||
preset/DIGITAL/20_FM_PLUCK 1a7ed2362a18b2e2
|
||||
preset/DIGITAL/21_FM_GRAND 173b91c2b4e7bd65
|
||||
preset/PHASE/00_CZ_BASS 7244498adc8f4620
|
||||
preset/PHASE/01_SOFT_KEYS f9348b4472fd13a4
|
||||
preset/PHASE/02_CZ_STRING 34bb29aeb3aaca76
|
||||
preset/PHASE/03_RESO_PLUCK 78ca95b53d12ece8
|
||||
preset/PHASE/04_CZ_BRASS e8f7f5fe6ae76714
|
||||
preset/PHASE/05_CZ_LEAD 311a62e813d84533
|
||||
preset/PHASE/06_CZ_PAD b75f9cbb44fb84a5
|
||||
preset/PHASE/07_CZ_RESO 0811d592ee75799a
|
||||
preset/LOFI/00_GAME_LEAD 82d1172ddd442934
|
||||
preset/LOFI/01_GB_BASS 86c061b85a2cf290
|
||||
preset/LOFI/02_8BIT_ARP 8ba73e2cfbd0b963
|
||||
preset/LOFI/03_NES_BASS ae68bd05a9f19b12
|
||||
preset/LOFI/04_CHIP_CHORD 06723186c4b12764
|
||||
preset/LOFI/05_1BIT_BEEP b2732064bea3066c
|
||||
preset/LOFI/06_WAVE_LEAD 23eb147f89c28417
|
||||
preset/LOFI/07_CHIP_NOISE 1b074b04fd6f9a69
|
||||
preset/SAMPLE/00_GRAND_PNO dbca4dc7df9d406c
|
||||
preset/SAMPLE/01_UP_BASS a994149fc7bad972
|
||||
preset/SAMPLE/02_VIBES ff2b0ca2960d0045
|
||||
preset/SAMPLE/03_HORN_STAB 3863c2e2aeeed5da
|
||||
preset/SAMPLE/04_STRING_STB af826a1719967773
|
||||
preset/SAMPLE/05_LOFI_FLUTE 2df32158be58cc1d
|
||||
preset/SAMPLE/06_SCRATCH b89c4977a09f31bc
|
||||
preset/SAMPLE/07_GM_KIT 82e037aa94f45e51
|
||||
preset/SAMPLE/08_DUSTY_PNO 6d2f943398970b04
|
||||
preset/SAMPLE/09_LOFI_KEYS 6839902727e60c59
|
||||
preset/SAMPLE/10_DEEP_BASS de978d1076c6ee20
|
||||
preset/VOICE/00_CHOIR_AAH 36bf68a95068eb8d
|
||||
preset/VOICE/01_SOUL_OOH e93089918661735f
|
||||
preset/VOICE/02_TALKBOX a39aafcb80c658e2
|
||||
preset/VOICE/03_WOW_BASS de48773f5a20222e
|
||||
preset/VOICE/04_HARMONICA 7ef0da8a7838e198
|
||||
preset/VOICE/05_ROBOT 650b63ad403bc58c
|
||||
preset/VOICE/06_VOX_PAD eabe0fffd7fce18c
|
||||
preset/TRIO/00_FAT_BASS c72179094993986e
|
||||
preset/TRIO/01_MIN_STAB 36788b82f6c2f214
|
||||
preset/TRIO/02_MIN7_STAB 969e097e9beb0382
|
||||
preset/TRIO/03_RAVE_STAB 1533db371d43c2ab
|
||||
preset/TRIO/04_DUB_CHORD 7186c1993bcaad74
|
||||
preset/TRIO/05_SAW_PAD 6e844ed71a5c24d1
|
||||
preset/TRIO/06_SYNC_LEAD 918ad5bfb40a0360
|
||||
preset/TRIO/07_HOOVER 384655d9b110001d
|
||||
preset/TRIO/08_ACCORDION 08dda133514f2d1e
|
||||
preset/TRIO/09_ENSEMBLE 687951f26a8a1a62
|
||||
preset/TRIO/10_80S_POLY acf24403f37dcc10
|
||||
preset/TRIO/11_SQR_LEAD 8b5006dca7e98bf9
|
||||
preset/TRIO/12_POWER_STAB bc5995a61cc10486
|
||||
preset/TRIO/13_PULSE_PAD 6b741b238835dcc5
|
||||
preset/WHEEL/00_SOUL_ORGAN 16df0cb061ba5bb2
|
||||
preset/WHEEL/01_GOSPEL 3466ffe0e5adda55
|
||||
preset/WHEEL/02_JAZZ_ORGAN 804aef352742770f
|
||||
preset/WHEEL/03_DIRTY_B3 f89b98547cb413ed
|
||||
preset/WHEEL/04_HOUSE_ORGN 03537985b04ea7ff
|
||||
preset/WHEEL/05_ROCK_ORGAN e8d878966bc133e2
|
||||
preset/WHEEL/06_CHAPEL f5236d85533a903e
|
||||
preset/WHEEL/07_REGGAE_ORG 344107147c3f118e
|
||||
preset/GRAIN/00_LOFI_CLOUD b9c8344408cd5910
|
||||
preset/GRAIN/01_VIBE_HAZE bf9a62e85f1e5f56
|
||||
preset/GRAIN/02_FLUTE_DUST 22ed1a0a15208262
|
||||
preset/GRAIN/03_STR_CLOUD 75331844d8f9477b
|
||||
preset/GRAIN/04_SHIMMER 383c6b56fe23e0b5
|
||||
preset/GRAIN/05_DRONE 99869b548336abd4
|
||||
preset/GRAIN/06_PNO_FREEZE bc1bc231c228b721
|
||||
preset/GRAIN/07_HORN_CLOUD f8901104755d1f60
|
||||
preset/FM6/00_TINE_EP b6ec8561abb7217e
|
||||
preset/FM6/01_GLASS_BELL f34ceecc6e7f17eb
|
||||
preset/FM6/02_ROUND_BASS 65dbe231f1f85f03
|
||||
preset/FM6/03_BRASS_SECT 001e9548252b4935
|
||||
preset/FM6/04_SOFT_PAD 695d302db2c964a2
|
||||
preset/FM6/05_WOOD_BARS 2a255c2f1618cb91
|
||||
preset/FM6/06_DRAWBARS bf906047d5d53c36
|
||||
preset/FM6/07_NYLON_PICK 3398c9b2570facf0
|
||||
preset/PHYS/00_BELL_TREE a1f8414c82430f1e
|
||||
preset/PHYS/01_MODAL_BAR 795ce8148c3fc0df
|
||||
preset/PHYS/02_STR_PLUCK b706488551cd5803
|
||||
preset/PHYS/03_BOWED_MTL 0da38a747b3d6458
|
||||
preset/PHYS/04_THUMB_PNO 95a2c210ba3d9fd1
|
||||
preset/PHYS/05_HAND_DRUM 6491ad5dbc1c505f
|
||||
preset/PHYS/06_MEMB_TOMS d4bb0d525e47d5e7
|
||||
preset/PHYS/07_SITAR c214c68a2c6391e9
|
||||
preset/PHYS/08_PHYS_HARP 2967343c3825d22e
|
||||
preset/PHYS/09_NYLON_GTR e2d0f74d7086494c
|
||||
preset/PHYS/10_STEEL_GTR 91bed612b8b379c7
|
||||
preset/PHYS/11_MUTED_GTR 5c014ec3969ddaf3
|
||||
preset/PHYS/12_PLUCK_BASS f4061e6bb1cbde56
|
||||
preset/PHYS/13_KOTO f6729edf3d978779
|
||||
preset/PHYS/14_BANJO e4e93bc33cad4cc0
|
||||
preset/PHYS/15_CELLO_BOW 8915d724b2724143
|
||||
preset/PHYS/16_TANPURA f6a79b19737cede0
|
||||
preset/PHYS/17_CHIMES 1d82ac6030ce6fc2
|
||||
preset/PHYS/18_BIG_BELL 6b966e0d9dc9c4d5
|
||||
preset/PHYS/19_VIBRA_BAR f2a1f3ec95b465e7
|
||||
preset/PHYS/20_GLASS_BOWL 70bc0b6f0132af8f
|
||||
preset/PHYS/21_STEEL_PAN 5dcdca7135822db5
|
||||
preset/PHYS/22_WOOD_BLOCK 7754760ff51518ec
|
||||
preset/PHYS/23_TABLA 7b2a924f5efb6744
|
||||
preset/PHYS/24_CONGA 6259733343420196
|
||||
preset/PHYS/25_TIMPANI bd8a99d7e56b6279
|
||||
preset/NOISE/00_WIND e5e3a2639d9a1168
|
||||
preset/NOISE/01_RAIN f321bd95bd84d89b
|
||||
preset/NOISE/02_NZ_ARCADE aa5175b4ca8551bc
|
||||
preset/NOISE/03_NZ_METAL 30af496ab45c3dfd
|
||||
preset/NOISE/04_OCEAN cf989fadacf6caf2
|
||||
preset/NOISE/05_VINYL 6473f0bf021e67b8
|
||||
preset/NOISE/06_HISS 206628447ef5bb20
|
||||
preset/NOISE/07_RISER 9c184d92b6eaad31
|
||||
preset/NOISE/08_NZ_SNARE e4ca8efeaba8ae23
|
||||
preset/NOISE/09_BITCRUSH 54bf702e1f2210d0
|
||||
preset/NOISE/10_RADIO 8f48581fb75d1a5d
|
||||
preset/HYBRID/00_CLIPPER 31cb3c25061e4527
|
||||
preset/HYBRID/01_POLY_PAD 04678e9bdd4d206f
|
||||
preset/HYBRID/02_STRINGS f71329776ce3bedf
|
||||
preset/HYBRID/03_ACID 597170a2f0d657ee
|
||||
preset/HYBRID/04_SYNC_LEAD 6cf7dfadb8d5075a
|
||||
preset/HYBRID/05_FM_BELL b4b2fcc6859e92c4
|
||||
preset/HYBRID/06_FM_KEYS c7744441dc9f4e44
|
||||
preset/HYBRID/07_WOBBLE 2090fad303003fa7
|
||||
preset/HYBRID/08_REESE e7f9cc04eb631d61
|
||||
preset/HYBRID/09_HOOVER fb97f4ac706b2bff
|
||||
preset/HYBRID/10_BRASS 849747b874156be2
|
||||
preset/HYBRID/11_VOX 5c1acc78aee8c695
|
||||
preset/HYBRID/12_PLUCK 167b29bc98f4ccf7
|
||||
preset/HYBRID/13_RISER 867db6fd596df586
|
||||
preset/HYBRID/14_METAL 9afd531bc3c1068d
|
||||
preset/HYBRID/15_FOLD_BASS 1c5e80b590aff8d6
|
||||
preset/HYBRID/16_CHIP_LEAD 9a5d6e667c89cd0f
|
||||
preset/HYBRID/17_GLASS_PAD 6aac8f8803f0a198
|
||||
preset/HYBRID/18_DRONE dcf7696f2e36bb93
|
||||
preset/HYBRID/19_808_SUB 3481a2529f60fecc
|
||||
preset/HYBRID/20_TRANCE fbb01aebf66e6dab
|
||||
preset/HYBRID/21_SAW_PLUCK aa973efcd01792cc
|
||||
preset/HYBRID/22_SPACE_BEL 25962aa3f6d2e743
|
||||
preset/HYBRID/23_INIT 13fa6b3311bdcfb8
|
||||
preset/HYBRID/24_MOOG_BASS b7c96a746255eca9
|
||||
preset/HYBRID/25_MOOG_LEAD e2a518f8faeb9c01
|
||||
preset/HYBRID/26_LADDER_PAD c27006e21d147774
|
||||
drums/gm_kit 72c58344b8b0f47b
|
||||
mode/ANALOG/POLY 5d0e4eb426c2ea24
|
||||
mode/ANALOG/MONO 18ee6950d997f284
|
||||
mode/ANALOG/LEGATO 7ec96f14879328dc
|
||||
mode/ANALOG/UNISON aa0364a434c13494
|
||||
mode/DIGITAL/POLY 11b6fb9e67ee1f3d
|
||||
mode/DIGITAL/MONO 3de55545ae6ef048
|
||||
mode/DIGITAL/LEGATO 61db501b1455d0bf
|
||||
mode/DIGITAL/UNISON d799715d3f8d8923
|
||||
mode/VOICE/POLY 36bf68a95068eb8d
|
||||
mode/VOICE/MONO a2abce138163e87e
|
||||
mode/VOICE/LEGATO e4553da7d08dd888
|
||||
mode/VOICE/UNISON a18664fb7e044302
|
||||
sends/ANALOG/dry 824241c6fea50294
|
||||
sends/ANALOG/chorus 89a1bda5d78b9032
|
||||
sends/ANALOG/delay 960faa3ed507cd24
|
||||
sends/ANALOG/reverb 544bb4a90d05551d
|
||||
sends/ANALOG/all 6f1901c9a9931585
|
||||
sends/ANALOG/dist 2a083173e2b0728b
|
||||
sends/DIGITAL/dry 20c8428b408e602c
|
||||
sends/DIGITAL/chorus 221d4aa1e68f324a
|
||||
sends/DIGITAL/delay f30e12ecfb7f89b4
|
||||
sends/DIGITAL/reverb 99466dd53db4b610
|
||||
sends/DIGITAL/all 0bd45b8af37a6686
|
||||
sends/DIGITAL/dist d36f205b881226f4
|
||||
song/4track_mix fd8ff7361410c8d2
|
||||
slicer/gate/ANALOG_DARK_STR e5ab0ee0862f6de2
|
||||
slicer/stut/DIGITAL_RHODES 099b9e70ef5d8a01
|
||||
slicer/song_gate_stut 7cdd42b5c789c377
|
||||
@@ -0,0 +1,86 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* GRAIN: a note played in the release of the note before sounds as loud as alone. A grain starts only while the
|
||||
* part's grains decode at most GR_LOAD_MAX source samples an output sample; the released note kept starting grains
|
||||
* through its long release, so the new held note's grains were refused for the load: SCAN PAD 86 then 88 (290 ms
|
||||
* after the release) came out 29 dB down, SLOOP's PNO FREEZE 88 then 90 35 dB down, for the whole note.
|
||||
* For each preset, note n (C5 .. F#7, every 2) for 1 s, released, 290 ms later n + 2 for 1 s: from 0.29 s on it holds
|
||||
* at least a third of the grains it holds alone (starved: none; the rms is printed). Exit status: failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#if CLIPPER_SYNTH
|
||||
#define TAPL mix_l
|
||||
#define TAPR mix_r
|
||||
#else
|
||||
#define TAPL acc[0].l
|
||||
#define TAPR acc[0].r
|
||||
#endif
|
||||
static int32_t o[CTL * 2];
|
||||
static void reset(uint32_t pi)
|
||||
{
|
||||
uint32_t i, b, k;
|
||||
for (k = 0; k < NPART; k++) {
|
||||
trk_all_off(&trk[k]);
|
||||
for (i = 0; i < NVOICE; i++) trk[k].v[i].active = 0, trk[k].v[i].stage = 0, trk[k].v[i].env = 0, trk[k].v[i].env_out = 0;
|
||||
}
|
||||
for (b = 0; b < 400; b++) mix_block(o, CTL);
|
||||
for (i = 0; i < P_E0; i++) trk[0].p[i] = TP[i].def;
|
||||
host_preset(&trk[0], ENGI_GRAIN, pi);
|
||||
trk[0].p[P_AMODE] = 0, trk[0].p[P_DLY] = trk[0].p[P_REV] = 0, trk[0].p[P_VOICE] = V_POLY;
|
||||
for (b = 0; b < 64; b++) mix_block(o, CTL);
|
||||
}
|
||||
/* note held for blocks: the rms of blocks from .. on, *ng the mean count of its grains there (the held voices') */
|
||||
static double hold(uint32_t note, uint32_t blocks, uint32_t from, double *ng)
|
||||
{
|
||||
gr_part_t *P = (gr_part_t *)eng_arena_of(&trk[0], ENGI_GRAIN);
|
||||
uint32_t b, i;
|
||||
double s2 = 0, g = 0;
|
||||
trk_note_on(&trk[0], note, 100);
|
||||
for (b = 0; b < blocks; b++) {
|
||||
mix_block(o, CTL);
|
||||
if (b < from)
|
||||
continue;
|
||||
for (i = 0; i < CTL; i++) {
|
||||
double x = (TAPL[i] + TAPR[i]) / 2.0;
|
||||
s2 += x * x;
|
||||
}
|
||||
for (i = 0; i < GR_NG; i++)
|
||||
g += P->g[i].owner && trk[0].v[(P->g[i].owner - 1u) % NVOICE].gate;
|
||||
}
|
||||
trk_note_off(&trk[0], note);
|
||||
if (ng)
|
||||
*ng = g / (blocks - from);
|
||||
return sqrt(s2 / ((blocks - from) * CTL));
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
uint32_t pi, b, gap = 400, n1, n2;
|
||||
int fails = 0;
|
||||
host_tracks_init();
|
||||
for (pi = 0; pi < ENGINES[ENGI_GRAIN]->npresets; pi++) {
|
||||
uint32_t bad = 0;
|
||||
double worst = 1e9;
|
||||
for (n1 = 72; n1 <= 100; n1 += 2) {
|
||||
double alone, after, g0, g1;
|
||||
n2 = n1 + 2;
|
||||
reset(pi);
|
||||
alone = hold(n2, 1400, 400, &g0);
|
||||
reset(pi);
|
||||
hold(n1, 1400, 1300, 0); /* 1 s */
|
||||
for (b = 0; b < gap; b++) /* released, 290 ms */
|
||||
mix_block(o, CTL);
|
||||
after = hold(n2, 1400, 400, &g1);
|
||||
if (g1 < g0 / 3) { /* (the level alone varies +-6 dB from cloud to cloud) */
|
||||
bad++;
|
||||
printf("grain: %-14s note %u: %.1f grains, rms %6.0f alone; 290 ms after note %u's release %.1f grains, rms %6.0f (%+.1f dB)\n",
|
||||
ENGINES[ENGI_GRAIN]->presets[pi].name, n2, g0, alone, n1, g1, after, 20 * log10((after + 1) / (alone + 1)));
|
||||
}
|
||||
if (g1 / (g0 + 1e-9) < worst)
|
||||
worst = g1 / (g0 + 1e-9);
|
||||
}
|
||||
printf("grain: %-14s 15 pairs C5 .. F#7: %s (the fewest grains: %.0f %% of alone)\n", ENGINES[ENGI_GRAIN]->presets[pi].name, bad ? "FAIL" : "ok", worst * 100);
|
||||
fails += bad != 0;
|
||||
}
|
||||
printf("grain: %d failed\n", fails);
|
||||
return fails;
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Clipper on the FM-1 (its 7 encoders: SELECT, ALGORITHM, PRESETS, KNOB 1..4, through panel.enc): every page, every
|
||||
* knob turned alone changes one value at most (sloop-pro #6, the same code here: on REC READY, KNOB 3 START also moved
|
||||
* the page's KNOB 3, KNOB 2 LENGTH the page's KNOB 2; the Clipper Pro version: the SMK-37's knobs). A turn is a detent at the read and one the scan ISR counts
|
||||
* right after it (as on the device, where the scan runs while a UI pass does: tests/ui_pages_test.c enc_late); the page,
|
||||
* HOME, the REC READY screen over each page, the synth and the drum track. What a turn changed: the global and track
|
||||
* parameters, the steps, the REC screen's MODE / LENGTH / START / QUANT, the track, the page.
|
||||
* cc -O2 -w -DCLIPPER_SYNTH=1 -Ibuild/gen -Ifirmware/src -Ifirmware/hal tests/knob_walk_test.c -lm */
|
||||
#define UI_PAGES_HARNESS_ONLY 1
|
||||
#include "ui_pages_test.c"
|
||||
|
||||
typedef struct {
|
||||
int16_t g[G_COUNT], p[NTRK][P_COUNT];
|
||||
step_t step[NTRK][NSTEP];
|
||||
uint8_t eng[NTRK], preset[NTRK];
|
||||
int32_t x[12];
|
||||
} snap_t;
|
||||
static snap_t s0, s1;
|
||||
static void snap(snap_t *s)
|
||||
{
|
||||
uint32_t k;
|
||||
memcpy(s->g, song.g, sizeof s->g);
|
||||
for (k = 0; k < NTRK; k++) {
|
||||
memcpy(s->p[k], trk[k].p, sizeof s->p[k]);
|
||||
memcpy(s->step[k], trk[k].step, sizeof s->step[k]);
|
||||
s->eng[k] = trk[k].eng_req, s->preset[k] = trk[k].preset;
|
||||
}
|
||||
s->x[0] = rec_tempo, s->x[1] = rec_count, s->x[2] = rec_quant_off, s->x[3] = song.sel, s->x[4] = ui.page;
|
||||
s->x[5] = ui.home, s->x[6] = ui.step_page, s->x[7] = ui.cursor, s->x[8] = drum_page, s->x[9] = drum_cursor;
|
||||
s->x[10] = rec_wait, s->x[11] = ui.zoom;
|
||||
}
|
||||
/* the values a turn changed (a new sound, PRESETS: one), their names into what */
|
||||
static uint32_t changed(char *what, size_t n)
|
||||
{
|
||||
static const char *const XN[12] = {"MODE", "START", "QUANT", "track", "page", "home", "step page", "cursor",
|
||||
"drum page", "drum cursor", "rec arm", "zoom"};
|
||||
uint32_t c = 0, k, i;
|
||||
what[0] = 0;
|
||||
#define NOTE(...) do { size_t l = strlen(what); c++; if (l + 24u < n) snprintf(what + l, n - l, __VA_ARGS__); } while (0)
|
||||
for (i = 0; i < G_COUNT; i++)
|
||||
if (s0.g[i] != s1.g[i])
|
||||
NOTE(" g%u", i);
|
||||
for (k = 0; k < NTRK; k++) {
|
||||
if (s0.eng[k] != s1.eng[k] || s0.preset[k] != s1.preset[k]) {
|
||||
NOTE(" t%u sound", k);
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < P_COUNT; i++)
|
||||
if (s0.p[k][i] != s1.p[k][i])
|
||||
NOTE(" t%u p%u%s", k, i, i == P_SLEN ? "(LEN)" : "");
|
||||
for (i = 0; i < NSTEP; i++)
|
||||
if (memcmp(&s0.step[k][i], &s1.step[k][i], sizeof s0.step[k][i])) {
|
||||
NOTE(" t%u steps", k); /* (the pattern: one value; a note's LEN is its TIE steps) */
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 12u; i++)
|
||||
if (s0.x[i] != s1.x[i] && !(i >= 4u && i <= 9u && s0.x[3] != s1.x[3]))
|
||||
NOTE(" %s", XN[i]); /* (ALGORITHM: the new track's page, ui.c page_fix, is the same move) */
|
||||
#undef NOTE
|
||||
return c;
|
||||
}
|
||||
static uint32_t enc_of(uint32_t role) /* the FM-1: the encoder of a role (EN_SELECT .. EN_K4) */
|
||||
{
|
||||
return panel.enc[role] % 7u;
|
||||
}
|
||||
static uint32_t bad;
|
||||
/* knob K(kn + 1) one detent (and a late one), on the screen as it is now; where: what is up */
|
||||
static void turn(uint32_t kn, int32_t d, const char *where)
|
||||
{
|
||||
char what[256];
|
||||
uint32_t e = enc_of(kn), c, i;
|
||||
for (i = 0; i < 7u; i++)
|
||||
encs[i] = enc_late[i] = 0;
|
||||
ui.hot_t = 0, ui.bpm_t = 0, ui.msg_t = 0, ui.arm = 0;
|
||||
frame(); /* (what the last turn left settles: GLO > MIDI's channels, ui.c
|
||||
* midi_chan_fix, a frame later) */
|
||||
snap(&s0);
|
||||
encs[e] = d, enc_late[e] = d;
|
||||
frame();
|
||||
frame(); /* (a detent left for the next pass: read there) */
|
||||
snap(&s1);
|
||||
c = changed(what, sizeof what);
|
||||
if (c > 1u) {
|
||||
bad++;
|
||||
if (bad <= 60u)
|
||||
printf("knob_walk: %-26s %-9s %+d changed %u values:%s\n", where, E_NAME[kn % NE], d, c, what);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
uint32_t i, pg, kn, t, rec;
|
||||
static track_t keep[NTRK];
|
||||
outdir = argc > 1 ? argv[1] : "build/host";
|
||||
panel = PANEL_DEFAULT; /* (the FM-1's: SELECT 0, ALGORITHM 1, PRESETS 6, KNOB 1..4 2..5) */
|
||||
bank_resolve();
|
||||
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; }
|
||||
TDRUM->p[P_E0] = DRUM_DEFAULT_KIT;
|
||||
for (t = 0; t < NTRK; t++) /* a pattern on every track: the REC screen's LENGTH and START */
|
||||
for (i = 0; i < 16u; i += 4u) {
|
||||
if (t == TRK_DRUM) {
|
||||
dstep_set(&trk[t].dstep[i], 0, LV_NORM, 0);
|
||||
} else {
|
||||
trk[t].step[i].time = ST_NOTE; trk[t].step[i].n = 1; trk[t].step[i].note[0] = (uint8_t)(48 + i);
|
||||
}
|
||||
}
|
||||
memcpy(keep, trk, sizeof keep);
|
||||
go_home(); ui.force = 1; frame();
|
||||
{ /* sloop-pro #6, on the FM-1: REC READY (a pattern: LENGTH, START, QUANT), KNOB 3 START */
|
||||
uint32_t ok;
|
||||
rec_count = 0; trk[0].p[P_SLEN] = 32; song.sel = 0;
|
||||
go_home(); rec_wait = 1; ui.force = 1; frame();
|
||||
{
|
||||
char what[256];
|
||||
snap(&s0);
|
||||
encs[enc_of(EN_K3)] = 1; enc_late[enc_of(EN_K3)] = 1; frame(); frame();
|
||||
snap(&s1);
|
||||
ok = rec_count == 1u && trk[0].p[P_SLEN] == 32 && changed(what, sizeof what) == 1u;
|
||||
if (!ok)
|
||||
printf("knob_walk: changed:%s\n", what);
|
||||
}
|
||||
check(ok, "#6 REC READY over HOME, KNOB 3 START -> count: nothing else (LENGTH, the HOME dial)");
|
||||
printf("knob_walk: (START %u, LENGTH %d steps)\n", rec_count, trk[0].p[P_SLEN]);
|
||||
rec_wait = 0; rec_count = 0; frame();
|
||||
}
|
||||
{ /* the count-in, a free take: KNOB 1..4 edit nothing (not the page under them either) */
|
||||
char what[256];
|
||||
uint32_t n = 0, w;
|
||||
for (w = 0; w < 2u; w++)
|
||||
for (kn = EN_K1; kn <= EN_K4; kn++) {
|
||||
go_home(); song.sel = 0; frame();
|
||||
rec_wait = (uint8_t)!w, ci_on = (uint8_t)!w, ft_on = (uint8_t)w;
|
||||
for (i = 0; i < 7u; i++)
|
||||
encs[i] = enc_late[i] = 0;
|
||||
snap(&s0);
|
||||
encs[enc_of(kn)] = 1; enc_late[enc_of(kn)] = 1; frame(); frame();
|
||||
snap(&s1);
|
||||
n += changed(what, sizeof what) != 0u;
|
||||
rec_wait = 0, ci_on = 0, ft_on = 0; frame();
|
||||
}
|
||||
check(!n, "the count-in, a free take: KNOB 1..4 change nothing");
|
||||
memcpy(trk, keep, sizeof keep);
|
||||
}
|
||||
for (rec = 0; rec < 2u; rec++)
|
||||
for (t = 0; t < 2u; t++)
|
||||
for (pg = 0; pg <= NPAGES; pg++) {
|
||||
char where[48];
|
||||
const char *name;
|
||||
song.sel = (uint8_t)(t ? TRK_DRUM : 0u);
|
||||
song.playing = 0, transport_req = 0, song.rec = 0, ft_on = 0, ci_on = 0;
|
||||
ui.menu = 0; ui.layer = LY_PLAY; ui.sheet = 0; vis_on = 0;
|
||||
if (pg == NPAGES) {
|
||||
go_home();
|
||||
name = "HOME";
|
||||
} else {
|
||||
ui.page = (uint8_t)pg; ui.home = 0; song.seq_mode = 0;
|
||||
name = PAGES[pg].title;
|
||||
}
|
||||
rec_wait = (uint8_t)rec;
|
||||
ui.force = 1; frame();
|
||||
if (pg < NPAGES && (ui.page != pg || ui.home))
|
||||
continue; /* (a page this track does not have) */
|
||||
if (rec && !rec_wait)
|
||||
continue; /* (the song page: no arm) */
|
||||
snprintf(where, sizeof where, "%s%s %s", rec ? "REC READY over " : "", name, t ? "(drums)" : "(synth)");
|
||||
for (kn = 0; kn < NE; kn++) { /* the roles, SELECT .. KNOB 4 (MASTER: a pot, main.c) */
|
||||
uint32_t r = kn;
|
||||
if (pg < NPAGES && !rec && r >= EN_K1 && PAGES[pg].scope == SC_GLOBAL &&
|
||||
(PAGES[pg].id[r - EN_K1] == G_LOAD || PAGES[pg].id[r - EN_K1] == G_SAVE ||
|
||||
PAGES[pg].id[r - EN_K1] == G_CLRSEQ || PAGES[pg].id[r - EN_K1] == G_INITSND ||
|
||||
PAGES[pg].id[r - EN_K1] == G_NEWPRJ))
|
||||
continue; /* (a GO: a detent arms, a second one acts on the whole pattern / project) */
|
||||
turn(kn, 1, where);
|
||||
turn(kn, -1, where);
|
||||
song.sel = (uint8_t)(t ? TRK_DRUM : 0u); /* (ALGORITHM: back to the track) */
|
||||
if (pg < NPAGES && (ui.page != pg || ui.home))
|
||||
break; /* (SELECT walked the pages) */
|
||||
}
|
||||
memcpy(trk, keep, sizeof keep);
|
||||
rec_wait = 0;
|
||||
}
|
||||
check(!bad, "every page, HOME, REC READY (synth, drums): each knob alone changes one value at most");
|
||||
printf("knob_walk: %s\n", fails ? "FAIL" : "ok");
|
||||
return fails != 0;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* (after Clipper 1.2) the filter MODEL changed under a held chord, every pair of models, on ANALOG, WAVE and VECTOR: the
|
||||
* click mark (the largest second difference) and the peak right after the change against the steady sound before and
|
||||
* after, as synth9_test does it (synth9 changes the model on ANALOG only). VECTOR keeps one set of filter states for
|
||||
* every model: a ladder's states (x 4096) read by an SVF burst at full scale (DIODE -> SEM: 17994, steady ~1800) until
|
||||
* fx.c part_apply cleared them while the part is ducked. Cutoffs 20 and 40, levels 40 and 100. Exit status: clicks. */
|
||||
#define main hostsim_main
|
||||
#include <stddef.h>
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#define NCAP (4096u * 24u)
|
||||
static int32_t cl[NCAP];
|
||||
static uint32_t ncap;
|
||||
static void run(uint32_t nb)
|
||||
{
|
||||
static int32_t o[CTL * 2];
|
||||
uint32_t b, i;
|
||||
ncap = 0;
|
||||
for (b = 0; b < nb; b++) {
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < CTL; i++)
|
||||
if (ncap < NCAP) cl[ncap++] = o[2 * i];
|
||||
}
|
||||
}
|
||||
static int32_t d2max(void)
|
||||
{
|
||||
int32_t mx = 0, d;
|
||||
uint32_t i;
|
||||
for (i = 2; i < ncap; i++) {
|
||||
d = cl[i] - 2 * cl[i - 1] + cl[i - 2];
|
||||
d = d < 0 ? -d : d;
|
||||
mx = d > mx ? d : mx;
|
||||
}
|
||||
return mx;
|
||||
}
|
||||
static int32_t peak(void)
|
||||
{
|
||||
int32_t mx = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < ncap; i++) mx = abs(cl[i]) > mx ? abs(cl[i]) : mx;
|
||||
return mx;
|
||||
}
|
||||
static const char *const MN[9] = {"", "SVF", "MOOG", "MS20", "DIODE", "SEM", "NOTCH", "BP", "HP"};
|
||||
static uint32_t sweep(int32_t cut, int32_t lvl)
|
||||
{
|
||||
static const uint32_t engs[3] = {0, ENGI_WAVE, ENGI_VECTOR};
|
||||
static const uint8_t ch[3] = {48, 55, 64};
|
||||
track_t *t = &trk[0];
|
||||
uint32_t e, from, to, i, bad = 0;
|
||||
for (e = 0; e < 3u; e++)
|
||||
for (from = FM_SVF; from <= FM_LAST; from++)
|
||||
for (to = FM_SVF; to <= FM_LAST; to++) {
|
||||
int32_t a, b, c, pk, steady_pk;
|
||||
if (to == from) continue;
|
||||
for (i = 0; i < NPART; i++) trk_all_off(&trk[i]);
|
||||
run(600);
|
||||
host_preset(t, engs[e], 0);
|
||||
t->p[P_DIST] = t->p[P_CHOR] = t->p[P_DLY] = t->p[P_REV] = 0;
|
||||
t->p[P_ATK] = 0, t->p[P_SUS] = 127, t->p[P_REL] = 10, t->p[P_VOICE] = V_POLY, t->p[P_GLIDE] = 0;
|
||||
t->p[P_SPREAD] = 0, t->p[P_ITYPE] = 0, t->p[P_AMODE] = 0, t->p[P_VINT] = 0;
|
||||
t->p[P_FMODEL] = (int16_t)from;
|
||||
if (engs[e] == ENGI_VECTOR) t->p[P_E7] = (int16_t)cut; else t->p[P_E4] = (int16_t)cut;
|
||||
t->p[P_LEVEL] = (int16_t)lvl;
|
||||
for (i = 0; i < 3u; i++) trk_note_on(t, ch[i], 100);
|
||||
run(800); /* (the duck of the preset's change, the sound steady) */
|
||||
run(200); a = d2max(); { int32_t pa = peak();
|
||||
t->p[P_FMODEL] = (int16_t)to;
|
||||
run(16); b = d2max(); pk = peak();
|
||||
run(200); c = d2max(); pa = pa > peak() ? pa : peak(); steady_pk = pa; }
|
||||
a = a > c ? a : c;
|
||||
if (b > a * 3 / 2 + 64 || pk > steady_pk * 3 / 2 + 64) {
|
||||
bad++;
|
||||
printf("model_switch: %-6s %-5s -> %-5s: click mark %6d (steady %5d), peak %6d after the change (steady %6d)\n",
|
||||
ENGINES[engs[e]]->name, MN[from], MN[to], b, a, pk, steady_pk);
|
||||
}
|
||||
}
|
||||
printf("model_switch: cutoff %3d level %3d: %u of %u changes click\n", cut, lvl, bad, 3u * (FM_LAST - FM_SVF + 1u) * (FM_LAST - FM_SVF));
|
||||
return bad;
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
uint32_t bad = 0;
|
||||
host_tracks_init();
|
||||
bad += sweep(20, 40);
|
||||
bad += sweep(40, 40);
|
||||
bad += sweep(20, 100);
|
||||
bad += sweep(40, 100);
|
||||
printf("model_switch: %s\n", bad ? "FAIL" : "no click on any model change (ANALOG, WAVE, VECTOR)");
|
||||
return bad != 0;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* NOISE in LFSR mode: its register clock follows the keys past the sample rate. A Clipper report (clipper-fm1 #10):
|
||||
* NZ ARCADE (TONE +84 semitones) played the same pitch on the whole upper half of the keyboard: the clock stopped at
|
||||
* one register step a sample. Now a sample takes as many steps as clocks passed: the register's period (127 steps, the
|
||||
* short register of NZ ARCADE) gives a fundamental of clock / 127 that goes on rising. For each note: the spectrum at
|
||||
* that fundamental stands out of the rest, and no two notes give the same samples. Exit status: failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#define NB 1200u /* blocks a note (~0.9 s) */
|
||||
static int32_t cap[24][NB * CTL];
|
||||
static int fails;
|
||||
static void ok(int c, const char *what)
|
||||
{
|
||||
printf("noise: %-96s %s\n", what, c ? "ok" : "FAIL");
|
||||
fails += !c;
|
||||
}
|
||||
/* the magnitude of the DFT of x[0..n) at f Hz (Hann window), and its median over 200 Hz .. 10 kHz */
|
||||
static double mag_at(const int32_t *x, uint32_t n, double f)
|
||||
{
|
||||
double re = 0, im = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
double w = 0.5 - 0.5 * cos(2 * M_PI * i / n), a = 2 * M_PI * f * i / FS;
|
||||
re += x[i] * w * cos(a);
|
||||
im -= x[i] * w * sin(a);
|
||||
}
|
||||
return sqrt(re * re + im * im);
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
uint32_t e, pi = 0, k, b, nn = 0, same = 0, weak = 0;
|
||||
static int32_t o[CTL * 2];
|
||||
const engine_t *en = ENGINES[ENGI_NOISE];
|
||||
host_tracks_init();
|
||||
for (k = 0; k < en->npresets; k++)
|
||||
if (!strcmp(en->presets[k].name, "NZ ARCADE"))
|
||||
pi = k;
|
||||
ok(!strcmp(en->presets[pi].name, "NZ ARCADE"), "NZ ARCADE found");
|
||||
e = ENGI_NOISE;
|
||||
host_preset(&trk[0], e, pi);
|
||||
trk[0].p[P_VOICE] = V_POLY;
|
||||
for (k = 36; k <= 102; k += 3, nn++) {
|
||||
trk_all_off(&trk[0]);
|
||||
for (b = 0; b < 400u; b++)
|
||||
mix_block(o, CTL);
|
||||
trk_note_on(&trk[0], k, 100);
|
||||
for (b = 0; b < NB; b++) {
|
||||
uint32_t i;
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < CTL; i++)
|
||||
cap[nn][b * CTL + i] = o[2 * i];
|
||||
}
|
||||
trk_note_off(&trk[0], k);
|
||||
}
|
||||
for (k = 0; k < nn; k++) {
|
||||
uint32_t note = 36 + 3 * k, n = 16384, a = 4000, j;
|
||||
double clock = 440.0 * pow(2.0, (note + en->presets[pi].e[7] - 69) / 12.0), f0 = clock / 127.0, m, med;
|
||||
static double s[64];
|
||||
if (k + 1 < nn && !memcmp(&cap[k][a], &cap[k + 1][a], 4096u * 4u))
|
||||
same++;
|
||||
if (f0 > 10000)
|
||||
continue;
|
||||
m = 0;
|
||||
for (j = 0; j < 7; j++) { /* the strongest bin around f0 (+-3 bins) */
|
||||
double v = mag_at(&cap[k][a], n, f0 + (j - 3.0) * FS / n);
|
||||
if (v > m)
|
||||
m = v;
|
||||
}
|
||||
for (j = 0; j < 64; j++) /* a sample of the spectrum: 200 Hz .. 10 kHz */
|
||||
s[j] = mag_at(&cap[k][a], n, 200.0 + j * 153.1);
|
||||
for (j = 1; j < 64; j++) { /* (sorted: the median) */
|
||||
double v = s[j];
|
||||
uint32_t q = j;
|
||||
while (q && s[q - 1] > v) { s[q] = s[q - 1]; q--; }
|
||||
s[q] = v;
|
||||
}
|
||||
med = s[32];
|
||||
printf("noise: NZ ARCADE note %3u: clock %8.0f Hz, fundamental %6.0f Hz, %5.1f dB over the median\n", note, clock, f0,
|
||||
20 * log10(m / (med + 1e-9)));
|
||||
if (20 * log10(m / (med + 1e-9)) < 6)
|
||||
weak++;
|
||||
}
|
||||
ok(same == 0, "NZ ARCADE: no two notes (3 semitones apart, C2..F#7) give the same samples");
|
||||
ok(weak == 0, "NZ ARCADE: each note's fundamental (clock / 127) stands 6 dB over the spectrum's median");
|
||||
printf("noise: %d failed\n", fails);
|
||||
return fails;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* PHYS in tune: every pitched factory preset plays its notes at the equal-tempered pitch. The STRING and SYMP models
|
||||
* were sharp: STR PLUCK +20 cents above E5 and +56 below E2, PLUCK BASS +71, BANJO +86, HARPSICH +104 at E1 .. E2
|
||||
* (the loop's damping filter was compensated by twice its lag, the dispersion all-pass by a rule of thumb that grew
|
||||
* with the delay; phys_dsp.c px_string_block).
|
||||
* Pitched: the STRING and SYMP models (plucked strings, the sympathetic ones), and MODAL with a harmonic body
|
||||
* (STRC 32 .. 38: stiffness 0) struck. Not here: MODAL's stiff bodies (bars, bells, blocks: their fundamental is set
|
||||
* off on purpose, Rings' NthHarmonicCompensation), its bowed presets (noise through the same resonators: in tune as
|
||||
* the struck ones, their phase too noisy to measure) and MEMB (drums).
|
||||
* For each preset, notes 28 .. 100 every 4 (velocity 100, the preset's sound without vibrato): the fundamental from
|
||||
* the phase advance of its partial between two windows 0.25 s apart (exact on a synthetic tone: SELF=cents tests the
|
||||
* estimator); fails beyond +-5 cents (env TOL). The strings with a curved bridge (STRING below STRC 31, SYMP with BUZZ:
|
||||
* KOTO, SITAR, TANPURA) bend their pitch as loud as they ring (the bridge shortens the string on the way up, longer on
|
||||
* the way down: Rings' CURVED_BRIDGE, by design: SITAR -16 at E5): +-20 cents for them (BENDTOL); their loop is in tune (+-1 cent
|
||||
* with the bridge straight). ONLY=name measures one preset. Exit status: failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#if CLIPPER_SYNTH
|
||||
#define TAPL mix_l
|
||||
#define TAPR mix_r
|
||||
#else
|
||||
#define TAPL acc[0].l
|
||||
#define TAPR acc[0].r
|
||||
#endif
|
||||
#define W 16384u /* window, samples (0.37 s) */
|
||||
#define D 11025u /* the second window this much later (0.25 s) */
|
||||
#define NX (W + D)
|
||||
static double x[NX];
|
||||
/* the Hann-windowed DFT of x[o .. o + W) at f Hz: re, im */
|
||||
static void dft(uint32_t o, double f, double *re, double *im)
|
||||
{
|
||||
uint32_t i;
|
||||
double r = 0, m = 0, w = 2 * M_PI * f / FS, c = cos(w), s = sin(w), cr = 1, ci = 0;
|
||||
for (i = 0; i < W; i++) {
|
||||
double h = (0.5 - 0.5 * cos(2 * M_PI * i / W)) * x[o + i], t;
|
||||
r += h * cr, m -= h * ci;
|
||||
t = cr * c - ci * s, ci = ci * c + cr * s, cr = t; /* (rotate: e^(j w i)) */
|
||||
}
|
||||
*re = r, *im = m;
|
||||
}
|
||||
/* the fundamental near fe: the strongest of +-80 cents (2-cent steps), then the phase advance over D samples */
|
||||
static double f0_of(double fe)
|
||||
{
|
||||
double best = 0, bf = fe, k, r0, i0, r1, i1, dp;
|
||||
for (k = -80; k <= 80; k += 2) {
|
||||
double ff = fe * pow(2, k / 1200.0), v;
|
||||
dft(0, ff, &r0, &i0);
|
||||
v = r0 * r0 + i0 * i0;
|
||||
if (v > best)
|
||||
best = v, bf = ff;
|
||||
}
|
||||
dft(0, bf, &r0, &i0);
|
||||
dft(D, bf, &r1, &i1);
|
||||
dp = atan2(i1, r1) - atan2(i0, r0) - 2 * M_PI * bf * D / FS; /* = 2 pi (f - bf) D / FS, mod 2 pi */
|
||||
dp -= 2 * M_PI * floor(dp / (2 * M_PI) + 0.5);
|
||||
return bf + dp * FS / (2 * M_PI * D);
|
||||
}
|
||||
static int pitched(const preset_t *pr)
|
||||
{
|
||||
if (pr->e[0] == PM_STRING || pr->e[0] == PM_SYMP)
|
||||
return 1;
|
||||
return pr->e[0] == PM_MODAL && pr->e[1] >= 32 && pr->e[1] <= 38 && !pr->e[6]; /* harmonic, struck */
|
||||
}
|
||||
static int bent(const preset_t *pr) /* a curved bridge (px_string_block: STRUCTURE < 0.24) */
|
||||
{
|
||||
return (pr->e[0] == PM_STRING && pr->e[1] * 516 < 15729) || (pr->e[0] == PM_SYMP && 16384 - pr->e[6] * 129 < 15729);
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
static int32_t o[CTL * 2];
|
||||
const engine_t *en = ENGINES[ENGI_PHYS];
|
||||
double tol = getenv("TOL") ? atof(getenv("TOL")) : 5.0, btol = getenv("BENDTOL") ? atof(getenv("BENDTOL")) : 20.0;
|
||||
uint32_t pi, n, i, b, k, fails = 0;
|
||||
host_tracks_init();
|
||||
if (getenv("SELF")) { /* the estimator on a decaying 3-partial tone */
|
||||
for (n = 28; n <= 100; n += 4) {
|
||||
double fe = 440 * pow(2, ((int)n - 69) / 12.0), ft = fe * pow(2, atof(getenv("SELF")) / 1200);
|
||||
for (i = 0; i < NX; i++) {
|
||||
double t = (i + 4480.0) / FS;
|
||||
x[i] = exp(-t * 3) * (8000 * sin(2 * M_PI * ft * t) + 6000 * sin(2 * M_PI * 2.01 * ft * t + 1) +
|
||||
3000 * sin(2 * M_PI * 3 * ft * t));
|
||||
}
|
||||
printf(" %u:%+.2f", n, 1200 * log2(f0_of(fe) / ft));
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
for (pi = 0; pi < en->npresets; pi++) {
|
||||
const preset_t *pr = &en->presets[pi];
|
||||
double worst = 0, t = bent(pr) ? btol : tol;
|
||||
uint32_t bad = 0, wn = 0;
|
||||
if (!pitched(pr) || (getenv("ONLY") && !strstr(pr->name, getenv("ONLY"))))
|
||||
continue;
|
||||
printf("phys_tune: %-12s", pr->name);
|
||||
for (n = 28; n <= 100; n += 4) {
|
||||
double fe = 440 * pow(2, ((int)n - 69) / 12.0), c;
|
||||
uint32_t any = 1;
|
||||
for (k = 0; k < NPART; k++)
|
||||
trk_all_off(&trk[k]);
|
||||
for (b = 0; b < 6000u && any; b++) { /* the last note rung out */
|
||||
mix_block(o, CTL);
|
||||
for (any = 0, i = 0; i < NVOICE; i++)
|
||||
any |= trk[0].v[i].active;
|
||||
}
|
||||
for (i = 0; i < P_E0; i++) /* the preset as ui.c apply_preset_to loads it (dry) */
|
||||
trk[0].p[i] = TP[i].def;
|
||||
host_preset(&trk[0], ENGI_PHYS, pi);
|
||||
trk[0].p[P_AMODE] = 0, trk[0].p[P_DLY] = trk[0].p[P_REV] = 0, trk[0].p[P_VOICE] = V_POLY;
|
||||
trk[0].p[P_LD_PIT] = 0; /* (no vibrato) */
|
||||
for (b = 0; b < 16; b++)
|
||||
mix_block(o, CTL);
|
||||
trk_note_on(&trk[0], n, 100);
|
||||
for (b = 0; b < 140; b++) /* (0.1 s: the attack) */
|
||||
mix_block(o, CTL);
|
||||
for (b = 0; b < NX / CTL; b++) {
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < CTL; i++)
|
||||
x[b * CTL + i] = (TAPL[i] + TAPR[i]) / 2.0;
|
||||
}
|
||||
trk_note_off(&trk[0], n);
|
||||
c = 1200 * log2(f0_of(fe) / fe);
|
||||
printf(" %3u:%+5.1f", n, c);
|
||||
if (fabs(c) > t)
|
||||
bad++;
|
||||
if (fabs(c) > fabs(worst))
|
||||
worst = c, wn = n;
|
||||
}
|
||||
printf(" %s (worst %+.1f cents at %u%s)\n", bad ? "FAIL" : "ok", worst, wn, bent(pr) ? "; curved bridge: +-20" : "");
|
||||
fails += bad != 0;
|
||||
}
|
||||
printf("phys_tune: %u failed\n", fails);
|
||||
return (int)fails;
|
||||
}
|
||||
+1
-1
@@ -188,7 +188,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
{ /* 7. the delay line at half rate (Clipper): the echo at the delay time, the repeats decaying */
|
||||
static int32_t zero[CTL], din[CTL], wl[CTL], wr[CTL];
|
||||
static int32_t y[FS * 3];
|
||||
static int32_t y[FS * 3 + CTL]; /* (+ CTL: the last block) */
|
||||
uint32_t i, k, dl, first = 0, second = 0;
|
||||
int32_t p1 = 0, p2 = 0;
|
||||
setup(RT_ROOM, 90, 60, 0);
|
||||
|
||||
@@ -61,6 +61,8 @@ $CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/song_audio_test" tests/song_audio
|
||||
run "song: four simultaneous tracks, scene transition and stop" "$OUT/song_audio_test" "$OUT/song-demo.wav"
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/song_ui_test" tests/song_ui_test.c -lm
|
||||
run "song screen: commands, load (OCT+ twice), display bounds" "$OUT/song_ui_test" "$OUT/song-screen.ppm"
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/song_arm_test" tests/song_arm_test.c -lm
|
||||
run "song screen: a confirmation left unconfirmed asks again weeks later (no load / replace on one press)" "$OUT/song_arm_test"
|
||||
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/studio_drums_test" tests/studio_drums_test.c -lm
|
||||
run "drum lanes, kit audio, metronome, record arm, free take" "$OUT/studio_drums_test" "$OUT/drum-styles.wav"
|
||||
@@ -74,6 +76,8 @@ $CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/drum_steal_test" tests/drum_steal
|
||||
run "SLOOP 2.8.3: drum voices on a busy beat, every kit: no kick cut by another sound" "$OUT/drum_steal_test"
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/chop_attack_test" tests/chop_attack_test.c -lm
|
||||
run "SLOOP 2.8.3: a sample played again starts from silence with its ATK (POLY same note, MONO, LEGATO, UNISON), no click" "$OUT/chop_attack_test"
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/fade_noise_test" tests/fade_noise_test.c -lm
|
||||
run "SLOOP Pro #4: a note fading out keeps 16-bit resolution (DAC, MASTER 2048, USB FULL, 808 SLIDE): no 16 LSB floor" "$OUT/fade_noise_test"
|
||||
|
||||
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/drumkit_test" tests/drumkit_test.c -lm
|
||||
run "synthesised drum kits: every kit x sound bounded, audible, finite, levels, cost" "$OUT/drumkit_test" "$OUT/drum-kits.wav" "$OUT/drum-kits.txt"
|
||||
@@ -117,8 +121,12 @@ $SYN -o "$OUT/clipper_ui_test" tests/clipper_ui_test.c -lm
|
||||
run "Clipper synth: HOME, presets, keys, pages, one track, MIDI omni, no drums / song" "$OUT/clipper_ui_test" "$OUT/clipper"
|
||||
$SYN -o "$OUT/clipper_hold_test" tests/hold_rec_test.c -lm
|
||||
run "Clipper synth (SLOOP 2.8.3): a note held under others, POLY and UNI2, live / recorded / overdub / free take, MIDI burst" "$OUT/clipper_hold_test"
|
||||
$SYN -o "$OUT/knob_walk_test" tests/knob_walk_test.c -lm
|
||||
run "Clipper synth (sloop-pro #6): every page, HOME, REC READY: a knob turned alone changes one value" "$OUT/knob_walk_test" "$OUT"
|
||||
$SYN -o "$OUT/clipper_chop_test" tests/chop_attack_test.c -lm
|
||||
run "Clipper synth (SLOOP 2.8.3): a sample played again starts from silence with its ATK, no click" "$OUT/clipper_chop_test"
|
||||
$SYN -o "$OUT/clipper_fade_test" tests/fade_noise_test.c -lm
|
||||
run "Clipper synth (SLOOP Pro #4): a note fading out keeps 16-bit resolution: the mix and MASTER rounded, no 16 LSB floor" "$OUT/clipper_fade_test"
|
||||
$SYN -o "$OUT/clipper_stress" tests/stress_test.c -lm
|
||||
run "Clipper synth: stress (hard random use, clean stop)" "$OUT/clipper_stress" "${STRESS_FRAMES:-40000}"
|
||||
$SYN -o "$OUT/clipper_soak" tests/soak_test.c -lm
|
||||
@@ -157,6 +165,21 @@ fi
|
||||
$SYN -o "$OUT/fmx_test" tests/fmx_test.c -lm
|
||||
mkdir -p build/fmx_demo
|
||||
run "Clipper 0.6 FMX: presets in tune, waves, PM / FM / RING, routing, 40 templates, PEG, bank (FMX and DX7 slots), DX7 converted" "$OUT/fmx_test" build/fmx_demo
|
||||
$SYN -o "$OUT/noise_clock_test" tests/noise_clock_test.c -lm
|
||||
run "NOISE LFSR: the clock follows the keys past the sample rate (NZ ARCADE, clipper-fm1 #10)" "$OUT/noise_clock_test"
|
||||
$SYN -o "$OUT/sample_pitch_test" tests/sample_pitch_test.c -lm
|
||||
run "SAMPLE, GRAIN: the pitch follows the keys to the top of the keyboard (up to the decode bound)" "$OUT/sample_pitch_test"
|
||||
$SYN -o "$OUT/grain_release_test" tests/grain_release_test.c -lm
|
||||
run "GRAIN: a note played in the release of the one before is not starved of grains" "$OUT/grain_release_test"
|
||||
$SYN -o "$OUT/phys_tune_test" tests/phys_tune_test.c -lm
|
||||
run "PHYS: every pitched preset in tune (+-5 cents; a curved bridge +-20), notes 28..100" "$OUT/phys_tune_test"
|
||||
$SYN -o "$OUT/unison_level_test" tests/unison_level_test.c -lm
|
||||
run "UNISON, UNI4: every engine spreads its voices' phases (no stack of voices in phase over POLY)" "$OUT/unison_level_test"
|
||||
$SYN -o "$OUT/fmx_kill_test" tests/fmx_kill_test.c -lm
|
||||
run "FMX: a voice given up (voice budget, overload) and played again starts from rest" "$OUT/fmx_kill_test"
|
||||
$SYN -o "$OUT/model_switch_test" tests/model_switch_test.c -lm
|
||||
run "filter MODEL changed under a held chord (ANALOG, WAVE, VECTOR): no click" "$OUT/model_switch_test"
|
||||
run "the editor protocol and the other inputs (USB / TRS MIDI, damaged flash) fuzzed under ASan + UBSan, and its reproducers" sh tests/editor_fuzz.sh "${EDFZ_N:-2000}" 1
|
||||
if $SYN_UB -o "$OUT/fmx_ub" tests/fmx_test.c -lm 2>/dev/null; then
|
||||
run "Clipper 0.6 FMX under ASan + UBSan" sh -c "'$OUT/fmx_ub' >/dev/null && echo clean"
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* SAMPLE and GRAIN follow the keys to the top of the FM-1's keyboard (OCT +3: note 115). Both bounded their decode
|
||||
* load with a cap on the playback rate (SAMPLE: 3 octaves over the zone's root; GRAIN: 2 source samples an output
|
||||
* sample), so every key past it played the same pitch: Clipper's sets are one 16 kHz zone (VOX's root A3), so SAMPLE
|
||||
* CHOIR was flat from A6 (93) and VOX CLOUD from G6 (87); SLOOP's top zones (root C5) went flat from C8 (108).
|
||||
* For each preset that follows the keys (C4 -> C5 one octave up): each note two semitones over the one before sounds
|
||||
* 1..3 semitones higher (the shift of its log-frequency spectrum, or of its strongest peak, or 4 semitones over the note before it;
|
||||
* no two steps in a row wrong), from C4 to TOP (env TOP, default 115). GRAIN: up to
|
||||
* where a grain would read more than 8 source samples an output sample (its part's decode bound, GR_LOAD_MAX, with the
|
||||
* preset's PTCH and RAND detune), if that comes first: past it a grain's pitch may stop (the cost bound). SAMPLE: up to
|
||||
* where a voice would decode more than 8 source samples an output sample (a 44.1 kHz zone 3 octaves up, the bound it
|
||||
* always had; SMP_STEP_MAX), if that comes first.
|
||||
* Exit status: failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#if CLIPPER_SYNTH
|
||||
#define TAPL mix_l
|
||||
#define TAPR mix_r
|
||||
#else
|
||||
#define TAPL acc[0].l
|
||||
#define TAPR acc[0].r
|
||||
#endif
|
||||
#define N 32768u /* (0.74 s: a cloud of short grains averages out) */
|
||||
#define LB 8 /* log-spectrum bins a semitone */
|
||||
#define LN (128 * LB) /* MIDI 8 .. 136 */
|
||||
static double re_[N], im_[N];
|
||||
static int fails;
|
||||
static void fft(double *re, double *im, uint32_t n)
|
||||
{
|
||||
uint32_t i, j = 0, k, m;
|
||||
for (i = 1; i < n; i++) {
|
||||
uint32_t bit = n >> 1;
|
||||
for (; j & bit; bit >>= 1) j ^= bit;
|
||||
j ^= bit;
|
||||
if (i < j) { double t = re[i]; re[i] = re[j]; re[j] = t; t = im[i]; im[i] = im[j]; im[j] = t; }
|
||||
}
|
||||
for (m = 2; m <= n; m <<= 1) {
|
||||
double a = -2 * M_PI / m;
|
||||
for (k = 0; k < n; k += m)
|
||||
for (i = 0; i < m / 2; i++) {
|
||||
double wr = cos(a * i), wi = sin(a * i);
|
||||
double xr = re[k + i + m / 2] * wr - im[k + i + m / 2] * wi, xi = re[k + i + m / 2] * wi + im[k + i + m / 2] * wr;
|
||||
re[k + i + m / 2] = re[k + i] - xr; im[k + i + m / 2] = im[k + i] - xi;
|
||||
re[k + i] += xr; im[k + i] += xi;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* note k of preset pi: its log spectrum (dB over a -60 dB floor) into ls, returns the rms */
|
||||
static double render(uint32_t e, uint32_t pi, uint32_t note, double *ls)
|
||||
{
|
||||
static int32_t o[CTL * 2];
|
||||
static double x[N], mag[N / 2 + 1];
|
||||
uint32_t i, b, any = 1, k;
|
||||
double s = 0, s2 = 0, mx = 1e-9;
|
||||
for (k = 0; k < NPART; k++)
|
||||
trk_all_off(&trk[k]);
|
||||
for (b = 0; b < 3000u && any; b++) { /* the last note's release */
|
||||
mix_block(o, CTL);
|
||||
for (any = 0, i = 0; i < NVOICE; i++)
|
||||
any |= trk[0].v[i].active;
|
||||
}
|
||||
for (i = 0; i < P_E0; i++) /* the preset as ui.c apply_preset_to loads it (dry) */
|
||||
trk[0].p[i] = TP[i].def;
|
||||
host_preset(&trk[0], e, pi);
|
||||
trk[0].p[P_AMODE] = 0;
|
||||
trk[0].p[P_DLY] = trk[0].p[P_REV] = 0;
|
||||
trk[0].p[P_VOICE] = V_POLY;
|
||||
for (b = 0; b < 16; b++)
|
||||
mix_block(o, CTL);
|
||||
trk_note_on(&trk[0], note, 100);
|
||||
for (b = 0; b < 140; b++) /* (0.1 s: the attack) */
|
||||
mix_block(o, CTL);
|
||||
for (b = 0; b < N / CTL; b++) {
|
||||
mix_block(o, CTL);
|
||||
for (i = 0; i < CTL; i++)
|
||||
x[b * CTL + i] = (TAPL[i] + TAPR[i]) / 2.0;
|
||||
}
|
||||
trk_note_off(&trk[0], note);
|
||||
for (i = 0; i < N; i++)
|
||||
s += x[i];
|
||||
for (i = 0; i < N; i++) {
|
||||
double v = x[i] - s / N;
|
||||
s2 += v * v;
|
||||
re_[i] = v * (0.5 - 0.5 * cos(2 * M_PI * i / N));
|
||||
im_[i] = 0;
|
||||
}
|
||||
fft(re_, im_, N);
|
||||
for (i = 0; i <= N / 2; i++)
|
||||
mag[i] = sqrt(re_[i] * re_[i] + im_[i] * im_[i]);
|
||||
for (i = 0; i < LN; i++) { /* the strongest bin within each 1/8 semitone */
|
||||
double f0 = 440.0 * pow(2, ((double)i / LB + 8 - 0.5 / LB - 69) / 12), f1 = f0 * pow(2, 1.0 / (12 * LB));
|
||||
double b0 = f0 * N / FS, b1 = f1 * N / FS, v = 0;
|
||||
uint32_t a = (uint32_t)b0, c;
|
||||
if (b1 >= N / 2) {
|
||||
ls[i] = 0;
|
||||
continue;
|
||||
}
|
||||
if (b1 - b0 < 1) {
|
||||
double fr = (b0 + b1) / 2 - a;
|
||||
v = mag[a] * (1 - fr) + mag[a + 1] * fr;
|
||||
} else
|
||||
for (c = a; c <= (uint32_t)b1; c++)
|
||||
if (mag[c] > v)
|
||||
v = mag[c];
|
||||
ls[i] = v;
|
||||
if (v > mx)
|
||||
mx = v;
|
||||
}
|
||||
for (i = 0; i < LN; i++) {
|
||||
double d = 20 * log10(ls[i] / mx + 1e-9) + 60;
|
||||
ls[i] = d > 0 ? d : 0;
|
||||
}
|
||||
return sqrt(s2 / N);
|
||||
}
|
||||
/* GRAIN: source samples an output sample a grain of the note reads at most (PTCH, the RAND detune at its top), Q16 */
|
||||
static double grain_rate(uint32_t pi, uint32_t note)
|
||||
{
|
||||
const preset_t *pr = &ENGINES[ENGI_GRAIN]->presets[pi];
|
||||
uint32_t src = (uint32_t)pr->e[0] % SMP_NALL;
|
||||
int32_t zl = gr_find(src, note);
|
||||
const smp_zone_t *z;
|
||||
double d16;
|
||||
if (zl < 0)
|
||||
return 0;
|
||||
z = gr_zone(src, (uint32_t)zl);
|
||||
d16 = note * 16.0 + pr->e[4] * 16 - z->root16 + pr->e[6] * pr->e[6] * 192.0 / (127 * 127);
|
||||
return pow(2, d16 / 192) * z->rate / 65536.0;
|
||||
}
|
||||
/* SAMPLE: the playback rate of the note (source samples an output sample) and its cap (eng_sample.c sample_render) */
|
||||
static int sample_capped(uint32_t pi, uint32_t note)
|
||||
{
|
||||
const preset_t *pr = &ENGINES[4]->presets[pi];
|
||||
uint32_t si = (uint32_t)pr->e[0] % SMP_NALL, i;
|
||||
const smp_zone_t *z = 0;
|
||||
double rate, lim;
|
||||
if (si >= SMP_NSETS)
|
||||
return 0;
|
||||
for (i = 0; i < SMP_SETS[si].nz; i++)
|
||||
if (note >= SMP_ZONES[SMP_SETS[si].z0 + i].lo && note <= SMP_ZONES[SMP_SETS[si].z0 + i].hi)
|
||||
z = &SMP_ZONES[SMP_SETS[si].z0 + i];
|
||||
if (!z)
|
||||
z = &SMP_ZONES[SMP_SETS[si].z0];
|
||||
rate = pow(2, (note * 16.0 + pr->e[1] * 16 - z->root16) / 192) * z->rate / 65536.0;
|
||||
lim = 8.0 * z->rate / 65536.0;
|
||||
return rate > (lim > (double)(SMP_STEP_MAX >> 16) ? lim : (double)(SMP_STEP_MAX >> 16));
|
||||
}
|
||||
/* how far b's spectrum lies over a's, in semitones (-4 .. +14) */
|
||||
static double shift(const double *a, const double *b)
|
||||
{
|
||||
int s, i, best = 0;
|
||||
double bv = -1;
|
||||
for (s = -4 * LB; s <= 14 * LB; s++) {
|
||||
double ab = 0, aa = 0, bb = 0;
|
||||
for (i = 0; i < LN; i++) {
|
||||
int j = i + s;
|
||||
double y = j >= 0 && j < LN ? b[j] : 0;
|
||||
ab += a[i] * y, aa += a[i] * a[i], bb += y * y;
|
||||
}
|
||||
if (aa > 0 && bb > 0 && ab / sqrt(aa * bb) > bv)
|
||||
bv = ab / sqrt(aa * bb), best = s;
|
||||
}
|
||||
return (double)best / LB;
|
||||
}
|
||||
/* the same from the strongest peak alone (a second opinion: either one right is enough) */
|
||||
static double peak_shift(const double *a, const double *b)
|
||||
{
|
||||
int i, ia = 0, ib = 0;
|
||||
for (i = 1; i < LN; i++) {
|
||||
if (a[i] > a[ia])
|
||||
ia = i;
|
||||
if (b[i] > b[ib])
|
||||
ib = i;
|
||||
}
|
||||
return (double)(ib - ia) / LB;
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
static const uint32_t EN[2] = {4, ENGI_GRAIN}; /* SAMPLE, GRAIN */
|
||||
static double l0[LN], l1[LN], lp[LN]; /* notes n, n + 2, n - 2 */
|
||||
uint32_t top = getenv("TOP") ? (uint32_t)atoi(getenv("TOP")) : 115u, k, pi, n;
|
||||
host_tracks_init();
|
||||
for (k = 0; k < 2u; k++) {
|
||||
const engine_t *en = ENGINES[EN[k]];
|
||||
for (pi = 0; pi < en->npresets; pi++) {
|
||||
double r60 = render(EN[k], pi, 60, l0), r72 = render(EN[k], pi, 72, l1), sh = shift(l0, l1), r;
|
||||
uint32_t bad = 0, first = 0, tested = 0, run = 0, runs = 0; /* runs: two wrong steps in a row (one alone:
|
||||
* a grain cloud's spectrum can fool the estimate once) */
|
||||
if (r60 < 30 || r72 < 30 || sh < 11 || sh > 13) {
|
||||
printf("pitch: %-6s %-14s C4 -> C5: %+5.2f semitones: does not follow the keys (a kit), not tested\n",
|
||||
en->name, en->presets[pi].name, sh);
|
||||
continue;
|
||||
}
|
||||
r = render(EN[k], pi, 60, l0);
|
||||
memcpy(lp, l0, sizeof lp);
|
||||
for (n = 60; n + 2u <= top; n += 2u) {
|
||||
double r1, d;
|
||||
if (EN[k] == ENGI_GRAIN && grain_rate(pi, n + 2u) > 8.0) {
|
||||
printf("pitch: %-6s %-14s from note %u: past the grain decode bound, not tested\n", en->name, en->presets[pi].name, n + 2u);
|
||||
break;
|
||||
}
|
||||
if (EN[k] == 4u && sample_capped(pi, n + 2u)) {
|
||||
printf("pitch: %-6s %-14s from note %u: past the decode bound, not tested\n", en->name, en->presets[pi].name, n + 2u);
|
||||
break;
|
||||
}
|
||||
r1 = render(EN[k], pi, n + 2u, l1);
|
||||
if (r > r60 / 30 && r1 > r60 / 30) {
|
||||
d = shift(l0, l1);
|
||||
tested++;
|
||||
if (d < 1.0 || d > 3.0)
|
||||
d = peak_shift(l0, l1);
|
||||
if ((d < 1.0 || d > 3.0) && n > 60u) { /* (a noisy cloud: n - 2 -> n + 2 is 4 semitones) */
|
||||
double d4 = shift(lp, l1), p4 = peak_shift(lp, l1);
|
||||
if ((d4 >= 2.5 && d4 <= 5.5) || (p4 >= 2.5 && p4 <= 5.5))
|
||||
d = 2.0;
|
||||
}
|
||||
if (d < 1.0 || d > 3.0) {
|
||||
if (!bad++)
|
||||
first = n;
|
||||
if (bad <= 4)
|
||||
printf("pitch: %-6s %-14s note %3u -> %3u: %+5.2f semitones\n", en->name, en->presets[pi].name, n, n + 2u, d);
|
||||
runs += ++run >= 2u;
|
||||
} else {
|
||||
run = 0;
|
||||
}
|
||||
}
|
||||
memcpy(lp, l0, sizeof lp);
|
||||
memcpy(l0, l1, sizeof l0);
|
||||
r = r1;
|
||||
}
|
||||
printf("pitch: %-6s %-14s C4..%u, %2u steps of 2 semitones: %s", en->name, en->presets[pi].name, n < top ? n : top, tested,
|
||||
runs ? "FAIL" : "ok");
|
||||
if (bad)
|
||||
printf(" (%u wrong, %u in a row, the first from note %u)", bad, runs, first);
|
||||
printf("\n");
|
||||
fails += runs != 0;
|
||||
}
|
||||
}
|
||||
printf("pitch: %d failed\n", fails);
|
||||
return fails;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* The song screen's confirmations (ui_song.c): OCT+ (load) and REC over a used section (replace) ask for a second
|
||||
* press within 3 s. The arm was compared with a deadline as a signed difference: one left unconfirmed read as still
|
||||
* armed 24.9 to 49.7 days later (a single press loaded or replaced a section). Now the time since the arm.
|
||||
* Exit status: failed checks. */
|
||||
#define FELUCCA_ARRANGER 1
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
static uint16_t screen[240*240];
|
||||
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)
|
||||
{
|
||||
uint32_t i,j;
|
||||
assert(x+w<=240 && y+h<=240);
|
||||
for(j=0;j<h;j++) for(i=0;i<w;i++) screen[(y+j)*240+x+i]=p[j*w+i];
|
||||
}
|
||||
#include "../firmware/src/gfx.c"
|
||||
enum {B_FX,B_SCL,B_ENV,B_LFO,B_EDIT,B_GLO,B_HOME,B_SAVE,B_ARP,B_SEQ,B_PLAY,B_REC,B_OCTDN,B_OCTUP,NB};
|
||||
enum {EN_SELECT,EN_ALGO,EN_PRESET,EN_K1,EN_K2,EN_K3,EN_K4,NE};
|
||||
static struct {uint8_t btn[NB];} panel;
|
||||
static struct {uint8_t home,page,force,msg_t;char msg[24];} ui;
|
||||
static int32_t enc[NE];
|
||||
static uint32_t ready, scene_saves, order_saves, loads;
|
||||
static uint32_t arrangement_ready(void) {return ready;}
|
||||
static void arrangement_apply(uint32_t scene) {(void)scene;}
|
||||
static uint32_t section_bars(uint32_t s) {(void)s;return 1;}
|
||||
static const page_t *cur_page(void) {return &PAGES[ui.page];}
|
||||
static int project_used(uint32_t i) {return (ready>>i)&1u;}
|
||||
static void project_save(uint32_t i) {ready|=1u<<i;scene_saves++;}
|
||||
static void project_load(uint32_t i) {(void)i;loads++;}
|
||||
static void settings_save(void) {}
|
||||
static void arrangement_save(void) {order_saves++;}
|
||||
static void ui_message(const char *s) {str_cpy(ui.msg,s,sizeof ui.msg);ui.msg_t=40;}
|
||||
static void go_home(void) {ui.home=1;}
|
||||
static void open_family(uint32_t f) {(void)f;ui.home=1;}
|
||||
static int32_t panel_enc(uint32_t i) {int32_t s=enc[i];enc[i]=0;return s;}
|
||||
static void song_backup(void) {}
|
||||
static void song_restore(void) {}
|
||||
#include "../firmware/src/ui_song.c"
|
||||
static void press(uint32_t b) {song_screen_input(1u<<panel.btn[b],0);}
|
||||
int main(void)
|
||||
{
|
||||
uint32_t i, fails = 0, s0, l0;
|
||||
arr_defaults(&arrangement);
|
||||
for(i=0;i<NB;i++) panel.btn[i]=(uint8_t)i;
|
||||
for(i=0;i<NPAGES;i++) if(PAGES[i].scope==SC_SONG) ui.page=(uint8_t)i;
|
||||
ready = 1; /* section A saved */
|
||||
fm1_ms = 1000000u;
|
||||
press(B_OCTUP); /* "OCT+ AGAIN: LOAD", then left */
|
||||
fm1_ms += 0x80000000u + 5000u; /* 24.9 days later */
|
||||
l0 = loads;
|
||||
press(B_OCTUP); /* one press: must ask again, not load */
|
||||
printf("song_arm: OCT+ once, 24.9 days after an OCT+ left unconfirmed: %s (%s)\n", loads == l0 ? "asks again" : "LOADED at once", ui.msg);
|
||||
fails += loads != l0;
|
||||
press(B_OCTDN); /* (no arm left: LOOP / SONG MODE toggled) */
|
||||
s0 = scene_saves;
|
||||
fm1_ms = 2000000u;
|
||||
press(B_REC); /* "REC AGAIN: REPLACE", then left */
|
||||
fm1_ms += 0x80000000u + 5000u;
|
||||
press(B_REC); /* one press: must ask again, not replace */
|
||||
printf("song_arm: REC once, 24.9 days after a REC left unconfirmed: %s (%s)\n", scene_saves == s0 ? "asks again" : "REPLACED at once", ui.msg);
|
||||
fails += scene_saves != s0;
|
||||
return (int)fails;
|
||||
}
|
||||
+28
-9
@@ -11,10 +11,10 @@
|
||||
* REVERB ROOM, PLATE, HALL, SHIMMER: bounded, dying away; HALL longer than PLATE; SHIMMER an octave up in its tail
|
||||
* DELAY PING: the first echo left (TIME), the second right (2 x TIME); TAPE: bounded at full feedback, its echoes
|
||||
* swung (not MONO's); a change of MODE under a sounding line: no click
|
||||
* STORE projects (every 1.0 value of both sounds, the delay's MODE; with track 3's steps there: their defaults, the
|
||||
* steps' nudges kept; a 0.9 project: the defaults); user presets (every value back, the sources 16..19 of
|
||||
* slots 1..6 by their fifth bit; the record SLOOP reads the same with or without the 1.0 values; no tail:
|
||||
* the defaults)
|
||||
* STORE projects (every 1.0 value of both sounds, the delay's MODE; with track 3's steps there: kept beside the
|
||||
* project, the steps' nudges kept; saved so by 1.0 .. 1.2: their defaults; a 0.9 project: the defaults);
|
||||
* user presets (every value back, the sources 16..19 of slots 1..6 by their fifth bit; the record SLOOP
|
||||
* reads the same with or without the 1.0 values; no tail: the defaults)
|
||||
* PAGES VOICE 3, LFO 3, ENV 2 LOOP, MACROS, DLY 2, the matrix's slots 7..12
|
||||
* FIX the JUNO chorus on a loud chord (8 voices at 127): no crack */
|
||||
#define main hostsim_main
|
||||
@@ -578,14 +578,33 @@ static void t_store(void)
|
||||
"project: every 1.0 value of both sounds and the delay's MODE kept (track 3's nudges: none), the size unchanged");
|
||||
trk[2].step[5].n = 1, trk[2].step[5].note[0] = 60, trk[2].micro[5] = -7;
|
||||
proj_capture(&pj);
|
||||
proj_apply(&pj, 1);
|
||||
for (i = P_SPREAD; i < P_E0; i++)
|
||||
dflt &= a->p[i] == TP[i].def && b->p[i] == TP[i].def;
|
||||
ok(dflt && trk[2].micro[5] == -7 && trk[2].step[5].n == 1 && song.g[G_DMODE] == DM_MONO,
|
||||
"project: track 3 with steps: its nudges kept, the 1.0 values at their defaults");
|
||||
{ /* (after 1.2) track 3 with steps (a SLOOP project's): its nudges stay its own in the project, the 1.0 values
|
||||
* beside it (project.c proj_x10_t: the side record in flash, object 14 in a backup) */
|
||||
uint32_t own = pj.t[2].micro[5] == -7;
|
||||
for (i = 0; i < NSTEP; i++)
|
||||
own &= i == 5u || pj.t[2].micro[i] == 0;
|
||||
for (i = P_SPREAD; i < P_E0; i++)
|
||||
a->p[i] = b->p[i] = TP[i].def;
|
||||
song.g[G_DMODE] = DM_MONO;
|
||||
proj_apply(&pj, 1);
|
||||
same = own;
|
||||
for (i = P_SPREAD; i < P_E0; i++)
|
||||
same &= a->p[i] == va[i] && b->p[i] == vb[i];
|
||||
ok(same && trk[2].micro[5] == -7 && trk[2].step[5].n == 1 && song.g[G_DMODE] == DM_TAPE,
|
||||
"project: track 3 with steps: its nudges kept as they are, every 1.0 value and the MODE kept (beside the project)");
|
||||
memset(&proj_x10s[proj_x10_at(&pj)], 0, sizeof proj_x10s[0]); /* (a project of 1.0 .. 1.2: nothing beside it) */
|
||||
for (i = P_SPREAD; i < P_E0; i++)
|
||||
a->p[i] = va[i];
|
||||
proj_apply(&pj, 1);
|
||||
for (i = P_SPREAD; i < P_E0; i++)
|
||||
dflt &= a->p[i] == TP[i].def && b->p[i] == TP[i].def;
|
||||
ok(dflt && trk[2].micro[5] == -7 && song.g[G_DMODE] == DM_MONO,
|
||||
"project: track 3 with steps, saved by 1.0 .. 1.2 (nothing beside it): its nudges kept, the 1.0 values at their defaults");
|
||||
}
|
||||
trk[2].step[5].n = 0, trk[2].micro[5] = 0;
|
||||
proj_capture(&pj);
|
||||
memset(pj.t[2].micro, 0, sizeof pj.t[2].micro); /* (as 0.9 wrote it) */
|
||||
memset(&proj_x10s[proj_x10_at(&pj)], 0, sizeof proj_x10s[0]);
|
||||
for (i = P_SPREAD; i < P_E0; i++)
|
||||
a->p[i] = va[i];
|
||||
proj_apply(&pj, 1);
|
||||
|
||||
@@ -33,7 +33,10 @@ static void lcd_fill(uint32_t x,uint32_t y,uint32_t w,uint32_t h,uint16_t c)
|
||||
static int32_t encs[7];
|
||||
static uint32_t fm1_ticks(void) { return fm1_ms * 1000u * 24u; }
|
||||
#define FM1_TICKS_PER_US 24u
|
||||
static int32_t fm1_enc_take(uint32_t e) { int32_t s = encs[e]; encs[e] = 0; return s; }
|
||||
static int32_t enc_late[7]; /* a detent the timer ISR counts just after a read (as on the FM-1, where the
|
||||
* scan runs while a UI pass does): it lands in the same pass
|
||||
* (tests/knob_walk_test.c) */
|
||||
static int32_t fm1_enc_take(uint32_t e) { int32_t s = encs[e]; encs[e] = enc_late[e]; enc_late[e] = 0; return s; }
|
||||
static uint8_t fm1_led[16], fm1_led_dim[16], fm1_led_bg[16];
|
||||
static volatile uint16_t fm1_led_bg_ns;
|
||||
#define FM1_NCOL 16u
|
||||
@@ -934,7 +937,7 @@ int main(int argc, char **argv)
|
||||
{ int16_t bpm = song.g[G_BPM], lv = trk[0].p[P_LEVEL];
|
||||
encs[panel.enc[EN_K2]] = 5; frame();
|
||||
check(trk[0].p[P_LEVEL] == lv && song.g[G_BPM] == bpm, "visualiser: KNOB 2 (the hidden TRACKS screen) edits nothing, SELECT is not the tempo"); }
|
||||
press(B_GLO); frames(40); /* (held past a tap) */
|
||||
press(B_GLO); frames(70); /* (held past a tap: 1 s, clipper-fm1 #24) */
|
||||
check(ui.layer == LY_MIX, "visualiser: a layer held shows its screen");
|
||||
release(B_GLO); frames(4);
|
||||
check(vis_shown(), "visualiser: ... and it comes back");
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* VOICE = UNISON (and UNI2 / UNI4) about as loud as POLY, on every engine. Unison starts its extra voices at random
|
||||
* phases (voice.c unison_spread) and at a lower level (the velocity: about the same sum). In phase they stack: 8
|
||||
* voices at 0.36 are +9 dB over one. unison_spread moved ph[0] only, and most engines keep more oscillators (ph[1],
|
||||
* ph[2], operators, a wave sequence's step, a sample's read position): their voices stacked in phase (ANALOG SINE PAD
|
||||
* +13.7 dB, PHASE CZ CHOIR +12.8, FMX +11 .. +15, MACRO CHORD / SWARM +13, SAMPLE +7.6 on average). Each engine now
|
||||
* spreads all of its oscillators by the same time shift (their relative phases, the timbre, as they were); SAMPLE
|
||||
* starts a voice up to four periods later (silence first; at most 256 source samples). FM6 scales UNI4 / UNI2 as
|
||||
* UNISON (its operators' levels ignore the velocity when their KVS is 0: UNI4 was +6 dB at random phases, +12 in phase).
|
||||
* For every preset of every engine, notes 36 and 60 (velocity 100, chorus, delay, reverb off): the rms over
|
||||
* 0.05 .. 0.55 s in UNISON (8 voices, the preset's DETUNE) and in UNI4 (Clipper) against POLY. Fails when a render is
|
||||
* more than +8 dB over POLY or an engine's mean over +5 dB. Exit status: failed checks. */
|
||||
#define main hostsim_main
|
||||
#include "hostsim.c"
|
||||
#undef main
|
||||
#if CLIPPER_SYNTH
|
||||
#define TAPL mix_l
|
||||
#define TAPR mix_r
|
||||
#else
|
||||
#define TAPL acc[0].l
|
||||
#define TAPR acc[0].r
|
||||
#endif
|
||||
static int32_t o[CTL * 2];
|
||||
static double play(uint32_t e, uint32_t p, uint32_t mode, uint32_t note)
|
||||
{
|
||||
uint32_t i, b, k, any = 1;
|
||||
double s2 = 0;
|
||||
for (k = 0; k < NPART; k++)
|
||||
trk_all_off(&trk[k]);
|
||||
for (b = 0; b < 6000u && any; b++) { /* the last note rung out */
|
||||
mix_block(o, CTL);
|
||||
for (any = 0, i = 0; i < NVOICE; i++)
|
||||
any |= trk[0].v[i].active;
|
||||
}
|
||||
for (i = 0; i < P_E0; i++) /* the preset as ui.c apply_preset_to loads it */
|
||||
trk[0].p[i] = TP[i].def;
|
||||
host_preset(&trk[0], e, p);
|
||||
trk[0].p[P_AMODE] = 0, trk[0].p[P_DLY] = trk[0].p[P_REV] = 0, trk[0].p[P_CHOR] = 0;
|
||||
trk[0].p[P_VOICE] = (int16_t)mode;
|
||||
for (b = 0; b < 16; b++)
|
||||
mix_block(o, CTL);
|
||||
trk_note_on(&trk[0], note, 100);
|
||||
for (b = 0; b < 760; b++) {
|
||||
mix_block(o, CTL);
|
||||
if (b >= 69)
|
||||
for (i = 0; i < CTL; i++) {
|
||||
double x = (TAPL[i] + TAPR[i]) / 2.0;
|
||||
s2 += x * x;
|
||||
}
|
||||
}
|
||||
trk_note_off(&trk[0], note);
|
||||
return sqrt(s2 / ((760 - 69) * CTL));
|
||||
}
|
||||
#if CLIPPER_SYNTH
|
||||
#define NM 2u
|
||||
static const uint32_t MODE[NM] = { V_UNISON, V_PUNI4 };
|
||||
static const char *const MN[NM] = { "UNISON", "UNI4" };
|
||||
#else
|
||||
#define NM 1u
|
||||
static const uint32_t MODE[NM] = { V_UNISON };
|
||||
static const char *const MN[NM] = { "UNISON" };
|
||||
#endif
|
||||
/* engine e: in each unison mode, the mean unison / POLY ratio (dB) of its presets at notes 36 and 60 */
|
||||
static void engine(uint32_t e, int *fails)
|
||||
{
|
||||
const engine_t *en = ENGINES[e];
|
||||
uint32_t p, k, m, n = 0;
|
||||
double sum[NM][2], worst[NM], mean;
|
||||
const char *wn[NM];
|
||||
for (m = 0; m < NM; m++)
|
||||
sum[m][0] = sum[m][1] = 0, worst[m] = -99, wn[m] = "";
|
||||
for (p = 0; p < en->npresets; p++, n++)
|
||||
for (k = 0; k < 2u; k++) {
|
||||
uint32_t note = k ? 60u : 36u;
|
||||
double r0 = play(e, p, V_POLY, note);
|
||||
for (m = 0; m < NM; m++) {
|
||||
double d = 20 * log10((play(e, p, MODE[m], note) + 1) / (r0 + 1));
|
||||
if (d > 8.0) {
|
||||
printf("unison: %-7s %-6s %-14s note %u: %+.1f dB over POLY FAIL\n", en->name, MN[m],
|
||||
en->presets[p].name, note, d);
|
||||
++*fails;
|
||||
}
|
||||
if (d > worst[m])
|
||||
worst[m] = d, wn[m] = en->presets[p].name;
|
||||
sum[m][k] += d;
|
||||
}
|
||||
}
|
||||
for (m = 0; n && m < NM; m++) {
|
||||
mean = (sum[m][0] + sum[m][1]) / (2 * n);
|
||||
printf("unison: %-7s %-6s mean %+5.1f dB over POLY (note 36 %+5.1f, 60 %+5.1f; %3u presets; the most %+5.1f, %s)%s\n",
|
||||
en->name, MN[m], mean, sum[m][0] / n, sum[m][1] / n, n, worst[m], wn[m], mean > 5.0 ? " FAIL" : "");
|
||||
if (mean > 5.0)
|
||||
++*fails;
|
||||
}
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
int fails = 0;
|
||||
uint32_t e;
|
||||
host_tracks_init();
|
||||
for (e = 0; e < NENGINES; e++)
|
||||
engine(e, &fails);
|
||||
printf("unison: %d failed\n", fails);
|
||||
return fails;
|
||||
}
|
||||
+12
-12
@@ -1,18 +1,18 @@
|
||||
# Clipper: publish the release on GitHub, from this folder (PUBLISH-GITHUB.bat).
|
||||
# 1. the source: clipper-1.2.bundle -> the repository OWNER/REPO (created if it does not exist), branch main, the tag
|
||||
# 2. the release v1.2 (the latest): docs/release-1.2.md, the firmware package (if INSTALL-CLIPPER.bat built it),
|
||||
# 1. the source: clipper-1.3.bundle -> the repository OWNER/REPO (created if it does not exist), branch main, the tag
|
||||
# 2. the release v1.3 (the latest): docs/release-1.3.md, the firmware package (if INSTALL-CLIPPER.bat built it),
|
||||
# the demo WAV
|
||||
# 3. the installer and the editor on GitHub Pages (branch gh-pages, from build\clipper-site)
|
||||
# Uses your own Git and GitHub CLI (gh) and your own GitHub login. Nothing is ever forced on main: a repository that
|
||||
# already has another history stops the script. gh-pages is generated: it is replaced each time.
|
||||
param([string]$Owner = "", [string]$Repo = "clipper-fm1", [string]$Tag = "v1.2")
|
||||
param([string]$Owner = "", [string]$Repo = "clipper-fm1", [string]$Tag = "v1.3")
|
||||
$ErrorActionPreference = 'Continue'
|
||||
Set-Location (Split-Path $PSScriptRoot)
|
||||
function Fail([string]$m) { Write-Host ""; Write-Host "ERROR: $m" -ForegroundColor Red; exit 1 }
|
||||
function Step([string]$m) { Write-Host "== $m" -ForegroundColor Cyan }
|
||||
|
||||
Write-Host ""
|
||||
Write-Host " C L I P P E R 1.2 -> GitHub" -ForegroundColor White
|
||||
Write-Host " C L I P P E R 1.3 -> GitHub" -ForegroundColor White
|
||||
Write-Host " ---- ---- ---- ----" -ForegroundColor DarkGray
|
||||
# Git and GitHub CLI: on the PATH, else where their installers put them, else installed now with winget (asked first)
|
||||
function Find-Tool([string]$t) {
|
||||
@@ -52,7 +52,7 @@ if (-not $Owner) { $Owner = "$(gh api user --jq .login)".Trim() }
|
||||
if (-not $Owner) { Fail "could not read your GitHub user name" }
|
||||
$full = "$Owner/$Repo"
|
||||
$pages = "https://$Owner.github.io/$Repo"
|
||||
$bundle = "clipper-1.2.bundle"
|
||||
$bundle = "clipper-1.3.bundle"
|
||||
if (-not (Test-Path $bundle)) { Fail "$bundle not found in this folder" }
|
||||
$work = Join-Path "build" "publish"
|
||||
$repoDir = Join-Path $work "repo"
|
||||
@@ -82,13 +82,13 @@ if ($LASTEXITCODE -ne 0) {
|
||||
if ("$(git ls-remote --tags origin "refs/tags/$Tag")".Trim()) {
|
||||
Write-Host " (the tag $Tag is already on GitHub: kept as it is)" -ForegroundColor DarkGray
|
||||
} else {
|
||||
git -c user.name="$Owner" -c user.email="$email" tag -a $Tag -m "Clipper 1.2"
|
||||
git -c user.name="$Owner" -c user.email="$email" tag -a $Tag -m "Clipper 1.3"
|
||||
git push origin $Tag
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; Fail "pushing the tag $Tag" }
|
||||
}
|
||||
$notes = Join-Path (Resolve-Path "..").Path "release-notes.md"
|
||||
$src = Join-Path "docs" "release-1.2.md"
|
||||
if (-not (Test-Path $src)) { Pop-Location; Fail "docs/release-1.2.md is missing from the bundle (an older bundle?)" }
|
||||
$src = Join-Path "docs" "release-1.3.md"
|
||||
if (-not (Test-Path $src)) { Pop-Location; Fail "docs/release-1.3.md is missing from the bundle (an older bundle?)" }
|
||||
$text = (Get-Content -Raw -Encoding UTF8 $src).Replace("https://isod89.github.io/clipper-fm1", $pages).Replace("isod89/clipper-fm1", $full)
|
||||
[IO.File]::WriteAllText($notes, $text, (New-Object Text.UTF8Encoding $false)) # (no BOM: GitHub shows the text as it is)
|
||||
Pop-Location
|
||||
@@ -100,16 +100,16 @@ $fw = Get-ChildItem (Join-Path (Join-Path $site "firmware") "clipper-*.fwsc") -E
|
||||
if ($fw) { $assets += $fw.FullName }
|
||||
else { Write-Host "(No firmware built: run INSTALL-CLIPPER.bat first. The release is published without the .fwsc; run this script again afterwards to add it.)" -ForegroundColor Yellow }
|
||||
$ed = Join-Path (Join-Path (Join-Path $site "webapp") "editor") "clipper-editor.html" # (1.2) the editor in one file, for offline use
|
||||
if (Test-Path $ed) { $edc = Join-Path $work "clipper-editor-1.2.html"; Copy-Item $ed $edc; $assets += (Resolve-Path $edc).Path }
|
||||
if (Test-Path $ed) { $edc = Join-Path $work "clipper-editor-1.3.html"; Copy-Item $ed $edc; $assets += (Resolve-Path $edc).Path }
|
||||
if (Test-Path "clipper-1.0-demo.wav") { $assets += (Resolve-Path "clipper-1.0-demo.wav").Path }
|
||||
gh release view $Tag --repo $full *> $null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Step "The release $Tag exists: updating its notes and files"
|
||||
gh release edit $Tag --repo $full --prerelease=false --latest --title "Clipper 1.2" --notes-file $notes
|
||||
gh release edit $Tag --repo $full --prerelease=false --latest --title "Clipper 1.3" --notes-file $notes
|
||||
if ($assets.Count -gt 0) { gh release upload $Tag @assets --repo $full --clobber }
|
||||
} else {
|
||||
Step "Creating the release $Tag"
|
||||
gh release create $Tag @assets --repo $full --latest --title "Clipper 1.2" --notes-file $notes
|
||||
gh release create $Tag @assets --repo $full --latest --title "Clipper 1.3" --notes-file $notes
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { Fail "the release $Tag" }
|
||||
|
||||
@@ -124,7 +124,7 @@ if (Test-Path (Join-Path (Join-Path (Join-Path $site "webapp") "installer") "ind
|
||||
git init --quiet
|
||||
git checkout --quiet -b gh-pages
|
||||
git add -A
|
||||
git -c user.name="$Owner" -c user.email="$email" commit --quiet -m "Clipper 1.2: the installer and the editor"
|
||||
git -c user.name="$Owner" -c user.email="$email" commit --quiet -m "Clipper 1.3: the installer and the editor"
|
||||
git push --force "https://github.com/$full.git" gh-pages
|
||||
$ok = $LASTEXITCODE -eq 0
|
||||
Pop-Location
|
||||
|
||||
+4
-3
@@ -2044,8 +2044,9 @@ function b64dec(s) {
|
||||
/* object ids (firmware editor.c ED_BK_IDS): 0 the working project, 1 the settings, 2..5 projects A..D,
|
||||
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] };
|
||||
file without it restores fine, a v8 device gets no object 8 sent; 9 = the SYN drum kits, firmware v10, likewise;
|
||||
Clipper: 12 / 13 the user presets' side records / tails after 6, 7; 14 the projects' 1.0 blocks after 0 and 2..5) */
|
||||
const BK = { FORMAT: "sloop-backup", VERSION: 1, SAMPLES: [32, 33, 34, 35], RESTORE: [6, 7, 12, 13, 8, 9, 2, 3, 4, 5, 0, 14, 1] };
|
||||
class BackupError extends Error { constructor(code, msg) { super(msg); this.code = code; } }
|
||||
/* read everything; progress(done, total bytes) */
|
||||
async function backupCapture(rq, info, progress = () => {}) {
|
||||
@@ -2097,7 +2098,7 @@ async function backupRestore(rq, file, progress = () => {}) {
|
||||
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
|
||||
if ((r.rc === 1 || r.rc === 5) && (id === 8 || id === 9 || id === 12 || id === 13 || id === 14)) 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) throw new BackupError("bkWrite", `begin ${id} rc ${r.rc}`);
|
||||
for (let off = 0; off < d.length; off += 256) {
|
||||
|
||||
+23
-3
@@ -32,13 +32,33 @@ export const STOCK_V15_SHA256 = "db1642b2b6fa5c2cccb11ffd13878068bb28601678d3644
|
||||
export const STOCK_V15_SIZE = 699956;
|
||||
export const STOCK_V15_PRODUCT = "FM-1_015";
|
||||
|
||||
// The official FM-1 V16 (2026-10-21; since then the only one M-VAVE offers): the same checks (after Clipper 1.2:
|
||||
// only V15 was accepted, so the way back failed with the file M-VAVE now gives; sloop-fm1 #8). The firmware's own
|
||||
// update entry (ota.c) still checks the package's loader (the official one's CRCs) and that its head equals the FM-1's
|
||||
export const STOCK_V16_SHA256 = "d017fb65e70aca97ee29d944470c3515a74581df5c0576bf70de917c7b2b61d5";
|
||||
export const STOCK_V16_SIZE = 718196;
|
||||
export const STOCK_V16_PRODUCT = "FM-1_016";
|
||||
// the official FM-1 packages accepted for the way back (the file M-VAVE offers, or the one before)
|
||||
export const STOCK_FM1 = [
|
||||
{ version: "V16", size: STOCK_V16_SIZE, sha256: STOCK_V16_SHA256, product: STOCK_V16_PRODUCT },
|
||||
{ version: "V15", size: STOCK_V15_SIZE, sha256: STOCK_V15_SHA256, product: STOCK_V15_PRODUCT },
|
||||
];
|
||||
// -> the FM-1 package it is (STOCK_FM1), or null
|
||||
export async function knownStockFm1(bytes) {
|
||||
const c = STOCK_FM1.filter((k) => k.size === bytes.length);
|
||||
if (!c.length) return null;
|
||||
const sha = await sha256hex(bytes);
|
||||
return c.find((k) => k.sha256 === sha && productOf(bytes) === k.product) || null;
|
||||
}
|
||||
|
||||
export async function sha256hex(bytes) {
|
||||
const d = await crypto.subtle.digest("SHA-256", bytes);
|
||||
return [...new Uint8Array(d)].map((x) => x.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
|
||||
export async function validateStockPackage(bytes) {
|
||||
if (bytes.length !== STOCK_V15_SIZE || await sha256hex(bytes) !== STOCK_V15_SHA256 || productOf(bytes) !== STOCK_V15_PRODUCT)
|
||||
throw new Error("select the unmodified official FM-1 V15 file (FM-1.fwsc)");
|
||||
return { product: STOCK_V15_PRODUCT, image: logicalImage(bytes) };
|
||||
const k = await knownStockFm1(bytes);
|
||||
if (!k)
|
||||
throw new Error("select the unmodified official FM-1 file (FM-1.fwsc, V16 or V15)");
|
||||
return { product: k.product, version: k.version, image: logicalImage(bytes) };
|
||||
}
|
||||
+25
-25
@@ -264,8 +264,8 @@ const $ = (id) => document.getElementById(id);
|
||||
const TEXT = {
|
||||
ja: {
|
||||
kicker: "M-VAVE FM-1 のためのシンセサイザー・ファームウェア",
|
||||
expTitle: "CLIPPER 1.2",
|
||||
expText: "Clipper 1.2 は FM-1 本体でテスト済みです。インストール前にエディタでバックアップを取り、気づいたことを知らせてください。",
|
||||
expTitle: "CLIPPER 1.3",
|
||||
expText: "Clipper 1.3 は FM-1 本体でテスト済みです。インストール前にエディタでバックアップを取り、気づいたことを知らせてください。",
|
||||
tEng: "音源エンジン", tSnd: "音色、レベル調整済み", tHy: "フィルター・モデル", tMx: "チューニング+自分の Scala 音階",
|
||||
intro: "FM-1 を USB で接続してください。(Chrome か Edge で使えます)",
|
||||
warn: "書き込み中は USB を抜かないでください。",
|
||||
@@ -291,20 +291,20 @@ const TEXT = {
|
||||
badpkg: "インストールするファイルが壊れています。ページを再読み込みしてください。",
|
||||
leave: "書き込み中です。ページを閉じないでください。",
|
||||
license: "GPL-3.0、無保証。ソース:",
|
||||
stockTitle: "公式ファームウェア(V15)に戻す",
|
||||
stockHelp: "M-VAVE のサイトから公式の FM-1 V15 をダウンロードし、中の FM-1.fwsc(変更していないもの)を選んでください。ファイルはこのブラウザの中で確認され、どこにも送られません。",
|
||||
stockTitle: "公式ファームウェアに戻す",
|
||||
stockHelp: "M-VAVE のサイトから公式の FM-1 ファームウェア(V16、または V15)をダウンロードし、中の FM-1.fwsc(変更していないもの)を選んでください。ファイルはこのブラウザの中で確認され、どこにも送られません。",
|
||||
stockBackup: "公式ファームウェアは Clipper の音色・プリセット・ウェーブテーブルを開けません。先にエディタでバックアップを保存してください(Backup タブ)。Clipper を入れ直せば、エディタから復元できます。",
|
||||
stockEditor: "エディタを開いてバックアップする", stockSaved: "バックアップをパソコンに保存しました",
|
||||
stockFile: "公式の FM-1.fwsc", stockGo: "公式 V15 をインストール",
|
||||
stockValid: "公式 V15 を確認しました", stockBad: "公式 V15 ではありません: ",
|
||||
stockConfirm: "FM-1 に公式 V15 をインストールします。Clipper の曲は公式ファームウェアでは開けません。バックアップは保存しましたか?",
|
||||
stockFinish: "FM-1 は Clipper の書き込みモードです。先に「インストール」で Clipper の書き込みを終えてから、公式 V15 に戻してください。",
|
||||
stockFile: "公式の FM-1.fwsc", stockGo: "公式ファームウェアをインストール",
|
||||
stockValid: "公式ファームウェアを確認しました", stockBad: "公式ファームウェア(V16 / V15)ではありません: ",
|
||||
stockConfirm: "FM-1 に公式ファームウェアをインストールします。Clipper の曲は公式ファームウェアでは開けません。バックアップは保存しましたか?",
|
||||
stockFinish: "FM-1 は Clipper の書き込みモードです。先に「インストール」で Clipper の書き込みを終えてから、公式ファームウェアに戻してください。",
|
||||
back: "M-VAVE のアップデーター M-UPGRADE(Downloads → PC Software)でも戻せます。FM-1 が見つからない場合は、MIDI を使う他のアプリとブラウザのタブを閉じてください。",
|
||||
},
|
||||
en: {
|
||||
kicker: "Synthesizer firmware for the M-VAVE FM-1",
|
||||
expTitle: "CLIPPER 1.2",
|
||||
expText: "Clipper 1.2 has been tested on the FM-1. Make a backup with the editor before installing, and please report what you find.",
|
||||
expTitle: "CLIPPER 1.3",
|
||||
expText: "Clipper 1.3 has been tested on the FM-1. Make a backup with the editor before installing, and please report what you find.",
|
||||
tEng: "synthesis engines", tSnd: "sounds, level-matched", tHy: "filter models", tMx: "tunings + your own Scala scales",
|
||||
intro: "Connect the FM-1 by USB. (Works in Chrome or Edge.)",
|
||||
warn: "Do not unplug the USB cable while writing.",
|
||||
@@ -330,20 +330,20 @@ const TEXT = {
|
||||
badpkg: "The file to install is damaged. Reload the page.",
|
||||
leave: "Writing. Do not close the page.",
|
||||
license: "GPL-3.0, no warranty. Source:",
|
||||
stockTitle: "Return to the official firmware (V15)",
|
||||
stockHelp: "Download the official FM-1 V15 from M-VAVE and select the FM-1.fwsc inside it, unmodified. The file is checked in this browser; it is not sent anywhere.",
|
||||
stockTitle: "Return to the official firmware",
|
||||
stockHelp: "Download the official FM-1 firmware (V16, or V15) from M-VAVE and select the FM-1.fwsc inside it, unmodified. The file is checked in this browser; it is not sent anywhere.",
|
||||
stockBackup: "The official firmware cannot open Clipper's sounds, presets or wavetables. Save a backup with the editor first (the Backup tab); reinstall Clipper and restore it from the editor whenever you want them back.",
|
||||
stockEditor: "Open the editor to back up", stockSaved: "I saved a backup on this computer",
|
||||
stockFile: "The official FM-1.fwsc", stockGo: "Install the official V15",
|
||||
stockValid: "Official V15 verified", stockBad: "Not the official V15: ",
|
||||
stockConfirm: "Install the official V15 on the FM-1? The official firmware cannot open Clipper's music. Did you save a backup?",
|
||||
stockFinish: "The FM-1 is in Clipper's update mode. Press Install to finish the Clipper update first, then return to the official V15.",
|
||||
stockFile: "The official FM-1.fwsc", stockGo: "Install the official firmware",
|
||||
stockValid: "Official firmware verified", stockBad: "Not the official firmware (V16 / V15): ",
|
||||
stockConfirm: "Install the official firmware on the FM-1? The official firmware cannot open Clipper's music. Did you save a backup?",
|
||||
stockFinish: "The FM-1 is in Clipper's update mode. Press Install to finish the Clipper update first, then return to the official firmware.",
|
||||
back: "M-VAVE's own updater, M-UPGRADE (Downloads → PC Software), works too. If it does not find the FM-1, close every other app and browser tab that uses MIDI.",
|
||||
},
|
||||
fr: {
|
||||
kicker: "Firmware synthétiseur pour la M-VAVE FM-1",
|
||||
expTitle: "CLIPPER 1.2",
|
||||
expText: "Clipper 1.2 a été testé sur la FM-1. Fais une sauvegarde avec l'éditeur avant d'installer, et signale ce que tu trouves.",
|
||||
expTitle: "CLIPPER 1.3",
|
||||
expText: "Clipper 1.3 a été testé sur la FM-1. Fais une sauvegarde avec l'éditeur avant d'installer, et signale ce que tu trouves.",
|
||||
tEng: "moteurs de synthèse", tSnd: "sons, niveaux égalisés", tHy: "modèles de filtre", tMx: "accordages + tes gammes Scala",
|
||||
intro: "Branche la FM-1 en USB. (Fonctionne dans Chrome ou Edge.)",
|
||||
warn: "Ne débranche pas le câble USB pendant l'écriture.",
|
||||
@@ -369,14 +369,14 @@ const TEXT = {
|
||||
badpkg: "Le fichier à installer est endommagé. Recharge la page.",
|
||||
leave: "Écriture en cours. Ne ferme pas la page.",
|
||||
license: "GPL-3.0, sans garantie. Source :",
|
||||
stockTitle: "Revenir au firmware officiel (V15)",
|
||||
stockHelp: "Télécharge la FM-1 V15 officielle sur le site de M-VAVE et choisis le FM-1.fwsc qu'elle contient, sans le modifier. Le fichier est vérifié dans ce navigateur ; il n'est envoyé nulle part.",
|
||||
stockTitle: "Revenir au firmware officiel",
|
||||
stockHelp: "Télécharge le firmware officiel de la FM-1 (V16, ou V15) sur le site de M-VAVE et choisis le FM-1.fwsc qu'elle contient, sans le modifier. Le fichier est vérifié dans ce navigateur ; il n'est envoyé nulle part.",
|
||||
stockBackup: "Le firmware officiel ne peut pas ouvrir les sons, les presets ni les tables d'ondes de Clipper. Fais d'abord une sauvegarde avec l'éditeur (onglet Backup) ; réinstalle Clipper et restaure-la depuis l'éditeur quand tu veux les retrouver.",
|
||||
stockEditor: "Ouvrir l'éditeur pour sauvegarder", stockSaved: "J'ai enregistré une sauvegarde sur cet ordinateur",
|
||||
stockFile: "Le FM-1.fwsc officiel", stockGo: "Installer la V15 officielle",
|
||||
stockValid: "V15 officielle vérifiée", stockBad: "Ce n'est pas la V15 officielle : ",
|
||||
stockConfirm: "Installer la V15 officielle sur la FM-1 ? Le firmware officiel ne peut pas ouvrir la musique de Clipper. As-tu fait une sauvegarde ?",
|
||||
stockFinish: "La FM-1 est en mode mise à jour de Clipper. Appuie d'abord sur Installer pour terminer la mise à jour de Clipper, puis reviens à la V15 officielle.",
|
||||
stockFile: "Le FM-1.fwsc officiel", stockGo: "Installer le firmware officiel",
|
||||
stockValid: "Firmware officiel vérifié", stockBad: "Ce n'est pas le firmware officiel (V16 / V15) : ",
|
||||
stockConfirm: "Installer le firmware officiel sur la FM-1 ? Le firmware officiel ne peut pas ouvrir la musique de Clipper. As-tu fait une sauvegarde ?",
|
||||
stockFinish: "La FM-1 est en mode mise à jour de Clipper. Appuie d'abord sur Installer pour terminer la mise à jour de Clipper, puis reviens au firmware officiel.",
|
||||
back: "L'outil de M-VAVE, M-UPGRADE (Downloads → PC Software), fonctionne aussi. S'il ne trouve pas la FM-1, ferme toutes les autres applis et onglets qui utilisent le MIDI.",
|
||||
},
|
||||
};
|
||||
@@ -481,7 +481,7 @@ $("go").addEventListener("click", async () => {
|
||||
lockAll(false);
|
||||
});
|
||||
|
||||
/* back to the official V15 (after Felucca 1.0): only the exact official file, a backup first (the editor),
|
||||
/* back to the official firmware, V16 or V15 (after Felucca 1.0; V16 after 1.2): only the exact official files, a backup first (the editor),
|
||||
through the same update path as M-UPGRADE; a device left in the official updater's mode is finished */
|
||||
$("stock-saved").addEventListener("change", () => lockAll(writing));
|
||||
$("stock-file").addEventListener("change", async () => {
|
||||
|
||||
+14
-2
@@ -524,7 +524,7 @@ 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,\n#if CLIPPER_SYNTH\n\s*12, 13, 14,\n#endif\n\s*32, 33, 34, 35\}/.test(ec), "backup: the object ids == editor.c ED_BK_IDS (35: USR4, 9: SYN kits, 12 / 13: the user presets' side records / tails, 14: the projects' 1.0 blocks)");
|
||||
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)));
|
||||
@@ -1808,7 +1808,19 @@ async function updater() {
|
||||
const pk = await import(join(HERE, "fm1pkg.js"));
|
||||
const notStock = new Uint8Array(pk.STOCK_V15_SIZE);
|
||||
const e6 = await pk.validateStockPackage(notStock).then(() => null, (x) => x);
|
||||
ok(e6 && /official FM-1 V15/.test(e6.message), "fm1pkg.js: only the exact official V15 is accepted (SHA-256)");
|
||||
ok(e6 && /official FM-1 file/.test(e6.message), "fm1pkg.js: only the exact official V15 / V16 is accepted (SHA-256)");
|
||||
/* (after 1.2, sloop-fm1 #8) V16, the file M-VAVE now offers, is accepted too: its size, digest and identity pinned;
|
||||
* a file of its size with other bytes is not. FM1_V16=path/FM-1.fwsc (M-VAVE's V16, not shipped here) checks the
|
||||
* real file */
|
||||
ok(pk.STOCK_V16_SIZE === 718196 && pk.STOCK_V16_PRODUCT === "FM-1_016" && pk.STOCK_FM1.length === 2 &&
|
||||
pk.STOCK_FM1.some((k) => k.product === "FM-1_015"), "fm1pkg.js: the official FM-1 V16 and V15 pinned");
|
||||
const e7 = await pk.validateStockPackage(new Uint8Array(pk.STOCK_V16_SIZE)).then(() => null, (x) => x);
|
||||
ok(e7 && /official FM-1 file/.test(e7.message), "fm1pkg.js: a file of V16's size, other bytes: refused");
|
||||
if (process.env.FM1_V16) {
|
||||
const v = await pk.validateStockPackage(new Uint8Array(readFileSync(process.env.FM1_V16)));
|
||||
ok(v.product === "FM-1_016" && v.version === "V16" && v.image.length === pk.STOCK_V16_SIZE - 20,
|
||||
"fm1pkg.js: M-VAVE's FM-1 V16 accepted (identity FM-1_016)");
|
||||
}
|
||||
}
|
||||
|
||||
await editorMock();
|
||||
|
||||
Reference in new issue
Block a user