Skip to content

audio_dsp

(sys:load “libs/core/audio_dsp.xtm”)

The audio_dsp package provides core dsp utilities, helper functions and generators for audio.

NOTE: SAMPLE is a type alias for float. However, it also tells you that this function expects a value between 0.0 and 1.0

dsp_randn:[float]*
  • SAMPLE : A random number between 0.0 and 1.0

This returns a Gaussian distributed random number between 0.0 and 1.0

It uses the Marsaglia algorithm (http://c-faq.com/lib/gaussian.html).

parabolicSineHP:[SAMPLE,SAMPLE]*
  1. x:SAMPLE : The x value for a Parabolic Sine function.
  • SAMPLE : The y value for this function.

A highly accurate implemntation of the Parabolic Sine function. If accuracy is less important than speed, there is also a low quality implementation of this function available to you.

parabolicSineLP:[SAMPLE,SAMPLE]*
  1. x:SAMPLE : The x value for a Parabolic Sine function.
  • SAMPLE : The y value for this function.

A low quality, but fast, implemntation of the Parabolic Sine function. If accuracy is more important than speed, there is a highly accurate implementation of this function available to you.

fasttan:[SAMPLE,SAMPLE]*
  1. x:SAMPLE : The x value for a tan function.
  • SAMPLE : The y value for this function.

A fast implemntation of tan.

TODO What are the compromises in using this? Is there a range of acceptable values.

fasttanh:[SAMPLE,SAMPLE]*
  1. x:SAMPLE : The x value for a tanh function.
  • SAMPLE : The y value for this function.

A fast implemntation of tanh.

TODO What are the compromises in using this? Is there a range of acceptable values.

fastsin:[SAMPLE,SAMPLE]*
  1. x:SAMPLE : The x value for a tanh function. X must be within the range -PI <= X <= PI
  • SAMPLE : The y value for this function.

A fast implementation of sin. When calling this function make sure that you adjust x so that it lies within the range -PI <= X <= PI

This is currently wrong, so I’m going to describe how it as if the bug was fixed.

integrator_c:[[SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE] : The leaky integrator closure.
  1. x:SAMPLE : The signal we wish to integrate.
  • SAMPLE : The current sum.

TODO Cuurrently this has a bug, so fix it.

This function returns a leaky integrator closure.

TODO Show how to create it and then used it.

These oscillators are useful for control level modulation, or situations where you’re not worried about aliasing. Otherwise use the band-limited oscillators described in the next section.

sin_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*

TODO I feel this should probably have sin in there somewhere.

  1. phase:SAMPLE : The initial phase (radians) for the oscillator.
  • [SAMPLE,SAMPLE,SAMPLE]* : The Sin Oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  • SAMPLE : The output signal for the oscillator.

This function creates an aliasing Sine oscillator.

TODO One example should be a cosine.

saw_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*
saw_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE,i1]*
  1. mod:SAMPLE : The initial phase where 0 <= mod <=1
  2. inverted:i1 optional : If #t then the saw tooth is inverted. The default is #f (i.e. a normal rising saw tooth).
  • [SAMPLE,SAMPLE,SAMPLE]* : The Saw Tooth Oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  • SAMPLE : The output signal for the oscillator.

This function creates an aliasing Sawtooth oscillator.

TODO One example should be an inverted saw tooth.

pulse_c:[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*
  1. mod:SAMPLE : The initial phase where 0 <= mod <=1
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The Pulsewave Oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  3. pw:SAMPLE : The pulse width where 0 <= pw <= 1.0
  • SAMPLE : The output signal for the oscillator.

This function creates an aliasing pulsewave oscillator.

TODO

tri_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*
  1. mod:SAMPLE : The initial phase where 0 <= mod <=1
  • [SAMPLE,SAMPLE,SAMPLE]* : The Triangle Oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  • SAMPLE : The output signal for the oscillator.

This function creates an aliasing triangle oscillator.

TODO

These oscillators are anti-aliased, but consume more resources. Use these for audio signals, but they’re probably overkill for most control signals (unless you’re modulating at audio rate).

blsaw_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*
blsaw_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE,i1]*
blsaw_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE,i1,i1]*
  1. mod:SAMPLE : The initial phase where 0 <= mod <=1
  2. inverted:i1 optional : If #t then the saw tooth is inverted. The default is #f (i.e. a normal rising saw tooth).
  3. high_cpu optional : If set to true this will use a better, but slower, algorithm. The default value is #f.
  • [SAMPLE,SAMPLE,SAMPLE]* : The Saw Tooth Oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  • SAMPLE : The output signal for the oscillator.

This function creates an anti-aliased Sawtooth oscillator. It is implemented using the BLEP method.

TODO One example should be an inverted saw tooth.

blpulse_c:[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,SAMPLE,i1]*
  1. mod:SAMPLE : The initial phase where 0 <= mod <=1
  2. highcpu:i1 optional : If set to true this will use a better, but slower, algorithm. The default value is #t (TODO really?).
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The Pulsewave Oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  3. pw:SAMPLE : The pulse width where 0 <= pw <= 1.0
  • SAMPLE : The output signal for the oscillator.

This function creates an anti-aliased pulsewave oscillator.

It uses the sum of saws method.

TODO

bltri_c:[[SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*
  1. mod:SAMPLE : The initial phase where 0 <= mod <=1
  • [SAMPLE,SAMPLE,SAMPLE]* : The triangle oscillator closure.
  1. amp:SAMPLE : Amplitude of the oscillator.
  2. freq:SAMPLE : Current frequency of the oscillator.
  • SAMPLE : The output signal for the oscillator.

This function creates an anti-aliased triangle oscillator. TODO - uses which method?

TODO

white_c:[[SAMPLE]*]*
  • [SAMPLE]* : White noise closure.
  • SAMPLE : The output signal for the oscillator.

This function creates a white noise generator. The white noise is gaussian distributed (see dsp_randn).

TODO

pink_c:[[SAMPLE]*]*
  • [SAMPLE]* : Pink noise closure.
  • SAMPLE : The output signal for the oscillator.

This function creates a pink noise generator. The pink noise is generated using Paul Kellet’s economy method: http://www.firstpr.com.au/dsp/pink-noise/

TODO

LinTerp:[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]*
  1. x1:SAMPLE : The x value before the interpolated value.
  2. x2:SAMPLE : The x value after the interpolated value.
  3. y1:SAMPLE : The y value before the interpolated value.
  4. y1:SAMPLE : The y value after the interpolated value.
  5. x:SAMPLE : The x that we want an interpolated value for.
  • SAMPLE : interpolated y value.

Given the points (x1,y1) and (x2,y2) this will return the interpolated value y when given an x that lies between x1 and x2.

hermite_interp:[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]*
  1. fractional:SAMPLE : position within the interval [x0, x1], in the range 0.0 to 1.0.
  2. y1:SAMPLE : the sample immediately before the interval (i.e. x[n-1]).
  3. x0:SAMPLE : the sample at the start of the interval; returned when fractional is 0.0.
  4. x1:SAMPLE : the sample at the end of the interval; returned when fractional is 1.0.
  5. x2:SAMPLE : the sample immediately after the interval (i.e. x[n+2]).
  • SAMPLE : interpolated y value.

Four-point cubic Hermite interpolation. Interpolates between x0 and x1, using the surrounding samples y1 and x2 to shape the curve.

($ (hermite_interp 0.5 0.0 1.0 2.0 3.0)) ;; returns 1.5

midi2frq:[float,float]*
  1. float : A midi note number
  • float : A frequency in herz

Converts a midi value to a frequency value. E.g. given 60 it will return the value 261.6 Hz

> ($ (midi2frq 60.0))
261.625549
frq2midi:[float,float]*
  1. float : A frequency in herz
  • float : A midi note number

Converts a frequency value to a midi value. E.g. given 261.6 it will return the value 60.

> ($ (midi2frq 261.625549))
60
bpm2hz:[float,float]*
  1. float : Beats per Minute
  • float : A frequency in herz

Converts a value in beats per minute to a frequency in herz.

> ($ (bpm2hz 60))
1.000
hz2bpm:[float,float]*
  1. float : A frequency in herz
  • float : Beats per minute

Converts a value in herz to beats per minute.

> ($ (hz2bpm 1.000))
60.000
amp2db:[float,float]*
  1. float : Volume amplitude Amps where 0.0 < Amps <= 1.0
  • float : Volume in decibels where -inf < db <= 0.0

A utility function that converts between Extempore’s model of volume amplitude and decibels.

Amplitude in Extempore is a linear scale between 0.0 and 1.0, where 0.0 is silence and 1.0 is the maximum value.

> ($ (amp2db 0.5))
-6.0206
db2amp:[float,float]*
  1. float : Volume in decibels where -inf < db <= 0.0
  • float : Volume amplitude Amps where 0.0 < Amps <= 1.0

A utility function that converts from decibels (where 0.0 is the maximum possible volume) to Extempore’s model of volume amplitude and decibels.

Amplitude in Extempore is a linear scale between 0.0 and 1.0, where 0.0 is silence and 1.0 is the maximum value.

> ($ (db2amp -6.0206))
0.5

These are closures that are useful for monitoring and manipulating volume.

rms_c:[[SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE]* : The closure we will use for our DSP chain.
  1. SAMPLE : current sound sample from input source.
  • db:SAMPLE : The RMS value for the current FRAME. Note that this is in decibels.
  • SAMPLE : The input value (e.g. the signal is passed straight through)

This function creates a closure that takes a signal and calculates the RMS value for it.

The RMS value is calculated every frames (e.g. the global variable FRAMES which defines extempore’s block size) and placed in the closure’s environment as the value db.

The signal is passed through the closure unchanged. This allows you to easily place it in a dsp chain without worrying about the signal.

DB is (RMS is +3db - i.e. dBFS with sine 1.0 at 0.0db) - need a better explaination TODO.

TODO

gainf::[SAMPLE,i64,i64,SAMPLE]*
  1. time:i64 : elapsed time since the envelope curve was triggered. The curve starts at time 0.
  2. width:i64 : the duration of the envelope curve in TODO.
  3. power:float : This controls the curve of the envelope curve. The envelope curve can be flat, linear or have a quadratic curve.
  • SAMPLE : The current value of the generated envelope curve. TODO RANGE?

Generates an envelope curve. The envelope curve has duration width, and given a time value between 0 and width TODO will return a value from within the curve.

TODO The value will always be between 0 and 1.0

The power parameter determines the shape of the curve. Positive values will give you a curve that goes up, negative values a curve that goes down.

If you want an envelope that descends, rather than ascends, use a negative power value.

  • 0.0 -> 1.0 : The output will always be power. E.g., if you set power to 0.5, you will always get an output of 0.5.
  • 1.01 -> 2.0 : This will give you an ascending line from 0 to the mantissa TODO check. So 1.5 will give you an ascending line from 0.0 to 0.5 over time width.
  • 2.01 and higher : These will give you ascending curves of increasing steepness. If the value is negative this will give you a descending curve that is the mirror of the ascending curve.

TODO. Needs several probably.

panner::[SAMPLE,i64,SAMPLE]*
  1. channel:i64 : The channel that you want the correct value for.
  2. pan:SAMPLE : The stereo pan, where 0.0 is on the left, 0.5 is the middle and 1.0 is the right.
  • SAMPLE : The properly panned value for this channel TODO how does it calculate this?

;; given current channel ;; and pan value [0.0-1.0] ;; returns value betwee n [0.0-1.0] ;; uses CHANNELS

Given a sample input and a desired pan level this function will calculate the correct output for the desired channel.

TODO How is this calculated?

TODO. Needs several probably.

hann:[SAMPLE,i64,i64,i64]*
  1. time:i64 : elapsed time since this function started (0 is the start time)
  2. width:i64 : Width of the hann window in TODO time periods
  3. repeat:i64 : repeat period. 1 is immediately, 2 is after a single cycle, 5 is after 4 cycles. TODO 0 should be never repeat.
  • SAMPLE - A value between 0.0 and 1.0, where 1.0 is the peak of the hann windows.

This generates a repeating hann window signal. Use repeat to define the repititon pattern. 0 for non-repeating, 1 for continuous, 2 for every other cycle, etc.

TODO

Could remove entirely hann by simply setting the the repeat to 0.0

impulse::[SAMPLE,i64,i64]*
  1. time:i64 : time in samples starting from 0.
  2. apex:i64 : time in samples after 0 when the impulse should be fired (TODO Note it can’t be 0 - which is odd). Until apex is reached the output will be 0.
  • SAMPLE - A value between 0.0 and 1.0 for the impulse value

This generates an impulse of 1.0 that begins at time period apex and outputs 1.0 for a single sample period. After it is activated it will exponentially decay to 0.

TODO

poly_blep:[float,float,float,i1]*
  1. pos:SAMPLE : TODO
  2. inc:SAMPLE : TODO
  3. height:SAMPLE : TODO
  4. rising_edge:i1 : TODO
  • SAMPLE : TODO

A polynomial bandlimited step function. TODO

blep_n:[float,float*,float,float,float,float,i1,float,i1]*
  1. table:SAMPLE* : TODO
  2. tablenlen:SAMPLE : length of table.
  3. mod:SAMPLE : TODO
  4. inc:SAMPLE : TODO
  5. height:SAMPLE : TODO
  6. rising:i1 : TODO
  7. num_points:SAMPLE : TODO
  8. interp:i1 : TODO
  • SAMPLE : TODO

TODO

print_audio_state:[void]*

Prints the status of the soundcard to the command line.

Many of the functions that create a filter closure expect an enumeration value. These are defined below:

  • LPF1 : Low Pass Filter, 1 pole.
  • LPF2 : Low Pass Filter, 2 poles.
  • LPF4 : Low Pass Filter, 4 poles.
  • HPF1 : High Pass Filter, 1 pole.
  • HPF2 : High Pass Filter, 2 poles.
  • HPF4 : High Pass Filter, 4 poles.
  • BPF1 : Band Pass Filter, 1 pole.
  • BPF2 : Band Pass Filter, 2 poles.
  • BPF4 : Band Pass Filter, 4 poles.
lpf_1p_c::[[SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE]* : The low pass filter closure.
  1. x:SAMPLE : input sample that we are filtering
  2. g:SAMPLE : positions the pole on the unit axis (0.0 -> 1.0)
  • SAMPLE : filtered output sample.

A simple 1 pole filter. g moves the pole along the axis. TODO - check that you’re remembering this correctly.

va_onepole::[[SAMPLE,SAMPLE,SAMPLE]*,i32]*
  1. type:i32 : The type of filter that is being created. You choices are LPF1 (for a low pass filter) and HPF1 (for a high pass filter).
  • [SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering
  2. freq:SAMPLE : filter cutoff frequency.
  3. q:SAMPLE : filter ‘q’ value
  • SAMPLE : filtered output sample.

A virtual analog modelled 1 pole filter. This can either be a low pass filter, or a high pass filter.

Based upon Will Pirkle’s implementation.

moog_ladder::[[SAMPLE,SAMPLE,SAMPLE]*,i32]*
  1. type:i32 : The type of filter that is being created. You choices are LPF2 and LPF4 (for a low pass filter), BPF2 and BPF4 (for a band pass filter) and HPF2 and HPF4 (for a high pass filter).
  • [SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering
  2. freq:SAMPLE : filter cutoff frequency.
  3. q:SAMPLE : filter ‘q’ value
  • SAMPLE : filtered output sample.

The legendary Moog filter. This can serve as a low pass, band pass and high pass filter. [TODO would be good to reference which one of the many designs this is, and it’s performance generally].

svf_c::[[|6,float|*,float,float,float,|6,float|*]*]*
  • [SAMPLE,SAMPLE,SAMPLE,|6,float|*]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  4. outarray:|6,float|* : Memory location to store the output.
  • |6,float|* : The output from the different components of this filter: |low pass, band pass, high pass, notch filter, peak filter, allpass filter|

An analog modelled state variable filter. State variable filters produce multiple filter responses from the same circuitry.

This design follows: http://www.cytomic.com/files/dsp/SvfLinearTrapOptimised2.pdf. The ‘using v1 to compute v2’ version.

lpf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a low pass filter. Not sure if this is analog modelled, or not.

lpf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a low pass filter. Not sure if this is analog modelled, or not.

lpf2_c:[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a low pass filter. Not sure if this is analog modelled, or not.

This is less efficient that lpf_c, but this one could be run on two processors. Currently this is probably more interesting rather than useful.

hpf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a high pass filter. Not sure if this is analog modelled, or not.

hpf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a high pass filter. Not sure if this is analog modelled, or not.

apf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of an all pass filter. Not sure if this is analog modelled, or not.

notch_c:[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a notch filter. Not sure if this is analog modelled, or not.

peak_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. res:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a peak filter. Not sure if this is analog modelled, or not.

bell_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. q:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a bell filter. Not sure if this is analog modelled, or not.

TODO: From the code. Q is usually around 0.5 gain is either a boost up to +5.0db or a reduction down to -24.0db. Little cryptic…

lshelf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. q:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a low shelf filter. Not sure if this is analog modelled, or not.

TODO: From the code. Q is usually around 0.5 gain is either a boost up to +5.0db or a reduction down to -24.0db. Little cryptic…

hshelf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. q:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

TODO - more info. Essentially this is a state variable filter version of a high shelf filter. Not sure if this is analog modelled, or not.

TODO: From the code. Q is usually around 0.5 gain is either a boost up to +5.0db or a reduction down to -24.0db. Little cryptic…

skf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. cutoff:SAMPLE : filter cutoff frequency.
  3. q:SAMPLE : Filter resonance (q).
  • SAMPLE : filtered output sample.

A low pass filter of the Sallen Key type.

TODO - more info probably.

Implemented using Andy Simper’s Sallen Key LPF http://cytomic.com/files/dsp/SkfLinearTrapOptimised2.pdf

delay_apf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE]* : The all pass filter closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. apf_gain:SAMPLE : TODO What this actually does :)
  • SAMPLE : filtered output sample.

All pass filter implemented using a delay.

tap delays will also end up here.

delay_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The delay closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. wet:SAMPLE : how much of the input signal should be mixed with the delay. 0.0 will give you 100% of in 1.0 will give you 100% of the delay (TODO Actually it doesn’t do this, but shouldn’t it?)
  3. feedback:SAMPLE : Feedback. In theory this should be how much of the out signal gets mixed into the delay with in. But that doesn’t seem to be what’s going on.
  • SAMPLE : filtered output sample.

Non interpolated delay line. TODO: Work out how this actually works and check that it’s correct (it probably is). It’s possible that this is actually a comb filter, in which case I think the name should be comb_c, and just rely upon it having a non-fractional delay maybe? It is confusing.

comb_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The delay closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. delay:SAMPLE : TODO Dig out the DSP books…
  3. mix:SAMPLE : how much of the input signal should be mixed with the delay. 0.0 will give you 100% of in 1.0 will give you 100% of the delay (TODO Actually it doesn’t do this, but shouldn’t it?)
  4. fb:SAMPLE : Feedback. In theory this should be how much of the out signal gets mixed into the delay with in. But that doesn’t seem to be what’s going on.
  • SAMPLE : filtered output sample.

Interpolated comb filter. You can use fractional delay amounts and it will do the necessary math to give you the intended result.

comb_lpf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The delay closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. delay:SAMPLE : TODO Dig out the DSP books…
  3. mix:SAMPLE : how much of the input signal should be mixed with the delay. 0.0 will give you 100% of in 1.0 will give you 100% of the delay (TODO Actually it doesn’t do this, but shouldn’t it?)
  4. fb:SAMPLE : Feedback. In theory this should be how much of the out signal gets mixed into the delay with in. But that doesn’t seem to be what’s going on.
  5. cof:SAMPLE : cutoff frequency for the low pass.
  6. res:SAMPLE : resonance amount (TODO Q?)
  • SAMPLE : filtered output sample.

TODO: Interpolated comb filter with a low pass filter. I’m not sure why this is necessary, other than as a building block for other ugens. Feels redundant.

comb_lpf_1p_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The delay closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. delay:SAMPLE : TODO Dig out the DSP books…
  3. combg:SAMPLE : TODO dunno
  4. lpfg:SAMPLE : low pass filter gain (see lpf I guess).
  5. cof:SAMPLE : cutoff frequency for the low pass.
  6. res:SAMPLE : resonance amount (TODO Q?)
  • SAMPLE : filtered output sample.

TODO: Interpolated comb filter with a simple 1 pole low pass filter. I’m not sure why this is necessary, other than as a building block for other ugens. Feels redundant.

comb_apf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The ugen closure.
  1. x:SAMPLE : input sample that we are filtering.
  2. delay:SAMPLE : TODO Dig out the DSP books…
  3. apf:gain : The all pass filter gain.
  • SAMPLE : filtered output sample.

TODO: Interpolated comb filter with a simple all pass filter filter. I’m not sure why this is necessary, other than as a building block for other ugens. Feels redundant.

delay_apf_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Delay time for this delay line.
  • [SAMPLE,SAMPLE,SAMPLE]* : The delay closure.
  1. in:SAMPLE : input sample that we are filtering.
  2. gain:SAMPLE : TODO Dig out the DSP books and work out what gain is doing here.
  • SAMPLE : filtered output sample.

TODO Assume this is an all pass filter that uses delay. Need to check.

Add the stereo reverb because that’s a thing.

flanger_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,i64]*
  1. delay:i64 : Max delay time for this flanger.
  • flanger_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The flanger closure.
  1. x:SAMPLE : The thing we’re TODO I guess the channel? Seems a little inflexible
  2. in:SAMPLE : input? TODO
  3. out:SAMPLE : output? TODO
  4. delay:SAMPLE : delay in milliseconds
  5. range:SAMPLE : range in miliseconds
  6. feedback:SAMPLE : 0..1 (TODO what do this do?)
  • SAMPLE : filtered output sample.

TODO Describe what a flanger does. Probably.

chorus_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]*,SAMPLE]*
  1. phase:SAMPLE : TODO Definition
  • [[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The flanger closure.
  1. x:SAMPLE : The thing we’re TODO I guess the channel? Seems a little inflexible
  2. in:SAMPLE : input? TODO
  3. out:SAMPLE : output? TODO
  4. feedback:SAMPLE : 0..1 (TODO what do this do?) feedbacks the output into the next signal almost certainly.
  • SAMPLE : filtered output sample.

TODO Describe what a chorus does. Probably.

tap_delay_c::[[float,float]*,i64,i64]*
  1. max_delay:i64 : Max length of this tap delay (e.g. 64)
  2. num_taps:SAMPLE :
  • [[SAMPLE,SAMPLE,SAMPLE,SAMPLE,SAMPLE]* : The flanger closure.
  1. x:SAMPLE : The input sample
  • SAMPLE : processed output

TODO Describe what a tap delay does. I feel this could be done more flexibly just by creating a general purpose delay line that can easily be accessed. Also needs some more controls (decay, etc).

reverb_c::[[i64,SAMPLE,SAMPLE,float,float,SAMPLE,SAMPLE]*]*
  • [[i64,SAMPLE,SAMPLE,float,float,SAMPLE,SAMPLE]* : The flanger closure.
  1. chan:i64 : The channel of the input (TODO need a better way of handling)
  2. x:SAMPLE : The input sample
  3. size:SAMPLE : roomsize from 0.0 to 1.0
  4. predelay:float : milliseconds. Can go as high as 2 seconds, but 40 milliseconds is a good starting point.
  5. absorb:SAMPLE : Amount of high frequency damping (simulating wall absorbtion). 0.0 to 1.0 6: mix:SAMPLE : 0.0 dry to 1.0 wet
  • SAMPLE : processed output

A reverb. TODO describe topology, type, etc. Need more reverb.

reverb_st_c::[[i64,SAMPLE,SAMPLE,float,float,SAMPLE,SAMPLE]*]*
  • [[i64,SAMPLE,SAMPLE,float,float,SAMPLE,SAMPLE]* : The flanger closure.
  1. chan:i64 : The channel of the input (TODO need a better way of handling)
  2. x:SAMPLE : The input sample
  3. size:SAMPLE : roomsize from 0.0 to 1.0
  4. predelay:float : milliseconds. Can go as high as 2 seconds, but 40 milliseconds is a good starting point.
  5. absorb:SAMPLE : Amount of high frequency damping (simulating wall absorbtion). 0.0 to 1.0
  6. mix:SAMPLE : 0.0 dry to 1.0 wet
  • SAMPLE : processed output

A reverb for stereo signal. A kludge apparently. TODO find out why.

crusher_c::[[SAMPLE,SAMPLE,SAMPLE]*]*
  • [[SAMPLE,SAMPLE,SAMPLE]* : The bit crusher closure.
  1. in:SAMPLE : The input sample
  2. bits:SAMPLE : bit size after processing (TODO why is this a float?)
  • SAMPLE : processed output

A ‘dodgy’ bitcrusher (TODO why dodgy)

hold3_c::[[SAMPLE,SAMPLE,SAMPLE]*]*
  • [[SAMPLE,SAMPLE,SAMPLE]* : The sample and hold closure.
  1. in:SAMPLE : The input sample
  2. h:SAMPLE : if h > 0.0 then continue to play the last held sample
  • SAMPLE : processed output

Sample and hold. TODO description.

distort_c::[[SAMPLE]*]*
  • gain:SAMPLE : How much gain to apply to the input (TODO think this should be a closure parameter)
  • [[SAMPLE]* : The distortion closure.
  1. in:SAMPLE : The input sample
  • gain:SAMPLE : How much gain to apply to the input
  • lim:SAMPLE : the level at which this should start to distort. (0.0-1.0)
  • SAMPLE : processed output

A very basic distortion ugen.

fade_c::[[SAMPLE,SAMPLE,SAMPLE,SAMPLE]*]*

TODO: This function doesn’t make sense to me. I feel there is a better way of achieving a linen. Shouldn’t it have a gate? and why not pass in the time, rather than it having it’s own internal sense of that?

This feels a little too complex for this file.

TODO maybe come back to this, but seems confusing as currently presented. need channels independent of sound for these to work well.

Why are there mix closures and functions?