public sealed class OversamplerRuns a nonlinearity at a higher rate, so the harmonics it makes have somewhere to go.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Bending a waveform makes harmonics, and harmonics above Nyquist do not vanish — they fold. A 5 kHz tone through a cubic curve produces 15 kHz, 25 kHz and 35 kHz. At 48 kHz everything above 24 comes back down: 25 reappears at 23, and 35 at 13. Those are not harmonics of 5 kHz. They are inharmonic tones that move the wrong way when the input pitch changes, which is exactly what makes aliased distortion sound like grit rather than like distortion.
The fix is room. Interpolate to four times the rate, shape there — where the first several harmonics fit below the new Nyquist — filter them off, and come back down. What folds is then far quieter and far higher, and the audible result is the harmonic series the curve was supposed to produce.
It is not always worth it. For sustained tonal material — a guitar, a synth — the difference is the whole character of the effect. For an explosion, a radio voice or a damaged machine, the source is already noisy and nobody can pick the aliasing out of it. So this is a switch and not a default.
One filter design, used both ways. Going up, the prototype is a polyphase interpolator; coming down it is a plain low-pass at the same cutoff running at the high rate, of which one output in Factor is kept. Two filters designed separately would be two chances to put the cutoff in the wrong place.
Fields and properties (3)
public int ChannelsHow many channels it holds state for.
public int FactorHow many points it produces per input sample.
public int LatencyHow many input samples of delay the two filters add, together.
Methods (4)
public Oversampler(int channels, int factor = 4)An oversampler over some channels.
public void Expand(int channel, float sample, Span<float> destination)Turns one sample into Factor of them.
public float Collapse(int channel, ReadOnlySpan<float> samples)Turns Factor shaped points back into one sample.
public void Reset()Forgets every filter's history.
Used by (2)
- DistortionEffectVixen.Audio
- OversamplingTestsVixen.Audio.Tests