Ejemplo n.º 1
0
 def _build_id_mapping_for_buses(self):
     input_count = self._input_count or 0
     output_count = self._output_count or 0
     first_private_bus_id = input_count + output_count
     allocators = {
         synthdeftools.CalculationRate.AUDIO:
         servertools.BlockAllocator(heap_minimum=first_private_bus_id, ),
         synthdeftools.CalculationRate.CONTROL:
         servertools.BlockAllocator(),
     }
     mapping = {}
     if output_count:
         bus_group = self.audio_output_bus_group
         for bus_id, bus in enumerate(bus_group):
             mapping[bus] = bus_id
     if input_count:
         bus_group = self.audio_input_bus_group
         for bus_id, bus in enumerate(bus_group, output_count):
             mapping[bus] = bus_id
     for bus in self._buses:
         if bus in mapping:
             continue
         allocator = allocators[bus.calculation_rate]
         if bus.bus_group is None:
             mapping[bus] = allocator.allocate(1)
         else:
             block_id = allocator.allocate(len(bus.bus_group))
             mapping[bus.bus_group] = block_id
             for bus_id in range(block_id, block_id + len(bus.bus_group)):
                 mapping[bus] = bus_id
     return mapping
Ejemplo n.º 2
0
 def setUp(self):
     super(TestCase, self).setUp()
     self.pseudo_server = types.SimpleNamespace(
         audio_bus_allocator=servertools.BlockAllocator(),
         control_bus_allocator=servertools.BlockAllocator(),
         node_id_allocator=servertools.NodeIdAllocator(),
         )
Ejemplo n.º 3
0
 def setUp(self):
     super(TestCase, self).setUp()
     self.pseudo_server = types.SimpleNamespace(
         audio_bus_allocator=servertools.BlockAllocator(),
         control_bus_allocator=servertools.BlockAllocator(),
         node_id_allocator=servertools.NodeIdAllocator(),
         )
     self.server = servertools.Server.get_default_server().boot()
     synthdefs.default.allocate(self.server)
     self.server.debug_osc = True
     self.server.latency = 0.0
Ejemplo n.º 4
0
 def _setup_allocators(self, server_options):
     from supriya.tools import servertools
     self._audio_bus_allocator = servertools.BlockAllocator(
         heap_maximum=server_options.audio_bus_channel_count,
         heap_minimum=server_options.first_private_bus_id,
     )
     self._buffer_allocator = servertools.BlockAllocator(
         heap_maximum=server_options.buffer_count, )
     self._control_bus_allocator = servertools.BlockAllocator(
         heap_maximum=server_options.control_bus_channel_count, )
     self._node_id_allocator = servertools.NodeIdAllocator(
         initial_node_id=server_options.initial_node_id, )
     self._sync_id = 0
    def test_01(self):

        allocator = servertools.BlockAllocator(
            heap_minimum=0,
            heap_maximum=16,
        )

        assert allocator.allocate(4) == 0
        assert allocator.allocate(4) == 4
        assert allocator.allocate(4) == 8
        assert allocator.allocate(4) == 12
        assert allocator.allocate(4) is None

        allocator.free(0)
        allocator.free(4)
        allocator.free(8)
        allocator.free(12)

        assert allocator.allocate(20) is None

        assert allocator.allocate_at(4, 2) == 4
        assert allocator.allocate(4) == 0
        assert allocator.allocate(4) == 6

        allocator.free(4)

        assert allocator.allocate(1) == 4
        assert allocator.allocate(1) == 5
Ejemplo n.º 6
0
 def test__perform_realtime_02(self):
     bus_uuid = uuid.uuid4()
     event = patterntools.BusEvent(
         calculation_rate='audio',
         channel_count=2,
         is_stop=True,
         release_time=0,
         uuid=bus_uuid,
     )
     server = types.SimpleNamespace(
         audio_bus_allocator=servertools.BlockAllocator(),
         control_bus_allocator=servertools.BlockAllocator(),
     )
     uuids = {
         bus_uuid: {
             0: servertools.BusGroup(
                 calculation_rate='audio',
                 bus_count=2,
             )
         },
     }
     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.BusEvent(
                 calculation_rate=supriya.tools.synthdeftools.CalculationRate.AUDIO,
                 channel_count=2,
                 delta=0,
                 is_stop=True,
                 release_time=0,
                 uuid=UUID('...'),
                 ),
             index=0,
             is_stop=True,
             requests=[],
             timestamp=100.0,
             uuid=UUID('...'),
             )
         ''',
         format(event_products[0]),
     )
Ejemplo n.º 7
0
 def test__perform_realtime_01(self):
     bus_uuid = uuid.uuid4()
     event = patterntools.BusEvent(
         calculation_rate='audio',
         channel_count=2,
         uuid=bus_uuid,
     )
     server = types.SimpleNamespace(
         audio_bus_allocator=servertools.BlockAllocator(),
         control_bus_allocator=servertools.BlockAllocator(),
     )
     uuids = {}
     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.BusEvent(
                 calculation_rate=supriya.tools.synthdeftools.CalculationRate.AUDIO,
                 channel_count=2,
                 delta=0,
                 uuid=UUID('...'),
                 ),
             index=0,
             requests=[],
             timestamp=100.0,
             uuid=UUID('...'),
             )
         ''',
         format(event_products[0]),
     )
     assert bus_uuid in uuids
     assert isinstance(uuids[bus_uuid], dict)
     assert list(uuids[bus_uuid].keys()) == [0]