Skip to content

Commit

Permalink
fix: byte 32-34 on wav header should be bytePerFrame. fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
brookmg committed Jun 14, 2021
1 parent 77b748c commit 2385dcd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions exorecord/src/main/java/dev/brookmg/exorecord/lib/WavFile.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.brookmg.exorecord.lib

import android.content.Context
import android.util.Log
import com.google.android.exoplayer2.Format.NO_VALUE
import dev.brookmg.exorecord.lib.Util.toByteArray
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -50,7 +49,7 @@ class WavFile(
// THE CHAOS
fileOutputStream.writeInt(Integer.reverseBytes(sampleRateHz)) // 24 - 28 - samples per second (numbers per second)
fileOutputStream.writeInt(Integer.reverseBytes(((sampleRateHz) * bytePerFrame ))) // 28 - 32 - bytes per second
fileOutputStream.write((bytePerFrame * channelCount).toShort().toByteArray(2), 0, 2) // 32 - 34 - # of bytes in one sample, for all channels
fileOutputStream.write((bytePerFrame).toShort().toByteArray(2), 0, 2) // 32 - 34 - # of bytes in one sample, for all channels
fileOutputStream.write((bytePerFrame * 8 / channelCount).toShort().toByteArray(2), 0, 2) // 34 - 36 // - how many bits in a sample(number)? usually 16 or 24

fileOutputStream.write("data".toByteArray()) // 36 40 - data
Expand Down

0 comments on commit 2385dcd

Please sign in to comment.