Skip to main content

Module non_linearity_transformers

Module non_linearity_transformers 

Source
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§

NonLinearityTransformer
Here is the struct which is simply a wrapper around a non-linearity function that implements the StreamOperator trait, allowing it to be used in a streaming context where it can process blocks of input samples and produce corresponding output samples. The NonLinearityTransformer struct takes a non-linearity function as an argument during initialization, and the process method 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 levels parameter 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 sigmoid function is a common non-linear activation function that maps input values to a range between 0 and 1. It is defined as sigmoid(x) = 1 / (1 + exp(-x)), where exp is 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.