Controls: D-Pad: [Arrows / WASD] - A: [J] - B: [K] - Menu: [U] - Home: [I]
Enjoy games at full speed with sound and lights on the Gamebuino META!
Emulator by aoneill

This is a little WAV player.

It will list all WAV files you placed into the "WAVFiles" Folder.

At the moment 100 Files are supported (you can change this at #define MAX_TRACKS 100)

Please don't rename the Folders, because the Player needs a constant path.


Buttons:

A - Start playing of the selected File

UP - Go up

Down - Go down


The wave files included are only for testing and I got them from the "picomon" Game 

WAVPlayer.zip




#include 
#define MAX_TRACKS 100
const char* path = "/WAVPlayer/WAVFiles/";
String wavFileNames[MAX_TRACKS];
const char* wavFileList[MAX_TRACKS];
String playingTrack = "";
int8_t wavfileCount = 0;
int8_t track = -1;

void setup() { gb.begin(); SerialUSB.begin(9600); list(); }

void loop() { // put your main code here, to run repeatedly: while (!gb.update()); // clear the previous screen gb.display.clear(); gb.display.println("Playing: "); gb.display.println(playingTrack); gb.display.println(""); gb.display.println("Press A to Stop");

if (gb.buttons.pressed(BUTTON_A)) { gb.sound.stop(track); track = -1; list(); } }

void scan() { wavfileCount = 0; SdBaseFile s; SdFile file; s.open(path, O_READ); while (1) { char name[255]; if (!file.openNext(&s, O_READ)) break; bool isDir = file.isDir(); file.getName(name, 255); file.close(); if (!isDir) { String fileName = String(name); if (fileName.indexOf(".wav") >= 0 || fileName.indexOf(".WAV") >= 0 ) { wavFileNames[wavfileCount] = fileName; wavfileCount++; } } } s.close(); }

void list() { scan(); if (wavfileCount > 0) { for (int i = 0; i < wavfileCount; i++) { wavFileList[i] = (const char *)wavFileNames[i].c_str(); } uint8_t entry = gb.gui.menu("File List", wavFileList, wavfileCount); if (wavFileList[entry] != "") { gb.gui.popup(wavFileList[entry], 200); playingTrack = wavFileList[entry]; String trackPath = String(path) + String(wavFileList[entry]); track = gb.sound.play(trackPath.c_str()); } } }

Last comments

avatar
gamebuino-admin
5 months ago
Author :  ripper121

No only WAV.

Take a look to Odroid Go, this device can Play MP3 because it uses a ESP32

avatar
gamebuino-admin
5 months ago
Author :  Flobann

Sorry, actually I just want to know if I can put music like an MP3 ??

avatar
gamebuino-admin
5 months ago
Author :  jicehel

??? I don't understand the question. This player is to play .wav music but i don't know if it's answer to your question because i don't have well understood what you would ask. Sorry