# aanl.lib

A library for antialiased nonlinearities. Its official prefix is aa.

This library provides aliasing-suppressed nonlinearities through first-order and second-order approximations of continuous-time signals, functions, and convolution based on antiderivatives. This technique is particularly effective if combined with low-factor oversampling, for example, operating at 96 kHz or 192 kHz sample-rate.

The library contains trigonometric functions as well as other nonlinear functions such as bounded and unbounded saturators.

Due to their limited domains or ranges, some of these functions may not suitable for audio nonlinear processing or waveshaping, although they have been included for completeness. Some other functions, for example, tan() and tanh(), are only available with first-order antialiasing due to the complexity of the antiderivative of the x * f(x) term, particularly because of the necessity of the dilogarithm function, which requires special implementation.

Future improvements to this library may include an adaptive mechanism to set the ill-conditioned cases threshold to improve performance in varying cases.

Note that the antialiasing functions introduce a delay in the path, respectively half and one-sample delay for first and second-order functions.

Also note that due to division by differences, it is vital to use double-precision or more to reduce errors.

The environment identifier for this library is aa. After importing the standard libraries in Faust, the functions below can be called as aa.function_name.

## Auxiliary Functions

### (aa.)clip

Clipping function.

### (aa.)Rsqrt

Real-valued sqrt().

### (aa.)Rlog

Real-valued log().

### (aa.)Rtan

Real-valued tan().

### (aa.)Racos

Real-valued acos().

### (aa.)Rasin

Real-valued asin().

### (aa.)Racosh

Real-valued acosh()

### (aa.)Rcosh

Real-valued cosh().

### (aa.)Rsinh

Real-valued sinh().

### (aa.)Ratanh

Real-valued atanh().

## Saturators

These antialiased saturators perform best with high-amplitude input signals. If the input is only slightly saturated, hence producing negligible aliasing, the trivial saturator may result in a better overall output, as noise can be introduced by first and second ADAA at low amplitudes.

Once determining the lowest saturation level for which the antialiased functions perform adequately, it might be sensible to cross-fade between the trivial and the antialiased saturators according to the amplitude profile of the input signal.

### (aa.)hardclip

The domain of this function is ℝ; its theoretical range is [-1.0; 1.0].

#### Usage

_ : aa.hardclip : _


### (aa.)hardclip2

The domain of this function is ℝ; its theoretical range is [-1.0; 1.0].

#### Usage

_ : aa.hardclip2 : _


### (aa.)cubic1

The domain of this function is ℝ; its theoretical range is [-2.0/3.0; 2.0/3.0].

#### Usage

_ : aa.cubic1 : _


### (aa.)parabolic

The domain of this function is ℝ; its theoretical range is [-1.0; 1.0].

#### Usage

_ : aa.parabolic : _


### (aa.)parabolic2

The domain of this function is ℝ; its theoretical range is [-1.0; 1.0].

#### Usage

_ : aa.parabolic : _


### (aa.)hyperbolic

The domain of this function is ℝ; its theoretical range is ]-1.0; 1.0[.

#### Usage

_ : aa.hyperbolic : _


### (aa.)hyperbolic2

The domain of this function is ℝ; its theoretical range is ]-1.0; 1.0[.

#### Usage

_ : aa.hyperbolic2 : _


### (aa.)sinarctan

The domain of this function is ℝ; its theoretical range is ]-1.0; 1.0[.

#### Usage

_ : aa.sinatan : _


### (aa.)sinarctan2

The domain of this function is ℝ; its theoretical range is ]-1.0; 1.0[.

#### Usage

_ : aa.sinarctan2 : _


### (aa.)tanh1

The domain of this function is ℝ; its theoretical range is ]-1.0; 1.0[.

#### Usage

_ : aa.tanh1 : _


### (aa.)arctan

The domain of this function is ℝ; its theoretical range is ]-π/2.0; π/2.0[.

#### Usage

_ : aa.arctan : _


### (aa.)arctan2

The domain of this function is ℝ; its theoretical range is ]-π/2.0; π/2.0[.

#### Usage

_ : aa.arctan2 : _


### (aa.)asinh1

The domain of this function is ℝ; its theoretical range is ℝ.

#### Usage

_ : aa.asinh1 : _


### (aa.)asinh2

The domain of this function is ℝ; its theoretical range is ℝ.

#### Usage

_ : aa.asinh2 : _


## Trigonometry

These functions are reliable if input signals are within their domains.

### (aa.)cosine1

The domain of this function is ℝ; its theoretical range is [-1.0; 1.0].

#### Usage

_ : aa.cosine1 : _


### (aa.)cosine2

The domain of this function is ℝ; its theoretical range is [-1.0; 1.0].

#### Usage

_ : aa.cosine2 : _


### (aa.)arccos

The domain of this function is [-1.0; 1.0]; its theoretical range is [π; 0.0].

#### Usage

_ : aa.arccos : _


### (aa.)arccos2

The domain of this function is [-1.0; 1.0]; its theoretical range is [π; 0.0].

Note that this function is not accurate for low-amplitude or low-frequency input signals. In that case, the first-order ADAA arccos() can be used.

#### Usage

_ : aa.arccos2 : _


### (aa.)acosh1

The domain of this function is ℝ >= 1.0; its theoretical range is ℝ >= 0.0.

#### Usage

_ : aa.acosh1 : _


### (aa.)acosh2

The domain of this function is ℝ >= 1.0; its theoretical range is ℝ >= 0.0.

Note that this function is not accurate for low-frequency input signals. In that case, the first-order ADAA acosh() can be used.

#### Usage

_ : aa.acosh2 : _


### (aa.)sine

The domain of this function is ℝ; its theoretical range is ℝ.

#### Usage

_ : aa.sine : _


### (aa.)sine2

The domain of this function is ℝ; its theoretical range is ℝ.

#### Usage

_ : aa.sine2 : _


### (aa.)arcsin

The domain of this function is [-1.0, 1.0]; its theoretical range is [-π/2.0; π/2.0].

#### Usage

_ : aa.arcsin : _


### (aa.)arcsin2

The domain of this function is [-1.0, 1.0]; its theoretical range is [-π/2.0; π/2.0].

Note that this function is not accurate for low-frequency input signals. In that case, the first-order ADAA asin() can be used.

#### Usage

_ : aa.arcsin2 : _


### (aa.)tangent

The domain of this function is [-π/2.0; π/2.0]; its theoretical range is ℝ.

#### Usage

_ : aa.tangent : _


### (aa.)atanh1

The domain of this function is ]-1.0; 1.0[; its theoretical range is ℝ.

#### Usage

_ : aa.atanh1 : _


### (aa.)atanh2

_ : aa.atanh2 : _