Has anyone else had trouble trying to get the adafruit wavesheild to work?

Here’s a basic overview of the project. An SD card has a bunch of .txt and .wav files on it, I want to go into the .txt files, read the data, and play the .wavs based on what is being read. Further along some inputs will decide which .txt file are going to be read, but for now I am having trouble getting the files read and the audio playing in the same code. Individually the code works, one code that plays the audio works, and another that parses the data works, but when I try to combine them the serial monitor starts outputting strange characters.

I am using the wavesheild and code described in the link:

the card is formatted and the files are formatted.

basically this code works by itself:

#include <SD.h>
#include <FatReader.h>
#include <SdReader.h>
#include "WaveUtil.h"
#include "WaveHC.h"

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

File myFile; //used with SD card reader

char wavArray[12][13]={  
  "134","135","136","137"};

char actArray[12][13];    //actArray[i][j] refers to ith row jth column


// this handy function will return the number of bytes currently free in RAM, great for debugging!*(entire function)   
int reeRam(void)    
{
  extern int  __bss_end; 
  extern int  *__brkval; 
  int free_memory; 
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end); 
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval); 
  }
  return free_memory; 
} 

// checks card for errors*(function)
void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  // set up serial port
  Serial.begin(9600);

  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad*
  Serial.println(FreeRam());      // if this is under 150 bytes it may spell trouble!*

  // Set the output pins for the DAC control. This pins are defined in the library*
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);


  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you*
  if (!card.init()) {         //play with 8 MHz spi (default faster!)*
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why*
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!*
  }

  // enable optimize read - some cards may timeout. Disable if you're having problems*
  card.partialBlockRead(true);

  // Now we will look for a FAT partition!*
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in*
    if (vol.init(card, part)) 
      break;                             // we found one, lets bail*
  }
  if (part == 5) {                       // if we ended up not finding one  :(*
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why*
    while(1);                            // then 'halt' - do nothing!*
  }

  // Lets tell the user about what we found*
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?*

  // Try to open the root directory*
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,*
    while(1);                             // then 'halt' - do nothing!*
  }

  // Whew! We got past the tough parts.*
  putstring_nl("Ready!");
}

void loop(){

  for(int i=0;i<12;i++){
  PlayPhrase(wavPlay);
  }
}

void PlayPhrase(char* name) 
{

  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); 
    Serial.print(name); 
    return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); 
    return;
  }

  // ok time to play! start playback
  wave.play();
int i=0;
  while(wave.isplaying){
   i++;
   Serial.println(i);
    if(i>125){
      wave.stop();
    }
  } 
}

This code works by itself:

#include <SD.h>

File myFile;

char wavArray[12][13];
char actArray[12][13];

void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);

  if (!SD.begin()) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  char list[12][13]={
    "L1.txt","L2.txt","L3.txt","L22.txt","L23.txt","L24.txt"    };
  for (int k=0;k<6;k++){
    int n=ParseData(list[k]);        
    Serial.println("wavArray:  actArray:  current list: ");//print out wavArray, actArray, stack number, and current list name
    for(int q=0;q<n;q++){
      Serial.print(wavArray[q]);
      Serial.print("  ");
      Serial.print(actArray[q]);
      Serial.print("  ");
      Serial.println(list[k]);
    }
    delay(1000);        
  }
}
void loop()
{

}

//Function for parsing data from micor SD to array
///***
//*  FUNCTION:  ParseList
//*
//*  PURPOSE:  Read a text file, parse it, and output data into arrays
//*
//*  CALL:  parselist(name)
//*
//*  WHERE:  i = Integer corresponding to the list number to load
//*
//*  INPUTS:  myFile (global) = Global File variable that holds the loaded file incoming data
//*                                                note that incoming data consists of a simple text file with each line 
//*                                                 ending with cr lf embedded ascii characters
//*
//*  OUTPUTS:  wave file names into wavArray[] and their pointers into a parallel array, actArray[]
//*      wavArray (global) = Global array that holds the wave file names, left justified in the array
//*           actArray (global) = Global array that holds the corresponding wave file actions, left justified 
//*
//*  Function RETURN : Returns :  Positive = integer number of entries found, max 12
//*/


int ParseData(char* name)
{

  String bufferString; //buffer string that contains data from the text file, temporarily 
  uint8_t j=0;//row variable

  myFile = SD.open(name); //open file for reading
  if (myFile) 
  {//if file is open
    while (myFile.available()) 
    {//repeat until there is nothing else to be read on the file
      for (int n=0;n<13;n++){
        wavArray[j][n]=0;
        actArray[j][n]=0;
      }
      char c=myFile.read(); //read data from the text file
      if (c=='\r'||c=='\n'||c==' '||c=='('||c==')')
      {
        //do not copy data ino buffer string if it corresponds to the above characters
      }
      else
      {
        bufferString+=c; //copy data to buffer string
      }

      if(c=='\n')
      {//if you have reached the end of a line
        uint8_t startIndex=bufferString.indexOf(',',bufferString.indexOf(',')+1); //set a start index to aid in searching for the action
        for (int i=0;i<bufferString.length();i++)
        {//repeat until you reach the end of the bufferString string
          if (bufferString[0]=='/')
          {//if the buffer starts with / it is a comment, ignore parsing data
            j-=1;
            break;
          }
          else if(bufferString[i]=='/')
          {//if the is a comment on the same line with valid data (after the valid data) break operation
            if (actArray[j][0]=='L')
            {//add .txt to actArray if data starts with "L"
              actArray[j][(i)-(startIndex+1)]='.';
              actArray[j][(i+1)-(startIndex+1)]='t';
              actArray[j][(i+2)-(startIndex+1)]='x';
              actArray[j][(i+3)-(startIndex+1)]='t';
            }              
            else
            {//add .wav if data does not start with "L"
              actArray[j][(i)-(startIndex+1)]='.';
              actArray[j][(i+1)-(startIndex+1)]='w';
              actArray[j][(i+2)-(startIndex+1)]='a';
              actArray[j][(i+3)-(startIndex+1)]='v';
            }
            if(bufferString[i+1]=='/')break;//break operation
          } 
          else if (bufferString[0]!='\0'&&bufferString[i]!='/')
          {//if buffersting contains text that is not a comment
            if(i<bufferString.indexOf(','))
            {//parse the text that is before the first comma onto  wavArray
              wavArray[j][i]=bufferString[i];
            }
            else if(i==bufferString.indexOf(','))
            { //add .wav after the parsed data once data has been parsed
              wavArray[j][i]='.';
              wavArray[j][i+1]='w';
              wavArray[j][i+2]='a';
              wavArray[j][i+3]='v';
            }
            else if(i>startIndex&&i<bufferString.length())
            {//parse the text that is after the second comma onto actArray
              actArray[j][i-(startIndex+1)]=bufferString[i];
              if (i==(bufferString.length()-1))
              {//if data has been parsed completely
                if (actArray[j][0]=='L')
                {//add .txt if data starts with "L"
                  actArray[j][(i+1)-(startIndex+1)]='.';
                  actArray[j][(i+2)-(startIndex+1)]='t';
                  actArray[j][(i+3)-(startIndex+1)]='x';
                  actArray[j][(i+4)-(startIndex+1)]='t';
                }              
                else
                {//add .wav if data does not start with "L"
                  actArray[j][(i+1)-(startIndex+1)]='.';
                  actArray[j][(i+2)-(startIndex+1)]='w';
                  actArray[j][(i+3)-(startIndex+1)]='a';
                  actArray[j][(i+4)-(startIndex+1)]='v';
                }
              }
            }            
          }
        }
        bufferString="";
        j+=1;
      }
    }
    // close the file:
    myFile.close();
  }
  else 
  {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  if (j>0)return(j);//return positive value equal to number of entries on each array
  else return(-1); //return negative value if no data is parsed
}

But when I try to combine them, nothing happens, the following code compiles, but does not work:

#include <SD.h>
#include <FatReader.h>
#include <SdReader.h>
#include "WaveUtil.h"
#include "WaveHC.h"

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

File myFile; //used with SD card reader

char wavArray[12][13];

char actArray[12][13];    //actArray[i][j] refers to ith row jth column

// this handy function will return the number of bytes currently free in RAM, great for debugging!*(entire function)   
int reeRam(void)    
{
  extern int  __bss_end; 
  extern int  *__brkval; 
  int free_memory; 
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end); 
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval); 
  }
  return free_memory; 
} 

// checks card for errors*(function)
void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  // set up serial port
  Serial.begin(9600);

  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad*
  Serial.println(FreeRam());      // if this is under 150 bytes it may spell trouble!*

  // Set the output pins for the DAC control. This pins are defined in the library*
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);


  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you*
  if (!card.init()) {         //play with 8 MHz spi (default faster!)*
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why*
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!*
  }

  // enable optimize read - some cards may timeout. Disable if you're having problems*
  card.partialBlockRead(true);

  // Now we will look for a FAT partition!*
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in*
    if (vol.init(card, part)) 
      break;                             // we found one, lets bail*
  }
  if (part == 5) {                       // if we ended up not finding one  :(*
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why*
    while(1);                            // then 'halt' - do nothing!*
  }

  // Lets tell the user about what we found*
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?*

  // Try to open the root directory*
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,*
    while(1);                             // then 'halt' - do nothing!*
  }

  // Whew! We got past the tough parts.*
  putstring_nl("Ready!");
}

void loop(){

  int n=ParseData("L21.txt");
  for(int i=0;i<n;i++){
    PlayPhrase(wavArray[i]);
  }
}

void PlayPhrase(char* name) 
{

  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); 
    Serial.print(name); 
    return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); 
    return;
  }

  // ok time to play! start playback
  wave.play();
  int i=0;
  while(wave.isplaying){
    i++;
    Serial.println(i);
    if(i>125){
      wave.stop();
    }
  } 
}

int ParseData(char* name)
{
  if (!SD.begin()) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  String bufferString; //buffer string that contains data from the text file, temporarily 
  uint8_t j=0;//row variable

  myFile = SD.open(name); //open file for reading
  if (myFile) 
  {//if file is open
    while (myFile.available()) 
    {//repeat until there is nothing else to be read on the file
      for (int n=0;n<13;n++){
        wavArray[j][n]=0;
        actArray[j][n]=0;
      }
      char c=myFile.read(); //read data from the text file
      if (c=='\r'||c=='\n'||c==' '||c=='('||c==')')
      {
        //do not copy data ino buffer string if it corresponds to the above characters
      }
      else
      {
        bufferString+=c; //copy data to buffer string
      }

      if(c=='\n')
      {//if you have reached the end of a line
        uint8_t startIndex=bufferString.indexOf(',',bufferString.indexOf(',')+1); //set a start index to aid in searching for the action
        for (int i=0;i<bufferString.length();i++)
        {//repeat until you reach the end of the bufferString string
          if (bufferString[0]=='/')
          {//if the buffer starts with / it is a comment, ignore parsing data
            j-=1;
            break;
          }
          else if(bufferString[i]=='/')
          {//if the is a comment on the same line with valid data (after the valid data) break operation
            if (actArray[j][0]=='L')
            {//add .txt to actArray if data starts with "L"
              actArray[j][(i)-(startIndex+1)]='.';
              actArray[j][(i+1)-(startIndex+1)]='t';
              actArray[j][(i+2)-(startIndex+1)]='x';
              actArray[j][(i+3)-(startIndex+1)]='t';
            }              
            else
            {//add .wav if data does not start with "L"
              actArray[j][(i)-(startIndex+1)]='.';
              actArray[j][(i+1)-(startIndex+1)]='w';
              actArray[j][(i+2)-(startIndex+1)]='a';
              actArray[j][(i+3)-(startIndex+1)]='v';
            }
            if(bufferString[i+1]=='/')break;//break operation
          } 
          else if (bufferString[0]!='\0'&&bufferString[i]!='/')
          {//if buffersting contains text that is not a comment
            if(i<bufferString.indexOf(','))
            {//parse the text that is before the first comma onto  wavArray
              wavArray[j][i]=bufferString[i];
            }
            else if(i==bufferString.indexOf(','))
            { //add .wav after the parsed data once data has been parsed
              wavArray[j][i]='.';
              wavArray[j][i+1]='w';
              wavArray[j][i+2]='a';
              wavArray[j][i+3]='v';
            }
            else if(i>startIndex&&i<bufferString.length())
            {//parse the text that is after the second comma onto actArray
              actArray[j][i-(startIndex+1)]=bufferString[i];
              if (i==(bufferString.length()-1))
              {//if data has been parsed completely
                if (actArray[j][0]=='L')
                {//add .txt if data starts with "L"
                  actArray[j][(i+1)-(startIndex+1)]='.';
                  actArray[j][(i+2)-(startIndex+1)]='t';
                  actArray[j][(i+3)-(startIndex+1)]='x';
                  actArray[j][(i+4)-(startIndex+1)]='t';
                }              
                else
                {//add .wav if data does not start with "L"
                  actArray[j][(i+1)-(startIndex+1)]='.';
                  actArray[j][(i+2)-(startIndex+1)]='w';
                  actArray[j][(i+3)-(startIndex+1)]='a';
                  actArray[j][(i+4)-(startIndex+1)]='v';
                }
              }
            }            
          }
        }
        bufferString="";
        j+=1;
      }
    }
    // close the file:
    myFile.close();
  }
  else 
  {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  if (j>0)return(j);//return positive value equal to number of entries on each array
  else return(-1); //return negative value if no data is parsed
}

Does anyone have any clue what could be happening? Could I be running out of memory or something?

Thanks in advance.