rsc3/doc-schelp/HelpSource/Classes/Spec.schelp

70 lines
2.6 KiB
Text
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
class:: Spec
summary:: input datatype specification
related:: Classes/ControlSpec, Classes/Warp
categories:: Control, Spec
description::
Specs specify what kind of input is required or permissible, and what the range of those parameters are. This is an abstract class - the most common subclass is: link::Classes/ControlSpec::.
ControlSpec is used by GUI sliders and knobs to specify the range and curve of the controls. Input datatypes are of interest to functions, to gui interface objects (sliders etc.) and can also be used for introspection.
The class Spec itself holds a master link::Classes/IdentityDictionary:: of common specifications. The name that the spec was stored as can then be used as a shorthand to refer to specs:
code::
\freq.asSpec
::
Some common mappings are initialized in code::ControlSpec.initClass::. You may add or overwrite mappings as you wish. The crucial library (available as a quark, see link::Classes/Quarks::) defines a number of additional subclasses. See the file quarks/cruciallib/Instr/MoreSpecs.sc
ClassMethods::
private::initClass
method::add
Add a spec to the global spec dictionary. The item will be converted to a spec using .asSpec.
Examples::
code::
Spec.add(\helpExp, ControlSpec( 0.01, 1.0, \exp) );
// the array will be converted to a control spec
Spec.add(\helpLin, [0, 1, \lin, 0.011, 0.01]);
// a symbol will be looked up converteuse the existing \freq spec for \helpLin2
Spec.add(\helpLin2, \freq);
// existing spec:
Spec.add(\helpLin, ControlSpec(0.ampdb, 1.ampdb, \db, units: " dB"));
// List of default specs:
\unipolar -> ControlSpec(0, 1),
\bipolar -> ControlSpec(-1, 1, default: 0),
\freq -> ControlSpec(20, 20000, \exp, 0, 440, units: " Hz"),
\lofreq -> ControlSpec(0.1, 100, \exp, 0, 6, units: " Hz"),
\midfreq -> ControlSpec(25, 4200, \exp, 0, 440, units: " Hz"),
\widefreq -> ControlSpec(0.1, 20000, \exp, 0, 440, units: " Hz"),
\phase -> ControlSpec(0, 2pi),
\rq -> ControlSpec(0.001, 2, \exp, 0, 0.707),
\audiobus -> ControlSpec(0, Server.default.options.numAudioBusChannels-1, step: 1),
\controlbus -> ControlSpec(0, Server.default.options.numControlBusChannels-1, step: 1),
\midi -> ControlSpec(0, 127, default: 64),
\midinote -> ControlSpec(0, 127, default: 60),
\midivelocity -> ControlSpec(1, 127, default: 64),
\db -> ControlSpec(0.ampdb, 1.ampdb, \db, units: " dB"),
\amp -> ControlSpec(0, 1, \amp, 0, 0),
\boostcut -> ControlSpec(-20, 20, units: " dB",default: 0),
\pan -> ControlSpec(-1, 1, default: 0),
\detune -> ControlSpec(-20, 20, default: 0, units: " Hz"),
\rate -> ControlSpec(0.125, 8, \exp, 0, 1),
\beats -> ControlSpec(0, 20, units: " Hz"),
\delay -> ControlSpec(0.0001, 1, \exp, 0, 0.3, units: " secs")
::