Help with envelope detector

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

I couldn't find the UAD link Giancarlo mentioned, but found a couple of docs which discuss it a bit. The UA manual actually has some useful details toward the end.
http://arpjournal.com/all-buttons-in-an ... roduction/
http://media.uaudio.com/assetlibrary/1/ ... manual.pdf
http://www.oldcrows.net/~jhaible/compre ... press.html

It is said that, especially at higher comp ratios, the "program adaptive" nature-- Immediately after a strong peak, the ratio will be higher-than-expected on subsequent quieter signals. Lighter peak limiting, with aggressive boosting of audio after limiting occurs. Or something like that. Might have read it wrong.

Maybe it was intentionally designed that way, or is an unintended behavior which people like. A feature not a bug.

Many old compressors used the diode drops to set a compressor threshold. For instance silicon diodes typically have about a 0.6 forward voltage drop. Below about 0.5 volts hardly anything will go thru the diode. Then it starts barely conducting, and begins to conduct more the closer you get to the diode threshold. Above the theshold, they conduct with low resistance, except they subtract 0.6 volts or whatever from the signal. So 1.2 volts in would be about 0.6 volts out. 2.4 volts in would be about 1.8 volts out, etc.

So if you adjust the input gain on the rectifier driver, so that nothing goes thru the diode up to -20 dB audio level. And you set a high ratio, so that the gain element responds strongly to any slight control voltage input-- Below -20 dB, the gain element doesn't do anything. But as soon as the audio starts peeking over the diode drop, the gain cell savagely begins to cut gain. That is a crude limiter, strong gain-change as soon as the rectifiers start passing signal, and no gain-change below the threshold. Quick transition between the states. You basically set the threshold by setting the gain of the diode driver amp. If you wanted a -30 dB threshold, you would raise the gain on the diode amp, so it exceeds the diode drop faster. If you wanted a -10 dB threshold, you would reduce the gain on the diode amp, so input has to get hotter before the audio exceeds the diode drop.

If you wanted it to work about the same with a lower ratio, you would adjust the gain cell somehow so that it doesn't respond so drastically to changes in control voltage.

There are VCA type compressors that use this technique. And optical compressors based on LED lights often rely on the diode drop of the LED. LED's have a bigger diode drop than silicon diodes. Germanium diodes have a smaller diode drop than silicon diodes. The electroluminescent optical compressors much the same as best I know. Voltage has to reach a certain threshold before the light panel will turn on. At audio levels not hot enough to turn on the light, nothing happens.

The ratio control of that 1176 is kinda rube goldbergish. With lower ratios, it sets the diode bias for a lower threshold, and with higher ratios it sets the diode bias for a higher threshold. So that gain change doesn't happen until the signal gets fairly loud, but then when gain change happens, because the rectifier amp gain is set so high, it aggressively limits once a signel gets over the diode threshold.

Many analog gain cells were not very linear, and there were part-to-part variations. If you have a gain cell (FET, Opto, whatever) where every one in the parts bin is different, and it doesn't consistently change resistance as the control voltage changes-- It would be impossible to make a feedforward compressor with such oddball parts. Maybe your rectifier/smoother thinks it is changing the gain of the cell -3 dB, but the the cell actually changed gain by -1.5 dB or -7 dB. It would act too weird. Maybe instead of the expected behavior of the compressor getting 1 dB louder when the input gets 3 dB louder-- Maybe the oddball gain cell would actually get -2 dB quieter or whatever.

So that is an explanation of why so many analog compressors, especially early ones, were feedback designs. The feedback "smooths out" the oddball response of gain cells such as FETs or Opto.

On the attack and release times-- Release resistors R56 and R57 seem "predictable" release against that C22 capacitor--

Time Constant = R * C Given the 0.22 uF cap and a 270k minimum Release resistance, ought to be 0.22e-6 * 270e3 = 59.4 ms. The max release ought to be 0.22e-6 * 5e6 = 1100 ms. The UA 1176 manual quotes Release Time ranging from 50 ms to 1100 ms. In this case the simple math agrees well with the factory specs.

Unfortunately the calcs to not agree so well with factory Attack Time specs. The UA 1176 manual says attack time varies between 20 and 800 microseconds. I do not doubt this, but currently do not understand how it happens.

The minimum attack TC, calced the same way as release-- 0.22e-6 * 470 = 103 usec. The max attack TC-- 0.22e-6 * 25.470e3 = 5603 usec. About a factor of 6 discrepancy compared to 20 and 800 usec.

That C27 in parallel with the 470 ohm resistor might have some effect on very fast spikes-- The time constant of 0.022e-6 * 470 = 10.3 usec. Fc = 1 / (2 * pi * TC), so that would be a resonant frequency of about 15.4 kHz. So a high freq signal, or a spike with the same frequency content, would charge C22 slightly faster. But at 15.4 kHz the parallel impedance of C27 and the 470 ohm resistor would only be reduced to 332 ohms. That is not low enough to speed up the attack time to anywhere near the factory specs.

The feedback nature of the device may be at least a partial explanation-- At high ratio it will tend to drive the rectifier HARD on fast transients.

Or maybe there are other reasons. Doesn't much matter anyway.

Post

About the 1176, is there any kind of release-to-attack smoothing or is it as simple as the naive digital peak decay?

Post


Post

]JCJR, thanks!

here is a "dinamic performance in time" of the 1176 (warm audio)
28wp7wy.jpg
settings: ratio: 4:1, attack: 50%, release 75% (fastest=100%), GR: 18db appox
Wave burst: sine at 1khz, attacks: 0dbfs, releases: -12 dbfs.
The labels are in ms

The first release is much faster than the second.
You do not have the required permissions to view the files attached to this post.

Post

Thanks juha_p for the envelope detector link.
camsr wrote:About the 1176, is there any kind of release-to-attack smoothing or is it as simple as the naive digital peak decay?
Hi camsr. Except for "possibly accidental but beneficial side-effects" in the circuit, am guessing it might be a process similar to ichad.c's smooth_abs combined with ichad.c's first AR example in his earlier post-- http://www.kvraudio.com/forum/viewtopic ... 6#p6429081

A full-wave rectifier drives thru the attack pot pulling up the smoothing cap. The release pot constantly discharges the smoothing cap toward the "no gain change" bias point of the circuit.

In an "idealized compressor" which might use a VCA which is unity gain at 0 volts, and the VCA gain increasingly attenuates with increasingly positive control voltage-- Such an idealized compressor release circuit would be constantly discharging toward 0 volts.

N-channel FETs have a "pinch-off voltage" which is some Gate voltage negative to the voltage at the FET's Source terminal. In the 1176 the FET's Source terminal is grounded, so the Gate pinch-off voltage is a few volts below ground. The FET is the lower leg of a resistor divider, so if the FET is turned off, there is no attenuation. As the FET gets turned on and has lower effective resistance, the resistor divider attenuates the signal. Approaching 0 volts on the Gate, at some point, often still below 0 volts, the FET gets "fully turned on" and has its lowest resistance. Which may typically be as low as a few ohms up to maybe a few hundred ohms, depending on the FET.

If it was just the 27 k resistor and the FET-- And maybe if this FET can fall to 200 ohms minimum resistance-- Then max attenuation would be large-- About -43 dB. However the 1176 "lower leg" of the resistor divider is the FET in series with a 10 k resistor. So with the FET fully turned-on, possibly the max attenuation in the 1176 is about 20 * log10(10k/37k) = -11.4 dB. There are some feedback connections around the FET, some of them presumably for FET linearization.

Referencing the circuits in the UA 1176 manual, there is a C28 50 uF cap connected from the FET Source terminal, thru a 180 ohm resistor to ground. So am guessing that 10 k resistor from FET Source to ground primarily functions to establish a good ground reference for the Source terminal-- That most of the AC signal attenuation is the 27 k resistor for the top leg, and the FET thru a cap and 180 ohm resistor to ground for the bottom attenuator leg. Therefore the max AC attenuation might be as much as about -40 dB, depending on what the FET's minimum resistance might be. That cap circuit may also provide some minimal amount of positive feedback for linearization or whatever.

The manual describes a trimmer resistor to adjust the envelope smoother bias-- The envelope smoother's "zero point". You turn the trimmer all the way down to about -10 volts at the FET gate, well-turned-off. Then feed a signal thru the compressor and gradually raise the trimmer until the gain drops -1 dB. Which sets the normal no-signal state of the FET to "barely turned on". So you know it will start attenuating with any small increase of the envelope. No "dead zone" in that part of the circuit.

Anyway, rather than releasing toward 0 volts, the 1176 envelope releases toward that "FET barely turned on" negative bias voltage. Works the same. Merely at a non-zero reference level.

Post

I read that the 1176 threshold (set by the diode drops and bias voltages in the rectifier circuit) is about -20 dB, but varies according to the ratio setting.

So any audio below -20 dB is not big enough to overcome the rectifier diode drops, and so no attack happens and no gain reduction happens. If the audio happens to rise to -19 dB, just a tiny bit of the tops of the audio waveforms make it thru the diodes, so the envelope gets charged with the tiny short isolated pulses, just the tops of every wave peak hot enough to barely get over the diode hump. Given the attack control's "very fast" attack spec, the release control's job is to smooth out this sparse pulse train into a signal smooth enough to avoid horrible intermodulation distortion.

Because of the fast attack, if you input a gated -19 dB sine wave test signal-- Perhaps the first short top-of-the-waveform blip would be sufficient to charge the envelope up to the max peak of that blip. Then the release control would hold it steady only gradually discharging-- Even with a minimum release time of 50 ms. So the second short blip from the top of the second wave peak, the diode wouldn't attack for the full 1 dB difference, as did the first blip. The diode would only attack for the tiny amount it is above the envelope level charged up by the first blip. Whatever small amount that the release had fallen.

So with signals only a small amount over-threshold, after the initial attack from the first couple of short wave peaks, perhaps subsequent wave peaks would be "trickle charging" the envelope thru the diode working in its "transition range". Am probably not explaining well. If the envelope has been charged up to the peaks of the first brief pulses, then further peaks at the same level would only be a tiny amount above the slowly releasing envelope. So the subsequent peaks at the same level would be recharging the attack thru a diode "not completely turned on".

Unless the release is fast enough, and the over-threshold pulses sparse enough, that the envelope can fall enough between each pulse, to allow each pulse to "fully turn on" the diode.

So maybe digital attack code which has a "transition band" around the instantaneous envelope level, rather than using a hard if-then, could be more like the real circuit. Dunno.

As envelope detector input signal levels increase, more of each waveform peak would "peek out" over the diode drop. With real loud inputs, the diode drop would almost be irrelevant, and the rectified signal would look very similar to ABS, except with brief "gaps" between each rectified half-wave.

Post

Anyway, maybe ichad.c's smooth_abs with the smoothing factor would work a threshold somewhat like the diodes in the 1176 rectifier. Or maybe some other kind of thresholding would work better, dunno.

When I began this hopelessly long silly tedious message, was thinking maybe ichad.c's smooth_abs smooth factor would work to emulate the diode drop. For instance if we want the -20 dB diode drop threshold, then we might use a smooth value of -20 dB = 0.1.

RectSignal = ((Input ^ 2 + 0.1 ^ 2) ^ 0.5) - 0.1;

Given a sine wave peaking at 1.0, it outputs a smooth curve kissing 0.9 at the top and 0 at the bottom. Given a sine wave peaking at 0.2 (-14 dB) it outputs a smooth curve kissing 0.1 at the top and 0 at the bottom. On over-threshold signals it seems to smoothly rectify the input and subtract our 0.1 diode drop.

It works "slightly wrong" with below-threshold signals, but perhaps not wrong enough to matter. For instance, given a sine wave input peaking at 0.05 (-26 dB) the analog diode circuit would likely output dang close to nothing. But the smooth abs outputs a smooth signal kissing -38.6 dB on the top and zero on the bottom.

Given a sine input peaking at 0.001 (-60 dB), the output kisses -106 dB on the top and zero on the bottom.

The below-diode-threshold output is so low, maybe the "leakage" doesn't matter, even if technically it ought to be zero.

Another issue-- The smooth_abs is "more smooth than the actual circuit". If we input a -14 dB sine wave, then smooth_abs outputs a -20 dB nice smooth DC-offset sine wave. But the actual circuit would output a spikier train looking about like 120 degree wide isolated humps, each separated by 60 degree wide silent spots, with the peaks of the humps hitting -20 dB.

On the other hand, the smooth_abs ought to be easier to filter even if it would not behave exactly like the diode circuit!

Post

It looks the the variation is release is caused by a charging capacitor then? Interesting.

Post

camsr wrote:It looks the the variation is release is caused by a charging capacitor then? Interesting.
Hi camsr. Dunno. The 1176 circuit was just interesting enough to waste a day or two looking at it.

As said earlier, looking at the circuit, did not yet figure out what makes the attack as fast as they claim. Maybe because it is a feedback compressor, and at high compression ratios the high-gain circuit loop just tends to over-drive the snot out of fast transients thru the rectifier amp, until a few microseconds later when the FET finally gets a chance to reduce the gain enough to quit slamming the rectifier amp. Which may result in a charge rate much faster than one might expect just from the RC time constant of the attack knob and the smoothing cap.

I looked at FET specs of one mentioned by DIY guys for 1176 clones, 2N5457 https://www.fairchildsemi.com/datasheet ... BF5457.pdf

If you look at the chart, top-right third page. It is hard to read. The curve possibly of most interest, the one for 25 C temperature, room temp. The FETs vary unit to unit, and would likely behave different in an attenuator circuit. It would need putting one in a breadboard and testing under the conditions of being in an attenuator circuit. The chart is based on 15 V drain-source voltage, and audio input thru an attenuator would be most likely lower, and variable.

The chart is gate-source voltage on X axis, milli-Mhos on Y axis. Ohms is 1 / Mhos. The 1176 FET is a voltage divider against 27 kohm.

Unless I made too many math errors, guestimating from the tiny chart, Gate voltage vs effective resistance--
-2.4 volts = infinite ohms
-2.2 volts = 1 kohm
-1.75 volts = 500 ohm
-1.2 volts = 333 ohm
-0.5 volts = 250 ohm
0 volts = 222 ohm

OK, attenuation if the FET is 1 kohm, will be -29 dB. So if the FET behaves in an attenuator similar to the referenced spec chart, virtually all of the compression happens with envelope voltage varying within a 0.2 Volt window! No gain change at about -2.4 Volts and -29 dB gain change at -2.2 Volts!

The mMhos appear fairly linear between 0 and 1 mMhos at 25 C, at least on the tiny chart. Maybe a non-linear curve if zoomed way in on that small section. If it were linear, -2.3 Volts would be 0.5 mMho, would be 2 kohm. -2.35 Volts would be 0.25 mMho = 4 kohm. -2.375 Volts would be 0.125 mMho = 8 kohm. -2.3875 Volts would be 16 kohm. -2.39375 Volts would be 32 kohm. -2.396875 Volts would be 64 kohm.

OK, here is the required equivalent resistance vs attenuation--

-3 dB -- 63 kohm
-6 dB -- 27 kohm
-9 dB --14.5 kohm
-12 dB -- 9 kohm
-15 dB -- 5.7 kohm
-18 dB -- 3.9 kohm
-21 dB -- 2.6 kohm
-24 dB -- 1.8 kohm

So if the FET as attenuator, behaves "in the ballpark of" the spec sheet chart, gain change is on a sensitive "hair-trigger" once the gain feedback control signal starts peaking over the rectifier diode drops. An 0.2 volt control range, going thru diodes with about an 0.6 volt diode drop!

The ratio push button switches are double gang. Two sets of switches under each button. One set of the button switches raises feedback gain to the rectifier amp as the ratio goes up. The rectifier amp gain is lower at 4 :1 ratio and higher at 20:1 ratio, so the feedback gain change is more brutal once audio gets over the diode thresholds.

The other set of ratio switches adjusts the FET control voltage bias. Because the "no gain change" bias would be about -2.4 volts or whatever is "a little higher than the FET pinch-off voltage", I think the bias behind the rectifier diodes is set lower than this pinch-off voltage. So that audio has to reach a certain level before it gets past the diode drop.

I think with higher ratios, it sets the bias lower, so that the signal out of the rectifier amp has to get hotter before it exceeds the diode drop.

So when you raise ratio, it apparently raises gain on the feedback rectifier amp, and lowers the bias so the rectifier amp has to get "louder" before signal gets past the diodes.

So with high ratio, the thing apparently has "drastic" response when the high-amplified feedback rectifier amp finally gets loud enough to overcome the diode drop.

Post

plusfer wrote:]JCJR, thanks!

here is a "dinamic performance in time" of the 1176 (warm audio)
28wp7wy.jpg
settings: ratio: 4:1, attack: 50%, release 75% (fastest=100%), GR: 18db appox
Wave burst: sine at 1khz, attacks: 0dbfs, releases: -12 dbfs.
The labels are in ms

The first release is much faster than the second.
Thanks plusfer

Eyeballing the chart, it does appear to be doing close to 4:1 ratio.

Interesting that it recovers faster from the short burst, quicker than the long burst. That is an astute observation.

Also seems to be a major fast attack phase, followed by a slower minor attack phase.

Not all compressors mark their front panel or spec sheet envelope times in "Time Constants" but it seems that the 1176 uses that lingo. I like TC as a measurement marker, just observing that not all compressors use that method.

With a simple first order AR, 1 TC is the time it takes to attack to about 63 percent of the final value, or release to about 37 percent of the final value. Maybe there would be some better more intuitive marking method. With TC markings, if attack and release is set at 100 ms, it would mean that the signal would rise within -4 dB of max final value in 100 ms, and would release to about -8.6 dB of the max value within 100 ms. There may be a more "intuitive" easier-to-explain-to-customers marking, though maybe it doesn't matter. Folks who adjust a compressor until it sounds good, learn what numbers on the dials work good, so perhaps it doesn't matter what the numbers mean in that context, except initial settings for the next time the same kind of track needs processing?

Also, if you stick a scope probe inside the circuit and look at the envelope, maybe the envelope times would be different than the time constants of the signal going thru the compressor. If the envelope is moving to 63 percent of final value in X ms, then depending on the compressors gain mapping, in some cases maybe the compressor output would have moved to some other percent of the final value within the same X ms?

A simple envelope will get within 99 percent of final value in about 5 time constants. Eyeballing your 1176 plot, the second release seems to reach final value in about 865 ms. Divided by 5, would maybe be a TC of 173 ms.

Eyeballing that first release curve after the short burst, maybe about a 43 ms TC?

Taking that UA manual schematics as "standard reference"-- http://media.uaudio.com/assetlibrary/1/ ... manual.pdf

The gain reduction circuit on page 30-- C9, R6 and R7, C3 and C6. I think C9, R6 and C3 help linearize the FET response, distortion correction. But C9 also has a fairly low impedance AC path to ground thru low value resistors. Against the high resistance of R6 and R7, the path thru C9 has a time constant of about 1 second. So for audio frequency AC changes in the envelope, among other functions the components might do, R6 and R7 may function as a divide-by-2 attenuator of the gain control envelope. So if the FET's "natural" practical gain-control range might be about 0.2 volts, maybe this divider would expand the gain-control range to about 0.4 volts? Making its response to control voltage not quite so "hair trigger"? I don't know that the gain-control range of the FET would only be about 0.2 volts, merely guessing that it might be rather small from that FET spec sheet chart earlier posted.

C3 in parallel with R6, and C6 in parallel with R7-- Because these caps are also equal in value, as are the two resistors, at higher frequencies C6 and C3 might also function as a divide-by-two at the FET gate terminal. So the FET gate ought to get this same "control voltage changes divided by 2" effect at either low or high AC frequencies. But the impedance of the divider going into "AC ground" thru C9, would be lower for fast gain control changes (mostly divided by 2 and shunted to ground thru the capacitors). And the divider impedance of slow AC changes in the control voltage would be higher, mostly dominated by those two 2.2 meg resistors.

2.2 meg in parallel with 200 pf would have a TC of about 0.44 ms and a corner frequency of about 362 Hz. Above 362 Hz the capacitors would begin to matter more than the resistors (for AC changes) and below 362 Hz the resistors would matter more than the capacitors.

At 3.62 KHz, the two series caps would have impedance of about 440 kohm and a time constant against that C9 0.22 uF cap of about 97 ms. At 7.24 kHz, the two series caps would have half-again the impedance, and a time constant against C9 of about 48 ms.

POSSIBLY at fast gain changes, the path of the caps to C9 could charge C9 enough for it to act as a secondary release smoother. Wild speculation. Fast control voltage changes would only go in the positive direction. The earlier "primary" smoothing cap C22 would prevent fast control voltage changes in a downward direction thru that C3+C6 divider. So the caps MIGHT charge up C9 enough to matter on attacks, but never significantly discharge C9 on release changes because the downward changes are too slow for C3 and C6 to matter.

Dunno. Even a time constant of 48 or 20 ms is rather large. Might be an insignificant effect in the ciruit. Tis an interesting circuit.

Post

Great info JCJR!
Thank you so much

Post Reply

Return to “DSP and Plugin Development”