Vixen
02b45cc4
csharp
public sealed class DistortionEffect

Bends the waveform, which is what every kind of distortion is.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Waveshaping and nothing else. There is no filtering here and there deliberately is not: the tone control every guitar amplifier puts around its distortion is an equaliser, and this engine has one. Building a fixed tone stack into the distortion would give one opinion about what distorted sound should be, where a EqualizerEffect either side of it gives all of them.

DriveDb is the whole control. Every curve here does nothing to a quiet signal and progressively more as it approaches the rail, so the way to get more distortion is to make the signal louder before it arrives — and then to turn the result back down, which is what OutputDb is for. That is what a real amplifier does too.

It aliases, and there is no oversampling. Bending a waveform makes harmonics, and harmonics above Nyquist fold back down as inharmonic tones that follow the pitch in the wrong direction. Oversampling by four is the fix and costs four times the arithmetic plus two filters; for a radio voice or an explosion nobody notices, and for a lead guitar everybody does. It is owed, and this is not the effect to put a guitar through yet.

Fields and properties (7)

  • public DistortionCurve Curve

    Which curve.

  • public float DriveDb

    How hard the signal is pushed into the curve, in decibels.

  • public float OutputDb

    A gain applied after the curve, in decibels, to put the level back.

  • public float Mix

    How much of the bent signal to keep, against the untouched one.

  • public bool Enabled

    Whether it does anything. A bypassed effect costs one branch a block.

  • public int Oversampling

    How many times the sample rate the shaping runs at: 1, 2 or 4.

  • public IReadOnlyList<string> Properties

    The knobs this effect will answer to, by name.

Methods (6)

  • public void Prepare(in AudioFormat format, int maxFrames)

    Sizes and clears every buffer the effect needs.

  • public void Process(Span<float> buffer, int frameCount, int channels)

    Processes a block in place.

  • public void Reset()

    Throws away everything the effect remembers about what came before.

  • public bool TrySetProperty(string name, float value)

    Sets one of the effect's knobs by name, for automation.

  • public bool TryGetProperty(string name, out float value)

    Reads one of the effect's knobs by name.

  • public static float Shape(float value, DistortionCurve curve)

    Bends one sample.

Used by (5)

  • DistortionEffectAssetVixen.Audio
  • MixControlTestsVixen.Audio.Tests
  • MixerAssetTestsVixen.Audio.Tests
  • OversamplingTestsVixen.Audio.Tests
  • ShapingEffectTestsVixen.Audio.Tests