Centralize WaveForm samples.
This commit is contained in:
parent
a5198b4f6a
commit
194b97ee10
7 changed files with 38 additions and 56 deletions
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.components.media
|
||||
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
object WaveFormSamples {
|
||||
val allRangeWaveForm = List(100) { it.toFloat() / 100 }.toImmutableList()
|
||||
|
||||
val realisticWaveForm = persistentListOf(
|
||||
0.000f, 0.000f, 0.000f, 0.003f, 0.354f,
|
||||
0.353f, 0.365f, 0.790f, 0.787f, 0.167f,
|
||||
0.333f, 0.975f, 0.000f, 0.102f, 0.003f,
|
||||
0.531f, 0.584f, 0.317f, 0.140f, 0.475f,
|
||||
0.496f, 0.561f, 0.042f, 0.263f, 0.169f,
|
||||
0.829f, 0.349f, 0.010f, 0.000f, 0.000f,
|
||||
1.000f, 0.334f, 0.321f, 0.011f, 0.000f,
|
||||
0.000f, 0.003f,
|
||||
)
|
||||
}
|
||||
|
|
@ -187,14 +187,14 @@ internal fun WaveformPlaybackViewPreview() = ElementPreview {
|
|||
showCursor = false,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = aWaveForm().toImmutableList(),
|
||||
waveform = WaveFormSamples.realisticWaveForm,
|
||||
)
|
||||
WaveformPlaybackView(
|
||||
modifier = Modifier.height(34.dp),
|
||||
showCursor = true,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = List(1024) { it / 1024f }.toImmutableList(),
|
||||
waveform = WaveFormSamples.allRangeWaveForm,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -217,45 +217,3 @@ private fun ImmutableList<Float>.normalisedData(maxSamplesCount: Int): Immutable
|
|||
|
||||
return result.toImmutableList()
|
||||
}
|
||||
|
||||
fun aWaveForm(): List<Float> {
|
||||
return listOf(
|
||||
0.000f,
|
||||
0.000f,
|
||||
0.000f,
|
||||
0.003f,
|
||||
0.354f,
|
||||
0.353f,
|
||||
0.365f,
|
||||
0.790f,
|
||||
0.787f,
|
||||
0.167f,
|
||||
0.333f,
|
||||
0.975f,
|
||||
0.000f,
|
||||
0.102f,
|
||||
0.003f,
|
||||
0.531f,
|
||||
0.584f,
|
||||
0.317f,
|
||||
0.140f,
|
||||
0.475f,
|
||||
0.496f,
|
||||
0.561f,
|
||||
0.042f,
|
||||
0.263f,
|
||||
0.169f,
|
||||
0.829f,
|
||||
0.349f,
|
||||
0.010f,
|
||||
0.000f,
|
||||
0.000f,
|
||||
1.000f,
|
||||
0.334f,
|
||||
0.321f,
|
||||
0.011f,
|
||||
0.000f,
|
||||
0.000f,
|
||||
0.003f,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue