Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
// this is the minimal working code to add audio to a project. This code library will allow you to pause and resume waves, and allow fat32 file format
#include "SdReader.h"
#include "FatReader.h"
#include "WaveHC.h"
#include <avr/pgmspace.h>
#include "WaveUtil.h"
char fire[] = "RIFLE.WAV";
char shotty[] = "SHOTGUN.WAV";
SdReader card;
FatVolume vol;
FatReader root;
FatReader f;
WaveHC wave; // only one!
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Ready");
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
if (!card.init()) {
putstring_nl("Card init. failed!");
return;
}
if (!vol.init(card)) {
putstring_nl("No partition!");
return;
}
if (!root.openRoot(vol)) {
putstring_nl("Couldn't open dir");
return;
}
//putstring_nl("Files found:");
}
void loop()
{
playfile(shotty);
delay(10);
wave.pause();
delay(60);
wave.resume();
delay(2000);
playfile(fire);
delay(2000); // if next wave starts, it will just skip it all together w/o some form of delay (IE, take hit will over-rite any other sounds etc
}
void playfile(char *name) {
if (wave.isplaying) {// already playing something, so stop it!
wave.stop(); // stop it
}
if (!f.open(root, name)) {
putstring("Couldn't open file ");
Serial.print(name);
return;
}
if (!wave.create(f)) {
putstring_nl("Not a valid WAV");
return;
}
// ok time to play!
wave.play();
}
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
Re: FAT32/SDHC library for Wave and other shields
init time: 40
Card type: SD1
readCID failedSD error
errorCode: 8
errorData: 0
Re: FAT32/SDHC library for Wave and other shields