Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
AutoMix lab: gentler phase lock once B is heard, slower tempo return after the mix
kota-zof886498aa45f
diff --git a/base/app/src/main/java/com/music/spotui/di/LocalPlayer.kt b/base/app/src/main/java/com/music/spotui/di/LocalPlayer.ktindex 0bcc50e2..644f26c1 100644--- a/base/app/src/main/java/com/music/spotui/di/LocalPlayer.kt+++ b/base/app/src/main/java/com/music/spotui/di/LocalPlayer.kt@@ -818,7 +818,8 @@ object LocalPlayer {// (Started early by the start delay on purpose: up to that much before its start is expected.)if (preroll && target < run.startMs - startLead * plan.speedB - 300) { d.pause(); d.seekTo(run.startMs); run.state = MixState.READY; run.errors.clear(); return }val err = bPos - target- run.errors.addLast(err); while (run.errors.size > 3) run.errors.removeFirst()+ // Five readings: a player's position moves in steps of 10–20 ms, three let that noise through.+ run.errors.addLast(err); while (run.errors.size > 5) run.errors.removeFirst()val e = run.errors.sorted()[run.errors.size / 2]val base = plan.speedB * rate()// A second after the start, the deck's distance says how late it sounded: the next starts that much earlier.@@ -834,11 +835,12 @@ object LocalPlayer {}run.locked = kotlin.math.abs(e) < 15if (!preroll) run.worstMs = maxOf(run.worstMs, kotlin.math.abs(e))- // Muted, or still low in the mix: fast and strong; heard: gentle.- val fast = preroll || quiet- val dead = if (preroll) 2.0 else 6.0- val horizon = if (fast) 300.0 else 1500.0- val limit = if (preroll) 0.08 else if (quiet) 0.05 else 0.02+ // Muted: fast and strong. Heard, even low in the mix, gentle: up to 5 % within 300 ms there+ // made B's tempo sway between 1.04 and 1.11 every second over a 9 % stretch (reported as a mess),+ // for gaps of 5–20 ms that are mostly the positions' own noise.+ val dead = if (preroll) 2.0 else 12.0+ val horizon = if (preroll) 300.0 else if (quiet) 800.0 else 2000.0+ val limit = if (preroll) 0.08 else if (quiet) 0.015 else 0.008val nudge = if (kotlin.math.abs(e) <= dead) 0.0 else (-e / horizon).coerceIn(-limit, limit)val speed = (base * (1 + nudge)).toFloat()// What the nudges moved the deck by so far (ms of B), for the start delay learnt above.diff --git a/base/automix/src/main/kotlin/app/myspoti/automix/MixPlanner.kt b/base/automix/src/main/kotlin/app/myspoti/automix/MixPlanner.ktindex 6f389615..30c40d6c 100644--- a/base/automix/src/main/kotlin/app/myspoti/automix/MixPlanner.kt+++ b/base/automix/src/main/kotlin/app/myspoti/automix/MixPlanner.kt@@ -516,7 +516,9 @@ object MixPlanner {}private fun restore(speed: Double, period: Double): Double {- val beats = max(8.0, abs(speed - 1) / if (abs(speed - 1) > WIDE_STRETCH) 0.004 else 0.003)+ // About 0.1 % a beat, 16 beats at least: at 0.3 % the tempo was heard dropping back to the+ // song's own after the mix (reported: "sped up, then suddenly normal").+ val beats = max(16.0, abs(speed - 1) / 0.001)return if (abs(speed - 1) < 1e-4) 0.0 else (beats * period).let { (it * 10).roundToInt() / 10.0 }}}