Values and messages¶
Value
dataclass
¶
One entry of a control's <values>: its live state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
|
'touch'
|
locked
|
bool
|
Whether the value is locked against user interaction. |
False
|
locked_default_current
|
bool
|
Whether the lock holds the current value rather than the default. |
False
|
default
|
bool | float | str
|
The value the control starts at. |
False
|
default_pull
|
int
|
How strongly the value returns to its default, 0 to 100. |
0
|
Source code in src/py2tosc/messages.py
Messages¶
OscMessage
dataclass
¶
An OSC binding.
The default sends the control's x value to /<control name> on every
change, over every connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the binding is active. |
True
|
send
|
bool
|
Whether the control transmits. |
True
|
receive
|
bool
|
Whether the control accepts incoming messages. |
True
|
feedback
|
bool
|
Whether received messages are echoed back. |
False
|
no_duplicates
|
bool
|
Whether to suppress repeated identical messages. |
False
|
connections
|
str
|
One character per connection slot, |
ALL_CONNECTIONS
|
triggers
|
list[Trigger]
|
What causes the message to be sent. |
_default_triggers()
|
path
|
list[Partial]
|
The partials that build the OSC address. |
_default_path()
|
arguments
|
list[Partial]
|
The partials that build the OSC arguments. |
_default_arguments()
|
Source code in src/py2tosc/messages.py
MidiMessage
dataclass
¶
A MIDI binding.
The default sends the control's x value as CC 0 on channel 0, scaled to
0-127.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the binding is active. |
True
|
send
|
bool
|
Whether the control transmits. |
True
|
receive
|
bool
|
Whether the control accepts incoming messages. |
True
|
feedback
|
bool
|
Whether received messages are echoed back. |
False
|
no_duplicates
|
bool
|
Whether to suppress repeated identical messages. |
False
|
connections
|
str
|
One character per connection slot, |
ALL_CONNECTIONS
|
triggers
|
list[Trigger]
|
What causes the message to be sent. |
_default_triggers()
|
message
|
MidiCommand
|
The status bytes to send. |
MidiCommand()
|
values
|
list[MidiValue]
|
The three slots the data bytes are drawn from. |
_default_midi_values()
|
Source code in src/py2tosc/messages.py
LocalMessage
dataclass
¶
A binding to another control in the same layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the binding is active. |
True
|
triggers
|
list[Trigger]
|
What causes the message to be sent. |
_default_triggers()
|
type
|
PartialType | str
|
Where the sent content comes from. |
VALUE
|
conversion
|
Conversion | str
|
The type the content is converted to. |
FLOAT
|
value
|
str
|
The value or property key to read. |
'x'
|
scale_min
|
float
|
Low end of the output range. |
0
|
scale_max
|
float
|
High end of the output range. |
1
|
dst_type
|
str
|
The type expected by the destination. |
''
|
dst_var
|
str
|
The value or property to write on the destination. |
''
|
dst_id
|
str
|
The |
''
|
Source code in src/py2tosc/messages.py
GamepadMessage
dataclass
¶
A binding to a game controller button or axis.
Unlike the other three, a gamepad binding is one-directional and carries no triggers: the controller drives the control, so there is nothing to send.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the binding is active. |
True
|
connections
|
str
|
One character per gamepad slot, |
ALL_GAMEPADS
|
type
|
str
|
The button or axis, for example |
'BUTTON_A'
|
conversion
|
Conversion | str
|
The type the input is converted to. |
FLOAT
|
scale_min
|
float
|
Low end of the output range. |
0
|
scale_max
|
float
|
High end of the output range. |
1
|
target_type
|
PartialType | str
|
Whether the input drives a value or a property. |
VALUE
|
target_var
|
str
|
The value or property to write on this control. |
'x'
|
Source code in src/py2tosc/messages.py
Message
module-attribute
¶
Any binding type a control can carry.
Connection fields¶
A binding carries one character per connection slot, 1 for enabled. The two
constants below are the "all of them" value for each width, and are the
defaults on the message types above.
Message parts¶
Trigger
dataclass
¶
A condition under which a message is sent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
The value that is watched, usually |
'x'
|
condition
|
TriggerCondition | str
|
Whether to fire on any change, or only on a rise or fall. |
ANY
|
Source code in src/py2tosc/messages.py
Partial
dataclass
¶
One segment of an OSC address or one OSC argument.
An address like /synth/cutoff is built from partials: a CONSTANT /,
then a PROPERTY naming the control, and so on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
PartialType | str
|
Where the segment's content comes from. |
CONSTANT
|
conversion
|
Conversion | str
|
The type the segment is converted to before sending. |
STRING
|
value
|
str
|
The constant text, property key or value key, depending on |
'/'
|
scale_min
|
float
|
Low end of the output range, for |
0
|
scale_max
|
float
|
High end of the output range, for |
1
|
Source code in src/py2tosc/messages.py
MidiCommand
dataclass
¶
The <message> inside a MIDI binding: the status bytes to send.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
MidiType | str
|
The MIDI status byte. |
CONTROLCHANGE
|
channel
|
int
|
MIDI channel, 0-15. |
0
|
data1
|
int
|
First data byte, for example the CC number. |
0
|
data2
|
int
|
Second data byte. |
0
|
Source code in src/py2tosc/messages.py
MidiValue
dataclass
¶
One of the three slots a MIDI message draws its bytes from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
PartialType | str
|
|
CONSTANT
|
key
|
str
|
The value or property key, when |
''
|
scale_min
|
float
|
Low end of the output range. |
0
|
scale_max
|
float
|
High end of the output range. |
15
|