quosa wrote:Program runs with gamebuino library and TMRpcm-WAV library but hangs after playing first wav; any idea?
- Code: Select all
#include <SD.h>
#include <SPI.h>
#include <Gamebuino.h>
#include <TMRpcm.h>
Gamebuino gb;
TMRpcm tmrpcm;
#define SD_ChipSelectPin 10
#define SPEAKER 3
File dataFile;
void setup(){
pinMode(SD_ChipSelectPin, OUTPUT);
pinMode(SPEAKER, OUTPUT);
tmrpcm.speakerPin = SPEAKER; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
gb.begin();
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
Serial.println("SD fail");
return; // don't do anything more if not
}else
{
Serial.println("SD Ok");
}
initGame(); // Titlescreen
}
void initGame(){
gb.titleScreen(F("Quosa's Spacedelivery"));
//gb.popup(F("Game is not Saved!"), 100);
}
void loop(){
if(gb.update()){
if(gb.buttons.pressed(BTN_A)){
tmrpcm.play("2.wav");}
}
}
I don't know if you noticed it, but I actually contributed to the tmrpcm library. I made the ID3 tag parser.
Well, the problem is, that it takes way to much ram to work on the Gamebuino, which has a little less available user ram than the Arduino Uno, because of the screen. Also, the wav decoder sometimes crashes because of some garbage at the end. I made my player completely myself because of this ram problem, so no libs used. It has the exact same sound quality, but the files need to be converted to raw before played.
I have no ram problems, as I'm streaming directly from SD (with a 64 bytes ring buffer). If you need any help, just ask me. I'd also love if you contribute to my player, and help improving it, than making a race out of everything