About
I always raise my nose at the idea of playing PWM audio from a microcontroller and opt for an R2R DAC because PWM has none of the sweet digital crunch and is harder to control from low-level C. But at some point i thought - maybe, maybe i could applyi the PWM idea to analog signals as an alternative way of creating a VCA. After all, if PWM from an arduino can create a waveshape, what should be stopping me from interrupting an analog VCO's output on and off real fast, smoothing it back out, and getting a quieter version of it?
Nothing! And this module does precisely that, in double. For a classic approach crossfader, one would have to take two VCAs, mix them down, then drive one in inversion to the other, so that as one gets quieter, the other gets louder. This design switches between the two signals repeatedly with the proportion of which gets more "showtime" per cycle as the fade control. Do this fast enough, and the ear stops hearing switching, and starts hearing mixing. This switching is done at a frequency outside human hearing range so that no artifacts show up as long as the fundamentals stay below ~9KHz. This approach takes way less parts than the classic VCA-based xfader. The drawbacks are bigger (but still non-critical) distortion, lack of precision for 1V/O CV processing and a slight "drop" in the repsonse curve instead of a continuously linear fadeout right when the signal's about to go from very quiet to silent.
At the top of the unit i made are two such crossfaders, each fit with two inputs and an output. The upper knob is the initial xfader position, marked with which input gets louder in which direction of the knob. A CV input fit with an attenuator allows controlling the fading with an external signal without frequency limits - FM crossfading is welcome, and also crank it up to over 10KHz if you like digital aliasing artifacts. The CV input is capable of amplifying the incoming CV signal, so even weaker CV sources will be able to drive the crossfader's position from one side to the other. Using a gate signal for CV, one could turn this crossfader into a switch by hard-fading from 0 to 100. If both inputs are used, crossfading action is obtained. However, either of the inputs may be unused; it will not lead to any additional hum or noise. Hence, if only the second input is used (e.g. B for the upper section), one gets a VCA with a classic "clockwise or more CV = louder" response. If only the first input is used (e.g. A), the VCA becomes inverse: more volts = less volume. This is great for using this as a ducking VCA for sidechaining or compression! As mentioned before, these "VCA"s have a slight bit of distortion to them and are sort of capped from processing very high frequencies without aliasing, but initialy, they were developed as proof-of-concept CV processors - i was happy to find them processing audio as well. These things are DC-coupled, so they can and should crossfade between envelopes, LFOs, sequences, etc - just don't expect perfect 1V/O reproduction!
As a little addition, the module is also fit with a comparator subsection. This is simply because one chip had an unused comparator circuit, and the faceplate had free space, and i love comparators. It can extract gates from continuous signals, and the gates then can be used to hard-switch between signals at a crossfader. Or one could use it as a completely separate device. The comparator has hysteresis ratio of about 10, which is a lot, so it could be used in some chaotic patching, but it's not the best PWM extractor ever. The builder can easily change that, though.
All in all, this module is a much simpler and cheaper take on the usual voltage controlled crossfader idea. It sounds surprisingly clean for how hacky its basic idea is while processing audio, does a great job fading between CVs, and the on-board comparator is a pleasant bonus. It's also a good starting point for other PWM-based ideas; this one uses a chip with three two-throw switches - but what if we use the other one with a single eight-throw switch? Voltage-controlled fading between 8 sources? Time will tell!
Schematic
The module is comprised of four chunks. Multiplexing core is the main signal path reliable for switching and filtering that make up the crossfading action. The HF Triangle Osc block generates a very fast triangle wave, and the PWM Extractos create duty cycle modulated pulsewaves out of it. Separately stands the Comparator subcircuit, which is a bonus feature of the module, but an important building block for patching.
Multiplexing Core
The module uses very few parts for the bang you get out of it. Up top is the multiplexing core based around a CD4053 chip. Technically not the best choice for switching analog signals, but we make it work. CD4053 has three separate single-pole dual-throw (SPDT), or "on-on" switches inside. Each has a control input pin that expects a logic pulse that selects one of the switch sides to be routed to the common pin. The switch is bidirectional; we will be using it as "two inputs, one output" device. One switch (X0/X1 ins, X out, A control pin) is used for one crossfader, the other switch (Y0/Y1 ins, Y out, B control pin) for the other, and the third switch is unused. The switches are all the same, so it doesn't matter which of them are used; pretty sure my actual physical module uses the Z0/Z1/Z/C switch for the second crossfader instead.
Now, these multiplexor chips - CD4051/52/53 - can be powered from a safe maximum of 18 volts, which means we cannot tie its power pins directly to the eurorack ±12V supply; 24V will fry it. But we also can't power it from ground and +V, because processing bipolar signals with it requires bipolar power, not unipolar. The originator of the genius hack implemented here, Rene Schmitz, uses two linear regulators to create +5V and -5V from the default power supply rails. But surprisingly, the chip and the process don't mind asymmetric power: in my case, a single +5V linear regulator IC3 is used to drive the chip's positive supply, while its negative supply is just the PSU -12V. This makes it 17V total, which is one volt shy of the maximum. The ground reference is closer to one rail than the other, making the situation asymmetric, but it doesn't seem to cause any troubles. The chip's logic levels are now +5V high and -12V (not zero!) low, so the inhibit pin 6 has to be tied to -12V. The control pins are pulled up to 5V via R24/25 10K resistors; we will be shorting them to -12V further down the circuit to create the switching action.
The way the entire ±12V signal range is coaxed through the CD4053 is borrowed from Rene Schmitz' genius Signal Switch design. Stunningly simple, yet more clever than i would ever come up with, his idea uses the virtual ground op-amps with negative feedback create at their inverting input to essentially make the voltage difference across the CMOS switch in/out pins chip negligible, thus never hitting the power rails and never actually running distortion-prone large signals through the switch. Let's look at the first crossfader's input A.
First, it goes through an inverting amplifier IC4A that is unity gain (R1=R2) and also has C1 in the feedback loop, netting a first order lowpass filter with about 15KHz cutoff. This stage is needed to invert the signal so the circuit down the road, which happens to be inverting, un-inverts it, and we get the correct signal back. The amplifier also prepares the signal to go through the multiplexor, preventing it from having higher order harmonics that may cause abrasive aliasing. The magic happens after this "preparation stage" amp.
If one imagines a signal going from IC4A out through R3, and treat the X0/X (pins 12/14) of the CD4053 (IC1) switch as a short circut, then with IC2A this all is simply another inverting amplifier. R4 is 100K = R3, so the amplifier is supposedly unity-gain. In reality, the device's output is a bit quieter than the input, but making R4 bigger introduces unwanted distortion, so i decided to keep it like this. C2 adds some lowpass filtering like with IC4A/C1, but with a much lower cutoff frequency. Op-Amps under negative feedback do their best to keep the voltages at the two inputs same. In our case, the non-inverting input +in is tied to ground. The signal comes all the way from R3, through the switch (imagined a short right now), and to IC2A inverting input, shifting it away from zero. IC2A now has to do its best to keep the two terminals at the same voltage by emitting such a voltage that passes through R4 and counters the signal that came through R3, bringing the net voltage at IC2A -in to whatever +in sits at. And since the latter is grounded, the former will end up at ground level, too - despite being physically connected to the circuit's zero! This is called a virtual ground - it sits at about the same potential as the actual zero of the circuit, but is not physically shorted to it. In this configuration, R8 doesn't do much going from virtual ground to actual ground, but it will become an important resistor later. However, this virtual ground impliesthat starting from the R3/R8 junction and all the way to the IC2A inverting input, the entire trace sits at zero volts - no matter what signal comes to the input A jack and out of IC2A! Indeed. the voltage difference between the switch pins is zero in this case.
If we stop thinking of the switch chip as a short circuit, not much changes! It presents such little resistance when turned on that the potential difference across its pins would still be negligible, although not zero. This means our signal is nothing but some dozen-millivolt-tall wiggling around zero to the switch, meaning much less distortion and the full ±12V range. However, this is true only for the one input of the switch that is selected using the control pin; the other one will thus always not be selected! This means that whatever comes from the input jack through the IC4 amp to the unselected switch input could ram a full-range ±12V signal right into our tiny feeble chip's input. ±12V is outside the chip's +5V/-12V power rails, so if we don't protect against this, the chip may get cooked! This is why R8 (R12, R26, R37) is installed. When the input is not selected, and the whole virtual ground magick is not going on on account of there's no path from the unselected input to the op amp inverting input, R3/R8 (and the other three same constructs) form a voltage divider with a ratio of 1/101 = ~ 0.0099. This means any hot ±12V signal coming in will become a puny few dozen mV tall one by the time it reaches an unselected switch input pin. The unselected pins are no longer in danger!
The capacitor C2 stuck in IC2A's feedback loop is what makes the crossfader not sound like garbage. in a usual inverting amplifier case one wouldn't just put a filtering cap like that for no reason, as that would limit the amplifier's signal pass band. In this case, that's precisely what is needed! We switch the signals back and forth at a very high frequency. That will produce some artifacts, most of which will be outside hearing range, but some will manifest as unpleasant clicks, pops and squeals. To counter the majority of those, the op-amps IC2A/IC2B are made into basic antialiasing filters with C2/C3 respectively. Some lowpass filtering helps smooth the switched signals out and hide the high frequency they're being switched at. Real antialiasing filters have a much sharper rolloff and should ideally be as brickwallish as possible (48db/oct is not the limit), but in our case a quick and dirty 6db/oct sort of does the job. The smooth rolloff is countered by a seriously low cutoff frequency; math says it should be about 1.5KHz, but ear tells it's much higher, because the crossfader definitely doesn't sound like standing outside a warehouse rave at 4AM; not sure why's that so, i picked the capacitor values by ear.
HF Triangle Osc
The idea is to switch between two signals at a very high rate while changing the proportion of which signal gets more "showtime" per cycle to have one or the other seem louder. The simplest way to do this is to create a pulsewidth modulated signal (PWM): a pulse whose width, or duty cycle, is controllable manually and with an external control voltage. The frequency should stay the same and be very high, but the percentage of the cycle length the pulse spends high should be variable. This is easy to do by comparing a continuous and linear waveshape, like a sawtooth or a triangle, to a user-determined voltage. The comparator will turn high whenever the waveshape voltage is over than the user-set threshold voltage. If the threshold is somewhere in the middle of the waveshape (e.g. zero if the wave is DC-decoupled), the comparison is true during the positive halfwave and false for the negative, resulting in a 50% duty cycle: a square wave. Pushing the threshold lower will result in even bigger duty cycle, since now the comparator is true for the entire positive and some of the negative half-wave. Naturally, if the threshold is below the wave's peak-to-peak range entirely, the comparator is always true, and the opposite situation is a permanent false. Modulating the threshold voltage directly modulates the pulse width. Now just use the resulting pulse to switch the signals around, and voila!
A continuous linear waveshape is required to extract the PWM from. There are countless ways to make a simple triangle oscillator, but ours has to be very, very fast, so setting up a usual op-amp like a TL07x as a triangle osc and another one as a comparator won't do; it will not reliably reach the required switching speeds. LM339 to the rescue! This quad comparator - not an op-amp - will both generate the triangle and then extract the pulse from it. Its operating speeds are considerably higher than that of TL07x or similar set up as a comparator, so it allows to ramp up the frequencies majorly. How much? No clue, i have no tool to measure. High enough for me not to hear major artifacts.
IC5A is set up as a simple oscillator. LM339 is an open-collector comparator: when the voltage at its +in is more than at its -in, the output is hi-z (almost doesn't interact with the circuit), and if the inverse is true, then the output gets shorted to the chip's negative power supply pin. Usually, a pull-up resistor is put from the positive power rail to the comparator output to create a "default" high level, which gets overridden by the chip shorting it low if the voltage at its +in is below than at the -in.
Our IC5 LM339 is powered from +-12V, so its outputs are hi-z/-12V for true/false respectively. In the oscillator subcircuit R35 provides a +12V puullup, so IC4A's output is now +12V/-12V for true/false instead. Let's imagine the voltage at the C10/R27/IC5A in- junction is zero. The voltage at the comparator's non-inverting input is then derived from +12V through the divider of R35+R41 and R40; 12V * (10K/100K+4.7K+10K) ≃ 1.05V. V(+in) > V(-in), so the comparator's output is true, it does not short the output to -12V, and +12V feel free to flow through R35 and R27 to charge C10. As C10 gets charged, the voltage at IC5A -in rises up from zero. It will eventually become higher than the 1.05V threshold at the non-inverting input set by the R35/R41/R40 divider. The comparator turns false and shorts the output to -12V. Now the threshold voltage at +in is -12V from the comparator output through the voltage divider R41/R40: -12V * (10K/100K+10K) ≃ -1.1V. C10 is now being discharged by -12V from the comparator output through R27 only. Eventually, discharging C10 will drag the voltage at the op amp's inverting input below that at the non-inverting one, flipping the comparator true again - and the cycle continues.
This results in a pulse at the IC5A output, which is good if you need a fixed duty cycle pulse. But we need to get ours modulated, so our real point of interest in this setup is, in fact, the C10/R27/IC5A -in junction. C10 gets perpetually charged and discharged through R27. Although this is an RC network, and technically the voltage-over-time response to a step function is logarithmic, the "target voltages" the capacitor sees are about +12 and -12 volts, while the oscillation itself is contained within about ±1V because of how much the R41/R40 divider slashes the +-12V pulse down. Essentially, we operate within such a small piece of the RC lowpass' usual transition curve that it's almost linear! And what is a voltage that goes up and down more or less linearly, but a triangle wave.
The theory is good and all, but my practice shows some interesting deviations from it. The oscillation cannot be ideally symmetric, because charging happens through R35+R27 (27.7K), while discharging happens through just R27 (22K), so one side of the triangle should be faster than the other. This is not critical. What is, though, is for some reason my triangle seems to have some sort of overshoot and some DC offset. The expected result is a ±1V triangle centered around zero, but what i seem to be getting is a ±2V triangle centered around about -0.25V. I think this is because of the comparator's speed limit, making it switch just a bit later than the actual threshold crossing happens, so that C10 is charged/discharged for a fraction of time longer. The way C10 is charged through a bigger resistance than it is discharged through should have something to do with the offset. Both of these aspects are countered down the circuit, but maybe you are smart enough to design a better HF osc for this case that fits all the expectations ideally, and then tell me how!
PWM Extractors
Downhill battle from there! We just compare the triangle to some user-set threshold and get a pulse. Make the threshold a sum of some initial setting knob and a CV input, and you get your PWM, ergo the crossfading, voltage-controlled. The triangle is offset to -0.25V or so and somehow is +-2V, so we gotta account for that, too. Aside from that, everything is nicely small in terms of fitting inside the LM339's effective range of voltages, which you can generally think of as "3 volts away from either of the power supply rails". Having two crossfaders means setting up two separate PWM extractors with separate thresholds, but the same HF triangle may be used to extract the pulse from. I'm dissecting one of the PWM extractors; the other one is the same thing.
The initial settings knob FADE_AB is set to travel between +12 and -12V. A general-purpose op-amp (IC2C) is used in an inverting summator configuration with R14 of 22K. Since the initial fade knob comes through R13=100K, at the output, the full swing of the knob produces ±12V * -(22K/100K) ≃ ±3V, which is more than enough to cover the entire range of the triangle. R19 of 1M adds positive offset to the mix, meaning the inverting amplifier produces a negative offset of +12V * -(22K/1000K) ≃ -0.25V. The offset compensates for the DC offset the triangle somehow ends up having. Finally, a CV input jack goes through an attenuator and is summed up via R24 of 22K, meaning it is unity-gain at the output. This is to ensure that even weak signals like a ±2.5V (5Vpp) LFO from some microcontroller can swing the crossfader from one extreme to the other. For most incoming CVs the optimal attenuator position would be somewhere in the middle. C7 is added to the feedback loop to add slight lowpass filtering: it still allows plenty of FM to pass, but prevents the annoying clicking and popping when gates, sequences, and such are being used as control voltages.
The op-amp's output is the threshold, and so, it is passed to the IC5C comparator -in, while the +in gets the bespoke HF triangle. This results in the comparator output getting shorted to -12V when the triangle is below threshold and entering a hi-z state when above. The proportion of how much time per cycle it spends shorted to -12V VS hi-z is determined by the threshold and directly impacts how much we hear one signal and not the other on the crossfader output. Note that there is no pullup resistor from 12V to the comparator's output. Since a CD4053 control pin is driven with IC5C's output, the expected logic levels are -12V for false and +5V, not +12V, for true. The former is satisfied by the comparator itself being ran off -12V, but the latter has to be ensured by having a pull-up resistor R17 to the +5V regulator out. This whole construct is repeated with IC2D, IC5B and the other control pin of the CD4053 to obtain the second PWM extractor driving the other CD4053 switch.
Comparator
This is boring stuff compared (haha) to everything above. There's another free comparator on the LM339 that didn't get used, and i'm not letting it go to waste. It's set up more or less like a textbook comparator, really, so not much to talk about here. Input X is a passive sum of the offset knob and the external signal. If no signal is presented, the offset goes full ±12V, but with R28=R36=100K, it will become about ±6V offset when an external signal is patched in. Likewise, the incoming signal will be effectively slashed in half in comparator's eyes. R29 adds some major hysteresis to the system, which means it will reject noise very well and expect the signal to go an extra mile to flip the output voltage wise. This is good for chaotic patching, since it lets some stuff happen before flipping while in a feedback loop. But this is bad for classic VCO PWM extraction, as it will ignore the thinnest end of the pulsewidths and just drop to silence abruptly. Make R29 10M or omit it altogether if you want things opposite! The Y input is going in directly to the -in with R38 being there to pull it down to ground if nothing is patched.
R30 is a pullup, and the LED is driven directly from the comparator output through R34 without a buffer. If we treat the LED as a short, which it kind of is when the comparator returns true and is hi-z, the comparator high output voltage is 12V * 10/14.7 ~= 8V. This is a perfectly sane gate signal level. However, since R30 is kind of big, the fanout of this comparator is limited to about 4 inputs with 100K input-to-ground impedance before the gate signal drops below 6 volts. This could be fixed with a buffer, but i don't think that's a serious concern, so i omitted this step. The comparator still shorts to -12V on false, and i like my gates unipolar, so D1/R39 rectify the resulting bipolar -12V/+8V pulse into a unipolar 0..8V pulse. Nice!
Media
Two audio-rate triangle waves crossfaded with one of the module's subsections. Notice the aliasing at higher pitches when the two waves are juxtaposed.
Using an LFO to modulate the fading in the previous patch. Audio-rate modulation sounds wonderful.
One of the triangles replaced with an amen break brought to modular levels, and the modulation fun continues.
A VCF is processing a sawtooth, and a crossfader output runs into its CV in. The crossfader fades between two separate LFOs, one square, one triangle. Later into the patch, a third LFO controls the fading between the first two; interesting near-chaotic patterning emerges.
Two synchronous 5-step sequences are routed through the crossfader to a VCO. The sequencer clock also gates a decay-only envelope. Instead of fading between them, a squarewave LFO is used to hard-switch between the two, leading to more unpredictable melodies out of two 5-step sequences. Note that the sequencers were tuned post-crossfader, since the module inverts the signals coming through.
Two decay-only envelopes are crossfaded: a short one hitting a stable quarter-note, and an aperiodic longer one. The result is used to control the volume of a sound which is taken from the other crossfader that goes between a triangle VCO and some noise. The VCO's pitch is controlled by a maximum-of of the two envelopes. The whole patch is orchestrated by SFP42 Random Factory. The result is a weird juxtaposition of a 4-on-the-floor beat and a chaotic beating via one crossfader, and a kick and a snare feel via the other.