diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt index d228b0f..819aeb7 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt @@ -108,7 +108,7 @@ private fun bytesToHexLower(bytes: ByteArray): String { return out.toString() } -private fun compressVoiceWaves(source: List, targetLength: Int): List { +internal fun compressVoiceWaves(source: List, targetLength: Int): List { if (targetLength <= 0) return emptyList() if (source.isEmpty()) return List(targetLength) { 0f } if (source.size == targetLength) return source @@ -142,7 +142,7 @@ private fun compressVoiceWaves(source: List, targetLength: Int): List(), compressVoiceWaves(listOf(1f), 0)) + } + + @Test + fun `compressVoiceWaves upsamples via interpolation`() { + val source = listOf(0.0f, 1.0f) + val result = compressVoiceWaves(source, 3) + assertEquals(3, result.size) + assertEquals(0.0f, result[0], 0.01f) + assertEquals(0.5f, result[1], 0.01f) + assertEquals(1.0f, result[2], 0.01f) + } +}