![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
statescriptMP
Dependencies: SMARTWAV USBDevice mbed
Diff: soundControl.cpp
- Revision:
- 0:9d97f34c6f46
diff -r 000000000000 -r 9d97f34c6f46 soundControl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/soundControl.cpp Mon May 18 01:18:45 2015 +0000 @@ -0,0 +1,71 @@ +#include "soundControl.h" + +extern SMARTWAV sWav; +extern Serial pc; + +soundControl::soundControl(void): + fileNameExists(false), + volumePtr(NULL), + volume(-1), + play(true), + reset(false) { + +} + +void soundControl::setFile(string fileNameIn) { + for (int i = 0; i < 20; i++) { + fileName[i] = NULL; + } + std::size_t length = fileNameIn.size(); + if (length <= 20) { + fileNameIn.copy(fileName, length, 0); + fileNameExists = true; + } +} +void soundControl::setVolume(int volumeIn) { + + if ((volumeIn >= 0) && (volumeIn < 256)) { + volume = volumeIn; + volumePtr = NULL; + } +} + +void soundControl::setVolume(int* volumeIn) { + + volume = -1; + volumePtr = volumeIn; + +} + +void soundControl::setPlayback(bool playIn) { + play = playIn; +} + +void soundControl::setReset() { + reset = true; +} + +void soundControl::execute() { + + if (reset) { + sWav.reset(); + } else if (!play) { + sWav.stopTrack(); + } else { + if (volume > -1) { + sWav.volume(volume); + } else if (volumePtr != NULL) { + sWav.volume(*volumePtr); + } + + if (fileNameExists) { + //sWav.playTracks(); + sWav.stopTrack(); + wait_ms(30);\\ANDY + sWav.playTrackName(fileName); + } + } +} + + +