Beispiel #1
0
 def _handle_first(self, expr, state):
     from supriya import synthdefs
     from supriya.tools import patterntools
     from supriya.tools import synthdeftools
     channel_count = self.channel_count
     if channel_count is None:
         synthdef = expr.get('synthdef') or synthdefs.default
         channel_count = synthdef.audio_output_channel_count
     if self.calculation_rate == synthdeftools.CalculationRate.AUDIO:
         link_synthdef_name = 'system_link_audio_{}'.format(channel_count)
     else:
         link_synthdef_name = 'system_link_control_{}'.format(channel_count)
     link_synthdef = getattr(synthdefs, link_synthdef_name)
     bus_event = patterntools.BusEvent(
         calculation_rate=self.calculation_rate,
         channel_count=channel_count,
         uuid=state['bus_uuid'],
         )
     group_event = patterntools.GroupEvent(
         uuid=state['group_uuid'],
         )
     link_event = patterntools.SynthEvent(
         add_action='ADD_AFTER',
         amplitude=1.0,
         in_=state['bus_uuid'],
         synthdef=link_synthdef,
         target_node=state['group_uuid'],
         uuid=state['link_uuid'],
         )
     events = [bus_event, group_event, link_event]
     return events, expr
Beispiel #2
0
 def _handle_first(self, expr, state):
     from supriya.tools import patterntools
     _, group_uuids, _ = state
     events = []
     for group_uuid in group_uuids:
         group_event = patterntools.GroupEvent(
             uuid=group_uuid,
             add_action='ADD_TO_TAIL',
         )
         events.append(group_event)
     return events, expr
Beispiel #3
0
 def _handle_last(self, expr, state):
     from supriya.tools import patterntools
     _, group_uuids, _ = state
     delta = expr.delta
     delta += (self._release_time or 0)
     expr = new(expr, delta=delta)
     events = []
     for group_uuid in group_uuids:
         group_event = patterntools.GroupEvent(
             uuid=group_uuid,
             is_stop=True,
         )
         events.append(group_event)
     return expr, events
Beispiel #4
0
 def _handle_last(self, expr, state):
     from supriya.tools import patterntools
     delta = expr.delta
     delta += (self._release_time or 0)
     expr = new(expr, delta=delta)
     link_event = patterntools.SynthEvent(
         uuid=state['link_uuid'],
         is_stop=True,
         )
     group_event = patterntools.GroupEvent(
         uuid=state['group_uuid'],
         is_stop=True,
         )
     bus_event = patterntools.BusEvent(
         uuid=state['bus_uuid'],
         is_stop=True,
         )
     events = [link_event, group_event, bus_event]
     return expr, events
Beispiel #5
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]),
     )
Beispiel #6
0
 def _handle_last(self, expr, state=None, yield_count=0):
     from supriya.tools import patterntools
     delta = expr.delta
     delta += (self._release_time or 0)
     expr = new(expr, delta=delta)
     link_event = patterntools.SynthEvent(
         uuid=state['link_uuid'],
         is_stop=True,
     )
     group_event = patterntools.GroupEvent(
         uuid=state['group_uuid'],
         is_stop=True,
     )
     bus_event = patterntools.BusEvent(
         uuid=state['bus_uuid'],
         is_stop=True,
     )
     events = [link_event, group_event, bus_event]
     events = events[-yield_count:]
     events.insert(0, expr)
     return events
Beispiel #7
0
 def test__perform_realtime_01(self):
     node_uuid = uuid.uuid4()
     event = patterntools.GroupEvent(uuid=node_uuid, )
     server = types.SimpleNamespace(
         node_id_allocator=servertools.NodeIdAllocator(), )
     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.GroupEvent(
                 delta=0,
                 uuid=UUID('...'),
                 ),
             index=0,
             requests=[
                 supriya.tools.requesttools.GroupNewRequest(
                     add_action=supriya.tools.servertools.AddAction.ADD_TO_HEAD,
                     node_id=1000,
                     target_node_id=1,
                     ),
                 ],
             timestamp=100.0,
             uuid=UUID('...'),
             )
         ''',
         format(event_products[0]),
     )
     assert node_uuid in uuids
     assert isinstance(uuids[node_uuid], dict)
     assert list(uuids[node_uuid].keys()) == [1000]