From aa45571b3a7f7fefa7682249304e3efe9e718f5b Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Oct 2026 20:36:47 +0000 Subject: [PATCH 001/124] Faust SetControls: write control zones without allocating Marshal.Copy([value], ...) allocated a float[1] per control and the IReadOnlyDictionary foreach boxed an enumerator per call. Write the float bits straight to the zone and use Dictionary's struct enumerator when the caller passes one. 10000-block smoke on a 2-control patch: 120 B/block -> 0. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Faust/NativeFaustRuntime.cs | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/AquaSynth.Faust/NativeFaustRuntime.cs b/src/AquaSynth.Faust/NativeFaustRuntime.cs index bf707ef..e6b44c4 100644 --- a/src/AquaSynth.Faust/NativeFaustRuntime.cs +++ b/src/AquaSynth.Faust/NativeFaustRuntime.cs @@ -840,16 +840,32 @@ internal sealed class FaustNativeToolchain : IDisposable public void SetControls(IntPtr dsp, IReadOnlyDictionary controls, IReadOnlyDictionary map) { - foreach (var (path, value) in controls) + // Dictionary's struct enumerator avoids boxing one through the interface on every audio block. + if (controls is Dictionary dictionary) { - if (!map.TryGetValue(path, out var zone) && - !map.TryGetValue(path.TrimStart('/'), out zone)) + foreach (var (path, value) in dictionary) { - throw new ArgumentException($"Faust control `{path}` was not exported by the compiled patch.", nameof(controls)); + WriteControl(map, path, value); } - Marshal.Copy([value], 0, zone, 1); + return; } + + foreach (var (path, value) in controls) + { + WriteControl(map, path, value); + } + } + + private static void WriteControl(IReadOnlyDictionary map, string path, float value) + { + if (!map.TryGetValue(path, out var zone) && + !map.TryGetValue(path.TrimStart('/'), out zone)) + { + throw new ArgumentException($"Faust control `{path}` was not exported by the compiled patch.", "controls"); + } + + Marshal.WriteInt32(zone, BitConverter.SingleToInt32Bits(value)); } public void Dispose() From 36ff76f03a0d8874d2b4563e2291e487f04d6cb8 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Oct 2026 20:42:06 +0000 Subject: [PATCH 002/124] Add thruster Faust patch with an rpm control Sustained heavy thruster: low rotor rumble, blade-chopped noise rasp, high-Q hull rattle modes, tanh clip. Compiled as Faust source through CompileSource; not a .aqua script and not indexed in library.yaml. Co-Authored-By: Claude Sonnet 5.5 --- patches/thruster/thruster.dsp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 patches/thruster/thruster.dsp diff --git a/patches/thruster/thruster.dsp b/patches/thruster/thruster.dsp new file mode 100644 index 0000000..58fbe6b --- /dev/null +++ b/patches/thruster/thruster.dsp @@ -0,0 +1,27 @@ +// thruster: sustained, heavy, brittle-hull thruster with an RPM control. +// Compile as Faust source (AquaSynthPatchCompiler.CompileSource); it is not a .aqua script. +// Control: rpm (300..6000). Rotor tone = 28 Hz + rpm*0.025 (about 36..180 Hz); three blades chop the rasp at 3x that. +declare name "thruster"; +import("stdfaust.lib"); + +rpm = hslider("rpm", 1200, 300, 6000, 1) : si.smooth(ba.tau2pole(0.2)); +load = (rpm - 300) / 5700; +shaft = 28 + rpm * 0.025; + +// effort: slow random wander of the shaft speed +wander = no.noise : fi.lowpass(2, 5) : *(0.35); +f0 = shaft * (1 + 0.04 * wander); + +// low rumble: saw at shaft speed plus a square a sub-octave down, low-passed +rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 * shaft); + +// blade pass: rasp noise chopped at 3x shaft, band tracks rpm +chop = 0.5 + 0.5 * os.osc(f0 * 3) ^ 2; +rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); + +// brittle hull: high-Q modes rattled by noise, louder with load +mode(f, q) = no.noise : fi.resonbp(f, q, 1); +rattle = (mode(173, 40) * (0.3 + 0.7 * load) + 0.8 * mode(311, 35) + 0.6 * mode(467, 30) + 0.4 * mode(1130, 25)) * (0.1 + 0.9 * load ^ 2) * 3; + +mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 0.6 * load) + rattle; +process = mix * (0.4 + 0.6 * load) : *(2.2) : ma.tanh : *(0.5); From e567b44c24e22f0d9d240e789fad01f7b32816fa Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Oct 2026 20:45:51 +0000 Subject: [PATCH 003/124] thruster: drive falls with load so tanh no longer pins the peak at high rpm Drive 2.2 -> max(0.1, 0.9 - load); rasp load weight 0.6 -> 1.5. rpm=4800 peak 0.500 -> 0.358. Co-Authored-By: Claude Sonnet 5.5 --- patches/thruster/thruster.dsp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patches/thruster/thruster.dsp b/patches/thruster/thruster.dsp index 58fbe6b..b23d9b9 100644 --- a/patches/thruster/thruster.dsp +++ b/patches/thruster/thruster.dsp @@ -23,5 +23,6 @@ rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); mode(f, q) = no.noise : fi.resonbp(f, q, 1); rattle = (mode(173, 40) * (0.3 + 0.7 * load) + 0.8 * mode(311, 35) + 0.6 * mode(467, 30) + 0.4 * mode(1130, 25)) * (0.1 + 0.9 * load ^ 2) * 3; -mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 0.6 * load) + rattle; -process = mix * (0.4 + 0.6 * load) : *(2.2) : ma.tanh : *(0.5); +mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 1.5 * load) + rattle; +// drive falls with load so the tanh stage stays out of saturation at high rpm; rasp and hull modes carry the strain +process = mix * (0.4 + 0.6 * load) * max(0.1, 0.9 - 1.0 * load) : ma.tanh : *(0.5); From 882b7203f51d2ab6373ce2b594d5e53e81dc04e0 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Oct 2026 20:48:55 +0000 Subject: [PATCH 004/124] thruster: lower hull-mode Q and soft-limit the rattle so high rpm is louder than low rpm Hull modes Q 40/35/30/25 -> 20/18/16/14; tanh on the rattle alone; drive floor 0.1 -> 0.35. Linux render, 48 kHz, 512-frame blocks: rpm 4800 steady RMS 0.1252 > rpm 600 0.0850; peaks 0.216/0.354/0.325. Co-Authored-By: Claude Sonnet 5.5 --- patches/thruster/thruster.dsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/thruster/thruster.dsp b/patches/thruster/thruster.dsp index b23d9b9..9cabb67 100644 --- a/patches/thruster/thruster.dsp +++ b/patches/thruster/thruster.dsp @@ -19,10 +19,10 @@ rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 chop = 0.5 + 0.5 * os.osc(f0 * 3) ^ 2; rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); -// brittle hull: high-Q modes rattled by noise, louder with load +// brittle hull: high-Q modes rattled by noise, louder with load; tanh on the rattle alone keeps ring-up spikes from setting the peak mode(f, q) = no.noise : fi.resonbp(f, q, 1); -rattle = (mode(173, 40) * (0.3 + 0.7 * load) + 0.8 * mode(311, 35) + 0.6 * mode(467, 30) + 0.4 * mode(1130, 25)) * (0.1 + 0.9 * load ^ 2) * 3; +rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode(467, 16) + 0.4 * mode(1130, 14)) * (0.1 + 0.9 * load ^ 2) * 3 : *(4) : ma.tanh : /(4); mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 1.5 * load) + rattle; -// drive falls with load so the tanh stage stays out of saturation at high rpm; rasp and hull modes carry the strain -process = mix * (0.4 + 0.6 * load) * max(0.1, 0.9 - 1.0 * load) : ma.tanh : *(0.5); +// drive falls only gently with load so tanh stays out of saturation while high rpm still ends up louder than low rpm +process = mix * (0.4 + 0.6 * load) * max(0.35, 0.9 - 1.0 * load) : ma.tanh : *(0.5); From c6561da8d4290b80fcac9926e96384927b412c56 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Oct 2026 20:54:51 +0000 Subject: [PATCH 005/124] thruster: v5 gain term 0.9-0.5*load plus 0.425 output trim Peak under 0.4 at rpm 600, rpm 4800 and the 600-4800 sweep. Co-Authored-By: Claude Sonnet 5.5 --- patches/thruster/thruster.dsp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patches/thruster/thruster.dsp b/patches/thruster/thruster.dsp index 9cabb67..9260b6a 100644 --- a/patches/thruster/thruster.dsp +++ b/patches/thruster/thruster.dsp @@ -25,4 +25,5 @@ rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode( mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 1.5 * load) + rattle; // drive falls only gently with load so tanh stays out of saturation while high rpm still ends up louder than low rpm -process = mix * (0.4 + 0.6 * load) * max(0.35, 0.9 - 1.0 * load) : ma.tanh : *(0.5); +// final 0.425 trim keeps peak under 0.4 at rpm 4800 +process = mix * (0.4 + 0.6 * load) * (0.9 - 0.5 * load) : ma.tanh : *(0.425); From ab9bcdc6b7a966b3ecaa1156a8750e9b34652bc6 Mon Sep 17 00:00:00 2001 From: Aqua Date: Mon, 2 Nov 2026 12:30:12 +0000 Subject: [PATCH 006/124] Docs: soundscape grammar for the Ratatoskr generative symphony (draft) One typed activity frame drives both orbit visuals and voices. Grammar only; no notes, nothing rendered or listened to. Marks the two inputs that could not be read (creature-projection-v2, Mimir harvest). Co-Authored-By: Claude Sonnet 5.5 --- docs/soundscape-grammar.md | 217 +++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 docs/soundscape-grammar.md diff --git a/docs/soundscape-grammar.md b/docs/soundscape-grammar.md new file mode 100644 index 0000000..aed23cd --- /dev/null +++ b/docs/soundscape-grammar.md @@ -0,0 +1,217 @@ +# Soundscape grammar for the Ratatoskr generative symphony (spec) + +Serves follow-up `aqua-body:follow_up:chat-s938-943`. **Grammar only.** No notes, +no motifs, no pitches, no instrument choices. Nothing here was rendered, run, +listened to, or measured; every number marked *proposed* is a design choice +awaiting a listening trial and a device measurement. Nothing in this document +may be cited as heard. + +## 0. Inputs not seen + +Two inputs named in the brief could not be read when this was written, and the +grammar is drafted without them. Each is a place to reconcile before the doc is +treated as in force. + +- `heimdall-body:follow_up:ratatoskr-creature-projection-v2`: `huginn view` + from instance `aqua` answers `absent`, and a search of the Heimdall checkout + (`GameCult/Heimdall`, forge, 2026-11-02) found no file mentioning it. The + constraints taken from the brief are used as stated there: coarse buckets, + neutral overrides, activity comes from the Heimdall session. Section 2 is the + place that must be reconciled against that follow-up's actual field list. +- `ratatoskr:follow_up:symphony-grammar-harvest-mimir` (Mimir birdsong + research): also `absent` from aqua's mind, and `GameCult/Mimir` holds no + symphony or voice-separation note (grep of `notes/`, `research/`, `docs/`). + Section 4 is therefore built from this repo's own `research/syrinx-modeling` + plus the general auditory-scene-analysis and acoustic-niche literature named + there, *recalled, not re-read for this draft*. The harvest, when it exists, + replaces or confirms section 4; it is the likeliest thing to change. + +Context actually read: `docs/gamecult/ratatoskr-target.md` in `GameCult/Ratatoskr` +at `b33d8de` (the agreement that one activity vocabulary drives both sound and +motion, the member-safe projection, "kind, Mind, time and intensity, never +briefs or mind contents"), and `docs/agent-activity-grammar.md` (an earlier, +unmerged AquaSynth draft for the Dings event source; not part of this change). + +## 1. Purpose and owner + +One typed **activity frame** per Mind, produced once, read by two consumers: + +- the **orbit renderer** (Persona motion around Yggdrasil), and +- the **voice scheduler** (which instrument voice speaks, how densely). + +Neither consumer owns the vocabulary; neither adds a field. The vocabulary owner +is this grammar. The frame's producer is the Heimdall session (section 2). A +consumer that needs a distinction the vocabulary lacks raises it as a change to +this document, not as a private side channel. + +## 2. The activity frame + +Typed CultNet/CultCache document, projected member-safe. No private pipe: the +frame reaches both consumers by the same subscription, and a consumer that +cannot read it plays nothing and draws the neutral pose. + +| field | type | values | note | +|---|---|---|---| +| `mind` | id | instance name | stable identity, not a run/session label | +| `kind` | enum, 7 | `Idle`, `Reading`, `Thinking`, `Working`, `Speaking`, `Waiting`, `Alert` | coarse; see below | +| `energy` | enum, 4 | `Low`, `Mid`, `High`, `Peak` | coarse bucket of rate/intensity, never a float | +| `seq` | u32 | monotonic per `mind` | ordering and staleness; consumers drop `seq <= last` | +| `at` | time bucket | 1 s resolution | producer's observation time, for the staleness rule | +| `override` | enum, 3 | `None`, `Neutral`, `Muted` | see rules O1..O3 | + +Why this small: 7 x 4 = 28 states fit in one byte on the wire and in a lookup +table on a phone; both consumers map state to behaviour by table, no arithmetic +on unbounded values. `kind` and `energy` are orthogonal on purpose, because +orbit radius/speed wants energy and voice choice wants kind. + +Rules: + +- **A1. Source.** The frame comes from the Heimdall session and only from it. + Neither consumer infers activity from Matrix presence, typing, message + traffic, or audio. (The target already notes presence/typing are too coarse + for Minds.) *Reconcile the exact kind list against the projection-v2 + follow-up before use.* +- **A2. Coarse by construction.** There is no continuous field in the frame. A + renderer that wants smooth motion interpolates between buckets locally; it + does not request finer data. +- **A3. Member-safe.** The frame carries kind, Mind, time and energy bucket. + Never brief text, document ids, claims, or mind contents. +- **A4. Missing is Idle.** No frame within the staleness window (section 5, S2) + means `Idle`/`Low`, rendered and sounded as nothing. Silence is the default + state, not a failure state. + +### Overrides + +- **O1. `Neutral`** (set by the session or by the member's own setting): the + Mind renders at the neutral pose and contributes no voice, regardless of + `kind`/`energy`. Neutral is not an error; it hides activity, it does not + pretend there is none to other consumers. +- **O2. `Muted`**: no voice, orbit unchanged. Lets a listener silence one Mind + without hiding its motion. +- **O3.** Overrides are data in the frame, set upstream. A consumer never + applies a local override and then reports it as the Mind's state. (A *user's* + own mute/volume is a client preference and stays local; it never rewrites a + frame.) + +## 3. Mapping tables (shape only) + +The grammar defines the mapping *axes*, not the values. Each consumer owns one +table keyed by the 28 states; the tables are checked in beside this document +when values exist. + +| axis | owner | driven by | notes | +|---|---|---|---| +| orbit radius / speed / phase coupling | orbit renderer | `energy`, `kind` | Nibu's side; not specified here | +| voice **presence** (sounding or silent) | voice scheduler | `kind` | `Idle`, `Waiting` default silent | +| voice **density** (events per window) | voice scheduler | `energy` | capped, section 5 | +| voice **role** (lead / support / texture) | voice scheduler | `kind` | role, not instrument | +| voice **identity** (which instrument) | voice scheduler | `mind` | never `kind`; section 4 | + +The one rule that ties the two consumers: **`mind` selects identity, `kind` +selects behaviour, `energy` selects amount.** A given Mind sounds like itself +in every state; what it does changes. + +## 4. Keeping voices distinct when mixed + +Principle, from the acoustic-niche and auditory-scene-analysis literature +(recalled, to be confirmed by the Mimir harvest): voices that share a niche in +frequency, time and space mask each other; voices that differ on several +independent axes stay separable even at high density. Assign each Mind a +distinct **niche** on independent axes, and make the scheduler protect those +niches. Axes: + +1. **Register band.** Each Mind owns a band; bands do not overlap among + concurrently audible voices. Most robust single cue. +2. **Timbre family.** Distinct spectral envelope and onset shape. Identity is + carried by instrument (`ratatoskr-target.md`: "the instrument says who + spoke"); this grammar does not choose instruments. +3. **Rhythmic slot.** Each Mind owns a phase offset within a shared pulse grid, + so onsets interleave instead of colliding. Collisions are the main cause of + masking at low density. +4. **Stereo position.** Fixed pan per Mind, stable across sessions. Free on + phones with headphones, nearly useless on speakers; never the only cue. +5. **Role contrast.** At most one `lead` voice sounding at a time; the rest + support or texture (quieter, sparser, narrower band). + +Rules: + +- **V1. Identity is stable.** The niche (axes 1-4) is a function of `mind` + only. It never moves with `kind`, `energy`, or which other Minds are present. + A listener learns a Mind once. +- **V2. Niche table is data**, held beside the Mind's other typed state + (the target already says the instrument per Mind belongs in a typed document + on the Mind side, not hardcoded). Not defined here. +- **V3. Voice cap.** At most **4** voices audible at once (*proposed*; the + human limit on following concurrent streams is small and phones are + small). Over the cap, the lowest-`energy` voices drop first, never the + `lead`. The cap is a requirement to measure, not a finding. +- **V4. Collision backoff.** If two voices would start within one pulse of each + other in the same register band, the lower-priority one slips to its next + slot. It does not stack. +- **V5. More Minds than niches.** When Minds exceed available niches, the + excess are *not* squeezed in by shrinking bands. They share a `texture` + voice or stay silent. Distinctness beats completeness. +- **V6. Identification is unproven.** Nominal separation (different bands, + different families) is not human discriminability. No Mind's niche is + accepted until a listener-identification trial passes (the existing + notification ledger requires the same). That trial has not happened. + +## 5. Timing, staleness and the callback deadline + +Hard rule: **the audio callback deadline wins over everything in this +document.** The callback never waits on the grammar, the network, a decode, an +allocation, or a lock. + +- **C1. Frame handoff is a snapshot.** The network/projection thread writes the + latest frame per `mind` into a preallocated table; the scheduler thread reads + it and writes a preallocated voice-command queue; the audio callback only + reads that queue. No thread but the callback touches the output buffer; the + callback never blocks on, or is blocked by, the others (single-producer + single-consumer, fixed capacity). +- **C2. Drop, never delay.** If the queue is full or the scheduler is late, the + frame or command is dropped. A late sound is not played to catch up and its + internal timing is never stretched. +- **S1. Latest wins.** Per `mind`, only the newest `seq` matters. Intermediate + frames missed during a stall are not replayed. +- **S2. Staleness.** A frame older than **10 s** (*proposed*) is treated as + absent (rule A4). Sounding on stale activity is misleading. +- **S3. Rate.** Voice density per `energy` is bounded by a ceiling per Mind per + window (*proposed*, set with the device measurement); rule V3 bounds the + total. Bursts are coalesced, not queued. +- **S4. Pre-rendered material.** The client ships rendered audio assets, no + synth in the browser (`ratatoskr-target.md` agreements). The scheduler + selects and positions assets; it generates nothing at callback time. Browsers + block audio until a first user gesture: before it, the scheduler runs but the + output is silent, and no state is lost. +- **S5. Backgrounded or hidden page.** Voice scheduler pauses with the orbit + renderer's pause (the target already pauses the background when hidden). On + resume, S1/S2 apply; there is no catch-up burst. +- **S6. Failure is silent.** No frame source, a dead scheduler, a refused + autoplay, or a full queue all produce silence and neutral pose. Nothing + retries, alerts, or alters the frame source. + +## 6. What this grammar does not decide + +- Motifs, notes, pitches, instruments, envelopes. (Next layer; needs a + listening trial per the repo's audio doctrine.) +- Orbit geometry and shader work (Nibu's side). +- The feed transport. `ratatoskr:question:activity-feed-source` owns where the + frame comes from; this document fixes only its *shape*, and that it is a + typed CultNet document, not a private channel. +- Per-device budgets. All numbers marked *proposed* need a phone measurement. + +## 7. Verification owed + +None run. To be done before the grammar leaves draft: + +1. Reconcile section 2 with `heimdall-body:follow_up:ratatoskr-creature-projection-v2`. +2. Reconcile section 4 with the Mimir harvest. +3. Round-trip the frame as a CultCache document and check the size claim (one + byte per state, 28 states). +4. Measure voice cap, density ceilings and scheduler cost on a real phone. +5. Listener-identification trial for any niche table (rule V6). + +## 8. Status + +Draft. Not implemented. No code changed. No audio was produced and none is +claimed. From 39843ae95c4403b6db26ac90f680f2a65bbe6b97 Mon Sep 17 00:00:00 2001 From: Aqua Date: Wed, 4 Nov 2026 13:38:49 +0000 Subject: [PATCH 007/124] Add static in-browser playground for AquaSynth patches tools/AquaLower lowers .aqua to Faust (FaustEmitter.EmitScript); tools/aqua-playground compiles the lowered Faust to wasm with @grame/faustwasm in the page and plays it through an AudioWorklet, with sliders from the DSP's UI and the Faust source shown. Thruster plus 41 .aqua patches. Headless node test compiles and renders every patch (non-silent, finite). Co-Authored-By: Claude Sonnet 5.5 --- tools/AquaLower/AquaLower.csproj | 15 + tools/AquaLower/Program.cs | 35 ++ tools/aqua-playground/.gitignore | 2 + tools/aqua-playground/README.md | 28 ++ tools/aqua-playground/build.mjs | 18 ++ tools/aqua-playground/lower.sh | 13 + tools/aqua-playground/lowered/808-clap.dsp | 76 +++++ tools/aqua-playground/lowered/808-cowbell.dsp | 65 ++++ tools/aqua-playground/lowered/808-hat.dsp | 65 ++++ tools/aqua-playground/lowered/808-kick.dsp | 54 ++++ tools/aqua-playground/lowered/808-snare.dsp | 65 ++++ tools/aqua-playground/lowered/808-tom.dsp | 54 ++++ .../advanced-alien-multivalve-graph.dsp | 231 ++++++++++++++ .../lowered/advanced-aurora-pad.dsp | 87 +++++ .../lowered/advanced-bird-syrinx-graph.dsp | 238 ++++++++++++++ .../lowered/advanced-bird-syrinx.dsp | 253 +++++++++++++++ .../lowered/advanced-glass-creature.dsp | 98 ++++++ .../lowered/advanced-human-larynx-graph.dsp | 185 +++++++++++ .../lowered/advanced-machine-breath.dsp | 87 +++++ .../lowered/advanced-ritual-sequence.dsp | 87 +++++ .../lowered/advanced-subtractive-drums.dsp | 98 ++++++ .../lowered/advanced-syrinx-voice.dsp | 238 ++++++++++++++ .../lowered/bfxr-coin-spark.dsp | 65 ++++ .../lowered/bfxr-portal-chirp.dsp | 65 ++++ .../lowered/bfxr-shield-pop.dsp | 65 ++++ .../aqua-playground/lowered/bfxr-ui-bloom.dsp | 65 ++++ tools/aqua-playground/lowered/catalog.json | 300 ++++++++++++++++++ .../dx7-algorithm-32-additive-organ.dsp | 112 +++++++ .../lowered/dx7-algorithm-8-bright-pair.dsp | 77 +++++ .../lowered/dx7-public-domain-mc-mm-5-3.dsp | 54 ++++ ...x7-public-domain-prc-synth1-calibrated.dsp | 52 +++ .../lowered/examples-language-tour.dsp | 76 +++++ .../aqua-playground/lowered/fm-bell-bell.dsp | 65 ++++ .../aqua-playground/lowered/fm-bell-chime.dsp | 65 ++++ .../aqua-playground/lowered/fm-bell-coin.dsp | 65 ++++ .../aqua-playground/lowered/fm-bell-gong.dsp | 65 ++++ tools/aqua-playground/lowered/sfxr-blip.dsp | 54 ++++ ...fxr-classic-classic-sfxr-abstract-golf.dsp | 120 +++++++ .../lowered/sfxr-explosion.dsp | 54 ++++ tools/aqua-playground/lowered/sfxr-hit.dsp | 54 ++++ tools/aqua-playground/lowered/sfxr-jump.dsp | 54 ++++ tools/aqua-playground/lowered/sfxr-laser.dsp | 54 ++++ tools/aqua-playground/lowered/sfxr-pickup.dsp | 54 ++++ .../aqua-playground/lowered/sfxr-powerup.dsp | 54 ++++ tools/aqua-playground/lowered/thruster.dsp | 29 ++ .../lowered/wobble-bass-growl.dsp | 65 ++++ .../lowered/wobble-bass-neuro.dsp | 65 ++++ .../lowered/wobble-bass-talker.dsp | 65 ++++ .../lowered/wobble-bass-yoy.dsp | 65 ++++ tools/aqua-playground/package-lock.json | 35 ++ tools/aqua-playground/package.json | 13 + tools/aqua-playground/test.mjs | 49 +++ tools/aqua-playground/web/app.js | 91 ++++++ tools/aqua-playground/web/index.html | 38 +++ tools/aqua-playground/web/styles.css | 19 ++ tools/aqua-playground/web/ui.mjs | 17 + 56 files changed, 4332 insertions(+) create mode 100644 tools/AquaLower/AquaLower.csproj create mode 100644 tools/AquaLower/Program.cs create mode 100644 tools/aqua-playground/.gitignore create mode 100644 tools/aqua-playground/README.md create mode 100644 tools/aqua-playground/build.mjs create mode 100755 tools/aqua-playground/lower.sh create mode 100644 tools/aqua-playground/lowered/808-clap.dsp create mode 100644 tools/aqua-playground/lowered/808-cowbell.dsp create mode 100644 tools/aqua-playground/lowered/808-hat.dsp create mode 100644 tools/aqua-playground/lowered/808-kick.dsp create mode 100644 tools/aqua-playground/lowered/808-snare.dsp create mode 100644 tools/aqua-playground/lowered/808-tom.dsp create mode 100644 tools/aqua-playground/lowered/advanced-alien-multivalve-graph.dsp create mode 100644 tools/aqua-playground/lowered/advanced-aurora-pad.dsp create mode 100644 tools/aqua-playground/lowered/advanced-bird-syrinx-graph.dsp create mode 100644 tools/aqua-playground/lowered/advanced-bird-syrinx.dsp create mode 100644 tools/aqua-playground/lowered/advanced-glass-creature.dsp create mode 100644 tools/aqua-playground/lowered/advanced-human-larynx-graph.dsp create mode 100644 tools/aqua-playground/lowered/advanced-machine-breath.dsp create mode 100644 tools/aqua-playground/lowered/advanced-ritual-sequence.dsp create mode 100644 tools/aqua-playground/lowered/advanced-subtractive-drums.dsp create mode 100644 tools/aqua-playground/lowered/advanced-syrinx-voice.dsp create mode 100644 tools/aqua-playground/lowered/bfxr-coin-spark.dsp create mode 100644 tools/aqua-playground/lowered/bfxr-portal-chirp.dsp create mode 100644 tools/aqua-playground/lowered/bfxr-shield-pop.dsp create mode 100644 tools/aqua-playground/lowered/bfxr-ui-bloom.dsp create mode 100644 tools/aqua-playground/lowered/catalog.json create mode 100644 tools/aqua-playground/lowered/dx7-algorithm-32-additive-organ.dsp create mode 100644 tools/aqua-playground/lowered/dx7-algorithm-8-bright-pair.dsp create mode 100644 tools/aqua-playground/lowered/dx7-public-domain-mc-mm-5-3.dsp create mode 100644 tools/aqua-playground/lowered/dx7-public-domain-prc-synth1-calibrated.dsp create mode 100644 tools/aqua-playground/lowered/examples-language-tour.dsp create mode 100644 tools/aqua-playground/lowered/fm-bell-bell.dsp create mode 100644 tools/aqua-playground/lowered/fm-bell-chime.dsp create mode 100644 tools/aqua-playground/lowered/fm-bell-coin.dsp create mode 100644 tools/aqua-playground/lowered/fm-bell-gong.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-blip.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-classic-classic-sfxr-abstract-golf.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-explosion.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-hit.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-jump.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-laser.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-pickup.dsp create mode 100644 tools/aqua-playground/lowered/sfxr-powerup.dsp create mode 100644 tools/aqua-playground/lowered/thruster.dsp create mode 100644 tools/aqua-playground/lowered/wobble-bass-growl.dsp create mode 100644 tools/aqua-playground/lowered/wobble-bass-neuro.dsp create mode 100644 tools/aqua-playground/lowered/wobble-bass-talker.dsp create mode 100644 tools/aqua-playground/lowered/wobble-bass-yoy.dsp create mode 100644 tools/aqua-playground/package-lock.json create mode 100644 tools/aqua-playground/package.json create mode 100644 tools/aqua-playground/test.mjs create mode 100644 tools/aqua-playground/web/app.js create mode 100644 tools/aqua-playground/web/index.html create mode 100644 tools/aqua-playground/web/styles.css create mode 100644 tools/aqua-playground/web/ui.mjs diff --git a/tools/AquaLower/AquaLower.csproj b/tools/AquaLower/AquaLower.csproj new file mode 100644 index 0000000..6c55fc0 --- /dev/null +++ b/tools/AquaLower/AquaLower.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + enable + enable + false + + + + + + + diff --git a/tools/AquaLower/Program.cs b/tools/AquaLower/Program.cs new file mode 100644 index 0000000..6f0b113 --- /dev/null +++ b/tools/AquaLower/Program.cs @@ -0,0 +1,35 @@ +using System.Text.Json; +using AquaSynth.Dsl; + +// Lowers .aqua patches to Faust source for the static playground (tools/aqua-playground). +// usage: AquaLower = ... +// A .aqua entry goes through FaustEmitter.EmitScript, the same lowering the daemon uses; a .dsp entry +// (the thruster) is already Faust and is copied verbatim. Writes /.dsp, and +// catalog.json for the browser (the one non-CultNet xeno at this boundary). +if (args.Length < 3) { Console.Error.WriteLine("usage: AquaLower = ..."); return 2; } +var outDir = Path.GetFullPath(args[0]); +var root = Path.GetFullPath(args[1]); +Directory.CreateDirectory(outDir); +var entries = new List(); +foreach (var spec in args.Skip(2)) +{ + var eq = spec.IndexOf('='); + var name = spec[..eq]; + var rel = spec[(eq + 1)..]; + var path = Path.Combine(root, rel); + var text = File.ReadAllText(path); + string source; + var warnings = new List(); + if (path.EndsWith(".aqua", StringComparison.Ordinal)) + { + var export = FaustEmitter.EmitScript(text, new FaustExportOptions(name)); + source = export.Source; + warnings.AddRange(export.Warnings); + } + else source = text; + File.WriteAllText(Path.Combine(outDir, name + ".dsp"), source); + entries.Add(new { name, origin = rel.Replace('\\', '/'), kind = path.EndsWith(".aqua", StringComparison.Ordinal) ? "aqua" : "faust", dsp = name + ".dsp", warnings }); + Console.WriteLine($"{name}: {source.Length} chars from {rel}, {warnings.Count} warnings"); +} +File.WriteAllText(Path.Combine(outDir, "catalog.json"), JsonSerializer.Serialize(entries, new JsonSerializerOptions { WriteIndented = true })); +return 0; diff --git a/tools/aqua-playground/.gitignore b/tools/aqua-playground/.gitignore new file mode 100644 index 0000000..b947077 --- /dev/null +++ b/tools/aqua-playground/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ diff --git a/tools/aqua-playground/README.md b/tools/aqua-playground/README.md new file mode 100644 index 0000000..720915b --- /dev/null +++ b/tools/aqua-playground/README.md @@ -0,0 +1,28 @@ +# AquaSynth Playground + +Static, serverless audition page for AquaSynth patches. Pick a patch, read the Faust it lowers to, +move the sliders the DSP itself declares, press Play. + +**What is live:** 42 patches (`catalog.json`): the hand-written Faust `thruster` (with its `rpm` +control) and 41 of the 43 `.aqua` files, lowered by `tools/AquaLower` through `FaustEmitter.EmitScript` +(the lowering the daemon uses). Faust is compiled to WebAssembly in the page +(`@grame/faustwasm` 0.20.0, libfaust 2.90), played through an AudioWorklet, and the lowered source +is shown in an editable box with a Recompile button. + +**What it is not:** `.aqua` is lowered ahead of time (`lowered/`), not in the page; editing Faust works, +editing `.aqua` does not. `advanced/additive-pad` and `advanced/electro-drop-demo` lower to ~1.5 MB of +Faust each and are left out. One-shot patches sound once per Play press and mostly declare no +controls, so their slider panel is empty. + +## Entry points + +- `lower.sh`: regenerate `lowered/*.dsp` and `catalog.json` (needs .NET SDK and `CULTLIB_ROOT`). +- `node build.mjs [outDir]`: assemble the site in `dist/` (run `npm install` first). +- `node test.mjs [dist]`: headless check of `dist/`: each patch compiles to wasm, renders 2 s + offline, is non-silent and finite; the thruster is also run at rpm 600 and 4800. + It cannot hear and does not run an AudioWorklet or a browser. +- `web/`: the page (`index.html`, `app.js`, `ui.mjs`, `styles.css`). + +Serve `dist/` from any static host (`python3 -m http.server`); AudioWorklet needs `localhost` or https. +The older `tools/vocal-tract-playground` renders server-side through the .NET renderer; this one +does not need a server. diff --git a/tools/aqua-playground/build.mjs b/tools/aqua-playground/build.mjs new file mode 100644 index 0000000..e23a87c --- /dev/null +++ b/tools/aqua-playground/build.mjs @@ -0,0 +1,18 @@ +// Assembles dist/ (the static site): web/, lowered/ patches + catalog.json, and the faustwasm runtime +// (ESM wrapper + libfaust wasm) copied from node_modules. Usage: node build.mjs [outDir] +import { cpSync, mkdirSync, rmSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const out = resolve(process.argv[2] ?? join(here, "dist")); +const fw = join(here, "node_modules/@grame/faustwasm"); +rmSync(out, { recursive: true, force: true }); +mkdirSync(join(out, "vendor/faustwasm"), { recursive: true }); +cpSync(join(here, "web"), out, { recursive: true }); +cpSync(join(here, "lowered"), out, { recursive: true }); +cpSync(join(fw, "dist/esm/index.js"), join(out, "vendor/faustwasm/index.js")); +cpSync(join(fw, "COPYING.txt"), join(out, "vendor/faustwasm/COPYING.txt")); +for (const f of ["libfaust-wasm.js", "libfaust-wasm.wasm", "libfaust-wasm.data"]) + cpSync(join(fw, "libfaust-wasm", f), join(out, "vendor/libfaust-wasm", f)); +console.log(`built ${out}`); diff --git a/tools/aqua-playground/lower.sh b/tools/aqua-playground/lower.sh new file mode 100755 index 0000000..bff324a --- /dev/null +++ b/tools/aqua-playground/lower.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Regenerates lowered/*.dsp and catalog.json from patches/ through the AquaLower tool (needs the .NET SDK +# and a CultLib checkout at the admitted revision: set CULTLIB_ROOT). The two largest patches +# (additive-pad, electro-drop-demo lower to about 1.5 MB of Faust each) stay out of the catalog. +set -euo pipefail +cd "$(dirname "$0")/../.." +entries=(thruster=thruster/thruster.dsp) +while IFS= read -r rel; do + case "$rel" in advanced/additive-pad.aqua|advanced/electro-drop-demo.aqua) continue;; esac + name=$(echo "${rel%.aqua}" | tr '/' '-') + entries+=("$name=$rel") +done < <(cd patches && find . -name '*.aqua' | sed 's|^\./||' | sort) +dotnet run -c Release --project tools/AquaLower -- tools/aqua-playground/lowered patches "${entries[@]}" diff --git a/tools/aqua-playground/lowered/808-clap.dsp b/tools/aqua-playground/lowered/808-clap.dsp new file mode 100644 index 0000000..e1243bc --- /dev/null +++ b/tools/aqua-playground/lowered/808-clap.dsp @@ -0,0 +1,76 @@ +import("stdfaust.lib"); +declare name "808-clap"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 1800 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = no.noise; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0.95 + patch_mod_noise + 0.0)) + no.noise * clip01(0.95 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.42 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.55 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.55 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered + (voice_0_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(0.004 + 0 * voice_0_age) * ma.SR)))); +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.11, 0.018) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +voice_1_age = age; +voice_1_freq = ((max(20, 2200 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = no.noise; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0.95 + patch_mod_noise + 0.0)) + no.noise * clip01(0.95 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.42 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.55 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.55 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered + (voice_1_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(0.008 + 0 * voice_1_age) * ma.SR)))); +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.11, 0.022) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +voice_2_age = age; +voice_2_freq = ((max(20, 2600 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = no.noise; +voice_2_colored = (voice_2_osc * (1.0 - clip01(0.95 + patch_mod_noise + 0.0)) + no.noise * clip01(0.95 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.42 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.55 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.55 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered + (voice_2_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(0.012 + 0 * voice_2_age) * ma.SR)))); +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0, 0, 1, 0.11, 0.028) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0 + voice_1 + voice_2) * 1); diff --git a/tools/aqua-playground/lowered/808-cowbell.dsp b/tools/aqua-playground/lowered/808-cowbell.dsp new file mode 100644 index 0000000..a9e3996 --- /dev/null +++ b/tools/aqua-playground/lowered/808-cowbell.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "808-cowbell"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 540 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = select2(wrap01(os.phasor(1.0, ((max(20, 540 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.43 + 0 * voice_0_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.18 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.18 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.18, 0.05) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.16); + +voice_1_age = age; +voice_1_freq = ((max(20, 800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = select2(wrap01(os.phasor(1.0, ((max(20, 800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.47 + 0 * voice_1_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.18 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.18 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.16, 0.045) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/808-hat.dsp b/tools/aqua-playground/lowered/808-hat.dsp new file mode 100644 index 0000000..551f76c --- /dev/null +++ b/tools/aqua-playground/lowered/808-hat.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "808-hat"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 9000 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = no.noise; +voice_0_colored = (voice_0_osc * (1.0 - clip01(1 + patch_mod_noise + 0.0)) + no.noise * clip01(1 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.24 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.9 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.9 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.055, 0.006) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.16); + +voice_1_age = age; +voice_1_freq = ((max(20, 6800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = select2(wrap01(os.phasor(1.0, ((max(20, 6800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.5 + 0 * voice_1_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.24 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.9 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.9 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.04, 0.005) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.045); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/808-kick.dsp b/tools/aqua-playground/lowered/808-kick.dsp new file mode 100644 index 0000000..9ee8ad7 --- /dev/null +++ b/tools/aqua-playground/lowered/808-kick.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "808-kick"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(32, 58 * pow(2.0, -3.8 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(32, 58 * pow(2.0, -3.8 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.18 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.18 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.85 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.6060606, 0.42, 0.045) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 1.32); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/808-snare.dsp b/tools/aqua-playground/lowered/808-snare.dsp new file mode 100644 index 0000000..b65dbaf --- /dev/null +++ b/tools/aqua-playground/lowered/808-snare.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "808-snare"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 180 * pow(2.0, -1.2 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 180 * pow(2.0, -1.2 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.12, 0.02) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +voice_1_age = age; +voice_1_freq = ((max(20, 140 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = no.noise; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0.85 + patch_mod_noise + 0.0)) + no.noise * clip01(0.85 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.55 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.45 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.45 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.2, 0.035) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.55); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/808-tom.dsp b/tools/aqua-playground/lowered/808-tom.dsp new file mode 100644 index 0000000..28235ed --- /dev/null +++ b/tools/aqua-playground/lowered/808-tom.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "808-tom"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(62, 115 * pow(2.0, -1.45 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(62, 115 * pow(2.0, -1.45 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.78 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.78125, 0.34, 0.055) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.704); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/advanced-alien-multivalve-graph.dsp b/tools/aqua-playground/lowered/advanced-alien-multivalve-graph.dsp new file mode 100644 index 0000000..f73fe80 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-alien-multivalve-graph.dsp @@ -0,0 +1,231 @@ +import("stdfaust.lib"); +declare name "advanced-alien-multivalve-graph"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0_base = hslider("/alien/core/pressure", 0.74, 0, 1.5, 0.001) : si.smoo; +patch_param_0_curve_time = max(0.0, age * 1 - 0); +patch_param_0_curve_value = select2(patch_param_0_curve_time < 0.1, select2(patch_param_0_curve_time < 0.5, select2(patch_param_0_curve_time < 0.9, 0.22, seg(patch_param_0_curve_time, 0.5, 0.4, 0.82, 0.22)), seg(patch_param_0_curve_time, 0.1, 0.4, 0.76, 0.82)), seg(patch_param_0_curve_time, 0, 0.1, 0.08, 0.76)); +patch_param_0_curve_depth = hslider("/curves/core_breath/depth", 0.9, 0, 1, 0.001) : si.smoo; +patch_param_0 = min(1.5, max(0, patch_param_0_base * (1.0 - patch_param_0_curve_depth) + patch_param_0_curve_value * patch_param_0_curve_depth)); +patch_param_1_base = hslider("/alien/side/pressure", 0.52, 0, 1.5, 0.001) : si.smoo; +patch_param_1_curve_time = max(0.0, age * 1 - 0); +patch_param_1_curve_value = select2(patch_param_1_curve_time < 0.18, select2(patch_param_1_curve_time < 0.38, select2(patch_param_1_curve_time < 0.62, select2(patch_param_1_curve_time < 0.9, 0.12, seg(patch_param_1_curve_time, 0.62, 0.28, 0.7, 0.12)), seg(patch_param_1_curve_time, 0.38, 0.24, 0.22, 0.7)), seg(patch_param_1_curve_time, 0.18, 0.2, 0.54, 0.22)), seg(patch_param_1_curve_time, 0, 0.18, 0.02, 0.54)); +patch_param_1_curve_depth = hslider("/curves/side_breath/depth", 0.9, 0, 1, 0.001) : si.smoo; +patch_param_1 = min(1.5, max(0, patch_param_1_base * (1.0 - patch_param_1_curve_depth) + patch_param_1_curve_value * patch_param_1_curve_depth)); +patch_param_2 = hslider("/alien/core/opening", 0.24, 0, 1, 0.001) : si.smoo; +patch_param_3 = hslider("/alien/side/opening", 0.3, 0, 1, 0.001) : si.smoo; +patch_param_4_base = hslider("/alien/aperture", 0.85, 0, 2, 0.001) : si.smoo; +patch_param_4_curve_time = max(0.0, age * 1 - 0); +patch_param_4_curve_value = select2(patch_param_4_curve_time < 0.22, select2(patch_param_4_curve_time < 0.55, select2(patch_param_4_curve_time < 0.9, 0.9, seg(patch_param_4_curve_time, 0.55, 0.35, 0.62, 0.9)), seg(patch_param_4_curve_time, 0.22, 0.33, 1.1, 0.62)), seg(patch_param_4_curve_time, 0, 0.22, 0.42, 1.1)); +patch_param_4_curve_depth = hslider("/curves/mouth_shape/depth", 0.8, 0, 1, 0.001) : si.smoo; +patch_param_4 = min(2, max(0, patch_param_4_base * (1.0 - patch_param_4_curve_depth) + patch_param_4_curve_value * patch_param_4_curve_depth)); +patch_param_5 = hslider("/alien/branch/opening", 0.46, 0, 1, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_graph_drive = 1.0; +voice_0_graph_terminal_area_core_valve = max(0.000001, ((max(0.0, min((0.48 + ((2.43) - 0.48) * (exp(0.0 - pow((0 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.48) * 0), (patch_param_4) + max(0.0, ((0.48 + ((2.43) - 0.48) * (exp(0.0 - pow((0 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.48) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((0 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))) * (max(0.0, min((0.48 + ((2.43) - 0.48) * (exp(0.0 - pow((0 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.48) * 0), (patch_param_4) + max(0.0, ((0.48 + ((2.43) - 0.48) * (exp(0.0 - pow((0 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.48) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((0 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0)))))))) * max(0.0, 1)); +voice_0_graph_terminal_reflection_core_valve = 0; +voice_0_graph_terminal_area_side_valve = max(0.000001, 0.04 * max(0.0, 1)); +voice_0_graph_terminal_reflection_side_valve = 0; +voice_0_graph_terminal_area_aperture = max(0.000001, ((max(0.0, min((0.44 + ((2.43) - 0.44) * (exp(0.0 - pow((5 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.44) * 1), (patch_param_4) + max(0.0, ((0.44 + ((2.43) - 0.44) * (exp(0.0 - pow((5 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.44) * 1)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((5 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))) * (max(0.0, min((0.44 + ((2.43) - 0.44) * (exp(0.0 - pow((5 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.44) * 1), (patch_param_4) + max(0.0, ((0.44 + ((2.43) - 0.44) * (exp(0.0 - pow((5 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.44) * 1)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((5 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0)))))))) * max(0.0, 0.85)); +voice_0_graph_terminal_reflection_aperture = ((0.72) * (1.0 - clip01(max(0.0, patch_param_4))) + (-0.58) * clip01(max(0.0, patch_param_4))); +voice_0_graph_terminal_area_side_coupler_from = max(0.000001, ((max(0.0, min((0.933 + ((2.43) - 0.933) * (exp(0.0 - pow((2.9 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.933) * 0), (patch_param_4) + max(0.0, ((0.933 + ((2.43) - 0.933) * (exp(0.0 - pow((2.9 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.933) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((2.9 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))) * (max(0.0, min((0.933 + ((2.43) - 0.933) * (exp(0.0 - pow((2.9 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.933) * 0), (patch_param_4) + max(0.0, ((0.933 + ((2.43) - 0.933) * (exp(0.0 - pow((2.9 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.933) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((2.9 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0)))))))) * max(0.0, 0.62)); +voice_0_graph_terminal_reflection_side_coupler_from = 0; +voice_0_graph_terminal_area_side_coupler_to = max(0.000001, 0.0324 * max(0.0, 0.46)); +voice_0_graph_terminal_reflection_side_coupler_to = 0; +voice_0_graph_node_area_core_valve = max(0.000001, voice_0_graph_terminal_area_core_valve); +voice_0_graph_node_reflection_core_valve = (voice_0_graph_terminal_reflection_core_valve) / 1; +voice_0_graph_node_area_side_coupler_from = max(0.000001, voice_0_graph_terminal_area_side_coupler_from); +voice_0_graph_node_reflection_side_coupler_from = (voice_0_graph_terminal_reflection_side_coupler_from) / 1; +voice_0_graph_node_area_aperture = max(0.000001, voice_0_graph_terminal_area_aperture); +voice_0_graph_node_reflection_aperture = (voice_0_graph_terminal_reflection_aperture) / 1; +voice_0_graph_node_area_side_valve = max(0.000001, voice_0_graph_terminal_area_side_valve); +voice_0_graph_node_reflection_side_valve = (voice_0_graph_terminal_reflection_side_valve) / 1; +voice_0_graph_node_area_side_coupler_to = max(0.000001, voice_0_graph_terminal_area_side_coupler_to); +voice_0_graph_node_reflection_side_coupler_to = (voice_0_graph_terminal_reflection_side_coupler_to) / 1; +voice_0_graph_segment_area_0 = max(0.000001, ((max(0.0, min((0.8685 + ((2.43) - 0.8685) * (exp(0.0 - pow((1.45 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.8685) * 0), (patch_param_4) + max(0.0, ((0.8685 + ((2.43) - 0.8685) * (exp(0.0 - pow((1.45 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.8685) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((1.45 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))) * (max(0.0, min((0.8685 + ((2.43) - 0.8685) * (exp(0.0 - pow((1.45 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.8685) * 0), (patch_param_4) + max(0.0, ((0.8685 + ((2.43) - 0.8685) * (exp(0.0 - pow((1.45 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.8685) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((1.45 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))))); +voice_0_graph_segment_area_1 = max(0.000001, ((max(0.0, min((0.692 + ((2.43) - 0.692) * (exp(0.0 - pow((3.95 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.692) * 0), (patch_param_4) + max(0.0, ((0.692 + ((2.43) - 0.692) * (exp(0.0 - pow((3.95 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.692) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((3.95 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))) * (max(0.0, min((0.692 + ((2.43) - 0.692) * (exp(0.0 - pow((3.95 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.692) * 0), (patch_param_4) + max(0.0, ((0.692 + ((2.43) - 0.692) * (exp(0.0 - pow((3.95 - (12.9)) / (max(0.001, 0.18 * 6)), 2.0))) + ((patch_param_4) - 0.692) * 0)) - (patch_param_4)) * (1.0 - (exp(0.0 - pow((3.95 - (3.4)) / (max(0.001, 0.09 * 6)), 2.0))))))))); +voice_0_graph_segment_area_2 = max(0.000001, 0.2916); +voice_0_graph_connection_coupling_side_coupler_connection = clip01(0.62); +voice_0_graph_connection_loss_side_coupler_connection = clip01(1); +voice_0_graph_radiation_gain = 1.0; +voice_0_graph_source_core_valve = 0.0; +voice_0_graph_source_side_valve = 0.0; +voice_0_graph(x) = voice_0_graph_loop ~ si.bus(6) : (si.block(6), _) with { + voice_0_graph_loop(r0, r1, r2, l0, l1, l2) = voice_0_graph_next_r0, voice_0_graph_next_r1, voice_0_graph_next_r2, voice_0_graph_next_l0, voice_0_graph_next_l1, voice_0_graph_next_l2, voice_0_graph_out with { + voice_0_graph_in_0_start = l0; + voice_0_graph_in_0_end = r0; + voice_0_graph_in_1_start = l1; + voice_0_graph_in_1_end = r1; + voice_0_graph_in_2_start = l2; + voice_0_graph_in_2_end = r2; + voice_0_graph_source_core_valve_core_valve_load_pressure = voice_0_graph_node_incident_pressure_core_valve; + voice_0_graph_source_core_valve_core_valve_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 190 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_core_valve_core_valve_flow_scale = max(0.0, 1.1); + voice_0_graph_source_core_valve_core_valve_tissue_loss = clip01(0.18); + voice_0_graph_source_core_valve_core_valve_aperture_shape = clip01(0.44); + voice_0_graph_source_core_valve_core_valve_flow_loss = max(0.0, 0.38); + voice_0_graph_source_core_valve_core_valve_reservoir_pressure = (clip01(patch_param_0)) * (max(0.0, 1)); + voice_0_graph_source_core_valve_core_valve_downstream_pressure = (max(0.0, 0.03)) + (max(0.0, 0.38)) * ma.tanh(voice_0_graph_source_core_valve_core_valve_load_pressure); + voice_0_graph_source_core_valve_core_valve_pressure_drive = max(0.0, voice_0_graph_source_core_valve_core_valve_reservoir_pressure - voice_0_graph_source_core_valve_core_valve_downstream_pressure); + voice_0_graph_source_core_valve_core_valve_stiffness = voice_0_graph_source_core_valve_core_valve_stiffness_hint * (0.35 + 1.65 * (clip01(0.44))); + voice_0_graph_source_core_valve_core_valve_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_core_valve_core_valve_stiffness) / (max(0.02, 0.35))))); + voice_0_graph_source_core_valve_core_valve_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_core_valve_core_valve_load_pressure * (max(0.0, 0.38))); + voice_0_graph_source_core_valve_core_valve_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.18)) + 0.080 * voice_0_graph_source_core_valve_core_valve_tissue_loss + 0.18 * clip01(max(0.0, patch_param_2)); + voice_0_graph_source_core_valve_core_valve_oscillation_gate = clip01((voice_0_graph_source_core_valve_core_valve_pressure_drive - voice_0_graph_source_core_valve_core_valve_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.18))))); + voice_0_graph_source_core_valve_core_valve_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_0)) * (1.0 - 0.45 * (max(0.0, 0.18)) - 0.35 * voice_0_graph_source_core_valve_core_valve_tissue_loss) + 0.35 * (clip01(0.44))); + voice_0_graph_source_core_valve_core_valve_modal_seed = (no.noise * 0.018 + voice_0_graph_source_core_valve_core_valve_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_2))) * 0.16); + voice_0_graph_source_core_valve_core_valve_modal_ring = voice_0_graph_source_core_valve_core_valve_modal_seed : fi.resonbp(voice_0_graph_source_core_valve_core_valve_modal_frequency, voice_0_graph_source_core_valve_core_valve_modal_q, 1); + voice_0_graph_source_core_valve_core_valve_modal_oscillator = os.osc(voice_0_graph_source_core_valve_core_valve_modal_frequency * voice_0_graph_source_core_valve_core_valve_load_detune) * voice_0_graph_source_core_valve_core_valve_oscillation_gate; + voice_0_graph_source_core_valve_core_valve_modal_tissue = (voice_0_graph_source_core_valve_core_valve_modal_oscillator * (0.70 + 0.80 * (clip01(0.44))) + voice_0_graph_source_core_valve_core_valve_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.18)) - 0.45 * voice_0_graph_source_core_valve_core_valve_tissue_loss); + voice_0_graph_source_core_valve_core_valve_upper_stiffness_effective = max((max(0.0, 0)), voice_0_graph_source_core_valve_core_valve_stiffness * (0.80 + 0.45 * (clip01(0.44)))); + voice_0_graph_source_core_valve_core_valve_lower_stiffness_effective = max((max(0.0, 0)), voice_0_graph_source_core_valve_core_valve_stiffness * (1.05 + 0.55 * (clip01(0.44)))); + voice_0_graph_source_core_valve_core_valve_coupling_stiffness = (max(0.0, 0.12)) * (1.0 + 1.5 * (clip01(0.44))); + voice_0_graph_source_core_valve_core_valve_lower_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.010 + 0.090 * (max(0.0, 0.18)) + 0.040 * (max(0.0, 0.12)) + 0.055 * voice_0_graph_source_core_valve_core_valve_tissue_loss) / (max(0.02, 0.3))))); + voice_0_graph_source_core_valve_core_valve_upper_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.012 + 0.105 * (max(0.0, 0.18)) + 0.030 * (max(0.0, 0.12)) + 0.055 * voice_0_graph_source_core_valve_core_valve_tissue_loss) / (max(0.02, 0.18))))); + voice_0_graph_source_core_valve_core_valve_lower_force = (voice_0_graph_source_core_valve_core_valve_pressure_drive * (0.0005 + 0.0028 * (1.0 - clip01(max(0.0, patch_param_2)))) - (max(0.0, 0.38)) * voice_0_graph_source_core_valve_core_valve_load_pressure * 0.0012) / (max(0.02, 0.3)); + voice_0_graph_source_core_valve_core_valve_upper_force = (voice_0_graph_source_core_valve_core_valve_pressure_drive * (0.0003 + 0.0018 * (1.0 - clip01(max(0.0, patch_param_2)))) - (max(0.0, 0.38)) * voice_0_graph_source_core_valve_core_valve_load_pressure * 0.0008) / (max(0.02, 0.18)); + voice_0_graph_source_core_valve_core_valve_lower_velocity = voice_0_graph_source_core_valve_core_valve_lower_force : + ~ *(voice_0_graph_source_core_valve_core_valve_lower_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_core_valve_core_valve_lower_stiffness_effective + voice_0_graph_source_core_valve_core_valve_coupling_stiffness + 0.4 * (max(0.0, 0.8)))); + voice_0_graph_source_core_valve_core_valve_upper_velocity = (voice_0_graph_source_core_valve_core_valve_upper_force + voice_0_graph_source_core_valve_core_valve_lower_velocity * voice_0_graph_source_core_valve_core_valve_coupling_stiffness * 0.35) : + ~ *(voice_0_graph_source_core_valve_core_valve_upper_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_core_valve_core_valve_upper_stiffness_effective + voice_0_graph_source_core_valve_core_valve_coupling_stiffness + 0.4 * (max(0.0, 0.8)))); + voice_0_graph_source_core_valve_core_valve_lower_displacement = voice_0_graph_source_core_valve_core_valve_lower_velocity : + ~ *(min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.3))))); + voice_0_graph_source_core_valve_core_valve_upper_displacement = voice_0_graph_source_core_valve_core_valve_upper_velocity : + ~ *(min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.18))))); + voice_0_graph_source_core_valve_core_valve_collision = (max(0.0, 0.45)) * max(0.0, 0.0 - ((max(0.0, 0.03)) + (max(0.0, patch_param_2)) + voice_0_graph_source_core_valve_core_valve_upper_displacement)); + voice_0_graph_source_core_valve_core_valve_displacement = voice_0_graph_source_core_valve_core_valve_lower_displacement * (1.0 - (clip01(0.42))) + (voice_0_graph_source_core_valve_core_valve_upper_displacement - voice_0_graph_source_core_valve_core_valve_collision) * (clip01(0.42)); + voice_0_graph_source_core_valve_core_valve_aperture_linear = max(0.0, (max(0.0, 0.03)) + (max(0.0, patch_param_2)) + voice_0_graph_source_core_valve_core_valve_displacement - (max(0.0, 0.8)) * pow(voice_0_graph_source_core_valve_core_valve_displacement, 3.0)); + voice_0_graph_source_core_valve_core_valve_aperture = voice_0_graph_source_core_valve_core_valve_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_core_valve_core_valve_aperture_shape) + pow(voice_0_graph_source_core_valve_core_valve_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_core_valve_core_valve_aperture_shape); + voice_0_graph_source_core_valve_core_valve_flow_resistance = 1.0 + voice_0_graph_source_core_valve_core_valve_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_core_valve_core_valve_aperture + (max(0.0, 0.03)))); + voice_0_graph_source_core_valve_core_valve_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_core_valve_core_valve_aperture)); + voice_0_graph_source_core_valve_core_valve_voicing = voice_0_graph_source_core_valve_core_valve_modal_tissue * (0.18 + 1.45 * (clip01(0.44))); + voice_0_graph_source_core_valve_core_valve_flow = ma.tanh(((voice_0_graph_source_core_valve_core_valve_pressure_drive * voice_0_graph_source_core_valve_core_valve_aperture * (1.5 + 3.5 * voice_0_graph_source_core_valve_core_valve_flow_scale)) + (voice_0_graph_source_core_valve_core_valve_voicing * voice_0_graph_source_core_valve_core_valve_pressure_drive * (0.45 + 1.55 * (clip01(0.44))))) / voice_0_graph_source_core_valve_core_valve_flow_resistance); + voice_0_graph_source_core_valve_core_valve_noise = voice_0_graph_source_core_valve_core_valve_turbulence * (clip01(0.05)) * voice_0_graph_source_core_valve_core_valve_pressure_drive * clip01(voice_0_graph_source_core_valve_core_valve_aperture) * (1.0 - 0.55 * (clip01(0.44))) / voice_0_graph_source_core_valve_core_valve_flow_resistance; + voice_0_graph_source_core_valve_core_valve_out = (voice_0_graph_source_core_valve_core_valve_flow * voice_0_graph_source_core_valve_core_valve_flow_scale * (0.55 + 2.6 * voice_0_graph_source_core_valve_core_valve_pressure_drive) + voice_0_graph_source_core_valve_core_valve_noise) * ((1) * (1.0)); + voice_0_graph_node_incident_pressure_core_valve = (voice_0_graph_in_0_start) / 1; + voice_0_graph_node_source_core_valve = voice_0_graph_source_core_valve_core_valve_out; + voice_0_graph_node_incident_pressure_side_coupler_from = (voice_0_graph_in_0_end + voice_0_graph_in_1_start) / 2; + voice_0_graph_node_source_side_coupler_from = 0.0; + voice_0_graph_node_incident_pressure_aperture = (voice_0_graph_in_1_end) / 1; + voice_0_graph_node_source_aperture = 0.0; + voice_0_graph_source_side_valve_side_valve_load_pressure = voice_0_graph_node_incident_pressure_side_valve; + voice_0_graph_source_side_valve_side_valve_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 190 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_side_valve_side_valve_flow_scale = max(0.0, 0.95); + voice_0_graph_source_side_valve_side_valve_tissue_loss = clip01(0.22); + voice_0_graph_source_side_valve_side_valve_aperture_shape = clip01(0.4); + voice_0_graph_source_side_valve_side_valve_flow_loss = max(0.0, 0.36); + voice_0_graph_source_side_valve_side_valve_reservoir_pressure = (clip01(patch_param_1)) * (max(0.0, 1)); + voice_0_graph_source_side_valve_side_valve_downstream_pressure = (max(0.0, 0.02)) + (max(0.0, 0.34)) * ma.tanh(voice_0_graph_source_side_valve_side_valve_load_pressure); + voice_0_graph_source_side_valve_side_valve_pressure_drive = max(0.0, voice_0_graph_source_side_valve_side_valve_reservoir_pressure - voice_0_graph_source_side_valve_side_valve_downstream_pressure); + voice_0_graph_source_side_valve_side_valve_stiffness = max(0.00002, (max(0.0, 0.026)) * (0.55 + 1.10 * (clip01(0.34)))); + voice_0_graph_source_side_valve_side_valve_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_side_valve_side_valve_stiffness) / (max(0.02, 0.22))))); + voice_0_graph_source_side_valve_side_valve_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_side_valve_side_valve_load_pressure * (max(0.0, 0.34))); + voice_0_graph_source_side_valve_side_valve_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.15)) + 0.080 * voice_0_graph_source_side_valve_side_valve_tissue_loss + 0.18 * clip01(max(0.0, patch_param_3)); + voice_0_graph_source_side_valve_side_valve_oscillation_gate = clip01((voice_0_graph_source_side_valve_side_valve_pressure_drive - voice_0_graph_source_side_valve_side_valve_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.15))))); + voice_0_graph_source_side_valve_side_valve_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_1)) * (1.0 - 0.45 * (max(0.0, 0.15)) - 0.35 * voice_0_graph_source_side_valve_side_valve_tissue_loss) + 0.35 * (clip01(0.34))); + voice_0_graph_source_side_valve_side_valve_modal_seed = (no.noise * 0.018 + voice_0_graph_source_side_valve_side_valve_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_3))) * 0.16); + voice_0_graph_source_side_valve_side_valve_modal_ring = voice_0_graph_source_side_valve_side_valve_modal_seed : fi.resonbp(voice_0_graph_source_side_valve_side_valve_modal_frequency, voice_0_graph_source_side_valve_side_valve_modal_q, 1); + voice_0_graph_source_side_valve_side_valve_modal_oscillator = os.osc(voice_0_graph_source_side_valve_side_valve_modal_frequency * voice_0_graph_source_side_valve_side_valve_load_detune) * voice_0_graph_source_side_valve_side_valve_oscillation_gate; + voice_0_graph_source_side_valve_side_valve_modal_tissue = (voice_0_graph_source_side_valve_side_valve_modal_oscillator * (0.70 + 0.80 * (clip01(0.34))) + voice_0_graph_source_side_valve_side_valve_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.15)) - 0.45 * voice_0_graph_source_side_valve_side_valve_tissue_loss); + voice_0_graph_source_side_valve_side_valve_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, 0.15)) + 0.055 * voice_0_graph_source_side_valve_side_valve_tissue_loss) / (max(0.02, 0.22))))); + voice_0_graph_source_side_valve_side_valve_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.22)))); + voice_0_graph_source_side_valve_side_valve_force = (voice_0_graph_source_side_valve_side_valve_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_3)))) - (max(0.0, 0.34)) * voice_0_graph_source_side_valve_side_valve_load_pressure * 0.001) / (max(0.02, 0.22)); + voice_0_graph_source_side_valve_side_valve_velocity = voice_0_graph_source_side_valve_side_valve_force : + ~ *(voice_0_graph_source_side_valve_side_valve_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_side_valve_side_valve_stiffness + 0.4 * (max(0.0, 0.8)))); + voice_0_graph_source_side_valve_side_valve_displacement = voice_0_graph_source_side_valve_side_valve_velocity : + ~ *(voice_0_graph_source_side_valve_side_valve_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_side_valve_side_valve_stiffness)); + voice_0_graph_source_side_valve_side_valve_aperture_linear = max(0.0, (max(0.0, 0.04)) + (max(0.0, patch_param_3)) + voice_0_graph_source_side_valve_side_valve_displacement - (max(0.0, 0.8)) * pow(voice_0_graph_source_side_valve_side_valve_displacement, 3.0)); + voice_0_graph_source_side_valve_side_valve_aperture = voice_0_graph_source_side_valve_side_valve_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_side_valve_side_valve_aperture_shape) + pow(voice_0_graph_source_side_valve_side_valve_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_side_valve_side_valve_aperture_shape); + voice_0_graph_source_side_valve_side_valve_flow_resistance = 1.0 + voice_0_graph_source_side_valve_side_valve_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_side_valve_side_valve_aperture + (max(0.0, 0.04)))); + voice_0_graph_source_side_valve_side_valve_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_side_valve_side_valve_aperture)); + voice_0_graph_source_side_valve_side_valve_voicing = voice_0_graph_source_side_valve_side_valve_modal_tissue * (0.18 + 1.45 * (clip01(0.34))); + voice_0_graph_source_side_valve_side_valve_flow = ma.tanh(((voice_0_graph_source_side_valve_side_valve_pressure_drive * voice_0_graph_source_side_valve_side_valve_aperture * (1.5 + 3.5 * voice_0_graph_source_side_valve_side_valve_flow_scale)) + (voice_0_graph_source_side_valve_side_valve_voicing * voice_0_graph_source_side_valve_side_valve_pressure_drive * (0.45 + 1.55 * (clip01(0.34))))) / voice_0_graph_source_side_valve_side_valve_flow_resistance); + voice_0_graph_source_side_valve_side_valve_noise = voice_0_graph_source_side_valve_side_valve_turbulence * (clip01(0.04)) * voice_0_graph_source_side_valve_side_valve_pressure_drive * clip01(voice_0_graph_source_side_valve_side_valve_aperture) * (1.0 - 0.55 * (clip01(0.34))) / voice_0_graph_source_side_valve_side_valve_flow_resistance; + voice_0_graph_source_side_valve_side_valve_out = (voice_0_graph_source_side_valve_side_valve_flow * voice_0_graph_source_side_valve_side_valve_flow_scale * (0.55 + 2.6 * voice_0_graph_source_side_valve_side_valve_pressure_drive) + voice_0_graph_source_side_valve_side_valve_noise) * ((1) * (1.0)); + voice_0_graph_node_incident_pressure_side_valve = (voice_0_graph_in_2_start) / 1; + voice_0_graph_node_source_side_valve = voice_0_graph_source_side_valve_side_valve_out; + voice_0_graph_node_incident_pressure_side_coupler_to = (voice_0_graph_in_2_end) / 1; + voice_0_graph_node_source_side_coupler_to = 0.0; + voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_from_0_end = (2.0 * ((voice_0_graph_terminal_area_side_coupler_from / 2)) - ((voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_to / 1))) / max(0.000001, (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_to / 1)); + voice_0_graph_connection_scattered_side_coupler_connection_side_coupler_from_0_end = voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_from_0_end * voice_0_graph_in_0_end + (1.0 + voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_from_0_end) * (voice_0_graph_in_1_start + voice_0_graph_in_2_end); + voice_0_graph_out_0_end = ((voice_0_graph_connection_scattered_side_coupler_connection_side_coupler_from_0_end) * (voice_0_graph_connection_coupling_side_coupler_connection) + voice_0_graph_in_0_end * (1.0 - (voice_0_graph_connection_coupling_side_coupler_connection)) + (voice_0_graph_node_source_side_coupler_from) / 2) * voice_0_graph_connection_loss_side_coupler_connection; + voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_from_1_start = (2.0 * ((voice_0_graph_terminal_area_side_coupler_from / 2)) - ((voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_to / 1))) / max(0.000001, (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_to / 1)); + voice_0_graph_connection_scattered_side_coupler_connection_side_coupler_from_1_start = voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_from_1_start * voice_0_graph_in_1_start + (1.0 + voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_from_1_start) * (voice_0_graph_in_0_end + voice_0_graph_in_2_end); + voice_0_graph_out_1_start = ((voice_0_graph_connection_scattered_side_coupler_connection_side_coupler_from_1_start) * (voice_0_graph_connection_coupling_side_coupler_connection) + voice_0_graph_in_1_start * (1.0 - (voice_0_graph_connection_coupling_side_coupler_connection)) + (voice_0_graph_node_source_side_coupler_from) / 2) * voice_0_graph_connection_loss_side_coupler_connection; + voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_to_2_end = (2.0 * ((voice_0_graph_terminal_area_side_coupler_to / 1)) - ((voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_to / 1))) / max(0.000001, (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_from / 2) + (voice_0_graph_terminal_area_side_coupler_to / 1)); + voice_0_graph_connection_scattered_side_coupler_connection_side_coupler_to_2_end = voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_to_2_end * voice_0_graph_in_2_end + (1.0 + voice_0_graph_connection_reflection_side_coupler_connection_side_coupler_to_2_end) * (voice_0_graph_in_0_end + voice_0_graph_in_1_start); + voice_0_graph_out_2_end = ((voice_0_graph_connection_scattered_side_coupler_connection_side_coupler_to_2_end) * (voice_0_graph_connection_coupling_side_coupler_connection) + voice_0_graph_in_2_end * (1.0 - (voice_0_graph_connection_coupling_side_coupler_connection)) + (voice_0_graph_node_source_side_coupler_to) / 1) * voice_0_graph_connection_loss_side_coupler_connection; + voice_0_graph_connection_energy_in_side_coupler_connection = ((voice_0_graph_terminal_area_side_coupler_from / 2)) * pow(voice_0_graph_in_0_end, 2.0) + ((voice_0_graph_terminal_area_side_coupler_from / 2)) * pow(voice_0_graph_in_1_start, 2.0) + ((voice_0_graph_terminal_area_side_coupler_to / 1)) * pow(voice_0_graph_in_2_end, 2.0); + voice_0_graph_connection_energy_out_side_coupler_connection = ((voice_0_graph_terminal_area_side_coupler_from / 2)) * pow(voice_0_graph_out_0_end, 2.0) + ((voice_0_graph_terminal_area_side_coupler_from / 2)) * pow(voice_0_graph_out_1_start, 2.0) + ((voice_0_graph_terminal_area_side_coupler_to / 1)) * pow(voice_0_graph_out_2_end, 2.0); + voice_0_graph_out_0_start = voice_0_graph_in_0_start * voice_0_graph_node_reflection_core_valve + (voice_0_graph_node_source_core_valve) / 1; + voice_0_graph_radiation_boundary_load_aperture = clip01((voice_0_graph_radiation_admittance_aperture) * (voice_0_graph_radiation_differentiation_aperture) * (clip01(0.96))); + voice_0_graph_radiation_reflected_raw_aperture = (voice_0_graph_in_1_end) * (voice_0_graph_terminal_reflection_aperture) + (voice_0_graph_node_source_aperture); + voice_0_graph_radiation_reflected_loaded_aperture = (voice_0_graph_radiation_reflected_raw_aperture) * (1.0 - (voice_0_graph_radiation_boundary_load_aperture)) + ((voice_0_graph_radiation_reflected_raw_aperture) : fi.lowpass(1, voice_0_graph_radiation_highpass_aperture)) * (voice_0_graph_radiation_boundary_load_aperture); + voice_0_graph_out_1_end = voice_0_graph_radiation_reflected_loaded_aperture; + voice_0_graph_radiation_model_aperture = 4; + voice_0_graph_radiation_reference_area_aperture = 0.35; + voice_0_graph_radiation_differentiation_aperture = 0.18; + voice_0_graph_radiation_highpass_aperture = 15.0; + voice_0_graph_radiation_admittance_aperture = sqrt(clip01((voice_0_graph_terminal_area_aperture) / max(0.000001, (voice_0_graph_terminal_area_aperture) + (voice_0_graph_radiation_reference_area_aperture)))); + voice_0_graph_radiation_flow_aperture = ((voice_0_graph_in_1_end - voice_0_graph_out_1_end)); + voice_0_graph_out_2_start = voice_0_graph_in_2_start * voice_0_graph_node_reflection_side_valve + (voice_0_graph_node_source_side_valve) / 1; + voice_0_graph_delay_0 = max(0.000001, 0.00033819 * ma.SR); + voice_0_graph_segment_loss_0 = clip01((0.996) * (sqrt(clip01((voice_0_graph_segment_area_0) / max(0.000001, (voice_0_graph_segment_area_0) + 0.012))) * (0.998 - 0.010 * clip01(0.080 / max(0.000001, (voice_0_graph_segment_area_0) + 0.080))))); + voice_0_graph_next_r0 = voice_0_graph_out_0_start : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_next_l0 = voice_0_graph_out_0_end : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_delay_1 = max(0.000001, 0.0002449 * ma.SR); + voice_0_graph_segment_loss_1 = clip01((0.996) * (sqrt(clip01((voice_0_graph_segment_area_1) / max(0.000001, (voice_0_graph_segment_area_1) + 0.012))) * (0.998 - 0.010 * clip01(0.080 / max(0.000001, (voice_0_graph_segment_area_1) + 0.080))))); + voice_0_graph_next_r1 = voice_0_graph_out_1_start : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_next_l1 = voice_0_graph_out_1_end : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_delay_2 = max(0.000001, 0.00026239 * ma.SR); + voice_0_graph_segment_loss_2 = clip01((0.994) * ((0.996 - 0.018 * clip01(0.050 / max(0.000001, (voice_0_graph_segment_area_2) + 0.050))))); + voice_0_graph_next_r2 = voice_0_graph_out_2_start : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_next_l2 = voice_0_graph_out_2_end : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_out = (((voice_0_graph_radiation_flow_aperture * (1.0 - (voice_0_graph_radiation_differentiation_aperture)) + (voice_0_graph_radiation_flow_aperture : fi.highpass(1, voice_0_graph_radiation_highpass_aperture)) * (voice_0_graph_radiation_differentiation_aperture)) * clip01(0.96) * voice_0_graph_radiation_admittance_aperture)) * voice_0_graph_radiation_gain; + }; +}; +voice_0_acoustic_graph_radiated = voice_0_graph(voice_0_graph_drive); +voice_0_freq = ((max(20, 190 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = voice_0_acoustic_graph_radiated; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.12, 0.9) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.2); + +process = softclip((voice_0) * 0.36); diff --git a/tools/aqua-playground/lowered/advanced-aurora-pad.dsp b/tools/aqua-playground/lowered/advanced-aurora-pad.dsp new file mode 100644 index 0000000..c28862e --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-aurora-pad.dsp @@ -0,0 +1,87 @@ +import("stdfaust.lib"); +declare name "advanced-aurora-pad"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.08 * lfo_sin(0.21, 0); +patch_mod_pitch = 0 + 0.012 * lfo_sin(0.21, 0) + 0 + 0.004 * lfo_tri(4.6, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + 0.09 * lfo_sin(0.21, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0 + 0.035 * lfo_tri(4.6, 0); +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0 + 0.16 * lfo_sin(0.21, 0); +patch_mod_fm_index = 0 + 0.35 * lfo_sin(0.21, 0); + +voice_0_age = age; +voice_0_freq = ((max(20, 220 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 220 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 220 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2.414))) * (max(0.0, 1.4 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.8, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.86 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.018 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.018 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = ((voice_0_phased : fi.resonbp(420, 5.25, 1.0)) * 0.25 + (voice_0_phased : fi.resonbp(1180, 6.555555, 1.0)) * 0.75 + (voice_0_phased : fi.resonbp(2450, 6.805555, 1.0)) * 0.42) / 1.42; +voice_0 = ((voice_0_phased * (1.0 - clip01(0.18 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0.18 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.018, 0, 1, 1.6, 1.15) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +voice_1_age = age; +voice_1_freq = ((max(20, 330 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 330 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 330 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3.01))) * (max(0.0, 0.9 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.8, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.86 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.018 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.018 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = ((voice_1_phased : fi.resonbp(420, 5.25, 1.0)) * 0.25 + (voice_1_phased : fi.resonbp(1180, 6.555555, 1.0)) * 0.75 + (voice_1_phased : fi.resonbp(2450, 6.805555, 1.0)) * 0.42) / 1.42; +voice_1 = ((voice_1_phased * (1.0 - clip01(0.18 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0.18 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.018, 0, 1, 1.6, 1.15) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +voice_2_age = age; +voice_2_freq = ((max(20, 440 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 440 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 440 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1.618))) * (max(0.0, 0.7 + patch_mod_fm_index + 0.0) * exp(-voice_2_age / max(0.8, 0.0001))) / ma.PI)); +voice_2_colored = (voice_2_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.86 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.018 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.018 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered; +voice_2_formants = ((voice_2_phased : fi.resonbp(420, 5.25, 1.0)) * 0.25 + (voice_2_phased : fi.resonbp(1180, 6.555555, 1.0)) * 0.75 + (voice_2_phased : fi.resonbp(2450, 6.805555, 1.0)) * 0.42) / 1.42; +voice_2 = ((voice_2_phased * (1.0 - clip01(0.26 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0.26 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0.018, 0, 1, 1.6, 1.15) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.06); + +voice_3_age = age; +voice_3_freq = ((max(20, 1600 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = no.noise; +voice_3_colored = (voice_3_osc * (1.0 - clip01(0.72 + patch_mod_noise + 0.0)) + no.noise * clip01(0.72 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(0.38 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.62 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.62 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = voice_3_phased; +voice_3 = ((voice_3_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0.018, 0, 1, 2, 1.4) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.018); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3) * 0.58); diff --git a/tools/aqua-playground/lowered/advanced-bird-syrinx-graph.dsp b/tools/aqua-playground/lowered/advanced-bird-syrinx-graph.dsp new file mode 100644 index 0000000..7234e76 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-bird-syrinx-graph.dsp @@ -0,0 +1,238 @@ +import("stdfaust.lib"); +declare name "advanced-bird-syrinx-graph"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0_base = hslider("/bird/left/pressure", 0.84, 0, 1.5, 0.001) : si.smoo; +patch_param_0_curve_time = max(0.0, age * 1 - 0); +patch_param_0_curve_value = select2(patch_param_0_curve_time < 0.025, select2(patch_param_0_curve_time < 0.22, select2(patch_param_0_curve_time < 0.54, select2(patch_param_0_curve_time < 0.82, 0.18, seg(patch_param_0_curve_time, 0.54, 0.28, 0.88, 0.18)), seg(patch_param_0_curve_time, 0.22, 0.32, 0.78, 0.88)), seg(patch_param_0_curve_time, 0.025, 0.195, 0.92, 0.78)), seg(patch_param_0_curve_time, 0, 0.025, 0.04, 0.92)); +patch_param_0_curve_depth = hslider("/curves/left_air/depth", 0.95, 0, 1, 0.001) : si.smoo; +patch_param_0 = min(1.5, max(0, patch_param_0_base * (1.0 - patch_param_0_curve_depth) + patch_param_0_curve_value * patch_param_0_curve_depth)); +patch_param_1_base = hslider("/bird/right/pressure", 0.72, 0, 1.5, 0.001) : si.smoo; +patch_param_1_curve_time = max(0.0, age * 1 - 0); +patch_param_1_curve_value = select2(patch_param_1_curve_time < 0.035, select2(patch_param_1_curve_time < 0.18, select2(patch_param_1_curve_time < 0.48, select2(patch_param_1_curve_time < 0.82, 0.12, seg(patch_param_1_curve_time, 0.48, 0.34, 0.62, 0.12)), seg(patch_param_1_curve_time, 0.18, 0.3, 0.82, 0.62)), seg(patch_param_1_curve_time, 0.035, 0.145, 0.75, 0.82)), seg(patch_param_1_curve_time, 0, 0.035, 0.02, 0.75)); +patch_param_1_curve_depth = hslider("/curves/right_air/depth", 0.95, 0, 1, 0.001) : si.smoo; +patch_param_1 = min(1.5, max(0, patch_param_1_base * (1.0 - patch_param_1_curve_depth) + patch_param_1_curve_value * patch_param_1_curve_depth)); +patch_param_2_base = hslider("/bird/left/opening", 0.2, 0, 1, 0.001) : si.smoo; +patch_param_2_curve_time = max(0.0, age * 1 - 0); +patch_param_2_curve_value = select2(patch_param_2_curve_time < 0.03, select2(patch_param_2_curve_time < 0.62, select2(patch_param_2_curve_time < 0.82, 0.02, seg(patch_param_2_curve_time, 0.62, 0.2, 0.18, 0.02)), seg(patch_param_2_curve_time, 0.03, 0.59, 0.21, 0.18)), seg(patch_param_2_curve_time, 0, 0.03, 0.01, 0.21)); +patch_param_2_curve_depth = hslider("/curves/left_labium_gate/depth", 0.9, 0, 1, 0.001) : si.smoo; +patch_param_2 = min(1, max(0, patch_param_2_base * (1.0 - patch_param_2_curve_depth) + patch_param_2_curve_value * patch_param_2_curve_depth)); +patch_param_3_base = hslider("/bird/right/opening", 0.18, 0, 1, 0.001) : si.smoo; +patch_param_3_curve_time = max(0.0, age * 1 - 0); +patch_param_3_curve_value = select2(patch_param_3_curve_time < 0.035, select2(patch_param_3_curve_time < 0.54, select2(patch_param_3_curve_time < 0.82, 0.02, seg(patch_param_3_curve_time, 0.54, 0.28, 0.15, 0.02)), seg(patch_param_3_curve_time, 0.035, 0.505, 0.18, 0.15)), seg(patch_param_3_curve_time, 0, 0.035, 0.01, 0.18)); +patch_param_3_curve_depth = hslider("/curves/right_labium_gate/depth", 0.9, 0, 1, 0.001) : si.smoo; +patch_param_3 = min(1, max(0, patch_param_3_base * (1.0 - patch_param_3_curve_depth) + patch_param_3_curve_value * patch_param_3_curve_depth)); +patch_param_4 = hslider("/bird/left/tension", 0.46, 0, 1, 0.001) : si.smoo; +patch_param_5 = hslider("/bird/right/tension", 0.52, 0, 1, 0.001) : si.smoo; +patch_param_6_base = hslider("/bird/beak/opening", 0.92, 0, 1.5, 0.001) : si.smoo; +patch_param_6_curve_time = max(0.0, age * 1 - 0); +patch_param_6_curve_value = select2(patch_param_6_curve_time < 0.04, select2(patch_param_6_curve_time < 0.44, select2(patch_param_6_curve_time < 0.82, 0.35, seg(patch_param_6_curve_time, 0.44, 0.38, 1.08, 0.35)), seg(patch_param_6_curve_time, 0.04, 0.4, 0.92, 1.08)), seg(patch_param_6_curve_time, 0, 0.04, 0.22, 0.92)); +patch_param_6_curve_depth = hslider("/curves/beak_gate/depth", 0.75, 0, 1, 0.001) : si.smoo; +patch_param_6 = min(1.5, max(0, patch_param_6_base * (1.0 - patch_param_6_curve_depth) + patch_param_6_curve_value * patch_param_6_curve_depth)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_graph_drive = 1.0; +voice_0_graph_terminal_area_left_merge = max(0.000001, 0.1444 * max(0.0, 1)); +voice_0_graph_terminal_reflection_left_merge = 0; +voice_0_graph_terminal_area_right_merge = max(0.000001, 0.1296 * max(0.0, 1)); +voice_0_graph_terminal_reflection_right_merge = 0; +voice_0_graph_terminal_area_trachea_base = max(0.000001, 0.1296 * max(0.0, 1)); +voice_0_graph_terminal_reflection_trachea_base = 0; +voice_0_graph_terminal_area_left_labium = max(0.000001, 0.0324 * max(0.0, 1)); +voice_0_graph_terminal_reflection_left_labium = 0; +voice_0_graph_terminal_area_right_labium = max(0.000001, 0.0289 * max(0.0, 1)); +voice_0_graph_terminal_reflection_right_labium = 0; +voice_0_graph_terminal_area_beak = max(0.000001, 0.1444 * max(0.0, 0.92)); +voice_0_graph_terminal_reflection_beak = ((0.96) * (1.0 - clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))) + (-0.72) * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))); +voice_0_graph_node_area_left_labium = max(0.000001, voice_0_graph_terminal_area_left_labium); +voice_0_graph_node_reflection_left_labium = (voice_0_graph_terminal_reflection_left_labium) / 1; +voice_0_graph_node_area_left_merge = max(0.000001, voice_0_graph_terminal_area_left_merge); +voice_0_graph_node_reflection_left_merge = (voice_0_graph_terminal_reflection_left_merge) / 1; +voice_0_graph_node_area_right_labium = max(0.000001, voice_0_graph_terminal_area_right_labium); +voice_0_graph_node_reflection_right_labium = (voice_0_graph_terminal_reflection_right_labium) / 1; +voice_0_graph_node_area_right_merge = max(0.000001, voice_0_graph_terminal_area_right_merge); +voice_0_graph_node_reflection_right_merge = (voice_0_graph_terminal_reflection_right_merge) / 1; +voice_0_graph_node_area_trachea_base = max(0.000001, voice_0_graph_terminal_area_trachea_base); +voice_0_graph_node_reflection_trachea_base = (voice_0_graph_terminal_reflection_trachea_base) / 1; +voice_0_graph_node_area_beak = max(0.000001, voice_0_graph_terminal_area_beak); +voice_0_graph_node_reflection_beak = (voice_0_graph_terminal_reflection_beak) / 1; +voice_0_graph_segment_area_0 = max(0.000001, 0.075625); +voice_0_graph_segment_area_1 = max(0.000001, 0.07022501); +voice_0_graph_segment_area_2 = max(0.000001, 0.2916); +voice_0_graph_connection_coupling_syrinx_merge = clip01(1); +voice_0_graph_connection_loss_syrinx_merge = clip01(1); +voice_0_graph_radiation_gain = 1.0; +voice_0_graph_source_left_labium = 0.0; +voice_0_graph_source_right_labium = 0.0; +voice_0_graph(x) = voice_0_graph_loop ~ si.bus(6) : (si.block(6), _) with { + voice_0_graph_loop(r0, r1, r2, l0, l1, l2) = voice_0_graph_next_r0, voice_0_graph_next_r1, voice_0_graph_next_r2, voice_0_graph_next_l0, voice_0_graph_next_l1, voice_0_graph_next_l2, voice_0_graph_out with { + voice_0_graph_in_0_start = l0; + voice_0_graph_in_0_end = r0; + voice_0_graph_in_1_start = l1; + voice_0_graph_in_1_end = r1; + voice_0_graph_in_2_start = l2; + voice_0_graph_in_2_end = r2; + voice_0_graph_source_left_labium_left_labium_load_pressure = voice_0_graph_node_incident_pressure_left_labium; + voice_0_graph_source_left_labium_left_labium_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 980 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_left_labium_left_labium_flow_scale = max(0.0, 1.22); + voice_0_graph_source_left_labium_left_labium_tissue_loss = clip01(0.16); + voice_0_graph_source_left_labium_left_labium_aperture_shape = clip01(0.38); + voice_0_graph_source_left_labium_left_labium_flow_loss = max(0.0, 0.32); + voice_0_graph_source_left_labium_left_labium_reservoir_pressure = (clip01(patch_param_0)) * (max(0.0, 1)); + voice_0_graph_source_left_labium_left_labium_downstream_pressure = (max(0.0, 0.02)) + (max(0.0, 0.46)) * ma.tanh(voice_0_graph_source_left_labium_left_labium_load_pressure); + voice_0_graph_source_left_labium_left_labium_pressure_drive = max(0.0, voice_0_graph_source_left_labium_left_labium_reservoir_pressure - voice_0_graph_source_left_labium_left_labium_downstream_pressure); + voice_0_graph_source_left_labium_left_labium_stiffness = max(0.00002, (max(0.0, 0.032)) * (0.55 + 1.10 * (clip01(patch_param_4)))); + voice_0_graph_source_left_labium_left_labium_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_left_labium_left_labium_stiffness) / (max(0.02, 0.24))))); + voice_0_graph_source_left_labium_left_labium_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_left_labium_left_labium_load_pressure * (max(0.0, 0.46))); + voice_0_graph_source_left_labium_left_labium_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.11)) + 0.080 * voice_0_graph_source_left_labium_left_labium_tissue_loss + 0.18 * clip01(max(0.0, patch_param_2)); + voice_0_graph_source_left_labium_left_labium_oscillation_gate = clip01((voice_0_graph_source_left_labium_left_labium_pressure_drive - voice_0_graph_source_left_labium_left_labium_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.11))))); + voice_0_graph_source_left_labium_left_labium_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_0)) * (1.0 - 0.45 * (max(0.0, 0.11)) - 0.35 * voice_0_graph_source_left_labium_left_labium_tissue_loss) + 0.35 * (clip01(patch_param_4))); + voice_0_graph_source_left_labium_left_labium_modal_seed = (no.noise * 0.018 + voice_0_graph_source_left_labium_left_labium_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_2))) * 0.16); + voice_0_graph_source_left_labium_left_labium_modal_ring = voice_0_graph_source_left_labium_left_labium_modal_seed : fi.resonbp(voice_0_graph_source_left_labium_left_labium_modal_frequency, voice_0_graph_source_left_labium_left_labium_modal_q, 1); + voice_0_graph_source_left_labium_left_labium_modal_oscillator = os.osc(voice_0_graph_source_left_labium_left_labium_modal_frequency * voice_0_graph_source_left_labium_left_labium_load_detune) * voice_0_graph_source_left_labium_left_labium_oscillation_gate; + voice_0_graph_source_left_labium_left_labium_modal_tissue = (voice_0_graph_source_left_labium_left_labium_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_4))) + voice_0_graph_source_left_labium_left_labium_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.11)) - 0.45 * voice_0_graph_source_left_labium_left_labium_tissue_loss); + voice_0_graph_source_left_labium_left_labium_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, 0.11)) + 0.055 * voice_0_graph_source_left_labium_left_labium_tissue_loss) / (max(0.02, 0.24))))); + voice_0_graph_source_left_labium_left_labium_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.24)))); + voice_0_graph_source_left_labium_left_labium_force = (voice_0_graph_source_left_labium_left_labium_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_2)))) - (max(0.0, 0.46)) * voice_0_graph_source_left_labium_left_labium_load_pressure * 0.001) / (max(0.02, 0.24)); + voice_0_graph_source_left_labium_left_labium_velocity = voice_0_graph_source_left_labium_left_labium_force : + ~ *(voice_0_graph_source_left_labium_left_labium_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_left_labium_left_labium_stiffness + 0.4 * (max(0.0, 0.82)))); + voice_0_graph_source_left_labium_left_labium_displacement = voice_0_graph_source_left_labium_left_labium_velocity : + ~ *(voice_0_graph_source_left_labium_left_labium_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_left_labium_left_labium_stiffness)); + voice_0_graph_source_left_labium_left_labium_aperture_linear = max(0.0, (max(0.0, 0.018)) + (max(0.0, patch_param_2)) + voice_0_graph_source_left_labium_left_labium_displacement - (max(0.0, 0.82)) * pow(voice_0_graph_source_left_labium_left_labium_displacement, 3.0)); + voice_0_graph_source_left_labium_left_labium_aperture = voice_0_graph_source_left_labium_left_labium_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_left_labium_left_labium_aperture_shape) + pow(voice_0_graph_source_left_labium_left_labium_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_left_labium_left_labium_aperture_shape); + voice_0_graph_source_left_labium_left_labium_flow_resistance = 1.0 + voice_0_graph_source_left_labium_left_labium_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_left_labium_left_labium_aperture + (max(0.0, 0.018)))); + voice_0_graph_source_left_labium_left_labium_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_left_labium_left_labium_aperture)); + voice_0_graph_source_left_labium_left_labium_voicing = voice_0_graph_source_left_labium_left_labium_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_4))); + voice_0_graph_source_left_labium_left_labium_flow = ma.tanh(((voice_0_graph_source_left_labium_left_labium_pressure_drive * voice_0_graph_source_left_labium_left_labium_aperture * (1.5 + 3.5 * voice_0_graph_source_left_labium_left_labium_flow_scale)) + (voice_0_graph_source_left_labium_left_labium_voicing * voice_0_graph_source_left_labium_left_labium_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_4))))) / voice_0_graph_source_left_labium_left_labium_flow_resistance); + voice_0_graph_source_left_labium_left_labium_noise = voice_0_graph_source_left_labium_left_labium_turbulence * (clip01(0.018)) * voice_0_graph_source_left_labium_left_labium_pressure_drive * clip01(voice_0_graph_source_left_labium_left_labium_aperture) * (1.0 - 0.55 * (clip01(patch_param_4))) / voice_0_graph_source_left_labium_left_labium_flow_resistance; + voice_0_graph_source_left_labium_left_labium_out = (voice_0_graph_source_left_labium_left_labium_flow * voice_0_graph_source_left_labium_left_labium_flow_scale * (0.55 + 2.6 * voice_0_graph_source_left_labium_left_labium_pressure_drive) + voice_0_graph_source_left_labium_left_labium_noise) * ((1) * (1.0)); + voice_0_graph_node_incident_pressure_left_labium = (voice_0_graph_in_0_start) / 1; + voice_0_graph_node_source_left_labium = voice_0_graph_source_left_labium_left_labium_out; + voice_0_graph_node_incident_pressure_left_merge = (voice_0_graph_in_0_end) / 1; + voice_0_graph_node_source_left_merge = 0.0; + voice_0_graph_source_right_labium_right_labium_load_pressure = voice_0_graph_node_incident_pressure_right_labium; + voice_0_graph_source_right_labium_right_labium_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 980 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_right_labium_right_labium_flow_scale = max(0.0, 1.18); + voice_0_graph_source_right_labium_right_labium_tissue_loss = clip01(0.18); + voice_0_graph_source_right_labium_right_labium_aperture_shape = clip01(0.38); + voice_0_graph_source_right_labium_right_labium_flow_loss = max(0.0, 0.32); + voice_0_graph_source_right_labium_right_labium_reservoir_pressure = (clip01(patch_param_1)) * (max(0.0, 1)); + voice_0_graph_source_right_labium_right_labium_downstream_pressure = (max(0.0, 0.02)) + (max(0.0, 0.46)) * ma.tanh(voice_0_graph_source_right_labium_right_labium_load_pressure); + voice_0_graph_source_right_labium_right_labium_pressure_drive = max(0.0, voice_0_graph_source_right_labium_right_labium_reservoir_pressure - voice_0_graph_source_right_labium_right_labium_downstream_pressure); + voice_0_graph_source_right_labium_right_labium_stiffness = max(0.00002, (max(0.0, 0.036)) * (0.55 + 1.10 * (clip01(patch_param_5)))); + voice_0_graph_source_right_labium_right_labium_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_right_labium_right_labium_stiffness) / (max(0.02, 0.25))))); + voice_0_graph_source_right_labium_right_labium_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_right_labium_right_labium_load_pressure * (max(0.0, 0.46))); + voice_0_graph_source_right_labium_right_labium_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.12)) + 0.080 * voice_0_graph_source_right_labium_right_labium_tissue_loss + 0.18 * clip01(max(0.0, patch_param_3)); + voice_0_graph_source_right_labium_right_labium_oscillation_gate = clip01((voice_0_graph_source_right_labium_right_labium_pressure_drive - voice_0_graph_source_right_labium_right_labium_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.12))))); + voice_0_graph_source_right_labium_right_labium_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_1)) * (1.0 - 0.45 * (max(0.0, 0.12)) - 0.35 * voice_0_graph_source_right_labium_right_labium_tissue_loss) + 0.35 * (clip01(patch_param_5))); + voice_0_graph_source_right_labium_right_labium_modal_seed = (no.noise * 0.018 + voice_0_graph_source_right_labium_right_labium_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_3))) * 0.16); + voice_0_graph_source_right_labium_right_labium_modal_ring = voice_0_graph_source_right_labium_right_labium_modal_seed : fi.resonbp(voice_0_graph_source_right_labium_right_labium_modal_frequency, voice_0_graph_source_right_labium_right_labium_modal_q, 1); + voice_0_graph_source_right_labium_right_labium_modal_oscillator = os.osc(voice_0_graph_source_right_labium_right_labium_modal_frequency * voice_0_graph_source_right_labium_right_labium_load_detune) * voice_0_graph_source_right_labium_right_labium_oscillation_gate; + voice_0_graph_source_right_labium_right_labium_modal_tissue = (voice_0_graph_source_right_labium_right_labium_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_5))) + voice_0_graph_source_right_labium_right_labium_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.12)) - 0.45 * voice_0_graph_source_right_labium_right_labium_tissue_loss); + voice_0_graph_source_right_labium_right_labium_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, 0.12)) + 0.055 * voice_0_graph_source_right_labium_right_labium_tissue_loss) / (max(0.02, 0.25))))); + voice_0_graph_source_right_labium_right_labium_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.25)))); + voice_0_graph_source_right_labium_right_labium_force = (voice_0_graph_source_right_labium_right_labium_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_3)))) - (max(0.0, 0.46)) * voice_0_graph_source_right_labium_right_labium_load_pressure * 0.001) / (max(0.02, 0.25)); + voice_0_graph_source_right_labium_right_labium_velocity = voice_0_graph_source_right_labium_right_labium_force : + ~ *(voice_0_graph_source_right_labium_right_labium_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_right_labium_right_labium_stiffness + 0.4 * (max(0.0, 0.84)))); + voice_0_graph_source_right_labium_right_labium_displacement = voice_0_graph_source_right_labium_right_labium_velocity : + ~ *(voice_0_graph_source_right_labium_right_labium_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_right_labium_right_labium_stiffness)); + voice_0_graph_source_right_labium_right_labium_aperture_linear = max(0.0, (max(0.0, 0.018)) + (max(0.0, patch_param_3)) + voice_0_graph_source_right_labium_right_labium_displacement - (max(0.0, 0.84)) * pow(voice_0_graph_source_right_labium_right_labium_displacement, 3.0)); + voice_0_graph_source_right_labium_right_labium_aperture = voice_0_graph_source_right_labium_right_labium_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_right_labium_right_labium_aperture_shape) + pow(voice_0_graph_source_right_labium_right_labium_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_right_labium_right_labium_aperture_shape); + voice_0_graph_source_right_labium_right_labium_flow_resistance = 1.0 + voice_0_graph_source_right_labium_right_labium_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_right_labium_right_labium_aperture + (max(0.0, 0.018)))); + voice_0_graph_source_right_labium_right_labium_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_right_labium_right_labium_aperture)); + voice_0_graph_source_right_labium_right_labium_voicing = voice_0_graph_source_right_labium_right_labium_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_5))); + voice_0_graph_source_right_labium_right_labium_flow = ma.tanh(((voice_0_graph_source_right_labium_right_labium_pressure_drive * voice_0_graph_source_right_labium_right_labium_aperture * (1.5 + 3.5 * voice_0_graph_source_right_labium_right_labium_flow_scale)) + (voice_0_graph_source_right_labium_right_labium_voicing * voice_0_graph_source_right_labium_right_labium_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_5))))) / voice_0_graph_source_right_labium_right_labium_flow_resistance); + voice_0_graph_source_right_labium_right_labium_noise = voice_0_graph_source_right_labium_right_labium_turbulence * (clip01(0.016)) * voice_0_graph_source_right_labium_right_labium_pressure_drive * clip01(voice_0_graph_source_right_labium_right_labium_aperture) * (1.0 - 0.55 * (clip01(patch_param_5))) / voice_0_graph_source_right_labium_right_labium_flow_resistance; + voice_0_graph_source_right_labium_right_labium_out = (voice_0_graph_source_right_labium_right_labium_flow * voice_0_graph_source_right_labium_right_labium_flow_scale * (0.55 + 2.6 * voice_0_graph_source_right_labium_right_labium_pressure_drive) + voice_0_graph_source_right_labium_right_labium_noise) * ((0.94) * (1.0)); + voice_0_graph_node_incident_pressure_right_labium = (voice_0_graph_in_1_start) / 1; + voice_0_graph_node_source_right_labium = voice_0_graph_source_right_labium_right_labium_out; + voice_0_graph_node_incident_pressure_right_merge = (voice_0_graph_in_1_end) / 1; + voice_0_graph_node_source_right_merge = 0.0; + voice_0_graph_node_incident_pressure_trachea_base = (voice_0_graph_in_2_start) / 1; + voice_0_graph_node_source_trachea_base = 0.0; + voice_0_graph_node_incident_pressure_beak = (voice_0_graph_in_2_end) / 1; + voice_0_graph_node_source_beak = 0.0; + voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end = (2.0 * (voice_0_graph_segment_area_0) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_left_merge_0_end = voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end * voice_0_graph_in_0_end + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end) * (voice_0_graph_in_1_end + voice_0_graph_in_2_start); + voice_0_graph_out_0_end = ((voice_0_graph_connection_scattered_syrinx_merge_left_merge_0_end) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_0_end * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_left_merge) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end = (2.0 * (voice_0_graph_segment_area_1) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_right_merge_1_end = voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end * voice_0_graph_in_1_end + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end) * (voice_0_graph_in_0_end + voice_0_graph_in_2_start); + voice_0_graph_out_1_end = ((voice_0_graph_connection_scattered_syrinx_merge_right_merge_1_end) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_1_end * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_right_merge) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start = (2.0 * (voice_0_graph_segment_area_2) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_trachea_base_2_start = voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start * voice_0_graph_in_2_start + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start) * (voice_0_graph_in_0_end + voice_0_graph_in_1_end); + voice_0_graph_out_2_start = ((voice_0_graph_connection_scattered_syrinx_merge_trachea_base_2_start) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_2_start * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_trachea_base) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_energy_in_syrinx_merge = (voice_0_graph_segment_area_0) * pow(voice_0_graph_in_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_in_1_end, 2.0) + (voice_0_graph_segment_area_2) * pow(voice_0_graph_in_2_start, 2.0); + voice_0_graph_connection_energy_out_syrinx_merge = (voice_0_graph_segment_area_0) * pow(voice_0_graph_out_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_out_1_end, 2.0) + (voice_0_graph_segment_area_2) * pow(voice_0_graph_out_2_start, 2.0); + voice_0_graph_out_0_start = voice_0_graph_in_0_start * voice_0_graph_node_reflection_left_labium + (voice_0_graph_node_source_left_labium) / 1; + voice_0_graph_out_1_start = voice_0_graph_in_1_start * voice_0_graph_node_reflection_right_labium + (voice_0_graph_node_source_right_labium) / 1; + voice_0_graph_radiation_boundary_load_beak = clip01((voice_0_graph_radiation_admittance_beak) * (voice_0_graph_radiation_differentiation_beak) * (clip01(0.98))); + voice_0_graph_radiation_reflected_raw_beak = (voice_0_graph_in_2_end) * (voice_0_graph_terminal_reflection_beak) + (voice_0_graph_node_source_beak); + voice_0_graph_radiation_reflected_loaded_beak = (voice_0_graph_radiation_reflected_raw_beak) * (1.0 - (voice_0_graph_radiation_boundary_load_beak)) + ((voice_0_graph_radiation_reflected_raw_beak) : fi.lowpass(1, voice_0_graph_radiation_highpass_beak)) * (voice_0_graph_radiation_boundary_load_beak); + voice_0_graph_out_2_end = voice_0_graph_radiation_reflected_loaded_beak; + voice_0_graph_radiation_model_beak = 2; + voice_0_graph_radiation_reference_area_beak = max(0.10, 1.10 * 1.10 * (0.25 + 0.75 * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0)))); + voice_0_graph_radiation_differentiation_beak = (0.50 + 0.22 * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))); + voice_0_graph_radiation_highpass_beak = (180.0 + 220.0 * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))); + voice_0_graph_radiation_admittance_beak = sqrt(clip01((voice_0_graph_terminal_area_beak) / max(0.000001, (voice_0_graph_terminal_area_beak) + (voice_0_graph_radiation_reference_area_beak)))); + voice_0_graph_radiation_flow_beak = ((voice_0_graph_in_2_end - voice_0_graph_out_2_end)); + voice_0_graph_delay_0 = max(0.000001, 0.00010496 * ma.SR); + voice_0_graph_segment_loss_0 = clip01((0.996) * ((0.996 - 0.018 * clip01(0.050 / max(0.000001, (voice_0_graph_segment_area_0) + 0.050))))); + voice_0_graph_next_r0 = voice_0_graph_out_0_start : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_next_l0 = voice_0_graph_out_0_end : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_delay_1 = max(0.000001, 0.00009913 * ma.SR); + voice_0_graph_segment_loss_1 = clip01((0.996) * ((0.996 - 0.018 * clip01(0.050 / max(0.000001, (voice_0_graph_segment_area_1) + 0.050))))); + voice_0_graph_next_r1 = voice_0_graph_out_1_start : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_next_l1 = voice_0_graph_out_1_end : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_delay_2 = max(0.000001, 0.00023907 * ma.SR); + voice_0_graph_segment_loss_2 = clip01((0.997) * (sqrt(clip01((voice_0_graph_segment_area_2) / max(0.000001, (voice_0_graph_segment_area_2) + 0.020))))); + voice_0_graph_next_r2 = voice_0_graph_out_2_start : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_next_l2 = voice_0_graph_out_2_end : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_out = (((voice_0_graph_radiation_flow_beak * (1.0 - (voice_0_graph_radiation_differentiation_beak)) + (voice_0_graph_radiation_flow_beak : fi.highpass(1, voice_0_graph_radiation_highpass_beak)) * (voice_0_graph_radiation_differentiation_beak)) * clip01(0.98) * voice_0_graph_radiation_admittance_beak)) * voice_0_graph_radiation_gain; + }; +}; +voice_0_acoustic_graph_radiated = voice_0_graph(voice_0_graph_drive); +voice_0_freq = ((max(20, 980 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = voice_0_acoustic_graph_radiated; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.06, 0.82) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.24); + +process = softclip((voice_0) * 0.4); diff --git a/tools/aqua-playground/lowered/advanced-bird-syrinx.dsp b/tools/aqua-playground/lowered/advanced-bird-syrinx.dsp new file mode 100644 index 0000000..a1e8dd2 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-bird-syrinx.dsp @@ -0,0 +1,253 @@ +import("stdfaust.lib"); +declare name "advanced-bird-syrinx"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0_base = hslider("/bird/left/pressure", 0.82, 0, 1, 0.001) : si.smoo; +patch_param_0_curve_time = max(0.0, age * 1 - 0); +patch_param_0_curve_value = select2(patch_param_0_curve_time < 0.035, select2(patch_param_0_curve_time < 0.32, select2(patch_param_0_curve_time < 0.78, select2(patch_param_0_curve_time < 1.08, 0.38, seg(patch_param_0_curve_time, 0.78, 0.3000001, 0.74, 0.38)), seg(patch_param_0_curve_time, 0.32, 0.46, 0.88, 0.74)), seg(patch_param_0_curve_time, 0.035, 0.285, 0.82, 0.88)), seg(patch_param_0_curve_time, 0, 0.035, 0.08, 0.82)); +patch_param_0_curve_depth = hslider("/curves/left_pressure/depth", 1, 0, 1, 0.001) : si.smoo; +patch_param_0 = min(1, max(0, patch_param_0_base * (1.0 - patch_param_0_curve_depth) + patch_param_0_curve_value * patch_param_0_curve_depth)); +patch_param_1_base = hslider("/bird/right/pressure", 0.7, 0, 1, 0.001) : si.smoo; +patch_param_1_curve_time = max(0.0, age * 1 - 0); +patch_param_1_curve_value = select2(patch_param_1_curve_time < 0.04, select2(patch_param_1_curve_time < 0.28, select2(patch_param_1_curve_time < 0.72, select2(patch_param_1_curve_time < 1.08, 0.28, seg(patch_param_1_curve_time, 0.72, 0.36, 0.62, 0.28)), seg(patch_param_1_curve_time, 0.28, 0.44, 0.74, 0.62)), seg(patch_param_1_curve_time, 0.04, 0.24, 0.68, 0.74)), seg(patch_param_1_curve_time, 0, 0.04, 0.04, 0.68)); +patch_param_1_curve_depth = hslider("/curves/right_pressure/depth", 1, 0, 1, 0.001) : si.smoo; +patch_param_1 = min(1, max(0, patch_param_1_base * (1.0 - patch_param_1_curve_depth) + patch_param_1_curve_value * patch_param_1_curve_depth)); +patch_param_2_base = hslider("/bird/left/opening", 0.24, 0, 1, 0.001) : si.smoo; +patch_param_2_curve_time = max(0.0, age * 1 - 0); +patch_param_2_curve_value = select2(patch_param_2_curve_time < 0.03, select2(patch_param_2_curve_time < 0.76, select2(patch_param_2_curve_time < 1.08, 0.04, seg(patch_param_2_curve_time, 0.76, 0.3200001, 0.2, 0.04)), seg(patch_param_2_curve_time, 0.03, 0.73, 0.24, 0.2)), seg(patch_param_2_curve_time, 0, 0.03, 0.02, 0.24)); +patch_param_2_curve_depth = hslider("/curves/left_opening/depth", 0.85, 0, 1, 0.001) : si.smoo; +patch_param_2 = min(1, max(0, patch_param_2_base * (1.0 - patch_param_2_curve_depth) + patch_param_2_curve_value * patch_param_2_curve_depth)); +patch_param_3_base = hslider("/bird/right/opening", 0.21, 0, 1, 0.001) : si.smoo; +patch_param_3_curve_time = max(0.0, age * 1 - 0); +patch_param_3_curve_value = select2(patch_param_3_curve_time < 0.035, select2(patch_param_3_curve_time < 0.7, select2(patch_param_3_curve_time < 1.08, 0.04, seg(patch_param_3_curve_time, 0.7, 0.3800001, 0.18, 0.04)), seg(patch_param_3_curve_time, 0.035, 0.665, 0.21, 0.18)), seg(patch_param_3_curve_time, 0, 0.035, 0.02, 0.21)); +patch_param_3_curve_depth = hslider("/curves/right_opening/depth", 0.85, 0, 1, 0.001) : si.smoo; +patch_param_3 = min(1, max(0, patch_param_3_base * (1.0 - patch_param_3_curve_depth) + patch_param_3_curve_value * patch_param_3_curve_depth)); +patch_param_4 = hslider("/bird/left/tension", 0.38, 0, 1, 0.001) : si.smoo; +patch_param_5 = hslider("/bird/right/tension", 0.45, 0, 1, 0.001) : si.smoo; +patch_param_6 = hslider("/bird/left/mass", 0.32, 0.02, 2, 0.001) : si.smoo; +patch_param_7 = hslider("/bird/right/mass", 0.34, 0.02, 2, 0.001) : si.smoo; +patch_param_8 = hslider("/bird/left/damping", 0.14, 0, 2, 0.001) : si.smoo; +patch_param_9 = hslider("/bird/right/damping", 0.16, 0, 2, 0.001) : si.smoo; +patch_param_10 = hslider("/bird/left/stiffness", 0.025, 0, 1, 0.001) : si.smoo; +patch_param_11 = hslider("/bird/right/stiffness", 0.03, 0, 1, 0.001) : si.smoo; +patch_param_12 = hslider("/bird/left/flow_scale", 1.2, 0, 4, 0.001) : si.smoo; +patch_param_13 = hslider("/bird/right/flow_scale", 1.1, 0, 4, 0.001) : si.smoo; +patch_param_14 = hslider("/bird/left/tissue_loss", 0.18, 0, 1, 0.001) : si.smoo; +patch_param_15 = hslider("/bird/right/tissue_loss", 0.2, 0, 1, 0.001) : si.smoo; +patch_param_16 = hslider("/bird/left/load_coupling", 0.42, 0, 2, 0.001) : si.smoo; +patch_param_17 = hslider("/bird/right/load_coupling", 0.42, 0, 2, 0.001) : si.smoo; +patch_param_18 = hslider("/bird/left/rest_opening", 0.025, 0, 1, 0.001) : si.smoo; +patch_param_19 = hslider("/bird/right/rest_opening", 0.025, 0, 1, 0.001) : si.smoo; +patch_param_20 = hslider("/bird/load", 0.85, 0, 2, 0.001) : si.smoo; +patch_param_21_base = hslider("/bird/beak/opening", 0.95, 0, 1.5, 0.001) : si.smoo; +patch_param_21_curve_time = max(0.0, age * 1 - 0); +patch_param_21_curve_value = select2(patch_param_21_curve_time < 0.06, select2(patch_param_21_curve_time < 0.82, select2(patch_param_21_curve_time < 1.08, 0.55, seg(patch_param_21_curve_time, 0.82, 0.2600001, 1.05, 0.55)), seg(patch_param_21_curve_time, 0.06, 0.76, 0.92, 1.05)), seg(patch_param_21_curve_time, 0, 0.06, 0.35, 0.92)); +patch_param_21_curve_depth = hslider("/curves/beak_opening/depth", 0.7, 0, 1, 0.001) : si.smoo; +patch_param_21 = min(1.5, max(0, patch_param_21_base * (1.0 - patch_param_21_curve_depth) + patch_param_21_curve_value * patch_param_21_curve_depth)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_graph_drive = 1.0; +voice_0_graph_terminal_area_left_merge = max(0.000001, 0.1764 * max(0.0, 1)); +voice_0_graph_terminal_reflection_left_merge = 0; +voice_0_graph_terminal_area_right_merge = max(0.000001, 0.16 * max(0.0, 1)); +voice_0_graph_terminal_reflection_right_merge = 0; +voice_0_graph_terminal_area_trachea_base = max(0.000001, 0.1444 * max(0.0, 1)); +voice_0_graph_terminal_reflection_trachea_base = 0; +voice_0_graph_terminal_area_left_labium = max(0.000001, 0.0484 * max(0.0, 1)); +voice_0_graph_terminal_reflection_left_labium = 0; +voice_0_graph_terminal_area_right_labium = max(0.000001, 0.04 * max(0.0, 1)); +voice_0_graph_terminal_reflection_right_labium = 0; +voice_0_graph_terminal_area_beak = max(0.000001, 0.2116 * max(0.0, 0.95)); +voice_0_graph_terminal_reflection_beak = ((0.96) * (1.0 - clip01(pow(clip01((max(0.0, patch_param_21)) / 1.5), 2.0))) + (-0.72) * clip01(pow(clip01((max(0.0, patch_param_21)) / 1.5), 2.0))); +voice_0_graph_node_area_left_labium = max(0.000001, voice_0_graph_terminal_area_left_labium); +voice_0_graph_node_reflection_left_labium = (voice_0_graph_terminal_reflection_left_labium) / 1; +voice_0_graph_node_area_left_merge = max(0.000001, voice_0_graph_terminal_area_left_merge); +voice_0_graph_node_reflection_left_merge = (voice_0_graph_terminal_reflection_left_merge) / 1; +voice_0_graph_node_area_right_labium = max(0.000001, voice_0_graph_terminal_area_right_labium); +voice_0_graph_node_reflection_right_labium = (voice_0_graph_terminal_reflection_right_labium) / 1; +voice_0_graph_node_area_right_merge = max(0.000001, voice_0_graph_terminal_area_right_merge); +voice_0_graph_node_reflection_right_merge = (voice_0_graph_terminal_reflection_right_merge) / 1; +voice_0_graph_node_area_trachea_base = max(0.000001, voice_0_graph_terminal_area_trachea_base); +voice_0_graph_node_reflection_trachea_base = (voice_0_graph_terminal_reflection_trachea_base) / 1; +voice_0_graph_node_area_beak = max(0.000001, voice_0_graph_terminal_area_beak); +voice_0_graph_node_reflection_beak = (voice_0_graph_terminal_reflection_beak) / 1; +voice_0_graph_segment_area_0 = max(0.000001, 0.1089); +voice_0_graph_segment_area_1 = max(0.000001, 0.0961); +voice_0_graph_segment_area_2 = max(0.000001, 0.2704); +voice_0_graph_connection_coupling_syrinx_merge = clip01(1); +voice_0_graph_connection_loss_syrinx_merge = clip01(1); +voice_0_graph_radiation_gain = 1.0; +voice_0_graph_source_left_labium = 0.0; +voice_0_graph_source_right_labium = 0.0; +voice_0_graph(x) = voice_0_graph_loop ~ si.bus(6) : (si.block(6), _) with { + voice_0_graph_loop(r0, r1, r2, l0, l1, l2) = voice_0_graph_next_r0, voice_0_graph_next_r1, voice_0_graph_next_r2, voice_0_graph_next_l0, voice_0_graph_next_l1, voice_0_graph_next_l2, voice_0_graph_out with { + voice_0_graph_in_0_start = l0; + voice_0_graph_in_0_end = r0; + voice_0_graph_in_1_start = l1; + voice_0_graph_in_1_end = r1; + voice_0_graph_in_2_start = l2; + voice_0_graph_in_2_end = r2; + voice_0_graph_source_left_labium_left_labium_load_pressure = voice_0_graph_node_incident_pressure_left_labium; + voice_0_graph_source_left_labium_left_labium_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 1120 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_left_labium_left_labium_flow_scale = max(0.0, patch_param_12); + voice_0_graph_source_left_labium_left_labium_tissue_loss = clip01(patch_param_14); + voice_0_graph_source_left_labium_left_labium_aperture_shape = clip01(0.4); + voice_0_graph_source_left_labium_left_labium_flow_loss = max(0.0, 0.35); + voice_0_graph_source_left_labium_left_labium_reservoir_pressure = (clip01(patch_param_0)) * (max(0.0, 1)); + voice_0_graph_source_left_labium_left_labium_downstream_pressure = (max(0.0, 0)) + (max(0.0, patch_param_16)) * ma.tanh(voice_0_graph_source_left_labium_left_labium_load_pressure); + voice_0_graph_source_left_labium_left_labium_pressure_drive = max(0.0, voice_0_graph_source_left_labium_left_labium_reservoir_pressure - voice_0_graph_source_left_labium_left_labium_downstream_pressure); + voice_0_graph_source_left_labium_left_labium_stiffness = max(0.00002, (max(0.0, patch_param_10)) * (0.55 + 1.10 * (clip01(patch_param_4)))); + voice_0_graph_source_left_labium_left_labium_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_left_labium_left_labium_stiffness) / (max(0.02, patch_param_6))))); + voice_0_graph_source_left_labium_left_labium_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_left_labium_left_labium_load_pressure * (max(0.0, patch_param_16))); + voice_0_graph_source_left_labium_left_labium_oscillation_threshold = 0.030 + 0.070 * (max(0.0, patch_param_8)) + 0.080 * voice_0_graph_source_left_labium_left_labium_tissue_loss + 0.18 * clip01(max(0.0, patch_param_2)); + voice_0_graph_source_left_labium_left_labium_oscillation_gate = clip01((voice_0_graph_source_left_labium_left_labium_pressure_drive - voice_0_graph_source_left_labium_left_labium_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, patch_param_8))))); + voice_0_graph_source_left_labium_left_labium_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_0)) * (1.0 - 0.45 * (max(0.0, patch_param_8)) - 0.35 * voice_0_graph_source_left_labium_left_labium_tissue_loss) + 0.35 * (clip01(patch_param_4))); + voice_0_graph_source_left_labium_left_labium_modal_seed = (no.noise * 0.018 + voice_0_graph_source_left_labium_left_labium_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_2))) * 0.16); + voice_0_graph_source_left_labium_left_labium_modal_ring = voice_0_graph_source_left_labium_left_labium_modal_seed : fi.resonbp(voice_0_graph_source_left_labium_left_labium_modal_frequency, voice_0_graph_source_left_labium_left_labium_modal_q, 1); + voice_0_graph_source_left_labium_left_labium_modal_oscillator = os.osc(voice_0_graph_source_left_labium_left_labium_modal_frequency * voice_0_graph_source_left_labium_left_labium_load_detune) * voice_0_graph_source_left_labium_left_labium_oscillation_gate; + voice_0_graph_source_left_labium_left_labium_modal_tissue = (voice_0_graph_source_left_labium_left_labium_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_4))) + voice_0_graph_source_left_labium_left_labium_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, patch_param_8)) - 0.45 * voice_0_graph_source_left_labium_left_labium_tissue_loss); + voice_0_graph_source_left_labium_left_labium_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, patch_param_8)) + 0.055 * voice_0_graph_source_left_labium_left_labium_tissue_loss) / (max(0.02, patch_param_6))))); + voice_0_graph_source_left_labium_left_labium_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, patch_param_6)))); + voice_0_graph_source_left_labium_left_labium_force = (voice_0_graph_source_left_labium_left_labium_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_2)))) - (max(0.0, patch_param_16)) * voice_0_graph_source_left_labium_left_labium_load_pressure * 0.001) / (max(0.02, patch_param_6)); + voice_0_graph_source_left_labium_left_labium_velocity = voice_0_graph_source_left_labium_left_labium_force : + ~ *(voice_0_graph_source_left_labium_left_labium_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_left_labium_left_labium_stiffness + 0.4 * (max(0.0, 0.9)))); + voice_0_graph_source_left_labium_left_labium_displacement = voice_0_graph_source_left_labium_left_labium_velocity : + ~ *(voice_0_graph_source_left_labium_left_labium_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_left_labium_left_labium_stiffness)); + voice_0_graph_source_left_labium_left_labium_aperture_linear = max(0.0, (max(0.0, patch_param_18)) + (max(0.0, patch_param_2)) + voice_0_graph_source_left_labium_left_labium_displacement - (max(0.0, 0.9)) * pow(voice_0_graph_source_left_labium_left_labium_displacement, 3.0)); + voice_0_graph_source_left_labium_left_labium_aperture = voice_0_graph_source_left_labium_left_labium_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_left_labium_left_labium_aperture_shape) + pow(voice_0_graph_source_left_labium_left_labium_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_left_labium_left_labium_aperture_shape); + voice_0_graph_source_left_labium_left_labium_flow_resistance = 1.0 + voice_0_graph_source_left_labium_left_labium_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_left_labium_left_labium_aperture + (max(0.0, patch_param_18)))); + voice_0_graph_source_left_labium_left_labium_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_left_labium_left_labium_aperture)); + voice_0_graph_source_left_labium_left_labium_voicing = voice_0_graph_source_left_labium_left_labium_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_4))); + voice_0_graph_source_left_labium_left_labium_flow = ma.tanh(((voice_0_graph_source_left_labium_left_labium_pressure_drive * voice_0_graph_source_left_labium_left_labium_aperture * (1.5 + 3.5 * voice_0_graph_source_left_labium_left_labium_flow_scale)) + (voice_0_graph_source_left_labium_left_labium_voicing * voice_0_graph_source_left_labium_left_labium_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_4))))) / voice_0_graph_source_left_labium_left_labium_flow_resistance); + voice_0_graph_source_left_labium_left_labium_noise = voice_0_graph_source_left_labium_left_labium_turbulence * (clip01(0.025)) * voice_0_graph_source_left_labium_left_labium_pressure_drive * clip01(voice_0_graph_source_left_labium_left_labium_aperture) * (1.0 - 0.55 * (clip01(patch_param_4))) / voice_0_graph_source_left_labium_left_labium_flow_resistance; + voice_0_graph_source_left_labium_left_labium_out = (voice_0_graph_source_left_labium_left_labium_flow * voice_0_graph_source_left_labium_left_labium_flow_scale * (0.55 + 2.6 * voice_0_graph_source_left_labium_left_labium_pressure_drive) + voice_0_graph_source_left_labium_left_labium_noise) * ((1) * (1.0)); + voice_0_graph_node_incident_pressure_left_labium = (voice_0_graph_in_0_start) / 1; + voice_0_graph_node_source_left_labium = voice_0_graph_source_left_labium_left_labium_out; + voice_0_graph_node_incident_pressure_left_merge = (voice_0_graph_in_0_end) / 1; + voice_0_graph_node_source_left_merge = 0.0; + voice_0_graph_source_right_labium_right_labium_load_pressure = voice_0_graph_node_incident_pressure_right_labium; + voice_0_graph_source_right_labium_right_labium_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 1120 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_right_labium_right_labium_flow_scale = max(0.0, patch_param_13); + voice_0_graph_source_right_labium_right_labium_tissue_loss = clip01(patch_param_15); + voice_0_graph_source_right_labium_right_labium_aperture_shape = clip01(0.4); + voice_0_graph_source_right_labium_right_labium_flow_loss = max(0.0, 0.35); + voice_0_graph_source_right_labium_right_labium_reservoir_pressure = (clip01(patch_param_1)) * (max(0.0, 1)); + voice_0_graph_source_right_labium_right_labium_downstream_pressure = (max(0.0, 0)) + (max(0.0, patch_param_17)) * ma.tanh(voice_0_graph_source_right_labium_right_labium_load_pressure); + voice_0_graph_source_right_labium_right_labium_pressure_drive = max(0.0, voice_0_graph_source_right_labium_right_labium_reservoir_pressure - voice_0_graph_source_right_labium_right_labium_downstream_pressure); + voice_0_graph_source_right_labium_right_labium_stiffness = max(0.00002, (max(0.0, patch_param_11)) * (0.55 + 1.10 * (clip01(patch_param_5)))); + voice_0_graph_source_right_labium_right_labium_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_right_labium_right_labium_stiffness) / (max(0.02, patch_param_7))))); + voice_0_graph_source_right_labium_right_labium_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_right_labium_right_labium_load_pressure * (max(0.0, patch_param_17))); + voice_0_graph_source_right_labium_right_labium_oscillation_threshold = 0.030 + 0.070 * (max(0.0, patch_param_9)) + 0.080 * voice_0_graph_source_right_labium_right_labium_tissue_loss + 0.18 * clip01(max(0.0, patch_param_3)); + voice_0_graph_source_right_labium_right_labium_oscillation_gate = clip01((voice_0_graph_source_right_labium_right_labium_pressure_drive - voice_0_graph_source_right_labium_right_labium_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, patch_param_9))))); + voice_0_graph_source_right_labium_right_labium_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_1)) * (1.0 - 0.45 * (max(0.0, patch_param_9)) - 0.35 * voice_0_graph_source_right_labium_right_labium_tissue_loss) + 0.35 * (clip01(patch_param_5))); + voice_0_graph_source_right_labium_right_labium_modal_seed = (no.noise * 0.018 + voice_0_graph_source_right_labium_right_labium_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_3))) * 0.16); + voice_0_graph_source_right_labium_right_labium_modal_ring = voice_0_graph_source_right_labium_right_labium_modal_seed : fi.resonbp(voice_0_graph_source_right_labium_right_labium_modal_frequency, voice_0_graph_source_right_labium_right_labium_modal_q, 1); + voice_0_graph_source_right_labium_right_labium_modal_oscillator = os.osc(voice_0_graph_source_right_labium_right_labium_modal_frequency * voice_0_graph_source_right_labium_right_labium_load_detune) * voice_0_graph_source_right_labium_right_labium_oscillation_gate; + voice_0_graph_source_right_labium_right_labium_modal_tissue = (voice_0_graph_source_right_labium_right_labium_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_5))) + voice_0_graph_source_right_labium_right_labium_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, patch_param_9)) - 0.45 * voice_0_graph_source_right_labium_right_labium_tissue_loss); + voice_0_graph_source_right_labium_right_labium_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, patch_param_9)) + 0.055 * voice_0_graph_source_right_labium_right_labium_tissue_loss) / (max(0.02, patch_param_7))))); + voice_0_graph_source_right_labium_right_labium_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, patch_param_7)))); + voice_0_graph_source_right_labium_right_labium_force = (voice_0_graph_source_right_labium_right_labium_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_3)))) - (max(0.0, patch_param_17)) * voice_0_graph_source_right_labium_right_labium_load_pressure * 0.001) / (max(0.02, patch_param_7)); + voice_0_graph_source_right_labium_right_labium_velocity = voice_0_graph_source_right_labium_right_labium_force : + ~ *(voice_0_graph_source_right_labium_right_labium_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_right_labium_right_labium_stiffness + 0.4 * (max(0.0, 0.9)))); + voice_0_graph_source_right_labium_right_labium_displacement = voice_0_graph_source_right_labium_right_labium_velocity : + ~ *(voice_0_graph_source_right_labium_right_labium_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_right_labium_right_labium_stiffness)); + voice_0_graph_source_right_labium_right_labium_aperture_linear = max(0.0, (max(0.0, patch_param_19)) + (max(0.0, patch_param_3)) + voice_0_graph_source_right_labium_right_labium_displacement - (max(0.0, 0.9)) * pow(voice_0_graph_source_right_labium_right_labium_displacement, 3.0)); + voice_0_graph_source_right_labium_right_labium_aperture = voice_0_graph_source_right_labium_right_labium_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_right_labium_right_labium_aperture_shape) + pow(voice_0_graph_source_right_labium_right_labium_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_right_labium_right_labium_aperture_shape); + voice_0_graph_source_right_labium_right_labium_flow_resistance = 1.0 + voice_0_graph_source_right_labium_right_labium_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_right_labium_right_labium_aperture + (max(0.0, patch_param_19)))); + voice_0_graph_source_right_labium_right_labium_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_right_labium_right_labium_aperture)); + voice_0_graph_source_right_labium_right_labium_voicing = voice_0_graph_source_right_labium_right_labium_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_5))); + voice_0_graph_source_right_labium_right_labium_flow = ma.tanh(((voice_0_graph_source_right_labium_right_labium_pressure_drive * voice_0_graph_source_right_labium_right_labium_aperture * (1.5 + 3.5 * voice_0_graph_source_right_labium_right_labium_flow_scale)) + (voice_0_graph_source_right_labium_right_labium_voicing * voice_0_graph_source_right_labium_right_labium_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_5))))) / voice_0_graph_source_right_labium_right_labium_flow_resistance); + voice_0_graph_source_right_labium_right_labium_noise = voice_0_graph_source_right_labium_right_labium_turbulence * (clip01(0.02)) * voice_0_graph_source_right_labium_right_labium_pressure_drive * clip01(voice_0_graph_source_right_labium_right_labium_aperture) * (1.0 - 0.55 * (clip01(patch_param_5))) / voice_0_graph_source_right_labium_right_labium_flow_resistance; + voice_0_graph_source_right_labium_right_labium_out = (voice_0_graph_source_right_labium_right_labium_flow * voice_0_graph_source_right_labium_right_labium_flow_scale * (0.55 + 2.6 * voice_0_graph_source_right_labium_right_labium_pressure_drive) + voice_0_graph_source_right_labium_right_labium_noise) * ((0.96) * (1.0)); + voice_0_graph_node_incident_pressure_right_labium = (voice_0_graph_in_1_start) / 1; + voice_0_graph_node_source_right_labium = voice_0_graph_source_right_labium_right_labium_out; + voice_0_graph_node_incident_pressure_right_merge = (voice_0_graph_in_1_end) / 1; + voice_0_graph_node_source_right_merge = 0.0; + voice_0_graph_node_incident_pressure_trachea_base = (voice_0_graph_in_2_start) / 1; + voice_0_graph_node_source_trachea_base = 0.0; + voice_0_graph_node_incident_pressure_beak = (voice_0_graph_in_2_end) / 1; + voice_0_graph_node_source_beak = 0.0; + voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end = (2.0 * (voice_0_graph_segment_area_0) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_left_merge_0_end = voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end * voice_0_graph_in_0_end + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end) * (voice_0_graph_in_1_end + voice_0_graph_in_2_start); + voice_0_graph_out_0_end = ((voice_0_graph_connection_scattered_syrinx_merge_left_merge_0_end) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_0_end * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_left_merge) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end = (2.0 * (voice_0_graph_segment_area_1) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_right_merge_1_end = voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end * voice_0_graph_in_1_end + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end) * (voice_0_graph_in_0_end + voice_0_graph_in_2_start); + voice_0_graph_out_1_end = ((voice_0_graph_connection_scattered_syrinx_merge_right_merge_1_end) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_1_end * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_right_merge) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start = (2.0 * (voice_0_graph_segment_area_2) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_trachea_base_2_start = voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start * voice_0_graph_in_2_start + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start) * (voice_0_graph_in_0_end + voice_0_graph_in_1_end); + voice_0_graph_out_2_start = ((voice_0_graph_connection_scattered_syrinx_merge_trachea_base_2_start) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_2_start * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_trachea_base) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_energy_in_syrinx_merge = (voice_0_graph_segment_area_0) * pow(voice_0_graph_in_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_in_1_end, 2.0) + (voice_0_graph_segment_area_2) * pow(voice_0_graph_in_2_start, 2.0); + voice_0_graph_connection_energy_out_syrinx_merge = (voice_0_graph_segment_area_0) * pow(voice_0_graph_out_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_out_1_end, 2.0) + (voice_0_graph_segment_area_2) * pow(voice_0_graph_out_2_start, 2.0); + voice_0_graph_out_0_start = voice_0_graph_in_0_start * voice_0_graph_node_reflection_left_labium + (voice_0_graph_node_source_left_labium) / 1; + voice_0_graph_out_1_start = voice_0_graph_in_1_start * voice_0_graph_node_reflection_right_labium + (voice_0_graph_node_source_right_labium) / 1; + voice_0_graph_radiation_boundary_load_beak = clip01((voice_0_graph_radiation_admittance_beak) * (voice_0_graph_radiation_differentiation_beak) * (clip01(1))); + voice_0_graph_radiation_reflected_raw_beak = (voice_0_graph_in_2_end) * (voice_0_graph_terminal_reflection_beak) + (voice_0_graph_node_source_beak); + voice_0_graph_radiation_reflected_loaded_beak = (voice_0_graph_radiation_reflected_raw_beak) * (1.0 - (voice_0_graph_radiation_boundary_load_beak)) + ((voice_0_graph_radiation_reflected_raw_beak) : fi.lowpass(1, voice_0_graph_radiation_highpass_beak)) * (voice_0_graph_radiation_boundary_load_beak); + voice_0_graph_out_2_end = voice_0_graph_radiation_reflected_loaded_beak; + voice_0_graph_radiation_model_beak = 2; + voice_0_graph_radiation_reference_area_beak = max(0.10, 1.10 * 1.10 * (0.25 + 0.75 * clip01(pow(clip01((max(0.0, patch_param_21)) / 1.5), 2.0)))); + voice_0_graph_radiation_differentiation_beak = (0.50 + 0.22 * clip01(pow(clip01((max(0.0, patch_param_21)) / 1.5), 2.0))); + voice_0_graph_radiation_highpass_beak = (180.0 + 220.0 * clip01(pow(clip01((max(0.0, patch_param_21)) / 1.5), 2.0))); + voice_0_graph_radiation_admittance_beak = sqrt(clip01((voice_0_graph_terminal_area_beak) / max(0.000001, (voice_0_graph_terminal_area_beak) + (voice_0_graph_radiation_reference_area_beak)))); + voice_0_graph_radiation_flow_beak = ((voice_0_graph_in_2_end - voice_0_graph_out_2_end)); + voice_0_graph_delay_0 = max(0.000001, 0.00011079 * ma.SR); + voice_0_graph_segment_loss_0 = clip01((0.999) * (sqrt(clip01((voice_0_graph_segment_area_0) / max(0.000001, (voice_0_graph_segment_area_0) + 0.02))))); + voice_0_graph_next_r0 = voice_0_graph_out_0_start : de.fdelay(1024, min(1023, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_next_l0 = voice_0_graph_out_0_end : de.fdelay(1024, min(1023, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_delay_1 = max(0.000001, 0.00010496 * ma.SR); + voice_0_graph_segment_loss_1 = clip01((0.999) * (sqrt(clip01((voice_0_graph_segment_area_1) / max(0.000001, (voice_0_graph_segment_area_1) + 0.02))))); + voice_0_graph_next_r1 = voice_0_graph_out_1_start : de.fdelay(1024, min(1023, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_next_l1 = voice_0_graph_out_1_end : de.fdelay(1024, min(1023, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_delay_2 = max(0.000001, 0.0002449 * ma.SR); + voice_0_graph_segment_loss_2 = clip01((0.999) * (sqrt(clip01((voice_0_graph_segment_area_2) / max(0.000001, (voice_0_graph_segment_area_2) + 0.02))))); + voice_0_graph_next_r2 = voice_0_graph_out_2_start : de.fdelay(1024, min(1023, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_next_l2 = voice_0_graph_out_2_end : de.fdelay(1024, min(1023, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_out = (((voice_0_graph_radiation_flow_beak * (1.0 - (voice_0_graph_radiation_differentiation_beak)) + (voice_0_graph_radiation_flow_beak : fi.highpass(1, voice_0_graph_radiation_highpass_beak)) * (voice_0_graph_radiation_differentiation_beak)) * clip01(1) * voice_0_graph_radiation_admittance_beak)) * voice_0_graph_radiation_gain; + }; +}; +voice_0_acoustic_graph_radiated = voice_0_graph(voice_0_graph_drive); +voice_0_freq = ((max(20, 1120 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = voice_0_acoustic_graph_radiated; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.08, 1.08) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.32); + +process = softclip((voice_0) * 0.42); diff --git a/tools/aqua-playground/lowered/advanced-glass-creature.dsp b/tools/aqua-playground/lowered/advanced-glass-creature.dsp new file mode 100644 index 0000000..23ffaa6 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-glass-creature.dsp @@ -0,0 +1,98 @@ +import("stdfaust.lib"); +declare name "advanced-glass-creature"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.18 * lfo_sin(1.8, 0); +patch_mod_pitch = 0 + 0.02 * lfo_sin(1.8, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0 + 0.8 * lfo_sin(1.8, 0); + +voice_0_age = age; +voice_0_freq = ((max(20, 523.25 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 523.25 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 523.25 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3.5))) * (max(0.0, 2.8 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.5, 0.0001))) / ma.PI) - 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.92 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.002, 0, 0.8928571, 1.05, 0.18) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.1344); + +voice_1_age = age; +voice_1_freq = ((max(20, 659.25 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age))) * (1.0 + select2(voice_1_age < 0, 0.0, sin(2.0 * ma.PI * (voice_1_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 659.25 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age))) * (1.0 + select2(voice_1_age < 0, 0.0, sin(2.0 * ma.PI * (voice_1_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 659.25 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age))) * (1.0 + select2(voice_1_age < 0, 0.0, sin(2.0 * ma.PI * (voice_1_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 4.2))) * (max(0.0, 2.8 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.5, 0.0001))) / ma.PI) - 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.92 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.002, 0, 1, 0.84, 0.11) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +voice_2_age = age; +voice_2_freq = ((max(20, 783.99 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age))) * (1.0 + select2(voice_2_age < 0, 0.0, sin(2.0 * ma.PI * (voice_2_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 783.99 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age))) * (1.0 + select2(voice_2_age < 0, 0.0, sin(2.0 * ma.PI * (voice_2_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 783.99 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age))) * (1.0 + select2(voice_2_age < 0, 0.0, sin(2.0 * ma.PI * (voice_2_age - 0) * 6.4) * 0.018))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3.5))) * (max(0.0, 1.9 + patch_mod_fm_index + 0.0) * exp(-voice_2_age / max(0.5, 0.0001))) / ma.PI) - 0.5); +voice_2_colored = (voice_2_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.92 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered; +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0.002, 0, 1, 0.72, 0.08) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.07); + +voice_3_age = age; +voice_3_freq = ((max(20, 261.63 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 261.63 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 261.63 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1.5))) * (max(0.0, 0.65 + patch_mod_fm_index + 0.0) * exp(-voice_3_age / max(1.2, 0.0001))) / ma.PI)); +voice_3_colored = (voice_3_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(0.92 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = voice_3_phased; +voice_3 = ((voice_3_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0.002, 0, 1, 1.3, 0.7) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.045); + +voice_4_age = age; +voice_4_freq = ((max(20, 2400 * pow(2.0, 0 * voice_4_age + 0.5 * 0 * voice_4_age * voice_4_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_4_osc = no.noise; +voice_4_colored = (voice_4_osc * (1.0 - clip01(0.9 + patch_mod_noise + 0.0)) + no.noise * clip01(0.9 + patch_mod_noise + 0.0)); +voice_4_driven = ma.tanh(voice_4_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_4_folded = voice_4_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_4_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_4_filtered = voice_4_folded : fi.lowpass(1, max(20.0, clip01(0.5 * (1.0 + 0 * voice_4_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.72 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.72 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_4_phased = voice_4_filtered; +voice_4_formants = voice_4_phased; +voice_4 = ((voice_4_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_4_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_4_age, 0.002, 0, 1, 0.55, 0.04) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.012); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3 + voice_4) * 0.52); diff --git a/tools/aqua-playground/lowered/advanced-human-larynx-graph.dsp b/tools/aqua-playground/lowered/advanced-human-larynx-graph.dsp new file mode 100644 index 0000000..1373aa3 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-human-larynx-graph.dsp @@ -0,0 +1,185 @@ +import("stdfaust.lib"); +declare name "advanced-human-larynx-graph"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0_base = hslider("/human/subglottal", 0.78, 0, 1.5, 0.001) : si.smoo; +patch_param_0_curve_time = max(0.0, age * 1 - 0); +patch_param_0_curve_value = select2(patch_param_0_curve_time < 0.08, select2(patch_param_0_curve_time < 0.72, select2(patch_param_0_curve_time < 1.1, 0.18, seg(patch_param_0_curve_time, 0.72, 0.38, 0.76, 0.18)), seg(patch_param_0_curve_time, 0.08, 0.64, 0.8, 0.76)), seg(patch_param_0_curve_time, 0, 0.08, 0.05, 0.8)); +patch_param_0_curve_depth = hslider("/curves/breath_phrase/depth", 0.9, 0, 1, 0.001) : si.smoo; +patch_param_0 = min(1.5, max(0, patch_param_0_base * (1.0 - patch_param_0_curve_depth) + patch_param_0_curve_value * patch_param_0_curve_depth)); +patch_param_1_base = hslider("/human/fold/opening", 0.16, 0, 1, 0.001) : si.smoo; +patch_param_1_curve_time = max(0.0, age * 1 - 0); +patch_param_1_curve_value = select2(patch_param_1_curve_time < 0.06, select2(patch_param_1_curve_time < 0.88, select2(patch_param_1_curve_time < 1.1, 0.03, seg(patch_param_1_curve_time, 0.88, 0.22, 0.14, 0.03)), seg(patch_param_1_curve_time, 0.06, 0.82, 0.18, 0.14)), seg(patch_param_1_curve_time, 0, 0.06, 0.02, 0.18)); +patch_param_1_curve_depth = hslider("/curves/fold_onset/depth", 0.8, 0, 1, 0.001) : si.smoo; +patch_param_1 = min(1, max(0, patch_param_1_base * (1.0 - patch_param_1_curve_depth) + patch_param_1_curve_value * patch_param_1_curve_depth)); +patch_param_2 = hslider("/human/fold/tension", 0.58, 0, 1, 0.001) : si.smoo; +patch_param_3 = hslider("/human/tongue/index", 3.3, 0, 6, 0.001) : si.smoo; +patch_param_4 = hslider("/human/tongue/diameter", 1.25, 0.05, 3, 0.001) : si.smoo; +patch_param_5 = hslider("/human/constriction/index", 4.8, 0, 6, 0.001) : si.smoo; +patch_param_6 = hslider("/human/constriction/diameter", 0.95, 0.02, 3, 0.001) : si.smoo; +patch_param_7_base = hslider("/human/lip/opening", 1.2, 0, 2, 0.001) : si.smoo; +patch_param_7_curve_time = max(0.0, age * 1 - 0); +patch_param_7_curve_value = select2(patch_param_7_curve_time < 0.35, select2(patch_param_7_curve_time < 0.75, select2(patch_param_7_curve_time < 1.1, 1.05, seg(patch_param_7_curve_time, 0.75, 0.35, 0.72, 1.05)), seg(patch_param_7_curve_time, 0.35, 0.4, 1.25, 0.72)), seg(patch_param_7_curve_time, 0, 0.35, 0.8, 1.25)); +patch_param_7_curve_depth = hslider("/curves/lip_vowel/depth", 0.65, 0, 1, 0.001) : si.smoo; +patch_param_7 = min(2, max(0, patch_param_7_base * (1.0 - patch_param_7_curve_depth) + patch_param_7_curve_value * patch_param_7_curve_depth)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_graph_drive = 1.0; +voice_0_graph_terminal_area_subglottal_wall = max(0.000001, 0.1024 * max(0.0, 1)); +voice_0_graph_terminal_reflection_subglottal_wall = 0.78; +voice_0_graph_terminal_area_trachea_top = max(0.000001, 0.49 * max(0.0, 1)); +voice_0_graph_terminal_reflection_trachea_top = 0; +voice_0_graph_terminal_area_oral_back = max(0.000001, ((max(0.0, min((0.55 + ((patch_param_4) - 0.55) * (exp(0.0 - pow((0 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.55) * 0), (patch_param_6) + max(0.0, ((0.55 + ((patch_param_4) - 0.55) * (exp(0.0 - pow((0 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.55) * 0)) - (patch_param_6)) * (1.0 - (exp(0.0 - pow((0 - (patch_param_5)) / (max(0.001, 0.09 * 7)), 2.0))))))) * (max(0.0, min((0.55 + ((patch_param_4) - 0.55) * (exp(0.0 - pow((0 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.55) * 0), (patch_param_6) + max(0.0, ((0.55 + ((patch_param_4) - 0.55) * (exp(0.0 - pow((0 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.55) * 0)) - (patch_param_6)) * (1.0 - (exp(0.0 - pow((0 - (patch_param_5)) / (max(0.001, 0.09 * 7)), 2.0)))))))) * max(0.0, 1)); +voice_0_graph_terminal_reflection_oral_back = 0; +voice_0_graph_terminal_area_folds = max(0.000001, 0.49 * max(0.0, 1)); +voice_0_graph_terminal_reflection_folds = 0; +voice_0_graph_terminal_area_mouth = max(0.000001, ((max(0.0, min((0.82 + ((patch_param_4) - 0.82) * (exp(0.0 - pow((6 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.82) * 1), (patch_param_6) + max(0.0, ((0.82 + ((patch_param_4) - 0.82) * (exp(0.0 - pow((6 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.82) * 1)) - (patch_param_6)) * (1.0 - (exp(0.0 - pow((6 - (patch_param_5)) / (max(0.001, 0.09 * 7)), 2.0))))))) * (max(0.0, min((0.82 + ((patch_param_4) - 0.82) * (exp(0.0 - pow((6 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.82) * 1), (patch_param_6) + max(0.0, ((0.82 + ((patch_param_4) - 0.82) * (exp(0.0 - pow((6 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 0.82) * 1)) - (patch_param_6)) * (1.0 - (exp(0.0 - pow((6 - (patch_param_5)) / (max(0.001, 0.09 * 7)), 2.0)))))))) * max(0.0, 1.2)); +voice_0_graph_terminal_reflection_mouth = ((0.96) * (1.0 - clip01(pow(clip01((max(0.0, patch_param_7)) / 1.5), 2.0))) + (-0.82) * clip01(pow(clip01((max(0.0, patch_param_7)) / 1.5), 2.0))); +voice_0_graph_node_area_subglottal_wall = max(0.000001, voice_0_graph_terminal_area_subglottal_wall); +voice_0_graph_node_reflection_subglottal_wall = (voice_0_graph_terminal_reflection_subglottal_wall) / 1; +voice_0_graph_node_area_folds_trachea_top = max(0.000001, voice_0_graph_terminal_area_trachea_top); +voice_0_graph_node_reflection_folds_trachea_top = (voice_0_graph_terminal_reflection_trachea_top) / 1; +voice_0_graph_node_area_oral_back = max(0.000001, voice_0_graph_terminal_area_oral_back); +voice_0_graph_node_reflection_oral_back = (voice_0_graph_terminal_reflection_oral_back) / 1; +voice_0_graph_node_area_mouth = max(0.000001, voice_0_graph_terminal_area_mouth); +voice_0_graph_node_reflection_mouth = (voice_0_graph_terminal_reflection_mouth) / 1; +voice_0_graph_segment_area_0 = max(0.000001, 0.3364); +voice_0_graph_segment_area_1 = max(0.000001, ((max(0.0, min((1.45 + ((patch_param_4) - 1.45) * (exp(0.0 - pow((3 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 1.45) * 0), (patch_param_6) + max(0.0, ((1.45 + ((patch_param_4) - 1.45) * (exp(0.0 - pow((3 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 1.45) * 0)) - (patch_param_6)) * (1.0 - (exp(0.0 - pow((3 - (patch_param_5)) / (max(0.001, 0.09 * 7)), 2.0))))))) * (max(0.0, min((1.45 + ((patch_param_4) - 1.45) * (exp(0.0 - pow((3 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 1.45) * 0), (patch_param_6) + max(0.0, ((1.45 + ((patch_param_4) - 1.45) * (exp(0.0 - pow((3 - (patch_param_3)) / (max(0.001, 0.18 * 7)), 2.0))) + ((patch_param_7) - 1.45) * 0)) - (patch_param_6)) * (1.0 - (exp(0.0 - pow((3 - (patch_param_5)) / (max(0.001, 0.09 * 7)), 2.0))))))))); +voice_0_graph_connection_coupling_larynx_to_tract = clip01(0.92); +voice_0_graph_connection_loss_larynx_to_tract = clip01(1); +voice_0_graph_radiation_gain = 1.0; +voice_0_graph_source_folds = 0.0; +voice_0_graph(x) = voice_0_graph_loop ~ si.bus(4) : (si.block(4), _) with { + voice_0_graph_loop(r0, r1, l0, l1) = voice_0_graph_next_r0, voice_0_graph_next_r1, voice_0_graph_next_l0, voice_0_graph_next_l1, voice_0_graph_out with { + voice_0_graph_in_0_start = l0; + voice_0_graph_in_0_end = r0; + voice_0_graph_in_1_start = l1; + voice_0_graph_in_1_end = r1; + voice_0_graph_node_incident_pressure_subglottal_wall = (voice_0_graph_in_0_start) / 1; + voice_0_graph_node_source_subglottal_wall = 0.0; + voice_0_graph_source_folds_folds_trachea_top_load_pressure = voice_0_graph_node_incident_pressure_folds_trachea_top; + voice_0_graph_source_folds_folds_trachea_top_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 145 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_folds_folds_trachea_top_flow_scale = max(0.0, 1.05); + voice_0_graph_source_folds_folds_trachea_top_tissue_loss = clip01(0.2); + voice_0_graph_source_folds_folds_trachea_top_aperture_shape = clip01(0.48); + voice_0_graph_source_folds_folds_trachea_top_flow_loss = max(0.0, 0.4); + voice_0_graph_source_folds_folds_trachea_top_reservoir_pressure = (clip01(patch_param_0)) * (max(0.0, 1)); + voice_0_graph_source_folds_folds_trachea_top_downstream_pressure = (max(0.0, 0.05)) + (max(0.0, 0.42)) * ma.tanh(voice_0_graph_source_folds_folds_trachea_top_load_pressure); + voice_0_graph_source_folds_folds_trachea_top_pressure_drive = max(0.0, voice_0_graph_source_folds_folds_trachea_top_reservoir_pressure - voice_0_graph_source_folds_folds_trachea_top_downstream_pressure); + voice_0_graph_source_folds_folds_trachea_top_stiffness = voice_0_graph_source_folds_folds_trachea_top_stiffness_hint * (0.35 + 1.65 * (clip01(patch_param_2))); + voice_0_graph_source_folds_folds_trachea_top_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_folds_folds_trachea_top_stiffness) / (max(0.02, 0.35))))); + voice_0_graph_source_folds_folds_trachea_top_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_folds_folds_trachea_top_load_pressure * (max(0.0, 0.42))); + voice_0_graph_source_folds_folds_trachea_top_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.18)) + 0.080 * voice_0_graph_source_folds_folds_trachea_top_tissue_loss + 0.18 * clip01(max(0.0, patch_param_1)); + voice_0_graph_source_folds_folds_trachea_top_oscillation_gate = clip01((voice_0_graph_source_folds_folds_trachea_top_pressure_drive - voice_0_graph_source_folds_folds_trachea_top_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.18))))); + voice_0_graph_source_folds_folds_trachea_top_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_0)) * (1.0 - 0.45 * (max(0.0, 0.18)) - 0.35 * voice_0_graph_source_folds_folds_trachea_top_tissue_loss) + 0.35 * (clip01(patch_param_2))); + voice_0_graph_source_folds_folds_trachea_top_modal_seed = (no.noise * 0.018 + voice_0_graph_source_folds_folds_trachea_top_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_1))) * 0.16); + voice_0_graph_source_folds_folds_trachea_top_modal_ring = voice_0_graph_source_folds_folds_trachea_top_modal_seed : fi.resonbp(voice_0_graph_source_folds_folds_trachea_top_modal_frequency, voice_0_graph_source_folds_folds_trachea_top_modal_q, 1); + voice_0_graph_source_folds_folds_trachea_top_modal_oscillator = os.osc(voice_0_graph_source_folds_folds_trachea_top_modal_frequency * voice_0_graph_source_folds_folds_trachea_top_load_detune) * voice_0_graph_source_folds_folds_trachea_top_oscillation_gate; + voice_0_graph_source_folds_folds_trachea_top_modal_tissue = (voice_0_graph_source_folds_folds_trachea_top_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_2))) + voice_0_graph_source_folds_folds_trachea_top_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.18)) - 0.45 * voice_0_graph_source_folds_folds_trachea_top_tissue_loss); + voice_0_graph_source_folds_folds_trachea_top_upper_stiffness_effective = max((max(0.0, 0.04)), voice_0_graph_source_folds_folds_trachea_top_stiffness * (0.80 + 0.45 * (clip01(patch_param_2)))); + voice_0_graph_source_folds_folds_trachea_top_lower_stiffness_effective = max((max(0.0, 0.06)), voice_0_graph_source_folds_folds_trachea_top_stiffness * (1.05 + 0.55 * (clip01(patch_param_2)))); + voice_0_graph_source_folds_folds_trachea_top_coupling_stiffness = (max(0.0, 0.09)) * (1.0 + 1.5 * (clip01(patch_param_2))); + voice_0_graph_source_folds_folds_trachea_top_lower_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.010 + 0.090 * (max(0.0, 0.18)) + 0.040 * (max(0.0, 0.18)) + 0.055 * voice_0_graph_source_folds_folds_trachea_top_tissue_loss) / (max(0.02, 0.36))))); + voice_0_graph_source_folds_folds_trachea_top_upper_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.012 + 0.105 * (max(0.0, 0.18)) + 0.030 * (max(0.0, 0.18)) + 0.055 * voice_0_graph_source_folds_folds_trachea_top_tissue_loss) / (max(0.02, 0.22))))); + voice_0_graph_source_folds_folds_trachea_top_lower_force = (voice_0_graph_source_folds_folds_trachea_top_pressure_drive * (0.0005 + 0.0028 * (1.0 - clip01(max(0.0, patch_param_1)))) - (max(0.0, 0.42)) * voice_0_graph_source_folds_folds_trachea_top_load_pressure * 0.0012) / (max(0.02, 0.36)); + voice_0_graph_source_folds_folds_trachea_top_upper_force = (voice_0_graph_source_folds_folds_trachea_top_pressure_drive * (0.0003 + 0.0018 * (1.0 - clip01(max(0.0, patch_param_1)))) - (max(0.0, 0.42)) * voice_0_graph_source_folds_folds_trachea_top_load_pressure * 0.0008) / (max(0.02, 0.22)); + voice_0_graph_source_folds_folds_trachea_top_lower_velocity = voice_0_graph_source_folds_folds_trachea_top_lower_force : + ~ *(voice_0_graph_source_folds_folds_trachea_top_lower_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_folds_folds_trachea_top_lower_stiffness_effective + voice_0_graph_source_folds_folds_trachea_top_coupling_stiffness + 0.4 * (max(0.0, 0.8)))); + voice_0_graph_source_folds_folds_trachea_top_upper_velocity = (voice_0_graph_source_folds_folds_trachea_top_upper_force + voice_0_graph_source_folds_folds_trachea_top_lower_velocity * voice_0_graph_source_folds_folds_trachea_top_coupling_stiffness * 0.35) : + ~ *(voice_0_graph_source_folds_folds_trachea_top_upper_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_folds_folds_trachea_top_upper_stiffness_effective + voice_0_graph_source_folds_folds_trachea_top_coupling_stiffness + 0.4 * (max(0.0, 0.8)))); + voice_0_graph_source_folds_folds_trachea_top_lower_displacement = voice_0_graph_source_folds_folds_trachea_top_lower_velocity : + ~ *(min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.36))))); + voice_0_graph_source_folds_folds_trachea_top_upper_displacement = voice_0_graph_source_folds_folds_trachea_top_upper_velocity : + ~ *(min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.22))))); + voice_0_graph_source_folds_folds_trachea_top_collision = (max(0.0, 0.62)) * max(0.0, 0.0 - ((max(0.0, 0.012)) + (max(0.0, patch_param_1)) + voice_0_graph_source_folds_folds_trachea_top_upper_displacement)); + voice_0_graph_source_folds_folds_trachea_top_displacement = voice_0_graph_source_folds_folds_trachea_top_lower_displacement * (1.0 - (clip01(0.24))) + (voice_0_graph_source_folds_folds_trachea_top_upper_displacement - voice_0_graph_source_folds_folds_trachea_top_collision) * (clip01(0.24)); + voice_0_graph_source_folds_folds_trachea_top_aperture_linear = max(0.0, (max(0.0, 0.012)) + (max(0.0, patch_param_1)) + voice_0_graph_source_folds_folds_trachea_top_displacement - (max(0.0, 0.8)) * pow(voice_0_graph_source_folds_folds_trachea_top_displacement, 3.0)); + voice_0_graph_source_folds_folds_trachea_top_aperture = voice_0_graph_source_folds_folds_trachea_top_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_folds_folds_trachea_top_aperture_shape) + pow(voice_0_graph_source_folds_folds_trachea_top_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_folds_folds_trachea_top_aperture_shape); + voice_0_graph_source_folds_folds_trachea_top_flow_resistance = 1.0 + voice_0_graph_source_folds_folds_trachea_top_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_folds_folds_trachea_top_aperture + (max(0.0, 0.012)))); + voice_0_graph_source_folds_folds_trachea_top_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_folds_folds_trachea_top_aperture)); + voice_0_graph_source_folds_folds_trachea_top_voicing = voice_0_graph_source_folds_folds_trachea_top_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_2))); + voice_0_graph_source_folds_folds_trachea_top_flow = ma.tanh(((voice_0_graph_source_folds_folds_trachea_top_pressure_drive * voice_0_graph_source_folds_folds_trachea_top_aperture * (1.5 + 3.5 * voice_0_graph_source_folds_folds_trachea_top_flow_scale)) + (voice_0_graph_source_folds_folds_trachea_top_voicing * voice_0_graph_source_folds_folds_trachea_top_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_2))))) / voice_0_graph_source_folds_folds_trachea_top_flow_resistance); + voice_0_graph_source_folds_folds_trachea_top_noise = voice_0_graph_source_folds_folds_trachea_top_turbulence * (clip01(0.035)) * voice_0_graph_source_folds_folds_trachea_top_pressure_drive * clip01(voice_0_graph_source_folds_folds_trachea_top_aperture) * (1.0 - 0.55 * (clip01(patch_param_2))) / voice_0_graph_source_folds_folds_trachea_top_flow_resistance; + voice_0_graph_source_folds_folds_trachea_top_out = (voice_0_graph_source_folds_folds_trachea_top_flow * voice_0_graph_source_folds_folds_trachea_top_flow_scale * (0.55 + 2.6 * voice_0_graph_source_folds_folds_trachea_top_pressure_drive) + voice_0_graph_source_folds_folds_trachea_top_noise) * ((1) * (1.0)); + voice_0_graph_node_incident_pressure_folds_trachea_top = (voice_0_graph_in_0_end) / 1; + voice_0_graph_node_source_folds_trachea_top = voice_0_graph_source_folds_folds_trachea_top_out; + voice_0_graph_node_incident_pressure_oral_back = (voice_0_graph_in_1_start) / 1; + voice_0_graph_node_source_oral_back = 0.0; + voice_0_graph_node_incident_pressure_mouth = (voice_0_graph_in_1_end) / 1; + voice_0_graph_node_source_mouth = 0.0; + voice_0_graph_connection_reflection_larynx_to_tract_trachea_top_0_end = (2.0 * ((voice_0_graph_terminal_area_trachea_top / 1)) - ((voice_0_graph_terminal_area_trachea_top / 1) + voice_0_graph_segment_area_1)) / max(0.000001, (voice_0_graph_terminal_area_trachea_top / 1) + voice_0_graph_segment_area_1); + voice_0_graph_connection_scattered_larynx_to_tract_trachea_top_0_end = voice_0_graph_connection_reflection_larynx_to_tract_trachea_top_0_end * voice_0_graph_in_0_end + (1.0 + voice_0_graph_connection_reflection_larynx_to_tract_trachea_top_0_end) * (voice_0_graph_in_1_start); + voice_0_graph_out_0_end = ((voice_0_graph_connection_scattered_larynx_to_tract_trachea_top_0_end) * (voice_0_graph_connection_coupling_larynx_to_tract) + voice_0_graph_in_0_end * (1.0 - (voice_0_graph_connection_coupling_larynx_to_tract)) + (voice_0_graph_node_source_folds_trachea_top) / 1) * voice_0_graph_connection_loss_larynx_to_tract; + voice_0_graph_connection_reflection_larynx_to_tract_oral_back_1_start = (2.0 * (voice_0_graph_segment_area_1) - ((voice_0_graph_terminal_area_trachea_top / 1) + voice_0_graph_segment_area_1)) / max(0.000001, (voice_0_graph_terminal_area_trachea_top / 1) + voice_0_graph_segment_area_1); + voice_0_graph_connection_scattered_larynx_to_tract_oral_back_1_start = voice_0_graph_connection_reflection_larynx_to_tract_oral_back_1_start * voice_0_graph_in_1_start + (1.0 + voice_0_graph_connection_reflection_larynx_to_tract_oral_back_1_start) * (voice_0_graph_in_0_end); + voice_0_graph_out_1_start = ((voice_0_graph_connection_scattered_larynx_to_tract_oral_back_1_start) * (voice_0_graph_connection_coupling_larynx_to_tract) + voice_0_graph_in_1_start * (1.0 - (voice_0_graph_connection_coupling_larynx_to_tract)) + (voice_0_graph_node_source_oral_back) / 1) * voice_0_graph_connection_loss_larynx_to_tract; + voice_0_graph_connection_energy_in_larynx_to_tract = ((voice_0_graph_terminal_area_trachea_top / 1)) * pow(voice_0_graph_in_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_in_1_start, 2.0); + voice_0_graph_connection_energy_out_larynx_to_tract = ((voice_0_graph_terminal_area_trachea_top / 1)) * pow(voice_0_graph_out_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_out_1_start, 2.0); + voice_0_graph_out_0_start = voice_0_graph_in_0_start * voice_0_graph_node_reflection_subglottal_wall + (voice_0_graph_node_source_subglottal_wall) / 1; + voice_0_graph_radiation_boundary_load_mouth = clip01((voice_0_graph_radiation_admittance_mouth) * (voice_0_graph_radiation_differentiation_mouth) * (clip01(0.98))); + voice_0_graph_radiation_reflected_raw_mouth = (voice_0_graph_in_1_end) * (voice_0_graph_terminal_reflection_mouth) + (voice_0_graph_node_source_mouth); + voice_0_graph_radiation_reflected_loaded_mouth = (voice_0_graph_radiation_reflected_raw_mouth) * (1.0 - (voice_0_graph_radiation_boundary_load_mouth)) + ((voice_0_graph_radiation_reflected_raw_mouth) : fi.lowpass(1, voice_0_graph_radiation_highpass_mouth)) * (voice_0_graph_radiation_boundary_load_mouth); + voice_0_graph_out_1_end = voice_0_graph_radiation_reflected_loaded_mouth; + voice_0_graph_radiation_model_mouth = 1; + voice_0_graph_radiation_reference_area_mouth = max(0.18, 1.90 * 1.90 * (0.30 + 0.70 * clip01(pow(clip01((max(0.0, patch_param_7)) / 1.5), 2.0)))); + voice_0_graph_radiation_differentiation_mouth = (0.62 + 0.24 * clip01(pow(clip01((max(0.0, patch_param_7)) / 1.5), 2.0))); + voice_0_graph_radiation_highpass_mouth = (120.0 + 180.0 * clip01(pow(clip01((max(0.0, patch_param_7)) / 1.5), 2.0))); + voice_0_graph_radiation_admittance_mouth = sqrt(clip01((voice_0_graph_terminal_area_mouth) / max(0.000001, (voice_0_graph_terminal_area_mouth) + (voice_0_graph_radiation_reference_area_mouth)))); + voice_0_graph_radiation_flow_mouth = ((voice_0_graph_in_1_end - voice_0_graph_out_1_end)); + voice_0_graph_delay_0 = max(0.000001, 0.00034985 * ma.SR); + voice_0_graph_segment_loss_0 = clip01((0.998) * (sqrt(clip01((voice_0_graph_segment_area_0) / max(0.000001, (voice_0_graph_segment_area_0) + 0.020))))); + voice_0_graph_next_r0 = voice_0_graph_out_0_start : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_next_l0 = voice_0_graph_out_0_end : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_delay_1 = max(0.000001, 0.00049563 * ma.SR); + voice_0_graph_segment_loss_1 = clip01((0.997) * (sqrt(clip01((voice_0_graph_segment_area_1) / max(0.000001, (voice_0_graph_segment_area_1) + 0.012))) * (0.998 - 0.010 * clip01(0.080 / max(0.000001, (voice_0_graph_segment_area_1) + 0.080))))); + voice_0_graph_next_r1 = voice_0_graph_out_1_start : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_next_l1 = voice_0_graph_out_1_end : de.fdelay(4096, min(4095, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_out = (((voice_0_graph_radiation_flow_mouth * (1.0 - (voice_0_graph_radiation_differentiation_mouth)) + (voice_0_graph_radiation_flow_mouth : fi.highpass(1, voice_0_graph_radiation_highpass_mouth)) * (voice_0_graph_radiation_differentiation_mouth)) * clip01(0.98) * voice_0_graph_radiation_admittance_mouth)) * voice_0_graph_radiation_gain; + }; +}; +voice_0_acoustic_graph_radiated = voice_0_graph(voice_0_graph_drive); +voice_0_freq = ((max(20, 145 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = voice_0_acoustic_graph_radiated; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.08, 1.1) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.18); + +process = softclip((voice_0) * 0.34); diff --git a/tools/aqua-playground/lowered/advanced-machine-breath.dsp b/tools/aqua-playground/lowered/advanced-machine-breath.dsp new file mode 100644 index 0000000..6453aa3 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-machine-breath.dsp @@ -0,0 +1,87 @@ +import("stdfaust.lib"); +declare name "advanced-machine-breath"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.16 * lfo_hold(5.5, 0); +patch_mod_pitch = 0 + 0.028 * lfo_hold(5.5, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + 0.24 * lfo_hold(5.5, 0); +patch_mod_hpf = 0 + 0.12 * lfo_sq(2.75, 0); +patch_mod_noise = 0 + 0.18 * lfo_sq(2.75, 0); +patch_mod_drive = 0 + 0.18 * lfo_hold(5.5, 0); +patch_mod_fold = 0 + 0.16 * lfo_hold(5.5, 0); +patch_mod_formant_mix = 0 + 0.25 * lfo_sq(2.75, 0); +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 72 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 72 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 72 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1.5))) * (max(0.0, 0.8 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.45, 0.0001))) / ma.PI) - 1.0; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0.12 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0.12 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.12 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.28 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.025 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.025 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = ((voice_0_phased : fi.resonbp(290, 5.272727, 1.0)) * 0.55 + (voice_0_phased : fi.resonbp(760, 6.333333, 1.0)) * 1 + (voice_0_phased : fi.resonbp(1780, 6.846154, 1.0)) * 0.5) / 2.05; +voice_0 = ((voice_0_phased * (1.0 - clip01(0.22 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0.22 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.004, 0, 1, 0.55, 0.72) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.1); + +voice_1_age = age; +voice_1_freq = ((max(20, 36 * pow(2.0, -0.18 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = select2(wrap01(os.phasor(1.0, ((max(20, 36 * pow(2.0, -0.18 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 36 * pow(2.0, -0.18 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1.5))) * (max(0.0, 0.8 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.45, 0.0001))) / ma.PI) < clip01(0.37 + 0 * voice_1_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0.12 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0.12 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.12 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.28 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.025 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.025 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.004, 0, 1, 0.55, 0.72) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.13); + +voice_2_age = age; +voice_2_freq = ((max(20, 700 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = no.noise; +voice_2_colored = (voice_2_osc * (1.0 - clip01(0.8 + patch_mod_noise + 0.0)) + no.noise * clip01(0.8 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0.12 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0.12 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.12 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.45 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.42 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.42 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered; +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0.004, 0, 1, 0.35, 0.5) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.055); + +voice_3_age = age; +voice_3_freq = ((max(20, 144 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 144 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 144 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2.25))) * (max(0.0, 1.1 + patch_mod_fm_index + 0.0) * exp(-voice_3_age / max(0.5, 0.0001))) / ma.PI) - 0.5); +voice_3_colored = (voice_3_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.34 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0.12 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0.12 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.12 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(0.28 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.025 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.025 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = ((voice_3_phased : fi.resonbp(510, 5.666667, 1.0)) * 0.35 + (voice_3_phased : fi.resonbp(1320, 7.764706, 1.0)) * 0.9 + (voice_3_phased : fi.resonbp(2100, 7, 1.0)) * 0.45) / 1.7; +voice_3 = ((voice_3_phased * (1.0 - clip01(0.18 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0.18 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0.004, 0, 1, 0.48, 0.62) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.045); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3) * 0.7); diff --git a/tools/aqua-playground/lowered/advanced-ritual-sequence.dsp b/tools/aqua-playground/lowered/advanced-ritual-sequence.dsp new file mode 100644 index 0000000..b59626c --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-ritual-sequence.dsp @@ -0,0 +1,87 @@ +import("stdfaust.lib"); +declare name "advanced-ritual-sequence"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time - floor(time / 0.42) * 0.42; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.2 * lfo_tri(2.38, 0); +patch_mod_pitch = 0 + 0.018 * lfo_tri(2.38, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + 0.12 * lfo_tri(2.38, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0 + 0.75 * lfo_tri(2.38, 0); + +voice_0_age = age; +voice_0_freq = ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.065, 1.4983, 1.0) * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.065, 1.4983, 1.0) * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.065, 1.4983, 1.0) * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2))) * (max(0.0, 1.8 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.32, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.035 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.035 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.001, 0, 0.8474576, 0.5, 0.045) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.1534); + +voice_1_age = age; +voice_1_freq = ((max(20, 293.66 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * select2(voice_1_age < 0.065, 1.3348, 1.0) * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 293.66 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * select2(voice_1_age < 0.065, 1.3348, 1.0) * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 293.66 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * select2(voice_1_age < 0.065, 1.3348, 1.0) * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2))) * (max(0.0, 1.8 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.32, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.035 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.035 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.001, 0, 0.8474576, 0.38, 0.035) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.09); + +voice_2_age = age; +voice_2_freq = ((max(20, 392 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * select2(voice_2_age < 0.065, 1.2599, 1.0) * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 392 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * select2(voice_2_age < 0.065, 1.2599, 1.0) * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 392 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * select2(voice_2_age < 0.065, 1.2599, 1.0) * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2))) * (max(0.0, 1.8 + patch_mod_fm_index + 0.0) * exp(-voice_2_age / max(0.32, 0.0001))) / ma.PI)); +voice_2_colored = (voice_2_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.035 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.035 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered; +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0.001, 0, 0.8474576, 0.32, 0.028) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.07); + +voice_3_age = age; +voice_3_freq = ((max(20, 3100 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = no.noise; +voice_3_colored = (voice_3_osc * (1.0 - clip01(1 + patch_mod_noise + 0.0)) + no.noise * clip01(1 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(0.46 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.68 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.68 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = voice_3_phased; +voice_3 = ((voice_3_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0.001, 0, 0.8474576, 0.16, 0.018) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.025); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3) * 0.62); diff --git a/tools/aqua-playground/lowered/advanced-subtractive-drums.dsp b/tools/aqua-playground/lowered/advanced-subtractive-drums.dsp new file mode 100644 index 0000000..e0bcd34 --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-subtractive-drums.dsp @@ -0,0 +1,98 @@ +import("stdfaust.lib"); +declare name "advanced-subtractive-drums"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(32, 58 * pow(2.0, -3.6 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(32, 58 * pow(2.0, -3.6 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.resonlp(max(20.0, clip01(0.78 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0), max(0.1, 0.28), 1.0) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.62, 0.38, 0.038) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.82); + +voice_1_age = age; +voice_1_freq = ((max(20, 1700 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = no.noise; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0.95 + patch_mod_noise + 0.0)) + no.noise * clip01(0.95 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.48 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.48 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)) : fi.resonbp(max(20.0, clip01(0.38) * 18000.0), max(0.1, 2.2), 1.0); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 0.62, 0.18, 0.018) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.26); + +voice_2_age = age; +voice_2_freq = ((max(20, 188 * pow(2.0, -1.05 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 188 * pow(2.0, -1.05 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 0.5); +voice_2_colored = (voice_2_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.52 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered; +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0, 0, 0.62, 0.13, 0.026) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +voice_3_age = age; +voice_3_freq = ((max(20, 8200 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = no.noise; +voice_3_colored = (voice_3_osc * (1.0 - clip01(1 + patch_mod_noise + 0.0)) + no.noise * clip01(1 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(0.2 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.88 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.88 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = voice_3_phased; +voice_3 = ((voice_3_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0, 0, 0.62, 0.052, 0.005) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.11); + +voice_4_age = age; +voice_4_freq = ((max(20, 540 * pow(2.0, 0 * voice_4_age + 0.5 * 0 * voice_4_age * voice_4_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_4_osc = select2(wrap01(os.phasor(1.0, ((max(20, 540 * pow(2.0, 0 * voice_4_age + 0.5 * 0 * voice_4_age * voice_4_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.42 + 0 * voice_4_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_4_colored = (voice_4_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_4_driven = ma.tanh(voice_4_colored * (1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.14 + patch_mod_drive + 0.0) * 12.0); +voice_4_folded = voice_4_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_4_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_4_filtered = voice_4_folded : fi.lowpass(1, max(20.0, clip01(0.72 * (1.0 + 0 * voice_4_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.18 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.18 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_4_phased = voice_4_filtered; +voice_4_formants = voice_4_phased; +voice_4 = ((voice_4_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_4_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_4_age, 0, 0, 0.62, 0.16, 0.035) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3 + voice_4) * 0.72); diff --git a/tools/aqua-playground/lowered/advanced-syrinx-voice.dsp b/tools/aqua-playground/lowered/advanced-syrinx-voice.dsp new file mode 100644 index 0000000..f7102ab --- /dev/null +++ b/tools/aqua-playground/lowered/advanced-syrinx-voice.dsp @@ -0,0 +1,238 @@ +import("stdfaust.lib"); +declare name "advanced-syrinx-voice"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0_base = hslider("/voice/left/pressure", 0.78, 0, 1.5, 0.001) : si.smoo; +patch_param_0_curve_time = max(0.0, age * 1 - 0); +patch_param_0_curve_value = select2(patch_param_0_curve_time < 0.04, select2(patch_param_0_curve_time < 0.28, select2(patch_param_0_curve_time < 0.56, select2(patch_param_0_curve_time < 0.92, 0.24, seg(patch_param_0_curve_time, 0.56, 0.36, 0.88, 0.24)), seg(patch_param_0_curve_time, 0.28, 0.28, 0.76, 0.88)), seg(patch_param_0_curve_time, 0.04, 0.24, 0.82, 0.76)), seg(patch_param_0_curve_time, 0, 0.04, 0.05, 0.82)); +patch_param_0_curve_depth = hslider("/curves/left_phrase_pressure/depth", 0.92, 0, 1, 0.001) : si.smoo; +patch_param_0 = min(1.5, max(0, patch_param_0_base * (1.0 - patch_param_0_curve_depth) + patch_param_0_curve_value * patch_param_0_curve_depth)); +patch_param_1_base = hslider("/voice/right/pressure", 0.66, 0, 1.5, 0.001) : si.smoo; +patch_param_1_curve_time = max(0.0, age * 1 - 0); +patch_param_1_curve_value = select2(patch_param_1_curve_time < 0.06, select2(patch_param_1_curve_time < 0.24, select2(patch_param_1_curve_time < 0.5, select2(patch_param_1_curve_time < 0.92, 0.18, seg(patch_param_1_curve_time, 0.5, 0.42, 0.58, 0.18)), seg(patch_param_1_curve_time, 0.24, 0.26, 0.74, 0.58)), seg(patch_param_1_curve_time, 0.06, 0.18, 0.68, 0.74)), seg(patch_param_1_curve_time, 0, 0.06, 0.03, 0.68)); +patch_param_1_curve_depth = hslider("/curves/right_phrase_pressure/depth", 0.92, 0, 1, 0.001) : si.smoo; +patch_param_1 = min(1.5, max(0, patch_param_1_base * (1.0 - patch_param_1_curve_depth) + patch_param_1_curve_value * patch_param_1_curve_depth)); +patch_param_2_base = hslider("/voice/left/opening", 0.23, 0, 1, 0.001) : si.smoo; +patch_param_2_curve_time = max(0.0, age * 1 - 0); +patch_param_2_curve_value = select2(patch_param_2_curve_time < 0.035, select2(patch_param_2_curve_time < 0.46, select2(patch_param_2_curve_time < 0.92, 0.05, seg(patch_param_2_curve_time, 0.46, 0.46, 0.18, 0.05)), seg(patch_param_2_curve_time, 0.035, 0.425, 0.24, 0.18)), seg(patch_param_2_curve_time, 0, 0.035, 0.02, 0.24)); +patch_param_2_curve_depth = hslider("/curves/left_phrase_opening/depth", 0.85, 0, 1, 0.001) : si.smoo; +patch_param_2 = min(1, max(0, patch_param_2_base * (1.0 - patch_param_2_curve_depth) + patch_param_2_curve_value * patch_param_2_curve_depth)); +patch_param_3_base = hslider("/voice/right/opening", 0.19, 0, 1, 0.001) : si.smoo; +patch_param_3_curve_time = max(0.0, age * 1 - 0); +patch_param_3_curve_value = select2(patch_param_3_curve_time < 0.04, select2(patch_param_3_curve_time < 0.42, select2(patch_param_3_curve_time < 0.92, 0.05, seg(patch_param_3_curve_time, 0.42, 0.5, 0.15, 0.05)), seg(patch_param_3_curve_time, 0.04, 0.38, 0.2, 0.15)), seg(patch_param_3_curve_time, 0, 0.04, 0.02, 0.2)); +patch_param_3_curve_depth = hslider("/curves/right_phrase_opening/depth", 0.85, 0, 1, 0.001) : si.smoo; +patch_param_3 = min(1, max(0, patch_param_3_base * (1.0 - patch_param_3_curve_depth) + patch_param_3_curve_value * patch_param_3_curve_depth)); +patch_param_4 = hslider("/voice/left/tension", 0.43, 0, 1, 0.001) : si.smoo; +patch_param_5 = hslider("/voice/right/tension", 0.5, 0, 1, 0.001) : si.smoo; +patch_param_6_base = hslider("/voice/beak/opening", 0.88, 0, 1.5, 0.001) : si.smoo; +patch_param_6_curve_time = max(0.0, age * 1 - 0); +patch_param_6_curve_value = select2(patch_param_6_curve_time < 0.08, select2(patch_param_6_curve_time < 0.52, select2(patch_param_6_curve_time < 0.92, 0.58, seg(patch_param_6_curve_time, 0.52, 0.4, 1.08, 0.58)), seg(patch_param_6_curve_time, 0.08, 0.44, 0.94, 1.08)), seg(patch_param_6_curve_time, 0, 0.08, 0.34, 0.94)); +patch_param_6_curve_depth = hslider("/curves/beak_phrase/depth", 0.72, 0, 1, 0.001) : si.smoo; +patch_param_6 = min(1.5, max(0, patch_param_6_base * (1.0 - patch_param_6_curve_depth) + patch_param_6_curve_value * patch_param_6_curve_depth)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_graph_drive = 1.0; +voice_0_graph_terminal_area_left_merge = max(0.000001, 0.1764 * max(0.0, 1)); +voice_0_graph_terminal_reflection_left_merge = 0; +voice_0_graph_terminal_area_right_merge = max(0.000001, 0.16 * max(0.0, 1)); +voice_0_graph_terminal_reflection_right_merge = 0; +voice_0_graph_terminal_area_trachea_base = max(0.000001, 0.1444 * max(0.0, 1)); +voice_0_graph_terminal_reflection_trachea_base = 0; +voice_0_graph_terminal_area_left_labium = max(0.000001, 0.0484 * max(0.0, 1)); +voice_0_graph_terminal_reflection_left_labium = 0; +voice_0_graph_terminal_area_right_labium = max(0.000001, 0.04 * max(0.0, 1)); +voice_0_graph_terminal_reflection_right_labium = 0; +voice_0_graph_terminal_area_beak = max(0.000001, 0.2116 * max(0.0, 0.88)); +voice_0_graph_terminal_reflection_beak = ((0.96) * (1.0 - clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))) + (-0.72) * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))); +voice_0_graph_node_area_left_labium = max(0.000001, voice_0_graph_terminal_area_left_labium); +voice_0_graph_node_reflection_left_labium = (voice_0_graph_terminal_reflection_left_labium) / 1; +voice_0_graph_node_area_left_merge = max(0.000001, voice_0_graph_terminal_area_left_merge); +voice_0_graph_node_reflection_left_merge = (voice_0_graph_terminal_reflection_left_merge) / 1; +voice_0_graph_node_area_right_labium = max(0.000001, voice_0_graph_terminal_area_right_labium); +voice_0_graph_node_reflection_right_labium = (voice_0_graph_terminal_reflection_right_labium) / 1; +voice_0_graph_node_area_right_merge = max(0.000001, voice_0_graph_terminal_area_right_merge); +voice_0_graph_node_reflection_right_merge = (voice_0_graph_terminal_reflection_right_merge) / 1; +voice_0_graph_node_area_trachea_base = max(0.000001, voice_0_graph_terminal_area_trachea_base); +voice_0_graph_node_reflection_trachea_base = (voice_0_graph_terminal_reflection_trachea_base) / 1; +voice_0_graph_node_area_beak = max(0.000001, voice_0_graph_terminal_area_beak); +voice_0_graph_node_reflection_beak = (voice_0_graph_terminal_reflection_beak) / 1; +voice_0_graph_segment_area_0 = max(0.000001, 0.1089); +voice_0_graph_segment_area_1 = max(0.000001, 0.0961); +voice_0_graph_segment_area_2 = max(0.000001, 0.2704); +voice_0_graph_connection_coupling_syrinx_merge = clip01(1); +voice_0_graph_connection_loss_syrinx_merge = clip01(1); +voice_0_graph_radiation_gain = 1.0; +voice_0_graph_source_left_labium = 0.0; +voice_0_graph_source_right_labium = 0.0; +voice_0_graph(x) = voice_0_graph_loop ~ si.bus(6) : (si.block(6), _) with { + voice_0_graph_loop(r0, r1, r2, l0, l1, l2) = voice_0_graph_next_r0, voice_0_graph_next_r1, voice_0_graph_next_r2, voice_0_graph_next_l0, voice_0_graph_next_l1, voice_0_graph_next_l2, voice_0_graph_out with { + voice_0_graph_in_0_start = l0; + voice_0_graph_in_0_end = r0; + voice_0_graph_in_1_start = l1; + voice_0_graph_in_1_end = r1; + voice_0_graph_in_2_start = l2; + voice_0_graph_in_2_end = r2; + voice_0_graph_source_left_labium_left_labium_load_pressure = voice_0_graph_node_incident_pressure_left_labium; + voice_0_graph_source_left_labium_left_labium_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 920 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 5.2) * 0.008))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_left_labium_left_labium_flow_scale = max(0.0, 1.15); + voice_0_graph_source_left_labium_left_labium_tissue_loss = clip01(0.18); + voice_0_graph_source_left_labium_left_labium_aperture_shape = clip01(0.4); + voice_0_graph_source_left_labium_left_labium_flow_loss = max(0.0, 0.35); + voice_0_graph_source_left_labium_left_labium_reservoir_pressure = (clip01(patch_param_0)) * (max(0.0, 1)); + voice_0_graph_source_left_labium_left_labium_downstream_pressure = (max(0.0, 0)) + (max(0.0, 0.42)) * ma.tanh(voice_0_graph_source_left_labium_left_labium_load_pressure); + voice_0_graph_source_left_labium_left_labium_pressure_drive = max(0.0, voice_0_graph_source_left_labium_left_labium_reservoir_pressure - voice_0_graph_source_left_labium_left_labium_downstream_pressure); + voice_0_graph_source_left_labium_left_labium_stiffness = max(0.00002, (max(0.0, 0.028)) * (0.55 + 1.10 * (clip01(patch_param_4)))); + voice_0_graph_source_left_labium_left_labium_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_left_labium_left_labium_stiffness) / (max(0.02, 0.3))))); + voice_0_graph_source_left_labium_left_labium_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_left_labium_left_labium_load_pressure * (max(0.0, 0.42))); + voice_0_graph_source_left_labium_left_labium_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.14)) + 0.080 * voice_0_graph_source_left_labium_left_labium_tissue_loss + 0.18 * clip01(max(0.0, patch_param_2)); + voice_0_graph_source_left_labium_left_labium_oscillation_gate = clip01((voice_0_graph_source_left_labium_left_labium_pressure_drive - voice_0_graph_source_left_labium_left_labium_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.14))))); + voice_0_graph_source_left_labium_left_labium_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_0)) * (1.0 - 0.45 * (max(0.0, 0.14)) - 0.35 * voice_0_graph_source_left_labium_left_labium_tissue_loss) + 0.35 * (clip01(patch_param_4))); + voice_0_graph_source_left_labium_left_labium_modal_seed = (no.noise * 0.018 + voice_0_graph_source_left_labium_left_labium_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_2))) * 0.16); + voice_0_graph_source_left_labium_left_labium_modal_ring = voice_0_graph_source_left_labium_left_labium_modal_seed : fi.resonbp(voice_0_graph_source_left_labium_left_labium_modal_frequency, voice_0_graph_source_left_labium_left_labium_modal_q, 1); + voice_0_graph_source_left_labium_left_labium_modal_oscillator = os.osc(voice_0_graph_source_left_labium_left_labium_modal_frequency * voice_0_graph_source_left_labium_left_labium_load_detune) * voice_0_graph_source_left_labium_left_labium_oscillation_gate; + voice_0_graph_source_left_labium_left_labium_modal_tissue = (voice_0_graph_source_left_labium_left_labium_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_4))) + voice_0_graph_source_left_labium_left_labium_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.14)) - 0.45 * voice_0_graph_source_left_labium_left_labium_tissue_loss); + voice_0_graph_source_left_labium_left_labium_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, 0.14)) + 0.055 * voice_0_graph_source_left_labium_left_labium_tissue_loss) / (max(0.02, 0.3))))); + voice_0_graph_source_left_labium_left_labium_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.3)))); + voice_0_graph_source_left_labium_left_labium_force = (voice_0_graph_source_left_labium_left_labium_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_2)))) - (max(0.0, 0.42)) * voice_0_graph_source_left_labium_left_labium_load_pressure * 0.001) / (max(0.02, 0.3)); + voice_0_graph_source_left_labium_left_labium_velocity = voice_0_graph_source_left_labium_left_labium_force : + ~ *(voice_0_graph_source_left_labium_left_labium_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_left_labium_left_labium_stiffness + 0.4 * (max(0.0, 0.88)))); + voice_0_graph_source_left_labium_left_labium_displacement = voice_0_graph_source_left_labium_left_labium_velocity : + ~ *(voice_0_graph_source_left_labium_left_labium_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_left_labium_left_labium_stiffness)); + voice_0_graph_source_left_labium_left_labium_aperture_linear = max(0.0, (max(0.0, 0.024)) + (max(0.0, patch_param_2)) + voice_0_graph_source_left_labium_left_labium_displacement - (max(0.0, 0.88)) * pow(voice_0_graph_source_left_labium_left_labium_displacement, 3.0)); + voice_0_graph_source_left_labium_left_labium_aperture = voice_0_graph_source_left_labium_left_labium_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_left_labium_left_labium_aperture_shape) + pow(voice_0_graph_source_left_labium_left_labium_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_left_labium_left_labium_aperture_shape); + voice_0_graph_source_left_labium_left_labium_flow_resistance = 1.0 + voice_0_graph_source_left_labium_left_labium_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_left_labium_left_labium_aperture + (max(0.0, 0.024)))); + voice_0_graph_source_left_labium_left_labium_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_left_labium_left_labium_aperture)); + voice_0_graph_source_left_labium_left_labium_voicing = voice_0_graph_source_left_labium_left_labium_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_4))); + voice_0_graph_source_left_labium_left_labium_flow = ma.tanh(((voice_0_graph_source_left_labium_left_labium_pressure_drive * voice_0_graph_source_left_labium_left_labium_aperture * (1.5 + 3.5 * voice_0_graph_source_left_labium_left_labium_flow_scale)) + (voice_0_graph_source_left_labium_left_labium_voicing * voice_0_graph_source_left_labium_left_labium_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_4))))) / voice_0_graph_source_left_labium_left_labium_flow_resistance); + voice_0_graph_source_left_labium_left_labium_noise = voice_0_graph_source_left_labium_left_labium_turbulence * (clip01(0.018)) * voice_0_graph_source_left_labium_left_labium_pressure_drive * clip01(voice_0_graph_source_left_labium_left_labium_aperture) * (1.0 - 0.55 * (clip01(patch_param_4))) / voice_0_graph_source_left_labium_left_labium_flow_resistance; + voice_0_graph_source_left_labium_left_labium_out = (voice_0_graph_source_left_labium_left_labium_flow * voice_0_graph_source_left_labium_left_labium_flow_scale * (0.55 + 2.6 * voice_0_graph_source_left_labium_left_labium_pressure_drive) + voice_0_graph_source_left_labium_left_labium_noise) * ((1) * (1.0)); + voice_0_graph_node_incident_pressure_left_labium = (voice_0_graph_in_0_start) / 1; + voice_0_graph_node_source_left_labium = voice_0_graph_source_left_labium_left_labium_out; + voice_0_graph_node_incident_pressure_left_merge = (voice_0_graph_in_0_end) / 1; + voice_0_graph_node_source_left_merge = 0.0; + voice_0_graph_source_right_labium_right_labium_load_pressure = voice_0_graph_node_incident_pressure_right_labium; + voice_0_graph_source_right_labium_right_labium_stiffness_hint = max(0.00002, min(0.16, pow(2.0 * ma.PI * max(20.0, ((max(20, 920 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 5.2) * 0.008))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) / ma.SR, 2.0))); + voice_0_graph_source_right_labium_right_labium_flow_scale = max(0.0, 1.08); + voice_0_graph_source_right_labium_right_labium_tissue_loss = clip01(0.2); + voice_0_graph_source_right_labium_right_labium_aperture_shape = clip01(0.4); + voice_0_graph_source_right_labium_right_labium_flow_loss = max(0.0, 0.35); + voice_0_graph_source_right_labium_right_labium_reservoir_pressure = (clip01(patch_param_1)) * (max(0.0, 1)); + voice_0_graph_source_right_labium_right_labium_downstream_pressure = (max(0.0, 0)) + (max(0.0, 0.42)) * ma.tanh(voice_0_graph_source_right_labium_right_labium_load_pressure); + voice_0_graph_source_right_labium_right_labium_pressure_drive = max(0.0, voice_0_graph_source_right_labium_right_labium_reservoir_pressure - voice_0_graph_source_right_labium_right_labium_downstream_pressure); + voice_0_graph_source_right_labium_right_labium_stiffness = max(0.00002, (max(0.0, 0.032)) * (0.55 + 1.10 * (clip01(patch_param_5)))); + voice_0_graph_source_right_labium_right_labium_modal_frequency = max(45.0, min(10000.0, (ma.SR / (2.0 * ma.PI)) * sqrt(max(0.00002, voice_0_graph_source_right_labium_right_labium_stiffness) / (max(0.02, 0.32))))); + voice_0_graph_source_right_labium_right_labium_load_detune = 1.0 - 0.035 * ma.tanh(voice_0_graph_source_right_labium_right_labium_load_pressure * (max(0.0, 0.42))); + voice_0_graph_source_right_labium_right_labium_oscillation_threshold = 0.030 + 0.070 * (max(0.0, 0.16)) + 0.080 * voice_0_graph_source_right_labium_right_labium_tissue_loss + 0.18 * clip01(max(0.0, patch_param_3)); + voice_0_graph_source_right_labium_right_labium_oscillation_gate = clip01((voice_0_graph_source_right_labium_right_labium_pressure_drive - voice_0_graph_source_right_labium_right_labium_oscillation_threshold) * (3.0 + 1.6 * max(0.0, 1.0 - (max(0.0, 0.16))))); + voice_0_graph_source_right_labium_right_labium_modal_q = 3.0 + 22.0 * clip01((clip01(patch_param_1)) * (1.0 - 0.45 * (max(0.0, 0.16)) - 0.35 * voice_0_graph_source_right_labium_right_labium_tissue_loss) + 0.35 * (clip01(patch_param_5))); + voice_0_graph_source_right_labium_right_labium_modal_seed = (no.noise * 0.018 + voice_0_graph_source_right_labium_right_labium_pressure_drive * max(0.0, 0.22 - clip01(max(0.0, patch_param_3))) * 0.16); + voice_0_graph_source_right_labium_right_labium_modal_ring = voice_0_graph_source_right_labium_right_labium_modal_seed : fi.resonbp(voice_0_graph_source_right_labium_right_labium_modal_frequency, voice_0_graph_source_right_labium_right_labium_modal_q, 1); + voice_0_graph_source_right_labium_right_labium_modal_oscillator = os.osc(voice_0_graph_source_right_labium_right_labium_modal_frequency * voice_0_graph_source_right_labium_right_labium_load_detune) * voice_0_graph_source_right_labium_right_labium_oscillation_gate; + voice_0_graph_source_right_labium_right_labium_modal_tissue = (voice_0_graph_source_right_labium_right_labium_modal_oscillator * (0.70 + 0.80 * (clip01(patch_param_5))) + voice_0_graph_source_right_labium_right_labium_modal_ring * 0.35) * max(0.0, 1.0 - 0.35 * (max(0.0, 0.16)) - 0.45 * voice_0_graph_source_right_labium_right_labium_tissue_loss); + voice_0_graph_source_right_labium_right_labium_velocity_decay = min(0.9995, max(0.20, 1.0 - ((0.008 + 0.08 * (max(0.0, 0.16)) + 0.055 * voice_0_graph_source_right_labium_right_labium_tissue_loss) / (max(0.02, 0.32))))); + voice_0_graph_source_right_labium_right_labium_displacement_decay = min(0.9998, max(0.20, 1.0 - 0.0008 / (max(0.02, 0.32)))); + voice_0_graph_source_right_labium_right_labium_force = (voice_0_graph_source_right_labium_right_labium_pressure_drive * (0.0004 + 0.0024 * (1.0 - clip01(max(0.0, patch_param_3)))) - (max(0.0, 0.42)) * voice_0_graph_source_right_labium_right_labium_load_pressure * 0.001) / (max(0.02, 0.32)); + voice_0_graph_source_right_labium_right_labium_velocity = voice_0_graph_source_right_labium_right_labium_force : + ~ *(voice_0_graph_source_right_labium_right_labium_velocity_decay / (1.0 + 10.0 * voice_0_graph_source_right_labium_right_labium_stiffness + 0.4 * (max(0.0, 0.88)))); + voice_0_graph_source_right_labium_right_labium_displacement = voice_0_graph_source_right_labium_right_labium_velocity : + ~ *(voice_0_graph_source_right_labium_right_labium_displacement_decay / (1.0 + 1.5 * voice_0_graph_source_right_labium_right_labium_stiffness)); + voice_0_graph_source_right_labium_right_labium_aperture_linear = max(0.0, (max(0.0, 0.024)) + (max(0.0, patch_param_3)) + voice_0_graph_source_right_labium_right_labium_displacement - (max(0.0, 0.88)) * pow(voice_0_graph_source_right_labium_right_labium_displacement, 3.0)); + voice_0_graph_source_right_labium_right_labium_aperture = voice_0_graph_source_right_labium_right_labium_aperture_linear * (1.0 - 0.55 * voice_0_graph_source_right_labium_right_labium_aperture_shape) + pow(voice_0_graph_source_right_labium_right_labium_aperture_linear, 2.0) * (0.55 * voice_0_graph_source_right_labium_right_labium_aperture_shape); + voice_0_graph_source_right_labium_right_labium_flow_resistance = 1.0 + voice_0_graph_source_right_labium_right_labium_flow_loss * (0.35 + 1.8 / max(0.035, voice_0_graph_source_right_labium_right_labium_aperture + (max(0.0, 0.024)))); + voice_0_graph_source_right_labium_right_labium_turbulence = no.noise : fi.highpass(2, 1200.0 + 2800.0 * clip01(1.0 - voice_0_graph_source_right_labium_right_labium_aperture)); + voice_0_graph_source_right_labium_right_labium_voicing = voice_0_graph_source_right_labium_right_labium_modal_tissue * (0.18 + 1.45 * (clip01(patch_param_5))); + voice_0_graph_source_right_labium_right_labium_flow = ma.tanh(((voice_0_graph_source_right_labium_right_labium_pressure_drive * voice_0_graph_source_right_labium_right_labium_aperture * (1.5 + 3.5 * voice_0_graph_source_right_labium_right_labium_flow_scale)) + (voice_0_graph_source_right_labium_right_labium_voicing * voice_0_graph_source_right_labium_right_labium_pressure_drive * (0.45 + 1.55 * (clip01(patch_param_5))))) / voice_0_graph_source_right_labium_right_labium_flow_resistance); + voice_0_graph_source_right_labium_right_labium_noise = voice_0_graph_source_right_labium_right_labium_turbulence * (clip01(0.016)) * voice_0_graph_source_right_labium_right_labium_pressure_drive * clip01(voice_0_graph_source_right_labium_right_labium_aperture) * (1.0 - 0.55 * (clip01(patch_param_5))) / voice_0_graph_source_right_labium_right_labium_flow_resistance; + voice_0_graph_source_right_labium_right_labium_out = (voice_0_graph_source_right_labium_right_labium_flow * voice_0_graph_source_right_labium_right_labium_flow_scale * (0.55 + 2.6 * voice_0_graph_source_right_labium_right_labium_pressure_drive) + voice_0_graph_source_right_labium_right_labium_noise) * ((0.94) * (1.0)); + voice_0_graph_node_incident_pressure_right_labium = (voice_0_graph_in_1_start) / 1; + voice_0_graph_node_source_right_labium = voice_0_graph_source_right_labium_right_labium_out; + voice_0_graph_node_incident_pressure_right_merge = (voice_0_graph_in_1_end) / 1; + voice_0_graph_node_source_right_merge = 0.0; + voice_0_graph_node_incident_pressure_trachea_base = (voice_0_graph_in_2_start) / 1; + voice_0_graph_node_source_trachea_base = 0.0; + voice_0_graph_node_incident_pressure_beak = (voice_0_graph_in_2_end) / 1; + voice_0_graph_node_source_beak = 0.0; + voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end = (2.0 * (voice_0_graph_segment_area_0) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_left_merge_0_end = voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end * voice_0_graph_in_0_end + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_left_merge_0_end) * (voice_0_graph_in_1_end + voice_0_graph_in_2_start); + voice_0_graph_out_0_end = ((voice_0_graph_connection_scattered_syrinx_merge_left_merge_0_end) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_0_end * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_left_merge) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end = (2.0 * (voice_0_graph_segment_area_1) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_right_merge_1_end = voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end * voice_0_graph_in_1_end + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_right_merge_1_end) * (voice_0_graph_in_0_end + voice_0_graph_in_2_start); + voice_0_graph_out_1_end = ((voice_0_graph_connection_scattered_syrinx_merge_right_merge_1_end) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_1_end * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_right_merge) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start = (2.0 * (voice_0_graph_segment_area_2) - (voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2)) / max(0.000001, voice_0_graph_segment_area_0 + voice_0_graph_segment_area_1 + voice_0_graph_segment_area_2); + voice_0_graph_connection_scattered_syrinx_merge_trachea_base_2_start = voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start * voice_0_graph_in_2_start + (1.0 + voice_0_graph_connection_reflection_syrinx_merge_trachea_base_2_start) * (voice_0_graph_in_0_end + voice_0_graph_in_1_end); + voice_0_graph_out_2_start = ((voice_0_graph_connection_scattered_syrinx_merge_trachea_base_2_start) * (voice_0_graph_connection_coupling_syrinx_merge) + voice_0_graph_in_2_start * (1.0 - (voice_0_graph_connection_coupling_syrinx_merge)) + (voice_0_graph_node_source_trachea_base) / 1) * voice_0_graph_connection_loss_syrinx_merge; + voice_0_graph_connection_energy_in_syrinx_merge = (voice_0_graph_segment_area_0) * pow(voice_0_graph_in_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_in_1_end, 2.0) + (voice_0_graph_segment_area_2) * pow(voice_0_graph_in_2_start, 2.0); + voice_0_graph_connection_energy_out_syrinx_merge = (voice_0_graph_segment_area_0) * pow(voice_0_graph_out_0_end, 2.0) + (voice_0_graph_segment_area_1) * pow(voice_0_graph_out_1_end, 2.0) + (voice_0_graph_segment_area_2) * pow(voice_0_graph_out_2_start, 2.0); + voice_0_graph_out_0_start = voice_0_graph_in_0_start * voice_0_graph_node_reflection_left_labium + (voice_0_graph_node_source_left_labium) / 1; + voice_0_graph_out_1_start = voice_0_graph_in_1_start * voice_0_graph_node_reflection_right_labium + (voice_0_graph_node_source_right_labium) / 1; + voice_0_graph_radiation_boundary_load_beak = clip01((voice_0_graph_radiation_admittance_beak) * (voice_0_graph_radiation_differentiation_beak) * (clip01(0.98))); + voice_0_graph_radiation_reflected_raw_beak = (voice_0_graph_in_2_end) * (voice_0_graph_terminal_reflection_beak) + (voice_0_graph_node_source_beak); + voice_0_graph_radiation_reflected_loaded_beak = (voice_0_graph_radiation_reflected_raw_beak) * (1.0 - (voice_0_graph_radiation_boundary_load_beak)) + ((voice_0_graph_radiation_reflected_raw_beak) : fi.lowpass(1, voice_0_graph_radiation_highpass_beak)) * (voice_0_graph_radiation_boundary_load_beak); + voice_0_graph_out_2_end = voice_0_graph_radiation_reflected_loaded_beak; + voice_0_graph_radiation_model_beak = 2; + voice_0_graph_radiation_reference_area_beak = max(0.10, 1.10 * 1.10 * (0.25 + 0.75 * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0)))); + voice_0_graph_radiation_differentiation_beak = (0.50 + 0.22 * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))); + voice_0_graph_radiation_highpass_beak = (180.0 + 220.0 * clip01(pow(clip01((max(0.0, patch_param_6)) / 1.5), 2.0))); + voice_0_graph_radiation_admittance_beak = sqrt(clip01((voice_0_graph_terminal_area_beak) / max(0.000001, (voice_0_graph_terminal_area_beak) + (voice_0_graph_radiation_reference_area_beak)))); + voice_0_graph_radiation_flow_beak = ((voice_0_graph_in_2_end - voice_0_graph_out_2_end)); + voice_0_graph_delay_0 = max(0.000001, 0.00011079 * ma.SR); + voice_0_graph_segment_loss_0 = clip01((0.999) * (sqrt(clip01((voice_0_graph_segment_area_0) / max(0.000001, (voice_0_graph_segment_area_0) + 0.02))))); + voice_0_graph_next_r0 = voice_0_graph_out_0_start : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_next_l0 = voice_0_graph_out_0_end : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_0))) * voice_0_graph_segment_loss_0; + voice_0_graph_delay_1 = max(0.000001, 0.00010496 * ma.SR); + voice_0_graph_segment_loss_1 = clip01((0.999) * (sqrt(clip01((voice_0_graph_segment_area_1) / max(0.000001, (voice_0_graph_segment_area_1) + 0.02))))); + voice_0_graph_next_r1 = voice_0_graph_out_1_start : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_next_l1 = voice_0_graph_out_1_end : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_1))) * voice_0_graph_segment_loss_1; + voice_0_graph_delay_2 = max(0.000001, 0.0002449 * ma.SR); + voice_0_graph_segment_loss_2 = clip01((0.999) * (sqrt(clip01((voice_0_graph_segment_area_2) / max(0.000001, (voice_0_graph_segment_area_2) + 0.02))))); + voice_0_graph_next_r2 = voice_0_graph_out_2_start : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_next_l2 = voice_0_graph_out_2_end : de.fdelay(2048, min(2047, max(0.000001, voice_0_graph_delay_2))) * voice_0_graph_segment_loss_2; + voice_0_graph_out = (((voice_0_graph_radiation_flow_beak * (1.0 - (voice_0_graph_radiation_differentiation_beak)) + (voice_0_graph_radiation_flow_beak : fi.highpass(1, voice_0_graph_radiation_highpass_beak)) * (voice_0_graph_radiation_differentiation_beak)) * clip01(0.98) * voice_0_graph_radiation_admittance_beak)) * voice_0_graph_radiation_gain; + }; +}; +voice_0_acoustic_graph_radiated = voice_0_graph(voice_0_graph_drive); +voice_0_freq = ((max(20, 920 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 5.2) * 0.008))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = voice_0_acoustic_graph_radiated; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)) : fi.resonbp(max(20.0, clip01(0.36) * 18000.0), max(0.1, 1.5), 1.0); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.12, 0.92) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.3); + +process = softclip((voice_0) * 0.46); diff --git a/tools/aqua-playground/lowered/bfxr-coin-spark.dsp b/tools/aqua-playground/lowered/bfxr-coin-spark.dsp new file mode 100644 index 0000000..cc4ec46 --- /dev/null +++ b/tools/aqua-playground/lowered/bfxr-coin-spark.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "bfxr-coin-spark"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 1180 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 1180 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 1180 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 5))) * (max(0.0, 3.2 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.16, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.05 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.05 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.42, 0.022) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.18); + +voice_1_age = age; +voice_1_freq = ((max(20, 1770 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 1770 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 1770 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 7))) * (max(0.0, 1.7 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.11, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.05 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.05 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.42, 0.022) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.09); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/bfxr-portal-chirp.dsp b/tools/aqua-playground/lowered/bfxr-portal-chirp.dsp new file mode 100644 index 0000000..ef6741c --- /dev/null +++ b/tools/aqua-playground/lowered/bfxr-portal-chirp.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "bfxr-portal-chirp"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0 + 0.018 * lfo_sin(9, 0); +patch_mod_duty = 0 + 0.06 * lfo_sin(9, 0); +patch_mod_lpf = 0 + 0.08 * lfo_sin(9, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 320 * pow(2.0, 0.85 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 320 * pow(2.0, 0.85 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 1.0; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0.08 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0.08 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.08 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.72 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.08 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.08 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.28, 0.09) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.14); + +voice_1_age = age; +voice_1_freq = ((max(20, 640 * pow(2.0, 0.85 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = select2(wrap01(os.phasor(1.0, ((max(20, 640 * pow(2.0, 0.85 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.44 + 0 * voice_1_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.16 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0.08 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0.08 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.08 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.72 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.08 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.08 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.28, 0.09) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.05); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/bfxr-shield-pop.dsp b/tools/aqua-playground/lowered/bfxr-shield-pop.dsp new file mode 100644 index 0000000..ef7c445 --- /dev/null +++ b/tools/aqua-playground/lowered/bfxr-shield-pop.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "bfxr-shield-pop"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 260 * pow(2.0, -0.75 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 7.2) * 0.04))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 260 * pow(2.0, -0.75 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 7.2) * 0.04))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.68 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.7575758, 0.36, 0.04) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.264); + +voice_1_age = age; +voice_1_freq = ((max(20, 900 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = no.noise; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0.7 + patch_mod_noise + 0.0)) + no.noise * clip01(0.7 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.68 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.4 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.4 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 0.7575758, 0.16, 0.018) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.05); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/bfxr-ui-bloom.dsp b/tools/aqua-playground/lowered/bfxr-ui-bloom.dsp new file mode 100644 index 0000000..2e48f40 --- /dev/null +++ b/tools/aqua-playground/lowered/bfxr-ui-bloom.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "bfxr-ui-bloom"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time - floor(time / 0.18) * 0.18; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 392 * pow(2.0, 0.18 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.08, 1.25, 1.0) * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 392 * pow(2.0, 0.18 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.08, 1.25, 1.0) * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.06 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.06 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.78 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.8196721, 0.5, 0.05) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.1464); + +voice_1_age = age; +voice_1_freq = ((max(20, 588 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 588 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.06 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.06 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.78 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.004, 0, 0.8196721, 0.38, 0.04) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.06); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/catalog.json b/tools/aqua-playground/lowered/catalog.json new file mode 100644 index 0000000..d3e3440 --- /dev/null +++ b/tools/aqua-playground/lowered/catalog.json @@ -0,0 +1,300 @@ +[ + { + "name": "thruster", + "origin": "thruster/thruster.dsp", + "kind": "faust", + "dsp": "thruster.dsp", + "warnings": [] + }, + { + "name": "808-clap", + "origin": "808/clap.aqua", + "kind": "aqua", + "dsp": "808-clap.dsp", + "warnings": [] + }, + { + "name": "808-cowbell", + "origin": "808/cowbell.aqua", + "kind": "aqua", + "dsp": "808-cowbell.dsp", + "warnings": [] + }, + { + "name": "808-hat", + "origin": "808/hat.aqua", + "kind": "aqua", + "dsp": "808-hat.dsp", + "warnings": [] + }, + { + "name": "808-kick", + "origin": "808/kick.aqua", + "kind": "aqua", + "dsp": "808-kick.dsp", + "warnings": [] + }, + { + "name": "808-snare", + "origin": "808/snare.aqua", + "kind": "aqua", + "dsp": "808-snare.dsp", + "warnings": [] + }, + { + "name": "808-tom", + "origin": "808/tom.aqua", + "kind": "aqua", + "dsp": "808-tom.dsp", + "warnings": [] + }, + { + "name": "advanced-alien-multivalve-graph", + "origin": "advanced/alien-multivalve-graph.aqua", + "kind": "aqua", + "dsp": "advanced-alien-multivalve-graph.dsp", + "warnings": [] + }, + { + "name": "advanced-aurora-pad", + "origin": "advanced/aurora-pad.aqua", + "kind": "aqua", + "dsp": "advanced-aurora-pad.dsp", + "warnings": [] + }, + { + "name": "advanced-bird-syrinx", + "origin": "advanced/bird-syrinx.aqua", + "kind": "aqua", + "dsp": "advanced-bird-syrinx.dsp", + "warnings": [] + }, + { + "name": "advanced-bird-syrinx-graph", + "origin": "advanced/bird-syrinx-graph.aqua", + "kind": "aqua", + "dsp": "advanced-bird-syrinx-graph.dsp", + "warnings": [] + }, + { + "name": "advanced-glass-creature", + "origin": "advanced/glass-creature.aqua", + "kind": "aqua", + "dsp": "advanced-glass-creature.dsp", + "warnings": [] + }, + { + "name": "advanced-human-larynx-graph", + "origin": "advanced/human-larynx-graph.aqua", + "kind": "aqua", + "dsp": "advanced-human-larynx-graph.dsp", + "warnings": [] + }, + { + "name": "advanced-machine-breath", + "origin": "advanced/machine-breath.aqua", + "kind": "aqua", + "dsp": "advanced-machine-breath.dsp", + "warnings": [] + }, + { + "name": "advanced-ritual-sequence", + "origin": "advanced/ritual-sequence.aqua", + "kind": "aqua", + "dsp": "advanced-ritual-sequence.dsp", + "warnings": [] + }, + { + "name": "advanced-subtractive-drums", + "origin": "advanced/subtractive-drums.aqua", + "kind": "aqua", + "dsp": "advanced-subtractive-drums.dsp", + "warnings": [ + "voice_0: low-pass resonance is approximated with Faust resonlp" + ] + }, + { + "name": "advanced-syrinx-voice", + "origin": "advanced/syrinx-voice.aqua", + "kind": "aqua", + "dsp": "advanced-syrinx-voice.dsp", + "warnings": [] + }, + { + "name": "bfxr-coin-spark", + "origin": "bfxr/coin-spark.aqua", + "kind": "aqua", + "dsp": "bfxr-coin-spark.dsp", + "warnings": [] + }, + { + "name": "bfxr-portal-chirp", + "origin": "bfxr/portal-chirp.aqua", + "kind": "aqua", + "dsp": "bfxr-portal-chirp.dsp", + "warnings": [] + }, + { + "name": "bfxr-shield-pop", + "origin": "bfxr/shield-pop.aqua", + "kind": "aqua", + "dsp": "bfxr-shield-pop.dsp", + "warnings": [] + }, + { + "name": "bfxr-ui-bloom", + "origin": "bfxr/ui-bloom.aqua", + "kind": "aqua", + "dsp": "bfxr-ui-bloom.dsp", + "warnings": [] + }, + { + "name": "dx7-algorithm-32-additive-organ", + "origin": "dx7/algorithm-32-additive-organ.aqua", + "kind": "aqua", + "dsp": "dx7-algorithm-32-additive-organ.dsp", + "warnings": [] + }, + { + "name": "dx7-algorithm-8-bright-pair", + "origin": "dx7/algorithm-8-bright-pair.aqua", + "kind": "aqua", + "dsp": "dx7-algorithm-8-bright-pair.dsp", + "warnings": [] + }, + { + "name": "dx7-public-domain-mc-mm-5-3", + "origin": "dx7/public-domain-mc-mm-5-3.aqua", + "kind": "aqua", + "dsp": "dx7-public-domain-mc-mm-5-3.dsp", + "warnings": [] + }, + { + "name": "dx7-public-domain-prc-synth1-calibrated", + "origin": "dx7/public-domain/prc-synth1-calibrated.aqua", + "kind": "aqua", + "dsp": "dx7-public-domain-prc-synth1-calibrated.dsp", + "warnings": [] + }, + { + "name": "examples-language-tour", + "origin": "examples/language-tour.aqua", + "kind": "aqua", + "dsp": "examples-language-tour.dsp", + "warnings": [ + "voice_2: low-pass resonance is approximated with Faust resonlp" + ] + }, + { + "name": "fm-bell-bell", + "origin": "fm-bell/bell.aqua", + "kind": "aqua", + "dsp": "fm-bell-bell.dsp", + "warnings": [] + }, + { + "name": "fm-bell-chime", + "origin": "fm-bell/chime.aqua", + "kind": "aqua", + "dsp": "fm-bell-chime.dsp", + "warnings": [] + }, + { + "name": "fm-bell-coin", + "origin": "fm-bell/coin.aqua", + "kind": "aqua", + "dsp": "fm-bell-coin.dsp", + "warnings": [] + }, + { + "name": "fm-bell-gong", + "origin": "fm-bell/gong.aqua", + "kind": "aqua", + "dsp": "fm-bell-gong.dsp", + "warnings": [] + }, + { + "name": "sfxr-blip", + "origin": "sfxr/blip.aqua", + "kind": "aqua", + "dsp": "sfxr-blip.dsp", + "warnings": [] + }, + { + "name": "sfxr-classic-classic-sfxr-abstract-golf", + "origin": "sfxr/classic/classic-sfxr-abstract-golf.aqua", + "kind": "aqua", + "dsp": "sfxr-classic-classic-sfxr-abstract-golf.dsp", + "warnings": [] + }, + { + "name": "sfxr-explosion", + "origin": "sfxr/explosion.aqua", + "kind": "aqua", + "dsp": "sfxr-explosion.dsp", + "warnings": [] + }, + { + "name": "sfxr-hit", + "origin": "sfxr/hit.aqua", + "kind": "aqua", + "dsp": "sfxr-hit.dsp", + "warnings": [] + }, + { + "name": "sfxr-jump", + "origin": "sfxr/jump.aqua", + "kind": "aqua", + "dsp": "sfxr-jump.dsp", + "warnings": [] + }, + { + "name": "sfxr-laser", + "origin": "sfxr/laser.aqua", + "kind": "aqua", + "dsp": "sfxr-laser.dsp", + "warnings": [] + }, + { + "name": "sfxr-pickup", + "origin": "sfxr/pickup.aqua", + "kind": "aqua", + "dsp": "sfxr-pickup.dsp", + "warnings": [] + }, + { + "name": "sfxr-powerup", + "origin": "sfxr/powerup.aqua", + "kind": "aqua", + "dsp": "sfxr-powerup.dsp", + "warnings": [] + }, + { + "name": "wobble-bass-growl", + "origin": "wobble-bass/growl.aqua", + "kind": "aqua", + "dsp": "wobble-bass-growl.dsp", + "warnings": [] + }, + { + "name": "wobble-bass-neuro", + "origin": "wobble-bass/neuro.aqua", + "kind": "aqua", + "dsp": "wobble-bass-neuro.dsp", + "warnings": [] + }, + { + "name": "wobble-bass-talker", + "origin": "wobble-bass/talker.aqua", + "kind": "aqua", + "dsp": "wobble-bass-talker.dsp", + "warnings": [] + }, + { + "name": "wobble-bass-yoy", + "origin": "wobble-bass/yoy.aqua", + "kind": "aqua", + "dsp": "wobble-bass-yoy.dsp", + "warnings": [] + } +] \ No newline at end of file diff --git a/tools/aqua-playground/lowered/dx7-algorithm-32-additive-organ.dsp b/tools/aqua-playground/lowered/dx7-algorithm-32-additive-organ.dsp new file mode 100644 index 0000000..f617a62 --- /dev/null +++ b/tools/aqua-playground/lowered/dx7-algorithm-32-additive-organ.dsp @@ -0,0 +1,112 @@ +import("stdfaust.lib"); +declare name "dx7-algorithm-32-additive-organ"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0 = hslider("/macro/drawbar", 0.78, 0, 1, 0.001) : si.smoo; +patch_param_1 = hslider("/macro/shimmer", 0.08, 0, 0.3, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.96 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.015 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.015 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.002, 0, 1, 0.32, 0.48) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.14); + +voice_1_age = age; +voice_1_freq = ((max(20, 392 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 392 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.96 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.015 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.015 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.002, 0, 1, 0.32, 0.48) * max(0.0, 1.0 + patch_mod_gain + 0.0) * patch_param_0); + +voice_2_age = age; +voice_2_freq = ((max(20, 588 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 588 * pow(2.0, 0 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_2_colored = (voice_2_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(0.96 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.015 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.015 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered; +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0.002, 0, 1, 0.32, 0.48) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +voice_3_age = age; +voice_3_freq = ((max(20, 784 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 784 * pow(2.0, 0 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_3_colored = (voice_3_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(0.96 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.015 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.015 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = voice_3_phased; +voice_3 = ((voice_3_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0.002, 0, 1, 0.32, 0.48) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +voice_4_age = age; +voice_4_freq = ((max(20, 980 * pow(2.0, 0 * voice_4_age + 0.5 * 0 * voice_4_age * voice_4_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_4_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 980 * pow(2.0, 0 * voice_4_age + 0.5 * 0 * voice_4_age * voice_4_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_4_colored = (voice_4_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_4_driven = ma.tanh(voice_4_colored * (1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0); +voice_4_folded = voice_4_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_4_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_4_filtered = voice_4_folded : fi.lowpass(1, max(20.0, clip01(0.96 * (1.0 + 0 * voice_4_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.015 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.015 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_4_phased = voice_4_filtered; +voice_4_formants = voice_4_phased; +voice_4 = ((voice_4_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_4_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_4_age, 0.002, 0, 1, 0.32, 0.48) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.055); + +voice_5_age = age; +voice_5_freq = ((max(20, 1176 * pow(2.0, 0 * voice_5_age + 0.5 * 0 * voice_5_age * voice_5_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_5_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 1176 * pow(2.0, 0 * voice_5_age + 0.5 * 0 * voice_5_age * voice_5_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 1176 * pow(2.0, 0 * voice_5_age + 0.5 * 0 * voice_5_age * voice_5_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1))) * (max(0.0, 0.18 + patch_mod_fm_index + 0.0) * exp(-voice_5_age / max(0.24, 0.0001))) / ma.PI)); +voice_5_colored = (voice_5_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_5_driven = ma.tanh(voice_5_colored * (1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.03 + patch_mod_drive + 0.0) * 12.0); +voice_5_folded = voice_5_driven * (1.0 - clip01(patch_param_1 + patch_mod_fold + 0.0)) + fold(voice_5_driven * (1.0 + clip01(patch_param_1 + patch_mod_fold + 0.0) * 3.5)) * clip01(patch_param_1 + patch_mod_fold + 0.0); +voice_5_filtered = voice_5_folded : fi.lowpass(1, max(20.0, clip01(0.96 * (1.0 + 0 * voice_5_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.015 * (1.0 + 0 * voice_5_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.015 * (1.0 + 0 * voice_5_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_5_phased = voice_5_filtered; +voice_5_formants = voice_5_phased; +voice_5 = ((voice_5_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_5_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_5_age, 0.002, 0, 1, 0.32, 0.48) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.035); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3 + voice_4 + voice_5) * 0.58); diff --git a/tools/aqua-playground/lowered/dx7-algorithm-8-bright-pair.dsp b/tools/aqua-playground/lowered/dx7-algorithm-8-bright-pair.dsp new file mode 100644 index 0000000..12295f4 --- /dev/null +++ b/tools/aqua-playground/lowered/dx7-algorithm-8-bright-pair.dsp @@ -0,0 +1,77 @@ +import("stdfaust.lib"); +declare name "dx7-algorithm-8-bright-pair"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0 = hslider("/macro/brightness", 2.6, 0, 5, 0.001) : si.smoo; +patch_param_1 = hslider("/macro/strike", 0.18, 0.02, 0.6, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 330 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 330 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 330 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2))) * (max(0.0, patch_param_0 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.22, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.9 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.001, 0, 1, patch_param_1, 0.045) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.04); + +voice_1_age = age; +voice_1_freq = ((max(20, 660 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 660 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0.05 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0.05 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.05 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.9 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.001, 0, 1, patch_param_1, 0.045) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.025); + +opgraph_0_freq = 330; +opgraph_0_op_6 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 4)) + (0.0) / ma.PI)) * oneshot_adsr_at(age, 0.035, 0.18, 0, 0, 0.215) * 0.9; +opgraph_0_op_4 = ((_ * 0.18 + (0.0)) : \(pm).(sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 2)) + pm / ma.PI)) * oneshot_adsr_at(age, 0.05, 0.24, 0, 0, 0.29) * 0.7)) ~ _; +opgraph_0_op_2 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 1)) + (0.0) / ma.PI)) * oneshot_adsr_at(age, 0.045, 0.2, 0, 0, 0.245) * 0.75; +opgraph_0_op_5 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 3)) + (opgraph_0_op_6 * 1.1) / ma.PI)) * oneshot_adsr_at(age, 0.04, 0.2, 0, 0, 0.24) * 0.82; +opgraph_0_op_1 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 1)) + (opgraph_0_op_2 * 0.85) / ma.PI)) * oneshot_adsr_at(age, 0.005, 0.08, 0.68, 0.34, 0.1) * 0.82; +opgraph_0_op_3 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 2)) + (opgraph_0_op_5 * 0.9 + opgraph_0_op_4 * 0.75) / ma.PI)) * oneshot_adsr_at(age, 0.06, 0.3, 0, 0, 0.36) * 0.6; +opgraph_0 = (opgraph_0_op_1 + opgraph_0_op_3) * 0.18; + +process = softclip((voice_0 + voice_1 + opgraph_0) * 0.52); diff --git a/tools/aqua-playground/lowered/dx7-public-domain-mc-mm-5-3.dsp b/tools/aqua-playground/lowered/dx7-public-domain-mc-mm-5-3.dsp new file mode 100644 index 0000000..efd7671 --- /dev/null +++ b/tools/aqua-playground/lowered/dx7-public-domain-mc-mm-5-3.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "dx7-public-domain-mc-mm-5-3"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 654.0639 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 654.0639 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.004, 0.008, 1, 0.004, 0.08) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 1); + +process = softclip((voice_0) * 0.82); diff --git a/tools/aqua-playground/lowered/dx7-public-domain-prc-synth1-calibrated.dsp b/tools/aqua-playground/lowered/dx7-public-domain-prc-synth1-calibrated.dsp new file mode 100644 index 0000000..f53571d --- /dev/null +++ b/tools/aqua-playground/lowered/dx7-public-domain-prc-synth1-calibrated.dsp @@ -0,0 +1,52 @@ +import("stdfaust.lib"); +declare name "dx7-public-domain-prc-synth1-calibrated"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +opgraph_0_freq = 261.6256; +opgraph_0_op_6 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 7.983435)) + (0.0) / ma.PI)) * rl4_env_at(age, 0.001451, 0.413879, 0, 0.296962, 0.399165, 1, 0.424308, 0.370614, 1, 0.549977, 0, 1, 0.85) * 0.125; +opgraph_0_op_4 = ((_ * 0.19 + (0.0)) : \(pm).(sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 0.501384)) + pm / ma.PI)) * rl4_env_at(age, 0.001451, 0.413879, 0, 0.296962, 0.353601, 1, 0.424308, 0.276106, 1, 0.549977, 0, 1, 0.85) * 0.917004)) ~ _; +opgraph_0_op_2 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 0.501384)) + (0.0) / ma.PI)) * rl4_env_at(age, 0.011383, 0.981531, 0, 0.293515, 0.842813, 1, 0.41932, 0.660018, 1, 0.549977, 0, 1, 0.85) * 0.545254; +opgraph_0_op_5 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 1)) + (opgraph_0_op_6 * 6) / ma.PI)) * rl4_env_at(age, 0.001451, 0.413879, 0, 0.296962, 0.241589, 1, 0.424308, 0.109464, 1, 0.549977, 0, 1, 0.85) * 0.32421; +opgraph_0_op_1 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 0.500346)) + (opgraph_0_op_2 * 6.275) / ma.PI)) * rl4_env_at(age, 0.001451, 0.984375, 0, 0.296962, 1, 1, 0.424308, 1, 1, 0.549977, 0, 1, 0.85) * 3; +opgraph_0_op_3 = sin(2.0 * ma.PI * (os.phasor(1.0, opgraph_0_freq * max(0.0, 0.499655)) + (opgraph_0_op_4 * 6 + opgraph_0_op_5 * 6) / ma.PI)) * rl4_env_at(age, 0.001451, 0.984375, 0, 0.296962, 1, 1, 0.424308, 1, 1, 0.549977, 0, 1, 0.85) * 3; +opgraph_0 = (opgraph_0_op_1 + opgraph_0_op_3) * 0.25; + +process = (opgraph_0) * 1.4; diff --git a/tools/aqua-playground/lowered/examples-language-tour.dsp b/tools/aqua-playground/lowered/examples-language-tour.dsp new file mode 100644 index 0000000..afced2b --- /dev/null +++ b/tools/aqua-playground/lowered/examples-language-tour.dsp @@ -0,0 +1,76 @@ +import("stdfaust.lib"); +declare name "examples-language-tour"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time - floor(time / 0.4739614) * 0.4739614; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.08 * lfo_tri(2, 0); +patch_mod_pitch = 0 + 0.01 * lfo_sin(5, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + -0.04 * lfo_tri(2, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0 + 0.08 * lfo_sin(5, 0) + 0 + 0.12 * lfo_tri(2, 0); +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 220 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 5) * 0.02))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 220 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 5) * 0.02))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = ((voice_0_phased : fi.resonbp(620, 6.888889, 1.0)) * 1 + (voice_0_phased : fi.resonbp(1040, 6.933333, 1.0)) * 0.8) / 1.8; +voice_0 = ((voice_0_phased * (1.0 - clip01(0.45 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0.45 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.002, 0, 1, 0.2, 0.03) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +voice_1_age = age; +voice_1_freq = ((max(20, 440 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 440 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.7 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.18, 0.02) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.04); + +voice_2_age = age; +voice_2_freq = ((max(20, 230.3403 * pow(2.0, 0.7460228 * voice_2_age + 0.5 * 0.00000008 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 230.3403 * pow(2.0, 0.7460228 * voice_2_age + 0.5 * 0.00000008 * voice_2_age * voice_2_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 1.0; +voice_2_colored = (voice_2_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.1212819 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1212819 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.resonlp(max(20.0, clip01(1 * (1.0 + -0.00208181 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0), 0.7 + clip01(0.00000026) * 18.0, 1.0) : fi.highpass(1, max(5.0, (clip01(0.0479493 * (1.0 + -0.0020957 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.0479493 * (1.0 + -0.0020957 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered + (voice_2_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(0.0001425 + -0.0005662 * voice_2_age) * ma.SR)))); +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0.00014083, 0, 0.9929289, 0.07120296, 0.07388992) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.2215667); + +process = softclip((voice_0 + voice_1 + voice_2) * 0.7); diff --git a/tools/aqua-playground/lowered/fm-bell-bell.dsp b/tools/aqua-playground/lowered/fm-bell-bell.dsp new file mode 100644 index 0000000..5642d9c --- /dev/null +++ b/tools/aqua-playground/lowered/fm-bell-bell.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "fm-bell-bell"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 440 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 440 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 440 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 4.1))) * (max(0.0, 5.8 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.55, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.9 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.002, 0, 1, 1.2, 0.04) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.24); + +voice_1_age = age; +voice_1_freq = ((max(20, 880 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 880 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 880 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 4.1))) * (max(0.0, 2.4 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.55, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.9 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.002, 0, 1, 1.2, 0.04) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/fm-bell-chime.dsp b/tools/aqua-playground/lowered/fm-bell-chime.dsp new file mode 100644 index 0000000..2712175 --- /dev/null +++ b/tools/aqua-playground/lowered/fm-bell-chime.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "fm-bell-chime"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 660 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 660 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 660 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3))) * (max(0.0, 4.2 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.38, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.001, 0, 1, 0.9, 0.025) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.18); + +voice_1_age = age; +voice_1_freq = ((max(20, 990 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 990 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 990 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3))) * (max(0.0, 2.1 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.38, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.001, 0, 1, 0.9, 0.025) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.07); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/fm-bell-coin.dsp b/tools/aqua-playground/lowered/fm-bell-coin.dsp new file mode 100644 index 0000000..94bf997 --- /dev/null +++ b/tools/aqua-playground/lowered/fm-bell-coin.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "fm-bell-coin"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 1200 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 1200 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 1200 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 5))) * (max(0.0, 3.4 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.18, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.45, 0.02) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.18); + +voice_1_age = age; +voice_1_freq = ((max(20, 1800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 1800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 1800 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 7))) * (max(0.0, 1.8 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.12, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.08 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.45, 0.02) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.09); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/fm-bell-gong.dsp b/tools/aqua-playground/lowered/fm-bell-gong.dsp new file mode 100644 index 0000000..c082a83 --- /dev/null +++ b/tools/aqua-playground/lowered/fm-bell-gong.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "fm-bell-gong"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 196 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2.414))) * (max(0.0, 7.2 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.9, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.003, 0, 1, 1.6, 0.08) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.24); + +voice_1_age = age; +voice_1_freq = ((max(20, 311 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 311 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 311 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3.73))) * (max(0.0, 4.1 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.7, 0.0001))) / ma.PI)); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.1 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.82 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0.003, 0, 1, 1.6, 0.08) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-blip.dsp b/tools/aqua-playground/lowered/sfxr-blip.dsp new file mode 100644 index 0000000..aa1b3b7 --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-blip.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-blip"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 78.2334 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 78.2334 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.1 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.1 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.01451247, 0.03832199) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-classic-classic-sfxr-abstract-golf.dsp b/tools/aqua-playground/lowered/sfxr-classic-classic-sfxr-abstract-golf.dsp new file mode 100644 index 0000000..5677485 --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-classic-classic-sfxr-abstract-golf.dsp @@ -0,0 +1,120 @@ +import("stdfaust.lib"); +declare name "sfxr-classic-classic-sfxr-abstract-golf"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time - floor(time / 0.11315) * 0.11315; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 148.7934 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.081844, 1.116121, 1.0) * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = select2(wrap01(os.phasor(1.0, ((max(20, 148.7934 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.081844, 1.116121, 1.0) * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.5 + 0 * voice_0_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.201 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.201 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.6896552, 0.1306122, 0.01451247) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.319); + +voice_1_age = age; +voice_1_freq = ((max(20, 229.0554 * pow(2.0, 0.703836 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 229.0554 * pow(2.0, 0.703836 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 1.0; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered + (voice_1_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(0.0001458 + -0.000504 * voice_1_age) * ma.SR)))); +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.07346939, 0.08185941) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +voice_2_age = age; +voice_2_freq = ((max(20, 20 * pow(2.0, 0.0320625 * voice_2_age + 0.5 * 0 * voice_2_age * voice_2_age))) * (1.0 + select2(voice_2_age < 0, 0.0, sin(2.0 * ma.PI * (voice_2_age - 0) * 3.4112) * 0.11))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_2_osc = no.noise; +voice_2_colored = (voice_2_osc * (1.0 - clip01(0.35 + patch_mod_noise + 0.0)) + no.noise * clip01(0.35 + patch_mod_noise + 0.0)); +voice_2_driven = ma.tanh(voice_2_colored * (1.0 + clip01(0.2136 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.2136 + patch_mod_drive + 0.0) * 12.0); +voice_2_folded = voice_2_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_2_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_2_filtered = voice_2_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_2_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_2_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_2_phased = voice_2_filtered + (voice_2_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(-0.0008712 + -0.00035 * voice_2_age) * ma.SR)))); +voice_2_formants = voice_2_phased; +voice_2 = ((voice_2_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_2_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_2_age, 0, 0, 0.6578947, 0.2938775, 0.1907029) * (1.0 - 0.0264 * (0.5 + 0.5 * lfo_sin(13.04, 0.0))) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.3344); + +voice_3_age = age; +voice_3_freq = ((max(20, 57.5946 * pow(2.0, -0.208544 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age))) * (1.0 + select2(voice_3_age < 0, 0.0, sin(2.0 * ma.PI * (voice_3_age - 0) * 3.9602) * 0.09))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_3_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 57.5946 * pow(2.0, -0.208544 * voice_3_age + 0.5 * 0 * voice_3_age * voice_3_age))) * (1.0 + select2(voice_3_age < 0, 0.0, sin(2.0 * ma.PI * (voice_3_age - 0) * 3.9602) * 0.09))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_3_colored = (voice_3_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_3_driven = ma.tanh(voice_3_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_3_folded = voice_3_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_3_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_3_filtered = voice_3_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_3_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_3_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_3_phased = voice_3_filtered; +voice_3_formants = voice_3_phased; +voice_3 = ((voice_3_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_3_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_3_age, 0, 0, 1, 0.1777778, 0.1306122) * (1.0 - 0.0216 * (0.5 + 0.5 * lfo_sin(13.94, 0.0))) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +voice_4_age = age; +voice_4_freq = ((max(20, 51.4206 * pow(2.0, 1.050624 * voice_4_age + 0.5 * 0 * voice_4_age * voice_4_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_4_osc = no.noise; +voice_4_colored = (voice_4_osc * (1.0 - clip01(0.35 + patch_mod_noise + 0.0)) + no.noise * clip01(0.35 + patch_mod_noise + 0.0)); +voice_4_driven = ma.tanh(voice_4_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_4_folded = voice_4_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_4_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_4_filtered = voice_4_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_4_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.12 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.12 * (1.0 + 0 * voice_4_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_4_phased = voice_4_filtered; +voice_4_formants = voice_4_phased; +voice_4 = ((voice_4_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_4_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_4_age, 0, 0, 1, 0.09070295, 0.00566893) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +voice_5_age = age; +voice_5_freq = ((max(20, 78.2334 * pow(2.0, -0.101156 * voice_5_age + 0.5 * 0 * voice_5_age * voice_5_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_5_osc = select2(wrap01(os.phasor(1.0, ((max(20, 78.2334 * pow(2.0, -0.101156 * voice_5_age + 0.5 * 0 * voice_5_age * voice_5_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.38 + 0 * voice_5_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_5_colored = (voice_5_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_5_driven = ma.tanh(voice_5_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_5_folded = voice_5_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_5_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_5_filtered = voice_5_folded : fi.lowpass(1, max(20.0, clip01(0.72 * (1.0 + 0 * voice_5_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.05 * (1.0 + 0 * voice_5_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.05 * (1.0 + 0 * voice_5_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_5_phased = voice_5_filtered; +voice_5_formants = voice_5_phased; +voice_5 = ((voice_5_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_5_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_5_age, 0, 0, 1, 0.07346939, 0.1097506) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +voice_6_age = age; +voice_6_freq = ((max(20, 78.2334 * pow(2.0, 0 * voice_6_age + 0.5 * 0 * voice_6_age * voice_6_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_6_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 78.2334 * pow(2.0, 0 * voice_6_age + 0.5 * 0 * voice_6_age * voice_6_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_6_colored = (voice_6_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_6_driven = ma.tanh(voice_6_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_6_folded = voice_6_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_6_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_6_filtered = voice_6_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_6_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.1 * (1.0 + 0 * voice_6_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.1 * (1.0 + 0 * voice_6_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_6_phased = voice_6_filtered; +voice_6_formants = voice_6_phased; +voice_6 = ((voice_6_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_6_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_6_age, 0, 0, 1, 0.01451247, 0.03832199) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0 + voice_1 + voice_2 + voice_3 + voice_4 + voice_5 + voice_6) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-explosion.dsp b/tools/aqua-playground/lowered/sfxr-explosion.dsp new file mode 100644 index 0000000..3df35ab --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-explosion.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-explosion"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time - floor(time / 0.174744) * 0.174744; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 20 * pow(2.0, 0.0320625 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 3.4112) * 0.11))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = no.noise; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0.35 + patch_mod_noise + 0.0)) + no.noise * clip01(0.35 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.2136 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.2136 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered + (voice_0_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(-0.0008712 + -0.00035 * voice_0_age) * ma.SR)))); +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.6578947, 0.2938775, 0.1907029) * (1.0 - 0.0264 * (0.5 + 0.5 * lfo_sin(13.04, 0.0))) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.3344); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-hit.dsp b/tools/aqua-playground/lowered/sfxr-hit.dsp new file mode 100644 index 0000000..9e8a840 --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-hit.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-hit"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 51.4206 * pow(2.0, 1.050624 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = no.noise; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0.35 + patch_mod_noise + 0.0)) + no.noise * clip01(0.35 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.12 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.12 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.09070295, 0.00566893) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-jump.dsp b/tools/aqua-playground/lowered/sfxr-jump.dsp new file mode 100644 index 0000000..7cfbefc --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-jump.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-jump"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 78.2334 * pow(2.0, -0.101156 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = select2(wrap01(os.phasor(1.0, ((max(20, 78.2334 * pow(2.0, -0.101156 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.38 + 0 * voice_0_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.72 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.05 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.05 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.07346939, 0.1097506) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-laser.dsp b/tools/aqua-playground/lowered/sfxr-laser.dsp new file mode 100644 index 0000000..4bcb2b0 --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-laser.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-laser"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 229.0554 * pow(2.0, 0.703836 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 229.0554 * pow(2.0, 0.703836 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 1.0; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered + (voice_0_filtered : de.fdelay(2048, min(2047.0, max(0.0, abs(0.0001458 + -0.000504 * voice_0_age) * ma.SR)))); +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.07346939, 0.08185941) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-pickup.dsp b/tools/aqua-playground/lowered/sfxr-pickup.dsp new file mode 100644 index 0000000..c2e1915 --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-pickup.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-pickup"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 148.7934 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.081844, 1.116121, 1.0) * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = select2(wrap01(os.phasor(1.0, ((max(20, 148.7934 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * select2(voice_0_age < 0.081844, 1.116121, 1.0) * pow(2.0, patch_mod_pitch + 0.0)) + 0) < clip01(0.5 + 0 * voice_0_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.201 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.201 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 0.6896552, 0.1306122, 0.01451247) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.319); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/sfxr-powerup.dsp b/tools/aqua-playground/lowered/sfxr-powerup.dsp new file mode 100644 index 0000000..cf8bf37 --- /dev/null +++ b/tools/aqua-playground/lowered/sfxr-powerup.dsp @@ -0,0 +1,54 @@ +import("stdfaust.lib"); +declare name "sfxr-powerup"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time - floor(time / 0.11315) * 0.11315; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 57.5946 * pow(2.0, -0.208544 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 3.9602) * 0.09))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, 57.5946 * pow(2.0, -0.208544 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age))) * (1.0 + select2(voice_0_age < 0, 0.0, sin(2.0 * ma.PI * (voice_0_age - 0) * 3.9602) * 0.09))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.12 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.1777778, 0.1306122) * (1.0 - 0.0216 * (0.5 + 0.5 * lfo_sin(13.94, 0.0))) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.22); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-playground/lowered/thruster.dsp b/tools/aqua-playground/lowered/thruster.dsp new file mode 100644 index 0000000..9260b6a --- /dev/null +++ b/tools/aqua-playground/lowered/thruster.dsp @@ -0,0 +1,29 @@ +// thruster: sustained, heavy, brittle-hull thruster with an RPM control. +// Compile as Faust source (AquaSynthPatchCompiler.CompileSource); it is not a .aqua script. +// Control: rpm (300..6000). Rotor tone = 28 Hz + rpm*0.025 (about 36..180 Hz); three blades chop the rasp at 3x that. +declare name "thruster"; +import("stdfaust.lib"); + +rpm = hslider("rpm", 1200, 300, 6000, 1) : si.smooth(ba.tau2pole(0.2)); +load = (rpm - 300) / 5700; +shaft = 28 + rpm * 0.025; + +// effort: slow random wander of the shaft speed +wander = no.noise : fi.lowpass(2, 5) : *(0.35); +f0 = shaft * (1 + 0.04 * wander); + +// low rumble: saw at shaft speed plus a square a sub-octave down, low-passed +rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 * shaft); + +// blade pass: rasp noise chopped at 3x shaft, band tracks rpm +chop = 0.5 + 0.5 * os.osc(f0 * 3) ^ 2; +rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); + +// brittle hull: high-Q modes rattled by noise, louder with load; tanh on the rattle alone keeps ring-up spikes from setting the peak +mode(f, q) = no.noise : fi.resonbp(f, q, 1); +rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode(467, 16) + 0.4 * mode(1130, 14)) * (0.1 + 0.9 * load ^ 2) * 3 : *(4) : ma.tanh : /(4); + +mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 1.5 * load) + rattle; +// drive falls only gently with load so tanh stays out of saturation while high rpm still ends up louder than low rpm +// final 0.425 trim keeps peak under 0.4 at rpm 4800 +process = mix * (0.4 + 0.6 * load) * (0.9 - 0.5 * load) : ma.tanh : *(0.425); diff --git a/tools/aqua-playground/lowered/wobble-bass-growl.dsp b/tools/aqua-playground/lowered/wobble-bass-growl.dsp new file mode 100644 index 0000000..914ab66 --- /dev/null +++ b/tools/aqua-playground/lowered/wobble-bass-growl.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "wobble-bass-growl"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.32 * lfo_sin(6, 0); +patch_mod_pitch = 0 + 0.035 * lfo_sin(6, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + 0.55 * lfo_sin(6, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0 + 0.08 * lfo_sin(6, 0); +patch_mod_drive = 0 + 0.28 * lfo_sin(6, 0); +patch_mod_fold = 0 + 0.22 * lfo_sin(6, 0); +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0 + 2.2 * lfo_sin(6, 0); + +voice_0_age = age; +voice_0_freq = ((max(20, 44 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 44 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 44 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1.5))) * (max(0.0, 1.2 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.45, 0.0001))) / ma.PI) - 1.0; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0.05 + patch_mod_noise + 0.0)) + no.noise * clip01(0.05 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.42 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.42 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0.18 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0.18 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.18 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.28 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.01 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.01 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.3, 0.7) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.2); + +voice_1_age = age; +voice_1_freq = ((max(20, 88 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = select2(wrap01(os.phasor(1.0, ((max(20, 88 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 88 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 1.5))) * (max(0.0, 1.2 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.45, 0.0001))) / ma.PI) < clip01(0.36 + 0 * voice_1_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0.05 + patch_mod_noise + 0.0)) + no.noise * clip01(0.05 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.42 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.42 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0.18 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0.18 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.18 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.28 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.01 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.01 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.3, 0.7) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.09); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/wobble-bass-neuro.dsp b/tools/aqua-playground/lowered/wobble-bass-neuro.dsp new file mode 100644 index 0000000..805ec9a --- /dev/null +++ b/tools/aqua-playground/lowered/wobble-bass-neuro.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "wobble-bass-neuro"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.28 * lfo_hold(7, 0); +patch_mod_pitch = 0 + 0.04 * lfo_hold(7, 0); +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + 0.52 * lfo_hold(7, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0 + 0.1 * lfo_hold(7, 0); +patch_mod_drive = 0 + 0.25 * lfo_hold(7, 0); +patch_mod_fold = 0 + 0.3 * lfo_hold(7, 0); +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0 + 2.8 * lfo_hold(7, 0); + +voice_0_age = age; +voice_0_freq = ((max(20, 49 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 49 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 49 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2.7))) * (max(0.0, 1.5 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.35, 0.0001))) / ma.PI) - 1.0; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0.04 + patch_mod_noise + 0.0)) + no.noise * clip01(0.04 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.38 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.38 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0.24 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0.24 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.24 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.25 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.28, 0.75) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.16); + +voice_1_age = age; +voice_1_freq = ((max(20, 147 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, 147 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 147 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2.7))) * (max(0.0, 1.5 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.35, 0.0001))) / ma.PI) - 0.5); +voice_1_colored = (voice_1_osc * (1.0 - clip01(0.04 + patch_mod_noise + 0.0)) + no.noise * clip01(0.04 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.38 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.38 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0.24 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0.24 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.24 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.25 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = voice_1_phased; +voice_1 = ((voice_1_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.28, 0.75) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.06); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/wobble-bass-talker.dsp b/tools/aqua-playground/lowered/wobble-bass-talker.dsp new file mode 100644 index 0000000..116e187 --- /dev/null +++ b/tools/aqua-playground/lowered/wobble-bass-talker.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "wobble-bass-talker"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.42 * lfo_tri(4, 0); +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0 + 0.48 * lfo_tri(4, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0 + 0.2 * lfo_tri(4, 0); +patch_mod_fold = 0 + 0.14 * lfo_tri(4, 0); +patch_mod_formant_mix = 0 + 0.38 * lfo_tri(4, 0); +patch_mod_fm_index = 0 + 1.6 * lfo_tri(4, 0); + +voice_0_age = age; +voice_0_freq = ((max(20, 55 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 55 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 55 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2))) * (max(0.0, 0.8 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.7, 0.0001))) / ma.PI) - 1.0; +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.3 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.3 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0.08 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0.08 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.08 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.34 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = ((voice_0_phased : fi.resonbp(520, 5.777778, 1.0)) * 0.7 + (voice_0_phased : fi.resonbp(1250, 7.352941, 1.0)) * 1 + (voice_0_phased : fi.resonbp(2600, 8.125, 1.0)) * 0.45) / 2.15; +voice_0 = ((voice_0_phased * (1.0 - clip01(0.35 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0.35 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.25, 0.8) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.18); + +voice_1_age = age; +voice_1_freq = ((max(20, 110 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 110 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 110 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 2))) * (max(0.0, 0.8 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.7, 0.0001))) / ma.PI) - 1.0; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.3 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.3 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0.08 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0.08 + patch_mod_fold + 0.0) * 3.5)) * clip01(0.08 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.34 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.02 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = ((voice_1_phased : fi.resonbp(520, 5.777778, 1.0)) * 0.7 + (voice_1_phased : fi.resonbp(1250, 7.352941, 1.0)) * 1 + (voice_1_phased : fi.resonbp(2600, 8.125, 1.0)) * 0.45) / 2.15; +voice_1 = ((voice_1_phased * (1.0 - clip01(0.35 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0.35 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.25, 0.8) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.08); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/lowered/wobble-bass-yoy.dsp b/tools/aqua-playground/lowered/wobble-bass-yoy.dsp new file mode 100644 index 0000000..fcaf023 --- /dev/null +++ b/tools/aqua-playground/lowered/wobble-bass-yoy.dsp @@ -0,0 +1,65 @@ +import("stdfaust.lib"); +declare name "wobble-bass-yoy"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_mod_gain = 0 + 0.5 * lfo_sq(5, 0); +patch_mod_pitch = 0 + 0.025 * lfo_sq(5, 0); +patch_mod_duty = 0 + 0.08 * lfo_sq(5, 0); +patch_mod_lpf = 0 + 0.5 * lfo_sq(5, 0); +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0 + 0.45 * lfo_sq(5, 0); +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, 62 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = select2(wrap01(os.phasor(1.0, ((max(20, 62 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 62 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3))) * (max(0.0, 0.7 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.5, 0.0001))) / ma.PI) < clip01(0.5 + 0 * voice_0_age + patch_mod_duty + 0.0), -0.5, 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.25 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.25 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.3 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = ((voice_0_phased : fi.resonbp(400, 5, 1.0)) * 0.6 + (voice_0_phased : fi.resonbp(900, 7.5, 1.0)) * 1 + (voice_0_phased : fi.resonbp(2100, 8.076923, 1.0)) * 0.4) / 2; +voice_0 = ((voice_0_phased * (1.0 - clip01(0.28 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0.28 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0, 0, 1, 0.22, 0.65) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.16); + +voice_1_age = age; +voice_1_freq = ((max(20, 124 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_1_osc = 2.0 * wrap01(os.phasor(1.0, ((max(20, 124 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, 124 * pow(2.0, 0 * voice_1_age + 0.5 * 0 * voice_1_age * voice_1_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3))) * (max(0.0, 0.7 + patch_mod_fm_index + 0.0) * exp(-voice_1_age / max(0.5, 0.0001))) / ma.PI) - 1.0; +voice_1_colored = (voice_1_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_1_driven = ma.tanh(voice_1_colored * (1.0 + clip01(0.25 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.25 + patch_mod_drive + 0.0) * 12.0); +voice_1_folded = voice_1_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_1_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_1_filtered = voice_1_folded : fi.lowpass(1, max(20.0, clip01(0.3 * (1.0 + 0 * voice_1_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.03 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.03 * (1.0 + 0 * voice_1_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_1_phased = voice_1_filtered; +voice_1_formants = ((voice_1_phased : fi.resonbp(400, 5, 1.0)) * 0.6 + (voice_1_phased : fi.resonbp(900, 7.5, 1.0)) * 1 + (voice_1_phased : fi.resonbp(2100, 8.076923, 1.0)) * 0.4) / 2; +voice_1 = ((voice_1_phased * (1.0 - clip01(0.28 + patch_mod_formant_mix + 0.0)) + voice_1_formants * clip01(0.28 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_1_age, 0, 0, 1, 0.22, 0.65) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.07); + +process = softclip((voice_0 + voice_1) * 1); diff --git a/tools/aqua-playground/package-lock.json b/tools/aqua-playground/package-lock.json new file mode 100644 index 0000000..ae5be49 --- /dev/null +++ b/tools/aqua-playground/package-lock.json @@ -0,0 +1,35 @@ +{ + "name": "aqua-playground", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "aqua-playground", + "devDependencies": { + "@grame/faustwasm": "0.20.0" + } + }, + "node_modules/@grame/faustwasm": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@grame/faustwasm/-/faustwasm-0.20.0.tgz", + "integrity": "sha512-oxy1MgkGVMxmWdmpiP0OGFv9T0nUfYYINFMoYhErzCipdfkMYv35KgVg5OojHa9NgXD9leLlAB+IIzJZ0KoIQQ==", + "dev": true, + "license": "LGPL-2.1", + "dependencies": { + "@types/emscripten": "^1.39.10" + }, + "bin": { + "faust2sndfile-ts": "scripts/faust2sndfile.js", + "faust2svg-ts": "scripts/faust2svg.js", + "faust2wasm-ts": "scripts/faust2wasm.js" + } + }, + "node_modules/@types/emscripten": { + "version": "1.41.6", + "resolved": "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.41.6.tgz", + "integrity": "sha512-uN+9i8bFT5CUcZfyIEYDrSueACEyKGbUs5kC/72DGlZZoinh84sJfVV0i8UOJD1asdzkvLPBRrKs41kZ8MdEXg==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/tools/aqua-playground/package.json b/tools/aqua-playground/package.json new file mode 100644 index 0000000..9ebad5f --- /dev/null +++ b/tools/aqua-playground/package.json @@ -0,0 +1,13 @@ +{ + "name": "aqua-playground", + "private": true, + "type": "module", + "description": "Static in-browser playground for AquaSynth patches: .aqua -> Faust (AquaLower) -> wasm (faustwasm) -> AudioWorklet.", + "scripts": { + "build": "node build.mjs", + "test": "node test.mjs" + }, + "devDependencies": { + "@grame/faustwasm": "0.20.0" + } +} diff --git a/tools/aqua-playground/test.mjs b/tools/aqua-playground/test.mjs new file mode 100644 index 0000000..4275537 --- /dev/null +++ b/tools/aqua-playground/test.mjs @@ -0,0 +1,49 @@ +// Headless check of the built site (dist/): every catalog patch compiles to wasm through the same +// faustwasm runtime the browser loads, exposes controls, and renders audible, finite samples. +// It measures non-silence and NaN only; it cannot hear anything. Usage: node build.mjs && node test.mjs +import { readFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; + +const dist = resolve(process.argv[2] ?? join(dirname(fileURLToPath(import.meta.url)), "dist")); +const { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } = + await import(pathToFileURL(join(dist, "vendor/faustwasm/index.js")).href); +const { controlsOf } = await import(pathToFileURL(join(dist, "ui.mjs")).href); + +const libfaust = new LibFaust(await instantiateFaustModuleFromFile(join(dist, "vendor/libfaust-wasm/libfaust-wasm.js"))); +const compiler = new FaustCompiler(libfaust); +const catalog = JSON.parse(readFileSync(join(dist, "catalog.json"), "utf8")); +const SR = 48000, SECONDS = 2; +let failed = 0; +console.log(`libfaust ${libfaust.version()}; ${catalog.length} patches; ${SECONDS} s at ${SR} Hz`); + +function stats(out) { + let peak = 0, bad = 0; + for (const ch of out) for (const v of ch) { if (!Number.isFinite(v)) bad++; else peak = Math.max(peak, Math.abs(v)); } + return { peak, bad }; +} + +for (const e of catalog) { + const g = new FaustMonoDspGenerator(); + const ok = await g.compile(compiler, e.name.replace(/[^A-Za-z0-9_]/g, "_"), readFileSync(join(dist, e.dsp), "utf8"), "-ftz 2"); + if (!ok) { failed++; console.log(`FAIL ${e.name}: compile: ${compiler.getErrorMessage()}`); continue; } + const controls = controlsOf(JSON.parse(g.factory.json)); + const { peak, bad } = stats((await g.createOfflineProcessor(SR, 512)).render(null, SR * SECONDS)); + const problems = []; + if (bad) problems.push(`${bad} non-finite samples`); + if (!(peak > 1e-4)) problems.push(`silent (peak ${peak})`); + if (e.name === "thruster") { + if (!controls.some((c) => c.label === "rpm")) problems.push("no rpm control in the DSP UI"); + for (const rpm of [600, 4800]) { + const p = await g.createOfflineProcessor(SR, 512); + p.setParamValue(controls.find((c) => c.label === "rpm").address, rpm); + const s = stats(p.render(null, SR * SECONDS)); + console.log(` thruster rpm=${rpm}: peak ${s.peak.toFixed(4)}, non-finite ${s.bad}`); + if (s.bad || !(s.peak > 1e-4)) problems.push(`rpm ${rpm}: peak ${s.peak}, non-finite ${s.bad}`); + } + } + failed += problems.length ? 1 : 0; + console.log(`${problems.length ? "FAIL" : "ok "} ${e.name}: peak ${peak.toFixed(4)}${peak > 1 ? " (CLIPS)" : ""}, ${controls.length} controls${problems.length ? " :: " + problems.join("; ") : ""}`); +} +console.log(failed ? `${failed} FAILED` : "all passed"); +process.exit(failed ? 1 : 0); diff --git a/tools/aqua-playground/web/app.js b/tools/aqua-playground/web/app.js new file mode 100644 index 0000000..da38b06 --- /dev/null +++ b/tools/aqua-playground/web/app.js @@ -0,0 +1,91 @@ +import { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } from "./vendor/faustwasm/index.js"; +import { controlsOf } from "./ui.mjs"; + +const $ = (id) => document.getElementById(id); +const status = (t) => { $("status").textContent = t; }; +let compiler, ctx, node, gain, analyser, generator, entry; + +async function init() { + const catalog = await (await fetch("./catalog.json")).json(); + for (const e of catalog) $("patch").add(new Option(`${e.name}${e.kind === "faust" ? " (hand-written Faust)" : ""}`, e.name)); + compiler = new FaustCompiler(new LibFaust(await instantiateFaustModuleFromFile("./vendor/libfaust-wasm/libfaust-wasm.js"))); + window.aquaCatalog = catalog; + $("patch").onchange = () => load(catalog.find((e) => e.name === $("patch").value)); + $("play").onclick = play; $("stop").onclick = stop; + $("recompile").onclick = () => compile($("source").value); + $("volume").oninput = () => { if (gain) gain.gain.value = Number($("volume").value); }; + const start = new URLSearchParams(location.search).get("patch"); + const first = catalog.find((e) => e.name === start) ?? catalog[0]; + $("patch").value = first.name; + await load(first); +} + +async function load(e) { + stop(); + entry = e; + $("origin").textContent = `from ${e.origin}`; + $("source").value = await (await fetch(`./${e.dsp}`)).text(); + await compile($("source").value); +} + +async function compile(code) { + stop(); + status("Compiling Faust to wasm…"); + const t0 = performance.now(); + const g = new FaustMonoDspGenerator(); + const ok = await g.compile(compiler, entry.name.replace(/[^A-Za-z0-9_]/g, "_"), code, "-ftz 2"); + if (!ok) { status(`Compile failed: ${compiler.getErrorMessage()}`); $("play").disabled = true; return; } + generator = g; + $("play").disabled = false; + const controls = controlsOf(JSON.parse(g.factory.json)); + buildControls(controls); + status(`Compiled in ${Math.round(performance.now() - t0)} ms; ${controls.length} controls. Press Play.`); +} + +function buildControls(controls) { + const box = $("controls"); box.replaceChildren(); + let group = null; + for (const c of controls) { + if (c.group !== group) { group = c.group; const h = document.createElement("div"); h.className = "grp"; h.textContent = group; box.append(h); } + const row = document.createElement("div"); row.className = "row"; + const label = document.createElement("label"); label.textContent = c.label; label.title = c.address; + const input = document.createElement("input"); + const out = document.createElement("output"); + if (c.type === "checkbox" || c.type === "button") { input.type = "checkbox"; input.checked = c.init > 0; } + else { input.type = "range"; input.min = c.min; input.max = c.max; input.step = c.step; input.value = c.init; } + const show = () => { out.textContent = input.type === "checkbox" ? (input.checked ? "on" : "off") : Number(input.value).toFixed(c.step < 0.01 ? 4 : c.step < 1 ? 2 : 0); }; + input.oninput = () => { show(); node?.setParamValue(c.address, input.type === "checkbox" ? Number(input.checked) : Number(input.value)); }; + input.dataset.address = c.address; show(); + row.append(label, input, out); box.append(row); + } +} + +async function play() { + stop(); + ctx ??= new AudioContext({ latencyHint: "interactive" }); + await ctx.resume(); + // A fresh node each press: one-shot .aqua patches run on a clock that starts at instantiation. + node = await generator.createNode(ctx); + if (!node) { status("createNode failed"); return; } + for (const input of $("controls").querySelectorAll("input")) input.dispatchEvent(new Event("input")); + gain = ctx.createGain(); gain.gain.value = Number($("volume").value); + analyser = ctx.createAnalyser(); analyser.fftSize = 1024; + node.connect(gain); gain.connect(analyser); analyser.connect(ctx.destination); + status(`Playing ${entry.name} at ${ctx.sampleRate} Hz.`); + meter(); +} + +function stop() { + if (node) { node.disconnect(); node.destroy?.(); node = null; } + gain?.disconnect(); analyser?.disconnect(); gain = analyser = null; + $("level").value = 0; +} + +function meter() { + if (!analyser) return; + const buf = new Float32Array(analyser.fftSize); analyser.getFloatTimeDomainData(buf); + $("level").value = buf.reduce((m, v) => Math.max(m, Math.abs(v)), 0); + requestAnimationFrame(meter); +} + +init().catch((err) => { status(`Failed to start: ${err}`); console.error(err); }); diff --git a/tools/aqua-playground/web/index.html b/tools/aqua-playground/web/index.html new file mode 100644 index 0000000..7f8974d --- /dev/null +++ b/tools/aqua-playground/web/index.html @@ -0,0 +1,38 @@ + + + + + + AquaSynth Playground + + + +
+
+

AquaSynth lab

+

Patch Playground

+

An AquaSynth .aqua patch is lowered to Faust, compiled to WebAssembly in this page, and played through an AudioWorklet. Nothing here is rendered on a server.

+
+
+ + + + + + Loading the Faust compiler… +
+
+
+

Controls (from the DSP's own UI)

+
+
+
+

Lowered Faust source

+ + +
+
+
+ + + diff --git a/tools/aqua-playground/web/styles.css b/tools/aqua-playground/web/styles.css new file mode 100644 index 0000000..3c7dcaf --- /dev/null +++ b/tools/aqua-playground/web/styles.css @@ -0,0 +1,19 @@ +:root { color-scheme: dark; --bg:#0b1418; --fg:#d7e6ea; --dim:#7f9aa3; --acc:#3fc1c9; --line:#1f3640; } +* { box-sizing: border-box; } +body { margin:0; background:var(--bg); color:var(--fg); font:15px/1.45 system-ui, sans-serif; } +main { max-width:1200px; margin:0 auto; padding:24px; } +.eyebrow { margin:0; color:var(--acc); text-transform:uppercase; letter-spacing:.12em; font-size:12px; } +h1 { margin:.1em 0 .2em; } h2 { font-size:16px; margin:0 0 8px; } small { color:var(--dim); font-weight:400; } +.lede { color:var(--dim); max-width:70ch; } +.bar { display:flex; flex-wrap:wrap; gap:12px 16px; align-items:center; padding:12px 0; border-block:1px solid var(--line); margin-bottom:16px; } +button, select { background:#10242b; color:var(--fg); border:1px solid var(--line); padding:6px 14px; border-radius:4px; font:inherit; } +button:hover { border-color:var(--acc); } button:disabled { opacity:.4; } +#status { color:var(--dim); } +.cols { display:grid; grid-template-columns:minmax(280px,1fr) minmax(320px,1.4fr); gap:24px; } +@media (max-width:800px) { .cols { grid-template-columns:1fr; } } +.controls { display:grid; gap:6px; max-height:70vh; overflow:auto; padding-right:8px; } +.controls .row { display:grid; grid-template-columns:minmax(0,1fr) 120px 58px; gap:8px; align-items:center; } +.controls .grp { color:var(--dim); font-size:12px; margin-top:8px; } +.controls label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } +.controls output { text-align:right; color:var(--acc); font-variant-numeric:tabular-nums; } +textarea { width:100%; height:62vh; background:#071013; color:#bcd3d8; border:1px solid var(--line); border-radius:4px; font:12px/1.4 ui-monospace, monospace; padding:8px; resize:vertical; } diff --git a/tools/aqua-playground/web/ui.mjs b/tools/aqua-playground/web/ui.mjs new file mode 100644 index 0000000..d06102a --- /dev/null +++ b/tools/aqua-playground/web/ui.mjs @@ -0,0 +1,17 @@ +// Flattens a Faust DSP JSON `ui` tree (factory.json) into the controls a slider panel needs. +// Shared by the browser app and the node test so both read the DSP's own UI declaration. +export function controlsOf(json) { + const out = []; + const walk = (items, group) => { + for (const it of items ?? []) { + if (it.items) walk(it.items, it.label ? [...group, it.label] : group); + else if (/slider|nentry|checkbox|button/.test(it.type)) + out.push({ + address: it.address, label: it.label, group: group.join(" / "), type: it.type, + init: Number(it.init ?? 0), min: Number(it.min ?? 0), max: Number(it.max ?? 1), step: Number(it.step ?? 0.01), + }); + } + }; + walk(json.ui, []); + return out; +} From 6080f9b8f182932b947eabf3930dec4757deffa0 Mon Sep 17 00:00:00 2001 From: Aqua Date: Wed, 4 Nov 2026 13:39:11 +0000 Subject: [PATCH 008/124] Playground: rename ui.mjs to ui.js so static hosts serve a JavaScript MIME type The minds host sends .mjs as application/octet-stream, which browsers refuse for module imports. Co-Authored-By: Claude Sonnet 5.5 --- tools/aqua-playground/README.md | 2 +- tools/aqua-playground/test.mjs | 2 +- tools/aqua-playground/web/app.js | 2 +- tools/aqua-playground/web/{ui.mjs => ui.js} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename tools/aqua-playground/web/{ui.mjs => ui.js} (100%) diff --git a/tools/aqua-playground/README.md b/tools/aqua-playground/README.md index 720915b..3ecc87f 100644 --- a/tools/aqua-playground/README.md +++ b/tools/aqua-playground/README.md @@ -21,7 +21,7 @@ controls, so their slider panel is empty. - `node test.mjs [dist]`: headless check of `dist/`: each patch compiles to wasm, renders 2 s offline, is non-silent and finite; the thruster is also run at rpm 600 and 4800. It cannot hear and does not run an AudioWorklet or a browser. -- `web/`: the page (`index.html`, `app.js`, `ui.mjs`, `styles.css`). +- `web/`: the page (`index.html`, `app.js`, `ui.js`, `styles.css`). Serve `dist/` from any static host (`python3 -m http.server`); AudioWorklet needs `localhost` or https. The older `tools/vocal-tract-playground` renders server-side through the .NET renderer; this one diff --git a/tools/aqua-playground/test.mjs b/tools/aqua-playground/test.mjs index 4275537..673653a 100644 --- a/tools/aqua-playground/test.mjs +++ b/tools/aqua-playground/test.mjs @@ -8,7 +8,7 @@ import { fileURLToPath, pathToFileURL } from "node:url"; const dist = resolve(process.argv[2] ?? join(dirname(fileURLToPath(import.meta.url)), "dist")); const { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } = await import(pathToFileURL(join(dist, "vendor/faustwasm/index.js")).href); -const { controlsOf } = await import(pathToFileURL(join(dist, "ui.mjs")).href); +const { controlsOf } = await import(pathToFileURL(join(dist, "ui.js")).href); const libfaust = new LibFaust(await instantiateFaustModuleFromFile(join(dist, "vendor/libfaust-wasm/libfaust-wasm.js"))); const compiler = new FaustCompiler(libfaust); diff --git a/tools/aqua-playground/web/app.js b/tools/aqua-playground/web/app.js index da38b06..54c0331 100644 --- a/tools/aqua-playground/web/app.js +++ b/tools/aqua-playground/web/app.js @@ -1,5 +1,5 @@ import { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } from "./vendor/faustwasm/index.js"; -import { controlsOf } from "./ui.mjs"; +import { controlsOf } from "./ui.js"; const $ = (id) => document.getElementById(id); const status = (t) => { $("status").textContent = t; }; diff --git a/tools/aqua-playground/web/ui.mjs b/tools/aqua-playground/web/ui.js similarity index 100% rename from tools/aqua-playground/web/ui.mjs rename to tools/aqua-playground/web/ui.js From 7593917e324e7d41c71ea353eb66e3fcd24b1914 Mon Sep 17 00:00:00 2001 From: Aqua Date: Wed, 4 Nov 2026 21:34:18 +0000 Subject: [PATCH 009/124] Add blinded A/B listening trial page for the thruster noise sweep Static page, trial patch (thruster + noise control), shared logic, dependency-free analyzer, node tests. Never run in a browser; nothing has been heard. Co-Authored-By: Claude Sonnet 5.5 --- tools/aqua-trial/.gitignore | 1 + tools/aqua-trial/README.md | 37 ++++++ tools/aqua-trial/analyze.mjs | 95 +++++++++++++++ tools/aqua-trial/build.mjs | 27 +++++ tools/aqua-trial/logic.mjs | 81 +++++++++++++ tools/aqua-trial/package.json | 7 ++ tools/aqua-trial/test.mjs | 174 ++++++++++++++++++++++++++++ tools/aqua-trial/thruster-trial.dsp | 32 +++++ tools/aqua-trial/web/index.html | 49 ++++++++ tools/aqua-trial/web/styles.css | 21 ++++ tools/aqua-trial/web/trial.js | 109 +++++++++++++++++ 11 files changed, 633 insertions(+) create mode 100644 tools/aqua-trial/.gitignore create mode 100644 tools/aqua-trial/README.md create mode 100644 tools/aqua-trial/analyze.mjs create mode 100644 tools/aqua-trial/build.mjs create mode 100644 tools/aqua-trial/logic.mjs create mode 100644 tools/aqua-trial/package.json create mode 100644 tools/aqua-trial/test.mjs create mode 100644 tools/aqua-trial/thruster-trial.dsp create mode 100644 tools/aqua-trial/web/index.html create mode 100644 tools/aqua-trial/web/styles.css create mode 100644 tools/aqua-trial/web/trial.js diff --git a/tools/aqua-trial/.gitignore b/tools/aqua-trial/.gitignore new file mode 100644 index 0000000..849ddff --- /dev/null +++ b/tools/aqua-trial/.gitignore @@ -0,0 +1 @@ +dist/ diff --git a/tools/aqua-trial/README.md b/tools/aqua-trial/README.md new file mode 100644 index 0000000..0870e58 --- /dev/null +++ b/tools/aqua-trial/README.md @@ -0,0 +1,37 @@ +# AquaSynth listening trial + +Blinded, randomized A/B ratings of a synthesized thruster, to test Deru's "dead radio" finding: that the +thruster's noise layers (rasp, rattle) are what makes it sound dead, and that a tone-forward mix lands better. + +**Status: the page has never been run in a browser, and nothing has been heard.** Node covers the logic and +the patch through the same faustwasm runtime the page loads (`node test.mjs`, 15 checks). The DOM glue +(`web/trial.js`), AudioContext playback and the download are untested. Follow-up: browser-verify. + +## Entry points + +- `web/`: the page. Consent checkbox gates Start; the page compiles `thruster-trial.dsp` in-browser, renders four + 4 s variants at the browser's sample rate, and runs six comparisons (every pair once, order and A/B position + randomized from a random seed). Per sound: rating 1-5 ("does it land?") and one word. Variant identity is never shown. +- `thruster-trial.dsp`: `patches/thruster/thruster.dsp` plus a `noise` control (percent). `noise` scales the rasp and + rattle layers only; the rumble (tone) is untouched, so lowering it moves the mix tone-forward. That reading of + "tone-forward mix" is this author's; at 100 the signal equals the thruster (asserted sample for sample). + Variants: rpm 600, noise 100 / 50 / 20 / 0. Not loudness-matched, so level and noise are confounded by design. +- `logic.mjs`: design, statistics, validation and export shape (shared by page and tests). +- `analyze.mjs`: dependency-free. `node analyze.mjs export1.json [export2.json ...]` prints per-variant n, mean, + sd, min/max, peak, rms, words, and whether peak / rms predicted the ratings (Spearman rho, permutation p; + "predicts" means |rho| >= 0.5 and p < 0.05, fixed before any data). +- `build.mjs`: assembles `dist/` and prints the content hash used in the publish path. Needs + `(cd ../aqua-playground && npm ci)` for the faustwasm runtime. `test.mjs` needs `dist/`. + +## Privacy + +Answers live in the page's memory only. The page makes no network request after loading its own assets and +writes nothing to storage. **Export** downloads a JSON file (patch, params, peak, rms, rating, word, time, +user agent, sample rate); sending it is the listener's act. + +## Measured finding before any listening + +Peak and rms hardly move across the sweep (48 kHz: rms 0.0734 / 0.0712 / 0.0706 / 0.0705; peak 0.189 / 0.161 / +0.148 / 0.140). At rpm 600 the rumble carries nearly all the energy, so these four variants differ mostly in +spectral texture, not level. That makes a peak/rms "prediction" of ratings less likely a priori, and the trial +a real test of whether the texture difference is audible. diff --git a/tools/aqua-trial/analyze.mjs b/tools/aqua-trial/analyze.mjs new file mode 100644 index 0000000..52b73ea --- /dev/null +++ b/tools/aqua-trial/analyze.mjs @@ -0,0 +1,95 @@ +#!/usr/bin/env node +// Dependency-free report over one or more trial exports: per-variant mean/spread of the "does it land?" rating, +// and whether render peak / rms predicted the ratings. Usage: node analyze.mjs export1.json [export2.json ...] +// Pure functions are exported for test.mjs; the CLI runs only when this file is the entry point. +import { readFileSync } from "node:fs"; +import { pathToFileURL } from "node:url"; +import { rng, shuffle, SCHEMA } from "./logic.mjs"; + +export const mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length; +export const sd = (xs) => (xs.length < 2 ? NaN : Math.sqrt(xs.reduce((a, x) => a + (x - mean(xs)) ** 2, 0) / (xs.length - 1))); + +export function pearson(xs, ys) { + const mx = mean(xs), my = mean(ys); + let sxy = 0, sxx = 0, syy = 0; + xs.forEach((x, i) => { sxy += (x - mx) * (ys[i] - my); sxx += (x - mx) ** 2; syy += (ys[i] - my) ** 2; }); + return sxx === 0 || syy === 0 ? NaN : sxy / Math.sqrt(sxx * syy); +} + +// Average ranks (ties share the mean rank), so Spearman is Pearson over ranks. +export function ranks(xs) { + const order = xs.map((v, i) => [v, i]).sort((a, b) => a[0] - b[0]); + const r = new Array(xs.length); + for (let i = 0; i < order.length;) { + let j = i; + while (j + 1 < order.length && order[j + 1][0] === order[i][0]) j++; + for (let k = i; k <= j; k++) r[order[k][1]] = (i + j) / 2 + 1; + i = j + 1; + } + return r; +} +export const spearman = (xs, ys) => pearson(ranks(xs), ranks(ys)); + +// Two-sided permutation p-value for Spearman rho; seeded so the report is reproducible. +export function permutationP(xs, ys, rho, rounds = 5000) { + if (!Number.isFinite(rho)) return NaN; + const rand = rng(12345); + let hits = 0; + for (let i = 0; i < rounds; i++) if (Math.abs(spearman(xs, shuffle(ys, rand))) >= Math.abs(rho) - 1e-12) hits++; + return (hits + 1) / (rounds + 1); +} + +export function predictor(records, key) { + const xs = records.map((r) => r[key]), ys = records.map((r) => r.rating); + const rho = spearman(xs, ys); + const p = permutationP(xs, ys, rho); + // Threshold chosen before any data exists: |rho| >= 0.5 and p < 0.05. With few records this is deliberately hard to meet. + const predicts = Number.isFinite(rho) && Math.abs(rho) >= 0.5 && p < 0.05; + return { key, n: records.length, rho, p, predicts }; +} + +export function analyze(exports) { + const records = exports.flatMap((e, i) => e.records.map((r) => ({ ...r, listener: i }))); + const byVariant = new Map(); + for (const r of records) (byVariant.get(r.variant) ?? byVariant.set(r.variant, []).get(r.variant)).push(r); + const variants = [...byVariant.entries()].map(([id, rs]) => { + const ratings = rs.map((r) => r.rating); + const words = {}; + for (const r of rs) { const w = r.word.toLowerCase(); words[w] = (words[w] ?? 0) + 1; } + return { + id, noise: rs[0].params.noise, n: ratings.length, mean: mean(ratings), sd: sd(ratings), + min: Math.min(...ratings), max: Math.max(...ratings), + peak: mean(rs.map((r) => r.peak)), rms: mean(rs.map((r) => r.rms)), words, + }; + }).sort((a, b) => b.noise - a.noise); + const predictors = ["peak", "rms"].map((k) => predictor(records, k)); + // Context: the manipulated variable itself, so a peak/rms "prediction" can be told apart from noise-amount doing the work. + const noise = predictor(records.map((r) => ({ ...r, noise: r.params.noise })), "noise"); + return { listeners: exports.length, records: records.length, variants, predictors, noise }; +} + +const f = (x, d = 3) => (Number.isFinite(x) ? x.toFixed(d) : "n/a"); + +export function format(rep) { + const out = [`${rep.listeners} listener export(s), ${rep.records} ratings`, "", "variant noise% n mean sd min max peak rms words"]; + for (const v of rep.variants) { + const words = Object.entries(v.words).sort((a, b) => b[1] - a[1]).map(([w, c]) => (c > 1 ? `${w}x${c}` : w)).join(","); + out.push(`${v.id.padEnd(11)} ${String(v.noise).padStart(5)} ${String(v.n).padStart(4)} ${f(v.mean, 2).padStart(6)} ${f(v.sd, 2).padStart(6)} ${String(v.min).padStart(4)} ${String(v.max).padStart(3)} ${f(v.peak).padStart(7)} ${f(v.rms).padStart(7)} ${words}`); + } + out.push("", "Did render level predict the rating? (Spearman rho over individual ratings, permutation p; predicts = |rho|>=0.5 and p<0.05)"); + for (const p of rep.predictors) out.push(` ${p.key.padEnd(5)} rho ${f(p.rho, 2).padStart(6)} p ${f(p.p, 4)} n ${p.n} -> ${p.predicts ? "PREDICTS" : "no evidence it predicts"}`); + out.push(` (context) noise% rho ${f(rep.noise.rho, 2)} p ${f(rep.noise.p, 4)}`); + out.push("", "Peak and rms fall with noise amount here (noise is not loudness-compensated), so a level effect and a noise effect are confounded, and this script does not separate them."); + return out.join("\n"); +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + const files = process.argv.slice(2); + if (!files.length) { console.error("usage: node analyze.mjs export.json [more.json ...]"); process.exit(2); } + const exports = files.map((p) => { + const e = JSON.parse(readFileSync(p, "utf8")); + if (e.schema !== SCHEMA) throw new Error(`${p}: schema ${e.schema}, expected ${SCHEMA}`); + return e; + }); + console.log(format(analyze(exports))); +} diff --git a/tools/aqua-trial/build.mjs b/tools/aqua-trial/build.mjs new file mode 100644 index 0000000..fa5c41f --- /dev/null +++ b/tools/aqua-trial/build.mjs @@ -0,0 +1,27 @@ +// Assembles dist/ (the static trial site): web/, logic.mjs, the trial patch, and the faustwasm runtime copied from +// the sibling aqua-playground's node_modules (run `npm install` there first). Prints a content hash for the +// publish path: minds.gamecult.org/aqua/trial-/. Usage: node build.mjs [outDir] +import { cpSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs"; +import { createHash } from "node:crypto"; +import { dirname, join, relative, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const out = resolve(process.argv[2] ?? join(here, "dist")); +const play = join(here, "../aqua-playground"); +const fw = join(play, "node_modules/@grame/faustwasm"); +rmSync(out, { recursive: true, force: true }); +mkdirSync(join(out, "vendor/faustwasm"), { recursive: true }); +cpSync(join(here, "web"), out, { recursive: true }); +cpSync(join(here, "logic.mjs"), join(out, "logic.mjs")); +cpSync(join(here, "thruster-trial.dsp"), join(out, "thruster-trial.dsp")); +cpSync(join(play, "web/ui.js"), join(out, "ui.js")); +cpSync(join(fw, "dist/esm/index.js"), join(out, "vendor/faustwasm/index.js")); +cpSync(join(fw, "COPYING.txt"), join(out, "vendor/faustwasm/COPYING.txt")); +for (const f of ["libfaust-wasm.js", "libfaust-wasm.wasm", "libfaust-wasm.data"]) + cpSync(join(fw, "libfaust-wasm", f), join(out, "vendor/libfaust-wasm", f)); + +const files = (d) => readdirSync(d).sort().flatMap((n) => (statSync(join(d, n)).isDirectory() ? files(join(d, n)) : [join(d, n)])); +const h = createHash("sha256"); +for (const f of files(out)) { h.update(relative(out, f)); h.update(readFileSync(f)); } +console.log(`built ${out}\nhash ${h.digest("hex").slice(0, 7)}`); diff --git a/tools/aqua-trial/logic.mjs b/tools/aqua-trial/logic.mjs new file mode 100644 index 0000000..aa24dd1 --- /dev/null +++ b/tools/aqua-trial/logic.mjs @@ -0,0 +1,81 @@ +// Trial logic shared by the browser page (web/trial.js) and the node tests: variants, the blinded pair design, +// render statistics, one-word validation and the export document. No DOM, no Faust import; the renderer is passed in. + +export const SCHEMA = "aquasynth.listening-trial.v1"; +export const PATCH = "thruster-trial"; +export const RPM = 600; +export const NOISE_PERCENTS = [100, 50, 20, 0]; +export const SECONDS = 4; + +export const variants = () => NOISE_PERCENTS.map((noise) => ({ id: `noise${noise}`, params: { rpm: RPM, noise } })); + +// mulberry32: small seeded PRNG so a session (and its tests) can be replayed from the seed. +export function rng(seed) { + let a = seed >>> 0; + return () => { + a = (a + 0x6d2b79f5) >>> 0; + let t = a; + t = Math.imul(t ^ (t >>> 15), t | 1); + t ^= t + Math.imul(t ^ (t >>> 7), t | 61); + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +} + +export function shuffle(items, rand) { + const a = [...items]; + for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(rand() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } + return a; +} + +// Every unordered pair of variants once, pair order shuffled, A/B assignment coin-flipped per pair. +// Each variant therefore appears in n-1 trials, and which one is A is independent of which one is quieter. +export function makeDesign(seed, vs = variants()) { + const rand = rng(seed); + const pairs = []; + for (let i = 0; i < vs.length; i++) for (let j = i + 1; j < vs.length; j++) pairs.push(rand() < 0.5 ? [vs[i], vs[j]] : [vs[j], vs[i]]); + return shuffle(pairs, rand).map(([a, b]) => ({ A: a, B: b })); +} + +export function stats(samples) { + let peak = 0, sq = 0, bad = 0; + for (const v of samples) { if (!Number.isFinite(v)) { bad++; continue; } peak = Math.max(peak, Math.abs(v)); sq += v * v; } + return { peak, rms: Math.sqrt(sq / Math.max(1, samples.length - bad)), nonFinite: bad }; +} + +// `generator` is a compiled faustwasm FaustMonoDspGenerator; `controls` are controlsOf(...) of its JSON. +export async function renderVariant(generator, controls, variant, sampleRate, seconds = SECONDS) { + const p = await generator.createOfflineProcessor(sampleRate, 512); + for (const [label, value] of Object.entries(variant.params)) { + const c = controls.find((x) => x.label === label); + if (!c) throw new Error(`patch has no control "${label}"`); + p.setParamValue(c.address, value); + } + const samples = p.render(null, Math.round(sampleRate * seconds))[0]; + return { samples, ...stats(samples) }; +} + +// One free word: trimmed, no inner whitespace, bounded. Returns the word or null. +export function cleanWord(text) { + const w = String(text ?? "").trim(); + return w.length > 0 && w.length <= 32 && !/\s/.test(w) ? w : null; +} + +export const validRating = (n) => Number.isInteger(n) && n >= 1 && n <= 5; + +// answers: [{ A: {rating, word, time, plays}, B: {...} }] aligned with design. +export function buildExport({ seed, design, renders, answers, sampleRate, userAgent, exportedAt }) { + const records = []; + design.forEach((trial, t) => { + for (const pos of ["A", "B"]) { + const a = answers[t]?.[pos]; + if (!a) continue; + const v = trial[pos]; + records.push({ + trial: t + 1, position: pos, patch: PATCH, variant: v.id, params: v.params, + peak: renders[v.id].peak, rms: renders[v.id].rms, + rating: a.rating, word: a.word, time: a.time, plays: a.plays, + }); + } + }); + return { schema: SCHEMA, patch: PATCH, seed, sampleRate, userAgent, exportedAt, seconds: SECONDS, records }; +} diff --git a/tools/aqua-trial/package.json b/tools/aqua-trial/package.json new file mode 100644 index 0000000..1edf509 --- /dev/null +++ b/tools/aqua-trial/package.json @@ -0,0 +1,7 @@ +{ + "name": "aqua-trial", + "private": true, + "type": "module", + "description": "Blinded A/B listening trial for AquaSynth patches (thruster noise-amount sweep). Static page; analysis script is dependency-free.", + "scripts": { "build": "node build.mjs", "test": "node test.mjs" } +} diff --git a/tools/aqua-trial/test.mjs b/tools/aqua-trial/test.mjs new file mode 100644 index 0000000..7570a86 --- /dev/null +++ b/tools/aqua-trial/test.mjs @@ -0,0 +1,174 @@ +// Node checks of the trial: design, validation, export shape, analyzer maths, and (through the same faustwasm runtime +// the page loads) the trial patch itself. It never runs the page in a browser and never plays or hears anything. +// Usage: (cd ../aqua-playground && npm ci) && node build.mjs && node test.mjs +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { makeDesign, variants, stats, cleanWord, validRating, buildExport, renderVariant, rng, shuffle, SCHEMA, PATCH } from "./logic.mjs"; +import { analyze, format, mean, sd, spearman, ranks, pearson } from "./analyze.mjs"; + +const here = dirname(fileURLToPath(import.meta.url)); +const dist = resolve(process.argv[2] ?? join(here, "dist")); +let n = 0; +const t = async (name, fn) => { await fn(); n++; console.log(`ok ${name}`); }; + +await t("design: every unordered pair once, both positions used, replayable from the seed", () => { + const d = makeDesign(7); + assert.equal(d.length, 6); + const keys = d.map((x) => [x.A.id, x.B.id].sort().join("|")); + assert.equal(new Set(keys).size, 6); + for (const v of variants()) assert.equal(d.filter((x) => x.A.id === v.id || x.B.id === v.id).length, 3); + assert.deepEqual(makeDesign(7), d); + // position is not tied to variant: over many seeds each variant lands in A about half the time + const inA = Object.fromEntries(variants().map((v) => [v.id, 0])); + for (let s = 0; s < 2000; s++) for (const x of makeDesign(s)) inA[x.A.id]++; + for (const c of Object.values(inA)) assert.ok(Math.abs(c / 6000 - 0.5) < 0.05, `A share ${c / 6000}`); + assert.notDeepEqual(makeDesign(1).map((x) => x.A.id), makeDesign(2).map((x) => x.A.id)); +}); + +await t("variants: rpm 600 and noise 100/50/20/0", () => { + assert.deepEqual(variants().map((v) => v.params), [100, 50, 20, 0].map((noise) => ({ rpm: 600, noise }))); +}); + +await t("stats: peak, rms, non-finite counted and excluded", () => { + const s = stats([0, 1, -1, 0]); + assert.equal(s.peak, 1); assert.ok(Math.abs(s.rms - Math.sqrt(0.5)) < 1e-12); + assert.equal(stats([1, NaN, Infinity]).nonFinite, 2); +}); + +await t("one word: trimmed, no inner whitespace, bounded; ratings 1-5 integers", () => { + assert.equal(cleanWord(" hollow "), "hollow"); + for (const bad of ["", " ", "two words", "a".repeat(33), null, undefined]) assert.equal(cleanWord(bad), null); + assert.deepEqual([0, 1, 5, 6, 2.5, "3"].map(validRating), [false, true, true, false, false, false]); +}); + +const fakeExport = (seed, rate) => { + const design = makeDesign(seed), rand = rng(seed); + const renders = { noise100: { peak: 0.19, rms: 0.073 }, noise50: { peak: 0.15, rms: 0.05 }, noise20: { peak: 0.12, rms: 0.04 }, noise0: { peak: 0.1, rms: 0.035 } }; + const answers = design.map(() => Object.fromEntries(["A", "B"].map((p) => [p, { rating: 1 + Math.floor(rand() * 5), word: "w", time: "2026-11-04T00:00:00Z", plays: 1 }]))); + return { design, renders, answers, doc: buildExport({ seed, design, renders, answers, sampleRate: rate, userAgent: "test-ua", exportedAt: "2026-11-04T00:00:00Z" }) }; +}; + +await t("export: one record per heard sound with the required fields", () => { + const { doc, design, answers } = fakeExport(3, 44100); + assert.equal(doc.schema, SCHEMA); assert.equal(doc.sampleRate, 44100); assert.equal(doc.userAgent, "test-ua"); + assert.equal(doc.records.length, 12); + for (const r of doc.records) for (const k of ["patch", "params", "rating", "word", "time", "peak", "rms", "variant", "trial", "position"]) assert.ok(r[k] !== undefined, k); + const r = doc.records[0]; + assert.equal(r.variant, design[0].A.id); assert.equal(r.rating, answers[0].A.rating); assert.equal(r.patch, PATCH); + assert.deepEqual(JSON.parse(JSON.stringify(doc)), doc); +}); + +await t("export: unanswered trials are omitted, not invented", () => { + const { design, renders, answers } = fakeExport(3, 48000); + const doc = buildExport({ seed: 3, design, renders, answers: answers.slice(0, 2), sampleRate: 48000, userAgent: "u", exportedAt: "x" }); + assert.equal(doc.records.length, 4); +}); + +await t("analyze maths: ranks with ties, spearman, pearson, sd", () => { + assert.deepEqual(ranks([10, 20, 20, 30]), [1, 2.5, 2.5, 4]); + assert.equal(spearman([1, 2, 3, 4], [10, 20, 30, 40]), 1); + assert.equal(spearman([1, 2, 3, 4], [4, 3, 2, 1]), -1); + assert.ok(Number.isNaN(pearson([1, 1, 1], [1, 2, 3]))); + assert.ok(Math.abs(sd([2, 4, 4, 4, 5, 5, 7, 9]) - 2.138089935) < 1e-8); + assert.equal(mean([1, 2, 3]), 2); +}); + +const synth = (ratingOf, listeners = 12) => { + const exports = []; + for (let l = 0; l < listeners; l++) { + const e = fakeExport(100 + l, 48000).doc; + e.records.forEach((r) => { r.rating = ratingOf(r, l); }); + exports.push(e); + } + return exports; +}; + +await t("analyze: ratings that follow rms are reported as predicted by peak and rms", () => { + const rep = analyze(synth((r) => (r.rms > 0.06 ? 5 : r.rms > 0.045 ? 4 : r.rms > 0.037 ? 2 : 1))); + assert.equal(rep.records, 144); + assert.deepEqual(rep.variants.map((v) => v.noise), [100, 50, 20, 0]); + assert.ok(rep.variants[0].mean > rep.variants[3].mean); + for (const p of rep.predictors) assert.ok(p.predicts && p.rho > 0.9, `${p.key} rho ${p.rho}`); + assert.match(format(rep), /PREDICTS/); +}); + +await t("analyze: ratings unrelated to level are not reported as predicted", () => { + const rand = rng(99); + const rep = analyze(synth(() => 1 + Math.floor(rand() * 5))); + for (const p of rep.predictors) assert.ok(!p.predicts, `${p.key} rho ${p.rho} p ${p.p}`); + assert.match(format(rep), /no evidence/); +}); + +await t("analyze: per-variant mean and spread are computed per variant", () => { + const rep = analyze(synth((r) => (r.params.noise === 100 ? 5 : r.params.noise === 50 ? 3 : 1 + (r.trial % 2) * 2))); + const by = Object.fromEntries(rep.variants.map((v) => [v.id, v])); + assert.equal(by.noise100.mean, 5); assert.equal(by.noise100.sd, 0); + assert.equal(by.noise50.mean, 3); + assert.ok(by.noise20.sd > 0 && by.noise20.min === 1 && by.noise20.max === 3); +}); + +await t("analyze CLI: runs on export files and rejects a foreign schema", async () => { + const { execFileSync, spawnSync } = await import("node:child_process"); + const { mkdtempSync, writeFileSync } = await import("node:fs"); + const { tmpdir } = await import("node:os"); + const d = mkdtempSync(join(tmpdir(), "trial-")); + const a = join(d, "a.json"), b = join(d, "b.json"); + writeFileSync(a, JSON.stringify(fakeExport(5, 48000).doc)); + writeFileSync(b, JSON.stringify({ ...fakeExport(5, 48000).doc, schema: "other" })); + assert.match(execFileSync("node", [join(here, "analyze.mjs"), a], { encoding: "utf8" }), /1 listener export/); + assert.notEqual(spawnSync("node", [join(here, "analyze.mjs"), b]).status, 0); + assert.equal(spawnSync("node", [join(here, "analyze.mjs")]).status, 2); +}); + +// --- the patch, through the runtime the page loads --- +const { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } = + await import(pathToFileURL(join(dist, "vendor/faustwasm/index.js")).href); +const { controlsOf } = await import(pathToFileURL(join(dist, "ui.js")).href); +const compiler = new FaustCompiler(new LibFaust(await instantiateFaustModuleFromFile(join(dist, "vendor/libfaust-wasm/libfaust-wasm.js")))); +const compile = async (path, name) => { + const g = new FaustMonoDspGenerator(); + assert.ok(await g.compile(compiler, name, readFileSync(path, "utf8"), "-ftz 2"), compiler.getErrorMessage()); + return { g, controls: controlsOf(JSON.parse(g.factory.json)) }; +}; +const trial = await compile(join(here, "thruster-trial.dsp"), "thruster_trial"); +const base = await compile(join(here, "../../patches/thruster/thruster.dsp"), "thruster"); +const SR = 48000; + +await t("patch: exposes rpm and noise controls", () => { + assert.ok(trial.controls.some((c) => c.label === "noise" && c.init === 100)); + assert.ok(trial.controls.some((c) => c.label === "rpm")); +}); + +await t("patch: noise=100 is sample-identical to patches/thruster/thruster.dsp at rpm 600", async () => { + const a = await renderVariant(trial.g, trial.controls, { params: { rpm: 600, noise: 100 } }, SR, 2); + const b = await renderVariant(base.g, base.controls, { params: { rpm: 600 } }, SR, 2); + assert.equal(a.samples.length, b.samples.length); + let maxDiff = 0; for (let i = 0; i < a.samples.length; i++) maxDiff = Math.max(maxDiff, Math.abs(a.samples[i] - b.samples[i])); + assert.ok(maxDiff < 1e-6, `max diff ${maxDiff}`); +}); + +await t("patch: all four variants finite and non-silent, rendered at 44100 and 48000, noise 0 is deterministic", async () => { + for (const rate of [44100, 48000]) { + const seen = []; + for (const v of variants()) { + const r = await renderVariant(trial.g, trial.controls, v, rate); + assert.equal(r.samples.length, rate * 4); + assert.equal(r.nonFinite, 0); assert.ok(r.peak > 1e-3, `${v.id} peak ${r.peak}`); + seen.push(r); + } + console.log(" " + variants().map((v, i) => `${v.id} peak ${seen[i].peak.toFixed(4)} rms ${seen[i].rms.toFixed(4)}`).join(" | ") + ` @${rate}`); + } + const x = await renderVariant(trial.g, trial.controls, variants()[3], SR, 1), y = await renderVariant(trial.g, trial.controls, variants()[3], SR, 1); + assert.deepEqual(x.samples, y.samples); +}); + +await t("patch: noise genuinely removes the noise layers (rms falls monotonically 100>50>20>0, rumble remains)", async () => { + const rms = []; + for (const v of variants()) rms.push((await renderVariant(trial.g, trial.controls, v, SR)).rms); + assert.ok(rms[0] > rms[1] && rms[1] > rms[2] && rms[2] > rms[3], rms.join(" > ")); + assert.ok(rms[3] > 1e-3); +}); + +console.log(`${n} passed`); diff --git a/tools/aqua-trial/thruster-trial.dsp b/tools/aqua-trial/thruster-trial.dsp new file mode 100644 index 0000000..672ffd8 --- /dev/null +++ b/tools/aqua-trial/thruster-trial.dsp @@ -0,0 +1,32 @@ +// thruster-trial: patches/thruster/thruster.dsp plus a `noise` control (percent, default 100) for the listening trial. +// `noise` scales the two noise-driven layers (rasp, rattle) and leaves the rumble (the tone) alone, so lowering it +// moves the mix tone-forward. At noise=100 it is the same signal as thruster.dsp (test.mjs asserts this sample for sample). +// Compile as Faust source; it is not a .aqua script. +// Control: rpm (300..6000). Rotor tone = 28 Hz + rpm*0.025 (about 36..180 Hz); three blades chop the rasp at 3x that. +declare name "thruster_trial"; +import("stdfaust.lib"); + +noise_amt = hslider("noise", 100, 0, 100, 1) / 100; +rpm = hslider("rpm", 1200, 300, 6000, 1) : si.smooth(ba.tau2pole(0.2)); +load = (rpm - 300) / 5700; +shaft = 28 + rpm * 0.025; + +// effort: slow random wander of the shaft speed +wander = no.noise : fi.lowpass(2, 5) : *(0.35); +f0 = shaft * (1 + 0.04 * wander); + +// low rumble: saw at shaft speed plus a square a sub-octave down, low-passed +rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 * shaft); + +// blade pass: rasp noise chopped at 3x shaft, band tracks rpm +chop = 0.5 + 0.5 * os.osc(f0 * 3) ^ 2; +rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); + +// brittle hull: high-Q modes rattled by noise, louder with load; tanh on the rattle alone keeps ring-up spikes from setting the peak +mode(f, q) = no.noise : fi.resonbp(f, q, 1); +rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode(467, 16) + 0.4 * mode(1130, 14)) * (0.1 + 0.9 * load ^ 2) * 3 : *(4) : ma.tanh : /(4); + +mix = rumble * (0.5 + 0.5 * load) + noise_amt * (rasp * (0.3 + 1.5 * load) + rattle); +// drive falls only gently with load so tanh stays out of saturation while high rpm still ends up louder than low rpm +// final 0.425 trim keeps peak under 0.4 at rpm 4800 +process = mix * (0.4 + 0.6 * load) * (0.9 - 0.5 * load) : ma.tanh : *(0.425); diff --git a/tools/aqua-trial/web/index.html b/tools/aqua-trial/web/index.html new file mode 100644 index 0000000..0b96d43 --- /dev/null +++ b/tools/aqua-trial/web/index.html @@ -0,0 +1,49 @@ + + + + + + AquaSynth listening trial + + + +
+

AquaSynth lab

+

Does it land?

+

Six short comparisons of a synthesized spacecraft thruster. You hear two renders, A and B, in random order, and say how well each one lands: 1 means it does not, 5 means it does. Then give each a single word. Use headphones or speakers at a comfortable level, and a quiet room if you can.

+ + + + + + +
+ + + diff --git a/tools/aqua-trial/web/styles.css b/tools/aqua-trial/web/styles.css new file mode 100644 index 0000000..8c1ca47 --- /dev/null +++ b/tools/aqua-trial/web/styles.css @@ -0,0 +1,21 @@ +:root { color-scheme: dark; --bg:#0b1418; --fg:#d7e6ea; --dim:#7f9aa3; --acc:#3fc1c9; --line:#1f3640; } +* { box-sizing: border-box; } +body { margin:0; background:var(--bg); color:var(--fg); font:16px/1.5 system-ui, sans-serif; } +main { max-width:760px; margin:0 auto; padding:24px; } +.eyebrow { margin:0; color:var(--acc); text-transform:uppercase; letter-spacing:.12em; font-size:12px; } +h1 { margin:.1em 0 .2em; } h2 { font-size:18px; } +.lede, .hint, #status { color:var(--dim); } +.consent { display:flex; gap:10px; align-items:flex-start; margin-bottom:12px; } +.consent input { margin-top:5px; } +button { background:#10242b; color:var(--fg); border:1px solid var(--line); padding:8px 18px; border-radius:4px; font:inherit; } +button:hover:not(:disabled) { border-color:var(--acc); } button:disabled { opacity:.4; } +.pair { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px; } +@media (max-width:560px) { .pair { grid-template-columns:1fr; } } +fieldset { border:1px solid var(--line); border-radius:6px; display:grid; gap:12px; padding:14px; } +legend { color:var(--acc); padding:0 6px; } +.stars { display:flex; gap:6px; } +.stars label { flex:1; text-align:center; border:1px solid var(--line); border-radius:4px; padding:6px 0; cursor:pointer; } +.stars input { position:absolute; opacity:0; } +.stars label:has(input:checked) { background:var(--acc); color:#06161a; border-color:var(--acc); } +.stars label:has(input:focus-visible) { outline:2px solid var(--acc); } +.word { background:#071013; color:var(--fg); border:1px solid var(--line); border-radius:4px; padding:8px; font:inherit; } diff --git a/tools/aqua-trial/web/trial.js b/tools/aqua-trial/web/trial.js new file mode 100644 index 0000000..ef4e721 --- /dev/null +++ b/tools/aqua-trial/web/trial.js @@ -0,0 +1,109 @@ +// Browser glue for the listening trial. The decisions (design, statistics, validation, export shape) live in +// ../logic.mjs and are tested in node; this file only touches the DOM, the AudioContext and the download. +// Nothing here makes a network request after the page assets load, and nothing is written to storage. +import { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } from "./vendor/faustwasm/index.js"; +import { controlsOf } from "./ui.js"; +import { variants, makeDesign, renderVariant, cleanWord, validRating, buildExport, PATCH } from "./logic.mjs"; + +const $ = (s, root = document) => root.querySelector(s); +const status = (t) => { $("#status").textContent = t; }; +const seed = crypto.getRandomValues(new Uint32Array(1))[0]; +const design = makeDesign(seed); +const answers = []; +const renders = {}; // variant id -> { buffer, peak, rms } +let ctx, source, current = 0, plays = { A: 0, B: 0 }; + +$("#agree").onchange = () => { $("#start").disabled = !$("#agree").checked; }; +$("#start").onclick = start; +$("#stop").onclick = stopSound; +$("#next").onclick = next; +$("#export").onclick = exportJson; +for (const fs of document.querySelectorAll("fieldset")) { + const stars = $(".stars", fs); + for (let n = 1; n <= 5; n++) { + const label = document.createElement("label"); + const input = Object.assign(document.createElement("input"), { type: "radio", name: `rate-${fs.dataset.pos}`, value: n }); + input.onchange = refresh; + label.append(input, String(n)); + stars.append(label); + } + $(".word", fs).oninput = refresh; + $(".play", fs).onclick = () => play(fs.dataset.pos); +} + +async function start() { + $("#start").disabled = true; $("#agree").disabled = true; + try { + ctx = new AudioContext(); // created inside the click so the browser allows playback + status("Loading the Faust compiler…"); + const compiler = new FaustCompiler(new LibFaust(await instantiateFaustModuleFromFile("./vendor/libfaust-wasm/libfaust-wasm.js"))); + const g = new FaustMonoDspGenerator(); + if (!await g.compile(compiler, "thruster_trial", await (await fetch(`./${PATCH}.dsp`)).text(), "-ftz 2")) throw new Error(compiler.getErrorMessage()); + const controls = controlsOf(JSON.parse(g.factory.json)); + for (const v of variants()) { + status(`Rendering ${Object.keys(renders).length + 1} of ${variants().length}…`); + const r = await renderVariant(g, controls, v, ctx.sampleRate); + if (r.nonFinite || !(r.peak > 1e-4)) throw new Error(`render ${v.id} is silent or not finite`); + const buffer = ctx.createBuffer(1, r.samples.length, ctx.sampleRate); + buffer.copyToChannel(r.samples, 0); + renders[v.id] = { buffer, peak: r.peak, rms: r.rms }; + } + } catch (err) { status(`Could not start: ${err}`); console.error(err); return; } + $("#consent").hidden = true; $("#trial").hidden = false; + show(); +} + +function show() { + plays = { A: 0, B: 0 }; + $("#progress").textContent = `Comparison ${current + 1} of ${design.length}`; + for (const fs of document.querySelectorAll("fieldset")) { + for (const i of fs.querySelectorAll(".stars input")) i.checked = false; + $(".word", fs).value = ""; + } + refresh(); +} + +function read(pos) { + const fs = $(`fieldset[data-pos="${pos}"]`); + const checked = $(".stars input:checked", fs); + return { rating: checked ? Number(checked.value) : null, word: cleanWord($(".word", fs).value) }; +} + +function refresh() { + const a = read("A"), b = read("B"); + $("#next").disabled = !(validRating(a.rating) && a.word && validRating(b.rating) && b.word && plays.A && plays.B); +} + +function play(pos) { + stopSound(); + ctx.resume(); + const { buffer } = renders[design[current][pos].id]; + source = ctx.createBufferSource(); source.buffer = buffer; + // 10 ms ramps so the start and stop of the file are not a click that colours the rating. + const g = ctx.createGain(), t = ctx.currentTime, end = t + buffer.duration; + g.gain.setValueAtTime(0, t); g.gain.linearRampToValueAtTime(0.8, t + 0.01); + g.gain.setValueAtTime(0.8, end - 0.01); g.gain.linearRampToValueAtTime(0, end); + source.connect(g).connect(ctx.destination); source.start(t); + plays[pos]++; refresh(); +} + +function stopSound() { try { source?.stop(); } catch {} source = null; } + +function next() { + stopSound(); + const time = new Date().toISOString(); + answers[current] = {}; + for (const pos of ["A", "B"]) answers[current][pos] = { ...read(pos), time, plays: plays[pos] }; + if (++current < design.length) return show(); + $("#trial").hidden = true; $("#done").hidden = false; +} + +function exportJson() { + const doc = buildExport({ + seed, design, answers, sampleRate: ctx.sampleRate, userAgent: navigator.userAgent, exportedAt: new Date().toISOString(), + renders: Object.fromEntries(Object.entries(renders).map(([id, r]) => [id, { peak: r.peak, rms: r.rms }])), + }); + const url = URL.createObjectURL(new Blob([JSON.stringify(doc, null, 2)], { type: "application/json" })); + const a = Object.assign(document.createElement("a"), { href: url, download: `aquasynth-trial-${seed.toString(16)}.json` }); + a.click(); URL.revokeObjectURL(url); +} From 45f62277f0e195480a8dd0934df41d286957468d Mon Sep 17 00:00:00 2001 From: Aqua Date: Wed, 4 Nov 2026 21:34:34 +0000 Subject: [PATCH 010/124] Rename logic.mjs to logic.js so static hosts serve a JavaScript MIME type Co-Authored-By: Claude Sonnet 5.5 --- tools/aqua-trial/README.md | 2 +- tools/aqua-trial/analyze.mjs | 2 +- tools/aqua-trial/build.mjs | 4 ++-- tools/aqua-trial/{logic.mjs => logic.js} | 0 tools/aqua-trial/test.mjs | 2 +- tools/aqua-trial/web/trial.js | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) rename tools/aqua-trial/{logic.mjs => logic.js} (100%) diff --git a/tools/aqua-trial/README.md b/tools/aqua-trial/README.md index 0870e58..9f14194 100644 --- a/tools/aqua-trial/README.md +++ b/tools/aqua-trial/README.md @@ -16,7 +16,7 @@ the patch through the same faustwasm runtime the page loads (`node test.mjs`, 15 rattle layers only; the rumble (tone) is untouched, so lowering it moves the mix tone-forward. That reading of "tone-forward mix" is this author's; at 100 the signal equals the thruster (asserted sample for sample). Variants: rpm 600, noise 100 / 50 / 20 / 0. Not loudness-matched, so level and noise are confounded by design. -- `logic.mjs`: design, statistics, validation and export shape (shared by page and tests). +- `logic.js`: design, statistics, validation and export shape (shared by page and tests). - `analyze.mjs`: dependency-free. `node analyze.mjs export1.json [export2.json ...]` prints per-variant n, mean, sd, min/max, peak, rms, words, and whether peak / rms predicted the ratings (Spearman rho, permutation p; "predicts" means |rho| >= 0.5 and p < 0.05, fixed before any data). diff --git a/tools/aqua-trial/analyze.mjs b/tools/aqua-trial/analyze.mjs index 52b73ea..0414d4c 100644 --- a/tools/aqua-trial/analyze.mjs +++ b/tools/aqua-trial/analyze.mjs @@ -4,7 +4,7 @@ // Pure functions are exported for test.mjs; the CLI runs only when this file is the entry point. import { readFileSync } from "node:fs"; import { pathToFileURL } from "node:url"; -import { rng, shuffle, SCHEMA } from "./logic.mjs"; +import { rng, shuffle, SCHEMA } from "./logic.js"; export const mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length; export const sd = (xs) => (xs.length < 2 ? NaN : Math.sqrt(xs.reduce((a, x) => a + (x - mean(xs)) ** 2, 0) / (xs.length - 1))); diff --git a/tools/aqua-trial/build.mjs b/tools/aqua-trial/build.mjs index fa5c41f..ac741ee 100644 --- a/tools/aqua-trial/build.mjs +++ b/tools/aqua-trial/build.mjs @@ -1,4 +1,4 @@ -// Assembles dist/ (the static trial site): web/, logic.mjs, the trial patch, and the faustwasm runtime copied from +// Assembles dist/ (the static trial site): web/, logic.js, the trial patch, and the faustwasm runtime copied from // the sibling aqua-playground's node_modules (run `npm install` there first). Prints a content hash for the // publish path: minds.gamecult.org/aqua/trial-/. Usage: node build.mjs [outDir] import { cpSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs"; @@ -13,7 +13,7 @@ const fw = join(play, "node_modules/@grame/faustwasm"); rmSync(out, { recursive: true, force: true }); mkdirSync(join(out, "vendor/faustwasm"), { recursive: true }); cpSync(join(here, "web"), out, { recursive: true }); -cpSync(join(here, "logic.mjs"), join(out, "logic.mjs")); +cpSync(join(here, "logic.js"), join(out, "logic.js")); cpSync(join(here, "thruster-trial.dsp"), join(out, "thruster-trial.dsp")); cpSync(join(play, "web/ui.js"), join(out, "ui.js")); cpSync(join(fw, "dist/esm/index.js"), join(out, "vendor/faustwasm/index.js")); diff --git a/tools/aqua-trial/logic.mjs b/tools/aqua-trial/logic.js similarity index 100% rename from tools/aqua-trial/logic.mjs rename to tools/aqua-trial/logic.js diff --git a/tools/aqua-trial/test.mjs b/tools/aqua-trial/test.mjs index 7570a86..9c519e8 100644 --- a/tools/aqua-trial/test.mjs +++ b/tools/aqua-trial/test.mjs @@ -5,7 +5,7 @@ import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; -import { makeDesign, variants, stats, cleanWord, validRating, buildExport, renderVariant, rng, shuffle, SCHEMA, PATCH } from "./logic.mjs"; +import { makeDesign, variants, stats, cleanWord, validRating, buildExport, renderVariant, rng, shuffle, SCHEMA, PATCH } from "./logic.js"; import { analyze, format, mean, sd, spearman, ranks, pearson } from "./analyze.mjs"; const here = dirname(fileURLToPath(import.meta.url)); diff --git a/tools/aqua-trial/web/trial.js b/tools/aqua-trial/web/trial.js index ef4e721..9c3f4f8 100644 --- a/tools/aqua-trial/web/trial.js +++ b/tools/aqua-trial/web/trial.js @@ -1,9 +1,9 @@ // Browser glue for the listening trial. The decisions (design, statistics, validation, export shape) live in -// ../logic.mjs and are tested in node; this file only touches the DOM, the AudioContext and the download. +// ../logic.js and are tested in node; this file only touches the DOM, the AudioContext and the download. // Nothing here makes a network request after the page assets load, and nothing is written to storage. import { instantiateFaustModuleFromFile, LibFaust, FaustCompiler, FaustMonoDspGenerator } from "./vendor/faustwasm/index.js"; import { controlsOf } from "./ui.js"; -import { variants, makeDesign, renderVariant, cleanWord, validRating, buildExport, PATCH } from "./logic.mjs"; +import { variants, makeDesign, renderVariant, cleanWord, validRating, buildExport, PATCH } from "./logic.js"; const $ = (s, root = document) => root.querySelector(s); const status = (t) => { $("#status").textContent = t; }; From d348a19ddd62cee1a6bb421d5386e2f6ab5e4464 Mon Sep 17 00:00:00 2001 From: Aqua Date: Thu, 5 Nov 2026 11:46:38 +0000 Subject: [PATCH 011/124] Docs: soundscape grammar names the Mimir harvest follow-up it could not see The follow-up is in force in Eureka's mind and names Mimir's bioacoustic research; the draft's earlier grep missed it. Section 4 stays recalled, not re-read, and the harvest stays owed. Co-Authored-By: Claude Sonnet 5.5 --- docs/soundscape-grammar.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/soundscape-grammar.md b/docs/soundscape-grammar.md index aed23cd..d37061d 100644 --- a/docs/soundscape-grammar.md +++ b/docs/soundscape-grammar.md @@ -13,18 +13,23 @@ grammar is drafted without them. Each is a place to reconcile before the doc is treated as in force. - `heimdall-body:follow_up:ratatoskr-creature-projection-v2`: `huginn view` - from instance `aqua` answers `absent`, and a search of the Heimdall checkout + from instance `aqua` answers `absent` (and `absent` from Eureka's mind on + 2026-11-05), and a search of the Heimdall checkout (`GameCult/Heimdall`, forge, 2026-11-02) found no file mentioning it. The constraints taken from the brief are used as stated there: coarse buckets, neutral overrides, activity comes from the Heimdall session. Section 2 is the place that must be reconciled against that follow-up's actual field list. - `ratatoskr:follow_up:symphony-grammar-harvest-mimir` (Mimir birdsong - research): also `absent` from aqua's mind, and `GameCult/Mimir` holds no - symphony or voice-separation note (grep of `notes/`, `research/`, `docs/`). + research): absent from aqua's mind, but it is in force in Eureka's mind + (read 2026-11-05, after this draft was written). It points at Mimir's + `docs/bioacoustic-timeline-watermark.md`, `research/bioacoustic-contestants-2026-05-24.md` + and `calibration/bioacoustic/` (at `c6f4541`), which this draft does not cite + and nobody has read for it. The earlier grep of `GameCult/Mimir` for a + symphony or voice-separation note found none; it did not look for bioacoustic research. Section 4 is therefore built from this repo's own `research/syrinx-modeling` plus the general auditory-scene-analysis and acoustic-niche literature named - there, *recalled, not re-read for this draft*. The harvest, when it exists, - replaces or confirms section 4; it is the likeliest thing to change. + there, *recalled, not re-read for this draft*. The harvest is still owed and + is the likeliest thing to change section 4. Context actually read: `docs/gamecult/ratatoskr-target.md` in `GameCult/Ratatoskr` at `b33d8de` (the agreement that one activity vocabulary drives both sound and From 46da9975dfd51552ac102472fa2fc545a14f1413 Mon Sep 17 00:00:00 2001 From: Aqua Date: Thu, 5 Nov 2026 11:46:43 +0000 Subject: [PATCH 012/124] Playground README: state plainly that it is unheard and unrun in a browser Co-Authored-By: Claude Sonnet 5.5 --- tools/aqua-playground/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/aqua-playground/README.md b/tools/aqua-playground/README.md index 3ecc87f..aa5da7f 100644 --- a/tools/aqua-playground/README.md +++ b/tools/aqua-playground/README.md @@ -3,6 +3,12 @@ Static, serverless audition page for AquaSynth patches. Pick a patch, read the Faust it lowers to, move the sliders the DSP itself declares, press Play. +**Status: unheard, and never run in a browser.** `node test.mjs` is the only check that has run: it +compiles each patch to wasm in Node and renders it offline (non-silent, finite). No patch has been listened to; +the page itself, its AudioWorklet path, sliders and layout have not been opened in any browser. One patch +is known to clip: `dx7-public-domain-prc-synth1-calibrated` peaks at 2.10. Browser verification is open as +`aqua-body:follow_up:playground-browser-verify`. + **What is live:** 42 patches (`catalog.json`): the hand-written Faust `thruster` (with its `rpm` control) and 41 of the 43 `.aqua` files, lowered by `tools/AquaLower` through `FaustEmitter.EmitScript` (the lowering the daemon uses). Faust is compiled to WebAssembly in the page From eb35ca545dd99bf5cdf7befc8e13731e68473555 Mon Sep 17 00:00:00 2001 From: Aqua Date: Thu, 5 Nov 2026 15:31:35 +0000 Subject: [PATCH 013/124] Add aqua-feel: headless feel meter and gate; fix PRC SYNTH1 clipping and thruster low-rpm hiss tools/aqua-feel renders every playground patch (thruster at four rpm) and every Ding event on every instrument offline through faustwasm, measures onset latency, attack, crest, true peak and clipping, BS.1770 loudness, centroid/flux over time, noise-to-tone ratio (flat and A-weighted) and a low-motion flag, writes report.json plus a static gallery, and gates against thresholds.json (waivers must cite a follow-up and go stale). Nothing is heard; metrics are evidence, not verdicts. Uses it: PRC SYNTH1 calibrated peaked at 2.10 (18,633 overs); shipped patch gain 1.4 to 0.45, peak 0.67. Thruster low-rpm A-weighted noise-to-tone 20.7/23.0 dB at rpm 300/600 down to 13.1/5.0 by cutting the idle rasp and rattle floors and opening the rumble low-pass at low load. Trial copy mirrored; its README notes the narrower sweep. AquaLower gains --dings to lower DingCatalog instruments and events. Co-Authored-By: Claude Sonnet 5.5 --- .gitignore | 1 + docs/renders/aqua-feel-2026-11-05.md | 46 ++++ .../public-domain/prc-synth1-calibrated.aqua | 4 +- patches/thruster/thruster.dsp | 9 +- tools/AquaLower/AquaLower.csproj | 1 + tools/AquaLower/Program.cs | 20 ++ tools/aqua-feel/README.md | 70 +++++ tools/aqua-feel/catalog.js | 27 ++ tools/aqua-feel/feel.mjs | 66 +++++ tools/aqua-feel/gallery.js | 51 ++++ tools/aqua-feel/gate.js | 44 +++ tools/aqua-feel/lowered-dings/dings.json | 184 +++++++++++++ tools/aqua-feel/lowered-dings/glass-chime.dsp | 56 ++++ tools/aqua-feel/lowered-dings/muted-pluck.dsp | 56 ++++ .../aqua-feel/lowered-dings/soft-triangle.dsp | 56 ++++ tools/aqua-feel/lowered-dings/warm-bell.dsp | 56 ++++ tools/aqua-feel/metrics.js | 256 ++++++++++++++++++ tools/aqua-feel/package.json | 7 + tools/aqua-feel/render.js | 70 +++++ tools/aqua-feel/report.js | 46 ++++ tools/aqua-feel/test.mjs | 146 ++++++++++ tools/aqua-feel/thresholds.json | 152 +++++++++++ tools/aqua-playground/README.md | 2 +- ...x7-public-domain-prc-synth1-calibrated.dsp | 2 +- tools/aqua-playground/lowered/thruster.dsp | 9 +- tools/aqua-trial/README.md | 11 +- tools/aqua-trial/thruster-trial.dsp | 9 +- 27 files changed, 1438 insertions(+), 19 deletions(-) create mode 100644 docs/renders/aqua-feel-2026-11-05.md create mode 100644 tools/aqua-feel/README.md create mode 100644 tools/aqua-feel/catalog.js create mode 100644 tools/aqua-feel/feel.mjs create mode 100644 tools/aqua-feel/gallery.js create mode 100644 tools/aqua-feel/gate.js create mode 100644 tools/aqua-feel/lowered-dings/dings.json create mode 100644 tools/aqua-feel/lowered-dings/glass-chime.dsp create mode 100644 tools/aqua-feel/lowered-dings/muted-pluck.dsp create mode 100644 tools/aqua-feel/lowered-dings/soft-triangle.dsp create mode 100644 tools/aqua-feel/lowered-dings/warm-bell.dsp create mode 100644 tools/aqua-feel/metrics.js create mode 100644 tools/aqua-feel/package.json create mode 100644 tools/aqua-feel/render.js create mode 100644 tools/aqua-feel/report.js create mode 100644 tools/aqua-feel/test.mjs create mode 100644 tools/aqua-feel/thresholds.json diff --git a/.gitignore b/.gitignore index 92db1ab..0a9a6b8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ NuGet.Local.Config _tmp_*.txt *.user *.suo +tools/aqua-feel/out/ diff --git a/docs/renders/aqua-feel-2026-11-05.md b/docs/renders/aqua-feel-2026-11-05.md new file mode 100644 index 0000000..58e0bf2 --- /dev/null +++ b/docs/renders/aqua-feel-2026-11-05.md @@ -0,0 +1,46 @@ +# aqua-feel first run, 2026-11-05 + +Nothing here was heard. These are metrics from offline renders (faustwasm, mono, 48 kHz, 3 s per patch); they are evidence, +not verdicts. `tools/aqua-feel/README.md` says what each number is and where it breaks. + +Before: `patches/` at `origin/main` d8c625c under the same rules: the gate fails on 3 items (PRC SYNTH1: overs, true peak, +loudness; sfxr golf: true peak, loudness, low motion; sfxr explosion: low motion). After: PRC SYNTH1 gain trimmed 1.4 to +0.45 (a uniform gain: crest and centroid are unchanged), and `thruster.dsp` mix edited (below). Gate after: pass, 4 waivers +(golf x3, explosion x1), 1 warning (golf, +0.9 dBTP). + +## prc-synth1-calibrated + + samplePeak 2.10 -> 0.67 -1.42 + truePeakDb 6.44 -> -3.41 -9.86 + overSamples 18633 -> 0 -18633.00 + loudnessLufs -0.67 -> -10.53 -9.86 + crestDb 6.67 -> 6.67 +0.00 + centroidMedianHz 794.44 -> 794.44 +0.00 + noiseToToneDb -17.18 -> -17.18 +0.00 + noiseToToneADb -19.14 -> -19.14 +0.00 + onsetMs 0.13 -> 0.13 +0.00 + attackMs 0.33 -> 0.33 +0.00 + lowMotion false -> false + +The shipped file's `patch gain=1.4` is the constant the parity probe in `Dx7ReferenceParityTests` writes; the probe asserts +RMS ratio against Dexed, so the test is untouched and still builds its own script at 1.4. Only the shipped library patch +carries the trim. Whether 0.45 is the right level for a listener is unchecked. + +## thruster + +Edits to `patches/thruster/thruster.dsp` (mirrored in `tools/aqua-trial/thruster-trial.dsp`): rasp gain `0.3 + 1.5*load` to +`0.05 + 1.75*load`; rattle floor `0.1 + 0.9*load^2` to `0.015 + 0.985*load^2`; rumble low-pass `60 + 2.5*shaft` to +`60 + 2.5*shaft + 140*(1-load)`. At load 1 (rpm 6000) every term equals its old value (rasp 1.8, rattle 1, low-pass 60 + 2.5*shaft). +Decomposition at rpm 300 before the edit (A-weighted noise-to-tone, dB): full mix +21, rasp removed +20.5, rattle removed ++13.0, both removed +12.5. The rattle modes, not the rasp, were most of the audible-band noise at low rpm; with both gone a +floor of +12.5 dB remains (the pitch-wandering saw smears its harmonics, which the line detector counts as noise). + + rpm A-weighted noise-to-tone dB (before -> after) loudness LUFS centroid Hz + 300 20.7 -> 13.1 -29.5 -> -30.2 2388 -> 752 + 600 23.0 -> 5.0 -28.0 -> -28.7 2531 -> 1228 + 1200 20.1 -> 12.7 -25.4 -> -26.1 2913 -> 2114 + 4800 10.3 -> 9.7 -17.3 -> -17.4 4987 -> 4914 + +The centroid falls a lot at low rpm: the sound is darker as well as less noisy. Whether that is "more tone" to a listener or +"muffled" is exactly what this meter cannot say. The listening trial (`tools/aqua-trial`) now sweeps a narrower noise range at +rpm 600 (see its README). diff --git a/patches/dx7/public-domain/prc-synth1-calibrated.aqua b/patches/dx7/public-domain/prc-synth1-calibrated.aqua index 78bbe7d..05b5ce2 100644 --- a/patches/dx7/public-domain/prc-synth1-calibrated.aqua +++ b/patches/dx7/public-domain/prc-synth1-calibrated.aqua @@ -2,9 +2,11 @@ # Family: dx7/public-domain # Source: analog1.syx voice 17 parity probe, generated from calibrated DX7 lowering # Notes: Hard DX7 parity target that forced applied EG, summed route, feedback, detune, and COM calibration. +# Headroom: patch gain is 0.45, not the 1.4 the parity probe in Dx7ReferenceParityTests uses. At 1.4 this graph peaked at 2.10 +# (18,633 samples past full scale in a 3 s render, found by tools/aqua-feel); 0.45 keeps the same signal at 0.675, about -3.4 dBFS. patch - gain=1.4 + gain=0.45 soft_clip=false opgraph diff --git a/patches/thruster/thruster.dsp b/patches/thruster/thruster.dsp index 9260b6a..c36a8ae 100644 --- a/patches/thruster/thruster.dsp +++ b/patches/thruster/thruster.dsp @@ -13,17 +13,18 @@ wander = no.noise : fi.lowpass(2, 5) : *(0.35); f0 = shaft * (1 + 0.04 * wander); // low rumble: saw at shaft speed plus a square a sub-octave down, low-passed -rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 * shaft); +// the low-pass opens up as load falls, so at low rpm the rotor tone reaches the 150-300 Hz range a small speaker can show +rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 * shaft + 140 * (1 - load)); // blade pass: rasp noise chopped at 3x shaft, band tracks rpm chop = 0.5 + 0.5 * os.osc(f0 * 3) ^ 2; rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); -// brittle hull: high-Q modes rattled by noise, louder with load; tanh on the rattle alone keeps ring-up spikes from setting the peak +// brittle hull: high-Q modes rattled by noise, louder with load (a 1.5% floor at idle, so low rpm is tone-led); tanh on the rattle alone keeps ring-up spikes from setting the peak mode(f, q) = no.noise : fi.resonbp(f, q, 1); -rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode(467, 16) + 0.4 * mode(1130, 14)) * (0.1 + 0.9 * load ^ 2) * 3 : *(4) : ma.tanh : /(4); +rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode(467, 16) + 0.4 * mode(1130, 14)) * (0.015 + 0.985 * load ^ 2) * 3 : *(4) : ma.tanh : /(4); -mix = rumble * (0.5 + 0.5 * load) + rasp * (0.3 + 1.5 * load) + rattle; +mix = rumble * (0.5 + 0.5 * load) + rasp * (0.05 + 1.75 * load) + rattle; // drive falls only gently with load so tanh stays out of saturation while high rpm still ends up louder than low rpm // final 0.425 trim keeps peak under 0.4 at rpm 4800 process = mix * (0.4 + 0.6 * load) * (0.9 - 0.5 * load) : ma.tanh : *(0.425); diff --git a/tools/AquaLower/AquaLower.csproj b/tools/AquaLower/AquaLower.csproj index 6c55fc0..fcd7f18 100644 --- a/tools/AquaLower/AquaLower.csproj +++ b/tools/AquaLower/AquaLower.csproj @@ -10,6 +10,7 @@ + diff --git a/tools/AquaLower/Program.cs b/tools/AquaLower/Program.cs index 6f0b113..e2d4948 100644 --- a/tools/AquaLower/Program.cs +++ b/tools/AquaLower/Program.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using AquaSynth.Dings; using AquaSynth.Dsl; // Lowers .aqua patches to Faust source for the static playground (tools/aqua-playground). @@ -6,6 +7,25 @@ using AquaSynth.Dsl; // A .aqua entry goes through FaustEmitter.EmitScript, the same lowering the daemon uses; a .dsp entry // (the thruster) is already Faust and is copied verbatim. Writes /.dsp, and // catalog.json for the browser (the one non-CultNet xeno at this boundary). +// usage: AquaLower --dings : lowers each DingCatalog instrument to /.dsp and writes dings.json +// (instruments with their root frequency, events with their notes) so aqua-feel can mix an event the way DingsPlaybackHost does. +if (args.Length == 2 && args[0] == "--dings") +{ + var dingDir = Path.GetFullPath(args[1]); + Directory.CreateDirectory(dingDir); + var instruments = new List(); + foreach (var ins in DingCatalog.Instruments.Values.OrderBy(i => i.Id, StringComparer.Ordinal)) + { + var export = FaustEmitter.EmitScript(ins.Script, new FaustExportOptions("dings_" + ins.Id.Replace('-', '_'))); + File.WriteAllText(Path.Combine(dingDir, ins.Id + ".dsp"), export.Source); + instruments.Add(new { id = ins.Id, rootFrequency = ins.RootFrequency, dsp = ins.Id + ".dsp", controlPath = "/ding/frequency", warnings = export.Warnings }); + Console.WriteLine($"{ins.Id}: {export.Source.Length} chars, {export.Warnings.Count} warnings"); + } + var events = DingCatalog.Events.Values.OrderBy(e => e.Id, StringComparer.Ordinal) + .Select(e => new { id = e.Id, meaning = e.Meaning, notes = e.Notes.Select(n => new { semitones = n.Semitones, delayMilliseconds = n.DelayMilliseconds, gain = n.Gain }) }); + File.WriteAllText(Path.Combine(dingDir, "dings.json"), JsonSerializer.Serialize(new { instruments, events, noteSeconds = 1.5 }, new JsonSerializerOptions { WriteIndented = true })); + return 0; +} if (args.Length < 3) { Console.Error.WriteLine("usage: AquaLower = ..."); return 2; } var outDir = Path.GetFullPath(args[0]); var root = Path.GetFullPath(args[1]); diff --git a/tools/aqua-feel/README.md b/tools/aqua-feel/README.md new file mode 100644 index 0000000..0526140 --- /dev/null +++ b/tools/aqua-feel/README.md @@ -0,0 +1,70 @@ +# aqua-feel + +Headless feel meter for AquaSynth. It renders every shipped patch and every Ding offline, measures the buffers, writes +JSON and a static HTML gallery, and gates the numbers against thresholds. + +**Nothing here was heard.** Every number is a measurement of an offline-rendered buffer. Metrics are evidence for a +listener to check, not verdicts: a render can pass every threshold and sound wrong, and fail one and sound fine. +The WAVs and the gallery exist so a person can press play. + +## Run + +``` +(cd ../aqua-playground && npm ci) # faustwasm runtime, once +node test.mjs # 20 checks of the meter on synthetic signals; renders no patch +node feel.mjs run # render 81 items (~15 s), write out/{report.json,index.html,wav/}, gate; exit 1 on failure +node feel.mjs run --only thruster # a subset; --out DIR; --no-gate +node feel.mjs gate out/report.json # re-gate a saved report +node feel.mjs compare before.json after.json [--only SUBSTR] # before/after table +node feel.mjs correlate trial-export.json ... # feel metrics vs aqua-trial listener ratings +``` + +Open `out/index.html` in a browser (it references `wav/` relatively). The gate is the CI step: `node feel.mjs run` exits +non-zero on any unwaived failure or stale waiver. No CI runner exists in this repo yet; nothing runs it automatically. + +## What it renders + +- Every patch in `tools/aqua-playground/lowered/` (41 `.aqua` files lowered by `tools/AquaLower`, plus the hand-written + `thruster.dsp` at rpm 300 / 600 / 1200 / 4800), 3 s each at 48 kHz, no gate or trigger: the sound the patch makes when started. + `advanced/additive-pad` and `advanced/electro-drop-demo` lower to ~1.5 MB of Faust each and are not in the playground, so not here. +- Every `DingCatalog` event on every instrument (9 x 4 = 36), mixed the way `DingsPlaybackHost` does it: each note rendered at + `root * 2^(semitones/12)` for 1.5 s, scaled by command gain 0.6 and the note gain, placed at its delay. + `lowered-dings/` is `dotnet run --project tools/AquaLower -- --dings tools/aqua-feel/lowered-dings`. + +Render path: the same faustwasm offline processor the playground and the listening trial use (libfaust 2.90.x, `-ftz 2`), +mono channel 0. It is **not** the daemon's native libfaust path (`-vec`); the same Faust source should render alike, but +nobody has diffed the two. + +## What it measures (per item, `report.json` `items[].metrics`) + +| metric | meaning | limits | +|---|---|---| +| `onsetMs` | first sample at or above max(-40 dB re peak, -70 dBFS), from note-on | Offline render has no device latency; this is the patch's own lead-in only | +| `attackMs`, `attackSlopeDbPerMs` | 10% to 90% of the FIRST peak (running max until the envelope falls 3 dB) on a 0.17 ms envelope | A faster attack reads as one hop. Meaningless on sustained noise: the "first peak" is just the first 3 dB dip | +| `samplePeak`, `truePeakDb`, `overSamples`, `flatTopRuns` | peak, 4x-oversampled true peak, samples beyond 1.0, runs of 3+ samples at 0.999 | WAVs are float32 so overs survive to disk | +| `loudnessLufs` | BS.1770-4 integrated, mono, K-weighted, gated | A mono sound with no reference level; compare items, do not read it as a delivered loudness | +| `crestDb`, `rmsDb` | over the active span (onset to last frame within 50 dB of peak) | | +| `centroidMedianHz`, `centroidCurve`, `fluxMean`, `fluxCurve` | STFT 2048/512 over active frames; flux is the change between unit-norm spectra | Flux on stationary noise is high; it is reported, not gated | +| `noiseToToneDb`, `noiseToToneADb` | energy not in stable spectral lines vs energy in them, flat and A-weighted | A heuristic split (see `metrics.js`): steady or decaying partials read tonal, noise-excited resonances read noise, gliding partials read noise. 8192-point window for spans of 1 s or more, else 2048, so compare the same sound across edits, not different sounds | +| `lowMotion` | span of 1 s or more with centroid spread under 0.08 octave and level range under 6 dB | The song-swarm collapse shape (docs/music-agent-orchestration-lessons.md): a held drone or a wash. A legitimate sustained drone is flagged too | + +## The gate + +`thresholds.json`: rules scoped to `all`, `patch`, `ding` or an id glob, each with a `why`; `level: warn` prints without failing. +`waivers` turn a known failure into a printed line and must name a reason and a follow-up id; a waiver that no longer matches +a failing rule is itself a failure, so it is deleted when the thing it excuses is fixed. The numbers were chosen after looking +at the shipped renders. They are tripwires, not taste. + +Current waivers: `sfxr-classic-classic-sfxr-abstract-golf` (+0.9 dBTP, -5.3 LUFS, held noise) and `sfxr-explosion` (3 s of +steady noise without decay). Nobody has listened to either to see if the number is the sound. + +## Reuse + +`report.js` imports `mean`, `spearman` and `permutationP` from `../aqua-trial/analyze.mjs` and the variants from +`../aqua-trial/logic.js`: `correlate` renders the trial's four thruster variants, measures them, and asks the trial's own +question (|rho| >= 0.5 and p < 0.05) of each metric against real ratings once listeners export some. With four variants +every correlation is really about the variant ordering. + +## Recorded first run + +`docs/renders/aqua-feel-2026-11-05.md`: before/after numbers for the PRC SYNTH1 and thruster edits. diff --git a/tools/aqua-feel/catalog.js b/tools/aqua-feel/catalog.js new file mode 100644 index 0000000..76ba31a --- /dev/null +++ b/tools/aqua-feel/catalog.js @@ -0,0 +1,27 @@ +// What aqua-feel renders: every playground patch, the thruster at four rpm, and every Ding event on every instrument. +import { join } from "node:path"; +import { readText, playground } from "./render.js"; +import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +export const THRUSTER_RPM = [300, 600, 1200, 4800]; +export const PATCH_SECONDS = 3, DING_COMMAND_GAIN = 0.6; + +export function patchItems() { + const dir = join(playground, "lowered"), cat = JSON.parse(readText(join(dir, "catalog.json"))), items = []; + for (const e of cat) { + const source = readText(join(dir, e.dsp)); + if (e.name === "thruster") for (const rpm of THRUSTER_RPM) items.push({ id: `thruster@rpm${rpm}`, group: "patch", origin: e.origin, source, params: { rpm }, seconds: PATCH_SECONDS }); + else items.push({ id: e.name, group: "patch", origin: e.origin, source, params: {}, seconds: PATCH_SECONDS }); + } + return items; +} + +export function dingItems() { + const dir = join(here, "lowered-dings"), d = JSON.parse(readText(join(dir, "dings.json"))), items = []; + for (const ins of d.instruments) for (const ev of d.events) + items.push({ id: `ding/${ev.id}/${ins.id}`, group: "ding", origin: `DingCatalog ${ev.id} on ${ins.id}`, ding: { instrument: ins, event: ev, source: readText(join(dir, ins.dsp)), noteSeconds: d.noteSeconds, commandGain: DING_COMMAND_GAIN } }); + return items; +} +export const allItems = () => [...patchItems(), ...dingItems()]; diff --git a/tools/aqua-feel/feel.mjs b/tools/aqua-feel/feel.mjs new file mode 100644 index 0000000..70bf702 --- /dev/null +++ b/tools/aqua-feel/feel.mjs @@ -0,0 +1,66 @@ +#!/usr/bin/env node +// aqua-feel: headless feel meter. Renders every shipped patch and Ding offline, measures the buffers, writes +// report.json plus a static gallery, and gates the numbers against thresholds.json. +// NOTHING HERE HEARS ANYTHING. These are measurements of rendered buffers; a number is evidence, never a verdict. +// Usage: node feel.mjs run [--out DIR] [--only SUBSTR] [--no-gate] render, measure, write report + gallery, gate +// node feel.mjs gate REPORT.json [THRESHOLDS.json] re-gate an existing report +// node feel.mjs compare BEFORE.json AFTER.json [--only SUBSTR] before/after table +// node feel.mjs correlate TRIAL_EXPORT.json ... feel metrics vs listening-trial ratings +import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { measure, SR } from "./metrics.js"; +import { loadRuntime, compile, renderOnce, renderDing, writeWav } from "./render.js"; +import { allItems } from "./catalog.js"; +import { gate, formatGate } from "./gate.js"; +import { gallery } from "./gallery.js"; +import { compareTable, correlate } from "./report.js"; + +const here = dirname(fileURLToPath(import.meta.url)); +export const CAVEAT = "Nothing here was heard. These are measurements of offline-rendered buffers (faustwasm, mono channel 0); metrics are evidence for a listener to check, not verdicts."; +const args = process.argv.slice(2), cmd = args.shift(); +const flag = (n) => { const i = args.indexOf(n); if (i < 0) return undefined; return args.splice(i, i + 2 > args.length ? 1 : 2).pop(); }; +const bool = (n) => { const i = args.indexOf(n); if (i < 0) return false; args.splice(i, 1); return true; }; +const readJson = (p) => JSON.parse(readFileSync(p, "utf8")); + +async function run() { + const out = resolve(flag("--out") ?? join(here, "out")), only = flag("--only"), noGate = bool("--no-gate"); + const items = allItems().filter((it) => !only || it.id.includes(only)); + if (!items.length) { console.error(`no item matches ${only}`); process.exit(2); } + const rt = await loadRuntime(); + console.log(`libfaust ${rt.version}; ${items.length} items; ${SR} Hz`); + const records = []; + for (const it of items) { + const t0 = Date.now(); + try { + const r = it.ding ? await renderDing(rt, it.ding.instrument, it.ding.source, it.ding.event, it.ding) : await renderOnce(await compile(rt, it.id, it.source), it.params, it.seconds); + const wav = `wav/${it.id.replace(/[^A-Za-z0-9._@-]+/g, "_")}.wav`; + writeWav(join(out, wav), r.samples); + records.push({ id: it.id, group: it.group, origin: it.origin, params: it.params ?? {}, seconds: r.samples.length / SR, channels: r.channels, wav, metrics: measure(r.samples) }); + console.log(`ok ${it.id} (${Date.now() - t0} ms)`); + } catch (e) { + records.push({ id: it.id, group: it.group, origin: it.origin, error: String(e.message ?? e) }); + console.log(`FAIL ${it.id}: ${e.message}`); + } + } + const thresholds = readJson(join(here, "thresholds.json")); + const report = { schema: "aqua-feel.report.v1", caveat: CAVEAT, libfaust: rt.version, sampleRate: SR, items: records }; + report.gate = gate(report, thresholds); + mkdirSync(out, { recursive: true }); + writeFileSync(join(out, "report.json"), JSON.stringify(report, null, 1)); + writeFileSync(join(out, "index.html"), gallery(report)); + console.log(`\nwrote ${join(out, "report.json")} and index.html\n${CAVEAT}\n\n${formatGate(report.gate)}`); + process.exit(!noGate && !report.gate.pass ? 1 : 0); +} + +const cmds = { + run, + gate() { + const report = readJson(args[0]), g = gate(report, readJson(args[1] ?? join(here, "thresholds.json"))); + console.log(formatGate(g)); process.exit(g.pass ? 0 : 1); + }, + compare() { const only = flag("--only"); console.log(compareTable(readJson(args[0]), readJson(args[1]), only)); }, + async correlate() { console.log(await correlate(args.map(readJson), join(here, "../aqua-trial"))); }, +}; +if (!cmds[cmd]) { console.error(readFileSync(fileURLToPath(import.meta.url), "utf8").split("\n").slice(1, 9).join("\n")); process.exit(2); } +await cmds[cmd](); diff --git a/tools/aqua-feel/gallery.js b/tools/aqua-feel/gallery.js new file mode 100644 index 0000000..fcb21c6 --- /dev/null +++ b/tools/aqua-feel/gallery.js @@ -0,0 +1,51 @@ +// Static HTML gallery from a report: no scripts, no network. Each card has the WAV (native audio controls, for a human +// to press), an SVG level envelope, an SVG spectral-centroid curve, and the metric table with gate failures marked. +// The page says on its face that nothing was heard. +const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]); +const num = (v, d = 1) => (typeof v === "number" && Number.isFinite(v) ? v.toFixed(d) : "–"); + +function plot(points, { w = 260, h = 56, ymin, ymax, log = false, color }) { + if (!points?.length) return ``; + const tmax = points[points.length - 1].t || 1, ys = points.map((p) => (log ? Math.log2(Math.max(p.v, 20)) : p.v)); + const lo = ymin ?? Math.min(...ys), hi = ymax ?? Math.max(...ys), span = hi - lo || 1; + const path = points.map((p, i) => `${i ? "L" : "M"}${((p.t / tmax) * (w - 2) + 1).toFixed(1)},${(h - 2 - ((ys[i] - lo) / span) * (h - 4)).toFixed(1)}`).join(""); + return ``; +} + +const ROWS = [ + ["onset ms", "onsetMs", 2], ["attack ms (10→90%, first peak)", "attackMs", 2], ["attack slope dB/ms", "attackSlopeDbPerMs", 1], + ["sample peak", "samplePeak", 3], ["true peak dBTP", "truePeakDb", 1], ["over-1.0 samples", "overSamples", 0], ["flat-top runs", "flatTopRuns", 0], + ["loudness LUFS", "loudnessLufs", 1], ["crest dB", "crestDb", 1], ["centroid median Hz", "centroidMedianHz", 0], ["flux mean", "fluxMean", 3], + ["noise-to-tone dB (flat)", "noiseToToneDb", 1], ["noise-to-tone dB (A-weighted)", "noiseToToneADb", 1], ["level range dB", "envRangeDb", 1], ["centroid spread (oct)", "centroidSpreadOct", 2], + ["active ms", "activeMs", 0], ["low motion", "lowMotion", 0], +]; + +export function gallery(report) { + const bad = new Map(); + for (const [kind, list] of [["fail", report.gate?.failures ?? []], ["waived", report.gate?.waived ?? []], ["warn", report.gate?.warnings ?? []]]) + for (const e of list) { const k = `${e.id}|${e.metric}`; if (!bad.has(k) || kind === "fail") bad.set(k, kind); } + const cards = report.items.map((it) => { + const m = it.metrics; + if (!m) return `

${esc(it.id)}

did not render: ${esc(it.error ?? "unknown")}

`; + const rows = ROWS.map(([label, key, d]) => { + const v = m[key], cls = bad.get(`${it.id}|${key}`) ?? "", shown = typeof v === "boolean" ? String(v) : num(v, d); + return `${label}${shown}${cls ? ` ${cls}` : ""}`; + }).join(""); + const worst = ["fail", "waived", "warn"].find((k) => [...bad].some(([key, v]) => key.startsWith(it.id + "|") && v === k)) ?? ""; + return `

${esc(it.id)} ${it.group}

+ +

level envelope (dB, ${num(m.envelopeCurve?.at(-1)?.t, 1)} s)

${plot(m.envelopeCurve, { ymin: -90, ymax: 6, color: "#6fb1c7" })} +

spectral centroid (log Hz)

${plot(m.centroidCurve, { log: true, ymin: Math.log2(20), ymax: Math.log2(16000), color: "#c7a46f" })} +${rows}

${esc(it.origin ?? "")}

`; + }); + const g = report.gate; + return `aqua-feel gallery + +

aqua-feel gallery

+ +
${cards.join("\n")}
`; +} diff --git a/tools/aqua-feel/gate.js b/tools/aqua-feel/gate.js new file mode 100644 index 0000000..f172bba --- /dev/null +++ b/tools/aqua-feel/gate.js @@ -0,0 +1,44 @@ +// Threshold gate over a report. Rules come from thresholds.json: { group: all|patch|ding, id?: glob, metric, min?, max?, +// equals?, level?: fail|warn, why }. A waiver { id, metric, reason, followUp } turns a known failure into a printed +// 'waived' line, and a waiver that no longer matches a failing rule is itself a failure, so waivers get deleted when +// the thing they excuse is fixed. Thresholds are tripwires for a listener to check, not a judgement of the sound. +const glob = (pattern) => new RegExp("^" + pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$"); +const get = (m, path) => path.split(".").reduce((o, k) => o?.[k], m); + +function violation(rule, value) { + if (value === undefined || value === null || Number.isNaN(value)) return rule.min !== undefined || rule.max !== undefined ? "no value" : null; + if (rule.equals !== undefined && value !== rule.equals) return `${value} (want ${rule.equals})`; + if (rule.max !== undefined && !(value <= rule.max)) return `${fmt(value)} (max ${rule.max})`; + if (rule.min !== undefined && !(value >= rule.min)) return `${fmt(value)} (min ${rule.min})`; + return null; +} +const fmt = (v) => (typeof v === "number" ? +v.toFixed(2) : v); + +export function gate(report, thresholds, { partial = false } = {}) { + const failures = [], warnings = [], waived = [], hits = new Set(); + const waivers = thresholds.waivers ?? []; + for (const it of report.items) { + if (it.error || it.metrics?.broken) { failures.push({ id: it.id, metric: "render", detail: it.error ?? `${it.metrics.nonFinite} non-finite samples`, why: "item did not render cleanly" }); continue; } + for (const rule of thresholds.rules) { + if (rule.group !== "all" && rule.group !== it.group) continue; + if (rule.id && !glob(rule.id).test(it.id)) continue; + const detail = violation(rule, get(it.metrics, rule.metric)); + if (!detail) continue; + const entry = { id: it.id, metric: rule.metric, detail, why: rule.why }; + const w = waivers.findIndex((x) => x.metric === rule.metric && glob(x.id).test(it.id)); + if (rule.level === "warn") warnings.push(entry); + else if (w >= 0) { hits.add(w); waived.push({ ...entry, reason: waivers[w].reason, followUp: waivers[w].followUp }); } + else failures.push(entry); + } + } + if (!partial) waivers.forEach((w, i) => { if (!hits.has(i)) failures.push({ id: w.id, metric: w.metric, detail: "waiver matches nothing failing", why: "stale waiver: delete it" }); }); + return { pass: failures.length === 0, items: report.items.length, failures, warnings, waived }; +} + +export function formatGate(g) { + const line = (e) => ` ${e.id} ${e.metric}: ${e.detail} [${e.why}]${e.reason ? `\n waived: ${e.reason}${e.followUp ? ` (${e.followUp})` : ""}` : ""}`; + const out = [`gate: ${g.pass ? "PASS" : "FAIL"} (${g.items} items, ${g.failures.length} failing, ${g.waived.length} waived, ${g.warnings.length} warnings)`]; + for (const [title, list] of [["FAILING", g.failures], ["WAIVED", g.waived], ["WARNINGS", g.warnings]]) if (list.length) out.push(title, ...list.map(line)); + out.push("", "Thresholds are tripwires for a listener to check. Passing means nothing was heard to be wrong; it does not mean it sounds right."); + return out.join("\n"); +} diff --git a/tools/aqua-feel/lowered-dings/dings.json b/tools/aqua-feel/lowered-dings/dings.json new file mode 100644 index 0000000..bdb3748 --- /dev/null +++ b/tools/aqua-feel/lowered-dings/dings.json @@ -0,0 +1,184 @@ +{ + "instruments": [ + { + "id": "glass-chime", + "rootFrequency": 261.6256, + "dsp": "glass-chime.dsp", + "controlPath": "/ding/frequency", + "warnings": [] + }, + { + "id": "muted-pluck", + "rootFrequency": 261.6256, + "dsp": "muted-pluck.dsp", + "controlPath": "/ding/frequency", + "warnings": [] + }, + { + "id": "soft-triangle", + "rootFrequency": 261.6256, + "dsp": "soft-triangle.dsp", + "controlPath": "/ding/frequency", + "warnings": [] + }, + { + "id": "warm-bell", + "rootFrequency": 261.6256, + "dsp": "warm-bell.dsp", + "controlPath": "/ding/frequency", + "warnings": [] + } + ], + "events": [ + { + "id": "input.required", + "meaning": "Input requested", + "notes": [ + { + "semitones": 12, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 5, + "delayMilliseconds": 260, + "gain": 1 + } + ] + }, + { + "id": "resource.limit", + "meaning": "Resource is holding", + "notes": [ + { + "semitones": 0, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 0, + "delayMilliseconds": 280, + "gain": 1 + }, + { + "semitones": 0, + "delayMilliseconds": 560, + "gain": 1 + } + ] + }, + { + "id": "session.end", + "meaning": "Session closure", + "notes": [ + { + "semitones": 7, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 0, + "delayMilliseconds": 240, + "gain": 1 + } + ] + }, + { + "id": "session.start", + "meaning": "Opening welcome", + "notes": [ + { + "semitones": 0, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 7, + "delayMilliseconds": 220, + "gain": 1 + } + ] + }, + { + "id": "task.acknowledge", + "meaning": "Quiet ongoing acknowledgement", + "notes": [ + { + "semitones": 7, + "delayMilliseconds": 0, + "gain": 1 + } + ] + }, + { + "id": "task.complete", + "meaning": "Satisfying closure", + "notes": [ + { + "semitones": 7, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 12, + "delayMilliseconds": 220, + "gain": 1 + } + ] + }, + { + "id": "task.error", + "meaning": "Gentle failure notice", + "notes": [ + { + "semitones": 7, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 4, + "delayMilliseconds": 240, + "gain": 1 + }, + { + "semitones": 0, + "delayMilliseconds": 480, + "gain": 1 + } + ] + }, + { + "id": "task.progress", + "meaning": "Faint ignorable progress", + "notes": [ + { + "semitones": -5, + "delayMilliseconds": 0, + "gain": 0.45 + } + ] + }, + { + "id": "user.spam", + "meaning": "Curt rate warning", + "notes": [ + { + "semitones": 9, + "delayMilliseconds": 0, + "gain": 1 + }, + { + "semitones": 9, + "delayMilliseconds": 190, + "gain": 1 + }, + { + "semitones": 9, + "delayMilliseconds": 380, + "gain": 1 + } + ] + } + ], + "noteSeconds": 1.5 +} \ No newline at end of file diff --git a/tools/aqua-feel/lowered-dings/glass-chime.dsp b/tools/aqua-feel/lowered-dings/glass-chime.dsp new file mode 100644 index 0000000..16d49a0 --- /dev/null +++ b/tools/aqua-feel/lowered-dings/glass-chime.dsp @@ -0,0 +1,56 @@ +import("stdfaust.lib"); +declare name "dings_glass_chime"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0 = hslider("/ding/frequency", 261.6256, 40, 4000, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 4.12))) * (max(0.0, 4.1 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.28, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(1 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0.04 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.001, 0, 1, 0.85, 0.025) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.12); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-feel/lowered-dings/muted-pluck.dsp b/tools/aqua-feel/lowered-dings/muted-pluck.dsp new file mode 100644 index 0000000..0fc3e02 --- /dev/null +++ b/tools/aqua-feel/lowered-dings/muted-pluck.dsp @@ -0,0 +1,56 @@ +import("stdfaust.lib"); +declare name "dings_muted_pluck"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0 = hslider("/ding/frequency", 261.6256, 40, 4000, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0.05 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.58 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.001, 0, 1, 0.34, 0.018) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.13); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-feel/lowered-dings/soft-triangle.dsp b/tools/aqua-feel/lowered-dings/soft-triangle.dsp new file mode 100644 index 0000000..154b917 --- /dev/null +++ b/tools/aqua-feel/lowered-dings/soft-triangle.dsp @@ -0,0 +1,56 @@ +import("stdfaust.lib"); +declare name "dings_soft_triangle"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0 = hslider("/ding/frequency", 261.6256, 40, 4000, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = 1.0 - 4.0 * abs(wrap01(os.phasor(1.0, ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0) - 0.5); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.72 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.006, 0, 1, 0.9, 0.04) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.14); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-feel/lowered-dings/warm-bell.dsp b/tools/aqua-feel/lowered-dings/warm-bell.dsp new file mode 100644 index 0000000..dd8fc08 --- /dev/null +++ b/tools/aqua-feel/lowered-dings/warm-bell.dsp @@ -0,0 +1,56 @@ +import("stdfaust.lib"); +declare name "dings_warm_bell"; +declare options "[nvoices:1]"; + +time = ba.time / ma.SR; +age = time; +clip01(x) = min(1.0, max(0.0, x)); +wrap01(x) = x - floor(x); +slew(rate,x) = x : *(1.0 - exp((0.0 - max(0.0001, rate)) / ma.SR)) : + ~ *(exp((0.0 - max(0.0001, rate)) / ma.SR)); +softclip(x) = ma.tanh(x * 1.35); +fold(x) = 2.0 * abs(2.0 * (x / 4.0 - floor(x / 4.0)) - 1.0) - 1.0; +release_start(a,d,g) = max(g, a + d); +oneshot_adsr_at(t,a,d,s,r,g) = select2(t < a, select2(t < a + d, select2(t < release_start(a,d,g), select2(t < release_start(a,d,g) + r, 0.0, s * (1.0 - (t - release_start(a,d,g)) / max(0.0001, r))), s), 1.0 - (1.0 - s) * ((t - a) / max(0.0001, d))), t / max(0.0001, a)); +oneshot_adsr(a,d,s,r,g) = oneshot_adsr_at(age,a,d,s,r,g); +seg(t,t0,d,a,b) = a + (b - a) * clip01((t - t0) / max(0.0001, d)); +bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d; +seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e); +smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x)); +seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d)); +seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d))); +seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b)); +rl_release_start(r1,r2,r3,g) = max(g, r1 + r2 + r3); +rl4_env_from_at(t,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = select2(t < r1, select2(t < r1 + r2, select2(t < r1 + r2 + r3, select2(t < rl_release_start(r1,r2,r3,g), select2(t < rl_release_start(r1,r2,r3,g) + r4, l4, seg_curve(c4, t, rl_release_start(r1,r2,r3,g), r4, l3, l4)), l3), seg_curve(c3, t, r1 + r2, r3, l2, l3)), seg_curve(c2, t, r1, r2, l1, l2)), seg_curve(c1, t, 0, r1, s0, l1)); +rl4_env_at(t,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(t,0.0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env_from(s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_from_at(age,s0,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +rl4_env(r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g) = rl4_env_at(age,r1,l1,c1,r2,l2,c2,r3,l3,c3,r4,l4,c4,g); +lfo_sin(hz, phase) = sin(2.0 * ma.PI * (age * hz + phase)); +lfo_tri(hz, phase) = 1.0 - 4.0 * abs((age * hz + phase - floor(age * hz + phase)) - 0.5); +lfo_sq(hz, phase) = select2((age * hz + phase - floor(age * hz + phase)) < 0.5, -1.0, 1.0); +lfo_hold(hz, phase) = no.noise : ba.latch(os.oscrs(hz)); + +patch_param_0 = hslider("/ding/frequency", 261.6256, 40, 4000, 0.001) : si.smoo; + +patch_mod_gain = 0.0; +patch_mod_pitch = 0.0; +patch_mod_duty = 0.0; +patch_mod_lpf = 0.0; +patch_mod_hpf = 0.0; +patch_mod_noise = 0.0; +patch_mod_drive = 0.0; +patch_mod_fold = 0.0; +patch_mod_formant_mix = 0.0; +patch_mod_fm_index = 0.0; + +voice_0_age = age; +voice_0_freq = ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0); +voice_0_osc = sin(2.0 * ma.PI * wrap01(os.phasor(1.0, ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0)) + 0 + sin(2.0 * ma.PI * os.phasor(1.0, ((max(20, patch_param_0 * pow(2.0, 0 * voice_0_age + 0.5 * 0 * voice_0_age * voice_0_age)))) * 1.0 * pow(2.0, patch_mod_pitch + 0.0) * max(0.0, 3.01))) * (max(0.0, 2.6 + patch_mod_fm_index + 0.0) * exp(-voice_0_age / max(0.42, 0.0001))) / ma.PI)); +voice_0_colored = (voice_0_osc * (1.0 - clip01(0 + patch_mod_noise + 0.0)) + no.noise * clip01(0 + patch_mod_noise + 0.0)); +voice_0_driven = ma.tanh(voice_0_colored * (1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0)) / ma.tanh(1.0 + clip01(0 + patch_mod_drive + 0.0) * 12.0); +voice_0_folded = voice_0_driven * (1.0 - clip01(0 + patch_mod_fold + 0.0)) + fold(voice_0_driven * (1.0 + clip01(0 + patch_mod_fold + 0.0) * 3.5)) * clip01(0 + patch_mod_fold + 0.0); +voice_0_filtered = voice_0_folded : fi.lowpass(1, max(20.0, clip01(0.86 * (1.0 + 0 * voice_0_age * 1.8) + patch_mod_lpf + 0.0) * 18000.0)) : fi.highpass(1, max(5.0, (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * (clip01(0 * (1.0 + 0 * voice_0_age * 2.0) + patch_mod_hpf + 0.0)) * 7000.0)); +voice_0_phased = voice_0_filtered; +voice_0_formants = voice_0_phased; +voice_0 = ((voice_0_phased * (1.0 - clip01(0 + patch_mod_formant_mix + 0.0)) + voice_0_formants * clip01(0 + patch_mod_formant_mix + 0.0)) * oneshot_adsr_at(voice_0_age, 0.004, 0, 1, 1.15, 0.035) * max(0.0, 1.0 + patch_mod_gain + 0.0) * 0.17); + +process = softclip((voice_0) * 1); diff --git a/tools/aqua-feel/metrics.js b/tools/aqua-feel/metrics.js new file mode 100644 index 0000000..4e4766a --- /dev/null +++ b/tools/aqua-feel/metrics.js @@ -0,0 +1,256 @@ +// Pure signal metrics for aqua-feel. Dependency-free; every function takes mono Float32Array/number[] at SR. +// These are measurements of a rendered buffer. Nothing here hears anything, and no number is a verdict. +export const SR = 48000; +const db = (x) => (x > 0 ? 20 * Math.log10(x) : -Infinity); +const pdb = (x) => (x > 0 ? 10 * Math.log10(x) : -Infinity); +const median = (xs) => { const s = Float64Array.from(xs).sort(); return s.length ? (s.length % 2 ? s[s.length >> 1] : (s[s.length / 2 - 1] + s[s.length / 2]) / 2) : NaN; }; +const mean = (xs) => (xs.length ? xs.reduce((a, b) => a + b, 0) / xs.length : NaN); +const sd = (xs) => (xs.length < 2 ? 0 : Math.sqrt(xs.reduce((a, x) => a + (x - mean(xs)) ** 2, 0) / (xs.length - 1))); +const quantile = (xs, q) => { const s = Float64Array.from(xs).sort(); return s.length ? s[Math.min(s.length - 1, Math.floor(q * s.length))] : NaN; }; + +// ---- levels ------------------------------------------------------------------------------------------------------ +export function samplePeak(x) { let p = 0; for (const v of x) { const a = Math.abs(v); if (a > p) p = a; } return p; } + +// True peak: 4x oversampled with a Hann-windowed sinc (BS.1770 Annex 2 style, 48 taps). Returns linear peak. +export function truePeak(x) { + const T = 12, phases = [0.25, 0.5, 0.75]; + const taps = phases.map((ph) => Array.from({ length: 2 * T }, (_, i) => { + const k = i - T + 1, t = k - ph, s = Math.abs(t) < 1e-12 ? 1 : Math.sin(Math.PI * t) / (Math.PI * t); + return s * (0.5 + 0.5 * Math.cos((Math.PI * t) / T)); + })); + let peak = samplePeak(x); + for (let n = 0; n < x.length; n++) { + for (let p = 0; p < 3; p++) { + let acc = 0; + for (let i = 0; i < 2 * T; i++) { const j = n + i - T + 1; if (j >= 0 && j < x.length) acc += x[j] * taps[p][i]; } + if (Math.abs(acc) > peak) peak = Math.abs(acc); + } + } + return peak; +} + +// Over = would clip at a +/-1.0 converter. Flat tops = runs of >=3 consecutive samples at >=0.999 (a clipped waveform's signature). +export function clipping(x) { + let over = 0, flat = 0, run = 0; + for (const v of x) { + const a = Math.abs(v); + if (a > 1) over++; + if (a >= 0.999) { run++; if (run === 3) flat++; } else run = 0; + } + return { overSamples: over, overFraction: x.length ? over / x.length : 0, flatTopRuns: flat }; +} + +const K1 = { b: [1.53512485958697, -2.69169618940638, 1.19839281085285], a: [1, -1.69065929318241, 0.73248077421585] }; +const K2 = { b: [1, -2, 1], a: [1, -1.99004745483398, 0.99007225036621] }; +function biquad(x, { b, a }) { + const y = new Float64Array(x.length); let x1 = 0, x2 = 0, y1 = 0, y2 = 0; + for (let n = 0; n < x.length; n++) { + const v = b[0] * x[n] + b[1] * x1 + b[2] * x2 - a[1] * y1 - a[2] * y2; + x2 = x1; x1 = x[n]; y2 = y1; y1 = v; y[n] = v; + } + return y; +} +// ITU-R BS.1770-4 integrated loudness, mono, 48 kHz coefficients, 400 ms blocks at 75% overlap, -70 LUFS absolute gate, +// -10 LU relative gate. A buffer shorter than 400 ms is zero-padded to one block. Returns LUFS, or null when silent. +export function integratedLoudness(x) { + const k = biquad(biquad(x, K1), K2), B = 19200, H = 4800; + const n = Math.max(1, Math.ceil(Math.max(0, k.length - B) / H) + 1), ms = []; + for (let i = 0; i < n; i++) { + let s = 0; for (let j = i * H; j < i * H + B && j < k.length; j++) s += k[j] * k[j]; + ms.push(s / B); + } + const lufs = (e) => -0.691 + pdb(e); + const pass1 = ms.filter((e) => lufs(e) > -70); + if (!pass1.length) return null; + const rel = lufs(mean(pass1)) - 10, pass2 = pass1.filter((e) => lufs(e) > rel); + return pass2.length ? lufs(mean(pass2)) : null; +} + +// ---- time structure ---------------------------------------------------------------------------------------------- +const HOP = 8; // envelope hop in samples (0.167 ms) +export function envelope(x) { + const env = new Float64Array(Math.ceil(x.length / HOP)); + for (let i = 0; i < x.length; i++) { const a = Math.abs(x[i]); if (a > env[(i / HOP) | 0]) env[(i / HOP) | 0] = a; } + return env; +} +const hopMs = (HOP / SR) * 1000; + +// Onset: first sample at or above max(-40 dB re peak, -70 dBFS). Attack is measured on the FIRST peak: the running +// envelope maximum from the onset until the envelope falls 3 dB below it (so a two-note Ding reports its first note's +// attack, not a ramp to the second note's peak). 10% -> 90% of that first peak. The envelope hop is 0.167 ms, so an +// attack faster than that is reported as one hop (resolutionLimited). activeEnd = last envelope hop within 50 dB of the peak. +export function timing(x) { + const peak = samplePeak(x); + if (!(peak > 0)) return { silent: true }; + const thr = Math.max(peak * 0.01, 10 ** (-70 / 20)); + let onsetSample = 0; while (onsetSample < x.length && Math.abs(x[onsetSample]) < thr) onsetSample++; + const env = envelope(x), start = Math.floor(onsetSample / HOP); + let top = start, end = start; + for (let i = start; i < env.length; i++) { if (env[i] > env[top]) top = i; if (env[i] < env[top] * 0.708) break; end = i; } + const first = env[top], at = (f) => { let i = start; while (i < end && env[i] < first * f) i++; return i; }; + const i10 = at(0.1), i90 = at(0.9); + const dt = Math.max(hopMs, (i90 - i10) * hopMs), floor = peak * 10 ** (-50 / 20); + let last = env.length - 1; while (last > 0 && env[last] < floor) last--; + return { + silent: false, onsetMs: (onsetSample / SR) * 1000, attackMs: dt, attackSlopeDbPerMs: db(0.9 / 0.1) / dt, + resolutionLimited: i90 - i10 <= 1, activeStartSample: onsetSample, activeEndSample: Math.min(x.length, (last + 1) * HOP), + peakAtMs: (env.indexOf(Math.max(...env)) * HOP / SR) * 1000, firstPeak: first, firstPeakAtMs: top * hopMs, + }; +} + +export function crest(x, t) { + const seg = x.subarray ? x.subarray(t.activeStartSample, t.activeEndSample) : x.slice(t.activeStartSample, t.activeEndSample); + let s = 0; for (const v of seg) s += v * v; + const rms = Math.sqrt(s / Math.max(1, seg.length)), peak = samplePeak(seg); + return { rms, rmsDb: db(rms), crestDb: db(peak / rms) }; +} + +// ---- spectrum ---------------------------------------------------------------------------------------------------- +export function fft(re, im) { + const n = re.length; + for (let i = 1, j = 0; i < n; i++) { + let bit = n >> 1; for (; j & bit; bit >>= 1) j ^= bit; j ^= bit; + if (i < j) { [re[i], re[j]] = [re[j], re[i]]; [im[i], im[j]] = [im[j], im[i]]; } + } + for (let len = 2; len <= n; len <<= 1) { + const ang = (-2 * Math.PI) / len, wr = Math.cos(ang), wi = Math.sin(ang); + for (let i = 0; i < n; i += len) { + let cr = 1, ci = 0; + for (let k = 0; k < len / 2; k++) { + const a = i + k, b = a + len / 2, tr = re[b] * cr - im[b] * ci, ti = re[b] * ci + im[b] * cr; + re[b] = re[a] - tr; im[b] = im[a] - ti; re[a] += tr; im[a] += ti; + [cr, ci] = [cr * wr - ci * wi, cr * wi + ci * wr]; + } + } + } +} + +const N = 2048, SHOP = 512; +const hanns = new Map(); +const hann = (n) => hanns.get(n) ?? (hanns.set(n, Float64Array.from({ length: n }, (_, i) => 0.5 - 0.5 * Math.cos((2 * Math.PI * i) / n))), hanns.get(n)); +export function stft(x, N = 2048, SHOP = 512) { + const frames = [], HANN = hann(N); + for (let s = 0; s + N <= Math.max(N, x.length); s += SHOP) { + const re = new Float64Array(N), im = new Float64Array(N); + for (let i = 0; i < N; i++) re[i] = (x[s + i] ?? 0) * HANN[i]; + fft(re, im); + const mag = new Float64Array(N / 2); let e = 0; + for (let k = 0; k < N / 2; k++) { mag[k] = Math.hypot(re[k], im[k]); e += mag[k] * mag[k]; } + frames.push({ t: (s + N / 2) / SR, mag, energy: e, n: N }); + } + return frames; +} + +// Tone vs noise, per time-frequency cell. A cell (bin k, frame t) is TONAL when (1) bin k is a local maximum at least +// 12 dB (power x16) above the median of its +/-12 neighbours in frame t, (2) that holds for a run of at least 4 +// consecutive frames, and (3) over that run the level is temporally smooth: the median absolute second difference of +// the dB level (max over k-1..k+1, so slow drift stays inside) is under 6 dB. A steady or exponentially decaying partial +// passes; a noise-excited resonance (a rattle, a vocal formant) passes (1) but fails (3), because noise gives each +// frame a Rayleigh-random level (about 9 dB median second difference). Tonal cells take +/-2 bins either side (the Hann +// main lobe). Everything else is noise. Limits: a gliding or strongly vibrato partial moves bins and reads as noise; +// with under 5 frames only (1) applies. +// A-weighting as a power factor per FFT bin (IEC 61672 curve, 0 dB at 1 kHz). +const aWeightPower = (hz) => { + const f2 = hz * hz, ra = (12194 ** 2 * f2 * f2) / ((f2 + 20.6 ** 2) * Math.sqrt((f2 + 107.7 ** 2) * (f2 + 737.9 ** 2)) * (f2 + 12194 ** 2)); + return (ra * 1.2589) ** 2; +}; +const prominent = (p, k) => { + const nb = []; for (let j = Math.max(1, k - 12); j <= Math.min(p.length - 1, k + 12); j++) if (j !== k) nb.push(p[j]); + return p[k] >= p[k - 1] && p[k] >= p[k + 1] && p[k] >= 16 * median(nb); +}; +function toneNoiseSpan(frames) { + const bins = frames[0].mag.length, T = frames.length, P = frames.map((f) => Float64Array.from(f.mag, (m) => m * m)); + const tonal = P.map(() => new Uint8Array(bins)), prom = P.map((p) => { const r = new Uint8Array(bins); for (let k = 2; k < bins - 2; k++) r[k] = prominent(p, k) ? 1 : 0; return r; }); + const mark = (t, k) => { for (let j = -2; j <= 2; j++) tonal[t][k + j] = 1; }; + for (let k = 2; k < bins - 2; k++) { + for (let t = 0; t < T;) { + if (!prom[t][k]) { t++; continue; } + let e = t; while (e + 1 < T && prom[e + 1][k]) e++; + if (T < 5) { for (let i = t; i <= e; i++) mark(i, k); } + else if (e - t + 1 >= 4) { + const lv = []; for (let i = t; i <= e; i++) lv.push(20 * Math.log10(Math.max(frames[i].mag[k - 1], frames[i].mag[k], frames[i].mag[k + 1], 1e-12))); + const d2 = []; for (let i = 1; i < lv.length - 1; i++) d2.push(Math.abs(lv[i + 1] - 2 * lv[i] + lv[i - 1])); + if (median(d2) < 6) for (let i = t; i <= e; i++) mark(i, k); + } + t = e + 1; + } + } + const aw = Float64Array.from({ length: bins }, (_, k) => aWeightPower((k * SR) / (2 * bins))); + let tone = 0, noise = 0, toneA = 0, noiseA = 0; + for (let t = 0; t < T; t++) for (let k = 1; k < bins; k++) { const v = P[t][k]; if (tonal[t][k]) { tone += v; toneA += v * aw[k]; } else { noise += v; noiseA += v * aw[k]; } } + return { tone, noise, toneA, noiseA }; +} + +// Noise-to-tone ratio in dB over the active span (energy-weighted across frames), flat and A-weighted. Flat power is +// dominated by whatever is loudest and lowest (a 35 Hz rumble hides a 1 kHz hiss); the A-weighted ratio is closer to what +// a listener could notice, which is a reason to look at it, not proof of what they notice. Uses an 8192-point window +// (5.9 Hz bins) when the active span is 1 s or longer, so a 35 Hz rumble resolves into lines; shorter sounds use 2048 +// (23 Hz bins). Compare it between renders of the same sound, not across sounds of different lengths. Clamped to +/-60 dB. +export function noiseToTone(x, t) { + const spanS = (t.activeEndSample - t.activeStartSample) / SR, n = spanS >= 1 ? 8192 : 2048; + const frames = stft(x.slice(t.activeStartSample, t.activeEndSample), n, n / 4), maxE = Math.max(...frames.map((f) => f.energy)); + const live = frames.filter((f) => f.energy >= maxE * 1e-5), r = toneNoiseSpan(live); + const ratio = (nz, tn) => Math.max(-60, Math.min(60, pdb(nz) - pdb(tn || 1e-30))); + return { db: ratio(r.noise, r.tone), dbA: ratio(r.noiseA, r.toneA), window: n }; +} + +const downsample = (pts, n) => { + if (pts.length <= n) return pts; + return Array.from({ length: n }, (_, i) => { + const a = Math.floor((i * pts.length) / n), b = Math.max(a + 1, Math.floor(((i + 1) * pts.length) / n)), seg = pts.slice(a, b); + return { t: mean(seg.map((s) => s.t)), v: mean(seg.map((s) => s.v)) }; + }); +}; + +// Centroid and flux over time, noise-to-tone ratio, and the low-motion flag, over frames within 50 dB of the loudest +// frame and inside the active span. Flux is the half-wave-rectified L2 change between consecutive unit-norm magnitude +// spectra, so it tracks timbre change and not loudness change. +export function spectral(x, t, curvePoints = 48) { + const all = stft(x), maxE = Math.max(...all.map((f) => f.energy)), t0 = t.activeStartSample / SR, t1 = t.activeEndSample / SR; + const idx = all.map((f, i) => (f.energy >= maxE * 1e-5 && f.t >= t0 - N / 2 / SR && f.t <= t1 + N / 2 / SR ? i : -1)).filter((i) => i >= 0); + if (idx.length < 2) return { frames: idx.length, centroidMedianHz: NaN, centroidCurve: [], fluxCurve: [], fluxMean: 0, fluxP95: 0, centroidSpreadOct: 0, envRangeDb: 0, motion: 0, lowMotion: false, lowMotionReason: "fewer than 2 active frames" }; + const cent = [], flux = [], hz = (k) => (k * SR) / N; + let prev = null; + for (const i of idx) { + const f = all[i]; let num = 0, den = 0; + for (let k = 1; k < f.mag.length; k++) { num += hz(k) * f.mag[k]; den += f.mag[k]; } + cent.push({ t: f.t, v: den > 0 ? num / den : 0 }); + const norm = Math.sqrt(f.energy) || 1; + if (prev) { let s = 0; for (let k = 1; k < f.mag.length; k++) { const d = Math.max(0, f.mag[k] / norm - prev[k]); s += d * d; } flux.push({ t: f.t, v: Math.sqrt(s) }); } + prev = Float64Array.from(f.mag, (m) => m / norm); + } + const cs = cent.map((c) => Math.log2(Math.max(c.v, 20))), fl = flux.slice(3).map((f) => f.v), fe = idx.map((i) => pdb(all[i].energy)); + const centroidSpreadOct = sd(cs), envRangeDb = Math.max(...fe) - Math.min(...fe), fluxMean = mean(fl.length ? fl : [0]); + // Low motion = the sound stays put: timbre barely moves AND level barely moves, over a span long enough to matter. + // A decaying bell has a large level range, so it is not flagged; a held drone or a pink wash is. Flux is reported + // but not used: stationary noise has high flux (periodogram scatter) while going nowhere. + const spanS = t1 - t0, still = centroidSpreadOct < 0.08 && envRangeDb < 6; + return { + frames: idx.length, centroidMedianHz: median(cent.map((c) => c.v)), centroidCurve: downsample(cent, curvePoints), fluxCurve: downsample(flux, curvePoints), + fluxMean, fluxP95: quantile(fl.length ? fl : [0], 0.95), + centroidSpreadOct, envRangeDb, motion: Math.min(1, centroidSpreadOct / 0.5 + envRangeDb / 30 + fluxMean / 0.5), + lowMotion: spanS >= 1 && still, lowMotionReason: spanS < 1 ? "active span under 1 s: not judged" : still ? `centroid spread ${centroidSpreadOct.toFixed(3)} oct, level range ${envRangeDb.toFixed(1)} dB` : "", + }; +} + +// Peak level in dB per bucket (about `n` buckets across the whole buffer), floored at -90 dB, for the gallery's envelope plot. +export function envelopeCurve(x, n = 96) { + const env = envelope(x), per = Math.max(1, Math.ceil(env.length / n)), out = []; + for (let i = 0; i < env.length; i += per) { let m = 0; for (let j = i; j < Math.min(env.length, i + per); j++) m = Math.max(m, env[j]); out.push({ t: ((i + per / 2) * HOP) / SR, v: Math.max(-90, db(m)) }); } + return out; +} + +// ---- one buffer -> one record ------------------------------------------------------------------------------------ +export function measure(x, { curvePoints = 48 } = {}) { + const peak = samplePeak(x), nonFinite = x.reduce((n, v) => n + (Number.isFinite(v) ? 0 : 1), 0); + if (nonFinite) return { nonFinite, silent: false, broken: true }; + const t = timing(x); + if (t.silent) return { silent: true, nonFinite: 0, samplePeak: 0 }; + const tp = truePeak(x), c = crest(x, t), sp = spectral(x, t, curvePoints), clip = clipping(x), nt = noiseToTone(x, t); + return { + silent: false, nonFinite: 0, samplePeak: peak, samplePeakDb: db(peak), truePeak: tp, truePeakDb: db(tp), ...clip, + loudnessLufs: integratedLoudness(x), rms: c.rms, rmsDb: c.rmsDb, crestDb: c.crestDb, + onsetMs: t.onsetMs, attackMs: t.attackMs, attackSlopeDbPerMs: t.attackSlopeDbPerMs, attackResolutionLimited: t.resolutionLimited, peakAtMs: t.peakAtMs, + activeMs: ((t.activeEndSample - t.activeStartSample) / SR) * 1000, noiseToToneDb: nt.db, noiseToToneADb: nt.dbA, noiseToToneWindow: nt.window, envelopeCurve: envelopeCurve(x), ...sp, + }; +} diff --git a/tools/aqua-feel/package.json b/tools/aqua-feel/package.json new file mode 100644 index 0000000..9015ff1 --- /dev/null +++ b/tools/aqua-feel/package.json @@ -0,0 +1,7 @@ +{ + "name": "aqua-feel", + "private": true, + "type": "module", + "description": "Headless feel meter for AquaSynth: renders every shipped patch and Ding offline and measures them. Measures; does not listen.", + "scripts": { "test": "node test.mjs", "feel": "node feel.mjs" } +} diff --git a/tools/aqua-feel/render.js b/tools/aqua-feel/render.js new file mode 100644 index 0000000..91cdb11 --- /dev/null +++ b/tools/aqua-feel/render.js @@ -0,0 +1,70 @@ +// Offline render through the same faustwasm runtime the playground and the listening trial load (not the daemon's +// native libfaust path: same Faust source, same compiler version family, but a different host; see README). +import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { SR } from "./metrics.js"; + +const here = dirname(fileURLToPath(import.meta.url)); +export const playground = resolve(here, "../aqua-playground"); + +export async function loadRuntime() { + const fw = join(playground, "node_modules/@grame/faustwasm"); + const mod = await import(pathToFileURL(join(fw, "dist/esm/index.js")).href); + const libfaust = new mod.LibFaust(await mod.instantiateFaustModuleFromFile(join(fw, "libfaust-wasm/libfaust-wasm.js"))); + return { mod, libfaust, compiler: new mod.FaustCompiler(libfaust), version: libfaust.version(), cache: new Map() }; +} + +// Compiled generator per DSP text (a Ding event reuses one compile for all its notes). +export async function compile(rt, name, source) { + if (rt.cache.has(source)) return rt.cache.get(source); + const g = new rt.mod.FaustMonoDspGenerator(); + if (!(await g.compile(rt.compiler, name.replace(/[^A-Za-z0-9_]/g, "_"), source, "-ftz 2"))) throw new Error(`compile ${name}: ${rt.compiler.getErrorMessage()}`); + const controls = []; + const walk = (items) => { for (const it of items ?? []) { if (it.items) walk(it.items); else if (it.address) controls.push({ label: it.label, address: it.address }); } }; + walk(JSON.parse(g.factory.json).ui); + const entry = { g, controls }; + rt.cache.set(source, entry); + return entry; +} + +// Render `seconds` of one generator with named controls; returns channel 0 and the channel count. +// Multi-channel output is reported, not mixed, so a metric always describes a buffer someone can hear. +export async function renderOnce(entry, params, seconds) { + const p = await entry.g.createOfflineProcessor(SR, 512); + for (const [label, value] of Object.entries(params ?? {})) { + const bare = (t) => t.replace(/^\//, ""), c = entry.controls.find((x) => bare(x.label) === bare(label) || x.address === label); + if (!c) throw new Error(`no control "${label}" (has ${entry.controls.map((x) => x.label).join(", ") || "none"})`); + p.setParamValue(c.address, value); + } + const out = p.render(null, Math.round(SR * seconds)); + return { samples: out[0], channels: out.length }; +} + +// A Ding event is the instrument's note rendered per DingNote at root * 2^(semitones/12), scaled by commandGain * note.gain +// and mixed at the note's delay: DingsPlaybackHost's recipe, minus the audio device. +export async function renderDing(rt, instrument, instrumentSource, event, { noteSeconds, commandGain }) { + const entry = await compile(rt, `ding_${instrument.id}`, instrumentSource); + const last = Math.max(...event.notes.map((n) => n.delayMilliseconds)); + const mix = new Float32Array(Math.round(SR * (noteSeconds + last / 1000))); + for (const n of event.notes) { + const hz = instrument.rootFrequency * 2 ** (n.semitones / 12); + const { samples } = await renderOnce(entry, { [instrument.controlPath]: hz }, noteSeconds); + const off = Math.round((n.delayMilliseconds / 1000) * SR), g = commandGain * n.gain; + for (let i = 0; i < samples.length && off + i < mix.length; i++) mix[off + i] += samples[i] * g; + } + return { samples: mix, channels: 1 }; +} + +// 32-bit float mono WAV, so overs above 1.0 survive to disk instead of being clamped on the way out. +export function wavFloat32(samples) { + const dataBytes = samples.length * 4, b = Buffer.alloc(44 + dataBytes); + b.write("RIFF", 0); b.writeUInt32LE(36 + dataBytes, 4); b.write("WAVEfmt ", 8); b.writeUInt32LE(16, 16); + b.writeUInt16LE(3, 20); b.writeUInt16LE(1, 22); b.writeUInt32LE(SR, 24); b.writeUInt32LE(SR * 4, 28); b.writeUInt16LE(4, 32); b.writeUInt16LE(32, 34); + b.write("data", 36); b.writeUInt32LE(dataBytes, 40); + for (let i = 0; i < samples.length; i++) b.writeFloatLE(samples[i], 44 + i * 4); + return b; +} +export function writeWav(path, samples) { mkdirSync(dirname(path), { recursive: true }); writeFileSync(path, wavFloat32(samples)); } + +export const readText = (p) => readFileSync(p, "utf8"); diff --git a/tools/aqua-feel/report.js b/tools/aqua-feel/report.js new file mode 100644 index 0000000..020b0d5 --- /dev/null +++ b/tools/aqua-feel/report.js @@ -0,0 +1,46 @@ +// Before/after table and the listening-trial correlation. +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { mean, spearman, permutationP } from "../aqua-trial/analyze.mjs"; +import { variants, SECONDS } from "../aqua-trial/logic.js"; +import { measure } from "./metrics.js"; +import { loadRuntime, compile, renderOnce } from "./render.js"; + +export const COMPARE_METRICS = ["samplePeak", "truePeakDb", "overSamples", "loudnessLufs", "crestDb", "centroidMedianHz", "noiseToToneDb", "noiseToToneADb", "onsetMs", "attackMs", "lowMotion"]; +const f = (v) => (typeof v === "number" ? (Number.isInteger(v) ? String(v) : v.toFixed(2)) : String(v)); + +export function compareTable(before, after, only) { + const b = new Map(before.items.map((i) => [i.id, i])), out = []; + for (const a of after.items) { + if ((only && !a.id.includes(only)) || !b.has(a.id) || !a.metrics || !b.get(a.id).metrics) continue; + out.push(`${a.id}`); + for (const k of COMPARE_METRICS) { + const x = b.get(a.id).metrics[k], y = a.metrics[k]; + if (x === undefined) continue; + const d = typeof x === "number" && typeof y === "number" ? (y - x >= 0 ? "+" : "") + (y - x).toFixed(2) : x === y ? "" : "changed"; + out.push(` ${k.padEnd(18)} ${f(x).padStart(10)} -> ${f(y).padStart(10)} ${d}`); + } + } + return out.length ? out.join("\n") : "no common items"; +} + +// Joins trial exports (aqua-trial) to feel metrics by rendering the same four variants, then asks the trial's own question +// of each metric: does it rank-correlate with the ratings (|rho| >= 0.5 and p < 0.05, fixed before any data)? With few +// listeners this is deliberately hard to meet; "no evidence" is the expected answer, and it is not evidence of absence. +export function correlate(exports, trialDir) { + return correlateAsync(exports, trialDir); +} +async function correlateAsync(exports, trialDir) { + const rt = await loadRuntime(), entry = await compile(rt, "thruster_trial", readFileSync(join(trialDir, "thruster-trial.dsp"), "utf8")); + const metricsBy = {}; + for (const v of variants()) metricsBy[v.id] = measure((await renderOnce(entry, v.params, SECONDS)).samples); + const records = exports.flatMap((e) => e.records); + const lines = [`${exports.length} listener export(s), ${records.length} ratings; variants rendered here at ${SECONDS} s`, "", "metric rho p n -> predicts?"]; + for (const k of ["noiseToToneDb", "noiseToToneADb", "loudnessLufs", "samplePeak", "rms", "centroidMedianHz", "fluxMean", "crestDb"]) { + const xs = records.map((r) => metricsBy[r.variant][k]), ys = records.map((r) => r.rating), rho = spearman(xs, ys), p = permutationP(xs, ys, rho); + lines.push(`${k.padEnd(18)} ${Number.isFinite(rho) ? rho.toFixed(2).padStart(6) : " n/a"} ${Number.isFinite(p) ? p.toFixed(3).padStart(6) : " n/a"} ${String(xs.length).padStart(3)} -> ${Number.isFinite(rho) && Math.abs(rho) >= 0.5 && p < 0.05 ? "PREDICTS" : "no evidence it predicts"}`); + } + lines.push("", `mean rating by variant: ${variants().map((v) => `${v.id} ${mean(records.filter((r) => r.variant === v.id).map((r) => r.rating)).toFixed(2)}`).join(", ")}`); + lines.push("Four variants are four distinct metric values, so every rank correlation here is really a statement about the variant ordering. Nothing was heard by this script."); + return lines.join("\n"); +} diff --git a/tools/aqua-feel/test.mjs b/tools/aqua-feel/test.mjs new file mode 100644 index 0000000..526c94f --- /dev/null +++ b/tools/aqua-feel/test.mjs @@ -0,0 +1,146 @@ +// Checks of the meter itself on synthetic signals with known answers, the gate's waiver bookkeeping, the WAV writer, the +// gallery, and the catalog. It renders no patch; `node feel.mjs run` does that. Nothing here hears anything. +// Usage: node test.mjs +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { SR, measure, truePeak, samplePeak, integratedLoudness, clipping, fft, timing } from "./metrics.js"; +import { gate } from "./gate.js"; +import { gallery } from "./gallery.js"; +import { wavFloat32 } from "./render.js"; +import { patchItems, dingItems } from "./catalog.js"; + +const here = dirname(fileURLToPath(import.meta.url)); +let n = 0; +const t = (name, fn) => { fn(); n++; console.log(`ok ${name}`); }; +const sine = (hz, amp, sec, ph = 0) => Float32Array.from({ length: Math.round(SR * sec) }, (_, i) => amp * Math.sin(2 * Math.PI * hz * i / SR + ph)); +let seed = 1; const rand = () => { seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0; return seed / 2 ** 32 - 0.5; }; +const noise = (amp, sec) => Float32Array.from({ length: Math.round(SR * sec) }, () => amp * 2 * rand()); +const decay = (x, tau) => x.map((v, i) => v * Math.exp(-i / SR / tau)); +const near = (a, b, tol, msg) => assert.ok(Math.abs(a - b) <= tol, `${msg}: ${a} vs ${b} (+/-${tol})`); + +t("fft: a bin-centred cosine lands in its bin", () => { + const re = Float64Array.from({ length: 256 }, (_, i) => Math.cos(2 * Math.PI * 16 * i / 256)), im = new Float64Array(256); + fft(re, im); near(Math.hypot(re[16], im[16]), 128, 1e-9, "bin 16"); near(Math.hypot(re[17], im[17]), 0, 1e-9, "bin 17"); +}); + +t("levels: a 0.5 sine reads peak 0.5, rms -9.03 dB, crest 3.01 dB, loudness -9.7 LUFS (BS.1770)", () => { + const m = measure(sine(440, 0.5, 2)); + near(m.samplePeak, 0.5, 1e-6, "peak"); near(m.rmsDb, -9.03, 0.05, "rms"); near(m.crestDb, 3.01, 0.05, "crest"); near(m.loudnessLufs, -9.7, 0.2, "LUFS"); +}); + +t("loudness: -6 dB is -6 LU; silence is null", () => { + near(integratedLoudness(sine(1000, 0.5, 2)) - integratedLoudness(sine(1000, 0.25, 2)), 6.02, 0.01, "6 dB step"); + assert.equal(integratedLoudness(new Float32Array(SR)), null); +}); + +t("loudness: gating drops the silent tail (the naive 3 s mean would read 7.8 dB lower); block-edge dilution stays under 2 dB", () => { + const x = new Float32Array(SR * 3); x.set(sine(1000, 0.5, 0.5)); + near(integratedLoudness(x), integratedLoudness(sine(1000, 0.5, 0.5)), 2, "gated vs bare"); +}); + +t("true peak: a tone sampled between its crests exceeds the sample peak; a sample-aligned one does not", () => { + const x = sine(12000, 0.9, 0.1, Math.PI / 4); // samples sit 45 degrees off the crests + assert.ok(samplePeak(x) < 0.7 && truePeak(x) > 0.85 && truePeak(x) < 0.95, `${samplePeak(x)} ${truePeak(x)}`); + const y = sine(1000, 0.5, 0.1); near(truePeak(y), 0.5, 0.01, "oversampling must not invent peaks on a slow tone"); +}); + +t("clipping: counts samples over 1.0 and flat-top runs, ignores a clean 0.99", () => { + const x = sine(100, 2, 0.1).map((v) => Math.max(-1.2, Math.min(1.2, v))); + const c = clipping(x); assert.ok(c.overSamples > 100 && c.flatTopRuns > 0); + const y = clipping(sine(100, 0.99, 0.1)); assert.equal(y.overSamples, 0); assert.equal(y.flatTopRuns, 0); +}); + +t("timing: onset latency is where the sound starts, attack is the first-note rise", () => { + const x = new Float32Array(SR); x.set(sine(1000, 0.5, 0.5).map((v, i) => v * Math.min(1, i / (0.01 * SR))), Math.round(0.02 * SR)); + const tm = timing(x); near(tm.onsetMs, 20 + 1, 1.5, "onset"); near(tm.attackMs, 8, 1.5, "10-90% of a 10 ms ramp is 8 ms"); +}); + +t("timing: a two-note event reports the first note's attack, not the ramp to the louder second note", () => { + const x = new Float32Array(SR * 2); + x.set(decay(sine(500, 0.3, 0.3), 0.05)); const b = decay(sine(800, 0.9, 0.5), 0.1); for (let i = 0; i < b.length; i++) x[Math.round(0.4 * SR) + i] += b[i]; + assert.ok(timing(x).attackMs < 3, `${timing(x).attackMs}`); +}); + +t("noise-to-tone: a sine reads far tonal, white noise far noisy, and the A-weighted ratio sees a quiet 1 kHz hiss under a loud 40 Hz tone", () => { + assert.ok(measure(sine(440, 0.5, 2)).noiseToToneDb < -30); + assert.ok(measure(noise(0.3, 2)).noiseToToneDb > 20); + const low = sine(40, 0.5, 3), hiss = noise(0.02, 3), x = low.map((v, i) => v + hiss[i]), m = measure(x); + assert.ok(m.noiseToToneADb > m.noiseToToneDb + 8, `flat ${m.noiseToToneDb}, A-weighted ${m.noiseToToneADb}`); +}); + +t("noise-to-tone: a noise-excited resonance is not called a tone, a steady sine is (temporal smoothness)", () => { + // two-pole resonator at 600 Hz, Q~25, fed with noise: spectrally narrow but randomly modulated + const w = 2 * Math.PI * 600 / SR, r = 1 - w / 50, a1 = -2 * r * Math.cos(w), a2 = r * r, e = noise(1, 3), y = new Float32Array(e.length); + for (let i = 2; i < y.length; i++) y[i] = e[i] - a1 * y[i - 1] - a2 * y[i - 2]; + const peak = samplePeak(y); const ring = y.map((v) => (0.4 * v) / peak); + assert.ok(measure(ring).noiseToToneDb > measure(sine(600, 0.4, 3)).noiseToToneDb + 25, "ringing noise must read noisier than a sine"); +}); + +t("low motion: a held tone and held noise are flagged; a decaying bell is not; under 1 s is not judged", () => { + assert.equal(measure(sine(440, 0.5, 2)).lowMotion, true); + assert.equal(measure(noise(0.3, 2)).lowMotion, true); + assert.equal(measure(decay(sine(880, 0.5, 2), 0.25)).lowMotion, false); + assert.equal(measure(sine(440, 0.5, 0.6)).lowMotion, false); +}); + +t("centroid: follows a sweep upward", () => { + const x = Float32Array.from({ length: SR * 2 }, (_, i) => 0.5 * Math.sin(2 * Math.PI * (200 * i / SR + 1000 * (i / SR) ** 2 / 2))); + const c = measure(x).centroidCurve; assert.ok(c.at(-2).v > c[1].v * 3, `${c[1].v} -> ${c.at(-2).v}`); +}); + +t("silence and non-finite: reported, not crashed on", () => { + assert.equal(measure(new Float32Array(SR)).silent, true); + const x = sine(440, 0.5, 0.1); x[10] = NaN; const m = measure(x); assert.equal(m.broken, true); assert.equal(m.nonFinite, 1); +}); + +const item = (id, group, metrics) => ({ id, group, metrics: { nonFinite: 0, silent: false, overSamples: 0, truePeakDb: -6, lowMotion: false, ...metrics } }); +const rules = [{ group: "all", metric: "overSamples", equals: 0, why: "clips" }, { group: "ding", metric: "onsetMs", max: 5, why: "late" }, { group: "all", metric: "truePeakDb", max: -1, level: "warn", why: "headroom" }]; + +t("gate: failing rule fails; group scoping respected; warn does not fail", () => { + const g = gate({ items: [item("a", "patch", { overSamples: 3, onsetMs: 50 }), item("b", "ding", { onsetMs: 50 }), item("c", "patch", { truePeakDb: -0.5 })] }, { rules }); + assert.equal(g.pass, false); assert.deepEqual(g.failures.map((f) => `${f.id}:${f.metric}`), ["a:overSamples", "b:onsetMs"]); assert.equal(g.warnings.length, 1); +}); + +t("gate: a waiver downgrades a failure, a stale waiver fails, partial runs skip the stale check", () => { + const rep = { items: [item("a", "patch", { overSamples: 3 }), item("c", "patch", {})] }; + const waivers = [{ id: "a", metric: "overSamples", reason: "r" }]; + assert.equal(gate(rep, { rules, waivers }).pass, true); assert.equal(gate(rep, { rules, waivers }).waived.length, 1); + const stale = gate(rep, { rules, waivers: [...waivers, { id: "c", metric: "overSamples", reason: "r" }] }); + assert.equal(stale.pass, false); assert.match(stale.failures[0].why, /stale waiver/); + assert.equal(gate(rep, { rules, waivers: [{ id: "c", metric: "overSamples", reason: "r" }] }, { partial: true }).pass, false); // a still fails +}); + +t("gate: a render error, NaN output, or glob rule id is handled", () => { + const g = gate({ items: [{ id: "x", group: "patch", error: "boom" }, { id: "y", group: "patch", metrics: { broken: true, nonFinite: 2 } }] }, { rules }); + assert.equal(g.failures.length, 2); + const g2 = gate({ items: [item("thruster@rpm300", "patch", { onsetMs: 1, ntr: 9 })] }, { rules: [{ group: "patch", id: "thruster@*", metric: "ntr", max: 5, why: "w" }] }); + assert.equal(g2.pass, false); +}); + +t("thresholds.json: every rule names a metric and a why; every waiver names a reason and a follow-up", () => { + const th = JSON.parse(readFileSync(join(here, "thresholds.json"), "utf8")); + for (const r of th.rules) { assert.ok(r.metric && r.why && ["all", "patch", "ding"].includes(r.group), JSON.stringify(r)); assert.ok(["min", "max", "equals"].some((k) => k in r)); } + for (const w of th.waivers) assert.ok(w.id && w.metric && w.reason && /^aqua-body:follow_up:/.test(w.followUp), JSON.stringify(w)); +}); + +t("wav: 32-bit float mono header, length, and samples above 1.0 survive", () => { + const b = wavFloat32(Float32Array.from([0, 2.5, -1.5])); + assert.equal(b.toString("ascii", 0, 4), "RIFF"); assert.equal(b.readUInt16LE(20), 3); assert.equal(b.readUInt16LE(34), 32); assert.equal(b.readUInt32LE(24), SR); + assert.equal(b.readUInt32LE(40), 12); assert.equal(b.readFloatLE(48), 2.5); assert.equal(b.length, 44 + 12); +}); + +t("catalog: the playground patches with the thruster fanned to four rpm, and 9 events on 4 instruments (36 Dings)", () => { + const p = patchItems(), d = dingItems(); + assert.equal(p.filter((i) => i.id.startsWith("thruster")).length, 4); assert.ok(p.length >= 41 && p.every((i) => i.source.includes("process"))); + assert.equal(d.length, 36); assert.ok(new Set(d.map((i) => i.id)).size === 36); +}); + +t("gallery: says on its face that nothing was heard, escapes ids, marks failing metrics", () => { + const rep = { sampleRate: SR, libfaust: "x", gate: { pass: false, failures: [{ id: "a Date: Thu, 5 Nov 2026 15:42:13 +0000 Subject: [PATCH 014/124] aqua-feel: review fixes (attack on low tones, disarmed guards, bounded waivers, drift test) - attack: peak-hold envelope and a 150 ms window; a 261 Hz tone no longer reads its first half-cycle as the attack (warm-bell 0.67 ms -> 3.8 ms, declared 4 ms). - gate: a rule whose id matches no item fails a full run; waivers carry a bound and cover only up to it; a missing metric fails its rule; silent items fail once; --only runs gate as partial; silent threshold is -70 dBFS. - DingCatalogTests: lowered Dings fed to the meter must match the catalog. - README states NTR window/Q dependence, short-buffer loudness padding and the assumed Ding command gain; faust-toolchain-boundary notes the v5 manifest predates the mix change. Co-Authored-By: Claude Sonnet 5.5 --- docs/faust-toolchain-boundary.md | 4 +- tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs | 34 +++++++++++ tools/aqua-feel/README.md | 21 ++++--- tools/aqua-feel/feel.mjs | 6 +- tools/aqua-feel/gallery.js | 2 +- tools/aqua-feel/gate.js | 56 +++++++++++++------ tools/aqua-feel/metrics.js | 45 +++++++++------ tools/aqua-feel/test.mjs | 48 +++++++++++++++- tools/aqua-feel/thresholds.json | 16 +++--- 9 files changed, 173 insertions(+), 59 deletions(-) diff --git a/docs/faust-toolchain-boundary.md b/docs/faust-toolchain-boundary.md index 5027d99..ee46cae 100644 --- a/docs/faust-toolchain-boundary.md +++ b/docs/faust-toolchain-boundary.md @@ -108,7 +108,9 @@ home whose `lib/` has `libfaust.so` and whose `share/faust` has both. listen. `docs/renders/thruster-v5-manifest.json` is its output for `patches/thruster/thruster.dsp` at PR #3 head `c6561da`, 4 s per case. The render is deterministic (two reruns byte-identical); the 2026-10-31 sweep file is a 6 s -render, which is why its hash differs from a 4 s sweep. +render, which is why its hash differs from a 4 s sweep. That manifest describes the mix at `c6561da`; +`patches/thruster/thruster.dsp` changed on 2026-11-05 (lower idle noise floors, rumble low-pass opens at low load; see +`docs/renders/aqua-feel-2026-11-05.md`), so its `dspSha256` and WAV hashes no longer match the repo's patch. ## Invariants diff --git a/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs b/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs index 4c45a01..5e6f9a6 100644 --- a/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs +++ b/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using AquaSynth.Dings; namespace AquaSynth.Dsl.Tests; @@ -32,4 +33,37 @@ public sealed class DingCatalogTests foreach (var pair in dingEvent.Notes.Zip(dingEvent.Notes.Skip(1))) Assert.InRange(pair.Second.DelayMilliseconds - pair.First.DelayMilliseconds, 180, 320); } + + // tools/aqua-feel measures the lowered files in tools/aqua-feel/lowered-dings; regenerate them with + // `dotnet run --project tools/AquaLower -- --dings tools/aqua-feel/lowered-dings` when the catalog changes. + [Fact] + public void LoweredDingsFedToTheFeelMeterMatchTheCatalog() + { + var dir = Path.Combine(RepositoryRoot(), "tools", "aqua-feel", "lowered-dings"); + foreach (var instrument in DingCatalog.Instruments.Values) + { + var expected = FaustEmitter.EmitScript(instrument.Script, new FaustExportOptions("dings_" + instrument.Id.Replace('-', '_'))).Source; + Assert.Equal(expected, File.ReadAllText(Path.Combine(dir, instrument.Id + ".dsp"))); + } + + using var doc = JsonDocument.Parse(File.ReadAllText(Path.Combine(dir, "dings.json"))); + var instruments = doc.RootElement.GetProperty("instruments").EnumerateArray().ToDictionary(e => e.GetProperty("id").GetString()!); + Assert.Equal(DingCatalog.Instruments.Keys.Order(), instruments.Keys.Order()); + foreach (var instrument in DingCatalog.Instruments.Values) + Assert.Equal(instrument.RootFrequency, instruments[instrument.Id].GetProperty("rootFrequency").GetSingle()); + var events = doc.RootElement.GetProperty("events").EnumerateArray().ToDictionary(e => e.GetProperty("id").GetString()!); + Assert.Equal(DingCatalog.Events.Keys.Order(), events.Keys.Order()); + foreach (var ev in DingCatalog.Events.Values) + { + var notes = events[ev.Id].GetProperty("notes").EnumerateArray().Select(n => (n.GetProperty("semitones").GetDouble(), n.GetProperty("delayMilliseconds").GetInt32(), n.GetProperty("gain").GetSingle())).ToArray(); + Assert.Equal(ev.Notes.Select(n => (n.Semitones, n.DelayMilliseconds, n.Gain)).ToArray(), notes); + } + } + + private static string RepositoryRoot() + { + var dir = new DirectoryInfo(AppContext.BaseDirectory); + while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "AquaSynth.sln"))) dir = dir.Parent; + return dir?.FullName ?? throw new InvalidOperationException("AquaSynth.sln not found above the test binaries."); + } } diff --git a/tools/aqua-feel/README.md b/tools/aqua-feel/README.md index 0526140..5d7d8e4 100644 --- a/tools/aqua-feel/README.md +++ b/tools/aqua-feel/README.md @@ -11,10 +11,10 @@ The WAVs and the gallery exist so a person can press play. ``` (cd ../aqua-playground && npm ci) # faustwasm runtime, once -node test.mjs # 20 checks of the meter on synthetic signals; renders no patch +node test.mjs # 26 checks of the meter on synthetic signals; renders no patch node feel.mjs run # render 81 items (~15 s), write out/{report.json,index.html,wav/}, gate; exit 1 on failure -node feel.mjs run --only thruster # a subset; --out DIR; --no-gate -node feel.mjs gate out/report.json # re-gate a saved report +node feel.mjs run --only thruster # a subset (gate skips id-rule and waiver bookkeeping); --out DIR; --no-gate +node feel.mjs gate out/report.json # re-gate a saved report (--partial for a subset) node feel.mjs compare before.json after.json [--only SUBSTR] # before/after table node feel.mjs correlate trial-export.json ... # feel metrics vs aqua-trial listener ratings ``` @@ -29,7 +29,8 @@ non-zero on any unwaived failure or stale waiver. No CI runner exists in this re `advanced/additive-pad` and `advanced/electro-drop-demo` lower to ~1.5 MB of Faust each and are not in the playground, so not here. - Every `DingCatalog` event on every instrument (9 x 4 = 36), mixed the way `DingsPlaybackHost` does it: each note rendered at `root * 2^(semitones/12)` for 1.5 s, scaled by command gain 0.6 and the note gain, placed at its delay. - `lowered-dings/` is `dotnet run --project tools/AquaLower -- --dings tools/aqua-feel/lowered-dings`. + `lowered-dings/` is `dotnet run --project tools/AquaLower -- --dings tools/aqua-feel/lowered-dings`; `DingCatalogTests.LoweredDingsFedToTheFeelMeterMatchTheCatalog` fails when it drifts from `DingCatalog.cs`. + The command gain 0.6 is an assumption (`DingsPlaybackHost` takes it from the caller as 0..1), so the Ding loudness window depends on it. Render path: the same faustwasm offline processor the playground and the listening trial use (libfaust 2.90.x, `-ftz 2`), mono channel 0. It is **not** the daemon's native libfaust path (`-vec`); the same Faust source should render alike, but @@ -40,19 +41,21 @@ nobody has diffed the two. | metric | meaning | limits | |---|---|---| | `onsetMs` | first sample at or above max(-40 dB re peak, -70 dBFS), from note-on | Offline render has no device latency; this is the patch's own lead-in only | -| `attackMs`, `attackSlopeDbPerMs` | 10% to 90% of the FIRST peak (running max until the envelope falls 3 dB) on a 0.17 ms envelope | A faster attack reads as one hop. Meaningless on sustained noise: the "first peak" is just the first 3 dB dip | +| `attackMs`, `attackSlopeDbPerMs`, `attackWindowLimited` | 10% to 90% of the envelope maximum inside the first 150 ms after onset, on a 0.17 ms peak-hold envelope (30 ms release, so a low tone's zero crossings are not read as dips) | A faster attack reads as one hop. A swell longer than 150 ms reports a lower bound and sets `attackWindowLimited`. The envelope is a peak follower, so a tone below ~30 Hz would still ripple | | `samplePeak`, `truePeakDb`, `overSamples`, `flatTopRuns` | peak, 4x-oversampled true peak, samples beyond 1.0, runs of 3+ samples at 0.999 | WAVs are float32 so overs survive to disk | -| `loudnessLufs` | BS.1770-4 integrated, mono, K-weighted, gated | A mono sound with no reference level; compare items, do not read it as a delivered loudness | +| `loudnessLufs` | BS.1770-4 integrated, mono, K-weighted (48 kHz coefficients; renders are fixed at 48 kHz), gated | A mono sound with no reference level; compare items, do not read it as a delivered loudness. A buffer under 400 ms is zero-padded to one block and reads low (0.1 s of full 1 kHz sine: -9.0, true -3.0); every shipped item is 1.5 s or longer | | `crestDb`, `rmsDb` | over the active span (onset to last frame within 50 dB of peak) | | | `centroidMedianHz`, `centroidCurve`, `fluxMean`, `fluxCurve` | STFT 2048/512 over active frames; flux is the change between unit-norm spectra | Flux on stationary noise is high; it is reported, not gated | -| `noiseToToneDb`, `noiseToToneADb` | energy not in stable spectral lines vs energy in them, flat and A-weighted | A heuristic split (see `metrics.js`): steady or decaying partials read tonal, noise-excited resonances read noise, gliding partials read noise. 8192-point window for spans of 1 s or more, else 2048, so compare the same sound across edits, not different sounds | +| `noiseToToneDb`, `noiseToToneADb` | energy not in stable spectral lines vs energy in them, flat and A-weighted | A heuristic split (see `metrics.js`): steady or decaying partials read tonal, noise-excited resonances read noise, gliding partials read noise. 8192-point window for spans of 1 s or more, else 2048, so compare the same sound across edits, not different sounds. It is window- and Q-dependent: white noise through a Q20 band-pass at 1 kHz reads as noise over 3 s (8192 window) but partly tonal over 0.5 s (2048 window), and a Q100 resonance reads tonal. The thruster rpm caps are fit to this heuristic at its 8192 window | | `lowMotion` | span of 1 s or more with centroid spread under 0.08 octave and level range under 6 dB | The song-swarm collapse shape (docs/music-agent-orchestration-lessons.md): a held drone or a wash. A legitimate sustained drone is flagged too | ## The gate `thresholds.json`: rules scoped to `all`, `patch`, `ding` or an id glob, each with a `why`; `level: warn` prints without failing. -`waivers` turn a known failure into a printed line and must name a reason and a follow-up id; a waiver that no longer matches -a failing rule is itself a failure, so it is deleted when the thing it excuses is fixed. The numbers were chosen after looking +`waivers` turn a known failure into a printed line and must name a reason and a follow-up id; a numeric waiver carries a bound +(`max`/`min`) and covers the item only up to it, so a waived item cannot get worse unseen. A waiver that no longer matches a +failing rule, and a rule with an `id` that matches no item (a renamed or dropped guard), are failures on a full run, so waivers +are deleted when the thing they excuse is fixed and a rename cannot silently disarm a cap. A missing metric fails its rule. The numbers were chosen after looking at the shipped renders. They are tripwires, not taste. Current waivers: `sfxr-classic-classic-sfxr-abstract-golf` (+0.9 dBTP, -5.3 LUFS, held noise) and `sfxr-explosion` (3 s of diff --git a/tools/aqua-feel/feel.mjs b/tools/aqua-feel/feel.mjs index 70bf702..f5d220c 100644 --- a/tools/aqua-feel/feel.mjs +++ b/tools/aqua-feel/feel.mjs @@ -3,7 +3,7 @@ // report.json plus a static gallery, and gates the numbers against thresholds.json. // NOTHING HERE HEARS ANYTHING. These are measurements of rendered buffers; a number is evidence, never a verdict. // Usage: node feel.mjs run [--out DIR] [--only SUBSTR] [--no-gate] render, measure, write report + gallery, gate -// node feel.mjs gate REPORT.json [THRESHOLDS.json] re-gate an existing report +// node feel.mjs gate REPORT.json [THRESHOLDS.json] [--partial] re-gate a report (--partial: a subset; skips id-rule and waiver bookkeeping) // node feel.mjs compare BEFORE.json AFTER.json [--only SUBSTR] before/after table // node feel.mjs correlate TRIAL_EXPORT.json ... feel metrics vs listening-trial ratings import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; @@ -45,7 +45,7 @@ async function run() { } const thresholds = readJson(join(here, "thresholds.json")); const report = { schema: "aqua-feel.report.v1", caveat: CAVEAT, libfaust: rt.version, sampleRate: SR, items: records }; - report.gate = gate(report, thresholds); + report.gate = gate(report, thresholds, { partial: Boolean(only) }); mkdirSync(out, { recursive: true }); writeFileSync(join(out, "report.json"), JSON.stringify(report, null, 1)); writeFileSync(join(out, "index.html"), gallery(report)); @@ -56,7 +56,7 @@ async function run() { const cmds = { run, gate() { - const report = readJson(args[0]), g = gate(report, readJson(args[1] ?? join(here, "thresholds.json"))); + const partial = bool("--partial"), report = readJson(args[0]), g = gate(report, readJson(args[1] ?? join(here, "thresholds.json")), { partial }); console.log(formatGate(g)); process.exit(g.pass ? 0 : 1); }, compare() { const only = flag("--only"); console.log(compareTable(readJson(args[0]), readJson(args[1]), only)); }, diff --git a/tools/aqua-feel/gallery.js b/tools/aqua-feel/gallery.js index fcb21c6..b800729 100644 --- a/tools/aqua-feel/gallery.js +++ b/tools/aqua-feel/gallery.js @@ -13,7 +13,7 @@ function plot(points, { w = 260, h = 56, ymin, ymax, log = false, color }) { } const ROWS = [ - ["onset ms", "onsetMs", 2], ["attack ms (10→90%, first peak)", "attackMs", 2], ["attack slope dB/ms", "attackSlopeDbPerMs", 1], + ["onset ms", "onsetMs", 2], ["attack ms (10→90% in first 150 ms)", "attackMs", 2], ["attack window-limited", "attackWindowLimited", 0], ["attack slope dB/ms", "attackSlopeDbPerMs", 1], ["sample peak", "samplePeak", 3], ["true peak dBTP", "truePeakDb", 1], ["over-1.0 samples", "overSamples", 0], ["flat-top runs", "flatTopRuns", 0], ["loudness LUFS", "loudnessLufs", 1], ["crest dB", "crestDb", 1], ["centroid median Hz", "centroidMedianHz", 0], ["flux mean", "fluxMean", 3], ["noise-to-tone dB (flat)", "noiseToToneDb", 1], ["noise-to-tone dB (A-weighted)", "noiseToToneADb", 1], ["level range dB", "envRangeDb", 1], ["centroid spread (oct)", "centroidSpreadOct", 2], diff --git a/tools/aqua-feel/gate.js b/tools/aqua-feel/gate.js index f172bba..2015d94 100644 --- a/tools/aqua-feel/gate.js +++ b/tools/aqua-feel/gate.js @@ -1,43 +1,63 @@ // Threshold gate over a report. Rules come from thresholds.json: { group: all|patch|ding, id?: glob, metric, min?, max?, -// equals?, level?: fail|warn, why }. A waiver { id, metric, reason, followUp } turns a known failure into a printed -// 'waived' line, and a waiver that no longer matches a failing rule is itself a failure, so waivers get deleted when -// the thing they excuse is fixed. Thresholds are tripwires for a listener to check, not a judgement of the sound. +// equals?, level?: fail|warn, why }. A waiver { id, metric, reason, followUp, max?|min? } turns a known failure into a +// printed 'waived' line, but only up to the bound it states: a numeric rule needs a waiver bound on the same side +// (max for a max rule, min for a min rule) and the value must stay inside it, so a waived item cannot get worse unseen. +// A waiver that matches nothing failing, and a rule with an `id` that matches no item, are failures on a full run, so +// waivers get deleted when the thing they excuse is fixed and a catalog rename cannot silently disarm a guard. +// Thresholds are tripwires for a listener to check, not a judgement of the sound. const glob = (pattern) => new RegExp("^" + pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$"); const get = (m, path) => path.split(".").reduce((o, k) => o?.[k], m); +const fmt = (v) => (typeof v === "number" ? +v.toFixed(2) : v); function violation(rule, value) { - if (value === undefined || value === null || Number.isNaN(value)) return rule.min !== undefined || rule.max !== undefined ? "no value" : null; + if (value === undefined || value === null || Number.isNaN(value)) return "no value"; if (rule.equals !== undefined && value !== rule.equals) return `${value} (want ${rule.equals})`; if (rule.max !== undefined && !(value <= rule.max)) return `${fmt(value)} (max ${rule.max})`; if (rule.min !== undefined && !(value >= rule.min)) return `${fmt(value)} (min ${rule.min})`; return null; } -const fmt = (v) => (typeof v === "number" ? +v.toFixed(2) : v); + +// Does waiver `w` cover this violation? Boolean/equals rules: any waiver for the metric. Numeric rules: the waiver must +// state a bound on the violated side and the value must lie within it. +function covers(w, rule, value) { + if (rule.equals !== undefined) return true; + if (typeof value !== "number" || Number.isNaN(value)) return false; + if (rule.max !== undefined && !(value <= rule.max)) return typeof w.max === "number" && value <= w.max; + if (rule.min !== undefined && !(value >= rule.min)) return typeof w.min === "number" && value >= w.min; + return false; +} export function gate(report, thresholds, { partial = false } = {}) { - const failures = [], warnings = [], waived = [], hits = new Set(); + const failures = [], warnings = [], waived = [], hits = new Set(), armed = new Set(); const waivers = thresholds.waivers ?? []; for (const it of report.items) { if (it.error || it.metrics?.broken) { failures.push({ id: it.id, metric: "render", detail: it.error ?? `${it.metrics.nonFinite} non-finite samples`, why: "item did not render cleanly" }); continue; } - for (const rule of thresholds.rules) { - if (rule.group !== "all" && rule.group !== it.group) continue; - if (rule.id && !glob(rule.id).test(it.id)) continue; - const detail = violation(rule, get(it.metrics, rule.metric)); - if (!detail) continue; + const silent = it.metrics?.silent === true; + if (silent) failures.push({ id: it.id, metric: "silent", detail: "peak under -70 dBFS", why: "an item that renders nothing" }); + thresholds.rules.forEach((rule, ri) => { + if (rule.group !== "all" && rule.group !== it.group) return; + if (rule.id && !glob(rule.id).test(it.id)) return; + armed.add(ri); + if (silent) return; // reported once above; its other metrics do not exist + const value = get(it.metrics, rule.metric), detail = violation(rule, value); + if (!detail) return; const entry = { id: it.id, metric: rule.metric, detail, why: rule.why }; - const w = waivers.findIndex((x) => x.metric === rule.metric && glob(x.id).test(it.id)); - if (rule.level === "warn") warnings.push(entry); - else if (w >= 0) { hits.add(w); waived.push({ ...entry, reason: waivers[w].reason, followUp: waivers[w].followUp }); } + if (rule.level === "warn") { warnings.push(entry); return; } + const w = waivers.findIndex((x) => x.metric === rule.metric && glob(x.id).test(it.id) && covers(x, rule, value)); + if (w >= 0) { hits.add(w); waived.push({ ...entry, reason: waivers[w].reason, followUp: waivers[w].followUp }); } else failures.push(entry); - } + }); } - if (!partial) waivers.forEach((w, i) => { if (!hits.has(i)) failures.push({ id: w.id, metric: w.metric, detail: "waiver matches nothing failing", why: "stale waiver: delete it" }); }); - return { pass: failures.length === 0, items: report.items.length, failures, warnings, waived }; + if (!partial) { + thresholds.rules.forEach((r, i) => { if (r.id && !armed.has(i)) failures.push({ id: r.id, metric: r.metric, detail: "rule matches no item", why: "disarmed guard: the item was renamed or dropped" }); }); + waivers.forEach((w, i) => { if (!hits.has(i)) failures.push({ id: w.id, metric: w.metric, detail: "waiver matches nothing failing within its bound", why: "stale waiver: delete it (or the item got worse than the bound)" }); }); + } + return { pass: failures.length === 0, items: report.items.length, partial, failures, warnings, waived }; } export function formatGate(g) { const line = (e) => ` ${e.id} ${e.metric}: ${e.detail} [${e.why}]${e.reason ? `\n waived: ${e.reason}${e.followUp ? ` (${e.followUp})` : ""}` : ""}`; - const out = [`gate: ${g.pass ? "PASS" : "FAIL"} (${g.items} items, ${g.failures.length} failing, ${g.waived.length} waived, ${g.warnings.length} warnings)`]; + const out = [`gate: ${g.pass ? "PASS" : "FAIL"} (${g.items} items${g.partial ? ", partial run: id-rule and waiver bookkeeping skipped" : ""}, ${g.failures.length} failing, ${g.waived.length} waived, ${g.warnings.length} warnings)`]; for (const [title, list] of [["FAILING", g.failures], ["WAIVED", g.waived], ["WARNINGS", g.warnings]]) if (list.length) out.push(title, ...list.map(line)); out.push("", "Thresholds are tripwires for a listener to check. Passing means nothing was heard to be wrong; it does not mean it sounds right."); return out.join("\n"); diff --git a/tools/aqua-feel/metrics.js b/tools/aqua-feel/metrics.js index 4e4766a..75beea0 100644 --- a/tools/aqua-feel/metrics.js +++ b/tools/aqua-feel/metrics.js @@ -1,6 +1,7 @@ // Pure signal metrics for aqua-feel. Dependency-free; every function takes mono Float32Array/number[] at SR. // These are measurements of a rendered buffer. Nothing here hears anything, and no number is a verdict. export const SR = 48000; +export const SILENT_PEAK = 10 ** (-70 / 20); // a buffer whose peak is below -70 dBFS counts as silent const db = (x) => (x > 0 ? 20 * Math.log10(x) : -Infinity); const pdb = (x) => (x > 0 ? 10 * Math.log10(x) : -Infinity); const median = (xs) => { const s = Float64Array.from(xs).sort(); return s.length ? (s.length % 2 ? s[s.length >> 1] : (s[s.length / 2 - 1] + s[s.length / 2]) / 2) : NaN; }; @@ -68,33 +69,41 @@ export function integratedLoudness(x) { // ---- time structure ---------------------------------------------------------------------------------------------- const HOP = 8; // envelope hop in samples (0.167 ms) +// Peak-hold envelope: max |x| per hop, held with a 30 ms exponential release so the zero crossings of a low tone do not +// read as dips (a plain per-hop max does: a 261 Hz sine "falls" 100% twice per cycle). The attack stays instantaneous. +const RELEASE_S = 0.03; export function envelope(x) { - const env = new Float64Array(Math.ceil(x.length / HOP)); + const env = new Float64Array(Math.ceil(x.length / HOP)), hold = Math.exp(-HOP / SR / RELEASE_S); for (let i = 0; i < x.length; i++) { const a = Math.abs(x[i]); if (a > env[(i / HOP) | 0]) env[(i / HOP) | 0] = a; } + for (let i = 1; i < env.length; i++) env[i] = Math.max(env[i], env[i - 1] * hold); return env; } +const maxIndex = (a) => { let k = 0; for (let i = 1; i < a.length; i++) if (a[i] > a[k]) k = i; return k; }; const hopMs = (HOP / SR) * 1000; -// Onset: first sample at or above max(-40 dB re peak, -70 dBFS). Attack is measured on the FIRST peak: the running -// envelope maximum from the onset until the envelope falls 3 dB below it (so a two-note Ding reports its first note's -// attack, not a ramp to the second note's peak). 10% -> 90% of that first peak. The envelope hop is 0.167 ms, so an -// attack faster than that is reported as one hop (resolutionLimited). activeEnd = last envelope hop within 50 dB of the peak. +// Silent = peak under -70 dBFS. Onset: first sample at or above max(-40 dB re peak, -70 dBFS). Attack is measured inside +// the first 150 ms after the onset (shorter than the 180 ms minimum gap between Ding notes, so a later, louder note cannot +// stretch it): 10% -> 90% of the envelope's maximum within that window. If that maximum falls in the last tenth of the +// window the sound is still swelling and attackMs is only a lower bound (attackWindowLimited). The envelope hop is +// 0.167 ms, so an attack faster than that is reported as one hop (resolutionLimited). activeEnd = last envelope hop +// within 50 dB of the peak. +const ATTACK_WINDOW_S = 0.15; export function timing(x) { const peak = samplePeak(x); - if (!(peak > 0)) return { silent: true }; - const thr = Math.max(peak * 0.01, 10 ** (-70 / 20)); + if (!(peak >= SILENT_PEAK)) return { silent: true }; + const thr = Math.max(peak * 0.01, SILENT_PEAK); let onsetSample = 0; while (onsetSample < x.length && Math.abs(x[onsetSample]) < thr) onsetSample++; - const env = envelope(x), start = Math.floor(onsetSample / HOP); - let top = start, end = start; - for (let i = start; i < env.length; i++) { if (env[i] > env[top]) top = i; if (env[i] < env[top] * 0.708) break; end = i; } - const first = env[top], at = (f) => { let i = start; while (i < end && env[i] < first * f) i++; return i; }; + const env = envelope(x), start = Math.floor(onsetSample / HOP), end = Math.min(env.length - 1, start + Math.round(ATTACK_WINDOW_S * SR / HOP)); + let top = start; for (let i = start; i <= end; i++) if (env[i] > env[top]) top = i; + const first = env[top], at = (f) => { let i = start; while (i < top && env[i] < first * f) i++; return i; }; const i10 = at(0.1), i90 = at(0.9); const dt = Math.max(hopMs, (i90 - i10) * hopMs), floor = peak * 10 ** (-50 / 20); let last = env.length - 1; while (last > 0 && env[last] < floor) last--; return { silent: false, onsetMs: (onsetSample / SR) * 1000, attackMs: dt, attackSlopeDbPerMs: db(0.9 / 0.1) / dt, - resolutionLimited: i90 - i10 <= 1, activeStartSample: onsetSample, activeEndSample: Math.min(x.length, (last + 1) * HOP), - peakAtMs: (env.indexOf(Math.max(...env)) * HOP / SR) * 1000, firstPeak: first, firstPeakAtMs: top * hopMs, + resolutionLimited: i90 - i10 <= 1, attackWindowLimited: top - start > 0.9 * (end - start) && end - start > 10, + activeStartSample: onsetSample, activeEndSample: Math.min(x.length, (last + 1) * HOP), + peakAtMs: (maxIndex(env) * HOP / SR) * 1000, firstPeak: first, firstPeakAtMs: top * hopMs, }; } @@ -188,7 +197,7 @@ function toneNoiseSpan(frames) { // (23 Hz bins). Compare it between renders of the same sound, not across sounds of different lengths. Clamped to +/-60 dB. export function noiseToTone(x, t) { const spanS = (t.activeEndSample - t.activeStartSample) / SR, n = spanS >= 1 ? 8192 : 2048; - const frames = stft(x.slice(t.activeStartSample, t.activeEndSample), n, n / 4), maxE = Math.max(...frames.map((f) => f.energy)); + const frames = stft(x.slice(t.activeStartSample, t.activeEndSample), n, n / 4), maxE = frames.reduce((m, f) => Math.max(m, f.energy), 0); const live = frames.filter((f) => f.energy >= maxE * 1e-5), r = toneNoiseSpan(live); const ratio = (nz, tn) => Math.max(-60, Math.min(60, pdb(nz) - pdb(tn || 1e-30))); return { db: ratio(r.noise, r.tone), dbA: ratio(r.noiseA, r.toneA), window: n }; @@ -206,7 +215,7 @@ const downsample = (pts, n) => { // frame and inside the active span. Flux is the half-wave-rectified L2 change between consecutive unit-norm magnitude // spectra, so it tracks timbre change and not loudness change. export function spectral(x, t, curvePoints = 48) { - const all = stft(x), maxE = Math.max(...all.map((f) => f.energy)), t0 = t.activeStartSample / SR, t1 = t.activeEndSample / SR; + const all = stft(x), maxE = all.reduce((m, f) => Math.max(m, f.energy), 0), t0 = t.activeStartSample / SR, t1 = t.activeEndSample / SR; const idx = all.map((f, i) => (f.energy >= maxE * 1e-5 && f.t >= t0 - N / 2 / SR && f.t <= t1 + N / 2 / SR ? i : -1)).filter((i) => i >= 0); if (idx.length < 2) return { frames: idx.length, centroidMedianHz: NaN, centroidCurve: [], fluxCurve: [], fluxMean: 0, fluxP95: 0, centroidSpreadOct: 0, envRangeDb: 0, motion: 0, lowMotion: false, lowMotionReason: "fewer than 2 active frames" }; const cent = [], flux = [], hz = (k) => (k * SR) / N; @@ -220,7 +229,7 @@ export function spectral(x, t, curvePoints = 48) { prev = Float64Array.from(f.mag, (m) => m / norm); } const cs = cent.map((c) => Math.log2(Math.max(c.v, 20))), fl = flux.slice(3).map((f) => f.v), fe = idx.map((i) => pdb(all[i].energy)); - const centroidSpreadOct = sd(cs), envRangeDb = Math.max(...fe) - Math.min(...fe), fluxMean = mean(fl.length ? fl : [0]); + const centroidSpreadOct = sd(cs), envRangeDb = fe.reduce((a, b) => Math.max(a, b), -Infinity) - fe.reduce((a, b) => Math.min(a, b), Infinity), fluxMean = mean(fl.length ? fl : [0]); // Low motion = the sound stays put: timbre barely moves AND level barely moves, over a span long enough to matter. // A decaying bell has a large level range, so it is not flagged; a held drone or a pink wash is. Flux is reported // but not used: stationary noise has high flux (periodogram scatter) while going nowhere. @@ -245,12 +254,12 @@ export function measure(x, { curvePoints = 48 } = {}) { const peak = samplePeak(x), nonFinite = x.reduce((n, v) => n + (Number.isFinite(v) ? 0 : 1), 0); if (nonFinite) return { nonFinite, silent: false, broken: true }; const t = timing(x); - if (t.silent) return { silent: true, nonFinite: 0, samplePeak: 0 }; + if (t.silent) return { silent: true, nonFinite: 0, samplePeak: peak }; const tp = truePeak(x), c = crest(x, t), sp = spectral(x, t, curvePoints), clip = clipping(x), nt = noiseToTone(x, t); return { silent: false, nonFinite: 0, samplePeak: peak, samplePeakDb: db(peak), truePeak: tp, truePeakDb: db(tp), ...clip, loudnessLufs: integratedLoudness(x), rms: c.rms, rmsDb: c.rmsDb, crestDb: c.crestDb, - onsetMs: t.onsetMs, attackMs: t.attackMs, attackSlopeDbPerMs: t.attackSlopeDbPerMs, attackResolutionLimited: t.resolutionLimited, peakAtMs: t.peakAtMs, + onsetMs: t.onsetMs, attackMs: t.attackMs, attackSlopeDbPerMs: t.attackSlopeDbPerMs, attackResolutionLimited: t.resolutionLimited, attackWindowLimited: t.attackWindowLimited, peakAtMs: t.peakAtMs, activeMs: ((t.activeEndSample - t.activeStartSample) / SR) * 1000, noiseToToneDb: nt.db, noiseToToneADb: nt.dbA, noiseToToneWindow: nt.window, envelopeCurve: envelopeCurve(x), ...sp, }; } diff --git a/tools/aqua-feel/test.mjs b/tools/aqua-feel/test.mjs index 526c94f..50e140d 100644 --- a/tools/aqua-feel/test.mjs +++ b/tools/aqua-feel/test.mjs @@ -57,12 +57,27 @@ t("timing: onset latency is where the sound starts, attack is the first-note ris const tm = timing(x); near(tm.onsetMs, 20 + 1, 1.5, "onset"); near(tm.attackMs, 8, 1.5, "10-90% of a 10 ms ramp is 8 ms"); }); -t("timing: a two-note event reports the first note's attack, not the ramp to the louder second note", () => { +t("timing: a two-note event reports the first note's attack, even when a louder note follows 200 ms later before the first has decayed", () => { const x = new Float32Array(SR * 2); - x.set(decay(sine(500, 0.3, 0.3), 0.05)); const b = decay(sine(800, 0.9, 0.5), 0.1); for (let i = 0; i < b.length; i++) x[Math.round(0.4 * SR) + i] += b[i]; + x.set(decay(sine(500, 0.3, 0.6), 0.5)); const b = decay(sine(800, 0.9, 0.5), 0.1); for (let i = 0; i < b.length; i++) x[Math.round(0.2 * SR) + i] += b[i]; assert.ok(timing(x).attackMs < 3, `${timing(x).attackMs}`); }); +t("timing: a swell longer than the 150 ms attack window is flagged window-limited", () => { + assert.equal(timing(sine(220, 0.5, 2).map((v, i) => v * i / (2 * SR))).attackWindowLimited, true); + assert.equal(timing(decay(sine(220, 0.5, 1), 0.2)).attackWindowLimited, false); +}); + +t("attack: a low tone's ramp is not mistaken for its zero crossings (261 Hz, 30 ms ramp; 220 Hz, 2 s swell)", () => { + const ramp = (hz, ms) => { const x = sine(hz, 0.5, 1); return x.map((v, i) => v * Math.min(1, i / (ms / 1000 * SR))); }; + for (const hz of [130, 261.6, 523, 1000]) near(timing(ramp(hz, 30)).attackMs, 24, 3, `${hz} Hz, 30 ms ramp`); + assert.ok(timing(sine(220, 0.5, 2).map((v, i) => v * i / (2 * SR))).attackMs > 100, "a 2 s swell is not a click"); +}); + +t("silent: a -80 dBFS tone is silent, a -60 dBFS tone is not", () => { + assert.equal(measure(sine(1000, 1e-4, 1)).silent, true); assert.equal(measure(sine(1000, 1e-3, 1)).silent, false); +}); + t("noise-to-tone: a sine reads far tonal, white noise far noisy, and the A-weighted ratio sees a quiet 1 kHz hiss under a loud 40 Hz tone", () => { assert.ok(measure(sine(440, 0.5, 2)).noiseToToneDb < -30); assert.ok(measure(noise(0.3, 2)).noiseToToneDb > 20); @@ -112,6 +127,31 @@ t("gate: a waiver downgrades a failure, a stale waiver fails, partial runs skip assert.equal(gate(rep, { rules, waivers: [{ id: "c", metric: "overSamples", reason: "r" }] }, { partial: true }).pass, false); // a still fails }); +t("gate: a waiver covers only up to its stated bound; a numeric waiver without a bound covers nothing", () => { + const r = [{ group: "all", metric: "truePeakDb", max: 0, why: "tp" }]; + const mk = (tp) => ({ items: [item("g", "patch", { truePeakDb: tp })] }); + const w = [{ id: "g", metric: "truePeakDb", max: 1, reason: "r" }]; + assert.equal(gate(mk(0.9), { rules: r, waivers: w }).pass, true); + assert.equal(gate(mk(6), { rules: r, waivers: w }).pass, false); + assert.equal(gate(mk(0.9), { rules: r, waivers: [{ id: "g", metric: "truePeakDb", reason: "r" }] }).pass, false); + assert.equal(gate(mk(null), { rules: r, waivers: w }).pass, false); +}); + +t("gate: a rule whose id matches no item fails a full run (disarmed guard) and is skipped on a partial run; a missing metric fails", () => { + const th = { rules: [{ group: "patch", id: "thruster@rpm600", metric: "truePeakDb", max: 0, why: "w" }] }; + const rep = { items: [item("thr@rpm600", "patch", {})] }; + assert.equal(gate(rep, th).pass, false); assert.match(gate(rep, th).failures[0].detail, /matches no item/); + assert.equal(gate(rep, th, { partial: true }).pass, true); + assert.equal(gate({ items: [item("a", "patch", {})] }, { rules: [{ group: "all", metric: "lowMotion", equals: false, why: "w" }] }).pass, true); + const gone = item("a", "patch", {}); delete gone.metrics.lowMotion; + assert.equal(gate({ items: [gone] }, { rules: [{ group: "all", metric: "lowMotion", equals: false, why: "w" }] }).pass, false); +}); + +t("gate: a silent item fails once and does not also trip every other rule", () => { + const g = gate({ items: [{ id: "s", group: "patch", metrics: { silent: true, nonFinite: 0, samplePeak: 0 } }] }, { rules: [{ group: "patch", metric: "onsetMs", max: 5, why: "w" }] }); + assert.equal(g.failures.length, 1); assert.equal(g.failures[0].metric, "silent"); +}); + t("gate: a render error, NaN output, or glob rule id is handled", () => { const g = gate({ items: [{ id: "x", group: "patch", error: "boom" }, { id: "y", group: "patch", metrics: { broken: true, nonFinite: 2 } }] }, { rules }); assert.equal(g.failures.length, 2); @@ -123,6 +163,10 @@ t("thresholds.json: every rule names a metric and a why; every waiver names a re const th = JSON.parse(readFileSync(join(here, "thresholds.json"), "utf8")); for (const r of th.rules) { assert.ok(r.metric && r.why && ["all", "patch", "ding"].includes(r.group), JSON.stringify(r)); assert.ok(["min", "max", "equals"].some((k) => k in r)); } for (const w of th.waivers) assert.ok(w.id && w.metric && w.reason && /^aqua-body:follow_up:/.test(w.followUp), JSON.stringify(w)); + for (const w of th.waivers) { + const rules = th.rules.filter((r) => r.metric === w.metric && (r.group === "all" || r.group === "patch")); + assert.ok(rules.every((r) => r.equals !== undefined || "max" in w || "min" in w), `numeric waiver without a bound: ${JSON.stringify(w)}`); + } }); t("wav: 32-bit float mono header, length, and samples above 1.0 survive", () => { diff --git a/tools/aqua-feel/thresholds.json b/tools/aqua-feel/thresholds.json index d0a5ffc..239e8d7 100644 --- a/tools/aqua-feel/thresholds.json +++ b/tools/aqua-feel/thresholds.json @@ -55,7 +55,7 @@ "group": "patch", "metric": "onsetMs", "max": 25, - "why": "first audible sample later than 25 ms after note-on" + "why": "first sample within 40 dB of the peak (and above -70 dBFS) later than 25 ms after note-on" }, { "group": "ding", @@ -74,7 +74,7 @@ "group": "ding", "metric": "onsetMs", "max": 5, - "why": "a notification that starts audibly late" + "why": "a notification whose first sample within 40 dB of the peak comes later than 5 ms after note-on" }, { "group": "ding", @@ -99,21 +99,21 @@ "id": "thruster@rpm300", "metric": "noiseToToneADb", "max": 16, - "why": "thruster low-rpm hiss: before the 2026-11-05 mix change this was 20.7 dB; the cap sits 3 dB over the 13.1 dB measured after it, so the hiss cannot creep back unnoticed" + "why": "thruster low-rpm hiss: before the 2026-11-05 mix change this was 20.7 dB; the cap sits 2-3 dB over the 13.1 dB measured after it, so the hiss cannot creep back unnoticed" }, { "group": "patch", "id": "thruster@rpm600", "metric": "noiseToToneADb", "max": 8, - "why": "thruster low-rpm hiss: before the 2026-11-05 mix change this was 23.0 dB; the cap sits 3 dB over the 5.0 dB measured after it, so the hiss cannot creep back unnoticed" + "why": "thruster low-rpm hiss: before the 2026-11-05 mix change this was 23.0 dB; the cap sits 2-3 dB over the 5.0 dB measured after it, so the hiss cannot creep back unnoticed" }, { "group": "patch", "id": "thruster@rpm1200", "metric": "noiseToToneADb", "max": 15, - "why": "thruster low-rpm hiss: before the 2026-11-05 mix change this was 20.1 dB; the cap sits 3 dB over the 12.7 dB measured after it, so the hiss cannot creep back unnoticed" + "why": "thruster low-rpm hiss: before the 2026-11-05 mix change this was 20.1 dB; the cap sits 2-3 dB over the 12.7 dB measured after it, so the hiss cannot creep back unnoticed" }, { "group": "patch", @@ -128,13 +128,15 @@ "id": "sfxr-classic-classic-sfxr-abstract-golf", "metric": "truePeakDb", "reason": "renders 0.99 sample peak and +0.9 dBTP inter-sample", - "followUp": "aqua-body:follow_up:sfxr-golf-hot" + "followUp": "aqua-body:follow_up:sfxr-golf-hot", + "max": 1.0 }, { "id": "sfxr-classic-classic-sfxr-abstract-golf", "metric": "loudnessLufs", "reason": "-5.3 LUFS integrated over the 3 s render", - "followUp": "aqua-body:follow_up:sfxr-golf-hot" + "followUp": "aqua-body:follow_up:sfxr-golf-hot", + "max": -5.0 }, { "id": "sfxr-classic-classic-sfxr-abstract-golf", From d4dce3ec0c0f2480e8a18b46cef735b1b4872126 Mon Sep 17 00:00:00 2001 From: Aqua Date: Thu, 5 Nov 2026 15:44:32 +0000 Subject: [PATCH 015/124] aqua-feel: keep the held envelope for attack only; activeEnd, crest and the plot use the raw one The 30 ms release hold inflated activeEnd by up to ~170 ms on percussive items and shifted crest, rms and noise-to-tone (808-hat activeMs 61 -> 187). Found in the second review pass; values return to the first run's. Doc cell for PRC attackMs corrected. Co-Authored-By: Claude Sonnet 5.5 --- docs/renders/aqua-feel-2026-11-05.md | 2 +- tools/aqua-feel/README.md | 2 +- tools/aqua-feel/metrics.js | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/renders/aqua-feel-2026-11-05.md b/docs/renders/aqua-feel-2026-11-05.md index 58e0bf2..020ba01 100644 --- a/docs/renders/aqua-feel-2026-11-05.md +++ b/docs/renders/aqua-feel-2026-11-05.md @@ -19,7 +19,7 @@ loudness; sfxr golf: true peak, loudness, low motion; sfxr explosion: low motion noiseToToneDb -17.18 -> -17.18 +0.00 noiseToToneADb -19.14 -> -19.14 +0.00 onsetMs 0.13 -> 0.13 +0.00 - attackMs 0.33 -> 0.33 +0.00 + attackMs 0.33 -> 4.50 (the metric changed to a 150 ms window with a held envelope during review; the patch did not) lowMotion false -> false The shipped file's `patch gain=1.4` is the constant the parity probe in `Dx7ReferenceParityTests` writes; the probe asserts diff --git a/tools/aqua-feel/README.md b/tools/aqua-feel/README.md index 5d7d8e4..87aa094 100644 --- a/tools/aqua-feel/README.md +++ b/tools/aqua-feel/README.md @@ -41,7 +41,7 @@ nobody has diffed the two. | metric | meaning | limits | |---|---|---| | `onsetMs` | first sample at or above max(-40 dB re peak, -70 dBFS), from note-on | Offline render has no device latency; this is the patch's own lead-in only | -| `attackMs`, `attackSlopeDbPerMs`, `attackWindowLimited` | 10% to 90% of the envelope maximum inside the first 150 ms after onset, on a 0.17 ms peak-hold envelope (30 ms release, so a low tone's zero crossings are not read as dips) | A faster attack reads as one hop. A swell longer than 150 ms reports a lower bound and sets `attackWindowLimited`. The envelope is a peak follower, so a tone below ~30 Hz would still ripple | +| `attackMs`, `attackSlopeDbPerMs`, `attackWindowLimited` | 10% to 90% of the envelope maximum inside the first 150 ms after onset, on a 0.17 ms peak-hold envelope (30 ms release, so a low tone's zero crossings are not read as dips) | A faster attack reads as one hop. Ripple in the first peaks pulls the 90% point late (muted-pluck declares 1 ms and reads about 7); sustained noise beds read an arbitrary 60-130 ms. A swell longer than 150 ms reports a lower bound and sets `attackWindowLimited`. The envelope is a peak follower, so a tone below ~30 Hz would still ripple | | `samplePeak`, `truePeakDb`, `overSamples`, `flatTopRuns` | peak, 4x-oversampled true peak, samples beyond 1.0, runs of 3+ samples at 0.999 | WAVs are float32 so overs survive to disk | | `loudnessLufs` | BS.1770-4 integrated, mono, K-weighted (48 kHz coefficients; renders are fixed at 48 kHz), gated | A mono sound with no reference level; compare items, do not read it as a delivered loudness. A buffer under 400 ms is zero-padded to one block and reads low (0.1 s of full 1 kHz sine: -9.0, true -3.0); every shipped item is 1.5 s or longer | | `crestDb`, `rmsDb` | over the active span (onset to last frame within 50 dB of peak) | | diff --git a/tools/aqua-feel/metrics.js b/tools/aqua-feel/metrics.js index 75beea0..98b9e64 100644 --- a/tools/aqua-feel/metrics.js +++ b/tools/aqua-feel/metrics.js @@ -69,13 +69,13 @@ export function integratedLoudness(x) { // ---- time structure ---------------------------------------------------------------------------------------------- const HOP = 8; // envelope hop in samples (0.167 ms) -// Peak-hold envelope: max |x| per hop, held with a 30 ms exponential release so the zero crossings of a low tone do not -// read as dips (a plain per-hop max does: a 261 Hz sine "falls" 100% twice per cycle). The attack stays instantaneous. +// Envelope: max |x| per hop. With held=true it also decays with a 30 ms release so the zero crossings of a low tone do not +// read as dips; only the attack uses that (the hold smears decays, so activeEnd, crest and the gallery plot use the raw one). const RELEASE_S = 0.03; -export function envelope(x) { +export function envelope(x, held = false) { const env = new Float64Array(Math.ceil(x.length / HOP)), hold = Math.exp(-HOP / SR / RELEASE_S); for (let i = 0; i < x.length; i++) { const a = Math.abs(x[i]); if (a > env[(i / HOP) | 0]) env[(i / HOP) | 0] = a; } - for (let i = 1; i < env.length; i++) env[i] = Math.max(env[i], env[i - 1] * hold); + if (held) for (let i = 1; i < env.length; i++) env[i] = Math.max(env[i], env[i - 1] * hold); return env; } const maxIndex = (a) => { let k = 0; for (let i = 1; i < a.length; i++) if (a[i] > a[k]) k = i; return k; }; @@ -93,17 +93,17 @@ export function timing(x) { if (!(peak >= SILENT_PEAK)) return { silent: true }; const thr = Math.max(peak * 0.01, SILENT_PEAK); let onsetSample = 0; while (onsetSample < x.length && Math.abs(x[onsetSample]) < thr) onsetSample++; - const env = envelope(x), start = Math.floor(onsetSample / HOP), end = Math.min(env.length - 1, start + Math.round(ATTACK_WINDOW_S * SR / HOP)); + const env = envelope(x, true), raw = envelope(x), start = Math.floor(onsetSample / HOP), end = Math.min(env.length - 1, start + Math.round(ATTACK_WINDOW_S * SR / HOP)); let top = start; for (let i = start; i <= end; i++) if (env[i] > env[top]) top = i; const first = env[top], at = (f) => { let i = start; while (i < top && env[i] < first * f) i++; return i; }; const i10 = at(0.1), i90 = at(0.9); const dt = Math.max(hopMs, (i90 - i10) * hopMs), floor = peak * 10 ** (-50 / 20); - let last = env.length - 1; while (last > 0 && env[last] < floor) last--; + let last = raw.length - 1; while (last > 0 && raw[last] < floor) last--; return { silent: false, onsetMs: (onsetSample / SR) * 1000, attackMs: dt, attackSlopeDbPerMs: db(0.9 / 0.1) / dt, resolutionLimited: i90 - i10 <= 1, attackWindowLimited: top - start > 0.9 * (end - start) && end - start > 10, activeStartSample: onsetSample, activeEndSample: Math.min(x.length, (last + 1) * HOP), - peakAtMs: (maxIndex(env) * HOP / SR) * 1000, firstPeak: first, firstPeakAtMs: top * hopMs, + peakAtMs: (maxIndex(raw) * HOP / SR) * 1000, firstPeak: first, firstPeakAtMs: top * hopMs, }; } From 0c9708e37611ad69ad9d9ef93025c91ec413b975 Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 02:07:26 +0000 Subject: [PATCH 016/124] Add Earcon Workshop: static earcon family generator, WAV/zip/JSON pack, node check Six events x four Dings-derived identities, pure-JS deterministic renderer shared by page and node, five sliders, offline export. Unheard: signal checks only. Co-Authored-By: Claude Sonnet 5.5 --- tools/earcon-workshop/README.md | 64 ++++++++ tools/earcon-workshop/cli.mjs | 12 ++ tools/earcon-workshop/package.json | 7 + tools/earcon-workshop/test.mjs | 125 +++++++++++++++ tools/earcon-workshop/web/app.js | 77 ++++++++++ tools/earcon-workshop/web/earcon.js | 218 +++++++++++++++++++++++++++ tools/earcon-workshop/web/index.html | 43 ++++++ tools/earcon-workshop/web/styles.css | 21 +++ 8 files changed, 567 insertions(+) create mode 100644 tools/earcon-workshop/README.md create mode 100644 tools/earcon-workshop/cli.mjs create mode 100644 tools/earcon-workshop/package.json create mode 100644 tools/earcon-workshop/test.mjs create mode 100644 tools/earcon-workshop/web/app.js create mode 100644 tools/earcon-workshop/web/earcon.js create mode 100644 tools/earcon-workshop/web/index.html create mode 100644 tools/earcon-workshop/web/styles.css diff --git a/tools/earcon-workshop/README.md b/tools/earcon-workshop/README.md new file mode 100644 index 0000000..b745daf --- /dev/null +++ b/tools/earcon-workshop/README.md @@ -0,0 +1,64 @@ +# Earcon Workshop + +Static, dependency-free browser page that generates a coherent family of short earcons (one per event, one timbre +identity) and exports them as WAVs plus a JSON pack. **Nothing here has been heard by anyone.** The automated checks +measure signals; no person has judged whether any earcon sounds good, is pleasant, is distinguishable in a real room, or +suits a real product. A human ear is owed (recorded as a follow-up on the forge PR). + +## What is live + +- `web/earcon.js`: the whole engine. Events (success, fail, warning, message, done, waiting), four identities taken from the + Dings catalog (warm bell, glass chime, soft triangle, muted pluck), five sliders (tempo, transpose, brightness, decay, + level), WAV encoder, pack builder, stored-ZIP writer. Pure functions, deterministic, no randomness, no noise voices. +- `web/index.html` + `app.js`: audition one earcon or the whole family, tweak sliders, download one WAV, `pack.json`, or a zip + of WAVs + `pack.json` + `README.md`. Playback is source -> gain -> analyser -> destination with a peak meter, the same graph shape as `tools/aqua-playground`. + The page plays the exact buffers it exports (offline render, not a second path). +- `cli.mjs`: the same export from a shell, e.g. `node cli.mjs warm-bell ./earcons tempo=1.2 level=0.6`. +- `test.mjs`: `node test.mjs` (about 10 s). + +Not the playground's Faust/AudioWorklet engine: that pulls the Faust compiler (wasm) into the page, which is not dependency-free. +The synthesis here is plain JS (FM bell and additive triangle voices, two-pole lowpass); it is a reimplementation of the Dings +instruments' ideas, not a lowering of their `.aqua` scripts, so it will not sound like the shipped Dings. + +## Run + +Serve `web/` from any static host (ES modules need http, not `file://`): + +```sh +cd tools/earcon-workshop/web && python3 -m http.server 8080 # then open http://localhost:8080/ +``` + +Never opened on a real display by a person. A headless Chromium smoke (load, audition, zip download, no console errors) passed once; no audio device was attached. + +## What the check covers (`test.mjs`) + +For each identity x event at the default setting and at two slider extremes (881 checks at the time of writing): + +- finite, non-silent, onset (first sample at or above -40 dBFS) under 20 ms, sample peak < 1.0 and <= 0.9, true peak < 1.0 (cross-checked + with `tools/aqua-feel/metrics.js`), no over-full-scale samples or flat tops, ends without a step, under 2.6 s, WAV round trip. +- Sibling distinctness: every pair of events within one identity, and every pair of identities on the same event, must differ by a + log-spectrogram distance of at least 8 dB (mean absolute dB over 32 log bands, 80 Hz to 16 kHz, 2048-point frames, cells where both sides sit + under -75 dB ignored). Controls: a clip against itself is 0, against silence is far, a 2% tempo change falls under the threshold. +- Determinism, sliders actually change the output, event selection honoured, ZIP entries and CRCs read back, pack lists its files and says `heard: false`. + +Limits worth knowing: distance is a spectrogram number, not a perceptual one; two earcons can pass it and still confuse a listener. +The metric and threshold were adjusted after the first run (see the history comment in `test.mjs`): the first averaging let silence +dilute the distance, motifs for warning, message, waiting and fail were reworked, and the threshold went from 4 to 8 dB after the +minimum came out at 13.8 dB. Brightness is limited to +-0.25 because a darker voice made the pluck family hard to tell apart under the first metric. True-peak overs in the first run were +FM aliasing at the bright/high extreme; fixed with a 9 kHz two-pole lowpass. + +## Using an exported pack + +The zip's own `README.md` carries the CI, chat-bot and app recipes (play on pass/fail in a shell, attach the file to a chat message, `new Audio(url).play()`). Summary: + +- **CI:** play `success`/`fail`/`done` from the runner or a dev box; never fail the build when no audio device exists. +- **Chat bots:** look up `pack.json -> events[id].file` and upload that WAV with the message. +- **Apps:** one preloaded audio element per event; browsers need a user gesture before first play. +- Every file peaks at or under 0.9 of full scale at the default level (0.7); the `level` slider tops out at 0.9. + +## Planned, not built + +- Ogg/Opus export (see `docs/research/dings-playback-and-ogg-export.md`); WAV only today. +- Custom motifs and a custom voice editor; only the six events and four identities exist. +- Lowering the voices from the real `.aqua` Dings scripts so the pack matches the Dings service. +- Any listening: a human trial, then tuning motifs and levels by ear. diff --git a/tools/earcon-workshop/cli.mjs b/tools/earcon-workshop/cli.mjs new file mode 100644 index 0000000..a8b853e --- /dev/null +++ b/tools/earcon-workshop/cli.mjs @@ -0,0 +1,12 @@ +// node cli.mjs [key=value ...] e.g. node cli.mjs warm-bell ./earcons tempo=1.2 level=0.6 +// Writes the WAVs, pack.json and README.md the page's zip contains, from the same renderer. +import { mkdir, writeFile } from "node:fs/promises"; +import { join } from "node:path"; +import { IDENTITIES, renderFamily, packFiles } from "./web/earcon.js"; + +const [identity, outDir, ...kv] = process.argv.slice(2); +if (!IDENTITIES[identity] || !outDir) { console.error(`usage: node cli.mjs <${Object.keys(IDENTITIES).join("|")}> [tempo= transpose= brightness= decay= level=]`); process.exit(2); } +const params = Object.fromEntries(kv.map((s) => s.split("=")).map(([k, v]) => [k, Number(v)])); +await mkdir(outDir, { recursive: true }); +for (const f of packFiles(renderFamily(identity, undefined, params))) await writeFile(join(outDir, f.name), f.bytes); +console.log(`wrote ${outDir}`); diff --git a/tools/earcon-workshop/package.json b/tools/earcon-workshop/package.json new file mode 100644 index 0000000..93923f0 --- /dev/null +++ b/tools/earcon-workshop/package.json @@ -0,0 +1,7 @@ +{ + "name": "earcon-workshop", + "private": true, + "type": "module", + "description": "Static, dependency-free earcon family generator for AquaSynth. Renders; does not listen.", + "scripts": { "test": "node test.mjs", "export": "node cli.mjs" } +} diff --git a/tools/earcon-workshop/test.mjs b/tools/earcon-workshop/test.mjs new file mode 100644 index 0000000..9006cb5 --- /dev/null +++ b/tools/earcon-workshop/test.mjs @@ -0,0 +1,125 @@ +// Automated checks for every identity x event, at default and at the slider extremes. Rendered with the same code the page runs. +// These measure signals: non-silent, onset, peak, clipping, sibling distinctness, determinism, WAV and ZIP round trips. +// They cannot say any earcon sounds good. A human ear is owed. +import { IDENTITIES, EVENTS, renderFamily, packFiles, encodeWav, decodeWav, buildPack, crc32, PARAM_RANGES, PEAK_CEILING, DEFAULT_PARAMS, SR } from "./web/earcon.js"; +import { samplePeak, truePeak, clipping, SILENT_PEAK } from "../aqua-feel/metrics.js"; + +// Spectral distance: log-magnitude STFT (2048 Hann, hop 512) pooled to 32 log-spaced bands 80 Hz..16 kHz, floored at -90 dB +// relative to full scale; mean absolute dB difference over (frame, band) cells where either side is above -75 dB (the shorter buffer is padded with silence). +const ACTIVE = -75; // cells where both spectra sit under this are shared emptiness and do not dilute the mean +const N = 2048, HOP = 512, BANDS = 32, FLOOR = -90; +function fft(re, im) { + const n = re.length; + for (let i = 1, j = 0; i < n; i++) { let b = n >> 1; for (; j & b; b >>= 1) j ^= b; j ^= b; if (i < j) { [re[i], re[j]] = [re[j], re[i]]; [im[i], im[j]] = [im[j], im[i]]; } } + for (let len = 2; len <= n; len <<= 1) { + const w = (-2 * Math.PI) / len; + for (let i = 0; i < n; i += len) for (let k = 0; k < len / 2; k++) { + const c = Math.cos(w * k), s = Math.sin(w * k), a = i + k, b = a + len / 2; + const xr = re[b] * c - im[b] * s, xi = re[b] * s + im[b] * c; + re[b] = re[a] - xr; im[b] = im[a] - xi; re[a] += xr; im[a] += xi; + } + } +} +const win = Float64Array.from({ length: N }, (_, i) => 0.5 - 0.5 * Math.cos((2 * Math.PI * i) / N)); +const edges = Array.from({ length: BANDS + 1 }, (_, i) => Math.round(((80 * (16000 / 80) ** (i / BANDS)) / SR) * N)); +function bandFrames(x) { + const frames = []; + for (let s = 0; s + N <= x.length + N - HOP; s += HOP) { + const re = new Float64Array(N), im = new Float64Array(N); + for (let i = 0; i < N; i++) re[i] = (s + i < x.length ? x[s + i] : 0) * win[i]; + fft(re, im); + frames.push(Float64Array.from({ length: BANDS }, (_, b) => { + let p = 0; for (let k = edges[b]; k < Math.max(edges[b + 1], edges[b] + 1); k++) p += re[k] ** 2 + im[k] ** 2; + return Math.max(FLOOR, 10 * Math.log10(p / (N * N / 4) + 1e-12)); // N/4 ~ Hann-scaled unit sine -> 0 dB + })); + } + return frames; +} +export function spectralDistance(a, b) { + const fa = bandFrames(a), fb = bandFrames(b), n = Math.max(fa.length, fb.length), silent = new Float64Array(BANDS).fill(FLOOR); + let sum = 0, cells = 0; + for (let t = 0; t < n; t++) { const x = fa[t] ?? silent, y = fb[t] ?? silent; for (let b = 0; b < BANDS; b++) if (x[b] > ACTIVE || y[b] > ACTIVE) { sum += Math.abs(x[b] - y[b]); cells++; } } + return cells ? sum / cells : 0; +} + +// History, kept because it changes how far to trust the number: the first metric averaged over every band and frame and +// put the closest pair near 3.3 dB at the dark/slow extreme; motifs were reworked, then the mean was restricted to active +// cells (shared silence was diluting it), and the threshold was raised from 4 to 8 dB after seeing a 13.8 dB minimum. +const MIN_DISTANCE_DB = 8; +const names = Object.keys(IDENTITIES), events = Object.keys(EVENTS); +const lo = (k) => PARAM_RANGES[k][0], hi = (k) => PARAM_RANGES[k][1]; +const settings = { + default: {}, + "slow dark long quiet": { tempo: hi("tempo"), brightness: lo("brightness"), decay: hi("decay"), level: lo("level"), transpose: lo("transpose") }, + "fast bright short loud": { tempo: lo("tempo"), brightness: hi("brightness"), decay: lo("decay"), level: hi("level"), transpose: hi("transpose") }, +}; +let failures = 0, checks = 0; +const check = (ok, msg) => { checks++; if (!ok) { failures++; console.error(`FAIL ${msg}`); } }; + +let worst = { d: Infinity, at: "" }; +for (const [sname, params] of Object.entries(settings)) for (const id of names) { + const fam = renderFamily(id, undefined, params); + for (const it of fam.items) { + const tag = `${id}/${it.event} [${sname}]`, x = it.samples; + check(x.every(Number.isFinite), `${tag}: NaN or Infinity`); + check(samplePeak(x) > SILENT_PEAK * 100, `${tag}: silent (peak ${samplePeak(x)})`); + check(it.onsetMs !== null && it.onsetMs < 20, `${tag}: onset ${it.onsetMs} ms, need < 20`); + check(it.peak < 1 && it.peak <= PEAK_CEILING + 1e-6, `${tag}: peak ${it.peak}`); + check(truePeak(x) < 1, `${tag}: true peak ${truePeak(x)} >= 1`); + const c = clipping(x); check(c.overSamples === 0 && c.flatTopRuns === 0, `${tag}: clipping ${JSON.stringify(c)}`); + check(it.durationMs < 2600, `${tag}: ${it.durationMs} ms is not short`); + check(Math.abs(x[x.length - 1]) < 1e-3, `${tag}: ends on a step (${x[x.length - 1]})`); + const wav = decodeWav(encodeWav(x)); check(wav.samples.length === x.length && wav.sampleRate === SR && samplePeak(wav.samples) < 1, `${tag}: WAV round trip`); + } + // siblings: every pair of events inside one identity + for (let i = 0; i < fam.items.length; i++) for (let j = i + 1; j < fam.items.length; j++) { + const d = spectralDistance(fam.items[i].samples, fam.items[j].samples); + if (d < worst.d) worst = { d, at: `${id} ${fam.items[i].event} vs ${fam.items[j].event} [${sname}]` }; + check(d >= MIN_DISTANCE_DB, `siblings ${id} ${fam.items[i].event} vs ${fam.items[j].event} [${sname}]: distance ${d.toFixed(2)} dB < ${MIN_DISTANCE_DB}`); + } +} +console.log(`closest sibling pair: ${worst.d.toFixed(2)} dB (${worst.at}); threshold ${MIN_DISTANCE_DB} dB`); + +// identities are distinct from each other on the same event too +for (const e of events) for (let i = 0; i < names.length; i++) for (let j = i + 1; j < names.length; j++) { + const d = spectralDistance(renderFamily(names[i], [e]).items[0].samples, renderFamily(names[j], [e]).items[0].samples); + check(d >= MIN_DISTANCE_DB, `identities ${names[i]} vs ${names[j]} on ${e}: distance ${d.toFixed(2)} dB`); +} + +// a self-pair must measure zero, and a silent-vs-signal pair must measure large: the metric can fail both ways +const probe = renderFamily("warm-bell", ["success"]).items[0].samples; +check(spectralDistance(probe, probe) === 0, "metric: self distance not 0"); +check(spectralDistance(probe, new Float32Array(probe.length)) > 10, "metric: silence not far from signal"); + +// negative control: a near-duplicate (2% tempo change) must land under the threshold, so the threshold can say 'too similar' +const near = spectralDistance(renderFamily("warm-bell", ["success"]).items[0].samples, renderFamily("warm-bell", ["success"], { tempo: 1.02 }).items[0].samples); +check(near < MIN_DISTANCE_DB, `negative control: a 2% tempo change measured ${near.toFixed(2)} dB, the threshold would not flag a near-duplicate`); +console.log(`near-duplicate control: ${near.toFixed(2)} dB`); + +// determinism: same inputs, same bytes +const a = packFiles(renderFamily("glass-chime", undefined, { tempo: 1.2 })), b = packFiles(renderFamily("glass-chime", undefined, { tempo: 1.2 })); +check(a.every((f, i) => crc32(f.bytes) === crc32(b[i].bytes)), "render is not deterministic"); +// sliders do something +const base = renderFamily("warm-bell", ["success"]).items[0], slow = renderFamily("warm-bell", ["success"], { tempo: 1.6 }).items[0], up = renderFamily("warm-bell", ["success"], { transpose: 12 }).items[0]; +check(slow.durationMs > base.durationMs, "tempo slider did not lengthen the earcon"); +check(spectralDistance(base.samples, up.samples) > 3, "transpose slider did not move the spectrum"); +// event subset only renders what was chosen +check(renderFamily("warm-bell", ["fail", "done"]).items.map((i) => i.event).join() === "fail,done", "event selection not honoured"); + +// pack: ZIP read back with node's own inflate-free parse of stored entries; pack.json lists every file, heard stays false +const files = packFiles(renderFamily("soft-triangle")), z = (await import("./web/earcon.js")).zip(files); +const dv = new DataView(z.buffer, z.byteOffset, z.byteLength), entries = dv.getUint16(z.length - 22 + 10, true), cdOff = dv.getUint32(z.length - 22 + 16, true); +check(entries === files.length, `zip entry count ${entries} != ${files.length}`); +let p = cdOff; +for (const f of files) { + const csize = dv.getUint32(p + 20, true), crc = dv.getUint32(p + 16, true), nl = dv.getUint16(p + 28, true), lho = dv.getUint32(p + 42, true); + const name = new TextDecoder().decode(z.subarray(p + 46, p + 46 + nl)), data = z.subarray(lho + 30 + nl, lho + 30 + nl + csize); + check(name === f.name && crc === crc32(data) && crc === crc32(f.bytes), `zip entry ${f.name} corrupt`); + p += 46 + nl; +} +const pack = JSON.parse(new TextDecoder().decode(files.find((f) => f.name === "pack.json").bytes)); +check(pack.heard === false && Object.values(pack.events).every((e) => files.some((f) => f.name === e.file)), "pack.json does not match its files"); +check(/Nobody has listened/.test(new TextDecoder().decode(files.find((f) => f.name === "README.md").bytes)), "pack README lost the unheard notice"); + +console.log(failures ? `${failures} of ${checks} checks FAILED` : `all ${checks} checks passed`); +process.exit(failures ? 1 : 0); diff --git a/tools/earcon-workshop/web/app.js b/tools/earcon-workshop/web/app.js new file mode 100644 index 0000000..bd4dabf --- /dev/null +++ b/tools/earcon-workshop/web/app.js @@ -0,0 +1,77 @@ +// Page glue only: state, DOM, AudioContext. Everything audible or exported comes from earcon.js. +// Playback graph follows the playground (tools/aqua-playground/web/app.js): source -> gain -> analyser -> destination, with a peak meter. +import { IDENTITIES, EVENTS, DEFAULT_PARAMS, PARAM_RANGES, renderFamily, buildPack, packFiles, zip, encodeWav, fileName, SR } from "./earcon.js"; + +const $ = (id) => document.getElementById(id); +const state = { identity: Object.keys(IDENTITIES)[0], chosen: new Set(Object.keys(EVENTS)), params: { ...DEFAULT_PARAMS } }; +let ctx, gain, analyser, playing = [], cached; + +const status = (t) => { $("status").textContent = t; }; +const download = (name, bytes, type) => { const a = document.createElement("a"); a.href = URL.createObjectURL(new Blob([bytes], { type })); a.download = name; a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 5000); }; + +function build() { + $("identity").innerHTML = Object.entries(IDENTITIES).map(([k, v]) => ``).join(""); + $("identity").onchange = () => { state.identity = $("identity").value; refresh(); }; + $("family").onclick = auditionFamily; $("stop").onclick = stop; + $("reset").onclick = () => { state.params = { ...DEFAULT_PARAMS }; buildControls(); refresh(); }; + $("zip").onclick = () => { const f = family(); download(`earcons-${f.identity}.zip`, zip(packFiles(f)), "application/zip"); }; + $("json").onclick = () => download("pack.json", JSON.stringify(buildPack(family()), null, 2) + "\n", "application/json"); + $("events").innerHTML = Object.entries(EVENTS).map(([k, e]) => `
+
${e.label}${e.meaning}
+
`).join(""); + for (const row of $("events").children) { + const k = row.dataset.event; + row.querySelector("input").onchange = (e) => { e.target.checked ? state.chosen.add(k) : state.chosen.delete(k); refresh(); }; + row.querySelector("[data-play]").onclick = () => playOne(k); + row.querySelector("[data-wav]").onclick = () => { const it = family().items.find((i) => i.event === k); download(fileName(state.identity, k), encodeWav(it.samples), "audio/wav"); }; + } + buildControls(); +} + +function buildControls() { + $("controls").innerHTML = ""; + for (const [k, [lo, hi, step]] of Object.entries(PARAM_RANGES)) { + const row = document.createElement("div"); row.className = "row"; + const input = Object.assign(document.createElement("input"), { type: "range", min: lo, max: hi, step, value: state.params[k] }); + const out = document.createElement("output"), show = () => { out.textContent = Number(input.value).toFixed(step < 1 ? 2 : 0); }; + input.oninput = () => { state.params[k] = Number(input.value); show(); refresh(); }; show(); + const label = document.createElement("label"); label.textContent = k; + row.append(label, input, out); $("controls").append(row); + } +} + +// One render per state change, cached until refresh(); that buffer is what is shown, played and exported. +function family() { return (cached ??= renderFamily(state.identity, Object.keys(EVENTS).filter((e) => state.chosen.has(e)), state.params)); } +function refresh() { + cached = null; const f = family(); + $("idnote").textContent = IDENTITIES[state.identity].note; + for (const row of $("events").children) { + const it = f.items.find((i) => i.event === row.dataset.event), cv = row.querySelector("canvas"), g = cv.getContext("2d"); + g.clearRect(0, 0, cv.width, cv.height); + row.style.opacity = it ? 1 : 0.4; + if (!it) continue; + g.fillStyle = "#3fc1c9"; const step = it.samples.length / cv.width; + for (let x = 0; x < cv.width; x++) { let p = 0; for (let i = Math.floor(x * step); i < Math.floor((x + 1) * step); i++) p = Math.max(p, Math.abs(it.samples[i])); const h = p * cv.height; g.fillRect(x, (cv.height - h) / 2, 1, Math.max(1, h)); } + } + $("pack").textContent = JSON.stringify(buildPack(f), null, 2); + status(`${f.items.length} earcons, peak ${Math.max(0, ...f.items.map((i) => i.peak)).toFixed(2)}, not heard by anyone.`); +} + +async function graph() { + ctx ??= new AudioContext({ latencyHint: "interactive" }); + await ctx.resume(); + if (!gain) { gain = ctx.createGain(); analyser = ctx.createAnalyser(); analyser.fftSize = 1024; gain.connect(analyser); analyser.connect(ctx.destination); meter(); } +} +function schedule(samples, when) { + const buf = ctx.createBuffer(1, samples.length, SR); buf.copyToChannel(samples, 0); + const src = ctx.createBufferSource(); src.buffer = buf; src.connect(gain); src.start(when); playing.push(src); +} +function stop() { for (const s of playing) { try { s.stop(); } catch { /* already ended */ } s.disconnect(); } playing = []; } +async function playOne(k) { stop(); await graph(); const it = family().items.find((i) => i.event === k); if (it) schedule(it.samples, ctx.currentTime + 0.02); } +async function auditionFamily() { stop(); await graph(); let t = ctx.currentTime + 0.05; for (const it of family().items) { schedule(it.samples, t); t += it.durationMs / 1000 + 0.35; } } +function meter() { + const b = new Float32Array(analyser.fftSize); analyser.getFloatTimeDomainData(b); + $("level").value = b.reduce((m, v) => Math.max(m, Math.abs(v)), 0); requestAnimationFrame(meter); +} + +build(); refresh(); diff --git a/tools/earcon-workshop/web/earcon.js b/tools/earcon-workshop/web/earcon.js new file mode 100644 index 0000000..1cca563 --- /dev/null +++ b/tools/earcon-workshop/web/earcon.js @@ -0,0 +1,218 @@ +// Earcon Workshop core. Pure JS, no dependencies, no randomness: the browser page and `node` run this one file, so +// the buffer you audition is the buffer you export. Motif and timbre ideas come from src/AquaSynth.Dings/DingCatalog.cs +// (semitone motifs on a root, FM-bell / triangle / pluck voices, no broadband noise). Nothing here has been heard. + +export const SR = 48000; +export const PEAK_CEILING = 0.9; // hard cap: every export peaks at or under this, so < 1.0 with headroom for 16-bit rounding +export const FORMAT = "aquasynth.earcon-pack.v0"; + +// Motif per event: semitones above the identity's root, onset delay (ms), relative gain. Contours differ on purpose +// (rise, fall, repeat, single, resolve, sparse) so siblings are told apart by shape and rhythm, not timbre alone. +export const EVENTS = { + success: { label: "Success", meaning: "It worked: rising fifth then octave", notes: [[0, 0, 1], [7, 110, 1], [12, 220, 1]] }, + fail: { label: "Fail", meaning: "It broke: falling minor figure, low landing", notes: [[5, 0, 1], [1, 160, 1], [-4, 320, 1]] }, + warning: { label: "Warning", meaning: "Look at this: tritone zigzag, three quick notes", notes: [[9, 0, 1], [3, 110, 1], [9, 220, 1]] }, + message: { label: "Message", meaning: "Someone spoke: quick two-note lift high in the register", notes: [[12, 0, 0.7], [19, 70, 0.9]] }, + done: { label: "Done", meaning: "Finished: falling resolve onto the root, long tail", notes: [[12, 0, 1], [7, 200, 1], [0, 400, 1.1]] }, + waiting: { label: "Waiting", meaning: "Needs you: quiet, sparse, slow low sway, three soft notes", notes: [[0, 0, 0.55], [5, 450, 0.55], [0, 900, 0.55]] }, +}; + +// Timbre identities. rootHz in the calm mid register; fmRatio/fmIndex/fmDecay shape the bell; harmonics > 0 selects the +// additive triangle; attack is seconds. Values start from the Dings catalog instruments and were not tuned by ear. +export const IDENTITIES = { + "warm-bell": { label: "Warm bell", note: "soft fundamental, restrained upper partial", rootHz: 261.6256, voice: "fm", fmRatio: 3.01, fmIndex: 2.6, fmDecay: 0.42, attack: 0.004, decay: 0.55, brightness: 0.34 }, + "glass-chime": { label: "Glass chime", note: "clear and precise", rootHz: 329.6276, voice: "fm", fmRatio: 4.12, fmIndex: 4.1, fmDecay: 0.28, attack: 0.002, decay: 0.45, brightness: 0.72 }, + "soft-triangle": { label: "Soft triangle", note: "rounded, calm", rootHz: 261.6256, voice: "tri", harmonics: 5, attack: 0.006, decay: 0.5, brightness: 0.46 }, + "muted-pluck": { label: "Muted pluck", note: "short, dry", rootHz: 293.6648, voice: "tri", harmonics: 7, attack: 0.002, decay: 0.25, brightness: 0.56 }, +}; + +export const DEFAULT_PARAMS = { tempo: 1, transpose: 0, brightness: 0, decay: 1, level: 0.7 }; +// brightness is an offset on the identity's own brightness (-0.4..0.4); tempo scales note spacing; decay scales tails; +// level is the family's peak target (0.1..0.9) applied as one factor so relative event loudness survives. +export const PARAM_RANGES = { + tempo: [0.6, 1.6, 0.01], transpose: [-12, 12, 1], brightness: [-0.25, 0.25, 0.01], decay: [0.5, 1.6, 0.01], level: [0.1, PEAK_CEILING, 0.01], +}; + +export function clampParams(p = {}) { + const out = { ...DEFAULT_PARAMS }; + for (const k of Object.keys(DEFAULT_PARAMS)) { + const v = Number(p[k] ?? DEFAULT_PARAMS[k]); + const [lo, hi] = PARAM_RANGES[k]; + out[k] = Math.min(hi, Math.max(lo, Number.isFinite(v) ? v : DEFAULT_PARAMS[k])); + } + return out; +} + +const TAU = Math.PI * 2; + +// One note into `out` at sample `start`. Linear attack (<= 6 ms), exponential decay reaching -60 dB at `decaySec`, +// one-pole lowpass whose cutoff follows brightness, 3 ms linear fade at the voice end so no tail ends on a step. +function addNote(out, start, hz, gain, id, decaySec, bright) { + const len = Math.min(out.length - start, Math.ceil(decaySec * SR)); + if (len <= 0) return; + const atk = Math.max(1, Math.round(id.attack * SR)); + const tau = decaySec / Math.log(1000); + const fade = Math.round(0.003 * SR); + const cutoff = Math.min(9000, 700 * 2 ** (bright * 4)); // 700 Hz .. 9 kHz; two poles keep FM sidebands off Nyquist + const a = 1 - Math.exp(-TAU * cutoff / SR); + const idx = id.voice === "fm" ? id.fmIndex * (0.5 + bright) : 0; // brighter -> more sidebands + const tri = id.voice === "tri" ? Math.max(1, Math.min(id.harmonics, Math.floor((0.45 * SR) / hz / 2))) : 0; + let z = 0, z2 = 0; + for (let n = 0; n < len; n++) { + const t = n / SR; + const env = Math.min(1, (n + 1) / atk) * Math.exp(-n / SR / tau) * Math.min(1, (len - n) / fade); + let y; + if (id.voice === "fm") y = Math.sin(TAU * hz * t + idx * Math.exp(-t / id.fmDecay) * Math.sin(TAU * hz * id.fmRatio * t)); + else { y = 0; for (let h = 0; h < tri; h++) { const k = 2 * h + 1; y += ((h & 1) ? -1 : 1) * Math.sin(TAU * hz * k * t) / (k * k); } y *= 8 / (Math.PI * Math.PI); } + z += a * (y - z); z2 += a * (z - z2); + out[start + n] += z2 * env * gain; + } +} + +// Voice gains: fm and tri are both roughly unit-amplitude before the lowpass; the family scale fixes the final level. +export function renderEvent(eventId, identityId, params = {}, scale = 1) { + const ev = EVENTS[eventId], id = IDENTITIES[identityId]; + if (!ev) throw new Error(`unknown event: ${eventId}`); + if (!id) throw new Error(`unknown identity: ${identityId}`); + const p = clampParams(params); + const decaySec = id.decay * p.decay * (eventId === "done" ? 1.4 : eventId === "message" ? 0.7 : 1); + const bright = Math.min(1, Math.max(0, id.brightness + p.brightness)); + const lastMs = Math.max(...ev.notes.map((n) => n[1])) * p.tempo; + const out = new Float32Array(Math.ceil((lastMs / 1000 + decaySec) * SR) + 1); + for (const [semi, ms, g] of ev.notes) { + const hz = id.rootHz * 2 ** ((semi + p.transpose) / 12); + addNote(out, Math.round(ms * p.tempo * SR / 1000), hz, g, id, decaySec, bright); + } + for (let i = 0; i < out.length; i++) out[i] *= scale; + return out; +} + +// A family is rendered as one unit: unscaled renders, then ONE factor sets the loudest event to `level`, so relative +// loudness between events (waiting quieter than done) is kept and no event can exceed PEAK_CEILING. +export function renderFamily(identityId, eventIds = Object.keys(EVENTS), params = {}) { + const p = clampParams(params); + const raw = eventIds.map((e) => renderEvent(e, identityId, p, 1)); + let max = 0; + for (const b of raw) for (let i = 0; i < b.length; i++) { const v = Math.abs(b[i]); if (v > max) max = v; } + const f = max > 0 ? Math.min(p.level, PEAK_CEILING) / max : 0; + const items = raw.map((b, i) => { for (let j = 0; j < b.length; j++) b[j] *= f; return { event: eventIds[i], samples: b, ...measure(b) }; }); + return { identity: identityId, params: p, sampleRate: SR, items }; +} + +export function measure(x) { + let peak = 0, sq = 0; + for (let i = 0; i < x.length; i++) { const a = Math.abs(x[i]); if (a > peak) peak = a; sq += x[i] * x[i]; } + let onset = -1; + for (let i = 0; i < x.length; i++) if (Math.abs(x[i]) >= 0.01) { onset = i; break; } // first sample at or above -40 dBFS + return { peak, rmsDb: sq > 0 ? 10 * Math.log10(sq / x.length) : -Infinity, onsetMs: onset < 0 ? null : (onset / SR) * 1000, durationMs: (x.length / SR) * 1000 }; +} + +// ---- WAV (16-bit PCM mono) ---------------------------------------------------------------------------------------- +export function encodeWav(x, sr = SR) { + const buf = new ArrayBuffer(44 + x.length * 2), v = new DataView(buf); + const s = (o, t) => { for (let i = 0; i < t.length; i++) v.setUint8(o + i, t.charCodeAt(i)); }; + s(0, "RIFF"); v.setUint32(4, 36 + x.length * 2, true); s(8, "WAVEfmt "); v.setUint32(16, 16, true); v.setUint16(20, 1, true); + v.setUint16(22, 1, true); v.setUint32(24, sr, true); v.setUint32(28, sr * 2, true); v.setUint16(32, 2, true); v.setUint16(34, 16, true); + s(36, "data"); v.setUint32(40, x.length * 2, true); + for (let i = 0; i < x.length; i++) v.setInt16(44 + i * 2, Math.round(Math.max(-1, Math.min(1, x[i])) * 32767), true); + return new Uint8Array(buf); +} + +export function decodeWav(bytes) { + const v = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); + if (v.getUint32(0) !== 0x52494646 || v.getUint32(8) !== 0x57415645) throw new Error("not a RIFF/WAVE file"); + const sr = v.getUint32(24, true), n = v.getUint32(40, true) / 2, x = new Float32Array(n); + for (let i = 0; i < n; i++) x[i] = v.getInt16(44 + i * 2, true) / 32767; + return { sampleRate: sr, samples: x }; +} + +// ---- Pack --------------------------------------------------------------------------------------------------------- +const fileName = (identity, event) => `${identity}-${event}.wav`; + +export function buildPack(family) { + return { + format: FORMAT, + heard: false, // nobody has listened to this pack; the flag stays false until a person edits it + sampleRate: family.sampleRate, + identity: family.identity, + params: family.params, + events: Object.fromEntries(family.items.map((it) => [it.event, { + file: fileName(family.identity, it.event), + meaning: EVENTS[it.event].meaning, + durationMs: Math.round(it.durationMs), + peak: +it.peak.toFixed(4), + onsetMs: +it.onsetMs.toFixed(2), + }])), + }; +} + +export function packReadme(pack) { + const ev = Object.entries(pack.events).map(([k, e]) => `| ${k} | \`${e.file}\` | ${e.durationMs} ms | ${e.meaning} |`).join("\n"); + return `# Earcon pack: ${pack.identity} + +Generated by the AquaSynth Earcon Workshop. **Nobody has listened to this pack.** Metrics (peak, onset, distinctness) say +the files are not silent, not clipped and differ from each other. They do not say the sounds are pleasant, clear in your +room, or fit your product. Audition them before you ship them. + +16-bit PCM mono WAV, ${pack.sampleRate} Hz. \`pack.json\` maps event id to file; \`params\` regenerates the same family in the workshop. + +| event | file | length | meaning | +|---|---|---|---| +${ev} + +## Using it + +**CI** (play on the runner or a dev box; never fail the build on a missing audio device): +\`\`\`sh +play_earcon() { f="$(dirname "$0")/earcons/$1"; { paplay "$f" || aplay -q "$f" || afplay "$f"; } 2>/dev/null || true; } +make test && play_earcon ${pack.events.success?.file ?? "success.wav"} || play_earcon ${pack.events.fail?.file ?? "fail.wav"} +\`\`\` +On a headless runner, attach the file to the job's notification instead (see chat bots). + +**Chat bots** (Discord, Slack, Matrix): read \`pack.json\`, look up \`events[eventId].file\`, upload that WAV with the message. +\`\`\`js +const pack = JSON.parse(await fs.readFile("pack.json", "utf8")); +await channel.send({ content: "build finished", files: [path.join(dir, pack.events.done.file)] }); +\`\`\` + +**Apps** (web): \`new Audio(url).play()\` after a user gesture; browsers block autoplay. Keep one \`Audio\` per event and reset +\`currentTime\` before replaying. Native apps: load the WAV through the platform's short-sound API. + +Keep the system volume yours: files peak at or under ${PEAK_CEILING} of full scale (level ${pack.params.level}), which is already loud on headphones. +`; +} + +// ---- Minimal stored (uncompressed) ZIP, so the page can hand over one file ------------------------------------------ +const CRC = (() => { const t = new Uint32Array(256); for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; t[n] = c >>> 0; } return t; })(); +export function crc32(b) { let c = 0xffffffff; for (let i = 0; i < b.length; i++) c = CRC[(c ^ b[i]) & 255] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; } + +export function zip(files) { // files: [{name, bytes}] + const enc = new TextEncoder(), parts = [], central = []; + let off = 0; + for (const f of files) { + const name = enc.encode(f.name), crc = crc32(f.bytes), h = new DataView(new ArrayBuffer(30)); + h.setUint32(0, 0x04034b50, true); h.setUint16(4, 20, true); h.setUint16(8, 0, true); h.setUint16(12, 0x21, true); h.setUint16(10, 0, true); + h.setUint32(14, crc, true); h.setUint32(18, f.bytes.length, true); h.setUint32(22, f.bytes.length, true); h.setUint16(26, name.length, true); + parts.push(new Uint8Array(h.buffer), name, f.bytes); + const c = new DataView(new ArrayBuffer(46)); + c.setUint32(0, 0x02014b50, true); c.setUint16(4, 20, true); c.setUint16(6, 20, true); c.setUint16(14, 0x21, true); + c.setUint32(16, crc, true); c.setUint32(20, f.bytes.length, true); c.setUint32(24, f.bytes.length, true); c.setUint16(28, name.length, true); c.setUint32(42, off, true); + central.push(new Uint8Array(c.buffer), name); + off += 30 + name.length + f.bytes.length; + } + const cdSize = central.reduce((s, p) => s + p.length, 0), end = new DataView(new ArrayBuffer(22)); + end.setUint32(0, 0x06054b50, true); end.setUint16(8, files.length, true); end.setUint16(10, files.length, true); end.setUint32(12, cdSize, true); end.setUint32(16, off, true); + const all = [...parts, ...central, new Uint8Array(end.buffer)], out = new Uint8Array(all.reduce((s, p) => s + p.length, 0)); + let o = 0; for (const p of all) { out.set(p, o); o += p.length; } + return out; +} + +export function packFiles(family) { + const pack = buildPack(family), enc = new TextEncoder(); + return [ + ...family.items.map((it) => ({ name: fileName(family.identity, it.event), bytes: encodeWav(it.samples) })), + { name: "pack.json", bytes: enc.encode(JSON.stringify(pack, null, 2) + "\n") }, + { name: "README.md", bytes: enc.encode(packReadme(pack)) }, + ]; +} +export { fileName }; diff --git a/tools/earcon-workshop/web/index.html b/tools/earcon-workshop/web/index.html new file mode 100644 index 0000000..deffe04 --- /dev/null +++ b/tools/earcon-workshop/web/index.html @@ -0,0 +1,43 @@ + + + + + + AquaSynth Earcon Workshop + + + +
+
+

AquaSynth lab

+

Earcon Workshop

+

Pick the events your tool needs and a voice. The workshop renders one short, related earcon per event, entirely in this page, and exports WAVs plus a JSON pack. Nobody has listened to any of this. The checks measure silence, clipping, onset and difference between siblings; they cannot tell you it sounds good.

+
+
+ + + + + + +
+
+
+

Events

+
+

Tweak (one factor each, applied to the whole family)

+
+

+
+
+

Export

+

+

The zip holds one 16-bit mono WAV per chosen event, pack.json and a README.md on using them in CI, chat bots and apps. Offline render from the same code that played above.

+

Pack (measured, not judged)

+

+      
+
+
+ + + diff --git a/tools/earcon-workshop/web/styles.css b/tools/earcon-workshop/web/styles.css new file mode 100644 index 0000000..5b68151 --- /dev/null +++ b/tools/earcon-workshop/web/styles.css @@ -0,0 +1,21 @@ +:root { color-scheme: dark; --bg:#0b1418; --fg:#d7e6ea; --dim:#7f9aa3; --acc:#3fc1c9; --line:#1f3640; } +* { box-sizing: border-box; } +body { margin:0; background:var(--bg); color:var(--fg); font:15px/1.45 system-ui, sans-serif; } +main { max-width:1100px; margin:0 auto; padding:24px; } +.eyebrow { margin:0; color:var(--acc); text-transform:uppercase; letter-spacing:.12em; font-size:12px; } +h1 { margin:.1em 0 .2em; } h2 { font-size:16px; margin:16px 0 8px; } small, .dim { color:var(--dim); font-weight:400; } +.lede { color:var(--dim); max-width:72ch; } .lede strong { color:var(--fg); } +.bar { display:flex; flex-wrap:wrap; gap:12px 16px; align-items:center; padding:12px 0; border-block:1px solid var(--line); margin-bottom:16px; } +button, select { background:#10242b; color:var(--fg); border:1px solid var(--line); padding:6px 14px; border-radius:4px; font:inherit; cursor:pointer; } +button:hover { border-color:var(--acc); } button:disabled { opacity:.4; } +#status { color:var(--dim); } +.cols { display:grid; grid-template-columns:minmax(300px,1.2fr) minmax(300px,1fr); gap:24px; } +@media (max-width:800px) { .cols { grid-template-columns:1fr; } } +.events { display:grid; gap:6px; } +.ev { display:grid; grid-template-columns:auto 1fr auto auto; gap:8px; align-items:center; padding:6px 8px; border:1px solid var(--line); border-radius:4px; } +.ev canvas { grid-column:1 / -1; width:100%; height:34px; background:#071013; border-radius:3px; } +.ev .meta { color:var(--dim); font-size:12px; } .ev b { display:block; font-weight:600; color:var(--fg); } +.controls { display:grid; gap:6px; } +.controls .row { display:grid; grid-template-columns:110px minmax(0,1fr) 58px; gap:8px; align-items:center; } +.controls output { text-align:right; color:var(--acc); font-variant-numeric:tabular-nums; } +pre { background:#071013; color:#bcd3d8; border:1px solid var(--line); border-radius:4px; font:12px/1.4 ui-monospace, monospace; padding:8px; max-height:60vh; overflow:auto; } From 33a4ccc0f2f6f15263db9687e09bf97af653e7b4 Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 05:36:46 +0000 Subject: [PATCH 017/124] earcon-workshop: review fixes (check count 882, lowpass comment says two poles) Co-Authored-By: Claude Sonnet 5.5 --- tools/earcon-workshop/README.md | 2 +- tools/earcon-workshop/web/earcon.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/earcon-workshop/README.md b/tools/earcon-workshop/README.md index b745daf..4c533d3 100644 --- a/tools/earcon-workshop/README.md +++ b/tools/earcon-workshop/README.md @@ -32,7 +32,7 @@ Never opened on a real display by a person. A headless Chromium smoke (load, aud ## What the check covers (`test.mjs`) -For each identity x event at the default setting and at two slider extremes (881 checks at the time of writing): +For each identity x event at the default setting and at two slider extremes (882 checks at the time of writing): - finite, non-silent, onset (first sample at or above -40 dBFS) under 20 ms, sample peak < 1.0 and <= 0.9, true peak < 1.0 (cross-checked with `tools/aqua-feel/metrics.js`), no over-full-scale samples or flat tops, ends without a step, under 2.6 s, WAV round trip. diff --git a/tools/earcon-workshop/web/earcon.js b/tools/earcon-workshop/web/earcon.js index 1cca563..6dcee6a 100644 --- a/tools/earcon-workshop/web/earcon.js +++ b/tools/earcon-workshop/web/earcon.js @@ -46,7 +46,7 @@ export function clampParams(p = {}) { const TAU = Math.PI * 2; // One note into `out` at sample `start`. Linear attack (<= 6 ms), exponential decay reaching -60 dB at `decaySec`, -// one-pole lowpass whose cutoff follows brightness, 3 ms linear fade at the voice end so no tail ends on a step. +// two-pole lowpass (two cascaded one-pole stages) whose cutoff follows brightness, 3 ms linear fade at the voice end so no tail ends on a step. function addNote(out, start, hz, gain, id, decaySec, bright) { const len = Math.min(out.length - start, Math.ceil(decaySec * SR)); if (len <= 0) return; From 235a397de0bfcff375d040e9a99881a9c5587d38 Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 12:40:06 +0000 Subject: [PATCH 018/124] aqua-feel: effects shelf (SHELF.md, generated shelf.json, render+check) 55 entries (thruster, 9 Ding events, 4 earcon identities, 41 playground patches): params with the DSP's own ranges, what each reacts to (event, control or start; none reacts to audio), the render command, duration, and a listening field that stays 'unheard'. shelf.mjs check runs every render command and reads the WAVs back: finite, not silent, as long as listed, and shelf.json/SHELF.md current. No dependencies added. Nothing was heard. Co-Authored-By: Claude Sonnet 5.5 --- tools/aqua-feel/README.md | 4 + tools/aqua-feel/SHELF.md | 125 ++ tools/aqua-feel/package.json | 2 +- tools/aqua-feel/shelf.json | 2824 ++++++++++++++++++++++++++++++++++ tools/aqua-feel/shelf.mjs | 180 +++ 5 files changed, 3134 insertions(+), 1 deletion(-) create mode 100644 tools/aqua-feel/SHELF.md create mode 100644 tools/aqua-feel/shelf.json create mode 100644 tools/aqua-feel/shelf.mjs diff --git a/tools/aqua-feel/README.md b/tools/aqua-feel/README.md index 87aa094..e20a649 100644 --- a/tools/aqua-feel/README.md +++ b/tools/aqua-feel/README.md @@ -61,6 +61,10 @@ at the shipped renders. They are tripwires, not taste. Current waivers: `sfxr-classic-classic-sfxr-abstract-golf` (+0.9 dBTP, -5.3 LUFS, held noise) and `sfxr-explosion` (3 s of steady noise without decay). Nobody has listened to either to see if the number is the sound. +## Effects shelf + +`SHELF.md` and `shelf.json` list every renderable effect (thruster, Dings, earcon families, playground patches) with params, trigger, render command and duration; `node shelf.mjs check` runs every render command and checks the WAVs are finite and not silent. Nothing on it is heard (`listening: unheard`). + ## Reuse `report.js` imports `mean`, `spearman` and `permutationP` from `../aqua-trial/analyze.mjs` and the variants from diff --git a/tools/aqua-feel/SHELF.md b/tools/aqua-feel/SHELF.md new file mode 100644 index 0000000..3f423bc --- /dev/null +++ b/tools/aqua-feel/SHELF.md @@ -0,0 +1,125 @@ +# Effects shelf + +What AquaSynth can render to a WAV today without a window, an audio device or a server: the thruster, the Dings event sounds, the +earcon workshop's families and the playground's synth patches. `shelf.json` is the machine-readable list (generated); the tables +below are generated from it. Both come from `node tools/aqua-feel/shelf.mjs build`. + +**Nothing on this shelf has been heard.** Every `listening` field is `unheard`. `node tools/aqua-feel/shelf.mjs check` runs each +entry's render command and proves the file is finite, not silent (peak above -70 dBFS) and as long as listed. It cannot say +that anything sounds good, fits an overlay, or is distinguishable on a stream. A person edits `listening` after listening. + +## For overlay packaging + +- **No entry reacts to audio.** Nothing here analyses a signal. Entries react to *events* (Ding event ids, earcon event ids), to a + *control value* (the thruster's `rpm`), or to being *started* (patches). Mapping a StreamPixels event onto any of these is not + done anywhere in the repo; that mapping is the packager's. +- Two event vocabularies exist and do not match: Dings use task-state ids (`task.complete`, `input.required`, ...), the earcon + workshop uses `success, fail, warning, message, done, waiting`. The earcon workshop is a separate JS implementation and + does not sound like the Dings. +- Every command runs from the repo root, needs node >= 20, and writes under `tools/aqua-feel/out/shelf/` (gitignored). Patch and + Ding renders need the faustwasm runtime once: `(cd tools/aqua-playground && npm ci)`. Earcon renders need nothing installed. +- Patch and Ding WAVs are mono float32 at 48 kHz; earcon WAVs are mono 16-bit at 48 kHz. +- `duration_s` for patches is the 3 s render window, not the effect's length: `behaviour` says whether the patch was still sounding + at 3 s (sustained) or had died away. Re-render with `--seconds N` for longer. +- Ding loudness uses command gain 0.6, an assumption carried over from `tools/aqua-feel`. + +## Render one + +```sh +node tools/aqua-feel/shelf.mjs render patch/thruster rpm=2400 --out /tmp/thruster.wav --seconds 5 +node tools/aqua-feel/shelf.mjs render ding/task.complete instrument=glass-chime --out /tmp/done.wav +node tools/earcon-workshop/cli.mjs warm-bell /tmp/earcons tempo=1.2 level=0.6 # six WAVs + pack.json +node tools/aqua-feel/shelf.mjs check # every entry (about two minutes); --only SUBSTR for a subset +``` + +Each entry in `shelf.json` carries its own `render.command` (the exact string `check` runs) and the files it writes. +Sustained patches such as the thruster keep sounding until stopped; the render command cuts them at the window. + +## Entries + + + +### Thruster (1) + +| id | reacts to | params | behaviour | duration | listening | +|---|---|---|---|---|---| +| `patch/thruster` | control: rpm | rpm 300..6000 (default 1200) | sustained | 3 s | unheard | + +### Dings (event sounds) (9) + +| id | reacts to | params | behaviour | duration | listening | +|---|---|---|---|---|---| +| `ding/input.required` | event `input.required` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.76 s | unheard | +| `ding/resource.limit` | event `resource.limit` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 2.06 s | unheard | +| `ding/session.end` | event `session.end` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.74 s | unheard | +| `ding/session.start` | event `session.start` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.72 s | unheard | +| `ding/task.acknowledge` | event `task.acknowledge` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.5 s | unheard | +| `ding/task.complete` | event `task.complete` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.72 s | unheard | +| `ding/task.error` | event `task.error` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.98 s | unheard | +| `ding/task.progress` | event `task.progress` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.5 s | unheard | +| `ding/user.spam` | event `user.spam` | instrument ∈ {glass-chime, muted-pluck, soft-triangle, warm-bell} (default warm-bell) | decays | 1.88 s | unheard | + +### Earcon workshop (one WAV per event) (4) + +| id | reacts to | params | behaviour | duration | listening | +|---|---|---|---|---|---| +| `earcon/warm-bell` | events: success, fail, warning, message, done, waiting | tempo 0.6..1.6 (default 1); transpose -12..12 (default 0); brightness -0.25..0.25 (default 0); decay 0.5..1.6 (default 1); level 0.1..0.9 (default 0.7) | decays | 1.45 s | unheard | +| `earcon/glass-chime` | events: success, fail, warning, message, done, waiting | tempo 0.6..1.6 (default 1); transpose -12..12 (default 0); brightness -0.25..0.25 (default 0); decay 0.5..1.6 (default 1); level 0.1..0.9 (default 0.7) | decays | 1.35 s | unheard | +| `earcon/soft-triangle` | events: success, fail, warning, message, done, waiting | tempo 0.6..1.6 (default 1); transpose -12..12 (default 0); brightness -0.25..0.25 (default 0); decay 0.5..1.6 (default 1); level 0.1..0.9 (default 0.7) | decays | 1.4 s | unheard | +| `earcon/muted-pluck` | events: success, fail, warning, message, done, waiting | tempo 0.6..1.6 (default 1); transpose -12..12 (default 0); brightness -0.25..0.25 (default 0); decay 0.5..1.6 (default 1); level 0.1..0.9 (default 0.7) | decays | 1.15 s | unheard | + +### Playground patches (one-shot and sustained synth sounds) (41) + +| id | reacts to | params | behaviour | duration | listening | +|---|---|---|---|---|---| +| `patch/808-clap` | start | none | decays | 3 s | unheard | +| `patch/808-cowbell` | start | none | decays | 3 s | unheard | +| `patch/808-hat` | start | none | decays | 3 s | unheard | +| `patch/808-kick` | start | none | decays | 3 s | unheard | +| `patch/808-snare` | start | none | decays | 3 s | unheard | +| `patch/808-tom` | start | none | decays | 3 s | unheard | +| `patch/advanced-alien-multivalve-graph` | start | alien/aperture 0..2 (default 0.85); alien/core/opening 0..1 (default 0.24); alien/core/pressure 0..1.5 (default 0.74); alien/side/opening 0..1 (default 0.3); alien/side/pressure 0..1.5 (default 0.52); curves/core_breath/depth 0..1 (default 0.9); curves/mouth_shape/depth 0..1 (default 0.8); curves/side_breath/depth 0..1 (default 0.9) | decays | 3 s | unheard | +| `patch/advanced-aurora-pad` | start | none | decays | 3 s | unheard | +| `patch/advanced-bird-syrinx` | start | bird/beak/opening 0..1.5 (default 0.95); bird/left/damping 0..2 (default 0.14); bird/left/flow_scale 0..4 (default 1.2); bird/left/load_coupling 0..2 (default 0.42); bird/left/mass 0.02..2 (default 0.32); bird/left/opening 0..1 (default 0.24); bird/left/pressure 0..1 (default 0.82); bird/left/rest_opening 0..1 (default 0.025); bird/left/stiffness 0..1 (default 0.025); bird/left/tension 0..1 (default 0.38); bird/left/tissue_loss 0..1 (default 0.18); bird/right/damping 0..2 (default 0.16); bird/right/flow_scale 0..4 (default 1.1); bird/right/load_coupling 0..2 (default 0.42); bird/right/mass 0.02..2 (default 0.34); bird/right/opening 0..1 (default 0.21); bird/right/pressure 0..1 (default 0.7); bird/right/rest_opening 0..1 (default 0.025); bird/right/stiffness 0..1 (default 0.03); bird/right/tension 0..1 (default 0.45); bird/right/tissue_loss 0..1 (default 0.2); curves/beak_opening/depth 0..1 (default 0.7); curves/left_opening/depth 0..1 (default 0.85); curves/left_pressure/depth 0..1 (default 1); curves/right_opening/depth 0..1 (default 0.85); curves/right_pressure/depth 0..1 (default 1) | decays | 3 s | unheard | +| `patch/advanced-bird-syrinx-graph` | start | bird/beak/opening 0..1.5 (default 0.92); bird/left/opening 0..1 (default 0.2); bird/left/pressure 0..1.5 (default 0.84); bird/left/tension 0..1 (default 0.46); bird/right/opening 0..1 (default 0.18); bird/right/pressure 0..1.5 (default 0.72); bird/right/tension 0..1 (default 0.52); curves/beak_gate/depth 0..1 (default 0.75); curves/left_air/depth 0..1 (default 0.95); curves/left_labium_gate/depth 0..1 (default 0.9); curves/right_air/depth 0..1 (default 0.95); curves/right_labium_gate/depth 0..1 (default 0.9) | decays | 3 s | unheard | +| `patch/advanced-glass-creature` | start | none | decays | 3 s | unheard | +| `patch/advanced-human-larynx-graph` | start | curves/breath_phrase/depth 0..1 (default 0.9); curves/fold_onset/depth 0..1 (default 0.8); curves/lip_vowel/depth 0..1 (default 0.65); human/constriction/diameter 0.02..3 (default 0.95); human/constriction/index 0..6 (default 4.8); human/fold/opening 0..1 (default 0.16); human/fold/tension 0..1 (default 0.58); human/lip/opening 0..2 (default 1.2); human/subglottal 0..1.5 (default 0.78); human/tongue/diameter 0.05..3 (default 1.25); human/tongue/index 0..6 (default 3.3) | decays | 3 s | unheard | +| `patch/advanced-machine-breath` | start | none | decays | 3 s | unheard | +| `patch/advanced-ritual-sequence` | start | none | sustained | 3 s | unheard | +| `patch/advanced-subtractive-drums` | start | none | decays | 3 s | unheard | +| `patch/advanced-syrinx-voice` | start | curves/beak_phrase/depth 0..1 (default 0.72); curves/left_phrase_opening/depth 0..1 (default 0.85); curves/left_phrase_pressure/depth 0..1 (default 0.92); curves/right_phrase_opening/depth 0..1 (default 0.85); curves/right_phrase_pressure/depth 0..1 (default 0.92); voice/beak/opening 0..1.5 (default 0.88); voice/left/opening 0..1 (default 0.23); voice/left/pressure 0..1.5 (default 0.78); voice/left/tension 0..1 (default 0.43); voice/right/opening 0..1 (default 0.19); voice/right/pressure 0..1.5 (default 0.66); voice/right/tension 0..1 (default 0.5) | decays | 3 s | unheard | +| `patch/bfxr-coin-spark` | start | none | decays | 3 s | unheard | +| `patch/bfxr-portal-chirp` | start | none | decays | 3 s | unheard | +| `patch/bfxr-shield-pop` | start | none | decays | 3 s | unheard | +| `patch/bfxr-ui-bloom` | start | none | sustained | 3 s | unheard | +| `patch/dx7-algorithm-32-additive-organ` | start | macro/drawbar 0..1 (default 0.78); macro/shimmer 0..0.3 (default 0.08) | decays | 3 s | unheard | +| `patch/dx7-algorithm-8-bright-pair` | start | macro/brightness 0..5 (default 2.6); macro/strike 0.02..0.6 (default 0.18) | decays | 3 s | unheard | +| `patch/dx7-public-domain-mc-mm-5-3` | start | none | decays | 3 s | unheard | +| `patch/dx7-public-domain-prc-synth1-calibrated` | start | none | decays | 3 s | unheard | +| `patch/examples-language-tour` | start | none | sustained | 3 s | unheard | +| `patch/fm-bell-bell` | start | none | decays | 3 s | unheard | +| `patch/fm-bell-chime` | start | none | decays | 3 s | unheard | +| `patch/fm-bell-coin` | start | none | decays | 3 s | unheard | +| `patch/fm-bell-gong` | start | none | decays | 3 s | unheard | +| `patch/sfxr-blip` | start | none | decays | 3 s | unheard | +| `patch/sfxr-classic-classic-sfxr-abstract-golf` | start | none | sustained | 3 s | unheard | +| `patch/sfxr-explosion` | start | none | sustained | 3 s | unheard | +| `patch/sfxr-hit` | start | none | decays | 3 s | unheard | +| `patch/sfxr-jump` | start | none | decays | 3 s | unheard | +| `patch/sfxr-laser` | start | none | decays | 3 s | unheard | +| `patch/sfxr-pickup` | start | none | decays | 3 s | unheard | +| `patch/sfxr-powerup` | start | none | sustained | 3 s | unheard | +| `patch/wobble-bass-growl` | start | none | decays | 3 s | unheard | +| `patch/wobble-bass-neuro` | start | none | decays | 3 s | unheard | +| `patch/wobble-bass-talker` | start | none | decays | 3 s | unheard | +| `patch/wobble-bass-yoy` | start | none | decays | 3 s | unheard | + + + +## Not on the shelf + +- `tools/aqua-trial`'s `thruster-trial.dsp` (the thruster plus a `noise` percent control): a listening-trial fixture, not an effect. +- `advanced/additive-pad` and `advanced/electro-drop-demo`: they lower to about 1.5 MB of Faust each and are not in the playground. +- The Dings daemon's native libfaust path (`-vec`): the shelf renders through faustwasm, the same host as `tools/aqua-feel`; the two + have not been diffed. +- Nothing is mapped to StreamPixels events, and no overlay-side player exists in this repo. diff --git a/tools/aqua-feel/package.json b/tools/aqua-feel/package.json index 9015ff1..6707152 100644 --- a/tools/aqua-feel/package.json +++ b/tools/aqua-feel/package.json @@ -3,5 +3,5 @@ "private": true, "type": "module", "description": "Headless feel meter for AquaSynth: renders every shipped patch and Ding offline and measures them. Measures; does not listen.", - "scripts": { "test": "node test.mjs", "feel": "node feel.mjs" } + "scripts": { "test": "node test.mjs", "feel": "node feel.mjs", "shelf": "node shelf.mjs build", "shelf:check": "node shelf.mjs check" } } diff --git a/tools/aqua-feel/shelf.json b/tools/aqua-feel/shelf.json new file mode 100644 index 0000000..fbbac7e --- /dev/null +++ b/tools/aqua-feel/shelf.json @@ -0,0 +1,2824 @@ +{ + "schema": "aquasynth.effects-shelf.v0", + "note": "Generated by tools/aqua-feel/shelf.mjs build. Nothing here was heard: every entry's listening status is 'unheard'. Commands run from the repo root.", + "sampleRate": 48000, + "entries": [ + { + "id": "patch/thruster", + "group": "thruster", + "name": "thruster", + "family": "thruster", + "source": "tools/aqua-playground/lowered/thruster.dsp", + "params": [ + { + "name": "rpm", + "kind": "slider", + "min": 300, + "max": 6000, + "default": 1200, + "step": 1 + } + ], + "reacts_to": { + "kind": "control", + "detail": "the rpm slider (300..6000, smoothed over 0.2 s): drive it from whatever number should make the thruster work harder. Nothing in the repo maps a stream metric to rpm." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/thruster --out tools/aqua-feel/out/shelf/patch_thruster.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_thruster.wav", + "duration_s": 3 + } + ] + }, + "check_variants": [ + { + "params": { + "rpm": 300 + }, + "command": "node tools/aqua-feel/shelf.mjs render patch/thruster rpm=300 --out tools/aqua-feel/out/shelf/patch_thruster_rpm300.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_thruster_rpm300.wav", + "duration_s": 3 + } + ] + }, + { + "params": { + "rpm": 6000 + }, + "command": "node tools/aqua-feel/shelf.mjs render patch/thruster rpm=6000 --out tools/aqua-feel/out/shelf/patch_thruster_rpm6000.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_thruster_rpm6000.wav", + "duration_s": 3 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "patch/808-clap", + "group": "patch", + "name": "808-clap", + "family": "808", + "source": "tools/aqua-playground/lowered/808-clap.dsp (lowered from patches/808/clap.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/808-clap --out tools/aqua-feel/out/shelf/patch_808-clap.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_808-clap.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/808-cowbell", + "group": "patch", + "name": "808-cowbell", + "family": "808", + "source": "tools/aqua-playground/lowered/808-cowbell.dsp (lowered from patches/808/cowbell.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/808-cowbell --out tools/aqua-feel/out/shelf/patch_808-cowbell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_808-cowbell.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/808-hat", + "group": "patch", + "name": "808-hat", + "family": "808", + "source": "tools/aqua-playground/lowered/808-hat.dsp (lowered from patches/808/hat.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/808-hat --out tools/aqua-feel/out/shelf/patch_808-hat.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_808-hat.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/808-kick", + "group": "patch", + "name": "808-kick", + "family": "808", + "source": "tools/aqua-playground/lowered/808-kick.dsp (lowered from patches/808/kick.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/808-kick --out tools/aqua-feel/out/shelf/patch_808-kick.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_808-kick.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/808-snare", + "group": "patch", + "name": "808-snare", + "family": "808", + "source": "tools/aqua-playground/lowered/808-snare.dsp (lowered from patches/808/snare.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/808-snare --out tools/aqua-feel/out/shelf/patch_808-snare.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_808-snare.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/808-tom", + "group": "patch", + "name": "808-tom", + "family": "808", + "source": "tools/aqua-playground/lowered/808-tom.dsp (lowered from patches/808/tom.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/808-tom --out tools/aqua-feel/out/shelf/patch_808-tom.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_808-tom.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-alien-multivalve-graph", + "group": "patch", + "name": "advanced-alien-multivalve-graph", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-alien-multivalve-graph.dsp (lowered from patches/advanced/alien-multivalve-graph.aqua)", + "params": [ + { + "name": "alien/aperture", + "kind": "slider", + "min": 0, + "max": 2, + "default": 0.85, + "step": 0.001 + }, + { + "name": "alien/core/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.24, + "step": 0.001 + }, + { + "name": "alien/core/pressure", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.74, + "step": 0.001 + }, + { + "name": "alien/side/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.3, + "step": 0.001 + }, + { + "name": "alien/side/pressure", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.52, + "step": 0.001 + }, + { + "name": "curves/core_breath/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.9, + "step": 0.001 + }, + { + "name": "curves/mouth_shape/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.8, + "step": 0.001 + }, + { + "name": "curves/side_breath/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.9, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-alien-multivalve-graph --out tools/aqua-feel/out/shelf/patch_advanced-alien-multivalve-graph.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-alien-multivalve-graph.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-aurora-pad", + "group": "patch", + "name": "advanced-aurora-pad", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-aurora-pad.dsp (lowered from patches/advanced/aurora-pad.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-aurora-pad --out tools/aqua-feel/out/shelf/patch_advanced-aurora-pad.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-aurora-pad.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-bird-syrinx", + "group": "patch", + "name": "advanced-bird-syrinx", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-bird-syrinx.dsp (lowered from patches/advanced/bird-syrinx.aqua)", + "params": [ + { + "name": "bird/beak/opening", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.95, + "step": 0.001 + }, + { + "name": "bird/left/damping", + "kind": "slider", + "min": 0, + "max": 2, + "default": 0.14, + "step": 0.001 + }, + { + "name": "bird/left/flow_scale", + "kind": "slider", + "min": 0, + "max": 4, + "default": 1.2, + "step": 0.001 + }, + { + "name": "bird/left/load_coupling", + "kind": "slider", + "min": 0, + "max": 2, + "default": 0.42, + "step": 0.001 + }, + { + "name": "bird/left/mass", + "kind": "slider", + "min": 0.02, + "max": 2, + "default": 0.32, + "step": 0.001 + }, + { + "name": "bird/left/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.24, + "step": 0.001 + }, + { + "name": "bird/left/pressure", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.82, + "step": 0.001 + }, + { + "name": "bird/left/rest_opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.025, + "step": 0.001 + }, + { + "name": "bird/left/stiffness", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.025, + "step": 0.001 + }, + { + "name": "bird/left/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.38, + "step": 0.001 + }, + { + "name": "bird/left/tissue_loss", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.18, + "step": 0.001 + }, + { + "name": "bird/right/damping", + "kind": "slider", + "min": 0, + "max": 2, + "default": 0.16, + "step": 0.001 + }, + { + "name": "bird/right/flow_scale", + "kind": "slider", + "min": 0, + "max": 4, + "default": 1.1, + "step": 0.001 + }, + { + "name": "bird/right/load_coupling", + "kind": "slider", + "min": 0, + "max": 2, + "default": 0.42, + "step": 0.001 + }, + { + "name": "bird/right/mass", + "kind": "slider", + "min": 0.02, + "max": 2, + "default": 0.34, + "step": 0.001 + }, + { + "name": "bird/right/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.21, + "step": 0.001 + }, + { + "name": "bird/right/pressure", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.7, + "step": 0.001 + }, + { + "name": "bird/right/rest_opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.025, + "step": 0.001 + }, + { + "name": "bird/right/stiffness", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.03, + "step": 0.001 + }, + { + "name": "bird/right/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.45, + "step": 0.001 + }, + { + "name": "bird/right/tissue_loss", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.2, + "step": 0.001 + }, + { + "name": "curves/beak_opening/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.7, + "step": 0.001 + }, + { + "name": "curves/left_opening/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.85, + "step": 0.001 + }, + { + "name": "curves/left_pressure/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 1, + "step": 0.001 + }, + { + "name": "curves/right_opening/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.85, + "step": 0.001 + }, + { + "name": "curves/right_pressure/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 1, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-bird-syrinx --out tools/aqua-feel/out/shelf/patch_advanced-bird-syrinx.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-bird-syrinx.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-bird-syrinx-graph", + "group": "patch", + "name": "advanced-bird-syrinx-graph", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-bird-syrinx-graph.dsp (lowered from patches/advanced/bird-syrinx-graph.aqua)", + "params": [ + { + "name": "bird/beak/opening", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.92, + "step": 0.001 + }, + { + "name": "bird/left/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.2, + "step": 0.001 + }, + { + "name": "bird/left/pressure", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.84, + "step": 0.001 + }, + { + "name": "bird/left/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.46, + "step": 0.001 + }, + { + "name": "bird/right/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.18, + "step": 0.001 + }, + { + "name": "bird/right/pressure", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.72, + "step": 0.001 + }, + { + "name": "bird/right/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.52, + "step": 0.001 + }, + { + "name": "curves/beak_gate/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.75, + "step": 0.001 + }, + { + "name": "curves/left_air/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.95, + "step": 0.001 + }, + { + "name": "curves/left_labium_gate/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.9, + "step": 0.001 + }, + { + "name": "curves/right_air/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.95, + "step": 0.001 + }, + { + "name": "curves/right_labium_gate/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.9, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-bird-syrinx-graph --out tools/aqua-feel/out/shelf/patch_advanced-bird-syrinx-graph.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-bird-syrinx-graph.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-glass-creature", + "group": "patch", + "name": "advanced-glass-creature", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-glass-creature.dsp (lowered from patches/advanced/glass-creature.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-glass-creature --out tools/aqua-feel/out/shelf/patch_advanced-glass-creature.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-glass-creature.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-human-larynx-graph", + "group": "patch", + "name": "advanced-human-larynx-graph", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-human-larynx-graph.dsp (lowered from patches/advanced/human-larynx-graph.aqua)", + "params": [ + { + "name": "curves/breath_phrase/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.9, + "step": 0.001 + }, + { + "name": "curves/fold_onset/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.8, + "step": 0.001 + }, + { + "name": "curves/lip_vowel/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.65, + "step": 0.001 + }, + { + "name": "human/constriction/diameter", + "kind": "slider", + "min": 0.02, + "max": 3, + "default": 0.95, + "step": 0.001 + }, + { + "name": "human/constriction/index", + "kind": "slider", + "min": 0, + "max": 6, + "default": 4.8, + "step": 0.001 + }, + { + "name": "human/fold/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.16, + "step": 0.001 + }, + { + "name": "human/fold/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.58, + "step": 0.001 + }, + { + "name": "human/lip/opening", + "kind": "slider", + "min": 0, + "max": 2, + "default": 1.2, + "step": 0.001 + }, + { + "name": "human/subglottal", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.78, + "step": 0.001 + }, + { + "name": "human/tongue/diameter", + "kind": "slider", + "min": 0.05, + "max": 3, + "default": 1.25, + "step": 0.001 + }, + { + "name": "human/tongue/index", + "kind": "slider", + "min": 0, + "max": 6, + "default": 3.3, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-human-larynx-graph --out tools/aqua-feel/out/shelf/patch_advanced-human-larynx-graph.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-human-larynx-graph.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-machine-breath", + "group": "patch", + "name": "advanced-machine-breath", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-machine-breath.dsp (lowered from patches/advanced/machine-breath.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-machine-breath --out tools/aqua-feel/out/shelf/patch_advanced-machine-breath.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-machine-breath.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-ritual-sequence", + "group": "patch", + "name": "advanced-ritual-sequence", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-ritual-sequence.dsp (lowered from patches/advanced/ritual-sequence.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-ritual-sequence --out tools/aqua-feel/out/shelf/patch_advanced-ritual-sequence.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-ritual-sequence.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-subtractive-drums", + "group": "patch", + "name": "advanced-subtractive-drums", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-subtractive-drums.dsp (lowered from patches/advanced/subtractive-drums.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-subtractive-drums --out tools/aqua-feel/out/shelf/patch_advanced-subtractive-drums.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-subtractive-drums.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/advanced-syrinx-voice", + "group": "patch", + "name": "advanced-syrinx-voice", + "family": "advanced", + "source": "tools/aqua-playground/lowered/advanced-syrinx-voice.dsp (lowered from patches/advanced/syrinx-voice.aqua)", + "params": [ + { + "name": "curves/beak_phrase/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.72, + "step": 0.001 + }, + { + "name": "curves/left_phrase_opening/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.85, + "step": 0.001 + }, + { + "name": "curves/left_phrase_pressure/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.92, + "step": 0.001 + }, + { + "name": "curves/right_phrase_opening/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.85, + "step": 0.001 + }, + { + "name": "curves/right_phrase_pressure/depth", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.92, + "step": 0.001 + }, + { + "name": "voice/beak/opening", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.88, + "step": 0.001 + }, + { + "name": "voice/left/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.23, + "step": 0.001 + }, + { + "name": "voice/left/pressure", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.78, + "step": 0.001 + }, + { + "name": "voice/left/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.43, + "step": 0.001 + }, + { + "name": "voice/right/opening", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.19, + "step": 0.001 + }, + { + "name": "voice/right/pressure", + "kind": "slider", + "min": 0, + "max": 1.5, + "default": 0.66, + "step": 0.001 + }, + { + "name": "voice/right/tension", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.5, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/advanced-syrinx-voice --out tools/aqua-feel/out/shelf/patch_advanced-syrinx-voice.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_advanced-syrinx-voice.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/bfxr-coin-spark", + "group": "patch", + "name": "bfxr-coin-spark", + "family": "bfxr", + "source": "tools/aqua-playground/lowered/bfxr-coin-spark.dsp (lowered from patches/bfxr/coin-spark.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/bfxr-coin-spark --out tools/aqua-feel/out/shelf/patch_bfxr-coin-spark.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_bfxr-coin-spark.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/bfxr-portal-chirp", + "group": "patch", + "name": "bfxr-portal-chirp", + "family": "bfxr", + "source": "tools/aqua-playground/lowered/bfxr-portal-chirp.dsp (lowered from patches/bfxr/portal-chirp.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/bfxr-portal-chirp --out tools/aqua-feel/out/shelf/patch_bfxr-portal-chirp.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_bfxr-portal-chirp.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/bfxr-shield-pop", + "group": "patch", + "name": "bfxr-shield-pop", + "family": "bfxr", + "source": "tools/aqua-playground/lowered/bfxr-shield-pop.dsp (lowered from patches/bfxr/shield-pop.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/bfxr-shield-pop --out tools/aqua-feel/out/shelf/patch_bfxr-shield-pop.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_bfxr-shield-pop.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/bfxr-ui-bloom", + "group": "patch", + "name": "bfxr-ui-bloom", + "family": "bfxr", + "source": "tools/aqua-playground/lowered/bfxr-ui-bloom.dsp (lowered from patches/bfxr/ui-bloom.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/bfxr-ui-bloom --out tools/aqua-feel/out/shelf/patch_bfxr-ui-bloom.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_bfxr-ui-bloom.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/dx7-algorithm-32-additive-organ", + "group": "patch", + "name": "dx7-algorithm-32-additive-organ", + "family": "dx7", + "source": "tools/aqua-playground/lowered/dx7-algorithm-32-additive-organ.dsp (lowered from patches/dx7/algorithm-32-additive-organ.aqua)", + "params": [ + { + "name": "macro/drawbar", + "kind": "slider", + "min": 0, + "max": 1, + "default": 0.78, + "step": 0.001 + }, + { + "name": "macro/shimmer", + "kind": "slider", + "min": 0, + "max": 0.3, + "default": 0.08, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/dx7-algorithm-32-additive-organ --out tools/aqua-feel/out/shelf/patch_dx7-algorithm-32-additive-organ.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_dx7-algorithm-32-additive-organ.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/dx7-algorithm-8-bright-pair", + "group": "patch", + "name": "dx7-algorithm-8-bright-pair", + "family": "dx7", + "source": "tools/aqua-playground/lowered/dx7-algorithm-8-bright-pair.dsp (lowered from patches/dx7/algorithm-8-bright-pair.aqua)", + "params": [ + { + "name": "macro/brightness", + "kind": "slider", + "min": 0, + "max": 5, + "default": 2.6, + "step": 0.001 + }, + { + "name": "macro/strike", + "kind": "slider", + "min": 0.02, + "max": 0.6, + "default": 0.18, + "step": 0.001 + } + ], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/dx7-algorithm-8-bright-pair --out tools/aqua-feel/out/shelf/patch_dx7-algorithm-8-bright-pair.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_dx7-algorithm-8-bright-pair.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/dx7-public-domain-mc-mm-5-3", + "group": "patch", + "name": "dx7-public-domain-mc-mm-5-3", + "family": "dx7", + "source": "tools/aqua-playground/lowered/dx7-public-domain-mc-mm-5-3.dsp (lowered from patches/dx7/public-domain-mc-mm-5-3.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/dx7-public-domain-mc-mm-5-3 --out tools/aqua-feel/out/shelf/patch_dx7-public-domain-mc-mm-5-3.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_dx7-public-domain-mc-mm-5-3.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/dx7-public-domain-prc-synth1-calibrated", + "group": "patch", + "name": "dx7-public-domain-prc-synth1-calibrated", + "family": "dx7", + "source": "tools/aqua-playground/lowered/dx7-public-domain-prc-synth1-calibrated.dsp (lowered from patches/dx7/public-domain/prc-synth1-calibrated.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/dx7-public-domain-prc-synth1-calibrated --out tools/aqua-feel/out/shelf/patch_dx7-public-domain-prc-synth1-calibrated.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_dx7-public-domain-prc-synth1-calibrated.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/examples-language-tour", + "group": "patch", + "name": "examples-language-tour", + "family": "examples", + "source": "tools/aqua-playground/lowered/examples-language-tour.dsp (lowered from patches/examples/language-tour.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/examples-language-tour --out tools/aqua-feel/out/shelf/patch_examples-language-tour.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_examples-language-tour.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/fm-bell-bell", + "group": "patch", + "name": "fm-bell-bell", + "family": "fm", + "source": "tools/aqua-playground/lowered/fm-bell-bell.dsp (lowered from patches/fm-bell/bell.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/fm-bell-bell --out tools/aqua-feel/out/shelf/patch_fm-bell-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_fm-bell-bell.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/fm-bell-chime", + "group": "patch", + "name": "fm-bell-chime", + "family": "fm", + "source": "tools/aqua-playground/lowered/fm-bell-chime.dsp (lowered from patches/fm-bell/chime.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/fm-bell-chime --out tools/aqua-feel/out/shelf/patch_fm-bell-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_fm-bell-chime.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/fm-bell-coin", + "group": "patch", + "name": "fm-bell-coin", + "family": "fm", + "source": "tools/aqua-playground/lowered/fm-bell-coin.dsp (lowered from patches/fm-bell/coin.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/fm-bell-coin --out tools/aqua-feel/out/shelf/patch_fm-bell-coin.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_fm-bell-coin.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/fm-bell-gong", + "group": "patch", + "name": "fm-bell-gong", + "family": "fm", + "source": "tools/aqua-playground/lowered/fm-bell-gong.dsp (lowered from patches/fm-bell/gong.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/fm-bell-gong --out tools/aqua-feel/out/shelf/patch_fm-bell-gong.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_fm-bell-gong.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-blip", + "group": "patch", + "name": "sfxr-blip", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-blip.dsp (lowered from patches/sfxr/blip.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-blip --out tools/aqua-feel/out/shelf/patch_sfxr-blip.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-blip.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-classic-classic-sfxr-abstract-golf", + "group": "patch", + "name": "sfxr-classic-classic-sfxr-abstract-golf", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-classic-classic-sfxr-abstract-golf.dsp (lowered from patches/sfxr/classic/classic-sfxr-abstract-golf.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-classic-classic-sfxr-abstract-golf --out tools/aqua-feel/out/shelf/patch_sfxr-classic-classic-sfxr-abstract-golf.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-classic-classic-sfxr-abstract-golf.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-explosion", + "group": "patch", + "name": "sfxr-explosion", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-explosion.dsp (lowered from patches/sfxr/explosion.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-explosion --out tools/aqua-feel/out/shelf/patch_sfxr-explosion.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-explosion.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-hit", + "group": "patch", + "name": "sfxr-hit", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-hit.dsp (lowered from patches/sfxr/hit.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-hit --out tools/aqua-feel/out/shelf/patch_sfxr-hit.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-hit.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-jump", + "group": "patch", + "name": "sfxr-jump", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-jump.dsp (lowered from patches/sfxr/jump.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-jump --out tools/aqua-feel/out/shelf/patch_sfxr-jump.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-jump.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-laser", + "group": "patch", + "name": "sfxr-laser", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-laser.dsp (lowered from patches/sfxr/laser.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-laser --out tools/aqua-feel/out/shelf/patch_sfxr-laser.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-laser.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-pickup", + "group": "patch", + "name": "sfxr-pickup", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-pickup.dsp (lowered from patches/sfxr/pickup.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-pickup --out tools/aqua-feel/out/shelf/patch_sfxr-pickup.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-pickup.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/sfxr-powerup", + "group": "patch", + "name": "sfxr-powerup", + "family": "sfxr", + "source": "tools/aqua-playground/lowered/sfxr-powerup.dsp (lowered from patches/sfxr/powerup.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "sustained: still sounding at the end of the render window, runs until stopped", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/sfxr-powerup --out tools/aqua-feel/out/shelf/patch_sfxr-powerup.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_sfxr-powerup.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/wobble-bass-growl", + "group": "patch", + "name": "wobble-bass-growl", + "family": "wobble", + "source": "tools/aqua-playground/lowered/wobble-bass-growl.dsp (lowered from patches/wobble-bass/growl.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/wobble-bass-growl --out tools/aqua-feel/out/shelf/patch_wobble-bass-growl.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_wobble-bass-growl.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/wobble-bass-neuro", + "group": "patch", + "name": "wobble-bass-neuro", + "family": "wobble", + "source": "tools/aqua-playground/lowered/wobble-bass-neuro.dsp (lowered from patches/wobble-bass/neuro.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/wobble-bass-neuro --out tools/aqua-feel/out/shelf/patch_wobble-bass-neuro.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_wobble-bass-neuro.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/wobble-bass-talker", + "group": "patch", + "name": "wobble-bass-talker", + "family": "wobble", + "source": "tools/aqua-playground/lowered/wobble-bass-talker.dsp (lowered from patches/wobble-bass/talker.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/wobble-bass-talker --out tools/aqua-feel/out/shelf/patch_wobble-bass-talker.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_wobble-bass-talker.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "patch/wobble-bass-yoy", + "group": "patch", + "name": "wobble-bass-yoy", + "family": "wobble", + "source": "tools/aqua-playground/lowered/wobble-bass-yoy.dsp (lowered from patches/wobble-bass/yoy.aqua)", + "params": [], + "reacts_to": { + "kind": "start", + "detail": "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." + }, + "behaviour": "decays: dies away inside the render window", + "duration_s": 3, + "duration_note": "the render window, not the effect's length", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render patch/wobble-bass-yoy --out tools/aqua-feel/out/shelf/patch_wobble-bass-yoy.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/patch_wobble-bass-yoy.wav", + "duration_s": 3 + } + ] + }, + "listening": "unheard" + }, + { + "id": "ding/input.required", + "group": "ding", + "name": "input.required", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "input.required", + "detail": "Ding event \"input.required\": Input requested. A Ding event is 2 note(s) at semitones 12, 5 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.76, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/input.required instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_input.required_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_input.required_warm-bell.wav", + "duration_s": 1.76 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/input.required instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_input.required_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_input.required_glass-chime.wav", + "duration_s": 1.76 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/input.required instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_input.required_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_input.required_muted-pluck.wav", + "duration_s": 1.76 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/input.required instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_input.required_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_input.required_soft-triangle.wav", + "duration_s": 1.76 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/resource.limit", + "group": "ding", + "name": "resource.limit", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "resource.limit", + "detail": "Ding event \"resource.limit\": Resource is holding. A Ding event is 3 note(s) at semitones 0, 0, 0 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 2.06, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/resource.limit instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_resource.limit_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_resource.limit_warm-bell.wav", + "duration_s": 2.06 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/resource.limit instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_resource.limit_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_resource.limit_glass-chime.wav", + "duration_s": 2.06 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/resource.limit instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_resource.limit_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_resource.limit_muted-pluck.wav", + "duration_s": 2.06 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/resource.limit instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_resource.limit_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_resource.limit_soft-triangle.wav", + "duration_s": 2.06 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/session.end", + "group": "ding", + "name": "session.end", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "session.end", + "detail": "Ding event \"session.end\": Session closure. A Ding event is 2 note(s) at semitones 7, 0 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.74, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/session.end instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_session.end_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.end_warm-bell.wav", + "duration_s": 1.74 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/session.end instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_session.end_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.end_glass-chime.wav", + "duration_s": 1.74 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/session.end instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_session.end_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.end_muted-pluck.wav", + "duration_s": 1.74 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/session.end instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_session.end_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.end_soft-triangle.wav", + "duration_s": 1.74 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/session.start", + "group": "ding", + "name": "session.start", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "session.start", + "detail": "Ding event \"session.start\": Opening welcome. A Ding event is 2 note(s) at semitones 0, 7 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.72, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/session.start instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_session.start_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.start_warm-bell.wav", + "duration_s": 1.72 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/session.start instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_session.start_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.start_glass-chime.wav", + "duration_s": 1.72 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/session.start instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_session.start_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.start_muted-pluck.wav", + "duration_s": 1.72 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/session.start instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_session.start_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_session.start_soft-triangle.wav", + "duration_s": 1.72 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/task.acknowledge", + "group": "ding", + "name": "task.acknowledge", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "task.acknowledge", + "detail": "Ding event \"task.acknowledge\": Quiet ongoing acknowledgement. A Ding event is 1 note(s) at semitones 7 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.5, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/task.acknowledge instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_task.acknowledge_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.acknowledge_warm-bell.wav", + "duration_s": 1.5 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.acknowledge instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_task.acknowledge_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.acknowledge_glass-chime.wav", + "duration_s": 1.5 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.acknowledge instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_task.acknowledge_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.acknowledge_muted-pluck.wav", + "duration_s": 1.5 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.acknowledge instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_task.acknowledge_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.acknowledge_soft-triangle.wav", + "duration_s": 1.5 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/task.complete", + "group": "ding", + "name": "task.complete", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "task.complete", + "detail": "Ding event \"task.complete\": Satisfying closure. A Ding event is 2 note(s) at semitones 7, 12 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.72, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/task.complete instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_task.complete_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.complete_warm-bell.wav", + "duration_s": 1.72 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.complete instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_task.complete_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.complete_glass-chime.wav", + "duration_s": 1.72 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.complete instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_task.complete_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.complete_muted-pluck.wav", + "duration_s": 1.72 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.complete instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_task.complete_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.complete_soft-triangle.wav", + "duration_s": 1.72 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/task.error", + "group": "ding", + "name": "task.error", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "task.error", + "detail": "Ding event \"task.error\": Gentle failure notice. A Ding event is 3 note(s) at semitones 7, 4, 0 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.98, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/task.error instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_task.error_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.error_warm-bell.wav", + "duration_s": 1.98 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.error instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_task.error_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.error_glass-chime.wav", + "duration_s": 1.98 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.error instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_task.error_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.error_muted-pluck.wav", + "duration_s": 1.98 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.error instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_task.error_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.error_soft-triangle.wav", + "duration_s": 1.98 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/task.progress", + "group": "ding", + "name": "task.progress", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "task.progress", + "detail": "Ding event \"task.progress\": Faint ignorable progress. A Ding event is 1 note(s) at semitones -5 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.5, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/task.progress instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_task.progress_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.progress_warm-bell.wav", + "duration_s": 1.5 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.progress instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_task.progress_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.progress_glass-chime.wav", + "duration_s": 1.5 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.progress instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_task.progress_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.progress_muted-pluck.wav", + "duration_s": 1.5 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/task.progress instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_task.progress_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_task.progress_soft-triangle.wav", + "duration_s": 1.5 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "ding/user.spam", + "group": "ding", + "name": "user.spam", + "family": "dings", + "source": "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + "params": [ + { + "name": "instrument", + "kind": "enum", + "values": [ + "glass-chime", + "muted-pluck", + "soft-triangle", + "warm-bell" + ], + "default": "warm-bell", + "note": "no instrument is the shipped default in the catalog; warm-bell is the shelf's choice" + } + ], + "reacts_to": { + "kind": "event", + "event_id": "user.spam", + "detail": "Ding event \"user.spam\": Curt rate warning. A Ding event is 3 note(s) at semitones 9, 9, 9 above 261.6256 Hz. Mapping stream events onto Ding events is not done anywhere." + }, + "behaviour": "decays", + "duration_s": 1.88, + "duration_note": "1.5 s per note plus the last note's delay; command gain 0.6 is an assumption (aqua-feel README)", + "render": { + "command": "node tools/aqua-feel/shelf.mjs render ding/user.spam instrument=warm-bell --out tools/aqua-feel/out/shelf/ding_user.spam_warm-bell.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_user.spam_warm-bell.wav", + "duration_s": 1.88 + } + ] + }, + "check_variants": [ + { + "params": { + "instrument": "glass-chime" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/user.spam instrument=glass-chime --out tools/aqua-feel/out/shelf/ding_user.spam_glass-chime.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_user.spam_glass-chime.wav", + "duration_s": 1.88 + } + ] + }, + { + "params": { + "instrument": "muted-pluck" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/user.spam instrument=muted-pluck --out tools/aqua-feel/out/shelf/ding_user.spam_muted-pluck.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_user.spam_muted-pluck.wav", + "duration_s": 1.88 + } + ] + }, + { + "params": { + "instrument": "soft-triangle" + }, + "command": "node tools/aqua-feel/shelf.mjs render ding/user.spam instrument=soft-triangle --out tools/aqua-feel/out/shelf/ding_user.spam_soft-triangle.wav", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/ding_user.spam_soft-triangle.wav", + "duration_s": 1.88 + } + ] + } + ], + "listening": "unheard" + }, + { + "id": "earcon/warm-bell", + "group": "earcon", + "name": "warm-bell", + "family": "earcon-workshop", + "source": "tools/earcon-workshop/web/earcon.js (plain JS reimplementation; not the Dings .aqua scripts, so it does not sound like the Dings)", + "params": [ + { + "name": "tempo", + "kind": "slider", + "min": 0.6, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "transpose", + "kind": "slider", + "min": -12, + "max": 12, + "step": 1, + "default": 0 + }, + { + "name": "brightness", + "kind": "slider", + "min": -0.25, + "max": 0.25, + "step": 0.01, + "default": 0 + }, + { + "name": "decay", + "kind": "slider", + "min": 0.5, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "level", + "kind": "slider", + "min": 0.1, + "max": 0.9, + "step": 0.01, + "default": 0.7 + } + ], + "reacts_to": { + "kind": "event", + "events": [ + { + "event_id": "success", + "detail": "It worked: rising fifth then octave" + }, + { + "event_id": "fail", + "detail": "It broke: falling minor figure, low landing" + }, + { + "event_id": "warning", + "detail": "Look at this: tritone zigzag, three quick notes" + }, + { + "event_id": "message", + "detail": "Someone spoke: quick two-note lift high in the register" + }, + { + "event_id": "done", + "detail": "Finished: falling resolve onto the root, long tail" + }, + { + "event_id": "waiting", + "detail": "Needs you: quiet, sparse, slow low sway, three soft notes" + } + ], + "detail": "one WAV per event; the caller picks the file for the event it has. Voice: soft fundamental, restrained upper partial" + }, + "behaviour": "decays", + "duration_s": 1.45, + "duration_note": "longest of the six event WAVs at default sliders", + "render": { + "command": "node tools/earcon-workshop/cli.mjs warm-bell tools/aqua-feel/out/shelf/earcon/warm-bell", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/earcon/warm-bell/warm-bell-success.wav", + "duration_s": 0.77 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/warm-bell/warm-bell-fail.wav", + "duration_s": 0.87 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/warm-bell/warm-bell-warning.wav", + "duration_s": 0.77 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/warm-bell/warm-bell-message.wav", + "duration_s": 0.455 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/warm-bell/warm-bell-done.wav", + "duration_s": 1.17 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/warm-bell/warm-bell-waiting.wav", + "duration_s": 1.45 + } + ] + }, + "listening": "unheard" + }, + { + "id": "earcon/glass-chime", + "group": "earcon", + "name": "glass-chime", + "family": "earcon-workshop", + "source": "tools/earcon-workshop/web/earcon.js (plain JS reimplementation; not the Dings .aqua scripts, so it does not sound like the Dings)", + "params": [ + { + "name": "tempo", + "kind": "slider", + "min": 0.6, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "transpose", + "kind": "slider", + "min": -12, + "max": 12, + "step": 1, + "default": 0 + }, + { + "name": "brightness", + "kind": "slider", + "min": -0.25, + "max": 0.25, + "step": 0.01, + "default": 0 + }, + { + "name": "decay", + "kind": "slider", + "min": 0.5, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "level", + "kind": "slider", + "min": 0.1, + "max": 0.9, + "step": 0.01, + "default": 0.7 + } + ], + "reacts_to": { + "kind": "event", + "events": [ + { + "event_id": "success", + "detail": "It worked: rising fifth then octave" + }, + { + "event_id": "fail", + "detail": "It broke: falling minor figure, low landing" + }, + { + "event_id": "warning", + "detail": "Look at this: tritone zigzag, three quick notes" + }, + { + "event_id": "message", + "detail": "Someone spoke: quick two-note lift high in the register" + }, + { + "event_id": "done", + "detail": "Finished: falling resolve onto the root, long tail" + }, + { + "event_id": "waiting", + "detail": "Needs you: quiet, sparse, slow low sway, three soft notes" + } + ], + "detail": "one WAV per event; the caller picks the file for the event it has. Voice: clear and precise" + }, + "behaviour": "decays", + "duration_s": 1.35, + "duration_note": "longest of the six event WAVs at default sliders", + "render": { + "command": "node tools/earcon-workshop/cli.mjs glass-chime tools/aqua-feel/out/shelf/earcon/glass-chime", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/earcon/glass-chime/glass-chime-success.wav", + "duration_s": 0.67 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/glass-chime/glass-chime-fail.wav", + "duration_s": 0.77 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/glass-chime/glass-chime-warning.wav", + "duration_s": 0.67 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/glass-chime/glass-chime-message.wav", + "duration_s": 0.385 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/glass-chime/glass-chime-done.wav", + "duration_s": 1.03 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/glass-chime/glass-chime-waiting.wav", + "duration_s": 1.35 + } + ] + }, + "listening": "unheard" + }, + { + "id": "earcon/soft-triangle", + "group": "earcon", + "name": "soft-triangle", + "family": "earcon-workshop", + "source": "tools/earcon-workshop/web/earcon.js (plain JS reimplementation; not the Dings .aqua scripts, so it does not sound like the Dings)", + "params": [ + { + "name": "tempo", + "kind": "slider", + "min": 0.6, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "transpose", + "kind": "slider", + "min": -12, + "max": 12, + "step": 1, + "default": 0 + }, + { + "name": "brightness", + "kind": "slider", + "min": -0.25, + "max": 0.25, + "step": 0.01, + "default": 0 + }, + { + "name": "decay", + "kind": "slider", + "min": 0.5, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "level", + "kind": "slider", + "min": 0.1, + "max": 0.9, + "step": 0.01, + "default": 0.7 + } + ], + "reacts_to": { + "kind": "event", + "events": [ + { + "event_id": "success", + "detail": "It worked: rising fifth then octave" + }, + { + "event_id": "fail", + "detail": "It broke: falling minor figure, low landing" + }, + { + "event_id": "warning", + "detail": "Look at this: tritone zigzag, three quick notes" + }, + { + "event_id": "message", + "detail": "Someone spoke: quick two-note lift high in the register" + }, + { + "event_id": "done", + "detail": "Finished: falling resolve onto the root, long tail" + }, + { + "event_id": "waiting", + "detail": "Needs you: quiet, sparse, slow low sway, three soft notes" + } + ], + "detail": "one WAV per event; the caller picks the file for the event it has. Voice: rounded, calm" + }, + "behaviour": "decays", + "duration_s": 1.4, + "duration_note": "longest of the six event WAVs at default sliders", + "render": { + "command": "node tools/earcon-workshop/cli.mjs soft-triangle tools/aqua-feel/out/shelf/earcon/soft-triangle", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/earcon/soft-triangle/soft-triangle-success.wav", + "duration_s": 0.72 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/soft-triangle/soft-triangle-fail.wav", + "duration_s": 0.82 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/soft-triangle/soft-triangle-warning.wav", + "duration_s": 0.72 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/soft-triangle/soft-triangle-message.wav", + "duration_s": 0.42 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/soft-triangle/soft-triangle-done.wav", + "duration_s": 1.1 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/soft-triangle/soft-triangle-waiting.wav", + "duration_s": 1.4 + } + ] + }, + "listening": "unheard" + }, + { + "id": "earcon/muted-pluck", + "group": "earcon", + "name": "muted-pluck", + "family": "earcon-workshop", + "source": "tools/earcon-workshop/web/earcon.js (plain JS reimplementation; not the Dings .aqua scripts, so it does not sound like the Dings)", + "params": [ + { + "name": "tempo", + "kind": "slider", + "min": 0.6, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "transpose", + "kind": "slider", + "min": -12, + "max": 12, + "step": 1, + "default": 0 + }, + { + "name": "brightness", + "kind": "slider", + "min": -0.25, + "max": 0.25, + "step": 0.01, + "default": 0 + }, + { + "name": "decay", + "kind": "slider", + "min": 0.5, + "max": 1.6, + "step": 0.01, + "default": 1 + }, + { + "name": "level", + "kind": "slider", + "min": 0.1, + "max": 0.9, + "step": 0.01, + "default": 0.7 + } + ], + "reacts_to": { + "kind": "event", + "events": [ + { + "event_id": "success", + "detail": "It worked: rising fifth then octave" + }, + { + "event_id": "fail", + "detail": "It broke: falling minor figure, low landing" + }, + { + "event_id": "warning", + "detail": "Look at this: tritone zigzag, three quick notes" + }, + { + "event_id": "message", + "detail": "Someone spoke: quick two-note lift high in the register" + }, + { + "event_id": "done", + "detail": "Finished: falling resolve onto the root, long tail" + }, + { + "event_id": "waiting", + "detail": "Needs you: quiet, sparse, slow low sway, three soft notes" + } + ], + "detail": "one WAV per event; the caller picks the file for the event it has. Voice: short, dry" + }, + "behaviour": "decays", + "duration_s": 1.15, + "duration_note": "longest of the six event WAVs at default sliders", + "render": { + "command": "node tools/earcon-workshop/cli.mjs muted-pluck tools/aqua-feel/out/shelf/earcon/muted-pluck", + "outputs": [ + { + "file": "tools/aqua-feel/out/shelf/earcon/muted-pluck/muted-pluck-success.wav", + "duration_s": 0.47 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/muted-pluck/muted-pluck-fail.wav", + "duration_s": 0.57 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/muted-pluck/muted-pluck-warning.wav", + "duration_s": 0.47 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/muted-pluck/muted-pluck-message.wav", + "duration_s": 0.245 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/muted-pluck/muted-pluck-done.wav", + "duration_s": 0.75 + }, + { + "file": "tools/aqua-feel/out/shelf/earcon/muted-pluck/muted-pluck-waiting.wav", + "duration_s": 1.15 + } + ] + }, + "listening": "unheard" + } + ] +} diff --git a/tools/aqua-feel/shelf.mjs b/tools/aqua-feel/shelf.mjs new file mode 100644 index 0000000..45bdea0 --- /dev/null +++ b/tools/aqua-feel/shelf.mjs @@ -0,0 +1,180 @@ +#!/usr/bin/env node +// The effects shelf: every sound AquaSynth can render headless today, as one machine-readable list (shelf.json) and a +// human page (SHELF.md), plus a check that runs each entry's render command and measures what it wrote. +// NOTHING HERE HEARS ANYTHING. `listening` stays "unheard" until a person edits it; the check proves a render is +// finite and not silent, which says nothing about whether it sounds good. +// Usage (from the repo root): +// node tools/aqua-feel/shelf.mjs build regenerate tools/aqua-feel/shelf.json and the table block of SHELF.md +// node tools/aqua-feel/shelf.mjs check [--only S] run every entry's render command, read the WAVs back, fail on silence/NaN/drift +// node tools/aqua-feel/shelf.mjs render ID [k=v ...] --out FILE.wav [--seconds N] render one patch or ding (what the entries call) +import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs"; +import { execSync } from "node:child_process"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { SR, SILENT_PEAK, samplePeak, measure } from "./metrics.js"; +import { loadRuntime, compile, renderOnce, renderDing, writeWav, readText, playground } from "./render.js"; +import { PATCH_SECONDS, DING_COMMAND_GAIN } from "./catalog.js"; +import { EVENTS, IDENTITIES, DEFAULT_PARAMS, PARAM_RANGES, renderFamily, fileName } from "../earcon-workshop/web/earcon.js"; + +const here = dirname(fileURLToPath(import.meta.url)), root = resolve(here, "../.."); +const SHELF_JSON = join(here, "shelf.json"), SHELF_MD = join(here, "SHELF.md"); +const OUT = "tools/aqua-feel/out/shelf"; // relative to the repo root, gitignored +const BEGIN = "", END = ""; +const dingsDir = join(here, "lowered-dings"); +const r3 = (x) => Math.round(x * 1000) / 1000; + +const args = process.argv.slice(2), cmd = args.shift(); +const flag = (n) => { const i = args.indexOf(n); if (i < 0) return undefined; return args.splice(i, 2)[1]; }; + +function controlsOf(entry) { // Faust UI -> shelf params; the ranges are the DSP's own declarations + const out = []; + const walk = (items) => { for (const it of items ?? []) { + if (it.items) walk(it.items); + else if (it.address) { + const name = it.label.replace(/^\//, ""); + if (/slider|nentry/i.test(it.type)) out.push({ name, kind: "slider", min: Number(it.min), max: Number(it.max), default: Number(it.init), step: Number(it.step) }); + else out.push({ name, kind: it.type }); // button / checkbox: reported as declared, not interpreted + } } }; + walk(JSON.parse(entry.g.factory.json).ui); + return out; +} + +async function build() { + const rt = await loadRuntime(), entries = []; + const dir = join(playground, "lowered"), cat = JSON.parse(readText(join(dir, "catalog.json"))); + for (const e of cat) { + const entry = await compile(rt, e.name, readText(join(dir, e.dsp))); + const params = controlsOf(entry), r = await renderOnce(entry, {}, PATCH_SECONDS), x = r.samples, tail = x.slice(x.length - Math.round(SR * 0.2)); + const m = measure(x), sustained = samplePeak(tail) >= 0.1 * samplePeak(x); + const isThruster = e.name === "thruster"; + entries.push({ + id: `patch/${e.name}`, group: isThruster ? "thruster" : "patch", name: e.name, family: e.name.split("-")[0], + source: e.kind === "faust" ? `tools/aqua-playground/lowered/${e.dsp}` : `tools/aqua-playground/lowered/${e.dsp} (lowered from patches/${e.origin})`, + params, + reacts_to: isThruster + ? { kind: "control", detail: "the rpm slider (300..6000, smoothed over 0.2 s): drive it from whatever number should make the thruster work harder. Nothing in the repo maps a stream metric to rpm." } + : { kind: "start", detail: "plays from the moment it is started; no gate, trigger or audio-feature input. Sliders, where listed, are live while it plays." }, + behaviour: sustained ? "sustained: still sounding at the end of the render window, runs until stopped" : "decays: dies away inside the render window", + duration_s: PATCH_SECONDS, duration_note: "the render window, not the effect's length", + render: { command: `node tools/aqua-feel/shelf.mjs render patch/${e.name} --out ${OUT}/patch_${e.name}.wav`, outputs: [{ file: `${OUT}/patch_${e.name}.wav`, duration_s: PATCH_SECONDS }] }, + ...(isThruster ? { check_variants: [300, 6000].map((rpm) => ({ params: { rpm }, command: `node tools/aqua-feel/shelf.mjs render patch/${e.name} rpm=${rpm} --out ${OUT}/patch_${e.name}_rpm${rpm}.wav`, outputs: [{ file: `${OUT}/patch_${e.name}_rpm${rpm}.wav`, duration_s: PATCH_SECONDS }] })) } : {}), + listening: "unheard", + }); + } + const d = JSON.parse(readText(join(dingsDir, "dings.json"))), instruments = d.instruments.map((i) => i.id), DEF_INS = "warm-bell"; + for (const ev of d.events) { + const dur = r3(d.noteSeconds + Math.max(...ev.notes.map((n) => n.delayMilliseconds)) / 1000); + const one = (ins) => ({ command: `node tools/aqua-feel/shelf.mjs render ding/${ev.id} instrument=${ins} --out ${OUT}/ding_${ev.id}_${ins}.wav`, outputs: [{ file: `${OUT}/ding_${ev.id}_${ins}.wav`, duration_s: dur }] }); + entries.push({ + id: `ding/${ev.id}`, group: "ding", name: ev.id, family: "dings", + source: "tools/aqua-feel/lowered-dings (lowered from src DingCatalog)", + params: [{ name: "instrument", kind: "enum", values: instruments, default: DEF_INS, note: `no instrument is the shipped default in the catalog; ${DEF_INS} is the shelf's choice` }], + reacts_to: { kind: "event", event_id: ev.id, detail: `Ding event "${ev.id}": ${ev.meaning}. A Ding event is ${ev.notes.length} note(s) at semitones ${ev.notes.map((n) => n.semitones).join(", ")} above ${d.instruments[0].rootFrequency} Hz. Mapping stream events onto Ding events is not done anywhere.` }, + behaviour: "decays", + duration_s: dur, duration_note: `${d.noteSeconds} s per note plus the last note's delay; command gain ${DING_COMMAND_GAIN} is an assumption (aqua-feel README)`, + render: one(DEF_INS), + check_variants: instruments.filter((i) => i !== DEF_INS).map((i) => ({ params: { instrument: i }, ...one(i) })), + listening: "unheard", + }); + } + for (const [id, ident] of Object.entries(IDENTITIES)) { + const fam = renderFamily(id), outDir = `${OUT}/earcon/${id}`; + entries.push({ + id: `earcon/${id}`, group: "earcon", name: id, family: "earcon-workshop", + source: "tools/earcon-workshop/web/earcon.js (plain JS reimplementation; not the Dings .aqua scripts, so it does not sound like the Dings)", + params: Object.entries(PARAM_RANGES).map(([name, [min, max, step]]) => ({ name, kind: "slider", min, max, step, default: DEFAULT_PARAMS[name] })), + reacts_to: { kind: "event", events: Object.entries(EVENTS).map(([k, v]) => ({ event_id: k, detail: v.meaning })), detail: "one WAV per event; the caller picks the file for the event it has. Voice: " + ident.note }, + behaviour: "decays", + duration_s: r3(Math.max(...fam.items.map((i) => i.durationMs)) / 1000), duration_note: "longest of the six event WAVs at default sliders", + render: { command: `node tools/earcon-workshop/cli.mjs ${id} ${outDir}`, outputs: fam.items.map((i) => ({ file: `${outDir}/${fileName(id, i.event)}`, duration_s: r3(i.durationMs / 1000) })) }, + listening: "unheard", + }); + } + return { schema: "aquasynth.effects-shelf.v0", note: "Generated by tools/aqua-feel/shelf.mjs build. Nothing here was heard: every entry's listening status is 'unheard'. Commands run from the repo root.", sampleRate: SR, entries }; +} + +function tableBlock(shelf) { + const rng = (p) => p.kind === "slider" ? `${p.name} ${p.min}..${p.max} (default ${p.default})` : p.kind === "enum" ? `${p.name} ∈ {${p.values.join(", ")}} (default ${p.default})` : `${p.name} (${p.kind})`; + const L = [BEGIN, ""]; + for (const [title, pick] of [["Thruster", (e) => e.group === "thruster"], ["Dings (event sounds)", (e) => e.group === "ding"], ["Earcon workshop (one WAV per event)", (e) => e.group === "earcon"], ["Playground patches (one-shot and sustained synth sounds)", (e) => e.group === "patch"]]) { + const es = shelf.entries.filter(pick); + L.push(`### ${title} (${es.length})`, "", "| id | reacts to | params | behaviour | duration | listening |", "|---|---|---|---|---|---|"); + for (const e of es) { + const re = e.reacts_to.kind === "event" && e.reacts_to.events ? `events: ${e.reacts_to.events.map((v) => v.event_id).join(", ")}` : e.reacts_to.kind === "event" ? `event \`${e.reacts_to.event_id}\`` : e.reacts_to.kind === "control" ? "control: rpm" : "start"; + L.push(`| \`${e.id}\` | ${re} | ${e.params.map(rng).join("; ") || "none"} | ${e.behaviour.split(":")[0]} | ${e.duration_s} s | ${e.listening} |`); + } + L.push(""); + } + L.push(END); + return L.join("\n"); +} + +function writeShelf(shelf) { + writeFileSync(SHELF_JSON, JSON.stringify(shelf, null, 1) + "\n"); + const md = readFileSync(SHELF_MD, "utf8"), a = md.indexOf(BEGIN), b = md.indexOf(END); + if (a < 0 || b < 0) throw new Error("SHELF.md has no generated block markers"); + writeFileSync(SHELF_MD, md.slice(0, a) + tableBlock(shelf) + md.slice(b + END.length)); +} + +// ---- render: what the entries' commands call ------------------------------------------------------------------------ +async function render() { + const out = flag("--out"), seconds = flag("--seconds"), [id, ...kv] = args; + if (!id || !out) { console.error("usage: shelf.mjs render ID [k=v ...] --out FILE.wav [--seconds N]"); process.exit(2); } + const params = Object.fromEntries(kv.map((s) => s.split("=")).map(([k, v]) => [k, isNaN(Number(v)) ? v : Number(v)])); + const rt = await loadRuntime(); let samples; + if (id.startsWith("patch/")) { + const name = id.slice(6), dir = join(playground, "lowered"), e = JSON.parse(readText(join(dir, "catalog.json"))).find((x) => x.name === name); + if (!e) { console.error(`no patch ${name}`); process.exit(2); } + samples = (await renderOnce(await compile(rt, name, readText(join(dir, e.dsp))), params, seconds ? Number(seconds) : PATCH_SECONDS)).samples; + } else if (id.startsWith("ding/")) { + const d = JSON.parse(readText(join(dingsDir, "dings.json"))), ev = d.events.find((x) => x.id === id.slice(5)), ins = d.instruments.find((x) => x.id === (params.instrument ?? "warm-bell")); + if (!ev || !ins) { console.error(`no ding event ${id.slice(5)} / instrument ${params.instrument}`); process.exit(2); } + samples = (await renderDing(rt, ins, readText(join(dingsDir, ins.dsp)), ev, { noteSeconds: d.noteSeconds, commandGain: DING_COMMAND_GAIN })).samples; + } else { console.error("render handles patch/ and ding/ ids; earcon entries use tools/earcon-workshop/cli.mjs"); process.exit(2); } + writeWav(resolve(out), samples); + console.log(`wrote ${out} (${(samples.length / SR).toFixed(3)} s)`); +} + +// ---- check ----------------------------------------------------------------------------------------------------------- +function readWav(path) { // PCM16 or float32 mono, as this repo's two writers produce + const b = readFileSync(path), v = new DataView(b.buffer, b.byteOffset, b.byteLength); + if (b.toString("latin1", 0, 4) !== "RIFF" || b.toString("latin1", 8, 12) !== "WAVE") throw new Error("not a RIFF/WAVE file"); + const tag = v.getUint16(20, true), ch = v.getUint16(22, true), sr = v.getUint32(24, true), bits = v.getUint16(34, true), n = v.getUint32(40, true) / (bits / 8); + if (ch !== 1 || !((tag === 1 && bits === 16) || (tag === 3 && bits === 32))) throw new Error(`unsupported wav tag ${tag} bits ${bits} channels ${ch}`); + const x = new Float32Array(n); + for (let i = 0; i < n; i++) x[i] = tag === 3 ? v.getFloat32(44 + i * 4, true) : v.getInt16(44 + i * 2, true) / 32768; + return { sr, x }; +} + +async function check() { + const only = flag("--only"), problems = [], rows = []; + mkdirSync(join(root, OUT), { recursive: true }); + const fresh = await build(), onDisk = existsSync(SHELF_JSON) ? readFileSync(SHELF_JSON, "utf8") : ""; + if (onDisk !== JSON.stringify(fresh, null, 1) + "\n") problems.push("shelf.json is stale: run `node tools/aqua-feel/shelf.mjs build`"); + const md = readFileSync(SHELF_MD, "utf8"), a = md.indexOf(BEGIN), b = md.indexOf(END); + if (a < 0 || md.slice(a, b + END.length) !== tableBlock(fresh)) problems.push("SHELF.md table block is stale: run `node tools/aqua-feel/shelf.mjs build`"); + for (const e of fresh.entries.filter((x) => !only || x.id.includes(only))) { + if (e.listening !== "unheard") problems.push(`${e.id}: listening is '${e.listening}'; this check cannot confirm that`); + for (const r of [e.render, ...(e.check_variants ?? [])]) { + try { + execSync(r.command, { cwd: root, stdio: ["ignore", "pipe", "pipe"] }); + for (const o of r.outputs) { + const { sr, x } = readWav(join(root, o.file)), peak = samplePeak(x), dur = x.length / sr; + if (sr !== SR) throw new Error(`${o.file}: sample rate ${sr}`); + if (!x.every(Number.isFinite)) throw new Error(`${o.file}: non-finite samples`); + if (peak < SILENT_PEAK) throw new Error(`${o.file}: silent (peak ${peak}, floor ${SILENT_PEAK.toFixed(6)})`); + if (Math.abs(dur - o.duration_s) > 0.01) throw new Error(`${o.file}: ${dur.toFixed(3)} s, shelf says ${o.duration_s} s`); + rows.push(`ok ${o.file.replace(OUT + "/", "")} peak ${(20 * Math.log10(peak)).toFixed(1)} dBFS ${dur.toFixed(3)} s [${r.command}]`); + } + } catch (err) { problems.push(`${e.id}: ${r.command}\n ${String(err.message ?? err).split("\n")[0]}`); } + } + } + console.log(rows.join("\n")); + console.log(`\n${rows.length} rendered file(s) checked across ${fresh.entries.filter((x) => !only || x.id.includes(only)).length} entries. Nothing here was heard.`); + if (problems.length) { console.log(`\nFAIL (${problems.length}):\n` + problems.map((p) => " " + p).join("\n")); process.exit(1); } + console.log("PASS: every render command ran, every WAV is finite, not silent, and as long as the shelf says; shelf.json and SHELF.md are current."); +} + +const cmds = { build: async () => { const s = await build(); writeShelf(s); console.log(`wrote ${SHELF_JSON}: ${s.entries.length} entries`); }, render, check }; +if (!cmds[cmd]) { console.error(readFileSync(fileURLToPath(import.meta.url), "utf8").split("\n").slice(1, 9).join("\n")); process.exit(2); } +await cmds[cmd](); From 396da106cdf1b7d913c73520c45661343fe66bae Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 18:29:25 +0000 Subject: [PATCH 019/124] One StoreFileName in Core: no id collisions, no '..' escape The daemon and native-runtime SafeFileName copies sanitised differently: the daemon mapped a/b, a b, a:b and a-b to the same name (a later patch overwrote an earlier artifact) and returned ".." unchanged, so a sessionId or runId of ".." resolved one directory above the store. Replace both with AquaSynth.Dsl.StoreFileName.From. Ids within [A-Za-z0-9._-] pass through; any other id is sanitised and suffixed with the first 8 hex of SHA-256 of the original. Empty, "." and all-dot ids are refused (ArgumentException). Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/StoreFileName.cs | 38 +++++++++++ src/AquaSynth.Faust/AquaSynthDaemonService.cs | 25 ++----- src/AquaSynth.Faust/NativeFaustRuntime.cs | 10 +-- .../AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 68 +++++++++++++++++++ 4 files changed, 114 insertions(+), 27 deletions(-) create mode 100644 src/AquaSynth.Core/StoreFileName.cs create mode 100644 tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs diff --git a/src/AquaSynth.Core/StoreFileName.cs b/src/AquaSynth.Core/StoreFileName.cs new file mode 100644 index 0000000..c18bda1 --- /dev/null +++ b/src/AquaSynth.Core/StoreFileName.cs @@ -0,0 +1,38 @@ +using System.Security.Cryptography; +using System.Text; + +namespace AquaSynth.Dsl; + +/// +/// The one mapping from a caller-chosen id to a single file-name component in a store. +/// Ids already within [A-Za-z0-9._-] pass through unchanged. Anything else is sanitised and +/// suffixed with the first 8 hex of SHA-256 of the original id, so distinct ids stay distinct. +/// The result is never a path: no separators, never "." or "..". +/// +public static class StoreFileName +{ + public static string From(string id) + { + ArgumentNullException.ThrowIfNull(id); + if (id.Length == 0 || id.All(c => c == '.')) + { + throw new ArgumentException($"Id '{id}' cannot name a store file.", nameof(id)); + } + + var builder = new StringBuilder(id.Length); + foreach (var c in id) + { + builder.Append(c is >= 'a' and <= 'z' or >= 'A' and <= 'Z' or >= '0' and <= '9' or '-' or '_' or '.' ? c : '_'); + } + + var safe = builder.ToString(); + // A trailing dot is dropped by Windows, so "a." would alias "a"; hash it like any other rewrite. + if (safe == id && !id.EndsWith('.')) + { + return safe; + } + + var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(id)))[..8].ToLowerInvariant(); + return $"{safe}-{hash}"; + } +} diff --git a/src/AquaSynth.Faust/AquaSynthDaemonService.cs b/src/AquaSynth.Faust/AquaSynthDaemonService.cs index 28ae62d..74f6830 100644 --- a/src/AquaSynth.Faust/AquaSynthDaemonService.cs +++ b/src/AquaSynth.Faust/AquaSynthDaemonService.cs @@ -556,9 +556,9 @@ public sealed class AquaSynthDaemonService : IDisposable session.Stream.ProcessBlock([], outputs, command.FrameCount, session.Controls); var mono = MixMono(outputs, command.FrameCount, command.Gain * session.Gain); var blockId = BlockId(command.CommandId); - var blockDir = Path.Combine(options.StoreRoot, "live", SafeFileName(command.SessionId)); + var blockDir = Path.Combine(options.StoreRoot, "live", StoreFileName.From(command.SessionId)); Directory.CreateDirectory(blockDir); - var floatPath = Path.Combine(blockDir, $"{SafeFileName(blockId)}.f32"); + var floatPath = Path.Combine(blockDir, $"{StoreFileName.From(blockId)}.f32"); await WriteFloat32Async(floatPath, mono).ConfigureAwait(false); var sequence = session.NextSequence(); @@ -703,8 +703,8 @@ public sealed class AquaSynthDaemonService : IDisposable var runId = $"{command.CommandId}-stream"; var verseId = "aquasynth.instrument"; - var audioStreamId = $"aquasynth.audio.{SafeFileName(command.CommandId)}"; - var controlStreamId = $"aquasynth.controls.{SafeFileName(command.CommandId)}"; + var audioStreamId = $"aquasynth.audio.{StoreFileName.From(command.CommandId)}"; + var controlStreamId = $"aquasynth.controls.{StoreFileName.From(command.CommandId)}"; if (!string.Equals(compile.Status, "succeeded", StringComparison.Ordinal)) { @@ -741,7 +741,7 @@ public sealed class AquaSynthDaemonService : IDisposable .GroupBy(frame => frame.Block) .ToDictionary(group => group.Key, group => NormalizeControls(group.Last().Controls), EqualityComparer.Default); - var streamDir = Path.Combine(options.StoreRoot, "streams", SafeFileName(runId)); + var streamDir = Path.Combine(options.StoreRoot, "streams", StoreFileName.From(runId)); Directory.CreateDirectory(streamDir); var packets = new List(); using (var stream = patch.CreateStreamingPatch()) @@ -918,7 +918,7 @@ public sealed class AquaSynthDaemonService : IDisposable private async Task WriteReceiptAsync(string family, string id, T document, bool global = false) where T : class { - var filePath = Path.Combine(options.StoreRoot, family, $"{SafeFileName(id)}.cc"); + var filePath = Path.Combine(options.StoreRoot, family, $"{StoreFileName.From(id)}.cc"); Directory.CreateDirectory(Path.GetDirectoryName(filePath)!); // Opening hydrates; a receipt file holds exactly one document, so everything else goes before the write. using var cache = CultCacheMessagePack.Create(filePath); @@ -1129,18 +1129,7 @@ public sealed class AquaSynthDaemonService : IDisposable private static string BlockId(string commandId) => $"{commandId}-block"; - private static string SessionId(string patchId, string compileKey) => $"{SafeFileName(patchId)}-{compileKey[..Math.Min(12, compileKey.Length)]}"; - - private static string SafeFileName(string value) - { - var builder = new StringBuilder(value.Length); - foreach (var c in value) - { - builder.Append(char.IsLetterOrDigit(c) || c is '-' or '_' or '.' ? c : '-'); - } - - return builder.ToString().Trim('-'); - } + private static string SessionId(string patchId, string compileKey) => $"{StoreFileName.From(patchId)}-{compileKey[..Math.Min(12, compileKey.Length)]}"; private static string ToArtifactUri(string path) => $"file:///{Path.GetFullPath(path).Replace('\\', '/')}"; diff --git a/src/AquaSynth.Faust/NativeFaustRuntime.cs b/src/AquaSynth.Faust/NativeFaustRuntime.cs index e6b44c4..99bc288 100644 --- a/src/AquaSynth.Faust/NativeFaustRuntime.cs +++ b/src/AquaSynth.Faust/NativeFaustRuntime.cs @@ -633,18 +633,10 @@ public sealed class AquaSynthNativeCompiler : IDisposable } Directory.CreateDirectory(outputRoot); - var path = Path.Combine(outputRoot, $"{SafeFileName(patchId)}.dsp"); + var path = Path.Combine(outputRoot, $"{StoreFileName.From(patchId)}.dsp"); File.WriteAllText(path, source); return path; } - - private static string SafeFileName(string value) - { - var invalid = Path.GetInvalidFileNameChars().ToHashSet(); - var chars = value.Select(ch => invalid.Contains(ch) ? '_' : ch).ToArray(); - var name = new string(chars).Trim(); - return string.IsNullOrWhiteSpace(name) ? "aquasynth_patch" : name; - } } public static class AquaSynthFaustToolchain diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs new file mode 100644 index 0000000..24ad104 --- /dev/null +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -0,0 +1,68 @@ +using AquaSynth.Faust; + +namespace AquaSynth.Dsl.Tests; + +public sealed class StoreFileNameTests +{ + [Fact] + public void DistinctIdsGetDistinctNames() + { + var ids = new[] { "a/b", "a b", "a:b", "a-b", "a_b", "a\\b", "a?b" }; + var names = ids.Select(StoreFileName.From).ToArray(); + Assert.Equal(ids.Length, names.Distinct(StringComparer.OrdinalIgnoreCase).Count()); + } + + [Theory] + [InlineData("dings.warm-bell")] + [InlineData("demo-stream-block")] + [InlineData("A_b.c-1")] + public void CleanIdsPassThroughUnchanged(string id) => Assert.Equal(id, StoreFileName.From(id)); + + [Fact] + public void RewrittenIdsCarryHashOfTheOriginal() + { + // sha256("a b") begins c2a5..., checked independently of the implementation. + var expected = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData("a b"u8.ToArray()))[..8].ToLowerInvariant(); + Assert.Equal($"a_b-{expected}", StoreFileName.From("a b")); + } + + [Theory] + [InlineData(".")] + [InlineData("..")] + [InlineData("")] + public void DotsAndEmptyAreRefused(string id) => Assert.Throws(() => StoreFileName.From(id)); + + [Theory] + [InlineData("../..")] + [InlineData("../../etc/passwd")] + [InlineData("..\\..\\x")] + [InlineData("/abs/path")] + [InlineData("C:\\abs")] + [InlineData("a.")] + [InlineData("a/..")] + public void NoIdCanMakePathCombineEscapeTheRoot(string id) + { + var root = Path.Combine(Path.GetTempPath(), "store-root-probe", "store"); + var name = StoreFileName.From(id); + Assert.Equal(name, Path.GetFileName(name)); + Assert.NotEqual(".", name); + Assert.NotEqual("..", name); + var full = Path.GetFullPath(Path.Combine(root, name)); + Assert.Equal(Path.GetFullPath(root), Path.GetDirectoryName(full)); + } + + [Fact] + public async Task DaemonReceiptForTraversalCommandIdStaysInsideStore() + { + var parent = Path.Combine(Path.GetTempPath(), "aquasynth-sfn-" + Guid.NewGuid().ToString("N")); + var storeRoot = Path.Combine(parent, "store"); + using var service = new AquaSynthDaemonService(new AquaSynthDaemonOptions(storeRoot)); + + await service.SampleAsync(new AquaSynthInstrumentSampleCommand( + "../../escape", "test.invalid", "test_invalid", "this is not aqua syntax", DurationSeconds: 0.1f)); + + Assert.Empty(Directory.GetFiles(parent)); + Assert.Empty(Directory.GetDirectories(parent).Where(d => Path.GetFileName(d) != "store")); + Assert.NotEmpty(Directory.GetFiles(Path.Combine(storeRoot, "compile"))); + } +} From abfc816804575cc2bbeb77ccf843e568b6e21635 Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 20:00:30 +0000 Subject: [PATCH 020/124] StoreFileName: close review findings (collisions, case, device stems, length, renderId) - Pass-through ids may not end in "-<16 hex>", so a rewritten name fed back as an id cannot alias it; hash widened 32 -> 64 bits. - Ids with uppercase are rewritten (case-insensitive filesystems). - Windows device stems (CON PRN AUX NUL COM0-9 LPT0-9, any extension) are rewritten. - Stem capped at 100 chars; longer ids carry the hash. - Daemon samples/ write now goes through StoreFileName.From(renderId). - Tests: rewritten-as-id, case-only, device stems, overlong; daemon test uses a compiling patch so the samples/ write is reached when Faust is present. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/StoreFileName.cs | 59 +++++++++++++++--- src/AquaSynth.Faust/AquaSynthDaemonService.cs | 5 +- .../AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 61 +++++++++++++++++-- 3 files changed, 109 insertions(+), 16 deletions(-) diff --git a/src/AquaSynth.Core/StoreFileName.cs b/src/AquaSynth.Core/StoreFileName.cs index c18bda1..de3d7cf 100644 --- a/src/AquaSynth.Core/StoreFileName.cs +++ b/src/AquaSynth.Core/StoreFileName.cs @@ -5,12 +5,19 @@ namespace AquaSynth.Dsl; /// /// The one mapping from a caller-chosen id to a single file-name component in a store. -/// Ids already within [A-Za-z0-9._-] pass through unchanged. Anything else is sanitised and -/// suffixed with the first 8 hex of SHA-256 of the original id, so distinct ids stay distinct. -/// The result is never a path: no separators, never "." or "..". +/// An id passes through unchanged only if it is already a fixed point: ASCII [A-Za-z0-9._-], +/// all lowercase (stores live on case-insensitive filesystems), at most long, +/// no trailing dot, not a Windows device stem (CON, NUL, COM1, ...), and not ending in a +/// "-" plus 16 hex digits. Every other id is sanitised and suffixed with "-" plus the first +/// 16 hex of SHA-256 of the original id. Passed-through names never end in the hash shape and +/// rewritten names always do, so the two sets cannot meet; distinct ids stay distinct up to a 64-bit +/// hash. The result is never a path: no separators, never "." or "..". /// public static class StoreFileName { + private const int MaxStem = 100; + private const int HashLength = 16; + public static string From(string id) { ArgumentNullException.ThrowIfNull(id); @@ -19,20 +26,56 @@ public static class StoreFileName throw new ArgumentException($"Id '{id}' cannot name a store file.", nameof(id)); } - var builder = new StringBuilder(id.Length); - foreach (var c in id) + var builder = new StringBuilder(Math.Min(id.Length, MaxStem)); + foreach (var c in id.Take(MaxStem)) { builder.Append(c is >= 'a' and <= 'z' or >= 'A' and <= 'Z' or >= '0' and <= '9' or '-' or '_' or '.' ? c : '_'); } var safe = builder.ToString(); - // A trailing dot is dropped by Windows, so "a." would alias "a"; hash it like any other rewrite. - if (safe == id && !id.EndsWith('.')) + if (IsFixedPoint(id, safe)) { return safe; } - var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(id)))[..8].ToLowerInvariant(); + var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(id)))[..HashLength].ToLowerInvariant(); return $"{safe}-{hash}"; } + + private static bool IsFixedPoint(string id, string safe) + { + if (safe != id || id.EndsWith('.') || id.Any(char.IsAsciiLetterUpper) || IsDeviceStem(id) || EndsWithHashShape(id)) + { + return false; + } + + return true; + } + + // Windows resolves CON, PRN, AUX, NUL, COM0-9, LPT0-9 as devices whatever the extension. + private static bool IsDeviceStem(string id) + { + var dot = id.IndexOf('.'); + var stem = (dot < 0 ? id : id[..dot]).TrimEnd(' '); + return stem.Length switch + { + 3 => stem.Equals("con", StringComparison.OrdinalIgnoreCase) + || stem.Equals("prn", StringComparison.OrdinalIgnoreCase) + || stem.Equals("aux", StringComparison.OrdinalIgnoreCase) + || stem.Equals("nul", StringComparison.OrdinalIgnoreCase), + 4 => char.IsAsciiDigit(stem[3]) + && (stem.StartsWith("com", StringComparison.OrdinalIgnoreCase) || stem.StartsWith("lpt", StringComparison.OrdinalIgnoreCase)), + _ => false, + }; + } + + private static bool EndsWithHashShape(string id) + { + if (id.Length <= HashLength || id[^(HashLength + 1)] != '-') + { + return false; + } + + return id[^HashLength..].All(c => c is >= '0' and <= '9' or >= 'a' and <= 'f'); + } } diff --git a/src/AquaSynth.Faust/AquaSynthDaemonService.cs b/src/AquaSynth.Faust/AquaSynthDaemonService.cs index 74f6830..0021895 100644 --- a/src/AquaSynth.Faust/AquaSynthDaemonService.cs +++ b/src/AquaSynth.Faust/AquaSynthDaemonService.cs @@ -661,8 +661,9 @@ public sealed class AquaSynthDaemonService : IDisposable var renderId = RenderId(command.CommandId); var sampleDir = Path.Combine(options.StoreRoot, "samples"); Directory.CreateDirectory(sampleDir); - var floatPath = Path.Combine(sampleDir, $"{renderId}.f32"); - var wavPath = Path.Combine(sampleDir, $"{renderId}.wav"); + var sampleStem = StoreFileName.From(renderId); + var floatPath = Path.Combine(sampleDir, $"{sampleStem}.f32"); + var wavPath = Path.Combine(sampleDir, $"{sampleStem}.wav"); await WriteFloat32Async(floatPath, samples).ConfigureAwait(false); await WriteWavAsync(wavPath, samples, patch.Manifest.SampleRate).ConfigureAwait(false); diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index 24ad104..d8012ae 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -15,14 +15,55 @@ public sealed class StoreFileNameTests [Theory] [InlineData("dings.warm-bell")] [InlineData("demo-stream-block")] - [InlineData("A_b.c-1")] + [InlineData("a_b.c-1")] + [InlineData("conx")] + [InlineData("com10")] public void CleanIdsPassThroughUnchanged(string id) => Assert.Equal(id, StoreFileName.From(id)); + [Fact] + public void RewrittenIdOutputAsAnIdDoesNotCollideWithTheOriginal() + { + var rewritten = StoreFileName.From("a b"); + Assert.NotEqual(rewritten, StoreFileName.From(rewritten)); + Assert.NotEqual(StoreFileName.From("a_b"), rewritten); + } + + [Fact] + public void IdsDifferingOnlyByCaseGetDistinctNames() + { + var names = new[] { "A", "a", "Ab", "aB", "ab" }.Select(StoreFileName.From).ToArray(); + Assert.Equal(names.Length, names.Distinct(StringComparer.OrdinalIgnoreCase).Count()); + } + + [Theory] + [InlineData("CON")] + [InlineData("nul")] + [InlineData("Aux.txt")] + [InlineData("com1")] + [InlineData("COM9.f32")] + [InlineData("lpt0")] + [InlineData("prn.cc")] + public void WindowsDeviceStemsAreRewritten(string id) + { + var name = StoreFileName.From(id); + Assert.NotEqual(id.ToLowerInvariant(), name.ToLowerInvariant()); + Assert.Matches("-[0-9a-f]{16}$", name); + } + + [Fact] + public void OverlongIdsAreBoundedAndStayDistinct() + { + var a = StoreFileName.From(new string('x', 400)); + var b = StoreFileName.From(new string('x', 399) + "y"); + Assert.True(a.Length + ".cc".Length <= 255); + Assert.NotEqual(a, b); + } + [Fact] public void RewrittenIdsCarryHashOfTheOriginal() { // sha256("a b") begins c2a5..., checked independently of the implementation. - var expected = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData("a b"u8.ToArray()))[..8].ToLowerInvariant(); + var expected = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData("a b"u8.ToArray()))[..16].ToLowerInvariant(); Assert.Equal($"a_b-{expected}", StoreFileName.From("a b")); } @@ -52,17 +93,25 @@ public sealed class StoreFileNameTests } [Fact] - public async Task DaemonReceiptForTraversalCommandIdStaysInsideStore() + public async Task DaemonSampleFilesForTraversalCommandIdStayInsideStore() { var parent = Path.Combine(Path.GetTempPath(), "aquasynth-sfn-" + Guid.NewGuid().ToString("N")); var storeRoot = Path.Combine(parent, "store"); using var service = new AquaSynthDaemonService(new AquaSynthDaemonOptions(storeRoot)); - await service.SampleAsync(new AquaSynthInstrumentSampleCommand( - "../../escape", "test.invalid", "test_invalid", "this is not aqua syntax", DurationSeconds: 0.1f)); + // A patch that compiles reaches the samples/ write; without native Faust only the compile-failed branch runs. + var result = await service.SampleAsync(new AquaSynthInstrumentSampleCommand( + "../../escape", "test.sine", "test_sine", + "voice wave=sine freq=440 gain=.2 attack=.001 sustain=.05 decay=.05", DurationSeconds: 0.1f)); Assert.Empty(Directory.GetFiles(parent)); Assert.Empty(Directory.GetDirectories(parent).Where(d => Path.GetFileName(d) != "store")); - Assert.NotEmpty(Directory.GetFiles(Path.Combine(storeRoot, "compile"))); + if (string.Equals(result.RenderReceipt.Status, "succeeded", StringComparison.Ordinal)) + { + Assert.Equal(storeRoot, Path.GetDirectoryName(Path.GetDirectoryName(UriPath(result.RenderReceipt.Float32Uri)))); + Assert.Equal(storeRoot, Path.GetDirectoryName(Path.GetDirectoryName(UriPath(result.RenderReceipt.WavUri)))); + } } + + private static string UriPath(string uri) => new Uri(uri).LocalPath; } From 448e3b04b08c618f281d0fd305e30b508677027c Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 22:17:59 +0000 Subject: [PATCH 021/124] docs: scope Faust DSP delivery to a Unity player (Windows/Linux) Co-Authored-By: Claude Sonnet 5.5 --- docs/faust-unity-player-scoping.md | 299 +++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 docs/faust-unity-player-scoping.md diff --git a/docs/faust-unity-player-scoping.md b/docs/faust-unity-player-scoping.md new file mode 100644 index 0000000..7299774 --- /dev/null +++ b/docs/faust-unity-player-scoping.md @@ -0,0 +1,299 @@ +# Faust DSP in a built Unity player (Windows + Linux): scoping + +Scoping only. No code changed. Follow-up `aqua-body:follow_up:chat-s3500-3500`, 2026-11-06. + +Question: how does Faust DSP (the thruster, `patches/thruster/thruster.dsp`, v5) reach a +built Unity player on Windows and Linux? (a) ahead-of-time (AOT) Faust to C++ per patch +inside a native plugin, or (b) runtime `libfaust`/LLVM inside the player. + +Marks: **[V]** verified here by reading source or running a tool on 2026-11-06. +**[U]** unverified: from memory, or needs a Unity editor/player or a Windows host this run +did not have. Nothing here has been run inside Unity. + +## Recommendation + +Take (a) for shipped patches such as the thruster. Keep (b) as a developer-time lane only, if +at all. Confidence: about 80% on the choice, lower on the details marked [U]. + +- (a) fits the thruster: a fixed graph with ordinary controls, which + `docs/faust-toolchain-boundary.md` ("Parameter changes are not recompiles"; "Shipping + builds should prefer Faust-generated native targets") already says is the shipping shape. +- (b) buys live recompilation of `.aqua` text in the player. Nothing asks for that yet. It + costs a ~130 MB LLVM dependency [V: `libLLVM.so.19.1` is 129,673,080 bytes on this host], + the Faust library tree at runtime, and a JIT in the player. +- Faust already ships a Unity target that is path (a) with the bridge written + (`architecture/unity/`, `faust2unity`, section "What Faust ships"). Start from it and do + not hand-roll a plugin. + +## What Faust ships for Unity [V] + +Checked in the 2.90.20 source tree this host built (`faust-llvm-build-20261031/src/architecture/unity/`). + +| File | Role | +|---|---| +| `unity.cpp` (253 lines) | Unity **native audio SDK** effect plugin: `UnityGetAudioEffectDefinitions`, `ProcessCallback`, `SetFloatParameterCallback`. | +| `unityplugin.cpp` (307 lines) | Plain C exports (`Faust_setParameterValue` etc.) for P/Invoke. | +| `FaustPlugin_template.cs` | `MonoBehaviour` on an `AudioSource`; `OnAudioFilterRead` calls `ctx.process(...)`. | +| `FaustUtilities_template.cs`, `FaustPolyUtilities_template.cs` | `DllImport` glue, inspector UI, polyphonic variant. | + +So Faust provides both bridge shapes the question names. The `FaustPlugin_template.cs` +path is the **OnAudioFilterRead bridge**: Unity calls `OnAudioFilterRead(float[] buffer, int +numchannels)` on its audio thread and C# P/Invokes the native `process`. `unity.cpp` is the +**native audio SDK** shape: Unity's mixer calls `ProcessCallback` directly with no managed +frame in the audio path. + +`faust2unity` builds the native libraries and C# scripts and packs a `.unitypackage`; +platform scripts are `faust2winunity` (MinGW cross-compile: `-w32`/`-w64`) and +`faust2linuxunity` (`g++`, `-fPIC -shared`, `.so`) [V: scripts and README read; not run]. + +## Path (a): AOT Faust to C++ in a native plugin + +### Per-platform outputs + +| Platform | Output | Toolchain | Status | +|---|---|---|---| +| Windows x64 | `FaustPlugin_.dll` | `faust2winunity -64` uses MinGW (`x86_64-w64-mingw32-gcc`) [V: script]. An MSVC build of the generated C++ is plausible but not in Faust's scripts. | [U] runs in a Unity Windows player | +| Linux x86_64 | `libFaustPlugin_.so` | `g++ -fPIC -shared` (`faust2linuxunity`) [V: script] | [U] runs in a Unity Linux player | +| Inputs | `thruster.dsp` + `stdfaust.lib` tree | `faust` CLI with `-I` at faustlibraries | [V] | + +Generating the thruster as C++ works [V]: `faust -I faustlibraries-20261031 -a minimal.cpp +-single -ftz 2 -vec -lv 1 thruster.dsp` gave 1,105 lines (40,045 bytes) with Faust 2.90.20. +Those are the same flags `AquaSynthNativeCompiler.CompileSource` passes to the JIT +(`src/AquaSynth.Faust/NativeFaustRuntime.cs:530`). The AOT lane should pick its flags +deliberately, not inherit them: `-vec` is a choice that the measurement plan below should +test against scalar output. + +Windows and Linux builds need two different hosts or a cross-compiler. Starfire (Windows) +has Faust and a compiler only if someone installs them there [U]. + +### What is reusable from AquaSynth + +| Part | Reusable for (a)? | Evidence | +|---|---|---| +| `patches/thruster/thruster.dsp` | Yes, as is. It is hand-written Faust, "not a `.aqua` script" (file header). | [V] | +| `FaustExport` / `FaustEmitter` (`src/AquaSynth.Core/FaustExport.cs`, 2,558 lines) | Only for `.aqua` patches. The thruster does not go through it. For an `.aqua` patch it yields the `.dsp` source to feed `faust -lang cpp`; `DspSourceDirectory` already writes it (`NativeFaustRuntime.cs:628`). | [V] | +| `FaustCompiler.CompileAsync` (`src/AquaSynth.Faust/FaustCompiler.cs:56`) | Yes. Runs the `faust` CLI with `-lang Cpp`; `FaustTargetLanguage.Cpp` exists. This is the AOT generator step. | [V] | +| `NativeFaustRuntime.cs` (1,132 lines: `AquaSynthPatchCompiler`, `AquaSynthStreamingPatch`, `FaustNativeToolchain`) | **Not in the shipped player.** It is the libfaust loader and the managed host. Under (a) it stays on the build/authoring side: it renders reference audio and the manifest that the plugin's output is checked against. | [V] | +| `tools/FaustRender` + `docs/renders/thruster-v5-manifest.json` | Yes, as the golden reference: hashes, peak, RMS, `nonFinite` per rpm case, 48 kHz / 512-frame blocks. The native plugin should be diffed against this. The manifest hashes predate the 2026-11-05 edit to `thruster.dsp` (`docs/faust-toolchain-boundary.md`, "Linux Native Toolchain"), so re-render first. | [V] | +| `AquaSynthNativeManifest` (id, compile key, sample rate, I/O counts, Faust version) | Yes as the artifact provenance record. It has **no parameter table** (no min, max, default). That is a gap for crossing params (below). | [V] | + +Missing for (a), not in AquaSynth today: a build step that runs `faust2unity`-style +generation per patch and records the result as artifacts. That should be a script in +`tools/`, not a new library. Per the boundary doc, AquaSynth owns "generated +source/native artifact layout" and "parameter and bus manifests", and Aquarium/Unity owns +"artifact loading policy for its platform". + +### Hot-path hazards in the managed bridge (if OnAudioFilterRead + managed host) + +If the player used `AquaSynthStreamingPatch` directly (managed host, native `libfaust` +instance), these are in the audio callback [V: `NativeFaustRuntime.cs`]: + +- `ProcessBlock(float[][] ...)` (line 251) allocates `IntPtr[]` arrays and pins six + `GCHandle`s per call. Use the pointer overload (line 235) with preallocated pinned buffers + (what `tools/FaustRender/Program.cs:37-40` already does). +- `SetControls` does a string dictionary lookup per control per block and a `Marshal.WriteInt32` + (lines 841-869). It also throws `ArgumentException` for an unknown path (line 865): an + exception in an audio callback. Resolve zone pointers once, off-thread. +- The `FaustNativeToolchain` delegates are `Marshal.GetDelegateForFunctionPointer` thunks + (line 886), not function pointers; fine for control rate, avoidable per block. + +Under the AOT plugin, none of this exists: the cost moves to the plugin's `setParamValue` +and `compute`. + +### Native audio SDK vs OnAudioFilterRead + +| | Native audio SDK (`unity.cpp`) | `OnAudioFilterRead` bridge (`FaustPlugin_template.cs`) | +|---|---|---| +| Where it runs | Mixer effect, native audio thread, no managed code | Managed callback on the audio thread, then P/Invoke | +| Source/generator | Effect slot on a mixer group; `ProcessCallback` returns `ERR_UNSUPPORTED` if `inchannels != outchannels` (`unity.cpp:179`) [V] | Component on a GameObject with `AudioSource` | +| Params | `SetFloatParameterCallback`, set from mixer exposed params or `AudioMixer.SetFloat` [U] | `setParameter(int, float)` per patch component | +| Risk | Mixer setup per patch; 15-char parameter names (below) | GC pauses or managed allocation can overrun the callback if the managed side allocates [U] | +| Fit for thruster | Better on determinism; whether a generator-only (0-input) effect behaves well in a mixer slot is [U] | Matches Faust's template; many instances are easy (one component each) | + +The thruster has 0 inputs and 1 output. In both shapes a 1-channel Faust output goes to +the first interleaved channel only and zero-fills the rest (`interleavedWrite`, +`architecture/faust/dsp/dsp-tools.h:216-223`) [V]. A stereo player would hear left only +unless the patch is made to output two channels or the plugin is edited. + +## Path (b): runtime `libfaust`/LLVM in the player + +`AquaSynthPatchCompiler` already is this, host-side: `createCDSPFactoryFromString` via +`NativeLibrary.Load` (`NativeFaustRuntime.cs:793`), the C API delegates (727-737), instances +created and computed through `computeCDSPInstance`. + +Per-platform outputs: + +| Platform | Ship | Evidence | +|---|---|---| +| Linux x64 | `libfaust.so.2.90.20` (8.4 MB) + system `libLLVM.so.19.1` (129.7 MB) + `libz3.so.4`, `libffi.so.8`, `libedit.so.2`, `libzstd`, `libz` (all dynamic deps) + `share/faust/*.lib` | [V: `ldd`, `ls`, doc] | +| Windows x64 | `libfaust.dll` plus `share/faust` | [U] no Windows libfaust built or run by this run. `AquaSynthFaustToolchain.LibraryFileNames` looks for `libfaust.dll`/`faust.dll` (`NativeFaustRuntime.cs:654-657`); the doc says `C:\Program Files\Faust` is the default home. | + +Costs specific to AquaSynth's own history, from `docs/faust-toolchain-boundary.md`: +the Linux link first failed (`cannot find -lPolly -lPollyISL -lzstd`), and the prefix +`share/faust` lacked `stdfaust.lib` until the faustlibraries tree was added. The library +tree has to travel with the player (`AquaSynthFaustToolchain.Find` probes +`/Tools/Faust`, line 666). + +Beyond size: + +- A JIT needs executable memory. Desktop Windows/Linux allow it; iOS and consoles do not + [U]. A player that needs those later cannot have (b) as its only path. +- The compile step is multi-hundred-millisecond to seconds and must run on a worker thread + with a finished-DSP handoff (boundary doc, "Runtime Rule"). `AquaSynthNativeManifest.CompileMilliseconds` + records it [V: field exists; no number measured here]. +- Output from a JIT with `-vec` at optLevel `-1` is whatever LLVM emits on that machine. + It is not bit-identical across hosts [U], so the reproducibility invariant in the + boundary doc ("artifacts are reproducible from script, version, target, options") weakens. + +## Licensing if shipped + +Read from files in the tree this run built [V] unless marked. + +| Component | Licence | Ship implication | +|---|---|---| +| Faust compiler / `libfaust` 2.90.20 | LGPL-2.1-or-later (header of `COPYING.txt`: "GNU Lesser General Public License ... version 2.1") | Dynamic loading of an unmodified `libfaust.so/.dll` satisfies LGPL if the user can replace it. Ship licence text and source offer. [U] legal review. | +| Faust architecture files (`unity.cpp`) | LGPL-3.0-or-later **with exception**: you may create a larger work with the architecture section and distribute it under terms of your choice, **so long as the architecture section is not modified** | Use `unity.cpp` / `unityplugin.cpp` unmodified and the rest of the plugin has no copyleft. Editing them (e.g. to add param clamping) drops the exception for that file. Prefer clamping elsewhere (below). | +| Generated C++ from `faust` (the DSP section of the output) | Not governed by the compiler licence per Faust's licence note [U: from Faust FAQ, not checked here] | Verify before shipping. | +| `faustlibraries` (`stdfaust.lib`, used by the thruster via `os`, `fi`, `no`, `si`, `ba`, `ma`) | Per-function: `oscillators.lib`, `noises.lib`, `signals.lib`, `basics.lib`, `maths.lib` headers say LGPL (GRAME); `filters.lib` says "Each function in this library has its own license" (e.g. Julius O. Smith III) | Compiled into the generated code. Need a per-function licence inventory of the functions the thruster calls before shipping. Not done. | +| LLVM (path (b) only) | Apache-2.0 with LLVM exceptions [U: from memory, not in tree] | Permissive; ship notice. Also notices for z3 (MIT), libffi (MIT), libedit (BSD) [U]. | + +Net: (a) puts only unmodified-architecture-file and faustlibraries notices in the player. (b) +adds LGPL relinking obligations for `libfaust` and a third-party LLVM stack. + +## Crossing bounded parameters (rpm now; load/velocity/quality later) + +Today's thruster has one control: +`rpm = hslider("rpm", 1200, 300, 6000, 1) : si.smooth(ba.tau2pole(0.2))` +(`thruster.dsp` line 6). `load` is derived from it (`load = (rpm - 300) / 5700`). The +generated C++ declares it with `addHorizontalSlider("rpm", &fHslider0, 1.2e+03f, 3e+02f, 6e+03f, 1.0f)` +[V]. Later controls (load, velocity, quality) must each be declared the same way, with a +default, min and max. + +### What crosses and how + +- **AOT / `OnAudioFilterRead`**: C# calls `Faust_setParameterValue(ctx, index, float)` + (`FaustUtilities_template.cs:307`), which does `*fZone = v` with no clamp + (`APIUI.h` `setParamValue(int, FAUSTFLOAT)` = `*fItems[p].fZone = v`) [V]. Parameters are + addressed by integer index in declaration order. The `.cs` file prints min/max/init + (`getParameterMin/Max`). +- **AOT / native audio SDK**: `ComputeUnityParameters` fills Unity's + `UnityAudioParameterDefinition` with `min`, `max`, `defaultval` from the Faust UI + (`unity.cpp:116-118`) [V]. Unity then knows the range and the default; the inspector and + mixer use it. **Names are cut to 15 characters** (`strncpy(pdef[i].name, ..., 15)`, + `unity.cpp:112`) [V]. `rpm` fits; Aqua-style paths such as `/curves//depth` do not. + The AquaSynth path lengths need a unique-prefix rule or the control must be + addressed by index. +- **Runtime `libfaust` (b)**: `AquaSynthStreamingPatch.SetControls` writes the float's + bits to the zone pointer with `Marshal.WriteInt32` (`NativeFaustRuntime.cs:868`). No + range or default crosses; `FaustUiGlue.AddControl` discards `init, min, max, step` + (line 1028) [V]. + +Float writes are the only thing crossing. A single aligned 32-bit store is atomic on x86-64, +so no lock is needed for one scalar control [U: assumes the compiler does not tear; the +generated code reads each zone once per block, `float fSlow0 = static_cast(fHslider0)`, +`compute` line 430 in the generated file] [V for the read]. A control that moves within a +block takes effect at the next block, smoothed by `si.smooth` (rpm uses a 0.2 s time +constant). + +### Needed for several bounded params + +1. A parameter table per patch alongside the existing `AquaSynthNativeManifest`: + `{path, index, default, min, max}`. (b) can get it from `FaustUiGlue` if + `AddControl` stops discarding `init/min/max`; (a) can get it from the same + `faust -json` output or from the C++ UI callbacks at build time. +2. One clamp site (below), driven from that table, owned by AquaSynth, not by + Unity code. +3. A normalized-to-range mapping owned by AquaSynth for load/velocity/quality when the game + supplies 0..1, if that is the game's contract. `ControlSurfaceCatalog` already holds + normalized surfaces for `.aqua` (`hslider(path, DefaultNormalized, 0, 1, 0.001)`, + `FaustExport.cs:157`) [V]; the thruster has none. + +## Are param inputs clamped today? + +No, for the thruster path. Layer by layer [V]: + +| Layer | Clamp? | +|---|---| +| `thruster.dsp` | No. Slider min/max are UI metadata. The generated `compute` reads the zone raw (`fSlow0 = fHslider0`). An rpm of 20000 or -5 reaches `si.smooth` and every formula (`shaft = 28 + rpm*0.025`, `load = (rpm-300)/5700`, band centres, drive). | +| `FaustNativeToolchain.WriteControl` (`NativeFaustRuntime.cs:860-869`) | No. Only unknown-path rejection, and `NaN`/infinity written as-is. | +| `AquaSynthStreamingPatch.SetControls` / `ProcessBlock` | No. | +| `tools/FaustRender/Program.cs:51` | No; it only sweeps within its CLI arguments. | +| `NativeFaustRuntimeTests.cs` | No test for out-of-range, NaN, or infinity control values found (grep for clamp/throws/range: no hit). | +| `ControlSplineTimeline` (`src/AquaSynth.Core/ControlSplineTimeline.cs:167-231`) | Yes, but only normalized `[0,1]` for `.aqua` control splines. It is not in the thruster path. | +| Faust `APIUI::setParamValue` (Unity bridge) | No (`*fZone = v`). | +| Unity side | The mixer/inspector clamp to the declared `min/max` in the native SDK path [U]. A script calling `setParameter` or `SetFloat` directly is not clamped by Faust's glue [V]. | + +The final `tanh` and the 0.425 trim (`thruster.dsp` last line) bound the output. Peak at +rpm 4800 is 0.36 (`docs/renders/thruster-v5-manifest.json`) [V]. Whether out-of-range rpm stays +finite and bounded is **not measured**: the manifest covers 300..6000 only. Hence +`nonFinite` coverage in the plan below includes out-of-range and non-finite inputs. + +Recommended clamp site: in the AquaSynth-owned manifest/host layer (for (a), a small +wrapper in the managed script that Faust's unmodified architecture files sit under; for (b), +`WriteControl`), clamping to the declared min/max and rejecting NaN. Do not edit +`unity.cpp`/`APIUI.h` (loses the architecture exception). The DSP itself can also carry the +bound: `hslider(...) : max(300) : min(6000)` in the `.dsp` is the one place both +lanes would share. That is a patch edit and a design choice for the thruster's owner, not +decided here. + +## Callback-deadline measurement plan (rerunnable) + +Goal: show, per path and platform, that `compute` fits the audio callback with margin, +including at the worst rpm sweep, under CPU load. Nothing here has been run. + +**Deadline.** `D = frames / sampleRate`. Unity's block comes from `AudioSettings.GetDSPBufferSize` +(`FaustPlugin_template.cs` `getBufferSize`). Test 256, 512, 1024 frames at 44.1 k and +48 k (the render manifest uses 48 k / 512, i.e. D = 10.67 ms). Proposed pass line: +p99.9 under 25% of D, max under 50% of D (a proposal, not a ruling). + +**What to time.** + +1. `compute(count, ...)` alone, pure C++ (AOT): build `thruster.cpp` with Faust's + `architecture/bench.cpp` or a 30-line driver; `std::chrono::steady_clock` around each + `compute`; 200,000 blocks; discard the first 1,000. [V: `bench.cpp` exists in + `architecture/`; not run.] +2. The whole plugin callback: `ProcessCallback` or `OnAudioFilterRead` including + `interleavedWrite` and the parameter write; timing taken inside the plugin with a + preallocated ring of timestamps, no logging in the callback; dumped on unload. +3. Managed host (b): `FaustRender`-style loop over `AquaSynthStreamingPatch.ProcessBlock` + with the pointer overload, `Stopwatch.GetTimestamp` around each call, GC allocation count + (`GC.GetAllocatedBytesForCurrentThread`) asserted zero across the loop. + +**Inputs.** The rpm cases from the manifest (600, 4800, sweeps) plus 300 and 6000 steady, a +full 300->6000->300 ramp changing rpm every block, and the out-of-range set +(`-1e9`, `0`, `1e6`, `NaN`, `+Inf`) with finite-and-bounded output asserted. Add the +rpm-and-load product of any new controls. Include denormal check (`-ftz 2` build vs without). + +**Conditions.** Idle host and with the Starfire load other Minds create (record +`nvidia-smi` and `query user` before and after; she wants it saturated, but a GPU hang resets +her display, so the run is CPU-only); one thread pinned; power plan noted; Debug and Release +for managed pieces. Linux on Yggdrasil or this host, Windows on Starfire over `ssh starfire` +(not run, and it is Meta's shared machine, so one job at a time). + +**Variants to compare**, same inputs: AOT `-vec` vs scalar; AOT `-O2` vs `-O3 -march=x86-64-v2` +(avoid `-march=native`, which the player's CPU may not match); JIT optLevel `-1` vs 3 [U: flag +meaning]. First-callback and instantiation time recorded separately from steady state. + +**Output.** One JSON per run: host, OS, CPU model, Faust version, compile flags, block size, +sample rate, n, min/p50/p99/p99.9/max in microseconds, % of D, overrun count (`t > D`), peak, +rms, `nonFinite`, `dspSha256`. Same shape and location as `docs/renders/thruster-v5-manifest.json` +so the existing hashes can be compared. A script for it belongs in `tools/` next to +`FaustRender`. + +**In the real player.** Unity does not expose callback timing directly. Time inside +the plugin as above, and read `AudioSettings` underrun counters / Profiler `Audio` markers +[U: exact counter names] over a 10-minute run in a development build on each OS. + +## Unverified list, in one place + +- That the generated Windows `.dll` and Linux `.so` load and play in a Unity Windows/Linux + player (no Unity available in this run). +- `faust2winunity` end-to-end on any host (MinGW not checked). +- Behaviour of a 0-input generator in a mixer effect slot; mixer parameter exposure. +- Generated-code licence position, LLVM/z3/libffi/libedit licences, and a per-function + inventory of `faustlibraries` licences for the thruster's calls. +- A Windows `libfaust.dll` build and its dependencies. +- Compile latency in milliseconds for the thruster (the field exists, no number taken). +- Out-of-range / non-finite rpm behaviour of the thruster output. +- Atomicity of the float zone write across a block boundary in a real plugin. +- Unity's DSP buffer size defaults and underrun counter names. From 0efce042f3678981d10e0be7ed740a078137da27 Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 23:19:35 +0000 Subject: [PATCH 022/124] docs: state the AOT patch-set limitation up front Co-Authored-By: Claude Sonnet 5.5 --- docs/faust-unity-player-scoping.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/faust-unity-player-scoping.md b/docs/faust-unity-player-scoping.md index 7299774..cf9a7e9 100644 --- a/docs/faust-unity-player-scoping.md +++ b/docs/faust-unity-player-scoping.md @@ -6,6 +6,8 @@ Question: how does Faust DSP (the thruster, `patches/thruster/thruster.dsp`, v5) built Unity player on Windows and Linux? (a) ahead-of-time (AOT) Faust to C++ per patch inside a native plugin, or (b) runtime `libfaust`/LLVM inside the player. +**Limitation:** AOT Faust-to-C++ fixes the patch set at build time. Player-authored or modded patches cannot run in a built player; live-edited patches run only in the editor or browser lane. + Marks: **[V]** verified here by reading source or running a tool on 2026-11-06. **[U]** unverified: from memory, or needs a Unity editor/player or a Windows host this run did not have. Nothing here has been run inside Unity. From ecf381e714034b098bdf27408a8bc820be64a517 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 00:21:10 +0000 Subject: [PATCH 023/124] docs: apply review 824 to Faust Unity scoping Restate the AOT limit in Recommendation and Unverified list, drop the unsourced "browser lane", and make the p99.9/max pass lines Aqua's ruling with the quiet-host caveat for the max line. Co-Authored-By: Claude Sonnet 5.5 --- docs/faust-unity-player-scoping.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/faust-unity-player-scoping.md b/docs/faust-unity-player-scoping.md index cf9a7e9..994b2e9 100644 --- a/docs/faust-unity-player-scoping.md +++ b/docs/faust-unity-player-scoping.md @@ -6,7 +6,7 @@ Question: how does Faust DSP (the thruster, `patches/thruster/thruster.dsp`, v5) built Unity player on Windows and Linux? (a) ahead-of-time (AOT) Faust to C++ per patch inside a native plugin, or (b) runtime `libfaust`/LLVM inside the player. -**Limitation:** AOT Faust-to-C++ fixes the patch set at build time. Player-authored or modded patches cannot run in a built player; live-edited patches run only in the editor or browser lane. +**Limitation:** AOT Faust-to-C++ fixes the patch set at build time. Player-authored or modded patches cannot run in a built player; live-edited patches run only in the editor (the developer-time lane of path (b)). Marks: **[V]** verified here by reading source or running a tool on 2026-11-06. **[U]** unverified: from memory, or needs a Unity editor/player or a Windows host this run @@ -17,6 +17,9 @@ did not have. Nothing here has been run inside Unity. Take (a) for shipped patches such as the thruster. Keep (b) as a developer-time lane only, if at all. Confidence: about 80% on the choice, lower on the details marked [U]. +The cost of (a): the patch set is fixed at build time. A built player cannot run +player-authored or modded patches; live-edited patches run only in the editor, through (b). + - (a) fits the thruster: a fixed graph with ordinary controls, which `docs/faust-toolchain-boundary.md` ("Parameter changes are not recompiles"; "Shipping builds should prefer Faust-generated native targets") already says is the shipping shape. @@ -246,7 +249,9 @@ including at the worst rpm sweep, under CPU load. Nothing here has been run. **Deadline.** `D = frames / sampleRate`. Unity's block comes from `AudioSettings.GetDSPBufferSize` (`FaustPlugin_template.cs` `getBufferSize`). Test 256, 512, 1024 frames at 44.1 k and 48 k (the render manifest uses 48 k / 512, i.e. D = 10.67 ms). Proposed pass line: -p99.9 under 25% of D, max under 50% of D (a proposal, not a ruling). +p99.9 under 25% of D, max under 50% of D (Aqua's ruling, 2026-11-07). The spike's +shared-host outliers (max 10.8-17.1 ms, 4-5 blocks over deadline) mean the max line can only +be judged on a quiet host; a max miss on a loaded host is not a verdict. **What to time.** @@ -288,6 +293,9 @@ the plugin as above, and read `AudioSettings` underrun counters / Profiler `Audi ## Unverified list, in one place +- That a built player can run anything but the patches compiled into it: player-authored or + modded patches are out of reach by construction under (a); live edit needs the editor and (b). + - That the generated Windows `.dll` and Linux `.so` load and play in a Unity Windows/Linux player (no Unity available in this run). - `faust2winunity` end-to-end on any host (MinGW not checked). From 22af1e935eb58b7c6470262d599076fad57101e3 Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 23:21:08 +0000 Subject: [PATCH 024/124] spike: AOT-compile thruster v5 to a C-ABI native lib with bounded rpm, test, timing script Linux only; Windows/Unity unverified. Co-Authored-By: Claude Sonnet 5.5 --- spikes/faust-aot-thruster/.gitignore | 1 + spikes/faust-aot-thruster/README.md | 26 ++ spikes/faust-aot-thruster/aqs_thruster.cpp | 71 +++ spikes/faust-aot-thruster/aqs_thruster.h | 52 +++ spikes/faust-aot-thruster/bench_thruster.c | 38 ++ spikes/faust-aot-thruster/run.sh | 21 + spikes/faust-aot-thruster/test_thruster.c | 94 ++++ spikes/faust-aot-thruster/thruster.dsp | 30 ++ spikes/faust-aot-thruster/thruster_dsp.h | 474 +++++++++++++++++++++ 9 files changed, 807 insertions(+) create mode 100644 spikes/faust-aot-thruster/.gitignore create mode 100644 spikes/faust-aot-thruster/README.md create mode 100644 spikes/faust-aot-thruster/aqs_thruster.cpp create mode 100644 spikes/faust-aot-thruster/aqs_thruster.h create mode 100644 spikes/faust-aot-thruster/bench_thruster.c create mode 100755 spikes/faust-aot-thruster/run.sh create mode 100644 spikes/faust-aot-thruster/test_thruster.c create mode 100644 spikes/faust-aot-thruster/thruster.dsp create mode 100644 spikes/faust-aot-thruster/thruster_dsp.h diff --git a/spikes/faust-aot-thruster/.gitignore b/spikes/faust-aot-thruster/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/spikes/faust-aot-thruster/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/spikes/faust-aot-thruster/README.md b/spikes/faust-aot-thruster/README.md new file mode 100644 index 0000000..f78a9be --- /dev/null +++ b/spikes/faust-aot-thruster/README.md @@ -0,0 +1,26 @@ +# Faust AOT spike: thruster v5 as a native lib (Linux) + +Spike for `docs/faust-unity-player-scoping.md` path (a). One patch, `patches/thruster/thruster.dsp` +(copied here as `thruster.dsp`; re-copy if the patch changes), compiled by the `faust` CLI to C++ and +wrapped behind a C ABI. Not wired into the solution or into Unity. + +Limitation: AOT fixes the patch set at build time, so player-authored patches cannot run this way. + +- `aqs_thruster.h`: the C ABI. `rpm` enters only via `aqs_thruster_set_rpm`: bounds are read from the + compiled patch's `hslider` (300..6000, default 1200); out-of-range and +-inf clamp to the nearest bound + (`AQS_PARAM_CLAMPED`), NaN applies the default (`AQS_PARAM_NAN`); both are counted and returned. + `aqs_thruster_process` rejects NULL, negative or >`AQS_MAX_BLOCK` frames instead of truncating. +- `test_thruster.c`: plain-C behaviour test (bounds, clamp, NaN, inf, hostile values give finite bounded + output, rpm actually changes the output, instances are deterministic). A flipped clamp bound fails it. +- `bench_thruster.c`: per-block `process` time at 48 kHz / 512 frames against the 10.667 ms deadline. +- `run.sh`: generate, build, test, bench. `FAUST`, `FAUST_PREFIX` (needs `include/faust`), `FAUST_LIBS` + (needs `stdfaust.lib`), `BLOCKS`, `RATE`, `FRAMES` override defaults. Exit status is test status; timing + is reported, not gated. + +Measured 2026-11-06, Faust 2.90.20, AMD EPYC-Genoa, shared Linux host, 20000 blocks, 3 runs: +median 0.052 ms (0.49% of deadline), p99 0.10-0.16 ms (~1-1.5%), max 10.8-17.1 ms (4-5 blocks of 20000 over +the deadline). The max is a scheduler preemption on a shared host, not DSP cost (median and p99 are +two orders under the deadline); a quiet or realtime-priority host is needed to say anything about the max. + +**Unverified:** Windows (MSVC build, `__declspec(dllexport)`), Unity P/Invoke, IL2CPP, the Unity audio +thread, any device. Nothing here ran inside Unity. diff --git a/spikes/faust-aot-thruster/aqs_thruster.cpp b/spikes/faust-aot-thruster/aqs_thruster.cpp new file mode 100644 index 0000000..8bfe829 --- /dev/null +++ b/spikes/faust-aot-thruster/aqs_thruster.cpp @@ -0,0 +1,71 @@ +#include "aqs_thruster.h" + +#include +#include + +#include +#include +#include +#include "thruster_dsp.h" + +struct aqs_thruster { + ThrusterDsp dsp; + APIUI ui; + float lo, hi, init, applied; + unsigned clamps = 0, nans = 0; +}; + +extern "C" { + +aqs_thruster* aqs_thruster_create(int sample_rate) { + if (sample_rate < 8000 || sample_rate > 384000) return nullptr; + aqs_thruster* t = new (std::nothrow) aqs_thruster(); + if (!t) return nullptr; + t->dsp.init(sample_rate); + t->dsp.buildUserInterface(&t->ui); + t->lo = t->ui.getParamMin(0); + t->hi = t->ui.getParamMax(0); + t->init = t->ui.getParamInit(0); + t->applied = t->init; + return t; +} + +void aqs_thruster_destroy(aqs_thruster* t) { delete t; } + +float aqs_thruster_rpm_min(const aqs_thruster* t) { return t->lo; } +float aqs_thruster_rpm_max(const aqs_thruster* t) { return t->hi; } +float aqs_thruster_rpm_default(const aqs_thruster* t) { return t->init; } + +int aqs_thruster_set_rpm(aqs_thruster* t, float rpm) { + if (!t) return -1; + int status = AQS_PARAM_OK; + if (std::isnan(rpm)) { + rpm = t->init; + status = AQS_PARAM_NAN; + ++t->nans; + } else if (rpm < t->lo) { + rpm = t->lo; + status = AQS_PARAM_CLAMPED; + ++t->clamps; + } else if (rpm > t->hi) { + rpm = t->hi; + status = AQS_PARAM_CLAMPED; + ++t->clamps; + } + t->applied = rpm; + t->ui.setParamValue(0, rpm); + return status; +} + +float aqs_thruster_rpm(const aqs_thruster* t) { return t->applied; } +unsigned aqs_thruster_clamp_count(const aqs_thruster* t) { return t->clamps; } +unsigned aqs_thruster_nan_count(const aqs_thruster* t) { return t->nans; } + +int aqs_thruster_process(aqs_thruster* t, float* out, int frames) { + if (!t || !out || frames < 0 || frames > AQS_MAX_BLOCK) return -1; + float* outs[1] = {out}; + t->dsp.compute(frames, nullptr, outs); + return frames; +} + +} // extern "C" diff --git a/spikes/faust-aot-thruster/aqs_thruster.h b/spikes/faust-aot-thruster/aqs_thruster.h new file mode 100644 index 0000000..0b93baf --- /dev/null +++ b/spikes/faust-aot-thruster/aqs_thruster.h @@ -0,0 +1,52 @@ +/* C ABI over the AOT-compiled thruster (patches/thruster/thruster.dsp). + * The host never touches Faust types. rpm enters only through aqs_thruster_set_rpm, + * which enforces the bounds declared in the .dsp (hslider min/max/init). */ +#ifndef AQS_THRUSTER_H +#define AQS_THRUSTER_H +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) +#define AQS_API __declspec(dllexport) +#else +#define AQS_API __attribute__((visibility("default"))) +#endif + +typedef struct aqs_thruster aqs_thruster; + +/* Result of a parameter write. The applied value is always inside [min,max]. */ +enum { + AQS_PARAM_OK = 0, /* applied as given */ + AQS_PARAM_CLAMPED = 1, /* out of range (including +-inf): applied the nearest bound */ + AQS_PARAM_NAN = 2 /* NaN: applied the declared default */ +}; + +/* Largest frame count one process call accepts; larger requests are rejected, not truncated. */ +#define AQS_MAX_BLOCK 16384 + +AQS_API aqs_thruster* aqs_thruster_create(int sample_rate); /* NULL on bad rate (<8000 or >384000) or OOM */ +AQS_API void aqs_thruster_destroy(aqs_thruster*); + +/* Declared bounds, read from the compiled patch. */ +AQS_API float aqs_thruster_rpm_min(const aqs_thruster*); +AQS_API float aqs_thruster_rpm_max(const aqs_thruster*); +AQS_API float aqs_thruster_rpm_default(const aqs_thruster*); + +/* Returns AQS_PARAM_*; negative on NULL handle. */ +AQS_API int aqs_thruster_set_rpm(aqs_thruster*, float rpm); +/* Value currently applied (post-clamp). */ +AQS_API float aqs_thruster_rpm(const aqs_thruster*); + +/* Counters since create, for the host to report: out-of-range and NaN writes. */ +AQS_API unsigned aqs_thruster_clamp_count(const aqs_thruster*); +AQS_API unsigned aqs_thruster_nan_count(const aqs_thruster*); + +/* Writes `frames` mono samples. Returns frames written, or -1 on NULL handle/out, + * frames < 0, or frames > AQS_MAX_BLOCK. No allocation, no locks. */ +AQS_API int aqs_thruster_process(aqs_thruster*, float* out, int frames); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/spikes/faust-aot-thruster/bench_thruster.c b/spikes/faust-aot-thruster/bench_thruster.c new file mode 100644 index 0000000..bf602b3 --- /dev/null +++ b/spikes/faust-aot-thruster/bench_thruster.c @@ -0,0 +1,38 @@ +/* Per-block callback time vs deadline. usage: bench_thruster [blocks] [rate] [frames] */ +#include +#include +#include +#include "aqs_thruster.h" + +static int cmp(const void* a, const void* b) { double x = *(const double*)a, y = *(const double*)b; return (x > y) - (x < y); } + +int main(int argc, char** argv) { + int blocks = argc > 1 ? atoi(argv[1]) : 20000; + int rate = argc > 2 ? atoi(argv[2]) : 48000; + int frames = argc > 3 ? atoi(argv[3]) : 512; + aqs_thruster* t = aqs_thruster_create(rate); + if (!t || blocks < 100) return 2; + float* out = malloc(sizeof(float) * frames); + double* ms = malloc(sizeof(double) * blocks); + const int warm = 200; + for (int i = 0; i < warm + blocks; ++i) { + /* sweep rpm across its whole range so the smoother and filters keep moving */ + aqs_thruster_set_rpm(t, 300.f + 5700.f * (0.5f + 0.5f * (float)((i % 997) - 498) / 498.f)); + struct timespec a, b; + clock_gettime(CLOCK_MONOTONIC, &a); + aqs_thruster_process(t, out, frames); + clock_gettime(CLOCK_MONOTONIC, &b); + if (i >= warm) ms[i - warm] = (b.tv_sec - a.tv_sec) * 1e3 + (b.tv_nsec - a.tv_nsec) / 1e6; + } + double deadline = 1e3 * frames / rate, sum = 0; + int over = 0; + for (int i = 0; i < blocks; ++i) { sum += ms[i]; if (ms[i] > deadline) ++over; } + qsort(ms, blocks, sizeof *ms, cmp); + double med = ms[blocks / 2], p99 = ms[(int)(blocks * 0.99)], mx = ms[blocks - 1]; + printf("rate=%d frames=%d blocks=%d deadline_ms=%.4f\n", rate, frames, blocks, deadline); + printf("median_ms=%.4f p99_ms=%.4f max_ms=%.4f mean_ms=%.4f\n", med, p99, mx, sum / blocks); + printf("median_pct_deadline=%.2f p99_pct_deadline=%.2f max_pct_deadline=%.2f over_deadline=%d\n", + 100 * med / deadline, 100 * p99 / deadline, 100 * mx / deadline, over); + free(out); free(ms); aqs_thruster_destroy(t); + return 0; /* timing is reported, not gated: a shared host preempts */ +} diff --git a/spikes/faust-aot-thruster/run.sh b/spikes/faust-aot-thruster/run.sh new file mode 100755 index 0000000..952c0d1 --- /dev/null +++ b/spikes/faust-aot-thruster/run.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Build the AOT thruster spike, run the boundary test, then the per-block timing report. +# Linux only. usage: run.sh [--bench-only] ; env: FAUST (faust CLI), FAUST_PREFIX (has include/faust), +# FAUST_LIBS (dir with stdfaust.lib), OUT (build dir), BLOCKS, RATE, FRAMES. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +FAUST=${FAUST:-faust} +FAUST_PREFIX=${FAUST_PREFIX:-$(dirname "$(dirname "$(command -v "$FAUST")")")} +FAUST_LIBS=${FAUST_LIBS:-$FAUST_PREFIX/share/faust} +OUT=${OUT:-$here/build} +mkdir -p "$OUT" +[ -f "$FAUST_LIBS/stdfaust.lib" ] || { echo "no stdfaust.lib in FAUST_LIBS=$FAUST_LIBS" >&2; exit 2; } +"$FAUST" -lang cpp -cn ThrusterDsp -I "$FAUST_LIBS" "$here/thruster.dsp" -o "$OUT/thruster_dsp.h" +"$FAUST" --version | head -1 +CXXF="-O2 -std=c++17 -fvisibility=hidden -I$OUT -I$here -I$FAUST_PREFIX/include" +g++ $CXXF -shared -fPIC -o "$OUT/libaqs_thruster.so" "$here/aqs_thruster.cpp" +gcc -O2 -I"$here" -o "$OUT/test_thruster" "$here/test_thruster.c" -L"$OUT" -laqs_thruster -lm -Wl,-rpath,"$OUT" +gcc -O2 -I"$here" -o "$OUT/bench_thruster" "$here/bench_thruster.c" -L"$OUT" -laqs_thruster -lm -Wl,-rpath,"$OUT" +"$OUT/test_thruster" +echo "--- timing (Linux $(uname -r), $(grep -m1 'model name' /proc/cpuinfo | cut -d: -f2 | xargs)); Windows/Unity: unverified" +"$OUT/bench_thruster" "${BLOCKS:-20000}" "${RATE:-48000}" "${FRAMES:-512}" diff --git a/spikes/faust-aot-thruster/test_thruster.c b/spikes/faust-aot-thruster/test_thruster.c new file mode 100644 index 0000000..2ecf293 --- /dev/null +++ b/spikes/faust-aot-thruster/test_thruster.c @@ -0,0 +1,94 @@ +/* Behaviour test for the bounded-parameter boundary. Plain C: proves the ABI is callable without C++. */ +#include +#include +#include +#include "aqs_thruster.h" + +static int fails; +#define CHECK(c) do { if (!(c)) { printf("FAIL line %d: %s\n", __LINE__, #c); ++fails; } } while (0) + +static float peak_after(aqs_thruster* t, float rpm, int* finite) { + static float buf[512]; + float pk = 0; + *finite = 1; + aqs_thruster_set_rpm(t, rpm); + for (int b = 0; b < 200; ++b) { /* ~2 s: lets the 0.2 s rpm smoother settle */ + CHECK(aqs_thruster_process(t, buf, 512) == 512); + for (int i = 0; i < 512; ++i) { + if (!isfinite(buf[i])) *finite = 0; + if (fabsf(buf[i]) > pk) pk = fabsf(buf[i]); + } + } + return pk; +} + +int main(void) { + CHECK(aqs_thruster_create(100) == NULL); + CHECK(aqs_thruster_create(1000000) == NULL); + aqs_thruster* t = aqs_thruster_create(48000); + CHECK(t != NULL); + if (!t) return 1; + + /* bounds come from the .dsp hslider("rpm", 1200, 300, 6000, 1) */ + CHECK(aqs_thruster_rpm_min(t) == 300.f); + CHECK(aqs_thruster_rpm_max(t) == 6000.f); + CHECK(aqs_thruster_rpm_default(t) == 1200.f); + CHECK(aqs_thruster_rpm(t) == 1200.f); + + CHECK(aqs_thruster_set_rpm(t, 4800.f) == AQS_PARAM_OK && aqs_thruster_rpm(t) == 4800.f); + CHECK(aqs_thruster_set_rpm(t, 300.f) == AQS_PARAM_OK && aqs_thruster_rpm(t) == 300.f); + CHECK(aqs_thruster_set_rpm(t, 6000.f) == AQS_PARAM_OK && aqs_thruster_rpm(t) == 6000.f); + CHECK(aqs_thruster_clamp_count(t) == 0 && aqs_thruster_nan_count(t) == 0); + + CHECK(aqs_thruster_set_rpm(t, 299.9f) == AQS_PARAM_CLAMPED && aqs_thruster_rpm(t) == 300.f); + CHECK(aqs_thruster_set_rpm(t, -50.f) == AQS_PARAM_CLAMPED && aqs_thruster_rpm(t) == 300.f); + CHECK(aqs_thruster_set_rpm(t, 6000.1f) == AQS_PARAM_CLAMPED && aqs_thruster_rpm(t) == 6000.f); + CHECK(aqs_thruster_set_rpm(t, INFINITY) == AQS_PARAM_CLAMPED && aqs_thruster_rpm(t) == 6000.f); + CHECK(aqs_thruster_set_rpm(t, -INFINITY) == AQS_PARAM_CLAMPED && aqs_thruster_rpm(t) == 300.f); + CHECK(aqs_thruster_clamp_count(t) == 5); + + aqs_thruster_set_rpm(t, 5000.f); + CHECK(aqs_thruster_set_rpm(t, NAN) == AQS_PARAM_NAN && aqs_thruster_rpm(t) == 1200.f); + CHECK(aqs_thruster_nan_count(t) == 1); + + CHECK(aqs_thruster_set_rpm(NULL, 1000.f) < 0); + float buf[16]; + CHECK(aqs_thruster_process(t, buf, -1) == -1); + CHECK(aqs_thruster_process(t, buf, AQS_MAX_BLOCK + 1) == -1); + CHECK(aqs_thruster_process(t, NULL, 16) == -1); + CHECK(aqs_thruster_process(NULL, buf, 16) == -1); + CHECK(aqs_thruster_process(t, buf, 0) == 0); + + /* hostile inputs never reach the DSP: output stays finite and under the patch's own peak bound */ + float hostile[] = {NAN, INFINITY, -INFINITY, 1e30f, -1e30f, 0.f}; + for (unsigned i = 0; i < sizeof hostile / sizeof *hostile; ++i) { + aqs_thruster* h = aqs_thruster_create(48000); + int fin; + float pk = peak_after(h, hostile[i], &fin); + CHECK(fin); + CHECK(pk > 0.01f && pk < 1.0f); + aqs_thruster_destroy(h); + } + + /* the patch is audibly rpm-dependent and loud at high rpm (guards against a stuck parameter) */ + int fin; + aqs_thruster* lo = aqs_thruster_create(48000); + aqs_thruster* hi = aqs_thruster_create(48000); + float plo = peak_after(lo, 300.f, &fin), phi = peak_after(hi, 4800.f, &fin); + CHECK(phi > plo); + CHECK(phi < 0.45f); /* patch comment: peak under 0.4 at rpm 4800, small margin */ + aqs_thruster_destroy(lo); aqs_thruster_destroy(hi); + + /* same rpm, same sample rate: two instances render identical bytes (noise is seeded) */ + aqs_thruster* a = aqs_thruster_create(48000); + aqs_thruster* b = aqs_thruster_create(48000); + static float xa[2048], xb[2048]; + aqs_thruster_set_rpm(a, 2000.f); aqs_thruster_set_rpm(b, 2000.f); + aqs_thruster_process(a, xa, 2048); aqs_thruster_process(b, xb, 2048); + CHECK(memcmp(xa, xb, sizeof xa) == 0); + aqs_thruster_destroy(a); aqs_thruster_destroy(b); + + aqs_thruster_destroy(t); + printf(fails ? "FAILED (%d)\n" : "ok\n", fails); + return fails != 0; +} diff --git a/spikes/faust-aot-thruster/thruster.dsp b/spikes/faust-aot-thruster/thruster.dsp new file mode 100644 index 0000000..c36a8ae --- /dev/null +++ b/spikes/faust-aot-thruster/thruster.dsp @@ -0,0 +1,30 @@ +// thruster: sustained, heavy, brittle-hull thruster with an RPM control. +// Compile as Faust source (AquaSynthPatchCompiler.CompileSource); it is not a .aqua script. +// Control: rpm (300..6000). Rotor tone = 28 Hz + rpm*0.025 (about 36..180 Hz); three blades chop the rasp at 3x that. +declare name "thruster"; +import("stdfaust.lib"); + +rpm = hslider("rpm", 1200, 300, 6000, 1) : si.smooth(ba.tau2pole(0.2)); +load = (rpm - 300) / 5700; +shaft = 28 + rpm * 0.025; + +// effort: slow random wander of the shaft speed +wander = no.noise : fi.lowpass(2, 5) : *(0.35); +f0 = shaft * (1 + 0.04 * wander); + +// low rumble: saw at shaft speed plus a square a sub-octave down, low-passed +// the low-pass opens up as load falls, so at low rpm the rotor tone reaches the 150-300 Hz range a small speaker can show +rumble = (os.sawtooth(f0) + 0.7 * os.square(f0 * 0.5)) : fi.lowpass(3, 60 + 2.5 * shaft + 140 * (1 - load)); + +// blade pass: rasp noise chopped at 3x shaft, band tracks rpm +chop = 0.5 + 0.5 * os.osc(f0 * 3) ^ 2; +rasp = no.noise : fi.resonbp(700 + rpm * 0.6, 1.5, 1) : *(chop); + +// brittle hull: high-Q modes rattled by noise, louder with load (a 1.5% floor at idle, so low rpm is tone-led); tanh on the rattle alone keeps ring-up spikes from setting the peak +mode(f, q) = no.noise : fi.resonbp(f, q, 1); +rattle = (mode(173, 20) * (0.3 + 0.7 * load) + 0.8 * mode(311, 18) + 0.6 * mode(467, 16) + 0.4 * mode(1130, 14)) * (0.015 + 0.985 * load ^ 2) * 3 : *(4) : ma.tanh : /(4); + +mix = rumble * (0.5 + 0.5 * load) + rasp * (0.05 + 1.75 * load) + rattle; +// drive falls only gently with load so tanh stays out of saturation while high rpm still ends up louder than low rpm +// final 0.425 trim keeps peak under 0.4 at rpm 4800 +process = mix * (0.4 + 0.6 * load) * (0.9 - 0.5 * load) : ma.tanh : *(0.425); diff --git a/spikes/faust-aot-thruster/thruster_dsp.h b/spikes/faust-aot-thruster/thruster_dsp.h new file mode 100644 index 0000000..4d1c225 --- /dev/null +++ b/spikes/faust-aot-thruster/thruster_dsp.h @@ -0,0 +1,474 @@ +/* ------------------------------------------------------------ +name: "thruster" +Code generated with Faust 2.90.20 (https://faust.grame.fr) +Compilation options: -lang cpp -i -fpga-mem-th 4 -ct 1 -cn ThrusterDsp -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0 +------------------------------------------------------------ */ + +#ifndef __ThrusterDsp_H__ +#define __ThrusterDsp_H__ + +#ifndef FAUSTFLOAT +#define FAUSTFLOAT float +#endif + +/* link with : "" */ +#include +#include +#include +#include +#ifndef FAUST_INT_WRAP +#define FAUST_INT_WRAP +inline int faust_wrap_add(int a, int b) { return int((unsigned int)a + (unsigned int)b); } +inline int faust_wrap_sub(int a, int b) { return int((unsigned int)a - (unsigned int)b); } +inline int faust_wrap_mul(int a, int b) { return int((unsigned int)a * (unsigned int)b); } +#endif + + +#ifndef FAUSTCLASS +#define FAUSTCLASS ThrusterDsp +#endif + +#ifdef __APPLE__ +#define exp10f __exp10f +#define exp10 __exp10 +#endif + +#if defined(_WIN32) +#define RESTRICT __restrict +#else +#define RESTRICT __restrict__ +#endif + +class ThrusterDspSIG0 { + + private: + + int iVec4[2]; + int iRec13[2]; + int fSampleRate; + + public: + + int getNumInputsThrusterDspSIG0() { + return 0; + } + int getNumOutputsThrusterDspSIG0() { + return 1; + } + + void instanceInitThrusterDspSIG0(int sample_rate) { + fSampleRate = sample_rate; + for (int l17 = 0; l17 < 2; l17 = faust_wrap_add(l17, 1)) { + iVec4[l17] = 0; + } + for (int l18 = 0; l18 < 2; l18 = faust_wrap_add(l18, 1)) { + iRec13[l18] = 0; + } + } + + void fillThrusterDspSIG0(int count, float* table) { + for (int i1 = 0; i1 < count; i1 = faust_wrap_add(i1, 1)) { + iVec4[0] = 1; + iRec13[0] = (faust_wrap_add(iVec4[1], iRec13[1])) % 65536; + table[i1] = std::sin(9.58738e-05f * static_cast(iRec13[0])); + iVec4[1] = iVec4[0]; + iRec13[1] = iRec13[0]; + } + } + +}; + +static ThrusterDspSIG0* newThrusterDspSIG0() { return (ThrusterDspSIG0*)new ThrusterDspSIG0(); } +static void deleteThrusterDspSIG0(ThrusterDspSIG0* dsp) { delete dsp; } + +static float ThrusterDsp_faustpower2_f(float value_f) { + return value_f * value_f; +} +static float ftbl0ThrusterDspSIG0[65536]; + +class ThrusterDsp : public dsp { + + private: + + int iVec0[2]; + int fSampleRate; + float fConst0; + float fConst1; + FAUSTFLOAT fHslider0; + float fVec1[2]; + float fConst2; + float fRec2[2]; + float fConst3; + float fConst4; + float fConst5; + float fConst6; + float fConst7; + int iRec6[2]; + float fRec4[2]; + float fConst8; + float fRec5[2]; + int iRec8[2]; + int iRec7[2]; + float fConst9; + int iRec10[2]; + int iRec9[2]; + float fVec2[2]; + int IOTA0; + float fVec3[4096]; + float fConst10; + float fRec3[2]; + float fRec0[2]; + float fRec1[2]; + float fRec11[2]; + float fRec12[2]; + float fConst11; + int iRec15[2]; + int iRec14[2]; + float fConst12; + float fConst13; + float fConst14; + float fRec16[2]; + float fRec17[2]; + float fConst15; + float fConst16; + float fConst17; + float fRec18[2]; + float fRec19[2]; + float fConst18; + float fConst19; + float fConst20; + float fRec20[2]; + float fRec21[2]; + float fConst21; + float fConst22; + float fConst23; + float fRec22[2]; + float fRec23[2]; + + public: + ThrusterDsp() { + } + + ThrusterDsp(const ThrusterDsp&) = default; + + virtual ~ThrusterDsp() = default; + + ThrusterDsp& operator=(const ThrusterDsp&) = default; + + void metadata(Meta* m) { + m->declare("basics.lib/name", "Faust Basic Element Library"); + m->declare("basics.lib/version", "1.23.9"); + m->declare("compile_options", "-lang cpp -i -fpga-mem-th 4 -ct 1 -cn ThrusterDsp -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0"); + m->declare("filename", "thruster.dsp"); + m->declare("filters.lib/_tanhalf:author", "Julius O. Smith III"); + m->declare("filters.lib/_tanhalf:license", "MIT"); + m->declare("filters.lib/lowpass0_highpass1:author", "Julius O. Smith III"); + m->declare("filters.lib/lowpass0_highpass1:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); + m->declare("filters.lib/lowpass0_highpass1:license", "LicenseRef-STK-4.3"); + m->declare("filters.lib/lowpass:author", "Julius O. Smith III"); + m->declare("filters.lib/lowpass:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); + m->declare("filters.lib/lowpass:license", "LicenseRef-STK-4.3"); + m->declare("filters.lib/name", "Faust Filters Library"); + m->declare("filters.lib/resonbp:author", "Julius O. Smith III"); + m->declare("filters.lib/resonbp:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); + m->declare("filters.lib/resonbp:license", "LicenseRef-STK-4.3"); + m->declare("filters.lib/svf:author", "Oleg Nesterov"); + m->declare("filters.lib/svf:copyright", "Copyright (C) 2020 Oleg Nesterov "); + m->declare("filters.lib/svf:license", "LicenseRef-STK-4.3"); + m->declare("filters.lib/tf1s:author", "Julius O. Smith III"); + m->declare("filters.lib/tf1s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); + m->declare("filters.lib/tf1s:license", "LicenseRef-STK-4.3"); + m->declare("filters.lib/tf2s:author", "Julius O. Smith III"); + m->declare("filters.lib/tf2s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); + m->declare("filters.lib/tf2s:license", "LicenseRef-STK-4.3"); + m->declare("filters.lib/version", "1.13.4"); + m->declare("maths.lib/author", "GRAME"); + m->declare("maths.lib/copyright", "GRAME"); + m->declare("maths.lib/license", "LicenseRef-LGPL-2.1-or-later-with-Faust-exception"); + m->declare("maths.lib/name", "Faust Math Library"); + m->declare("maths.lib/version", "2.9.5"); + m->declare("name", "thruster"); + m->declare("noises.lib/name", "Faust Noise Generator Library"); + m->declare("noises.lib/version", "1.9.2"); + m->declare("oscillators.lib/lf_sawpos:author", "Bart Brouns, revised by Stéphane Letz"); + m->declare("oscillators.lib/lf_sawpos:licence", "LicenseRef-STK-4.3"); + m->declare("oscillators.lib/name", "Faust Oscillator Library"); + m->declare("oscillators.lib/saw2ptr:author", "Julius O. Smith III"); + m->declare("oscillators.lib/saw2ptr:license", "LicenseRef-STK-4.3"); + m->declare("oscillators.lib/sawN:author", "Julius O. Smith III"); + m->declare("oscillators.lib/sawN:license", "LicenseRef-STK-4.3"); + m->declare("oscillators.lib/version", "1.9.6"); + m->declare("platform.lib/name", "Generic Platform Library"); + m->declare("platform.lib/version", "1.3.2"); + m->declare("routes.lib/name", "Faust Signal Routing Library"); + m->declare("routes.lib/version", "1.4.1"); + m->declare("signals.lib/name", "Faust Routing Library"); + m->declare("signals.lib/version", "1.8.2"); + } + + virtual int getNumInputs() { + return 0; + } + virtual int getNumOutputs() { + return 1; + } + + static void classInit(int sample_rate) { + ThrusterDspSIG0* sig0 = newThrusterDspSIG0(); + sig0->instanceInitThrusterDspSIG0(sample_rate); + sig0->fillThrusterDspSIG0(65536, ftbl0ThrusterDspSIG0); + deleteThrusterDspSIG0(sig0); + } + + virtual void instanceConstants(int sample_rate) { + fSampleRate = sample_rate; + fConst0 = std::min(1.92e+05f, std::max(5e+01f, static_cast(fSampleRate))); + fConst1 = 3.1415927f / fConst0; + fConst2 = std::exp(-(5.0f / fConst0)); + fConst3 = 1.0f / fConst0; + fConst4 = std::tan(std::max(0.0f, std::min(15.707963f / fConst0, 1.5676547f))); + fConst5 = fConst4 + 1.4142135f; + fConst6 = fConst4 * std::min(3.4028235e+38f, 1.0f / (fConst4 * fConst5 + 1.0f)); + fConst7 = 2.0f * fConst6; + fConst8 = 2.0f * fConst4; + fConst9 = 0.175f * fConst0; + fConst10 = 0.5f * fConst0; + fConst11 = 3.0f / fConst0; + fConst12 = std::tan(std::max(0.0f, std::min(543.49554f / fConst0, 1.5676547f))); + fConst13 = fConst12 * std::min(3.4028235e+38f, 1.0f / (fConst12 * (fConst12 + 0.05f) + 1.0f)); + fConst14 = -0.05f - fConst12; + fConst15 = std::tan(std::max(0.0f, std::min(977.03534f / fConst0, 1.5676547f))); + fConst16 = fConst15 * std::min(3.4028235e+38f, 1.0f / (fConst15 * (fConst15 + 0.055555556f) + 1.0f)); + fConst17 = -0.055555556f - fConst15; + fConst18 = std::tan(std::max(0.0f, std::min(1467.1238f / fConst0, 1.5676547f))); + fConst19 = fConst18 * std::min(3.4028235e+38f, 1.0f / (fConst18 * (fConst18 + 0.0625f) + 1.0f)); + fConst20 = -0.0625f - fConst18; + fConst21 = std::tan(std::max(0.0f, std::min(3549.9998f / fConst0, 1.5676547f))); + fConst22 = fConst21 * std::min(3.4028235e+38f, 1.0f / (fConst21 * (fConst21 + 0.071428575f) + 1.0f)); + fConst23 = -0.071428575f - fConst21; + } + + virtual void instanceResetUserInterface() { + fHslider0 = static_cast(1.2e+03f); + } + + virtual void instanceClear() { + for (int l0 = 0; l0 < 2; l0 = faust_wrap_add(l0, 1)) { + iVec0[l0] = 0; + } + for (int l1 = 0; l1 < 2; l1 = faust_wrap_add(l1, 1)) { + fVec1[l1] = 0.0f; + } + for (int l2 = 0; l2 < 2; l2 = faust_wrap_add(l2, 1)) { + fRec2[l2] = 0.0f; + } + for (int l3 = 0; l3 < 2; l3 = faust_wrap_add(l3, 1)) { + iRec6[l3] = 0; + } + for (int l4 = 0; l4 < 2; l4 = faust_wrap_add(l4, 1)) { + fRec4[l4] = 0.0f; + } + for (int l5 = 0; l5 < 2; l5 = faust_wrap_add(l5, 1)) { + fRec5[l5] = 0.0f; + } + for (int l6 = 0; l6 < 2; l6 = faust_wrap_add(l6, 1)) { + iRec8[l6] = 0; + } + for (int l7 = 0; l7 < 2; l7 = faust_wrap_add(l7, 1)) { + iRec7[l7] = 0; + } + for (int l8 = 0; l8 < 2; l8 = faust_wrap_add(l8, 1)) { + iRec10[l8] = 0; + } + for (int l9 = 0; l9 < 2; l9 = faust_wrap_add(l9, 1)) { + iRec9[l9] = 0; + } + for (int l10 = 0; l10 < 2; l10 = faust_wrap_add(l10, 1)) { + fVec2[l10] = 0.0f; + } + IOTA0 = 0; + for (int l11 = 0; l11 < 4096; l11 = faust_wrap_add(l11, 1)) { + fVec3[l11] = 0.0f; + } + for (int l12 = 0; l12 < 2; l12 = faust_wrap_add(l12, 1)) { + fRec3[l12] = 0.0f; + } + for (int l13 = 0; l13 < 2; l13 = faust_wrap_add(l13, 1)) { + fRec0[l13] = 0.0f; + } + for (int l14 = 0; l14 < 2; l14 = faust_wrap_add(l14, 1)) { + fRec1[l14] = 0.0f; + } + for (int l15 = 0; l15 < 2; l15 = faust_wrap_add(l15, 1)) { + fRec11[l15] = 0.0f; + } + for (int l16 = 0; l16 < 2; l16 = faust_wrap_add(l16, 1)) { + fRec12[l16] = 0.0f; + } + for (int l19 = 0; l19 < 2; l19 = faust_wrap_add(l19, 1)) { + iRec15[l19] = 0; + } + for (int l20 = 0; l20 < 2; l20 = faust_wrap_add(l20, 1)) { + iRec14[l20] = 0; + } + for (int l21 = 0; l21 < 2; l21 = faust_wrap_add(l21, 1)) { + fRec16[l21] = 0.0f; + } + for (int l22 = 0; l22 < 2; l22 = faust_wrap_add(l22, 1)) { + fRec17[l22] = 0.0f; + } + for (int l23 = 0; l23 < 2; l23 = faust_wrap_add(l23, 1)) { + fRec18[l23] = 0.0f; + } + for (int l24 = 0; l24 < 2; l24 = faust_wrap_add(l24, 1)) { + fRec19[l24] = 0.0f; + } + for (int l25 = 0; l25 < 2; l25 = faust_wrap_add(l25, 1)) { + fRec20[l25] = 0.0f; + } + for (int l26 = 0; l26 < 2; l26 = faust_wrap_add(l26, 1)) { + fRec21[l26] = 0.0f; + } + for (int l27 = 0; l27 < 2; l27 = faust_wrap_add(l27, 1)) { + fRec22[l27] = 0.0f; + } + for (int l28 = 0; l28 < 2; l28 = faust_wrap_add(l28, 1)) { + fRec23[l28] = 0.0f; + } + } + + virtual void init(int sample_rate) { + classInit(sample_rate); + instanceInit(sample_rate); + } + + virtual void instanceInit(int sample_rate) { + instanceConstants(sample_rate); + instanceResetUserInterface(); + instanceClear(); + } + + virtual ThrusterDsp* clone() { + return new ThrusterDsp(*this); + } + + virtual int getSampleRate() { + return fSampleRate; + } + + virtual void buildUserInterface(UI* ui_interface) { + ui_interface->openVerticalBox("thruster"); + ui_interface->addHorizontalSlider("rpm", &fHslider0, FAUSTFLOAT(1.2e+03f), FAUSTFLOAT(3e+02f), FAUSTFLOAT(6e+03f), FAUSTFLOAT(1.0f)); + ui_interface->closeBox(); + } + + virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { + FAUSTFLOAT* output0 = outputs[0]; + float fSlow0 = static_cast(fHslider0); + float fSlow1 = fSlow0 + -3e+02f; + for (int i0 = 0; i0 < count; i0 = faust_wrap_add(i0, 1)) { + iVec0[0] = 1; + fVec1[0] = fSlow0; + fRec2[0] = fConst2 * (std::min(3.4028235e+38f, fVec1[1] - fSlow0) + fRec2[1]); + float fTemp0 = fSlow0 + fRec2[0]; + float fTemp1 = 28.0f + 0.025f * fTemp0; + float fTemp2 = fSlow1 + fRec2[0]; + float fTemp3 = 0.0001754386f * fTemp2; + float fTemp4 = std::tan(std::max(0.0f, std::min(fConst1 * (6e+01f + 2.5f * fTemp1 + 1.4e+02f * (1.0f - fTemp3)), 1.5676547f))); + iRec6[0] = faust_wrap_add(12345, faust_wrap_mul(1103515245, iRec6[1])); + float fTemp5 = 4.656613e-10f * static_cast(iRec6[0]); + float fTemp6 = fTemp5 - (fConst5 * fRec4[1] + fRec5[1]); + fRec4[0] = fRec4[1] + fConst7 * fTemp6; + float fTemp7 = fRec4[1] + fConst6 * fTemp6; + fRec5[0] = fRec5[1] + fConst8 * fTemp7; + float fTemp8 = fTemp1 * (1.0f + 0.014f * (fRec5[1] + fConst4 * fTemp7)); + float fTemp9 = std::fabs(fTemp8); + float fTemp10 = fConst3 * fTemp9; + float fTemp11 = 1.0737418e+09f * (fTemp10 - std::floor(fTemp10)); + float fTemp12 = std::floor(fTemp11); + int iTemp13 = faust_wrap_add(iRec8[1], static_cast(16777216.0f * (fTemp11 - fTemp12))); + iRec8[0] = iTemp13 & 16777215; + int iTemp14 = faust_wrap_add(faust_wrap_add(iRec7[1], static_cast(fTemp12)), iTemp13 >> 24); + int iTemp15 = iTemp14 & 1073741823; + iRec7[0] = iTemp15; + float fTemp16 = static_cast(iTemp15); + int iTemp17 = faust_wrap_sub(1, iVec0[1]); + float fTemp18 = std::max(0.5f * fTemp8, 23.44895f); + float fTemp19 = std::max(2e+01f, std::fabs(fTemp18)); + float fTemp20 = fConst3 * fTemp19; + float fTemp21 = 1.0737418e+09f * (fTemp20 - std::rint(fTemp20)); + float fTemp22 = std::floor(fTemp21); + int iTemp23 = faust_wrap_add(iRec10[1], static_cast(16777216.0f * (fTemp21 - fTemp22))); + iRec10[0] = ((iTemp17) ? 0 : iTemp23 & 16777215); + iRec9[0] = ((iTemp17) ? 0 : (faust_wrap_add(faust_wrap_add(iRec9[1], static_cast(fTemp22)), iTemp23 >> 24)) & 1073741823); + float fTemp24 = ThrusterDsp_faustpower2_f(-1.0f + 1.1920929e-07f * static_cast(iRec9[0] >> 6)); + fVec2[0] = fTemp24; + float fTemp25 = static_cast(iVec0[1]) * (fTemp24 - fVec2[1]) / fTemp19; + fVec3[IOTA0 & 4095] = fTemp25; + float fTemp26 = std::max(0.0f, std::min(8191.0f, fConst10 / fTemp18)); + int iTemp27 = static_cast(fTemp26); + float fTemp28 = std::floor(fTemp26); + float fTemp29 = 1.0f + fTemp4; + float fTemp30 = fTemp4 * (-1.0f - (fTemp10 + fRec3[1]) + 2.0f * ((iTemp14 > 1073741823) ? 1.0f + 9.313226e-10f * fTemp16 * (1.0f - fConst0 / std::max(1.1920929e-07f, fTemp9)) : 9.313226e-10f * fTemp16) + fConst9 * (fTemp25 - fVec3[(faust_wrap_sub(IOTA0, iTemp27)) & 4095] * (1.0f - fTemp26 + fTemp28) - (fTemp26 - fTemp28) * fVec3[(faust_wrap_sub(IOTA0, faust_wrap_add(1, iTemp27))) & 4095])) * std::min(3.4028235e+38f, 1.0f / fTemp29); + fRec3[0] = fRec3[1] + 2.0f * fTemp30; + float fTemp31 = fTemp4 * (fRec3[1] + fTemp30 - (fTemp29 * fRec0[1] + fRec1[1])) * std::min(3.4028235e+38f, 1.0f / (1.0f + fTemp4 * fTemp29)); + fRec0[0] = fRec0[1] + 2.0f * fTemp31; + float fTemp32 = fTemp4 * (fRec0[1] + fTemp31); + fRec1[0] = fRec1[1] + 2.0f * fTemp32; + float fTemp33 = 8.77193e-05f * fTemp2; + float fTemp34 = std::tan(std::max(0.0f, std::min(fConst1 * (7e+02f + 0.6f * fTemp0), 1.5676547f))); + float fTemp35 = fRec11[1] + fTemp34 * (fTemp5 + fRec11[1] * (-0.6666667f - fTemp34) - fRec12[1]) * std::min(3.4028235e+38f, 1.0f / (1.0f + fTemp34 * (0.6666667f + fTemp34))); + fRec11[0] = 2.0f * fTemp35 - fRec11[1]; + fRec12[0] = 2.0f * (fRec12[1] + fTemp34 * fTemp35) - fRec12[1]; + float fTemp36 = fConst11 * fTemp8; + float fTemp37 = 1.0737418e+09f * (fTemp36 - std::rint(fTemp36)); + float fTemp38 = std::floor(fTemp37); + int iTemp39 = faust_wrap_add(iRec15[1], static_cast(16777216.0f * (fTemp37 - fTemp38))); + iRec15[0] = ((iTemp17) ? 0 : iTemp39 & 16777215); + iRec14[0] = ((iTemp17) ? 0 : (faust_wrap_add(faust_wrap_add(iRec14[1], static_cast(fTemp38)), iTemp39 >> 24)) & 1073741823); + float fTemp40 = fRec16[1] + fConst13 * (fTemp5 + fConst14 * fRec16[1] - fRec17[1]); + fRec16[0] = 2.0f * fTemp40 - fRec16[1]; + fRec17[0] = 2.0f * (fRec17[1] + fConst12 * fTemp40) - fRec17[1]; + float fTemp41 = fRec18[1] + fConst16 * (fTemp5 + fConst17 * fRec18[1] - fRec19[1]); + fRec18[0] = 2.0f * fTemp41 - fRec18[1]; + fRec19[0] = 2.0f * (fRec19[1] + fConst15 * fTemp41) - fRec19[1]; + float fTemp42 = fRec20[1] + fConst19 * (fTemp5 + fConst20 * fRec20[1] - fRec21[1]); + fRec20[0] = 2.0f * fTemp42 - fRec20[1]; + fRec21[0] = 2.0f * (fRec21[1] + fConst18 * fTemp42) - fRec21[1]; + float fTemp43 = fRec22[1] + fConst22 * (fTemp5 + fConst23 * fRec22[1] - fRec23[1]); + fRec22[0] = 2.0f * fTemp43 - fRec22[1]; + fRec23[0] = 2.0f * (fRec23[1] + fConst21 * fTemp43) - fRec23[1]; + output0[i0] = static_cast(0.425f * tanhf(((fRec1[1] + fTemp32) * (0.5f + fTemp33) + 0.5f * fTemp35 * (1.0f + ThrusterDsp_faustpower2_f(ftbl0ThrusterDspSIG0[std::max(0, std::min(static_cast(0.00390625f * static_cast(iRec14[0] >> 6)), 65535))])) * (0.05f + 0.00030701753f * fTemp2) + 0.25f * tanhf(12.0f * (fTemp40 * (0.3f + 0.00012280702f * fTemp2) + 0.8f * fTemp41 + 0.6f * fTemp42 + 0.4f * fTemp43) * (0.015f + 0.985f * ThrusterDsp_faustpower2_f(fTemp3)))) * (0.4f + 0.000105263156f * fTemp2) * (0.9f - fTemp33))); + iVec0[1] = iVec0[0]; + fVec1[1] = fVec1[0]; + fRec2[1] = fRec2[0]; + iRec6[1] = iRec6[0]; + fRec4[1] = fRec4[0]; + fRec5[1] = fRec5[0]; + iRec8[1] = iRec8[0]; + iRec7[1] = iRec7[0]; + iRec10[1] = iRec10[0]; + iRec9[1] = iRec9[0]; + fVec2[1] = fVec2[0]; + IOTA0 = faust_wrap_add(IOTA0, 1); + fRec3[1] = fRec3[0]; + fRec0[1] = fRec0[0]; + fRec1[1] = fRec1[0]; + fRec11[1] = fRec11[0]; + fRec12[1] = fRec12[0]; + iRec15[1] = iRec15[0]; + iRec14[1] = iRec14[0]; + fRec16[1] = fRec16[0]; + fRec17[1] = fRec17[0]; + fRec18[1] = fRec18[0]; + fRec19[1] = fRec19[0]; + fRec20[1] = fRec20[0]; + fRec21[1] = fRec21[0]; + fRec22[1] = fRec22[0]; + fRec23[1] = fRec23[0]; + } + } + +}; + +#endif From 5d724f5f5b41db258b2308bb15e78466ea3ccb6c Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 6 Nov 2026 23:21:13 +0000 Subject: [PATCH 025/124] spike: drop stray generated header (run.sh generates it into build/) Co-Authored-By: Claude Sonnet 5.5 --- spikes/faust-aot-thruster/thruster_dsp.h | 474 ----------------------- 1 file changed, 474 deletions(-) delete mode 100644 spikes/faust-aot-thruster/thruster_dsp.h diff --git a/spikes/faust-aot-thruster/thruster_dsp.h b/spikes/faust-aot-thruster/thruster_dsp.h deleted file mode 100644 index 4d1c225..0000000 --- a/spikes/faust-aot-thruster/thruster_dsp.h +++ /dev/null @@ -1,474 +0,0 @@ -/* ------------------------------------------------------------ -name: "thruster" -Code generated with Faust 2.90.20 (https://faust.grame.fr) -Compilation options: -lang cpp -i -fpga-mem-th 4 -ct 1 -cn ThrusterDsp -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0 ------------------------------------------------------------- */ - -#ifndef __ThrusterDsp_H__ -#define __ThrusterDsp_H__ - -#ifndef FAUSTFLOAT -#define FAUSTFLOAT float -#endif - -/* link with : "" */ -#include -#include -#include -#include -#ifndef FAUST_INT_WRAP -#define FAUST_INT_WRAP -inline int faust_wrap_add(int a, int b) { return int((unsigned int)a + (unsigned int)b); } -inline int faust_wrap_sub(int a, int b) { return int((unsigned int)a - (unsigned int)b); } -inline int faust_wrap_mul(int a, int b) { return int((unsigned int)a * (unsigned int)b); } -#endif - - -#ifndef FAUSTCLASS -#define FAUSTCLASS ThrusterDsp -#endif - -#ifdef __APPLE__ -#define exp10f __exp10f -#define exp10 __exp10 -#endif - -#if defined(_WIN32) -#define RESTRICT __restrict -#else -#define RESTRICT __restrict__ -#endif - -class ThrusterDspSIG0 { - - private: - - int iVec4[2]; - int iRec13[2]; - int fSampleRate; - - public: - - int getNumInputsThrusterDspSIG0() { - return 0; - } - int getNumOutputsThrusterDspSIG0() { - return 1; - } - - void instanceInitThrusterDspSIG0(int sample_rate) { - fSampleRate = sample_rate; - for (int l17 = 0; l17 < 2; l17 = faust_wrap_add(l17, 1)) { - iVec4[l17] = 0; - } - for (int l18 = 0; l18 < 2; l18 = faust_wrap_add(l18, 1)) { - iRec13[l18] = 0; - } - } - - void fillThrusterDspSIG0(int count, float* table) { - for (int i1 = 0; i1 < count; i1 = faust_wrap_add(i1, 1)) { - iVec4[0] = 1; - iRec13[0] = (faust_wrap_add(iVec4[1], iRec13[1])) % 65536; - table[i1] = std::sin(9.58738e-05f * static_cast(iRec13[0])); - iVec4[1] = iVec4[0]; - iRec13[1] = iRec13[0]; - } - } - -}; - -static ThrusterDspSIG0* newThrusterDspSIG0() { return (ThrusterDspSIG0*)new ThrusterDspSIG0(); } -static void deleteThrusterDspSIG0(ThrusterDspSIG0* dsp) { delete dsp; } - -static float ThrusterDsp_faustpower2_f(float value_f) { - return value_f * value_f; -} -static float ftbl0ThrusterDspSIG0[65536]; - -class ThrusterDsp : public dsp { - - private: - - int iVec0[2]; - int fSampleRate; - float fConst0; - float fConst1; - FAUSTFLOAT fHslider0; - float fVec1[2]; - float fConst2; - float fRec2[2]; - float fConst3; - float fConst4; - float fConst5; - float fConst6; - float fConst7; - int iRec6[2]; - float fRec4[2]; - float fConst8; - float fRec5[2]; - int iRec8[2]; - int iRec7[2]; - float fConst9; - int iRec10[2]; - int iRec9[2]; - float fVec2[2]; - int IOTA0; - float fVec3[4096]; - float fConst10; - float fRec3[2]; - float fRec0[2]; - float fRec1[2]; - float fRec11[2]; - float fRec12[2]; - float fConst11; - int iRec15[2]; - int iRec14[2]; - float fConst12; - float fConst13; - float fConst14; - float fRec16[2]; - float fRec17[2]; - float fConst15; - float fConst16; - float fConst17; - float fRec18[2]; - float fRec19[2]; - float fConst18; - float fConst19; - float fConst20; - float fRec20[2]; - float fRec21[2]; - float fConst21; - float fConst22; - float fConst23; - float fRec22[2]; - float fRec23[2]; - - public: - ThrusterDsp() { - } - - ThrusterDsp(const ThrusterDsp&) = default; - - virtual ~ThrusterDsp() = default; - - ThrusterDsp& operator=(const ThrusterDsp&) = default; - - void metadata(Meta* m) { - m->declare("basics.lib/name", "Faust Basic Element Library"); - m->declare("basics.lib/version", "1.23.9"); - m->declare("compile_options", "-lang cpp -i -fpga-mem-th 4 -ct 1 -cn ThrusterDsp -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0"); - m->declare("filename", "thruster.dsp"); - m->declare("filters.lib/_tanhalf:author", "Julius O. Smith III"); - m->declare("filters.lib/_tanhalf:license", "MIT"); - m->declare("filters.lib/lowpass0_highpass1:author", "Julius O. Smith III"); - m->declare("filters.lib/lowpass0_highpass1:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); - m->declare("filters.lib/lowpass0_highpass1:license", "LicenseRef-STK-4.3"); - m->declare("filters.lib/lowpass:author", "Julius O. Smith III"); - m->declare("filters.lib/lowpass:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); - m->declare("filters.lib/lowpass:license", "LicenseRef-STK-4.3"); - m->declare("filters.lib/name", "Faust Filters Library"); - m->declare("filters.lib/resonbp:author", "Julius O. Smith III"); - m->declare("filters.lib/resonbp:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); - m->declare("filters.lib/resonbp:license", "LicenseRef-STK-4.3"); - m->declare("filters.lib/svf:author", "Oleg Nesterov"); - m->declare("filters.lib/svf:copyright", "Copyright (C) 2020 Oleg Nesterov "); - m->declare("filters.lib/svf:license", "LicenseRef-STK-4.3"); - m->declare("filters.lib/tf1s:author", "Julius O. Smith III"); - m->declare("filters.lib/tf1s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); - m->declare("filters.lib/tf1s:license", "LicenseRef-STK-4.3"); - m->declare("filters.lib/tf2s:author", "Julius O. Smith III"); - m->declare("filters.lib/tf2s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III "); - m->declare("filters.lib/tf2s:license", "LicenseRef-STK-4.3"); - m->declare("filters.lib/version", "1.13.4"); - m->declare("maths.lib/author", "GRAME"); - m->declare("maths.lib/copyright", "GRAME"); - m->declare("maths.lib/license", "LicenseRef-LGPL-2.1-or-later-with-Faust-exception"); - m->declare("maths.lib/name", "Faust Math Library"); - m->declare("maths.lib/version", "2.9.5"); - m->declare("name", "thruster"); - m->declare("noises.lib/name", "Faust Noise Generator Library"); - m->declare("noises.lib/version", "1.9.2"); - m->declare("oscillators.lib/lf_sawpos:author", "Bart Brouns, revised by Stéphane Letz"); - m->declare("oscillators.lib/lf_sawpos:licence", "LicenseRef-STK-4.3"); - m->declare("oscillators.lib/name", "Faust Oscillator Library"); - m->declare("oscillators.lib/saw2ptr:author", "Julius O. Smith III"); - m->declare("oscillators.lib/saw2ptr:license", "LicenseRef-STK-4.3"); - m->declare("oscillators.lib/sawN:author", "Julius O. Smith III"); - m->declare("oscillators.lib/sawN:license", "LicenseRef-STK-4.3"); - m->declare("oscillators.lib/version", "1.9.6"); - m->declare("platform.lib/name", "Generic Platform Library"); - m->declare("platform.lib/version", "1.3.2"); - m->declare("routes.lib/name", "Faust Signal Routing Library"); - m->declare("routes.lib/version", "1.4.1"); - m->declare("signals.lib/name", "Faust Routing Library"); - m->declare("signals.lib/version", "1.8.2"); - } - - virtual int getNumInputs() { - return 0; - } - virtual int getNumOutputs() { - return 1; - } - - static void classInit(int sample_rate) { - ThrusterDspSIG0* sig0 = newThrusterDspSIG0(); - sig0->instanceInitThrusterDspSIG0(sample_rate); - sig0->fillThrusterDspSIG0(65536, ftbl0ThrusterDspSIG0); - deleteThrusterDspSIG0(sig0); - } - - virtual void instanceConstants(int sample_rate) { - fSampleRate = sample_rate; - fConst0 = std::min(1.92e+05f, std::max(5e+01f, static_cast(fSampleRate))); - fConst1 = 3.1415927f / fConst0; - fConst2 = std::exp(-(5.0f / fConst0)); - fConst3 = 1.0f / fConst0; - fConst4 = std::tan(std::max(0.0f, std::min(15.707963f / fConst0, 1.5676547f))); - fConst5 = fConst4 + 1.4142135f; - fConst6 = fConst4 * std::min(3.4028235e+38f, 1.0f / (fConst4 * fConst5 + 1.0f)); - fConst7 = 2.0f * fConst6; - fConst8 = 2.0f * fConst4; - fConst9 = 0.175f * fConst0; - fConst10 = 0.5f * fConst0; - fConst11 = 3.0f / fConst0; - fConst12 = std::tan(std::max(0.0f, std::min(543.49554f / fConst0, 1.5676547f))); - fConst13 = fConst12 * std::min(3.4028235e+38f, 1.0f / (fConst12 * (fConst12 + 0.05f) + 1.0f)); - fConst14 = -0.05f - fConst12; - fConst15 = std::tan(std::max(0.0f, std::min(977.03534f / fConst0, 1.5676547f))); - fConst16 = fConst15 * std::min(3.4028235e+38f, 1.0f / (fConst15 * (fConst15 + 0.055555556f) + 1.0f)); - fConst17 = -0.055555556f - fConst15; - fConst18 = std::tan(std::max(0.0f, std::min(1467.1238f / fConst0, 1.5676547f))); - fConst19 = fConst18 * std::min(3.4028235e+38f, 1.0f / (fConst18 * (fConst18 + 0.0625f) + 1.0f)); - fConst20 = -0.0625f - fConst18; - fConst21 = std::tan(std::max(0.0f, std::min(3549.9998f / fConst0, 1.5676547f))); - fConst22 = fConst21 * std::min(3.4028235e+38f, 1.0f / (fConst21 * (fConst21 + 0.071428575f) + 1.0f)); - fConst23 = -0.071428575f - fConst21; - } - - virtual void instanceResetUserInterface() { - fHslider0 = static_cast(1.2e+03f); - } - - virtual void instanceClear() { - for (int l0 = 0; l0 < 2; l0 = faust_wrap_add(l0, 1)) { - iVec0[l0] = 0; - } - for (int l1 = 0; l1 < 2; l1 = faust_wrap_add(l1, 1)) { - fVec1[l1] = 0.0f; - } - for (int l2 = 0; l2 < 2; l2 = faust_wrap_add(l2, 1)) { - fRec2[l2] = 0.0f; - } - for (int l3 = 0; l3 < 2; l3 = faust_wrap_add(l3, 1)) { - iRec6[l3] = 0; - } - for (int l4 = 0; l4 < 2; l4 = faust_wrap_add(l4, 1)) { - fRec4[l4] = 0.0f; - } - for (int l5 = 0; l5 < 2; l5 = faust_wrap_add(l5, 1)) { - fRec5[l5] = 0.0f; - } - for (int l6 = 0; l6 < 2; l6 = faust_wrap_add(l6, 1)) { - iRec8[l6] = 0; - } - for (int l7 = 0; l7 < 2; l7 = faust_wrap_add(l7, 1)) { - iRec7[l7] = 0; - } - for (int l8 = 0; l8 < 2; l8 = faust_wrap_add(l8, 1)) { - iRec10[l8] = 0; - } - for (int l9 = 0; l9 < 2; l9 = faust_wrap_add(l9, 1)) { - iRec9[l9] = 0; - } - for (int l10 = 0; l10 < 2; l10 = faust_wrap_add(l10, 1)) { - fVec2[l10] = 0.0f; - } - IOTA0 = 0; - for (int l11 = 0; l11 < 4096; l11 = faust_wrap_add(l11, 1)) { - fVec3[l11] = 0.0f; - } - for (int l12 = 0; l12 < 2; l12 = faust_wrap_add(l12, 1)) { - fRec3[l12] = 0.0f; - } - for (int l13 = 0; l13 < 2; l13 = faust_wrap_add(l13, 1)) { - fRec0[l13] = 0.0f; - } - for (int l14 = 0; l14 < 2; l14 = faust_wrap_add(l14, 1)) { - fRec1[l14] = 0.0f; - } - for (int l15 = 0; l15 < 2; l15 = faust_wrap_add(l15, 1)) { - fRec11[l15] = 0.0f; - } - for (int l16 = 0; l16 < 2; l16 = faust_wrap_add(l16, 1)) { - fRec12[l16] = 0.0f; - } - for (int l19 = 0; l19 < 2; l19 = faust_wrap_add(l19, 1)) { - iRec15[l19] = 0; - } - for (int l20 = 0; l20 < 2; l20 = faust_wrap_add(l20, 1)) { - iRec14[l20] = 0; - } - for (int l21 = 0; l21 < 2; l21 = faust_wrap_add(l21, 1)) { - fRec16[l21] = 0.0f; - } - for (int l22 = 0; l22 < 2; l22 = faust_wrap_add(l22, 1)) { - fRec17[l22] = 0.0f; - } - for (int l23 = 0; l23 < 2; l23 = faust_wrap_add(l23, 1)) { - fRec18[l23] = 0.0f; - } - for (int l24 = 0; l24 < 2; l24 = faust_wrap_add(l24, 1)) { - fRec19[l24] = 0.0f; - } - for (int l25 = 0; l25 < 2; l25 = faust_wrap_add(l25, 1)) { - fRec20[l25] = 0.0f; - } - for (int l26 = 0; l26 < 2; l26 = faust_wrap_add(l26, 1)) { - fRec21[l26] = 0.0f; - } - for (int l27 = 0; l27 < 2; l27 = faust_wrap_add(l27, 1)) { - fRec22[l27] = 0.0f; - } - for (int l28 = 0; l28 < 2; l28 = faust_wrap_add(l28, 1)) { - fRec23[l28] = 0.0f; - } - } - - virtual void init(int sample_rate) { - classInit(sample_rate); - instanceInit(sample_rate); - } - - virtual void instanceInit(int sample_rate) { - instanceConstants(sample_rate); - instanceResetUserInterface(); - instanceClear(); - } - - virtual ThrusterDsp* clone() { - return new ThrusterDsp(*this); - } - - virtual int getSampleRate() { - return fSampleRate; - } - - virtual void buildUserInterface(UI* ui_interface) { - ui_interface->openVerticalBox("thruster"); - ui_interface->addHorizontalSlider("rpm", &fHslider0, FAUSTFLOAT(1.2e+03f), FAUSTFLOAT(3e+02f), FAUSTFLOAT(6e+03f), FAUSTFLOAT(1.0f)); - ui_interface->closeBox(); - } - - virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { - FAUSTFLOAT* output0 = outputs[0]; - float fSlow0 = static_cast(fHslider0); - float fSlow1 = fSlow0 + -3e+02f; - for (int i0 = 0; i0 < count; i0 = faust_wrap_add(i0, 1)) { - iVec0[0] = 1; - fVec1[0] = fSlow0; - fRec2[0] = fConst2 * (std::min(3.4028235e+38f, fVec1[1] - fSlow0) + fRec2[1]); - float fTemp0 = fSlow0 + fRec2[0]; - float fTemp1 = 28.0f + 0.025f * fTemp0; - float fTemp2 = fSlow1 + fRec2[0]; - float fTemp3 = 0.0001754386f * fTemp2; - float fTemp4 = std::tan(std::max(0.0f, std::min(fConst1 * (6e+01f + 2.5f * fTemp1 + 1.4e+02f * (1.0f - fTemp3)), 1.5676547f))); - iRec6[0] = faust_wrap_add(12345, faust_wrap_mul(1103515245, iRec6[1])); - float fTemp5 = 4.656613e-10f * static_cast(iRec6[0]); - float fTemp6 = fTemp5 - (fConst5 * fRec4[1] + fRec5[1]); - fRec4[0] = fRec4[1] + fConst7 * fTemp6; - float fTemp7 = fRec4[1] + fConst6 * fTemp6; - fRec5[0] = fRec5[1] + fConst8 * fTemp7; - float fTemp8 = fTemp1 * (1.0f + 0.014f * (fRec5[1] + fConst4 * fTemp7)); - float fTemp9 = std::fabs(fTemp8); - float fTemp10 = fConst3 * fTemp9; - float fTemp11 = 1.0737418e+09f * (fTemp10 - std::floor(fTemp10)); - float fTemp12 = std::floor(fTemp11); - int iTemp13 = faust_wrap_add(iRec8[1], static_cast(16777216.0f * (fTemp11 - fTemp12))); - iRec8[0] = iTemp13 & 16777215; - int iTemp14 = faust_wrap_add(faust_wrap_add(iRec7[1], static_cast(fTemp12)), iTemp13 >> 24); - int iTemp15 = iTemp14 & 1073741823; - iRec7[0] = iTemp15; - float fTemp16 = static_cast(iTemp15); - int iTemp17 = faust_wrap_sub(1, iVec0[1]); - float fTemp18 = std::max(0.5f * fTemp8, 23.44895f); - float fTemp19 = std::max(2e+01f, std::fabs(fTemp18)); - float fTemp20 = fConst3 * fTemp19; - float fTemp21 = 1.0737418e+09f * (fTemp20 - std::rint(fTemp20)); - float fTemp22 = std::floor(fTemp21); - int iTemp23 = faust_wrap_add(iRec10[1], static_cast(16777216.0f * (fTemp21 - fTemp22))); - iRec10[0] = ((iTemp17) ? 0 : iTemp23 & 16777215); - iRec9[0] = ((iTemp17) ? 0 : (faust_wrap_add(faust_wrap_add(iRec9[1], static_cast(fTemp22)), iTemp23 >> 24)) & 1073741823); - float fTemp24 = ThrusterDsp_faustpower2_f(-1.0f + 1.1920929e-07f * static_cast(iRec9[0] >> 6)); - fVec2[0] = fTemp24; - float fTemp25 = static_cast(iVec0[1]) * (fTemp24 - fVec2[1]) / fTemp19; - fVec3[IOTA0 & 4095] = fTemp25; - float fTemp26 = std::max(0.0f, std::min(8191.0f, fConst10 / fTemp18)); - int iTemp27 = static_cast(fTemp26); - float fTemp28 = std::floor(fTemp26); - float fTemp29 = 1.0f + fTemp4; - float fTemp30 = fTemp4 * (-1.0f - (fTemp10 + fRec3[1]) + 2.0f * ((iTemp14 > 1073741823) ? 1.0f + 9.313226e-10f * fTemp16 * (1.0f - fConst0 / std::max(1.1920929e-07f, fTemp9)) : 9.313226e-10f * fTemp16) + fConst9 * (fTemp25 - fVec3[(faust_wrap_sub(IOTA0, iTemp27)) & 4095] * (1.0f - fTemp26 + fTemp28) - (fTemp26 - fTemp28) * fVec3[(faust_wrap_sub(IOTA0, faust_wrap_add(1, iTemp27))) & 4095])) * std::min(3.4028235e+38f, 1.0f / fTemp29); - fRec3[0] = fRec3[1] + 2.0f * fTemp30; - float fTemp31 = fTemp4 * (fRec3[1] + fTemp30 - (fTemp29 * fRec0[1] + fRec1[1])) * std::min(3.4028235e+38f, 1.0f / (1.0f + fTemp4 * fTemp29)); - fRec0[0] = fRec0[1] + 2.0f * fTemp31; - float fTemp32 = fTemp4 * (fRec0[1] + fTemp31); - fRec1[0] = fRec1[1] + 2.0f * fTemp32; - float fTemp33 = 8.77193e-05f * fTemp2; - float fTemp34 = std::tan(std::max(0.0f, std::min(fConst1 * (7e+02f + 0.6f * fTemp0), 1.5676547f))); - float fTemp35 = fRec11[1] + fTemp34 * (fTemp5 + fRec11[1] * (-0.6666667f - fTemp34) - fRec12[1]) * std::min(3.4028235e+38f, 1.0f / (1.0f + fTemp34 * (0.6666667f + fTemp34))); - fRec11[0] = 2.0f * fTemp35 - fRec11[1]; - fRec12[0] = 2.0f * (fRec12[1] + fTemp34 * fTemp35) - fRec12[1]; - float fTemp36 = fConst11 * fTemp8; - float fTemp37 = 1.0737418e+09f * (fTemp36 - std::rint(fTemp36)); - float fTemp38 = std::floor(fTemp37); - int iTemp39 = faust_wrap_add(iRec15[1], static_cast(16777216.0f * (fTemp37 - fTemp38))); - iRec15[0] = ((iTemp17) ? 0 : iTemp39 & 16777215); - iRec14[0] = ((iTemp17) ? 0 : (faust_wrap_add(faust_wrap_add(iRec14[1], static_cast(fTemp38)), iTemp39 >> 24)) & 1073741823); - float fTemp40 = fRec16[1] + fConst13 * (fTemp5 + fConst14 * fRec16[1] - fRec17[1]); - fRec16[0] = 2.0f * fTemp40 - fRec16[1]; - fRec17[0] = 2.0f * (fRec17[1] + fConst12 * fTemp40) - fRec17[1]; - float fTemp41 = fRec18[1] + fConst16 * (fTemp5 + fConst17 * fRec18[1] - fRec19[1]); - fRec18[0] = 2.0f * fTemp41 - fRec18[1]; - fRec19[0] = 2.0f * (fRec19[1] + fConst15 * fTemp41) - fRec19[1]; - float fTemp42 = fRec20[1] + fConst19 * (fTemp5 + fConst20 * fRec20[1] - fRec21[1]); - fRec20[0] = 2.0f * fTemp42 - fRec20[1]; - fRec21[0] = 2.0f * (fRec21[1] + fConst18 * fTemp42) - fRec21[1]; - float fTemp43 = fRec22[1] + fConst22 * (fTemp5 + fConst23 * fRec22[1] - fRec23[1]); - fRec22[0] = 2.0f * fTemp43 - fRec22[1]; - fRec23[0] = 2.0f * (fRec23[1] + fConst21 * fTemp43) - fRec23[1]; - output0[i0] = static_cast(0.425f * tanhf(((fRec1[1] + fTemp32) * (0.5f + fTemp33) + 0.5f * fTemp35 * (1.0f + ThrusterDsp_faustpower2_f(ftbl0ThrusterDspSIG0[std::max(0, std::min(static_cast(0.00390625f * static_cast(iRec14[0] >> 6)), 65535))])) * (0.05f + 0.00030701753f * fTemp2) + 0.25f * tanhf(12.0f * (fTemp40 * (0.3f + 0.00012280702f * fTemp2) + 0.8f * fTemp41 + 0.6f * fTemp42 + 0.4f * fTemp43) * (0.015f + 0.985f * ThrusterDsp_faustpower2_f(fTemp3)))) * (0.4f + 0.000105263156f * fTemp2) * (0.9f - fTemp33))); - iVec0[1] = iVec0[0]; - fVec1[1] = fVec1[0]; - fRec2[1] = fRec2[0]; - iRec6[1] = iRec6[0]; - fRec4[1] = fRec4[0]; - fRec5[1] = fRec5[0]; - iRec8[1] = iRec8[0]; - iRec7[1] = iRec7[0]; - iRec10[1] = iRec10[0]; - iRec9[1] = iRec9[0]; - fVec2[1] = fVec2[0]; - IOTA0 = faust_wrap_add(IOTA0, 1); - fRec3[1] = fRec3[0]; - fRec0[1] = fRec0[0]; - fRec1[1] = fRec1[0]; - fRec11[1] = fRec11[0]; - fRec12[1] = fRec12[0]; - iRec15[1] = iRec15[0]; - iRec14[1] = iRec14[0]; - fRec16[1] = fRec16[0]; - fRec17[1] = fRec17[0]; - fRec18[1] = fRec18[0]; - fRec19[1] = fRec19[0]; - fRec20[1] = fRec20[0]; - fRec21[1] = fRec21[0]; - fRec22[1] = fRec22[0]; - fRec23[1] = fRec23[0]; - } - } - -}; - -#endif From 9c3ae654ca464a2f94748fd66be462a8fda55003 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 01:24:09 +0000 Subject: [PATCH 026/124] docs: mark spike max block time unexplained; spike is a bare C loop, not a player Co-Authored-By: Claude Sonnet 5.5 --- docs/faust-unity-player-scoping.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/faust-unity-player-scoping.md b/docs/faust-unity-player-scoping.md index 994b2e9..9313cb3 100644 --- a/docs/faust-unity-player-scoping.md +++ b/docs/faust-unity-player-scoping.md @@ -250,8 +250,15 @@ including at the worst rpm sweep, under CPU load. Nothing here has been run. (`FaustPlugin_template.cs` `getBufferSize`). Test 256, 512, 1024 frames at 44.1 k and 48 k (the render manifest uses 48 k / 512, i.e. D = 10.67 ms). Proposed pass line: p99.9 under 25% of D, max under 50% of D (Aqua's ruling, 2026-11-07). The spike's -shared-host outliers (max 10.8-17.1 ms, 4-5 blocks over deadline) mean the max line can only -be judged on a quiet host; a max miss on a loaded host is not a verdict. +shared-host outliers (max 10.8-17.1 ms, 4-5 blocks over deadline) are **unexplained**: the spike +(`spikes/faust-aot-thruster/`) shows they are not per-block DSP cost (an empty timed busy-wait stalls +the same way), but not what causes them. Until a quiet or realtime host explains or removes them, the +max line has no verdict from this host. + +**What the spike measures, and what it does not.** It times a bare C loop calling the compiled +`process` back to back on Linux. That shows the patch is cheap (median 0.05 ms against 10.67 ms). It +does not show that a Unity player meets its deadline: the player's audio thread, the managed-to-native +transition, IL2CPP, mixer and other DSP sharing the callback, and Windows scheduling are all absent. **What to time.** From e4c6b2d3b336f978223415f05ebd9f3fa6ae4102 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 01:24:21 +0000 Subject: [PATCH 027/124] spike: pin cores, per-overrun wall timestamps, noop control; max block time marked unexplained Co-Authored-By: Claude Sonnet 5.5 --- spikes/faust-aot-thruster/README.md | 35 ++++++++++++++++++---- spikes/faust-aot-thruster/bench_thruster.c | 33 ++++++++++++++++---- spikes/faust-aot-thruster/run.sh | 10 +++++-- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/spikes/faust-aot-thruster/README.md b/spikes/faust-aot-thruster/README.md index f78a9be..885fa67 100644 --- a/spikes/faust-aot-thruster/README.md +++ b/spikes/faust-aot-thruster/README.md @@ -12,15 +12,38 @@ Limitation: AOT fixes the patch set at build time, so player-authored patches ca `aqs_thruster_process` rejects NULL, negative or >`AQS_MAX_BLOCK` frames instead of truncating. - `test_thruster.c`: plain-C behaviour test (bounds, clamp, NaN, inf, hostile values give finite bounded output, rpm actually changes the output, instances are deterministic). A flipped clamp bound fails it. -- `bench_thruster.c`: per-block `process` time at 48 kHz / 512 frames against the 10.667 ms deadline. +- `bench_thruster.c`: per-block `process` time at 48 kHz / 512 frames against the 10.667 ms deadline; prints one `OVERRUN` line + per block over the deadline with wall-clock timestamp, wall ms and thread CPU ms. - `run.sh`: generate, build, test, bench. `FAUST`, `FAUST_PREFIX` (needs `include/faust`), `FAUST_LIBS` - (needs `stdfaust.lib`), `BLOCKS`, `RATE`, `FRAMES` override defaults. Exit status is test status; timing + (needs `stdfaust.lib`), `BLOCKS`, `RATE`, `FRAMES`, `CORE` (pin the bench to one cpu via `taskset`), `NOOP=1` (time a busy-wait + instead of the patch) override defaults. Exit status is test status; timing is reported, not gated. -Measured 2026-11-06, Faust 2.90.20, AMD EPYC-Genoa, shared Linux host, 20000 blocks, 3 runs: -median 0.052 ms (0.49% of deadline), p99 0.10-0.16 ms (~1-1.5%), max 10.8-17.1 ms (4-5 blocks of 20000 over -the deadline). The max is a scheduler preemption on a shared host, not DSP cost (median and p99 are -two orders under the deadline); a quiet or realtime-priority host is needed to say anything about the max. +**Scope: this measures a bare C loop.** `bench_thruster` calls `aqs_thruster_process` back to back on one +Linux thread. It shows the patch is cheap, not that a Unity player meets its deadline (no Unity audio +thread, P/Invoke, IL2CPP, mixer or Windows scheduling in it). + +Measured 2026-11-06/07, Faust 2.90.20, AMD EPYC-Genoa, shared Linux host (load average ~8 on 16 cores): +median 0.052 ms (0.49% of the 10.667 ms deadline), p99 0.08-0.16 ms (~1-1.5%). Cheap: that part is +reliable. + +**Max block time: UNEXPLAINED. It is not a pass.** Max was 10.8-17.1 ms, with 1-5 of 20000 blocks over +the deadline per run (70-74 of 400000). What the instrumented runs (`run.sh`, `CORE=` pins with +`taskset`; every overrun prints a `wall_unix` timestamp, wall ms and thread CPU ms) do show: + +- Not per-block DSP cost: `NOOP=1` times a 0.05 ms busy-wait instead of `process`, and stalls the same + way (core 3, 400000 blocks: 74 overruns with `process`, 67 with the busy-wait, both ~11 ms). +- Not a DSP-state pattern: overrun block indices differ every run and are not tied to the rpm sweep. +- Periodic in wall time, per core: pinned to core 3, overruns recur every ~0.3-0.4 s (mostly); pinned + to core 9, every ~1-2 s (17 in 400000 blocks). Unpinned runs get 1-5 per 20000. +- The thread's CPU time over a stalled block is about equal to its wall time (e.g. 10.84 vs 10.85 ms), + so the stall is charged to the thread rather than showing as time off-CPU. Ordinary run-queue + preemption would not look like that. The earlier claim that these were scheduler preemption is + withdrawn. + +Cause not identified (candidates: hypervisor/container CPU accounting, per-core host timer or housekeeping +work, SMI; none tested). Whether the player would see it is unknown. A quiet, realtime-priority or +isolated-core host is needed before the max can be called anything. **Unverified:** Windows (MSVC build, `__declspec(dllexport)`), Unity P/Invoke, IL2CPP, the Unity audio thread, any device. Nothing here ran inside Unity. diff --git a/spikes/faust-aot-thruster/bench_thruster.c b/spikes/faust-aot-thruster/bench_thruster.c index bf602b3..202df60 100644 --- a/spikes/faust-aot-thruster/bench_thruster.c +++ b/spikes/faust-aot-thruster/bench_thruster.c @@ -1,4 +1,7 @@ -/* Per-block callback time vs deadline. usage: bench_thruster [blocks] [rate] [frames] */ +/* Per-block callback time vs deadline. usage: bench_thruster [blocks] [rate] [frames] [noop] + noop: time a 0.05 ms busy-wait instead of process(), to tell host stalls from DSP cost */ +#define _GNU_SOURCE +#include #include #include #include @@ -10,29 +13,47 @@ int main(int argc, char** argv) { int blocks = argc > 1 ? atoi(argv[1]) : 20000; int rate = argc > 2 ? atoi(argv[2]) : 48000; int frames = argc > 3 ? atoi(argv[3]) : 512; + int noop = argc > 4; aqs_thruster* t = aqs_thruster_create(rate); if (!t || blocks < 100) return 2; float* out = malloc(sizeof(float) * frames); double* ms = malloc(sizeof(double) * blocks); + double* cpu = malloc(sizeof(double) * blocks); /* thread CPU time per block: wall >> cpu means preempted, not DSP */ + double* wall = malloc(sizeof(double) * blocks); /* CLOCK_REALTIME at block end, seconds, for lining up with host load */ const int warm = 200; for (int i = 0; i < warm + blocks; ++i) { /* sweep rpm across its whole range so the smoother and filters keep moving */ aqs_thruster_set_rpm(t, 300.f + 5700.f * (0.5f + 0.5f * (float)((i % 997) - 498) / 498.f)); - struct timespec a, b; + struct timespec a, b, ca, cb, w; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ca); clock_gettime(CLOCK_MONOTONIC, &a); - aqs_thruster_process(t, out, frames); + if (noop) { struct timespec s; do clock_gettime(CLOCK_MONOTONIC, &s); while ((s.tv_sec - a.tv_sec) * 1e9 + (s.tv_nsec - a.tv_nsec) < 5e4); } + else aqs_thruster_process(t, out, frames); clock_gettime(CLOCK_MONOTONIC, &b); - if (i >= warm) ms[i - warm] = (b.tv_sec - a.tv_sec) * 1e3 + (b.tv_nsec - a.tv_nsec) / 1e6; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &cb); + clock_gettime(CLOCK_REALTIME, &w); + if (i >= warm) { + ms[i - warm] = (b.tv_sec - a.tv_sec) * 1e3 + (b.tv_nsec - a.tv_nsec) / 1e6; + cpu[i - warm] = (cb.tv_sec - ca.tv_sec) * 1e3 + (cb.tv_nsec - ca.tv_nsec) / 1e6; + wall[i - warm] = w.tv_sec + w.tv_nsec / 1e9; + } } double deadline = 1e3 * frames / rate, sum = 0; int over = 0; - for (int i = 0; i < blocks; ++i) { sum += ms[i]; if (ms[i] > deadline) ++over; } + printf("start_cpu=%d\n", sched_getcpu()); + for (int i = 0; i < blocks; ++i) { + sum += ms[i]; + if (ms[i] > deadline) { + ++over; + printf("OVERRUN block=%d wall_unix=%.6f wall_ms=%.4f thread_cpu_ms=%.4f\n", i, wall[i], ms[i], cpu[i]); + } + } qsort(ms, blocks, sizeof *ms, cmp); double med = ms[blocks / 2], p99 = ms[(int)(blocks * 0.99)], mx = ms[blocks - 1]; printf("rate=%d frames=%d blocks=%d deadline_ms=%.4f\n", rate, frames, blocks, deadline); printf("median_ms=%.4f p99_ms=%.4f max_ms=%.4f mean_ms=%.4f\n", med, p99, mx, sum / blocks); printf("median_pct_deadline=%.2f p99_pct_deadline=%.2f max_pct_deadline=%.2f over_deadline=%d\n", 100 * med / deadline, 100 * p99 / deadline, 100 * mx / deadline, over); - free(out); free(ms); aqs_thruster_destroy(t); + free(out); free(ms); free(cpu); free(wall); aqs_thruster_destroy(t); return 0; /* timing is reported, not gated: a shared host preempts */ } diff --git a/spikes/faust-aot-thruster/run.sh b/spikes/faust-aot-thruster/run.sh index 952c0d1..40e9717 100755 --- a/spikes/faust-aot-thruster/run.sh +++ b/spikes/faust-aot-thruster/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Build the AOT thruster spike, run the boundary test, then the per-block timing report. # Linux only. usage: run.sh [--bench-only] ; env: FAUST (faust CLI), FAUST_PREFIX (has include/faust), -# FAUST_LIBS (dir with stdfaust.lib), OUT (build dir), BLOCKS, RATE, FRAMES. +# FAUST_LIBS (dir with stdfaust.lib), CORE (cpu to pin the bench to via taskset; default: unpinned), OUT (build dir), BLOCKS, RATE, FRAMES. set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) FAUST=${FAUST:-faust} @@ -18,4 +18,10 @@ gcc -O2 -I"$here" -o "$OUT/test_thruster" "$here/test_thruster.c" -L"$OUT" -laqs gcc -O2 -I"$here" -o "$OUT/bench_thruster" "$here/bench_thruster.c" -L"$OUT" -laqs_thruster -lm -Wl,-rpath,"$OUT" "$OUT/test_thruster" echo "--- timing (Linux $(uname -r), $(grep -m1 'model name' /proc/cpuinfo | cut -d: -f2 | xargs)); Windows/Unity: unverified" -"$OUT/bench_thruster" "${BLOCKS:-20000}" "${RATE:-48000}" "${FRAMES:-512}" +PIN=() +if [ -n "${CORE:-}" ]; then + command -v taskset >/dev/null && PIN=(taskset -c "$CORE") || echo "CORE set but taskset missing: running unpinned" >&2 +fi +echo "bench start $(date -u +%FT%T.%NZ) pin=${PIN[*]:-none} loadavg_before=$(cut -d' ' -f1-3 /proc/loadavg)" +"${PIN[@]}" "$OUT/bench_thruster" "${BLOCKS:-20000}" "${RATE:-48000}" "${FRAMES:-512}" ${NOOP:+noop} +echo "bench end $(date -u +%FT%T.%NZ) loadavg_after=$(cut -d' ' -f1-3 /proc/loadavg)" From a42cc13e5f48a77c43e5527035ef2eb00d9abfa9 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 04:28:50 +0000 Subject: [PATCH 028/124] spike: reword to Nibu's #13 review (no preemption reading, cheap-on-this-host, control counts) Co-Authored-By: Claude Sonnet 5.5 --- spikes/faust-aot-thruster/README.md | 19 ++++++++++--------- spikes/faust-aot-thruster/bench_thruster.c | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/spikes/faust-aot-thruster/README.md b/spikes/faust-aot-thruster/README.md index 885fa67..6d34f5b 100644 --- a/spikes/faust-aot-thruster/README.md +++ b/spikes/faust-aot-thruster/README.md @@ -24,22 +24,23 @@ Linux thread. It shows the patch is cheap, not that a Unity player meets its dea thread, P/Invoke, IL2CPP, mixer or Windows scheduling in it). Measured 2026-11-06/07, Faust 2.90.20, AMD EPYC-Genoa, shared Linux host (load average ~8 on 16 cores): -median 0.052 ms (0.49% of the 10.667 ms deadline), p99 0.08-0.16 ms (~1-1.5%). Cheap: that part is -reliable. +median 0.052 ms (0.49% of the 10.667 ms deadline), p99 0.08-0.16 ms (~1-1.5%). Cheap on this host: +median 0.052 ms, p99 under 0.16 ms. The host's tail is not judgeable (see below). **Max block time: UNEXPLAINED. It is not a pass.** Max was 10.8-17.1 ms, with 1-5 of 20000 blocks over -the deadline per run (70-74 of 400000). What the instrumented runs (`run.sh`, `CORE=` pins with +the deadline per run (400000-block `process` runs: 70-74 over; see the control below). What the instrumented runs (`run.sh`, `CORE=` pins with `taskset`; every overrun prints a `wall_unix` timestamp, wall ms and thread CPU ms) do show: -- Not per-block DSP cost: `NOOP=1` times a 0.05 ms busy-wait instead of `process`, and stalls the same - way (core 3, 400000 blocks: 74 overruns with `process`, 67 with the busy-wait, both ~11 ms). +- Not per-block DSP cost: `NOOP=1` times a 0.05 ms busy-wait instead of `process`, and stalls about the + same way (core 3, 400000 blocks: 74 overruns with `process`, 67 with the busy-wait, both ~11 ms; counts + differ by ~10%, no run-to-run spread measured for the control). - Not a DSP-state pattern: overrun block indices differ every run and are not tied to the rpm sweep. - Periodic in wall time, per core: pinned to core 3, overruns recur every ~0.3-0.4 s (mostly); pinned - to core 9, every ~1-2 s (17 in 400000 blocks). Unpinned runs get 1-5 per 20000. + to core 9, every ~1-2 s (17 in 400000 blocks). Cause of the periodicity untested (not shown to be a timer). Unpinned runs get 1-5 per 20000. - The thread's CPU time over a stalled block is about equal to its wall time (e.g. 10.84 vs 10.85 ms), - so the stall is charged to the thread rather than showing as time off-CPU. Ordinary run-queue - preemption would not look like that. The earlier claim that these were scheduler preemption is - withdrawn. + so the stall is charged to the thread rather than showing as time off-CPU. An ordinary guest + run-queue preemption would be expected to show off-CPU time; this does not. The host (vCPU steal) is + left open. The earlier claim that these were scheduler preemption is withdrawn, not refuted. Cause not identified (candidates: hypervisor/container CPU accounting, per-core host timer or housekeeping work, SMI; none tested). Whether the player would see it is unknown. A quiet, realtime-priority or diff --git a/spikes/faust-aot-thruster/bench_thruster.c b/spikes/faust-aot-thruster/bench_thruster.c index 202df60..8972cb6 100644 --- a/spikes/faust-aot-thruster/bench_thruster.c +++ b/spikes/faust-aot-thruster/bench_thruster.c @@ -18,7 +18,7 @@ int main(int argc, char** argv) { if (!t || blocks < 100) return 2; float* out = malloc(sizeof(float) * frames); double* ms = malloc(sizeof(double) * blocks); - double* cpu = malloc(sizeof(double) * blocks); /* thread CPU time per block: wall >> cpu means preempted, not DSP */ + double* cpu = malloc(sizeof(double) * blocks); /* thread CPU time per block: a large wall-cpu gap means time off-CPU; no gap means the stall is charged to the thread */ double* wall = malloc(sizeof(double) * blocks); /* CLOCK_REALTIME at block end, seconds, for lining up with host load */ const int warm = 200; for (int i = 0; i < warm + blocks; ++i) { @@ -55,5 +55,5 @@ int main(int argc, char** argv) { printf("median_pct_deadline=%.2f p99_pct_deadline=%.2f max_pct_deadline=%.2f over_deadline=%d\n", 100 * med / deadline, 100 * p99 / deadline, 100 * mx / deadline, over); free(out); free(ms); free(cpu); free(wall); aqs_thruster_destroy(t); - return 0; /* timing is reported, not gated: a shared host preempts */ + return 0; /* timing is reported, not gated: a shared host stalls */ } From dda7a4f26b58a6eb7bf73af18b26d9220b5a2e93 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 05:33:49 +0000 Subject: [PATCH 029/124] spike: README reports 74 of 400000 as a single run's figure Co-Authored-By: Claude Sonnet 5.5 --- spikes/faust-aot-thruster/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spikes/faust-aot-thruster/README.md b/spikes/faust-aot-thruster/README.md index 6d34f5b..6cad95b 100644 --- a/spikes/faust-aot-thruster/README.md +++ b/spikes/faust-aot-thruster/README.md @@ -28,7 +28,7 @@ median 0.052 ms (0.49% of the 10.667 ms deadline), p99 0.08-0.16 ms (~1-1.5%). C median 0.052 ms, p99 under 0.16 ms. The host's tail is not judgeable (see below). **Max block time: UNEXPLAINED. It is not a pass.** Max was 10.8-17.1 ms, with 1-5 of 20000 blocks over -the deadline per run (400000-block `process` runs: 70-74 over; see the control below). What the instrumented runs (`run.sh`, `CORE=` pins with +the deadline per run (400000-block `process`: 74 over in one run, core 3; see the control below). What the instrumented runs (`run.sh`, `CORE=` pins with `taskset`; every overrun prints a `wall_unix` timestamp, wall ms and thread CPU ms) do show: - Not per-block DSP cost: `NOOP=1` times a 0.05 ms busy-wait instead of `process`, and stalls about the From 28e37f5cbb004d86ce0bf72ae33717da382ee9bb Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 06:35:25 +0000 Subject: [PATCH 030/124] IpaGestureExperiment: use StoreFileName, delete the last SafeFileName copy Round and candidate ids in the IPA experiment bundle went through a private sanitiser that mapped distinct ids ("a/b", "a-b") to one file and accepted ".." as a round id. They now go through the shared StoreFileName. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/IpaGestureExperiment.cs | 11 ++--------- tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/AquaSynth.Core/IpaGestureExperiment.cs b/src/AquaSynth.Core/IpaGestureExperiment.cs index aead558..ec5e562 100644 --- a/src/AquaSynth.Core/IpaGestureExperiment.cs +++ b/src/AquaSynth.Core/IpaGestureExperiment.cs @@ -108,7 +108,7 @@ public static class IpaGestureExperiment throw new ArgumentException("At least one experiment variant is required.", nameof(variants)); } - var roundDirectory = Path.Combine(rootDirectory, SafeFileName(roundId)); + var roundDirectory = Path.Combine(rootDirectory, StoreFileName.From(roundId)); var candidateDirectory = Path.Combine(roundDirectory, "candidates"); var timelineDirectory = Path.Combine(roundDirectory, "timelines"); Directory.CreateDirectory(candidateDirectory); @@ -122,7 +122,7 @@ public static class IpaGestureExperiment { foreach (var variant in variantList) { - var candidateId = SafeFileName($"{target.Id}-{variant.Id}"); + var candidateId = StoreFileName.From($"{target.Id}-{variant.Id}"); var script = BuildCandidateScript(target, variant); var scriptPath = Path.Combine(candidateDirectory, $"{candidateId}.aqua"); File.WriteAllText(scriptPath, script, Encoding.UTF8); @@ -705,13 +705,6 @@ public static class IpaGestureExperiment private static string SafeDslName(string value) => new(value.Select(character => char.IsLetterOrDigit(character) ? character : '_').ToArray()); - private static string SafeFileName(string value) - { - var invalid = Path.GetInvalidFileNameChars().ToHashSet(); - var safe = new string(value.Select(character => invalid.Contains(character) || char.IsWhiteSpace(character) ? '-' : character).ToArray()); - return safe.Length == 0 ? "candidate" : safe; - } - private static string Format(float value) => value.ToString("0.######", CultureInfo.InvariantCulture); diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index d8012ae..2f82405 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -113,5 +113,20 @@ public sealed class StoreFileNameTests } } + [Fact] + public void IpaRoundCandidatesWithCollidingSanitisedIdsKeepDistinctFilesAndStayInRoot() + { + var root = Path.Combine(Path.GetTempPath(), $"aquasynth-ipa-sfn-{Guid.NewGuid():N}"); + var result = IpaGestureExperiment.WriteRound( + root, + "round-sfn", + [new IpaGestureExperimentTarget("a/b", "p", "voiceless_bilabial_plosive", .1f), new IpaGestureExperimentTarget("a-b", "m", "voiced_bilabial_nasal", .1f)], + [new IpaGestureExperimentVariant("base")]); + + Assert.Equal(2, result.Candidates.Select(c => c.Id).Distinct(StringComparer.OrdinalIgnoreCase).Count()); + Assert.All(result.Candidates, c => Assert.StartsWith(Path.GetFullPath(root), Path.GetFullPath(c.ScriptPath))); + Assert.Throws(() => IpaGestureExperiment.WriteRound(root, "..", [new IpaGestureExperimentTarget("a", "p", "voiceless_bilabial_plosive")], [new IpaGestureExperimentVariant("base")])); + } + private static string UriPath(string uri) => new Uri(uri).LocalPath; } From de754b5b8c8035300729d50a90e082a2796a74da Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 09:29:43 +0000 Subject: [PATCH 031/124] StoreFileName: route IpaTrialOrchestrator and FaustCompiler through it; daemon test uses ".." Nibu's review at abfc816: the daemon test passed against the old sanitizer because "../../escape" never escaped there; the bare ".." did. IpaTrialOrchestrator (SafeName, raw BatchId in Path.Combine) and FaustCompiler.SafeArtifactName were second owners of the same decision. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Faust/FaustCompiler.cs | 8 ++------ src/AquaSynth.Faust/IpaTrialOrchestrator.cs | 11 ++++------- tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 4 ++-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/AquaSynth.Faust/FaustCompiler.cs b/src/AquaSynth.Faust/FaustCompiler.cs index b2b197d..94f363b 100644 --- a/src/AquaSynth.Faust/FaustCompiler.cs +++ b/src/AquaSynth.Faust/FaustCompiler.cs @@ -222,12 +222,8 @@ public static class FaustCompiler _ => throw new ArgumentOutOfRangeException(nameof(language), language, null) }; - private static string SafeArtifactName(string value) - { - var sanitized = new string(value.Select(character => - char.IsAsciiLetterOrDigit(character) || character is '-' or '_' ? character : '_').ToArray()); - return string.IsNullOrWhiteSpace(sanitized) ? "aquasynth_patch" : sanitized; - } + private static string SafeArtifactName(string value) => + string.IsNullOrWhiteSpace(value) ? "aquasynth_patch" : StoreFileName.From(value); private static async Task FaustArchDirAsync(string faustPath, CancellationToken cancellationToken) { diff --git a/src/AquaSynth.Faust/IpaTrialOrchestrator.cs b/src/AquaSynth.Faust/IpaTrialOrchestrator.cs index 4f33bf4..d28b020 100644 --- a/src/AquaSynth.Faust/IpaTrialOrchestrator.cs +++ b/src/AquaSynth.Faust/IpaTrialOrchestrator.cs @@ -124,7 +124,7 @@ public static class IpaTrialOrchestrator throw new ArgumentException("At least one IPA trial target set is required.", nameof(trialSets)); } - var batchDirectory = Path.Combine(artifactRoot, options.BatchId); + var batchDirectory = Path.Combine(artifactRoot, StoreFileName.From(options.BatchId)); Directory.CreateDirectory(batchDirectory); var storePath = Path.Combine(batchDirectory, options.TrialResultStoreFileName); var referenceRenderer = new PinkTromboneReferenceRenderer(); @@ -156,7 +156,7 @@ public static class IpaTrialOrchestrator var candidateDir = Path.Combine(round.RoundDirectory, "audio", candidate.Id); Directory.CreateDirectory(candidateDir); var script = await File.ReadAllTextAsync(candidate.ScriptPath, cancellationToken).ConfigureAwait(false); - var source = FaustEmitter.EmitScript(script, new FaustExportOptions(SafeName(candidate.Id))).Source; + var source = FaustEmitter.EmitScript(script, new FaustExportOptions(StoreFileName.From(candidate.Id))).Source; var dspPath = Path.Combine(candidateDir, "candidate.dsp"); await File.WriteAllTextAsync(dspPath, source, cancellationToken).ConfigureAwait(false); @@ -274,7 +274,7 @@ public static class IpaTrialOrchestrator throw new ArgumentException("At least one IPA script candidate is required.", nameof(candidates)); } - var batchDirectory = Path.Combine(artifactRoot, options.BatchId); + var batchDirectory = Path.Combine(artifactRoot, StoreFileName.From(options.BatchId)); var candidateRoot = Path.Combine(batchDirectory, "agent-candidates"); var timelineRoot = Path.Combine(batchDirectory, "agent-timelines"); Directory.CreateDirectory(candidateRoot); @@ -298,7 +298,7 @@ public static class IpaTrialOrchestrator var startedAt = DateTimeOffset.UtcNow; var startedStamp = Stopwatch.GetTimestamp(); - var safeCandidateId = SafeName(candidate.CandidateId); + var safeCandidateId = StoreFileName.From(candidate.CandidateId); var candidateDir = Path.Combine(candidateRoot, safeCandidateId); Directory.CreateDirectory(candidateDir); var audioDir = Path.Combine(candidateDir, "audio"); @@ -721,9 +721,6 @@ public static class IpaTrialOrchestrator return samples; } - private static string SafeName(string value) => - new(value.Select(character => char.IsLetterOrDigit(character) ? character : '_').ToArray()); - private static string Escape(string value) => value.Contains(',') || value.Contains('"') || value.Contains('\n') || value.Contains('\r') ? $"\"{value.Replace("\"", "\"\"", StringComparison.Ordinal)}\"" diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index d8012ae..1efb857 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -93,7 +93,7 @@ public sealed class StoreFileNameTests } [Fact] - public async Task DaemonSampleFilesForTraversalCommandIdStayInsideStore() + public async Task DaemonSampleFilesForDotDotCommandIdStayInsideStore() { var parent = Path.Combine(Path.GetTempPath(), "aquasynth-sfn-" + Guid.NewGuid().ToString("N")); var storeRoot = Path.Combine(parent, "store"); @@ -101,7 +101,7 @@ public sealed class StoreFileNameTests // A patch that compiles reaches the samples/ write; without native Faust only the compile-failed branch runs. var result = await service.SampleAsync(new AquaSynthInstrumentSampleCommand( - "../../escape", "test.sine", "test_sine", + "..", "test.sine", "test_sine", "voice wave=sine freq=440 gain=.2 attack=.001 sustain=.05 decay=.05", DurationSeconds: 0.1f)); Assert.Empty(Directory.GetFiles(parent)); From 4865830d825ef11917c4b87a894f8fae727a5a9b Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 09:54:00 +0000 Subject: [PATCH 032/124] IpaGestureExperiment: make the target/variant candidate id injective ("a","b-c") and ("a-b","c") both joined to "a-b-c" before the map and wrote the same files. Each part goes through StoreFileName.From first and the pair is joined with '/', which no mapped part can contain. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/IpaGestureExperiment.cs | 2 +- tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/AquaSynth.Core/IpaGestureExperiment.cs b/src/AquaSynth.Core/IpaGestureExperiment.cs index ec5e562..27b94cc 100644 --- a/src/AquaSynth.Core/IpaGestureExperiment.cs +++ b/src/AquaSynth.Core/IpaGestureExperiment.cs @@ -122,7 +122,7 @@ public static class IpaGestureExperiment { foreach (var variant in variantList) { - var candidateId = StoreFileName.From($"{target.Id}-{variant.Id}"); + var candidateId = StoreFileName.From($"{StoreFileName.From(target.Id)}/{StoreFileName.From(variant.Id)}"); var script = BuildCandidateScript(target, variant); var scriptPath = Path.Combine(candidateDirectory, $"{candidateId}.aqua"); File.WriteAllText(scriptPath, script, Encoding.UTF8); diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index ab4c0ee..e6f56f8 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -128,5 +128,20 @@ public sealed class StoreFileNameTests Assert.Throws(() => IpaGestureExperiment.WriteRound(root, "..", [new IpaGestureExperimentTarget("a", "p", "voiceless_bilabial_plosive")], [new IpaGestureExperimentVariant("base")])); } + [Fact] + public void IpaRoundJoinedTargetVariantIdsThatConcatenateEquallyKeepDistinctFiles() + { + var root = Path.Combine(Path.GetTempPath(), $"aquasynth-ipa-join-{Guid.NewGuid():N}"); + var result = IpaGestureExperiment.WriteRound( + root, + "round-join", + [new IpaGestureExperimentTarget("a", "p", "voiceless_bilabial_plosive", .1f), new IpaGestureExperimentTarget("a-b", "m", "voiced_bilabial_nasal", .1f)], + [new IpaGestureExperimentVariant("b-c"), new IpaGestureExperimentVariant("c")]); + + Assert.Equal(4, result.Candidates.Count); + Assert.Equal(4, result.Candidates.Select(c => c.Id).Distinct(StringComparer.OrdinalIgnoreCase).Count()); + Assert.Equal(4, result.Candidates.Select(c => c.ScriptPath).Distinct(StringComparer.OrdinalIgnoreCase).Count()); + } + private static string UriPath(string uri) => new Uri(uri).LocalPath; } From afd0cc9ec34803fceae898a7d005230816fbff7b Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 09:54:00 +0000 Subject: [PATCH 033/124] StoreFileName: device stems no longer survive as the stem; IpaTrialWorker paths use it "nul.x" was rewritten to "nul.x-", whose stem is still NUL on Windows; rewritten device names now get a leading underscore, and the test asserts the stem is not reserved. IpaTrialWorker candidate directories go through StoreFileName.From; its remaining SafeName only slugs uuid-suffixed record ids. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/StoreFileName.cs | 6 ++++++ tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 2 ++ tools/IpaTrialWorker/Program.cs | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/AquaSynth.Core/StoreFileName.cs b/src/AquaSynth.Core/StoreFileName.cs index de3d7cf..c52e883 100644 --- a/src/AquaSynth.Core/StoreFileName.cs +++ b/src/AquaSynth.Core/StoreFileName.cs @@ -38,6 +38,12 @@ public static class StoreFileName return safe; } + // "nul.x-" still has the device stem "nul"; the underscore moves the whole name off it. + if (IsDeviceStem(safe)) + { + safe = "_" + safe; + } + var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(id)))[..HashLength].ToLowerInvariant(); return $"{safe}-{hash}"; } diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index 1efb857..0fd3e31 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -48,6 +48,8 @@ public sealed class StoreFileNameTests var name = StoreFileName.From(id); Assert.NotEqual(id.ToLowerInvariant(), name.ToLowerInvariant()); Assert.Matches("-[0-9a-f]{16}$", name); + var stem = name.Split('.')[0].TrimEnd(' '); + Assert.DoesNotMatch("^(?i:con|prn|aux|nul|com[0-9]|lpt[0-9])$", stem); } [Fact] diff --git a/tools/IpaTrialWorker/Program.cs b/tools/IpaTrialWorker/Program.cs index b463dec..23d7750 100644 --- a/tools/IpaTrialWorker/Program.cs +++ b/tools/IpaTrialWorker/Program.cs @@ -228,7 +228,7 @@ static async Task SongScoreAsync(Dictionary options) { var startedAt = DateTimeOffset.UtcNow; var startedStamp = Stopwatch.GetTimestamp(); - var safeCandidateId = SafeName(candidate.CandidateId); + var safeCandidateId = StoreFileName.From(candidate.CandidateId); var candidateDir = Path.Combine(candidateRoot, safeCandidateId); var audioDir = Path.Combine(candidateDir, "audio"); Directory.CreateDirectory(audioDir); @@ -2658,10 +2658,10 @@ static bool IsOfficialMusicArtifactPath(string path) } static string CandidatePatchPath(SongSummaryRow row) => - Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", SafeName(row.CandidateId), "candidate.aqua"); + Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", StoreFileName.From(row.CandidateId), "candidate.aqua"); static string CandidateAnalysisPath(SongSummaryRow row) => - Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", SafeName(row.CandidateId), "candidate-analysis.md"); + Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", StoreFileName.From(row.CandidateId), "candidate-analysis.md"); static string EvaluatorReportPath(SongSummaryRow row) => Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "evaluator-report.md"); From 80ebf390339b66ae913538329c26af11a48acaf2 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 10:33:47 +0000 Subject: [PATCH 034/124] StoreFileName.Combine: batch ids from the command line cannot leave the artifact root IpaTrialWorker song-score took --batch-id raw into Path.Combine; the orchestrator sites share the new Combine. Tests cover traversal and absolute batch ids and the underscore on device stems (nul.x, LPT1.x); drop the double From on the emitter name. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/StoreFileName.cs | 3 +++ src/AquaSynth.Faust/IpaTrialOrchestrator.cs | 6 +++--- .../AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 19 +++++++++++++++++++ tools/IpaTrialWorker/Program.cs | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/AquaSynth.Core/StoreFileName.cs b/src/AquaSynth.Core/StoreFileName.cs index c52e883..0de02d1 100644 --- a/src/AquaSynth.Core/StoreFileName.cs +++ b/src/AquaSynth.Core/StoreFileName.cs @@ -48,6 +48,9 @@ public static class StoreFileName return $"{safe}-{hash}"; } + /// A child of named for an external id; the result never leaves the root. + public static string Combine(string root, string id) => Path.Combine(root, From(id)); + private static bool IsFixedPoint(string id, string safe) { if (safe != id || id.EndsWith('.') || id.Any(char.IsAsciiLetterUpper) || IsDeviceStem(id) || EndsWithHashShape(id)) diff --git a/src/AquaSynth.Faust/IpaTrialOrchestrator.cs b/src/AquaSynth.Faust/IpaTrialOrchestrator.cs index d28b020..ef37d3d 100644 --- a/src/AquaSynth.Faust/IpaTrialOrchestrator.cs +++ b/src/AquaSynth.Faust/IpaTrialOrchestrator.cs @@ -124,7 +124,7 @@ public static class IpaTrialOrchestrator throw new ArgumentException("At least one IPA trial target set is required.", nameof(trialSets)); } - var batchDirectory = Path.Combine(artifactRoot, StoreFileName.From(options.BatchId)); + var batchDirectory = StoreFileName.Combine(artifactRoot, options.BatchId); Directory.CreateDirectory(batchDirectory); var storePath = Path.Combine(batchDirectory, options.TrialResultStoreFileName); var referenceRenderer = new PinkTromboneReferenceRenderer(); @@ -156,7 +156,7 @@ public static class IpaTrialOrchestrator var candidateDir = Path.Combine(round.RoundDirectory, "audio", candidate.Id); Directory.CreateDirectory(candidateDir); var script = await File.ReadAllTextAsync(candidate.ScriptPath, cancellationToken).ConfigureAwait(false); - var source = FaustEmitter.EmitScript(script, new FaustExportOptions(StoreFileName.From(candidate.Id))).Source; + var source = FaustEmitter.EmitScript(script, new FaustExportOptions(candidate.Id)).Source; var dspPath = Path.Combine(candidateDir, "candidate.dsp"); await File.WriteAllTextAsync(dspPath, source, cancellationToken).ConfigureAwait(false); @@ -274,7 +274,7 @@ public static class IpaTrialOrchestrator throw new ArgumentException("At least one IPA script candidate is required.", nameof(candidates)); } - var batchDirectory = Path.Combine(artifactRoot, StoreFileName.From(options.BatchId)); + var batchDirectory = StoreFileName.Combine(artifactRoot, options.BatchId); var candidateRoot = Path.Combine(batchDirectory, "agent-candidates"); var timelineRoot = Path.Combine(batchDirectory, "agent-timelines"); Directory.CreateDirectory(candidateRoot); diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index 0fd3e31..3620874 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -43,9 +43,12 @@ public sealed class StoreFileNameTests [InlineData("COM9.f32")] [InlineData("lpt0")] [InlineData("prn.cc")] + [InlineData("nul.x")] + [InlineData("LPT1.x")] public void WindowsDeviceStemsAreRewritten(string id) { var name = StoreFileName.From(id); + Assert.StartsWith("_", name); Assert.NotEqual(id.ToLowerInvariant(), name.ToLowerInvariant()); Assert.Matches("-[0-9a-f]{16}$", name); var stem = name.Split('.')[0].TrimEnd(' '); @@ -115,5 +118,21 @@ public sealed class StoreFileNameTests } } + [Theory] + [InlineData("../x")] + [InlineData("..\\x")] + [InlineData("/etc/x")] + [InlineData("C:\\x")] + public void BatchIdsFromTheCommandLineCannotLeaveTheArtifactRoot(string batchId) + { + var root = Path.Combine(Path.GetTempPath(), "artifact-root-probe", "artifacts"); + var full = Path.GetFullPath(StoreFileName.Combine(root, batchId)); + Assert.Equal(Path.GetFullPath(root), Path.GetDirectoryName(full)); + } + + [Fact] + public void BareDotDotBatchIdIsRefused() => + Assert.Throws(() => StoreFileName.Combine(Path.GetTempPath(), "..")); + private static string UriPath(string uri) => new Uri(uri).LocalPath; } diff --git a/tools/IpaTrialWorker/Program.cs b/tools/IpaTrialWorker/Program.cs index 23d7750..f7089d1 100644 --- a/tools/IpaTrialWorker/Program.cs +++ b/tools/IpaTrialWorker/Program.cs @@ -214,7 +214,7 @@ static async Task SongScoreAsync(Dictionary options) throw new InvalidDataException($"No .aqua song candidates found under `{patchRoot}`."); } - var batchDirectory = Path.Combine(artifactRoot, batchId); + var batchDirectory = StoreFileName.Combine(artifactRoot, batchId); var candidateRoot = Path.Combine(batchDirectory, "song-candidates"); var timelineRoot = Path.Combine(batchDirectory, "song-timelines"); Directory.CreateDirectory(candidateRoot); From 5a77dc8e83b28e8eca48818ffca4755dd75c5f59 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 10:38:28 +0000 Subject: [PATCH 035/124] AquaLower names lowered .dsp files through StoreFileName; pin Windows forms; note limits Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/StoreFileName.cs | 5 ++++ .../AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 27 +++++++++++++++++++ tools/AquaLower/Program.cs | 5 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/AquaSynth.Core/StoreFileName.cs b/src/AquaSynth.Core/StoreFileName.cs index 0de02d1..9dcac70 100644 --- a/src/AquaSynth.Core/StoreFileName.cs +++ b/src/AquaSynth.Core/StoreFileName.cs @@ -13,6 +13,11 @@ namespace AquaSynth.Dsl; /// rewritten names always do, so the two sets cannot meet; distinct ids stay distinct up to a 64-bit /// hash. The result is never a path: no separators, never "." or "..". /// +/// +/// Not handled: symlinks and junctions already inside a store are followed, and Windows 8.3 short names +/// were not verified. An id with an uppercase letter is rewritten, so a batch directory named for such +/// an id gains a hash suffix. +/// public static class StoreFileName { private const int MaxStem = 100; diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index b083f6f..8da1f52 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -160,6 +160,33 @@ public sealed class StoreFileNameTests Assert.Equal(Path.GetFullPath(root), Path.GetDirectoryName(full)); } + [Theory] + [InlineData("\\\\host\\share\\x")] + [InlineData("C:x")] + [InlineData("a:b")] + [InlineData("x.")] + [InlineData("x ")] + [InlineData("x. ")] + public void WindowsAbsoluteAndTrailingDotOrSpaceIdsStayContainedAndPlain(string id) + { + var root = Path.Combine(Path.GetTempPath(), "artifact-root-probe", "artifacts"); + var name = StoreFileName.From(id); + Assert.Matches("^[A-Za-z0-9._-]+$", name); + Assert.False(name.EndsWith('.') || name.EndsWith(' ')); + Assert.Equal(Path.GetFullPath(root), Path.GetDirectoryName(Path.GetFullPath(StoreFileName.Combine(root, id)))); + } + + [Theory] + [InlineData("../x")] + [InlineData("a/b")] + [InlineData("name:with:colons")] + public void LoweredDspFileNameStaysInTheOutputDirectory(string name) + { + var outDir = Path.Combine(Path.GetTempPath(), "aqualower-probe", "out"); + var file = StoreFileName.From(name) + ".dsp"; + Assert.Equal(Path.GetFullPath(outDir), Path.GetDirectoryName(Path.GetFullPath(Path.Combine(outDir, file)))); + } + [Fact] public void BareDotDotBatchIdIsRefused() => Assert.Throws(() => StoreFileName.Combine(Path.GetTempPath(), "..")); diff --git a/tools/AquaLower/Program.cs b/tools/AquaLower/Program.cs index e2d4948..8ee3fd7 100644 --- a/tools/AquaLower/Program.cs +++ b/tools/AquaLower/Program.cs @@ -47,8 +47,9 @@ foreach (var spec in args.Skip(2)) warnings.AddRange(export.Warnings); } else source = text; - File.WriteAllText(Path.Combine(outDir, name + ".dsp"), source); - entries.Add(new { name, origin = rel.Replace('\\', '/'), kind = path.EndsWith(".aqua", StringComparison.Ordinal) ? "aqua" : "faust", dsp = name + ".dsp", warnings }); + var dspFile = StoreFileName.From(name) + ".dsp"; + File.WriteAllText(Path.Combine(outDir, dspFile), source); + entries.Add(new { name, origin = rel.Replace('\\', '/'), kind = path.EndsWith(".aqua", StringComparison.Ordinal) ? "aqua" : "faust", dsp = dspFile, warnings }); Console.WriteLine($"{name}: {source.Length} chars from {rel}, {warnings.Count} warnings"); } File.WriteAllText(Path.Combine(outDir, "catalog.json"), JsonSerializer.Serialize(entries, new JsonSerializerOptions { WriteIndented = true })); From aec15751cc005cb410ebb92370da89c3849eb167 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 7 Nov 2026 11:51:44 +0000 Subject: [PATCH 036/124] StoreFileName tests: device lookalikes and IPA pair distinctness Adds CON.tar.gz to the device-stem cases, a lookalike theory (trailing space, superscript digit, accented letter, trailing dot) and a 6x6 IPA round grid whose ids and script paths must stay distinct. Tests only. Co-Authored-By: Claude Sonnet 5.5 --- .../AquaSynth.Dsl.Tests/StoreFileNameTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs index 8da1f52..0e3f5da 100644 --- a/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs +++ b/tests/AquaSynth.Dsl.Tests/StoreFileNameTests.cs @@ -45,6 +45,7 @@ public sealed class StoreFileNameTests [InlineData("prn.cc")] [InlineData("nul.x")] [InlineData("LPT1.x")] + [InlineData("CON.tar.gz")] public void WindowsDeviceStemsAreRewritten(string id) { var name = StoreFileName.From(id); @@ -55,6 +56,20 @@ public sealed class StoreFileNameTests Assert.DoesNotMatch("^(?i:con|prn|aux|nul|com[0-9]|lpt[0-9])$", stem); } + [Theory] + [InlineData("nul ")] + [InlineData("COM\u00b9")] + [InlineData("COM1 .x")] + [InlineData("con\u00e9.x")] + [InlineData("NUL.")] + public void DeviceLookalikesNeverLeaveAReservedStem(string id) + { + var name = StoreFileName.From(id); + Assert.Matches("^[A-Za-z0-9._-]+$", name); + Assert.DoesNotMatch("^(?i:con|prn|aux|nul|com[0-9]|lpt[0-9])$", name.Split('.')[0].TrimEnd(' ')); + Assert.Matches("-[0-9a-f]{16}$", name); + } + [Fact] public void OverlongIdsAreBoundedAndStayDistinct() { @@ -148,6 +163,23 @@ public sealed class StoreFileNameTests Assert.Equal(4, result.Candidates.Select(c => c.ScriptPath).Distinct(StringComparer.OrdinalIgnoreCase).Count()); } + [Fact] + public void IpaRoundPairsWithSeparatorCharactersInIdsStayDistinct() + { + var root = Path.Combine(Path.GetTempPath(), $"aquasynth-ipa-pair-{Guid.NewGuid():N}"); + string[] targets = ["a", "a/b", "a-b", "a_b", "A", "a b"]; + string[] variants = ["b-c", "c", "b/c", "b_c", "B-C", "b c"]; + var result = IpaGestureExperiment.WriteRound( + root, + "round-pairs", + targets.Select(t => new IpaGestureExperimentTarget(t, "p", "voiceless_bilabial_plosive", .1f)).ToArray(), + variants.Select(v => new IpaGestureExperimentVariant(v)).ToArray()); + + Assert.Equal(36, result.Candidates.Count); + Assert.Equal(36, result.Candidates.Select(c => c.Id).Distinct(StringComparer.OrdinalIgnoreCase).Count()); + Assert.Equal(36, result.Candidates.Select(c => c.ScriptPath).Distinct(StringComparer.OrdinalIgnoreCase).Count()); + } + [Theory] [InlineData("../x")] [InlineData("..\\x")] From 9fa30ef9d3ad5035a475dbfebf3841946d1f77ad Mon Sep 17 00:00:00 2001 From: Aqua Date: Sun, 8 Nov 2026 00:51:14 +0000 Subject: [PATCH 037/124] aqua-listen: listening-test kit (manifest + clips -> one self-contained HTML page) Blind randomized order and A/B pairs, consent first, keep/fix/drop + reason + 1-5 landed + headphones/speakers, localStorage autosave, export of verdict.json and verdict.md. CSP default-src 'none': no network. 16 node tests; headless Chromium smoke script. Nothing was heard. Co-Authored-By: Claude Sonnet 5.5 --- tools/aqua-listen/README.md | 59 +++++++++++++++++ tools/aqua-listen/build.mjs | 54 +++++++++++++++ tools/aqua-listen/logic.cjs | 103 +++++++++++++++++++++++++++++ tools/aqua-listen/package.json | 7 ++ tools/aqua-listen/smoke.mjs | 38 +++++++++++ tools/aqua-listen/test.mjs | 109 +++++++++++++++++++++++++++++++ tools/aqua-listen/web/index.html | 16 +++++ tools/aqua-listen/web/page.js | 109 +++++++++++++++++++++++++++++++ tools/aqua-listen/web/styles.css | 18 +++++ 9 files changed, 513 insertions(+) create mode 100644 tools/aqua-listen/README.md create mode 100644 tools/aqua-listen/build.mjs create mode 100644 tools/aqua-listen/logic.cjs create mode 100644 tools/aqua-listen/package.json create mode 100644 tools/aqua-listen/smoke.mjs create mode 100644 tools/aqua-listen/test.mjs create mode 100644 tools/aqua-listen/web/index.html create mode 100644 tools/aqua-listen/web/page.js create mode 100644 tools/aqua-listen/web/styles.css diff --git a/tools/aqua-listen/README.md b/tools/aqua-listen/README.md new file mode 100644 index 0000000..eb3886e --- /dev/null +++ b/tools/aqua-listen/README.md @@ -0,0 +1,59 @@ +# aqua-listen + +A listening-test kit: a folder of sound clips and a manifest become **one HTML file** you can send to a listener. They open it, listen, say keep / fix / drop for each sound, and send back two small files. + +**Status:** the page was driven in headless Chromium (consent gate, autosave across reload, export, zero network requests) and `node test.mjs` covers validation, ordering and the export shape. Nobody has listened with it yet, and the headless browser played nothing audibly; real playback on a phone or other browser is untried. + +## For the listener (no technical knowledge needed) + +1. Open the `listen.html` file you were sent by double-clicking it. Any recent browser works. +2. Read the short note and tick the box. You can type a nickname or leave it blank. +3. Pick **headphones** or **speakers** at the top, whichever you are using. Change it if you switch. +4. For each sound: press play (as often as you like), read what it is *meant* to feel like, then choose + - **keep** (good as it is), **fix** (nearly, but something is wrong), or **drop** (not worth having), + - how well it **landed**, from 1 (not at all) to 5 (completely), + - and one line on why. +5. Some sounds come as a pair, **A** and **B**. Rate both, then say which you prefer, or that there is no difference. +6. The sounds are in a random order and their names are hidden on purpose. Please don't hunt for them. +7. Your answers save themselves in your browser as you go. You can close the tab and come back to the same file later. +8. When done, press **Export**. Two files land in your downloads: `verdict.json` and `verdict.md`. Send both to whoever gave you the page. That is the only way anything leaves your computer. + +Privacy: the page has no network access at all (the browser is told to refuse it), no account, no tracking. "Erase my answers" at the bottom wipes what the page saved. + +## For the person building a kit + +``` +node build.mjs --manifest kit.json --clips ./clips --out ./dist # writes dist/listen.html +node test.mjs # 16 checks, no dependencies, no browser +node smoke.mjs dist/listen.html # optional browser smoke, see below +``` + +`kit.json`: + +```json +{ "kit": { "id": "my-kit-1", "title": "Thruster sweep", "note": "optional line shown under the title" }, + "clips": [ + { "id": "t1", "file": "thr-a.wav", "title": "Thruster, low", "feel": "heavy, steady, not hissy", "group": "thruster", "pair": "t2" }, + { "id": "t2", "file": "thr-b.wav", "title": "Thruster, low, tonal", "feel": "heavy, steady, not hissy", "group": "thruster", "pair": "t1" } +] } +``` + +- `id`, `file` (wav, mp3, ogg or flac, relative to `--clips`), `title`, `feel` (intended feel; shown to the listener), `group`: required. `pair`: optional, must name another clip whose `pair` names this one. Anything wrong stops the build with the full list of problems. +- Title, id and group are hidden from the listener and appear only in the export. The intended feel is shown, since "did it land" needs it. +- Order is shuffled from a random seed kept with the listener's answers (it is in the export). A pair is shuffled as one unit, with A/B position shuffled inside it. +- Audio is embedded as-is (base64), so the page is about 1.4x the clip bytes. The build warns over 100 MB. +- Autosave key is the kit id plus a hash of the manifest and clip bytes: a rebuilt kit with changed clips starts fresh instead of mixing answers. + +### Export + +`verdict.json` (`schema: "aqua.listen.verdict.v1"`): `kit`, `exportedAt`, `seed`, `consent`, `listener`, `device`, `notes`, `summary` (counts), `clips[]` in the order heard (`position, id, title, group, feel, file, pair, slot, verdict, reason, landed, device`), `pairs[]` (`a, b, preferred`: a clip id or `no-difference`). `verdict.md` is the same as a table. Unanswered fields are `null`. + +The blank verdict files this was meant to match were not found under `/opt/commons/handoff/`, so this shape is the kit's own. If a house format exists, the change is in `buildVerdict` / `verdictMarkdown` in `logic.cjs`. + +### Browser smoke + +`PLAYWRIGHT_CORE=/path/to/playwright-core CHROME=/path/to/chrome node smoke.mjs dist/listen.html` ticks through consent, answers a clip, reloads, exports, and fails on any network request or page error. It is not in `node test.mjs` because the repo carries no browser dependency. + +## Files + +`logic.cjs` validation, ordering, export shape (shared by build, page, tests) · `build.mjs` assembles the page · `web/` page template, glue and styles · `test.mjs` · `smoke.mjs` diff --git a/tools/aqua-listen/build.mjs b/tools/aqua-listen/build.mjs new file mode 100644 index 0000000..16526ab --- /dev/null +++ b/tools/aqua-listen/build.mjs @@ -0,0 +1,54 @@ +#!/usr/bin/env node +// Builds one self-contained listening page. Usage: +// node build.mjs --manifest kit.json --clips DIR --out DIR (writes DIR/listen.html; --clips defaults to the manifest's folder) +import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync } from "node:fs"; +import { createHash } from "node:crypto"; +import { createRequire } from "node:module"; +import { dirname, extname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const L = createRequire(import.meta.url)("./logic.cjs"); +const MIME = { ".wav": "audio/wav", ".mp3": "audio/mpeg", ".ogg": "audio/ogg", ".flac": "audio/flac" }; + +// Throws one Error listing every manifest problem and every missing file. Returns {html, hash, bytes}. +export function buildKit(manifest, clipsDir) { + const errs = L.validateManifest(manifest); + if (errs.length === 0) for (const c of manifest.clips) { + const f = resolve(clipsDir, c.file); + if (!f.startsWith(resolve(clipsDir) + "/") && !f.startsWith(resolve(clipsDir) + "\\")) errs.push(`clip ${c.id}: ${c.file} leaves the clips folder`); + else if (!existsSync(f) || !statSync(f).isFile()) errs.push(`clip ${c.id}: file not found: ${c.file}`); + } + if (errs.length) throw new Error("manifest invalid:\n " + errs.join("\n ")); + const audio = {}, h = createHash("sha256"); + h.update(JSON.stringify(manifest)); + for (const c of manifest.clips) { + const buf = readFileSync(resolve(clipsDir, c.file)); + h.update(buf); + audio[c.id] = { mime: MIME[extname(c.file).toLowerCase()], b64: buf.toString("base64") }; + } + const hash = h.digest("hex").slice(0, 8); + const data = JSON.stringify({ manifest, hash, audio }).replace(/{const module={exports:{}};${readFileSync(join(here, "logic.cjs"), "utf8")}\nreturn module.exports})();`; + const part = (n) => readFileSync(join(here, "web", n), "utf8"); + const esc = (s) => s.replace(/&/g, "&").replace(/ esc(manifest.kit.title)).replace("/*STYLES*/", () => part("styles.css")) + .replace("/*DATA*/", () => data).replace("/*LOGIC*/", () => logic.replace(/<\/script/gi, "<\\/script")).replace("/*PAGE*/", () => part("page.js").replace(/<\/script/gi, "<\\/script")); + return { html, hash, bytes: Buffer.byteLength(html) }; +} + +if (process.argv[1] === fileURLToPath(import.meta.url)) { + const a = process.argv.slice(2), opt = (n) => { const i = a.indexOf(n); return i < 0 ? undefined : a[i + 1]; }; + const mf = opt("--manifest"), out = opt("--out"); + if (!mf || !out) { console.error("usage: node build.mjs --manifest kit.json --clips DIR --out DIR"); process.exit(2); } + try { + const manifest = JSON.parse(readFileSync(mf, "utf8")); + const r = buildKit(manifest, resolve(opt("--clips") ?? dirname(resolve(mf)))); + mkdirSync(out, { recursive: true }); + writeFileSync(join(out, "listen.html"), r.html); + console.log(`built ${join(out, "listen.html")}\nclips ${manifest.clips.length} bytes ${r.bytes} hash ${r.hash}`); + if (r.bytes > 100e6) console.log("warning: over 100 MB; some browsers and mail systems will struggle. Trim clips."); + } catch (e) { console.error(e.message); process.exit(1); } +} diff --git a/tools/aqua-listen/logic.cjs b/tools/aqua-listen/logic.cjs new file mode 100644 index 0000000..e7aec25 --- /dev/null +++ b/tools/aqua-listen/logic.cjs @@ -0,0 +1,103 @@ +// Shared by build.mjs, the page and test.mjs. CommonJS so build.mjs can inline this file into the page verbatim. +"use strict"; +const SCHEMA = "aqua.listen.verdict.v1"; +const VERDICTS = ["keep", "fix", "drop"]; +const DEVICES = ["headphones", "speakers"]; +const AUDIO_EXT = /\.(wav|mp3|ogg|flac)$/i; + +// Manifest: { kit: {id, title, note?}, clips: [{id, file, title, feel, group, pair?}] }. Returns a list of problems (empty = valid). +function validateManifest(m) { + const errs = []; + const str = (v) => typeof v === "string" && v.trim() !== ""; + if (!m || typeof m !== "object" || Array.isArray(m)) return ["manifest must be an object with `kit` and `clips`"]; + if (!m.kit || !str(m.kit.id) || !/^[A-Za-z0-9._-]+$/.test(m.kit.id)) errs.push("kit.id must be a non-empty string of letters, digits, . _ -"); + if (!m.kit || !str(m.kit.title)) errs.push("kit.title is required"); + if (!Array.isArray(m.clips) || m.clips.length === 0) { errs.push("clips must be a non-empty array"); return errs; } + const byId = new Map(); + m.clips.forEach((c, i) => { + const at = `clips[${i}]${c && str(c.id) ? ` (${c.id})` : ""}`; + if (!c || typeof c !== "object") { errs.push(`${at}: must be an object`); return; } + for (const k of ["id", "file", "title", "feel", "group"]) if (!str(c[k])) errs.push(`${at}: ${k} is required`); + if (c.pair !== undefined && !str(c.pair)) errs.push(`${at}: pair must be a clip id`); + if (str(c.file)) { + if (!AUDIO_EXT.test(c.file)) errs.push(`${at}: file must be .wav, .mp3, .ogg or .flac`); + if (/^([A-Za-z]:|[\\/])/.test(c.file) || c.file.split(/[\\/]/).includes("..")) errs.push(`${at}: file must be a relative path inside the clips folder`); + } + if (str(c.id)) { if (byId.has(c.id)) errs.push(`${at}: duplicate id`); else byId.set(c.id, c); } + }); + for (const c of m.clips) { + if (!c || !str(c.pair) || !str(c.id)) continue; + const at = `clip ${c.id}`, o = byId.get(c.pair); + if (c.pair === c.id) errs.push(`${at}: cannot be paired with itself`); + else if (!o) errs.push(`${at}: pair ${c.pair} is not a clip id`); + else if (o.pair !== c.id) errs.push(`${at}: pair ${c.pair} does not point back (pairs must be mutual)`); + } + return errs; +} + +function rng(seed) { // mulberry32 + let a = seed >>> 0; + return () => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; +} +function shuffle(xs, r) { const a = xs.slice(); for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(r() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; } + +// Presentation order from a seed: singles and A/B pairs are shuffled as units; inside a pair the A/B position is shuffled. +// Returns [{id, slot: 'A'|'B'|null}], a pair's two clips adjacent. +function planOrder(clips, seed) { + const r = rng(seed), seen = new Set(), units = []; + for (const c of clips) { + if (seen.has(c.id)) continue; + seen.add(c.id); + if (c.pair) { seen.add(c.pair); units.push([c.id, c.pair]); } else units.push([c.id]); + } + const out = []; + for (const u of shuffle(units, r)) { + if (u.length === 1) out.push({ id: u[0], slot: null }); + else { const [x, y] = shuffle(u, r); out.push({ id: x, slot: "A" }, { id: y, slot: "B" }); } + } + return out; +} + +// state: {seed, consent, listener, device, notes, answers: {id: {verdict, reason, landed, device}}, pairs: {"idA|idB": 'A'|'B'|'same'}} +function buildVerdict(manifest, order, state, now) { + const byId = new Map(manifest.clips.map((c) => [c.id, c])); + const slot = new Map(order.map((o) => [o.id, o.slot])); + const clips = order.map((o, i) => { + const c = byId.get(o.id), a = state.answers[o.id] || {}; + return { position: i + 1, id: c.id, title: c.title, group: c.group, feel: c.feel, file: c.file, + pair: c.pair || null, slot: o.slot, + verdict: VERDICTS.includes(a.verdict) ? a.verdict : null, reason: a.reason || "", + landed: Number.isInteger(a.landed) && a.landed >= 1 && a.landed <= 5 ? a.landed : null, + device: DEVICES.includes(a.device) ? a.device : null }; + }); + const pairs = []; + for (const o of order) { + const c = byId.get(o.id); + if (o.slot !== "A") continue; + const key = `${o.id}|${c.pair}`, p = state.pairs[key]; + pairs.push({ a: o.id, b: c.pair, preferred: p === "A" ? o.id : p === "B" ? c.pair : p === "same" ? "no-difference" : null }); + } + const count = (v) => clips.filter((c) => c.verdict === v).length; + return { schema: SCHEMA, kit: { id: manifest.kit.id, title: manifest.kit.title }, exportedAt: now, seed: state.seed, + consent: !!state.consent, listener: state.listener || "", device: state.device || null, notes: state.notes || "", + summary: { total: clips.length, keep: count("keep"), fix: count("fix"), drop: count("drop"), unanswered: clips.filter((c) => !c.verdict).length }, + clips, pairs }; +} + +const cell = (s) => String(s ?? "").replace(/\|/g, "\\|").replace(/\r?\n/g, " "); +function verdictMarkdown(v) { + const L = [`# Listening verdict: ${v.kit.title}`, "", + `Kit \`${v.kit.id}\`, exported ${v.exportedAt}, seed ${v.seed}. Listener: ${v.listener || "(anonymous)"}. Listening on: ${v.device || "not stated"}.`, + `Consent given: ${v.consent ? "yes" : "no"}.`, "", + `**${v.summary.keep} keep, ${v.summary.fix} fix, ${v.summary.drop} drop, ${v.summary.unanswered} unanswered** of ${v.summary.total}.`, "", + "| # | clip | group | intended feel | verdict | landed (1-5) | device | reason |", "|---|---|---|---|---|---|---|---|"]; + for (const c of v.clips) L.push(`| ${c.position} | ${cell(c.title)} (\`${cell(c.id)}\`)${c.slot ? ` [${c.slot}]` : ""} | ${cell(c.group)} | ${cell(c.feel)} | ${c.verdict ?? "-"} | ${c.landed ?? "-"} | ${c.device ?? "-"} | ${cell(c.reason)} |`); + if (v.pairs.length) { + L.push("", "## A/B pairs", "", "| A | B | preferred |", "|---|---|---|"); + for (const p of v.pairs) L.push(`| \`${p.a}\` | \`${p.b}\` | ${p.preferred ?? "-"} |`); + } + if (v.notes) L.push("", "## Notes", "", v.notes); + return L.join("\n") + "\n"; +} + +module.exports = { SCHEMA, VERDICTS, DEVICES, AUDIO_EXT, validateManifest, planOrder, buildVerdict, verdictMarkdown, rng }; diff --git a/tools/aqua-listen/package.json b/tools/aqua-listen/package.json new file mode 100644 index 0000000..0254838 --- /dev/null +++ b/tools/aqua-listen/package.json @@ -0,0 +1,7 @@ +{ + "name": "aqua-listen", + "private": true, + "type": "module", + "description": "Listening-test kit builder: a folder of clips and a manifest become one self-contained HTML page that collects keep/fix/drop verdicts. No dependencies.", + "scripts": { "build": "node build.mjs", "test": "node test.mjs" } +} diff --git a/tools/aqua-listen/smoke.mjs b/tools/aqua-listen/smoke.mjs new file mode 100644 index 0000000..471eb0c --- /dev/null +++ b/tools/aqua-listen/smoke.mjs @@ -0,0 +1,38 @@ +// Browser smoke for a built page: node smoke.mjs listen.html (needs playwright-core and a Chromium; set PLAYWRIGHT_CORE=/path/to/playwright-core +// and optionally CHROME=/path/to/chrome). Not part of `node test.mjs`: the repo has no browser dependency. +import { createRequire } from "node:module"; +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; +const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_CORE ?? "playwright-core"); +const file = resolve(process.argv[2]); +const browser = await chromium.launch({ executablePath: process.env.CHROME || undefined }); +const ctx = await browser.newContext({ acceptDownloads: true }), page = await ctx.newPage(); +const requests = [], errors = []; +page.on("request", (r) => { if (!r.url().startsWith("file:") && !r.url().startsWith("blob:") && !r.url().startsWith("data:")) requests.push(r.url()); }); +page.on("pageerror", (e) => errors.push(e.message)); +await page.goto("file://" + file); +const check = (c, m) => { if (!c) { console.error("FAIL", m); process.exitCode = 1; } else console.log("ok", m); }; +check(await page.locator("button:has-text('Start listening')").isDisabled(), "Start is disabled until consent is ticked"); +check((await page.locator("audio").count()) === 0, "no clip is shown before consent"); +await page.check("#consent"); await page.fill("#alias", "Tester"); await page.click("button:has-text('Start listening')"); +const total = await page.locator("audio").count(); +check(total > 0, `${total} clips shown after consent`); +check(!/Title|title/.test(await page.locator("main").innerText()), "titles are hidden while listening"); +await page.check("input[name=device][value=headphones]"); +const first = page.locator("section.card").first(); +await first.locator("input[value=fix]").check(); await first.locator("input[type=radio][name^=l-][value='4']").check(); await first.locator("input[type=text]").fill("a bit thin"); +await page.reload(); +check(await page.locator("section.card").first().locator("input[value=fix]").isChecked(), "answers survive a reload (localStorage autosave)"); +check((await page.locator("section.card").first().locator("input[type=text]").inputValue()) === "a bit thin", "reason survives a reload"); +const got = []; +page.on("download", (d) => got.push(d)); +await page.click("button:has-text('Export')"); +for (let i = 0; i < 50 && got.length < 2; i++) await page.waitForTimeout(100); +const names = got.map((d) => d.suggestedFilename()).sort(); +check(names.join() === "verdict.json,verdict.md", "export downloads verdict.json and verdict.md"); +const v = JSON.parse(readFileSync(await got.find((d) => d.suggestedFilename() === "verdict.json").path(), "utf8")); +check(v.listener === "Tester" && v.device === "headphones" && v.clips[0].verdict === "fix" && v.clips[0].landed === 4 && v.clips[0].device === "headphones", "verdict.json carries the answers"); +check(v.consent === true && v.clips.length === total, "consent recorded, every clip present"); +check(requests.length === 0, `no network requests (${requests.join(", ")})`); +check(errors.length === 0, `no page errors (${errors.join("; ")})`); +await browser.close(); diff --git a/tools/aqua-listen/test.mjs b/tools/aqua-listen/test.mjs new file mode 100644 index 0000000..702e122 --- /dev/null +++ b/tools/aqua-listen/test.mjs @@ -0,0 +1,109 @@ +// node test.mjs: manifest validation, ordering, verdict export shape, and the built page's isolation. No browser; see README for the browser smoke. +import assert from "node:assert/strict"; +import { createRequire } from "node:module"; +import { mkdtempSync, writeFileSync, mkdirSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { buildKit } from "./build.mjs"; + +const L = createRequire(import.meta.url)("./logic.cjs"); +let n = 0; +const test = (name, fn) => { fn(); n++; console.log("ok", name); }; +const clip = (id, extra = {}) => ({ id, file: `${id}.wav`, title: `Title ${id}`, feel: "calm", group: "g", ...extra }); +const mf = (clips) => ({ kit: { id: "k1", title: "Kit" }, clips }); +const has = (m, re) => L.validateManifest(m).some((e) => re.test(e)); + +test("a valid manifest has no problems", () => assert.deepEqual(L.validateManifest(mf([clip("a", { pair: "b" }), clip("b", { pair: "a" }), clip("c")])), [])); +test("manifest must be an object with clips", () => { assert.ok(L.validateManifest([]).length); assert.ok(has(mf([]), /non-empty/)); }); +test("kit id and title are required", () => { assert.ok(has({ kit: { id: "a b", title: "x" }, clips: [clip("a")] }, /kit\.id/)); assert.ok(has({ kit: { id: "a" }, clips: [clip("a")] }, /kit\.title/)); }); +test("every clip field is required", () => { for (const k of ["id", "file", "title", "feel", "group"]) { const c = clip("a"); delete c[k]; assert.ok(has(mf([c]), new RegExp(k + " is required")), k); } }); +test("duplicate ids are rejected", () => assert.ok(has(mf([clip("a"), clip("a", { file: "z.wav" })]), /duplicate id/))); +test("files must be audio and stay inside the folder", () => { + assert.ok(has(mf([clip("a", { file: "a.txt" })]), /must be \.wav/)); + assert.ok(has(mf([clip("a", { file: "../a.wav" })]), /relative path/)); + assert.ok(has(mf([clip("a", { file: "/etc/a.wav" })]), /relative path/)); + assert.ok(has(mf([clip("a", { file: "C:\\a.wav" })]), /relative path/)); +}); +test("pairs must exist, be mutual, and not be self", () => { + assert.ok(has(mf([clip("a", { pair: "zz" })]), /not a clip id/)); + assert.ok(has(mf([clip("a", { pair: "b" }), clip("b")]), /does not point back/)); + assert.ok(has(mf([clip("a", { pair: "b" }), clip("b", { pair: "c" }), clip("c", { pair: "b" })]), /does not point back/)); + assert.ok(has(mf([clip("a", { pair: "a" })]), /itself/)); +}); + +const clips = Array.from({ length: 12 }, (_, i) => clip("c" + i, i < 4 ? { pair: i % 2 ? "c" + (i - 1) : "c" + (i + 1) } : {})); +test("order is deterministic per seed, covers every clip once, and varies by seed", () => { + const a = L.planOrder(clips, 7), b = L.planOrder(clips, 7); + assert.deepEqual(a, b); + assert.deepEqual(a.map((o) => o.id).sort(), clips.map((c) => c.id).sort()); + assert.notDeepEqual(L.planOrder(clips, 8).map((o) => o.id), a.map((o) => o.id)); +}); +test("a pair is adjacent, slotted A then B, and both clips take position A across seeds", () => { + const firstA = new Set(); + for (let s = 1; s <= 40; s++) { + const o = L.planOrder(clips, s); + o.forEach((x, i) => { if (x.slot === "A") { assert.equal(o[i + 1].slot, "B"); assert.equal(clips.find((c) => c.id === x.id).pair, o[i + 1].id); if (x.id === "c0" || x.id === "c1") firstA.add(x.id); } else if (x.slot === null) assert.ok(!clips.find((c) => c.id === x.id).pair); }); + } + assert.deepEqual([...firstA].sort(), ["c0", "c1"]); +}); + +const manifest = mf([clip("a", { pair: "b", title: "Pipe | one" }), clip("b", { pair: "a" }), clip("c")]); +test("verdict.json has the exported shape", () => { + const order = [{ id: "c", slot: null }, { id: "b", slot: "A" }, { id: "a", slot: "B" }]; + const v = L.buildVerdict(manifest, order, { seed: 5, consent: true, listener: "Pat", device: "headphones", notes: "hi", + answers: { c: { verdict: "keep", reason: "clean", landed: 5, device: "headphones" }, a: { verdict: "bogus", landed: 9 } }, pairs: { "b|a": "B" } }, "2026-01-01T00:00:00Z"); + assert.equal(v.schema, L.SCHEMA); + assert.deepEqual(Object.keys(v), ["schema", "kit", "exportedAt", "seed", "consent", "listener", "device", "notes", "summary", "clips", "pairs"]); + assert.deepEqual(v.summary, { total: 3, keep: 1, fix: 0, drop: 0, unanswered: 2 }); + assert.deepEqual(Object.keys(v.clips[0]), ["position", "id", "title", "group", "feel", "file", "pair", "slot", "verdict", "reason", "landed", "device"]); + assert.deepEqual(v.clips.map((c) => c.id), ["c", "b", "a"]); + assert.equal(v.clips[0].verdict, "keep"); assert.equal(v.clips[0].landed, 5); + assert.equal(v.clips[2].verdict, null, "an unknown verdict is blank, not passed through"); assert.equal(v.clips[2].landed, null, "landed outside 1-5 is blank"); + assert.deepEqual(v.pairs, [{ a: "b", b: "a", preferred: "a" }], "pair choice B means the clip shown second"); + JSON.parse(JSON.stringify(v)); +}); +test("verdict.md lists every clip, escapes pipes, and states the totals", () => { + const order = L.planOrder(manifest.clips, 3); + const v = L.buildVerdict(manifest, order, { seed: 3, consent: true, answers: { c: { verdict: "drop", reason: "line1\nline2 | x", landed: 1 } }, pairs: {} }, "t"); + const md = L.verdictMarkdown(v); + assert.match(md, /^# Listening verdict: Kit/); + assert.match(md, /0 keep, 0 fix, 1 drop, 2 unanswered\*\* of 3/); + assert.match(md, /Pipe \\\| one/); assert.match(md, /line1 line2 \\\| x/); + assert.equal(md.split("\n").filter((l) => /^\| \d+ \|/.test(l)).length, 3); + assert.match(md, /## A\/B pairs/); +}); + +const dir = mkdtempSync(join(tmpdir(), "aqua-listen-")); +const wav = Buffer.alloc(44 + 400); wav.write("RIFF", 0); wav.write("WAVE", 8); +for (const id of ["a", "b", "c"]) writeFileSync(join(dir, id + ".wav"), wav); +test("the built page is one file with no network reach", () => { + const r = buildKit(manifest, dir), h = r.html; + assert.match(h, /Content-Security-Policy" content="default-src 'none'/); + assert.doesNotMatch(h, /connect-src|img-src|]*\ssrc=|(.*?)<\/script>/s.exec(h)[1]); + assert.equal(Buffer.from(data.audio.a.b64, "base64").compare(wav), 0); + assert.equal(data.hash, r.hash); +}); +test("the page shows the consent note first and skips it only for a returning, consenting listener", () => { + const h = buildKit(manifest, dir).html; + assert.ok(h.indexOf("function consent()") < h.indexOf("function main()")); + assert.ok(h.includes("if (load() && load().consent) start(); else consent();")); + assert.ok(h.includes("sends nothing anywhere")); +}); +test("the content hash changes when a clip changes", () => { + const h1 = buildKit(manifest, dir).hash; writeFileSync(join(dir, "c.wav"), Buffer.concat([wav, Buffer.from([1])])); + assert.notEqual(buildKit(manifest, dir).hash, h1); +}); +test("build refuses a missing file and a manifest escape, naming them", () => { + assert.throws(() => buildKit(mf([clip("zz")]), dir), /file not found: zz\.wav/); + assert.throws(() => buildKit(mf([clip("a", { file: "../x.wav" })]), dir), /relative path/); + assert.throws(() => buildKit(mf([clip("a", { title: "" })]), dir), /title is required/); +}); +test("markup in a title cannot break the page", () => { + const m = mf([clip("a", { title: "" , feel: ""})]); + const h = buildKit(m, dir).html; + assert.equal((h.match(/<\/script>/g) || []).length, 3); +}); +console.log(`${n} tests passed`); diff --git a/tools/aqua-listen/web/index.html b/tools/aqua-listen/web/index.html new file mode 100644 index 0000000..b54a6bb --- /dev/null +++ b/tools/aqua-listen/web/index.html @@ -0,0 +1,16 @@ + + + + + + +/*TITLE*/ + + + +
+ + + + + diff --git a/tools/aqua-listen/web/page.js b/tools/aqua-listen/web/page.js new file mode 100644 index 0000000..e232f3a --- /dev/null +++ b/tools/aqua-listen/web/page.js @@ -0,0 +1,109 @@ +// Page glue. The kit (manifest, content hash, base64 audio) is in #kit-data; logic is AquaListen (logic.cjs, inlined). +(() => { + const L = globalThis.AquaListen, kit = JSON.parse(document.getElementById("kit-data").textContent); + const app = document.getElementById("app"), KEY = `aqua-listen:${kit.manifest.kit.id}:${kit.hash}`; + let state = null, order = null; + + const save = () => { try { localStorage.setItem(KEY, JSON.stringify(state)); } catch (e) { /* private mode: the export still works */ } }; + const load = () => { try { const s = JSON.parse(localStorage.getItem(KEY)); return s && s.seed ? s : null; } catch (e) { return null; } }; + const h = (tag, attrs, ...kids) => { + const e = document.createElement(tag); + for (const [k, v] of Object.entries(attrs || {})) { if (k === "class") e.className = v; else if (k.startsWith("on")) e.addEventListener(k.slice(2), v); else if (v !== false && v != null) e.setAttribute(k, v === true ? "" : v); } + for (const k of kids.flat()) e.append(k); + return e; + }; + const blobUrl = (id) => { + const a = kit.audio[id], bin = atob(a.b64), u = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; i++) u[i] = bin.charCodeAt(i); + return URL.createObjectURL(new Blob([u], { type: a.mime })); + }; + + function consent() { + const box = h("input", { type: "checkbox", id: "consent" }), go = h("button", { disabled: true, onclick: start }, "Start listening"); + box.addEventListener("change", () => { go.disabled = !box.checked; }); + app.replaceChildren( + h("h1", {}, kit.manifest.kit.title), + h("div", { class: "card" }, + h("p", {}, h("strong", {}, "Before you start. ")), + h("p", {}, `You will hear ${kit.manifest.clips.length} short sounds in a random order and say what you think of each. Your answers help decide which sounds get kept, fixed or dropped.`), + h("ul", {}, + h("li", {}, "This page works on its own. It talks to no server, has no account and no tracking, and sends nothing anywhere."), + h("li", {}, "Your answers are saved in this browser only, so you can close the tab and come back. Clearing your browser data erases them."), + h("li", {}, "Nothing leaves your computer until you press Export, which saves two files. Sending those files to the person who gave you this page is your choice."), + h("li", {}, "You can stay anonymous. A name or nickname is optional.")), + h("p", {}, h("label", {}, box, " I understand, and I'm happy to take part.")), + h("p", {}, h("label", {}, "Name or nickname (optional) ", h("input", { type: "text", id: "alias", maxlength: "60" }))), + go)); + } + + function start() { + state = load() || { seed: (crypto.getRandomValues(new Uint32Array(1))[0] || 1), answers: {}, pairs: {}, device: null, notes: "", listener: "" }; + state.consent = true; state.listener = document.getElementById("alias") ? document.getElementById("alias").value.trim() || state.listener : state.listener; + save(); main(); + } + + const answered = (id) => { const a = state.answers[id]; return !!(a && a.verdict && a.landed); }; + function touch(id, patch) { + const a = state.answers[id] = Object.assign({}, state.answers[id], patch); + if (!a.device && state.device) a.device = state.device; + save(); progress(); + const card = document.getElementById("clip-" + id); if (card) card.classList.toggle("done", answered(id)); + } + function radios(name, values, current, onpick, labels) { + return values.map((v) => { const r = h("input", { type: "radio", name, value: String(v) }); if (String(current) === String(v)) r.checked = true; r.addEventListener("change", () => onpick(v)); return h("label", {}, r, " ", labels ? labels[v] : String(v)); }); + } + + function clipCard(o, n) { + const c = kit.manifest.clips.find((x) => x.id === o.id), a = state.answers[o.id] || {}, id = o.id; + const audio = h("audio", { controls: true, preload: "none" }); audio.src = blobUrl(id); + const reason = h("input", { type: "text", maxlength: "300", value: a.reason || "", placeholder: "One line: why?" }); + reason.addEventListener("input", () => touch(id, { reason: reason.value })); + return h("section", { class: "card" + (answered(id) ? " done" : ""), id: "clip-" + id }, + h("h2", {}, o.slot ? `Sound ${o.slot}` : `Sound ${n}`), + h("p", { class: "feel" }, `It should feel: ${c.feel}`), + audio, + h("div", { class: "row" }, h("span", {}, "Keep, fix or drop?"), radios("v-" + id, L.VERDICTS, a.verdict, (v) => touch(id, { verdict: v }))), + h("div", { class: "row" }, h("span", {}, "Did it land? 1 = not at all, 5 = completely"), radios("l-" + id, [1, 2, 3, 4, 5], a.landed, (v) => touch(id, { landed: Number(v) }))), + reason); + } + + function main() { + order = L.planOrder(kit.manifest.clips, state.seed); + const byId = new Map(kit.manifest.clips.map((c) => [c.id, c])); + const prog = h("span", { id: "progress" }); + const dev = h("span", {}, "I'm listening on: ", radios("device", L.DEVICES, state.device, (v) => { state.device = v; save(); })); + const cards = []; let n = 0; + for (let i = 0; i < order.length; i++) { + const o = order[i]; + if (o.slot === "A") { + const b = order[i + 1], key = `${o.id}|${byId.get(o.id).pair}`; + const pick = h("div", { class: "row" }, h("span", {}, "Which do you prefer?"), radios("p-" + key, ["A", "B", "same"], state.pairs[key], (v) => { state.pairs[key] = v; save(); }, { A: "A", B: "B", same: "No difference" })); + n++; cards.push(h("div", { class: "pair" }, h("h3", {}, `Pair ${n}: A and B`), clipCard(o, n), clipCard(b, n), pick)); i++; + } else { n++; cards.push(clipCard(o, n)); } + } + const notes = h("textarea", { rows: "3", placeholder: "Anything else? (optional)" }, state.notes || ""); notes.addEventListener("input", () => { state.notes = notes.value; save(); }); + app.replaceChildren( + h("h1", {}, kit.manifest.kit.title), + kit.manifest.kit.note ? h("p", { class: "hint" }, kit.manifest.kit.note) : "", + h("div", { class: "bar" }, h("div", { class: "row" }, dev, prog)), + ...cards, + h("div", { class: "card" }, h("h2", {}, "Finished?"), notes, + h("p", { class: "hint" }, "Export saves verdict.json and verdict.md to your downloads. Unanswered sounds are exported as blank."), + h("div", { class: "row" }, h("button", { onclick: exportAll }, "Export verdict.json + verdict.md"), h("button", { class: "quiet", onclick: reset }, "Erase my answers")))); + progress(); + } + + function progress() { const e = document.getElementById("progress"); if (e) e.textContent = `${kit.manifest.clips.filter((c) => answered(c.id)).length} of ${kit.manifest.clips.length} answered`; } + function download(name, text, type) { + const a = h("a", { href: URL.createObjectURL(new Blob([text], { type })), download: name }); + document.body.append(a); a.click(); a.remove(); + } + function exportAll() { + const v = L.buildVerdict(kit.manifest, order, state, new Date().toISOString()); + download("verdict.json", JSON.stringify(v, null, 2) + "\n", "application/json"); + download("verdict.md", L.verdictMarkdown(v), "text/markdown"); + } + function reset() { if (confirm("Erase every answer you've given in this browser?")) { try { localStorage.removeItem(KEY); } catch (e) {} location.reload(); } } + + if (load() && load().consent) start(); else consent(); +})(); diff --git a/tools/aqua-listen/web/styles.css b/tools/aqua-listen/web/styles.css new file mode 100644 index 0000000..00652d8 --- /dev/null +++ b/tools/aqua-listen/web/styles.css @@ -0,0 +1,18 @@ +:root { color-scheme: light dark; --fg: #1d1f24; --bg: #f6f5f1; --card: #fff; --line: #cfcdc4; --accent: #1f5f8b; } +@media (prefers-color-scheme: dark) { :root { --fg: #e8e6df; --bg: #17181b; --card: #212328; --line: #3a3d44; --accent: #6db3e0; } } +body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, sans-serif; } +main { max-width: 46rem; margin: 0 auto; padding: 1rem; } +h1 { font-size: 1.4rem; margin: 0.5rem 0; } +.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin: 1rem 0; } +.card.done { border-left: 6px solid var(--accent); } +.feel { font-style: italic; } +.row { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; margin: 0.5rem 0; } +.row label { white-space: nowrap; } +input[type=text], textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 0.4rem; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; } +audio { width: 100%; } +button { font: inherit; padding: 0.5rem 1rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; } +button.quiet { background: transparent; color: var(--accent); } +button:disabled { opacity: 0.4; cursor: default; } +.bar { position: sticky; top: 0; background: var(--bg); padding: 0.5rem 0; border-bottom: 1px solid var(--line); z-index: 1; } +.pair { border: 2px dashed var(--line); border-radius: 10px; padding: 0 0.75rem; margin: 1rem 0; } +small, .hint { opacity: 0.75; } From 3d01ff4db107aa9f5a9ad132e16321b1aaf2ba96 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sun, 8 Nov 2026 00:57:36 +0000 Subject: [PATCH 038/124] Speech: bare IPA n is an alveolar nasal; word script on the experiment scaffold; WordRender probe PatchScript.GestureDescriptor had no case for n, so it fell to the alveolar approximant (no velum). IpaGestureExperiment.BuildWordScript runs gestures back to back on the same scaffold as BuildCandidateScript (refactored onto one Scaffold). tools/WordRender renders a word offline through native libfaust, driving surface sliders from ControlSplineTimeline because the Faust exporter's summed spline offsets do not sequence gestures. Two tests. Nothing was heard: the render is a near-pure sine with no vowel quality. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Core/IpaGestureExperiment.cs | 63 ++++++++++---- src/AquaSynth.Core/PatchScript.cs | 1 + tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs | 41 +++++++++ tools/WordRender/Program.cs | 87 +++++++++++++++++++ tools/WordRender/WordRender.csproj | 12 +++ 5 files changed, 185 insertions(+), 19 deletions(-) create mode 100644 tools/WordRender/Program.cs create mode 100644 tools/WordRender/WordRender.csproj diff --git a/src/AquaSynth.Core/IpaGestureExperiment.cs b/src/AquaSynth.Core/IpaGestureExperiment.cs index 27b94cc..146f1ef 100644 --- a/src/AquaSynth.Core/IpaGestureExperiment.cs +++ b/src/AquaSynth.Core/IpaGestureExperiment.cs @@ -196,27 +196,52 @@ public static class IpaGestureExperiment var duration = Math.Clamp(target.DurationSeconds * variant.DurationScale, 0.03f, 1.5f); var intensity = Math.Clamp(variant.IntensityScale, 0.05f, 2f); - var sustain = Math.Clamp(duration + 0.12f, 0.15f, 2f); - var descriptor = target.Descriptor.Replace(' ', '_'); - var frequency = DescriptorTokens(target.Descriptor).Contains("vowel") ? 150 : 135; - - return $$""" - patch gain=.45 - morphology name=oral length_cm=17 diameters=.55,.75,1.05,1.45,1.25,.8 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 lip_opening=1.2 - morphology name=nasal length_cm=12 diameters=.04,.28,.52,.72 - waveguide_path name=oral_path morphology=oral strategy=thiran order=1 max_delay=4096 loss=.998 - waveguide_path name=nasal_path morphology=nasal strategy=thiran order=1 max_delay=4096 loss=.997 - source_port name=folds path=oral_path kind=glottal position=0 pressure=.66 tension=.54 opening=.42 noise=.04 impedance=.32 flow_scale=.12 - branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=.01 coupling=1 - constriction_contact name=contact path=oral_path position=.92 opening=.5 resistance=.45 stored_pressure=.12 - radiation_load name=mouth path=oral_path kind=lip position=1 aperture=.8 reflection=-.82 impedance=.28 - probe_timeline name=flow network=voice blocks=12 block_size=64 - vocal_network name=voice paths=oral_path,nasal_path sources=folds contacts=contact branches=velopharynx radiation=mouth probe=flow - phoneme_gesture name={{SafeDslName(target.Id)}} ipa={{target.Ipa}} descriptor={{descriptor}} start=0 dur={{Format(duration)}} intensity={{Format(intensity)}} - vocal network=voice freq={{Format(frequency)}} gain=.7 sustain={{Format(sustain)}} - """; + return Scaffold( + [GestureLine(target, 0, duration, intensity)], + Math.Clamp(duration + 0.12f, 0.15f, 2f), + DescriptorTokens(target.Descriptor).Contains("vowel") ? 150 : 135); } + /// + /// One word on the same scaffold: the targets run back to back, each at its own intensity (a stress mark is a higher + /// intensity on the stressed vowel). An empty descriptor leaves it to the DSL's own IPA table. Pitch stays flat at ; no contour is authored. + /// + public static string BuildWordScript(IReadOnlyList<(IpaGestureExperimentTarget Target, float Intensity)> phones, float frequency = 140, float tailSeconds = 0.12f) + { + if (phones.Count == 0) throw new ArgumentException("a word needs at least one phone", nameof(phones)); + var lines = new List(); + var start = 0f; + foreach (var (target, intensity) in phones) + { + ArgumentException.ThrowIfNullOrWhiteSpace(target.Id); + ArgumentException.ThrowIfNullOrWhiteSpace(target.Ipa); + var duration = Math.Clamp(target.DurationSeconds, 0.03f, 1.5f); + lines.Add(GestureLine(target, start, duration, Math.Clamp(intensity, 0.05f, 2f))); + start += duration; + } + + return Scaffold(lines, Math.Clamp(start + tailSeconds, 0.15f, 4f), frequency); + } + + private static string GestureLine(IpaGestureExperimentTarget target, float start, float duration, float intensity) => + $"phoneme_gesture name={SafeDslName(target.Id)} ipa={target.Ipa} {(target.Descriptor.Length == 0 ? "" : $"descriptor={target.Descriptor.Replace(' ', '_')} ")}start={Format(start)} dur={Format(duration)} intensity={Format(intensity)}"; + + private static string Scaffold(IReadOnlyList gestureLines, float sustain, float frequency) => $$""" + patch gain=.45 + morphology name=oral length_cm=17 diameters=.55,.75,1.05,1.45,1.25,.8 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 lip_opening=1.2 + morphology name=nasal length_cm=12 diameters=.04,.28,.52,.72 + waveguide_path name=oral_path morphology=oral strategy=thiran order=1 max_delay=4096 loss=.998 + waveguide_path name=nasal_path morphology=nasal strategy=thiran order=1 max_delay=4096 loss=.997 + source_port name=folds path=oral_path kind=glottal position=0 pressure=.66 tension=.54 opening=.42 noise=.04 impedance=.32 flow_scale=.12 + branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=.01 coupling=1 + constriction_contact name=contact path=oral_path position=.92 opening=.5 resistance=.45 stored_pressure=.12 + radiation_load name=mouth path=oral_path kind=lip position=1 aperture=.8 reflection=-.82 impedance=.28 + probe_timeline name=flow network=voice blocks=12 block_size=64 + vocal_network name=voice paths=oral_path,nasal_path sources=folds contacts=contact branches=velopharynx radiation=mouth probe=flow + {{string.Join("\n", gestureLines)}} + vocal network=voice freq={{Format(frequency)}} gain=.7 sustain={{Format(sustain)}} + """; + private static IReadOnlyList SummarizeMetrics(IReadOnlyList metrics) => metrics .Where(metric => metric.Layer.Equals("gesture", StringComparison.OrdinalIgnoreCase)) diff --git a/src/AquaSynth.Core/PatchScript.cs b/src/AquaSynth.Core/PatchScript.cs index 91fafa7..d47cbe5 100644 --- a/src/AquaSynth.Core/PatchScript.cs +++ b/src/AquaSynth.Core/PatchScript.cs @@ -1518,6 +1518,7 @@ public static class PatchScript "p" => "voiceless_bilabial_plosive", "b" => "voiced_bilabial_plosive", "m" => "voiced_bilabial_nasal", + "n" => "voiced_alveolar_nasal", "s" => "voiceless_alveolar_fricative", "z" => "voiced_alveolar_fricative", "ʃ" => "voiceless_postalveolar_fricative", diff --git a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs index 1d00e05..9ace5ec 100644 --- a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs +++ b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs @@ -613,6 +613,47 @@ public sealed class PatchScriptTests Assert.True(fricativeControls["/vocal/sources/0/noise"] > nasalControls["/vocal/sources/0/noise"]); } + [Fact] + public void BareNIsAnAlveolarNasalNotTheApproximantFallback() + { + var patch = PatchScript.Parse(""" + morphology name=oral length_cm=17 diameters=.6,.8,1.2,1.6,1.3,.9 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 lip_opening=1.5 + morphology name=nasal length_cm=12 diameters=.05,.35,.6,.8 + waveguide_path name=oral_path morphology=oral loss=.998 + waveguide_path name=nasal_path morphology=nasal loss=.997 + source_port name=folds path=oral_path pressure=.7 tension=.55 opening=.45 noise=.05 impedance=.3 + branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=.01 coupling=1 + constriction_contact name=contact path=oral_path position=.92 opening=.5 resistance=.4 stored_pressure=.1 + radiation_load name=mouth path=oral_path aperture=.8 reflection=-.82 impedance=.28 + vocal_network name=voice paths=oral_path,nasal_path sources=folds contacts=contact branches=velopharynx radiation=mouth + phoneme_gesture name=en ipa=n start=0 dur=.1 + vocal network=voice freq=140 gain=.2 sustain=.3 + """); + + Assert.Equal("voiced_alveolar_nasal", patch.PhonemeGestures.Single().Descriptor); + Assert.Contains(patch.ControlSplines, spline => spline.Name.StartsWith("en_velum", StringComparison.Ordinal) && spline.SurfacePath == "/vocal/branches/0/opening"); + var catalog = ControlSurfaceCatalog.FromPatch(patch); + Assert.True(catalog.CreateTimeline().ControlValuesAt(.03f)["/vocal/branches/0/opening"] > .5f, "the velum opens for n"); + } + + [Fact] + public void WordScriptRunsGesturesBackToBackAndLeavesDescriptorsToTheDslTable() + { + var script = IpaGestureExperiment.BuildWordScript( + [ + (new IpaGestureExperimentTarget("w_n", "n", "", .1f), 1f), + (new IpaGestureExperimentTarget("w_i", "i", "", .2f), 1.2f), + (new IpaGestureExperimentTarget("w_b", "b", "", .1f), 1f) + ], frequency: 140); + + var patch = PatchScript.Parse(script); + Assert.Equal(["n", "i", "b"], patch.PhonemeGestures.Select(gesture => gesture.Ipa)); + Assert.Equal([0f, .1f, .3f], patch.PhonemeGestures.Select(gesture => gesture.StartSeconds)); + Assert.Equal(["voiced_alveolar_nasal", "voiced_close_front_unrounded_vowel", "voiced_bilabial_plosive"], patch.PhonemeGestures.Select(gesture => gesture.Descriptor)); + Assert.Equal(1.2f, patch.PhonemeGestures[1].Intensity); + Assert.Throws(() => IpaGestureExperiment.BuildWordScript([])); + } + [Fact] public void IpaGestureExperimentWritesFrozenRoundBundle() { diff --git a/tools/WordRender/Program.cs b/tools/WordRender/Program.cs new file mode 100644 index 0000000..807b57a --- /dev/null +++ b/tools/WordRender/Program.cs @@ -0,0 +1,87 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text.Json; +using AquaSynth.Dsl; +using AquaSynth.Faust; + +// Offline probe: one word as a run of IPA gestures on the IpaGestureExperiment scaffold, rendered through the native +// libfaust path to a mono 16-bit WAV plus script.aqua, source.dsp and manifest.json. It measures peak, rms and NaN; +// it cannot say how the word sounds. +// usage: WordRender