0.42.0 (78): 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
e78b2c1418
commit
0d6ed4694f
@@ -5,6 +5,17 @@ Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
|
||||
is shared with Android, continuing Android's numbering, and both apps ship the
|
||||
same features; the Android side of each version is in `../CHANGELOG.md`.
|
||||
|
||||
## 0.42.0 (build 78)
|
||||
|
||||
- RANDOM: the Synth, Morph Pad, Grain Cloud, Wavetable and Ambience Reverb
|
||||
editors have a RANDOM button in the preset bar, which rolls a new patch and
|
||||
names it. Always audible, never clipping — the ranges it draws from are picked
|
||||
to keep a patch there rather than scattered over the whole knob. It replaces the
|
||||
editor's settings like a preset does (SAVE first to keep what is there) and
|
||||
leaves a loaded sample or an imported wavetable alone. The same rules and the
|
||||
same seeds as Android, from `core/src/model/Randomizer.cpp`.
|
||||
(Android has the same in 0.42.0.)
|
||||
|
||||
## 0.41.1 (build 77)
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
+8
-1
@@ -100,6 +100,12 @@ build/core/oneshot_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/oneshot_test.cpp
|
||||
mkdir -p build/core
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/oneshot_test.cpp
|
||||
|
||||
# The randomizer plays what it generates, so it links the golden tests' TestVoice
|
||||
# wrappers too (see VOICE_SRC).
|
||||
build/core/randomizer_test: $(CORE_SRC) $(CORE_HDR) $(VOICE_SRC) $(VOICE_HDR) ../core/tests/randomizer_test.cpp
|
||||
mkdir -p build/core
|
||||
$(CXX) $(CXXFLAGS) -I../core/tests -o $@ $(CORE_SRC) $(VOICE_SRC) ../core/tests/randomizer_test.cpp
|
||||
|
||||
build/core/bench: $(CORE_SRC) $(CORE_HDR) ../core/tests/bench.cpp
|
||||
mkdir -p build/core
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/bench.cpp
|
||||
@@ -125,7 +131,7 @@ zip-test: build/core/zip_test
|
||||
build/core/zip_test build/core/java.zip build/core/ours.zip
|
||||
unzip -tq build/core/ours.zip
|
||||
|
||||
core-test: build/core/golden_test build/core/sampler_test build/core/engine_test build/core/io_test build/core/midi_test build/core/host_test build/core/midimap_test build/core/bundle_test build/core/oneshot_test zip-test
|
||||
core-test: build/core/golden_test build/core/sampler_test build/core/engine_test build/core/io_test build/core/midi_test build/core/host_test build/core/midimap_test build/core/bundle_test build/core/oneshot_test build/core/randomizer_test zip-test
|
||||
@test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden
|
||||
build/core/golden_test $(GOLDEN) $(TYPES)
|
||||
build/core/sampler_test
|
||||
@@ -136,6 +142,7 @@ core-test: build/core/golden_test build/core/sampler_test build/core/engine_test
|
||||
build/core/midimap_test ../app/src/test/resources/midimap/filter.szm
|
||||
build/core/oneshot_test
|
||||
build/core/bundle_test $(GOLDEN)/bundles/android_sampler.zip ../app/src/test/resources/presetbundle/ios_sampler.zip
|
||||
build/core/randomizer_test $(SEEDS)
|
||||
|
||||
# ------------------------------------------------------------------ app
|
||||
AU_SRC := app/FX/SizzleDeviceAU.mm app/FX/SizzleEffectAU.mm app/FX/SizzleInstrumentAU.mm app/FX/SizzleDeviceAU+Sources.mm
|
||||
|
||||
@@ -12,6 +12,7 @@ Makefile (`make -C ios help`).
|
||||
| `../core/tests/golden_test.cpp` | Compares the core with audio the Kotlin code renders |
|
||||
| `../core/tests/voices/` | The `TestVoice` wrappers `golden_test` drives the instruments through. Under `tests/`, not `src/`, so neither app compiles them |
|
||||
| `../core/tests/bench.cpp` | `make bench`: what the FX chain and each effect cost. Asserts nothing, so it is not part of `core-test` |
|
||||
| `../core/tests/randomizer_test.cpp` | Plays what the preset randomizer generates over many seeds: in range, audible, not clipping. `--dump <TYPE> <seed> [key=value …]` inspects one roll |
|
||||
| `app/components.txt` | The plugin list (AU type, subtype, device, name) |
|
||||
| `app/FX/` | The plugin extension: `SizzleDeviceAU` (shared: parameters, presets, state), `SizzleEffectAU` (aufx), `SizzleInstrumentAU` (aumu), `SizzleFXViewController` (factory + editor). The app compiles the same classes to host them itself |
|
||||
| `app/Host/SizzleSession*` | The bridge to the C++ song + engine (audio output, song lock, live-note queue); one category per screen |
|
||||
|
||||
@@ -246,6 +246,16 @@ private struct PresetBar: View {
|
||||
MixKit.Button(label: "DELETE", danger: true) { confirmDelete = current }
|
||||
Spacer().frame(width: 20)
|
||||
}
|
||||
// RANDOM, for the devices core/'s randomizer covers (the Synth,
|
||||
// Morph Pad, Grain Cloud, Wavetable and Ambience). It replaces the
|
||||
// settings in place, the way loading a preset does.
|
||||
if session.canRandomizeType(type) {
|
||||
MixKit.Button(label: "RANDOM") {
|
||||
guard session.randomizeSlot(slot) != nil else { return }
|
||||
selected = nil
|
||||
model.refresh()
|
||||
}
|
||||
}
|
||||
MixKit.Button(label: "SAVE") {
|
||||
saveName = slotName.trimmingCharacters(in: .whitespaces).isEmpty ? displayName : slotName
|
||||
saving = true
|
||||
|
||||
@@ -136,6 +136,12 @@ NS_SWIFT_UI_ACTOR
|
||||
/// Factory preset names for a device type (Android's PresetLibrary set).
|
||||
- (NSArray<NSString *> *)factoryPresetsForType:(NSString *)type;
|
||||
- (void)applyFactoryPreset:(NSString *)name toSlot:(NSInteger)slot;
|
||||
/// Does this device type have a preset randomizer (core/src/model/Randomizer.cpp)?
|
||||
- (BOOL)canRandomizeType:(NSString *)type;
|
||||
/// Roll a playable patch into [slot] and return the name it came with, or nil when
|
||||
/// the slot's device has no randomizer. The slot's own files — a loaded sample, an
|
||||
/// imported wavetable — are kept: the roll is of the settings, not of the sounds.
|
||||
- (nullable NSString *)randomizeSlot:(NSInteger)slot;
|
||||
|
||||
#pragma mark - Live notes (keyboard, MIDI): queued to the audio thread
|
||||
- (void)noteOn:(NSInteger)note velocity:(NSInteger)velocity midiChannel:(NSInteger)channel;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "sizzle/DeviceSpecs.gen.hpp"
|
||||
#include "sizzle/Engine.hpp"
|
||||
#include "sizzle/Model.hpp"
|
||||
#include "sizzle/Randomizer.hpp"
|
||||
|
||||
using namespace sizzle;
|
||||
|
||||
@@ -498,6 +499,34 @@ bool isSampleKey(const char *key) {
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)canRandomizeType:(NSString *)type {
|
||||
return type.length && model::canRandomize(type.UTF8String) ? YES : NO;
|
||||
}
|
||||
|
||||
- (nullable NSString *)randomizeSlot:(NSInteger)slot {
|
||||
if (slot < 0 || slot >= 16) return nil;
|
||||
const std::string type = [self typeOfSlot:slot].UTF8String;
|
||||
if (!model::canRandomize(type.c_str())) return nil;
|
||||
|
||||
const uint32_t seed = arc4random();
|
||||
Params rolled;
|
||||
if (!model::randomize(type.c_str(), seed, rolled)) return nil;
|
||||
const std::string name = model::randomName(type.c_str(), seed);
|
||||
|
||||
[self edit:^(model::Project &p, engine::Engine &e) {
|
||||
model::ToolboxSlot &s = p.toolbox[(size_t)slot];
|
||||
// Only the keys the roll produced are written, and those are exactly the
|
||||
// device's own parameters. Anything else the slot holds — the sample a Grain
|
||||
// Cloud reads, the WAV behind a custom wavetable — is therefore left in
|
||||
// place: the roll is of the settings, not of the sounds. Writing through
|
||||
// set() also bumps the slot version, so the engine re-reads it.
|
||||
for (int i = 0; i < rolled.size(); ++i) s.set(rolled.keyAt(i), rolled.valueAt(i));
|
||||
s.name = name;
|
||||
e.rebuildFxChains();
|
||||
}];
|
||||
return @(name.c_str());
|
||||
}
|
||||
|
||||
#pragma mark - live notes
|
||||
|
||||
- (void)noteOn:(NSInteger)note velocity:(NSInteger)velocity midiChannel:(NSInteger)ch {
|
||||
|
||||
Reference in New Issue
Block a user