tanh

This is a rational approximation of the tanh function. The gain parameter boosts the audio signal into the tanh function, for harder saturation.
Author: Jaffasplaffa
License: BSD
Github: jaffa/sat/tanh.axo

Inlets

frac32buffer i

Outlets

frac32buffer o

Parameters

bool32.tgl On

frac32.u.map.gain16 Gain

Audio Rate
// Rational Tanh approximation

int32_t Gain = __SSAT(___SMMUL(param_Gain, __SSAT(inlet_i, 28) << 4) << 1, 28);

float input = arm::q_to_float(((Gain >> 5)), 21);
float Tanh;

Tanh = (input * (27 + input * input) / (27 + 9 * input * input));

outlet_o = (param_On) ? ((int32_t)(Tanh * (1 << 21))) << 6 : inlet_i;

Privacy

© 2024 Zrna Research