a high-performance, automatic gain control (agc) and dynamic range compression device for hi-fi...

20
A high-performance, automatic gain control (AGC) and dynamic range compression device for hi-fi audio systems Glauco Masotti Abstract An automatic gain control (AGC) and dynamic range compression device for audio systems is presented 1 . In one mode of operation, the device is capable of emulating manual regulation of the audio level, relieving users from the task of making adjustments each time they change input source. In this modality the maximum output amplitude is kept nearly constant over time, but with negligible alteration of the genuine dynamic range of the input signal. The introduced distortion, noise and other artifacts are below normal audible perception. In other modes of operation, the device can also perform a certain amount of dynamic range compression, acting more promptly to maintain the output signal close to the optimum desired level. In any case, thanks to some original solutions, the alteration of the real dynamics of the source is minimal, compared to the results of common techniques. Other inconveniences of typical AGC circuits are avoided as well. The gadget is also simple to use and self-adapting, it's thus suitable for home use with hi-fi audio systems. Keywords: automatic gain control (AGC), overcoming common AGC defects, hifi audio system with multiple sources, automatic volume leveling (AVL) upon switching input source, automatic adjustment of audio level, dynamic range compression, audio compression, consumer audio products, electronic device, circuit schematic, self-construction of electronic gadgets. Contents 1. Introduction 2. Principle of operation and state of the art 3. Circuit description and analysis 4. Practical realization 5. Measured results 6. Usage experience and conclusions References 1 I was in doubt if this work was worth a patent or not, because when I designed and built this device (just two months ago), some of the solutions that I devised appeared to me, if not absolutely new, at least unusual. Thus I spent a few days in an exhausting search throughout patent databases, to ascertain if these ideas were really unprecedented or not. The result of this search was somewhat surprising. In fact I found three patents (in particular US4115741 and US5301369, but also to a less degree US20060034400) were some solutions similar to those adopted in my design appear, at least in concept, although with a different implementation and in different contexts. However, what's really unbelievable for me is that (unless some omissions were intentional, but it's hard to believe) the authors seem not to have completely understood what they did! In fact none of these patents recognize the positive implication of certain solutions (in particular of one of them, which is the basic idea of this work). It seems that they used certain methods incidentally, in fact these are not the main focus of the patents and consequently they are not highlighted, nor claimed. Therefore I have reasons to believe that what I am going to “unveil” you in this document it's really unprecedented, and therefore it's a novelty. Nevertheless it's also apparent that similar solutions, although unnoticed or not completely understood, already appeared in the literature, in one form or another. That's why, like in other cases, I excluded the possibility of patenting this work, and I opted instead for publishing it. February 2014 (Last revised May 2014) Page 1 of 20

Upload: glaucomasotti

Post on 08-Feb-2016

138 views

Category:

Documents


1 download

DESCRIPTION

An automatic gain control (AGC) and dynamic range compression device for audio systems is presented1.In one mode of operation, the device is capable of emulating manual regulation of the audio level, relieving users from the task of making adjustments each time they change input source. In this modality the maximum output amplitude is kept nearly constant over time, but with negligible alteration of the genuine dynamic range of the input signal. The introduced distortion, noise and other artifacts are below normal audible perception. In other modes of operation, the device can also perform a certain amount of dynamic range compression, acting more promptly to maintain the output signal close to the optimum desired level. In any case, thanks to some original solutions, the alteration of the real dynamics of the source is minimal, compared to the results of common techniques. Other inconveniences of typical AGC circuits are avoided as well. The gadget is also simple to use and self-adapting, it's thus suitable for home use with hi-fi audio systems.

TRANSCRIPT

Page 1: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

A high-performance, automatic gain control (AGC) and dynamic range compression device for hi-fi audio systems

Glauco Masotti

Abstract

An automatic gain control (AGC) and dynamic range compression device for audio systems is presented1.In one mode of operation, the device is capable of emulating manual regulation of the audio level, relieving users from the task of making adjustments each time they change input source. In this modality the maximum output amplitude is kept nearly constant over time, but with negligible alteration of the genuine dynamic range of the input signal. The introduced distortion, noise and other artifacts are below normal audible perception. In other modes of operation, the device can also perform a certain amount of dynamic range compression, acting more promptly to maintain the output signal close to the optimum desired level. Inany case, thanks to some original solutions, the alteration of the real dynamics of the source is minimal, compared to the results of common techniques. Other inconveniences of typical AGC circuits are avoided as well. The gadget is also simple to use and self-adapting, it's thus suitable for home use with hi-fi audio systems.

Keywords: automatic gain control (AGC), overcoming common AGC defects, hifi audio system with multiple sources, automatic volume leveling (AVL) upon switching input source, automatic adjustment of audio level, dynamic range compression, audio compression, consumer audio products, electronic device, circuit schematic, self-construction of electronic gadgets.

Contents

1. Introduction2. Principle of operation and state of the art3. Circuit description and analysis4. Practical realization5. Measured results6. Usage experience and conclusions

References

1 I was in doubt if this work was worth a patent or not, because when I designed and built this device (just two monthsago), some of the solutions that I devised appeared to me, if not absolutely new, at least unusual. Thus I spent a few days in an exhausting search throughout patent databases, to ascertain if these ideas were really unprecedented or not. The result of this search was somewhat surprising. In fact I found three patents (in particular US4115741 and US5301369, but also to a less degree US20060034400) were some solutions similar to those adopted in my design appear, at least in concept, although with a different implementation and in different contexts. However, what's really unbelievable for me is that (unless some omissions were intentional, but it's hard to believe) the authors seem not to have completely understood what they did! In fact none of these patents recognize the positive implication of certain solutions (in particular of one of them, which is the basic idea of this work). It seems that they used certain methods incidentally, in fact these are not the main focus of the patents and consequently they are not highlighted, nor claimed. Therefore I have reasons to believe that what I am going to “unveil” you in this document it's really unprecedented, and therefore it's a novelty. Nevertheless it's also apparent that similar solutions, although unnoticed or not completely understood, already appeared in the literature, in one form or another. That's why, like in other cases, I excluded the possibility of patenting this work, and I opted instead for publishing it.

February 2014 (Last revised May 2014) Page 1 of 20

Page 2: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

1. Introduction

Do you listen to music? Do you have a hi-fi system with multiple sources?Are you tired to adjust the volume pot every time you change station on your tuner, or commute the input of your amplifier from CD to tape, or to a digital TV and radio receiver (DTV), or to the AUX input, where youconnected your PC to listen to web radios? Yes, because, as you know, each source has its typical signal level, and this is different for each one of them!Do you want to listen to that talk show, or to that conference, where one speaks loudly and the other one softly, without missing a word? Are you disturbed each time a commercial break in loudly and forces you to reduce the volume? Do you often make records of music or movies, so that you have every time to adjust the optimum recording level, to avoid clipping yet maintaining the best S/N ratio? Or do you even have, like me, a modulator and a transmitter, to broadcast on cable your music to every roomof your house? In this case the amplitude of the input signal to the modulator would be yet more critical.

If your answer is yes to some of the above questions, then this device can simplify your life, making your listening experience more enjoyable.

Unfortunately it's not an off the shelf product, I don't know of any consumer product with similar characteristics. Well, there are pro or semi-pro instruments which do audio compression, but what could be useful is simply to add automatic gain control (AGC) to our hi-fi system, to obtain a nearly uniform audio level from all sources.This device performs AGC for our audio system, i.e. it does something very similar to what we do by manually adjusting the volume pot of our amplifier, or the recording level of our recorder, each time that we change source, except that it does this automatically, precisely and quickly.

I don't know why this function is not provided in standard consumer audio systems, perhaps because there is the (wrong) belief that an AGC must necessarily alter too much the dynamic range of the original source, introducing unwanted artifacts [18], like “pumping” up and down the sound level in short term cyclic gain variations (something referred also as “breathing”), rising hiss during quiet passages, distorting or making the sound “duller” by limiting the peaks, etc. Well, I think that all these defects can be eliminated by a proper design of the AGC circuit. I had the objective of avoiding all the above inconveniences in designing this device and, thanks also to some original solutions, I can tell you that I am very much enjoying the prototype that I built for myself. I tested it with every kind of audio source, even with the most challenging passages of classical music, and I could not perceive any audible difference in sound quality between the original signal and the one regulated by the AGC (the device obviously has a bypass button, to exclude it and listen directly from the original source).In fact the device can operate to preserve at most the dynamic range of each source, adapting the gain without introducing distortion, very much resembling manual level adjustment, nevertheless it can also provide enough compression of the dynamic range of the source, if desired. This can be useful particularly when we listen to spoken parts, rather than to music, because compressing the dynamic range enhances speech intelligibility.

Using a professional audio compression module for this task it's a sort of overkill, for the problem at hand. These instruments are designed for musicians and professional audio recording or broadcasting studios, therefore they are expensive, they do not connect simply to a consumer hi-fi system, and they are difficult to use, with a lot of settings to be adjusted to obtain a good result, they cannot provide simplicity of use, thus they don't do the same job of this much simpler gadget.

However, if you know about electronics, and you are an hobbyist, you can build this device yourself. Everything you need to know is explained in this document. The electrical schematic of the circuit is presented and discussed in detail, with an in-dept discussion of all relevant technical aspects, so that you should recognize why certain original solutions adopted here can offer superior performance, with respect to other known approaches.

February 2014 (Last revised May 2014) Page 2 of 20

Page 3: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

Pictures of the realized prototype are shown and many practical suggestions for realizing the device without problems are given. The device can be built with quite common parts, most of which can be found, at no cost, in old TV sets, satellite receivers, recorders, etc., destined to recycling.

Here you see a picture of the realized prototype (Fig. 1).

Fig. 1

It's that thing with the white cover placed over the cassette deck. Actually this latter is used just as a level meter, for visual indication and to adjust the input level to the amplifier, to the modulator and to the “Line-in” input of the PC for digital recording purposes (I don't use anymore the cassette deck recorder). Until a few days ago I had to adjust the “REC LEVEL” pot almost every time after changing source, now I have regulated it at the optimum level once and for all, thus I don't touch it anymore, so that listening to many sources is no more an hassle for me.(By the way, you may have noticed that the case of the AGC module is recycled, in fact it was the case of an obsolete ADSL modem, I placed the AGC prototype inside it! What was the back of the modem now it's the front of the AGC module. The case offers perfect shielding and required little mechanical work for placing all the components :)

February 2014 (Last revised May 2014) Page 3 of 20

Page 4: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

The next figure (Fig. 2) shows a (partial) scheme of my audio system and how I connected the AGC device to it.

Fig. 2

If the “TAPE MONITOR” button is pressed, the amplifier sends to the speakers the signal processed by the AGC. The FM modulator, the VCR (which is now mainly used as an A/V repeater) and the input line of the PC always receive the processed signal instead (unless the bypass button of the AGC is pressed), via the low impedance “PHONES” output of the stereo cassette deck.

Because my experience with this gadget is so positive, I thought to share this result with you, publishing this document.

February 2014 (Last revised May 2014) Page 4 of 20

Page 5: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

2. Principle of operation and state of the art

The device follows a feedback design scheme, as used in AGC [1] and audio compression systems [2]. Its conceptual and functional scheme is outlined in Fig. 3.

Fig. 3

The input signal Vin is fed to a Voltage Controlled Amplifier (VCA), whose gain is proportional to the controlvoltage VGain. This latter is determined by a feedback chain composed of a series of functional modules. The first module is a Level detector, whose output is proportional to the maximum level of the output signal VOut (the peak level in our case). A low pass filter follows [3], whose purpose is to average and smooth the signal of the previous stage, so that its output is proportional not to the instantaneous peak level of Vout , but to a short term moving average of it. This measure is more correlated with the perceptual sensation of sound intensity [4]. The output of the filter is stored in a short term volatile storage, so that memory of the recent level reached by the output is retained. Thus the regulation of the VCA is not immediately adapted to changes of the output level, but only after a reasonable time. In this way a suitable amount of the original dynamics of the input signal is preserved. The stored signal is faced with the reference VRef ,which represent the desired, “ideal” level of the output, and the difference between the reference level and the currently stored level is fed to an error amplifier. The voltage VGain that controls the VCA is thus proportional to this error, i.e. the amplification will be bigger if the error increases and vice versa, so that the output level is maintained close the desired level, even if the input level changes a lot over time.

A number of more or less good circuits of this kind, ranging from very basic solutions to moderately sophisticated ones, can be found on the web, e.g. [5], [6], [7], [8], [20].Most solutions are based on using a FET as a voltage controlled resistor, this approach is also used on op-amp based Wein-bridge oscillators [9], to stabilize the amplitude of oscillation, and is also used here.

3. Circuit description and analysis

The schematic of Fig. 4 shows the circuit for one channel only, let’s assume it's the R (right) channel, plus the few parts which are shared, or which interface with the corresponding part of the L (left) channel. For audio signal processing one BA15218N per channel is employed. This type of IC is particularly suited for our purposes, because it features low noise, low distortion, and low offset.Given the switch S1 is in the ON position (the other is the BYPASS position), the input signal reaches the non inverting input of IC1a though the coupling capacitor C1. The input impedance is determined by R1//R2 to a suitable 54K value. IC1a operates as an input buffer with unit gain. It is biased by R2, which is

February 2014 (Last revised May 2014) Page 5 of 20

Page 6: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

Fig. 4

connected to the V+/2 line, so that the output working point is set in the middle of the available voltage swing. R3, on the feedback path, compensates the voltage drops of input biasing currents at IC1a inputs, thusminimizing the contribution to offset voltage at pin 1, which is desirable to be as close to 0 as possible, for

February 2014 (Last revised May 2014) Page 6 of 20

Page 7: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

proper operation of T1 as a voltage controlled resistor. IC1a drives the low impedance variable attenuator made by R4 and the group T1, R5, R6, of equivalent resistance Rf, which is the heart of the AGC. The impedance of the attenuator is imposed by the characteristics of the employed FET, a common BF256 (2N3819, 2N5486, etc.) type. The minimal resistance, when Vgs = 0, it's around 133Ω. The introduced attenuation is Av = Rf/(Rf+R5), thus to achieve a ratio of min/max attenuation > 10, to allow for an input range of the peak level of all sources of at least 20 dB, a resistance of 1.5K has been chosen for R4. With thisvalue we have a maximum attenuation of ~ 12 times (22dB), i.e. 1/12 < Av < 1. The following stage it's the output buffer, which offers a fixed gain of 11 and thus compensates for the initial attenuation and brings back the signal to a good level for the following stages. R9 ensures stability, in case ofhigh capacitive loads and prevents damage to IC1, in case the output is shorted.As we will see, the AGC operates to maintain the output level to a sustained 1.7 Vp (1.21 Vrms for a sinusoidal wave), this means that the signal level Vds, seen at pin 5 of IC1b and between drain and source of T1, is typically < 154 mV, which is well inside the linear region of operation of the FET, which, employing feedback resistors, extends to +/-1V with < 0.5% distortion [10]. Two feedback resistors of 470K (R5, R6) have been used, as suggested in the application note [10].

The signal at the output is also fed to the base of T2, which is configured with equal loads on emitter and collector. This configuration is well known [11], although seldom used, since the tube age [12], and providesphase splitting. The signal at the emitter is in phase with the input and that at the collector in opposition of phase. The circuit provides an almost unit gain at both outputs, provided the input impedance of the following stages, particularly at the collector, is high enough to be considered a negligible load, and the hfe of the transistor is high enough for the base current to be considered negligible, for this reason it's better to employ as T2 a transistor with a high beta, like the BC548C. Care should be taken also to correctly set the operating point of the transistor, to allow for maximum excursion of voltage at the outputs, in order to accommodate also for large signals before clipping occurs!The loads for T2 are essentially the bases of T3 and T4, which are connected as voltage followers, thus presenting a high impedance, but biased at interdiction, in this way they behave like rectifying diodes, but with a current gain. Using two transistors, rather than two simple diodes, we have three advantages: the first has been already mentioned, it's the higher input impedance, the second is that this allows for a fast attack time (as we will see later in greater detail) and the third is that the voltage drop represented by the Vbe of a transistor is less variant than the voltage drop of a diode for the same amount of output current variation. In our case the two transistors can sustain a load of less than 200Ω without problems, and, for their emitter current passing from 10 uA to 1 mA, their Vbe has a typical variation of only 100 mV, while the voltage dropof a 1N4148 diode for the same variation of current is of 230 mV!But what's all this for? The group composed by T2, T3, T4 and associated passive components acts as a full wave rectifier. In fact, being the outputs of T2 in opposition of phase, one of them will always be “the positive half wave”, for any input waveform, forcing either T2 or T3 to conduction, if the peak voltage exceeds the threshold of conduction of the transistors. To my knowledge this solution for making a full wave rectifier is unedited, it can be my fault, but I have never seen something similar2. The concept is old, because power supply rectifiers, based on transformers having a secondary with a central tap, do the same thing, but here we have realized this idea using a phase splitter rather than an impractical transformer with a central tap. This solution is also somewhat simpler than one of the classical versions which employ at least two op-amps and two diodes, plus passive components. Well it's not an ideal full wave rectifier, it's affected by the threshold of conduction of the two transistors, but,as we will see, this is not an inconvenient in our case, but something that we can exploit!

It is worth noting that most published projects, employ a much simpler solution for detecting the signal level.Some use crude half wave rectification, which may provide an incorrect result for asymmetric waveforms, moreover doubling the attack time for the same time constant of the low-pass filter which follows.

2 At the time of my first writing and when I designed the device this was certainly true. However (as cited in Note 1) Irecently discovered that something similar is shown in patent US4115741, although the author implemented the phase shifter differently, using two transistors and a more complicated bias scheme.

February 2014 (Last revised May 2014) Page 7 of 20

Page 8: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

Others employ two diodes connected as a half-wave voltage doubler (Fig. 5).

Fig. 5

This solution responds both to positive and negative peaks, but its result may not be so good! In fact, even considering a sinusoidal input and an ideal input source with Rg= 0, the circuit has an intrinsic rise time [14],which in our case has the effect of lengthening the attack time. Things get worse if Rg > 0 and C2 < C1 (like it's often seen), because the effect of the load RL becomes greater [15]. If Rg and RL are not negligible, the rise time will require a greater number of cycles for an increasing input frequency (and with arbitrary input waveforms the result is even less predictable). Moreover the ripple is at input frequency, not at double the input frequency like in a full wave rectifier, thus requiring greater filtering of the output. For all these reasonsI think that the solution adopted here is better.

The load of T3 and T4 is the RC low-pass filter made by R19+R20 = R and the total capacity of C9+C10+C11 = C. The reason for using three capacitors rather than only one is that it's possible in this way to select the capacitors so that the total capacity which is used in the two channels is about the same, overcoming the difficulty of finding electrolytics with low tolerance values. In my case I was able to arrange the triple for both channels with a tolerance < 2%! In case your multimeter is not capable of measuring capacities > 100 uF, like mine, simply measure each capacitor one by one, and use another fixed 100 uF capacitor placed in series during the measures. The output of the filter is the voltage Vc across the capacitors, which, recalling the block scheme of Fig. 3, represents the detected signal level, used for regulating the attenuation Av abovementioned, in order to maintain a nearly constant output level.The large capacity of 300 uF is used to allow for a very long “release time” of the AGC, as we will see. The time constant τ = R*C of the filter determines instead the “attack time” of the AGC. In the prototype I have set τ at about 53 ms, regulating R = 177Ω. The shorter τ the faster the output Vc of the filter will react to input signals. If we make τ very short, e.g. using a very small capacity C, the circuit will behave like a peak detector, i.e. T3 and T4 will be able to charge the capacitor to the peak value of the signal even for short burst of sound, while, making the time constant longer, only sustained sounds will be able to charge C at, or very close to, the peak value. Because an increase in Vc causes a decrease of Av, it is not good to have abrupt changes of Av at every sound peak, because this will introduce audible distortion. I's thus better to have smooth variations of Vc, even if the input changes abruptly with a burst of sound; this willpreserve sound fidelity, at the cost of occasionally exceeding, for very short intervals, the maximum desirable peak value at the output. This can be done by increasing τ, thus decreasing the cut-off frequency of the low-pass filter. On the other hand we cannot make the time constant too big, because this would make thereaction time of the level detector so slow that we would be able to perceive the exceeding loudness during the bursts of sound and the subsequent reduction of amplitude operated by the device. Setting the optimum time constant it's thus a choice of compromise. The authors of the various projects published in the web haveset this parameter to values ranging from as low as 1 ms to about 0.3”! I made a conservative choice in favor of a relatively slow attack time. I left τ set at 53 ms after having tried values of approximately 200 and 100 ms. A time constant of 200 ms was clearly too big, while setting the value at 100 ms was satisfactory. The 53 ms setting sounded as good as 100 ms, with no audible distortion, but with the advantage of keeping the output more regulated, with no perceivable excess in loudness, even during the most critical passages of classical music. I haven't tried smaller values because I didn’t see the necessity for doing that and because, even before introducing audible distortion, lower values would necessarily alter the original sound “color” toa greater extent. If you want to keep things simple you may thus do the same choice as me and just place a 180Ω resistor in place of R19 and R20, otherwise you may want to experiment with lower values, or substitute R19 and the trimmer R20 with three resistances and a commutator, to set fast, mean and slow attack time as desired (like I did for the release time, as we will see below). Three 91Ω resistors could

February 2014 (Last revised May 2014) Page 8 of 20

Page 9: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

perhaps be a good choice for this purpose.

I don't have an oscilloscope to ascertain the real behavior of Vc at attack time, but I tried to speculate what may happen in a simple exemplar case: the sudden step from silence to a strong sinusoidal wave exceeding the maximum desirable output level. The example assumes τ = 1, and a frequency of the incoming signal >> 1/2πτ (the cut-off frequency of the low-pass filter). With the advertence that the quantitative aspects of this speculation may be very much approximated, and thus mainly the “qualitative” aspects should be taken into account, what may happen should resemble what depicted in Fig. 6 (I made this and other studies presented here using some standard graphics tools and Graph [17]; I take the occasion to acknowledge the author).

Fig. 6

This behavior seems reasonable. If this speculation resembles reality, in this example it takes ~ 1.5τ to achieve a regulated output below +1.8 dB of the final value and ~ 2.2τ below +1dB. This could be a more precise way to define the attack time, and seems to justify, in our case, a conventional assumption of the attack time as 2τ. It also appears clearly that a full wave rectifier contributes a lot in reducing the attack time. Also the exponential increase of Vc seems appropriate, because most of the gain reduction is actuated as soon as the perturbation starts, but at the same time without introducing distortion3.

3 Therefore this solution seems advantageous with respect to using a linear stepwise increment of Vc at attack time, like most of ancient and recent digital systems do (e.g. see the already cited patent US20060034400) .

February 2014 (Last revised May 2014) Page 9 of 20

Page 10: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

But let's advance in analyzing the schematic of the device. After the capacitors of the filter we find T5 and T6, configured as a current mirror. Their function is to slowly discharge the capacitors C9, C10, C11 (let's call them C for sake of brevity). The capacitors C represent an analog memory that store Vc, which, as we have seen, is the detected maximum level of the output signal. Without T5 and T6 this “memory”, the “short term storage” of Fig. 3, would last too long. In fact only the tiny base current of T7 (< 4 nA) and the leakage currents will contribute to discharge C. Although, in general, electrolytic capacitors may have a non negligible leakage current, good capacitors usually have a very low leakage current. To build up the total capacity C, I used some 7-8 year old, 100uF capacitors extracted from a not working PC motherboard. Testing the leakage current of each capacitor at 12 V, with my TENMA 72-7745 multimeter, I was not able tomeasure it, this means that the current should be < 60 nA, otherwise, with a resolution of 0.1 uA, I should have seen some blinking of the least significant digit, isn't it? Moreover the leakage current at 10% of the operating voltage can be as low as 3% of the leakage at rated voltage [13], thus we may have values of ~5nAfor the total leakage of C. Then we should take into account the leakage of the reversely biased EB junctions of T3 and T4, plus the biasing current of T7. In the realistic hypothesis that all discharge currents sum up to 10 nA, as ∆t = ∆V*C/I, we would need to wait 3000” (i.e. 50') for a variation of Vc of only 100 mv! Such a persistent memory is clearly too long lasting. This means that the AGC would regulate the output with a gain set for a certain input source, with a certain level, when in the meantime the situation may have completely changed. There is thus the necessity, after a reasonable time, to “forget” old situations, if we wantthat the AGC automatically adapts to the new ones. This “reasonable time” is what is called the “release time” of the AGC. I think that not only the time for erasing the memory is important, but also the pace of this process! This is a very important issue which can influence dramatically the performance of the AGC, but which is very much neglected. In fact, all of the schematics that I have seen4, including integrated solutions [19], simply use a resistor for discharging C. This implies that the capacitor is discharged with an exponential law, but this is not good at all! In fact, as we will see, an exponential decay of Vc causes a proportional exponential decreaseof Vgs, which increases the total gain A of the audio chain too soon.

Fig. 7

4 This was written after the realization of the prototype, before discovering the patents already cited in Note 1.

February 2014 (Last revised May 2014) Page 10 of 20

Page 11: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

Let's anticipate here one of the measured results obtained with the prototype. The law of variation of A as a function of Vgs, has been experimentally determined and is shown in Fig. 7. Considering this response, it's easy to deduce that, if we start from a condition of strong input signal, which forces Vgs=0 to obtain maximum attenuation, and then a quiet passage follows, the initial quick decrease of Vc, typical of an exponential decay, as shown with the red line in Fig. 8, will also cause a quick increase of A. Despite a large time constant for the release time, this law of variation will cause the gain of the AGC to increase too quickly, rendering this quite passage at an unnatural level; also the noise floor will raise quickly,causing the phenomenon of audible hiss cited in the introduction.

Fig. 8

Let's see what happens instead if we impose a linear law of variation for Vc (which is represented by the green line in Fig. 8) and consequently for Vgs. Looking at Fig. 8, we see that, at the time the value of the linear law halves, the value of the exponential law is reduced to less than 1/10 of the total excursion. In practical terms this means an increase in gain of 5 dB with the linear law and of about 18 dB with the exponential law! The exponential law implies that most of the gain change occurs at the beginning of the release time, while for the linear law it's the opposite! A linear law will thus preserve much more of the dynamics of the original signal, particularly in the first part of the release time. With a linear law the AGC will adequate its gain mainly at the end of the release period, in case no other strong signal arrives in the meanwhile. This would probably be the case when we switch from a strong source to a weak one, and this seems to me a more correct and “intelligent” behavior of the AGC.This argument explains why T5 and T6 are configured as a current mirror. To linearly discharge a capacitor we need to draw a constant current from it, this is exactly what T6 does! The current of T6 is imposed by the current in T5, which is set by the resistance network R21..R26. The trimmer R22 balances the currents of corresponding T5 in the R and L channels, in order to have nearly equal release times for both channels. In case of a perfectly symmetric correspondence of component characteristics, the voltage across R23 would beexactly V+/2, in practice we have to compensate for the resulting total unbalance of the two circuits.

February 2014 (Last revised May 2014) Page 11 of 20

Page 12: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

Assuming the central pin of the switch S2 (connected to R23) is approximately at V+/2, by selecting a total series resistance of 10, 20 or 30MΩ, we can set a discharge current of 545, 272.5 and 182 nA for T5 and consequently for T6 collector. In any case these values are much greater than the total estimated leakage current of 10 nA.

The voltage Vc is fed to the base of T7. Recalling Fig. 3, this is the input of the error amplifier, which also sets implicitly the voltage reference. In fact we can write this relation:

Vc ~ max(Vp+, |Vp-|) - Vbe1 <= Vbe2 + Vewhere Vp+ and Vp- are the positive and negative peaks of the signals, Vbe1 is the base-emitter voltage drop at conduction of T3 and T4, Vbe2 is the base-emitter voltage of T7 and Ve is the biasing voltage at the emitter of T7. Arbitrarily setting Ve = 0.66V, the above relation implies:

max(Vp+, |Vp-|) <= Vbe2 + Vbe1 + Ve ~ 0.52 + 0.52 + 0.66 = 1.7Vthus this is the detected output peak level that the AGC will keep nearly constant.By changing the reference voltage Ve we are able to increase or decrease the output level. In our case 1.7V seems a suitable value, it corresponds to the output level of a strong but not exaggerated source, i.e. well above the noise floor of subsequent stages, and thus capable of delivering a high S/N ratio to the speakers, but without introducing appreciable distortion.The 0.66 volt reference contribute to diminish the influence of variations of Vbe1 and Vbe2 in the equation, but, to stabilize further the output level, Ve is temperature compensated, with the help of D2 and D3. In fact Ve = Vr – 2*Vd. At the operating current of ~ 30 uA, we can estimate a change in Vd of -1.9 mV/°C, thus Ve increases of +3.8 mV/°C, which compensates the decrease of Vbe2+Vbe1, consequently Vbe2+Vbe1+Ve sums up to a nearly constant value, over a wide domain of ambient temperature.Assuming a variation of Vc of -100 mV (which should reflect a similar variation of Vp at the output, corresponding to -0.53 dB over 1.7V) for passing Vgs from 0 to -3.9V (which seems to be the typical cut-off voltage for T1, i.e. Vgs-off), an average leakage current of 10 nA, and a 0.99 gain for the current mirrors, for each position of S2, we will have a correspondent release time of 54.6”, 107” and 158” (2' 38”), which seemsquite good for our purposes. The shorter period should be suitable for listening to spoken parts, which require, not to compromise intelligibility of words, a quick adaptation of gain upon changes in loudness of the speakers, the longer period instead is suitable for classical music, characterized by a large dynamic range spanned in long intervals of time, while the intermediate period should be best for pop music, a good compromise between the requirement of preserving the dynamic range of each song and of adapting the gain to level changes fromone song to another.

Please note that these are very long release times, compared to what is normally seen in published projects. Short release time and exponential decay law may be responsible for most of the AGC defects lamented by their detractors. With the introduction of a linear law of decay, which is probably the main innovation of this project5, and theadoption of relatively long release times, I believe that most of the inconveniences of former AGC solutions has been overcome.

5 In reality here applies what I wrote in Note 1. As we have seen, a linear law implies the use of a current sink (or source), something which is not customarily done. However in US4115741 a preferred embodiment is described where the discharge of the storage capacitor is provided by a current sink. But this fact is left as a neglected detail, no comment on it! Also in US5301369 a linear decay is used, but apparently in an incidental way, because the positive implications of this design are not highlighted, nor claimed. However an array of current sinks is used for discharging the storage capacitor, with the purpose of varying the attack or release time, something that the authors could have done also using an array of resistors, because the reasons of their choice are not explained. Nevertheless the authors wrote: “The external capacitor … is constantly being discharged by a programmable current sink … The slow current drain … allows for a slow linear voltage decay as compared to the exponential decay caused by the discharge resistor in prior art circuits”. Finally in US20060034400 a digital AGC implementation is presented, where a “linear staircase decay” (thus resembling a plain linear decay) is used at release time. But also here the advantages of using a linear law of decay are not mentioned. Therefore, although the solution presented here has some similar precedents, and thus it's not patentable, it appears that the recognition (or should I say the discovery?) and the explicitation of its advantages, as Imade here, it's a novelty, which should imply a reconsideration of this solution in future projects.

February 2014 (Last revised May 2014) Page 12 of 20

Page 13: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

It is worth noting that, when switching from a high level source to a low level one, the device would take the entire release time for adapting the gain to the new source, however, if we want a sudden adaptation, we can push the reset button S3, which has the effect of quickly discharge the storage capacitors.

T7 and T8 are connected as a high-gain dc coupled amplifier. In fact T7 is a 2SC1222 type, characterized by a high current gain even at very low collector current, the load at the collector, given the very high value of R28, is substantially equivalent to hie of T8, then, in operating conditions, the resistance Rf of T1 will be low(< 3K), thus the equivalent output load of T8 is RL ~ R5//R6=235K, which is a high resistance.D4 rises a bit the biasing voltage of T8 emitter, so that T7 is able to drive T8 to interdiction. The dynamic resistance of D4 at the operating current (~100 uA), is negligible (~ 625 Ω), compared to the resistance at thecollector. Therefore T8 is without appreciable negative feedback. Also the total resistance Re seen at the emitter of T7 doesn't provide sufficient negative feedback. In fact it turns out that the total gain of T7 plus T8(which, as a result of some measures, should be ~ 1000), is too high for the feedback loop of the AGC. An excessive gain implies that the response curve of the AGC becomes too flat, variations of the output level, and consequently of Vc, are limited to a few millivolts, thus long release times would be impossible to realize. T9, R30 and R31, serve the purpose of overcoming this problem. They introduce additional negative feedback, so that the overall gain of the error amplifier (made by T7, T8 and T9) can be reduced to the desired value (i.e. Vgs-off/100mV ~ 39). T9 is a high current gain emitter follower, which copies the output of the error amplifier (the collector of T8) introducing a negligible load, R31 then applies a negative feedback to the emitter of T7. In this configuration the gain of the amplifier with feedback can be grossly estimated as Af ~ 1 + R31/Re, where Re is the equivalent emitter resistance of T7, given by R29//(2*Rd+Rr),Rd is the differential resistance of the diodes at the operating current and Rr is the resistance seen from the central pin of trimmer R34.An exact calculation of R31 is quite complicated, because there are many interfering effects to take into account. The exact value of the open loop-gain of T7 and T8 should be determined, as well as the variation inthe implicit reference level caused by an increase in Vbe of T3, T4, T7 when also the output level increases, plus the exact value of the equivalent resistance Re at the emitter of T7 should be calculated. For a common 1N4148 diode, from the given characteristic curves, we can estimate Rd ~ 1.5K at 35uA, but this is a quite approximate estimate, moreover the current through D2 and D3 diminishes as the output increases, thus Rd of the diodes increases, causing the gain of the error amplifier to become smaller, and the variation over the entire operating range of 27..36 uA may be non negligible. We also have Rr, which obviously varies with regulation of the trimmer! Although a value of Rr ~10.4K can be predicted for having Vr=1.76V at the central pin (I save you he details of the calculations), a substantial difference, determined byvariability of component characteristics, may arise in practice. For all these reasons the value of R31 has been determined experimentally, choosing among the standard values. A value of 390K gave the best results, in substantial agreement with the desired variation of Vc.The range of currents flowing in the main paths of the circuit are reported in the schematic. It is interesting tonote that, as the voltage at the collector of T8 rises, the current in T9 also diminishes, approaching 0, therefore also the current flowing from the base of T9 approaches 0; nevertheless even a very small current may cause Vgs to go positive for a few mV (e.g. a tiny 20nA current, flowing though 235K, causes a drop of 4.7 mV). Although the FET T1 can sustain a small positive bias of the PN junctions without damage [14], there is no purpose for having Vgs > 0, so it's better to avoid to operate T1 in this region. The diode D5, as long as Vd < Vbe (which is true for most diodes at operating currents around 2 uA, like in this case, howeverthe use of a low voltage drop diode is recommended here, as selected common type or a MPG06J type), starts conducting before the emitter of T9 goes to V+/2 + Vbe, thus T9 becomes interdicted before its base voltage goes > V+/2, so that Vgs is effectively limited to be <= 0. The connection of the collector of T8 to thegate of T1 closes the control loop.

The device requires a single +12V power supply, only about 12.5 mA are drawn. C5 is placed at the V+ input for further filtering and decoupling. The V+/2 voltage, required for biasing the op-amps and T1, is derived from a simple resistive divider. The current drawn from the the V+/2 line is < 43 uA, therefore, with R11 and R12 set at 3.9K, the maximum voltage variation is < -84 mV, so that it can be neglected. The large capacitorsC3 and C4 provide abundant filtering for hum and other possible noise sources.The entire circuit is enclosed in a shielded case and powered by a small external +12V power supply. In this

February 2014 (Last revised May 2014) Page 13 of 20

Page 14: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

way we avoid the introduction of additional hum noise, via parasitic coupling with dispersed fields of the power transformer or of power lines.

4. Practical realization

The prototype has been built on a small 8.5x7.5 cm pre-drilled base. The disposition of parts is shown in Fig. 9.

Fig. 9

As it can be noted, a large part of the available space is taken by the large 3-way switch S2 (which was once part of an old TEAC cassette deck). Note the two BA15218N on the left side, the power supply capacitors at the bottom edge, and the battery of 100 uF capacitors on the right side of the picture, close to them we have the R20 trimmers, to regulate the attack time, and the two {T5, T6} couples (the current mirrors) on the bottom-right side. The trimmer with the white cap close to the power supply capacitors is R22, and is thus for balancing the release time of the R and L channel. On the upper-right side we have the two R34 trimmers,to regulate the output level.In assembling the circuit I used a new, at least for me, method. I placed all the components on the base, fixing the leads (not the component bodies!), from time to time, with a small amount of cyanoacrylate glue. Polymerized cyanoacrylate glue has in fact excellent dielectric properties. This seems a good alternative to bending the leads or pre-solder them to fix the components to the base. Once terminated the disposition of allcomponents I was able to flip the base upside down, without the inconvenience of some components dropping down, and solder everything. You may say “but what if you have to dismount and take a componentout to substitute it or modify it's position? Doesn't the glue make it difficult or impossible to do so?”. The

February 2014 (Last revised May 2014) Page 14 of 20

Page 15: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

fact is that this type of glue is very sensitive to temperature, heated above 120° it looses most of its mechanical resistance, so that, with the help of the solder, it's possible to dismount components without excessive difficulty, as long as there is not to much glue and you don't let it to cool down again. You may occasionally have to clean up the holes of the base clogged by the glue to reuse them however, but, all in all, I think that the balance is positive.

Fig. 10

Fig. 10 shows the base assembled on the chassis, together with the cables (note the small plastic bridge used to secure them) and the bypass switch S1 (which comes from the same old cassette deck as S2). Also this switch was fixed with cyanoacrylate glue, without the need to further drill the chassis.Then the case was closed by placing the plastic cover, which has an internal metallic mesh, so that the circuitis completely shielded. The last step is to make the external connections to the power supply and to the audiosystem. The final aspect is as shown in Fig. 1.

February 2014 (Last revised May 2014) Page 15 of 20

Page 16: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

5. Measured results

Fig. 11 shows the measured transfer response of the AGC with a continuous sinusoidal input.

Fig. 11

First of all we can observe a very close match (which goes even beyond my initial expectations!) between the R and L curve of response. We can recognize an initial region, which corresponds to a very low input level, where the AGC in inactive and the device has in effect all the available gain of 11. Then we have an almost flat region, where the AGC performs its action, which extends approximately from 104 to 1404 mV, and a final region, of high input level, up to 1620 mV, or slightly more, where the AGC operates at the minimum possible gain of 11/12. It is not advisable to operate the device with input signals higher than this, because, just passed this level, the voltage Ve at the emitter of T7 rises above 1V, T7 is no more able to keep T8 at interdiction, Vgs starts growing and so does the gain, so that the output becomes a large saturated signal!

February 2014 (Last revised May 2014) Page 16 of 20

Page 17: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

It's interesting to zoom-in the flat region, which is shown in more detail in Fig. 12.

Fig. 12

We note that, when the AGC starts operating, there are non-linear effects of the A(Vgs) characteristics (the characteristics of the R channel is also shown in the graph, superimposed to the response curve), that appear clearly in the graph. These effects are due to the transistors in the feedback loop that just start conducting, they are all in a knee of their characteristic curves. The response is probably made worse by the fact that the load at the collector of T8 is initially equivalent to R6 (not R6//R7), because when Vgs is slightly bigger thanVgs-off the resistance Rf of T1 is high, so that the gain of the error amplifier is initially higher than required, causing a flatter response, which the non-linear effects turn into a slightly negative slope!

Fig. 13

February 2014 (Last revised May 2014) Page 17 of 20

Page 18: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

This is not a big deal (in fact we are talking of a difference of 0.2 dB, moreover useful sources are not in this region, at least in my case), however, if you are interested in linearizing this part of the curve, improving overall response, a simple 15K resistor, like shown in Fig. 13, in parallel with T1 will probably be sufficient.This will reduce the maximum available gain to 10, rather than 11, but this also should not be a problem, because even a gain of 10 should be enough for all kind of sources. If you try this let me know your results.

However, returning to Fig. 12, if we fit a line to the measured values which extends throughout the entire domain of regulation, we see that the variation of the “idealized” output (the green line) corresponds to 75 mV rms, i.e. 106 mVp for a sine wave, a result quite in agreement with the expected 100 mVp excursion.

The response in dB of the device, as shown in Fig. 14, rather than in a linear scale, is even more interesting.

Fig. 14

We can see that the entire useful input range of 22.8 dB is restricted to a nearly uniform level contained in ±0.7 dB. If we consider a reduced domain of -8.8 dB to +1.32 dB around the 0 dB level, which contains mostof the input sources (at least in my case), the variation of the output level is reduced further to -0.4, +0.2 dB, which, IMHO, it's a quite good result.

I also measured the maximum release time. I fed to the AGC a strong input signal, corresponding to the maximum regulated level, so that Vgs=0, then I quickly reduced the input to the minimum regulated level, i.e. an input level producing Vgs ~ Vgs-off, and I measured the time required for the AGC to bring the

February 2014 (Last revised May 2014) Page 18 of 20

Page 19: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

output back to a regulated level. After adjusting R22 to match the results of the R and L channels (which were in origin quite unbalanced), the release time, as defined above, was 42” and 41” in fast mode, 86” and 84” in mean mode, 148” and 137” in slow mode, respectively for the R and L channel. There is thus still a difference between the R and L channel of +2.4% in fast and mean mode, and of +8% in slow mode. Spending more time in tweaking R22 I would have probably achieved a better match, but this differences arenot relevant in practice.These durations are not far to what desired and calculated above. In fact the average difference is -24% in fast mode, -20% in mean mode, and -10% in slow mode. This difference, with respect to expected values, is probably mainly due to the fact that the current mirrors T5 and T6 are far from ideal. In fact it's difficult to realize good current mirrors with discrete components. In our case it appears that the current gain of at least one mirror is > 1, particularly when the current is higher. It's something that may happen if the Ic(Vbe) characteristic of T5 and T6 doesn't match perfectly. This forced me to increase the current of the other channel, in order to balance them, so that the measured release times are shorter that expected. We should achieve better results using T5 and T6 from a same substrate, using two matched integrated couples or a matched transistor array (e.g. one THAT 300 can provide the two matched couples required), but I have used two (much cheaper) discrete transistors recycled from an old analog satellite receiver instead! (Maybe you consider this insane, but I have a certain satisfaction in giving a new life to old things, reusing them in an ingenious way rather than throwing them away.) Although I tried to match T5 and T6 for similar Vbe and hfe under a specific test condition, this is not a guarantee for a perfect match, moreover I could achieve only a quite approximate match for the two selected couples.Another source of divergence are the real values of the passive components R24, R25, R26 and C9, C10, C11. Although I tried to match them, like I said above, some differences with respect to ideal values still arise. Also the real leakage currents are most likely greater than previously estimated. All these discrepancies, summed together, lead to the measured results.Nevertheless these results are completely satisfactory in practical terms, as already pointed out in the introduction.

6. Usage experience and conclusions

Finally, a few words on my direct usage experience. First of all I was positively surprised because the device has not added perceivable noise to the audio chain. To say the truth, once I firstly connected the gadget to the audio system, and carefully listening to the output with earphones, a tiny (apparently 100 Hz) hum was audible, but I was able to eliminate it completely with a cleaner disposition of the cables, avoiding interlacing or proximity of signal cables with any cable related to power supply, and with an additional ground path, joining the case of the AGC with the case of the amplifier.Then I must say, once again, that I am very much satisfied with the performances of the device. I already resumed the reasons in the introduction, but let me stress here the absence of audible distortion and of artifacts, particularly operating the device in slow mode. Only when listening with careful attention to criticalpassages, and operating the device in mean or fast mode, it's possible to note some alteration to the original dynamics of the music, but faster modes are exactly intended for producing a certain amount of dynamic compression of the original signal.

If you build another instance of this device for your personal use, I will be glad to hear from you and about your experience6. This will be particularly true if you can provide further insight in the functioning of the device (e.g. because you tested it with an instrumentation more sophisticated than mine), if you discover some errors in this document, if you make some improvements to the circuit, or if you re-elaborate it for a commercial version of the device. In this latter case I wish you success with this business and I will be curious to see you version of the product.

6 You can contact me at: glauco dot masotti at virgilio dot it

February 2014 (Last revised May 2014) Page 19 of 20

Page 20: A high-performance, automatic gain control (AGC)  and dynamic range compression device for hi-fi audio systems

References.

[1] - Automatic gain control. http://en.wikipedia.org/wiki/Automatic_gain_control

[2] - Dynamic range compression. http://en.wikipedia.org/wiki/Dynamic_range_compression

[3] – Low pass filter. http://en.wikipedia.org/wiki/Low-pass_filter

[4] – AND8227/D, “Compandor Application Automatic Gain Control”, Paul Lee, ON Semiconductorwww.onsemi.com/pub/Collateral/AND8227-D.PDF

[5] - Audio Compression Amplifier /AGC, Jim Keith.http://www.electroschematics.com/9400/audio-compressor-agc/

[6] - Automatic Gain Control Circuit, Popescu Marian.http://www.electroschematics.com/2132/automatic-gain-control/

[7] - Audio compressor, L. Mayes.http://graffiti.virgin.net/ljmayes.mal/comp/comp.htm

[8] - AGC amplifier features 60-dB dynamic range, Julius Foit, August 4, 2005, EDN.http://www.embedded.com/design/analog/4322909/AGC-amplifier-features-60-dB-dynamic-range

[9] - Op Amp Circuit Collection, National Semiconductor, Application Note 31.www.ti.com/ww/en/bobpease/assets/AN-31.pdf

[10] – AN105, “FETs As Voltage-Controlled Resistors”, Siliconix application note, 1997, http://pdf1.alldatasheet.com/datasheet-pdf/view/161774/VISHAY/AN105.html

[11] – Transistors Tutorial, http://www.sentex.ca/~mec1995/tutorial/xtor/xtor2/xtor2.html

[12] - Valve Technology - A Practical Guide, http://www.r-type.org/articles/art-010p.htm

[13] - Aluminum Electrolytic Capacitors - General Technical Information, EPCOS. http://www.ele.tut.fi/teaching/ele-3100/lk0809/tehol/oheismat/elko.pdf

[14] - The junction field-effect transistor (JFET). http://courses.engr.illinois.edu/ece343/jfet.pdf

[15] - Voltage multipliers. http://www.allaboutcircuits.com/vol_3/chpt_3/8.html

[16] - Voltage Multiplier Rise Time, John Dunn. http://licn.typepad.com/my_weblog/2011/03/voltage-multiplier-rise-time-john-dunn-consultant-

ambertec-pe-pc.html

[17] – Graph - Plotting of mathematical functions, Ivan Johansen. http://www.padowan.dk/

[18] - Limiting vs. Compression vs. AGC http://www.dvinfo.net/forum/all-things-audio/31466-limiting-vs-compression-vs-agc.html

[19] – LM4918, Stereo Audio Amp with AGC Controlhttp://www.alldatasheet.com/datasheet-pdf/pdf/95612/NSC/LM4918.html

[20] - Synthesizing an Audio AGC Circuit, Phil Anderson.www.arrl.org/files/file/QEX_Next_Issue/Sep-Oct_2010/Anderson%20Sept-Oct.pdf

February 2014 (Last revised May 2014) Page 20 of 20