Programming the adafruit wave shield?

Ok, so I really am extremely new to all of the arduino related stuff, but I am a student and I really want to learn. I have just finished assembling the wave shield and it is connected to my arduino uno. I have formatted the SD card following the instructions on adafruit, and I have my files correctly formatted to. But, I have looked at the code on the site and it makes no sense to me. If I try to use it, the arduino software throws countless errors at me. All I want to do essentially, is have a program where if I press a button, play soundfile 1, if I press a different button, play soundfile 2 etc. Or, even just how would I write a program just to play a file on the SD card, and then I can figure out how to merge that into if statements myself, I just need some help with the initial code and how it works. Thanks.

If you'd read the sticky, you'd know that if you want to post in this forum, you need to post your code. There is code, as you noted, on the Adafruit site.

If you fat-fingered the code, and have errors, you need to do more than tell us that there were countless numbers of them. You need to SHOW us the errors.

// Plays a full file from beginning to end with no pause. void playcomplete(char *name) { // call our helper to find and play this name playfile(name); while (wave.isplaying) { // do nothing while its playing } // now its done playing }

void playfile(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 (!, 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; }

So, that's the code from the site, it was from a hyper link that was called something like "play one wav file all the way through once" The error given is 'wave' was not declared in this scope.

The error given is 'wave' was not declared in this scope.

There is more to the error than that. There is more to the code than that.

Did you download and install the wave library in the proper place? Did you restart the IDE after doing that?

I didn't even know there was a wave libary. Oh jees, I'm not having a good night haha. I just want to test my wave shield by playing a wav file on the SD card which I converted to WAV following the instructions on the adafruit site. That's it, once I've done that, I can work on the code for my project myself, but I need to know if the wave shield works or not. Can you help me out at all or should I just give up and call it a night? xD

I didn't even know there was a wave libary.

So you do now. Download it and put it in the libraries folder. Then restart the arduino IDE.

Use your computer to put a wav file of the correct format with the correct file name onto your SD card. Transfer it to your wave shield and run the code you downloaded.

Alright, I'll do it all tomorrow, had a busy day and my head hurts, just want to call it a night. Thanks a lot though, :)

Alright, so I downloaded the WaveHC folder and all the rest and put them all into my main sketches folder, restarted the IDE, and tried to run the daphc code that plays all WAV files on the SD card. I’m still getting thrown errors, such as “variable or field ‘play’ declared void” I don’t understand why it will not work, I followed the readme file and did as it said.


  • 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

// 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

// 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 :frowning:
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. | LS_FLAG_FRAGMENTED);

//////////////////////////////////// LOOP
void loop() {

/////////////////////////////////// HELPERS

  • print error message and halt
    void error_P(const char str) {
    PgmPrint("Error: ");
  • 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);
  • 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 *)&[8], PSTR(“WAV”), 3)) {

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 (!, dirBuf)) { // open the file in the directory
error(“ failed”); // something went wrong

if (file.isDir()) { // check if we opened a new directory
putstring("Subdir: ");
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!; // make some noise!

uint8_t n = 0;
while (wave.isplaying) {// playing occurs in interrupts, so we print dots in realtime
if (!(++n % 32))Serial.println();
sdErrorCheck(); // everything OK?
// if (wave.errors)Serial.println(wave.errors); // wave decoding errors

I'm still getting thrown errors, such as "variable or field 'play' declared void"

Post the EXACT error message.There is likely still something wring with where you installed the libraries. A link to where you got them from would be helpful, too.

I have older versions of the libraries involved. I pasted your (improperly posted) code in the IDE, and got several errors related to using older versions of the libraries (pre 1.0 versions).

Once I modified all the libraries to play with 1.0.3, the code you posted compiled.

I installed all of the files/folders into C:\Users\Daniel\Documents\Arduino This is where all of my Arduino sketches are saved, and that error, variable or field 'play' declared void, is the exact error. I downloaded the latest rar file from the ada site, like clicked on the WaveHC link, and went to the top link on the downloads page with the most recent date on it, found here There is nothing higher than 1.0.

I installed all of the files/folders into C:\Users\Daniel\Documents\Arduino

There needs to be a libraries folder in the Arduino folder. It is in that libraries folder that WaveHC belongs, containing a bunch of files and folders.

and that error, variable or field 'play' declared void, is the exact error.

No, I'm sorry, but it isn't. Along with that error message is the exact name of the file that causes the error, and the line number in the file that the error occurred on. All that is important information, to me at least.

There is nothing higher than 1.0.

No major changes in the structure of the Arduino code have occurred since 1.0. There were major changes between 0023 and 1.0.

I downloaded the zip file at the top of the list in your link. I copied the WaveHC file from the zip file to C:\Users\PaulS\Documents\Arduino\libraries. I started the IDE. I pasted your code. I got one "error":

Binary sketch size: 12,606 bytes (of a 28,672 byte maximum)

Ahhh, I get you, there’s a libraries folder in the arduino program files part, I thought you meant libraries like my documents, my videos etc. I do apollogise for that. Now there are no errors coming up, I can;t thank you enough for your help and patience! Now I just need to reformat my SD card cuz if printed an error to the serial about the SD Card xD