AsyncAudioRecorder.h

Go to the documentation of this file.
00001 
00027 #ifndef ASYNC_AUDIO_RECORDER_INCLUDED
00028 #define ASYNC_AUDIO_RECORDER_INCLUDED
00029 
00030 
00031 /****************************************************************************
00032  *
00033  * System Includes
00034  *
00035  ****************************************************************************/
00036 
00037 #include <stdint.h>
00038 #include <stdio.h>
00039 #include <sigc++/sigc++.h>
00040 
00041 #include <string>
00042 
00043 #include <AsyncAudioSink.h>
00044 
00045 
00046 /****************************************************************************
00047  *
00048  * Project Includes
00049  *
00050  ****************************************************************************/
00051 
00052 
00053 
00054 /****************************************************************************
00055  *
00056  * Local Includes
00057  *
00058  ****************************************************************************/
00059 
00060 
00061 
00062 /****************************************************************************
00063  *
00064  * Forward declarations
00065  *
00066  ****************************************************************************/
00067 
00068 
00069 
00070 /****************************************************************************
00071  *
00072  * Namespace
00073  *
00074  ****************************************************************************/
00075 
00076 namespace Async
00077 {
00078 
00079 
00080 /****************************************************************************
00081  *
00082  * Forward declarations of classes inside of the declared namespace
00083  *
00084  ****************************************************************************/
00085 
00086   
00087 
00088 /****************************************************************************
00089  *
00090  * Defines & typedefs
00091  *
00092  ****************************************************************************/
00093 
00094 
00095 
00096 /****************************************************************************
00097  *
00098  * Exported Global Variables
00099  *
00100  ****************************************************************************/
00101 
00102 
00103 
00104 /****************************************************************************
00105  *
00106  * Class definitions
00107  *
00108  ****************************************************************************/
00109 
00118 class AudioRecorder : public Async::AudioSink
00119 {
00120   public:
00121     typedef enum { FMT_RAW, FMT_WAV } Format;
00122     
00129     explicit AudioRecorder(const std::string& filename,
00130                            AudioRecorder::Format format=FMT_RAW,
00131                            int sample_rate=0);
00132   
00136     ~AudioRecorder(void);
00137   
00142     bool initialize(void);
00143     
00155     virtual int writeSamples(const float *samples, int count);
00156     
00165     virtual void flushSamples(void);
00166 
00167     
00168   private:
00169     std::string filename;
00170     FILE        *file;
00171     int         samples_written;
00172     Format      format;
00173     int         sample_rate;
00174     
00175     AudioRecorder(const AudioRecorder&);
00176     AudioRecorder& operator=(const AudioRecorder&);
00177     void writeWaveHeader(void);
00178     int store32bitValue(char *ptr, uint32_t val);
00179     int store16bitValue(char *ptr, uint16_t val);
00180 
00181 };  /* class AudioRecorder */
00182 
00183 
00184 } /* namespace */
00185 
00186 #endif /* ASYNC_AUDIO_RECORDER_INCLUDED */
00187 
00188 
00189 
00190 /*
00191  * This file has not been truncated
00192  */
00193 
Generated by  doxygen 1.6.2-20100208