Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of GR-PEACH_Audio_WAV by
main.cpp
00001 #include "mbed.h" 00002 #include "SdUsbConnect.h" 00003 #include "EasyPlayback.h" 00004 #include "EasyDec_WavCnv2ch.h" 00005 00006 #define FNAME_LEN (64) 00007 #define MOUNT_NAME "storage" 00008 00009 static InterruptIn skip_btn(USER_BUTTON0); 00010 static EasyPlayback AudioPlayer(EasyPlayback::AUDIO_TPYE_PWM, P4_5, P4_7); 00011 00012 static void skip_btn_fall(void) { 00013 AudioPlayer.skip(); 00014 } 00015 00016 int main() { 00017 DIR * d; 00018 struct dirent * p; 00019 char file_path[sizeof("/"MOUNT_NAME"/") + FNAME_LEN]; 00020 SdUsbConnect storage(MOUNT_NAME); 00021 00022 AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav"); // decoder setting 00023 AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".WAV"); // decoder setting 00024 AudioPlayer.outputVolume(0.5); // Volume control (min:0.0 max:1.0) 00025 skip_btn.fall(&skip_btn_fall); // button setting 00026 00027 while (1) { 00028 storage.wait_connect(); 00029 d = opendir("/"MOUNT_NAME"/"); // file search 00030 while ((p = readdir(d)) != NULL) { 00031 size_t len = strlen(p->d_name); 00032 if (len < FNAME_LEN) { 00033 sprintf(file_path, "/%s/%s", MOUNT_NAME, p->d_name); // make file path 00034 printf("%s\r\n", file_path); 00035 AudioPlayer.play(file_path); // playback 00036 } 00037 } 00038 closedir(d); 00039 } 00040 }
Generated on Wed Jul 13 2022 00:51:59 by
1.7.2
