Demo of Embedded Artists LPCXpresso baseboard SD card reader and audio facilities. Updated to put wav file player in a separate library and use the high capacity SD card library provided by Klaus Bu.

Dependencies:   mbed

Revision:
1:22c43c468a2f
Parent:
0:1f4b7aa80ab3
Child:
2:affcc36a50b4
--- a/main.cpp	Sat Jul 03 10:07:07 2010 +0000
+++ b/main.cpp	Fri Jul 09 14:25:50 2010 +0000
@@ -1,19 +1,16 @@
 /*
- Demo of Embedded Artists LPCXpresso baseboard SD card
- reader and audio facilities.
+ Demo of Embedded Artists LPCXpresso baseboard SD card reader and audio facilities.
 
- WAVEplayer by Vlad Cazan/Stephan Rochon modified by Tom Coxon 
- to run correctly on the Embedded Artists LPCXpresso baseboard.
+ Based on WAVEplayer by Vlad Cazan/Stephan Rochon modified by Tom Coxon to run correctly on
+ the Embedded Artists LPCXpresso baseboard.
  
- Also modified to play 8 bit sample size in addition to 
- original 16 bit.
+ Also modified to play 8 bit sample size in addition to original 16 bit and to be more fault tolerant 
+ when playing wav files.
  
- Place suitable wav files with 8 or 16 bit sample sizes on the
- SD card and ensure the file names are 8.3 format.  Then change
- the main method below to the relevant file paths. 
+ Place suitable uncompressed wav files with 8 or 16 bit sample sizes on the SD card and ensure the 
+ file names are 8.3 format.  Then change the main method below to the relevant file paths. 
  
- Please set all jumpers on board to the default case except for 
- the following:
+ Please set all jumpers on board to the default case except for the following:
  
  Audio setup:
  
@@ -113,6 +110,9 @@
     long slice,num_slices;
     DAC_wptr=0;
     DAC_rptr=0;
+    
+    size_t result;
+
     for (i=0;i<256;i+=2) {
         DAC_fifo[i]=0;
         DAC_fifo[i+1]=3000;
@@ -179,11 +179,14 @@
                 DAC_on=1;
                 led2=1;
                 for (slice=0;slice<num_slices;slice+=SLICE_BUF_SIZE) {
-                    fread(slice_buf,wav_format.block_align*SLICE_BUF_SIZE,1,wavfile);
+                
+                    result = fread(slice_buf,wav_format.block_align*SLICE_BUF_SIZE,1,wavfile);
                     if (feof(wavfile)) {
                         printf("Oops -- not enough slices in the wave file\r\n");
-                        exit(1);
+
+                        break;
                     }
+
                     data_sptr=(short *)slice_buf;
                     for (i=0;i<SLICE_BUF_SIZE;i++) {
                         dac_data=0;