Loading the basic SimpleAudioPlayer example will play the first audio file fine, but if instead of going to an infinite loop at the end we let the loop function rollover after a delay, the following audio is all stuttering.
I narrowed the problem down to two lines; I added the following function to the audio library:
void AudioClass::rst(void){
// Buffering starts from the beginning
running = buffer;
next = buffer;
}
I just have to call this function after the file ends, and the next file I open will play correctly.
Hope this helps someone.
I have been experiencing the same problem with the distorted audio on subsequent plays. I have never modified a library file and would appreciate any guidance.
When adding the lines:
void AudioClass::rst(void){
// Buffering starts from the beginning
running = buffer;
next = buffer;
}
to Audio.h
Where must these lines be added? I placed them just before the debug() section and this is the output of the compiler:
In file included from Instabraille.ino:4:0: C:\Program Files\Arduino\libraries\Audio\src/Audio.h:31:6: error: extra qualification 'AudioClass::' on member 'rst' [-fpermissive] void AudioClass::rst(void){
^* C:\Program Files\Arduino\libraries\Audio\src/Audio.h:31:6: error: 'void AudioClass::rst()' cannot be overloaded In file included from Instabraille.ino:4:0: C:\Program Files\Arduino\libraries\Audio\src/Audio.h:24:7: error: with 'void AudioClass::rst()'
void rst();*
^* Error compiling.
Without these lines and just the addition of the void rst(); after the void end(); the source compiles fine.
Would certainly appreciate any assistance.
void AudioClass::rst(void){
// Buffering starts from the beginning
running = buffer;
next = buffer;
}
Save this as a non formatted text file.
Open the file /Arduino/libraries/Audio/src/Audio.h
Add the 1 line void rst(); (as provided by Steamboat:)
Directly under
class AudioClass : public Print {
public:
AudioClass(DACClass &_dac) : dac(&_dac) { };
void prepare(int16_t *buffer, int S, int volume);
void begin(uint32_t sampleRate, uint32_t msPreBuffer);
void end();
void rst();
Save this as a non formatted text file.
In your code, Assuming you are starting with the Arduino SimpleAudioPlayer example, add Audio.rst(); directly after your myFile.close(); statement.
myFile.close();
Audio.rst();
Upon compilation of your code, the additions to the Audio.cpp and Audio.h files will be incorporated into your final code for uploading to the Due. Utilizing this method will produce the first and all subsequent audio files being played clearly without distortion.
In file included from sketch_jul27c.ino:16:0:
C:\Documents and Settings\Brendan\My Documents\Arduino\libraries\Audio\src/Audio.h:31:6: error: extra qualification 'AudioClass::' on member 'rst' [-fpermissive]
void AudioClass::rst(void){
^
C:\Documents and Settings\Brendan\My Documents\Arduino\libraries\Audio\src/Audio.h:31:6: error: 'void AudioClass::rst()' cannot be overloaded
In file included from sketch_jul27c.ino:16:0:
C:\Documents and Settings\Brendan\My Documents\Arduino\libraries\Audio\src/Audio.h:24:7: error: with 'void AudioClass::rst()'
void rst();
^
Error compiling