From dcf85ba91500c43b69b7f76131069b5721822087 Mon Sep 17 00:00:00 2001 From: Reactorcoremeltdown Date: Sat, 14 Nov 2026 20:47:06 +0100 Subject: [PATCH] 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 --- .../android/sizzle/audio/IosGoldenExport.kt | 148 +++++++ docs/DEVELOPER_HANDOVER.md | 17 +- ios/.gitignore | 1 + ios/CHANGELOG.md | 16 + ios/Makefile | 144 +++++-- ios/README.md | 218 ++++++---- ios/app/FX/Components.gen.h | 17 + ios/app/FX/FX.entitlements | 10 + ios/app/FX/Info.plist | 115 +++++ ios/app/FX/SizzleEffectAU.h | 26 ++ ios/app/FX/SizzleEffectAU.mm | 405 ++++++++++++++++++ ios/app/FX/SizzleFXViewController.mm | 201 +++++++++ .../AppIcon.appiconset/Contents.json | 6 + .../AppIcon.appiconset/icon-1024.png | Bin 0 -> 48476 bytes ios/app/Host/Assets.xcassets/Contents.json | 1 + ios/app/Host/Bridging.h | 1 + ios/app/Host/ContentView.swift | 37 ++ ios/app/Host/Host.entitlements | 10 + ios/app/Host/ObjC/SPKTry.h | 13 + ios/app/Host/ObjC/SPKTry.m | 13 + ios/app/Host/PluginCheck.swift | 96 +++++ ios/app/Host/SizzleApp.swift | 9 + ios/app/components.txt | 14 + ios/app/project.yml | 66 +++ ios/app/tests/au_test.mm | 159 +++++++ ios/core/include/sizzle/DeviceSpecs.gen.hpp | 364 ++++++++++++++++ ios/core/include/sizzle/Effect.hpp | 27 ++ ios/core/include/sizzle/Params.hpp | 45 ++ ios/core/include/sizzle/Specs.hpp | 35 ++ ios/core/src/Params.cpp | 65 +++ ios/core/src/Specs.cpp | 14 + ios/core/src/fx/AmbienceReverb.cpp | 401 +++++++++++++++++ ios/core/src/fx/Bitcrusher.cpp | 42 ++ ios/core/src/fx/Filter.cpp | 111 +++++ ios/core/src/fx/GranularGlitch.cpp | 91 ++++ ios/core/src/fx/GraphicEq.cpp | 67 +++ ios/core/src/fx/KotlinMath.hpp | 34 ++ ios/core/src/fx/MixTightener.cpp | 190 ++++++++ ios/core/src/fx/Registry.cpp | 39 ++ ios/core/src/fx/TapeDelay.cpp | 122 ++++++ ios/core/src/fx/TapeEngine.cpp | 102 +++++ ios/core/tests/golden_test.cpp | 87 ++++ ios/tools/gen_components.py | 82 ++++ versions.properties | 8 +- 44 files changed, 3542 insertions(+), 127 deletions(-) create mode 100644 app/src/test/java/cc/tiredsysadmin/android/sizzle/audio/IosGoldenExport.kt create mode 100644 ios/CHANGELOG.md create mode 100644 ios/app/FX/Components.gen.h create mode 100644 ios/app/FX/FX.entitlements create mode 100644 ios/app/FX/Info.plist create mode 100644 ios/app/FX/SizzleEffectAU.h create mode 100644 ios/app/FX/SizzleEffectAU.mm create mode 100644 ios/app/FX/SizzleFXViewController.mm create mode 100644 ios/app/Host/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 ios/app/Host/Assets.xcassets/AppIcon.appiconset/icon-1024.png create mode 100644 ios/app/Host/Assets.xcassets/Contents.json create mode 100644 ios/app/Host/Bridging.h create mode 100644 ios/app/Host/ContentView.swift create mode 100644 ios/app/Host/Host.entitlements create mode 100644 ios/app/Host/ObjC/SPKTry.h create mode 100644 ios/app/Host/ObjC/SPKTry.m create mode 100644 ios/app/Host/PluginCheck.swift create mode 100644 ios/app/Host/SizzleApp.swift create mode 100644 ios/app/components.txt create mode 100644 ios/app/project.yml create mode 100644 ios/app/tests/au_test.mm create mode 100644 ios/core/include/sizzle/DeviceSpecs.gen.hpp create mode 100644 ios/core/include/sizzle/Effect.hpp create mode 100644 ios/core/include/sizzle/Params.hpp create mode 100644 ios/core/include/sizzle/Specs.hpp create mode 100644 ios/core/src/Params.cpp create mode 100644 ios/core/src/Specs.cpp create mode 100644 ios/core/src/fx/AmbienceReverb.cpp create mode 100644 ios/core/src/fx/Bitcrusher.cpp create mode 100644 ios/core/src/fx/Filter.cpp create mode 100644 ios/core/src/fx/GranularGlitch.cpp create mode 100644 ios/core/src/fx/GraphicEq.cpp create mode 100644 ios/core/src/fx/KotlinMath.hpp create mode 100644 ios/core/src/fx/MixTightener.cpp create mode 100644 ios/core/src/fx/Registry.cpp create mode 100644 ios/core/src/fx/TapeDelay.cpp create mode 100644 ios/core/src/fx/TapeEngine.cpp create mode 100644 ios/core/tests/golden_test.cpp create mode 100755 ios/tools/gen_components.py diff --git a/app/src/test/java/cc/tiredsysadmin/android/sizzle/audio/IosGoldenExport.kt b/app/src/test/java/cc/tiredsysadmin/android/sizzle/audio/IosGoldenExport.kt new file mode 100644 index 0000000..6913eeb --- /dev/null +++ b/app/src/test/java/cc/tiredsysadmin/android/sizzle/audio/IosGoldenExport.kt @@ -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, `__.scn` (its parameters) and + * `__.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>> { + if (type == ToolboxType.MIX_TIGHTENER) { + return listOf("default" to emptyMap()) + + 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 + } +} diff --git a/docs/DEVELOPER_HANDOVER.md b/docs/DEVELOPER_HANDOVER.md index 91dcad4..29face2 100644 --- a/docs/DEVELOPER_HANDOVER.md +++ b/docs/DEVELOPER_HANDOVER.md @@ -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 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 -that would ship every device as an AUv3 plugin, installed with TrollStore. For -now it holds only a spike that checks whether hosts see AUv3 plugins from a -TrollStore install and whether App Groups work there. See `ios/README.md`. +`ios/` is a separate tree with its own Makefile: Sizzle's devices as AUv3 plugins +in an iPadOS 15+ app installed with TrollStore (0.1.0 ships the eight audio +effects). The DSP is a C++ port of the Kotlin code in `ios/core`, verified +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 diff --git a/ios/.gitignore b/ios/.gitignore index 924054e..613d80a 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -2,3 +2,4 @@ build/ dist/ # generated from spike/project.yml by `make project` *.xcodeproj/ +core/golden/ diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md new file mode 100644 index 0000000..9b9a2b6 --- /dev/null +++ b/ios/CHANGELOG.md @@ -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. diff --git a/ios/Makefile b/ios/Makefile index fbaada9..a61757d 100644 --- a/ios/Makefile +++ b/ios/Makefile @@ -1,69 +1,133 @@ # 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 -# one sine-wave AUv3 instrument and an App Group, built to answer "do hosts see -# AUv3 plugins from a TrollStore-installed app?" before any real porting. +# app/ the Sizzle app (cc.tiredsysadmin.ios.sizzle): Sizzle's devices as AUv3 +# plugins for hosts like AUM, installed with TrollStore. iOS/iPadOS 15+. +# 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 project generate spike/SizzleSpike.xcodeproj from spike/project.yml -# make sim build the spike for the iOS Simulator -# make sim-run install + launch it on a booted simulator (self-test runs at launch) +# make golden export DeviceSpecs.gen.hpp + Kotlin reference audio (needs the +# Android toolchain; runs IosGoldenExport in ../app) +# 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 -# dist/cc.tiredsysadmin.ios.sizzlespike_.ipa for TrollStore +# dist/cc.tiredsysadmin.ios.sizzle_.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_.ipa) # make clean remove build/ and dist/ # # Needs Xcode and XcodeGen (brew install xcodegen). Builds stay local (CLAUDE.md). SHELL := /bin/sh -SPIKE := spike -PROJECT := $(SPIKE)/SizzleSpike.xcodeproj -SCHEME := SizzleSpike -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/*') +VERSIONS := ../versions.properties +VERSION := $(shell sed -n 's/^ios.versionName[[:space:]]*=[[:space:]]*//p' $(VERSIONS) | tr -d ' ') +BUILD_NO := $(shell sed -n 's/^ios.versionCode[[:space:]]*=[[:space:]]*//p' $(VERSIONS) | tr -d ' ') -SIM_APP := build/sim/Build/Products/Debug-iphonesimulator/$(SCHEME).app -DEV_APP := build/dev/Build/Products/Release-iphoneos/$(SCHEME).app +APP_ID := cc.tiredsysadmin.ios.sizzle +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 +# 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 help: @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.pbxproj: $(SPIKE)/project.yml - cd $(SPIKE) && xcodegen generate --spec project.yml --quiet +$(PROJECT)/project.pbxproj: app/project.yml app/FX/Info.plist + cd app && xcodegen generate --spec project.yml --quiet -# Simulator: Xcode's "sign to run locally" (-) embeds the entitlements, so the -# App Group works there too. -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. +# Device: build without signing, then ad-hoc sign inside-out (extension first) with +# each target's entitlements. TrollStore re-signs at install and keeps them. ipa: $(IPA) -$(IPA): $(PROJECT)/project.pbxproj $(SOURCES) - xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Release \ - -sdk iphoneos -derivedDataPath build/dev CODE_SIGNING_ALLOWED=NO build +$(IPA): $(PROJECT)/project.pbxproj $(APP_SRC) $(VERSIONS) + xcodebuild -quiet -project $(PROJECT) -scheme Sizzle -configuration Release \ + -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 cp -R $(DEV_APP) build/Payload/ - codesign -f -s - --entitlements $(SPIKE)/AU/AU.entitlements \ - build/Payload/$(SCHEME).app/PlugIns/SizzleSpikeAU.appex - codesign -f -s - --entitlements $(SPIKE)/App/App.entitlements \ - build/Payload/$(SCHEME).app + codesign -f -s - --entitlements app/FX/FX.entitlements build/Payload/Sizzle.app/PlugIns/SizzleFX.appex + codesign -f -s - --entitlements app/Host/Host.entitlements build/Payload/Sizzle.app rm -f $@ && cd build && zip -qr ../$@ Payload @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: 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 diff --git a/ios/README.md b/ios/README.md index 53f529b..a66c8c0 100644 --- a/ios/README.md +++ b/ios/README.md @@ -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). -The plan is to ship every Sizzle instrument and effect as AUv3 plugins inside one -app (iOS/iPadOS 15+), installed with TrollStore. Before porting anything, the -**spike** in `spike/` answers the one question that could sink the plan: do hosts -(AUM, GarageBand, Loopy…) list AUv3 plugins from a TrollStore-installed app, and do -App Groups work there? +Sizzle's instruments and effects as AUv3 plugins for hosts such as AUM, GarageBand +and Loopy, in one app (`cc.tiredsysadmin.ios.sizzle`, iOS/iPadOS 15+) installed +with TrollStore. This tree is separate from the Android app and has its own +Makefile (`make -C ios help`). -## The spike - -| Piece | What it is | +| Path | What it is | |---|---| -| `spike/project.yml` | XcodeGen spec; `make project` generates the Xcode project (git-ignored) | -| `spike/App/` | SwiftUI host app `cc.tiredsysadmin.ios.sizzlespike` with a self-test (Run self-test button) | -| `spike/AU/` | App extension `…sizzlespike.au`: one AUv3 instrument (`aumu` / `sSpk` / `Tsys`), "Tired Sysadmin: Sizzle Spike Sine", a sine voice with a Gain parameter | -| `spike/Shared/Spike.swift` | The App Group id, the component description, and the App Group probe both sides run | +| `core/` | The C++ DSP core: a port of the Android app's Kotlin DSP | +| `core/include/sizzle/DeviceSpecs.gen.hpp` | Every device's parameters, generated from `ToolboxType` (Kotlin) | +| `core/tests/golden_test.cpp` | Compares the core with audio the Kotlin code renders | +| `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 - `Tsys/sSpk`. That is the same registry hosts read, so a FAIL here means no host - will see the plugin. -2. **[2] Instantiated out of process / Rendered 1 s offline:** iOS launches the - extension and its render block produces sound (silent, offline render; peak > 0.05). - "Play tone (1 s)" does the same through the speaker. -3. **[3] App Group:** the app writes `app.txt`, the extension writes `au.txt` when it is - created (and `au-view.txt` when a host opens its view), and each side lists what's - there. After [2], seeing `au.txt` in the app's list proves both sides share files, - which is how the real port will hand samples and SF2 files to the plugins. +## How the port is verified + +The Kotlin DSP is the reference. `make golden` runs `IosGoldenExport` (a JVM unit +test in the Android app, skipped by the normal `make check`), which: + +- writes `DeviceSpecs.gen.hpp`, so iOS uses the same parameter definitions + (keys, labels, ranges, defaults, choices) and the Mix Tightener presets; +- renders a fixed 1.5 s test signal (decaying saw burst, noise, sine sweep, + silences for tails) through every effect at its defaults and two variants that + 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 ". 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 ```sh -make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_.ipa +make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzle_.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 -(extension first) with each target's entitlements, and zipped as `Payload/`. -TrollStore re-signs at install time and keeps the entitlements it finds; ldid -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`. +The device build is unsigned, then ad-hoc signed inside-out (extension first) +with each target's entitlements and zipped as `Payload/`. TrollStore re-signs at +install and keeps the entitlements. -`make sim` / `make sim-run` build and run it in the Simulator, but no Simulator -runtime was installed when the spike was written, so it hasn't been run there. +The extension links the core with `-force_load`: effect makers are found through +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 -1. AirDrop or copy the newest `cc.tiredsysadmin.ios.sizzlespike_.ipa` to the - iPad, open it with TrollStore, install. -2. Open **Sizzle Spike**, tap **Run self-test**, and note [1]–[3] (screenshot). -3. In AUM (or GarageBand → Audio Units, Loopy, Drambo…), add an instrument and look - for **Tired Sysadmin: Sizzle Spike Sine**. Load it, play notes, open its view (it - 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-.ips`. +1. Install the newest `cc.tiredsysadmin.ios.sizzle_.ipa` with TrollStore. +2. Open **Sizzle**, tap **Check all plugins**: 8/8 should pass. +3. In AUM, add an audio track or a synth, then an effect slot: the plugins are + listed as "Tired Sysadmin: Sizzle …". Try the editor, a Mix Tightener preset, + and saving and reopening an AUM session (restores `fullState`). ## Decisions -- **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and - review; the generated project is git-ignored. -- **Swift render block in the spike:** good enough for one sine voice (no allocation - or locks in the render block). The real port puts the DSP in a C++ core (see the - conversation that planned it: Kotlin DSP → C++ verified against reference audio - rendered by the Kotlin code). -- **One extension, factory dispatch:** the real port will list many - `AudioComponents` in one or a few extensions and pick the unit in - `createAudioUnit(with:)` by subtype, instead of one extension per device. -- **Versions:** the spike's version lives in `spike/project.yml` - (`MARKETING_VERSION` 0.1.0, `CURRENT_PROJECT_VERSION` 1, which names the .ipa). +- **C++ core, not Kotlin/Native:** an AUv3 render callback must not allocate, + lock or wait for a garbage collector; plain C++ with preallocated state meets + that, and can later replace the Kotlin DSP on Android through JNI. +- **Reference audio instead of reading the code twice:** the Kotlin output is the + specification, so ports can be done by anyone (including parallel agents) and + checked mechanically. +- **XcodeGen:** projects are text (`app/project.yml`); generated projects are + git-ignored. Generated sources that iOS needs to build without the Android + toolchain (`DeviceSpecs.gen.hpp`, `FX/Info.plist`, `Components.gen.h`) are + committed. +- **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. diff --git a/ios/app/FX/Components.gen.h b/ios/app/FX/Components.gen.h new file mode 100644 index 0000000..e4efab9 --- /dev/null +++ b/ios/app/FX/Components.gen.h @@ -0,0 +1,17 @@ +// GENERATED from components.txt by tools/gen_components.py. Do not edit. +#pragma once +#include + +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; diff --git a/ios/app/FX/FX.entitlements b/ios/app/FX/FX.entitlements new file mode 100644 index 0000000..b45a639 --- /dev/null +++ b/ios/app/FX/FX.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.cc.tiredsysadmin.ios.sizzle + + + diff --git a/ios/app/FX/Info.plist b/ios/app/FX/Info.plist new file mode 100644 index 0000000..6c1f313 --- /dev/null +++ b/ios/app/FX/Info.plist @@ -0,0 +1,115 @@ + + + + + + CFBundleDevelopmentRegionen + CFBundleDisplayNameSizzle FX + CFBundleExecutable$(EXECUTABLE_NAME) + CFBundleIdentifier$(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion6.0 + CFBundleName$(PRODUCT_NAME) + CFBundlePackageTypeXPC! + CFBundleShortVersionString$(MARKETING_VERSION) + CFBundleVersion$(CURRENT_PROJECT_VERSION) + NSExtension + + NSExtensionAttributes + + AudioComponents + + + descriptionSizzle Bitcrusher + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Bitcrusher + sandboxSafe + subtypesBcr + tagsEffects + typeaufx + version65536 + + + descriptionSizzle Filter + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Filter + sandboxSafe + subtypesFlt + tagsEffects + typeaufx + version65536 + + + descriptionSizzle 10-Band EQ + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle 10-Band EQ + sandboxSafe + subtypesEqx + tagsEffects + typeaufx + version65536 + + + descriptionSizzle Tape Delay + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Tape Delay + sandboxSafe + subtypesDly + tagsEffects + typeaufx + version65536 + + + descriptionSizzle Mix Tightener + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Mix Tightener + sandboxSafe + subtypesMxt + tagsEffects + typeaufx + version65536 + + + descriptionSizzle Tape Engine + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Tape Engine + sandboxSafe + subtypesTpe + tagsEffects + typeaufx + version65536 + + + descriptionSizzle Granular Glitch + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Granular Glitch + sandboxSafe + subtypesGrn + tagsEffects + typeaufx + version65536 + + + descriptionSizzle Ambience Reverb + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle Ambience Reverb + sandboxSafe + subtypesAmb + tagsEffects + typeaufx + version65536 + + + + NSExtensionPointIdentifiercom.apple.AudioUnit-UI + NSExtensionPrincipalClassSizzleFXViewController + + + diff --git a/ios/app/FX/SizzleEffectAU.h b/ios/app/FX/SizzleEffectAU.h new file mode 100644 index 0000000..5b46658 --- /dev/null +++ b/ios/app/FX/SizzleEffectAU.h @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import + +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 diff --git a/ios/app/FX/SizzleEffectAU.mm b/ios/app/FX/SizzleEffectAU.mm new file mode 100644 index 0000000..8bbfd10 --- /dev/null +++ b/ios/app/FX/SizzleEffectAU.mm @@ -0,0 +1,405 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import "SizzleEffectAU.h" +#import "Components.gen.h" +#import + +#include +#include +#include +#include +#include +#include +#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 fx[2]; + int channels = 0; + + std::atomic values[Params::kMax]; + std::atomic valuesSeq{1}; + + Params mailbox[2]; + std::atomic mailboxIdx{0}; + std::atomic mailboxSeq{1}; + + // render thread only + Params live; + uint32_t seenValues = 0, seenMailbox = 0; + double tempo = 120.0; + std::atomic bypass{false}; + std::vector 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 _k; + AUAudioUnitBusArray *_inputs; + AUAudioUnitBusArray *_outputs; + AUAudioUnitBus *_inBus; + AUAudioUnitBus *_outBus; + AUParameterTree *_tree; + Params _base; // main thread: the full settings (incl. hidden keys) + NSArray *_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(); + _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 *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 *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 *)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 *)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 *)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 *)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 diff --git a/ios/app/FX/SizzleFXViewController.mm b/ios/app/FX/SizzleFXViewController.mm new file mode 100644 index 0000000..0a8f0b9 --- /dev/null +++ b/ios/app/FX/SizzleFXViewController.mm @@ -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 +#import +#import "Components.gen.h" +#import "SizzleEffectAU.h" + +@interface SizzleFXViewController : AUViewController +@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 *_controls; + NSMutableDictionary *_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 *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 *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 *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 diff --git a/ios/app/Host/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/app/Host/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..df8b22a --- /dev/null +++ b/ios/app/Host/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,6 @@ +{ + "images" : [ + { "filename" : "icon-1024.png", "idiom" : "universal", "platform" : "ios", "size" : "1024x1024" } + ], + "info" : { "author" : "xcode", "version" : 1 } +} diff --git a/ios/app/Host/Assets.xcassets/AppIcon.appiconset/icon-1024.png b/ios/app/Host/Assets.xcassets/AppIcon.appiconset/icon-1024.png new file mode 100644 index 0000000000000000000000000000000000000000..a2ed9b5d49ea79e4b247d35fb3875663daa96663 GIT binary patch literal 48476 zcmc$`c|6o@`#1hUQQ0ajWUC}=BuUoMDr8?K>nNd;lqDfXt0;sSl4X>AiK6U`vX8Co z`w$Z*jBPB#%>2$7b$`Fl^L?KCdA|2^zh1w;uIp0Q@j1@pJl6N|J_Q>YXmjs4umgf1 zZktCAHv7pf@y)~U1G4n5s@w!v@-xrC&z1Vf!Bk6|05;Um1rEyz_dw-A=Vtq}5b zl_+f+ZBBd68Pbx4R>fAUMZYqB!Ueqmf6DlajGtgwpij`q-~V-05jwaJ+Sv717&}zM z8VCcz!B2RRHBc3+)?Cn^{|@Jeu0YHWZ2p7|;)IwV0G|wkU4!gd4*vb*oHiFE3;q41 zDD4GMFc4__-&G-eqzwwZ0x>_pR7wEa$q8+qG6-0p?cc6owdlXmf(-SmfIa_OcU6oX z+6Qe~mvICCqJ4q2H~t4hJchAB*I24Hulrwe0C3rxclY+|K{nwf;qg=QvpZ9`8T<{y%rTf2#gm5Zk{H8UIxMQC^P!Ug-Xx)#rqG z{+)ph)UOuh`FCZWzv>6Ug#M(se@one+~o}N_J1Uhe|nGqw~2Ez2mkvN9O1D4e+uRQ zn#(tX`(F>`UH{deL8uy8l{={;4PZn^P9^WdBVS{;4zn|7H6Bp67s;1}OTc|M%SK_ zjOKr}n$b9c%=K@H8;1JqkQO-le;y<7R#14+j&0j^aBbhdgO@kt)wZxOuCTDu^o)j) z7jq-uzb93VR7qI<8A|3>gd6(^BzGSl|4zd}gpQVvR;E^;*7h?hET9fFL~xGGce7YE z2G75<%p9#%iRijuJR@_hw5x9U=6=}6D3>cePa`yT*DvV`;U#XK#is;QXKy~lr+lj5 z(i3nsrtsai(fecLL=q!+W*NMj{TogAr12l_x7NPcSPviL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{^~BL(}2h{7inLZi-{mwoYYg7 zQbn7~G_9arf1 zyD<~Cp46k%wR`%xEyxWae)07nZi(%i&oLaf;FcqXxp1ZzDsE1g_%70 z%(d&cUp~x$kZsO;e659!o?cj2S5s+eMC-)}D3C5VkR!Q_rE$)3GO(P9oLh1N2^s)7 zRzwU776{25c~Izv;4$7qfE*?Ku{5tk105izK8UA;1R)2E@a%AMApSBh3;&u-Or?(> zQEm=`f;?m^(O0DTAL2y<5hCeG_441WS~Qt(7Qr$}7ftFCw5(4`Z-A?ol9Rtd=~4%@ zmVPG)zAm1g#E ze*0Sbu>>Obb(|%)mVPW@M$tV8-l&u#zR2Zr=hAO2{n%5H3zG&;ND>uswHQbNY3B#X z@+2e4*o=@rCG4NdP&jJ}?D!iEZ-4a|f|J9gT@fdU`MaXN zA%c(puM^OJE&Z)GhCtqbuBr*OD#eTm=_dkkIXyR^+axM*kWfjwW$rs++wnF7(w=^; zSA)pm;!lK&1j9%xaY!XKU{6Aovf`7DQhg literal 0 HcmV?d00001 diff --git a/ios/app/Host/Assets.xcassets/Contents.json b/ios/app/Host/Assets.xcassets/Contents.json new file mode 100644 index 0000000..46cba7d --- /dev/null +++ b/ios/app/Host/Assets.xcassets/Contents.json @@ -0,0 +1 @@ +{ "info" : { "author" : "xcode", "version" : 1 } } diff --git a/ios/app/Host/Bridging.h b/ios/app/Host/Bridging.h new file mode 100644 index 0000000..a0863f7 --- /dev/null +++ b/ios/app/Host/Bridging.h @@ -0,0 +1 @@ +#import "ObjC/SPKTry.h" diff --git a/ios/app/Host/ContentView.swift b/ios/app/Host/ContentView.swift new file mode 100644 index 0000000..6d7b77c --- /dev/null +++ b/ios/app/Host/ContentView.swift @@ -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)" + } +} diff --git a/ios/app/Host/Host.entitlements b/ios/app/Host/Host.entitlements new file mode 100644 index 0000000..b45a639 --- /dev/null +++ b/ios/app/Host/Host.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.cc.tiredsysadmin.ios.sizzle + + + diff --git a/ios/app/Host/ObjC/SPKTry.h b/ios/app/Host/ObjC/SPKTry.h new file mode 100644 index 0000000..8b77e79 --- /dev/null +++ b/ios/app/Host/ObjC/SPKTry.h @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import + +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 diff --git a/ios/app/Host/ObjC/SPKTry.m b/ios/app/Host/ObjC/SPKTry.m new file mode 100644 index 0000000..759740e --- /dev/null +++ b/ios/app/Host/ObjC/SPKTry.m @@ -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)"]; + } +} diff --git a/ios/app/Host/PluginCheck.swift b/ios/app/Host/PluginCheck.swift new file mode 100644 index 0000000..a1c217c --- /dev/null +++ b/ios/app/Host/PluginCheck.swift @@ -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..> 8) & 0xFFFF) / 65535 * 0.6 - 0.3 } + for ch in 0.. 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.. 0.01 ? String(format: "PASS peak %.2f", peak) : String(format: "FAIL silent (peak %.4f)", peak) + } catch { + return "FAIL \(error.localizedDescription)" + } + } +} diff --git a/ios/app/Host/SizzleApp.swift b/ios/app/Host/SizzleApp.swift new file mode 100644 index 0000000..9fa16d6 --- /dev/null +++ b/ios/app/Host/SizzleApp.swift @@ -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() } } +} diff --git a/ios/app/components.txt b/ios/app/components.txt new file mode 100644 index 0000000..b902baf --- /dev/null +++ b/ios/app/components.txt @@ -0,0 +1,14 @@ +# The AUv3 plugins the app ships. One line each: +# +# 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 diff --git a/ios/app/project.yml b/ios/app/project.yml new file mode 100644 index 0000000..dab068c --- /dev/null +++ b/ios/app/project.yml @@ -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 diff --git a/ios/app/tests/au_test.mm b/ios/app/tests/au_test.mm new file mode 100644 index 0000000..b4ae5ff --- /dev/null +++ b/ios/app/tests/au_test.mm @@ -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 +#include +#include +#include +#include +#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 readF32(const char *path) { + std::ifstream f(path, std::ios::binary); + std::vector b((std::istreambuf_iterator(f)), {}); + std::vector 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 &in, std::vector &L, std::vector &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 renderCore(const char *type, const Params &p, const std::vector &in) { + auto fx = Effect::create(type, 48000); + fx->update(p, 120.f); + std::vector 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 &a, const std::vector &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 \n"); return 2; } + std::vector 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 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 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; +} diff --git a/ios/core/include/sizzle/DeviceSpecs.gen.hpp b/ios/core/include/sizzle/DeviceSpecs.gen.hpp new file mode 100644 index 0000000..0e1ea3d --- /dev/null +++ b/ios/core/include/sizzle/DeviceSpecs.gen.hpp @@ -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 diff --git a/ios/core/include/sizzle/Effect.hpp b/ios/core/include/sizzle/Effect.hpp new file mode 100644 index 0000000..3b9d789 --- /dev/null +++ b/ios/core/include/sizzle/Effect.hpp @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later +#pragma once + +#include +#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 create(const char *type, int sampleRate); +}; + +} // namespace sizzle diff --git a/ios/core/include/sizzle/Params.hpp b/ios/core/include/sizzle/Params.hpp new file mode 100644 index 0000000..aca582c --- /dev/null +++ b/ios/core/include/sizzle/Params.hpp @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later +#pragma once + +#include +#include +#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 diff --git a/ios/core/include/sizzle/Specs.hpp b/ios/core/include/sizzle/Specs.hpp new file mode 100644 index 0000000..8424805 --- /dev/null +++ b/ios/core/include/sizzle/Specs.hpp @@ -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 diff --git a/ios/core/src/Params.cpp b/ios/core/src/Params.cpp new file mode 100644 index 0000000..3db853d --- /dev/null +++ b/ios/core/src/Params.cpp @@ -0,0 +1,65 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "sizzle/Params.hpp" +#include +#include + +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 diff --git a/ios/core/src/Specs.cpp b/ios/core/src/Specs.cpp new file mode 100644 index 0000000..ba576bb --- /dev/null +++ b/ios/core/src/Specs.cpp @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#include +#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 diff --git a/ios/core/src/fx/AmbienceReverb.cpp b/ios/core/src/fx/AmbienceReverb.cpp new file mode 100644 index 0000000..f228de1 --- /dev/null +++ b/ios/core/src/fx/AmbienceReverb.cpp @@ -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 +#include +#include +#include +#include +#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 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 diffusers; + std::vector fdn; + std::vector 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 makeAmbienceReverb(int sampleRate) { + return std::make_unique(sampleRate); +} + +} // namespace sizzle diff --git a/ios/core/src/fx/Bitcrusher.cpp b/ios/core/src/fx/Bitcrusher.cpp new file mode 100644 index 0000000..f9bd575 --- /dev/null +++ b/ios/core/src/fx/Bitcrusher.cpp @@ -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 makeBitcrusher(int) { return std::make_unique(); } + +} // namespace sizzle diff --git a/ios/core/src/fx/Filter.cpp b/ios/core/src/fx/Filter.cpp new file mode 100644 index 0000000..d5513b5 --- /dev/null +++ b/ios/core/src/fx/Filter.cpp @@ -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 +#include +#include +#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 makeFilter(int sr) { return std::make_unique(sr); } + +} // namespace sizzle diff --git a/ios/core/src/fx/GranularGlitch.cpp b/ios/core/src/fx/GranularGlitch.cpp new file mode 100644 index 0000000..473406d --- /dev/null +++ b/ios/core/src/fx/GranularGlitch.cpp @@ -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 +#include +#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 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 makeGranularGlitch(int sr) { return std::make_unique(sr); } + +} // namespace sizzle diff --git a/ios/core/src/fx/GraphicEq.cpp b/ios/core/src/fx/GraphicEq.cpp new file mode 100644 index 0000000..92105b9 --- /dev/null +++ b/ios/core/src/fx/GraphicEq.cpp @@ -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 +#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 makeGraphicEq(int sr) { return std::make_unique(sr); } + +} // namespace sizzle diff --git a/ios/core/src/fx/KotlinMath.hpp b/ios/core/src/fx/KotlinMath.hpp new file mode 100644 index 0000000..166e951 --- /dev/null +++ b/ios/core/src/fx/KotlinMath.hpp @@ -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 + +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 inline T coerceIn(T v, T lo, T hi) { return v < lo ? lo : (v > hi ? hi : v); } +template inline T coerceAtLeast(T v, T lo) { return v < lo ? lo : v; } +template inline T coerceAtMost(T v, T hi) { return v > hi ? hi : v; } + +} // namespace sizzle::kt diff --git a/ios/core/src/fx/MixTightener.cpp b/ios/core/src/fx/MixTightener.cpp new file mode 100644 index 0000000..b03c1dc --- /dev/null +++ b/ios/core/src/fx/MixTightener.cpp @@ -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 +#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 makeMixTightener(int sampleRate) { return std::make_unique(sampleRate); } + +} // namespace sizzle diff --git a/ios/core/src/fx/Registry.cpp b/ios/core/src/fx/Registry.cpp new file mode 100644 index 0000000..0e47b5e --- /dev/null +++ b/ios/core/src/fx/Registry.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +// Effect::create. Each effect lives in src/fx/.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 +#include "sizzle/Effect.hpp" + +#define SIZZLE_MAKER(fn) \ + __attribute__((weak)) std::unique_ptr 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::create(const char *type, int sr) { + struct Entry { const char *type; std::unique_ptr (*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 diff --git a/ios/core/src/fx/TapeDelay.cpp b/ios/core/src/fx/TapeDelay.cpp new file mode 100644 index 0000000..48c1305 --- /dev/null +++ b/ios/core/src/fx/TapeDelay.cpp @@ -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 +#include +#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 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 makeTapeDelay(int sampleRate) { return std::make_unique(sampleRate); } + +} // namespace sizzle diff --git a/ios/core/src/fx/TapeEngine.cpp b/ios/core/src/fx/TapeEngine.cpp new file mode 100644 index 0000000..18ef5b7 --- /dev/null +++ b/ios/core/src/fx/TapeEngine.cpp @@ -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 +#include +#include +#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 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 makeTapeEngine(int sr) { return std::make_unique(sr); } + +} // namespace sizzle diff --git a/ios/core/tests/golden_test.cpp b/ios/core/tests/golden_test.cpp new file mode 100644 index 0000000..9d3966e --- /dev/null +++ b/ios/core/tests/golden_test.cpp @@ -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 [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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "sizzle/Effect.hpp" + +using namespace sizzle; + +static std::vector readF32(const std::string &path) { + std::ifstream f(path, std::ios::binary); + std::vector bytes((std::istreambuf_iterator(f)), {}); + std::vector 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 [TYPE ...]\n", argv[0]); return 2; } + std::string dir = argv[1]; + std::vector only(argv + 2, argv + argc); + std::vector 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 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 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; +} diff --git a/ios/tools/gen_components.py b/ios/tools/gen_components.py new file mode 100755 index 0000000..17a9669 --- /dev/null +++ b/ios/tools/gen_components.py @@ -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 +""" +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""" + descriptionSizzle {escape(name)} + factoryFunctionSizzleFXViewController + manufacturerTsys + nameTired Sysadmin: Sizzle {escape(name)} + sandboxSafe + subtype{sub} + tags{TAGS[t]} + type{t} + version65536 + """) + plist = f""" + + + + + CFBundleDevelopmentRegionen + CFBundleDisplayNameSizzle FX + CFBundleExecutable$(EXECUTABLE_NAME) + CFBundleIdentifier$(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion6.0 + CFBundleName$(PRODUCT_NAME) + CFBundlePackageTypeXPC! + CFBundleShortVersionString$(MARKETING_VERSION) + CFBundleVersion$(CURRENT_PROJECT_VERSION) + NSExtension + + NSExtensionAttributes + + AudioComponents + +{chr(10).join(comps)} + + + NSExtensionPointIdentifiercom.apple.AudioUnit-UI + NSExtensionPrincipalClassSizzleFXViewController + + + +""" + 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 + +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]) diff --git a/versions.properties b/versions.properties index b9c485e..6c1d70b 100644 --- a/versions.properties +++ b/versions.properties @@ -14,9 +14,11 @@ android.versionCode = 70 # 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 # platform". Namespace for every platform: cc.tiredsysadmin..sizzle. -# iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): only the AUv3 spike exists so far; -# its version is in ios/spike/project.yml (0.1.0, build 1). See ios/README.md. -ios.versionName = - +# iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): the AUv3 plugin app in ios/app; the +# Makefile there passes these to Xcode and names the .ipa by versionCode. (The +# TrollStore spike in ios/spike keeps its own version in its project.yml.) +ios.versionName = 0.1.0 +ios.versionCode = 1 macos.versionName = - linux.versionName = - bsd.versionName = -