A warm op-amp preamplifier
A hi-fi line preamplifier that sounds like a tube stage but is built with op-amps. The resistor values were not picked by hand: a genetic algorithm found them, by simulating thousands of variants and comparing each with a simulated 12AX7 tube.
Where it stands
Designed, simulated and checked, but never built or measured. Every number on this page comes from simulation (ngspice, with the NE5532 op-amp model, on the circuit as it sits on the board). The claim is not that it sounds exactly like a tube. It is that, in simulation, it has the same harmonic fingerprint as a 12AX7 stage.
At a glance
| What | Stereo line preamplifier stage for hi-fi, in front of an existing power amplifier |
|---|---|
| Sound | The mild warmth of a 12AX7 stage: mostly second harmonic (H2), growing with level |
| Gain | 10 dB (×3.2) |
| Frequency response | 20 Hz to 20 kHz within ±0.11 dB |
| Distortion at 1 V rms | 0.3%, almost all H2: −50.3 dB, against −50.0 dB for the tube |
| Signal to noise | about 97.5 dB relative to 1 V rms (unweighted, 20 kHz bandwidth) |
| Parts | 3 × NE5532 op-amp, 12 × 1N4148 diode, 1% metal-film resistors, 2 trimpots |
| Supply | regulated ±15 V |
The idea
Tube amplifiers are often called warm. Much of that comes from how a triode distorts: softly and asymmetrically, with mostly second harmonic, one octave above the note. At low levels the distortion is negligible, and the louder you play, the more H2 you get. The third harmonic, which sounds harder, stays much lower.
Op-amps are the opposite: extremely clean. This design adds just the tube-like part with a few diodes, an even-harmonic generator mixed with the clean signal. How much of what, and with which resistors, is a puzzle of eleven interacting values. A genetic algorithm solved it.
How it works
- Input. A film capacitor and a 100 kΩ resistor block DC and set the input impedance.
- Amplifier U1A. Non-inverting, gain 1 + 39k/20k = 2.95. A capacitor makes the DC gain 1 so offset is not amplified. Its output is the signal V1.
- Inverter U2A. Makes an upside-down copy, −V1.
- Two diode branches, the heart of the sound. Branch A gets +V1, branch B gets −V1 (through a resistor and the trimpot), and each ends in three 1N4148 diodes in series, biased with about 1 mA from a filtered +15 V. The voltage across a diode is logarithmic, ln(1 + x). Branch A sees +x and branch B sees −x, so the odd terms cancel when they are added: ln(1+x) + ln(1−x) ≈ −x². That is pure second harmonic, growing with the square of the level, as in a triode. The branches are deliberately not exactly equal, which leaves a small, controlled amount of H3, also like the tube.
- Summer U3A. Adds the clean signal and the two diode signals. One resistor sets the total gain to 10 dB, and a small capacitor keeps the op-amp stable at high frequency.
- Output. A 100 Ω resistor keeps it stable with long cables, and a capacitor blocks DC.
Why three diodes per branch? The larger the voltage across the chain, the less the weak diode signal has to be amplified afterwards, and so the less noise. Three diodes give three times the signal for only √3 times the noise. The algorithm chose three by itself. The diode bias comes from a filtered supply (about 7 Hz corner, over 40 dB of hum rejection at 100 Hz) because hum on that line would otherwise end up in the signal. The trimpot balances the two branches and so sets the amount of H3 (about ±3 dB), without noticeably changing H2 or the gain. Three NE5532 chips serve both channels: one stage per chip, with the left channel in one half and the right channel in the other.
Designed by evolution
The target: a simulated 12AX7
The reference is a classic common-cathode 12AX7 stage (250 V supply, 100 kΩ plate resistor, 1.5 kΩ cathode resistor), simulated with Norman Koren's well-known tube model at 170 V on the plate and 0.8 mA. Its fingerprint at 1 V rms output: H2 about −50 dB (0.3%), H3 about −96 dB. H2 rises 6 dB for every doubling of level, H3 12 dB, and H4 and above stay far below −90 dB. Those curves are what the algorithm has to match.
Eleven knobs
The topology is fixed. The algorithm picks eleven values: ten resistors from the E24 series (100 Ω to 1 MΩ) and the number of diodes per branch (1 to 4). That is about 1018 combinations, far too many to try.
Scoring a candidate
For every candidate, ngspice runs a transient simulation at six output levels (0.1 to 7 V rms, a 1 kHz sine), an AC analysis and a noise analysis. The cost, lower is better, adds up the deviation from 10 dB gain, the RMS difference in dB from the tube for H2 over all levels, the same for H3 with less weight, a penalty if H4 or H5 exceed the tube's, a penalty if the response strays more than ±0.2 dB between 20 Hz and 20 kHz, and a penalty if the signal to noise falls below 100 dB. Designs with a gain far from 10 dB are thrown out by a quick AC check, before the expensive simulation.
Evolution
A population of 48 designs, 40 generations, a genetic algorithm with simulated binary crossover and polynomial mutation on integers (the index into the E24 series), eight ngspice processes in parallel at 3 to 5 seconds per evaluation. After the run, a local search tries the neighbouring E24 values for each resistor. In total about 5,758 circuits were evaluated.
| Run | What happened | Cost |
|---|---|---|
| 1 | Random start. The algorithm switched branch B off: one diode chain alone turned out to be already tube-like. H2 stayed 5 dB too low. | 9.7 |
| 2 | Noise target relaxed, symmetric starting designs. Failed: a larger coupling capacitor made the simulation four times slower, and good designs ran into the time-out. | 11.2 |
| 3 | Corrected, and started from runs 1 and 2. Both branches active, H2 and H3 within about 1 dB of the tube. | 2.9 |
Run 3 shows why the second branch is worth having: with two nearly symmetric branches the algorithm can set H2 and H3 independently.
From evolved values to a buildable design
The summing resistor went from 1k2 to 1k27 (an E96 value) to land the gain exactly on 10 dB; it scales the clean and the distorted path equally, so the character stays the same. Branch B's resistor became a fixed 4k42 plus a 500 Ω trimpot, chosen from a sensitivity analysis (that resistor mostly affects H3, by about −0.5 dB per 1%). Then came the practical parts: the supply filter for the diodes, the output network, decoupling, and two channels on one board. The whole thing was simulated again with the NE5532 model.
Results
All of it is simulation of the circuit as it sits on the board, including supply filter, output network and a 10 kΩ load.
| Output (V rms) | THD | H2 op-amp | H2 tube | H3 op-amp | H3 tube |
|---|---|---|---|---|---|
| 0.1 | 0.03% | −70.3 dB | −70.0 dB | < −110 dB | < −110 dB |
| 0.5 | 0.15% | −56.4 dB | −56.0 dB | −109 dB | −108 dB |
| 1.0 | 0.31% | −50.3 dB | −50.0 dB | −97.2 dB | −95.8 dB |
| 2.0 | 0.61% | −44.3 dB | −43.9 dB | −85.3 dB | −83.6 dB |
| 4.0 | 1.24% | −38.1 dB | −37.9 dB | −73.6 dB | −71.5 dB |
| 6.0 | 1.89% | −34.5 dB | −34.3 dB | −67.3 dB | −64.4 dB |
H2 follows the tube within 0.4 dB over the whole range. H3 sits 1 to 3 dB below the tube, with the same slope, and the trimpot can move it by ±3 dB if wanted.
| Figure | Value |
|---|---|
| Gain at 1 kHz | 10.03 dB |
| Frequency response, 20 Hz to 20 kHz | ±0.11 dB |
| H4 and H5 | below −99 dB up to 6 V rms |
| Signal to noise | 97.5 dB relative to 1 V rms |
| Supply hum rejection (+15 V, through the diode bias) | 41.6 dB at 100 Hz, 61.5 dB at 1 kHz |
| Maximum output | about 7 V rms into 10 kΩ |
| Input impedance | 100 kΩ |
Check with the real NE5532 model
The algorithm used a fast, generic op-amp model. As a check, the design was also run with the manufacturer's NE5532 macromodel: gain, flatness and harmonics agree to within 0.1 dB. Only the noise is about 1.5 dB higher, because the model is noisier (6.4 nV/√Hz) than the datasheet (5 nV/√Hz), so in practice the noise should come out slightly better.
Tolerances
How accurate would a home-built unit be? A Monte Carlo analysis simulated virtual boards with random errors: resistors ±1% and diode-to-diode spread (saturation current lognormal, about ±11 mV in threshold). 21 of 24 virtual boards gave a usable simulation; three ran into the simulator's time limit.
| Quantity | Spread without adjusting (σ) | With the trimpot set (σ) |
|---|---|---|
| Gain | ±0.13 dB | ±0.12 dB |
| H2 at 1 V rms | ±0.09 dB | ±0.13 dB |
| H3 at 4 V rms | ±0.43 dB | ±0.01 dB |
The circuit is robust. Even without measuring anything, a unit with 1% resistors lands within half a dB of the design. The reason: at a fixed bias current the shape of a diode's curve does not depend on its saturation current, so diode spread only shifts the DC voltage. A 1% error in any one resistor moves H2 by at most 0.1 dB and H3 by at most 0.5 dB.
Two boards
The same circuit, with the same values, exists as two board designs in KiCad: one with through-hole parts to solder yourself, and one with surface-mount parts, meant to be made and assembled by a board manufacturer so there is no soldering at all.
| Through-hole | SMD | |
|---|---|---|
| Meant for | soldering yourself | assembly by the manufacturer |
| Board size | 178 × 100 mm | 129 × 72 mm |
| Op-amps | 3 × NE5532P (DIP-8, in sockets) | 3 × NE5532DR (SOIC-8) |
| Diodes | 1N4148 | 1N4148WS |
| Resistors | metal film 1%, 0.25 W | thick film 1%, 0805 |
| Connections | pin headers | screw terminals |
Does the sound change with the SMD parts? Not measurably in the simulation, and not by the physics either. The 1N4148WS is the same silicon diode in a smaller package, and the NE5532DR is the same chip. Thick-film resistors make extra noise under DC, but the only resistors with real DC across them feed the diode chain, whose impedance is so low (about 55 Ω against 9 kΩ) that their noise is attenuated more than a hundred times. The ceramic input capacitor can distort under large AC voltage, but almost no voltage stands across it and there is no DC on it.
For setting up, the trimpot has a no-instruments method (set it to 280 Ω before soldering, which with the fixed 4k42 gives the design value 4k70) and a measured one (a 1 kHz sine at 4 V rms output, adjusted until H3 reads about −73.5 dB with a sound card and free software). The preamplifier expects a line source and a regulated ±15 V supply.
Neither board has been ordered, made or measured. Both pass the KiCad electrical and design-rule checks without errors, and that is all that can be claimed.
Limits
- The op-amps' own supply rejection (about 100 dB on the datasheet) is not in the macromodel; only the path through the diode bias was simulated. Use a regulated supply.
- Dynamic tube effects, such as supply sag and bias shift on overload, are not imitated. The design targets the static harmonic fingerprint.
- The reference is one generic 12AX7 stage. A real tube preamplifier often has several stages and an output transformer.
- It is a simulation. Whether it sounds like a tube is exactly what building it would answer.
Download
Everything needed to have the board made, or to repeat the whole design process, is free to download.
| File | What is in it | Size | SHA-256 |
|---|---|---|---|
| Through-hole board warm-preamp-through-hole.zip | Gerbers and drill files for the board manufacturer, parts list, schematic PDF, board layers, 3D renders and the KiCad 10 project (178 × 100 mm). | 1.5 MB | 2cf56750c1f33859a3a3a1ab0a36cf4d30aa37220f2c3c44f7b81fc4a32ad29c |
| SMD board, ready to assemble warm-preamp-smd.zip | The same for the surface-mount board (129 × 72 mm), plus the manufacturer's parts list and the placement file for assembly. | 1.3 MB | 1ea9087148231eb53f312c0e149ee9e8d9947c3a8a195b25432b7585fc223c9b |
| The software and the documentation warm-preamp-software.zip | The Python code that ran the genetic algorithm, simulated and checked the design and generated the KiCad boards, the evolved designs, the SPICE models and the full documentation with its data. | 0.4 MB | 4cae57b5c280dda4c8e08d46be28257659fa397727088375b876532a93c8f883 |
- The Gerbers are inside each board package (
warm_preamp_gerbers.zip), ready to upload to a board manufacturer. The SMD package also has the manufacturer's parts list and placement file; the supplier part numbers are deliberately left empty, so you choose them. - To rerun the software you need Python, ngspice, KiCad 10 and, for routing, Java with Freerouting; the documentation in the software package lists the steps. The package does not include those tools.
- The NE5532 SPICE model in the software package is Texas Instruments' (via the KiCad SPICE library), and the tube model is Norman Koren's.
- Neither board has been ordered, made or measured. Both pass the KiCad electrical and design-rule checks. Anything connected to mains power is your responsibility: the preamplifier itself runs on a regulated ±15 V.
- Open source: the software is MIT licensed, the hardware design CERN-OHL-P v2 and the documentation CC BY 4.0 (copyright KyntoSoftware), all on GitHub. Provided as is, without warranty.
Tools used: ngspice, pymoo, KiCad and Freerouting.