signal/shaper
src/signal/shaper.tur
defn
gain
(gain [g :float])
scale a signal by a constant factor.
Example
((gain 0.5) (sine 440.0 0.0))
defn
offset
(offset [c :float])
shift a signal by a constant: y = x + c.
Example
((offset 0.5) (constant 0.25)) sampled at any t => 0.75
defn
invert
(invert)
negate a signal: y = -x.
defn
abs-sf
(abs-sf)
absolute value of a signal sample-wise.
defn
scale
(scale [in-lo :float in-hi :float out-lo :float out-hi :float x :float] :float)
linear remap of a value from [in-lo, in-hi] to [out-lo, out-hi].
Example
(scale 0.0 1.0 -1.0 1.0 0.75) ; => 0.5
defn
saturate-tanh
(saturate-tanh [drive :float])
soft-saturate via tanh: y = tanh(drive*x) / tanh(drive).
Parameters
| drive | > 0; higher values saturate harder. The denominator keeps | |
| the peak output near +/-1.0 regardless of drive. |
Example
((saturate-tanh 3.0) some-oscillator)
defn
hard-clip
(hard-clip [limit :float])
symmetric clip to [-limit, +limit].
Example
((hard-clip 0.9) some-osc)
defn
clip
(clip [lo :float hi :float])
asymmetric hard-clip to [lo, hi].
Example
((clip -0.2 0.8) some-osc)
defn
mix
(mix [alpha :float])
weighted mix of a Pair signal: out = alpha*x + (1-alpha)*y.
Example
((mix 0.5) (pair-signals (sine 440.0 0.0) (sine 660.0 0.0)))
defn
add
(add)
sum a Pair signal sample-wise.
defn
multiply
(multiply)
product of a Pair signal sample-wise.
Example
((multiply) (pair-signals lfo carrier))
Internal definitions
__pair-fst-f-- local readers for the float-pair shape__pair-snd-f__shaper_fabs-- absolute value of a float.__shaper_tanh-- hyperbolic tangent.