Пример #1
0
    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
Пример #2
0
    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] == []
Пример #3
0
    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
Пример #4
0
 def _setup_proxies(self):
     from supriya.tools import servertools
     self._audio_input_bus_group = servertools.AudioInputBusGroup(self)
     self._audio_output_bus_group = servertools.AudioOutputBusGroup(self)
     self._root_node = servertools.RootNode(server=self)
     self._nodes[0] = self._root_node
     default_group = servertools.Group()
     default_group.allocate(
         add_action=servertools.AddAction.ADD_TO_HEAD,
         node_id_is_permanent=True,
         target_node=self.root_node,
     )
     self._default_group = default_group
Пример #5
0
    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
Пример #6
0
 def test__perform_realtime_02(self):
     node_uuid = uuid.uuid4()
     event = patterntools.GroupEvent(
         is_stop=True,
         release_time=0,
         uuid=node_uuid,
     )
     server = types.SimpleNamespace(
         node_id_allocator=servertools.NodeIdAllocator(), )
     uuids = {
         node_uuid: {
             1000: servertools.Group(),
         },
     }
     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.GroupEvent(
                 delta=0,
                 is_stop=True,
                 release_time=0,
                 uuid=UUID('...'),
                 ),
             index=0,
             is_stop=True,
             requests=[
                 supriya.tools.requesttools.NodeFreeRequest(
                     node_ids=(1000,),
                     ),
                 ],
             timestamp=100.0,
             uuid=UUID('...'),
             )
         ''',
         format(event_products[0]),
     )
Пример #7
0
 def _perform_realtime(
     self,
     index=0,
     server=None,
     timestamp=0,
     uuids=None,
     ):
     from supriya.tools import patterntools
     node_uuid = self.get('uuid') or uuid.uuid4()
     requests = []
     if not self.get('is_stop'):
         node_id = server.node_id_allocator.allocate_node_id()
         uuids[node_uuid] = {node_id: servertools.Group()}
         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')
         request = requesttools.GroupNewRequest(
             add_action=add_action,
             node_id=node_id,
             target_node_id=target_node_id,
             )
     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]
Пример #8
0
    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
Пример #9
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
Пример #10
0
    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
Пример #11
0
    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
Пример #12
0
    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
Пример #13
0
    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,
        )
Пример #14
0
    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
Пример #15
0
    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
Пример #16
0
    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
Пример #17
0
    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]
Пример #18
0
    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
Пример #19
0
    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
Пример #20
0
    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
Пример #21
0
    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
Пример #22
0
    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