// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later #pragma once // The preset pseudorandomizer: a playable patch from a seed, for the five devices // where "surprise me" is a musical thing to ask for. Shared by both apps (handover // §5.4.2's parity rule), so a roll of the dice gives the same patch on Android and // on iOS for the same seed. // // "Playable" is the whole point, and it is what makes this more than scattering // values over the parameter ranges: // // - audible. Something always sounds: at least one oscillator or layer is up, an // amp envelope that decays to nothing gets 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 below the range where a patch screams, and the reverb's wet // and dry cannot both sit at 0 dB. `randomizer_test` renders every device over // many seeds and fails if a patch comes out silent or clipping. // - musical where it matters. Tunings come from consonant intervals rather than // a uniform draw over ±12 semitones, detune stays inside a chorus, and pitch // modulation is small enough to stay in tune. // // Nothing structural is rolled: a sample or an imported wavetable is the user's // choice, so "Custom" sources and tables are never picked, and the sample keys a // slot already holds are left alone. #include #include #include "sizzle/Params.hpp" namespace sizzle::model { /** True when [type] (a ToolboxType name) has a randomizer: NES_SYNTH, MORPH_PAD, * GRAIN_CLOUD, WAVETABLE and AMBIENCE. The UI shows its dice button for these. */ bool canRandomize(const char *type); /** Fill [out] with a playable random patch for [type]. Every value is written * through the device's own ParamSpec, so nothing can land outside its range or * off an enum's choices. [seed] makes it reproducible: the same seed is the same * patch, here and on the other platform. Returns false, leaving [out] untouched, * for a type with no randomizer. */ bool randomize(const char *type, uint32_t seed, Params &out); /** A short two-word name for the patch [seed] produces ("Hazy Drift"), so a roll * arrives with something to call it and SAVE has a name to offer. Empty for a * type with no randomizer. */ std::string randomName(const char *type, uint32_t seed); /** The whole thing as preset text (io::PresetIo's format, NAME included) — what * the Android app receives over JNI and hands to PresetIo.import. Empty for a * type with no randomizer. */ std::string randomPresetText(const char *type, uint32_t seed); } // namespace sizzle::model