Problem
First off, this is a very minor issue when playing a reallly short file. For example, at a default SD Read buffer of 131,072B, sample rate of 96kHz, 1-chan, 16-bit, the min audio duration would be 0.68s. Perhaps not worth addressing.
Unable to play the attached WAV file (0.17s long), unless I extend it to a longer duration (5.17s).
Sinc_Factor_16x_65-pts-02.wav
Setup
-Example script from preunification branch was modified to play the attached file:
AudioSDPlayer_F32::fillBufferFromSD() modified to report file position and error code during readFromSDtoBuffer()
- Debug print statements turned on for AudioSDPlayer_F32 clas
Error
18:31:50.838 -> AudioSDPlayer_F32::open:fillBufferFromSD
18:31:50.838 -> File pos=44
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= 0
18:31:50.838 -> File pos=4140
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= 0
....
18:31:50.838 -> File pos=28716
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= 0
18:31:50.838 -> File pos=32812
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= -1
Cause
This while statement expects enough audio data to fill the entire buffer. When it runs out, check for file.available() fails and returns an error code.
|
while ((error_code == 0) && (space_to_fill_in_buffer > MIN_READ_SIZE_BYTES)) { //only continue of there is space |
Proposed solution
Perhaps this is intended behavior, to return an error if the buffer is not completely full? However, is there any downside to gracefully handling the audio data running out first? Note that this fill method could end up loading metadata located after the audio data.
In open()...
|
if(fillBufferFromSD() < 0) { |
- Mark current position `fillStartPos = file.position();
- If
fillBufferFromSD() returns an error:
- Calculate
bytesLoaded = file.position()-fillStartPos
- If error, check if all the audio bytes were loaded: `if (bytesLoaded file.position() == total_length). If so, then squash the error.
Note that besides open() there are several other functions that call fillBufferFromSD().
Problem
First off, this is a very minor issue when playing a reallly short file. For example, at a default SD Read buffer of 131,072B, sample rate of 96kHz, 1-chan, 16-bit, the min audio duration would be 0.68s. Perhaps not worth addressing.
Unable to play the attached WAV file (0.17s long), unless I extend it to a longer duration (5.17s).
Sinc_Factor_16x_65-pts-02.wav
Setup
-Example script from preunification branch was modified to play the attached file:
AudioSDPlayer_F32::fillBufferFromSD()modified to report file position and error code duringreadFromSDtoBuffer()Error
18:31:50.838 -> AudioSDPlayer_F32::open:fillBufferFromSD
18:31:50.838 -> File pos=44
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= 0
18:31:50.838 -> File pos=4140
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= 0
....
18:31:50.838 -> File pos=28716
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= 0
18:31:50.838 -> File pos=32812
18:31:50.838 -> Read size=4096
18:31:50.838 -> Error_code= -1
Cause
This while statement expects enough audio data to fill the entire buffer. When it runs out, check for
file.available()fails and returns an error code.Tympan_Library/src/AudioSDPlayer_F32.cpp
Line 551 in 0767fb2
Proposed solution
Perhaps this is intended behavior, to return an error if the buffer is not completely full? However, is there any downside to gracefully handling the audio data running out first? Note that this fill method could end up loading metadata located after the audio data.
In
open()...Tympan_Library/src/AudioSDPlayer_F32.cpp
Line 163 in 0767fb2
fillBufferFromSD()returns an error:bytesLoaded = file.position()-fillStartPosNote that besides
open()there are several other functions that call fillBufferFromSD().