Expand description
This transformation applies a non-linear function to the input signal, which can be used for various purposes such as distortion effects in audio processing, or for implementing activation functions in neural networks. The non-linearity is applied element-wise to the input signal, and the output is of the same length as the input. The specific non-linear function can be defined by the user, allowing for flexibility in how the transformation is applied to the signal.
See the book entry Channels and equalisation.
Structs§
- NonLinearity
Transformer - Here is the struct which is simply a wrapper around a non-linearity function that implements the
StreamOperatortrait, allowing it to be used in a streaming context where it can process blocks of input samples and produce corresponding output samples. TheNonLinearityTransformerstruct takes a non-linearity function as an argument during initialization, and theprocessmethod applies this function to each sample in the input signal, producing a transformed output signal.
Functions§
- hard_
clip_ complex - hard_
clip_ real - Hard clipping is a simple non-linear transformation that limits the amplitude of the input signal to a specified threshold.
- quantize_
complex - quantize_
real - Quantization is a non-linear transformation that maps a continuous range of values to a finite set of discrete levels.
This assumes the input is normalized to the range [-1, 1]. The
levelsparameter specifies the number of quantization levels, which determines the resolution of the quantization process. For real-valued inputs, the quantization process involves dividing the range of possible input values into a specified number of levels and mapping each input value to the nearest quantization level. For complex-valued inputs, the quantization process is applied separately to the real and imaginary parts of the complex number, resulting in a quantized complex output where both the real and imaginary components have been transformed by the quantization process. - sigmoid
- The
sigmoidfunction is a common non-linear activation function that maps input values to a range between 0 and 1. It is defined assigmoid(x) = 1 / (1 + exp(-x)), whereexpis the exponential function. The sigmoid function is often used in machine learning and neural networks to introduce non-linearity into the model, allowing it to learn complex patterns in the data. In the context of signal processing, applying a sigmoid non-linearity can create distortion effects or be used for dynamic range compression.