0
mirror of https://github.com/torvalds/GuitarPedal.git synced 2026-09-11 17:10:09 +00:00
Files
Linus Torvalds e68dd21b60 [RAT]: a model of the ProCo RAT, fitted to an Aion FX Helios
Not a distortion curve with a filter on it.  The circuit is an op-amp
with a diode clamp in its feedback path, and almost everything that
makes a RAT sound like a RAT comes from that arrangement rather than
from the diodes' curve:

  - The Distortion pot is a rheostat in the feedback network, so it
    changes the gain the loop is asking for.  Against a finite
    gain-bandwidth that drags the closed-loop corner across most of the
    audio band - about 2 kHz at noon, 560 Hz at the top - so turning it
    up makes the pedal darker as well as louder.  An ideal op-amp here
    is 7.9 dB bright at 5 kHz at noon and 22.8 dB at the top.

  - The op-amp's rails are inside the loop, which is where the circuit
    has them and is not a formality.  When it saturates the loop opens,
    the feedback capacitors go on charging, and when it comes back out
    depends on which rail it was against.  Two unequal rails and a
    capacitive feedback leg make a duty cycle, and for a clipped wave
    the duty cycle is exactly where the even harmonics come from:
    H2/H1 is |cos(pi*d)|, which is nothing at all at a half.  Clip the
    rails onto a linear filter's output instead and the duty cycle is
    50% by construction and H2 is 55 dB down; the pedal's is 19.6.

  - The clamp is a diode equation and not a level.  A diode has no
    clipping voltage - it is a logarithm and it keeps rising - so the
    pedal goes on getting louder when played harder after it has
    started to clip, and a fixed threshold does not.  The three Mode
    positions are three places to start leaning, not three heights.

  - The charge on C7 is a state and not a filter.  There is no DC path
    to ground behind R5, so the operating point sits wherever the two
    half cycles pass equal charge, which for a drive that meets one
    rail harder than the other is not zero.  A high-pass would force it
    to zero and take the second harmonic with it.

Solving the diode equation is the one expensive thing in here, and it
does not have to happen at the sample rate: the curve depends on nothing
but the Mode switch and cannot move while a note is playing.  So
scripts/rat_clamp.py solves it at every point of a table at build time,
converged, with no budget to keep to, and the audio core does an index
and a lerp.  The constants it solves from come out of the effect rather
than out of the netlist, because they were fitted to this pedal and a
generic 1N914 has different ones.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-09-07 16:36:14 -07:00
..
2026-09-01 17:27:07 -07:00