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/audio-player/ for more information.

Dependencies:   DebounceIn RPG SDFileSystem TextLCD mbed wav_header wave_player

Files at this revision

API Documentation at this revision

Comitter:
rsartin3
Date:
Tue Mar 05 06:34:43 2013 +0000
Parent:
0:040129c3d961
Commit message:
;

Changed in this revision

DebounceIn.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
wav_header.lib Show annotated file Show diff for this revision Revisions of this file
--- a/DebounceIn.lib	Mon Mar 04 22:37:29 2013 +0000
+++ b/DebounceIn.lib	Tue Mar 05 06:34:43 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/AjK/code/DebounceIn/#1f3e0982f89d
+http://mbed.org/users/rsartin3/code/DebounceIn/#1f3e0982f89d
--- 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() {
--- a/wav_header.lib	Mon Mar 04 22:37:29 2013 +0000
+++ b/wav_header.lib	Tue Mar 05 06:34:43 2013 +0000
@@ -1,1 +1,1 @@
-wav_header#a50bba1964ec
+http://mbed.org/users/rsartin3/code/wav_header/#a50bba1964ec