Vixen
02b45cc4
csharp
public sealed class BitCrusherEffect

Throws away resolution, on purpose, in both of the ways audio has any.

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

Remarks

Digital audio has two kinds of precision — how finely a sample's value is measured, and how often it is measured — and this ruins each of them independently, because they sound completely different and a preset usually wants one and not the other.

Bits is quantisation noise. Rounding every sample to one of a handful of levels adds an error that follows the signal, which is heard as a gritty, crunchy edge that gets louder as the sound gets quieter. That last part is the giveaway of a low bit depth and is the opposite of how analogue noise behaves.

Downsample is aliasing. Holding each sample for several outputs is a sample rate reduction with no filter in front of it, so everything above the new Nyquist folds back down as inharmonic tones. It is what makes something sound like it is coming through a 1990s handheld rather than merely sounding rough.

The rate divisor is fractional and that is not a novelty. A phase accumulator means it can be swept — from 1 to 20 over a second — which is the sound of a signal degrading, and it cannot be done by an integer counter without stepping audibly on the way.

Fields and properties (5)

  • public float Bits

    How many bits of resolution to leave. Fractional is allowed and useful for a sweep.

  • public float Downsample

    How many output samples each input sample is held for.

  • public float Mix

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

  • public bool Enabled

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

  • public IReadOnlyList<string> Properties

    The knobs this effect will answer to, by name.

Methods (5)

  • 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.

Used by (4)

  • BitCrusherEffectAssetVixen.Audio
  • MixControlTestsVixen.Audio.Tests
  • MixerAssetTestsVixen.Audio.Tests
  • ShapingEffectTestsVixen.Audio.Tests