Visualizer tweaks

This commit is contained in:
Damontecres 2026-03-15 08:28:02 -04:00
parent 1ee1a855a2
commit 48a933136f
No known key found for this signature in database
2 changed files with 10 additions and 11 deletions

View file

@ -40,7 +40,7 @@ fun BoxScope.BarVisualizer(
data.forEachIndexed { index, data ->
val height by animateDpAsState(
targetValue = size.height * data / 128f,
targetValue = size.height * data / 256f,
animationSpec = tween(easing = LinearEasing),
)
Box(

View file

@ -47,8 +47,6 @@ import org.jellyfin.sdk.model.api.LyricDto
import org.jellyfin.sdk.model.extensions.ticks
import timber.log.Timber
import java.util.UUID
import kotlin.math.abs
import kotlin.math.ceil
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
@ -267,15 +265,16 @@ class NowPlayingViewModel
waveform: ByteArray,
samplingRate: Int,
) {
val resolution = 64
val processed = IntArray(resolution)
val resolution = 96
val captureSize =
Visualizer.getCaptureSizeRange()[1]
val groupSize = captureSize / resolution.toFloat()
for (i in 0 until resolution) {
val v = abs(waveform[ceil(i * groupSize).toInt()].toInt())
processed[i] = abs(v * v / (128) - 128)
}
val groupSize = (captureSize / resolution.toFloat()).toInt()
val processed =
waveform
.toList()
.chunked(groupSize)
.map { it.average().toInt() + 128 }
.toIntArray()
viz.update { processed }
}
@ -311,7 +310,7 @@ class NowPlayingViewModel
captureSize = Visualizer.getCaptureSizeRange()[1]
setDataCaptureListener(
this@NowPlayingViewModel,
Visualizer.getMaxCaptureRate() / 2,
Visualizer.getMaxCaptureRate() / 3,
true,
false,
)