iOS 0.1.0: the eight audio effects as AUv3 plugins on a C++ core

C++ ports of the Kotlin effects, checked against audio the Kotlin code renders
(25 scenarios, IosGoldenExport); an Objective-C++ AUv3 wrapper checked on the
Mac against the core (parameters, presets, saved state); a container app that
checks each plugin on the device. Built as a TrollStore .ipa.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-14 20:47:06 +01:00
co-authored by Claude Opus 5.5
parent c9ad186de1
commit dcf85ba915
44 changed files with 3542 additions and 127 deletions
@@ -0,0 +1,148 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
package cc.tiredsysadmin.android.sizzle.audio
import cc.tiredsysadmin.android.sizzle.model.MixTightenerPresets
import cc.tiredsysadmin.android.sizzle.model.ToolboxKind
import cc.tiredsysadmin.android.sizzle.model.ToolboxSlot
import cc.tiredsysadmin.android.sizzle.model.ToolboxType
import org.junit.Assume.assumeTrue
import org.junit.Test
import java.io.File
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.PI
import kotlin.math.exp
import kotlin.math.roundToInt
import kotlin.math.sin
/**
* Feeds the iOS port (ios/core): the Kotlin DSP is the reference the C++ port must
* reproduce. Runs only when SIZZLE_GOLDEN_DIR is set (`make -C ios golden`), so the
* normal `make check` skips it. Writes:
*
* - `ios/core/include/sizzle/DeviceSpecs.gen.hpp` (SIZZLE_SPECS_OUT): every
* device's parameters and the Mix Tightener presets, so iOS shares one definition;
* - into SIZZLE_GOLDEN_DIR: `input.f32` (a fixed test signal) and, per audio
* effect and scenario, `<TYPE>__<scenario>.scn` (its parameters) and
* `<TYPE>__<scenario>.f32` (the Kotlin output), all raw little-endian float32.
*/
class IosGoldenExport {
@Test fun export() {
val dir = System.getenv("SIZZLE_GOLDEN_DIR")
assumeTrue("set SIZZLE_GOLDEN_DIR to export", dir != null)
val out = File(dir!!).apply { mkdirs() }
System.getenv("SIZZLE_SPECS_OUT")?.let { File(it).writeText(specsHeader()) }
val input = testSignal()
writeF32(File(out, "input.f32"), input)
for (type in ToolboxType.entries) {
if (AudioEffect.create(type, SR) == null) continue
for ((name, values) in scenarios(type)) {
val slot = ToolboxSlot(0).apply { fill(type) }
values.forEach { (k, v) -> slot.set(k, v) }
val fx = AudioEffect.create(type, SR)!!
fx.update(slot, TEMPO)
val y = FloatArray(input.size) { fx.process(input[it]) }
val base = "${type.name}__$name"
File(out, "$base.scn").writeText(buildString {
append("type ${type.name}\nsr $SR\ntempo $TEMPO\n")
// Every value the effect can read, in the slot's own string form.
slot.values.toSortedMap().forEach { (k, v) -> append("p $k $v\n") }
})
writeF32(File(out, "$base.f32"), y)
}
}
}
/** Defaults, then two variants that move every listed parameter (enums to
* other choices), so each control's code path is exercised. The Mix Tightener
* hides its real settings in presets, so it uses two factory presets instead. */
private fun scenarios(type: ToolboxType): List<Pair<String, Map<String, String>>> {
if (type == ToolboxType.MIX_TIGHTENER) {
return listOf("default" to emptyMap<String, String>()) +
MixTightenerPresets.FACTORY.take(3).mapIndexed { i, p -> "preset$i" to p.params }
}
fun variant(frac: Float, choice: (Int) -> Int) = type.params.associate { s ->
s.key to if (s.isEnum) s.choices[choice(s.choices.size)]
else (s.min + frac * (s.max - s.min)).let { if (s.isInt) it.roundToInt().toFloat() else it }.toString()
}
return listOf(
"default" to emptyMap(),
"high" to variant(0.75f) { n -> n - 1 },
"low" to variant(0.25f) { n -> minOf(1, n - 1) },
)
}
/** 1.5 s: a decaying saw burst, silence, LCG noise, silence, a sine sweep, then
* silence for tails. Exercises gates, envelopes, filters and feedback paths. */
private fun testSignal(): FloatArray {
val n = (SR * 1.5).toInt()
var seed = 0x1234567
var sweepPhase = 0.0
return FloatArray(n) { i ->
val t = i.toDouble() / SR
when {
t < 0.25 -> (0.6 * (2 * ((t * 110) % 1.0) - 1) * exp(-t * 6)).toFloat()
t < 0.40 -> 0f
t < 0.70 -> { seed = seed * 1103515245 + 12345; ((seed ushr 8) and 0xFFFF) / 65535f * 0.6f - 0.3f }
t < 0.90 -> 0f
t < 1.20 -> {
val f = 100 * Math.pow(50.0, (t - 0.9) / 0.3)
sweepPhase += 2 * PI * f / SR
(0.5 * sin(sweepPhase)).toFloat()
}
else -> 0f
}
}
}
private fun writeF32(f: File, x: FloatArray) {
val bb = ByteBuffer.allocate(x.size * 4).order(ByteOrder.LITTLE_ENDIAN)
x.forEach { bb.putFloat(it) }
f.writeBytes(bb.array())
}
private fun cstr(s: String) = "\"" + s.replace("\\", "\\\\").replace("\"", "\\\"") + "\""
private fun specsHeader(): String = buildString {
append("// GENERATED by IosGoldenExport (make -C ios golden). Do not edit.\n")
append("// Every Sizzle device's parameters, from ToolboxType in the Android app.\n")
append("#pragma once\n#include \"sizzle/Specs.hpp\"\n\nnamespace sizzle::gen {\n\n")
for (t in ToolboxType.entries) {
t.params.forEachIndexed { i, s ->
if (s.isEnum) append("inline const char *const ${t.name}_c$i[] = {${s.choices.joinToString(", ") { cstr(it) }}, nullptr};\n")
}
if (t.params.isEmpty()) { append("inline const ParamSpec *const ${t.name}_params = nullptr;\n\n"); continue }
append("inline const ParamSpec ${t.name}_params[] = {\n")
t.params.forEachIndexed { i, s ->
append(" {${cstr(s.key)}, ${cstr(s.label)}, ${s.default}f, ${s.min}f, ${s.max}f, ${s.isInt}, ")
append(if (s.isEnum) "${t.name}_c$i" else "nullptr").append("},\n")
}
append("};\n\n")
}
append("inline const DeviceSpec devices[] = {\n")
for (t in ToolboxType.entries) {
val kind = if (t.kind == ToolboxKind.INSTRUMENT) "Kind::Instrument" else "Kind::Effect"
append(" {${cstr(t.name)}, ${cstr(t.displayName)}, $kind, ${t.name}_params, ${t.params.size}},\n")
}
append("};\ninline constexpr int deviceCount = ${ToolboxType.entries.size};\n\n")
append("// Mix Tightener factory presets: name, then key/value pairs, nullptr-terminated.\n")
MixTightenerPresets.FACTORY.forEachIndexed { i, p ->
append("inline const char *const mixTightener$i[] = {${cstr(p.name)}, ")
p.params.toSortedMap().forEach { (k, v) -> append("${cstr(k)}, ${cstr(v)}, ") }
append("nullptr};\n")
}
append("inline const char *const *const mixTightenerPresets[] = {")
append(MixTightenerPresets.FACTORY.indices.joinToString(", ") { "mixTightener$it" })
append(", nullptr};\n\n} // namespace sizzle::gen\n")
}
private companion object {
const val SR = 48_000
const val TEMPO = 120f
}
}
+12 -5
View File
@@ -377,12 +377,19 @@ in a `LaunchedEffect`, opens the editor, and on CLOSE / Back returns to `returnT
The mixer's INSTRUMENT and FX dropdowns use it on long-press (`RetroDropdown`'s The mixer's INSTRUMENT and FX dropdowns use it on long-press (`RetroDropdown`'s
optional `onLongClick`, with a haptic tick; a tap still opens the menu). optional `onLongClick`, with a haptic tick; a tap still opens the menu).
### 5.4.2 iOS/iPadOS AUv3 port (staging) ### 5.4.2 iOS/iPadOS AUv3 port
`ios/` is a separate tree with its own Makefile for the planned iPadOS 15+ app `ios/` is a separate tree with its own Makefile: Sizzle's devices as AUv3 plugins
that would ship every device as an AUv3 plugin, installed with TrollStore. For in an iPadOS 15+ app installed with TrollStore (0.1.0 ships the eight audio
now it holds only a spike that checks whether hosts see AUv3 plugins from a effects). The DSP is a C++ port of the Kotlin code in `ios/core`, verified
TrollStore install and whether App Groups work there. See `ios/README.md`. against audio the Kotlin code renders: `app/src/test/.../audio/IosGoldenExport.kt`
writes the reference files and `ios/core/include/sizzle/DeviceSpecs.gen.hpp` when
`SIZZLE_GOLDEN_DIR` is set (`make -C ios golden`); without it the test is skipped.
What this means for Android work: a change to an effect's DSP or to a device's
parameters makes the iOS reference stale. Run `make -C ios golden core-test`
afterwards and port the change, or note it in `ios/README.md`. See that file for
the design, the porting rules and the test steps.
### 5.5 Sizzle as a background MIDI sound module ### 5.5 Sizzle as a background MIDI sound module
+1
View File
@@ -2,3 +2,4 @@ build/
dist/ dist/
# generated from spike/project.yml by `make project` # generated from spike/project.yml by `make project`
*.xcodeproj/ *.xcodeproj/
core/golden/
+16
View File
@@ -0,0 +1,16 @@
# Changelog
Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
`../versions.properties` (`ios.versionName` / `ios.versionCode`).
## 0.1.0 (build 1)
- First build: Sizzle's eight audio effects as AUv3 plugins (Bitcrusher, Filter,
10-Band EQ, Tape Delay, Mix Tightener, Tape Engine, Granular Glitch, Ambience
Reverb), listed in hosts as "Tired Sysadmin: Sizzle …".
- Sound matches the Android app: the C++ core is checked against audio rendered
by the Kotlin code (25 scenarios), and the plugin wrapper against the core.
- Stereo as dual mono, host tempo for the tempo-synced effects, Mix Tightener
factory presets, user presets and saved host sessions.
- A generic editor with every parameter; the card editors come later.
- The app lists the installed plugins and checks each one on the device.
+104 -40
View File
@@ -1,69 +1,133 @@
# Sizzle for iOS/iPadOS — build entrypoint (separate from the Android Makefile). # Sizzle for iOS/iPadOS — build entrypoint (separate from the Android Makefile).
# #
# For now this tree holds only the TrollStore AUv3 spike (spike/): a host app plus # app/ the Sizzle app (cc.tiredsysadmin.ios.sizzle): Sizzle's devices as AUv3
# one sine-wave AUv3 instrument and an App Group, built to answer "do hosts see # plugins for hosts like AUM, installed with TrollStore. iOS/iPadOS 15+.
# AUv3 plugins from a TrollStore-installed app?" before any real porting. # core/ the C++ DSP core those plugins run: a port of the Android app's Kotlin
# DSP, checked sample by sample against audio the Kotlin code renders.
# spike/ the TrollStore AUv3 feasibility spike (kept for reference).
# #
# make help what each target does # make help what each target does
# make project generate spike/SizzleSpike.xcodeproj from spike/project.yml # make golden export DeviceSpecs.gen.hpp + Kotlin reference audio (needs the
# make sim build the spike for the iOS Simulator # Android toolchain; runs IosGoldenExport in ../app)
# make sim-run install + launch it on a booted simulator (self-test runs at launch) # make core-test build the C++ core and compare it with the reference audio
# (TYPES="FILTER EQ10" limits it to some devices)
# make au-test macOS check of the AUv3 wrapper: every effect through AVAudioEngine
# must match the core, plus parameters, presets and saved state
# make project generate app/Sizzle.xcodeproj (components + XcodeGen)
# make ipa unsigned device build, ad-hoc signed with entitlements, packed as # make ipa unsigned device build, ad-hoc signed with entitlements, packed as
# dist/cc.tiredsysadmin.ios.sizzlespike_<build>.ipa for TrollStore # dist/cc.tiredsysadmin.ios.sizzle_<versionCode>.ipa for TrollStore
# make bump-minor new feature -> x.(y+1).0, versionCode +1 (also bump-patch/-major)
# make spike-ipa the spike's .ipa (dist/cc.tiredsysadmin.ios.sizzlespike_<build>.ipa)
# make clean remove build/ and dist/ # make clean remove build/ and dist/
# #
# Needs Xcode and XcodeGen (brew install xcodegen). Builds stay local (CLAUDE.md). # Needs Xcode and XcodeGen (brew install xcodegen). Builds stay local (CLAUDE.md).
SHELL := /bin/sh SHELL := /bin/sh
SPIKE := spike VERSIONS := ../versions.properties
PROJECT := $(SPIKE)/SizzleSpike.xcodeproj VERSION := $(shell sed -n 's/^ios.versionName[[:space:]]*=[[:space:]]*//p' $(VERSIONS) | tr -d ' ')
SCHEME := SizzleSpike BUILD_NO := $(shell sed -n 's/^ios.versionCode[[:space:]]*=[[:space:]]*//p' $(VERSIONS) | tr -d ' ')
APP_ID := cc.tiredsysadmin.ios.sizzlespike
BUILD_NO := $(shell sed -n 's/^ *CURRENT_PROJECT_VERSION: *"\(.*\)"/\1/p' $(SPIKE)/project.yml)
SOURCES := $(shell find $(SPIKE) -type f -not -path '*.xcodeproj/*')
SIM_APP := build/sim/Build/Products/Debug-iphonesimulator/$(SCHEME).app APP_ID := cc.tiredsysadmin.ios.sizzle
DEV_APP := build/dev/Build/Products/Release-iphoneos/$(SCHEME).app PROJECT := app/Sizzle.xcodeproj
APP_SRC := $(shell find app core/src core/include -type f -not -path '*.xcodeproj/*')
DEV_APP := build/dev/Build/Products/Release-iphoneos/Sizzle.app
IPA := dist/$(APP_ID)_$(BUILD_NO).ipa IPA := dist/$(APP_ID)_$(BUILD_NO).ipa
# C++ DSP core: reference audio lives in core/golden/ (regenerated, not committed).
CORE_SRC := $(wildcard core/src/*.cpp core/src/fx/*.cpp)
CORE_HDR := $(wildcard core/include/sizzle/*.hpp core/src/fx/*.hpp)
CXX ?= c++
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -Icore/include -Icore/src/fx
GOLDEN := core/golden
SPECS_GEN := core/include/sizzle/DeviceSpecs.gen.hpp
# Gradle needs the Android SDK; same default location as the Android Makefile.
ANDROID_SDK ?= $(or $(ANDROID_HOME),$(HOME)/Library/Android/sdk)
SPIKE_PROJ := spike/SizzleSpike.xcodeproj
SPIKE_SRC := $(shell find spike -type f -not -path '*.xcodeproj/*')
SPIKE_NO := $(shell sed -n 's/^ *CURRENT_PROJECT_VERSION: *"\(.*\)"/\1/p' spike/project.yml)
SPIKE_IPA := dist/cc.tiredsysadmin.ios.sizzlespike_$(SPIKE_NO).ipa
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
help: help:
@sed -n 's/^# //p' Makefile @sed -n 's/^# //p' Makefile
@echo ""
@echo "current: $(APP_ID) $(VERSION) (build $(BUILD_NO))"
# ------------------------------------------------------------------ core
golden:
cd .. && ANDROID_HOME=$(ANDROID_SDK) SIZZLE_GOLDEN_DIR=$(CURDIR)/$(GOLDEN) \
SIZZLE_SPECS_OUT=$(CURDIR)/$(SPECS_GEN) \
./gradlew -q :app:testDebugUnitTest --tests '*IosGoldenExport*' --rerun
@ls $(GOLDEN)/*.scn | wc -l | xargs echo "reference scenarios:"
build/core/golden_test: $(CORE_SRC) $(CORE_HDR) core/tests/golden_test.cpp
mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) core/tests/golden_test.cpp
core-test: build/core/golden_test
@test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden
build/core/golden_test $(GOLDEN) $(TYPES)
# ------------------------------------------------------------------ app
build/core/au_test: app/FX/SizzleEffectAU.mm app/FX/SizzleEffectAU.h app/FX/Components.gen.h app/tests/au_test.mm $(CORE_SRC) $(CORE_HDR)
mkdir -p build/core
$(CXX) $(CXXFLAGS) -Wno-deprecated-declarations -fobjc-arc -Iapp/FX -o $@ app/FX/SizzleEffectAU.mm app/tests/au_test.mm $(CORE_SRC) \
-framework AVFoundation -framework AudioToolbox -framework Foundation
au-test: build/core/au_test
@test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden
build/core/au_test $(GOLDEN)/input.f32
app/FX/Info.plist app/FX/Components.gen.h: app/components.txt tools/gen_components.py
python3 tools/gen_components.py app/components.txt app/FX/Info.plist app/FX/Components.gen.h
project: $(PROJECT)/project.pbxproj project: $(PROJECT)/project.pbxproj
$(PROJECT)/project.pbxproj: $(SPIKE)/project.yml $(PROJECT)/project.pbxproj: app/project.yml app/FX/Info.plist
cd $(SPIKE) && xcodegen generate --spec project.yml --quiet cd app && xcodegen generate --spec project.yml --quiet
# Simulator: Xcode's "sign to run locally" (-) embeds the entitlements, so the # Device: build without signing, then ad-hoc sign inside-out (extension first) with
# App Group works there too. # each target's entitlements. TrollStore re-signs at install and keeps them.
sim: $(SIM_APP)
$(SIM_APP): $(PROJECT)/project.pbxproj $(SOURCES)
xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Debug \
-sdk iphonesimulator -derivedDataPath build/sim \
CODE_SIGN_IDENTITY=- CODE_SIGN_STYLE=Manual build
sim-run: $(SIM_APP)
xcrun simctl install booted $(SIM_APP)
xcrun simctl launch booted $(APP_ID)
# Device: build without signing, then ad-hoc sign inside-out (extension first)
# with each target's entitlements. TrollStore re-signs at install time but keeps
# the entitlements it finds, which is how the App Group survives.
ipa: $(IPA) ipa: $(IPA)
$(IPA): $(PROJECT)/project.pbxproj $(SOURCES) $(IPA): $(PROJECT)/project.pbxproj $(APP_SRC) $(VERSIONS)
xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Release \ xcodebuild -quiet -project $(PROJECT) -scheme Sizzle -configuration Release \
-sdk iphoneos -derivedDataPath build/dev CODE_SIGNING_ALLOWED=NO build -sdk iphoneos -derivedDataPath build/dev CODE_SIGNING_ALLOWED=NO \
MARKETING_VERSION=$(VERSION) CURRENT_PROJECT_VERSION=$(BUILD_NO) build
rm -rf build/Payload && mkdir -p build/Payload dist rm -rf build/Payload && mkdir -p build/Payload dist
cp -R $(DEV_APP) build/Payload/ cp -R $(DEV_APP) build/Payload/
codesign -f -s - --entitlements $(SPIKE)/AU/AU.entitlements \ codesign -f -s - --entitlements app/FX/FX.entitlements build/Payload/Sizzle.app/PlugIns/SizzleFX.appex
build/Payload/$(SCHEME).app/PlugIns/SizzleSpikeAU.appex codesign -f -s - --entitlements app/Host/Host.entitlements build/Payload/Sizzle.app
codesign -f -s - --entitlements $(SPIKE)/App/App.entitlements \
build/Payload/$(SCHEME).app
rm -f $@ && cd build && zip -qr ../$@ Payload rm -f $@ && cd build && zip -qr ../$@ Payload
@echo "wrote $@" @echo "wrote $@"
# ------------------------------------------------------------------ versions
bump-major: ; @$(MAKE) --no-print-directory bump FIELD=1
bump-minor: ; @$(MAKE) --no-print-directory bump FIELD=2
bump-patch: ; @$(MAKE) --no-print-directory bump FIELD=3
bump:
@new=$$(echo $(VERSION) | awk -F. -v f=$(FIELD) '{ if (f==1) {$$1++; $$2=0; $$3=0} else if (f==2) {$$2++; $$3=0} else {$$3++} print $$1"."$$2"."$$3 }'); \
code=$$(( $(BUILD_NO) + 1 )); \
sed -i '' -e "s/^ios.versionName .*/ios.versionName = $$new/" -e "s/^ios.versionCode .*/ios.versionCode = $$code/" $(VERSIONS); \
echo "ios $$new (build $$code)"
# ------------------------------------------------------------------ spike
$(SPIKE_PROJ)/project.pbxproj: spike/project.yml
cd spike && xcodegen generate --spec project.yml --quiet
spike-ipa: $(SPIKE_IPA)
$(SPIKE_IPA): $(SPIKE_PROJ)/project.pbxproj $(SPIKE_SRC)
xcodebuild -quiet -project $(SPIKE_PROJ) -scheme SizzleSpike -configuration Release \
-sdk iphoneos -derivedDataPath build/spike CODE_SIGNING_ALLOWED=NO build
rm -rf build/SpikePayload && mkdir -p build/SpikePayload/Payload dist
cp -R build/spike/Build/Products/Release-iphoneos/SizzleSpike.app build/SpikePayload/Payload/
codesign -f -s - --entitlements spike/AU/AU.entitlements \
build/SpikePayload/Payload/SizzleSpike.app/PlugIns/SizzleSpikeAU.appex
codesign -f -s - --entitlements spike/App/App.entitlements build/SpikePayload/Payload/SizzleSpike.app
rm -f $@ && cd build/SpikePayload && zip -qr ../../$@ Payload
@echo "wrote $@"
clean: clean:
rm -rf build dist rm -rf build dist
.PHONY: help project sim sim-run ipa clean .PHONY: help golden core-test au-test project ipa bump-major bump-minor bump-patch bump spike-ipa clean
+139 -79
View File
@@ -1,97 +1,157 @@
# Sizzle for iOS/iPadOS — staging tree # Sizzle for iOS/iPadOS
This tree is separate from the Android app (its own Makefile, nothing shared yet). Sizzle's instruments and effects as AUv3 plugins for hosts such as AUM, GarageBand
The plan is to ship every Sizzle instrument and effect as AUv3 plugins inside one and Loopy, in one app (`cc.tiredsysadmin.ios.sizzle`, iOS/iPadOS 15+) installed
app (iOS/iPadOS 15+), installed with TrollStore. Before porting anything, the with TrollStore. This tree is separate from the Android app and has its own
**spike** in `spike/` answers the one question that could sink the plan: do hosts Makefile (`make -C ios help`).
(AUM, GarageBand, Loopy…) list AUv3 plugins from a TrollStore-installed app, and do
App Groups work there?
## The spike | Path | What it is |
| Piece | What it is |
|---|---| |---|---|
| `spike/project.yml` | XcodeGen spec; `make project` generates the Xcode project (git-ignored) | | `core/` | The C++ DSP core: a port of the Android app's Kotlin DSP |
| `spike/App/` | SwiftUI host app `cc.tiredsysadmin.ios.sizzlespike` with a self-test (Run self-test button) | | `core/include/sizzle/DeviceSpecs.gen.hpp` | Every device's parameters, generated from `ToolboxType` (Kotlin) |
| `spike/AU/` | App extension `…sizzlespike.au`: one AUv3 instrument (`aumu` / `sSpk` / `Tsys`), "Tired Sysadmin: Sizzle Spike Sine", a sine voice with a Gain parameter | | `core/tests/golden_test.cpp` | Compares the core with audio the Kotlin code renders |
| `spike/Shared/Spike.swift` | The App Group id, the component description, and the App Group probe both sides run | | `app/components.txt` | The plugin list (AU type, subtype, device, name) |
| `app/FX/` | The effects extension: `SizzleEffectAU` (the AUv3) and `SizzleFXViewController` (factory + editor) |
| `app/Host/` | The container app: lists the plugins, checks each one on the device |
| `app/tests/au_test.mm` | Mac-side test of the AUv3 wrapper |
| `tools/gen_components.py` | `components.txt` → the extension's Info.plist and `Components.gen.h` |
| `spike/` | The TrollStore AUv3 feasibility spike (see the end of this file) |
The self-test shows three checks: Versions: `ios.versionName` / `ios.versionCode` in `../versions.properties`
(`make -C ios bump-minor` etc.); the .ipa is named by versionCode. Changes are
listed in `CHANGELOG.md` here.
1. **[1] Registered components:** what `AVAudioUnitComponentManager` lists for ## How the port is verified
`Tsys/sSpk`. That is the same registry hosts read, so a FAIL here means no host
will see the plugin. The Kotlin DSP is the reference. `make golden` runs `IosGoldenExport` (a JVM unit
2. **[2] Instantiated out of process / Rendered 1 s offline:** iOS launches the test in the Android app, skipped by the normal `make check`), which:
extension and its render block produces sound (silent, offline render; peak > 0.05).
"Play tone (1 s)" does the same through the speaker. - writes `DeviceSpecs.gen.hpp`, so iOS uses the same parameter definitions
3. **[3] App Group:** the app writes `app.txt`, the extension writes `au.txt` when it is (keys, labels, ranges, defaults, choices) and the Mix Tightener presets;
created (and `au-view.txt` when a host opens its view), and each side lists what's - renders a fixed 1.5 s test signal (decaying saw burst, noise, sine sweep,
there. After [2], seeing `au.txt` in the app's list proves both sides share files, silences for tails) through every effect at its defaults and two variants that
which is how the real port will hand samples and SF2 files to the plugins. move every parameter (the Mix Tightener uses three of its presets instead), into
`core/golden/` (not committed; regenerate any time).
`make core-test` renders the same scenarios through the C++ core and requires a
largest difference below 1e-4. Today all 25 pass; most are bit-exact, the rest
differ by about one float ulp. Porting rules that make this possible:
- translate line for line, keeping Kotlin's types: `Float` → `float`,
`Double` → `double`, so every expression runs in the same precision;
- `kotlin.math` on a Float goes through Java's double `Math` and rounds back:
use the helpers in `core/src/fx/KotlinMath.hpp` (`roundToInt` is floor(x+0.5),
`toInt` truncates and saturates);
- Kotlin `Int` wraps and `ushr` is a logical shift: use `uint32_t` for the
xorshift generators;
- settings are text, as in `ToolboxSlot`: `Params::f()` / `Params::s()` read
exactly what `slot.float()` / `slot.string()` would.
Known gap: the Tape Delay "low" variant switches all four heads off (on-values
below 0.5), so it only tests the dry path; add a scenario with heads on.
`make au-test` then checks the AUv3 wrapper on the Mac (AUAudioUnit exists on
macOS): every effect is registered in-process and driven through AVAudioEngine.
The output must equal the core's at defaults and after moving every parameter
through the AU, a Mix Tightener factory preset must equal the core with that
preset, and `fullState` must restore into a fresh instance. All pass bit-exact.
## The plugins (0.1.0: the eight audio effects)
All eight are `aufx` plugins from one extension (`SizzleFX.appex`), manufacturer
`Tsys`, named "Tired Sysadmin: Sizzle <device>". The extension's factory picks
the device by subtype; subtypes are in `app/components.txt` and must never change
once shipped, since hosts save projects by them.
`SizzleEffectAU` (Objective-C++, no Swift on the audio path):
- **Parameters** come from the generated specs: address = index in the device's
parameter list; choices become indexed parameters with value strings; whole
numbers use the indexed unit.
- **Stereo:** the Kotlin effects are mono (Sizzle's mixer is mono), so each
channel runs its own instance (dual mono). Mono and stereo buses are accepted.
- **Threads:** AU parameter changes (host, automation events, the editor) go into
one atomic float per parameter. Whole settings (presets, restored state,
hidden keys such as the Mix Tightener's) go through a two-slot mailbox. The
render thread copies, overlays the parameter values, and calls
`Effect::update` only when something changed or the host tempo moved. No locks
on the audio thread. (Applying changes formats and parses text with
`snprintf`/`strtof` on the audio thread, only when something changed; a
numeric fast path can replace that later.)
- **Tempo** comes from the host's musical context (120 BPM without one), for the
tempo-synced Delay and Tape Engine.
- **Presets:** the Mix Tightener's factory presets are AU factory presets; user
presets use the AU's `fullState`, which stores every key as text
(`sizzleValues`), hidden ones included.
- **Bypass** passes the input through; non-finite output samples are zeroed.
The editor is generic for now (sliders, segmented switches for short choice
lists, menus for long ones, a preset menu); the card editors of the Android app
come later.
The container app lists the registered plugins, and **Check all plugins** loads
each one out of process (as a host does), renders a test signal offline and
reports PASS (finite, not silent) or FAIL.
### Build ### Build
```sh ```sh
make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_<build>.ipa make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzle_<versionCode>.ipa
make -C ios core-test # C++ core vs Kotlin reference
make -C ios au-test # the AUv3 wrapper on the Mac
``` ```
Needs Xcode and XcodeGen. The device build is unsigned, then ad-hoc signed inside-out The device build is unsigned, then ad-hoc signed inside-out (extension first)
(extension first) with each target's entitlements, and zipped as `Payload/`. with each target's entitlements and zipped as `Payload/`. TrollStore re-signs at
TrollStore re-signs at install time and keeps the entitlements it finds; ldid install and keeps the entitlements.
isn't needed. Checked on the Mac: arm64, minimum OS 15.0 for the app and the
extension, App Group entitlement on both, extension entry point `NSExtensionMain`,
extension point `com.apple.AudioUnit-UI`.
`make sim` / `make sim-run` build and run it in the Simulator, but no Simulator The extension links the core with `-force_load`: effect makers are found through
runtime was installed when the spike was written, so it hasn't been run there. weak placeholders in `Registry.cpp` (so the core test can link before every port
exists), and from a static library the linker would otherwise keep the
placeholders and leave the real ports out. That happened once; the symptom would
have been every plugin failing to start.
### Test on the iPad ### Test on the iPad
1. AirDrop or copy the newest `cc.tiredsysadmin.ios.sizzlespike_<build>.ipa` to the 1. Install the newest `cc.tiredsysadmin.ios.sizzle_<n>.ipa` with TrollStore.
iPad, open it with TrollStore, install. 2. Open **Sizzle**, tap **Check all plugins**: 8/8 should pass.
2. Open **Sizzle Spike**, tap **Run self-test**, and note [1]–[3] (screenshot). 3. In AUM, add an audio track or a synth, then an effect slot: the plugins are
3. In AUM (or GarageBand → Audio Units, Loopy, Drambo…), add an instrument and look listed as "Tired Sysadmin: Sizzle …". Try the editor, a Mix Tightener preset,
for **Tired Sysadmin: Sizzle Spike Sine**. Load it, play notes, open its view (it and saving and reopening an AUM session (restores `fullState`).
lists the App Group files).
4. Back in Sizzle Spike, **Run self-test** again: `au-view.txt` should now be listed.
What the outcomes mean:
- [1] PASS and the host lists it: the plan works as designed.
- [1] PASS but no host lists it: hosts filter TrollStore apps somehow; investigate
before porting.
- [1] FAIL: iOS didn't register the extension (pluginkit); try re-launching the app,
then a respring, then reinstall.
- [3] NOT AVAILABLE: App Groups don't survive TrollStore signing. The fallback is
passing sample data through the plugin's saved state, or having the plugin
pick files with a document picker.
### Results so far
- **Build 1 (0.1.0):** AUM lists the plugin, loads it, and it plays from a MIDI
keyboard, so hosts do see AUv3 plugins from a TrollStore install. AUM showed a
red X as its icon (the app had no icon), and the app itself closed right after
opening (it ran the self-test at launch).
- **Build 2 (0.1.1):** adds an app icon, the SwiftUI scene manifest, and makes the
self-test crash-proof for diagnosis. It runs only on the button. Each step is
saved before it runs, so the next launch says where a crash happened
("The previous run stopped during: …"). AVAudioEngine's Objective-C exceptions
are caught by `App/ObjC/SPKTry.m` and printed instead of killing the app.
If the app still closes before showing anything, the crash is at launch. Its log
is in Settings → Privacy & Security → Analytics & Improvements → Analytics Data,
in a file named `SizzleSpike-<date>.ips`.
## Decisions ## Decisions
- **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and - **C++ core, not Kotlin/Native:** an AUv3 render callback must not allocate,
review; the generated project is git-ignored. lock or wait for a garbage collector; plain C++ with preallocated state meets
- **Swift render block in the spike:** good enough for one sine voice (no allocation that, and can later replace the Kotlin DSP on Android through JNI.
or locks in the render block). The real port puts the DSP in a C++ core (see the - **Reference audio instead of reading the code twice:** the Kotlin output is the
conversation that planned it: Kotlin DSP → C++ verified against reference audio specification, so ports can be done by anyone (including parallel agents) and
rendered by the Kotlin code). checked mechanically.
- **One extension, factory dispatch:** the real port will list many - **XcodeGen:** projects are text (`app/project.yml`); generated projects are
`AudioComponents` in one or a few extensions and pick the unit in git-ignored. Generated sources that iOS needs to build without the Android
`createAudioUnit(with:)` by subtype, instead of one extension per device. toolchain (`DeviceSpecs.gen.hpp`, `FX/Info.plist`, `Components.gen.h`) are
- **Versions:** the spike's version lives in `spike/project.yml` committed.
(`MARKETING_VERSION` 0.1.0, `CURRENT_PROJECT_VERSION` 1, which names the .ipa). - **One extension, factory dispatch** instead of one extension per device.
- **Generic editor first:** every parameter is reachable now; the card editors
(tabs, knobs, drawings) are a separate step.
## Next steps
1. Instruments (Synth, Wavetable, Morph Pad, Grain Cloud, Sampler, SF2/XI) as
`aumu` plugins, through the same reference-audio route (the export will need
note scripts, not just an input signal).
2. MIDI effects (Arpeggiator, Transposer, LFO) as `aumi` plugins.
3. The card editors in SwiftUI from the `DeviceLayouts` data.
4. Sample and SF2 files through the App Group (`group.cc.tiredsysadmin.ios.sizzle`).
## The TrollStore spike (spike/)
A host app with one sine AUv3 instrument and an App Group self-test, built to check
feasibility before porting (`make -C ios spike-ipa`).
- **Build 1:** AUM listed the plugin, loaded it and played it from a MIDI
keyboard, so hosts do see AUv3 plugins from a TrollStore install. The app
closed right after opening, and AUM showed a red X instead of an icon.
- **Build 2:** added an app icon (AUM's red X went away), the SwiftUI scene
manifest, and a crash-proof self-test on a button. Confirmed on the iPad: the
self-test works, the icon shows, sound works.
+17
View File
@@ -0,0 +1,17 @@
// GENERATED from components.txt by tools/gen_components.py. Do not edit.
#pragma once
#include <AudioToolbox/AudioToolbox.h>
typedef struct { OSType subtype; const char *toolboxType; const char *name; } SizzleComponent;
static const SizzleComponent kSizzleComponents[] = {
{'sBcr', "BITCRUSHER", "Bitcrusher"},
{'sFlt', "FILTER", "Filter"},
{'sEqx', "EQ10", "10-Band EQ"},
{'sDly', "DELAY", "Tape Delay"},
{'sMxt', "MIX_TIGHTENER", "Mix Tightener"},
{'sTpe', "TAPE_ENGINE", "Tape Engine"},
{'sGrn', "GRANULAR", "Granular Glitch"},
{'sAmb', "AMBIENCE", "Ambience Reverb"}
};
static const int kSizzleComponentCount = 8;
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.cc.tiredsysadmin.ios.sizzle</string>
</array>
</dict>
</plist>
+115
View File
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- GENERATED from components.txt by tools/gen_components.py. Do not edit. -->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key><string>en</string>
<key>CFBundleDisplayName</key><string>Sizzle FX</string>
<key>CFBundleExecutable</key><string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>CFBundleName</key><string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key><string>XPC!</string>
<key>CFBundleShortVersionString</key><string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key><string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>AudioComponents</key>
<array>
<dict>
<key>description</key><string>Sizzle Bitcrusher</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Bitcrusher</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sBcr</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle Filter</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Filter</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sFlt</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle 10-Band EQ</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle 10-Band EQ</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sEqx</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle Tape Delay</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Tape Delay</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sDly</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle Mix Tightener</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Mix Tightener</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sMxt</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle Tape Engine</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Tape Engine</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sTpe</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle Granular Glitch</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Granular Glitch</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sGrn</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
<dict>
<key>description</key><string>Sizzle Ambience Reverb</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle Ambience Reverb</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>sAmb</string>
<key>tags</key><array><string>Effects</string></array>
<key>type</key><string>aufx</string>
<key>version</key><integer>65536</integer>
</dict>
</array>
</dict>
<key>NSExtensionPointIdentifier</key><string>com.apple.AudioUnit-UI</string>
<key>NSExtensionPrincipalClass</key><string>SizzleFXViewController</string>
</dict>
</dict>
</plist>
+26
View File
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import <AudioToolbox/AudioToolbox.h>
NS_ASSUME_NONNULL_BEGIN
/// One Sizzle audio effect as an AUv3 (`aufx`): wraps a C++ `sizzle::Effect`
/// chosen by its ToolboxType name ("DELAY", "FILTER", …). Parameters come from the
/// generated device specs; each channel runs its own mono effect instance.
@interface SizzleEffectAU : AUAudioUnit
- (nullable instancetype)initWithComponentDescription:(AudioComponentDescription)desc
toolboxType:(const char *)toolboxType
displayName:(NSString *)displayName
error:(NSError **)outError;
/// The device's name as shown in Sizzle ("Tape Delay").
@property (nonatomic, readonly) NSString *displayName;
/// Formats a parameter value the way Sizzle's editor does (units, %, choices).
- (NSString *)stringForParameter:(AUParameter *)param value:(AUValue)value;
@end
NS_ASSUME_NONNULL_END
+405
View File
@@ -0,0 +1,405 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import "SizzleEffectAU.h"
#import "Components.gen.h"
#import <AVFoundation/AVFoundation.h>
#include <atomic>
#include <cmath>
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include "sizzle/DeviceSpecs.gen.hpp"
#include "sizzle/Effect.hpp"
using namespace sizzle;
namespace {
/**
* Everything the render thread touches, owned by the AU.
*
* Two ways settings reach the effect, neither of them locking:
* - AU parameters (host automation, the UI) are written into [values] (one atomic
* float per parameter, address = index in the spec) and bump [valuesSeq];
* - whole settings (presets, restored state, hidden keys such as the Mix
* Tightener's) are written by the main thread into the spare half of [mailbox]
* and published with [mailboxIdx] / [mailboxSeq].
* The render thread copies the published mailbox into [live], overlays the
* parameter values, and calls Effect::update only when something changed.
*/
struct Kernel {
const DeviceSpec *spec = nullptr;
std::string type;
std::unique_ptr<Effect> fx[2];
int channels = 0;
std::atomic<float> values[Params::kMax];
std::atomic<uint32_t> valuesSeq{1};
Params mailbox[2];
std::atomic<int> mailboxIdx{0};
std::atomic<uint32_t> mailboxSeq{1};
// render thread only
Params live;
uint32_t seenValues = 0, seenMailbox = 0;
double tempo = 120.0;
std::atomic<bool> bypass{false};
std::vector<float> inBuf[2];
AUHostMusicalContextBlock musicalContext = nil;
void publish(const Params &p) {
int next = 1 - mailboxIdx.load(std::memory_order_acquire);
mailbox[next] = p;
mailboxIdx.store(next, std::memory_order_release);
mailboxSeq.fetch_add(1, std::memory_order_release);
}
/** Parameter i's value as Params text: a choice name or a number. */
void overlay(Params &p) {
for (int i = 0; i < spec->paramCount; ++i) {
const ParamSpec &s = spec->params[i];
float v = values[i].load(std::memory_order_relaxed);
if (s.isEnum()) {
int n = s.choiceCount(), idx = (int)std::lround(v);
p.set(s.key, s.choices[idx < 0 ? 0 : (idx >= n ? n - 1 : idx)]);
} else {
p.set(s.key, s.isInt ? std::round(v) : v);
}
}
}
/** Called at the top of each render cycle. */
void refresh(bool tempoChanged) {
uint32_t ms = mailboxSeq.load(std::memory_order_acquire);
uint32_t vs = valuesSeq.load(std::memory_order_acquire);
if (ms == seenMailbox && vs == seenValues && !tempoChanged) return;
if (ms != seenMailbox) live = mailbox[mailboxIdx.load(std::memory_order_acquire)];
seenMailbox = ms;
seenValues = vs;
overlay(live);
for (int c = 0; c < channels; ++c) fx[c]->update(live, (float)tempo);
}
};
int choiceIndex(const ParamSpec &s, const char *name) {
for (int i = 0; s.choices[i]; ++i) if (std::strcmp(s.choices[i], name) == 0) return i;
return 0;
}
} // namespace
@implementation SizzleEffectAU {
std::unique_ptr<Kernel> _k;
AUAudioUnitBusArray *_inputs;
AUAudioUnitBusArray *_outputs;
AUAudioUnitBus *_inBus;
AUAudioUnitBus *_outBus;
AUParameterTree *_tree;
Params _base; // main thread: the full settings (incl. hidden keys)
NSArray<AUAudioUnitPreset *> *_factoryPresets;
AUAudioUnitPreset *_currentPreset;
NSString *_displayName;
}
/// The standard initializer (used by AUAudioUnit registration and the Mac test):
/// picks the device from the component's subtype in components.txt.
- (instancetype)initWithComponentDescription:(AudioComponentDescription)desc
options:(AudioComponentInstantiationOptions)options
error:(NSError **)outError {
for (int i = 0; i < kSizzleComponentCount; ++i)
if (kSizzleComponents[i].subtype == desc.componentSubType)
return [self initWithComponentDescription:desc toolboxType:kSizzleComponents[i].toolboxType
displayName:@(kSizzleComponents[i].name) error:outError];
if (outError) *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_InvalidElement userInfo:nil];
return nil;
}
- (instancetype)initWithComponentDescription:(AudioComponentDescription)desc
toolboxType:(const char *)toolboxType
displayName:(NSString *)displayName
error:(NSError **)outError {
self = [super initWithComponentDescription:desc options:0 error:outError];
if (!self) return nil;
_displayName = displayName;
_k = std::make_unique<Kernel>();
_k->type = toolboxType;
_k->spec = findDevice(toolboxType);
if (!_k->spec) {
if (outError) *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_InvalidProperty userInfo:nil];
return nil;
}
AVAudioFormat *fmt = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:44100 channels:2];
_inBus = [[AUAudioUnitBus alloc] initWithFormat:fmt error:outError];
_outBus = [[AUAudioUnitBus alloc] initWithFormat:fmt error:outError];
if (!_inBus || !_outBus) return nil;
_inBus.maximumChannelCount = 2;
_outBus.maximumChannelCount = 2;
_inputs = [[AUAudioUnitBusArray alloc] initWithAudioUnit:self busType:AUAudioUnitBusTypeInput busses:@[_inBus]];
_outputs = [[AUAudioUnitBusArray alloc] initWithAudioUnit:self busType:AUAudioUnitBusTypeOutput busses:@[_outBus]];
[self buildParameterTree];
_base.fill(*_k->spec);
[self pushBase];
[self buildFactoryPresets];
self.maximumFramesToRender = 4096;
return self;
}
- (NSString *)displayName { return _displayName; }
#pragma mark - parameters
- (void)buildParameterTree {
const DeviceSpec *spec = _k->spec;
NSMutableArray<AUParameter *> *params = [NSMutableArray array];
for (int i = 0; i < spec->paramCount; ++i) {
const ParamSpec &s = spec->params[i];
AUParameter *p;
AudioUnitParameterOptions flags = kAudioUnitParameterFlag_IsReadable | kAudioUnitParameterFlag_IsWritable;
if (s.isEnum()) {
NSMutableArray<NSString *> *names = [NSMutableArray array];
for (int c = 0; s.choices[c]; ++c) [names addObject:@(s.choices[c])];
p = [AUParameterTree createParameterWithIdentifier:@(s.key) name:@(s.label) address:(AUParameterAddress)i
min:0 max:(AUValue)(names.count - 1)
unit:kAudioUnitParameterUnit_Indexed unitName:nil
flags:flags valueStrings:names dependentParameters:nil];
p.value = (AUValue)s.def;
} else {
p = [AUParameterTree createParameterWithIdentifier:@(s.key) name:@(s.label) address:(AUParameterAddress)i
min:s.min max:s.max
unit:s.isInt ? kAudioUnitParameterUnit_Indexed : kAudioUnitParameterUnit_Generic
unitName:nil flags:flags valueStrings:nil dependentParameters:nil];
p.value = s.def;
}
_k->values[i].store(p.value);
[params addObject:p];
}
_tree = [AUParameterTree createTreeWithChildren:params];
Kernel *k = _k.get();
_tree.implementorValueObserver = ^(AUParameter *param, AUValue value) {
if (param.address < (AUParameterAddress)k->spec->paramCount) {
k->values[param.address].store(value, std::memory_order_relaxed);
k->valuesSeq.fetch_add(1, std::memory_order_release);
}
};
_tree.implementorValueProvider = ^AUValue(AUParameter *param) {
return param.address < (AUParameterAddress)k->spec->paramCount ? k->values[param.address].load() : 0;
};
__weak SizzleEffectAU *weakSelf = self;
_tree.implementorStringFromValueCallback = ^NSString *(AUParameter *param, const AUValue *value) {
return [weakSelf stringForParameter:param value:value ? *value : param.value] ?: @"";
};
}
- (AUParameterTree *)parameterTree { return _tree; }
/// Publish [_base] to the render thread and move the AU parameters to match it.
- (void)pushBase {
const DeviceSpec *spec = _k->spec;
for (int i = 0; i < spec->paramCount; ++i) {
const ParamSpec &s = spec->params[i];
AUValue v = s.isEnum() ? (AUValue)choiceIndex(s, _base.s(s.key, s.choices[0])) : _base.f(s.key, s.def);
[_tree parameterWithAddress:(AUParameterAddress)i].value = v; // notifies UI + kernel
}
_k->publish(_base);
}
/// Bring [_base] up to date with the AU parameters (they're the source of truth for
/// the visible keys; _base also holds hidden ones).
- (void)pullBase {
_k->overlay(_base);
}
- (NSString *)stringForParameter:(AUParameter *)param value:(AUValue)value {
if (param.address >= (AUParameterAddress)_k->spec->paramCount) return @"";
const ParamSpec &s = _k->spec->params[param.address];
if (s.isEnum()) {
int n = s.choiceCount(), i = (int)std::lround(value);
return @(s.choices[i < 0 ? 0 : (i >= n ? n - 1 : i)]);
}
const char *label = s.label;
if (strstr(label, "(dB)")) return [NSString stringWithFormat:@"%.1f dB", value];
if (strstr(label, "(ms)")) return [NSString stringWithFormat:@"%.0f ms", value];
if (s.isInt) return s.min < 0 ? [NSString stringWithFormat:@"%+d", (int)std::lround(value)]
: [NSString stringWithFormat:@"%d", (int)std::lround(value)];
if (s.min == 0 && s.max == 1) return [NSString stringWithFormat:@"%d%%", (int)std::lround(value * 100)];
if (s.min == -1 && s.max == 1) return [NSString stringWithFormat:@"%+d%%", (int)std::lround(value * 100)];
return [NSString stringWithFormat:@"%.2f", value];
}
#pragma mark - presets and state
- (void)buildFactoryPresets {
NSMutableArray *list = [NSMutableArray array];
if (_k->type == "MIX_TIGHTENER") {
for (int i = 0; gen::mixTightenerPresets[i]; ++i) {
AUAudioUnitPreset *p = [AUAudioUnitPreset new];
p.number = i;
p.name = @(gen::mixTightenerPresets[i][0]);
[list addObject:p];
}
}
_factoryPresets = list;
}
- (NSArray<AUAudioUnitPreset *> *)factoryPresets { return _factoryPresets; }
- (BOOL)supportsUserPresets { return YES; }
- (AUAudioUnitPreset *)currentPreset { return _currentPreset; }
- (void)setCurrentPreset:(AUAudioUnitPreset *)preset {
if (preset == nil) { _currentPreset = nil; return; }
if (preset.number >= 0) {
if (preset.number < (NSInteger)_factoryPresets.count && _k->type == "MIX_TIGHTENER") {
const char *const *kv = gen::mixTightenerPresets[preset.number];
_base.fill(*_k->spec);
for (int i = 1; kv[i] && kv[i + 1]; i += 2) _base.set(kv[i], kv[i + 1]);
[self pushBase];
}
_currentPreset = preset;
} else {
NSError *err = nil;
NSDictionary *state = [self presetStateFor:preset error:&err];
if (state) self.fullState = state;
_currentPreset = preset;
}
}
static NSString *const kStateKey = @"sizzleValues";
- (NSDictionary<NSString *, id> *)fullState {
NSMutableDictionary *state = [NSMutableDictionary dictionaryWithDictionary:[super fullState] ?: @{}];
[self pullBase];
NSMutableDictionary *values = [NSMutableDictionary dictionary];
for (int i = 0; i < _base.size(); ++i) values[@(_base.keyAt(i))] = @(_base.valueAt(i));
state[kStateKey] = values;
state[@"sizzleType"] = @(_k->type.c_str());
return state;
}
- (void)setFullState:(NSDictionary<NSString *, id> *)fullState {
[super setFullState:fullState];
NSDictionary *values = fullState[kStateKey];
if (![values isKindOfClass:[NSDictionary class]]) return;
_base.fill(*_k->spec);
for (NSString *key in values) {
id v = values[key];
if ([key isKindOfClass:[NSString class]] && [v isKindOfClass:[NSString class]])
_base.set(key.UTF8String, ((NSString *)v).UTF8String);
}
[self pushBase];
}
#pragma mark - busses and render
- (AUAudioUnitBusArray *)inputBusses { return _inputs; }
- (AUAudioUnitBusArray *)outputBusses { return _outputs; }
- (NSArray<NSNumber *> *)channelCapabilities { return @[@1, @1, @2, @2]; }
- (BOOL)canProcessInPlace { return YES; }
- (void)setShouldBypassEffect:(BOOL)bypass {
[super setShouldBypassEffect:bypass];
_k->bypass.store(bypass);
}
- (BOOL)allocateRenderResourcesAndReturnError:(NSError **)outError {
if (![super allocateRenderResourcesAndReturnError:outError]) return NO;
AVAudioChannelCount chIn = _inBus.format.channelCount, chOut = _outBus.format.channelCount;
if (chIn != chOut || chOut < 1 || chOut > 2) {
if (outError) *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_FailedInitialization userInfo:nil];
self.renderResourcesAllocated = NO;
return NO;
}
int sr = (int)std::lround(_outBus.format.sampleRate);
Kernel *k = _k.get();
k->channels = (int)chOut;
for (int c = 0; c < 2; ++c) {
k->fx[c] = c < k->channels ? Effect::create(k->type.c_str(), sr) : nullptr;
k->inBuf[c].assign(self.maximumFramesToRender, 0.f);
}
if (!k->fx[0]) {
if (outError) *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_FailedInitialization userInfo:nil];
self.renderResourcesAllocated = NO;
return NO;
}
k->musicalContext = self.musicalContextBlock;
k->seenValues = k->seenMailbox = 0; // force update() on the first render
return YES;
}
- (void)deallocateRenderResources {
for (auto &f : _k->fx) f.reset();
_k->musicalContext = nil;
[super deallocateRenderResources];
}
- (AUInternalRenderBlock)internalRenderBlock {
Kernel *k = _k.get();
return ^AUAudioUnitStatus(AudioUnitRenderActionFlags *actionFlags, const AudioTimeStamp *timestamp,
AVAudioFrameCount frameCount, NSInteger outputBusNumber,
AudioBufferList *outputData, const AURenderEvent *events,
AURenderPullInputBlock pullInputBlock) {
if (frameCount > k->inBuf[0].size() || !pullInputBlock) return kAudioUnitErr_TooManyFramesToProcess;
// Pull the input into our own buffers.
struct { AudioBufferList list; AudioBuffer extra; } in;
in.list.mNumberBuffers = (UInt32)k->channels;
for (int c = 0; c < k->channels; ++c) {
in.list.mBuffers[c].mNumberChannels = 1;
in.list.mBuffers[c].mDataByteSize = frameCount * sizeof(float);
in.list.mBuffers[c].mData = k->inBuf[c].data();
}
AudioUnitRenderActionFlags pullFlags = 0;
AUAudioUnitStatus err = pullInputBlock(&pullFlags, timestamp, frameCount, 0, &in.list);
if (err != noErr) return err;
// Host automation arrives as render events: apply at block start.
bool changed = false;
for (const AURenderEvent *e = events; e; e = e->head.next) {
if (e->head.eventType == AURenderEventParameter || e->head.eventType == AURenderEventParameterRamp) {
AUParameterAddress a = e->parameter.parameterAddress;
if (a < (AUParameterAddress)k->spec->paramCount) {
k->values[a].store(e->parameter.value, std::memory_order_relaxed);
changed = true;
}
}
}
if (changed) k->valuesSeq.fetch_add(1, std::memory_order_release);
bool tempoChanged = false;
if (k->musicalContext) {
double bpm = 0;
if (k->musicalContext(&bpm, nullptr, nullptr, nullptr, nullptr, nullptr) && bpm > 0 && bpm != k->tempo) {
k->tempo = bpm;
tempoChanged = true;
}
}
k->refresh(tempoChanged);
bool bypass = k->bypass.load(std::memory_order_relaxed);
for (int c = 0; c < k->channels && c < (int)outputData->mNumberBuffers; ++c) {
float *src = k->inBuf[c].data();
if (!outputData->mBuffers[c].mData) outputData->mBuffers[c].mData = src; // in place
float *dst = (float *)outputData->mBuffers[c].mData;
outputData->mBuffers[c].mDataByteSize = frameCount * sizeof(float);
if (bypass) {
if (dst != src) std::memcpy(dst, src, frameCount * sizeof(float));
continue;
}
Effect *fx = k->fx[c].get();
for (AVAudioFrameCount i = 0; i < frameCount; ++i) {
float y = fx->process(src[i]);
dst[i] = std::isfinite(y) ? y : 0.f;
}
}
(void)actionFlags; (void)outputBusNumber;
return noErr;
};
}
@end
+201
View File
@@ -0,0 +1,201 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The FX extension's principal class: the factory for every effect listed in
// components.txt (picked by subtype) and a generic editor for its parameters
// (sliders, segmented switches for short choice lists, menus for long ones).
// The card-style editors of the Android app come later; this keeps every
// parameter reachable meanwhile.
#import <CoreAudioKit/CoreAudioKit.h>
#import <UIKit/UIKit.h>
#import "Components.gen.h"
#import "SizzleEffectAU.h"
@interface SizzleFXViewController : AUViewController <AUAudioUnitFactory>
@end
static UIColor *Amber(void) { return [UIColor colorWithRed:0.96 green:0.76 blue:0.29 alpha:1]; }
static UIColor *Dim(void) { return [UIColor colorWithWhite:0.62 alpha:1]; }
@implementation SizzleFXViewController {
SizzleEffectAU *_au;
UIStackView *_stack;
NSMutableDictionary<NSNumber *, UIControl *> *_controls;
NSMutableDictionary<NSNumber *, UILabel *> *_valueLabels;
AUParameterObserverToken _token;
BOOL _built;
}
#pragma mark - factory
- (AUAudioUnit *)createAudioUnitWithComponentDescription:(AudioComponentDescription)desc error:(NSError **)error {
for (int i = 0; i < kSizzleComponentCount; ++i) {
if (kSizzleComponents[i].subtype == desc.componentSubType) {
_au = [[SizzleEffectAU alloc] initWithComponentDescription:desc
toolboxType:kSizzleComponents[i].toolboxType
displayName:@(kSizzleComponents[i].name)
error:error];
dispatch_async(dispatch_get_main_queue(), ^{ [self buildIfReady]; });
return _au;
}
}
if (error) *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_InvalidElement userInfo:nil];
return nil;
}
#pragma mark - view
- (void)viewDidLoad {
[super viewDidLoad];
self.preferredContentSize = CGSizeMake(520, 420);
self.view.backgroundColor = [UIColor colorWithRed:0.07 green:0.08 blue:0.09 alpha:1];
UIScrollView *scroll = [UIScrollView new];
scroll.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:scroll];
_stack = [UIStackView new];
_stack.axis = UILayoutConstraintAxisVertical;
_stack.spacing = 10;
_stack.translatesAutoresizingMaskIntoConstraints = NO;
[scroll addSubview:_stack];
UILayoutGuide *g = self.view.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[scroll.leadingAnchor constraintEqualToAnchor:g.leadingAnchor],
[scroll.trailingAnchor constraintEqualToAnchor:g.trailingAnchor],
[scroll.topAnchor constraintEqualToAnchor:g.topAnchor],
[scroll.bottomAnchor constraintEqualToAnchor:g.bottomAnchor],
[_stack.leadingAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.leadingAnchor constant:14],
[_stack.trailingAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.trailingAnchor constant:-14],
[_stack.topAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.topAnchor constant:12],
[_stack.bottomAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.bottomAnchor constant:-12],
[_stack.widthAnchor constraintEqualToAnchor:scroll.frameLayoutGuide.widthAnchor constant:-28],
]];
[self buildIfReady];
}
- (UILabel *)label:(NSString *)text size:(CGFloat)size color:(UIColor *)color {
UILabel *l = [UILabel new];
l.text = text;
l.font = [UIFont monospacedSystemFontOfSize:size weight:UIFontWeightRegular];
l.textColor = color;
return l;
}
- (void)buildIfReady {
if (_built || !_au || !_stack) return;
_built = YES;
_controls = [NSMutableDictionary dictionary];
_valueLabels = [NSMutableDictionary dictionary];
[_stack addArrangedSubview:[self label:_au.displayName.uppercaseString size:15 color:Amber()]];
if (_au.factoryPresets.count > 0) {
UIButton *presets = [UIButton buttonWithType:UIButtonTypeSystem];
[presets setTitle:@"PRESET ▾" forState:UIControlStateNormal];
presets.titleLabel.font = [UIFont monospacedSystemFontOfSize:13 weight:UIFontWeightRegular];
presets.tintColor = Amber();
presets.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
NSMutableArray<UIAction *> *items = [NSMutableArray array];
__weak SizzleEffectAU *au = _au;
__weak UIButton *weakButton = presets;
for (AUAudioUnitPreset *p in _au.factoryPresets) {
[items addObject:[UIAction actionWithTitle:p.name image:nil identifier:nil handler:^(UIAction *a) {
au.currentPreset = p;
[weakButton setTitle:[NSString stringWithFormat:@"PRESET: %@ ▾", p.name] forState:UIControlStateNormal];
}]];
}
presets.menu = [UIMenu menuWithChildren:items];
presets.showsMenuAsPrimaryAction = YES;
[_stack addArrangedSubview:presets];
}
for (AUParameter *p in _au.parameterTree.allParameters) [self addRowFor:p];
__weak SizzleFXViewController *weakSelf = self;
_token = [_au.parameterTree tokenByAddingParameterObserver:^(AUParameterAddress address, AUValue value) {
dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf show:address value:value]; });
}];
}
- (void)addRowFor:(AUParameter *)p {
NSNumber *addr = @(p.address);
UIStackView *head = [UIStackView new];
head.axis = UILayoutConstraintAxisHorizontal;
[head addArrangedSubview:[self label:p.displayName.uppercaseString size:11 color:Dim()]];
UILabel *value = [self label:[_au stringForParameter:p value:p.value] size:11 color:UIColor.whiteColor];
value.textAlignment = NSTextAlignmentRight;
[head addArrangedSubview:value];
_valueLabels[addr] = value;
UIControl *control;
NSArray<NSString *> *choices = p.valueStrings;
NSUInteger chars = [[choices componentsJoinedByString:@""] length];
__weak SizzleFXViewController *weakSelf = self;
if (choices.count > 0 && choices.count <= 6 && chars <= 34) {
UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:choices];
seg.selectedSegmentIndex = (NSInteger)lroundf(p.value);
seg.selectedSegmentTintColor = Amber();
[seg addAction:[UIAction actionWithHandler:^(UIAction *a) {
[weakSelf set:p value:(AUValue)seg.selectedSegmentIndex];
}] forControlEvents:UIControlEventValueChanged];
control = seg;
} else if (choices.count > 0) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeSystem];
b.tintColor = Amber();
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
NSMutableArray<UIAction *> *items = [NSMutableArray array];
[choices enumerateObjectsUsingBlock:^(NSString *name, NSUInteger i, BOOL *stop) {
[items addObject:[UIAction actionWithTitle:name image:nil identifier:nil handler:^(UIAction *a) {
[weakSelf set:p value:(AUValue)i];
}]];
}];
b.menu = [UIMenu menuWithChildren:items];
b.showsMenuAsPrimaryAction = YES;
[b setTitle:[NSString stringWithFormat:@"%@ ▾", choices[(NSUInteger)lroundf(p.value)]] forState:UIControlStateNormal];
control = b;
} else {
UISlider *s = [UISlider new];
s.minimumValue = p.minValue;
s.maximumValue = p.maxValue;
s.value = p.value;
s.minimumTrackTintColor = Amber();
BOOL isInt = p.unit == kAudioUnitParameterUnit_Indexed;
[s addAction:[UIAction actionWithHandler:^(UIAction *a) {
AUValue v = isInt ? roundf(s.value) : s.value;
[weakSelf set:p value:v];
}] forControlEvents:UIControlEventValueChanged];
control = s;
}
_controls[addr] = control;
UIStackView *row = [[UIStackView alloc] initWithArrangedSubviews:@[head, control]];
row.axis = UILayoutConstraintAxisVertical;
row.spacing = 4;
[_stack addArrangedSubview:row];
}
- (void)set:(AUParameter *)p value:(AUValue)v {
[p setValue:v originator:_token];
[self show:p.address value:v];
}
- (void)show:(AUParameterAddress)address value:(AUValue)value {
AUParameter *p = [_au.parameterTree parameterWithAddress:address];
if (!p) return;
_valueLabels[@(address)].text = [_au stringForParameter:p value:value];
UIControl *c = _controls[@(address)];
if ([c isKindOfClass:[UISlider class]]) {
if (!c.isTracking) ((UISlider *)c).value = value;
} else if ([c isKindOfClass:[UISegmentedControl class]]) {
((UISegmentedControl *)c).selectedSegmentIndex = (NSInteger)lroundf(value);
} else if ([c isKindOfClass:[UIButton class]] && p.valueStrings.count) {
NSUInteger i = MIN((NSUInteger)lroundf(value), p.valueStrings.count - 1);
[(UIButton *)c setTitle:[NSString stringWithFormat:@"%@ ▾", p.valueStrings[i]] forState:UIControlStateNormal];
}
}
- (void)dealloc {
if (_token && _au) [_au.parameterTree removeParameterObserver:_token];
}
@end
@@ -0,0 +1,6 @@
{
"images" : [
{ "filename" : "icon-1024.png", "idiom" : "universal", "platform" : "ios", "size" : "1024x1024" }
],
"info" : { "author" : "xcode", "version" : 1 }
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

@@ -0,0 +1 @@
{ "info" : { "author" : "xcode", "version" : 1 } }
+1
View File
@@ -0,0 +1 @@
#import "ObjC/SPKTry.h"
+37
View File
@@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
/// The container app: what Sizzle installs as plugins, and an on-device check
/// that each one loads and processes sound. The plugins themselves are used from
/// a host (AUM, GarageBand, Loopy, …).
struct ContentView: View {
@StateObject private var check = PluginCheck()
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Sizzle").font(.system(.largeTitle, design: .monospaced)).foregroundColor(.orange)
Text("AUv3 plugins for AUM, GarageBand, Loopy and other hosts.\nLook for \"Tired Sysadmin: Sizzle …\".")
.font(.system(.footnote, design: .monospaced)).foregroundColor(.gray)
Text(versionLine).font(.system(.caption, design: .monospaced)).foregroundColor(.gray)
Button("Check all plugins") { Task { await check.run() } }
.buttonStyle(.bordered).disabled(check.running)
ScrollView {
Text(check.lines.joined(separator: "\n"))
.font(.system(.footnote, design: .monospaced))
.frame(maxWidth: .infinity, alignment: .leading)
.textSelection(.enabled)
}
}
.padding()
.preferredColorScheme(.dark)
.onAppear { check.listInstalled() }
}
private var versionLine: String {
let v = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?"
let b = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "?"
return "version \(v) (\(b)) · iOS \(ProcessInfo.processInfo.operatingSystemVersionString)"
}
}
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.cc.tiredsysadmin.ios.sizzle</string>
</array>
</dict>
</plist>
+13
View File
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Runs `block`, turning an Objective-C exception (AVAudioEngine raises them for
/// misuse, and Swift can't catch them, so they crash the app) into a returned
/// description. Returns nil when the block finished normally.
NSString *_Nullable SPKTry(NS_NOESCAPE void (^block)(void));
NS_ASSUME_NONNULL_END
+13
View File
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import "SPKTry.h"
NSString *_Nullable SPKTry(NS_NOESCAPE void (^block)(void)) {
@try {
block();
return nil;
} @catch (NSException *e) {
return [NSString stringWithFormat:@"%@: %@", e.name, e.reason ?: @"(no reason)"];
}
}
+96
View File
@@ -0,0 +1,96 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import AVFoundation
/// Lists Sizzle's registered plugins and, on request, loads each one out of
/// process (as a host would) and renders a test signal through it offline.
/// PASS = loads, output is finite, and not silent.
@MainActor
final class PluginCheck: ObservableObject {
@Published var lines: [String] = []
@Published var running = false
private static let manufacturer: FourCharCode = "Tsys".utf8.reduce(0) { ($0 << 8) | FourCharCode($1) }
private func installed() -> [AVAudioUnitComponent] {
let any = AudioComponentDescription(componentType: 0, componentSubType: 0,
componentManufacturer: Self.manufacturer,
componentFlags: 0, componentFlagsMask: 0)
return AVAudioUnitComponentManager.shared().components(matching: any)
.filter { $0.audioComponentDescription.componentType == kAudioUnitType_Effect }
}
func listInstalled() {
let comps = installed()
lines = ["Registered effects: \(comps.count)"] + comps.map { " \($0.name)" }
}
func run() async {
running = true
defer { running = false }
let comps = installed()
lines = ["Checking \(comps.count) effects…"]
var ok = 0
for c in comps {
let result = await check(c)
if result.hasPrefix("PASS") { ok += 1 }
lines.append("\(result) \(c.name.replacingOccurrences(of: "Tired Sysadmin: ", with: ""))")
}
lines.append("\(ok)/\(comps.count) passed")
}
/// 1 s at 44.1 kHz stereo: a decaying saw burst, then noise, then silence.
private func testBuffer(format: AVAudioFormat) -> AVAudioPCMBuffer {
let n = AVAudioFrameCount(format.sampleRate)
let buf = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: n)!
buf.frameLength = n
var seed: UInt32 = 0x1234567
for i in 0..<Int(n) {
let t = Double(i) / format.sampleRate
var x: Float = 0
if t < 0.3 { x = Float(0.6 * (2 * (t * 110).truncatingRemainder(dividingBy: 1) - 1) * exp(-t * 6)) }
else if t < 0.6 { seed = seed &* 1103515245 &+ 12345; x = Float((seed >> 8) & 0xFFFF) / 65535 * 0.6 - 0.3 }
for ch in 0..<Int(format.channelCount) { buf.floatChannelData![ch][i] = x }
}
return buf
}
private func check(_ comp: AVAudioUnitComponent) async -> String {
do {
let unit = try await AVAudioUnit.instantiate(with: comp.audioComponentDescription, options: .loadOutOfProcess)
let engine = AVAudioEngine()
let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)!
let player = AVAudioPlayerNode()
var thrown: Error?
let ex = SPKTry {
do {
try engine.enableManualRenderingMode(.offline, format: format, maximumFrameCount: 4096)
engine.attach(player)
engine.attach(unit)
engine.connect(player, to: unit, format: format)
engine.connect(unit, to: engine.mainMixerNode, format: format)
try engine.start()
player.scheduleBuffer(self.testBuffer(format: format), completionHandler: nil)
player.play()
} catch { thrown = error }
}
if let ex = ex { return "FAIL exception \(ex)" }
if let e = thrown { return "FAIL \(e.localizedDescription)" }
let out = AVAudioPCMBuffer(pcmFormat: engine.manualRenderingFormat, frameCapacity: 4096)!
var peak: Float = 0, finite = true
for _ in 0..<11 {
_ = try engine.renderOffline(4096, to: out)
for ch in 0..<Int(out.format.channelCount) {
let d = out.floatChannelData![ch]
for i in 0..<Int(out.frameLength) { let v = d[i]; if !v.isFinite { finite = false }; peak = max(peak, abs(v)) }
}
}
engine.stop()
if !finite { return "FAIL non-finite output" }
return peak > 0.01 ? String(format: "PASS peak %.2f", peak) : String(format: "FAIL silent (peak %.4f)", peak)
} catch {
return "FAIL \(error.localizedDescription)"
}
}
}
+9
View File
@@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
@main
struct SizzleApp: App {
var body: some Scene { WindowGroup { ContentView() } }
}
+14
View File
@@ -0,0 +1,14 @@
# The AUv3 plugins the app ships. One line each:
# <AU type> <subtype> <ToolboxType> <display name>
# tools/gen_components.py turns this into app/FX/Info.plist (AudioComponents) and
# app/FX/Components.gen.h (subtype -> ToolboxType); edit here, not there.
# Manufacturer code for all of them: Tsys. Never change a subtype once shipped:
# hosts save projects by these codes.
aufx sBcr BITCRUSHER Bitcrusher
aufx sFlt FILTER Filter
aufx sEqx EQ10 10-Band EQ
aufx sDly DELAY Tape Delay
aufx sMxt MIX_TIGHTENER Mix Tightener
aufx sTpe TAPE_ENGINE Tape Engine
aufx sGrn GRANULAR Granular Glitch
aufx sAmb AMBIENCE Ambience Reverb
+66
View File
@@ -0,0 +1,66 @@
# XcodeGen spec for Sizzle on iOS/iPadOS (see ios/README.md). `make -C ios project`
# generates Sizzle.xcodeproj (git-ignored). Versions are passed in by the Makefile
# from versions.properties (ios.versionName / ios.versionCode).
name: Sizzle
options:
bundleIdPrefix: cc.tiredsysadmin.ios
deploymentTarget:
iOS: "15.0"
settings:
base:
SWIFT_VERSION: "5.0"
TARGETED_DEVICE_FAMILY: "1,2"
ARCHS: arm64
DEVELOPMENT_TEAM: ""
CLANG_CXX_LANGUAGE_STANDARD: c++17
CLANG_ENABLE_OBJC_ARC: YES
HEADER_SEARCH_PATHS: ["$(SRCROOT)/../core/include", "$(SRCROOT)/../core/src/fx"]
targets:
SizzleCore:
type: library.static
platform: iOS
sources:
- path: ../core/src
excludes: ["**/*.md"]
settings:
base:
PRODUCT_NAME: SizzleCore
GCC_OPTIMIZATION_LEVEL: s
SizzleFX:
type: app-extension
platform: iOS
sources: [FX]
dependencies:
- target: SizzleCore
- sdk: AudioToolbox.framework
- sdk: AVFoundation.framework
- sdk: CoreAudioKit.framework
- sdk: UIKit.framework
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzle.fx
CODE_SIGN_ENTITLEMENTS: FX/FX.entitlements
INFOPLIST_FILE: FX/Info.plist
# force_load: the effects are found through weak placeholder makers (Registry.cpp),
# so without it the linker keeps the placeholders and skips the real ports.
OTHER_LDFLAGS: ["-lc++", "-force_load", "$(BUILT_PRODUCTS_DIR)/libSizzleCore.a"]
Sizzle:
type: application
platform: iOS
sources: [Host]
dependencies:
- target: SizzleFX
embed: true
codeSign: false
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzle
CODE_SIGN_ENTITLEMENTS: Host/Host.entitlements
GENERATE_INFOPLIST_FILE: YES
INFOPLIST_KEY_CFBundleDisplayName: Sizzle
INFOPLIST_KEY_UILaunchScreen_Generation: YES
INFOPLIST_KEY_UIApplicationSceneManifest_Generation: YES
INFOPLIST_KEY_UISupportedInterfaceOrientations: "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"
ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon
SWIFT_OBJC_BRIDGING_HEADER: Host/Bridging.h
+159
View File
@@ -0,0 +1,159 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Mac-side check of the AUv3 wrapper (SizzleEffectAU), run by `make -C ios au-test`.
// AUAudioUnit exists on macOS too, so every effect in components.txt is registered
// in-process and driven through AVAudioEngine (offline), like a host would:
// 1. audio: the reference input through the AU must equal the C++ core run
// directly (both channels), so the wrapper adds nothing and drops nothing;
// 2. parameters: moving every parameter through the AU's tree must change the
// output to exactly what the core gives for those values;
// 3. presets (Mix Tightener) and saved state (fullState round trip).
#import <AVFoundation/AVFoundation.h>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <vector>
#import "Components.gen.h"
#import "SizzleEffectAU.h"
#include "sizzle/DeviceSpecs.gen.hpp"
#include "sizzle/Effect.hpp"
using namespace sizzle;
static int failures = 0;
static void check(bool ok, const char *what, const char *name) {
std::printf("%s %-18s %s\n", ok ? "PASS" : "FAIL", name, what);
if (!ok) ++failures;
}
static std::vector<float> readF32(const char *path) {
std::ifstream f(path, std::ios::binary);
std::vector<char> b((std::istreambuf_iterator<char>(f)), {});
std::vector<float> v(b.size() / 4);
memcpy(v.data(), b.data(), v.size() * 4);
return v;
}
static AVAudioUnit *instantiate(AudioComponentDescription d) {
__block AVAudioUnit *unit = nil;
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[AVAudioUnit instantiateWithComponentDescription:d options:0 completionHandler:^(AVAudioUnit *u, NSError *e) {
unit = u;
if (e) std::printf("instantiate error: %s\n", e.localizedDescription.UTF8String);
dispatch_semaphore_signal(sem);
}];
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
return unit;
}
/// Render [in] (mono, both channels) through [unit]; returns the left and right outputs.
static void renderAU(AVAudioUnit *unit, const std::vector<float> &in, std::vector<float> &L, std::vector<float> &R) {
AVAudioEngine *engine = [AVAudioEngine new];
AVAudioFormat *fmt = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:48000 channels:2];
NSError *err = nil;
[engine enableManualRenderingMode:AVAudioEngineManualRenderingModeOffline format:fmt maximumFrameCount:1024 error:&err];
AVAudioPlayerNode *player = [AVAudioPlayerNode new];
[engine attachNode:player];
[engine attachNode:unit];
[engine connect:player to:unit format:fmt];
[engine connect:unit to:engine.mainMixerNode format:fmt];
[engine startAndReturnError:&err];
AVAudioPCMBuffer *src = [[AVAudioPCMBuffer alloc] initWithPCMFormat:fmt frameCapacity:(AVAudioFrameCount)in.size()];
src.frameLength = (AVAudioFrameCount)in.size();
memcpy(src.floatChannelData[0], in.data(), in.size() * 4);
memcpy(src.floatChannelData[1], in.data(), in.size() * 4);
[player scheduleBuffer:src completionHandler:nil];
[player play];
AVAudioPCMBuffer *out = [[AVAudioPCMBuffer alloc] initWithPCMFormat:engine.manualRenderingFormat frameCapacity:1024];
L.clear(); R.clear();
while (L.size() < in.size()) {
[engine renderOffline:1024 toBuffer:out error:&err];
L.insert(L.end(), out.floatChannelData[0], out.floatChannelData[0] + out.frameLength);
R.insert(R.end(), out.floatChannelData[1], out.floatChannelData[1] + out.frameLength);
}
L.resize(in.size()); R.resize(in.size());
[engine stop];
}
static std::vector<float> renderCore(const char *type, const Params &p, const std::vector<float> &in) {
auto fx = Effect::create(type, 48000);
fx->update(p, 120.f);
std::vector<float> y(in.size());
for (size_t i = 0; i < in.size(); ++i) { float v = fx->process(in[i]); y[i] = std::isfinite(v) ? v : 0.f; }
return y;
}
static double maxDiff(const std::vector<float> &a, const std::vector<float> &b) {
double m = 0;
for (size_t i = 0; i < a.size() && i < b.size(); ++i) m = std::max(m, std::fabs((double)a[i] - b[i]));
return m;
}
int main(int argc, char **argv) {
@autoreleasepool {
if (argc < 2) { std::fprintf(stderr, "usage: au_test <golden/input.f32>\n"); return 2; }
std::vector<float> in = readF32(argv[1]);
in.resize(48000); // 1 s is plenty
for (int c = 0; c < kSizzleComponentCount; ++c) {
const SizzleComponent &sc = kSizzleComponents[c];
AudioComponentDescription d = {kAudioUnitType_Effect, sc.subtype, 'Tsys', 0, 0};
[AUAudioUnit registerSubclass:SizzleEffectAU.class asComponentDescription:d name:@(sc.name) version:1];
AVAudioUnit *unit = instantiate(d);
if (!unit) { check(false, "instantiate", sc.name); continue; }
const DeviceSpec *spec = findDevice(sc.toolboxType);
// 1. defaults
Params p; p.fill(*spec);
std::vector<float> L, R, want = renderCore(sc.toolboxType, p, in);
renderAU(unit, in, L, R);
char msg[160];
double dl = maxDiff(L, want), dr = maxDiff(R, want);
snprintf(msg, sizeof msg, "defaults: AU == core (L %.2g, R %.2g)", dl, dr);
check(dl < 1e-6 && dr < 1e-6, msg, sc.name);
// 2. move every parameter to 70% (enums: last choice) through the AU tree
AUAudioUnit *au = unit.AUAudioUnit;
for (int i = 0; i < spec->paramCount; ++i) {
const ParamSpec &s = spec->params[i];
AUParameter *param = [au.parameterTree parameterWithAddress:(AUParameterAddress)i];
AUValue v = s.isEnum() ? (AUValue)(s.choiceCount() - 1) : s.min + 0.7f * (s.max - s.min);
if (s.isInt) v = std::round(v);
param.value = v;
if (s.isEnum()) p.set(s.key, s.choices[s.choiceCount() - 1]); else p.set(s.key, v);
}
want = renderCore(sc.toolboxType, p, in);
renderAU(unit, in, L, R);
dl = maxDiff(L, want);
snprintf(msg, sizeof msg, "parameters at 70%%: AU == core (%.2g)", dl);
check(dl < 1e-6, msg, sc.name);
// 3a. factory presets
if (au.factoryPresets.count > 0) {
au.currentPreset = au.factoryPresets[1];
Params pp; pp.fill(*spec);
const char *const *kv = gen::mixTightenerPresets[1];
for (int i = 1; kv[i] && kv[i + 1]; i += 2) pp.set(kv[i], kv[i + 1]);
want = renderCore(sc.toolboxType, pp, in);
renderAU(unit, in, L, R);
dl = maxDiff(L, want);
snprintf(msg, sizeof msg, "factory preset \"%s\": AU == core (%.2g)", kv[0], dl);
check(dl < 1e-6, msg, sc.name);
}
// 3b. fullState round trip into a fresh instance
NSDictionary *state = au.fullState;
AVAudioUnit *other = instantiate(d);
other.AUAudioUnit.fullState = state;
std::vector<float> L2, R2;
renderAU(unit, in, L, R);
renderAU(other, in, L2, R2);
dl = maxDiff(L, L2);
snprintf(msg, sizeof msg, "fullState round trip renders the same (%.2g)", dl);
check(dl < 1e-6, msg, sc.name);
}
std::printf("\n%s (%d failures)\n", failures ? "FAILED" : "all passed", failures);
}
return failures ? 1 : 0;
}
+364
View File
@@ -0,0 +1,364 @@
// GENERATED by IosGoldenExport (make -C ios golden). Do not edit.
// Every Sizzle device's parameters, from ToolboxType in the Android app.
#pragma once
#include "sizzle/Specs.hpp"
namespace sizzle::gen {
inline const char *const NES_SYNTH_c0[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12", nullptr};
inline const char *const NES_SYNTH_c5[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12", nullptr};
inline const char *const NES_SYNTH_c10[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12", nullptr};
inline const char *const NES_SYNTH_c28[] = {"Tri", "Saw", "Square", "Sine", "S&H", nullptr};
inline const char *const NES_SYNTH_c30[] = {"0°", "45°", "90°", "135°", "180°", "225°", "270°", "315°", nullptr};
inline const char *const NES_SYNTH_c31[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
inline const char *const NES_SYNTH_c32[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
inline const char *const NES_SYNTH_c34[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
inline const char *const NES_SYNTH_c35[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
inline const char *const NES_SYNTH_c37[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
inline const char *const NES_SYNTH_c38[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
inline const char *const NES_SYNTH_c40[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
inline const char *const NES_SYNTH_c41[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
inline const ParamSpec NES_SYNTH_params[] = {
{"osc0wave", "Osc1 Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c0},
{"osc0oct", "Osc1 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
{"osc0semi", "Osc1 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
{"osc0fine", "Osc1 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
{"osc0level", "Osc1 Level", 0.9f, 0.0f, 1.0f, false, nullptr},
{"osc1wave", "Osc2 Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c5},
{"osc1oct", "Osc2 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
{"osc1semi", "Osc2 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
{"osc1fine", "Osc2 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
{"osc1level", "Osc2 Level", 0.0f, 0.0f, 1.0f, false, nullptr},
{"osc2wave", "Osc3 Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c10},
{"osc2oct", "Osc3 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
{"osc2semi", "Osc3 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
{"osc2fine", "Osc3 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
{"osc2level", "Osc3 Level", 0.0f, 0.0f, 1.0f, false, nullptr},
{"noise", "Noise", 0.0f, 0.0f, 1.0f, false, nullptr},
{"cutoff", "Cutoff", 0.55f, 0.0f, 1.0f, false, nullptr},
{"reso", "Resonance", 0.15f, 0.0f, 1.0f, false, nullptr},
{"keytrack", "Key Track", 0.3f, 0.0f, 1.0f, false, nullptr},
{"fenvamt", "Filter Env", 0.4f, -1.0f, 1.0f, false, nullptr},
{"fatk", "F.Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
{"fdec", "F.Decay", 0.25f, 0.0f, 2.0f, false, nullptr},
{"fsus", "F.Sustain", 0.4f, 0.0f, 1.0f, false, nullptr},
{"frel", "F.Release", 0.2f, 0.0f, 3.0f, false, nullptr},
{"attack", "Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
{"decay", "Decay", 0.2f, 0.0f, 2.0f, false, nullptr},
{"sustain", "Sustain", 0.7f, 0.0f, 1.0f, false, nullptr},
{"release", "Release", 0.2f, 0.0f, 3.0f, false, nullptr},
{"lfowave", "LFO Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c28},
{"lfodiv", "LFO Rate", 3.0f, 0.0f, 6.0f, true, nullptr},
{"lfophase", "LFO Phase", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c30},
{"m0src", "Mod1 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c31},
{"m0dst", "Mod1 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c32},
{"m0amt", "Mod1 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
{"m1src", "Mod2 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c34},
{"m1dst", "Mod2 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c35},
{"m1amt", "Mod2 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
{"m2src", "Mod3 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c37},
{"m2dst", "Mod3 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c38},
{"m2amt", "Mod3 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
{"m3src", "Mod4 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c40},
{"m3dst", "Mod4 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c41},
{"m3amt", "Mod4 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
};
inline const ParamSpec SAMPLER_params[] = {
{"volume", "Volume", 0.8f, 0.0f, 1.0f, false, nullptr},
};
inline const char *const SOUNDFONT_c6[] = {"Off", "On", nullptr};
inline const ParamSpec SOUNDFONT_params[] = {
{"program", "Program", 0.0f, 0.0f, 127.0f, true, nullptr},
{"volume", "Volume", 0.8f, 0.0f, 1.0f, false, nullptr},
{"attack", "Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
{"decay", "Decay", 0.1f, 0.0f, 2.0f, false, nullptr},
{"sustain", "Sustain", 1.0f, 0.0f, 1.0f, false, nullptr},
{"release", "Release", 0.2f, 0.0f, 3.0f, false, nullptr},
{"loop", "Loop", 0.0f, 0.0f, 1.0f, false, SOUNDFONT_c6},
{"loopXfade", "Loop XFade", 0.0f, 0.0f, 500.0f, false, nullptr},
};
inline const char *const MORPH_PAD_c0[] = {"Off", "Mist", "Cathedral", "Glacier", "Abyss", "Aurora", "Ember", "Tide", "Dust", "Wind", "Organ", "Hollow", "Vowel", "Shimmer", "Chanter", "Ensemble", "Bells", "Nocturne", "Haze", "Pulse", "Rime", "Deep", "Spectral", "Rust", "Still", "Velvet", "Chrome", "Swarm", "Foghorn", "Solar", "Cave", "Glass Harp", "Monk", "Static", "Lullaby", "Storm", "Prism", nullptr};
inline const char *const MORPH_PAD_c19[] = {"Unison", "-12", "+7", "+12", nullptr};
inline const char *const MORPH_PAD_c21[] = {"Low", "Band", "High", nullptr};
inline const char *const MORPH_PAD_c33[] = {"-12", "Unison", "+12", "+19", "+24", nullptr};
inline const ParamSpec MORPH_PAD_params[] = {
{"morphTo", "Morph To", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c0},
{"morph", "Morph", 0.0f, 0.0f, 1.0f, false, nullptr},
{"mtime", "Morph Time s", 0.0f, 0.0f, 120.0f, false, nullptr},
{"choir", "Choir", 0.5984252f, 0.0f, 1.0f, false, nullptr},
{"partials", "Partials", 0.7007874f, 0.0f, 1.0f, false, nullptr},
{"breath", "Breath", 0.2519685f, 0.0f, 1.0f, false, nullptr},
{"timbre", "Timbre", 0.503937f, 0.0f, 1.0f, false, nullptr},
{"warmth", "Warmth", 0.1496063f, 0.0f, 1.0f, false, nullptr},
{"body", "Body", 1.0f, 0.0f, 1.0f, false, nullptr},
{"attack", "Attack", 0.7007874f, 0.0f, 1.0f, false, nullptr},
{"release", "Release", 0.6535433f, 0.0f, 1.0f, false, nullptr},
{"velsens", "Velocity", 0.2992126f, 0.0f, 1.0f, false, nullptr},
{"motion", "Motion", 0.3464567f, 0.0f, 1.0f, false, nullptr},
{"mrate", "Motion Rate", 0.4015748f, 0.0f, 1.0f, false, nullptr},
{"tide", "Tide", 0.19685039f, 0.0f, 1.0f, false, nullptr},
{"tperiod", "Tide Speed", 0.2992126f, 0.0f, 1.0f, false, nullptr},
{"detune", "Detune", 0.4015748f, 0.0f, 1.0f, false, nullptr},
{"cfilter", "Filter", 0.3464567f, 0.0f, 1.0f, false, nullptr},
{"shape", "Shape", 0.0f, 0.0f, 1.0f, false, nullptr},
{"interval", "Interval", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c19},
{"creso", "Resonance", 0.0f, 0.0f, 1.0f, false, nullptr},
{"ctype", "Filter Type", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c21},
{"soft", "Soft", 0.0f, 0.0f, 1.0f, false, nullptr},
{"tilt", "Tilt", 0.4488189f, 0.0f, 1.0f, false, nullptr},
{"odd", "Odd", 0.19685039f, 0.0f, 1.0f, false, nullptr},
{"stretch", "Stretch", 0.0f, 0.0f, 1.0f, false, nullptr},
{"evolve", "Evolve", 0.0f, 0.0f, 1.0f, false, nullptr},
{"beat", "Beat", 0.0f, 0.0f, 1.0f, false, nullptr},
{"formant", "Formant", 0.6692913f, 0.0f, 1.0f, false, nullptr},
{"peak", "Peak", 0.0f, 0.0f, 1.0f, false, nullptr},
{"bres", "Glass", 0.5511811f, 0.0f, 1.0f, false, nullptr},
{"color", "Color", 0.0f, 0.0f, 1.0f, false, nullptr},
{"grain", "Grain", 0.0f, 0.0f, 1.0f, false, nullptr},
{"bpitch", "Pitch", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c33},
{"btone", "Tone", 0.503937f, 0.0f, 1.0f, false, nullptr},
{"air", "Air", 0.0f, 0.0f, 1.0f, false, nullptr},
};
inline const char *const GRAIN_CLOUD_c0[] = {"Felt Piano", "Bowed Glass", "Music Box", "Warm Pad", "Strings", "Low Drone", "Rain Field", "Kalimba", "Breath Choir", "Glass Tines", "Custom", nullptr};
inline const char *const GRAIN_CLOUD_c1[] = {"Cloud", "Dust", "Tape", "Bloom", "Pulse", "Drift", nullptr};
inline const char *const GRAIN_CLOUD_c15[] = {"Auto", "Hann", "Tukey", "Perc", "Swell", "Gauss", nullptr};
inline const char *const GRAIN_CLOUD_c22[] = {"Off", "On", nullptr};
inline const ParamSpec GRAIN_CLOUD_params[] = {
{"source", "Source", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c0},
{"mode", "Mode", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c1},
{"position", "Position", 0.35f, 0.0f, 1.0f, false, nullptr},
{"texture", "Texture", 0.72f, 0.0f, 1.0f, false, nullptr},
{"scatter", "Scatter", 0.45f, 0.0f, 1.0f, false, nullptr},
{"drift", "Drift", 0.35f, 0.0f, 1.0f, false, nullptr},
{"motion", "Evolve", 0.35f, 0.0f, 1.0f, false, nullptr},
{"pitch", "Pitch", 0.0f, -24.0f, 24.0f, true, nullptr},
{"harmony", "Harmony", 0.3f, 0.0f, 1.0f, false, nullptr},
{"size_mul", "Size", 0.0f, -2.0f, 2.0f, false, nullptr},
{"dens_mul", "Density", 0.0f, -2.0f, 2.0f, false, nullptr},
{"scan", "Scan", 0.0f, -1.0f, 1.0f, false, nullptr},
{"reverse", "Reverse", 0.1f, 0.0f, 1.0f, false, nullptr},
{"pitch_rand", "Pitch Rnd", 0.0f, 0.0f, 12.0f, false, nullptr},
{"size_rand", "Size Rnd", 0.3f, 0.0f, 1.0f, false, nullptr},
{"window", "Envelope", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c15},
{"grain_tone", "Tone", -0.1f, -1.0f, 1.0f, false, nullptr},
{"attack", "Attack", 0.15f, 0.0f, 1.0f, false, nullptr},
{"release", "Release", 0.45f, 0.0f, 1.0f, false, nullptr},
{"velo", "Velocity", 0.5f, 0.0f, 1.0f, false, nullptr},
{"start", "Start", 0.0f, 0.0f, 1.0f, false, nullptr},
{"end", "End", 1.0f, 0.0f, 1.0f, false, nullptr},
{"freeze", "Freeze", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c22},
{"level", "Level", 0.75f, 0.0f, 1.0f, false, nullptr},
};
inline const char *const WAVETABLE_c0[] = {"Classic", "PWM", "Vowels", "Harmonic Sweep", "Sync", "FM", "Organ", "Fold", "Digital", "Glass", "Odd Even", "Comb", "Custom", nullptr};
inline const char *const WAVETABLE_c7[] = {"Classic", "PWM", "Vowels", "Harmonic Sweep", "Sync", "FM", "Organ", "Fold", "Digital", "Glass", "Odd Even", "Comb", "Custom", nullptr};
inline const char *const WAVETABLE_c19[] = {"Auto", "256", "512", "1024", "2048", nullptr};
inline const char *const WAVETABLE_c20[] = {"Low", "Band", "High", nullptr};
inline const char *const WAVETABLE_c35[] = {"Sine", "Tri", "Saw", "Square", "S&H", nullptr};
inline const ParamSpec WAVETABLE_params[] = {
{"o1table", "Osc1 Table", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c0},
{"o1pos", "Osc1 Position", 0.0f, 0.0f, 1.0f, false, nullptr},
{"o1oct", "Osc1 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
{"o1semi", "Osc1 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
{"o1fine", "Osc1 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
{"o1level", "Osc1 Level", 0.8f, 0.0f, 1.0f, false, nullptr},
{"o1bend", "Osc1 Bend", 0.0f, -1.0f, 1.0f, false, nullptr},
{"o2table", "Osc2 Table", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c7},
{"o2pos", "Osc2 Position", 0.3f, 0.0f, 1.0f, false, nullptr},
{"o2oct", "Osc2 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
{"o2semi", "Osc2 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
{"o2fine", "Osc2 Fine", 7.0f, -50.0f, 50.0f, false, nullptr},
{"o2level", "Osc2 Level", 0.0f, 0.0f, 1.0f, false, nullptr},
{"o2bend", "Osc2 Bend", 0.0f, -1.0f, 1.0f, false, nullptr},
{"unison", "Unison", 1.0f, 1.0f, 4.0f, true, nullptr},
{"spread", "Spread", 0.3f, 0.0f, 1.0f, false, nullptr},
{"sub", "Sub", 0.0f, 0.0f, 1.0f, false, nullptr},
{"noise", "Noise", 0.0f, 0.0f, 1.0f, false, nullptr},
{"velsens", "Velocity", 0.5f, 0.0f, 1.0f, false, nullptr},
{"wtframe", "Frame Size", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c19},
{"ftype", "Filter", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c20},
{"cutoff", "Cutoff", 0.75f, 0.0f, 1.0f, false, nullptr},
{"reso", "Resonance", 0.15f, 0.0f, 1.0f, false, nullptr},
{"keytrack", "Key Track", 0.4f, 0.0f, 1.0f, false, nullptr},
{"fenv", "Env Amount", 0.2f, -1.0f, 1.0f, false, nullptr},
{"drive", "Drive", 0.0f, 0.0f, 1.0f, false, nullptr},
{"attack", "Attack", 0.01f, 0.0f, 5.0f, false, nullptr},
{"decay", "Decay", 0.3f, 0.0f, 5.0f, false, nullptr},
{"sustain", "Sustain", 0.8f, 0.0f, 1.0f, false, nullptr},
{"release", "Release", 0.4f, 0.0f, 8.0f, false, nullptr},
{"mattack", "Mod Attack", 0.5f, 0.0f, 10.0f, false, nullptr},
{"mdecay", "Mod Decay", 2.0f, 0.0f, 10.0f, false, nullptr},
{"msustain", "Mod Sustain", 0.5f, 0.0f, 1.0f, false, nullptr},
{"mrelease", "Mod Release", 1.0f, 0.0f, 10.0f, false, nullptr},
{"menvpos", "Env > Position", 0.3f, -1.0f, 1.0f, false, nullptr},
{"lfowave", "LFO Wave", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c35},
{"lfodiv", "LFO Sync", 1.0f, 0.0f, 6.0f, true, nullptr},
{"lfopos", "LFO > Position", 0.15f, 0.0f, 1.0f, false, nullptr},
{"lfopitch", "LFO > Pitch", 0.0f, 0.0f, 1.0f, false, nullptr},
{"lfocut", "LFO > Cutoff", 0.0f, 0.0f, 1.0f, false, nullptr},
};
inline const char *const ARPEGGIATOR_c0[] = {"Up", "Down", "UpDown", "Random", nullptr};
inline const char *const ARPEGGIATOR_c3[] = {"Off", "On", nullptr};
inline const ParamSpec ARPEGGIATOR_params[] = {
{"mode", "Mode", 0.0f, 0.0f, 1.0f, false, ARPEGGIATOR_c0},
{"octaves", "Octaves", 1.0f, 1.0f, 4.0f, true, nullptr},
{"division", "Division", 3.0f, 0.0f, 6.0f, true, nullptr},
{"resetbar", "Reset/Bar", 0.0f, 0.0f, 1.0f, false, ARPEGGIATOR_c3},
};
inline const ParamSpec TRANSPOSER_params[] = {
{"octaves", "Octaves", 0.0f, -4.0f, 4.0f, true, nullptr},
{"semitones", "Semitones", 0.0f, -24.0f, 24.0f, true, nullptr},
};
inline const char *const LFO_c0[] = {"Sine", "Triangle", "Saw", "Square", "SampleHold", nullptr};
inline const ParamSpec LFO_params[] = {
{"wave", "Wave", 0.0f, 0.0f, 1.0f, false, LFO_c0},
{"phase", "Phase", 0.0f, 0.0f, 1.0f, false, nullptr},
{"depth", "Depth", 0.5f, 0.0f, 1.0f, false, nullptr},
{"division", "Division", 3.0f, 0.0f, 6.0f, true, nullptr},
};
inline const ParamSpec DELAY_params[] = {
{"feedback", "Feedback", 0.4f, 0.0f, 0.9f, false, nullptr},
{"drywet", "Dry/Wet", 0.35f, 0.0f, 1.0f, false, nullptr},
{"tape", "Tape Strength", 0.3f, 0.0f, 1.0f, false, nullptr},
{"head0On", "Head 1 On", 1.0f, 0.0f, 1.0f, false, nullptr},
{"head0Div", "Head 1 Div", 5.0f, 0.0f, 12.0f, false, nullptr},
{"head1On", "Head 2 On", 0.0f, 0.0f, 1.0f, false, nullptr},
{"head1Div", "Head 2 Div", 8.0f, 0.0f, 12.0f, false, nullptr},
{"head2On", "Head 3 On", 0.0f, 0.0f, 1.0f, false, nullptr},
{"head2Div", "Head 3 Div", 3.0f, 0.0f, 12.0f, false, nullptr},
{"head3On", "Head 4 On", 0.0f, 0.0f, 1.0f, false, nullptr},
{"head3Div", "Head 4 Div", 2.0f, 0.0f, 12.0f, false, nullptr},
};
inline const char *const FILTER_c0[] = {"LPF", "HPF", "BPF", nullptr};
inline const ParamSpec FILTER_params[] = {
{"type", "Type", 0.0f, 0.0f, 1.0f, false, FILTER_c0},
{"cutoff", "Cutoff", 0.7f, 0.0f, 1.0f, false, nullptr},
{"resonance", "Resonance", 0.2f, 0.0f, 1.0f, false, nullptr},
{"warmth", "Warmth", 0.0f, 0.0f, 1.0f, false, nullptr},
{"envamt", "Env Amount", 0.0f, 0.0f, 1.0f, false, nullptr},
{"attack", "Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
{"decay", "Decay", 0.1f, 0.0f, 2.0f, false, nullptr},
{"sustain", "Sustain", 1.0f, 0.0f, 1.0f, false, nullptr},
{"release", "Release", 0.2f, 0.0f, 3.0f, false, nullptr},
};
inline const ParamSpec EQ10_params[] = {
{"band0", "Band 1", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band1", "Band 2", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band2", "Band 3", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band3", "Band 4", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band4", "Band 5", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band5", "Band 6", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band6", "Band 7", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band7", "Band 8", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band8", "Band 9", 0.0f, -1.0f, 1.0f, false, nullptr},
{"band9", "Band 10", 0.0f, -1.0f, 1.0f, false, nullptr},
};
inline const ParamSpec BITCRUSHER_params[] = {
{"bits", "Bits", 8.0f, 1.0f, 16.0f, true, nullptr},
{"downsample", "Downsample", 1.0f, 1.0f, 32.0f, true, nullptr},
{"drive", "Drive", 0.2f, 0.0f, 1.0f, false, nullptr},
};
inline const char *const AMBIENCE_c0[] = {"Room 1", "Room 2", "Hall 1", "Hall 2", "Plate", "Spring", "Goldfoil", nullptr};
inline const ParamSpec AMBIENCE_params[] = {
{"algo", "Algorithm", 0.0f, 0.0f, 6.0f, false, AMBIENCE_c0},
{"predelay", "Pre-Delay", 10.0f, 0.0f, 500.0f, false, nullptr},
{"roomsize", "Room Size", 1.0f, 0.3f, 2.0f, false, nullptr},
{"decay", "Decay", 1.5f, 0.1f, 20.0f, false, nullptr},
{"hfdamp", "HF Damp", 0.0f, 0.0f, 1.0f, false, nullptr},
{"lfabsorb", "LF Absorb", 0.0f, 0.0f, 1.0f, false, nullptr},
{"diffusion", "Diffusion", 0.7f, 0.0f, 1.0f, false, nullptr},
{"modamt", "Mod Amount", 0.25f, 0.0f, 1.0f, false, nullptr},
{"modrate", "Mod Rate", 0.5f, 0.05f, 2.0f, false, nullptr},
{"erlevel", "ER Level", 0.6f, 0.0f, 1.0f, false, nullptr},
{"saturation", "Saturation", 0.0f, 0.0f, 1.0f, false, nullptr},
{"wet", "Wet (dB)", -4.0f, -60.0f, 0.0f, false, nullptr},
{"dry", "Dry (dB)", 0.0f, -60.0f, 0.0f, false, nullptr},
{"duckamt", "Ducking (dB)", 0.0f, 0.0f, 20.0f, false, nullptr},
{"duckthresh", "Duck Thresh (dB)", -20.0f, -60.0f, 0.0f, false, nullptr},
{"duckattack", "Duck Attack (ms)", 10.0f, 0.5f, 100.0f, false, nullptr},
{"duckrelease", "Duck Release (ms)", 200.0f, 10.0f, 2000.0f, false, nullptr},
};
inline const ParamSpec MIX_TIGHTENER_params[] = {
{"strength", "Strength", 1.0f, 0.0f, 1.0f, false, nullptr},
};
inline const ParamSpec TAPE_ENGINE_params[] = {
{"speed", "Speed", 1.0f, 0.25f, 1.0f, false, nullptr},
{"wow", "Wow", 0.15f, 0.0f, 1.0f, false, nullptr},
{"flutter", "Flutter", 0.15f, 0.0f, 1.0f, false, nullptr},
{"hiss", "Hiss", 0.1f, 0.0f, 1.0f, false, nullptr},
{"division", "Wow Sync", 2.0f, 0.0f, 6.0f, true, nullptr},
};
inline const ParamSpec GRANULAR_params[] = {
{"intensity", "Intensity", 0.3f, 0.0f, 1.0f, false, nullptr},
};
inline const DeviceSpec devices[] = {
{"NES_SYNTH", "Synth", Kind::Instrument, NES_SYNTH_params, 43},
{"SAMPLER", "Sampler", Kind::Instrument, SAMPLER_params, 1},
{"SOUNDFONT", "SF2 / XI Loader", Kind::Instrument, SOUNDFONT_params, 8},
{"MORPH_PAD", "Morph Pad", Kind::Instrument, MORPH_PAD_params, 36},
{"GRAIN_CLOUD", "Grain Cloud", Kind::Instrument, GRAIN_CLOUD_params, 24},
{"WAVETABLE", "Wavetable", Kind::Instrument, WAVETABLE_params, 40},
{"ARPEGGIATOR", "MIDI Arpeggiator", Kind::Effect, ARPEGGIATOR_params, 4},
{"TRANSPOSER", "MIDI Transposer", Kind::Effect, TRANSPOSER_params, 2},
{"LFO", "MIDI LFO", Kind::Effect, LFO_params, 4},
{"DELAY", "Tape Delay", Kind::Effect, DELAY_params, 11},
{"FILTER", "Filter (LP/HP/BP)", Kind::Effect, FILTER_params, 9},
{"EQ10", "10-Band EQ", Kind::Effect, EQ10_params, 10},
{"BITCRUSHER", "Bitcrusher", Kind::Effect, BITCRUSHER_params, 3},
{"AMBIENCE", "Ambience Reverb", Kind::Effect, AMBIENCE_params, 17},
{"MIX_TIGHTENER", "Mix Tightener", Kind::Effect, MIX_TIGHTENER_params, 1},
{"TAPE_ENGINE", "Tape Engine", Kind::Effect, TAPE_ENGINE_params, 5},
{"GRANULAR", "Granular Glitch", Kind::Effect, GRANULAR_params, 1},
};
inline constexpr int deviceCount = 17;
// Mix Tightener factory presets: name, then key/value pairs, nullptr-terminated.
inline const char *const mixTightener0[] = {"808 Crisp", "cHiAtk", "3", "cHiMk", "2", "cHiRatio", "3", "cHiRel", "80", "cHiThr", "-24", "cLoAtk", "8", "cLoMk", "3", "cLoRatio", "4", "cLoRel", "140", "cLoThr", "-22", "cMidMk", "1", "cMidRatio", "2.5", "cMidThr", "-20", "eqHiFreq", "9000", "eqHiGain", "4", "eqLoFreq", "70", "eqLoGain", "4", "eqMidFreq", "450", "eqMidGain", "-2", "limCeil", "-0.3", "limRel", "80", "outGain", "2", "xHi", "3000", "xLo", "120", nullptr};
inline const char *const mixTightener1[] = {"Boom-Bap Kit", "cLoAtk", "12", "cLoMk", "2", "cLoRatio", "3", "cLoRel", "160", "cLoThr", "-20", "cMidMk", "1", "cMidRatio", "2.5", "cMidThr", "-18", "eqHiFreq", "10000", "eqHiGain", "1.5", "eqLoFreq", "90", "eqLoGain", "2", "limCeil", "-0.5", "outGain", "1.5", "xHi", "2500", "xLo", "160", nullptr};
inline const char *const mixTightener2[] = {"Trap Hats", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "4", "cHiRel", "60", "cHiThr", "-26", "cLoRatio", "1.5", "cMidRatio", "2", "eqHiFreq", "11000", "eqHiGain", "5", "eqMidFreq", "4000", "eqMidGain", "1", "limCeil", "-0.3", "outGain", "2", "xHi", "4000", nullptr};
inline const char *const mixTightener3[] = {"Industrial Drums", "cHiMk", "2", "cHiRatio", "3", "cHiThr", "-20", "cLoAtk", "6", "cLoMk", "3", "cLoRatio", "5", "cLoRel", "120", "cLoThr", "-18", "cMidAtk", "8", "cMidMk", "3", "cMidRatio", "4", "cMidRel", "120", "cMidThr", "-16", "eqHiFreq", "8000", "eqHiGain", "2", "eqLoFreq", "80", "eqLoGain", "3", "eqMidFreq", "2200", "eqMidGain", "3", "eqMidQ", "1.2", "limCeil", "-0.2", "limRel", "60", "outGain", "3", "xHi", "2000", "xLo", "150", nullptr};
inline const char *const mixTightener4[] = {"Techno Kick", "cHiRatio", "1.5", "cLoAtk", "4", "cLoMk", "3", "cLoRatio", "6", "cLoRel", "100", "cLoThr", "-16", "cMidRatio", "2", "eqLoFreq", "60", "eqLoGain", "3", "eqMidFreq", "700", "eqMidGain", "-2", "limCeil", "-0.2", "outGain", "2.5", "xHi", "3000", "xLo", "120", nullptr};
inline const char *const mixTightener5[] = {"House Groove", "cHiMk", "1", "cHiRatio", "2", "cHiThr", "-22", "cLoMk", "1.5", "cLoRatio", "2.5", "cLoThr", "-22", "cMidMk", "1", "cMidRatio", "2", "cMidThr", "-20", "eqHiFreq", "9000", "eqHiGain", "1.5", "eqLoFreq", "90", "eqLoGain", "1.5", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.85", "xHi", "2600", "xLo", "180", nullptr};
inline const char *const mixTightener6[] = {"DnB Breaks", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "3", "cHiRel", "60", "cHiThr", "-22", "cLoAtk", "3", "cLoMk", "2", "cLoRatio", "4", "cLoRel", "90", "cLoThr", "-18", "cMidAtk", "4", "cMidMk", "2", "cMidRatio", "3", "cMidRel", "90", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "2", "eqLoFreq", "80", "eqLoGain", "2", "eqMidFreq", "2500", "eqMidGain", "1.5", "limCeil", "-0.3", "limRel", "50", "outGain", "2", "xHi", "2500", "xLo", "150", nullptr};
inline const char *const mixTightener7[] = {"Lo-Fi Kit", "cHiRatio", "1.5", "cLoMk", "1", "cLoRatio", "2.5", "cLoThr", "-22", "cMidRatio", "2", "eqHiFreq", "6000", "eqHiGain", "-4", "eqLoFreq", "100", "eqLoGain", "2", "eqMidFreq", "500", "eqMidGain", "1", "limCeil", "-1", "outGain", "1", "strength", "0.8", "xHi", "2200", "xLo", "200", nullptr};
inline const char *const mixTightener8[] = {"Snare Crack", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "3", "cHiRel", "70", "cHiThr", "-22", "cLoRatio", "1.5", "cMidAtk", "3", "cMidMk", "2", "cMidRatio", "4", "cMidRel", "100", "cMidThr", "-18", "eqHiFreq", "8000", "eqHiGain", "3", "eqLoFreq", "200", "eqLoGain", "-2", "eqMidFreq", "2000", "eqMidGain", "3", "eqMidQ", "1.5", "limCeil", "-0.3", "outGain", "2", "xHi", "1800", "xLo", "250", nullptr};
inline const char *const mixTightener9[] = {"Clap Snap", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "3", "cLoRatio", "1.5", "cMidAtk", "3", "cMidMk", "1", "cMidRatio", "3", "eqHiFreq", "9000", "eqHiGain", "4", "eqMidFreq", "1500", "eqMidGain", "2", "outGain", "2", "xHi", "3000", nullptr};
inline const char *const mixTightener10[] = {"Cymbal Sheen", "cHiAtk", "5", "cHiMk", "1", "cHiRatio", "2.5", "cHiRel", "120", "cHiThr", "-26", "eqHiFreq", "12000", "eqHiGain", "4", "eqMidFreq", "3000", "eqMidGain", "-1", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.75", "xHi", "5000", nullptr};
inline const char *const mixTightener11[] = {"Percussion Tight", "cHiMk", "1", "cHiRatio", "2.5", "cLoMk", "1", "cLoRatio", "2", "cMidAtk", "4", "cMidMk", "1.5", "cMidRatio", "3", "eqHiFreq", "8000", "eqHiGain", "2", "eqMidFreq", "2500", "eqMidGain", "1.5", "outGain", "1.5", "xHi", "2500", "xLo", "200", nullptr};
inline const char *const mixTightener12[] = {"EBM Bass", "cHiRatio", "1.5", "cLoAtk", "10", "cLoMk", "3", "cLoRatio", "4", "cLoRel", "130", "cLoThr", "-18", "cMidAtk", "12", "cMidMk", "2", "cMidRatio", "3", "cMidRel", "130", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "-2", "eqLoFreq", "80", "eqLoGain", "3", "eqMidFreq", "800", "eqMidGain", "2", "eqMidQ", "1.2", "limCeil", "-0.3", "outGain", "2.5", "xHi", "1500", "xLo", "150", nullptr};
inline const char *const mixTightener13[] = {"Reese Bass", "cHiRatio", "1.5", "cLoAtk", "8", "cLoMk", "3", "cLoRatio", "5", "cLoRel", "120", "cLoThr", "-16", "cMidMk", "2", "cMidRatio", "3", "cMidThr", "-18", "eqLoFreq", "70", "eqLoGain", "2", "eqMidFreq", "500", "eqMidGain", "2", "limCeil", "-0.3", "outGain", "2", "xHi", "1200", "xLo", "140", nullptr};
inline const char *const mixTightener14[] = {"Acid 303", "cHiRatio", "2", "cLoMk", "2", "cLoRatio", "3", "cMidAtk", "6", "cMidMk", "2", "cMidRatio", "4", "cMidRel", "110", "cMidThr", "-18", "eqLoFreq", "90", "eqLoGain", "1", "eqMidFreq", "1200", "eqMidGain", "3", "eqMidQ", "1.5", "limCeil", "-0.4", "outGain", "2", "xHi", "1800", "xLo", "160", nullptr};
inline const char *const mixTightener15[] = {"Sub Bass Tame", "cHiRatio", "1.2", "cLoAtk", "12", "cLoMk", "3", "cLoRatio", "6", "cLoRel", "150", "cLoThr", "-14", "cMidRatio", "2", "eqLoFreq", "55", "eqLoGain", "2", "eqMidFreq", "900", "eqMidGain", "-2", "limCeil", "-0.5", "outGain", "2", "strength", "0.9", "xHi", "2000", "xLo", "120", nullptr};
inline const char *const mixTightener16[] = {"FM Bass Punch", "cHiRatio", "2", "cLoAtk", "6", "cLoMk", "2", "cLoRatio", "4", "cLoRel", "110", "cLoThr", "-18", "cMidMk", "1.5", "cMidRatio", "3", "cMidThr", "-18", "eqLoFreq", "90", "eqLoGain", "2", "eqMidFreq", "1000", "eqMidGain", "1.5", "limCeil", "-0.3", "outGain", "2", "xHi", "2200", "xLo", "160", nullptr};
inline const char *const mixTightener17[] = {"Goth Bass", "cHiRatio", "1.5", "cLoAtk", "10", "cLoMk", "3", "cLoRatio", "4", "cLoRel", "140", "cLoThr", "-18", "cMidMk", "1", "cMidRatio", "2.5", "eqHiFreq", "8000", "eqHiGain", "-2", "eqLoFreq", "75", "eqLoGain", "3", "eqMidFreq", "600", "eqMidGain", "-1", "limCeil", "-0.5", "outGain", "2", "strength", "0.9", "xHi", "1600", "xLo", "140", nullptr};
inline const char *const mixTightener18[] = {"Synthwave Bass", "cHiRatio", "2", "cLoAtk", "10", "cLoMk", "2", "cLoRatio", "3", "cLoRel", "130", "cLoThr", "-20", "cMidMk", "1", "cMidRatio", "2.5", "eqHiFreq", "7000", "eqHiGain", "1", "eqLoFreq", "80", "eqLoGain", "2.5", "eqMidFreq", "900", "eqMidGain", "1", "limCeil", "-0.5", "outGain", "1.8", "xHi", "2000", "xLo", "150", nullptr};
inline const char *const mixTightener19[] = {"Synthwave Lead", "cHiMk", "1.5", "cHiRatio", "2", "cHiThr", "-22", "cLoRatio", "1.5", "cMidAtk", "12", "cMidMk", "1.5", "cMidRatio", "2.5", "cMidRel", "150", "cMidThr", "-20", "eqHiFreq", "9000", "eqHiGain", "4", "eqLoFreq", "200", "eqLoGain", "-1", "eqMidFreq", "2000", "eqMidGain", "1.5", "limCeil", "-0.5", "outGain", "2", "strength", "0.85", "xHi", "3000", "xLo", "300", nullptr};
inline const char *const mixTightener20[] = {"Cutting Lead", "cHiMk", "1", "cHiRatio", "2", "cLoRatio", "1.5", "cMidAtk", "8", "cMidMk", "2", "cMidRatio", "3", "cMidRel", "130", "cMidThr", "-18", "eqHiFreq", "8000", "eqHiGain", "2", "eqLoFreq", "200", "eqLoGain", "-2", "eqMidFreq", "3000", "eqMidGain", "3", "eqMidQ", "1.2", "limCeil", "-0.4", "outGain", "2", "xHi", "3500", "xLo", "300", nullptr};
inline const char *const mixTightener21[] = {"Darkwave Pad", "cHiRatio", "2", "cLoMk", "1", "cLoRatio", "2", "cMidAtk", "20", "cMidMk", "1", "cMidRatio", "2", "cMidRel", "200", "cMidThr", "-24", "eqHiFreq", "8000", "eqHiGain", "-2", "eqLoFreq", "150", "eqLoGain", "1", "eqMidFreq", "1000", "eqMidGain", "0.5", "limCeil", "-1", "outGain", "1", "strength", "0.7", "xHi", "2500", "xLo", "250", nullptr};
inline const char *const mixTightener22[] = {"Ambient Wash", "cMidAtk", "30", "cMidMk", "0.5", "cMidRatio", "1.8", "cMidRel", "250", "cMidThr", "-26", "eqHiFreq", "10000", "eqHiGain", "1", "eqLoFreq", "120", "eqLoGain", "1", "limCeil", "-1.5", "outGain", "0.5", "strength", "0.6", "xHi", "3000", "xLo", "300", nullptr};
inline const char *const mixTightener23[] = {"Pluck Tight", "cHiAtk", "2", "cHiMk", "1.5", "cHiRatio", "2.5", "cHiRel", "70", "cHiThr", "-22", "cLoRatio", "1.5", "cMidAtk", "3", "cMidMk", "1.5", "cMidRatio", "3", "cMidRel", "100", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "3", "eqMidFreq", "2500", "eqMidGain", "2", "outGain", "1.5", "xHi", "3000", "xLo", "300", nullptr};
inline const char *const mixTightener24[] = {"Arp Sparkle", "cHiAtk", "4", "cHiMk", "1.5", "cHiRatio", "2.5", "cHiThr", "-24", "cMidMk", "1", "cMidRatio", "2", "eqHiFreq", "11000", "eqHiGain", "4", "eqMidFreq", "3000", "eqMidGain", "1", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.8", "xHi", "4000", nullptr};
inline const char *const mixTightener25[] = {"Chip Lead", "cHiMk", "1", "cHiRatio", "2", "cLoRatio", "1.2", "cMidMk", "2", "cMidRatio", "3", "cMidThr", "-18", "eqHiFreq", "8000", "eqHiGain", "2", "eqLoFreq", "150", "eqLoGain", "-3", "eqMidFreq", "2500", "eqMidGain", "2.5", "eqMidQ", "1.2", "limCeil", "-0.4", "outGain", "2", "xHi", "3000", "xLo", "350", nullptr};
inline const char *const mixTightener26[] = {"Bell Clarity", "cHiAtk", "4", "cHiMk", "1", "cHiRatio", "2", "cMidAtk", "6", "cMidMk", "1", "cMidRatio", "2", "eqHiFreq", "10000", "eqHiGain", "3", "eqMidFreq", "1800", "eqMidGain", "1.5", "limCeil", "-0.5", "outGain", "1", "strength", "0.75", "xHi", "4000", nullptr};
inline const char *const mixTightener27[] = {"Keys Clarity", "cHiMk", "1", "cHiRatio", "2", "cLoRatio", "1.8", "cMidAtk", "10", "cMidMk", "1", "cMidRatio", "2.5", "cMidRel", "150", "cMidThr", "-22", "eqHiFreq", "9000", "eqHiGain", "2", "eqLoFreq", "200", "eqLoGain", "-1", "eqMidFreq", "2500", "eqMidGain", "1.5", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.8", "xHi", "3000", "xLo", "250", nullptr};
inline const char *const mixTightener28[] = {"Mix Glue", "cHiAtk", "15", "cHiMk", "1", "cHiRatio", "2", "cHiRel", "180", "cHiThr", "-22", "cLoAtk", "20", "cLoMk", "1", "cLoRatio", "2", "cLoRel", "200", "cLoThr", "-22", "cMidAtk", "25", "cMidMk", "1", "cMidRatio", "2", "cMidRel", "200", "cMidThr", "-22", "eqHiFreq", "10000", "eqHiGain", "1", "eqLoFreq", "100", "eqLoGain", "0.5", "limCeil", "-0.8", "outGain", "1", "strength", "0.7", "xHi", "2500", "xLo", "200", nullptr};
inline const char *const mixTightener29[] = {"Loudness Max", "cHiMk", "2", "cHiRatio", "3", "cHiThr", "-20", "cLoMk", "2", "cLoRatio", "3", "cLoThr", "-20", "cMidMk", "2", "cMidRatio", "3", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "2", "eqLoFreq", "90", "eqLoGain", "1", "limCeil", "-0.1", "limRel", "40", "outGain", "4", "xHi", "2800", "xLo", "180", nullptr};
inline const char *const *const mixTightenerPresets[] = {mixTightener0, mixTightener1, mixTightener2, mixTightener3, mixTightener4, mixTightener5, mixTightener6, mixTightener7, mixTightener8, mixTightener9, mixTightener10, mixTightener11, mixTightener12, mixTightener13, mixTightener14, mixTightener15, mixTightener16, mixTightener17, mixTightener18, mixTightener19, mixTightener20, mixTightener21, mixTightener22, mixTightener23, mixTightener24, mixTightener25, mixTightener26, mixTightener27, mixTightener28, mixTightener29, nullptr};
} // namespace sizzle::gen
+27
View File
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <memory>
#include "sizzle/Params.hpp"
namespace sizzle {
/**
* An insert effect: the C++ twin of AudioEffect in Effects.kt. `update` refreshes
* cached settings (call it when the params change, and once before processing);
* `process` runs per mono sample and must never allocate or lock. Construct on a
* normal thread: constructors allocate delay lines for [sampleRate].
*/
class Effect {
public:
virtual ~Effect() = default;
virtual void update(const Params &p, float tempoBpm) = 0;
virtual float process(float x) = 0;
/** The effect for ToolboxType name [type] ("DELAY", "FILTER", …), or nullptr
* for types without an audio processor (the MIDI effects) or not ported yet. */
static std::unique_ptr<Effect> create(const char *type, int sampleRate);
};
} // namespace sizzle
+45
View File
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <cstdlib>
#include <cstring>
#include "sizzle/Specs.hpp"
namespace sizzle {
/**
* A device's settings, the C++ twin of ToolboxSlot's string map: every value is
* kept as text so `f()` / `s()` read exactly what the Kotlin `slot.float()` /
* `slot.string()` would. Fixed capacity, no allocation: safe to read from
* `Effect::update` on the audio thread. Keys are stored by copy, so values can
* come from a file (tests), a preset, or AU parameters.
*/
class Params {
public:
static constexpr int kMax = 96;
static constexpr int kKeyLen = 24;
static constexpr int kValLen = 32;
/** All of [spec]'s defaults, like ToolboxSlot.fill(). */
void fill(const DeviceSpec &spec);
void set(const char *key, const char *value);
void set(const char *key, float value);
/** Number as Kotlin's String.toFloat would parse it, else [fallback]. */
float f(const char *key, float fallback = 0.f) const;
/** The stored text (enum choice name), else [fallback]. */
const char *s(const char *key, const char *fallback = "") const;
bool has(const char *key) const { return find(key) >= 0; }
/** Stored entries in insertion order (for saving state). */
int size() const { return n_; }
const char *keyAt(int i) const { return keys_[i]; }
const char *valueAt(int i) const { return vals_[i]; }
private:
int find(const char *key) const;
char keys_[kMax][kKeyLen] = {};
char vals_[kMax][kValLen] = {};
int n_ = 0;
};
} // namespace sizzle
+35
View File
@@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
// Plain descriptions of Sizzle's devices and their parameters. The tables
// themselves are generated from the Android app (DeviceSpecs.gen.hpp).
namespace sizzle {
enum class Kind { Instrument, Effect };
/** One parameter, as ToolboxType's ParamSpec: choices != nullptr marks an enum
* (nullptr-terminated list of names; the default is an index into it). */
struct ParamSpec {
const char *key;
const char *label;
float def, min, max;
bool isInt;
const char *const *choices;
bool isEnum() const { return choices != nullptr; }
int choiceCount() const { int n = 0; if (choices) while (choices[n]) ++n; return n; }
};
struct DeviceSpec {
const char *type; // ToolboxType name, e.g. "BITCRUSHER"
const char *displayName;
Kind kind;
const ParamSpec *params;
int paramCount;
};
/** The device with ToolboxType name [type], or nullptr. */
const DeviceSpec *findDevice(const char *type);
} // namespace sizzle
+65
View File
@@ -0,0 +1,65 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#include "sizzle/Params.hpp"
#include <cctype>
#include <cstdio>
namespace sizzle {
void Params::fill(const DeviceSpec &spec) {
n_ = 0;
for (int i = 0; i < spec.paramCount; ++i) {
const ParamSpec &p = spec.params[i];
if (p.isEnum()) {
int idx = (int)p.def;
int n = p.choiceCount();
if (idx < 0) idx = 0;
if (idx > n - 1) idx = n - 1;
set(p.key, p.choices[idx]);
} else {
set(p.key, p.def);
}
}
}
int Params::find(const char *key) const {
for (int i = 0; i < n_; ++i) if (std::strcmp(keys_[i], key) == 0) return i;
return -1;
}
void Params::set(const char *key, const char *value) {
int i = find(key);
if (i < 0) {
if (n_ >= kMax) return;
i = n_++;
std::snprintf(keys_[i], kKeyLen, "%s", key);
}
std::snprintf(vals_[i], kValLen, "%s", value);
}
void Params::set(const char *key, float value) {
// Shortest text that reads back as the same float (Kotlin stores toString()).
char buf[kValLen];
std::snprintf(buf, sizeof buf, "%.9g", (double)value);
set(key, buf);
}
float Params::f(const char *key, float fallback) const {
int i = find(key);
if (i < 0) return fallback;
const char *s = vals_[i];
while (std::isspace((unsigned char)*s)) ++s;
if (!*s) return fallback;
char *end = nullptr;
float v = std::strtof(s, &end);
while (end && std::isspace((unsigned char)*end)) ++end;
return (end && *end == '\0') ? v : fallback;
}
const char *Params::s(const char *key, const char *fallback) const {
int i = find(key);
return i < 0 ? fallback : vals_[i];
}
} // namespace sizzle
+14
View File
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#include <cstring>
#include "sizzle/DeviceSpecs.gen.hpp"
namespace sizzle {
const DeviceSpec *findDevice(const char *type) {
for (const auto &d : gen::devices) if (std::strcmp(d.type, type) == 0) return &d;
return nullptr;
}
} // namespace sizzle
+401
View File
@@ -0,0 +1,401 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of AmbienceReverb.kt: mono 8-line FDN reverb (OTODESK "Ambience" style) with
// predelay, early reflections, input diffusers, nested allpasses, xorshift-noise
// LFOs, ducking and wet saturation. Line-for-line; Float stays float.
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <vector>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
// The JVM never fuses a*b+c; keep the compiler from contracting into FMA.
#if defined(__clang__)
#pragma clang fp contract(off)
#endif
namespace sizzle {
namespace {
constexpr int N = 8;
const float FWHT_NORM = 1.f / kt::sqrtf_((float)N);
constexpr float LATE_SCALE = 2.f / N;
constexpr int MAX_ER = 12;
constexpr int MAX_ER_ACTIVE = 6;
constexpr float PHI = 1.6180339887f;
constexpr float TWO_PI = 6.28318530718f;
const float ALGO_HF[] = {0.00f, 0.26f, 0.26f, 0.22f, 0.36f, 0.14f, 0.30f};
const float ALGO_OFFSET_DB[] = {0.8f, 0.9f, 0.5f, 0.5f, 1.5f, 0.6f, 0.6f};
const float ALGO_SAT_MUL[] = {0.90f, 0.90f, 0.93f, 0.93f, 1.00f, 1.05f, 1.02f};
const float SIGN_FLIP[N] = {1.f, -1.f, 1.f, -1.f, -1.f, 1.f, -1.f, 1.f};
const char *const ALGORITHMS[] = {"Room 1", "Room 2", "Hall 1", "Hall 2", "Plate", "Spring", "Goldfoil"};
const float ER_ROOM1[] = {
5.2f, 0.65f, 8.7f, 0.58f, 12.4f, 0.52f, 15.8f, 0.46f, 19.3f, 0.42f, 24.1f, 0.36f,
28.6f, 0.32f, 33.5f, 0.28f, 38.9f, 0.24f, 45.2f, 0.20f, 52.8f, 0.16f, 62.4f, 0.13f,
};
const float ER_ROOM2[] = {
7.5f, 0.62f, 12.3f, 0.55f, 17.1f, 0.49f, 22.8f, 0.43f, 28.5f, 0.38f, 34.2f, 0.33f,
41.6f, 0.28f, 49.3f, 0.24f, 57.8f, 0.20f, 67.5f, 0.17f, 78.2f, 0.14f, 90.6f, 0.11f,
};
const float ER_HALL1[] = {
12.0f, 0.58f, 18.5f, 0.52f, 25.7f, 0.47f, 33.4f, 0.42f, 42.1f, 0.38f, 51.6f, 0.33f,
62.3f, 0.29f, 73.9f, 0.25f, 86.5f, 0.21f, 99.8f, 0.18f, 113.4f, 0.15f, 128.7f, 0.12f,
};
const float ER_HALL2[] = {
16.5f, 0.55f, 24.8f, 0.50f, 33.7f, 0.45f, 43.5f, 0.40f, 54.2f, 0.36f, 65.8f, 0.32f,
78.4f, 0.28f, 92.1f, 0.24f, 107.3f, 0.21f, 123.6f, 0.18f, 141.2f, 0.15f, 160.5f, 0.12f,
};
const float *const ER_PATTERNS[] = {ER_ROOM1, ER_ROOM2, ER_HALL1, ER_HALL2, nullptr, nullptr, nullptr};
const int ER_PATTERN_SIZE[] = {24, 24, 24, 24, 0, 0, 0};
inline float lnf_(float x) { return (float)std::log((double)x); }
inline float floorf_(float x) { return (float)std::floor((double)x); }
inline float pow10(float x) { return kt::expf_(x * 2.302585093f); }
inline float db2lin(float db) { return pow10(db / 20.f); }
/** In-place size-N Fast Walsh-Hadamard transform, normalised (÷√N) → orthonormal. */
void fwht(float *v) {
int h = 1;
while (h < N) {
int i = 0;
while (i < N) {
int j = i;
while (j < i + h) {
float a = v[j]; float b = v[j + h];
v[j] = a + b; v[j + h] = a - b;
j++;
}
i += h * 2;
}
h *= 2;
}
for (int k = 0; k < N; ++k) v[k] *= FWHT_NORM;
}
bool isPrime(int n) {
if (n < 2) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
int i = 3;
while (i * i <= n) { if (n % i == 0) return false; i += 2; }
return true;
}
bool usedNone(const int *used, int count, int v) {
for (int k = 0; k < count; ++k) if (used[k] == v) return false;
return true;
}
int nearestUniquePrime(int target, const int *used, int count) {
int t = std::max(target, 2);
int offset = 0;
while (offset < 100000) {
int hi = t + offset;
if (isPrime(hi) && usedNone(used, count, hi)) return hi;
int lo = t - offset;
if (offset > 0 && lo >= 2 && isPrime(lo) && usedNone(used, count, lo)) return lo;
offset++;
}
return t;
}
float softClip(float x) {
if (x > 1.f) return 1.f - 1.f / (x + 1.f);
if (x < -1.f) return -1.f + 1.f / (-x + 1.f);
return x;
}
/** A power-of-two circular buffer with fractional (linear-interpolated) reads. */
class DelayLine {
std::vector<float> buf;
int mask;
int w = 0;
public:
explicit DelayLine(int size) {
int p = 1;
while (p < size) p *= 2;
buf.assign((size_t)p, 0.f);
mask = p - 1;
}
float maxDelay() const { return (float)(mask - 2); }
void write(float x) { buf[(size_t)w] = x; w = (w + 1) & mask; }
float read(float delay) const {
float d = kt::coerceIn(delay, 1.f, (float)mask - 1.f);
float rp = (float)w - d;
float i0f = floorf_(rp);
float frac = rp - i0f;
int i0 = kt::toInt(i0f) & mask;
int i1 = (i0 + 1) & mask;
return buf[(size_t)i0] * (1.f - frac) + buf[(size_t)i1] * frac;
}
};
class AmbienceReverb final : public Effect {
float fs;
DelayLine preDelay;
DelayLine erLine;
std::vector<DelayLine> diffusers;
std::vector<DelayLine> fdn;
std::vector<DelayLine> apf;
float fbVec[N] = {};
float fbScratch[N] = {};
float nextFb[N] = {};
float baseDelay[N] = {};
float decayGain[N] = {};
float hfState[N] = {};
float lfState[N] = {};
float freqMod[N];
float apfBase[N];
float diffuserSmp[4];
int32_t lfoState[N];
float lfoSmooth[N] = {};
float lfoCoeff[N] = {};
float lfoRateMul[N];
float hfCoeff = 1.f;
float lfCoeff = 0.f;
float lfAmt = 0.f;
float apfGain = 0.5f;
float diffusionSens = 1.f;
bool bypassER = false;
float makeup = 1.f;
float satMul = 1.f;
float modDepthScale = 1.f;
int erCount = 0;
float erDelaySmp[MAX_ER] = {};
float erGain[MAX_ER] = {};
float wetLin = 0.63f;
float dryLin = 1.f;
float preDelaySmp = 480.f;
float modDepth = 0.f;
float diffGain = 0.63f;
float effApfGain = 0.4f;
float satAmt = 0.f;
float erLevel = 0.6f;
float duckAmtDb = 0.f;
float duckThreshDb = -20.f;
float duckThreshLin = 0.1f;
float duckAtt = 0.01f;
float duckRel = 0.001f;
float duckEnv = 0.f;
float dc1 = 0.f;
float dcY = 0.f;
int lastAlgo = -1;
float lastSize = NAN;
float lastDecay = NAN;
float lastHf = NAN;
float lastLf = NAN;
float lastDiffusion = NAN;
void recompute(int algo, float size, float decay, float hf, float lf, float diffusion) {
(void)diffusion;
switch (algo) {
case 0: case 1: apfGain = 0.3f; diffusionSens = 1.f; bypassER = false; break;
case 2: case 3: apfGain = 0.618f; diffusionSens = 1.f; bypassER = false; break;
case 4: apfGain = 0.7f; diffusionSens = 0.7f; bypassER = true; break;
case 5: apfGain = 0.5f; diffusionSens = 0.5f; bypassER = true; break;
default: apfGain = 0.75f; diffusionSens = 0.8f; bypassER = true; break;
}
float sizeCoeff = kt::coerceIn(size + 0.5f, 0.5f, 2.f);
float minMs = 15.f + sizeCoeff * 7.5f;
float maxMs = 50.f + sizeCoeff * 75.f;
int minS = std::max(11, kt::toInt(minMs * 0.001f * fs));
int maxS = kt::coerceAtLeast(kt::toInt(maxMs * 0.001f * fs), minS + 1);
float logMin = lnf_((float)minS);
float logMax = lnf_((float)maxS);
int used[N] = {};
for (int i = 0; i < N; ++i) {
float t = (float)i / ((float)N - 1.f);
int target = kt::toInt(kt::expf_(logMin + t * (logMax - logMin)));
int p = nearestUniquePrime(target, used, i);
used[i] = p;
baseDelay[i] = kt::coerceAtMost((float)p, fdn[(size_t)i].maxDelay());
}
for (int i = 0; i < N; ++i) {
float tSec = baseDelay[i] / fs;
decayGain[i] = kt::coerceIn(pow10(-3.f * tSec / decay), 0.f, 0.9995f);
}
float totalHf = kt::coerceIn(hf + ALGO_HF[algo], 0.f, 0.95f);
float hfCut = 16000.f * (1.f - totalHf) + 700.f * totalHf;
hfCoeff = kt::coerceIn(1.f - kt::expf_(-TWO_PI * hfCut / fs), 0.02f, 1.f);
lfCoeff = kt::coerceIn(1.f - kt::expf_(-TWO_PI * 200.f / fs), 0.f, 1.f);
lfAmt = lf * 0.9f;
modDepthScale = 1.f + kt::coerceIn((decay - 1.f) * 0.5f, 0.f, 2.f);
float decayCompDb = 7.f * kt::log10f_(kt::coerceAtLeast(decay, 0.1f));
makeup = db2lin(16.f + decayCompDb + ALGO_OFFSET_DB[algo]);
satMul = ALGO_SAT_MUL[algo];
const float *pattern = ER_PATTERNS[algo];
erCount = bypassER ? 0 : std::min(ER_PATTERN_SIZE[algo] / 2, MAX_ER_ACTIVE);
float erSizeScale = 0.5f + size;
for (int t = 0; t < erCount; ++t) {
erDelaySmp[t] = kt::coerceIn(pattern[t * 2] * 0.001f * fs * erSizeScale, 1.f, erLine.maxDelay());
erGain[t] = pattern[t * 2 + 1];
}
}
float nextLfo(int i) {
uint32_t s = (uint32_t)lfoState[i];
s = s ^ (s << 13); s = s ^ (s >> 17); s = s ^ (s << 5);
lfoState[i] = (int32_t)s;
float n = (float)s * 2.3283064e-10f * 2.f - 1.f;
lfoSmooth[i] += (n - lfoSmooth[i]) * lfoCoeff[i];
return lfoSmooth[i];
}
public:
explicit AmbienceReverb(int sampleRate)
: fs((float)sampleRate),
preDelay(kt::toInt(fs * 0.55f)),
erLine(kt::toInt(fs * 0.6f)) {
diffusers.reserve(4);
for (int i = 0; i < 4; ++i) diffusers.emplace_back(kt::toInt(fs * 0.03f));
fdn.reserve(N);
apf.reserve(N);
for (int i = 0; i < N; ++i) fdn.emplace_back(kt::toInt(fs * 0.3f));
for (int i = 0; i < N; ++i) apf.emplace_back(kt::toInt(fs * 0.03f));
for (int it = 0; it < N; ++it) {
freqMod[it] = 0.5f + (1.f - (float)it / ((float)N - 1.f));
apfBase[it] = (2.3f + (float)it * 0.37f) * 0.001f * fs;
lfoState[it] = 12345 + it * 9876;
float a = (float)it * PHI;
lfoRateMul[it] = 0.8f + (a - floorf_(a)) * 0.4f;
}
for (int it = 0; it < 4; ++it) diffuserSmp[it] = (3.f + (float)it * 2.f) * 0.001f * fs;
}
void update(const Params &p, float) override {
const char *algoName = p.s("algo", "Room 1");
int algo = -1;
for (int k = 0; k < 7; ++k) if (std::strcmp(ALGORITHMS[k], algoName) == 0) { algo = k; break; }
algo = kt::coerceIn(algo, 0, 6);
float size = kt::coerceIn(p.f("roomsize", 1.f), 0.3f, 2.f);
float decay = kt::coerceIn(p.f("decay", 1.5f), 0.1f, 20.f);
float hf = kt::coerceIn(p.f("hfdamp", 0.f), 0.f, 1.f);
float lf = kt::coerceIn(p.f("lfabsorb", 0.f), 0.f, 1.f);
float diffusion = kt::coerceIn(p.f("diffusion", 0.7f), 0.f, 1.f);
wetLin = db2lin(p.f("wet", -4.f));
dryLin = db2lin(p.f("dry", 0.f));
preDelaySmp = kt::coerceIn(p.f("predelay", 10.f), 0.f, 500.f) * 0.001f * fs;
erLevel = kt::coerceIn(p.f("erlevel", 0.6f), 0.f, 1.f);
satAmt = kt::coerceIn(p.f("saturation", 0.f), 0.f, 1.f);
float modAmt = kt::coerceIn(p.f("modamt", 0.25f), 0.f, 1.f);
float modRate = kt::coerceIn(p.f("modrate", 0.5f), 0.05f, 2.f);
// Uses the modDepthScale from the previous recompute (as the Kotlin does).
modDepth = modAmt * modAmt * 0.001f * fs * modDepthScale;
for (int i = 0; i < N; ++i) {
lfoCoeff[i] = kt::coerceIn(1.f - kt::expf_(-TWO_PI * modRate * lfoRateMul[i] / fs), 0.0001f, 0.9999f);
}
duckAmtDb = kt::coerceIn(p.f("duckamt", 0.f), 0.f, 20.f);
duckThreshDb = p.f("duckthresh", -20.f);
duckThreshLin = db2lin(duckThreshDb);
duckAtt = 1.f - kt::expf_(-1.f / (fs * kt::coerceAtLeast(p.f("duckattack", 10.f), 0.1f) * 0.001f));
duckRel = 1.f - kt::expf_(-1.f / (fs * kt::coerceAtLeast(p.f("duckrelease", 200.f), 0.1f) * 0.001f));
float effDiff = diffusion * diffusionSens;
diffGain = 0.25f + effDiff * 0.55f;
effApfGain = apfGain * (0.6f + effDiff * 0.4f) * 0.78f;
if (algo != lastAlgo || size != lastSize || decay != lastDecay ||
hf != lastHf || lf != lastLf || diffusion != lastDiffusion) {
lastAlgo = algo; lastSize = size; lastDecay = decay;
lastHf = hf; lastLf = lf; lastDiffusion = diffusion;
recompute(algo, size, decay, hf, lf, diffusion);
float d2 = diffusion * diffusionSens;
diffGain = 0.25f + d2 * 0.55f;
effApfGain = apfGain * (0.6f + d2 * 0.4f) * 0.78f;
}
}
float process(float x) override {
preDelay.write(x);
float din = preDelaySmp > 0.5f ? preDelay.read(preDelaySmp) : x;
float peak = std::fabs(x);
duckEnv += (peak - duckEnv) * (peak > duckEnv ? duckAtt : duckRel);
float duckGain = 1.f;
if (duckAmtDb > 0.001f && duckEnv > duckThreshLin) {
float overDb = 20.f * kt::log10f_(std::max(duckEnv, 1e-6f)) - duckThreshDb;
duckGain = db2lin(-std::min(overDb, duckAmtDb));
}
float fdnIn = din;
for (int i = 0; i < 4; ++i) {
float d = diffusers[(size_t)i].read(diffuserSmp[i]);
float w = fdnIn + diffGain * d;
diffusers[(size_t)i].write(w);
fdnIn = d - diffGain * w;
}
float er = 0.f;
if (!bypassER) {
erLine.write(din);
for (int t = 0; t < erCount; ++t) er += erLine.read(erDelaySmp[t]) * erGain[t] * 0.5f;
fdnIn += er * 0.15f;
}
std::memcpy(fbScratch, fbVec, sizeof(fbScratch));
fwht(fbScratch);
for (int i = 0; i < N; ++i) fbScratch[i] *= SIGN_FLIP[i];
float inPerCh = fdnIn * 0.25f;
float out = 0.f;
for (int i = 0; i < N; ++i) {
float lfo = nextLfo(i);
DelayLine &line = fdn[(size_t)i];
float d = line.read(baseDelay[i] + lfo * modDepth * freqMod[i]);
d *= decayGain[i];
hfState[i] += hfCoeff * (d - hfState[i]); d = hfState[i];
lfState[i] += lfCoeff * (d - lfState[i]); d -= lfAmt * lfState[i];
DelayLine &ap = apf[(size_t)i];
float ad = ap.read(apfBase[i] + lfo * modDepth * 0.1f * freqMod[i]);
float aw = d + effApfGain * ad;
ap.write(aw);
float apfOut = ad - effApfGain * aw;
nextFb[i] = apfOut;
line.write(inPerCh + fbScratch[i]);
out += apfOut;
}
std::memcpy(fbVec, nextFb, sizeof(fbVec));
float late = out * LATE_SCALE * makeup;
float amt = kt::coerceIn(satAmt * satMul, 0.f, 1.f);
if (amt > 0.0001f) late += amt * (kt::tanhf_(late * 2.f) * 0.5f - late);
float wetRaw = (bypassER ? 0.f : er * erLevel) + late;
float dcOut = wetRaw - dc1 + 0.999f * dcY;
dc1 = wetRaw; dcY = dcOut;
float wet = softClip(dcOut * wetLin * duckGain);
return x * dryLin + wet;
}
};
} // namespace
std::unique_ptr<Effect> makeAmbienceReverb(int sampleRate) {
return std::make_unique<AmbienceReverb>(sampleRate);
}
} // namespace sizzle
+42
View File
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of Bitcrusher (Effects.kt): bit-depth reduction + sample-rate reduction + drive.
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
namespace sizzle {
namespace {
class Bitcrusher final : public Effect {
float levels = 256.f;
int downsample = 1;
float drive = 1.f;
int counter = 0;
float held = 0.f;
public:
void update(const Params &p, float) override {
float bits = kt::coerceIn(p.f("bits", 8.f), 1.f, 16.f);
levels = kt::powf_(2.f, bits);
downsample = kt::coerceAtLeast(kt::toInt(p.f("downsample", 1.f)), 1);
drive = 1.f + p.f("drive", 0.2f) * 4.f;
}
float process(float x) override {
if (counter <= 0) {
counter = downsample;
float driven = kt::tanhf_(x * drive);
held = (float)kt::roundToInt(driven * levels) / levels;
}
counter--;
return held;
}
};
} // namespace
std::unique_ptr<Effect> makeBitcrusher(int) { return std::make_unique<Bitcrusher>(); }
} // namespace sizzle
+111
View File
@@ -0,0 +1,111 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of BiquadFilterEffect (Effects.kt): RBJ LP/HP/BP biquad whose cutoff an
// input-level-gated ADSR opens, plus soft-saturation "warmth".
#include <algorithm>
#include <cmath>
#include <cstring>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
namespace sizzle {
namespace {
constexpr int CTRL_INTERVAL = 32;
constexpr float GATE_HI = 0.010f;
constexpr float GATE_LO = 0.004f;
class Filter final : public Effect {
double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0, z1 = 0, z2 = 0;
int sampleRate;
float sr;
enum Type { LPF, HPF, BPF } type = LPF;
float baseCutoff = 0.7f;
double q = 1.0;
float warmth = 0.f, envAmount = 0.f;
enum Phase { IDLE, ATTACK, DECAY, SUSTAIN, RELEASE } phase = IDLE;
float env = 0.f, attackInc = 1.f, decayInc = 1.f, sustainLevel = 1.f;
float releaseSeconds = 0.2f, releaseInc = 1.f, levelEnv = 0.f, levelCoeff = 0.f;
bool gateOpen = false;
int ctrl = 0;
void computeCoefficients(Type t, double freq, double qq) {
double w0 = 2.0 * M_PI * freq / sampleRate;
double cosW = std::cos(w0);
double alpha = std::sin(w0) / (2.0 * qq);
double a0;
switch (t) {
case HPF:
b0 = (1 + cosW) / 2; b1 = -(1 + cosW); b2 = (1 + cosW) / 2;
a0 = 1 + alpha; a1 = -2 * cosW; a2 = 1 - alpha; break;
case BPF:
b0 = alpha; b1 = 0.0; b2 = -alpha;
a0 = 1 + alpha; a1 = -2 * cosW; a2 = 1 - alpha; break;
default:
b0 = (1 - cosW) / 2; b1 = 1 - cosW; b2 = (1 - cosW) / 2;
a0 = 1 + alpha; a1 = -2 * cosW; a2 = 1 - alpha; break;
}
b0 /= a0; b1 /= a0; b2 /= a0; a1 /= a0; a2 /= a0;
}
public:
explicit Filter(int rate) : sampleRate(rate), sr((float)rate) {}
void update(const Params &p, float) override {
const char *t = p.s("type", "LPF");
type = std::strcmp(t, "HPF") == 0 ? HPF : std::strcmp(t, "BPF") == 0 ? BPF : LPF;
baseCutoff = kt::coerceIn(p.f("cutoff", 0.7f), 0.f, 1.f);
q = (double)(0.5 + p.f("resonance", 0.2f) * 8.f);
warmth = kt::coerceIn(p.f("warmth", 0.f), 0.f, 1.f);
envAmount = kt::coerceIn(p.f("envamt", 0.f), 0.f, 1.f);
sustainLevel = kt::coerceIn(p.f("sustain", 1.f), 0.f, 1.f);
attackInc = 1.f / (std::max(p.f("attack", 0.005f), 0.0005f) * sr);
float decay = p.f("decay", 0.10f);
decayInc = decay <= 0.f ? 1.f : (1.f - sustainLevel) / (decay * sr);
releaseSeconds = p.f("release", 0.20f);
levelCoeff = 1.f - kt::expf_(-1.f / (sr * 0.005f));
ctrl = 0;
}
float process(float x) override {
levelEnv += (std::fabs(x) - levelEnv) * levelCoeff;
if (!gateOpen && levelEnv > GATE_HI) {
gateOpen = true; phase = ATTACK;
} else if (gateOpen && levelEnv < GATE_LO) {
gateOpen = false;
releaseInc = releaseSeconds <= 0.f ? 1.f : env / (releaseSeconds * sr);
if (releaseInc <= 0.f) releaseInc = 1.f;
phase = RELEASE;
}
switch (phase) {
case ATTACK: env += attackInc; if (env >= 1.f) { env = 1.f; phase = DECAY; } break;
case DECAY: env -= decayInc; if (env <= sustainLevel) { env = sustainLevel; phase = SUSTAIN; } break;
case RELEASE: env -= releaseInc; if (env <= 0.f) { env = 0.f; phase = IDLE; } break;
default: break;
}
if (ctrl <= 0) {
ctrl = CTRL_INTERVAL;
float eff = kt::coerceIn(baseCutoff + envAmount * env * (1.f - baseCutoff), 0.f, 1.f);
double freq = 20.0 * std::pow(900.0, (double)eff);
computeCoefficients(type, kt::coerceIn(freq, 20.0, sampleRate * 0.45), q);
}
ctrl--;
double input = (double)x;
double out = b0 * input + z1;
z1 = b1 * input - a1 * out + z2;
z2 = b2 * input - a2 * out;
float y = (float)out;
if (warmth > 0.0001f) y += warmth * (kt::tanhf_(y * 1.8f) / 1.8f - y);
return y;
}
};
} // namespace
std::unique_ptr<Effect> makeFilter(int sr) { return std::make_unique<Filter>(sr); }
} // namespace sizzle
+91
View File
@@ -0,0 +1,91 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of GranularGlitch (Effects.kt), audio path only: a rolling 1 s buffer whose
// read head randomly jumps back to replay short (sometimes octave-shifted) grains,
// dry in between. The VizEffect scope/playhead is not ported (output-independent).
#include <cstdint>
#include <vector>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
namespace sizzle {
namespace {
constexpr float MAX_TRIGGER = 0.0009f;
constexpr float MIN_JUMP_S = 0.03f;
constexpr float MAX_JUMP_S = 0.5f;
constexpr float GRAIN_MIN_S = 0.02f;
constexpr float GRAIN_MAX_S = 0.15f;
class GranularGlitch final : public Effect {
int sampleRate;
std::vector<float> buf;
int size;
int writePos = 0;
double readPos = 0.0;
int grainLeft = 0;
double grainRate = 1.0;
float intensity = 0.f;
uint32_t rng = 0x2F6E1DB7u;
float nextUnit() {
uint32_t s = rng; s ^= s << 13; s ^= s >> 17; s ^= s << 5; rng = s;
return (float)s * 2.3283064e-10f; // 0 … 1
}
bool maybeStartGrain(int wp) {
if (nextUnit() > intensity * intensity * MAX_TRIGGER) return false;
float minJ = MIN_JUMP_S * (float)sampleRate;
float maxJ = (MIN_JUMP_S + intensity * (MAX_JUMP_S - MIN_JUMP_S)) * (float)sampleRate;
float jump = minJ + nextUnit() * (maxJ - minJ);
double rp = (double)wp - (double)jump;
while (rp < 0) rp += size;
readPos = rp;
float lenSec = GRAIN_MAX_S - intensity * (GRAIN_MAX_S - GRAIN_MIN_S);
grainLeft = kt::coerceAtLeast(kt::toInt(lenSec * (float)sampleRate * (0.5f + nextUnit())), 64);
if (nextUnit() < intensity * 0.3f) grainRate = 2.0;
else if (nextUnit() < intensity * 0.2f) grainRate = 0.5;
else grainRate = 1.0;
return true;
}
public:
explicit GranularGlitch(int rate) : sampleRate(rate), buf((size_t)rate, 0.f), size(rate) {}
void update(const Params &p, float) override {
intensity = kt::coerceIn(p.f("intensity", 0.3f), 0.f, 1.f);
}
float process(float x) override {
int wp = writePos;
buf[wp] = x;
writePos++; if (writePos >= size) writePos = 0;
float out;
if (grainLeft <= 0 && (intensity < 0.001f || !maybeStartGrain(wp))) {
readPos = (double)wp;
out = x;
} else {
int i0 = (int)readPos % size;
int i1 = (i0 + 1) % size;
float frac = (float)(readPos - (int)readPos);
out = buf[i0] + (buf[i1] - buf[i0]) * frac;
double rp = readPos + grainRate;
if (rp >= size) rp -= size;
if (rp < 0) rp += size;
double gap = wp - rp; if (gap < 0) gap += size;
if (gap < 2.0) { rp = wp - 2.0; if (rp < 0) rp += size; }
readPos = rp;
grainLeft--;
}
return out;
}
};
} // namespace
std::unique_ptr<Effect> makeGranularGlitch(int sr) { return std::make_unique<GranularGlitch>(sr); }
} // namespace sizzle
+67
View File
@@ -0,0 +1,67 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of GraphicEq (Effects.kt): ten peaking biquads at octave-spaced centres.
#include <cmath>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
namespace sizzle {
namespace {
struct PeakBiquad {
double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0, z1 = 0, z2 = 0;
void set(int sampleRate, float freq, float gainDb) {
if (freq >= sampleRate * 0.45f) return;
double a = std::pow(10.0, gainDb / 40.0);
double w0 = 2.0 * M_PI * freq / sampleRate;
double cosW = std::cos(w0);
double alpha = std::sin(w0) / (2.0 * 1.0);
double a0 = 1 + alpha / a;
b0 = (1 + alpha * a) / a0;
b1 = (-2 * cosW) / a0;
b2 = (1 - alpha * a) / a0;
a1 = (-2 * cosW) / a0;
a2 = (1 - alpha / a) / a0;
}
float process(float x) {
double input = (double)x;
double out = b0 * input + z1;
z1 = b1 * input - a1 * out + z2;
z2 = b2 * input - a2 * out;
return (float)out;
}
};
class GraphicEq final : public Effect {
static constexpr float centers[10] = {31.f, 63.f, 125.f, 250.f, 500.f, 1000.f, 2000.f, 4000.f, 8000.f, 16000.f};
static constexpr const char *keys[10] = {"band0", "band1", "band2", "band3", "band4",
"band5", "band6", "band7", "band8", "band9"};
PeakBiquad bands[10];
int sampleRate;
public:
explicit GraphicEq(int sr) : sampleRate(sr) {}
void update(const Params &p, float) override {
for (int i = 0; i < 10; ++i) {
float gainDb = kt::coerceIn(p.f(keys[i], 0.f), -1.f, 1.f) * 12.f;
bands[i].set(sampleRate, centers[i], gainDb);
}
}
float process(float x) override {
float y = x;
for (auto &b : bands) y = b.process(y);
return y;
}
};
} // namespace
std::unique_ptr<Effect> makeGraphicEq(int sr) { return std::make_unique<GraphicEq>(sr); }
} // namespace sizzle
+34
View File
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
// Kotlin/JVM math semantics, so ports read like the Kotlin and match its output.
// kotlin.math on Float goes through Java's double Math and rounds back to float.
#include <cmath>
namespace sizzle::kt {
inline float tanhf_(float x) { return (float)std::tanh((double)x); }
inline float expf_(float x) { return (float)std::exp((double)x); }
inline float sinf_(float x) { return (float)std::sin((double)x); }
inline float cosf_(float x) { return (float)std::cos((double)x); }
inline float powf_(float a, float b) { return (float)std::pow((double)a, (double)b); }
inline float sqrtf_(float x) { return (float)std::sqrt((double)x); }
inline float log10f_(float x) { return (float)std::log10((double)x); }
/** Float.roundToInt(): Math.round, i.e. floor(x + 0.5). */
inline int roundToInt(float x) { return (int)std::floor((double)x + 0.5); }
inline int roundToInt(double x) { return (int)std::floor(x + 0.5); }
/** Float.toInt(): truncation toward zero, NaN → 0, saturating. */
inline int toInt(float x) {
if (std::isnan(x)) return 0;
if (x >= 2147483647.f) return 2147483647;
if (x <= -2147483648.f) return (-2147483647 - 1);
return (int)x;
}
template <class T> inline T coerceIn(T v, T lo, T hi) { return v < lo ? lo : (v > hi ? hi : v); }
template <class T> inline T coerceAtLeast(T v, T lo) { return v < lo ? lo : v; }
template <class T> inline T coerceAtMost(T v, T hi) { return v > hi ? hi : v; }
} // namespace sizzle::kt
+190
View File
@@ -0,0 +1,190 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of MixTightener (Effects.kt): parametric EQ -> 3-band multiband compressor ->
// peak limiter, morphed by one Strength control; per-band values are hidden params
// set by presets. Includes the private Bq biquad (TDF-II, double state).
#include <cmath>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
namespace sizzle {
namespace {
class Bq {
double b0 = 1.0, b1 = 0.0, b2 = 0.0;
double a1 = 0.0, a2 = 0.0;
double z1 = 0.0, z2 = 0.0;
void setRaw(double nb0, double nb1, double nb2, double a0, double na1, double na2) {
b0 = nb0 / a0; b1 = nb1 / a0; b2 = nb2 / a0; a1 = na1 / a0; a2 = na2 / a0;
}
public:
void identity() { b0 = 1.0; b1 = 0.0; b2 = 0.0; a1 = 0.0; a2 = 0.0; }
void peak(int sr, float freq, float gainDb, float q) {
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
double a = std::pow(10.0, gainDb / 40.0);
double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0);
double alpha = std::sin(w0) / (2.0 * kt::coerceAtLeast(q, 0.1f));
setRaw(1 + alpha * a, -2 * cw, 1 - alpha * a, 1 + alpha / a, -2 * cw, 1 - alpha / a);
}
void lowShelf(int sr, float freq, float gainDb) {
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
double a = std::pow(10.0, gainDb / 40.0); double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0);
double alpha = std::sin(w0) / 2.0 * std::sqrt(2.0); double ta = 2.0 * std::sqrt(a) * alpha;
setRaw(
a * ((a + 1) - (a - 1) * cw + ta), 2 * a * ((a - 1) - (a + 1) * cw),
a * ((a + 1) - (a - 1) * cw - ta), (a + 1) + (a - 1) * cw + ta,
-2 * ((a - 1) + (a + 1) * cw), (a + 1) + (a - 1) * cw - ta);
}
void highShelf(int sr, float freq, float gainDb) {
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
double a = std::pow(10.0, gainDb / 40.0); double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0);
double alpha = std::sin(w0) / 2.0 * std::sqrt(2.0); double ta = 2.0 * std::sqrt(a) * alpha;
setRaw(
a * ((a + 1) + (a - 1) * cw + ta), -2 * a * ((a - 1) + (a + 1) * cw),
a * ((a + 1) + (a - 1) * cw - ta), (a + 1) - (a - 1) * cw + ta,
2 * ((a - 1) - (a + 1) * cw), (a + 1) - (a - 1) * cw - ta);
}
void lowPass(int sr, float freq, float q) {
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0); double alpha = std::sin(w0) / (2.0 * q);
setRaw((1 - cw) / 2, 1 - cw, (1 - cw) / 2, 1 + alpha, -2 * cw, 1 - alpha);
}
void highPass(int sr, float freq, float q) {
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0); double alpha = std::sin(w0) / (2.0 * q);
setRaw((1 + cw) / 2, -(1 + cw), (1 + cw) / 2, 1 + alpha, -2 * cw, 1 - alpha);
}
void reset() { z1 = 0.0; z2 = 0.0; }
float process(float x) {
double inp = (double)x;
double out = b0 * inp + z1;
z1 = b1 * inp - a1 * out + z2;
z2 = b2 * inp - a2 * out;
if (!std::isfinite(out)) { z1 = 0.0; z2 = 0.0; out = 0.0; }
return (float)out;
}
};
constexpr int CTRL = 16; // samples between (expensive) gain recomputes
constexpr float GAIN_SMOOTH = 0.05f; // per-sample gain ramp toward the control-rate target
class MixTightener final : public Effect {
int sampleRate;
Bq eqLo, eqMid, eqHi;
bool eqActive = false;
Bq xLoLP, xLoHP, xHiLP, xHiHP;
bool compActive = false;
float env[3] = {0.f, 0.f, 0.f};
float gain[3] = {1.f, 1.f, 1.f};
float target[3] = {1.f, 1.f, 1.f};
float atkCoef[3] = {}, relCoef[3] = {};
float thrDb[3] = {}, ratio[3] = {}, makeDb[3] = {};
int ctrl = 0;
float limCeil = 1.f, limRelCoef = 0.f, limEnv = 0.f;
float outGain = 1.f;
float strength = 1.f;
float compScale = 1.f;
static float dbToLin(float db) { return (float)std::pow(10.0, db / 20.0); }
float coefFromMs(float ms) const {
float t = kt::coerceAtLeast(ms, 0.1f) * 0.001f * sampleRate;
return (float)(1.0 - std::exp(-1.0 / t));
}
float compBand(int i, float band) {
float r = std::fabs(band);
float e = env[i];
env[i] = r > e ? e + atkCoef[i] * (r - e) : e + relCoef[i] * (r - e);
gain[i] += GAIN_SMOOTH * (target[i] - gain[i]);
return band * gain[i];
}
public:
explicit MixTightener(int rate) : sampleRate(rate) {}
void update(const Params &p, float) override {
strength = kt::coerceIn(p.f("strength", 1.f), 0.f, 1.f);
float eqS = strength * kt::coerceIn(p.f("eqAmt", 1.f), 0.f, 1.f);
float compAmt = kt::coerceIn(p.f("compAmt", 1.f), 0.f, 1.f);
compScale = strength * compAmt;
float limS = strength * kt::coerceIn(p.f("limAmt", 1.f), 0.f, 1.f);
float loG = kt::coerceIn(p.f("eqLoGain", 0.f), -18.f, 18.f) * eqS;
float midG = kt::coerceIn(p.f("eqMidGain", 0.f), -18.f, 18.f) * eqS;
float hiG = kt::coerceIn(p.f("eqHiGain", 0.f), -18.f, 18.f) * eqS;
if (std::fabs(loG) > 0.1f) eqLo.lowShelf(sampleRate, p.f("eqLoFreq", 120.f), loG); else eqLo.identity();
if (std::fabs(midG) > 0.1f) eqMid.peak(sampleRate, p.f("eqMidFreq", 1000.f), midG,
kt::coerceIn(p.f("eqMidQ", 1.0f), 0.2f, 8.f)); else eqMid.identity();
if (std::fabs(hiG) > 0.1f) eqHi.highShelf(sampleRate, p.f("eqHiFreq", 8000.f), hiG); else eqHi.identity();
eqActive = std::fabs(loG) > 0.1f || std::fabs(midG) > 0.1f || std::fabs(hiG) > 0.1f;
float xl = kt::coerceIn(p.f("xLo", 200.f), 40.f, sampleRate * 0.4f);
float xh = kt::coerceIn(p.f("xHi", 2500.f), xl + 50.f, sampleRate * 0.45f);
xLoLP.lowPass(sampleRate, xl, 0.5f); xLoHP.highPass(sampleRate, xl, 0.5f);
xHiLP.lowPass(sampleRate, xh, 0.5f); xHiHP.highPass(sampleRate, xh, 0.5f);
thrDb[0] = p.f("cLoThr", -24.f); ratio[0] = kt::coerceIn(p.f("cLoRatio", 2.f), 1.f, 20.f);
makeDb[0] = p.f("cLoMk", 0.f); atkCoef[0] = coefFromMs(p.f("cLoAtk", 10.f)); relCoef[0] = coefFromMs(p.f("cLoRel", 120.f));
thrDb[1] = p.f("cMidThr", -22.f); ratio[1] = kt::coerceIn(p.f("cMidRatio", 2.f), 1.f, 20.f);
makeDb[1] = p.f("cMidMk", 0.f); atkCoef[1] = coefFromMs(p.f("cMidAtk", 15.f)); relCoef[1] = coefFromMs(p.f("cMidRel", 140.f));
thrDb[2] = p.f("cHiThr", -24.f); ratio[2] = kt::coerceIn(p.f("cHiRatio", 2.f), 1.f, 20.f);
makeDb[2] = p.f("cHiMk", 0.f); atkCoef[2] = coefFromMs(p.f("cHiAtk", 5.f)); relCoef[2] = coefFromMs(p.f("cHiRel", 90.f));
bool anyRatio = false, anyMake = false;
for (int i = 0; i < 3; i++) {
if (ratio[i] > 1.01f) anyRatio = true;
if (std::fabs(makeDb[i]) > 0.1f) anyMake = true;
}
compActive = compAmt > 0.001f && (anyRatio || anyMake);
limCeil = 1.f + (dbToLin(kt::coerceIn(p.f("limCeil", -0.5f), -24.f, 0.f)) - 1.f) * limS;
limRelCoef = coefFromMs(p.f("limRel", 100.f));
outGain = 1.f + (dbToLin(kt::coerceIn(p.f("outGain", 0.f), -12.f, 18.f)) - 1.f) * limS;
}
float process(float x) override {
if (strength < 0.001f) return x;
float s = x;
if (eqActive) { s = eqLo.process(s); s = eqMid.process(s); s = eqHi.process(s); }
if (compActive) {
float low = xLoLP.process(s);
float hp = xLoHP.process(s);
float mid = xHiLP.process(hp);
float high = xHiHP.process(hp);
if (ctrl <= 0) {
ctrl = CTRL;
for (int i = 0; i < 3; i++) {
float envDb = 20.f * kt::log10f_(env[i] + 1e-9f);
float over = envDb - thrDb[i];
float grDb = over > 0.f ? -over * (1.f - 1.f / ratio[i]) : 0.f;
target[i] = dbToLin(kt::coerceIn((grDb + makeDb[i]) * compScale, -40.f, 24.f));
}
}
ctrl--;
s = compBand(0, low) + compBand(1, mid) + compBand(2, high);
}
float r = std::fabs(s);
limEnv = r > limEnv ? r : limEnv + limRelCoef * (r - limEnv);
if (limEnv > limCeil && limEnv > 1e-6f) s *= limCeil / limEnv;
s *= outGain;
return s > 1.f ? 1.f : s < -1.f ? -1.f : !std::isfinite(s) ? 0.f : s;
}
};
} // namespace
std::unique_ptr<Effect> makeMixTightener(int sampleRate) { return std::make_unique<MixTightener>(sampleRate); }
} // namespace sizzle
+39
View File
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Effect::create. Each effect lives in src/fx/<Name>.cpp and defines its maker
// below. The defaults here are weak definitions returning nullptr; a port's own
// (strong) definition replaces its default at link time, so a build without some
// of those files still links (lets ports land one by one).
#include <cstring>
#include "sizzle/Effect.hpp"
#define SIZZLE_MAKER(fn) \
__attribute__((weak)) std::unique_ptr<Effect> fn(int) { return nullptr; }
namespace sizzle {
SIZZLE_MAKER(makeBitcrusher);
SIZZLE_MAKER(makeFilter);
SIZZLE_MAKER(makeGraphicEq);
SIZZLE_MAKER(makeTapeDelay);
SIZZLE_MAKER(makeMixTightener);
SIZZLE_MAKER(makeTapeEngine);
SIZZLE_MAKER(makeGranularGlitch);
SIZZLE_MAKER(makeAmbienceReverb);
std::unique_ptr<Effect> Effect::create(const char *type, int sr) {
struct Entry { const char *type; std::unique_ptr<Effect> (*make)(int); };
const Entry table[] = {
{"BITCRUSHER", makeBitcrusher}, {"FILTER", makeFilter},
{"EQ10", makeGraphicEq}, {"DELAY", makeTapeDelay},
{"MIX_TIGHTENER", makeMixTightener}, {"TAPE_ENGINE", makeTapeEngine},
{"GRANULAR", makeGranularGlitch}, {"AMBIENCE", makeAmbienceReverb},
};
for (const auto &e : table)
if (std::strcmp(type, e.type) == 0) return e.make(sr);
return nullptr;
}
} // namespace sizzle
+122
View File
@@ -0,0 +1,122 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of TapeDelay (Effects.kt): one shared delay line read by up to four
// tempo-synced tape heads (averaged), with saturation, a darkening one-pole LP
// in the feedback path and sine wow/flutter, all scaled by "tape".
#include <cmath>
#include <vector>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
// The JVM never fuses a*b+c; keep clang from contracting into FMAs.
#if defined(__clang__)
#pragma STDC FP_CONTRACT OFF
#endif
namespace sizzle {
namespace {
// DelayDivisions (model/Toolbox.kt).
constexpr int HEADS = 4;
constexpr float MAX_FEEDBACK = 0.9f;
constexpr double BEAT_FRACTIONS[] = {
4.0, // 1/1
3.0, // 1/2.
2.0, // 1/2
1.5, // 1/4.
4.0 / 3.0, // 1/2T
1.0, // 1/4
0.75, // 1/8.
2.0 / 3.0, // 1/4T
0.5, // 1/8
0.375, // 1/16.
1.0 / 3.0, // 1/8T
0.25, // 1/16
1.0 / 6.0, // 1/16T
};
constexpr int DIV_COUNT = (int)(sizeof(BEAT_FRACTIONS) / sizeof(BEAT_FRACTIONS[0]));
constexpr int DIV_DEFAULT = 5; // indexOf("1/4")
inline double beatFraction(int i) { return BEAT_FRACTIONS[kt::coerceIn(i, 0, DIV_COUNT - 1)]; }
constexpr double FLUTTER_HZ = 5.0;
const char *const HEAD_ON_KEYS[HEADS] = {"head0On", "head1On", "head2On", "head3On"};
const char *const HEAD_DIV_KEYS[HEADS] = {"head0Div", "head1Div", "head2Div", "head3Div"};
class TapeDelay final : public Effect {
int sampleRate;
std::vector<float> buffer; // up to 4 s of delay line
int bufferSize;
int writeIndex = 0;
int delaySamples[HEADS];
bool headOn[HEADS] = {};
float feedback = 0.4f;
float dryWet = 0.35f;
float satBlend = 0.f;
float lpAlpha = 1.f;
float lpState = 0.f;
double flutterInc = 0.0;
float flutterDepth = 0.f;
double flutterPhase = 0.0;
public:
explicit TapeDelay(int rate)
: sampleRate(rate), buffer((size_t)rate * 4, 0.f), bufferSize(rate * 4) {
for (int h = 0; h < HEADS; h++) delaySamples[h] = rate / 2;
}
void update(const Params &p, float tempoBpm) override {
double samplesPerBeat = (60.0 / (double)tempoBpm) * sampleRate;
for (int h = 0; h < HEADS; h++) {
headOn[h] = p.f(HEAD_ON_KEYS[h], h == 0 ? 1.f : 0.f) >= 0.5f;
int idx = kt::toInt(p.f(HEAD_DIV_KEYS[h], (float)DIV_DEFAULT));
// Double.toInt(): truncation (values here are small and positive).
double d = beatFraction(idx) * samplesPerBeat;
int ds = std::isnan(d) ? 0 : d >= 2147483647.0 ? 2147483647 : (int)d;
delaySamples[h] = kt::coerceIn(ds, 1, bufferSize - 2);
}
feedback = kt::coerceIn(p.f("feedback", 0.4f), 0.f, MAX_FEEDBACK);
dryWet = kt::coerceIn(p.f("drywet", 0.35f), 0.f, 1.f);
float tape = kt::coerceIn(p.f("tape", 0.3f), 0.f, 1.f);
satBlend = tape;
lpAlpha = 1.f - tape * 0.85f;
flutterInc = 2.0 * M_PI * FLUTTER_HZ / sampleRate;
flutterDepth = tape * (float)sampleRate * 0.0015f;
}
float process(float x) override {
flutterPhase += flutterInc;
if (flutterPhase > 2 * M_PI) flutterPhase -= 2 * M_PI;
float flutter = (float)std::sin(flutterPhase) * flutterDepth;
float wet = 0.f;
int active = 0;
for (int h = 0; h < HEADS; h++) {
if (!headOn[h]) continue;
active++;
float pos = (float)(writeIndex - delaySamples[h]) - flutter;
while (pos < 0.f) pos += (float)bufferSize;
int i0 = kt::toInt(pos) % bufferSize;
int i1 = (i0 + 1) % bufferSize;
float frac = pos - (float)kt::toInt(pos);
wet += buffer[i0] + (buffer[i1] - buffer[i0]) * frac;
}
if (active > 0) wet /= (float)active;
float fb = wet * feedback;
fb += satBlend * (kt::tanhf_(fb) - fb);
lpState += lpAlpha * (fb - lpState);
fb = lpState;
buffer[writeIndex] = x + fb;
writeIndex = (writeIndex + 1) % bufferSize;
return x * (1.f - dryWet) + wet * dryWet;
}
};
} // namespace
std::unique_ptr<Effect> makeTapeDelay(int sampleRate) { return std::make_unique<TapeDelay>(sampleRate); }
} // namespace sizzle
+102
View File
@@ -0,0 +1,102 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Port of TapeEngine (Effects.kt): a varispeed reel-to-reel. Input is written into
// a ring at rate 1 and read back at a gliding `speed`, with wow/flutter wobble and
// xorshift hiss.
#include <cmath>
#include <cstdint>
#include <vector>
#include "sizzle/Effect.hpp"
#include "KotlinMath.hpp"
namespace sizzle {
namespace {
constexpr int NOMINAL_DELAY = 128;
constexpr float MIN_SPEED = 0.25f;
constexpr float MAX_WOW = 0.03f;
constexpr float MAX_FLUT = 0.008f;
constexpr float MAX_HISS = 0.02f;
constexpr double FLUTTER_HZ = 11.0;
constexpr float SPEED_GLIDE = 0.00012f;
constexpr double MIN_GAP = 2.0;
/** TimeDivision.beatFraction by index, with fromIndex's clamping. */
double beatFraction(int i) {
static constexpr double kFrac[] = {4.0, 2.0, 1.0, 0.5, 0.25, 0.125, 0.75};
return kFrac[kt::coerceIn(i, 0, 6)];
}
class TapeEngine final : public Effect {
int sampleRate;
std::vector<float> buf;
int size;
int writePos = NOMINAL_DELAY;
double readPos = 0.0;
double targetSpeed = 1.0;
double curSpeed = 1.0;
double wowInc = 0.0, wowPhase = 0.0; float wowDepth = 0.f;
double flutInc, flutPhase = 0.0; float flutDepth = 0.f;
float hiss = 0.f;
uint32_t rng = 0x51ED2A19u;
float nextRand() {
uint32_t s = rng; s ^= s << 13; s ^= s >> 17; s ^= s << 5; rng = s;
return (float)(int32_t)s * 4.656613e-10f; // -1 … 1
}
public:
explicit TapeEngine(int rate)
: sampleRate(rate), buf((size_t)rate * 2, 0.f), size(rate * 2),
flutInc(FLUTTER_HZ / rate) {}
void update(const Params &p, float tempoBpm) override {
targetSpeed = (double)kt::coerceIn(p.f("speed", 1.f), MIN_SPEED, 1.f);
wowDepth = kt::coerceIn(p.f("wow", 0.15f), 0.f, 1.f) * MAX_WOW;
flutDepth = kt::coerceIn(p.f("flutter", 0.15f), 0.f, 1.f) * MAX_FLUT;
hiss = kt::coerceIn(p.f("hiss", 0.10f), 0.f, 1.f) * MAX_HISS;
double secPerBeat = 60.0 / (double)tempoBpm;
double frac = beatFraction(kt::toInt(p.f("division", 2.f)));
double wowHz = 1.0 / kt::coerceAtLeast(frac * secPerBeat, 1e-4);
wowInc = wowHz / sampleRate;
flutInc = FLUTTER_HZ / sampleRate;
}
float process(float x) override {
buf[writePos] = x;
writePos++; if (writePos >= size) writePos = 0;
curSpeed += (targetSpeed - curSpeed) * (double)SPEED_GLIDE; // tape inertia
wowPhase += wowInc; if (wowPhase >= 1.0) wowPhase -= 1.0;
flutPhase += flutInc; if (flutPhase >= 1.0) flutPhase -= 1.0;
double wow = std::sin(2.0 * M_PI * wowPhase) * (double)wowDepth;
double flut = std::sin(2.0 * M_PI * flutPhase) * (double)flutDepth;
double rate = curSpeed * (1.0 + wow + flut);
if (rate < 0.01) rate = 0.01;
int i0 = (int)readPos % size;
int i1 = (i0 + 1) % size;
float frac = (float)(readPos - (int)readPos);
float out = buf[i0] + (buf[i1] - buf[i0]) * frac;
double rp = readPos + rate;
if (rp >= size) rp -= size;
double gap = writePos - rp; if (gap < 0) gap += size;
double maxGap = size - 2.0;
if (gap < MIN_GAP) { rp = writePos - MIN_GAP; if (rp < 0) rp += size; }
else if (gap > maxGap) { rp = writePos - maxGap; if (rp < 0) rp += size; }
readPos = rp;
if (hiss > 0.f) out += nextRand() * hiss;
return out;
}
};
} // namespace
std::unique_ptr<Effect> makeTapeEngine(int sr) { return std::make_unique<TapeEngine>(sr); }
} // namespace sizzle
+87
View File
@@ -0,0 +1,87 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Renders every reference scenario exported by IosGoldenExport (Kotlin) through the
// C++ core and compares sample by sample.
//
// golden_test <golden dir> [TYPE ...]
//
// A scenario passes when the largest difference is below 1e-4 (float rounding and
// libm vs Java Math differ by an ulp here and there). Types with no C++ port yet are
// listed as SKIP. Exit status is non-zero if any scenario fails.
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <dirent.h>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "sizzle/Effect.hpp"
using namespace sizzle;
static std::vector<float> readF32(const std::string &path) {
std::ifstream f(path, std::ios::binary);
std::vector<char> bytes((std::istreambuf_iterator<char>(f)), {});
std::vector<float> out(bytes.size() / 4);
std::memcpy(out.data(), bytes.data(), out.size() * 4);
return out;
}
int main(int argc, char **argv) {
if (argc < 2) { std::fprintf(stderr, "usage: %s <golden dir> [TYPE ...]\n", argv[0]); return 2; }
std::string dir = argv[1];
std::vector<std::string> only(argv + 2, argv + argc);
std::vector<float> input = readF32(dir + "/input.f32");
if (input.empty()) { std::fprintf(stderr, "no input.f32 in %s (run make -C ios golden)\n", dir.c_str()); return 2; }
std::vector<std::string> scns;
if (DIR *d = opendir(dir.c_str())) {
while (dirent *e = readdir(d)) {
std::string n = e->d_name;
if (n.size() > 4 && n.compare(n.size() - 4, 4, ".scn") == 0) scns.push_back(n.substr(0, n.size() - 4));
}
closedir(d);
}
std::sort(scns.begin(), scns.end());
int pass = 0, fail = 0, skip = 0;
for (const auto &base : scns) {
std::ifstream f(dir + "/" + base + ".scn");
std::string line, type;
int sr = 48000;
float tempo = 120.f;
Params p;
while (std::getline(f, line)) {
std::istringstream ls(line);
std::string tag; ls >> tag;
if (tag == "type") ls >> type;
else if (tag == "sr") ls >> sr;
else if (tag == "tempo") ls >> tempo;
else if (tag == "p") {
std::string key, val; ls >> key; std::getline(ls, val);
if (!val.empty() && val[0] == ' ') val.erase(0, 1);
p.set(key.c_str(), val.c_str());
}
}
if (!only.empty() && std::find(only.begin(), only.end(), type) == only.end()) continue;
auto fx = Effect::create(type.c_str(), sr);
if (!fx) { std::printf("SKIP %-36s (not ported)\n", base.c_str()); ++skip; continue; }
std::vector<float> want = readF32(dir + "/" + base + ".f32");
fx->update(p, tempo);
double maxErr = 0; size_t at = 0;
for (size_t i = 0; i < input.size() && i < want.size(); ++i) {
float y = fx->process(input[i]);
double e = std::fabs((double)y - (double)want[i]);
if (!(e <= maxErr)) { maxErr = e; at = i; } // NaN counts as worst
}
bool ok = maxErr < 1e-4 && want.size() == input.size();
std::printf("%s %-36s max diff %.3g at sample %zu\n", ok ? "PASS" : "FAIL", base.c_str(), maxErr, at);
ok ? ++pass : ++fail;
}
std::printf("\n%d passed, %d failed, %d not ported\n", pass, fail, skip);
return fail ? 1 : 0;
}
+82
View File
@@ -0,0 +1,82 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
# SPDX-License-Identifier: GPL-3.0-or-later
"""Generate the FX extension's Info.plist and Components.gen.h from components.txt.
usage: gen_components.py <components.txt> <Info.plist out> <Components.gen.h out>
"""
import sys
from xml.sax.saxutils import escape
TAGS = {"aufx": "Effects", "aumu": "Synthesizer", "aumi": "MIDI", "aumf": "Effects"}
def main(src, plist_out, header_out):
rows = []
for line in open(src):
line = line.split("#", 1)[0].strip()
if not line:
continue
t, sub, toolbox, name = line.split(None, 3)
assert len(t) == 4 and len(sub) == 4, line
rows.append((t, sub, toolbox, name))
comps = []
for t, sub, _, name in rows:
comps.append(f""" <dict>
<key>description</key><string>Sizzle {escape(name)}</string>
<key>factoryFunction</key><string>SizzleFXViewController</string>
<key>manufacturer</key><string>Tsys</string>
<key>name</key><string>Tired Sysadmin: Sizzle {escape(name)}</string>
<key>sandboxSafe</key><true/>
<key>subtype</key><string>{sub}</string>
<key>tags</key><array><string>{TAGS[t]}</string></array>
<key>type</key><string>{t}</string>
<key>version</key><integer>65536</integer>
</dict>""")
plist = f"""<?xml version="1.0" encoding="UTF-8"?>
<!-- GENERATED from components.txt by tools/gen_components.py. Do not edit. -->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key><string>en</string>
<key>CFBundleDisplayName</key><string>Sizzle FX</string>
<key>CFBundleExecutable</key><string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>CFBundleName</key><string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key><string>XPC!</string>
<key>CFBundleShortVersionString</key><string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key><string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>AudioComponents</key>
<array>
{chr(10).join(comps)}
</array>
</dict>
<key>NSExtensionPointIdentifier</key><string>com.apple.AudioUnit-UI</string>
<key>NSExtensionPrincipalClass</key><string>SizzleFXViewController</string>
</dict>
</dict>
</plist>
"""
open(plist_out, "w").write(plist)
entries = ",\n".join(f' {{\'{sub}\', "{toolbox}", "{name}"}}' for _, sub, toolbox, name in rows)
header = f"""// GENERATED from components.txt by tools/gen_components.py. Do not edit.
#pragma once
#include <AudioToolbox/AudioToolbox.h>
typedef struct {{ OSType subtype; const char *toolboxType; const char *name; }} SizzleComponent;
static const SizzleComponent kSizzleComponents[] = {{
{entries}
}};
static const int kSizzleComponentCount = {len(rows)};
"""
open(header_out, "w").write(header)
if __name__ == "__main__":
main(*sys.argv[1:4])
+5 -3
View File
@@ -14,9 +14,11 @@ android.versionCode = 70
# No desktop builds exist yet. These lines are the agreed slots so a port starts # No desktop builds exist yet. These lines are the agreed slots so a port starts
# with a version instead of inventing one; `-` means "not built on this # with a version instead of inventing one; `-` means "not built on this
# platform". Namespace for every platform: cc.tiredsysadmin.<os>.sizzle. # platform". Namespace for every platform: cc.tiredsysadmin.<os>.sizzle.
# iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): only the AUv3 spike exists so far; # iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): the AUv3 plugin app in ios/app; the
# its version is in ios/spike/project.yml (0.1.0, build 1). See ios/README.md. # Makefile there passes these to Xcode and names the .ipa by versionCode. (The
ios.versionName = - # TrollStore spike in ios/spike keeps its own version in its project.yml.)
ios.versionName = 0.1.0
ios.versionCode = 1
macos.versionName = - macos.versionName = -
linux.versionName = - linux.versionName = -
bsd.versionName = - bsd.versionName = -