To understand how the sound library works you can read the Sound wiki page.
Copy and paste the generated code to the beginning of your Arduino Sketch.
To play a pattern named myPattern, use the following at any point of your program.
- Code: Select all
gb.sound.playPattern(myPattern, 0);
Code Example
This example plays myPattern when the button A is pressed
- Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
const uint16_t myPattern[] PROGMEM = {0x0005,0x3089,0x208,0x238,0x7849,0x1468,0x0000};
void setup(){
gb.begin();
gb.titleScreen(F("playPattern Example"));
}
void loop(){
if(gb.update()){
gb.display.println(F("Press \25 to play");
if(gb.buttons.pressed(BTN_A)){
gb.sound.playPattern(myPattern, 0);
}
if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("playPattern Example"));
}
}
}
Download
GitHub repo
Download ZIP
TODO
* save and open
* instruments, tracks
* audio playback