Skip to content

Native Android client for Spotify, built with Jetpack Compose

AutoMix: the two faders' sum is bounded in a mix: two loud masters' peaks add up on a shared beat (120 locked renders on the bench: 63 clipped unbounded, 46 now)

kota-zo4d93059df7a6
diff --git a/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueCompiler.kt b/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueCompiler.kt
index 6f271761..11fef529 100644
--- a/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueCompiler.kt
+++ b/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueCompiler.kt
@@ -4,6 +4,7 @@ package app.myspoti.automix.segue
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.log10
+import kotlin.math.min
import kotlin.math.roundToInt
import kotlin.math.roundToLong
import kotlin.math.sin
@@ -51,7 +52,8 @@ internal class SegueCompiler(private val t: SegueTuning) {
for (x in positions.distinct().sorted()) {
val (ga, gb) = gains(x)
val power = ga * ga + gb * gb
- val scale = if (power > 1) 1 / sqrt(power) else 1.0
+ // Equal power for songs that do not add up, a bound on the sum for the peaks that do: two loud masters land on one beat.
+ val scale = min(if (power > 1) 1 / sqrt(power) else 1.0, if (ga + gb > t.overlapMaxSum) t.overlapMaxSum / (ga + gb) else 1.0)
a += knot(x, db(ga * scale)); b += knot(x, db(gb * scale))
}
return listOf(lane(LaneSide.OUTGOING, Target.LEVEL, a), lane(LaneSide.INCOMING, Target.LEVEL, b))
diff --git a/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueTuning.kt b/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueTuning.kt
index 19859653..350242f4 100644
--- a/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueTuning.kt
+++ b/base/automix/src/main/kotlin/app/myspoti/automix/segue/SegueTuning.kt
@@ -139,6 +139,8 @@ data class SegueTuning(
val topInDb: Double = -12.0,
/** A cut on the beat lasts this share of a beat [I]: quick, without a click. */
val cutBeatShare: Double = 0.25,
+ /** The two faders' largest sum [I]: 1 can never clip two peaks that meet, and dips by 3 dB at equal gains. */
+ val overlapMaxSum: Double = 1.25,
/** Knots per equal-power curve [I]: enough that the steps between them are not heard. */
val curveKnots: Int = 16,
/** Loudness gap left alone, and the largest one corrected, dB [R]. */
diff --git a/docs/automix/segue-design.md b/docs/automix/segue-design.md
index dc20bae5..f6a0a847 100644
--- a/docs/automix/segue-design.md
+++ b/docs/automix/segue-design.md
@@ -285,6 +285,7 @@ marked `[R]`, reused from this repository.
| `stretchMinBeatShare`, `stretchMinDownConfidence` | 0.85, 0.5 | What a stretch must have to be relied on |
| `penaltyVoiceCut`, `phraseNoteInside` | 0.5, 0.25 | The two score terms added with stretches |
| `voiceBarRisk`, `lockedTinyBars` | 0.6 `[R]`, 2 | A bar counted as sung; the shortest locked length |
+| `overlapMaxSum` | 1.25 | Two masters' peaks add up on a shared beat; 1 never clips but dips by 3 dB. Bench, 120 locked renders: unbounded 63 clipped, 1.25 46, 1.0 7 |
| `coreOutDb`, `coreInDb`, `topInDb`, `cutBeatShare` | −24, −12, −12 dB, 0.25 | The three-band and cut shapes |
| `blockFrames`, `shelfLowHz`, `shelfHighHz`, `holdRampUs` | 64, 180 Hz, 2.5 kHz, 400 ms `[R]` | Values the player and the render already use |
| `shelfQ`, `coreQ` | 0.707 `[U]`, 0.5 | The slope of a shelf, and a bell wide enough to span the middle band |