BiasGate
Tier: Color | ComponentType: 24 | Params: 5
Transistor bias/starve simulation with splutter gating -- models a transistor operating near its cutoff point with randomized threshold instability.
Overview
BiasGate simulates the behavior of a transistor circuit that has been starved of bias current to the point where it intermittently cuts off. When a transistor's bias point is set near its conduction threshold, small signals may not be strong enough to turn it on, creating a natural gating effect. The "splutter" parameter adds random variation to this threshold, causing the gate to fire erratically -- the characteristic sputtering, dying-battery sound of a nearly dead fuzz pedal.
The bias point parameter shifts the entire input signal up or down before the gate decision. With a positive bias, the signal sits higher on the transfer curve and the transistor stays on more of the time. With a negative bias, the signal is pushed below the conduction threshold and more of it gets gated out. At zero bias, the gate responds symmetrically to positive and negative signal excursions.
The gate envelope uses a fast attack (~1 ms) so the transistor turns on almost instantly when signal exceeds the threshold, and a configurable release time that controls how quickly the signal decays to silence when it drops below threshold. Short release times create choppy, staccato gating. Long release times create a smoother fade that sounds more like a dying amplifier losing power. A DC blocker follows the gate to remove the offset introduced by the bias, and a makeup gain stage compensates for the level loss from gating.
File Locations
| Path | |
|---|---|
| Header | Sources/FolioDSP/include/FolioDSP/Color/BiasGate.h |
| Implementation | Sources/FolioDSP/src/Color/BiasGate.cpp |
| Tests | Tests/FolioDSPTests/BiasGateTests.swift |
| Bridge | Sources/FolioDSPBridge/src/FolioDSPBridge.mm (BiasGateBridge) |
Parameters
| Index | Name | Description | Min | Max | Default Min | Default Max | Default | Unit |
|---|---|---|---|---|---|---|---|---|
| 0 | Bias Point | DC offset added to signal before gate -- shifts operating point | -1.0 | 1.0 | -0.5 | 0.5 | 0.0 | |
| 1 | Threshold | Signal level required to turn on the transistor | 0.001 | 0.5 | 0.01 | 0.2 | 0.05 | |
| 2 | Splutter | Random threshold variation -- higher values = more erratic gating | 0.0 | 1.0 | 0.0 | 1.0 | 0.0 | |
| 3 | Gate Release | Envelope release time when signal drops below threshold | 1 | 1000 | 5 | 200 | 50 | ms |
| 4 | Makeup Gain | Output gain to compensate for level loss from gating | 0 | 40 | 0 | 20 | 0 | dB |
Processing Algorithm
The process() function executes these steps for each input sample:
1. Bias Offset
A DC offset shifts the signal's operating point relative to the gate threshold:
2. Splutter Threshold
The gate threshold is randomized per-sample using a xorshift32 PRNG:
Where \(T\) is the base threshold, \(S\) is the splutter amount (0--1), and \(r \in [0, 1)\) is a uniform random value. At \(S = 0\), the threshold is deterministic. At \(S = 1\), the effective threshold ranges from \(T\) to \(2T\).
3. Gate Decision
The transistor is considered "on" when the absolute biased signal exceeds the effective threshold:
4. Gate Envelope
A one-pole smoother creates the gate envelope with fast attack and configurable release:
Where \(R\) is the gate release time in milliseconds. The attack is fixed at ~1 ms.
5. Apply Gate
The biased signal is multiplied by the gate envelope:
6. DC Blocker
A first-order highpass removes the DC offset introduced by the bias:
Where \(\alpha_{\text{dc}} = 1 - e^{-2\pi \cdot 10 / f_s}\).
7. Makeup Gain
Output gain compensates for the level reduction caused by gating:
Core Equations
Snapshot Fields
| Field | Type | Range | Unit | Description |
|---|---|---|---|---|
| Input Level | Float | 0--1 | Smoothed absolute input level | |
| Output Level | Float | 0--1 | Smoothed absolute output level | |
| Bias Point | Float | -1--1 | Current bias parameter value | |
| Gate Gain | Float | 0--1 | Current gate envelope level | |
| Splutter | Float | 0--1 | Effective splutter threshold (after randomization) | |
| Transistor On | Bool | 0--1 | Whether the transistor is currently conducting | |
| Eff. Bias | Float | -2--2 | Effective biased signal value (input + bias) |
Implementation Notes
- DC blocker uses a one-pole highpass at 10 Hz with coefficient \(\alpha = 1 - e^{-2\pi \cdot 10 / f_s}\). This is essential because the bias parameter introduces a DC offset that would otherwise propagate through the signal chain.
- xorshift32 PRNG: The random number generator uses the xorshift32 algorithm (shifts 13, 17, 5) for real-time-safe random values. The output is mapped to \([0, 1)\) by dividing by \(2^{32}\).
- Gate initialization: On reset, the gate starts fully open (
gateGain_ = 1.0,transistorOn_ = true) so the signal passes through immediately. - Test consideration: Tests must use AC signals (sine waves), not DC, because the DC blocker correctly removes constant inputs.
- Level tracking uses exponential smoothing with coefficient 0.01 for display-rate visualization.
- Snapshot emission is decimated to ~60 fps (every 735 samples at 44.1 kHz).
Equation Summary
y = gate(x + bias) ยท makeup