Page 1 of 1

Gamebuino WAV player

PostPosted: Sun Aug 10, 2014 1:06 pm
by deepsheet
Just for fun, I used an Arduino WAV player library on the Gamebuino to test the quality of the speaker :)

Here are the results. I know there is already an audio demo, but it doesn't use WAV files read from the SD ;)

Unfortunately, enabling the Gamebuino library disables the WAV audio. Is there a way to "disable" Gamebuino's Sound library?

https://vine.co/v/MVxtgrWVvJH

Re: Gamebuino WAV player

PostPosted: Mon Aug 11, 2014 8:24 am
by ripper121
Go to the lib files search for it and write a If around it with a flag you can set in the ino file

Re: Gamebuino WAV player

PostPosted: Mon Aug 11, 2014 9:11 am
by rodot
You can set NUM_CHANNEL to 0 in the file settings.c in the Gamebuino library ;)

Re: Gamebuino WAV player

PostPosted: Mon Aug 11, 2014 8:39 pm
by albertinjo
What library have you used, can we have a look at the code please.

Re: Gamebuino WAV player

PostPosted: Fri Aug 15, 2014 2:31 pm
by deepsheet
Hello and sorry for the long delay :)

I used the https://github.com/TMRh20/TMRpcm library mainly because I have used it in the past for other Arduino projects. The only change you need to make is to uncomment USE_TIMER2 in pcmConfig.h and use pin 3 in your sketches :)

Everything else (including converting every file to wav) is included in the project wiki.

I was planning on making a simple wav player but lost interest in favor to other Gamebuino apps I'm planning :D

Re: Gamebuino WAV player

PostPosted: Fri Aug 15, 2014 3:03 pm
by Matrix828
deepsheet wrote:I was planning on making a simple wav player but lost interest in favor to other Gamebuino apps I'm planning :D


Like what? Details please, I'm curious :D

Re: Gamebuino WAV player

PostPosted: Sun Jan 11, 2015 11:42 pm
by quosa
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");}
      }
}

Re: Gamebuino WAV player

PostPosted: Thu May 21, 2015 11:40 am
by Muessigb
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 ;)