Wave Shield Error
Moderators: adafruit_support_bill, adafruit

Wave Shield Error

by warcow on Wed Mar 13, 2013 12:18 am

Hi,

I finished assembling my Wave shield but when I try to verify and upload the code I get errors. I get the errors when just verifying the code. So I don't think anything is wrong with my circuit. It should pass the compile verification. In fact any of the Wave shield example sketches I try I get errors compiling. I have uploaded other sketches to the board not related to the wave shield and they compile and upload just fine.

I just want the wave shield to play the one song on my SD Card in a continuous loop. Nothing complicated.


Here is the sketch I got when I downloaded the most up to date version of the wavehc Library. It is the one named daphc.pde
I just copied and pasted the code into the code editor window of the arduino IDE

Code: Select all | TOGGLE FULL SIZE
/*
 * This example plays every .WAV file it finds on the SD card in a loop
 */
#include <WaveHC.h>
#include <WaveUtil.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 volumes root directory
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

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


/*
 * Define macro to put error messages in flash memory
 */
#define error(msg) error_P(PSTR(msg))

// Function definitions (we define them here, but the code is below)
void play(FatReader &dir);

//////////////////////////////////// SETUP
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
  Serial.println(FreeRam());

  //  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!) 
    error("Card init. failed!");  // Something went wrong, lets print out why
  }
 
  // 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  :(
    error("No valid FAT partition!");  // Something went wrong, lets print out why
  }
 
  // 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)) {
    error("Can't open root dir!");      // Something went wrong,
  }
 
  // Whew! We got past the tough parts.
  putstring_nl("Files found (* = fragmented):");

  // Print out all of the files in all the directories.
  root.ls(LS_R | LS_FLAG_FRAGMENTED);
}

//////////////////////////////////// LOOP
void loop() {
  root.rewind();
  play(root);
}

/////////////////////////////////// HELPERS
/*
 * print error message and halt
 */
void error_P(const char *str) {
  PgmPrint("Error: ");
  SerialPrint_P(str);
  sdErrorCheck();
  while(1);
}
/*
 * print error message and halt if SD I/O error, great for debugging!
 */
void sdErrorCheck(void) {
  if (!card.errorCode()) return;
  PgmPrint("\r\nSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  PgmPrint(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}
/*
 * 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 it if not a subdirectory and not a .WAV file
    if (!DIR_IS_SUBDIR(dirBuf)
         && strncmp_P((char *)&dirBuf.name[8], PSTR("WAV"), 3)) {
      continue;
    }

    Serial.println();            // clear out a new line
   
    for (uint8_t i = 0; i < dirLevel; i++) {
       Serial.write(' ');       // this is for prettyprinting, put spaces in front
    }
    if (!file.open(vol, dirBuf)) {        // open the file in the directory
      error("file.open failed");          // something went wrong
    }
   
    if (file.isDir()) {                   // check if we opened a new directory
      putstring("Subdir: ");
      printEntryName(dirBuf);
      Serial.println();
      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!
       
        uint8_t n = 0;
        while (wave.isplaying) {// playing occurs in interrupts, so we print dots in realtime
          putstring(".");
          if (!(++n % 32))Serial.println();
          delay(100);
        }       
        sdErrorCheck();                    // everything OK?
        // if (wave.errors)Serial.println(wave.errors);     // wave decoding errors
      }
    }
  }
}


And here is the error's I get:

Code: Select all | TOGGLE FULL SIZE









daphc.pde:-1: error: variable or field 'play' declared void
daphc.pde:-1: error: 'FatReader' was not declared in this scope
daphc.pde:-1: error: 'dir' was not declared in this scope
daphc.pde:-1: error: 'SdReader' does not name a type
daphc.pde:-1: error: 'FatVolume' does not name a type
daphc.pde:-1: error: 'FatReader' does not name a type
daphc.pde:-1: error: 'WaveHC' does not name a type
daphc.pde:-1: error: 'dir_t' does not name a type
daphc.pde:-1: error: variable or field 'play' declared void
daphc.pde:-1: error: 'FatReader' was not declared in this scope
daphc.pde:-1: error: 'dir' was not declared in this scope
daphc.cpp: In function 'void setup()':
daphc.pde:-1: error: 'putstring_nl' was not declared in this scope
daphc.pde:-1: error: 'putstring' was not declared in this scope
daphc.pde:-1: error: 'FreeRam' was not declared in this scope
daphc.pde:-1: error: 'card' was not declared in this scope
daphc.pde:-1: error: 'card' was not declared in this scope
daphc.pde:-1: error: 'vol' was not declared in this scope
daphc.pde:-1: error: 'vol' was not declared in this scope
daphc.pde:-1: error: 'root' was not declared in this scope
daphc.pde:-1: error: 'root' was not declared in this scope
daphc.pde:-1: error: 'LS_R' was not declared in this scope
daphc.pde:-1: error: 'LS_FLAG_FRAGMENTED' was not declared in this scope
daphc.cpp: In function 'void loop()':
daphc.pde:-1: error: 'root' was not declared in this scope
daphc.pde:-1: error: 'play' was not declared in this scope
daphc.cpp: In function 'void error_P(const char*)':
daphc.pde:-1: error: 'PgmPrint' was not declared in this scope
daphc.pde:-1: error: 'SerialPrint_P' was not declared in this scope
daphc.cpp: In function 'void sdErrorCheck()':
daphc.pde:-1: error: 'card' was not declared in this scope
daphc.pde:-1: error: 'PgmPrint' was not declared in this scope
daphc.pde:-1: error: 'card' was not declared in this scope
daphc.cpp: At global scope:
daphc.pde:-1: error: variable or field 'play' declared void
daphc.pde:-1: error: 'FatReader' was not declared in this scope
daphc.pde:-1: error: 'dir' was not declared in this scope


Any help would be greatly appriciated

Thanks
Warcow
warcow
 
Posts: 8
Joined: Fri Feb 22, 2013 5:10 pm

Re: Wave Shield Error

by adafruit_support_mike on Wed Mar 13, 2013 2:09 am

It looks like the compiler can't find the WaveHC.h and WaveUtil.h headers.

If you launch the Arduino IDE, click on the 'Sketch' menu then select the 'Import Library...' item, do you see an item at the bottom of the popup menu named 'wavehc20110919'? If not, check to make sure the library is in the right place: inside a folder named 'libraries' in your sketchbook folder.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 10750
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield Error

by wiremanflash on Thu Mar 14, 2013 11:47 pm

details, details, details...

I downloaded the file wavehc20110919.zip and installed it and imported it correctly and have WaveHC listed as opposed to the answer given just above. That's 8 characters different, so I think WaveHC is what you should be seeing in your directory structure ("...\libraries\WaveHC\..") and
Arduino 1.0.4 > Sketch > Import Library > (pulldown list)
IDE GUI command structure.
wiremanflash
 
Posts: 14
Joined: Thu Mar 14, 2013 10:36 pm

Re: Wave Shield Error

by adafruit_support_mike on Fri Mar 15, 2013 12:17 am

You're right.. 'WaveHC' is the official name for the folder.

The name that appears in the menu doesn't have any effect on the Arduino IDE's ability to import libraries though. I just renamed the folder FooBar, restarted the IDE, did an import, and got exactly the right set of #includes.

The important thing is that the headers are in an immediate sub-folder of 'libraries' in the sketchbook folder. If not, the IDE doesn't know where to look.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 10750
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield Error

by wiremanflash on Sat Mar 16, 2013 12:44 am

So all the headers in your accessible libraries need unique names because their library name or folder name is only organizational for the user?
wiremanflash
 
Posts: 14
Joined: Thu Mar 14, 2013 10:36 pm

Re: Wave Shield Error

by adafruit_support_bill on Sat Mar 16, 2013 5:42 am

That is right. At startup, the IDE scans the top-level library folders looking for headers and building a list. If you have duplicate headers you will likely have compile problems.
User avatar
adafruit_support_bill
 
Posts: 31704
Joined: Sat Feb 07, 2009 10:11 am