stt(dump): WAV-заголовок — размеры little-endian (плееры открывают дампы)
This commit is contained in:
@@ -42,13 +42,17 @@ class WavWriter(
|
||||
runCatching {
|
||||
RandomAccessFile(path, "rw").use { raf ->
|
||||
raf.seek(4)
|
||||
raf.writeInt((36 + dataBytes).toInt()) // размер RIFF
|
||||
raf.write(leInt(36 + dataBytes)) // размер RIFF (little-endian)
|
||||
raf.seek(40)
|
||||
raf.writeInt(dataBytes.toInt()) // размер data
|
||||
raf.write(leInt(dataBytes)) // размер data (little-endian)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 4 байта little-endian (WAV-заголовок), в отличие от RandomAccessFile.writeInt (big-endian). */
|
||||
private fun leInt(v: Long): ByteArray =
|
||||
ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(v.toInt()).array()
|
||||
|
||||
private fun headerBytes(): ByteArray =
|
||||
ByteBuffer.allocate(44).order(ByteOrder.LITTLE_ENDIAN).apply {
|
||||
put("RIFF".toByteArray())
|
||||
|
||||
Reference in New Issue
Block a user