a
Dependencies: 4DGL-uLCD-SE LSM9DS1_Library_cal SDFileSystem mbed-rtos mbed wave_player
playSound.cpp
00001 #include "playSound.h" 00002 #include "uLCD_4DGL.h" 00003 #include "SDFileSystem.h" 00004 #include "wave_player.h" 00005 00006 extern uLCD_4DGL uLCD; 00007 extern wave_player player; 00008 00009 // Given the filename of a .wav file in the SD card, play the file over the speaker. 00010 void playSound(char * wav) 00011 { 00012 // open wav file 00013 FILE *wave_file; 00014 wave_file=fopen(wav,"r"); 00015 00016 if(wave_file == NULL){ 00017 uLCD.locate(0,4); 00018 uLCD.printf("Error in SD"); 00019 return; 00020 } 00021 // play wav file 00022 player.play(wave_file); 00023 00024 // close wav file 00025 fclose(wave_file); 00026 }
Generated on Mon Jul 18 2022 22:47:22 by 1.7.2