Sexy_Slenderman

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.

Sexy_Slenderman

// 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 (!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();}

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.

Sexy_Slenderman

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

Sexy_Slenderman

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 cardFatVolume vol; // This holds the information for the partition on the cardFatReader root; // This holds the information for the volumes root directoryWaveHC wave; // This is the only wave (audio) object, since we will only play one at a time

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

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

Sexy_Slenderman

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 http://code.google.com/p/wavehc/downloads/list 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.

Quote

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.

Quote

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":

Quote

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

The art of getting good answers lies in asking good questions.

Sexy_Slenderman

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