diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce655a..5bfd9ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ Sizzletracker for Android (`cc.tiredsysadmin.android.sizzle`). One entry per version in `versions.properties`; versions before 0.28.0 are described in the git log (one commit per version). +## 0.36.1 (versionCode 69) + +- **Wavetable editor fits without scrolling:** tabs are now OSC 1 · OSC 2 · VOICE + · FILTER · AMP · MOD · LFO, each oscillator's card draws its own table, and LOAD + TABLE moved into Oscillator 1's title with the frame size below the table. The + big table strip above the tabs is gone. Tabs in every device editor now share + the width instead of scrolling sideways. + ## 0.36.0 (versionCode 68) - **One-tap transfer from Mikro Seq:** a song sent by Mikro Seq's "Current to diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/DeviceLayouts.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/DeviceLayouts.kt index 1d92442..063adbc 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/DeviceLayouts.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/DeviceLayouts.kt @@ -19,20 +19,27 @@ object DeviceLayouts { fun pagesFor(type: ToolboxType): List = when (type) { ToolboxType.WAVETABLE -> listOf( - Page("Osc", listOf( - Panel("Oscillator 1", Tone.SOURCE, osc(1)), - Panel("Oscillator 2", Tone.SOURCE, osc(2)), + // One oscillator per tab, each drawing its own table, so every page fits + // above the keyboard without scrolling. A loaded WAV lands on oscillator 1, + // so LOAD TABLE and its frame size sit on that card. + Page("Osc 1", listOf( + Panel("Oscillator 1", Tone.SOURCE, listOf("o1table", "wtframe") + osc(1).drop(1), Viz.Wavetable(1), + labels = mapOf("wtframe" to "Frame"), action = { vm, slot -> LoadTableAction(vm, slot) }), + )), + Page("Osc 2", listOf( + Panel("Oscillator 2", Tone.SOURCE, osc(2), Viz.Wavetable(2)), )), Page("Voice", listOf( Panel("Voice", Tone.SOURCE, listOf("unison", "spread", "sub", "noise", "velsens")), - Panel("Table import", Tone.OUT, listOf("wtframe")), )), Page("Filter", listOf( Panel("Filter", Tone.FILTER, listOf("ftype", "cutoff", "reso", "keytrack", "fenv", "drive"), Viz.Filter("ftype", "cutoff", "reso"), labels = mapOf("ftype" to "Type", "fenv" to "Env Amt")), )), - Page("Env", listOf( + Page("Amp", listOf( Panel("Amp envelope", Tone.ENV, listOf("attack", "decay", "sustain", "release"), ADSR), + )), + Page("Mod", listOf( Panel("Mod envelope", Tone.MOD, listOf("mattack", "mdecay", "msustain", "mrelease", "menvpos"), Viz.Envelope("mattack", "mdecay", "msustain", "mrelease")), )), diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/Panels.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/Panels.kt index 6bd02a2..31a3e41 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/Panels.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/Panels.kt @@ -79,6 +79,8 @@ sealed interface Viz { data class Filter(val type: String?, val cutoff: String, val reso: String) : Viz /** Two cycles of the wave named by [wave]'s choice. */ data class Lfo(val wave: String) : Viz + /** The Wavetable oscillator [osc]'s table, frames stacked, the one at its position lit. */ + data class Wavetable(val osc: Int) : Viz } /** @@ -95,6 +97,8 @@ class Panel( val labels: Map = emptyMap(), val faders: List? = null, val faderScale: Float = 1f, + /** A small action drawn at the right of the card's title (e.g. the Wavetable's LOAD TABLE). */ + val action: (@Composable (AppViewModel, ToolboxSlot) -> Unit)? = null, ) /** A tab of cards. */ @@ -131,22 +135,22 @@ fun DevicePanels(vm: AppViewModel, slot: ToolboxSlot, pages: List) { @Composable private fun PageTabs(pages: List, selected: Int, onSelect: (Int) -> Unit) { val c = LocalRetro.current - Row( - Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()), - horizontalArrangement = Arrangement.spacedBy(4.dp), - ) { + // Tabs share the width (up to seven fit a phone), so none hides off-screen. + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(4.dp)) { pages.forEachIndexed { i, p -> val on = i == selected val tone = toneColor(p.panels.first().tone) Box( Modifier + .weight(1f) .border(1.dp, if (on) tone else c.grid, RectangleShape) .background(if (on) tone.copy(alpha = 0.22f) else c.surface) .clickable { onSelect(i) } - .padding(horizontal = 12.dp, vertical = 7.dp), + .padding(horizontal = 2.dp, vertical = 7.dp), + contentAlignment = Alignment.Center, ) { Text(p.title.uppercase(), color = if (on) tone else c.textDim, - fontFamily = FontFamily.Monospace, fontSize = 12.sp) + fontFamily = FontFamily.Monospace, fontSize = 12.sp, maxLines = 1, softWrap = false) } } } @@ -174,9 +178,13 @@ fun PanelCard(vm: AppViewModel, slot: ToolboxSlot, panel: Panel, rev: Int = vm.r Box(Modifier.size(8.dp).background(tone)) Spacer(Modifier.width(6.dp)) Text(panel.title.uppercase(), color = tone, fontFamily = FontFamily.Monospace, fontSize = 11.sp, - letterSpacing = 1.sp) + letterSpacing = 1.sp, modifier = Modifier.weight(1f)) + panel.action?.invoke(vm, slot) + } + panel.viz?.let { + if (it is Viz.Wavetable) WavetablePreview(slot, it.osc, tone, rev) + else VizCanvas(slot, it, byKey, tone, rev) } - panel.viz?.let { VizCanvas(slot, it, byKey, tone, rev) } if (panel.faders != null) { FaderBank(vm, slot, specs, panel, tone, rev) @@ -368,6 +376,7 @@ private fun VizCanvas(slot: ToolboxSlot, viz: Viz, byKey: Map drawLine(c.grid, Offset(0f, zeroY), Offset(w, zeroY), strokeWidth = 1f) drawLine(c.grid, Offset(fc * w, top), Offset(fc * w, bottom), strokeWidth = 1f) } + is Viz.Wavetable -> Unit // drawn by WavetablePreview is Viz.Lfo -> { val name = choice(viz.wave).lowercase() val n = 160 diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/ToolboxScreen.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/ToolboxScreen.kt index c2984a2..b2d630b 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/ToolboxScreen.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/ToolboxScreen.kt @@ -350,7 +350,7 @@ private fun ParamEditor(vm: AppViewModel, slot: ToolboxSlot, onClose: () -> Unit // The Synth / Sampler / SoundFont / Delay / tape and glitch effects have // bespoke editors; everything else is grouped cards ([DevicePanels]), with - // a source strip on top for the Wavetable and Grain Cloud and the LFO's + // a source strip on top for the Grain Cloud and the LFO's // target picker below. when (type) { ToolboxType.NES_SYNTH -> NesSynthEditor(vm, slot) @@ -360,10 +360,6 @@ private fun ParamEditor(vm: AppViewModel, slot: ToolboxSlot, onClose: () -> Unit ToolboxType.SAMPLER -> SamplerEditor(vm, slot, samplerPad, onSelectPad = { samplerPad = it }) ToolboxType.SOUNDFONT -> SoundFontEditor(vm, slot) ToolboxType.DELAY -> DelayEditor(vm, slot) - ToolboxType.WAVETABLE -> { - WavetableEditor(vm, slot) - DevicePanels(vm, slot, DeviceLayouts.pagesFor(type)) - } ToolboxType.GRAIN_CLOUD -> { GrainCloudEditor(vm, slot) DevicePanels(vm, slot, DeviceLayouts.pagesFor(type)) diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/WavetableEditor.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/WavetableEditor.kt index da21cb9..546992e 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/WavetableEditor.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/toolbox/WavetableEditor.kt @@ -7,10 +7,12 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.Canvas import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.material3.AlertDialog import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -21,28 +23,76 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import cc.tiredsysadmin.android.sizzle.model.ToolboxSlot import cc.tiredsysadmin.android.sizzle.ui.AppViewModel -import cc.tiredsysadmin.android.sizzle.ui.components.RetroButton import cc.tiredsysadmin.android.sizzle.ui.theme.LocalRetro import cc.tiredsysadmin.android.sizzle.wavetable.WaveDefs import cc.tiredsysadmin.android.sizzle.wavetable.WaveTables -/** - * The Wavetable's table strip: LOAD TABLE (a Serum / WaveEdit / power-of-two-frame - * WAV becomes the "Custom" table) and a view of oscillator 1's table, every frame - * stacked back to front with the one at its POSITION lit. +/* + * The Wavetable's own pieces inside its generic cards (see DeviceLayouts): each + * oscillator card draws that oscillator's table ([WavetablePreview], via + * [Viz.Wavetable]), and Oscillator 1's card carries LOAD TABLE ([LoadTableAction]), + * because a loaded WAV becomes the "Custom" table and is selected on oscillator 1. */ + +/** Every frame of oscillator [osc]'s table stacked back to front, the one at its POSITION lit. */ @Composable -fun WavetableEditor(vm: AppViewModel, slot: ToolboxSlot) { +fun WavetablePreview(slot: ToolboxSlot, osc: Int, tone: Color, rev: Int) { + 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 + val table = if (name == WaveTables.CUSTOM) WaveTables.forSample(slot.string(WaveDefs.SAMPLE_KEY), frame) else WaveTables.factory(name) + val pos = slot.float("o${osc}pos", 0f) + val caption = if (table == null) "$name (preparing…)" + else "${if (name == WaveTables.CUSTOM) "your table" else name} · ${table.frames} frames" + + Box(Modifier.fillMaxWidth().height(72.dp).background(c.background).border(1.dp, c.grid, RectangleShape)) { + if (table != null) { + // 128 points of each frame's richest level, stacked; recomputed per table only + val curves = remember(table) { + val n = table.size(0); val step = maxOf(1, table.frames / 16) + (0 until table.frames step step).map { f -> FloatArray(128) { i -> table.data[0][f * n + i * n / 128] } to f } + } + val lit = (pos * (table.frames - 1) + 0.5f).toInt() + Canvas(Modifier.fillMaxWidth().height(72.dp)) { + if (rev < 0) return@Canvas // capture the revision so the drawing follows edits + val k = curves.size + val rowH = size.height * 0.45f + for ((idx, cf) in curves.withIndex().reversed()) { + val (pts, f) = cf + val depth = if (k > 1) idx.toFloat() / (k - 1) else 0f + val x0 = size.width * 0.04f + depth * size.width * 0.18f + val w = size.width * 0.76f + val yMid = size.height * 0.72f - depth * size.height * 0.45f + val near = kotlin.math.abs(f - lit) * 2 <= maxOf(1, table.frames / curves.size) + val col = if (near) tone else c.text.copy(alpha = 0.25f) + for (i in 1 until pts.size) { + drawLine(col, + Offset(x0 + w * (i - 1) / pts.size, yMid - pts[i - 1] * rowH * 0.5f), + Offset(x0 + w * i / pts.size, yMid - pts[i] * rowH * 0.5f), + strokeWidth = if (near) 2f else 1f) + } + } + } + } + Text(caption, color = c.textDim, fontFamily = FontFamily.Monospace, fontSize = 9.sp, + modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp)) + } +} + +/** LOAD TABLE in Oscillator 1's title: a Serum / WaveEdit / power-of-two-frame WAV + * becomes the "Custom" table and is selected on oscillator 1. */ +@Composable +fun LoadTableAction(vm: AppViewModel, slot: ToolboxSlot) { val c = LocalRetro.current val context = LocalContext.current - @Suppress("UNUSED_VARIABLE") val rev = vm.revision - var importError by remember(slot.index) { mutableStateOf(null) } val picker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri -> if (uri == null) return@rememberLauncherForActivityResult @@ -54,47 +104,13 @@ fun WavetableEditor(vm: AppViewModel, slot: ToolboxSlot) { "Couldn't load this wavetable. Use an uncompressed .wav (Serum, WaveEdit, or frames of 256–2048 samples)." } } - - val name = slot.string("o1table", WaveDefs.TABLES[0]) - val frame = slot.string("wtframe", WaveDefs.FRAME_SIZES[0]).toIntOrNull() ?: 0 - val table = if (name == WaveTables.CUSTOM) WaveTables.forSample(slot.string(WaveDefs.SAMPLE_KEY), frame) else WaveTables.factory(name) - val pos = slot.float("o1pos", 0f) - - Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { - RetroButton("LOAD TABLE") { picker.launch(arrayOf("*/*")) } - Text( - if (table == null) "Osc 1: $name (preparing…)" else "Osc 1: ${if (name == WaveTables.CUSTOM) "your table" else name} · ${table.frames} frames", - color = c.textDim, fontFamily = FontFamily.Monospace, fontSize = 10.sp, - ) - if (table != null) { - // 128 points of each frame's richest level, stacked; recomputed per table only - val curves = remember(table) { - val n = table.size(0); val step = maxOf(1, table.frames / 16) - (0 until table.frames step step).map { f -> FloatArray(128) { i -> table.data[0][f * n + i * n / 128] } to f } - } - val lit = (pos * (table.frames - 1) + 0.5f).toInt() - Canvas(Modifier.fillMaxWidth().height(110.dp).background(c.surface)) { - val k = curves.size - val rowH = size.height * 0.45f - for ((idx, cf) in curves.withIndex().reversed()) { - val (pts, f) = cf - val depth = if (k > 1) idx.toFloat() / (k - 1) else 0f - val x0 = size.width * 0.04f + depth * size.width * 0.18f - val w = size.width * 0.76f - val yMid = size.height * 0.72f - depth * size.height * 0.45f - val near = kotlin.math.abs(f - lit) * 2 <= maxOf(1, table.frames / curves.size) - val col = if (near) c.accent else c.text.copy(alpha = 0.25f) - for (i in 1 until pts.size) { - drawLine(col, - Offset(x0 + w * (i - 1) / pts.size, yMid - pts[i - 1] * rowH * 0.5f), - Offset(x0 + w * i / pts.size, yMid - pts[i] * rowH * 0.5f), - strokeWidth = if (near) 2f else 1f) - } - } - } - } - } - + Text( + "+ LOAD TABLE", color = c.accent, fontFamily = FontFamily.Monospace, fontSize = 11.sp, + modifier = Modifier + .border(1.dp, c.accent.copy(alpha = 0.6f), RectangleShape) + .clickable { picker.launch(arrayOf("*/*")) } + .padding(horizontal = 8.dp, vertical = 3.dp), + ) importError?.let { msg -> AlertDialog( onDismissRequest = { importError = null }, diff --git a/docs/DEVELOPER_HANDOVER.md b/docs/DEVELOPER_HANDOVER.md index b9d0365..250476f 100644 --- a/docs/DEVELOPER_HANDOVER.md +++ b/docs/DEVELOPER_HANDOVER.md @@ -349,6 +349,16 @@ table). `DeviceLayoutsTest` checks that every parameter of every laid-out device is on exactly one card and that knob labels stay short. A device missing from `DeviceLayouts` falls back to one card with all its parameters. +**Fit above the keyboard (0.36.1).** Instruments pin an audition keyboard, which +leaves the editor about 460 dp on a 20:9 phone, of which the title, preset bar and +tab strip take about 170. A page should therefore stay under ~290 dp (one card +with a drawing, a choice row and a knob row is ~230; two such cards don't fit). +That is why the Wavetable has one oscillator per tab and separate AMP and MOD +tabs. Its table drawing is a `Viz.Wavetable(osc)` inside each oscillator card +(`WavetablePreview`), and LOAD TABLE is a `Panel.action` in Oscillator 1's title +(`LoadTableAction`, WavetableEditor.kt). Tabs share the strip's width (up to +seven fit) instead of scrolling sideways. + **Recomposition pitfall (fixed in 0.35.1).** Slot params live in a plain map that Compose can't observe; edits bump `vm.revision` instead. Because the compiler's strong skipping compares `vm`/`slot` by identity, a child composable that receives diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md index a289140..0092ef3 100644 --- a/docs/USER_GUIDE.md +++ b/docs/USER_GUIDE.md @@ -227,7 +227,7 @@ The keyboard pinned at the bottom of the Toolbox auditions the current device. **Device editors.** Controls are grouped into cards by what they do, each with its own colour: amber for the sound source, green for the filter, pink for envelopes, violet for modulation, white for output and mix. Bigger devices split their cards -into tabs along the top (Wavetable: OSC · VOICE · FILTER · ENV · LFO). Drag a knob +into tabs along the top (Wavetable: OSC 1 · OSC 2 · VOICE · FILTER · AMP · MOD · LFO). Drag a knob up or down to turn it, double‑tap it to reset; short choices are switches you tap. Envelope, filter and LFO cards draw their shape and follow the knobs as you turn them. The 10‑Band EQ is a row of vertical faders (double‑tap one to flatten it). @@ -313,7 +313,8 @@ WAV made of frames of 256 to 2048 samples (set **Frame Size** if it guesses wron oscillator 1 then plays it as **Custom**. **Bend** sharpens a wave without changing its pitch, **Unison** stacks up to four detuned copies (**Spread**), and there is a **Sub** sine, **Noise**, a **Filter** with its own envelope amount and **Drive**. -The table view shows oscillator 1's frames, the one at its position lit. +Each oscillator's tab draws its table's frames, the one at its position lit; +**LOAD TABLE** is in oscillator 1's title, with **Frame** below its table. ### Effects diff --git a/versions.properties b/versions.properties index 914dbcb..8d2efea 100644 --- a/versions.properties +++ b/versions.properties @@ -8,8 +8,8 @@ # or polish. android.versionCode is monotonic and bumps by 1 on every release, # because F-Droid and the Android package manager order installs by it alone. -android.versionName = 0.36.0 -android.versionCode = 68 +android.versionName = 0.36.1 +android.versionCode = 69 # No desktop builds exist yet. These lines are the agreed slots so a port starts # with a version instead of inventing one; `-` means "not built on this