i have this project in which i have to use a yun and a usb sound card to randomly play mp3's stored in my sd card. i followed this tutorial and it works
however i need help in creating a code that with the one push of a button will play a mp3 sound from the sd card randomly. i have 10 or more sound clips which i want to play randomly and need help with this
i was wondering if there is a way in which the yun can read the number of files inside the sd card first, store them in a array. then read all the file names inside the sd and then produce the sounds
You don't have to quote my post, what I wrote is already there
I use "/mnt/sd" and let OpenWRT make that into "/mnt/sda1".
I'm using "SerialUSB", that seems to be the new preferred name.
Because my folder with mp3 files are part of a website, I have it located a few folders deep.
You want to redirect the output of the wordcount into a folder ? It is simpler as you can see in this example:
// Number of files in the mp3 folder
SerialUSB.print(F( "Number of files in mp3 folder : "));
yunProcess.runShellCommand(F( "ls /mnt/sd/arduino/www/mp3 | wc -l"));
int result = yunProcess.parseInt();
SerialUSB.println( result);
// Remove any remaining characters
while(yunProcess.available() > 0)
yunProcess.read();
SerialUSB.println();
For the FileIO I have included FileIO.h and have called FileSystem.begin() in setup().
// List the files in the mp3 folder
int found = 0;
File folder = FileSystem.open( "/mnt/sd/arduino/www/mp3");
folder.rewindDirectory();
while( File entry = folder.openNextFile()) // stops if openNextFile returns zero
{
found++;
SerialUSB.println( entry.name());
if( entry.isDirectory())
found--;
}
SerialUSB.print(F( "Number of files found: "));
SerialUSB.println( found);
SerialUSB.println();