def __init__(self, children=None, name=None): from supriya.tools import servertools Node.__init__(self, name=name) self._children = [] self._control_interface = servertools.GroupInterface(client=self) self._named_children = {} if children is not None: self[:] = children
def allocate( self, add_action=None, node_id_is_permanent=False, sync=False, target_node=None, ): # TODO: Handle AddAction.REPLACE un-allocation of target node from supriya.tools import requesttools from supriya.tools import servertools if self.is_allocated: return add_action, node_id, target_node_id = Node.allocate( self, add_action=add_action, node_id_is_permanent=node_id_is_permanent, target_node=target_node, ) group_new_request = requesttools.GroupNewRequest( add_action=add_action, node_id=node_id, target_node_id=target_node_id, ) nodes, paused_nodes, requests, synthdefs = \ self._collect_requests_and_synthdefs(self) if self.is_paused: paused_nodes.add(self) requests.insert(0, group_new_request) if synthdefs: self._allocate_synthdefs(synthdefs) if paused_nodes: pairs = sorted((node.node_id, False) for node in paused_nodes) request = requesttools.NodeRunRequest( node_id_run_flag_pairs=pairs, ) requests.append(request) if 1 < len(requests): message_bundler = servertools.MessageBundler( server=self.server, sync=True, ) message_bundler.add_messages(requests) message_bundler.add_synchronizing_request(group_new_request) message_bundler.send_messages() else: group_new_request.communicate( server=self.server, sync=True, ) return self
def __init__( self, synthdef=None, name=None, register_controls=None, **kwargs ): from supriya.tools import servertools from supriya.tools import synthdeftools assert isinstance(synthdef, synthdeftools.SynthDef) Node.__init__( self, name=name, ) self._synthdef = synthdef self._control_interface = servertools.SynthInterface( client=self, synthdef=self._synthdef, ) if register_controls is not None: register_controls = bool(register_controls) self._register_controls = register_controls self._control_interface._set(**kwargs)
def allocate( self, add_action=None, node_id_is_permanent=False, sync=True, target_node=None, **kwargs ): from supriya.tools import requesttools from supriya.tools import servertools if self.is_allocated: return add_action, node_id, target_node_id = Node.allocate( self, add_action=add_action, node_id_is_permanent=node_id_is_permanent, target_node=target_node, ) if not self.synthdef.is_allocated: self.synthdef.allocate() self.controls._set(**kwargs) requests = [] settings, map_requests = self.controls._make_synth_new_settings() synth_request = requesttools.SynthNewRequest( add_action=add_action, node_id=node_id, synthdef=self.synthdef, target_node_id=target_node_id, **settings ) requests.append(synth_request) requests.extend(map_requests) if self.is_paused: pause_request = requesttools.NodeRunRequest( [(self.node_id, False)]) requests.append(pause_request) if 1 < len(requests): message_bundler = servertools.MessageBundler( server=self.server, sync=True, ) message_bundler.add_messages(requests) message_bundler.add_synchronizing_request(synth_request) message_bundler.send_messages() else: synth_request.communicate( server=self.server, sync=True, ) return self
def __init__( self, synthdef=None, name=None, register_controls=None, **kwargs ): from supriya import synthdefs from supriya.tools import servertools from supriya.tools import synthdeftools assert isinstance(synthdef, synthdeftools.SynthDef) Node.__init__( self, name=name, ) self._synthdef = synthdef or synthdefs.synthdef self._control_interface = servertools.SynthInterface( client=self, synthdef=self._synthdef, ) if register_controls is not None: register_controls = bool(register_controls) self._register_controls = register_controls self._control_interface._set(**kwargs)
def free(self): for node in self: node._unregister_with_local_server() Node.free(self) return self
def _unregister_with_local_server(self): for child in self: child._unregister_with_local_server() return Node._unregister_with_local_server(self)
def free(self): Node.free(self)
def _unregister_with_local_server(self): node_id = Node._unregister_with_local_server(self) if 'gate' in self.controls: self['gate'].reset() return node_id