Arithmetic Controller
Description
Controller whose output combines two or more input controllers using one of the four basic arithmetic operations (+, -, *, /). Dimension of the input controllers is limited to 1.
(make-controller 'arithmetic ... )
Lisp Syntax and Default Values
TheĀ 'arithmetic controller can be created using the following Lisp syntax:
(make-controller 'arithmetic dimension operator controller1 controller2 ... )
(make-controller 'arithmetic dimension operator (list controller1 controller2 ... ))
Parameters
The 'arithmetic controller takes the following arguments:
- dimension: number of dimensions of the input and output controllers (should be set to 1).
- operator: one of the four symbols +, -, *, / (in quotes, or preceded by an apostrophe)
- controller1, controller2, etc...: controllers to "plug-in" to the math operation.
The number of dimensions of both input controllers and the resulting output controller must be 1.
Any number of input controllers may be provided (just as you would do for the Lisp functions +, -, * and /), but they must all be one-dimensional controllers. The controllers may be provided as a series of arguments or as a list.
Discussion
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 my-env1 (make-controller 'envelope 1 '((0 0.0) (0.2 1.0) (0.4 0.7) (1.2 0.7) (2 0))))
(setq my-env2 (make-controller 'envelope 1 '((0 1.5) (2 0.25)) ))
(setq my-product (make-controller 'arithmetic 1 "*" my-env1 my-env2))
(defun +~ (ctlr0 ctlr1) (make-controller 'arithmetic 1 '+ (list ctlr0 ctlr1)))
(defun *~ (ctlr0 ctlr1) (make-controller 'arithmetic 1 '* (list ctlr0 ctlr1)))
(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))
Options
There are no special options for this controller.