Effects
Basic audio effects.
- class tiliqua.dsp.WaveShaper(*args, src_loc_at=0, **kwargs)
Waveshapermaps every samplextof(x), wherefcan be any arbitrary python function.f(x)is evaluated atN=lut_sizepoints at elaboration time, to create a LUT (lookup table ROM) mapping the input domain (ASQ) to output samples. For any input sample that sits between elements in the ROM, linear interpolation is used to determine the output sample.This can be used for waveshaping, but is also useful for arbitrary remapping of samples, for example tanh-based soft clipping, linear- to exponential or linear-to-log space conversion.
- Members:
i (
In(stream.Signature(ASQ))) – Input stream for sending samples to the waveshaper.o (
In(stream.Signature(ASQ))) – Output stream for getting samples from the waveshaper.
- __init__(lut_function=None, lut_size=512, continuous=False, macp=None)
- lut_functionfunction
Function taking and emitting
floatvalues in a validASQrange.- lut_sizeint
Size of the LUT ROM in elements. Larger provides a better approximation.
- continuousbool
Behavior of linear interpolation at
ASQendpoints. ForASQ.i_bits==1and for a function wheref(+1) ~= f(-1), this should be used to ensure an incoming saw results in a continuous output.- macpmac.MAC
Optional shared MAC provider.
- class tiliqua.dsp.PitchShift(*args, src_loc_at=0, **kwargs)
Granular pitch shifter. Works by crossfading 2 separately tracked taps on a delay line - both tap positions are moving towards the write head (for pitching up) or away from the write head (for pitching down). Whenever the tap positions are close to overflowing, the discontinuity is smoothed by a crossfade of length
xfade.Maximum pitch-shifting grain size is the delay line ‘max_delay’ // 2. Smaller grain sizes or crossfades result in a ‘fluttering’ effect, but have lower latency. To reduce fluttering at low latency, one can dynamically track the
grain_szbased on the input frequency.The delay line write head must be hooked up to the input source from outside this component (this allows multiple shifters to share a single delay line).
- Members:
i (
In(stream.Signature(StructLayout({"pitch": ..., "grain_sz": ...}))) – Input stream, one element per desired output sample.pitchis afixed.SQi where 0 is no pitch shift, positive shifts up (e.g. 1 is 2x speed), negative shifts down.grain_szis the length of audio grain used for pitch shifting - up to thetap.max_delayo (
In(stream.Signature(ASQ))) – Output stream of pitch shifted samples.
- __init__(tap, xfade=256, macp=None)
- tapdelay_line.DelayLineTap()
DelayLineTapwhich pitch shifter reads at 2 tap positions for every output sample. The delayline write head must be hooked up to the input source.- xfadeint
Crossfade length between taps, in samples. Crossfades occur at every transition where we switch from one part of the delayline to the other. Longer crossfades and grain sizes produce less ‘fluttering’.
- macpmac.MAC
Optional shared MAC provider.