ControlSpec:
Filter:
Classes | Control | Spec

ControlSpec : Spec : Object

numerical input specification
Source: Spec.sc

Description

The original, and most common spec (see Spec). A ControlSpec is used by GUI sliders and knobs to specify the range and curve of the controls. ControlSpec may be used in many ways to map from linear 0..1 range to your desired range and back.

The most common way to create a ControlSpec is by

Class Methods

ControlSpec.new(minval: 0.0, maxval: 1.0, warp: 'lin', step: 0.0, default, units, grid)

Arguments:

minval

The minimum value of the range.

maxval

The maximium value of the range.

warp

a Warp, a symbol (e.g. \lin or \exponential: Default value is \lin), or something else that returns a Warp when sent the message .asWarp. A CurveWarp is defined by a number.

step

The smallest possible increment.

default

The default value.

units

The units, e.g. "hz". Used by some gui's as a unit label.

grid

Inherited class methods

Undocumented class methods

ControlSpec.newFrom(similar)

Instance Methods

.map(value)

Maps and constrains a value between 0 and 1 to the range between minval and maxval.

.unmap(value)

Maps and constrains a value between minval and maxval to the range between 0 and 1.

.clipLo

The lower of maxval and minval.

.clipHi

The higher of maxval and minval.

.constrain(value)

Returns value.asFloat.clip(clipLo, clipHi).round(step).

.range

Returns maxval - minval.

.guessNumberStep

Used for EZ GUI classes for guessing a sensible step if none is specified.

.gridClass

Returns the AbstractGridLines subclass corresponding to the current spec, in particular its warp behavior.

.grid

.grid = value

Get/set an instance of the AbstractGridLines subclass that describes the range and warp behavior of the current spec, e.g. for use by DrawGrid for drawing grids in Plotter.

Inherited instance methods

Undocumented instance methods

.calcRange(data, defaultRange: 1.0)

.copy

.default

.default = value

.gridValues(n: 20, min, max, base: 10)

.hasZeroCrossing

.looseRange(data, defaultRange, minval, maxval)

.maxval

.maxval = v

.minval

.minval = v

.normalize(min, max)

.ratio

.roundRange(base: 10)

.setFrom(otherSpec)

.shift(amount: 1)

.step

.step = s

.units

.units = value

.warp

.warp = w

.zoom(ratio: 1)

Examples