Go Down

Topic: Help w/ Wave Shield for Arduino Uno (Read 254 times) previous topic - next topic

Cabron

Apr 17, 2014, 08:53 pm Last Edit: Apr 17, 2014, 09:54 pm by Cabron Reason: 1
Hello,

I hope you are all well.

I am trying to test my waveshield with my Arduino Uno board.

I am following this tutorial: https://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino/wavehc-library

The code I've been using, suggested by the tutorial is as it followos:


#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

uint8_t dirLevel; // indent level for file/dir names    (for prettyprinting)
//dir_t dirBuf;     // buffer for directory reads

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


void setup() {
 Serial.begin(9600);           // set up Serial library at 9600 bps for debugging
 
 putstring_nl("\nWave test!");  // say we woke up!
 
 putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad

 // 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("Files found:");
 dirLevel = 0;
 // Print out all of the files in all the directories.
 lsR(root);
}

/*
* list recursively - possible stack overflow if subdirectories too nested
*/
void lsR(FatReader &d)
{
 int8_t r;                     // indicates the level of recursion
 
 while ((r = d.readDir(dirBuf)) > 0) {     // read the next file in the directory
   // skip subdirs . and ..
   if (dirBuf.name[0] == '.')
     continue;
   
   for (uint8_t i = 0; i < dirLevel; i++)
     Serial.print(' ');        // this is for prettyprinting, put spaces in front
   printEntryName(dirBuf);           // print the name of the file we just found
   Serial.println();           // and a new line
   
   if (DIR_IS_SUBDIR(dirBuf)) {   // we will recurse on any direcory
     FatReader s;                 // make a new directory object to hold information
     dirLevel += 2;               // indent 2 spaces for future prints
     if (s.open(vol, dirBuf))
       lsR(s);                    // list all the files in this directory now!
     dirLevel -=2;                // remove the extra indentation
   }
 }
 sdErrorCheck();                  // are we doign OK?
}


/*
* print dir_t name field. The output is 8.3 format, so like SOUND.WAV or FILENAME.DAT
*/
void printEntryName(dir_t &dir)
{
 for (uint8_t i = 0; i < 11; i++) {     // 8.3 format has 8+3 = 11 letters in it
   if (dir.name == ' ')
       continue;         // dont print any spaces in the name
   if (i == 8)
       Serial.print('.');           // after the 8th letter, place a dot
   Serial.print(dir.name);      // print the n'th digit
 }
 if (DIR_IS_SUBDIR(dir))
   Serial.print('/');       // directories get a / at the end
}

/*
* play recursively - possible stack overflow if subdirectories too nested
*/
void play(FatReader &dir)
{
 FatReader file;
 while (dir.readDir(dirBuf) > 0) {    // Read every file in the directory one at a time
   // skip . and .. directories
   if (dirBuf.name[0] == '.')
     continue;
   
   Serial.println();            // clear out a new line
   
   for (uint8_t i = 0; i < dirLevel; i++)
      Serial.print(' ');       // this is for prettyprinting, put spaces in front

   if (!file.open(vol, dirBuf)) {       // open the file in the directory
     Serial.println("file.open failed");  // something went wrong :(
     while(1);                            // halt
   }
   
   if (file.isDir()) {                    // check if we opened a new directory
     putstring("Subdir: ");
     printEntryName(dirBuf);
     dirLevel += 2;                       // add more spaces
     // play files in subdirectory
     play(file);                         // recursive!
     dirLevel -= 2;    
   }
   else {
     // Aha! we found a file that isnt a directory
     putstring("Playing "); printEntryName(dirBuf);       // print it out
     if (!wave.create(file)) {            // Figure out, is it a WAV proper?
       putstring(" Not a valid WAV");     // ok skip it
     } else {
       Serial.println();                  // Hooray it IS a WAV proper!
       wave.play();                       // make some noise!
     
       while (wave.isplaying) {           // playing occurs in interrupts, so we print dots in realtime
         putstring(".");
         delay(100);
       }
       sdErrorCheck();                    // everything OK?
//        if (wave.errors)Serial.println(wave.errors);     // wave decoding errors
     }
   }
 }
}

Unfortunatly, when I try to Verify/Upload, an error is given which states that 'sdErrorCheck was not declared in this scope.

Does anybody knows why and what I should do?

Many thanks for your help.

PaulS

Quote
Unfortunatly, when I try to Verify/Upload, an error is given which states that 'sdErrorCheck was not declared in this scope.

Does anybody knows why and what I should do?

Because it wasn't, and you should declare it in that scope.

You are trying to call that function, but you have not defined that function.

I'm pretty sure that i will never equal a smiley face, so you should delete all that code.


Go Up