0.41.1 (77): cleanup and optimisation round (Android and iOS)

Nothing user-visible changes, except that the Android app is half the size and
both are lighter on the battery.

R8 is on for release builds (21.5 MB -> 10.1 MB); only the two JNI classes are
pinned by name, since the app reflects over nothing of its own, and `make dist`
keeps the mapping beside the APK. The Kotlin DSP that core/ replaced in 0.37.0
was still compiled into every APK with nothing calling it — it moves to the test
source set, where it belongs as the reference the C++ is checked against — and
the golden tests' TestVoice wrappers leave core/src for core/tests/voices, so
neither app compiles them either.

Speed: channel gain, mute/solo and the FX chain are read once per audio block
instead of once per frame in Engine::fillBlock (both platforms, bit-identical —
all 61 reference scenarios still match); the transport pollers idle at 100 ms
(Android) and 10 Hz (iOS) instead of polling flat out while a song is stopped,
woken by any transport call; ProjectIo.save builds into one pre-sized buffer and
a burst of edits is coalesced into one engine sync; the Kotlin grain sources and
factory wavetables are built when their editor opens rather than at launch, where
they duplicated ~6 MB the engine already renders in core/; and Xcode builds the
DSP core at -O2, the level the golden tests measure, not -Os.

Fix: `make lint` failed on a manifest asking for ACCESS_FINE_LOCATION without
ACCESS_COARSE_LOCATION (the BLE MIDI scan on Android 8-11), so `make check`
passes again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-18 10:21:09 +01:00
co-authored by Claude Opus 5
parent cdabf3018b
commit dd04a61e22
46 changed files with 508 additions and 192 deletions
+10 -5
View File
@@ -52,9 +52,13 @@ android {
buildTypes {
release {
// Shrinking is off by default so newcomers get readable stack traces.
// Flip to true once the app stabilises.
isMinifyEnabled = false
// R8: shrink + optimise + obfuscate, and drop unreferenced resources.
// Only the JNI entry points need keeping (see proguard-rules.pro); the
// app reflects over nothing of its own. A release stack trace is now
// obfuscated, so keep app/build/outputs/mapping/release/mapping.txt
// beside any APK you publish — `make dist` copies it into dist/.
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
@@ -66,8 +70,9 @@ android {
// the app un-optimised and makes Compose several times slower — so measuring
// UI "snappiness" on a debug build is misleading. This variant flips
// debuggability off (the single biggest perf lever) while reusing the debug
// signing key, so it still installs without a release keystore. R8/shrinking
// stays off to avoid needing JNI/Compose keep-rules for now.
// signing key, so it still installs without a release keystore. R8 stays off
// here on purpose: staging exists to measure the UI, and un-obfuscated stack
// traces are worth more than the last few hundred KB. `release` is minified.
create("staging") {
initWith(getByName("debug"))
isDebuggable = false
+19 -3
View File
@@ -1,3 +1,19 @@
# ProGuard/R8 rules for release builds. Minification is currently disabled in
# build.gradle.kts (isMinifyEnabled = false), so this file is intentionally empty.
# Add keep-rules here if/when you enable shrinking and hit reflection issues.
# R8 rules for the release build (isMinifyEnabled = true in build.gradle.kts).
#
# Keep as little as possible: everything else — Compose, media3, DataStore,
# coroutines — ships its own consumer rules inside its AAR, and the app itself
# uses no reflection over its own classes (songs, presets, themes and bindings
# are all read and written as text by hand-written parsers in io/).
# JNI. The native library resolves Java_<mangled package>_<class>_<method> by
# name at *runtime*, so a renamed class or method is an UnsatisfiedLinkError on
# first play — not a build error. Both halves of the bridge must keep their
# names: audio/NativeEngine (the engine, src/main/cpp/jni_engine.cpp) and
# audio/NativeAudioBridge (the Oboe stream, src/main/cpp/native_audio.cpp).
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
# Kotlin tells R8 what is nullable through these; dropping them makes R8's
# warnings about the Kotlin stdlib noisy for no gain.
-dontwarn kotlin.Unit
+6 -1
View File
@@ -10,7 +10,11 @@
BLUETOOTH_CONNECT : Bluetooth MIDI + gamepad on Android 12+.
BLUETOOTH_SCAN : finding BLE MIDI controllers (Settings › MIDI inputs) on
Android 12+; never used to derive location.
BLUETOOTH / _ADMIN / ACCESS_FINE_LOCATION : the same scan on Android 8-11. -->
BLUETOOTH / _ADMIN : the same scan on Android 8-11.
ACCESS_FINE_LOCATION + ACCESS_COARSE_LOCATION : a BLE scan on Android 8-11
was gated on location permission. Both are declared
because the platform (and lint) treat FINE as an
upgrade of COARSE, and we only ever scan with them. -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
@@ -20,6 +24,7 @@
android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
<!-- Hardware we can *use* but do not *require* (so the app still installs on
@@ -104,10 +104,12 @@ class SizzleApp : Application() {
override fun onCreate() {
super.onCreate()
// The Grain Cloud's built-in sources are synthesised, not shipped: render them
// in the background now so they're ready before anyone plays one.
cc.tiredsysadmin.android.sizzle.audio.GrainSources.prewarm()
cc.tiredsysadmin.android.sizzle.wavetable.WaveTables.prewarm()
// The Grain Cloud's sources and the factory wavetables are synthesised, not
// shipped — but the engine (core/, through EngineHost) renders its own set as
// soon as it is created, and nothing outside the two editors' drawings reads
// the Kotlin ones. They are built when those editors open (WavetablePreview /
// GrainCloudEditor) instead of here, so launch no longer renders ~6 MB of PCM
// twice and no longer holds the second copy for the life of the process.
// Crash recovery: restore the last autosaved project before the engine or
// UI read it, so a crash / process-death resumes where the user left off.
projectStore.restore(project)
@@ -49,13 +49,18 @@ class AudioEngine(
rebuildFxChains()
}
/** The Kotlin project changed: bring the engine's copy up to date soon (once per
* main-loop turn however many edits arrive). Any thread. */
/** The Kotlin project changed: bring the engine's copy up to date soon. Any thread.
*
* Coalesced to one sync per [SYNC_COALESCE_MS]. A drag over the pattern grid or a
* knob fires an edit per pointer event — each one its own main-loop turn, so a
* per-turn flag would still serialise the whole song 60 times a second. The
* engine's copy being a frame or two stale is inaudible (nothing has sounded yet
* that the edit changes), and every transport or routing call syncs first anyway. */
fun requestSync() {
main.post {
if (syncPending) return@post
syncPending = true
main.post { syncPending = false; syncNow() }
main.postDelayed({ syncPending = false; syncNow() }, SYNC_COALESCE_MS)
}
}
@@ -90,13 +95,19 @@ class AudioEngine(
private val _transport = MutableStateFlow(TransportState())
val transport: StateFlow<TransportState> = _transport
/** Wakes the transport poller out of its idle wait (see [start]). At most one
* permit is outstanding, so a flood of transport calls costs one extra turn. */
private val pollWake = java.util.concurrent.Semaphore(0)
private fun wakePoller() { if (pollWake.availablePermits() == 0) pollWake.release() }
/** Start playback, optionally from [startBeat] (see Engine::play). */
fun play(startBeat: Int = -1) { syncNow(); if (NativeEngine.created) NativeEngine.nativePlay(startBeat); publish() }
fun pause() { if (NativeEngine.created) NativeEngine.nativePause(); publish() }
fun play(startBeat: Int = -1) { syncNow(); if (NativeEngine.created) NativeEngine.nativePlay(startBeat); publish(); wakePoller() }
fun pause() { if (NativeEngine.created) NativeEngine.nativePause(); publish(); wakePoller() }
/** MIDI panic: hard-silence every voice and cancel the arpeggiators. */
fun panic() { if (NativeEngine.created) NativeEngine.nativePanic(); publish() }
fun panic() { if (NativeEngine.created) NativeEngine.nativePanic(); publish(); wakePoller() }
/** Stop; if already stopped, rewind to the top. */
fun stop() { if (NativeEngine.created) NativeEngine.nativeStop(); publish() }
fun stop() { if (NativeEngine.created) NativeEngine.nativeStop(); publish(); wakePoller() }
private fun publish() {
if (!NativeEngine.created) return
@@ -160,6 +171,7 @@ class AudioEngine(
fun setRecordingArm(armed: Boolean, tailBars: Int) {
recordArmed = armed
if (NativeEngine.created) NativeEngine.nativeSetRecordingArm(armed, tailBars.coerceIn(0, 8))
wakePoller()
}
fun setRecordTailBars(tailBars: Int) {
@@ -167,10 +179,13 @@ class AudioEngine(
}
/** An external MIDI clock's Start: an armed recording starts even with the song stopped. */
fun externalClockStart() { if (NativeEngine.created) NativeEngine.nativeExternalClockStart() }
fun externalClockStart() {
if (NativeEngine.created) NativeEngine.nativeExternalClockStart()
wakePoller()
}
fun externalClockStop() { if (NativeEngine.created) NativeEngine.nativeExternalClockStop() }
private var wasRecording = false
@Volatile private var wasRecording = false
private fun pollRecording() {
val active = NativeEngine.nativeRecordingActive()
@@ -198,11 +213,15 @@ class AudioEngine(
fun start() {
if (running) return
running = true
// Transport and recording state for the UI, ~100 times a second.
// Transport and recording state for the UI: ~100 times a second while there is
// something to watch, 10 times a second when the song is stopped and nothing is
// armed (then only an external MIDI clock could start a take). A transport call
// wakes the thread through [pollWake], so the playhead still appears at once.
poller = thread(name = "sizzle-transport", isDaemon = true) {
while (running) {
if (NativeEngine.created) { publish(); pollRecording() }
Thread.sleep(10)
val busy = _transport.value.isPlaying || recordArmed || wasRecording
pollWake.tryAcquire(if (busy) 10L else 100L, java.util.concurrent.TimeUnit.MILLISECONDS)
}
}
main.post(safetyNet)
@@ -268,6 +287,7 @@ class AudioEngine(
/** Stop the engine entirely (called when the last owner lets go). */
fun release() {
running = false
wakePoller()
main.removeCallbacks(safetyNet)
if (NativeEngine.created) { NativeEngine.nativeSetRecordingArm(false, 0); NativeEngine.nativeEndCapture() }
nativeBridge?.stop()
@@ -276,11 +296,13 @@ class AudioEngine(
renderThread = null
track?.run { stop(); release() }
track = null
poller?.join(100)
poller?.join(200)
poller = null
}
private companion object {
const val BLOCK_FRAMES = 192 // the engine's block (~4 ms at 48 kHz)
/** How long a burst of edits is collected before one sync (see [requestSync]). */
const val SYNC_COALESCE_MS = 33L
}
}
@@ -79,7 +79,9 @@ class BleMidi(private val context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT)
} else {
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)
// Both, as the manifest declares them: a FINE request without COARSE is
// rejected by the platform's permission model (and flagged by lint).
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)
}
fun hasPermissions(): Boolean = requiredPermissions().all {
@@ -73,8 +73,8 @@ class MidiClock(context: Context) {
override fun onDeviceAdded(device: MidiDeviceInfo) = openDevice(device)
}
callback = cb
mm.devices.forEach(::openDevice)
mm.registerDeviceCallback(cb, handler)
allDevices(mm).forEach(::openDevice)
registerCallback(mm, cb)
running = true
thread = Thread({ sendLoop() }, "sizzle-midi-clock").apply {
priority = Thread.MAX_PRIORITY; isDaemon = true; start()
@@ -90,6 +90,16 @@ class MidiClock(context: Context) {
outPorts.clear()
}
// Same two deprecations MidiInput suppresses the same way: getDevices and the
// Handler overload of registerDeviceCallback are still the only ones that list
// and watch every transport below API 33.
@Suppress("DEPRECATION")
private fun allDevices(mm: MidiManager): List<MidiDeviceInfo> = mm.devices.toList()
@Suppress("DEPRECATION")
private fun registerCallback(mm: MidiManager, cb: MidiManager.DeviceCallback) =
mm.registerDeviceCallback(cb, handler)
private fun openDevice(info: MidiDeviceInfo) {
if (info.inputPortCount == 0) return // need a port we can send TO
midiManager?.openDevice(info, { device ->
@@ -4,6 +4,7 @@
package cc.tiredsysadmin.android.sizzle.io
import cc.tiredsysadmin.android.sizzle.model.Cell
import cc.tiredsysadmin.android.sizzle.model.LoopRegion
import cc.tiredsysadmin.android.sizzle.model.Mixer
import cc.tiredsysadmin.android.sizzle.model.Pattern
import cc.tiredsysadmin.android.sizzle.model.Project
@@ -27,58 +28,100 @@ import cc.tiredsysadmin.android.sizzle.model.ToolboxType
object ProjectIo {
private const val HEADER = "SIZZLETRACKER-SNG 1"
/** Room for a typical song, so [save]'s buffer never has to grow and copy. */
private const val INITIAL_CAPACITY = 32 * 1024
// ------------------------------------------------------------------- write
fun save(project: Project): String = buildString {
appendLine(HEADER)
appendLine("NAME=${project.name}")
appendLine("TEMPO=${project.tempoBpm}")
appendLine("SIG=${project.timeSignature.name}")
appendLine("SCALE=${project.scale.name}")
appendLine("ROOT=${project.rootNote}")
appendLine("ACTIVE=${project.activePatternId}")
/**
* The whole project as `.sng` text.
*
* This is the hot path of the UI → engine bridge, not just the file writer:
* `AudioEngine.syncNow` calls it after every edit and the engine diffs the text
* (see DEVELOPER_HANDOVER.md §5.4.2). So it builds into one pre-sized buffer and
* appends numbers straight into it instead of formatting a String per line —
* byte for byte the same output, a fraction of the garbage.
*/
fun save(project: Project): String {
val sb = StringBuilder(INITIAL_CAPACITY)
sb.append(HEADER).append('\n')
sb.append("NAME=").append(project.name).append('\n')
sb.append("TEMPO=").append(project.tempoBpm).append('\n')
sb.append("SIG=").append(project.timeSignature.name).append('\n')
sb.append("SCALE=").append(project.scale.name).append('\n')
sb.append("ROOT=").append(project.rootNote).append('\n')
sb.append("ACTIVE=").append(project.activePatternId).append('\n')
project.patterns.forEach { p ->
appendLine("[PATTERN id=${p.id} name=${encodeName(p.name)} len=${p.length}]")
sb.append("[PATTERN id=").append(p.id).append(" name=").append(encodeName(p.name))
.append(" len=").append(p.length).append("]\n")
for (t in 0 until Pattern.TRACK_COUNT) {
val col = p.tracks[t]
for (line in 0 until p.length) {
val cell = p.cell(t, line)
if (!cell.isEmpty) appendLine("$t,$line,${cell.note},${cell.velocity},${cell.channel}")
val cell = col[line]
if (cell.isEmpty) continue
sb.append(t).append(',').append(line).append(',').append(cell.note)
.append(',').append(cell.velocity).append(',').append(cell.channel).append('\n')
}
}
}
val arr = project.arrangement
val mutes = arr.laneMuted.joinToString("") { if (it) "1" else "0" }
appendLine("[ARRANGEMENT bars=${arr.lengthBars} loop=${arr.loopEnabled.b()} mutes=$mutes]")
sb.append("[ARRANGEMENT bars=").append(arr.lengthBars)
.append(" loop=").append(if (arr.loopEnabled) '1' else '0').append(" mutes=")
for (muted in arr.laneMuted) sb.append(if (muted) '1' else '0')
sb.append("]\n")
val usedBeats = arr.lastFilledBeat() + 1
for (lane in arr.slots.indices) {
val row = arr.slots[lane]
for (beat in 0 until usedBeats) {
val pid = arr.slots[lane][beat]
val pid = row[beat]
// >= 0 is a block id; NOTE_OFF is a marker and must survive too.
// Anything else is EMPTY and is simply omitted.
if (pid >= 0 || pid == cc.tiredsysadmin.android.sizzle.model.Arrangement.NOTE_OFF) appendLine("$lane,$beat,$pid")
if (pid < 0 && pid != cc.tiredsysadmin.android.sizzle.model.Arrangement.NOTE_OFF) continue
sb.append(lane).append(',').append(beat).append(',').append(pid).append('\n')
}
}
appendLine("[REGION A en=${arr.regionA.enabled.b()} s=${arr.regionA.start} e=${arr.regionA.end} r=${arr.regionA.repeats}]")
appendLine("[REGION B en=${arr.regionB.enabled.b()} s=${arr.regionB.start} e=${arr.regionB.end} r=${arr.regionB.repeats}]")
return sb.appendTail(project).toString()
}
appendLine("[MIXER]")
/** The rest of [save]: regions, mixer, toolbox. Split out only to keep each half
* readable; the two together produce one buffer. */
private fun StringBuilder.appendTail(project: Project): StringBuilder = apply {
val arr = project.arrangement
appendRegion('A', arr.regionA)
appendRegion('B', arr.regionB)
append("[MIXER]\n")
project.mixer.channels.forEach { ch ->
appendLine(
"${ch.index},${ch.instrumentSlot},${ch.fxSlots.joinToString(",")}," +
"${ch.midiChannel},${ch.volume},${ch.mute.b()},${ch.solo.b()},${ch.limiter.b()}",
)
append(ch.index).append(',').append(ch.instrumentSlot)
for (fx in ch.fxSlots) append(',').append(fx)
append(',').append(ch.midiChannel).append(',').append(ch.volume)
.append(',').append(if (ch.mute) '1' else '0')
.append(',').append(if (ch.solo) '1' else '0')
.append(',').append(if (ch.limiter) '1' else '0').append('\n')
}
appendLine("[TOOLBOX]")
append("[TOOLBOX]\n")
project.toolbox.forEach { slot ->
if (!slot.isEmpty) {
val params = slot.values.entries.joinToString(",") { "${it.key}=${it.value}" }
appendLine("${slot.index}=${slot.type!!.name};${slot.name};$params")
if (slot.isEmpty) return@forEach
append(slot.index).append('=').append(slot.type!!.name).append(';').append(slot.name).append(';')
var first = true
for ((k, v) in slot.values) {
if (!first) append(',')
first = false
append(k).append('=').append(v)
}
append('\n')
}
}
private fun StringBuilder.appendRegion(id: Char, r: LoopRegion) {
append("[REGION ").append(id)
.append(" en=").append(if (r.enabled) '1' else '0')
.append(" s=").append(r.start).append(" e=").append(r.end)
.append(" r=").append(r.repeats).append("]\n")
}
// -------------------------------------------------------------------- read
/**
* Parse [text] into the *existing* [project], replacing its contents. Used to
@@ -153,8 +196,6 @@ object ProjectIo {
}
// ----- small helpers -----
private fun Boolean.b() = if (this) "1" else "0"
private fun parseAttrs(line: String): Map<String, String> =
line.trim('[', ']').substringAfter(' ', "").split(' ')
.mapNotNull { tok -> tok.split('=', limit = 2).takeIf { it.size == 2 }?.let { it[0] to it[1] } }
@@ -195,7 +236,7 @@ object ProjectIo {
p.arrangement.set(lane, beat, pid)
}
private fun applyRegion(region: cc.tiredsysadmin.android.sizzle.model.LoopRegion, a: Map<String, String>) {
private fun applyRegion(region: LoopRegion, a: Map<String, String>) {
region.enabled = a["en"] == "1"
region.start = a["s"]?.toIntOrNull() ?: 0
region.end = a["e"]?.toIntOrNull() ?: 0
@@ -49,7 +49,7 @@ enum class ToolboxType(
// ---------- Instruments ----------
// A classic 3-oscillator subtractive synth (Minimoog-style): oscillators →
// mixer → resonant filter (own contour) → amp (own envelope), with a tempo-synced
// LFO and a small mod matrix. Rendered by [SynthVoice]; edited by NesSynthEditor.
// LFO and a small mod matrix. Rendered by core/src/synth/SynthVoice; edited by NesSynthEditor.
// NOTE: the enum name NES_SYNTH is the on-disk/serialized identifier (preset dirs,
// .sng type) and must stay stable for backward compatibility; only the user-facing
// displayName is generic.
@@ -124,17 +124,17 @@ enum class ToolboxType(
// FRASIL's drone voice (MPL-2.0, see the frasil package): three layers (a detuned
// saw choir, drifting additive partials, noise through resonators) that evolve
// while held, morphing toward one of FRASIL's 36 drone sounds. Rendered by
// FrasilVoice inside SynthVoice; edited by the paged editor in ToolboxScreen.
// core/src/frasil/FrasilVoice inside SynthVoice; edited by the paged editor in ToolboxScreen.
MORPH_PAD(ToolboxKind.INSTRUMENT, "Morph Pad", FrasilDefs.PARAMS),
// ECHOFIELD's granular engine (MIT, see the echofield package): one cloud of up to
// 32 grains per mixer channel, read from a built-in source (audio/GrainSources)
// or your own sample ("sfSample", as the SF2/XI loader keeps it); held notes pitch
// the grains. Rendered by GrainCloud in AudioEngine; edited by GrainCloudEditor.
// the grains. Rendered by core/src/echofield/GrainCloud; edited by GrainCloudEditor.
GRAIN_CLOUD(ToolboxKind.INSTRUMENT, "Grain Cloud", EchofieldDefs.PARAMS),
// A two-oscillator wavetable synth (Sizzle's own, see the wavetable package): 12
// generated tables or an imported Serum / WaveEdit WAV ("sfSample"), band-limited
// per octave, position swept by an envelope and LFO, unison, SVF filter. Rendered
// by WaveVoice inside SynthVoice; edited by WavetableEditor + the paged list.
// by core/src/wavetable/WaveVoice inside SynthVoice; edited by WavetableEditor + the paged list.
WAVETABLE(ToolboxKind.INSTRUMENT, "Wavetable", WaveDefs.PARAMS),
// ---------- Effects ----------
@@ -221,7 +221,7 @@ enum class ToolboxType(
ToolboxKind.EFFECT, "Ambience Reverb",
// A mono port of the Ambience 16-channel FDN reverb (OTODESK): 7 algorithms,
// tempo-independent tunables and 21 factory spaces (seeded into the preset
// library). Rendered by audio/AmbienceReverb.kt.
// library). Rendered by core/src/fx/AmbienceReverb.cpp.
listOf(
ParamSpec("algo", "Algorithm", 0f, 0f, 6f, AmbiencePresets.ALGORITHMS),
ParamSpec("predelay", "Pre-Delay", 10f, 0f, 500f),
@@ -249,7 +249,7 @@ enum class ToolboxType(
// morphs the whole chain from transparent (0) to the full preset (1). Every
// per-band value is a hidden slot param set by the genre/instrument presets
// (see MixTightenerPresets); only Strength is user-facing. Rendered by
// MixTightener in Effects.kt, edited by ui/toolbox/MixTightenerEditor.
// core/src/fx/MixTightener.cpp, edited by ui/toolbox/MixTightenerEditor.
listOf(ParamSpec("strength", "Strength", 1f, 0f, 1f)),
),
TAPE_ENGINE(
@@ -258,7 +258,7 @@ enum class ToolboxType(
// the pitch dives like a slowing tape (the 'speed' param is driven by that reel
// gesture, not a slider). wow/flutter add slow + fast pitch wobble, hiss adds
// tape noise, and the wow wobble rate is tempo-synced via 'division'. Rendered
// by TapeEngine in Effects.kt, edited by ui/toolbox/TapeEngineEditor.
// by core/src/fx/TapeEngine.cpp, edited by ui/toolbox/TapeEngineEditor.
listOf(
ParamSpec("speed", "Speed", 1f, 0.25f, 1f),
ParamSpec("wow", "Wow", 0.15f, 0f, 1f),
@@ -272,7 +272,7 @@ enum class ToolboxType(
// Stutters/repeats short grains read from a rolling buffer of the incoming
// sound; the read head jumps around, and the editor draws it as a moving
// playhead over a dotted scope of the signal. One control: Intensity (how often
// it glitches + how mangled). Rendered by GranularGlitch in Effects.kt, edited
// it glitches + how mangled). Rendered by core/src/fx/GranularGlitch.cpp, edited
// by ui/toolbox/GranularEditor.
listOf(ParamSpec("intensity", "Intensity", 0.3f, 0f, 1f)),
);
@@ -156,9 +156,6 @@ class AppViewModel(
* notification's Stop action changes it with no UI around. */
val soundModuleMode: StateFlow<Boolean> get() = sizzleApp.soundModuleEnabled
/** MIDI sources currently open (USB, Bluetooth, other apps' virtual ports). */
val midiSources: StateFlow<Int> get() = sizzleApp.soundModule.sources
fun updateSoundModuleMode(enabled: Boolean) = sizzleApp.setSoundModuleEnabled(enabled)
/** Every MIDI source that can send to Sizzle, with whether it is listened to. */
@@ -23,7 +23,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material.icons.filled.Piano
import androidx.compose.material.icons.filled.ContentCopy
@@ -170,7 +170,7 @@ fun SettingsScreen(vm: AppViewModel) {
@Composable
private fun SubHeader(title: String, onBack: () -> Unit) {
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
IconButton(onClick = onBack) { Icon(Icons.Filled.ArrowBack, contentDescription = "Back") }
IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back") }
Text(title, style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.primary)
}
}
@@ -16,6 +16,7 @@ import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -58,6 +59,12 @@ fun GrainCloudEditor(vm: AppViewModel, slot: ToolboxSlot) {
}
}
// Same as the wavetables: the ten built-in sources are synthesised, the engine
// renders its own set in core/, and this Kotlin copy exists only to draw the
// waveform below. Built when the editor opens rather than at launch — that is
// about 6 MB of PCM an app that never opens one no longer renders or holds.
LaunchedEffect(Unit) { GrainSources.prewarm() }
val sourceName = slot.string("source", EchofieldDefs.SOURCES[0])
val custom = sourceName == EchofieldDefs.CUSTOM
val sample = if (custom) SampleStore.get(slot.string(EchofieldDefs.SAMPLE_KEY)) else GrainSources.get(sourceName)
@@ -228,7 +228,7 @@ private fun roundedPoly(v: Array<Offset>, corner: Float): Path {
val a = curr + toward(curr, prev, corner) // approach point on the incoming edge
val b = curr + toward(curr, next, corner) // leave point on the outgoing edge
if (i == 0) path.moveTo(a.x, a.y) else path.lineTo(a.x, a.y)
path.quadraticBezierTo(curr.x, curr.y, b.x, b.y)
path.quadraticTo(curr.x, curr.y, b.x, b.y)
}
path.close()
return path
@@ -17,6 +17,7 @@ import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -45,6 +46,12 @@ import cc.tiredsysadmin.android.sizzle.wavetable.WaveTables
/** Every frame of oscillator [osc]'s table stacked back to front, the one at its POSITION lit. */
@Composable
fun WavetablePreview(slot: ToolboxSlot, osc: Int, tone: Color, rev: Int) {
// The factory tables are formulas, built on a worker, and only this drawing needs
// the Kotlin copy — the engine builds its own in core/. So they are built when a
// Wavetable editor is first opened, not at launch: an app that never shows one
// pays nothing. Idempotent and non-blocking; `factory` returns null until ready
// and the caption says "preparing…".
LaunchedEffect(Unit) { WaveTables.prewarm() }
val c = LocalRetro.current
val name = slot.string("o${osc}table", WaveDefs.TABLES[0])
val frame = slot.string("wtframe", WaveDefs.FRAME_SIZES[0]).toIntOrNull() ?: 0
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/fx/AmbienceReverb.cpp.
package cc.tiredsysadmin.android.sizzle.audio
import cc.tiredsysadmin.android.sizzle.model.AmbiencePresets
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/fx/.
package cc.tiredsysadmin.android.sizzle.audio
import cc.tiredsysadmin.android.sizzle.model.DelayDivisions
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/host/MasterRecorder.cpp.
package cc.tiredsysadmin.android.sizzle.audio
import java.io.File
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/sampler/SampleVoice.cpp.
package cc.tiredsysadmin.android.sizzle.audio
import kotlin.math.exp
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/synth/SynthPatch.cpp.
package cc.tiredsysadmin.android.sizzle.audio
import cc.tiredsysadmin.android.sizzle.frasil.FrasilPatch
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/synth/SynthVoice.cpp.
package cc.tiredsysadmin.android.sizzle.audio
import cc.tiredsysadmin.android.sizzle.frasil.FrasilVoice
@@ -80,7 +86,6 @@ class SynthVoice(private val sampleRate: Int) {
private val pad = FrasilVoice(sampleRate)
private val wave = WaveVoice(sampleRate)
private var mode = MODE_SYNTH
private val padMode get() = mode == MODE_PAD
val isActive: Boolean get() = when (mode) { MODE_PAD -> pad.isActive; MODE_WAVE -> wave.isActive; else -> ampEnv.active }
/** Gate is still open (attack/decay/sustain) — the note is *held*. A voice in its
@@ -7,6 +7,12 @@
// spawn, render_grains_part, schedule, ef_render's gate and source fade, auto_level).
// The MIT licence text is in LICENSES/MIT.txt of this repository.
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/echofield/GrainCloud.cpp.
package cc.tiredsysadmin.android.sizzle.echofield
import cc.tiredsysadmin.android.sizzle.audio.GrainSources
@@ -6,6 +6,12 @@
// If a copy of the MPL was not distributed with this file, You can obtain one at
// https://mozilla.org/MPL/2.0/ (also in LICENSES/MPL-2.0.txt of this repository).
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/frasil/FrasilVoice.cpp.
package cc.tiredsysadmin.android.sizzle.frasil
import cc.tiredsysadmin.android.sizzle.model.ToolboxSlot
@@ -11,6 +11,12 @@
// ch_svf, ch_lp, blepi, partial_ramp, partials_chunk, souffle_chunk, breath_noise,
// render_part) and the mix's DC blocker, warmth and FULLNESS high-pass.
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/frasil/FrasilVoice.cpp.
package cc.tiredsysadmin.android.sizzle.frasil
import cc.tiredsysadmin.android.sizzle.frasil.FrasilDefs.AIR
@@ -1,6 +1,12 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Kotlin reference the C++ port in core/ is checked against (handover §5.4.2):
// the IosGolden* tests render it, and `make -C ios core-test` compares the C++ with
// that audio sample by sample. It lives in the TEST source set because both apps
// play core/ — in src/main it would only be dead code in the APK. Keep it in step
// with core/src/wavetable/WaveVoice.cpp.
package cc.tiredsysadmin.android.sizzle.wavetable
import cc.tiredsysadmin.android.sizzle.model.TimeDivision