# Arrp Core Library: signal

## prev(v, x)

The array x prefixed with an element equal to v.

y[0] = v; y[i] = x[i - 1];

## delay(v, n, x)

The stream x prefixed with n elements equal to v.

y[i] = v, if i < n; y[i] = x[i - n];

## window(size, hop, x)

A stream of consecutive finite segments of stream x, each with the given size and starting 'hop' elements apart.

y[i, j] = x[i * hop + j], if j < size

## hold_while(condition, x)

A stream with each element equal to the corresponding element of stream x when condition is false (and at start) (or at start) and equal to its preceding element if condition is true.

y[0] = x[0]; y[i] = x[i], if condition[i] is true; y[i] = y[i - 1];

## phase(freq, start)

A ramp from 0 to 1, repeating with a frequency 'freq' (in repetitions per sample) and starting at 'start'.

## sine(freq, start_phase)

A sine wave in range [-1, 1] with frequency 'freq' (in repetitions per sample) starting at the given start_phase.

## triangle(freq, start_phase)

A triangle wave in range [-1, 1] with frequency 'freq' (in repetitions per sample) starting at the given start_phase.

## square(freq, start_phase)

A square wave in range [-1, 1] with frequency 'freq' (in repetitions per sample) starting at the given start_phase.

## pulse(rate)

A pulse stream - the value 1 repeating every 1/rate elements, with values 0 in between.

## pulse_width(rate, width)

A stream repeating every 1/rate elements; width denotes the beginning fraction of elements in each period equal to 1, with other elements equal to 0.

## white_noise(seed)

White noise - a stream of uniformly distributed values in range [-1, 1.0). The random generator is seeded with the given seed.

## convolve(h, x)

Convolution of stream x with a finite array h.

## iir(a, b, x)

Infinite impulse response filter with feed-forward coefficients b and feed-backward coefficients a, applied to stream x.

## fir(h, x)

Finite impulse response filter with coefficients h (impulse response), applied to stream x.

## one_pole(a, x)

One pole filter with coefficient a, applied to stream x.

## line(r, x)

A linear smoothing of stream x with the output rate limited at r (per sample). Each output element reduces the difference between the previous output element and the current input element by r.

y[i] = { min(x[i], y[i - 1] + r), if x[i] > y[i - 1]; max(x[i], y[i - 1] - r), otherwise; }