Skip to content

Scale Controller

Description

This controller takes a controller as input and scales it from one range to another.

Syntax and Default Values

The scale controller can be created using the following Lisp, mlys.lua or mlys (Max) syntax:

(make-controller 'scale
                  dimension
                  inmin
                  inmax
                  outmin
                  outmax
                  controller)

The dimension and period parameters are mandatory in Lisp.


In Modalys for Max, this object is named mlys.scale:

Parameters

The 'scale controller takes six arguments:

  • dimension: dimension of the input and output controllers.
  • inmin: lower range of input controller values.
  • inmax: upper range of input controller values.
  • outmin: lower range of output controller values.
  • outmax: upper range of output controller values.
  • controller: controller to be scaled.

The dimension should be the same as that of the input controller (automatic for Lua or Max)

⚠️ The minimum and maximum values are provided as fixed values, and apply for each dimension of the input.

The input and output range is not clipped, therefore any out-of-range values will still be appropriately scaled, according to the multiplier derived form the given input and output ranges.

Discussion

Scaling controllers is a necessary and useful tool. The following example shows a break-point envelope controller that is scaled and inverted using the 'scale controller (a graph of the original and scaled envelopes is shown in the image, above):

(setq my-env (make-controller 'envelope 1 '((0 0.0) (0.2 1.0) (0.4 0.7) (1.2 0.7) (2 0))))
(setq my-scale (make-controller 'scale 0 0 1 2 -2 my-env))
One common use is scaling the speed of an access so it can be used as an input force for another object, such as this one which scales speed values by a factor of 50:

(setq speed-ctl (make-controller 'access-speed 1 my-string-out))
(setq scaledspeed-ctl (make-controller 'scale 1 0 1 0 50 speed-ctl))
(make-connection 'force my-plate-acc scaledspeed-ctl)
Additionally, MIDI controllers always output values between 0 and 127, so we generally need to use a scale controller to apply those values meaningfully in Modalys. For example, if we wanted to use pitch bend to control the frequency of a sine wave (controller) between 220Hz and 440Hz, we could do the following:

(setq midi-ctl (make-controller 'midi-file 1 "my-midi-file.mid" 1 (list 'pitchbend)))
(setq scaledmidi-ctl (make-controller 'scale 1 0 127 220 440 midi-ctl))
(setq sine-ctl (make-controller 'sine 1 scaledmidi-ctl))


★     ★