0.41.2 (78): 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:
co-authored by
Claude Opus 5
parent
634dd05486
commit
ba98ec56f4
@@ -5,6 +5,39 @@ version in `versions.properties`; versions before 0.28.0 are described in the gi
|
||||
log (one commit per version). Since 0.37.0 Android and iOS share one version and
|
||||
one feature set; the iOS side of each version is in `ios/CHANGELOG.md`.
|
||||
|
||||
## 0.41.2 (versionCode 78)
|
||||
|
||||
Housekeeping and speed; nothing you can see changes, except that the app is
|
||||
half the size and lighter on the battery.
|
||||
|
||||
- **The APK is half as big** — 21.5 MB → 10.1 MB. Release builds now go through
|
||||
R8 (shrink, optimise, obfuscate, and drop unused resources), which throws away
|
||||
the Compose and Material icon code the app never calls. Only the two JNI
|
||||
classes are pinned by name (`app/proguard-rules.pro`), because the native
|
||||
library looks them up at runtime; `make dist` keeps the de-obfuscation map next
|
||||
to the APK so a crash report from a published build can still be read.
|
||||
- **Less battery while a song is stopped.** The thread that feeds the transport
|
||||
display polled the engine 100 times a second whatever was happening; it now
|
||||
does that only while the song plays or a recording is armed, and waits 100 ms a
|
||||
turn otherwise. Pressing Play still moves the playhead in the same frame — a
|
||||
transport call wakes it. iOS does the same (30 Hz playing, 10 Hz stopped).
|
||||
- **Smoother editing.** Every edit hands the engine the whole song as text. That
|
||||
text is now built in one pre-sized pass instead of a string per line, and a
|
||||
burst of edits — dragging a note column, sweeping a knob — is collected into
|
||||
one sync instead of one per touch event.
|
||||
- **The mixer costs less per sample.** Channel volume, mute/solo and the effect
|
||||
chain are read once per audio block rather than once per frame, in the shared
|
||||
C++ engine (so iOS gets it too). Bit-for-bit the same audio: all 61 reference
|
||||
scenarios still match the Kotlin DSP.
|
||||
- **Dead code gone.** The Kotlin DSP that `core/` replaced in 0.37.0 was still
|
||||
compiled into every APK although nothing called it; it has moved to the test
|
||||
source set, where it belongs as the reference the C++ is checked against. The
|
||||
golden tests' `TestVoice` wrappers left the shared engine's sources for the
|
||||
same reason, and a handful of unused declarations are gone.
|
||||
- Fix: `make lint` failed on a manifest that asked for `ACCESS_FINE_LOCATION`
|
||||
without `ACCESS_COARSE_LOCATION` (the BLE MIDI scan on Android 8–11). Both are
|
||||
declared and both are requested now, so `make check` passes again.
|
||||
|
||||
## 0.41.1 (versionCode 77)
|
||||
|
||||
- No Android change: an iOS redraw fix (see `ios/CHANGELOG.md`).
|
||||
|
||||
@@ -35,6 +35,10 @@ FDROID_METADATA := /var/lib/fdroid/metadata
|
||||
# directory expects; app/build.gradle.kts stamps the same name onto the output.
|
||||
APK_NAME := $(APP_ID)_$(VERSION_CODE).apk
|
||||
RELEASE_APK := app/build/outputs/apk/release/$(APK_NAME)
|
||||
# R8 renames the release build, so a crash report from it is unreadable without
|
||||
# this. It is staged beside the APK and kept locally — never published.
|
||||
RELEASE_MAP := app/build/outputs/mapping/release/mapping.txt
|
||||
DIST_MAP := dist/$(APP_ID)_$(VERSION_CODE)-mapping.txt
|
||||
STAGING_APK := app/build/outputs/apk/staging/app-staging.apk
|
||||
METADATA_YML := dist/$(APP_ID).yml
|
||||
|
||||
@@ -110,12 +114,18 @@ launch:
|
||||
# ------------------------------------------------------------------ dist
|
||||
# Everything a publish needs, staged locally first so it can be inspected
|
||||
# before anything leaves the machine.
|
||||
dist: dist/$(APK_NAME) $(METADATA_YML)
|
||||
dist: dist/$(APK_NAME) $(DIST_MAP) $(METADATA_YML)
|
||||
|
||||
dist/$(APK_NAME): $(RELEASE_APK)
|
||||
@mkdir -p dist
|
||||
cp $(RELEASE_APK) $@
|
||||
|
||||
# The de-obfuscation map for this exact versionCode. `publish` does not upload it;
|
||||
# it stays here so a stack trace from the published APK can still be read.
|
||||
$(DIST_MAP): $(RELEASE_APK)
|
||||
@mkdir -p dist
|
||||
cp $(RELEASE_MAP) $@
|
||||
|
||||
# F-Droid metadata. Regenerated from versions.properties on every dist so the
|
||||
# CurrentVersion lines can never lag the APK next to them.
|
||||
$(METADATA_YML): $(VERSIONS) Makefile
|
||||
@@ -153,6 +163,7 @@ publish-metadata: $(METADATA_YML)
|
||||
|
||||
publish: publish-apk publish-metadata
|
||||
@echo "published $(APP_ID) $(VERSION_NAME) ($(VERSION_CODE)); sign it on the repo host"
|
||||
@echo "keep $(DIST_MAP) — it is the only way to read a crash from this build"
|
||||
|
||||
# ------------------------------------------------------------------ versioning
|
||||
# versionCode always moves by exactly 1: F-Droid and the package manager order
|
||||
|
||||
+10
-5
@@ -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
|
||||
|
||||
Vendored
+19
-3
@@ -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
|
||||
|
||||
@@ -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,56 +28,98 @@ 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
|
||||
@@ -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
|
||||
|
||||
+6
@@ -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
|
||||
+6
@@ -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
|
||||
+6
@@ -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
|
||||
+6
@@ -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
|
||||
+6
@@ -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
|
||||
+6
-1
@@ -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
|
||||
+6
@@ -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 +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
|
||||
+6
@@ -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
|
||||
+6
@@ -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
|
||||
@@ -19,7 +19,6 @@ public:
|
||||
bool resetOnBar = false;
|
||||
int genStamp = -1;
|
||||
|
||||
int noteCount() const { return noteCount_; }
|
||||
/** Active while it holds at least one note. */
|
||||
bool active() const { return noteCount_ > 0; }
|
||||
|
||||
|
||||
@@ -605,6 +605,24 @@ void Engine::Impl::fillBlock(float *out, int frames) {
|
||||
auditionCloudActive = auditionCloud->isActive();
|
||||
for (int i = 0; i < (int)auditionSampleVoices.size(); ++i) if (auditionSampleVoices[i]->isActive()) actASmp[actASmpN++] = i;
|
||||
|
||||
// Per-channel mixer state is read once per block, not once per sample: mute,
|
||||
// solo and volume cannot change inside a block (the UI's edits land through
|
||||
// syncProjectText between blocks), so this is the same audio with 4 loads and
|
||||
// 4 branches lifted out of a 48 000-iteration loop. The FX chain pointers come
|
||||
// out too, so the per-sample inner loop walks a plain pointer range.
|
||||
float chGain[TRACK_COUNT] = {0.f, 0.f, 0.f, 0.f};
|
||||
bool chLimit[TRACK_COUNT] = {false, false, false, false};
|
||||
FxUnit *chFxBegin[TRACK_COUNT] = {nullptr, nullptr, nullptr, nullptr};
|
||||
FxUnit *chFxEnd[TRACK_COUNT] = {nullptr, nullptr, nullptr, nullptr};
|
||||
if (proj) {
|
||||
for (int ch = 0; ch < TRACK_COUNT; ++ch) {
|
||||
const auto &mc = proj->mixer.channels[ch];
|
||||
chGain[ch] = mc.audible(anySolo) ? mc.volume : 0.f;
|
||||
chLimit[ch] = mc.limiter;
|
||||
chFxBegin[ch] = chains->ch[ch].data();
|
||||
chFxEnd[ch] = chFxBegin[ch] + chains->ch[ch].size();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < frames; ++i) {
|
||||
if (playing.load(std::memory_order_relaxed) && proj) advanceSequencer(*proj);
|
||||
|
||||
@@ -618,11 +636,10 @@ void Engine::Impl::fillBlock(float *out, int frames) {
|
||||
for (int k = 0; k < actBSmpN; ++k) { const int vi = actBSmp[k]; channelSum[vi / BUS_POLYPHONY] += busSampleVoices[vi]->render(); }
|
||||
for (int ch = 0; ch < TRACK_COUNT; ++ch) if (cloudOn[ch]) channelSum[ch] += clouds[ch]->render();
|
||||
for (int ch = 0; ch < TRACK_COUNT; ++ch) {
|
||||
const auto &mc = proj->mixer.channels[ch];
|
||||
float s = mc.audible(anySolo) ? channelSum[ch] * mc.volume : 0.f;
|
||||
for (FxUnit &u : chains->ch[ch]) s = u.effect->process(s);
|
||||
float s = channelSum[ch] * chGain[ch];
|
||||
for (FxUnit *u = chFxBegin[ch]; u != chFxEnd[ch]; ++u) s = u->effect->process(s);
|
||||
if (!std::isfinite(s)) s = 0.f;
|
||||
if (mc.limiter) s = softClip(s);
|
||||
if (chLimit[ch]) s = softClip(s);
|
||||
const float a = s < 0.f ? -s : s;
|
||||
if (a > chBlockPeak[ch]) chBlockPeak[ch] = a;
|
||||
mixL += s; mixR += s;
|
||||
@@ -636,6 +653,8 @@ void Engine::Impl::fillBlock(float *out, int frames) {
|
||||
const float oR = limOutR;
|
||||
out[2 * i] = oL;
|
||||
out[2 * i + 1] = oR;
|
||||
// Checked per sample, not hoisted: recordSample itself clears recCapturing
|
||||
// when a take's FX tail runs out, and must not be called again after that.
|
||||
if (recCapturing.load(std::memory_order_relaxed) && sink) recordSample(proj, oL, oR);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ public:
|
||||
void kill();
|
||||
/** Follow edits while sounding: the values glide there over ~25 ms. */
|
||||
void setPatch(const FrasilPatch &p) { patch = p; }
|
||||
/** A gliding engine value now (a defs index), for tests. */
|
||||
float valueForTest(int i) const { return cur[i]; }
|
||||
float render();
|
||||
|
||||
private:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "voices/TestVoice.hpp"
|
||||
#include "wavetable/WaveTables.hpp"
|
||||
|
||||
using namespace sizzle;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include "frasil/FrasilVoice.hpp"
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "TestVoice.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include "GrainCloud.hpp"
|
||||
#include "GrainSources.hpp"
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "echofield/GrainCloud.hpp"
|
||||
#include "echofield/GrainSources.hpp"
|
||||
#include "TestVoice.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "SampleStore.hpp"
|
||||
#include "SampleVoice.hpp"
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "sampler/SampleStore.hpp"
|
||||
#include "sampler/SampleVoice.hpp"
|
||||
#include "TestVoice.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include "frasil/FrasilVoice.hpp"
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "TestVoice.hpp"
|
||||
#include "synth/SynthVoice.hpp"
|
||||
#include "wavetable/WaveTables.hpp"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// definition replaces its placeholder at link time.
|
||||
|
||||
#include <cstring>
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "TestVoice.hpp"
|
||||
|
||||
#define SIZZLE_TEST_MAKER(fn) \
|
||||
__attribute__((weak)) std::unique_ptr<TestVoice> fn(const TestVoiceSetup &) { return nullptr; }
|
||||
@@ -5,9 +5,9 @@
|
||||
// WaveVoice alone, patch from the slot, factory tables built up front.
|
||||
|
||||
#include <memory>
|
||||
#include "sizzle/TestVoice.hpp"
|
||||
#include "WaveTables.hpp"
|
||||
#include "WaveVoice.hpp"
|
||||
#include "TestVoice.hpp"
|
||||
#include "wavetable/WaveTables.hpp"
|
||||
#include "wavetable/WaveVoice.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
+94
-53
@@ -41,7 +41,7 @@ in exactly what it needs and nothing else:
|
||||
| `make staging` | non-debuggable build, release-like performance, debug key |
|
||||
| `make install` | `adb install -r` of the staging APK (keeps projects/presets) |
|
||||
| `make release` | **unsigned** release APK, named for F-Droid |
|
||||
| `make dist` | stages the release APK + F-Droid metadata under `dist/` |
|
||||
| `make dist` | stages the release APK + its R8 mapping + F-Droid metadata under `dist/` |
|
||||
| `make publish` | uploads `dist/` to the private F-Droid repo — **manual only** |
|
||||
| `make bump-minor` | feature bump: `x.(y+1).0`, versionCode +1 |
|
||||
|
||||
@@ -98,11 +98,11 @@ the numbers by hand is how they drift apart.
|
||||
|
||||
### 2.3 Build types
|
||||
|
||||
| Type | Debuggable | Signing | Use |
|
||||
|------|-----------|---------|-----|
|
||||
| `debug` | yes | debug key | breakpoints, instant-run edits |
|
||||
| `staging` | **no** | debug key | anything on a real device |
|
||||
| `release` | no | **unsigned** | publishing only |
|
||||
| Type | Debuggable | R8 | Signing | Use |
|
||||
|------|-----------|----|---------|-----|
|
||||
| `debug` | yes | no | debug key | breakpoints, instant-run edits |
|
||||
| `staging` | **no** | no | debug key | anything on a real device |
|
||||
| `release` | no | **yes** | **unsigned** | publishing only |
|
||||
|
||||
`staging` exists because `debug` is misleading: a debuggable build makes ART run
|
||||
the app un-optimised and Compose several times slower, so UI "snappiness"
|
||||
@@ -114,6 +114,22 @@ installs without a release keystore. **Use `staging` for every on-device test.**
|
||||
the private F-Droid repo; `fdroid publish` signs what lands in the unsigned
|
||||
directory. No keystore should ever exist in this checkout.
|
||||
|
||||
`release` is also the only build R8 touches (shrink + optimise + obfuscate, plus
|
||||
unused-resource removal). The app reflects over nothing of its own — songs,
|
||||
presets, themes and bindings are all hand-written text parsers — so
|
||||
`app/proguard-rules.pro` keeps exactly one thing: **native method names**. JNI
|
||||
resolves `Java_cc_tiredsysadmin_android_sizzle_audio_NativeEngine_*` by name at
|
||||
runtime, so a renamed class or method is an `UnsatisfiedLinkError` on first play,
|
||||
not a build error. Everything else (Compose, media3, DataStore, coroutines) ships
|
||||
its own consumer rules inside its AAR.
|
||||
|
||||
A release stack trace is therefore obfuscated. `make dist` copies
|
||||
`app/build/outputs/mapping/release/mapping.txt` to
|
||||
`dist/<application_id>_<versionCode>-mapping.txt`; keep it for every published
|
||||
APK, because it is the only way to read a crash from that build. It is never
|
||||
uploaded. `staging` keeps R8 off on purpose: it exists to measure the UI, and a
|
||||
readable stack trace is worth more there than the last few hundred KB.
|
||||
|
||||
### 2.4 Publishing
|
||||
|
||||
Publishing is **always a manual action, never automatic** — it is not a side
|
||||
@@ -214,35 +230,28 @@ cc.tiredsysadmin.android.sizzle
|
||||
│ ├── MidiTrace.kt Optional receive/engine trace (setprop log.tag.SizzleMidiTrace VERBOSE)
|
||||
│ └── MidiInput.kt Lists/opens MIDI sources (USB, BLE, other apps' virtual ports), reconnects dead ones -> MidiSoundModule / CC bindings
|
||||
│
|
||||
├── audio/ The real-time sound engine (own thread)
|
||||
├── audio/ The engine's face (the DSP itself is core/, in C++)
|
||||
│ ├── AudioEngine.kt Drives core/ through NativeEngine: transport, sync, meters, recording
|
||||
│ ├── NativeEngine.kt JNI to core/src/host/EngineHost (src/main/cpp/jni_engine.cpp)
|
||||
│ ├── NativeAudioBridge.kt Starts/stops the Oboe stream (which renders in C++, no JVM call)
|
||||
│ ├── Transport.kt TransportState snapshot published to the UI
|
||||
│ ├── SynthVoice.kt One synth note (3-osc subtractive), or a Morph Pad / Wavetable note (FrasilVoice / WaveVoice)
|
||||
│ ├── GrainSources.kt The Grain Cloud's ten built-in sources, synthesised in the background
|
||||
│ ├── SampleVoice.kt Pitched + sliced playback of a decoded sample
|
||||
│ ├── SampleStore.kt Process-wide decoded-PCM cache + WAV encode/decode
|
||||
│ ├── SampleStore.kt Process-wide decoded-PCM cache + WAV encode/decode (mirrored into core/)
|
||||
│ ├── SampleRecorder.kt Ad-hoc mic/USB capture into a sample
|
||||
│ ├── SoundFontLoader.kt Extract PCM from an .sf2 / .xi into the SampleStore
|
||||
│ ├── Effects.kt Insert DSP: TapeDelay, Filter, Bitcrusher, GraphicEq (+ AudioEffect API)
|
||||
│ ├── AmbienceReverb.kt FDN reverb processor
|
||||
│ ├── MasterRecorder.kt Renders the master bus (with FX tail) to a WAV
|
||||
│ ├── NativeAudioBridge.kt JNI bridge to the Oboe callback (calls fillBlock)
|
||||
│ └── AudioEngine.kt Oboe/AudioTrack + sample-accurate sequencer + voice/FX mixing
|
||||
│ └── GrainSources.kt The Grain Cloud's ten built-in sources (the UI draws their peaks)
|
||||
│
|
||||
├── frasil/ MPL-2.0 (not GPL): the Morph Pad, ported from FRASIL (see §5.7)
|
||||
│ ├── FrasilDefs.kt Its settings, engine-unit mapping, the 36 drone presets
|
||||
│ ├── FrasilPatch.kt Parsed slot snapshot (+ morph target); FrasilClock (the shared TIDE time)
|
||||
│ └── FrasilVoice.kt One pad note: choir + partials + breath, drift, tide, warmth
|
||||
│ └── FrasilDefs.kt Its settings, engine-unit mapping, the 36 drone presets
|
||||
│
|
||||
├── wavetable/ The Wavetable synth (Sizzle's own, GPL; see §5.9)
|
||||
│ ├── WaveTables.kt Band-limited tables: FFT, one mip level per octave, 12 generated tables, WAV import
|
||||
│ ├── WaveDefs.kt Its settings, 12 factory presets
|
||||
│ └── WaveVoice.kt WavePatch + one note: 2 table oscillators, bend, unison, sub, SVF, 2 envelopes, LFO
|
||||
│ ├── WaveTables.kt Band-limited tables: FFT, one mip level per octave (the editor draws them)
|
||||
│ └── WaveDefs.kt Its settings, 12 factory presets
|
||||
│
|
||||
├── echofield/ MIT: the Grain Cloud, ported from ECHOFIELD (see §5.8)
|
||||
│ ├── EchofieldDefs.kt Its settings, 14 factory presets, the source list
|
||||
│ └── GrainCloud.kt GrainPatch + one channel's cloud: modes, scheduler, grains, gate, auto-level
|
||||
│ └── EchofieldDefs.kt Its settings, 14 factory presets, the source list
|
||||
│
|
||||
├── cpp/native_audio.cpp Low-latency Oboe stream; RT callback pulls audio via JNI
|
||||
├── cpp/native_audio.cpp Low-latency Oboe stream; its RT callback renders core/ directly
|
||||
├── cpp/jni_engine.cpp The JNI surface of core/src/host/EngineHost
|
||||
│
|
||||
├── io/ Human-readable text persistence
|
||||
│ ├── PresetIo.kt Instrument/effect preset <-> KEY=VALUE text
|
||||
@@ -409,11 +418,17 @@ playback continues. Samples go across as they enter `SampleStore` (`put` /
|
||||
`remove` mirror into the native store). Transport, meters, scope and finished
|
||||
recordings are polled from a 10 ms thread.
|
||||
|
||||
The Kotlin engine (`ReferenceEngine` and the voices and effects under `audio/`,
|
||||
`frasil/`, `echofield/`, `wavetable/`) is now only a reference: the
|
||||
`IosGolden*` unit tests render it so the C++ can be checked bit for bit
|
||||
(`make -C ios golden core-test`). The UI still uses a few of those Kotlin classes
|
||||
to draw (wavetable frames, Grain Cloud source peaks, sample decoding).
|
||||
The Kotlin engine is now only a reference, and lives in the **test** source set:
|
||||
`app/src/test/java/.../audio` (`ReferenceEngine`, `SynthVoice`, `SynthPatch`,
|
||||
`Effects`, `AmbienceReverb`, `SampleVoice`, `MasterRecorder`), `.../frasil`
|
||||
(`FrasilVoice`, `FrasilPatch`), `.../echofield` (`GrainCloud`) and
|
||||
`.../wavetable` (`WaveVoice`). The `IosGolden*` unit tests render it so the C++
|
||||
can be checked bit for bit (`make -C ios golden core-test`). It is **not** in
|
||||
`src/main`, because nothing in the app calls it any more — there it would only be
|
||||
dead code in every APK. What the UI genuinely still needs to *draw* did stay in
|
||||
`src/main`: `wavetable/WaveTables` (table frames), `audio/GrainSources` (source
|
||||
peaks), `audio/SampleStore` + `SoundFontLoader` (sample decoding), and the three
|
||||
`*Defs` files (parameter and preset data, shared with the editors).
|
||||
|
||||
**Parity rule:** every feature or fix lands in both apps in the same change, with
|
||||
one shared version bump. Engine and DSP work goes into `core/` only.
|
||||
@@ -429,7 +444,9 @@ ordinary device callback, so it is listed and played like USB gear. Connected
|
||||
addresses are remembered (`SettingsStore.bleMidiDevices`) and reopened by
|
||||
address at start, without a scan. Permissions: `BLUETOOTH_SCAN`
|
||||
(`neverForLocation`) + `BLUETOOTH_CONNECT` on Android 12+, `ACCESS_FINE_LOCATION`
|
||||
(and the legacy `BLUETOOTH` / `BLUETOOTH_ADMIN`) on 8-11, asked for when SCAN is
|
||||
with `ACCESS_COARSE_LOCATION` (the platform treats FINE as an upgrade of COARSE
|
||||
and refuses a FINE-only request; `make lint` enforces it) and the legacy
|
||||
`BLUETOOTH` / `BLUETOOTH_ADMIN` on 8-11, asked for when SCAN is
|
||||
first tapped. The emulator has no usable Bluetooth radio (its Bluetooth service
|
||||
crashes on a scan); test on a phone.
|
||||
|
||||
@@ -710,14 +727,20 @@ of real time on a desktop JVM.
|
||||
### Add a new instrument or effect
|
||||
1. Add an entry to `ToolboxType` (`model/Toolbox.kt`) with its `ParamSpec` list.
|
||||
2. Teach the engine how to sound it:
|
||||
It all happens in `core/` (C++), which is what both apps play — never in the
|
||||
Kotlin reference, which only follows so the golden comparison still holds:
|
||||
- **Instrument**: handle its type where the engine picks a voice per channel
|
||||
(see how `NES_SYNTH`, `SAMPLER`, and `SOUNDFONT` are dispatched in
|
||||
`AudioEngine`).
|
||||
- **Signal effect**: add a processor in `audio/Effects.kt` implementing
|
||||
`AudioEffect` and register it in `AudioEffect.create(...)`; the per-channel
|
||||
insert chain picks it up automatically.
|
||||
(see how `NES_SYNTH`, `SAMPLER` and `SOUNDFONT` are dispatched in
|
||||
`core/src/engine/Engine.cpp`).
|
||||
- **Signal effect**: add a processor under `core/src/fx/` implementing
|
||||
`sizzle::Effect` (`core/include/sizzle/Effect.hpp`) and register its maker in
|
||||
`core/src/fx/Registry.cpp`; the per-channel insert chain picks it up
|
||||
automatically, and so does the AUv3 wrapper once it is in `ios/app/components.txt`.
|
||||
- **MIDI effect** (arp/transpose/LFO-style): hook into the sequencer instead
|
||||
of the signal path (see `advanceArps` / `applyLfos` in `AudioEngine`).
|
||||
of the signal path (see `advanceArps` / `applyLfos` in `Engine.cpp`).
|
||||
- **Keep the reference in step**: mirror the change in the Kotlin file under
|
||||
`app/src/test/.../audio` (or `frasil` / `echofield` / `wavetable`), then
|
||||
`make -C ios golden core-test` to check the two sample for sample.
|
||||
The Toolbox picker, parameter editor, and preset save/load all work automatically
|
||||
from the `ParamSpec` list (the editor then shows one card with every parameter).
|
||||
3. Group its controls: add a case to `DeviceLayouts.pagesFor` (cards, tones,
|
||||
@@ -740,14 +763,25 @@ the Settings theme picker immediately.
|
||||
|
||||
## 7. Threading & performance notes
|
||||
|
||||
- The audio render loop is in `AudioEngine.renderLoop()` on a `MAX_PRIORITY`
|
||||
thread. It **must never allocate or block**. Keep it that way.
|
||||
- The audio render loop is `Engine::fillBlock` in `core/src/engine/Engine.cpp`,
|
||||
called from the Oboe real-time callback (`src/main/cpp/native_audio.cpp`) — all
|
||||
C++, with no JVM call on the audio thread, so no GC pause can glitch it. It
|
||||
**must never allocate, lock or block**. Keep it that way: the active-voice index
|
||||
lists are rebuilt once per block, per-channel mixer gains and FX-chain pointers
|
||||
are hoisted out of the per-sample loop, and `EngineHost` only ever *try*-locks.
|
||||
(`AudioEngine.startAudioTrack` keeps a Kotlin `MAX_PRIORITY` loop as the
|
||||
fallback when Oboe cannot start; it calls the same `nativeRender`.)
|
||||
- Timing is derived from *counting audio samples* (`samplesPerLine`), not from
|
||||
timers, so playback never drifts.
|
||||
- UI ⇄ audio sharing is lock-free by design (audio reads plain fields). This can
|
||||
produce a one-frame-stale read during a simultaneous edit — harmless for a
|
||||
tracker. If you ever add compound state that must be read atomically, publish it
|
||||
as an immutable snapshot (like `TransportState`) rather than adding locks.
|
||||
- UI ⇄ audio sharing crosses through text: `ProjectIo.save` plus
|
||||
`EngineHost::syncProjectText`, which diffs and copies only what changed (§5.4.2).
|
||||
`save` is therefore a hot path, not just the file writer — it builds into one
|
||||
pre-sized buffer, and `AudioEngine.requestSync` coalesces a burst of edits
|
||||
(a drag fires one per pointer event) into one sync per `SYNC_COALESCE_MS`.
|
||||
- The transport poller (`AudioEngine.start`) runs at 100 Hz only while the song
|
||||
plays or a take is armed; stopped and idle it waits 100 ms a turn, and any
|
||||
transport call wakes it through a semaphore so the playhead is never late.
|
||||
`AppModel.pollTransport` does the same on iOS (30 Hz playing, 10 Hz idle).
|
||||
- Block size is `BLOCK_FRAMES = 192` (~4 ms @ 48 kHz). Lower = tighter latency,
|
||||
higher = safer against underruns.
|
||||
- **UI rendering**: the pattern grid (`PatternGrid`) and arrangement roll
|
||||
@@ -856,11 +890,11 @@ polish and interchange niceties, not functional gaps.
|
||||
empty. Voices are a lane×track matrix so lanes layer polyphonically.
|
||||
- **Per-channel effect DSP** (milestone 3 ✓): each mixer channel runs an insert
|
||||
chain built from its FX slots — Tape Delay, Digital Reverb, Filter (LP/HP/BP),
|
||||
Bitcrusher, and 10-band EQ are real processors in `audio/Effects.kt`. Effect
|
||||
Bitcrusher, and 10-band EQ are real processors in `core/src/fx/`. Effect
|
||||
parameters update live per audio block; add/remove rebuilds the chain.
|
||||
- **Sampler instrument** ✓: WAV import (SAF file picker) + ad-hoc mic/USB
|
||||
recorder (`audio/SampleRecorder.kt`), decoded to a mono cache
|
||||
(`audio/SampleStore.kt`), played pitched + sliced by `audio/SampleVoice.kt`.
|
||||
(`audio/SampleStore.kt`), played pitched + sliced by `core/src/sampler/SampleVoice.cpp`.
|
||||
Its editor (`ui/toolbox/SamplerEditor.kt`) shows a waveform with two draggable
|
||||
slice markers, start-octave + volume, and a two-octave audition keyboard. Each
|
||||
(lane, track) has both a synth and a sample voice; the channel instrument type
|
||||
@@ -893,11 +927,16 @@ polish and interchange niceties, not functional gaps.
|
||||
(`version`/`bpm`/`sig`, `block`…`endblock` with `roll`/`track`/steps) — covered
|
||||
by passing JVM unit tests in `app/src/test`.
|
||||
- Background playback foreground service with Play/Pause/Stop notification.
|
||||
- **Full C++ audio port** ✓ (0.37.0): the whole DSP — sequencer, mixer, every
|
||||
instrument and effect, the master recorder — is `core/`, shared with the iOS app
|
||||
and driven over JNI. The Kotlin DSP it replaced lives on in the **test** source
|
||||
set (`app/src/test/.../audio`, `frasil`, `echofield`, `wavetable`) as the
|
||||
reference the C++ is checked against, so none of it ships in the APK.
|
||||
- **Oboe / AAudio native output** ✓ (default): `src/main/cpp/native_audio.cpp`
|
||||
opens a low-latency Oboe stream whose real-time callback pulls audio via JNI
|
||||
(`audio/NativeAudioBridge.kt`) from the SAME `AudioEngine.fillBlock` the
|
||||
AudioTrack loop uses — so both backends produce identical sound, only the
|
||||
delivery path differs. Oboe is the default engine; it falls back to the
|
||||
(`audio/NativeAudioBridge.kt`) from the SAME `Engine::fillBlock` the AudioTrack
|
||||
fallback loop reaches through `nativeRender` — so both backends produce
|
||||
identical sound, only the delivery path differs. Oboe is the default engine; it falls back to the
|
||||
AudioTrack loop only if it fails to initialise (or the native lib is absent),
|
||||
surfacing a popup with the reason (there is no user toggle).
|
||||
Built via **NDK r27** (`ndkVersion` in `app/build.gradle.kts`) + CMake + the
|
||||
@@ -909,9 +948,9 @@ polish and interchange niceties, not functional gaps.
|
||||
`llvm-readelf -l <lib>.so` → LOAD `Align 0x4000`.)
|
||||
- **SF2 / XI loader instrument** ✓: `audio/SoundFontLoader.kt` extracts PCM from
|
||||
an `.sf2` / `.xi` into the `SampleStore`, played back through the same
|
||||
`SampleVoice` path as the Sampler; edited via `ui/toolbox/SoundFontEditor.kt`
|
||||
`SampleVoice` path in `core/` as the Sampler; edited via `ui/toolbox/SoundFontEditor.kt`
|
||||
(root note, volume, ADSR).
|
||||
- **Master recording** ✓: `audio/MasterRecorder.kt` renders the stereo master bus
|
||||
- **Master recording** ✓: `core/src/host/MasterRecorder.cpp` renders the stereo master bus
|
||||
(plus a configurable FX tail) to a WAV in a user-chosen folder (SAF).
|
||||
- **Stereo output & recording** ✓: `fillBlock` renders interleaved stereo and the
|
||||
recorder captures two channels (voices/inserts are mono, so both channels carry
|
||||
@@ -933,11 +972,13 @@ polish and interchange niceties, not functional gaps.
|
||||
- **Byte-exact desktop `.sng` compatibility.** `io/SngFormat.kt` reads/writes the
|
||||
reference line format and round-trips musically; a field-for-field byte match
|
||||
with the CLI project layout is the remaining interchange nicety.
|
||||
- **Full C++ audio port.** The DSP currently runs in Kotlin behind the Oboe
|
||||
callback (via JNI). Porting the hot path to C++ would remove JVM/GC from the
|
||||
real-time thread — a performance hardening step, not a functional gap.
|
||||
- **Route the Oboe backend through the chosen output device** (Oboe
|
||||
`setDeviceId`), matching the AudioTrack path's device selection.
|
||||
- **Block-rate FX processing.** Insert effects are `process(float)` per sample, so
|
||||
a four-effect chain on four channels is 16 virtual calls per frame. Giving
|
||||
`Effect` a block entry point (defaulting to a loop over `process`) would let the
|
||||
heavier ports vectorise. Sample-for-sample identical if done carefully, but it
|
||||
touches every effect and the golden comparison, so it is its own change.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -5,6 +5,28 @@ Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
|
||||
is shared with Android, continuing Android's numbering, and both apps ship the
|
||||
same features; the Android side of each version is in `../CHANGELOG.md`.
|
||||
|
||||
## 0.41.2 (build 78)
|
||||
|
||||
Housekeeping and speed; nothing you can see changes.
|
||||
|
||||
- **The DSP core is built at `-O2`.** It was `-Os`, which traded the engine's
|
||||
speed for a little binary size in an app that has to hold a 4 ms deadline. The
|
||||
golden tests measure the core at `-O2`, so the build that ships is now the
|
||||
build that was checked.
|
||||
- **The mixer costs less per sample.** Channel volume, mute/solo and the effect
|
||||
chain are read once per audio block rather than once per frame
|
||||
(`core/src/engine/Engine.cpp`, shared with Android). Bit-for-bit the same
|
||||
audio: all 61 reference scenarios still match.
|
||||
- **Less battery while a song is stopped.** The transport display polled the
|
||||
engine 30 times a second whatever was happening; stopped it now ticks 10 times
|
||||
a second, and any transport call — the PLAY button, a gamepad, a MIDI binding —
|
||||
starts the display-rate ticks in the same turn. The tick also stopped hopping
|
||||
through a task per poll, 30 times a second, for a main-thread timer that was
|
||||
already on the main actor.
|
||||
- **Dead code gone.** The golden tests' `TestVoice` wrappers were compiled into
|
||||
the app and the plugin extension although only `golden_test` calls them; they
|
||||
have moved to `core/tests/voices/`. A couple of unused declarations went too.
|
||||
|
||||
## 0.41.1 (build 77)
|
||||
|
||||
- Fix: some controls only showed their new state after something else redrew
|
||||
|
||||
+6
-2
@@ -36,6 +36,10 @@ 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/*/*.cpp)
|
||||
CORE_HDR := $(wildcard ../core/include/sizzle/*.hpp ../core/src/*/*.hpp)
|
||||
# The golden tests' TestVoice wrappers. They live under tests/, not src/, so neither
|
||||
# app compiles them: only golden_test calls makeTestVoice.
|
||||
VOICE_SRC := $(wildcard ../core/tests/voices/*.cpp)
|
||||
VOICE_HDR := ../core/tests/voices/TestVoice.hpp
|
||||
CXX ?= c++
|
||||
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -I../core/include -I../core/src -I../core/src/fx -lz
|
||||
GOLDEN := ../core/golden
|
||||
@@ -62,9 +66,9 @@ golden:
|
||||
./gradlew -q :app:testDebugUnitTest --tests '*IosGolden*' --rerun
|
||||
@ls $(GOLDEN)/*.scn | wc -l | xargs echo "reference scenarios:"
|
||||
|
||||
build/core/golden_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/golden_test.cpp
|
||||
build/core/golden_test: $(CORE_SRC) $(CORE_HDR) $(VOICE_SRC) $(VOICE_HDR) ../core/tests/golden_test.cpp
|
||||
mkdir -p build/core
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/golden_test.cpp
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) $(VOICE_SRC) ../core/tests/golden_test.cpp
|
||||
|
||||
build/core/sampler_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/sampler_test.cpp
|
||||
mkdir -p build/core
|
||||
|
||||
+13
-4
@@ -10,6 +10,7 @@ Makefile (`make -C ios help`).
|
||||
| `../core/` | The shared C++ engine (Android plays through it too): 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 |
|
||||
| `../core/tests/voices/` | The `TestVoice` wrappers `golden_test` drives the instruments through. Under `tests/`, not `src/`, so neither app compiles them |
|
||||
| `app/components.txt` | The plugin list (AU type, subtype, device, name) |
|
||||
| `app/FX/` | The plugin extension: `SizzleDeviceAU` (shared: parameters, presets, state), `SizzleEffectAU` (aufx), `SizzleInstrumentAU` (aumu), `SizzleFXViewController` (factory + editor). The app compiles the same classes to host them itself |
|
||||
| `app/Host/SizzleSession*` | The bridge to the C++ song + engine (audio output, song lock, live-note queue); one category per screen |
|
||||
@@ -27,8 +28,11 @@ listed in `CHANGELOG.md` here.
|
||||
|
||||
## 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:
|
||||
The Kotlin DSP is the reference. It lives in the Android app's **test** source set
|
||||
(`../app/src/test/java/.../audio`, `frasil`, `echofield`, `wavetable`) — both apps
|
||||
play `core/`, so it is no longer part of either one. `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;
|
||||
@@ -38,8 +42,13 @@ test in the Android app, skipped by the normal `make check`), which:
|
||||
`../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:
|
||||
largest difference below 1e-4. Today all 61 pass; most are bit-exact, the rest
|
||||
differ by about one float ulp. It compiles the core at `-O2` — and so does Xcode
|
||||
(`GCC_OPTIMIZATION_LEVEL: 2` on the `SizzleCore` target in `app/project.yml`, in
|
||||
every configuration), so the build that ships is the build that was measured. An
|
||||
optimisation level is not a free choice here: it decides FP contraction, and the
|
||||
comparison only holds for the level the tests use. 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;
|
||||
|
||||
@@ -20,7 +20,7 @@ final class AppModel: ObservableObject {
|
||||
@Published private(set) var revision = 0
|
||||
@Published var tab: Tab = .tracker
|
||||
|
||||
// Transport, polled ~30×/s.
|
||||
// Transport, polled 30×/s while playing (see pollTransport).
|
||||
@Published private(set) var isPlaying = false
|
||||
@Published private(set) var currentLine = 0
|
||||
@Published private(set) var currentBeat = 0
|
||||
@@ -45,12 +45,33 @@ final class AppModel: ObservableObject {
|
||||
|
||||
init() {
|
||||
observer = NotificationCenter.default.addObserver(forName: .SizzleSessionDidChange, object: nil, queue: .main) { [weak self] _ in
|
||||
Task { @MainActor in self?.revision += 1 }
|
||||
// SizzleSession's -edit: announces transport calls too, so this is also
|
||||
// where the poll rate catches up: however playback was started — the
|
||||
// tracker's PLAY button, a gamepad, a MIDI binding — the display-rate
|
||||
// ticks begin in the same turn, not up to a tick later.
|
||||
Task { @MainActor in self?.revision += 1; self?.pollTransport() }
|
||||
}
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 1.0 / 30, repeats: true) { [weak self] _ in
|
||||
Task { @MainActor in self?.pollTransport() }
|
||||
// The timer fires on the main run loop, so the body is already on the main
|
||||
// actor: assumeIsolated instead of `Task { @MainActor in … }`, which hopped
|
||||
// through an allocation and a scheduler turn 30 times a second forever.
|
||||
// Ticks while stopped only watch for isPlaying, so they run at 10×/s.
|
||||
startTimer(hz: Self.idleHz)
|
||||
}
|
||||
|
||||
private static let playingHz = 30.0
|
||||
private static let idleHz = 10.0
|
||||
|
||||
private func startTimer(hz: Double) {
|
||||
timer?.invalidate()
|
||||
timerHz = hz
|
||||
let t = Timer(timeInterval: 1.0 / hz, repeats: true) { [weak self] _ in
|
||||
MainActor.assumeIsolated { self?.pollTransport() }
|
||||
}
|
||||
RunLoop.main.add(t, forMode: .common)
|
||||
timer = t
|
||||
}
|
||||
|
||||
private var timerHz = 0.0
|
||||
|
||||
private func pollTransport() {
|
||||
let playing = session.isPlaying
|
||||
@@ -60,8 +81,19 @@ final class AppModel: ObservableObject {
|
||||
if line != currentLine { currentLine = line }
|
||||
if beat != currentBeat { currentBeat = beat }
|
||||
}
|
||||
// Follow the playhead at display rate; idle at a third of that, which is what
|
||||
// a stopped song needs to notice someone else starting it.
|
||||
let want = playing ? Self.playingHz : Self.idleHz
|
||||
if want != timerHz { startTimer(hz: want) }
|
||||
}
|
||||
|
||||
func playPause() { session.isPlaying ? session.pause() : session.play() }
|
||||
func stop() { session.stop() }
|
||||
func playPause() {
|
||||
session.isPlaying ? session.pause() : session.play()
|
||||
pollTransport()
|
||||
}
|
||||
|
||||
func stop() {
|
||||
session.stop()
|
||||
pollTransport()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,6 @@ final class PluginCheck: ObservableObject {
|
||||
.filter { [kAudioUnitType_Effect, kAudioUnitType_MusicDevice].contains($0.audioComponentDescription.componentType) }
|
||||
}
|
||||
|
||||
func listInstalled() {
|
||||
let comps = installed()
|
||||
lines = ["Registered plugins (extension): \(comps.count)"] + comps.map { " \($0.name)" }
|
||||
}
|
||||
|
||||
func run() async {
|
||||
running = true
|
||||
defer { running = false }
|
||||
|
||||
@@ -113,31 +113,6 @@ struct SetupRow: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// An Android settings section not ported yet: its place in the layout, greyed
|
||||
/// out and marked as coming later.
|
||||
struct ComingLaterRow: View {
|
||||
let title: String
|
||||
let subtitle: String
|
||||
let icon: String
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: icon).font(.system(size: 16)).foregroundColor(Theme.dim).frame(width: 24)
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(title).font(.system(size: 15, weight: .medium)).foregroundColor(Theme.dim)
|
||||
Text(subtitle).font(.system(size: 12)).foregroundColor(Theme.dim.opacity(0.75)).lineLimit(2)
|
||||
}
|
||||
Spacer(minLength: 8)
|
||||
Text("Later").font(.system(size: 11)).foregroundColor(Theme.dim)
|
||||
.padding(.horizontal, 8).padding(.vertical, 3)
|
||||
.overlay(Capsule().stroke(Theme.grid, lineWidth: 1))
|
||||
.fixedSize()
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityHint("Coming in a later version")
|
||||
}
|
||||
}
|
||||
|
||||
/// The Setup tab's modal dialogs. iOS 15 alerts can't hold a text field, so the
|
||||
/// save prompt (and with it every dialog here, for one look) is drawn in SwiftUI.
|
||||
|
||||
+6
-1
@@ -25,7 +25,12 @@ targets:
|
||||
settings:
|
||||
base:
|
||||
PRODUCT_NAME: SizzleCore
|
||||
GCC_OPTIMIZATION_LEVEL: s
|
||||
# -O2 in every configuration, matching ios/Makefile's CXXFLAGS — the one
|
||||
# build of this code the golden tests actually measure. It was -Os, which
|
||||
# trades the DSP's speed for a few hundred KB in an app that has to hold a
|
||||
# 4 ms deadline; and optimising Debug too is deliberate (the Android
|
||||
# CMakeLists does the same), because an -O0 core cannot render in real time.
|
||||
GCC_OPTIMIZATION_LEVEL: 2
|
||||
SizzleFX:
|
||||
type: app-extension
|
||||
platform: iOS
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@
|
||||
# or polish. versionCode is monotonic and bumps by 1 on every release,
|
||||
# because F-Droid and the Android package manager order installs by it alone.
|
||||
|
||||
versionName = 0.41.1
|
||||
versionCode = 77
|
||||
versionName = 0.41.2
|
||||
versionCode = 78
|
||||
|
||||
# Namespace for every platform: cc.tiredsysadmin.<os>.sizzle. Android:
|
||||
# cc.tiredsysadmin.android.sizzle (app/), iOS/iPadOS: cc.tiredsysadmin.ios.sizzle
|
||||
|
||||
Reference in New Issue
Block a user