Reference
Ce contenu n’est pas encore disponible dans votre langue.
Diogenic language reference
Introduction
Section titled “Introduction”Diogenic is a language designed to write DSP patches as S-expressions. It borrows a lot of its syntax from Lisp.
Functions
Section titled “Functions”Functions in diogenic are similar to macros in the way they’re implemented; function names are erased from the final instruction sequence during compilation.
(defun my-saturation (in) (tanh (* 2.0 (foldback 0.75 in))))
(+ (my-saturation (sine! 220.0)) (my-saturation (sine! 440.0)))You may use functions defined in other files:
; my-lib.scm(use std/builtin)
(defun sawtooth-lfo (freq) (builtin/slew ; slew is a function imported from std/builtin (sawtooth! freq) 0.05)); main.scm(use "my-lib.scm")
(sine! (map (sawtooth-lfo 0.2) -1 1 220.0 440.0))Macros
Section titled “Macros”->
Pipes the nth child to the first argument of the n+1th child.
Useful for long, sequential chains of DSP calls.
(-> (sine! 220.0) (cos) (tan) (foldback :threshold 0.8))
; compiles down to:(foldback (tan (cos (sine! 220.0))) :threshold 0.8)Special Forms
Section titled “Special Forms”Special forms are expressions that take some unevaluated arguments.
Takes name, value couples as reusable bindings
(let (freq 440.0 threshold (+ 0.5 (* 0.1 (sine! :freq 0.2)))) (foldback threshold freq))Values defined in the bindings section may reference previously bound variables:
(let (mod-freq 220.0 mod-phase PI mod (sine! mod-freq mod-phase)) (...))Linearly rescales an input signal from a specified range to another.
(map (sine! :freq 0.2) ; input signal -1.0 1.0 ; input range 0.0 0.6) ; output rangemap expects literal numbers for the ranges.
Built-in devices
Section titled “Built-in devices”Pure devices only manipulate the diogenic VM stack. Impure devices
may also manipulate the state, a persistent f32 array. These are
marked by and exclamation mark (!).
This version of diogenic includes 63 devices.
+
arithmetic addition. 2 arguments.
- lhs
- rhs
arithmetic subtraction. 2 arguments.
- lhs
- rhs
arithmetic multiplication. 2 arguments.
- lhs
- rhs
arithmetic division, no guard against divide by zero. 2 arguments.
- lhs
- rhs
less than comparison. 2 arguments.
- lhs
- rhs
less equal than comparison. 2 arguments.
- lhs
- rhs
greater than comparison. 2 arguments.
- lhs
- rhs
greater equal than comparison. 2 arguments.
- lhs
- rhs
smallest given argument. 2 arguments.
- lhs
- rhs
biggest given argument. 2 arguments.
- lhs
- rhs
weighted average of two input signals. 3 arguments.
- a, first signal
- b, second signal
- alpha, weighted average coefficient
chebyshev
Section titled “chebyshev”first kind Chebyshev function. 2 arguments.
- in
- order
delay!
Section titled “delay!”delays the input signal. 2 arguments.
- in, input signal
- delay, delay, in seconds
downsample!
Section titled “downsample!”reduce the sample rate. 2 arguments.
- in, input signal
- sample-rate, target sample rate
grains!
Section titled “grains!”granular synthesis. 6 arguments.
- in, input signal
- density, default:
10, grain density, in grains per second - size, default:
100, grain size, in milliseconds - speed, default:
1, grain playback speed - position, default:
0.5, grain spawn position, 0 = tail, 1 = head - fade, default:
10, grain fade in/out, in milliseconds
random!
Section titled “random!”random interpolated instantaneous wave amplitude. 1 argument.
- freq, random value refresh rate, in Hz
instantaneous sine wave amplitude. 2 arguments.
- freq, target frequency
- pm, default:
0, instantaneous phase offset
sawtooth!
Section titled “sawtooth!”instantaneous saw tooth wave amplitude. 2 arguments.
- freq, target frequency
- pm, default:
0, instantaneous phase offset
square!
Section titled “square!”instantaneous square wave amplitude. 2 arguments.
- freq, target frequency
- pm, default:
0, instantaneous phase offset
triangle!
Section titled “triangle!”instantaneous triangle wave amplitude. 2 arguments.
- freq, target frequency
- pm, default:
0, instantaneous phase offset
pan signal between left and right channels. 2 arguments.
- in, input signal
- alpha, panning modifier: -1.0 = all left, 0.0 = middle, 1.0 = all right.
binary logarithm. 1 argument.
- in
decimal logarithm. 1 argument.
- in
neperian logarithm. 1 argument.
- in
base-e exponential. 1 argument.
- in
base-2 exponential. 1 argument.
- in
arc sinus. 1 argument.
- in
hyperbolic arc sinus. 1 argument.
- in
sinus. 1 argument.
- in
hyperbolic sinus. 1 argument.
- in
arc cosinus. 1 argument.
- in
hyperbolic arc cosinus. 1 argument.
- in
cosinus. 1 argument.
- in
hyperbolic cosinus. 1 argument.
- in
arc tangent. 1 argument.
- in
hyperbolic arc tangent. 1 argument.
- in
tangent. 1 argument.
- in
hyperbolic tangent. 1 argument.
- in
sigmoid
Section titled “sigmoid”sigmoid. 1 argument.
- in
floor rounding. 1 argument.
- in
ceil rounding. 1 argument.
- in
absolute value. 1 argument.
- in
midi->freq
Section titled “midi->freq”midi pitch to frequency unit translation. 1 argument.
- in
freq->midi
Section titled “freq->midi”frequency to midi pitch unit translation. 1 argument.
- in
bi->uni
Section titled “bi->uni”bipolar [-1; 1] to unipolar [0; 1] signal remapping. 1 argument.
- in
uni->bi
Section titled “uni->bi”unipolar [0; 1] to bipolar [-1; 1] signal remapping. 1 argument.
- in
db->amp
Section titled “db->amp”decibel to amplitude unit translation. 1 argument.
- in
amp->db
Section titled “amp->db”amplitude to decibel unit translation. 1 argument.
- in
noise!
Section titled “noise!”normally distributed random value centered around 0 with a standard deviation of 1. 0 arguments.
clamps the signal between t-1 and t+1. 2 arguments.
- in, input signal
- threshold,
t
clamps the signal between -t and +t. 2 arguments.
- in, input signal
- threshold,
t
diode wave shaper. 2 arguments.
- in, input signal
- threshold,
t
foldback
Section titled “foldback”foldback wave shaper. 2 arguments.
- in, input signal
- threshold,
t
quantize
Section titled “quantize”quantizer. 2 arguments.
- in, input signal
- bits, level of precision, roughly equates to the bits used to encode the amplitude. Typically ranges between 0.0 and 32.0.
b-highpass!
Section titled “b-highpass!”biquadratic high pass filter. 4 arguments.
- in, input signal
- freq, target frequency
- q, default:
0.707, quality factor - g, default:
1, gain factor
b-lowpass!
Section titled “b-lowpass!”biquadratic low pass filter. 4 arguments.
- in, input signal
- freq, target frequency
- q, default:
0.707, quality factor - g, default:
1, gain factor
b-bandpass!
Section titled “b-bandpass!”biquadratic band pass filter. 4 arguments.
- in, input signal
- freq, target frequency
- q, default:
0.707, quality factor - g, default:
1, gain factor
b-notch!
Section titled “b-notch!”biquadratic notch filter. 4 arguments.
- in, input signal
- freq, target frequency
- q, default:
0.707, quality factor - g, default:
1, gain factor