"That" compressor - good, easy, adjustable DIY compressor  [documentation]

Original effects with schematics, layouts and instructions, freely contributed by members or found in publications. Cannot be used for commercial purposes without the consent of the owners of the copyright.
Post Reply
User avatar
dylan159
Solder Soldier
Information
Posts: 240
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 86 times
Been thanked: 477 times
Contact:

Post by dylan159 »

I had wanted to make a compressor circuit for a long time, because it's a popular and somewhat easy to make effect, but the existing DIY offer left something to be desired. You should be ready to accept some compromise, in the form of: noisy and hard to find OTA chips; expensive and hard to find (in THT at least) VCA chips; hard to find (again in THT) and fiddly JFETs; circuits that underperform in some way or another, or; circuits that aren't well translated to instrument input and stompbox format, in the form unbuffered gain controls and bipolar power supplies.
I'm not claiming that making a good VCA is easy, and the VCA chips of THAT corporation deserve some credit anyway, for their incredible performance and how easy they make a precise gain control. I own a compressor using one of such chips, and while I can't find any flaws in it, I still think a more accessible DIY alternative should be possible, without any major compromise.

I was then confronted with a choice between LDR optocouplers and JFETs as control elements: the former offer very good distortion performance, and I've used them successfully in the VCA-1 and the Trembling Satellite; I still wanted to give the latter a chance, because of their intrinsically higher speed (attack time can always be made slower with the side-chain, but there's an intrinsic lower limit) and the better defined voltage-resistance relationship. I thought they were still a decent option, if the circuit wasn't picky about specific part numbers, given also the possibility of using SOT-23 devices.

I've actually made and tested a JFET circuit before this one, but I was forced to face a distortion problem that's hard to overcome: I thought instrument levels were small enough to be fine, but the peaks (otherwise, what's a compressor for) aren't! There are ways around it, but an upper limit on amplitude handling without distortion is given by Vp, the pinch-off voltage. You can't use a part with a very negative Vp on a 9 V single supply or you won't be able to use much of its resistance range. Moreover, the necessary local negative feedback (usually) halves the control voltage that reaches the gate, making things even worse!
This is how, after a month, I ended up with the following circuit, using a trusty homemade LDR-LED optocoupler, with the LDR is still available at low prices despite its small Cadmium content, a situation I hope doesn't change.

That's not to say my troubles instantly ended, having made this choice: they started even earlier, due to the general lack of useful technical information about compressor theory, and they persisted, while I was looking for a circuit that gave me the results I wanted. THAT corporation has by far the best collection of resources, but while it's all useful on a general level, most of it is best applied to their own chips. You start getting into this and the world seems in your hands, but then you wonder how general those conclusions are, when you don't have RMS detectors and precise voltage-gain control relationships.
Maybe it's worth taking a moment to go over some general principles.
Notes on dynamics processing
Dynamics processors are inevitably shown on a log-log plot of input vs. output dB levels, like the one here for a downward compression (the usual kind).
compressor.png
The x axis shows the dB (peak, RMS, pick one) of the input signal, on the y axis the corresponding dB level at the output. Easy right? Deceptively, I'd say. Also because the axes are logarithmic, this kind of plot has some quirks:
  • Because it's a steady-state representation of input vs output in dB, the slope doesn't represent gain, but the rate of change of gain: the slope corresponds to ratio, and an unprocessed signal will always be a 45° line (the black one). Compression and expansion result from rotation of those lines.
  • Static gain has the effect of sliding the whole curve up or down (dBout = dBin + c), but gain at any point isn't easily visualized if the slope isn't 45°.
The curve above represents downward compression: at some point above a threshold, the transfer curve deviates from a straight line, and is rotated clockwise (the grey portion). Through a combination of above and below-threshold rotation, in both directions, one can achieve different effects:
  • Line passes through the origin, slope is 45°, there is no threshold; this is a unity gain buffer.
  • Slope is 45°, there is no threshold, but the line doesn't pass through the origin; if it passes above it's an amplifier, if it passes below it's an attenuator.
  • The less trivial case above; 45° line through the origin, rotated clockwise after a threshold. Downward compression with unity gain below threshold.
  • 45° line above a threshold, but it's rotated anti-clockwise below a threshold. This is downward expansion, and if you prolong the 45° line and it passes through the origin, above-threshold gain is unity.
  • Same as above, but the line turns clockwise below the threshold; this is upward compression. You know it's compression because the output dB range is smaller than the input one.
  • 45° line from the origin up to a threshold, then it rotates anti-clockwise; this one is upward expansion.
  • There is no threshold in this dB range, the whole line is turned clockwise; this is the so-called "full range" compression.
  • In the same way, turning the whole curve anti-clockwise results in "full range" expansion.
Some of these cases are less common than others, and these are only the simplest, since you can have more complex curves with "soft knees", two nontrivial slopes, multiple thresholds...
The circuit
compressor.png
This circuit aims at being a simple but versatile compressor, meant primarily for stompbox use, but suitable for other applications, given the good signal handling capability and the control options. It's configurable for anything between 1 and 5 controls: the schematic shows all of them, but includes suggestions for fixed values to substitute where possible; the "Threshold" control is the only one that is necessary, followed by the make-up gain.

I don't feel very ashamed for having reused the same joke as for that overdrive for the name, since it seems even more fitting for a compressor :D .

Signal path

The signal path is simple, as in these circuits the complexity tends to be concentrated in the side-chain. It's reminiscent of the ones found in the VCA-1 and the Satellite, but with the difference that the LDR is normally non-conducting if the signal is below the threshold; this is because the turn-on time of LDRs is faster than the turn-off, and I wanted to be able to have a fast attack.

The small amount of gain at the input improves SNR over having it all after the attenuation, and is possible thanks to the low distortion of LDRs even at large levels. I've found that 6dB is a safe amount of gain to avoid clipping, at 9 V with normal op-amps.

The second half of the 072 buffers the output, and can go from 0 up to 20 dB. This is only necessary with low thresholds, when most of your signal is compressed instead of just the peaks, and the average level drops.

I was experimenting with the resistance in the attenuator to observe something I call "compliance": how many dB above the threshold can the input go before the compression ratio goes down, because the control element can't attenuate the signal further ( in this case, the resistance has reached a minimum). While this eventually happens, the main consequence is a decrease of the compression ratio without affecting the threshold. To explain this, think of the divider as a common emitter amplifier and vary the load resistor: in feedback compressors, ratio is proportional to closed-loop gain. That's how this became my

serendipitous "Ratio" control. This could also be a switch between presets. The relationship isn't linear, and the ratio here varies between roughly 3:1 and 8:1 (measured). If you don't want the control, I think 47k is a good compromise between Johnson noise and the high ratios usually found in stompbox compressors.

The LDR I've used has a wide resistance range, roughly from 400 ohms (light) to 20M (dark), but almost any should work fine, since the low part of the resistance range isn't usually reached in practice, and it's the ratio with the "Ratio" resistance that matters for both: as long as the dark resistance isn't higher than that, nothing bad will happen, and if it's not, it's just a matter of make-up gain. Feedback will take care of the rest.

Side-chain

I went back and forth between different arrangements for the side-chain, both referenced to half supply and to ground (possible with the 358-style op-amps), before settling on this one. I've even tried a feedworward arrangement, but found it unusable with the not-well defined characteristics of the optocoupler.

The final design features 4 op-amp sections, but despite that it's as compact as it can be. I show using a LM324, which is the quad version of the 358, but two LM358 can be used instead. These op-amps aren't the best in most regards, but you'll find me using them often out of the signal path not only because they're one of the cheapest and most easily available models, but for their very useful capability of having the output go to the negative rail ("single supply" op-amps). This is exploited by U1B and U1C here.
The first op-amp just buffers the signal before the rectifier. Not sharing this stage with the output has the advantage of letting you set the make-up gain without it affecting the threshold or the ratio in a vicious cycle. An op-amp buffer keeps the same DC level, which is necessary for correct operation of the rectifier.
The rectifier itself is an odd one: it's based on one of the simplest full-wave precision rectifiers possible, which I've found it shown by two different sources.
How it works is that U1A is an inverting amplifier with -1 gain for inputs more negative than Vref, and the diode drop is compensated by feedback. With more positive inputs, the output of the op-amp is disconnected and the signal goes out through the two resistors.

The downsides of the original are that it's sensitive to both source and load impedances: the buffer takes care of the former, U1B of the latter. The third issue, and the one that led to my version, is that the op-amp goes open loop on positive peaks, and those 4.5 V negative pulses can couple in very small quantity to nearby stages pretty easily (the demo below was made with this rectifier, and you probably can't hear anything wrong, but it bothered me).
My solution was to make an hybrid between this and the standard full-wave rectifier shown in the ESP page above. You can think of this as a version of that one with passive summing, or a version of the more frugal one that doesn't go open-loop as badly. The only thing to watch out for is that the resistor feeding the input must be much smaller than the resistor network in the inverting rectifier, for the two peaks to be matched. This is done in the schematic.

It's even possible to ground-reference this circuit (and it would solve the open-loop problem), and even AC-couple it: in this last case you need to be careful to load the source with a resistor smaller than the two input and feedback resistors (10k to ground, 100k in series works well).
You might think "why haven't you just used the more standard precision full-wave circuit instead"? For some reason, trying to offset that one in a similar way, by pulling the virtual ground input up to 9v, couldn't get the output below 0.6 V and the rectifier just got clipped below that, a problem I didn't have with the "Threshold" control connected to the inverting input, and the rectifier to the noninverting one.

What follows is a somewhat standard AD envelope generator, using signal Schottky diodes for the good compromise between low Vf and leakage. Discharging to the op-amp output, together with the full-wave rectification, results in very low ripple. Linear taper gives linear control over Attack and Decay times (which are level-dependent so not specified), but log pots might give better adjustability, I haven't tried it. I've also suggested some good fixed setting for the total resistance if you don't want these controls. I understand not everyone wants the highest number of controls in a compressor like me, and the "Decay" control is particularly subtle, unless you play staccato and set it too slow. Ripple is not an issue even at the faster settings, it seems.

While it is sometimes possible to connect a passive AD directly to the rectifier, that one needs to have an output that goes open with no input, or the capacitor would be discharged just as quickly as it charged. An example of this is the simple single-diode precision half-wave rectifier. Here, U1B has also another role, though...
For the rectified signal, U1B is a non-inverting amplifier with a gain of two. The inverting input is fed a voltage by the "Threshold" control, and for this one it is a unity-gain inverting amplifier. What this does is shift the rectified signal down from 4.5 V. At the maximum setting, U1B idles at 0 V, at the minimum at about 1.2-1.3 V, a voltage that is just below what's required by the LED for any significant attenuation. This effectively controls the peak signal voltage required for the optocoupler to kick into action. Together with the envelope diodes, this results in a little bit of soft knee, even if not by much.
The threshold voltage varies from basically zero, to ~ -6 dB from the maximum designed input level of 1 V peak.
The 47k resistor in series with the "Threshold" pot is generous, to account for tolerance in the pot resistance value, but is the largest common value that allows full control over the thresold. You'll find that at very low settings (below a quarter, depending on "Ratio"), there will always be some attenuation. This is the point at which the compressor stops behaving like the usual above-threshold compressor, and becomes a full-range compressor, with a ratio that is fixed at about 2:1 regardless of the "Ratio" setting (or any other circuit parameter, I'm not sure why). A linear potentiometer gives linear control over the threshold peak voltage, but a log pot gives better control over low threshold settings.

The envelope output (yet another node that is sensitive to any kind of loading, even BJT base current), is buffered by the last op-amp to drive the optocoupler LED. In most cases, the LED current is low and it glows dimly, so the 1k resistor is mostly there as safety measure. I've used a 5 mm high brightness red LED, but yellow, green, red and white are all suitable.

Other amenities like high-passing the side-chain or a high shelf eq on the output are easily applicable, but I think the circuit as it is doesn't need anything else and can stay reasonably simple.
Transfer curves
Here are a few representative curves. In all of them 0 dB = 1 V peak. The yellow line isn't representative of input signal and is mostly just a reference for compression ratio, because of the make-up gain and my interface's input gain setting, but I've made an attempt to match it with the sub-threshold level, or with the half-way level for the "full range" one.
halfthresmaxratio.png
Threshold at half, ratio maxed.
halfthresminratio.png
Threshold at half, minimum ratio.
fullrange.png
Pseudo-"full range" with the threshold set very low.
Demo
Acknowledgements
As it is usual for my most involved projects, I thank aotmr for the feedback, the discussion, and helping me find a way out when I was stuck with some issues.
Plugindoctor has been fundamental for checking that I was getting what I wanted, but if you know of similar software let me know.
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
bmxguitarsbmx
Cap Cooler
Information
Posts: 472
Joined: 25 Mar 2010, 21:15
Has thanked: 657 times
Been thanked: 203 times

Post by bmxguitarsbmx »

* not to be confused with the THAT4301 Compressor popular with DIY'ers. At first I assumed this would be a 4315 version of the THAT4301 or something.

User avatar
dylan159
Solder Soldier
Information
Posts: 240
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 86 times
Been thanked: 477 times
Contact:

Post by dylan159 »

bmxguitarsbmx wrote: 02 Jul 2023, 20:27 * not to be confused with the THAT4301 Compressor popular with DIY'ers. At first I assumed this would be a 4315 version of the THAT4301 or something.
I knew the joke would have worked! You mean THAT compressor, but I've made this compressor! :lol:
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
mictester
Old Solderhand
Information
Posts: 2915
Joined: 11 Sep 2008, 20:29
my favorite amplifier: Mesa Boogie, Roost Sessionmaster, AC30
Completed builds: Hundreds! Mostly originals, a few clones and lots of modifications.
Location: Somewhat closer to Amsterdam than before!
Has thanked: 32 times
Been thanked: 825 times
Contact:

Post by mictester »

That is a pretty nifty piece of design, and you've made a very good job of explaining your design approach and reasoning.

I have one (minor) criticism: I've never liked "exposing" Op-Amp inputs directly to the Outside World™ - I've always found them to be somewhat vulnerable - so I'd be inclined to add a simple unity gain transistor buffer stage to the input. This would have the added benefit of allowing the biasing resistor to the first stage non-inverting input to be much smaller, reducing its noise contribution (obviously requiring an increase in the value of the DC blocking capacitor). You could (if you wanted) use bootstrapping to give a high input impedance, without the risk to the input of the TL072....

I also have a suggestion - The LCR0202 is an LED and LDR combination in a small opaque black plastic box. I've found that this part is ideal for this kind of application, and has the advantages that you can test your board with ambient light present and it's a neat, robust solution. They're widely available for pennies (I bought a whole bagful of them from Aliexpress for $12). They're also easy enough to match up accurately if you want a stereo pair....

Your compressor can act almost as a limiter when the ratio is set high, and the rapid attack time of the circuit makes it good enough for line-level use (with minor modification), and I've used something similar to a stereo version of this circuit for many years to protect my PA speakers from over-enthusiastic musos!
"Why is it humming?" "Because it doesn't know the words!"

User avatar
dylan159
Solder Soldier
Information
Posts: 240
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 86 times
Been thanked: 477 times
Contact:

Post by dylan159 »

mictester wrote: 02 Jul 2023, 22:30 That is a pretty nifty piece of design, and you've made a very good job of explaining your design approach and reasoning.

I have one (minor) criticism: I've never liked "exposing" Op-Amp inputs directly to the Outside World™ - I've always found them to be somewhat vulnerable - so I'd be inclined to add a simple unity gain transistor buffer stage to the input. This would have the added benefit of allowing the biasing resistor to the first stage non-inverting input to be much smaller, reducing its noise contribution (obviously requiring an increase in the value of the DC blocking capacitor). You could (if you wanted) use bootstrapping to give a high input impedance, without the risk to the input of the TL072....
Your intentions are noble, but buffers are made of real components and add their own noise, without any gain to offset it! You'll often find me criticizing circuits that follow this "buffer first, think later" approach, usually even with a lot of gain after them. This is a concern that comes with the small instrument level signals.
Don't worry about the bias resistor: it's true that its noise is at the input when the input is floating (it would be swamped by the various interferences), but when something is plugged in it's shunted by the source! Even a guitar pickup is low enough impedance that an high impedance bias resistor doesn't increase noise (finding by Douglas Self, small signal audio design).
I personally haven't had an issue with static damage on op-amp inputs yet in years, but a series 1k resistor should be sufficient to protect it (you can pair it with diode clamps too). Maybe I'll start incorporating that into my design vocabulary, as I have for the series resistor at the output to isolate cable capacitance.

You can use prepackaged optocouplers, but I always assume the most common, cheapest, simplest components. Homemade ones never failed me, and this circuit is a test of how you can breadboard with one: I was using a shirt before, but I've found that by using two layers of not heated shrink tubing (to disassemble it later), plugged at both ends with tack adhesive, my LDR measured >20M in indoor daylight, which is as high as it can go.

Thanks anyway.
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
Lani
Breadboard Brother
Information
Posts: 141
Joined: 22 May 2017, 11:57
my favorite amplifier: Bassman 5f6a
Completed builds: .....ummmm yeah. Too many to list.....
Location: Ithaca, New York
Has thanked: 107 times
Been thanked: 74 times

Post by Lani »

Thanks for this Dylan159!!!
I'll upload the .PDF files when I get home from work this evening.
THAT COMPRESSOR - 3D TOP (BK).png
THAT COMPRESSOR - 3D BOTTOM (BK).png
Here they are...
If anyone wants the gerber files PM me...
EDIT- Schematic added to file
Attachments
THAT COMPRESSOR - ETCH FILES & SCHEMATIC.rar
(353.21 KiB) Downloaded 13 times
Last edited by Lani on 04 Jul 2023, 22:02, edited 2 times in total.

User avatar
dylan159
Solder Soldier
Information
Posts: 240
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 86 times
Been thanked: 477 times
Contact:

Post by dylan159 »

Lani wrote: 03 Jul 2023, 12:25 Thanks for this Dylan159!!!
I'll upload the .PDF files when I get home from work this evening.
Great job as usual!
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

Post Reply