This is a sample that drives a speaker with PWM.
Fork of GR-PEACH_Audio_WAV by
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.
| Format | Wav file (RIFF format) ".wav" |
| Channel | 1ch and 2ch |
| Frequencies | 32kHz, 44.1kHz and 48kHz |
| Quantization bit rate | 8bits 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 15:570acc3d2b89, committed 2018-07-24
- Comitter:
- dkato
- Date:
- Tue Jul 24 05:45:07 2018 +0000
- Parent:
- 14:f3eda9558df6
- Child:
- 16:63d0cf9e117b
- Commit message:
- upports mbed-os 5.9.1 and later
Changed in this revision
--- a/SDBlockDevice_GR_PEACH.lib Thu Jul 06 05:10:49 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/dkato/code/SDBlockDevice_GR_PEACH/#98b088c91edd
--- a/USBHost_custom.lib Thu Jul 06 05:10:49 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/Renesas/code/USBHost_custom/#cdc0d2ab4678
--- a/main.cpp Thu Jul 06 05:10:49 2017 +0000
+++ b/main.cpp Tue Jul 24 05:45:07 2018 +0000
@@ -1,9 +1,7 @@
#include "mbed.h"
#include "EasyPlaybackPWM.h"
#include "EasyDec_WavCnv2ch.h"
-#include "FATFileSystem.h"
-#include "SDBlockDevice_GR_PEACH.h"
-#include "USBHostMSD.h"
+#include "SdUsbConnect.h"
#define FILE_NAME_LEN (64)
#define MOUNT_NAME "storage"
@@ -20,9 +18,6 @@
DIR * d;
struct dirent * p;
char file_path[sizeof("/"MOUNT_NAME"/") + FILE_NAME_LEN];
- FATFileSystem fs("storage");
- SDBlockDevice_GR_PEACH sd;
- USBHostMSD usb;
// decoder setting
AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav");
@@ -36,17 +31,8 @@
// wait for the storage device to be connected
printf("Finding a storage...\r\n");
- while (1) {
- if (sd.connect()) {
- fs.mount(&sd);
- break;
- }
- if (usb.connect()) {
- fs.mount(&usb);
- break;
- }
- Thread::wait(500);
- }
+ SdUsbConnect storage(MOUNT_NAME);
+ storage.wait_connect();
printf("done\r\n");
while(1) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-gr-libs.lib Tue Jul 24 05:45:07 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/d-kato/mbed-gr-libs/#96620c101d2ba348ef418a03f77928242503a718
--- a/mbed-os.lib Thu Jul 06 05:10:49 2017 +0000 +++ b/mbed-os.lib Tue Jul 24 05:45:07 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#f4864dc6429e1ff5474111d4e0f6bee36a759b1c +https://github.com/ARMmbed/mbed-os/#50bd61a4a72332baa6b1bac6caccb44dc5423309
