当前位置: 首页>>代码示例>>Python>>正文


Python ChannelTranslationSelector.set_mode方法代码示例

本文整理汇总了Python中_Framework.ChannelTranslationSelector.ChannelTranslationSelector.set_mode方法的典型用法代码示例。如果您正苦于以下问题:Python ChannelTranslationSelector.set_mode方法的具体用法?Python ChannelTranslationSelector.set_mode怎么用?Python ChannelTranslationSelector.set_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_Framework.ChannelTranslationSelector.ChannelTranslationSelector的用法示例。


在下文中一共展示了ChannelTranslationSelector.set_mode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MaschineDeviceComponent

# 需要导入模块: from _Framework.ChannelTranslationSelector import ChannelTranslationSelector [as 别名]
# 或者: from _Framework.ChannelTranslationSelector.ChannelTranslationSelector import set_mode [as 别名]
class MaschineDeviceComponent(DeviceComponent):
    """ Class representing a device in Live """

    def __init__(self, surface):
        DeviceComponent.__init__(self)
        self.surface = surface
        self.device_listener = None
        self.device_parm_listener = None
        self._control_translation_selector = ChannelTranslationSelector(8)

    def set_device(self, device):
        DeviceComponent.set_device(self, device)
        if self.device_listener != None:
            self.device_listener(device)

    def set_parameter_controls(self, controls):
        DeviceComponent.set_parameter_controls(self, controls)
        self._control_translation_selector.set_controls_to_translate(controls)
        self._control_translation_selector.set_mode(self._bank_index)

    def _on_parameters_changed(self):
        DeviceComponent._on_parameters_changed(self)
        if self.device_parm_listener != None:
            self.device_parm_listener()

    def set_device_changed_listener(self, listener):
        self.device_listener = listener

    def set_device_parm_listener(self, listener):
        self.device_parm_listener = listener

    def show_message(self, message):
        self.surface.show_message(message)

    def disconnect(self):
        DeviceComponent.disconnect(self)
        self._control_translation_selector.disconnect()
        self.surface = None
        self.device_listener = None
        self.device_parm_listener = None
开发者ID:AngeousaQ,项目名称:AbletonLive9_RemoteScripts,代码行数:42,代码来源:MaschineDeviceComponent.py

示例2: ShiftableDeviceComponent

# 需要导入模块: from _Framework.ChannelTranslationSelector import ChannelTranslationSelector [as 别名]
# 或者: from _Framework.ChannelTranslationSelector.ChannelTranslationSelector import set_mode [as 别名]
class ShiftableDeviceComponent(DeviceComponent):
    """ DeviceComponent that only uses bank buttons if a shift button is pressed """

    def __init__(self):
        DeviceComponent.__init__(self)
        self._shift_button = None
        self._shift_pressed = False
        self._control_translation_selector = ChannelTranslationSelector(8)

    def disconnect(self):
        DeviceComponent.disconnect(self)
        self._control_translation_selector.disconnect()
        if self._shift_button != None:
            self._shift_button.remove_value_listener(self._shift_value)
            self._shift_button = None

    def set_parameter_controls(self, controls):
        DeviceComponent.set_parameter_controls(self, controls)
        self._control_translation_selector.set_controls_to_translate(controls)
        self._control_translation_selector.set_mode(self._bank_index)

    def set_device(self, device):
        DeviceComponent.set_device(self, device)
        self._control_translation_selector.set_mode(self._bank_index)

    def set_shift_button(self, button):
        if not (button == None or isinstance(button, ButtonElement) and button.is_momentary()):
            raise AssertionError
            if self._shift_button != button:
                if self._shift_button != None:
                    self._shift_button.remove_value_listener(self._shift_value)
                self._shift_button = button
                self._shift_button != None and self._shift_button.add_value_listener(self._shift_value)
            self.update()

    def update(self):
        if self._parameter_controls != None:
            for control in self._parameter_controls:
                control.release_parameter()

        if self.is_enabled() and self._device != None:
            self._device_bank_registry.set_device_bank(self._device, self._bank_index)
            if self._parameter_controls != None:
                if self._bank_index < number_of_parameter_banks(self._device):
                    old_bank_name = self._bank_name
                    self._assign_parameters()
                    if self._bank_name != old_bank_name:
                        self._show_msg_callback(self._device.name + ' Bank: ' + self._bank_name)
            self._shift_pressed or self._on_on_off_changed()
        elif self._bank_buttons != None:
            for index in range(len(self._bank_buttons)):
                if index == self._bank_index:
                    self._bank_buttons[index].turn_on()
                else:
                    self._bank_buttons[index].turn_off()

    def _shift_value(self, value):
        raise self._shift_button != None or AssertionError
        raise value in range(128) or AssertionError
        self._shift_pressed = value != 0
        self.update()

    def _bank_value(self, value, sender):
        if not (sender != None and sender in self._bank_buttons):
            raise AssertionError
            if self._shift_pressed and self.is_enabled():
                self._bank_name = (value != 0 or not sender.is_momentary()) and ''
                self._bank_index = list(self._bank_buttons).index(sender)
                self._control_translation_selector.set_mode(self._bank_index)
                self.update()

    def _on_off_value(self, value):
        if not self._shift_pressed:
            DeviceComponent._on_off_value(self, value)

    def _on_on_off_changed(self):
        if not self._shift_pressed:
            DeviceComponent._on_device_on_off_changed(self)
开发者ID:burij,项目名称:CMD-LC-1-Ableton-9-Control-Surface-Script,代码行数:80,代码来源:ShiftableDeviceComponent.py

示例3: ShiftableDeviceComponent

# 需要导入模块: from _Framework.ChannelTranslationSelector import ChannelTranslationSelector [as 别名]
# 或者: from _Framework.ChannelTranslationSelector.ChannelTranslationSelector import set_mode [as 别名]
class ShiftableDeviceComponent(DeviceComponent):
    ' DeviceComponent that only uses bank buttons if a shift button is pressed '
    __module__ = __name__

    def __init__(self):
        DeviceComponent.__init__(self)
        self._shift_button = None
        self._shift_pressed = False
        self._control_translation_selector = ChannelTranslationSelector(8)


    def disconnect(self):
        DeviceComponent.disconnect(self)
        self._control_translation_selector.disconnect()
        if (self._shift_button != None):
            self._shift_button.remove_value_listener(self._shift_value)
            self._shift_button = None


    def set_parameter_controls(self, controls):
        DeviceComponent.set_parameter_controls(self, controls)
        self._control_translation_selector.set_controls_to_translate(controls)
        self._control_translation_selector.set_mode(self._bank_index)



    def set_device(self, device):
        DeviceComponent.set_device(self, device)
        self._control_translation_selector.set_mode(self._bank_index)



    def set_shift_button(self, button):
        assert ((button == None) or (isinstance(button, ButtonElement) and button.is_momentary()))
        if (self._shift_button != button):
            if (self._shift_button != None):
                self._shift_button.remove_value_listener(self._shift_value)
            self._shift_button = button
            if (self._shift_button != None):
                self._shift_button.add_value_listener(self._shift_value)
            self.update()



    def update(self):
        if (self._parameter_controls != None):
            for control in self._parameter_controls:
                control.release_parameter()

        if (self.is_enabled() and (self._device != None)):
            self._device_bank_registry[self._device] = self._bank_index
            if ((self._parameter_controls != None) and (self._bank_index < number_of_parameter_banks(self._device))):
                old_bank_name = self._bank_name
                self._assign_parameters()
                if (self._bank_name != old_bank_name):
                    self._show_msg_callback(((self._device.name + ' Bank: ') + self._bank_name))

        if (not self._shift_pressed):
            self._on_on_off_changed()

        elif (self._bank_buttons != None):
            for index in range(len(self._bank_buttons)):
                if (index == self._bank_index):
                    self._bank_buttons[index].turn_on()
                else:
                    self._bank_buttons[index].turn_off()

        #self._rebuild_callback()



    def _shift_value(self, value):
        assert (self._shift_button != None)
        assert (value in range(128))
        self._shift_pressed = (value != 0)
        self.update()



    def _bank_value(self, value, sender):
        assert ((sender != None) and (sender in self._bank_buttons))
        if (self._shift_pressed and self.is_enabled()):
            if ((value != 0) or (not sender.is_momentary())):
                self._bank_name = ''
                self._bank_index = list(self._bank_buttons).index(sender)
                self._control_translation_selector.set_mode(self._bank_index)
                self.update()



    def _on_off_value(self, value):
        if not self._shift_pressed:
            DeviceComponent._on_off_value(self, value)



    def _on_on_off_changed(self):
        if not self._shift_pressed:
            DeviceComponent._on_on_off_changed(self)

#.........这里部分代码省略.........
开发者ID:bshmidt,项目名称:AbletonDJTemplate,代码行数:103,代码来源:ShiftableDeviceComponent.py

示例4: MaschineDeviceComponent

# 需要导入模块: from _Framework.ChannelTranslationSelector import ChannelTranslationSelector [as 别名]
# 或者: from _Framework.ChannelTranslationSelector.ChannelTranslationSelector import set_mode [as 别名]

#.........这里部分代码省略.........
                self._lock_button.turn_off()
            if self._bank_up_button != None:
                self._bank_up_button.turn_off()
            if self._bank_down_button != None:
                self._bank_down_button.turn_off()
            if self._bank_buttons != None:
                for button in self._bank_buttons:
                    button.turn_off()

            if self._parameter_controls != None:
                self._release_parameters(self._parameter_controls)

    def set_touch_mode(self, touchchannel):
        self.touch_mode = True
        nr_dev_ctrl = len(self._parameter_controls)
        for ctrl in self._parameter_controls:
            touch_button = ButtonElement(False, MIDI_CC_TYPE, touchchannel, ctrl.message_identifier())
            self.del_touch_buttons.append(touch_button)
            touch_button.add_value_listener(self._clear_param, True)

    def enter_clear_mode(self):
        self.clear_mode = True
        self.del_parm_map = {}
        self.del_clip_map = {}
        for control in self._parameter_controls:
            key = control.message_identifier()
            self.del_parm_map[key] = control.mapped_parameter()
            self.touch_mode or control.add_value_listener(self._clear_param, True)

        self.touch_mode or self.set_enabled(False)

    def exit_clear_mode(self):
        self.clear_mode = False
        self.touch_mode or self.set_enabled(True)
        for control in self._parameter_controls:
            self.touch_mode or control.remove_value_listener(self._clear_param)

    def _get_track_of_device(self, obj):
        if obj != None:
            parent = obj.canonical_parent
            if isinstance(parent, Live.Track.Track):
                return parent
            else:
                return self._get_track_of_device(parent)

    def _get_clip_of_device(self):
        track = self._get_track_of_device(self._device)
        if track:
            if track.can_be_armed:
                for clip_slot in track.clip_slots:
                    if clip_slot.has_clip and clip_slot.is_playing:
                        return clip_slot.clip

    def _clear_param(self, value, control):
        key = control.message_identifier()
        if self._device and key in self.del_parm_map:
            if not (key in self.del_clip_map and self.del_clip_map[key]):
                prev_clip = None
                clip = self._get_clip_of_device()
                clip and clip != prev_clip and clip.clear_envelope(self.del_parm_map[key])
                self.del_clip_map[key] = clip

    def set_device(self, device):
        DeviceComponent.set_device(self, device)
        if self.device_listener != None:
            self.device_listener(device)

    def set_parameter_controls(self, controls):
        DeviceComponent.set_parameter_controls(self, controls)
        self._control_translation_selector.set_controls_to_translate(controls)
        self._control_translation_selector.set_mode(self._bank_index)

    def _on_parameters_changed(self):
        DeviceComponent._on_parameters_changed(self)
        if self.device_parm_listener != None:
            self.device_parm_listener()

    def set_device_changed_listener(self, listener):
        self.device_listener = listener

    def set_device_parm_listener(self, listener):
        self.device_parm_listener = listener

    def show_message(self, message):
        self.canonical_parent.show_message(message)

    def disconnect(self):
        self._control_translation_selector.disconnect()
        self.device_listener = None
        self.device_parm_listener = None
        self.del_parm_map = None
        self.del_clip_map = None
        for touch_button in self.del_touch_buttons:
            touch_button.remove_value_listener(self._clear_param)

        if self.clear_mode and not self.touch_mode:
            for control in self._parameter_controls:
                self.touch_mode and control.remove_value_listener(self._clear_param)

        DeviceComponent.disconnect(self)
开发者ID:AkiSyndicat,项目名称:AbletonLive9_RemoteScripts,代码行数:104,代码来源:MaschineDeviceComponent.py


注:本文中的_Framework.ChannelTranslationSelector.ChannelTranslationSelector.set_mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。