Hi everyone,
I took Erel's RecordToWave example, and replaced the btnPlay_Click subroutine as shown below. In the DirRootExternal directory of my device I have a WAV file called mFileName, which I read into array B() of bytes. Then I just write that array to the AudioStreamer. Everything works, in spite of array B() being much bigger than the PlayerBufferSize (4096 in my device).
I'm confused because the documentation says one should not pass arrays bigger than the PlayerBufferSize. Thanks in advance for any clarifications.
Rod
I took Erel's RecordToWave example, and replaced the btnPlay_Click subroutine as shown below. In the DirRootExternal directory of my device I have a WAV file called mFileName, which I read into array B() of bytes. Then I just write that array to the AudioStreamer. Everything works, in spite of array B() being much bigger than the PlayerBufferSize (4096 in my device).
I'm confused because the documentation says one should not pass arrays bigger than the PlayerBufferSize. Thanks in advance for any clarifications.
Rod
B4X:
Sub btnPlay_Click
Dim INSTR As InputStream, NumBytes As Long
'Read bytes of WAV file into array B() (only audio data; WAV header dropped)
NumBytes = File.Size(File.DirRootExternal, mFileName) - 44 'Number of audio bytes in WAV file (excluding header)
INSTR = File.OpenInput(File.DirRootExternal, mFileName) 'Open WAV file for input
Dim B(44) As Byte 'Read first 44 bytes (header)
INSTR.READBYTES(B, 0, B.length)
Dim B(NumBytes) As Byte 'Read all remaining bytes (audio data) into array B()
INSTR.READBYTES(B, 0, B.length)
streamer.StartPlaying
streamer.Write(B) 'This works in spite of B() being much bigger than the PlayerBufferSize
streamer.Write(Null)
End Sub