CsoundUnity 4.0.0-alpha.3
Loading...
Searching...
No Matches
Csound.Unity.CsoundChannelController Class Reference

Utility class for controller and channels. More...

Public Member Functions

void SetRange (float uMin, float uMax, float uValue=0f, float uSkew=1f, float uIncrement=0.001f)
 Sets the numeric range and default value for this channel controller.
MYFLT ToCsoundValue (float rawValue)
 Converts an arbitrary 0-based value to Csound's terms using this controller's type. For a value that is not value — one that was blended or morphed.
bool IsOutOfRange (float rawValue)
 Whether a stored value falls outside the range this csd declares for the channel.
bool IsOutOfRange ()
 Whether this controller's own value falls outside its range.
void SetFromCsoundValue (MYFLT csoundValue)
 Stores a value that came from Csound, undoing CsoundValue.
CsoundChannelController Clone ()
 Returns a copy of this CsoundChannelController.

Public Attributes

string type
 Widget type string parsed from the CSD (e.g. "slider", "button", "combobox", "xypad").
string channel
 The Csound channel name used with chnget/chnset.
string text
 Display label text for this widget.
string caption
 Caption (tooltip) text for this widget.
float min
 Minimum value of the channel range.
float max
 Maximum value of the channel range.
float value
 Current or initial value of the channel.
float skew
 Skew factor for non-linear mapping (1 = linear).
float increment
 Discrete step size for sliders with snap increments.
string[] options
 The entries of a combobox, in the order the csd lists them. A preset stores which entry is selected, not their names: this array is replaced whole whenever a csd is parsed.
bool zeroBasedOptions
 Whether this widget's option list counts from zero on the way to Csound.
string channelY
 Second channel name. Used by xypad for the Y axis channel.
float minY
 Y axis minimum value. Used by xypad.
float maxY
 Y axis maximum value. Used by xypad.
float value2
 Initial Y value. Used by xypad (rangeY third token).
int x
 Horizontal position in pixels, from the Cabbage bounds() attribute.
int y
 Vertical position in pixels, from the Cabbage bounds() attribute.
int width
 Width in pixels, from the Cabbage bounds() attribute.
int height
 Height in pixels, from the Cabbage bounds() attribute.

Properties

bool IsCombobox [get]
 True when this controller describes a Cabbage combobox.
bool HasSecondValue [get]
 True when this controller carries a second value on channelY: xypad, hrange and vrange. The name is the test, not the type — the parser fills channelY exactly for the widgets that have one.
bool IsContinuous [get]
 True when this channel holds a number to slide through rather than a state to switch, so interpolating it means something: the sliders and the two-value widgets.
MYFLT CsoundValue [get]
 The value in Csound's terms. A Cabbage 2 combobox counts from 1, 0 meaning "no selection", while value holds the 0-based index Unity's dropdowns use, so it reads back one higher; a widget with zeroBasedOptions counts from 0 at both ends and is passed through. Every path that writes a channel to Csound goes through here, so the convention lives in one place instead of being restated at each call site.

Detailed Description

Utility class for controller and channels.

Member Function Documentation

◆ Clone()

CsoundChannelController Csound.Unity.CsoundChannelController.Clone ( )
inline

Returns a copy of this CsoundChannelController.

Memberwise, so the copy points at the same options array. That is sound for what those are: see the field.

Returns
A copy of this controller.

◆ IsOutOfRange() [1/2]

bool Csound.Unity.CsoundChannelController.IsOutOfRange ( )
inline

Whether this controller's own value falls outside its range.

Returns
true when value lands outside the range.

◆ IsOutOfRange() [2/2]

bool Csound.Unity.CsoundChannelController.IsOutOfRange ( float rawValue)
inline

Whether a stored value falls outside the range this csd declares for the channel.

The range is written in Csound's terms, so the value goes through ToCsoundValue before it is compared. A range of zero width is a channel with no range to speak of, and everything fits inside it.

Parameters
rawValueA value in the same terms as value.
Returns
true when the value lands outside the range, false when the range has no width.

◆ SetFromCsoundValue()

void Csound.Unity.CsoundChannelController.SetFromCsoundValue ( MYFLT csoundValue)
inline

Stores a value that came from Csound, undoing CsoundValue.

Parameters
csoundValueThe value as Csound holds it.

◆ SetRange()

void Csound.Unity.CsoundChannelController.SetRange ( float uMin,
float uMax,
float uValue = 0f,
float uSkew = 1f,
float uIncrement = 0::001f )
inline

Sets the numeric range and default value for this channel controller.

Parameters
uMinMinimum value.
uMaxMaximum value.
uValueInitial/default value.
uSkewSkew factor for non-linear mapping (1 = linear).
uIncrementStep size for discrete increments.

◆ ToCsoundValue()

MYFLT Csound.Unity.CsoundChannelController.ToCsoundValue ( float rawValue)
inline

Converts an arbitrary 0-based value to Csound's terms using this controller's type. For a value that is not value — one that was blended or morphed.

Parameters
rawValueA value in the same terms as value.
Returns
The value as Csound expects it: a Cabbage 2 combobox counts from 1, everything else is unchanged.

Member Data Documentation

◆ caption

string Csound.Unity.CsoundChannelController.caption

Caption (tooltip) text for this widget.

◆ channel

string Csound.Unity.CsoundChannelController.channel

The Csound channel name used with chnget/chnset.

◆ channelY

string Csound.Unity.CsoundChannelController.channelY

Second channel name. Used by xypad for the Y axis channel.

◆ height

int Csound.Unity.CsoundChannelController.height

Height in pixels, from the Cabbage bounds() attribute.

◆ increment

float Csound.Unity.CsoundChannelController.increment

Discrete step size for sliders with snap increments.

◆ max

float Csound.Unity.CsoundChannelController.max

Maximum value of the channel range.

◆ maxY

float Csound.Unity.CsoundChannelController.maxY

Y axis maximum value. Used by xypad.

◆ min

float Csound.Unity.CsoundChannelController.min

Minimum value of the channel range.

◆ minY

float Csound.Unity.CsoundChannelController.minY

Y axis minimum value. Used by xypad.

◆ options

string [] Csound.Unity.CsoundChannelController.options

The entries of a combobox, in the order the csd lists them. A preset stores which entry is selected, not their names: this array is replaced whole whenever a csd is parsed.

◆ skew

float Csound.Unity.CsoundChannelController.skew

Skew factor for non-linear mapping (1 = linear).

◆ text

string Csound.Unity.CsoundChannelController.text

Display label text for this widget.

◆ type

string Csound.Unity.CsoundChannelController.type

Widget type string parsed from the CSD (e.g. "slider", "button", "combobox", "xypad").

◆ value

float Csound.Unity.CsoundChannelController.value

Current or initial value of the channel.

◆ value2

float Csound.Unity.CsoundChannelController.value2

Initial Y value. Used by xypad (rangeY third token).

◆ width

int Csound.Unity.CsoundChannelController.width

Width in pixels, from the Cabbage bounds() attribute.

◆ x

int Csound.Unity.CsoundChannelController.x

Horizontal position in pixels, from the Cabbage bounds() attribute.

◆ y

int Csound.Unity.CsoundChannelController.y

Vertical position in pixels, from the Cabbage bounds() attribute.

◆ zeroBasedOptions

bool Csound.Unity.CsoundChannelController.zeroBasedOptions

Whether this widget's option list counts from zero on the way to Csound.

Cabbage 2 sends 1 for the first entry of a combobox, and that is what the field's default keeps, so every preset and scene written before this reads as it did. Cabbage 3 sends 0 for the first entry, and a csd written for it expects the orchestra to read the index it declared, so its parser sets this.

Property Documentation

◆ CsoundValue

MYFLT Csound.Unity.CsoundChannelController.CsoundValue
get

The value in Csound's terms. A Cabbage 2 combobox counts from 1, 0 meaning "no selection", while value holds the 0-based index Unity's dropdowns use, so it reads back one higher; a widget with zeroBasedOptions counts from 0 at both ends and is passed through. Every path that writes a channel to Csound goes through here, so the convention lives in one place instead of being restated at each call site.

◆ HasSecondValue

bool Csound.Unity.CsoundChannelController.HasSecondValue
get

True when this controller carries a second value on channelY: xypad, hrange and vrange. The name is the test, not the type — the parser fills channelY exactly for the widgets that have one.

◆ IsCombobox

bool Csound.Unity.CsoundChannelController.IsCombobox
get

True when this controller describes a Cabbage combobox.

◆ IsContinuous

bool Csound.Unity.CsoundChannelController.IsContinuous
get

True when this channel holds a number to slide through rather than a state to switch, so interpolating it means something: the sliders and the two-value widgets.

A button, a checkbox or a combobox has no meaningful halfway point, which is why those are snapped instead — see CsoundUnity.DiscreteChannelMode.


The documentation for this class was generated from the following file: