00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #ifndef SFML_SOUNDRECORDER_HPP
00026 #define SFML_SOUNDRECORDER_HPP
00027
00029
00031 #include <SFML/System/Thread.hpp>
00032 #include <vector>
00033
00034
00035 namespace sf
00036 {
00041 class SFML_API SoundRecorder : private Thread
00042 {
00043 public :
00044
00045 typedef bool (*FuncType)(const Int16*, std::size_t, void*);
00046
00055 SoundRecorder(FuncType Callback, void* UserData = NULL);
00056
00061 virtual ~SoundRecorder();
00062
00071 void Start(unsigned int SampleRate = 44100);
00072
00077 void Stop();
00078
00085 unsigned int GetSampleRate() const;
00086
00094 static bool CanCapture();
00095
00096 protected :
00097
00102 SoundRecorder();
00103
00104 private :
00105
00115 virtual bool ProcessSamples(const Int16* Samples, std::size_t SamplesCount);
00116
00121 virtual void Run();
00122
00127 void ProcessCapturedSamples();
00128
00133 void CleanUp();
00134
00136
00138 FuncType myCallback;
00139 void* myUserData;
00140 std::vector<Int16> mySamples;
00141 unsigned int mySampleRate;
00142 bool myIsCapturing;
00143 };
00144
00145 }
00146
00147
00148 #endif // SFML_SOUNDRECORDER_HPP