Daiki Kato / Mbed OS GR-PEACH_Audio_WAV_PwmOut Featured

Dependencies:   EasyPlayback

Fork of GR-PEACH_Audio_WAV by Renesas

This is a sample that drives a speaker with PWM. This sample will play a ".wav" file of the microSD or USB memory root folder. If the USER_BUTTON0 is pressed, the next song is played.

/media/uploads/dkato/pwm_speaker_img.png

FormatWav file (RIFF format) ".wav"
Channel1ch and 2ch
Frequencies32kHz, 44.1kHz and 48kHz
Quantization bit rate8bits and 16bits


You can adjust the volume by changing the following.

main.cpp

AudioPlayer.outputVolume(0.5);  // Volume control (min:0.0 max:1.0)


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:
7:4b6799c255ea
Parent:
5:983467c1466b
Child:
8:7121197d098e
--- a/main.cpp	Fri Jun 26 07:35:16 2015 +0000
+++ b/main.cpp	Tue Aug 18 04:19:19 2015 +0000
@@ -28,7 +28,7 @@
 static uint8_t artist_buf[TEXT_SIZE];
 static uint8_t album_buf[TEXT_SIZE];
 
-TLV320_RBSP audio(P3_13, P10_13, I2C_SDA, I2C_SCL, P4_4, P4_5, P4_7, P4_6,
+TLV320_RBSP audio(P10_13, I2C_SDA, I2C_SCL, P4_4, P4_5, P4_7, P4_6,
                   0x80, (AUDIO_WRITE_BUFF_NUM - 1), 0);
 
 static void callback_audio_write_end(void * p_data, int32_t result, void * p_app_data) {
@@ -89,15 +89,21 @@
                             fclose(fp);
                             fp = NULL;
                         } else if ((wav_file.GetChannel() != 2)
-                                || (wav_file.GetBlockSize() != 16)
-                                || (wav_file.GetSamplingRate() != 44100)) {
+                                || (audio.format(wav_file.GetBlockSize()) == false)
+                                || (audio.frequency(wav_file.GetSamplingRate()) == false)) {
+                            printf("Error File  :%s\n", p->d_name);
+                            printf("Audio Info  :%dch, %dbit, %dHz\n", wav_file.GetChannel(),
+                                    wav_file.GetBlockSize(), wav_file.GetSamplingRate());
+                            printf("\n");
                             fclose(fp);
                             fp = NULL;
                         } else {
-                            printf("File  :%s\n", p->d_name);
-                            printf("Title :%s\n", title_buf);
-                            printf("Artist:%s\n", artist_buf);
-                            printf("Album :%s\n", album_buf);
+                            printf("File        :%s\n", p->d_name);
+                            printf("Audio Info  :%dch, %dbit, %dHz\n", wav_file.GetChannel(),
+                                    wav_file.GetBlockSize(), wav_file.GetSamplingRate());
+                            printf("Title       :%s\n", title_buf);
+                            printf("Artist      :%s\n", artist_buf);
+                            printf("Album       :%s\n", album_buf);
                             printf("\n");
                             break;
                         }