Go Down

Topic: Arduino DUE Audio player stuttering problems (Read 1 time) previous topic - next topic

mastrogippo

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:

Code: [Select]
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.

Steamboat

Perfect - thanks - works for me!

Pleasse remember that you also have to make the function public in the Audio.h


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();
Rainer from Germany
wood-walker.org

thtorre

#2
Apr 02, 2015, 02:11 am Last Edit: Apr 02, 2015, 02:13 am by thtorre
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.

thtorre

Here all all the steps to resolve the distorted audio files when using the Audio library for the Arduino Due.

Open the file /Arduino/libraries/Audio/src/Audio.cpp
Add the 5 lines (as provided by mastrogippo):


Directly under

// Start DAC
   dac->begin(VARIANT_MCK / sampleRate);
   dac->setOnTransmitEnd_CB(onTransmitEnd, this);
}

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.

Steamboat

It's me again - yes, first it worked for me - but now I got the stuttering again after I added just some code to my promgram

I am using exactly the same WAV sequenz as before - I even did not remove the SD-card


Is there maybe an overlap in the storage or something like that IDK ?

Rainer
Rainer from Germany
wood-walker.org

Brendan1979

 I did do ths nut i am gettinh this error:



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

any help?

JohnDragonMan

hmm i am getting the stuttering audio fault too.

i have edited both files multiple times and now ending up with lots of errors.

could someone just be kind and upload the altered "Audio.cpp" and "Audio.h" files please?

i have been trying to make this audio code confirmation keypad door lock for MONTHS. i'm about ready to give up and sell everything!
- JohnDragonMan

Creator of "Fiat Panda 4x4 Project: Fallout"

Go Up