This sample will play a ".wav" file of the USB root folder. Only RIFF format.

Fork of GR-PEACH_Audio_WAV by Daiki Kato

Audio sample for GR-PEACH or GR-LYCHEE. This sample will play a ".wav" file in the root of USB memory or SD card. If the USER_BUTTON0 is pressed, the next song is played.

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

Please refer to following link about Audio/Camera Shield.
https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield

For GR-PEACH:

FormatWav file (RIFF format) ".wav"
Channel2ch
Frequencies32kHz, 44.1kHz, 48kHz, 88.2kHz and 96kHz
Quantization bit rate16bits, 24bits and 32bits


For GR-LYCHEE:

FormatWav file (RIFF format) ".wav"
Channel2ch
Frequencies32kHz, 44.1kHz and 48kHz
Quantization bit rate16bits



  • Use USB0 of PEACH:
    /media/uploads/dkato/audio_wav_usb0.png

    If you use the USB0 as USB Host, please close GR-PEACH's JP3.
    /media/uploads/RyoheiHagimoto/usb.jpg

    Please select USB0 connector by the following configuration.

mbed_app.json

{
    "config": {
        "usb-host-ch":{
            "help": "(for GR-PEACH) 0:ch0 1:ch1",
            "value": "0"
        },
        "audio-camera-shield":{
            "help": "(for GR-PEACH) 0:not use 1:use",
            "value": "0"
        }
    }
}



  • Use USB1 of GR-PEACH:
    /media/uploads/dkato/audio_wav_usb1.png

    If you use the USB1 as USB Host, please close Audio/Camera Shield's JP1. /media/uploads/dkato/audiocamerashield_jp1.jpg

    Please select Audio/Camera Shield and USB1 connector by the following configuration.

mbed_app.json

{
    "config": {
        "usb-host-ch":{
            "help": "(for GR-PEACH) 0:ch0 1:ch1",
            "value": "1"
        },
        "audio-camera-shield":{
            "help": "(for GR-PEACH) 0:not use 1:use",
            "value": "1"
        }
    }
}
Revision:
5:983467c1466b
Parent:
4:01651a6c3f9a
Child:
6:ad0b3ce4284b
--- a/dec_wav.h	Wed Jun 24 09:05:12 2015 +0000
+++ b/dec_wav.h	Wed Jun 24 10:00:46 2015 +0000
@@ -19,7 +19,7 @@
      * @param fp file pointer
      * @return true = success, false = failure
      */
-    bool analyze_heder(uint8_t * p_title, uint8_t * p_artist, uint8_t * p_album, uint16_t tag_size, FILE * fp) {
+    bool AnalyzeHeder(uint8_t * p_title, uint8_t * p_artist, uint8_t * p_album, uint16_t tag_size, FILE * fp) {
         bool result = false;
         size_t read_size;
         uint8_t wk_read_buff[36];
@@ -31,9 +31,6 @@
         uint32_t read_index = 0;
         uint32_t data_index = 0;
         uint16_t wk_len;
-        uint16_t ch;
-        uint32_t sampling_rate;
-        uint16_t block_size;
 
         if (fp == NULL) {
             return false;
@@ -62,13 +59,13 @@
             // do nothing
         } else {
             read_index += 36;
-            ch = ((uint32_t)wk_read_buff[22] << 0) + ((uint32_t)wk_read_buff[23] << 8);
+            channel = ((uint32_t)wk_read_buff[22] << 0) + ((uint32_t)wk_read_buff[23] << 8);
             sampling_rate = ((uint32_t)wk_read_buff[24] << 0)
                           + ((uint32_t)wk_read_buff[25] << 8)
                           + ((uint32_t)wk_read_buff[26] << 16)
                           + ((uint32_t)wk_read_buff[27] << 24);
             block_size = ((uint32_t)wk_read_buff[34] << 0) + ((uint32_t)wk_read_buff[35] << 8);
-            if ((ch != 2) || (block_size != 16) || (sampling_rate != 44100)) {
+            if ((channel != 2) || (block_size != 16) || (sampling_rate != 44100)) {
                 return false;
             }
             while (1) {
@@ -152,7 +149,7 @@
      * @param len data buffer length
      * @return get data size
      */
-    size_t get_next_data(void *buf, size_t len) {
+    size_t GetNextData(void *buf, size_t len) {
         if ((music_data_index + len) > music_data_size) {
             len = music_data_size - music_data_index;
         }
@@ -161,8 +158,35 @@
         return fread(buf, sizeof(char), len, wav_fp);
     };
 
+    /** get channel
+     *
+     * @return channel
+     */
+    uint16_t GetChannel() {
+        return channel;
+    };
+
+    /** get block size
+     *
+     * @return block size
+     */
+    uint16_t GetBlockSize() {
+        return block_size;
+    };
+
+    /** get sampling rate
+     *
+     * @return sampling rate
+     */
+    uint16_t GetSamplingRate() {
+        return sampling_rate;
+    };
+
 private:
     FILE * wav_fp;
     uint32_t music_data_size;
     uint32_t music_data_index;
+    uint16_t channel;
+    uint16_t block_size;
+    uint32_t sampling_rate;
 };