I've had the idea of an envelope-controlled VCA effect pedal for a few months. Of course, many existing circuits fall into this broad definition, including compressors, the boss slow gear and tremolo effects, for the VCA part. So what would set mine aside? One focus is on versatility. Once you have a way to control your output with a voltage, you can do whatever you like with it: swells, plucks, tremolo or even compressor if you try hard enough. I wanted to have at least a few of these modes at my disposal.
This project can be split into two main separate challenges: settling on a way to control the signal amplitude, and setting on a way to generate an envelope from the input signal. Other design choices and goals will be explained along the way.
The signal path
This part of the circuit is actually the most trivial to analyze. We just have an op-amp high impedance input stage with enough gain to compensate the loss of the following LDR-resistor divider when it's at the minimum attenuation. The LDR-resistor pair is the voltage controlled attenuator (hey, I never said the A stood for amplifier, but there's no practical difference here), which I've chosen because of its apparent simplicity (more on that later), low noise (compared to an OTA for example) and low distortion (unlike other methods, it doesn't require prior attenuation to keep distortion levels acceptable, which would otherwise harm the SNR).
The LDR I'm using has a wide resistance range, going below 1k at high light levels and above 60M at low light levels. Light resistance was measured at a current of 3.2mA with a 5mm bright red LED to be about 460Ω. To measure the dark resistance, I've thrown a shirt over it as soon as I was done with the LED and quickly got the measurement, since this will keep creeping back up for a long while otherwise.
The gate generator
Usually, in envelope-controlled pedals, the sidechain isn't much more complicated than an amplifier and a rectifier/peak detector giving you the control voltage. The envelope of this control voltage is simply decided by the charge and discharge curves of the hold capacitor, usually with a series and a parallel resistor.
While I think this basic scheme is effective in most situations, there are a few reasons I opted for something different.
First, unless the amplifier is saturating at all input voltages (which requires a way to gate any noise), the maximum output voltage depends on the input amplitude. Sometimes this is exactly what you want, for example it makes a filter controlled this way touch sensitive, but I don't think it's the case here. For one thing, it would mean that the gain depends on the input amplitude, thus making quiet notes quieter and loud notes louder (this is also basically how a compressor works). It also means that the attack and release times depend on the input amplitude too.
Second, this kind of envelope generator can only operate in attack-release mode. It charges when there's signal (attack) and can discharge only when you stop (release). Actually it will try to discharge when you're still playing too, since the resistor is always there, and this sometimes results in ripple, especially with slow attack and quick release settings.
Those are the main reasons I came up with what I have. As with the rest of the circuit, this part has been through many revisions, which included also full-wave rectifiers with gain and Schmitt triggers. In the end, what convinced me was simpler.
U2A is a comparator, with the amplified input voltage as one input and a trimmable reference as the other. I think SENS is one of the rare good places for a trim pot: it allows you to set a threshold which corresponds to the peak voltage at which the comparator output goes positive. This is something I usually set once and I'm happy with it but you can't really predict with enough accuracy. Since the input is DC-coupled and there are some offsets, I can't give you the exact maximum thresholds, but the trim spans a range of about 88mV, after considering the gain. As it happens, I went back and forth between this noninverting comparator and an inverting one with the trim pot in the upper leg. I've opted for this one for how the (positive) 272 offset allowed me to go all the way down to 0mV of threshold and a bit negative even, which results in a gate active with no signal and should be avoided. Either way, while most 272 have a positive offset, this varies between units and between op amps. What matters is that you get the threshold where you want it: low enough that any note triggers the envelope, high enough that random notes and ringing strings don't activate it, or even worse don't allow you to reset the gate. This depends on the instrument output level and technique, so you're free to adjust it. I've experimented with hysteresis on this stage, but I didn't feel like it was doing much, since the threshold is offset from the input by how much I want it already: anything above it is considered signal and that's it.
By itself, the output of this stage is a burst of ~8V pulses each time the peaks go over the threshold. It needs to go in the following stage to generate a good gate signal that is high when there's no signal, low when there is.
The output of the comparator charges C4 through a diode, so that it doesn't get discharged right away. The discharge path is through R8. You might think it wrong to have no series resistor before the capacitor, but I've seen examples of this practice: the limit is the op amp's output current, and that's fine for a nonlinear application where I don't want any delay between the input and the gate changing state.
The capacitor voltage is compared against an arbitrary reference, for which I used the one I already had. Why arbitrary? We can assume the capacitor gets charged practically in an instant, what is important is that the discharge time is fast enough to feel responsive, slow enough to avoid double triggering of the gate because of some ripple. From the RC discharge formula and rearranging for time, we find that the time to get from my “on” voltage V+ to my threshold V0 is
t=(ln(V+)-ln(V0))RC
Given that the positive saturation voltage of the LM358, in line with most op amps, is about 8V on my 9.3V supply, I still have the values of R and C to play with to get what I want. Having set C to a nice 100n, I found values of R of 220k and above to work reliably. Here I've chosen 470k because it works well also with bass, for guitar 220k was also perfectly fine. This gives me a quite snappy 26ms recovery time, the time it takes for the gate to go high again after cessation of the signal. To give some context, this is the length of a 64th note at 144 bpm. I think that's fast enough for anyone.
As this gate generator works, there will always be a point where the signal drops below the threshold, if anything because to signal a new note start, it has to go back high again beforehand. Ideally, you want to mute your strings before you get to this point, which takes some seconds, because I've observed that the amplitude envelope of a ringing string usually has some ripple towards the end, and that will result in multiple triggering of the gate, as the first comparator stops enough for the capacitor to discharge, before outputting some extra pulses. Other than proper technique, the only other fix I've found for this problem was to make the time constant sluggishly long, or lower the threshold (same thing, as we've said). No amount of hysteresis was of any help, and this is a behavior shown also by other gate generator/fundamental detector circuits I've simulated, from MFOS and parasit studio.
I've tried adding hysteresis here too, but realized there's no point in having two different thresholds: the positive going edge is as fast as it's allowed, so it matters little where it lies. That leaves me just to set the negative-going threshold far from eventual ripple, as established by the RC time constant.
Anyway, now that we have converted the input signal into a gate, it's time to feed it to the envelope generator!
The envelope generator
This envelope generator uses a LM555 and is built around a schematic by Thomas Henry. His view of the 555 as a collection of parts inspired me to look further into this popular chip and made me realize it's indeed a very convenient package for this task, even if it's possible to achieve the same results otherwise, for example using D flip-flops and comprarators like MFOS, or NAND schmitt gates, as in an equivalent version of this sidechain using only those devised by my friend aotmr. Thanks to this research, I was also able to adapt the circuit to my purposes.
The main gate input is the one going into pin 2. One difference from the reference is that I'm using U2B to provide an active-low gate, so there's no discrete inverter in front. The AD/swell switch allows two modes, the Loop switch a third one:
In AD mode, only the negative edge is passed on, which means the 555 will time the envelope just on the note attack, first charging C9 through the attack pot, then discharging it through the decay pot as soon as the upper threshold (6V) is achieved, even if you keep playing during this time. This mode is good for pluck sounds, with the attack set to minimum and a defined decay, or short envelopes with both attack and a defined decay, or “reverse” sounds with a slow attack and a short decay.
The other mode is Swell, which instead DC couples the gate to the trigger input. This is a more traditional AR envelope effect, which attacks as usual, but with a time only dependent on the attack setting, and stays at unity gain until you stop playing, at which point the release stage begins. As the name says, this is the mode for swells, if you just want a slow attack and then let everything pass until the gate eventually closes. The release pot allows you to adjust how quickly the signal gets muted again: a quick decay allows you to swell every note, a slower one allows you to keep playing after the envelope has been triggered. This mode is also useful as noise gate: set the attack to the minimum, release at will, and it will faithfully reproduce the input until it gets under the threshold, at which point it will get muted.
The final mode is Loop. This overrides the AD/Swell setting and feeds the envelope output back into the trigger input, causing it to loop like an oscillator with separately adjustable ramp-up and ramp-down times. In this mode the effect is basically a tremolo with a wide frequency range, from a fraction of an Hz to audio frequencies, with the waveform adjustable from ramp down, through triangle, to ramp up.
Having talked about the basic operation, there are some additional tricks I've used to get it working as intended.
The first one is the switch on the reset pin. I've quickly realized that if I just tied this pin high, the envelope, once triggered, would continue its cycle to the end no matter what, oblivious to the fact that I might want to trigger it again sooner. Q1 has the simple task of switching the reset pin high as soon as the gate goes low, allowing the envelope to trigger successfully, but to pull it down as soon as the gate closes, regardless of the AD/Swell setting, making it go into the decay/release phase straight away if the input signal stops. I feel like this is the desired behavior with this kind of envelope in all circumstances, with the two modes providing decay or release, but if it's something you wish to have control over, that's how you could.
Trick number two and three: the circuit as described works well for the envelope modes, but in loop mode it would output a voltage oscillating between 3 and 6V, because those are the two thresholds by default. This results in a very “shallow” tremolo. One effective fix is to use the output to pull down the CV pin, which drags with it both thresholds. Since it can only be pulled down, the upper threshold for pin 6 is still 6V, but when trigger needs to set the internal latch, the threshold will be about 0.9V. This doesn't affect the envelope operation, but makes the loop more much more effective.
The only problem lies with the AD mode: Swell is DC coupled, so the single supply 358 can pull the trigger pin to ground without issues. In AD mode, where pin 2 is usually pulled up to VCC, you can only rely on the negative edge from 9V down, so an op-amp which has just 8V of swing, not being RRO, can't go below 1V. This is fixed by trick three, which is to bias pin 2 to about 8V for AD mode. The divider gets overridden in the other two modes anyway. D4 is just a protection against the corresponding positive going edge when the gate goes back up.
Voltage control of the LDR
Now that I had a nice input-controlled envelope, it would be a waste to use it badly to control the LDR resistance. There are multiple steps to this process: the function of control voltage to LED current, the function of LED current to LDR resistance, the function of LDR resistance to attenuation.
Let's do as I did and work backwards: the resistance-to-attenuation formula is just the voltage divider formula, with the added complication of not knowing the value of the fixed resistor. What I did was looking at the minimum and maximum resistance of the LDR, work out a formula for the attenuation ratio, and looking at different cases for different values of the fixed resistor. For the series LDR, shunt resistor, as I'm using it in the circuit, this formula turns out to be
(R+D)/(R+L)
with R the fixed resistor, D the dark resistance, L the light resistance. I've also worked out the case of series resistor and shunt LDR, which is
(D(L+R))/(L(D+R))
Turns out, perhaps unsurprisingly, that these two configurations are equivalent, since the voltage divider R/(V+R) with series LDR is 1-V/(V+R), with V/(V+R) being the voltage divider with shunt LDR and V the variable resistance.
This means, by plugging in the extremes of 0 and infinite resistance for R, that the limit attenuation range is equal to the LDR resistance range, and the minimum approaches 1 (no attenuation) for both cases.
The main takeaway from this, and the main difference between the two, is that you need different resistors to reach optimal performance, by which I mean the best compromise between attenuation range and static minimum attenuation. Of course using a ridiculously small resistor for the series LDR case will give you the maximum range, but you also don't have much signal left even when the LDR is at minimum resistance.
Say you want -6dB as your maximum level, that means a resistor equal to the light resistance for the series LDR case, but a resistor equal to the dark resistance for the shunt LDR. Of course the dark resistance will probably not be reached in most cases, which limits the available range but also means a more reasonable resistor for the shunt LDR case. In both cases, given the nice symmetry, the attenuation range achieved would be (D/L+1)/2, close to one half, in linear terms, of the maximum, or just 6 dB less.
Keeping this in mind, let's pass on to the LED current to LDR resistance function, which is the one we have less control over, save choosing a different LED or LDR. By my measurements and also from references 1 and 2, the agreement seems to be this is a power law with a negative exponent and a constant which is the light resistance. Keep this in mind too.
The final piece of the puzzle is the voltage to current relationship. With linear control voltage, ignoring from a moment the current to resistance relationship, we basically get a linear attenuation, which means a logarithmic curve in dB. So it would make sense to have an exponential control over the resistance, in order to get a linear-in-dB attenuation curve. Turns out the power law doesn't mess with this too much, except for adding an upper bound to the attenuation, which is what we expect from reality anyway. Thus all we're left with is adding an exponential converter, which isn't unheard of for controlling a vactrol.
The exponential converter
Q2 takes an attenuated version of the envelope output and can be thought of as a follower which also cancels out the corresponding Vbe offset of Q3. When the control voltage is 0V, the only base current to Q3 is from the large pull-up resistor, which results in a current I measured to be about 5.6uA through the LED. When there's a voltage on the base of Q2, this results in an exponential increase of current through the LED, according to the BJT's transconductance relationship. R22 doesn't really affect the operation and just puts a safe limit to the current which isn't normally reached in operation.
The range control, as I've said, adjusts the quiescent LED current and to a lesser extent the maximum current. I've chosen R22 so that the maximum current is limited to the same amount, so all this does is reduce the range between off and on resistances, if you want a more subtle attenuation effect which doesn't completely mute the signal.
The more astute might have worked out that, while AD and loop mode peak at 6V, the Swell mode can reach 8V (the saturation voltage of U1B) because C9 keeps charging as long as there's signal. This could result in a louder signal in this mode, because the LED is driven harder. While this was not very audible in testing, I adjusted the attenuator before the exponential converter anyway so that it saturates at 6V, giving the same attenuation in all modes.
Patching
I've included a couple of suggested locations for external gate and CV. The gate takes the place of the level detector and is placed before the inverting comparator so you can use a standard active-high gate. The gate voltage should be at least 5V (or less if you want to power this circuit from lower voltages!), up to the supply voltage, using an attenuator if that gets exceeded. If instead you want to use a passive foot switch, that can only pull down, you should place it after U2B and provide a pull up resistor there, or wire it between pin 6 and VCC.
The other jack is a CV input, which is shown for 5V but can easily be adapted to other voltages by scaling R18 accordingly. If you keep the envelope connected this provides modulation over it, but if you prefer turning this into into a somewhat accurate VCA that accepts an external linear CV, you can put a dummy plug into “gate in” to stop the envelope, without the need for another switch.
For operation at different voltages, the only thing that should be necessary is scaling R19 and R22 proportionally.
Component choice and unused tricks
The circuit features an curious combination of op-amps and that matters more than usual. For U1A the requirement is just low noise, since it's an ordinary low-gain amplifier. Since I had to use its other half though, I've decided on the TLC272 I had, which isn't that noisier than a TL072 and is a single supply CMOS op-amp. I needed this feature because the other half had to go either where it's shown, or where U2B is, and both of those need the full swing. U2A doesn't, but since the output of that is a burst of full-output pulses, I had crosstalk issues by having that on the same chip as the low gain input stage.
The only real requirement for U2A is that it can work as a comparator. I actually had a 072 here before noticing the crosstalk, and it worked fine thanks to the unused trick #1: if used as noninverting comparator as shown, the 072 will flip into positive saturation again if the noinverting input drops under a volt or so, and that's not good. I've noticed that using it as inverting comparator didn't show this problem, and I took advantage of this by having a 072 as U2B before needing the full negative swing after the CV pin trick.
It's worth mentioning here unused trick #2: using a series LED as level shifter for the 072, which allows its output to go down to 0V. I was making use of this to make it possible for it to turn off Q1 and also experimentally to shift the loop output down for better muting. When I added the CV modulation trick I decided to move the single supply 358 there because in AD mode the necessary trigger is down from the bias point, so that would have had to be further down.
So the requirement for U2B and U1B is again going down to the negative supply rail and, for the latter, that it doesn't have phase reversal since it's used as a follower on a single supply (the Henry circuit gets away with using a 072 because it's powered from a bipolar supply). You could honestly use two 358 if you want, or any other single supply op-amp that satisfies these few requirements.
I've ended up using the other half of the 272 where it is because, unlike the sharp edges of U2B, the output of the envelope has smoother ramps, and the decay one which is the more annoying in case of pops and clicks is limited by the stopper R16.
While the more frugal CMOS 555 would seem a perfect choice for this kind of circuit, I've tried a 7555, after scaling R29 to 22k according to the 100k internal divider, and I had a small issue with the reset switch Q1 not doing its job: the envelope and loop mode worked well, but I couldn't get the envelope to skip to the decay phase when the gate closes as intended. Maybe others will work well, but I've opted for using the bipolar variant with generous supply decoupling and it works well for me.
The build
Here are some pictures of my build. I had to make another riser frame because I keep overestimating the depth of a 1590B. I then plugged the ends of the DIY vactrol with tack, after checking it's not conductive. Acrylic glue measured about 1Meg even when seemingly dry. This is probably less than necessary, but I didn't want light leaking in from my clear frame.
The indicator LED is D6 in the schematic. I've actually wired it between VCC and the op amp, switching it with the bypass switch. This way it shows an inverted version of the linear envelope, which means it's on with the pedal engaged and no signal.
You can see shielded cable for the AD/AR switch: since this brings the gate signal, I had pops whenever it got near anything else but this fixed it.
Board layout
Here's a verified perfboard layout for it. The indicator LED is as in the schematic here (anode to op-amp).
Demo
It's difficult to do this pedal justice with a short demo since it's so versatile, but I've tried to show the main features.
As usual, thanks to aotmr for the support and feedback.
Update: sidechain input and active-low gate
The below schematic shows two more addition to the sidechain that should cover the remaining possibilites: the sidechain input allows using a different signal to trigger the detector (clean signal, other track, metronome; be creative); the active-low gate has the simple advantage that a ground-referenced footswitch can be plugged in and used to trigger the envelope, while it can still be converted in a standard gate by a transistor.
I absolutely love this! I have long been kind of obsessed with using ADSR type effects for guitar. This circuit, with its ability to use an external trigger, reminds me of the total sleeper, the Paia Gator, which was my first foray into this sort of thing. I got a lot of mileage out of the Gator as a triggered tremolo, feeding it a pattern from a drum machine that my drummer would also be listening to in order to sync the tempo. I currently have the new, digital EHX Attack Decay, a Behringer Slow Gear clone (I sold my Slow Gear) and a Pigtronix Philosopher King, which is based on the original analog (CA3080-based) EHX Attack Decay. The latter…