This program utilizes an LCD, RPG, 8 ohm speaker, and SD card to provide the basic functions of a music player. The project cycles through the SD card for .wav files and tracks elapsed time. See http://mbed.org/users/rsartin3/notebook/wav-player-with-RPG-based-menu/ for more information.

Dependencies:   DebounceIn RPG SDFileSystem TextLCD mbed wav_header wave_player

Fork of Audio_Player by Ryan Sartin

Revision:
1:f31b40073d35
Parent:
0:040129c3d961
Child:
2:d9953793444c
--- a/main.cpp	Mon Mar 04 22:37:29 2013 +0000
+++ b/main.cpp	Tue Mar 05 06:34:43 2013 +0000
@@ -1,7 +1,6 @@
 /*
-    MUSIC PLAYER HOORAY
-    wumbo
-*/
+ * Audio Player
+ */
 
 #include "mbed.h"
 #include "DebounceIn.h"
@@ -36,16 +35,16 @@
 AnalogOut DACout(p18);
 wave_player waver(&DACout);
 
-// Timer Junk
+// Ticker for interrupting song
 Ticker songTick;
 time_t time_i;
 
 struct playlist { 
         // Doubly-linked list to easily traverse between filenames
-        char s_name[30];      // File name without .wav extension
-        playlist *prev;                 // Pointer to next filename
-        playlist *next;                 // Pointer to previous filename
-};      // Structure name courtesy of Layla Marshall
+        char s_name[30]; // File name without .wav extension
+        playlist *prev;  // Pointer to next filename
+        playlist *next;  // Pointer to previous filename
+};
 
 void insert( struct playlist *root, string songName)
 {
@@ -77,11 +76,11 @@
     */
     DIR *d;                 // Directory pointer
     dirent *file;           // dirent to get file name
-   // playlist *curr = root;  // 
+    // playlist *curr = root;
     int count = 0;          // count of songs added to playlist
         
     if(DEBUG) pc.printf("\n\rWell... Let's get started!\r\n");
-    if((d = opendir(location)) == NULL) {       //Attempt to open directory at given location
+    if((d = opendir(location)) == NULL) { // Attempt to open directory at given location
         // If Error
         lcd.cls();
         lcd.printf("Unable to open directory!");
@@ -103,17 +102,17 @@
                 
                 if(count == 0){ // If still at root node
                     count++;    // Increment count
-                    strcpy(root->s_name, (str.substr(0,exten)).c_str()); //Copy filename into root node
-                //    curr = root;
+                    strcpy(root->s_name, (str.substr(0,exten)).c_str()); // Copy filename into root node
+                    // curr = root;
                 }else{
-                    count++;    // Increment count
+                    count++;                            // Increment count
                     insert(root,str.substr(0,exten));   // Add new song to playlist           
                 }
             }        
         }
         closedir(d);    // Close directory
     }
-    return count;   //Return number of songnames added to playlist
+    return count;       // Return number of songnames added to playlist
 }
 
 void printList(playlist *root) {
@@ -177,7 +176,6 @@
    // if(DEBUG) printf("Time Elapsed: %d. (Start: %d, Stop: %d)\n\r", time_f - time_i, time_i, time_f);
     lcd.locate(6,1);
     lcd.printf("%d", time_f - time_i + 1);
-
 }
 
 int main() {