コード例 #1
0
 def __init__(self, c_instance, *a, **k):
     product_id_bytes = consts.MANUFACTURER_ID + consts.DEVICE_CODE
     super(Launchpad_Pro, self).__init__(c_instance=c_instance, product_id_bytes=product_id_bytes, *a, **k)
     self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
     with self.component_guard():
         self._skin = make_default_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._midimap = MidiMap()
         self._target_track_component = TargetTrackComponent(name='Target_Track')
         self._create_background()
         self._create_global_component()
         self._last_sent_mode_byte = None
         with inject(layout_setup=const(self._layout_setup), should_arm=const(self._should_arm_track)).everywhere():
             self._create_session()
             self._create_recording()
             self._create_actions()
             self._create_drums()
             self._create_mixer()
             self._create_device()
             self._create_modes()
             self._create_m4l_interface()
         self._on_session_record_changed.subject = self.song()
     self.set_highlighting_session_component(self._session)
     self.set_device_component(self._device)
     self._device_selection_follows_track_selection = True
     self._on_session_record_changed()
コード例 #2
0
 def __init__(self, c_instance, *a, **k):
     product_id_bytes = consts.MANUFACTURER_ID + consts.DEVICE_CODE
     super(Launchpad_Pro, self).__init__(c_instance=c_instance, product_id_bytes=product_id_bytes, *a, **k)
     self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
     with self.component_guard():
         self._skin = make_default_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._midimap = MidiMap()
         self._target_track_component = TargetTrackComponent(name='Target_Track')
         self._create_background()
         self._create_global_component()
         self._last_sent_mode_byte = None
         with inject(layout_setup=const(self._layout_setup), should_arm=const(self._should_arm_track)).everywhere():
             self._create_session()
             self._create_recording()
             self._create_actions()
             self._create_drums()
             self._create_mixer()
             self._create_device()
             self._create_modes()
             self._create_user()
         self._on_session_record_changed.subject = self.song()
     self.set_device_component(self._device)
     self._on_session_record_changed()
     return
コード例 #3
0
class Messenger(object):
    """
    Externally provided interface for those components that provide
    global Push feedback.
    """
    expect_dialog = dependency(expect_dialog=const(nop))
    show_notification = dependency(show_notification=const(nop))
コード例 #4
0
 def make_injector(self):
   """ Adds some additional stuff to the injector, used in BaseMessenger """
   return inject(
     double_press_context = const(self._double_press_context),
     control_surface = const(self),
    
     log_message = const(self.log_message))
コード例 #5
0
 def __init__(self, c_instance, *a, **k):
     super(Launchpad_MK2, self).__init__(product_id_bytes=consts.PRODUCT_ID_BYTES, c_instance=c_instance, *a, **k)
     self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
     with self.component_guard():
         self._skin = make_default_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
         self._create_session()
         self._create_mixer()
         self._last_sent_layout_byte = None
         with inject(switch_layout=const(self._switch_layout)).everywhere():
             self._create_modes()
コード例 #6
0
 def __init__(self, c_instance, *a, **k):
     super(Launchpad_MK2, self).__init__(product_id_bytes=consts.PRODUCT_ID_BYTES, c_instance=c_instance, *a, **k)
     self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
     with self.component_guard():
         self._skin = make_default_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
         self._create_session()
         self._create_mixer()
         self._last_sent_layout_byte = None
         with inject(switch_layout=const(self._switch_layout)).everywhere():
             self._create_modes()
コード例 #7
0
    def query(self, browser):
        root = super(SourceBrowserQuery, self).query(browser)
        groups = dict()
        for item in root:
            groups.setdefault(item.source, []).append(item)

        return map(lambda (k, g): VirtualBrowserItem(name=k, children_query=const(g)), sorted(groups.items(), key=first))
コード例 #8
0
    def query(self, browser):
        root = super(SourceBrowserQuery, self).query(browser)
        groups = dict()
        for item in root:
            groups.setdefault(item.source, []).append(item)

        return map(lambda (k, g): VirtualBrowserItem(name=k, children_query=const(g)), sorted(groups.items(), key=first))
 def __init__(self,
              device_bank_registry=None,
              info_layer=None,
              delete_handler=None,
              *a,
              **k):
     super(DeviceNavigationComponent, self).__init__(*a, **k)
     self._make_navigation_node = partial(
         make_navigation_node, device_bank_registry=device_bank_registry)
     self._state_buttons = None
     self._delete_handler = delete_handler
     self._device_list = self.register_component(
         ScrollableListWithTogglesComponent())
     self._on_selection_clicked_in_controller.subject = self._device_list
     self._on_selection_changed_in_controller.subject = self._device_list
     self._on_state_changed_in_controller.subject = self._device_list
     self._current_node = None
     self._message_box = self.register_component(
         MessageBoxComponent(layer=info_layer, is_enabled=False))
     self._message_box.text = consts.MessageBoxText.EMPTY_DEVICE_CHAIN
     self._selected_track = None
     self._on_selected_track_changed.subject = self.song().view
     with inject(selection=const(NamedTuple(
             selected_device=None))).everywhere():
         self._on_selected_track_changed()
コード例 #10
0
 def __init__(self, *a, **k):
     super(MIDI_Mix, self).__init__(*a, **k)
     with self.component_guard():
         self._skin = Skin(Colors)
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
         self._create_mixer()
コード例 #11
0
 def __init__(self, *a, **k):
     super(MIDI_Mix, self).__init__(*a, **k)
     with self.component_guard():
         self._skin = Skin(Colors)
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
         self._create_mixer()
コード例 #12
0
 def __init__(self, *a, **k):
     super(MIDI_Mix, self).__init__(*a, **k)
     with self.component_guard():
         self._skin = Skin(Colors)
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
         self._create_mixer()
         self._create_session()
         self._session.set_mixer(self._mixer)
         self.set_highlighting_session_component(self._session)
コード例 #13
0
ファイル: Launchkey_MK2.py プロジェクト: aumhaa/livepy_diff
 def __init__(self, c_instance, *a, **k):
     super(Launchkey_MK2, self).__init__(c_instance=c_instance, *a, **k)
     self._is_25_key_model = False
     self._is_in_control_on = True
     with self.component_guard():
         self._skin = make_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
     self._request_task = self._tasks.add(Task.sequence(Task.wait(self.identity_request_delay), Task.run(self._send_identity_request)))
     self._request_task.kill()
コード例 #14
0
 def __init__(self, *a, **k):
     super(RolandMX1, self).__init__(*a, **k)
     with self.component_guard():
         self._skin = make_default_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
         self._transport = self._create_transport()
         self._mixer = self._create_mixer()
         self._session = self._create_session()
         self._step_button_modes = self._create_step_button_modes()
コード例 #15
0
 def __init__(self, c_instance, *a, **k):
     super(Launchkey_MK2, self).__init__(c_instance=c_instance, *a, **k)
     self._is_25_key_model = False
     self._is_in_control_on = True
     self._identity_response_pending = False
     with self.component_guard():
         self._skin = make_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
     self._request_task = self._tasks.add(Task.sequence(Task.wait(self.identity_request_delay), Task.run(self._send_identity_request)))
     self._request_task.kill()
コード例 #16
0
 def make_injector(self):
   """ Adds some additional stuff to the injector, used in BaseMessenger """
   return inject(
     control_surface = const(self),
     log_message = const(self.log_message),
     reset_controlled_track = const(self.reset_controlled_track),
     with_note = const(self.with_note),
     with_session = const(self.with_session),
     with_sequencer = const(self.with_sequencer),
     display_num = const(self.display_num),
   ) 
コード例 #17
0
 def __init__(self, c_instance, *a, **k):
     super(Launchkey_MK1, self).__init__(c_instance=c_instance, *a, **k)
     set_log_instance(self) # For Debug Output only
     self._is_25_key_model = False
     self._is_in_control_on = True
     with self.component_guard():
         self._skin = make_skin()
         with inject(skin=const(self._skin)).everywhere():
             self._create_controls()
     self._request_task = self._tasks.add(Task.sequence(Task.wait(self.identity_request_delay), Task.run(self._send_identity_request)))
     self._request_task.kill()
     self._encoder_mode_toggle_enabled = False
     self._encoder_mode_task = self._tasks.add(Task.sequence(Task.wait(self.encoder_in_control_double_click_time), Task.run(self._disable_toggle_encoder_mode)))
     self._encoder_mode_task.kill()
コード例 #18
0
 def __init__(self, device_bank_registry = None, info_layer = None, delete_handler = None, *a, **k):
     super(DeviceNavigationComponent, self).__init__(*a, **k)
     self._make_navigation_node = partial(make_navigation_node, device_bank_registry=device_bank_registry)
     self._state_buttons = None
     self._delete_handler = delete_handler
     self._device_list = self.register_component(ScrollableListWithTogglesComponent())
     self._on_selection_clicked_in_controller.subject = self._device_list
     self._on_selection_changed_in_controller.subject = self._device_list
     self._on_state_changed_in_controller.subject = self._device_list
     self._current_node = None
     self._message_box = self.register_component(MessageBoxComponent(layer=info_layer, is_enabled=False))
     self._message_box.text = consts.MessageBoxText.EMPTY_DEVICE_CHAIN
     self._selected_track = None
     self._on_selected_track_changed.subject = self.song().view
     with inject(selection=const(NamedTuple(selected_device=None))).everywhere():
         self._on_selected_track_changed()
コード例 #19
0
 def _sigabort_create(self):
     if self._show_returns == 3 or self._show_returns == 4:
         self._fold_enabled = False
         self._toggle_returns = True
     if not self._enable_function:
         self._direct_bank = False
         self._has_transport = False
     if self._channel_strip:
         self._fold_enabled = False
     self._user_custom = self._enable_function and not self._direct_bank and not self._has_transport
     self._bcr_controls = BCL(self, self._preset, self._relative,
                              self._bit_14)
     self._device_selection_follows_track_selection = True
     self._default_skin = make_default_skin()
     with inject(skin=const(self._default_skin)).everywhere():
         self._create_controls()
     self._set_offsets_task = self._tasks.add(
         Task.sequence(Task.wait(0), Task.run(self._set_session_offsets)))
     self._set_offsets_task.kill()
     if self._show_selected:
         self._show_selected_task = self._tasks.add(
             Task.sequence(Task.wait(1),
                           Task.run(self._show_selected_track)))
     return False
コード例 #20
0
 def is_pressed(self):
     return find_if(lambda c: getattr(c, 'is_pressed', const(False))(), self.owned_control_elements()) != None
コード例 #21
0
    """
    __subject_events__ = ('break_double_press',)

    @contextmanager
    def breaking_double_press(self):
        self._broke_double_press = False
        yield
        if not self._broke_double_press:
            self.break_double_press()

    def break_double_press(self):
        self.notify_break_double_press()
        self._broke_double_press = True


GLOBAL_DOUBLE_PRESS_CONTEXT_PROVIDER = const(DoublePressContext())

class DoublePressElement(WrapperElement):
    """
    Element wrapper that provides a facade with two events,
    single_press and double_press.
    
    The single_press() and double_press() methods create non-momentary
    button-like controls that represent these events.  Note that these
    controls are individual and have their own ownership, put the
    original DoublePressElement as a hidden element of the layer where
    these are used if ownership is to be taken into account.
    """
    __subject_events__ = ('single_press', 'double_press')
    DOUBLE_PRESS_MAX_DELAY = Defaults.MOMENTARY_DELAY
コード例 #22
0
 def is_momentary(self):
     return find_if(lambda c: getattr(c, 'is_momentary', const(False))
                    (), self.nested_control_elements()) != None
コード例 #23
0
 def is_pressed(self):
     return find_if(lambda c: getattr(c, 'is_pressed', const(False))
                    (), self.owned_control_elements()) != None
コード例 #24
0
    """
    __subject_events__ = ('break_double_press', )

    @contextmanager
    def breaking_double_press(self):
        self._broke_double_press = False
        yield
        if not self._broke_double_press:
            self.break_double_press()

    def break_double_press(self):
        self.notify_break_double_press()
        self._broke_double_press = True


GLOBAL_DOUBLE_PRESS_CONTEXT_PROVIDER = const(DoublePressContext())


class DoublePressElement(WrapperElement):
    """
    Element wrapper that provides a facade with two events,
    single_press and double_press.
    
    The single_press() and double_press() methods create non-momentary
    button-like controls that represent these events.  Note that these
    controls are individual and have their own ownership, put the
    original DoublePressElement as a hidden element of the layer where
    these are used if ownership is to be taken into account.
    """
    __subject_events__ = ('single_press', 'double_press')
    DOUBLE_PRESS_MAX_DELAY = Defaults.MOMENTARY_DELAY
コード例 #25
0
ファイル: APC400000.py プロジェクト: martinpechmann/APC400000
 def make_injector(self):
     """ Adds some additional stuff to the injector, used in APCMessenger """
     return inject(
         double_press_context = const(self._double_press_context),
         control_surface = const(self),
         log_message = const(self.log_message))
コード例 #26
0
 class ProxiedInterface(EncoderElement.ProxiedInterface):
     is_pressed = const(False)
     add_touch_value_listener = nop
     remove_touch_value_listener = nop
     touch_value_has_listener = nop
コード例 #27
0
class TaskServer(Server):

    @depends(log_message = const(print_message),
             parent_task_group = None)
    def __init__(self,
                 service,
                 log_message = None,
                 parent_task_group = None,
                 *a, **k):
        super(TaskServer, self).__init__(
            service,
            *a, **k)
        self._log_message = log_message
        self._server_task = parent_task_group.add(self.tick_server).kill()
        self._all_poll = rpyc.lib.compat.poll()
        self._all_poll.register(self.listener.fileno(), 'r')
        self._fd_to_conn = {}
        self.log_message("server created")

    def start(self):
        self.listener.listen(self.backlog)
        self.logger.info("server started on [%s]:%s", self.host, self.port)
        self.active = True
        if self.auto_register:
            # [jbo] This is copied from the base class, but I am not
            # sure it will work nor needed... embedded Python often
            # needs special stuff to enable threading.
            t = threading.Thread(target = self._bg_register)
            t.setDaemon(True)
            t.start()
        self._server_task.restart()
        self.log_message("server started")

    def close(self):
        self._server_task.kill()
        super(TaskServer, self).close()
        self.log_message("server stopped")

    def log_message(self, *messages):
        self._log_message("[%s]" % self.service.get_service_name(), *messages)

    def tick_server(self, delta=None):
        left_attempts = RPYC_POLL_ATTEMPTS
        while left_attempts > 0:
            try:
                active = self._all_poll.poll(RPYC_POLL_TIMEOUT)
                attempts = 1
                for fd, evt in active:
                    if fd == self.listener.fileno():
                        self._handle_accept(fd, evt)
                    elif fd in self._fd_to_conn:
                        self._handle_serve(fd, evt)
                        if 'r' in evt:
                            attempts = RPYC_READ_ATTEMPT_FACTOR
                        elif 'w' in evt:
                            attempts = RPYC_WRITE_ATTEMPT_FACTOR
                left_attempts -= attempts
            except Exception, e:
                # The select module on Windows throws a select.error exception when any
                # of the elements in the select set is not a valid file descriptor any
                # more. It doesn't tell us which one though, so we need to iterate over
                # all fds and find out which ones no longer work.
                #
                # On Mac there's no such exception type (it only throws IOError there),
                # so we need to do these string comparisons instead of catching the
                # exception by type.
                if e.__class__.__name__ == 'error' and e.__class__.__module__ == 'select':
                    self._drop_broken_sockets_on_windows()
                else:
                    raise

        return Task.RUNNING
コード例 #28
0
 def is_momentary(self):
     return find_if(lambda c: getattr(c, 'is_momentary', const(False))(), self.nested_control_elements()) != None
コード例 #29
0
class RpycServer(Server):

    @depends(parent_task_group = None, log_message = const(print_message))
    def __init__(self, parent_task_group = None, log_message = None,
            connection_callback = lambda: None, disconnection_callback = lambda: None):
        if sys.platform == 'win32':
            kwargs = dict(hostname = rpyc_config.HOSTNAME, port = rpyc_config.PORT)
        else:
            try:
                os.unlink(rpyc_config.SOCKET_PATH)
            except OSError:
                pass
            kwargs = dict(socket_path = rpyc_config.SOCKET_PATH)
        super(RpycServer, self).__init__(LiveApiService, **kwargs)
        self._connection_callback = connection_callback
        self._disconnection_callback = disconnection_callback
        self._log_message = log_message
        self._live_task = parent_task_group.add(self._live_tick).kill()
        self._listener_poll = rpyc.lib.compat.poll()
        self._listener_poll.register(self.listener.fileno(), 'r')
        self._connection = None

    def start(self):
        self.listener.listen(1)
        self.active = True
        self._live_task.restart()
        self._log_message('server started', self.host, self.port)

    def close(self):
        super(RpycServer, self).close()
        self._live_task.kill()
        self._log_message('server stopped')

    def _live_tick(self, delta = None):
        if self._connection:
            self._serve()
        else:
            self._wait()
        return Task.RUNNING

    def _serve(self):
        try:
            """poll_all() ignores EOFError, use poll() instead
               higher timeout: lower client latency, less responsive ui
               lower timeout: higher client latency, more responsive ui"""
            timeout = Timeout(0.025)
            while not timeout.expired():
                self._connection.poll(timeout.timeleft())
        except:
            try:
                self._connection.close()
            except:
                pass
            self._connection = None
            self._disconnection_callback()
            self._log_message('client disconnected')

    def _wait(self):
        if not self._listener_poll.poll(0.01):
            return
        sock, addrinfo = self.listener.accept()
        self.clients.add(sock)
        config = dict(self.protocol_config, allow_all_attrs = True, allow_setattr = True)
        self._connection = Connection(self.service, Channel(SocketStream(sock)), config)
        self._connection_callback()
        self._log_message('client connected', addrinfo)
コード例 #30
0
 def on_nested_control_element_value(self, value, sender):
     with self._is_pressed():
         self.notify_value(value)
     if value != OFF_VALUE and not getattr(sender, 'is_momentary', const(False))():
         self.notify_value(OFF_VALUE)
コード例 #31
0
 def on_nested_control_element_value(self, value, sender):
     with self._is_pressed():
         self.notify_value(value)
     if value != OFF_VALUE and not getattr(sender, 'is_momentary',
                                           const(False))():
         self.notify_value(OFF_VALUE)