FX suite (wauvio/fx)
Saturation and bitcrushing
See it in action: An effect chain
Oversampler1
Single-channel 1×/2×/4×/8× oversampler built from 97-tap Kaiser-windowed half-band stages (≈90 dB stop-band). prepare(factor), process(in, out, n, fn) up-samples, runs fn at the high rate, then down-samples; latency() and the static latency_for(factor) give the integer round-trip delay.
Saturator
| Field | Default | Meaning |
|---|---|---|
mode | Soft | Soft, Tube, Tape, Hard, Fold, Asymmetric |
drive_db | 12 | Input gain into the shaper |
bias | 0 | −1..1; adds even harmonics (Tube/Asymmetric) |
tone_hz | 0 | Post low-pass; 0 = off |
mix | 1 | |
output_db | 0 | |
oversample | 2 | 1, 2, 4 or 8; reported via latency_samples() |
Bitcrusher
bits (8; 2–24, fractional allowed, mid-tread so silence stays silent), downsample (1 = off), dither (TPDF, seeded), mix, seed.
Full API listing
wauvio/fx/effects/saturation.hpp
wauvio::fx::class Oversampler1
// Oversampler1 - one channel. Each 2x stage is a 97-tap Kaiser-windowed half-band
// low-pass (beta 9, ~90 dB stop-band). Latency is an integer number of samples.
class Oversampler1
public:
static constexpr int D = 48; // half length; taps = 2D + 1
static constexpr int T = 2 * D + 1;
/// factor: 1, 2, 4 or 8
void prepare(int factor)
int factor() const noexcept { return factor_; }
static int normalise_factor(int f) noexcept { return f >= 8 ? 8 : f >= 4 ? 4 : f >= 2 ? 2 : 1; }
/// Round-trip delay (base-rate samples) for a given factor, before prepare().
static size_t latency_for(int f) noexcept { f = normalise_factor(f); return f == 1 ? 0 : static_cast<size_t>(D) * (2 * static_cast<size_t>(f) - 2) / static_cast<size_t>(f); }
/// Round-trip delay in base-rate samples (up + down).
size_t latency() const noexcept { return latency_for(factor_); }
void reset() { for (auto& s : st_) { std::fill(s.up_hist.begin(), s.up_hist.end(), 0.0f);
/// Up-sample, run fn(float* hi, size_t m) in place at the high rate, down-sample.
/// `in` and `out` may be the same pointer.
template <class F>
void process(const float* in, float* out, size_t n, F&& fn)
if (factor_ == 1) { if (in != out) std::copy(in, in + n, out); fn(out, n); return; }
const size_t B = 1024;
for (size_t off = 0; off < n; off += B)
wauvio::fx::class Saturator
class Saturator : public Effect
public:
enum class Mode { Soft, Tube, Tape, Hard, Fold, Asymmetric };
Mode mode = Mode::Soft;
double drive_db = 12.0; ///< input gain into the shaper
double bias = 0.0; ///< -1..1, adds even harmonics (Tube/Asymmetric); Tube always adds a little
double tone_hz = 0.0; ///< post low-pass; 0 = off
double mix = 1.0;
double output_db = 0.0;
int oversample = 2; ///< 1 (off), 2, 4 or 8 - reduces aliasing of the added harmonics
std::string name() const override { return "Saturator"; }
size_t latency_samples() const override { return Oversampler1::latency_for(oversample); }
void reset() override
using Effect::process;
void process(float* L, float* R, size_t n) override
wauvio::fx::class Bitcrusher
class Bitcrusher : public Effect
public:
double bits = 8.0; ///< 2..24 -> 2^bits - 1 levels (mid-tread: silence stays silent); fractions allowed
double downsample = 1.0; ///< hold each sample for this many samples (1 = off, 4 = quarter rate)
bool dither = false; ///< TPDF dither before quantising (seeded, deterministic)
double mix = 1.0;
uint64_t seed = 1;
std::string name() const override { return "Bitcrusher"; }
void reset() override { phase_[0] = phase_[1] = 1.0; held_[0] = held_[1] = 0.0f; rng_.reseed(seed); }
using Effect::process;
void process(float* L, float* R, size_t n) override