Vixen
02b45cc4
csharp
public sealed class ModulatedDelayEffect

A delay whose length is being moved by a slow oscillator.

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

Remarks

One effect, because they are one effect. A flanger is a 1–10 ms delay swept with feedback, a chorus is a 15–40 ms delay swept with more depth and no feedback, and a vibrato is either of those with the dry signal turned off. Writing them as three classes would be the same two hundred lines three times, and the interesting differences would be buried in the duplication rather than visible as the defaults they are. Chorus, Flanger and Vibrato hand back the presets.

Why they sound different at all. A flanger's delay is short enough that the dry and delayed copies interfere across the whole audible range, producing a comb of notches at harmonically related frequencies — which the ear hears as one moving resonance. A chorus's delay is longer than the ear's fusion window, so the copies are heard as separate near-unison voices instead. Same arithmetic, and the number that separates them is about 15 ms.

The delay is read at a fractional position and interpolated. That is the whole thing: rounding the sweep to whole samples makes it step, and a stepping delay is a click per step rather than a sweep. Linear interpolation loses a little top end at long delays and is what almost every implementation uses.

The channels are swept out of phase with each other. Modulating both identically gives an effect that is undeniably present and completely mono; ninety degrees apart is what makes a chorus wide.

Fields and properties (11)

  • public ModulatedDelayKind Kind

    What it is being. Descriptive; the numbers below are what actually decide.

  • public float DelaySeconds

    The middle of the sweep, in seconds.

  • public float DepthSeconds

    How far either side of that the sweep travels, in seconds.

  • public float RateHz

    How many times a second the oscillator goes round.

  • public float Feedback

    How much of the output feeds back in. Negative inverts, which is a flanger's other voice.

  • public int Voices

    How many taps to read the line at, spread evenly around the oscillator.

  • public float StereoSpread

    How far apart the channels are swept, as a fraction of the cycle.

  • public float Wet

    How much of the swept signal to add.

  • public float Dry

    How much of the untouched signal to keep. Zero turns any of these into a vibrato.

  • 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 (8)

  • public static ModulatedDelayEffect Chorus()

    A chorus: three taps, a slow deep sweep, no feedback.

  • public static ModulatedDelayEffect Flanger()

    A flanger: one tap, short, fast, and resonant.

  • public static ModulatedDelayEffect Vibrato()

    A vibrato: the sweep alone, with none of the dry signal to interfere with.

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

  • MixControlTestsVixen.Audio.Tests
  • MixerAssetTestsVixen.Audio.Tests
  • ModulatedDelayEffectAssetVixen.Audio
  • ModulationEffectTestsVixen.Audio.Tests