CVWidget2D:
Filter:
Classes (extension) | GUI | Conductor | External Control > MIDI | External Control > OSC

CVWidget2D : CVWidget : Object
ExtensionExtension

a control-widget that can either be embedded in other views or opened as a standalone-widget, offering easy connections with external MIDI-/OSC-hard- and software.

Description

A CVWidget2D is widget that can be used to set e.g. controls in running Synths, Ndefs, ProxySpace slots, NodeProxys, Patches and other other values that can be set at runtime. Also it may be used in connection with Patterns. Contrary to CVWidgetKnob and CVWidgetMS it holds two CVs.

Class Methods

CVWidget2D.new(parent, widgetCV, name, connectSliders, connectTextFields, bounds, defaultActions, setup, controllersAndModels, cvcGui, persistent, server)

Create a new CVWidget2D. To display the widget on screen you must call front on the resulting object.

Arguments:

parent

an instance of Window or View - optional. If none is given the it will be created internally.

widgetCV

an Event of CVs - optional. If none is given it will be created internally. The array may hold 2 CVs, on in slot \lo the other in slot \hi.

name

a String or a Symbol - optional. If none is given the widget will be named "knob".

bounds

a Rect - optional. If none is given the widget will be created with a default size.

defaultActions

an Event holding 2 Functions - optional. By default the Event has to look like (lo: lofunction, hi: hifunction). The functions may be given as a Function or a String that compiles to one when interpret is called on it. If an argument is added to the functions it will provide the widget's CV. E.g.: { arg cv; cv.value.postln }

setup

optional - an Event containing the following optional keys in two separate Events -> (lo:(<setup-lo>), hi:(<setup-hi)):

midiMode
see CVWidget: -setMidiMode. default: 0
midiMean
see CVWidget: -setMidiMean. default: 64
midiResolution
see CVWidget: -setMidiResolution. default: 1
softWithin
see CVWidget: -setSoftWithin. default: 0.1
ctrlButtonBank
see CVWidget: -setCtrlButtonBank. default: nil
calibrate
see CVWidget: -setCalibrate. default: true
controllersAndModels

if a widget wraps a CV that has been created within some CVWidget the models and controllers of that other widget can be added here. CVWidget2D expects the parameters to be passed in in an Event containing the keys \lo and \hi: (lo: wdgtControllersAndModels-lo, hi: wdgtControlersAndModels-hi). However, it is not recommended to do so as there are specific methods that allow you to recreate widgets that have already been closed. See also CVWidget: -wdgtControllersAndModels.

cvcGui

a multi-purpose argument: usually you will not set anything here. It is used with the -open method resp. CVCenter. Within these it is used to pass in OSC-/MIDI-responders resp. the widgets MIDI-/OSC-environment. See also CVWidget: -midiOscEnv

persistent

if set to true the widget's OSC-/MIDI-responders will not be removed when the widget gets closed - default: nil

server

only used for SwingOSC compatability (untested)

Returns:

only used for SwingOSC compatability (untested) this (a CVWidget2D)

Inherited class methods

Instance Methods

.open(window, wdgtBounds)

If a widget has been created with the argument persistent set to true the user may reopen the widget with this method. This is basically a workaround due to the fact that GUIs in SuperCollider usually can't be opened again once they have been closed (even though executing the variable storing the the regarding object still returns the object). However, rather than reopening the old widget this method will create a new one, holding all properties, the CV and MIDI-/OSC-responders. In order to make this work as desired one should apply the following syntax where x holds the instance of the initially created widget:

x = x.open // the old widget was stored in x which will afterwards hold the new widget

See example in CVWidget: reusable_widgets

Arguments:

window

a Window or nil - if none is provided the window will be created internally

wdgtBounds

a Rect or nil - if none is provided the bounds of the old widget will be used.

Returns:

a CVWidget2D

GUI-elements

WARNING: Opposite to CVWidgetKnob many elements of the GUI are returned as Events containing a \lo and a \hi element. Basically all of the following elements are getters but not setters. However, it is possible to change the value returned in \lo or \hi as they are simply values within an Event - do not attempt to do so or unexpected things will happen!

.slider2d

The Slider2D on the top of the left side of the widget. It allows the user to set two values at once. The horizontal axis of the slider represents the value of widgetCV.lo, the vertical axis the value of widgetCV.hi.

Returns:

.rangeSlider

The RangeSlider on the bottom of the Slider2D. It allows the user to set two values at once. The left end of the bar represents the the value of widgetCV.lo, the right end the value of widgetCV.hi.

Returns:

.numVal

An Event containing two NumberBoxes, displaying or setting the current value of the widget's CVs.

Returns:

an Event

.specBut

An Event containing two Buttons, linking to the regarding spec-tab within the widget's editor ( \lo or \hi) (see also: CVWidgetEditor)

Returns:

an Event

.midiHead

An Event containing two Buttons linking to the regarding MIDI-tab within the widget's editor ( \lo or \hi) (see also: CVWidgetEditor)

Returns:

an Event

.midiLearn

An Event containing two Buttons ( \lo or \hi) that, if clicked, either triggers the MIDI-learn functionality (button-label: "L") or creates a CCResponder for the values entered in -midiSrc, -midiChan or/and -midiCtrl (button-label: "C"). If a CCResponder is present the button-label gets changed to "X" - upon clicking the responder gets removed again.

Returns:

an Event

.midiSrc

An Event containing two TextFields ( \lo and \hi), each displaying the ID of a connected MIDI-device. If no CCResponder is present one may enter the ID of a device (if known) and when clicking the -midiLearn button the widget will create a CCResponder listening to that device.

Returns:

an Event

.midiChan

An Event containing two TextFields ( \lo and \hi), each displaying the channel for an existing CCResponder or, if none is present, one may use this field to set the channel for which the CCResponder shall be created.

Returns:

an Event

.midiCtrl

An Event containing two TextFields ( \lo and \hi), each displaying the controller-number of an existing CCResponder or, if none is present, one may use this field to set the controller-number for which the CCResponder shall be created.

NOTE: SuperCollider numbers hardware-controllers internally beginning with 0 - if 0 gets entered here the controller will be displayed as 1 as most devices will probably number their knobs and sliders beginning with 1. Also, the way controller-numbers are displayed is related to the ctrlButtonBank setting which can be set with CVWidget: -setCtrlButtonBank

Returns:

an Event

.oscEditBut

An Event containing two Buttons ( \lo and \hi) that link to the widget's OSC-tabs within the regarding CVWidgetEditor. If an OSCresponder is present, the button-label will display the command-name, the message-slot and the current OSC-mapping (if the button is big enough to display all this information - mapping can be \linlin, \linexp, \explin or \expexp).

Returns:

an Event

.calibBut

An Event containing two Buttons that link to the OSC-tabs within the regarding CVWidgetEditor, displaying the current calibration-status.

Returns:

an Event

.actionsBut

An Event containing two Buttons, each linking to the actions-tab within the widget's regarding CVWidgetEditors. The button displays the number of active actions resp. existing actions in total.

Returns:

an Event

.background

.background = color

From superclass: CVWidget

Get or set the background-color of the widget. Tne setter for this method is implemented within CVWidgetMS while the getter is implemented as a global getter for all CVWidgets in CVWidget.

Arguments:

color

a Color

Returns:

a Color (getter) or this (a CVWidgetMS) (setter)

.stringColor

.stringColor = color

From superclass: CVWidget

Get or set the string-color of the widget. Tne setter for this method is implemented within CVWidgetMS while the getter is implemented as a global getter for all CVWidgets in CVWidget.

Arguments:

color

a Color

Returns:

a Color (getter) or this (a CVWidgetMS) (setter)

Inherited instance methods

Undocumented instance methods

.size

Examples

See examples in CVWidget: examples