mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Visualizer tweaks
This commit is contained in:
parent
1ee1a855a2
commit
48a933136f
2 changed files with 10 additions and 11 deletions
|
|
@ -40,7 +40,7 @@ fun BoxScope.BarVisualizer(
|
||||||
|
|
||||||
data.forEachIndexed { index, data ->
|
data.forEachIndexed { index, data ->
|
||||||
val height by animateDpAsState(
|
val height by animateDpAsState(
|
||||||
targetValue = size.height * data / 128f,
|
targetValue = size.height * data / 256f,
|
||||||
animationSpec = tween(easing = LinearEasing),
|
animationSpec = tween(easing = LinearEasing),
|
||||||
)
|
)
|
||||||
Box(
|
Box(
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@ import org.jellyfin.sdk.model.api.LyricDto
|
||||||
import org.jellyfin.sdk.model.extensions.ticks
|
import org.jellyfin.sdk.model.extensions.ticks
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import kotlin.math.abs
|
|
||||||
import kotlin.math.ceil
|
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
|
|
@ -267,15 +265,16 @@ class NowPlayingViewModel
|
||||||
waveform: ByteArray,
|
waveform: ByteArray,
|
||||||
samplingRate: Int,
|
samplingRate: Int,
|
||||||
) {
|
) {
|
||||||
val resolution = 64
|
val resolution = 96
|
||||||
val processed = IntArray(resolution)
|
|
||||||
val captureSize =
|
val captureSize =
|
||||||
Visualizer.getCaptureSizeRange()[1]
|
Visualizer.getCaptureSizeRange()[1]
|
||||||
val groupSize = captureSize / resolution.toFloat()
|
val groupSize = (captureSize / resolution.toFloat()).toInt()
|
||||||
for (i in 0 until resolution) {
|
val processed =
|
||||||
val v = abs(waveform[ceil(i * groupSize).toInt()].toInt())
|
waveform
|
||||||
processed[i] = abs(v * v / (128) - 128)
|
.toList()
|
||||||
}
|
.chunked(groupSize)
|
||||||
|
.map { it.average().toInt() + 128 }
|
||||||
|
.toIntArray()
|
||||||
viz.update { processed }
|
viz.update { processed }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,7 +310,7 @@ class NowPlayingViewModel
|
||||||
captureSize = Visualizer.getCaptureSizeRange()[1]
|
captureSize = Visualizer.getCaptureSizeRange()[1]
|
||||||
setDataCaptureListener(
|
setDataCaptureListener(
|
||||||
this@NowPlayingViewModel,
|
this@NowPlayingViewModel,
|
||||||
Visualizer.getMaxCaptureRate() / 2,
|
Visualizer.getMaxCaptureRate() / 3,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue