Sound recorder and playback device
Dependents: Seeed_Grove_Recorder_Example
Diff: GroveRecorder.cpp
- Revision:
- 1:19584eb1fdf7
- Parent:
- 0:2d4b0841e58c
--- a/GroveRecorder.cpp Thu Apr 30 19:49:15 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -#include "GroveRecorder.h" - -GroveRecorder::GroveRecorder(PinName recordPin, PinName playPin) - : maxSoundTime(defaultMaxSoundTime), record(recordPin, 0), play(playPin, 0) { - // Empty -} - -void GroveRecorder::stopRecording() { - record = 0; -} - -void GroveRecorder::startRecording(float time) { - if (!record) { - if (time > maxSoundTime) { - time = maxSoundTime; - } - - record = 1; - recordTimeout.attach(this, &GroveRecorder::stopRecording, time); - } -} - -void GroveRecorder::startRecordingMaxTime() { - startRecording(maxSoundTime); -} - -void GroveRecorder::stopPlaying() { - play = 0; -} - -void GroveRecorder::startPlaying(float time) { - if (!play && !record) { - if (time > maxSoundTime) { - time = maxSoundTime; - } - - play = 1; - playTimeout.attach(this, &GroveRecorder::stopPlaying, time); - } -} - -void GroveRecorder::startPlayingMaxTime() { - startPlaying(maxSoundTime); -} - \ No newline at end of file