diracFilter

weird dirac/slope-change filter, mostly used for taking away fast changes in the signal rate-change (like in saw and pulse waves). It takes the difference of the difference of the difference between 2 samples. The last one is the current rate, the incoming signal is changing. The middle one is the rate at which this incoming rate is changing. And the first one would then be the change-rate of the changerate of the rate of the incoming signal.... get it? The faster the signal-rate-change changes, the more it will push down the frequency of the LP filter, removing more high frequencies and thus, smoothing the signal where it's needed.
Author: Remco van der Most
License: BSD
Github: sss/filter/diracFilter.axo

Inlets

frac32buffer input

Outlets

frac32buffer output

Parameters

frac32.s.map.pitch cut

frac32.s.map.pitch smooth

frac32.u.map.gain gain

int32.hradio mode

Declaration
int32_t val;
int32_t prev1;
int32_t prev2;
int32_t prev3;
int32_t diff1;
int32_t diff2;
int32_t diff3;
int32_t rate;
int32_t LP;
int32_t smooth;
int32_t HP;
Init
val = 0;
LP = 0;
HP = 0;
Audio Rate
int32_t in = inlet_in;
diff1 = in - prev1;
diff2 = diff1 - prev2;
diff3 = diff2 - prev3;

rate = ___SMMUL(
    __SSAT(param_mode > 0 ? (param_mode > 1 ? diff3 << 3 : diff2) : diff1 >> 3,
           24)
        << 8,
    param_gain);
rate = rate > 0 ? -rate : rate;
int32_t g;
MTOF(param_smooth - rate, g)
smooth = __SMMLA((rate - smooth) << 1, g, smooth);
int32_t freq;
MTOF(param_cut + smooth, freq)
LP = __SMMLA((in - LP) << 1, freq, LP);
HP = HP + ((LP - HP) >> 12);
outlet_out = LP - HP;

prev1 = in;
prev2 = diff1;
prev3 = diff2;

Privacy

© 2024 Zrna Research