00001 00028 #ifndef ASYNC_AUDIO_DELAY_LINE_INCLUDED 00029 #define ASYNC_AUDIO_DELAY_LINE_INCLUDED 00030 00031 00032 /**************************************************************************** 00033 * 00034 * System Includes 00035 * 00036 ****************************************************************************/ 00037 00038 00039 00040 /**************************************************************************** 00041 * 00042 * Project Includes 00043 * 00044 ****************************************************************************/ 00045 00046 #include <AsyncAudioSink.h> 00047 #include <AsyncAudioSource.h> 00048 00049 00050 /**************************************************************************** 00051 * 00052 * Local Includes 00053 * 00054 ****************************************************************************/ 00055 00056 00057 00058 /**************************************************************************** 00059 * 00060 * Forward declarations 00061 * 00062 ****************************************************************************/ 00063 00064 00065 00066 /**************************************************************************** 00067 * 00068 * Namespace 00069 * 00070 ****************************************************************************/ 00071 00072 namespace Async 00073 { 00074 00075 00076 /**************************************************************************** 00077 * 00078 * Forward declarations of classes inside of the declared namespace 00079 * 00080 ****************************************************************************/ 00081 00082 00083 00084 /**************************************************************************** 00085 * 00086 * Defines & typedefs 00087 * 00088 ****************************************************************************/ 00089 00090 00091 00092 /**************************************************************************** 00093 * 00094 * Exported Global Variables 00095 * 00096 ****************************************************************************/ 00097 00098 00099 00100 /**************************************************************************** 00101 * 00102 * Class definitions 00103 * 00104 ****************************************************************************/ 00105 00117 class AudioDelayLine : public Async::AudioSink, public Async::AudioSource 00118 { 00119 public: 00124 explicit AudioDelayLine(int length_ms); 00125 00129 ~AudioDelayLine(void); 00130 00142 void mute(bool do_mute, int time_ms=0); 00143 00152 void clear(int time_ms=-1); 00153 00163 int writeSamples(const float *samples, int count); 00164 00173 void flushSamples(void); 00174 00183 void resumeOutput(void); 00184 00193 void allSamplesFlushed(void); 00194 00195 00196 protected: 00197 00198 private: 00199 float *buf; 00200 int size; 00201 int ptr; 00202 int flush_cnt; 00203 bool is_muted; 00204 int mute_cnt; 00205 int last_clear; 00206 00207 AudioDelayLine(const AudioDelayLine&); 00208 AudioDelayLine& operator=(const AudioDelayLine&); 00209 void writeRemainingSamples(void); 00210 int writeToSink(int count); 00211 00212 }; /* class AudioDelayLine */ 00213 00214 00215 } /* namespace */ 00216 00217 #endif /* ASYNC_AUDIO_DELAY_LINE_INCLUDED */ 00218 00219 00220 00221 /* 00222 * This file has not been truncated 00223 */ 00224