00001 00027 #ifndef ASYNC_AUDIO_AMP_INCLUDED 00028 #define ASYNC_AUDIO_AMP_INCLUDED 00029 00030 00031 /**************************************************************************** 00032 * 00033 * System Includes 00034 * 00035 ****************************************************************************/ 00036 00037 #include <cmath> 00038 00039 00040 /**************************************************************************** 00041 * 00042 * Project Includes 00043 * 00044 ****************************************************************************/ 00045 00046 #include <AsyncAudioProcessor.h> 00047 00048 00049 /**************************************************************************** 00050 * 00051 * Local Includes 00052 * 00053 ****************************************************************************/ 00054 00055 00056 00057 /**************************************************************************** 00058 * 00059 * Forward declarations 00060 * 00061 ****************************************************************************/ 00062 00063 00064 00065 /**************************************************************************** 00066 * 00067 * Namespace 00068 * 00069 ****************************************************************************/ 00070 00071 namespace Async 00072 { 00073 00074 00075 /**************************************************************************** 00076 * 00077 * Forward declarations of classes inside of the declared namespace 00078 * 00079 ****************************************************************************/ 00080 00081 00082 00083 /**************************************************************************** 00084 * 00085 * Defines & typedefs 00086 * 00087 ****************************************************************************/ 00088 00089 00090 00091 /**************************************************************************** 00092 * 00093 * Exported Global Variables 00094 * 00095 ****************************************************************************/ 00096 00097 00098 00099 /**************************************************************************** 00100 * 00101 * Class definitions 00102 * 00103 ****************************************************************************/ 00104 00112 class AudioAmp : public Async::AudioProcessor 00113 { 00114 public: 00118 AudioAmp(void) : m_gain(1.0) {} 00119 00123 ~AudioAmp(void) {} 00124 00129 void setGain(float gain_db) { m_gain = powf(10, gain_db / 20); } 00130 00135 float gain(void) const { return 20 * log10(m_gain); } 00136 00137 00138 protected: 00139 void processSamples(float *dest, const float *src, int count) 00140 { 00141 for (int i=0; i<count; ++i) 00142 { 00143 dest[i] = src[i] * m_gain; 00144 } 00145 } 00146 00147 00148 private: 00149 AudioAmp(const AudioAmp&); 00150 AudioAmp& operator=(const AudioAmp&); 00151 00152 float m_gain; 00153 00154 }; /* class AudioAmp */ 00155 00156 00157 } /* namespace */ 00158 00159 #endif /* ASYNC_AUDIO_AMP_INCLUDED */ 00160 00161 00162 00163 /* 00164 * This file has not been truncated 00165 */ 00166