Liking cljdoc? Tell your friends :D

fastmath.signal

Signal processing (effect) and generation (oscillators).

Singal is any sequence with double values.

Signal processing

To process signal use apply-effects or apply-effects-raw (operates on double-array only) function.

Effect is signal filter, created by effect multimethod. Effects can be composed with compose-effects. Effect can be treated as function and can be called for given sample.

Each effect has it's own parametrization which should be passed during creation.

List of all available effects is under effects-list value.

Effects parametrization

Each effect has its own parameters.

:simple-lowpass, :simple-highpass

  • :rate - sample rate (default 44100.0)
  • :cutoff - cutoff frequency (default 2000.0)

:biquad-eq

Biquad equalizer

  • :fc - center frequency
  • :gain - gain
  • :bw - bandwidth (default: 1.0)
  • :fs - sampling rate (defatult: 44100.0)

:biquad-hs, :biquad-ls

Biquad highpass and lowpass shelf filters

  • :fc - center frequency
  • :gain - gain
  • :slope - shelf slope (default 1.5)
  • :fs - sampling rate (default 44100.0)

:biquad-lp, :biquad-hp, :biquad-bp

Biquad lowpass, highpass and bandpass filters

  • :fc - cutoff/center frequency
  • :bw - bandwidth (default 1.0)
  • :fs - sampling rate (default 44100.0)

:dj-eq

  • :high - high frequency gain (10000Hz)
  • :mid - mid frequency gain (1000Hz)
  • :low - low frequency gain (100Hz)
  • :shelf-slope - shelf slope for high frequency (default 1.5)
  • :peak-bw - peak bandwidth for mid and low frequencies (default 1.0)
  • :rate - sampling rate (default 44100.0)

:phaser-allpass

  • :delay - delay factor (default: 0.5)

:divider

  • :denom (long, default 2.0)

:fm

Modulate and demodulate signal using frequency

  • :quant - quantization value (0.0 - if no quantization, default 10)
  • :omega - carrier factor (default 0.014)
  • :phase - deviation factor (default 0.00822)

:bandwidth-limit

https://searchcode.com/file/18573523/cmt/src/lofi.cpp#

  • :rate - sample rate (default 44100.0)
  • :freq - cutoff frequency (default 1000.0)

:distort

  • :factor - distortion factor (default 1.0)

:foverdrive

Fast overdrive

  • :drive - drive (default 2.0)

:decimator

  • :bits - bit depth (default 2)
  • :fs - decimator sample rate (default 4410.0)
  • :rate - input sample rate (default 44100.0)

:basstreble

  • :bass - bass gain (default 1.0)
  • :treble - treble gain (default 1.0)
  • :gain - gain (default 0.0)
  • :rate - sample rate (default 44100.0)
  • :slope - slope for both (default 0.4)
  • :bass-freq - bass freq (default 250.0)
  • :treble-freq - treble freq (default 4000.0)

:echo

  • :delay - delay time in seconds (default 0.5)
  • :decay - decay (amount echo in signal, default 0.5)
  • :rate - sample rate (default 44100.0)

Warning! Echo filter uses mutable array as a internal state, don't use the same filter in paraller processing.

:vcf303

  • :rate - sample rate (default 44100.0)
  • :trigger - boolean, trigger some action (default false), set true when you reset filter every line
  • :cutoff - cutoff frequency (values 0-1, default 0.8)
  • :resonance - resonance (values 0-1, default 0.8)
  • :env-mod - envelope modulation (values 0-1, default 0.5)
  • :decay - decay (values 0-1, default 1.0)
  • :gain - gain output signal (default: 1.0)

:slew-limit

http://git.drobilla.net/cgit.cgi/omins.lv2.git/tree/src/slew_limiter.c

  • :rate - sample rate
  • :maxrise - maximum change for rising signal (in terms of 1/rate steps, default 500)
  • :maxfall - maximum change for falling singal (default 500)

:mda-thru-zero

  • :rate - sample rate
  • :speed - effect rate
  • :depth
  • :mix
  • :depth-mod
  • :feedback

Warning: internal state is kept in doubles array.

Oscillators

oscillator creates function which generates signal value for given time.

To sample generated wave to signal, call oscillator->signal with following parameters:

  • f - oscillator
  • samplerate - sample rate (samples per second)
  • seconds - duration

To convert signal to oscillator (using interpolation) use signal->oscillator passing signal and duration.

Add oscillators using oscillators-sum.

Smoothing filter

Savitzky-Golay smoothing filter savgol-filter.

File operations

You can save-signal or load-signal. Representation is 16 bit signed, big endian. Use Audacity or SoX to convert to/from audio files.

Signal processing (effect) and generation (oscillators).

Singal is any sequence with double values.

## Signal processing

To process signal use [[apply-effects]] or [[apply-effects-raw]] (operates on `double-array` only) function.

Effect is signal filter, created by [[effect]] multimethod. Effects can be composed with [[compose-effects]]. Effect can be treated as function and can be called for given sample.

Each effect has it's own parametrization which should be passed during creation.

List of all available effects is under [[effects-list]] value.

### Effects parametrization

Each effect has its own parameters.

#### :simple-lowpass, :simple-highpass

* `:rate` - sample rate (default 44100.0)
* `:cutoff` - cutoff frequency (default 2000.0)

#### :biquad-eq

Biquad equalizer

* `:fc` - center frequency
* `:gain` - gain
* `:bw` - bandwidth (default: 1.0)
* `:fs` - sampling rate (defatult: 44100.0)

#### :biquad-hs, :biquad-ls

Biquad highpass and lowpass shelf filters

* `:fc` - center frequency
* `:gain` - gain
* `:slope` - shelf slope (default 1.5)
* `:fs` - sampling rate (default 44100.0)

#### :biquad-lp, :biquad-hp, :biquad-bp

Biquad lowpass, highpass and bandpass filters

* `:fc` - cutoff/center frequency
* `:bw` - bandwidth (default 1.0)
* `:fs` - sampling rate (default 44100.0)

#### :dj-eq

* `:high` - high frequency gain (10000Hz)
* `:mid` - mid frequency gain (1000Hz)
* `:low` - low frequency gain (100Hz)
* `:shelf-slope` - shelf slope for high frequency (default 1.5)
* `:peak-bw` - peak bandwidth for mid and low frequencies (default 1.0)
* `:rate` - sampling rate (default 44100.0)

#### :phaser-allpass

* `:delay` - delay factor (default: 0.5)

#### :divider

* `:denom` (long, default 2.0)

#### :fm

Modulate and demodulate signal using frequency

 * `:quant` - quantization value (0.0 - if no quantization, default 10)
 * `:omega` - carrier factor (default 0.014)
 * `:phase` - deviation factor (default 0.00822)

#### :bandwidth-limit

https://searchcode.com/file/18573523/cmt/src/lofi.cpp#

* `:rate` - sample rate (default 44100.0)
* `:freq` - cutoff frequency (default 1000.0)

#### :distort

* `:factor` - distortion factor (default 1.0)

#### :foverdrive

Fast overdrive

* `:drive` - drive (default 2.0)

#### :decimator

* `:bits` - bit depth (default 2)
* `:fs` - decimator sample rate (default 4410.0)
* `:rate` - input sample rate (default 44100.0)

#### :basstreble

* `:bass` - bass gain (default 1.0)
* `:treble` - treble gain (default 1.0)
* `:gain` - gain (default 0.0)
* `:rate` - sample rate (default 44100.0)
* `:slope` - slope for both (default 0.4)
* `:bass-freq` - bass freq (default 250.0)
* `:treble-freq` - treble freq (default 4000.0)

#### :echo

* `:delay` - delay time in seconds (default 0.5)
* `:decay` - decay (amount echo in signal, default 0.5)
* `:rate` - sample rate (default 44100.0)

_Warning! Echo filter uses mutable array as a internal state, don't use the same filter in paraller processing._

#### :vcf303

* `:rate` - sample rate (default 44100.0)
* `:trigger` - boolean, trigger some action (default `false`), set true when you reset filter every line
* `:cutoff` - cutoff frequency (values 0-1, default 0.8)
* `:resonance` - resonance (values 0-1, default 0.8)
* `:env-mod` - envelope modulation (values 0-1, default 0.5)
* `:decay` - decay (values 0-1, default 1.0)
* `:gain` - gain output signal (default: 1.0)

#### :slew-limit

http://git.drobilla.net/cgit.cgi/omins.lv2.git/tree/src/slew_limiter.c

* `:rate` - sample rate
* `:maxrise` - maximum change for rising signal (in terms of 1/rate steps, default 500)
* `:maxfall` - maximum change for falling singal (default 500)

#### :mda-thru-zero

* `:rate` - sample rate
* `:speed` - effect rate
* `:depth`
* `:mix`
* `:depth-mod`
* `:feedback`

_Warning: internal state is kept in doubles array._

## Oscillators

[[oscillator]] creates function which generates signal value for given time.

To sample generated wave to signal, call [[oscillator->signal]] with following parameters:

* `f` - oscillator
* `samplerate` - sample rate (samples per second)
* `seconds` - duration

To convert signal to oscillator (using interpolation) use [[signal->oscillator]] passing signal and duration.

Add oscillators using [[oscillators-sum]].

## Smoothing filter

Savitzky-Golay smoothing filter [[savgol-filter]].

## File operations

You can [[save-signal]] or [[load-signal]]. Representation is 16 bit signed, big endian. Use Audacity or SoX to convert to/from audio files.
raw docstring

apply-effectsclj

(apply-effects in effects)
(apply-effects in effects reset)

Apply effects to signal as any sequence.

If reset is positive, reinit state each reset number of samples.

Returns new signal.

Apply effects to signal as any sequence.

If `reset` is positive, reinit state each `reset` number of samples.

Returns new signal.
sourceraw docstring

apply-effects-rawclj

(apply-effects-raw in effects)
(apply-effects-raw in effects reset)

Apply effects to signal as double-array.

If reset is positive, reinit state each reset number of samples.

Returns new signal as double-array.

Apply effects to signal as `double-array`.

If `reset` is positive, reinit state each `reset` number of samples.

Returns new signal as `double-array`.
sourceraw docstring

compose-effectsclj

(compose-effects e & es)

Compose effects.

Compose effects.
sourceraw docstring

db->linearclj

(db->linear x)

DB to Linear

DB to Linear
sourceraw docstring

effectcljmultimethod

Create effect for given name (as keyword) and optional parameters.

List of all possible effects is under effects-list.

Effect is a custom type which contains: name, sample (result of last call), effect function and current state.

Effect can be considered as function: call with sample to effect with next state or call without parameter to obtain latest result. Effects are also composable with compose-effects.

Create effect for given name (as keyword) and optional parameters.

List of all possible effects is under [[effects-list]].

Effect is a custom type which contains: name, sample (result of last call), effect function and current state.

Effect can be considered as function: call with sample to effect with next state or call without parameter to obtain latest result. Effects are also composable with [[compose-effects]].
sourceraw docstring

effect-nodeclj

(effect-node effect-name f)

Create EffectsList node from effect function and initial state.

Create `EffectsList` node from effect function and initial state.
sourceraw docstring

effects-listclj

List of effects.

List of effects.
sourceraw docstring

kernel-smoothing-filterclj

(kernel-smoothing-filter kernel)
(kernel-smoothing-filter kernel length)
(kernel-smoothing-filter kernel length step)

Creates Nadaraya-Watson kernel-weighted average

Arguments:

  • kernel - [[kernel]] function (default gaussian)
  • length - length of the kernel (default: 5)
  • step - distance between consecutive samples (default: 1.0)

Returns filtering function. See also savgol-filter.

Creates Nadaraya-Watson kernel-weighted average

Arguments:

* kernel - [[kernel]] function (default `gaussian`)
* length - length of the kernel (default: 5)
* step - distance between consecutive samples (default: 1.0)

Returns filtering function. See also [[savgol-filter]].
sourceraw docstring

linear->dbclj

(linear->db x)

Linear to DB

Linear to DB
sourceraw docstring

load-signalclj

(load-signal filename)

Read signal from file

Expected representation is 16 bit signed, big endian file.

Read signal from file

Expected representation is 16 bit signed, big endian file.
sourceraw docstring

moving-average-filterclj

(moving-average-filter)
(moving-average-filter length)

Creates moving average filter.

Arguments:

  • length - length of the kernel (default: 5)

Returns filtering function. See also savgol-filter.

Creates moving average filter.

Arguments:

* length - length of the kernel (default: 5)

Returns filtering function. See also [[savgol-filter]].
sourceraw docstring

oscillatorcljmultimethod

Create oscillator.

Parameters are:

  • oscilator name (see oscillators variable)
  • frequency
  • amplitude
  • phase (0-1)

Multimethod creates oscillator function accepting double (as time) and returns double from [-1.0 1.0] range.

To convert oscillator to signal, call [[signal-from-oscillator]].

To add oscillators, call [[sum-oscillators]].

Create oscillator.

Parameters are:

* oscilator name (see `oscillators` variable)
* frequency
* amplitude
* phase (0-1)

Multimethod creates oscillator function accepting `double` (as time) and returns `double` from [-1.0 1.0] range.

To convert `oscillator` to signal, call [[signal-from-oscillator]].

To add oscillators, call [[sum-oscillators]].
sourceraw docstring

oscillator->signalclj

(oscillator->signal f samplerate seconds)

Create signal from oscillator.

Parameters are:

  • f - oscillator
  • samplerate - in Hz
  • seconds - duration

Returns sampled signal as double array.

Create signal from oscillator.

Parameters are:

* f - oscillator
* samplerate - in Hz
* seconds - duration

Returns sampled signal as double array.
sourceraw docstring

oscillator-gainclj

(oscillator-gain fs gain)
source

oscillatorsclj

List of oscillator names used with oscillator

List of oscillator names used with [[oscillator]]
sourceraw docstring

oscillators-sumclj

(oscillators-sum & fs)

Create oscillator which is sum of all oscillators.

Create oscillator which is sum of all oscillators.
sourceraw docstring

reset-effectsclj

(reset-effects e)

Resets effects state to initial one.

Resets effects state to initial one.
sourceraw docstring

save-signalclj

(save-signal sig filename)

Save signal to file.

Representation is: 16 bit signed, big endian file You can use Audacity/SOX utilities to convert files to audio.

Save signal to file.

Representation is: 16 bit signed, big endian file
You can use Audacity/SOX utilities to convert files to audio.
sourceraw docstring

savgol-filterclj

(savgol-filter)
(savgol-filter length)
(savgol-filter length order)
(savgol-filter length order derivative)

Creates Savitzky-Golay smoothing filter.

Arguments:

  • length - length of the kernel (default: 5)
  • order - polynomial order (default: 2)
  • derivative - signal derivative (default: 0)

Returns filtering function which accepts collection of numbers and returns filtered signal.

Creates Savitzky-Golay smoothing filter.

Arguments:

* length - length of the kernel (default: 5)
* order - polynomial order (default: 2)
* derivative - signal derivative (default: 0)

Returns filtering function which accepts collection of numbers and returns filtered signal.
sourceraw docstring

signal->oscillatorclj

(signal->oscillator sig seconds)
(signal->oscillator sig seconds interpolator)

Create oscillator from signal.

Parameters:

  • sig - signal as sequence
  • seconds - duration
  • interpolator - interpolation (see fastmath.interpolation). Default: [[linear-smile]].
Create oscillator from signal.

Parameters:

* sig - signal as sequence
* seconds - duration
* interpolator - interpolation (see [[fastmath.interpolation]]). Default: [[linear-smile]].
sourceraw docstring

single-passclj

(single-pass e sample)

Process on sample using effects, returns EffectsList with result and new effect states.

Process on sample using effects, returns `EffectsList` with result and new effect states.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close