sc3nb.sc_objects.node
Implements Node and subclasses Synth and Group.
Module Contents
Class List
Replies of Group Commands |
|
OSC Commands for Groups |
|
OSC Commands for Synths |
|
Replies of Node Commands |
|
OSC Commands for Nodes |
|
AddAction of SuperCollider nodes. |
|
Information about the Synth from /n_info |
|
Information about the Group from /n_info |
|
Representation of a Node on SuperCollider. |
|
Representation of a Synth on SuperCollider. |
|
Representation of a Group on SuperCollider. |
|
Node Tree is a class for parsing /g_queryTree.reply |
Content
- class sc3nb.sc_objects.node.GroupReply[source]
-
Replies of Group Commands
Initialize self. See help(type(self)) for accurate signature.
- class sc3nb.sc_objects.node.GroupCommand[source]
-
OSC Commands for Groups
Initialize self. See help(type(self)) for accurate signature.
- class sc3nb.sc_objects.node.SynthCommand[source]
-
OSC Commands for Synths
Initialize self. See help(type(self)) for accurate signature.
- class sc3nb.sc_objects.node.NodeReply[source]
-
Replies of Node Commands
Initialize self. See help(type(self)) for accurate signature.
- class sc3nb.sc_objects.node.NodeCommand[source]
-
OSC Commands for Nodes
Initialize self. See help(type(self)) for accurate signature.
- class sc3nb.sc_objects.node.AddAction[source]
Bases:
enum.EnumAddAction of SuperCollider nodes.
This Enum contains the codes for the different ways to add a node.
- class sc3nb.sc_objects.node.SynthInfo[source]
Bases:
NamedTupleInformation about the Synth from /n_info
- class sc3nb.sc_objects.node.GroupInfo[source]
Bases:
NamedTupleInformation about the Group from /n_info
- class sc3nb.sc_objects.node.Node(*, nodeid: Optional[int] = None, add_action: Optional[Union[AddAction, int]] = None, target: Optional[Union[Node, int]] = None, server: Optional[sc3nb.sc_objects.server.SCServer] = None)[source]
Bases:
abc.ABCRepresentation of a Node on SuperCollider.
Create a new Node
- Parameters:
- nodeidint or None
This Nodes node id or None
- add_actionAddAction or corresponding int, optional
This Nodes AddAction when created in Server, by default None
- targetNode or int or None, optional
This Nodes AddActions target, by default None
- serverSCServer, optional
The Server for this Node, by default use the SC default server
Overview:
Create a new Node
Derive Node group from addaction and target
Free the node with /n_free.
Turn node on or off with /n_run.
Set a control value(s) of the node with n_set.
Fill ranges of control values with n_fill.
Map a node's control to read from a bus using /n_map or /n_mapa.
Set gate as specified.
Sends an n_query message to the server.
Trace a node.
Move this node
Register to be watched.
Unregister to stop being watched.
Callback that is executed when this Synth is freed
Wait until this Node is freed
Return self==value.
Get the corresponding node id
- abstract new(*args, add_action: Optional[Union[AddAction, int]] = None, target: Optional[Union[Node, int]] = None, return_msg: bool = False, **kwargs) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Create a new Node
- Parameters:
- add_actionAddAction or int, optional
Where the Node should be added, by default AddAction.TO_HEAD (0)
- targetNode or int, optional
AddAction target, if None it will be the default group of the server
- _set_node_attrs(target: Optional[Union[Node, int]] = None, add_action: Optional[Union[AddAction, int]] = None) None[source]
Derive Node group from addaction and target
- Parameters:
- targetint or Node
Target nodeid or Target Node of this Node’s AddAction
- add_actionAddAction
AddAction of this Node, default AddAction.TO_HEAD (0)
- free(return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Free the node with /n_free.
This will set is_running and is_playing to false. Even when the message is returned to mimic the behavior of the SuperCollider Node See https://doc.sccode.org/Classes/Node.html#-freeMsg
- Returns:
- Node or OSCMessage
self for chaining or OSCMessage when return_msg=True
- run(on: bool = True, return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Turn node on or off with /n_run.
- Parameters:
- onbool
True for on, False for off, by default True
- Returns:
- Node or OSCMessage
self for chaining or OSCMessage when return_msg=True
- set(argument: Union[str, Dict, List], *values: Any, return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Set a control value(s) of the node with n_set.
- Parameters:
- argumentstr | dict | list
if string: name of control argument if dict: dict with argument, value pairs if list: use list as message content
- valueany, optional
only used if argument is string, by default None
Examples
>>> synth.set("freq", 400) >>> synth.set({"dur": 1, "freq": 400}) >>> synth.set(["dur", 1, "freq", 400])
- fill(control: Union[str, int], num_controls: int, value: Any, return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Fill ranges of control values with n_fill.
- Parameters:
- controlint or string
control index or name
- num_controlsint
number of control values to fill
- valuefloat or int
value to set
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- OSCMessage
if return_msg else self
- map(control: Union[str, int], bus: sc3nb.sc_objects.bus.Bus, return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Map a node’s control to read from a bus using /n_map or /n_mapa.
- Parameters:
- controlint or string
control index or name
- busBus
control/audio bus
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- OSCMessage
if return_msg else self
- release(release_time: Optional[float] = None, return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Set gate as specified.
https://doc.sccode.org/Classes/Node.html#-release
- Parameters:
- release_timefloat, optional
amount of time in seconds during which the node will release. If set to a value <= 0, the synth will release immediately. If None using its Envs normal release stage(s)
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- OSCMessage
if return_msg else self
- query() Union[SynthInfo, GroupInfo][source]
Sends an n_query message to the server.
The answer is send to all clients who have registered via the /notify command. Content of answer:
node ID the node’s parent group ID previous node ID, -1 if no previous node. next node ID, -1 if no next node. 1 if the node is a group, 0 if it is a synth
- if the node is a group:
ID of the head node, -1 if there is no head node. ID of the tail node, -1 if there is no tail node.
- Returns:
- SynthInfo or GroupInfo
n_info answer. See above for content description
- trace(return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Trace a node.
Print out values of the inputs and outputs for one control period. If node is a group then print the node IDs and names of each node.
- Parameters:
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- Node or OSCMessage
if return_msg else self
- move(add_action: AddAction, another_node: Node, return_msg: bool = False) Union[Node, sc3nb.osc.osc_communication.OSCMessage][source]
Move this node
- Parameters:
- add_actionAddAction [TO_HEAD, TO_TAIL, AFTER, BEFORE]
What add action should be done.
- another_nodeNode
The node which is the target of the add action
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- Node or OSCMessage
if return_msg this will be the OSCMessage, else self
- Raises:
- ValueError
If a wrong AddAction was provided
- wait(timeout: Optional[float] = None) None[source]
Wait until this Node is freed
- Raises:
- TimeoutError
If timeout was provided and wait timed out.
- class sc3nb.sc_objects.node.Synth(name: Optional[str] = None, controls: Dict[str, Any] = None, *, nodeid: Optional[int] = None, new: bool = True, add_action: Optional[Union[AddAction, int]] = None, target: Optional[Union[Node, int]] = None, server: Optional[sc3nb.sc_objects.server.SCServer] = None)[source]
Bases:
NodeRepresentation of a Synth on SuperCollider.
Create a Python representation of a SuperCollider synth.
- Parameters:
- namestr, optional
name of the synth to be created, by default “default”
- controlsdict, optional
synth control arguments, by default None
- nodeidint, optional
ID of the node in SuperCollider, by default sc3nb will create one. Can be set to an existing id to create a Python instance of a running Node.
- newbool, optional
True if synth should be created on the server, by default True Should be False if creating an instance of a running Node.
- add_actionAddAction or int, optional
Where the Synth should be added, by default AddAction.TO_HEAD (0)
- targetNode or int, optional
AddAction target, if None it will be the default group of the server
- serverSCServer
sc3nb SCServer instance
- Raises:
- ValueError
Raised when synth can’t be found via SynthDescLib.global
Examples
>>> scn.Synth(sc, "s1", {"dur": 1, "freq": 400})
Overview:
Creates the synth on the server with s_new.
Get a Synth argument
Set part of an arrayed control.
Implement setattr(self, name, value).
Return repr(self).
- new(controls: Optional[dict] = None, add_action: Optional[Union[AddAction, int]] = None, target: Optional[Union[Node, int]] = None, *, return_msg: bool = False) Union[Synth, sc3nb.osc.osc_communication.OSCMessage][source]
Creates the synth on the server with s_new.
Attention: Here you create an identical synth! Same nodeID etc. - This will fail if there is already this nodeID on the SuperCollider server!
- class sc3nb.sc_objects.node.Group(*, nodeid: Optional[int] = None, new: bool = True, parallel: bool = False, add_action: AddAction = AddAction.TO_HEAD, target: Optional[Union[Node, int]] = None, server: Optional[sc3nb.sc_objects.server.SCServer] = None)[source]
Bases:
NodeRepresentation of a Group on SuperCollider.
Create a Python representation of a SuperCollider group.
- Parameters:
- nodeidint, optional
ID of the node in SuperCollider, by default sc3nb will create one. Can be set to an existing id to create a Python instance of a running Node.
- newbool, optional
True if synth should be created on the server, by default True Should be False if creating an instance of a running Node.
- parallelbool, optional
If True create a parallel group, by default False
- add_actionAddAction or int, optional
Where the Group should be added, by default AddAction.TO_HEAD (0)
- targetNode or int, optional
AddAction target, if None it will be the default group of the server
- serverSCServer, optional
Server instance where this Group is located, by default use the SC default server
Overview:
Creates the synth on the server with g_new / p_new.
Move node to this groups head with g_head.
Move node to this groups tail with g_tail.
Frees all nodes in the group with g_freeAll.
Free all synths in this group and its sub-groups with g_deepFree.
Posts a representation of this group's node subtree with g_dumpTree.
Send a g_queryTree message for this group.
Return repr(self).
- new(add_action=AddAction.TO_HEAD, target=None, *, parallel=None, return_msg=False) Union[Group, sc3nb.osc.osc_communication.OSCMessage][source]
Creates the synth on the server with g_new / p_new.
Attention: Here you create an identical group! Same nodeID etc. - This will fail if there is already this nodeID on the SuperCollider server!
- Parameters:
- add_actionAddAction or int, optional
where the group should be added, by default AddAction.TO_HEAD (0)
- targetNode or int, optional
add action target, by default 1
- parallelbool, optional
If True use p_new, by default False
- return_msgbool, optional
If ture return the OSCMessage instead of sending it, by default False
- Returns:
- Group
self
- move_node_to_head(node, return_msg=False)[source]
Move node to this groups head with g_head.
- Parameters:
- nodeNode
node to move
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- Group
self
- move_node_to_tail(node, return_msg=False)[source]
Move node to this groups tail with g_tail.
- Parameters:
- nodeNode
node to move
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- Group
self
- free_all(return_msg=False)[source]
Frees all nodes in the group with g_freeAll.
- Parameters:
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- OSCMessage
if return_msg else self
- deep_free(return_msg=False)[source]
Free all synths in this group and its sub-groups with g_deepFree.
Sub-groups are not freed.
- Parameters:
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- OSCMessage
if return_msg else self
- dump_tree(post_controls=True, return_msg=False)[source]
Posts a representation of this group’s node subtree with g_dumpTree.
- Parameters:
- post_controlsbool, optional
True for control values, by default False
- return_msgbool, optional
If True return msg else send it directly, by default False
- Returns:
- OSCMessage
if return_msg else self
- query_tree(include_controls=False) Group[source]
Send a g_queryTree message for this group.
See https://doc.sccode.org/Reference/Server-Command-Reference.html#/g_queryTree for details.
- Parameters:
- include_controlsbool, optional
True for control values, by default False
- Returns:
- tuple
/g_queryTree.reply
- class sc3nb.sc_objects.node.NodeTree(info: Sequence[Any], root_nodeid: int, controls_included: bool, start: int = 0, server: Optional[sc3nb.sc_objects.server.SCServer] = None)[source]
Node Tree is a class for parsing /g_queryTree.reply
Overview:
Parse Nodes from reply of the /g_queryTree cmd of scsynth.
- static parse_nodes(info: Sequence[Any], controls_included: bool = True, start: int = 0, server: Optional[sc3nb.sc_objects.server.SCServer] = None) Tuple[int, Node][source]
Parse Nodes from reply of the /g_queryTree cmd of scsynth. This reads the /g_queryTree.reply and creates the corresponding Nodes in Python. See https://doc.sccode.org/Reference/Server-Command-Reference.html#/g_queryTree
- Parameters:
- controls_includedbool
If True the current control (arg) values for synths will be included
- startint
starting position of the parsing, used for recursion, default 0
- infoSequence[Any]
/g_queryTree.reply to be parsed.
- Returns:
- Tuple[int, Node]
postion where the parsing ended, resulting Node