A CV models a single Float or an Array of such values constrained to a specific numerical range by a ControlSpec.
CV is derived from Stream so it can be used directly in Stream and Pattern definitions. CV:connect(view)
will connect a CV to a GUI ControlView in both Cocoa and Qt (as well as Swing).
GUI representations. A similar set of methods have been defined that connect argument arrays consisting of keys and CVs to Nodes, Buses, Buffers, and NodeProxys.
An SV is a CV that models an index into an array of Symbols. The array is held in the instance variable items. The symbol corresponding to the CV's current value can be accessed with the method SV: -item.
spec |
Any object that responds to |
default |
The initial value is constrained to lie within the range of the spec. |
a CV
An IdentityDictionary, holding the various view-classes for various gui-elements that may be used with CV as its keys and the class that syncs the view's value to the CV's value as its values:
Calls *buildViewDictionary on startup.
As the name suggests this method builds the viewDictionary and prepares the various connectable view-elements (sliders, number-boxes etc.) for the use with CV. The method also takes care of the different GUI-schemes (Cocoa, Qt, Swing).
Set the ControlSpec and (optionally) a default value - see also *new
(s) |
any object that responds to asSpec ( |
(v) |
the initial value of the CV |
Set the values of the CV's ControlSpec explicitely.
default |
inital value |
lo |
smallest possible value |
hi |
highest possible value |
step |
smallest incremental change |
warp |
either 'linear' or 'exponential' In the case of exponential warp, min and max must be non-zero and the same sign. |
Set the CV's spec to
ControlSpec(-100, 20, \lin, 1, 0)
the CV
Set or get the current value of the CV.
val |
Usually a Float or an Integer. If the CV's ControlSpec's |
if used as a getter the current value of the CV
Similar as -value but requires or returns a number ranging form 0 to 1 that corresponds to postion of the current value between min and max.
in |
a number between 0 and 1 |
if used as a getter the current value of the CV normalized to a value between 0 and 1
Interprets the value of the CV as a probability table and returns a weighted random value.
For use in Patterns: uses the value of key in the current Event as an index and returns the indexed value
key |
a Symbol |
the value indexed by key
the yielded value of the CV
Return the in unmapped value of the given argument val
(determined by the CV's ControlSpec). If an array of values is given an array of unmapped values will be returned. The given value will not alter the CV's value.
val |
a single numerical value or an array of numerical values |
Appends the CV's current value as OSC compliant argument to the given Array
array |
Usually an Array of numerical values. |
an OSC compliant representation of the CV's value appended to a given array
As CV inherits from Stream this method implements the method defined in the Stream interface. Calling this method simply returns the CV's value.
Return the size of the CV's internal ControlSpec. I.e. a CV's value or input will be a single numeric value if the ControlSpec
An Integer denoting the size of the CV's value
When a CV's value is changed a changed message (identified by the symbol \synch
) is send to update any dependant objects. For example, action_(function)
creates a SimpleController which is added to the dependants of the CV and evaluated whenever the CV changes value. This same basic mechanism is used to connect the CV to GUIs, server, objects, and some other objects in the language. Most of this is more or less hidden from view.
Under normal circumstances, CV connections are automatically removed when the targeted Control, Bus or View is deleted. If there is a program error, it is possible that connections will persist and will need to be explicitly removed.
Create and return a dependant SimpleController that evaluates the function whenever the CV's value is altered. Though the method takes a function as argument it is important to understand that it creates a new SimpleController. The function can not be updated or altered later, only the controller can be removed and a new one be added. The first argument passed to the function will always be the CV itself, making it easy to query the CV's current value or input.
function |
an arbitrary Function |
Remove all SimpleControllers that have been added with -addController. Possibly it's more important to be able to remove single controllers. However, some CVs create controllers behind the sceneswhen being instantiated. The method aims to be a clean-up possibility, removing sideeffects.
removeAllControllers
will only remove actions that have been added to the CV while keeping synchronisations with sliders and other views. However, CV also inherits a method Object: -release which will completly uninitialize the CV, removing all dependants.Connects a CV to a view. Array defines connect to allow a set of CVs to be connected to a view with multiple control values (i.e., Slider2D).
The following methods establish connections Views and CVs.
One CV can be connected to many views but each view is connected to only one CV. When a CV's value changes, it is relayed to all of its dependants including the source of the the change. That way, the GUI accurately reflects the new value of the CV. See the behavior of 'b' in the following example.
An example connecting a MultiSliderView
view |
a View, usable with a CV. See *viewDictionary to for an overview of qualified views. |
OSC commands (i.e., /n_set
, /s_new
) specify initial values of parameters as a flat Array of pairs consisting of a name and its initial value:
"Extended argument arrays" allow CVs to be used in place of the initial value. This is the standard syntax for establishing connections between CVs and a server. In an extended argument array, the CV's value can be altered before being sent, multiple CV's can determine the value to be sent, and the value to be sent can be determined by a function (here freq
is just meant as an example key):
value | [freq: 440] |
CV | [freq: aCV] |
altered CV | [freq: [aCV, aCV.midicps]] |
combination | [freq: [[aCV, bCV], aCV.midicps + bCV]] |
function | [freq: [aCV, { aCV.midicps.value + 33.rand }] |
For example, the method Synth: *controls is identical to Synth: *new except the args
parameter is extended:
In the previous two examples, the modifying expression is actually a combination of Streams altered with binary and unary operators. This is concise, but in some cases, it may be necessary to use a Function to define the modification.
Array: -connectToBuffer: the receiver is an array of CVs
Array: -connectToBus: the receiver is an array of CVs.
Bus: -setControls: connects CVs to consecutive buses
Pfunc can be used to change the CV from within a Pattern:
The input_(in) method makes it easy to connect a CV to any control source:
The methods input and input_ are also used by CVPreset to allow interpolations between settings that follow warp of the CV's ControlSpec.