0.42.0 (79): preset randomizer for five devices (Android and iOS)
A RANDOM button in the preset bar of the Synth, Morph Pad, Grain Cloud, Wavetable and Ambience Reverb editors: it rolls a playable patch and names it. The rules live in core/src/model/Randomizer.cpp and are shared, so a seed gives the same patch on both platforms. Android reaches it over JNI as preset text and imports it; iOS writes the Params into the slot. Neither touches the slot's own files — a loaded sample or an imported wavetable survives a roll, because the dice are for the settings, not for the sounds. Scattering values over the parameter ranges produces silence and the occasional scream, so the rules encode three things instead: something always sounds (a layer is always up, an envelope that decays to nothing gets a body, a filter is never shut, a reverb is never fully dry); levels share a budget and resonance, drive and saturation stay out of the range where a patch screams; and tunings come from consonant intervals rather than a uniform draw. core/tests/randomizer_test.cpp is the specification: it renders every device over hundreds of seeds through the real voice and fails on anything out of range, silent, clipping or non-finite. Every bound that looks arbitrary was put there by a seed it caught — a band-pass parked above the note (peak 0.010 against a 0.3 median), a Vel -> Cutoff mod slot closing the filter (0.41 -> 0.02), a choir-only Morph Pad through its own band-pass, and MORPH TO, which a roll now leaves alone because MORPH TIME carries a held note all the way onto a factory drone at a level the randomizer never chose (1.33 with every layer of its own at zero). --dump <TYPE> <seed> [key=value ...] re-renders one roll with overrides, which is how each of those was found. Also fixes the shared engine not compiling outside Apple's toolchain: a missing <cstdint> in core/include/sizzle/Model.hpp. No change to the apps, but the engine's tests and benchmark now build with GCC too — which is how the rules above were iterated while the Mac was unreachable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
b3bae931b1
commit
0e8032532f
@@ -252,7 +252,7 @@ cc.tiredsysadmin.android.sizzle
|
||||
│ └── EchofieldDefs.kt Its settings, 14 factory presets, the source list
|
||||
│
|
||||
├── cpp/native_audio.cpp Low-latency Oboe stream; its RT callback renders core/ directly
|
||||
├── cpp/jni_engine.cpp The JNI surface of core/src/host/EngineHost
|
||||
├── cpp/jni_engine.cpp The JNI surface of core/src/host/EngineHost (+ the preset randomizer)
|
||||
│
|
||||
├── io/ Human-readable text persistence
|
||||
│ ├── PresetIo.kt Instrument/effect preset <-> KEY=VALUE text
|
||||
@@ -457,6 +457,60 @@ connected BLE MIDI peripherals are remembered and reconnected at launch through
|
||||
CoreBluetooth (best effort: iOS decides whether that brings the CoreMIDI source
|
||||
back without the panel).
|
||||
|
||||
### 5.4.4 The preset randomizer (0.42.0)
|
||||
|
||||
`core/src/model/Randomizer.cpp` turns a seed into a playable patch for the five
|
||||
devices where "surprise me" is a musical thing to ask: **Synth**, **Morph Pad**,
|
||||
**Grain Cloud**, **Wavetable** and **Ambience Reverb**. Both apps show it as a
|
||||
**RANDOM** button in the shared preset bar, and the same seed gives the same patch
|
||||
on both (`model::randomize(type, seed, Params&)`).
|
||||
|
||||
**Why it is not just `random()` over each range.** Scattering values over the
|
||||
parameter ranges mostly produces silence and the occasional scream. The rules
|
||||
encode three things instead:
|
||||
|
||||
- *audible*: something always sounds. One oscillator or layer is always up, an
|
||||
envelope that decays to nothing is given a body, a filter is never shut, and a
|
||||
reverb is never fully dry.
|
||||
- *inside the rails*: oscillator levels share a budget, resonance, drive and
|
||||
saturation stay out of the range where a patch screams, and the reverb's wet sits
|
||||
under its dry.
|
||||
- *musical where it matters*: tunings come from consonant intervals, detune stays
|
||||
inside a chorus, and pitch modulation stays small enough to keep a patch in tune.
|
||||
|
||||
**Nothing structural is rolled.** "Custom" sources and tables are never picked and
|
||||
the slot's own keys (`sfSample`, `sfFile`, the Sampler's pads) survive a roll — a
|
||||
sample or an imported wavetable is the user's, and the dice are for the settings.
|
||||
`MORPH TO` is left Off for the same reason *and* for a measured one (below).
|
||||
|
||||
**The test is the specification.** `core/tests/randomizer_test.cpp` (part of
|
||||
`make -C ios core-test`) renders every device over hundreds of seeds through the
|
||||
real voice — the golden tests' `TestVoice` wrappers — and fails on a patch that
|
||||
is out of range, silent, clipping or non-finite. Every bound in Randomizer.cpp
|
||||
that looks arbitrary was put there by a seed this test caught; four worth knowing,
|
||||
because each is a trap the next device will have too:
|
||||
|
||||
| What it caught | Why |
|
||||
|---|---|
|
||||
| A band-pass parked above the note | Only a *low*-pass is open at the top. Band and high need a cutoff near or under the played pitch, or a patch with every oscillator up is silent (peak 0.010 against a median of 0.3). `cutoffFor` is the shared fix. |
|
||||
| `Vel → Cutoff` at −0.69 | A mod slot can close the filter. Pitch, Cutoff, PWM and Amp get bounded amounts; Cutoff asymmetrically, since opening is free and closing is not. |
|
||||
| A choir-only Morph Pad through a band-pass | That filter is on the choir layer alone — the partials and breath go round it — so a patch whose choir is its only layer gets a plain open low-pass. |
|
||||
| `MORPH TO` + `MORPH TIME` | A held note travels all the way onto a factory drone and *is* that preset from then on, at a level the randomizer never chose (peak 1.33 with every layer of its own at zero). Budgeting cannot reach past a morph, so a roll does not pick a target. |
|
||||
|
||||
`randomizer_test --dump <TYPE> <seed> [key=value …]` prints one roll and what it
|
||||
measured, with overrides, which is how each of those was found: re-render the same
|
||||
patch with one value changed until the peak moves.
|
||||
|
||||
**How it reaches the apps.** Android: `nativeCanRandomize` / `nativeRandomPreset` /
|
||||
`nativeRandomName` in `jni_engine.cpp` (pure functions — no engine, so they work
|
||||
before `nativeCreate`), the patch arriving as `PresetIo` text that
|
||||
`AppViewModel.randomizeSlot` imports. iOS: `SizzleSession.randomizeSlot` writes the
|
||||
`Params` into the slot directly. Both keep the slot's non-parameter keys.
|
||||
|
||||
**Adding a device to it** means writing its rules in Randomizer.cpp, adding its
|
||||
name to `kRandomizable`, and adding a row to `kDevices` in the test with a floor
|
||||
and a ceiling. The button then appears on both platforms with no UI change.
|
||||
|
||||
### 5.5 Sizzle as a background MIDI sound module
|
||||
|
||||
Goal: another app (Mikro Seq, a DAW, a controller app) plays Sizzle's mixer over
|
||||
@@ -742,6 +796,9 @@ of real time on a desktop JVM.
|
||||
- **Keep the reference in step**: mirror the change in the Kotlin file under
|
||||
`app/src/test/.../audio` (or `frasil` / `echofield` / `wavetable`), then
|
||||
`make -C ios golden core-test` to check the two sample for sample.
|
||||
4. Optionally give it a **RANDOM** button: rules in `core/src/model/Randomizer.cpp`,
|
||||
its name in `kRandomizable`, a row in `randomizer_test`'s `kDevices`. See §5.4.4 —
|
||||
and read its table of traps before inventing bounds.
|
||||
The Toolbox picker, parameter editor, and preset save/load all work automatically
|
||||
from the `ParamSpec` list (the editor then shows one card with every parameter).
|
||||
3. Group its controls: add a case to `DeviceLayouts.pagesFor` (cards, tones,
|
||||
|
||||
@@ -345,6 +345,8 @@ its number to switch it off/on:
|
||||
Every device editor has a preset bar at the top:
|
||||
|
||||
- **PRESET** dropdown — load a saved preset.
|
||||
- **RANDOM** — roll a new patch (Synth, Morph Pad, Grain Cloud, Wavetable and
|
||||
Ambience Reverb only; see below).
|
||||
- **SAVE** — save the current settings as a named preset.
|
||||
- **DELETE** — remove the selected preset (asks to confirm).
|
||||
- **IMPORT** — load a preset from a file (Sampler presets can be imported from a
|
||||
@@ -355,6 +357,26 @@ Presets are plain text (`.szp`), stored per device type in the app's storage.
|
||||
Factory presets are seeded automatically and reappear as new ones ship, but ones
|
||||
you delete stay deleted.
|
||||
|
||||
### RANDOM
|
||||
|
||||
The five devices with the most knobs — **Synth**, **Morph Pad**, **Grain Cloud**,
|
||||
**Wavetable** and **Ambience Reverb** — have a **RANDOM** button that throws a new
|
||||
patch into the editor and gives it a name ("Hazy Drift"). It is a starting point,
|
||||
not a slot machine: a roll is always something you can hear and never something
|
||||
that clips, because the levels, the filters and the envelopes are drawn inside
|
||||
ranges that keep a patch in that territory rather than scattered over the whole
|
||||
knob. Expect a usable sound most of the time and a keeper now and then.
|
||||
|
||||
RANDOM replaces the settings in the editor, exactly like loading a preset, so
|
||||
**SAVE** anything you want to keep first. It does *not* touch a sample you have
|
||||
loaded or a wavetable you have imported — the roll is of the settings, not of
|
||||
your sounds. Roll again as often as you like; when one is worth keeping, SAVE it.
|
||||
|
||||
The other devices have no RANDOM, and that is deliberate: a Sampler or an SF2/XI
|
||||
loader is only as interesting as the sound you put in it, and the MIDI effects
|
||||
(arpeggiator, transposer, LFO) have so few settings that a dice roll says nothing
|
||||
a glance at them would not.
|
||||
|
||||
---
|
||||
|
||||
## Setup tab
|
||||
|
||||
Reference in New Issue
Block a user