Загрузка данных


import("stdfaust.lib");

// =============================================================================
// EVH 5150 LEAD CHANNEL AMP HEAD SIMULATION (NO CABINET / NO IR)
// =============================================================================

// =============================================================================
// UI LAYOUT & GROUPS
// =============================================================================
ampGroup(x)   = vgroup("EVH 5150 Lead Channel", x);
gainGroup(x)  = ampGroup(hgroup("[1] Preamp Control", x));
eqGroup(x)    = ampGroup(hgroup("[2] Tone Stack", x));
powerGroup(x) = ampGroup(hgroup("[3] Power Amp & Master", x));

// UI Controls
preGain  = gainGroup(hslider("[1] Pre-Gain [style:knob]", 5.0, 0.0, 10.0, 0.1));
brightSw = gainGroup(checkbox("[2] Bright / Tight Boost"));

lowKnob  = eqGroup(hslider("[1] Low [style:knob]", 5.0, 0.0, 10.0, 0.1));
midKnob  = eqGroup(hslider("[2] Mid [style:knob]", 5.0, 0.0, 10.0, 0.1));
highKnob = eqGroup(hslider("[3] High [style:knob]", 5.0, 0.0, 10.0, 0.1));

resKnob  = powerGroup(hslider("[1] Resonance [style:knob]", 5.0, 0.0, 10.0, 0.1));
presKnob = powerGroup(hslider("[2] Presence [style:knob]", 5.0, 0.0, 10.0, 0.1));
postGain = powerGroup(hslider("[3] Post-Gain [style:knob]", 3.0, 0.0, 10.0, 0.1));

// =============================================================================
// DSP MODULES
// =============================================================================

// 12AX7 Triode Emulation (Asymmetric non-linear transfer function with bias)
tubeStage(drive, bias, x) = ma.tanh(x * drive + bias) - ma.tanh(bias);

// 1. Input Conditioning Stage
// High-pass filter cuts sub-bass rumble to prevent gain mud. Bright switch boosts punchy upper-mids.
inputConditioning(bright, x) = x : fi.highpass(1, 95.0) : brightFilter
with {
    brightFilter = select2(bright, _, fi.peak_eq(3.5, 2200.0, 1200.0));
};

// 2. Preamp Distortion (4 Cascading Triode Gain Stages)
// Inter-stage high-pass and low-pass filtering shape the high-gain sound.
preamp(drive, bright, x) = inputConditioning(bright, x)
                         : stage1
                         : stage2
                         : stage3
                         : stage4
with {
    // Non-linear gain mapping from Pre-Gain knob (0..10)
    kDrive = 1.0 + ma.pow(drive, 1.8) * 0.85;

    // Stage 1: Input gain boost
    stage1 = tubeStage(kDrive * 2.2, 0.12)
           : fi.highpass(1, 120.0)
           : fi.lowpass(1, 9000.0);

    // Stage 2: Heavy distortion with tight low-end cutoff
    stage2 = tubeStage(kDrive * 2.0, -0.18)
           : fi.highpass(1, 220.0)
           : fi.lowpass(1, 7500.0);

    // Stage 3: Lead saturation stage
    stage3 = tubeStage(kDrive * 1.8, 0.22)
           : fi.highpass(1, 160.0)
           : fi.lowpass(1, 6000.0);

    // Stage 4: Compression and cathode-follower emulation (peak taming)
    stage4 = tubeStage(1.5, -0.08)
           : fi.lowpass(1, 5500.0);
};

// 3. Passive 5150 Tone Stack Emulation
// Features a signature mid-frequency dip at 500 Hz
toneStack(l, m, h, x) = x : fi.low_shelf(lDb, 110.0)
                          : fi.peak_eq(mDb - 3.5, 500.0, 350.0)
                          : fi.high_shelf(hDb, 2400.0)
with {
    lDb = (l - 5.0) * 2.2;
    mDb = (m - 5.0) * 2.5;
    hDb = (h - 5.0) * 2.2;
};

// 4. Power Amplifier Stage (6L6 Soft Clipping + Negative Feedback)
// Resonance alters low-end dampening, Presence alters high-end bite.
powerAmp(res, pres, master, x) = x : powerTubeSat : powerEq
with {
    mLevel = ma.pow(master / 10.0, 2.0) * 1.5;

    // 6L6 Power tube soft saturation
    powerTubeSat(in) = ma.tanh(in * mLevel * 1.2);

    // Presence & Resonance controls in power-amp feedback loop
    resDb  = (res - 5.0) * 1.8;
    presDb = (pres - 5.0) * 2.0;

    powerEq = fi.peak_eq(resDb, 80.0, 60.0)
            : fi.high_shelf(presDb, 4200.0);
};

// =============================================================================
// MAIN SIGNAL PROCESSING PATH
// =============================================================================
process = _ : preamp(preGain, brightSw)
           : toneStack(lowKnob, midKnob, highKnob)
           : powerAmp(resKnob, presKnob, postGain)
           : fi.dcblocker
           : *(0.5); // Master output attenuation to avoid digital clipping