This sample will play a ".wav" file of the USB root folder. Only RIFF format, 48kHz, 16bit, 2ch.

Dependencies:   USBHostDac USBHost_custom_Addiso

Fork of USBHostDac_example by GR-PEACH_producer_meeting

Isochronous transfer sample for GR-PEACH. This sample will play a ".wav" file of the USB root folder. Only RIFF format, 48kHz, 16bit, 2ch.

/media/uploads/dkato/usbdacsample.png
The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Revision:
3:ed025cdb164d
Parent:
2:4611f39d677b
Child:
4:c7cba8933302
--- a/main.cpp	Fri Jun 26 08:00:14 2015 +0000
+++ b/main.cpp	Fri Jun 26 08:05:15 2015 +0000
@@ -15,12 +15,11 @@
 DigitalIn  button(USER_BUTTON0);
 
 #define AUDIO_WRITE_BUFF_SIZE  (4096)
-#define AUDIO_WRITE_BUFF_NUM   (9)
 #define FILE_NAME_LEN          (64)
 #define TEXT_SIZE              (64 + 1) //null-terminated
 #define FLD_PATH               "/usb/"
 
-static uint8_t audio_write_buff[AUDIO_WRITE_BUFF_NUM][AUDIO_WRITE_BUFF_SIZE];
+static uint8_t audio_write_buff[AUDIO_WRITE_BUFF_SIZE];
 //Tag buffer
 static uint8_t title_buf[TEXT_SIZE];
 static uint8_t artist_buf[TEXT_SIZE];
@@ -30,7 +29,6 @@
     FILE * fp = NULL;
     DIR  * d = NULL;
     char file_path[sizeof(FLD_PATH) + FILE_NAME_LEN];
-    int buff_index = 0;
     size_t audio_data_size;
     dec_wav wav_file;
 
@@ -76,7 +74,7 @@
                             fp = NULL;
                         } else if ((wav_file.GetChannel() != 2)
                                 || (wav_file.GetBlockSize() != 16)
-                                || (wav_file.GetSamplingRate() != 44100)) {
+                                || (wav_file.GetSamplingRate() != 48000)) {
                             fclose(fp);
                             fp = NULL;
                         } else {
@@ -95,7 +93,7 @@
                 }
             } else {
                 // file read
-                uint8_t * p_buf = audio_write_buff[buff_index];
+                uint8_t * p_buf = audio_write_buff;
 
                 audio_data_size = wav_file.GetNextData(p_buf, AUDIO_WRITE_BUFF_SIZE);
                 if (audio_data_size > 0) {
@@ -109,10 +107,6 @@
                         flush = true;
                     }
                     usbdac.send(p_buf, audio_data_size, flush);
-                    buff_index++;
-                    if (buff_index >= AUDIO_WRITE_BUFF_NUM) {
-                        buff_index = 0;
-                    }
                 }
 
                 // file close