Skip to content

Reference

Diogenic language reference

Diogenic is a language designed to write DSP patches as S-expressions. It borrows a lot of its syntax from Lisp.

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))

->

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 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 range

map expects literal numbers for the ranges.

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

first kind Chebyshev function. 2 arguments.

  • in
  • order

delays the input signal. 2 arguments.

  • in, input signal
  • delay, delay, in seconds

reduce the sample rate. 2 arguments.

  • in, input signal
  • sample-rate, target sample rate

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 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

instantaneous saw tooth wave amplitude. 2 arguments.

  • freq, target frequency
  • pm, default: 0, instantaneous phase offset

instantaneous square wave amplitude. 2 arguments.

  • freq, target frequency
  • pm, default: 0, instantaneous phase offset

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. 1 argument.

  • in

floor rounding. 1 argument.

  • in

ceil rounding. 1 argument.

  • in

absolute value. 1 argument.

  • in

midi pitch to frequency unit translation. 1 argument.

  • in

frequency to midi pitch unit translation. 1 argument.

  • in

bipolar [-1; 1] to unipolar [0; 1] signal remapping. 1 argument.

  • in

unipolar [0; 1] to bipolar [-1; 1] signal remapping. 1 argument.

  • in

decibel to amplitude unit translation. 1 argument.

  • in

amplitude to decibel unit translation. 1 argument.

  • in

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 wave shaper. 2 arguments.

  • in, input signal
  • threshold, t

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.

biquadratic high pass filter. 4 arguments.

  • in, input signal
  • freq, target frequency
  • q, default: 0.707, quality factor
  • g, default: 1, gain factor

biquadratic low pass filter. 4 arguments.

  • in, input signal
  • freq, target frequency
  • q, default: 0.707, quality factor
  • g, default: 1, gain factor

biquadratic band pass filter. 4 arguments.

  • in, input signal
  • freq, target frequency
  • q, default: 0.707, quality factor
  • g, default: 1, gain factor

biquadratic notch filter. 4 arguments.

  • in, input signal
  • freq, target frequency
  • q, default: 0.707, quality factor
  • g, default: 1, gain factor