Sound recorder and playback device
Dependents: Seeed_Grove_Recorder_Example
Diff: GroveRecorder.h
- Revision:
- 0:2d4b0841e58c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GroveRecorder.h Thu Apr 30 19:49:15 2015 +0000 @@ -0,0 +1,77 @@ +#ifndef _GROVE_RECORDER_H_ +#define _GROVE_RECORDER_H_ + +#include "mbed.h" + +/** GroveDetector class. + * Used to control recording and playblack of sounds using this component: http://www.seeedstudio.com/depot/Grove-Recorder-p-1825.html + */ +class GroveRecorder { +public: + /** + * Constructor. Initializes the maximum record/playback sound to defaultMaxSoundTime. + * + * @param recordPin The pin that controls recording. + * @param playPin The pin that controls playback. + */ + GroveRecorder(PinName recordPin, PinName playPin); + + /** + * Starts a new recording. + * + * @param time Controls how long to record. + */ + void startRecording(float time); + + /** + * Starts a new recording with a length of the maximum time. + */ + void startRecordingMaxTime(); + + /** + * Stops the current recording. + */ + void stopRecording(); + + /** + * Starts playback of the previous recording. + * + * @param time Controls how long to play the last recording. + */ + void startPlaying(float time); + + + /** + * Starts playback of the previous recording up to the maximum time. + */ + void startPlayingMaxTime(); + + /** + * Stops the current playback + */ + void stopPlaying(); + + /** + * Set the default max recording and playback time. The default is 10 seconds. + * + * @param maxTime The maximum time in seconds to record and playback sounds. + */ + void setMaxSoundTime(float maxTime); + + +private: + /** + * Default sound recording/playback is 10 seconds + */ + const static float defaultMaxSoundTime = 10.0f; + + float maxSoundTime; + + DigitalOut record; + DigitalOut play; + + Timeout recordTimeout; + Timeout playTimeout; +}; + +#endif \ No newline at end of file