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.
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer LCD_fonts MMA8452 SDFileSystem mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Diff: Sound/playSound.cpp
- Revision:
- 27:bd55ab4d137c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Sound/playSound.cpp Fri Oct 30 11:08:31 2015 +0000
@@ -0,0 +1,26 @@
+#include "playSound.h"
+#include "uLCD_4DGL.h"
+#include "SDFileSystem.h"
+#include "wave_player.h"
+
+extern uLCD_4DGL uLCD;
+extern wave_player player;
+
+// Given the filename of a .wav file in the SD card, play the file over the speaker.
+void playSound(char * wav)
+{
+ // open wav file
+ FILE *wave_file;
+ wave_file=fopen(wav,"r");
+
+ if(wave_file == NULL){
+ uLCD.locate(0,4);
+ uLCD.printf("Error in SD");
+ return;
+ }
+ // play wav file
+ player.play(wave_file);
+
+ // close wav file
+ fclose(wave_file);
+}
\ No newline at end of file
