Skip to content

Arithmetic Controller


Controller whose output combines two or more input controllers using one of the four basic arithmetic operations (+, -, *, /). Dimension of each input controller must be the same.

(make-controller 'arithmetic ... )

Syntax and Default Values

The arithmetic controller can be created using the following Lisp syntax:

(make-controller 'arithmetic
                  c1 c2 ... )

(make-controller 'arithmetic
                  (list c1 c2 ... ))
c1 = create_controller{kind="dynamic",value={4.5, -2.1}}
c2 = create_controller{kind="dynamic",value={3.2, -45.9}}
c3 = modalys.create_controller{kind="arithmetic",name="MyArithmetic",


The 'arithmetic controller takes the following arguments:

  • dimension: dimension of the arithmetic controller (should be set to -1 to set the dimension of the input controllers automatically).
  • operator: one of the four symbols +, -, *, / (in quotes, or preceded by an apostrophe)
  • c1, c2, etc.: controllers to feed the math operation.

The dimension of all input controllers and the resulting output controller should match.

Any number of input controllers may be provided (just as you would do for the Lisp functions +, -, * and /), but they must all have the same dimension. The controllers may be provided as a series of arguments or as a list.


Arithmetic controllers are used to realize arithmetic operations efficiently in controller networks.

A basic example shows two breakpoint envelopes being multiplied together (as shown in the image at the top of the page):

(setq c1 (make-controller 'envelope 1 '((0 0.0) (0.2 1.0) (0.4 0.7) (1.2 0.7) (2 0))))
(setq c2 (make-controller 'envelope 1 '((0 1.5) (2 0.25)) ))
(setq my-product (make-controller 'arithmetic -1 "*" c1 c2))
To provide an example, we could rewrite the fm excitation of the Modalys example 5 the following way (using Max's naming convention):
(defun +~ (c0 c1) (make-controller 'arithmetic -1 '+ (list c0 c1)))
(defun *~ (c0 c1) (make-controller 'arithmetic -1 '* (list c0 c1)))
(defun sin~ (frequency) (make-controller 'sine 1 frequency))
;;; we assume here that cf, mr, mi and ae are bound to one-dimensional controllers
(setq mrcf (*~ mr cf))
(setq fm-output (*~ (sin~ (+~ (*~ (*~ mrcf mi) (sin~ mrcf)) cf)) ae))
The result is more efficient and more general code (besides we tried to make it more readable).
★     ★