a

Dependencies:   4DGL-uLCD-SE LSM9DS1_Library_cal SDFileSystem mbed-rtos mbed wave_player

Sound/playSound.cpp

Committer:
rmaran6
Date:
2016-11-02
Revision:
0:2b0c527942db

File content as of revision 0:2b0c527942db:

#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);
}