From 4200a1937828294530afd84ad8f0a1a8483fd9d3 Mon Sep 17 00:00:00 2001 From: Fabian Wiesel Date: Sat, 30 Mar 2024 07:36:56 +0100 Subject: [PATCH] Normalize volume for brightness Undo an unintentional change done in f6a429e. The brightness was calculated from the normalized volume, but when factoring the norm out in the history, that norm was dropped. --- app/src/main/kotlin/de/rochefort/childmonitor/VolumeView.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/de/rochefort/childmonitor/VolumeView.kt b/app/src/main/kotlin/de/rochefort/childmonitor/VolumeView.kt index 3e716ba..148a7c0 100644 --- a/app/src/main/kotlin/de/rochefort/childmonitor/VolumeView.kt +++ b/app/src/main/kotlin/de/rochefort/childmonitor/VolumeView.kt @@ -52,10 +52,11 @@ class VolumeView : View { val width = width val size = volumeHistory.size() // Size is at most width val volumeNorm = volumeHistory.volumeNorm + val minBrightness = 0.3 val relativeBrightness: Double = if (size > 0) { - volumeHistory[size - 1].coerceAtLeast(0.3) + (volumeNorm * volumeHistory[size - 1]).coerceAtLeast(minBrightness) } else { - 0.3 + minBrightness } val blue: Int val rest: Int