def allocate(self): from supriya.tools import osctools from supriya.tools import servertools self._input_meter_callback = osctools.OscCallback( address_pattern=self.input_meter_command, procedure=self._handle_input_levels, ) self._output_meter_callback = osctools.OscCallback( address_pattern=self.output_meter_command, procedure=self._handle_output_levels, ) self.server.register_osc_callback(self._input_meter_callback) self.server.register_osc_callback(self._output_meter_callback) input_meter_synthdef = self.input_meter_synthdef output_meter_synthdef = self.output_meter_synthdef self._input_meter_synth = servertools.Synth( input_meter_synthdef, ) self._output_meter_synth = servertools.Synth( output_meter_synthdef, ) self._input_meter_synth.allocate( add_action=servertools.AddAction.ADD_TO_HEAD, node_id_is_permanent=True, target_node=self.server.root_node, ) self._output_meter_synth.allocate( add_action=servertools.AddAction.ADD_TO_TAIL, node_id_is_permanent=True, target_node=self.server.root_node, ) return self
def test_01(self): group_a = servertools.Group() group_a.allocate() synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b = servertools.Group() group_a.append(group_b) synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) group_c = servertools.Group() group_b.append(group_c) synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group 1006 test ''', ), server_state assert group_a not in group_a assert group_b in group_a assert group_c not in group_a assert synth_a in group_a assert synth_b not in group_a assert synth_c not in group_a assert synth_d in group_a assert group_a not in group_b assert group_b not in group_b assert group_c in group_b assert synth_a not in group_b assert synth_b in group_b assert synth_c in group_b assert synth_d not in group_b assert group_a not in group_c assert group_b not in group_c assert group_c not in group_c assert synth_a not in group_c assert synth_b not in group_c assert synth_c not in group_c assert synth_d not in group_c
def test_01(self): group_a = servertools.Group() group_a.allocate() synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b = servertools.Group() group_a.append(group_b) synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) group_c = servertools.Group() group_b.append(group_c) synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group 1006 test ''', ), server_state assert [x for x in group_a] == [ synth_a, group_b, synth_d, ] assert [x for x in group_b] == [ synth_b, synth_c, group_c, ] assert [x for x in group_c] == []
def _setup_node(self): from supriya.tools import servertools synth = servertools.Synth(self.record_synthdef) synth.allocate( add_action=servertools.AddAction.ADD_TO_TAIL, target_node=self.server.root_node, node_id_is_permanent=True, ) self._record_node = synth
def test_01(self): group_a = servertools.Group() group_a.allocate() synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b = servertools.Group() group_a.append(group_b) synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 test ''', ), server_state assert group_a.index(synth_a) == 0 assert group_a.index(group_b) == 1 assert group_a.index(synth_d) == 2 assert group_b.index(synth_b) == 0 assert group_b.index(synth_c) == 1
def _build_start_bundle( self, dictionaries, first_visit, index, synth_uuid, synthdef, timestamp, uuids, ): from supriya.tools import patterntools requests = [] node_ids = uuids[synth_uuid] if first_visit: for node_id, dictionary in zip(node_ids, dictionaries): add_action = dictionary.pop('add_action') target_node = dictionary.pop('target_node') if target_node is None: target_node = 1 synth_kwargs = { key: value for key, value in dictionary.items() if key in synthdef.parameter_names } request = requesttools.SynthNewRequest( add_action=add_action, node_id=node_id, synthdef=synthdef, target_node_id=target_node, **synth_kwargs) requests.append(request) synth = servertools.Synth(synthdef) node_ids[node_id] = synth else: for node_id, dictionary in zip(node_ids, dictionaries): synth_kwargs = { key: value for key, value in dictionary.items() if key in synthdef.parameter_names } request = requesttools.NodeSetRequest(node_id=node_id, **synth_kwargs) requests.append(request) event_product = patterntools.EventProduct( event=self, index=index, is_stop=False, requests=requests, timestamp=timestamp, uuid=synth_uuid, ) return event_product
def _perform_realtime( self, index=0, server=None, timestamp=0, uuids=None, ): # TODO: Should this handle multichannel expansion? from supriya import synthdefs from supriya.tools import patterntools node_uuid = self.get('uuid') or uuid.uuid4() requests = [] synthdef = self.get('synthdef') or synthdefs.default if not self.get('is_stop'): target_node_id = self.get('target_node') if not target_node_id: target_node_id = 1 elif isinstance(target_node_id, uuid.UUID): target_node_id = list(uuids[target_node_id])[0] add_action = self.get('add_action') dictionaries = self._expand( self.settings, synthdef, uuids, realtime=False, synth_parameters_only=True, ) synths = uuids[node_uuid] = {} for dictionary in dictionaries: node_id = server.node_id_allocator.allocate_node_id() synth = servertools.Synth(synthdef, **dictionary) synths[node_id] = synth request = requesttools.SynthNewRequest( add_action=add_action, node_id=node_id, target_node_id=target_node_id, synthdef=synthdef, **dictionary) requests.append(request) else: request = requesttools.NodeFreeRequest(node_ids=sorted( uuids[node_uuid]), ) requests.append(request) event_product = patterntools.EventProduct( event=self, index=index, is_stop=self.get('is_stop'), requests=requests, timestamp=timestamp, uuid=self['uuid'], ) return [event_product]
def test_02(self): synth = servertools.Synth(synthdefs.test) synth['frequency'].set(443) synth['amplitude'].set(0.5) assert synth['frequency'].get() == 443 assert synth['amplitude'].get() == 0.5 synth.allocate() server_state = str( self.server.query_remote_nodes(include_controls=True)) assert server_state == stringtools.normalize( r''' NODE TREE 0 group 1 group 1000 test amplitude: 0.5, frequency: 443.0 ''', ) synth.free() assert synth['frequency'].get() == 443 assert synth['amplitude'].get() == 0.5 control_bus = servertools.Bus(0, calculation_rate='control') audio_bus = servertools.Bus(0, calculation_rate='audio') synth['frequency'].set(control_bus) synth['amplitude'].set(audio_bus) assert synth['frequency'].get() == control_bus assert synth['amplitude'].get() == audio_bus synth.allocate() server_state = str( self.server.query_remote_nodes(include_controls=True)) assert server_state == stringtools.normalize( r''' NODE TREE 0 group 1 group 1001 test amplitude: a0, frequency: c0 ''', ) synth.free() assert synth['frequency'].get() == control_bus assert synth['amplitude'].get() == audio_bus
def test_01(self): group = servertools.Group().allocate() assert len(group) == 0 remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), remote_state synth = servertools.Synth(synthdefs.test) assert synth.parent is None assert not synth.is_allocated group[:] = [synth] assert len(group) == 1 assert synth.parent is group assert synth in group assert synth.is_allocated remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test ''', ), remote_state group[:] = [] assert len(group) == 0 assert synth.parent is None assert synth not in group assert not synth.is_allocated remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), remote_state
def play(self, add_action=None, target_node=None, **kwargs): """ Plays the synthdef on the server. :: >>> from supriya.tools import servertools >>> from supriya.tools import synthdeftools >>> from supriya.tools import ugentools :: >>> server = servertools.Server() >>> server.boot() <Server: udp://127.0.0.1:57751, 8i8o> :: >>> ugen = ugentools.Out.ar(source=ugentools.SinOsc.ar() * 0.01) >>> synthdef = synthdeftools.SynthDef.from_ugens(ugen) >>> synth = synthdef.play() :: >>> server.quit() <Server: offline> """ from supriya.tools import servertools if target_node is not None: target_node = servertools.Node.expr_as_target(target_node) server = target_node.server else: server = servertools.Server.get_default_server() target_node = servertools.Node.expr_as_target(server) if not server.is_running: server.boot() if not self.is_allocated: self.allocate(server=server) self.server.sync() synth = servertools.Synth(self, **kwargs) synth.allocate( add_action=add_action, sync=True, target_node=target_node, ) return synth
def test__perform_realtime_02(self): node_uuid = uuid.uuid4() event = patterntools.SynthEvent( is_stop=True, uuid=node_uuid, ) server = types.SimpleNamespace( node_id_allocator=servertools.NodeIdAllocator(), ) uuids = { node_uuid: { 1000: servertools.Synth(synthdefs.default), }, } event_products = event._perform_realtime( server=server, timestamp=100.0, uuids=uuids, ) assert len(event_products) == 1 self.compare_strings( ''' supriya.tools.patterntools.EventProduct( event=supriya.tools.patterntools.SynthEvent( delta=0, is_stop=True, uuid=UUID('...'), ), index=0, is_stop=True, requests=[ supriya.tools.requesttools.NodeFreeRequest( node_ids=(1000,), ), ], timestamp=100.0, uuid=UUID('...'), ) ''', format(event_products[0]), )
def test_04(self): group_a = servertools.Group(name='Group A').allocate() group_b = servertools.Group(name='Group B').allocate() synth_a = servertools.Synth(synthdefs.test, name='Synth A') synth_b = servertools.Synth(synthdefs.test, name='Synth B') synth_c = servertools.Synth(synthdefs.test, name='Synth C') synth_d = servertools.Synth(synthdefs.test, name='Synth D') synth_e = servertools.Synth(synthdefs.test, name='Synth E') synth_f = servertools.Synth(synthdefs.test, name='Synth F') local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group ''', ), remote_state assert local_state == remote_state assert len(group_a) == 0 assert len(group_b) == 0 group_a[:] = [synth_a, synth_b] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group 1002 test 1003 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 2 assert len(group_b) == 0 group_a[:] = [synth_b, synth_a] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group 1003 test 1002 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 2 assert len(group_b) == 0 group_a[:] = [synth_c, synth_d, synth_b, synth_a] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group 1004 test 1005 test 1003 test 1002 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 4 assert len(group_b) == 0 group_b[1:-1] = [synth_c, synth_b] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1004 test 1003 test 1000 group 1005 test 1002 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 2 assert len(group_b) == 2 group_b[1:-1] = [synth_b, synth_c, synth_e] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1003 test 1004 test 1006 test 1000 group 1005 test 1002 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 2 assert len(group_b) == 3 group_a[:] = [synth_c, synth_f] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1003 test 1006 test 1000 group 1004 test 1007 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 2 assert len(group_b) == 2 group_a[:-1] = [synth_f] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1003 test 1006 test 1000 group 1007 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 1 assert len(group_b) == 2 group_b[len(group_b):] = [group_a] local_state = str(self.server.query_local_nodes()) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1003 test 1006 test 1000 group 1007 test ''', ), remote_state assert local_state == remote_state assert len(group_a) == 1 assert len(group_b) == 3
def test_02(self): group = servertools.Group().allocate() synth_a = servertools.Synth(synthdefs.test) synth_b = servertools.Synth(synthdefs.test) group[:] = [synth_a, synth_b] assert len(group) == 2 assert synth_a.parent is group assert synth_b.parent is group assert synth_a in group assert synth_b in group assert synth_a.is_allocated assert synth_b.is_allocated assert synth_a is group[0] assert synth_b is group[1] remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 test ''', ), remote_state group[:] = [synth_b, synth_a] assert len(group) == 2 assert synth_a.parent is group assert synth_b.parent is group assert synth_a in group assert synth_b in group assert synth_a.is_allocated assert synth_b.is_allocated assert synth_a is group[1] assert synth_b is group[0] remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1002 test 1001 test ''', ), remote_state group[:] = [] assert len(group) == 0 assert synth_a.parent is None assert synth_b.parent is None assert synth_a not in group assert synth_b not in group assert not synth_a.is_allocated assert not synth_b.is_allocated remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), remote_state
def test_01(self): group_a = servertools.Group() group_a.allocate(target_node=self.server) group_b = servertools.Group() group_b.allocate(target_node=self.server) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group ''', ), server_state synthdef = synthdefs.test assert not synthdef.is_allocated synth_a = servertools.Synth(synthdef) synth_b = servertools.Synth(synthdef) synth_c = servertools.Synth(synthdef) synth_d = servertools.Synth(synthdef) assert not synth_a.is_allocated assert not synth_b.is_allocated assert not synth_c.is_allocated assert not synth_d.is_allocated synth_a.allocate() server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1002 test 1001 group 1000 group ''', ), server_state group_a.extend([synth_a, synth_b]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group 1002 test 1003 test ''', ), server_state group_b.extend([synth_c]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1004 test 1000 group 1002 test 1003 test ''', ), server_state group_b.extend([synth_d, synth_b, synth_a]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1004 test 1005 test 1003 test 1002 test 1000 group ''', ), server_state
def test_06(self): group = servertools.Group() synth_a = servertools.Synth( name='Synth A', synthdef=synthdefs.test, ) synth_b = servertools.Synth( name='Synth B', synthdef=synthdefs.test, ) synth_b['amplitude'] = 0.5 synth_b['frequency'] = 443 audio_bus = servertools.Bus(0, 'audio') control_bus = servertools.Bus(1, 'control') synth_c = servertools.Synth( name='Synth C', synthdef=synthdefs.test, ) synth_c['amplitude'] = audio_bus synth_c['frequency'] = control_bus group[:] = [synth_a, synth_b, synth_c] group_state = str(group) assert systemtools.TestManager.compare( group_state, ''' ??? group ??? test (Synth A) amplitude: 1.0, frequency: 440.0 ??? test (Synth B) amplitude: 0.5, frequency: 443.0 ??? test (Synth C) amplitude: a0, frequency: c1 ''', ), group_state group.allocate() group_state = str(group) assert systemtools.TestManager.compare( group_state, ''' 1000 group 1001 test (Synth A) amplitude: 1.0, frequency: 440.0 1002 test (Synth B) amplitude: 0.5, frequency: 443.0 1003 test (Synth C) amplitude: a0, frequency: c1 ''', ), group_state remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: 1.0, frequency: 440.0 1002 test amplitude: 0.5, frequency: 443.0 1003 test amplitude: a0, frequency: c1 ''', ), remote_state synth_b['amplitude', 'frequency'] = 0.75, 880 synth_c['amplitude', 'frequency'] = control_bus, audio_bus remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: 1.0, frequency: 440.0 1002 test amplitude: 0.75, frequency: 880.0 1003 test amplitude: c1, frequency: a0 ''', ), remote_state group[:] = [synth_c, synth_b, synth_a] remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1003 test amplitude: c1, frequency: a0 1002 test amplitude: 0.75, frequency: 880.0 1001 test amplitude: 1.0, frequency: 440.0 ''', ), remote_state group.free() group_state = str(group) assert systemtools.TestManager.compare( group_state, ''' ??? group ??? test (Synth C) amplitude: c1, frequency: a0 ??? test (Synth B) amplitude: 0.75, frequency: 880.0 ??? test (Synth A) amplitude: 1.0, frequency: 440.0 ''', ), group_state
def test_01(self): group_a = servertools.Group() group_a.allocate() assert len(group_a) == 0 synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) assert len(group_a) == 1 group_b = servertools.Group() group_a.append(group_b) assert len(group_a) == 2 assert len(group_b) == 0 synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) assert len(group_a) == 2 assert len(group_b) == 1 synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) assert len(group_a) == 2 assert len(group_b) == 2 synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) assert len(group_a) == 3 assert len(group_b) == 2 server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 test ''', ), server_state assert len(group_a) == 3 assert len(group_b) == 2 group_a.pop() assert len(group_a) == 2 group_b.pop() assert len(group_b) == 1 group_a.pop() assert len(group_a) == 1 assert len(group_b) == 1 assert not group_b[0].is_allocated group_a.pop() assert len(group_a) == 0 server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), server_state
def test_01(self): group = servertools.Group() synth_a = servertools.Synth(synthdefs.test) synth_b = servertools.Synth(synthdefs.test, amplitude=0.0) group.extend([synth_a, synth_b]) group.allocate() remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: 1.0, frequency: 440.0 1002 test amplitude: 0.0, frequency: 440.0 ''', ), remote_state local_state = str(self.server.query_local_nodes(True)) assert local_state == remote_state bus_a = servertools.Bus(calculation_rate='control').allocate() bus_a.set(0.25) group.controls['amplitude'] = bus_a remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: c0, frequency: 440.0 1002 test amplitude: c0, frequency: 440.0 ''', ), remote_state local_state = str(self.server.query_local_nodes(True)) assert local_state == remote_state bus_b = servertools.Bus(calculation_rate='control').allocate() bus_b.set(0.75) group.controls['amplitude'] = bus_b remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: c1, frequency: 440.0 1002 test amplitude: c1, frequency: 440.0 ''', ), remote_state local_state = str(self.server.query_local_nodes(True)) assert local_state == remote_state bus_b.set(0.675) remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: c1, frequency: 440.0 1002 test amplitude: c1, frequency: 440.0 ''', ), remote_state local_state = str(self.server.query_local_nodes(True)) assert local_state == remote_state group.controls['amplitude'] = None remote_state = str(self.server.query_remote_nodes(True)) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test amplitude: 1.0, frequency: 440.0 1002 test amplitude: 0.0, frequency: 440.0 ''', ), remote_state local_state = str(self.server.query_local_nodes(True)) assert local_state == remote_state
def test_Node_parentage_01(self): root_node = self.server.root_node default_group = self.server.default_group group_a = servertools.Group().allocate() group_b = servertools.Group().allocate(target_node=group_a) group_c = servertools.Group().allocate(target_node=group_b) group_d = servertools.Group().allocate(target_node=group_c) synth_a = servertools.Synth(synthdefs.test) synth_b = servertools.Synth(synthdefs.test) group_d.extend([synth_a, synth_b]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 group 1002 group 1003 group 1004 test 1005 test ''', ), server_state assert group_a.parentage == ( group_a, default_group, root_node, ) assert group_b.parentage == ( group_b, group_a, default_group, root_node, ) assert group_c.parentage == ( group_c, group_b, group_a, default_group, root_node, ) assert group_d.parentage == ( group_d, group_c, group_b, group_a, default_group, root_node, ) assert synth_a.parentage == ( synth_a, group_d, group_c, group_b, group_a, default_group, root_node, ) assert synth_b.parentage == ( synth_b, group_d, group_c, group_b, group_a, default_group, root_node, ) group_a.succeed_by(group_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 group 1002 group 1003 group 1004 test 1005 test ''', ), server_state assert group_d.parentage == ( group_d, default_group, root_node, ) assert synth_a.parentage == ( synth_a, group_d, default_group, root_node, ) assert synth_b.parentage == ( synth_b, group_d, default_group, root_node, )
def test_01(self): group_a = servertools.Group() group_a.allocate(target_node=self.server) group_b = servertools.Group() group_b.allocate(target_node=self.server) synthdef = synthdefs.test assert not synthdef.is_allocated synth_a = servertools.Synth(synthdef) assert not synthdef.is_allocated assert not synth_a.is_allocated group_a.append(synth_a) assert synthdef.is_allocated assert synth_a.is_allocated assert synth_a.parent is group_a assert synth_a in group_a assert synth_a not in group_b server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group 1002 test ''', ), server_state group_b.append(synth_a) assert synthdef.is_allocated assert synth_a.is_allocated assert synth_a.parent is group_b assert synth_a in group_b assert synth_a not in group_a server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1002 test 1000 group ''', ), server_state synth_b = servertools.Synth(synthdef) assert not synth_b.is_allocated assert synth_b.parent is None group_b.append(synth_b) assert synth_b.is_allocated assert synth_b.parent is group_b server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 group 1002 test 1003 test 1000 group ''', ), server_state
def test_01(self): synth_a = servertools.Synth(synthdefs.test) synth_b = servertools.Synth(synthdefs.test) synth_c = servertools.Synth(synthdefs.test) synth_d = servertools.Synth(synthdefs.test) synth_e = servertools.Synth(synthdefs.test) synth_a.allocate() server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 test ''', ), server_state synth_a.succeed_by(synth_b) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 test 1001 test ''', ), server_state synth_a.succeed_by([synth_c, synth_d]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 test 1002 test 1003 test 1001 test ''', ), server_state synth_a.succeed_by([synth_e, synth_b]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 test 1004 test 1001 test 1002 test 1003 test ''', ), server_state
def test_03(self): group_a = servertools.Group() group_a.allocate() synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b = servertools.Group() group_a.append(group_b) synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) group_c = servertools.Group() group_b.append(group_c) synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group 1006 test ''', ), remote_state assert len(group_a) == 3 assert len(group_b) == 3 assert len(group_c) == 0 assert synth_a.parent is group_a assert synth_b.parent is group_b assert synth_c.parent is group_b assert synth_d.parent is group_a assert group_b.parent is group_a assert group_c.parent is group_b assert synth_a is group_a[0] assert synth_b is group_b[0] assert synth_c is group_b[1] assert synth_d is group_a[2] assert group_b is group_a[1] assert group_c is group_b[2] del (group_a[-1]) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group ''', ), remote_state assert len(group_a) == 2 assert len(group_b) == 3 assert len(group_c) == 0 assert synth_a.parent is group_a assert synth_b.parent is group_b assert synth_c.parent is group_b assert synth_d.parent is None assert group_b.parent is group_a assert group_c.parent is group_b assert synth_a is group_a[0] assert synth_b is group_b[0] assert synth_c is group_b[1] assert synth_d not in group_a assert group_b is group_a[1] assert group_c is group_b[2] del (group_b[1]) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1005 group ''', ), remote_state assert len(group_a) == 2 assert len(group_b) == 2 assert len(group_c) == 0 assert synth_a.parent is group_a assert synth_b.parent is group_b assert synth_c.parent is None assert synth_d.parent is None assert group_b.parent is group_a assert group_c.parent is group_b assert synth_a is group_a[0] assert synth_b is group_b[0] assert synth_c not in group_b assert synth_d not in group_a assert group_b is group_a[1] assert group_c is group_b[1] del (group_a[0]) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1002 group 1003 test 1005 group ''', ), remote_state assert len(group_a) == 1 assert len(group_b) == 2 assert len(group_c) == 0 assert synth_a.parent is None assert synth_b.parent is group_b assert synth_c.parent is None assert synth_d.parent is None assert group_b.parent is group_a assert group_c.parent is group_b assert synth_a not in group_a assert synth_b is group_b[0] assert synth_c not in group_b assert synth_d not in group_a assert group_b is group_a[0] assert group_c is group_b[1] del (group_b[1]) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1002 group 1003 test ''', ), remote_state assert len(group_a) == 1 assert len(group_b) == 1 assert len(group_c) == 0 assert synth_a.parent is None assert synth_b.parent is group_b assert synth_c.parent is None assert synth_d.parent is None assert group_b.parent is group_a assert group_c.parent is None assert synth_a not in group_a assert synth_b is group_b[0] assert synth_c not in group_b assert synth_d not in group_a assert group_b is group_a[0] assert group_c not in group_b del (group_a[0]) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), remote_state assert len(group_a) == 0 assert len(group_b) == 1 assert len(group_c) == 0 assert synth_a.parent is None assert synth_b.parent is group_b assert synth_c.parent is None assert synth_d.parent is None assert group_b.parent is None assert group_c.parent is None assert synth_a not in group_a assert synth_b is group_b[0] assert synth_c not in group_b assert synth_d not in group_a assert group_b not in group_a assert group_c not in group_b assert not synth_b.is_allocated
def test_05(self): group_a = servertools.Group(name='Group A', ) synth_a = servertools.Synth( synthdefs.test, name='Synth A', ) group_a.append(synth_a) group_b = servertools.Group(name='Group B', ) group_a.append(group_b) synth_b = servertools.Synth( synthdefs.test, name='Synth B', ) group_b.append(synth_b) synth_c = servertools.Synth( synthdefs.test, name='Synth C', ) group_b.append(synth_c) group_c = servertools.Group(name='Group C', ) group_b.append(group_c) synth_d = servertools.Synth( synthdefs.test, name='Synth D', ) group_a.append(synth_d) synth_e = servertools.Synth( synthdefs.test, name='Synth E', ) group_a.allocate() remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group 1006 test ''', ), remote_state group_a_state = str(group_a) assert systemtools.TestManager.compare( group_a_state, ''' 1000 group (Group A) 1001 test (Synth A) amplitude: 1.0, frequency: 440.0 1002 group (Group B) 1003 test (Synth B) amplitude: 1.0, frequency: 440.0 1004 test (Synth C) amplitude: 1.0, frequency: 440.0 1005 group (Group C) 1006 test (Synth D) amplitude: 1.0, frequency: 440.0 ''', ), group_a_state assert group_a.node_id == 1000 assert synth_a.node_id == 1001 assert group_b.node_id == 1002 assert synth_b.node_id == 1003 assert synth_c.node_id == 1004 assert group_c.node_id == 1005 assert synth_d.node_id == 1006 assert synth_e.node_id is None synth_e.allocate( add_action=servertools.AddAction.REPLACE, target_node=group_a, ) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1007 test ''', ), remote_state assert group_a.node_id is None assert synth_a.node_id is None assert group_b.node_id is None assert synth_b.node_id is None assert synth_c.node_id is None assert group_c.node_id is None assert synth_d.node_id is None assert synth_e.node_id == 1007 group_a_state = str(group_a) assert systemtools.TestManager.compare( group_a_state, ''' ??? group (Group A) ??? test (Synth A) amplitude: 1.0, frequency: 440.0 ??? group (Group B) ??? test (Synth B) amplitude: 1.0, frequency: 440.0 ??? test (Synth C) amplitude: 1.0, frequency: 440.0 ??? group (Group C) ??? test (Synth D) amplitude: 1.0, frequency: 440.0 ''', ), group_a_state
def test_01(self): group_a = servertools.Group() group_a.allocate() synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b = servertools.Group() group_a.append(group_b) synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) group_c = servertools.Group() group_b.append(group_c) synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group 1006 test ''', ), server_state assert group_a[0] is synth_a assert group_a[1] is group_b assert group_a[2] is synth_d assert group_b[0] is synth_b assert group_b[1] is synth_c assert group_b[2] is group_c assert group_a[-1] is synth_d assert group_a[-2] is group_b assert group_a[-3] is synth_a assert group_b[-1] is group_c assert group_b[-2] is synth_c assert group_b[-3] is synth_b assert group_a[:] == [synth_a, group_b, synth_d] assert group_a[1:] == [group_b, synth_d] assert group_a[1:-1] == [group_b] assert group_a[2:] == [synth_d] assert group_a[:-1] == [synth_a, group_b] assert group_a[:-2] == [synth_a] assert group_b[:] == [synth_b, synth_c, group_c] assert group_b[1:] == [synth_c, group_c] assert group_b[1:-1] == [synth_c] assert group_b[2:] == [group_c] assert group_b[:-1] == [synth_b, synth_c] assert group_b[:-2] == [synth_b]
def test_01(self): synth_a = servertools.Synth(synthdefs.test) synth_b = servertools.Synth(synthdefs.test) synth_c = servertools.Synth(synthdefs.test) synth_d = servertools.Synth(synthdefs.test) synth_e = servertools.Synth(synthdefs.test) synth_a.allocate() synth_b.allocate() server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 test 1000 test ''', ), server_state synth_a.replace_with(synth_c) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1001 test 1002 test ''', ), server_state synth_b.replace_with([synth_d, synth_e]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1003 test 1004 test 1002 test ''', ), server_state synth_c.replace_with([synth_a, synth_e]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1003 test 1005 test 1004 test ''', ), server_state
def test_01(self): group_a = servertools.Group() group_a.allocate() synth_a = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b = servertools.Group() group_a.append(group_b) synth_b = servertools.Synth(synthdefs.test) group_b.append(synth_b) synth_c = servertools.Synth(synthdefs.test) group_b.append(synth_c) group_c = servertools.Group() group_b.append(group_c) synth_d = servertools.Synth(synthdefs.test) group_a.append(synth_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group 1006 test ''', ), server_state del (group_a[-1]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1004 test 1005 group ''', ), server_state del (group_b[1]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test 1002 group 1003 test 1005 group ''', ), server_state del (group_a[0]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1002 group 1003 test 1005 group ''', ), server_state del (group_b[1]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1002 group 1003 test ''', ), server_state del (group_a[0]) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), server_state assert not group_b.is_allocated assert not group_c.is_allocated assert not synth_a.is_allocated assert not synth_b.is_allocated assert not synth_c.is_allocated assert not synth_d.is_allocated
def test_01(self): group_a = servertools.Group().allocate() group_b = servertools.Group().allocate() synth_a = servertools.Synth(synthdefs.test) synth_b = servertools.Synth(synthdefs.test) group_a.append(synth_a) group_b.append(synth_b) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1003 test 1000 group 1002 test ''', ), remote_state local_state = str(self.server.query_local_nodes()) assert local_state == remote_state osc_message = osctools.OscMessage( '/n_after', synth_b.node_id, synth_a.node_id, ) self.server.send_message(osc_message) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1000 group 1002 test 1003 test ''', ), remote_state local_state = str(self.server.query_local_nodes()) assert local_state == remote_state osc_message = osctools.OscMessage( '/n_order', 0, group_b.node_id, synth_b.node_id, synth_a.node_id, ) self.server.send_message(osc_message) remote_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( remote_state, ''' NODE TREE 0 group 1 group 1001 group 1003 test 1002 test 1000 group ''', ), remote_state local_state = str(self.server.query_local_nodes()) assert local_state == remote_state
def test_01(self): group = servertools.Group().allocate() synth_a = servertools.Synth(synthdefs.test) synth_a.allocate(target_node=group, ) synth_b = servertools.Synth(synthdefs.test) synth_b.allocate(target_node=group, ) server_state = str( self.server.query_remote_nodes(include_controls=True)) assert server_state == stringtools.normalize(r''' NODE TREE 0 group 1 group 1000 group 1002 test amplitude: 1.0, frequency: 440.0 1001 test amplitude: 1.0, frequency: 440.0 ''') assert synth_a['frequency'].get() == 440.0 assert synth_a['amplitude'].get() == 1.0 assert synth_b['frequency'].get() == 440.0 assert synth_b['amplitude'].get() == 1.0 synth_a.controls['frequency'].set(443) synth_a.controls['amplitude'].set(0.5) server_state = str( self.server.query_remote_nodes(include_controls=True)) assert server_state == stringtools.normalize(r''' NODE TREE 0 group 1 group 1000 group 1002 test amplitude: 1.0, frequency: 440.0 1001 test amplitude: 0.5, frequency: 443.0 ''') assert synth_a['frequency'].get() == 443.0 assert synth_a['amplitude'].get() == 0.5 assert synth_b['frequency'].get() == 440.0 assert synth_b['amplitude'].get() == 1.0 synth_b.controls['frequency', 'amplitude'] = 441, 0.25 server_state = str( self.server.query_remote_nodes(include_controls=True)) assert server_state == stringtools.normalize(r''' NODE TREE 0 group 1 group 1000 group 1002 test amplitude: 0.25, frequency: 441.0 1001 test amplitude: 0.5, frequency: 443.0 ''') assert synth_a['frequency'].get() == 443.0 assert synth_a['amplitude'].get() == 0.5 assert synth_b['frequency'].get() == 441.0 assert synth_b['amplitude'].get() == 0.25 bus_a = servertools.Bus(calculation_rate='control') bus_a.allocate() bus_b = servertools.Bus(calculation_rate='audio') bus_b.allocate() synth_a['frequency'].set(bus_a) synth_b['amplitude'].set(bus_b) server_state = str( self.server.query_remote_nodes(include_controls=True)) assert server_state == stringtools.normalize(r''' NODE TREE 0 group 1 group 1000 group 1002 test amplitude: a16, frequency: 441.0 1001 test amplitude: 0.5, frequency: c0 ''') assert synth_a['frequency'].get() == bus_a assert synth_a['amplitude'].get() == 0.5 assert synth_b['frequency'].get() == 441.0 assert synth_b['amplitude'].get() == bus_b
def test_01(self): group = servertools.Group().allocate() server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group ''', ), server_state synth_a = servertools.Synth(synthdefs.test) group.insert(0, synth_a) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1001 test ''', ), server_state synth_b = servertools.Synth(synthdefs.test) group.insert(0, synth_b) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1002 test 1001 test ''', ), server_state synth_c = servertools.Synth(synthdefs.test) group.insert(1, synth_c) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1002 test 1003 test 1001 test ''', ), server_state synth_d = servertools.Synth(synthdefs.test) group.insert(3, synth_d) server_state = str(self.server.query_remote_nodes()) assert systemtools.TestManager.compare( server_state, ''' NODE TREE 0 group 1 group 1000 group 1002 test 1003 test 1001 test 1004 test ''', ), server_state