text: the automatic gain control circuit shown in fig2 is suitable for use with a microphone for a mobile telephone . in this embodiment , the microphone gain control is separated into two parts : the analog gain adc_gain and the digital gain gd . commercially available codecs , such as the mt8960 sold by zarlink semiconductor inc . allow for both analog and digital gain control . the analog gain control acts on the input signal prior to analog to digital conversion , and the digital gain control acts on the digital samples of the input signal . the codec analog gain normally has a larger step size than the digital gain . a 6 db step is very common for analog gain . in order to control the variation of the gain slowly , the digital gain is changed . the overall gain applied to the input signal is a combination of these two gains . as shown in fig2 , the gain adjust block 10 for a codec 25 converting the analog signal sin to a digital signal sin ( n ) is controlled by a counter 11 which supplies a comparator 12 . when the counter reaches a certain value , determined by the threshold value applied to an input of the comparator , it starts the microphone gain adjustment process and in the meantime , resets its content to zero . the purpose of the counter is to provide sufficient time for the signal power ( p s ) to update its value after each gain adjustment . the gain adjustment block 10 comprises a first comparator 13 connected to a block 14 for reducing the analog gain and a second comparator 28 connected through and gates 15 and 16 to a block 16 for increasing the analog gain . the first and gate 15 has one input receiving a speech flag generated by a speech detector ( not shown ). when the gain adjustment block first starts , it compares the signal power ps of the input signal with a high threshold value γh . if the signal power from microphone is above the high threshold γh , the microphone is saturated and the block 14 is activated to reduce the analog gain of the codec by one step ( normally 6 db ). the signal power ps is also compared with a low threshold γl . if the signal power is above the threshold , the comparator 28 does not present an output and nothing changes . if the signal power is below the low threshold γl and speech is present , it means that signal power is too low . in this case a small gain step μ is added by the multiplier 18 to the digital gain signal gd , which controls the digital gain of the codec . the detection of speech activity is important to make sure that the gain will not be increased in the presence pure noise . when speech is not present , a low noise power should not trigger the digital gain increase because the comparator 15 will not generated an output . the two threshold γl and γh should not be the same and there will be noticeable difference between them ( γh & gt ; γl ). γh is the saturation threshold and γl should be well below γh for two reasons because the microphone should not always work around saturation level . it is necessary to maintain a certain dynamic range for the peak signal power . also , it is very important to maintain a stable microphone gain for both good echo cancellation and high speech quality . a stable microphone gain is maintained when signal power ranges between γh and γl . this signal power range is called the dead - zone because in the deadzone , the microphone gain will not be adjusted . ideally , the adc analog gain should be maintained to maintain the maximum dynamic range for the codec . as noted above digital gain is used to increase the gain slowly because the analog gain normally has a large step size . therefore , when the digital gain is above certain value γ c , the analog gain can be increased by 6 db and the digital gain reduced at the same time by 6 db , which means that the gain is divided by 2 , so that the total gain remains the same . this is achieved by comparator 20 , divider 21 and mux 22 . when the digital gain gd exceeds the threshold γ c , and an output signal is present from the comparator 15 , the comparator 16 selects the input 1 of the mux 22 to divide the digital gain signal by a factor of 2 . at the same time the output of the comparator 16 activates the block 17 to increase the analog gain by 6 db , resulting in a net gain change of zero . a flow chart illustrating the operation of the automatic microphone gain control circuit is shown in fig3 . the system starts at step 30 . the contents of the counter 111 are compared with the counter threshold in step 31 . if the count does not equal the threshold , the counter is incremented at step 32 and the system loops back to the start 30 . if the count equals the threshold , the counter is reset at step 33 and at step 34 a determination made as to whether ps & gt ; γh . if yes , the analog gain is decremented by one increment at step 35 . if not , at step 36 a determination is made as to whether speech is present and ps & lt ; γl . if no , the system loops back to the start . if yes , at step a determination is made at step 37 as to whether gd & gt ; γc . if not , the digital gain gd is incremented by a factor μ at step 39 and the system loops back to the start . if not , at step 38 , the analog gain is incremented by one increment of 6 db , and the digital gain divider is activated so that the digital gain is divided by 2 , which has the effect of reducing the digital gain generated by the circuit by 6 db . the overall gain thus remains the same . the actual parameters used in the mobile acoustic echo canceller depend on the particular application and will be selected by a person skilled in the art . γh is the signal saturation level , and its value depends on the particular codec being used . codec dynamic range and linearity range determine its value . normally , this level is around 0 dbm0 to 9 dbm0 for voice applications . γl is the minimum signal level sent from codec for acoustic echo cancellation . for better echo cancellation performance , this level should be increased to give a better dynamic range . however , to stabilize microphone gain for both speech quality and echo cancellation , it is important to maintain a sufficiently large dead - zone , in general γl should at least 6 db below γh . typically , γl should chosen 6 - 12 db below γh . the value of the counter threshold depends on how many data frames are needed for the signal power update . for speech applications , this value can be chosen around 16000 for an 8 khz sampling frequency . γ c is the maximum digital gain which can be applied to the codec input signal . to get a large signal dynamic range , it is preferable to use as much analog gain as possible . in general , γ c should be given the value 1 . in such a case , gd varies between 0 . 5 and 1 . the value of μ should be small for slow gain variation . it makes echo cancellation more stable . however , if μ is too small , the microphone may stay in the low gain for too long and far - end listener may complain that the speech volume is too small . a suitable value for μ is 0 . 01 , although for different applications , much more variation on μ is always possible . fig4 shows a complete mobile handsfree echo cancellation and noise control system . reference signal r ( n ) received from the mobile network is passed to loudspeaker 40 , which generates an echo through microphone 41 . automatic gain control circuit 42 , associated with codec 47 , controls the gain of the microphone signal sin ( n ). the echo is cancelled by echo canceler 43 to produce sout ( n ), which is passed to non - linear processor 44 and noise reduction circuit 45 in a manner that is conventional per ser . in the mobile handsfree applications , a sudden increase in background noise is the normal cause of microphone saturation , such as window open while driving on the highway . when the microphone is saturated , the automatic gain control circuit 42 will reduce the analog gain . when the noise condition improves , the automatic gain control circuit should release the gain reduction ( that is increase gain ) slowly . if the gain is increased too fast , it will cause both unstable echo cancellation and variation in speech level . if the gain is released too slowly , the far - end listener may experience too low a speech level for a long time . to overcome this problem , an inverse agc function 46 is added in fig4 . this inverse agc reverses all agc gain reduction with a gain increase , maintaining the total gain from microphone to mobile network unchanged . the inverse agc 46 can operate in the same ways as the agc 42 , expect that the signals are reversed so that when the agc 42 increments , the agc 46 decrements by the same amount and vice versa . the signal to the mobile network may not be saturated even with this inverse agc because echo component at microphone is cancelled by echo cancellation and non - linear processor ( nlp ), and the wind - noise is reduced by noise reduction ( nr ) circuitry before the inverse agc . the scheme in fig4 can maintain speech level unchanged while controlling the microphone saturation .