Async  0.18.0
AsyncAudioProcessor.h
Go to the documentation of this file.
1 
28 #ifndef ASYNC_AUDIO_PROCESSOR_INCLUDED
29 #define ASYNC_AUDIO_PROCESSOR_INCLUDED
30 
31 
32 /****************************************************************************
33  *
34  * System Includes
35  *
36  ****************************************************************************/
37 
38 #include <string>
39 
40 
41 /****************************************************************************
42  *
43  * Project Includes
44  *
45  ****************************************************************************/
46 
47 
48 
49 /****************************************************************************
50  *
51  * Local Includes
52  *
53  ****************************************************************************/
54 
55 #include <AsyncAudioSource.h>
56 #include <AsyncAudioSink.h>
57 
58 
59 
60 /****************************************************************************
61  *
62  * Forward declarations
63  *
64  ****************************************************************************/
65 
66 
67 
68 /****************************************************************************
69  *
70  * Namespace
71  *
72  ****************************************************************************/
73 
74 namespace Async
75 {
76 
77 
78 /****************************************************************************
79  *
80  * Forward declarations of classes inside of the declared namespace
81  *
82  ****************************************************************************/
83 
84 
85 
86 /****************************************************************************
87  *
88  * Defines & typedefs
89  *
90  ****************************************************************************/
91 
92 
93 
94 /****************************************************************************
95  *
96  * Exported Global Variables
97  *
98  ****************************************************************************/
99 
100 
101 
102 /****************************************************************************
103  *
104  * Class definitions
105  *
106  ****************************************************************************/
107 
117 class AudioProcessor : public AudioSink, public AudioSource
118 {
119  public:
123  AudioProcessor(void);
124 
128  virtual ~AudioProcessor(void);
129 
136  int writeSamples(const float *samples, int len);
137 
141  void flushSamples(void);
142 
146  void resumeOutput(void);
147 
151  void allSamplesFlushed(void);
152 
153 
154  protected:
160  void setInputOutputSampleRate(int input_rate, int output_rate);
161 
173  virtual void processSamples(float *dest, const float *src, int count) = 0;
174 
175 
176  private:
177  static const int BUFSIZE = 256;
178 
179  float buf[BUFSIZE];
180  int buf_cnt;
181  bool do_flush;
182  bool input_stopped;
183  bool output_stopped;
184  int input_rate;
185  int output_rate;
186  float *input_buf;
187  int input_buf_cnt;
188  int input_buf_size;
189 
191  AudioProcessor& operator=(const AudioProcessor&);
192  void writeFromBuf(void);
193 
194 }; /* class AudioProcessor */
195 
196 
197 } /* namespace */
198 
199 #endif /* ASYNC_AUDIO_PROCESSOR_INCLUDED */
200 
201 
202 
203 /*
204  * This file has not been truncated
205  */
206