示例#1
0
	def __init__(self, parent, control_surface, skin, grid_resolution, parent_task_group, settings = DEFAULT_INSTRUMENT_SETTINGS, *a, **k):
		super(MonoDrumpadComponent, self).__init__(*a, **k)
		self._settings = settings
		self._parent = parent
		self._control_surface = control_surface
		self._skin = skin
		self._grid_resolution = grid_resolution

		self._drum_offset_component = self.register_component(self._offset_settings_component_class(attribute_tag = 'drum_offset', name = 'DrumPadOffset', parent_task_group = parent_task_group, value_dict = range(28), default_value_index = self._settings['DefaultDrumOffset'], default_channel = 0, bank_increment = 4, on_color = 'MonoInstrument.OffsetOnValue', off_color = 'MonoInstrument.OffsetOffValue'))
		self._drum_offset_value.subject = self._drum_offset_component
		self.set_offset_shift_toggle = self._drum_offset_component.shift_toggle.set_control_element

		self._drumgroup = MonoDrumGroupComponent(translation_channel = 3, set_pad_translations = self._control_surface.set_pad_translations, channel_list = self._settings['Channels'], settings = self._settings)
		self._drumpad_position_value.subject = self._drumgroup
		self.set_drumpad_matrix = self._drumgroup.set_matrix
		self.set_drumpad_select_matrix = self._drumgroup.set_select_matrix

		drum_clip_creator = ClipCreator()
		drum_note_editor = MonoNoteEditorComponent(clip_creator=drum_clip_creator, grid_resolution=grid_resolution)
		self._step_sequencer = MonoStepSeqComponent(clip_creator=drum_clip_creator, skin=skin, grid_resolution=grid_resolution, name='Drum_Sequencer', note_editor_component=drum_note_editor, instrument_component=self._drumgroup)
		self._step_sequencer._playhead_component._notes=tuple(chain(*starmap(range, ((64, 68), (56, 60), (48, 52), (40, 44)))))
		self._step_sequencer._playhead_component._triplet_notes=tuple(chain(*starmap(range, ((64, 67), (56, 59), (48, 51), (40, 43)))))
		self._step_sequencer._playhead_component._feedback_channels = [15]
		self._step_sequencer._note_editor._visible_steps_model = lambda indices: filter(lambda k: k % 4 != 3, indices)
		self.set_sequencer_matrix = self._step_sequencer.set_button_matrix
		self.set_playhead = self._step_sequencer.set_playhead
		self.set_loop_selector_matrix = self._step_sequencer.set_loop_selector_matrix 
		self.set_quantization_buttons = self._step_sequencer.set_quantization_buttons
		self.set_follow_button = self._step_sequencer.set_follow_button
		self.set_follow_button = self._step_sequencer.set_follow_button
		self.set_mute_button = self._step_sequencer.set_mute_button
		self.set_solo_button = self._step_sequencer.set_solo_button
		self.register_component(self._step_sequencer)

		self.set_split_matrix = self._parent._selected_session.set_clip_launch_buttons
class MonoDrumpadComponent(CompoundComponent):


	_offset_settings_component_class = OffsetTaggedSetting

	def __init__(self, parent, control_surface, skin, grid_resolution, parent_task_group, settings = DEFAULT_INSTRUMENT_SETTINGS, *a, **k):
		super(MonoDrumpadComponent, self).__init__(*a, **k)
		self._settings = settings
		self._parent = parent
		self._control_surface = control_surface
		self._skin = skin
		self._grid_resolution = grid_resolution

		self._drum_offset_component = self.register_component(self._offset_settings_component_class(attribute_tag = 'drum_offset', name = 'DrumPadOffset', parent_task_group = parent_task_group, value_dict = range(28), default_value_index = self._settings['DefaultDrumOffset'], default_channel = 0, bank_increment = 4, on_color = 'MonoInstrument.OffsetOnValue', off_color = 'MonoInstrument.OffsetOffValue'))
		self._drum_offset_value.subject = self._drum_offset_component
		self.set_offset_shift_toggle = self._drum_offset_component.shift_toggle.set_control_element

		self._drumgroup = MonoDrumGroupComponent(translation_channel = 3, set_pad_translations = self._control_surface.set_pad_translations, channel_list = self._settings['Channels'], settings = self._settings)
		self._drumpad_position_value.subject = self._drumgroup
		self.set_drumpad_matrix = self._drumgroup.set_matrix
		self.set_drumpad_select_matrix = self._drumgroup.set_select_matrix

		drum_clip_creator = ClipCreator()
		drum_note_editor = MonoNoteEditorComponent(clip_creator=drum_clip_creator, grid_resolution=grid_resolution)
		self._step_sequencer = MonoStepSeqComponent(clip_creator=drum_clip_creator, skin=skin, grid_resolution=grid_resolution, name='Drum_Sequencer', note_editor_component=drum_note_editor, instrument_component=self._drumgroup)
		self._step_sequencer._playhead_component._notes=tuple(chain(*starmap(range, ((64, 68), (56, 60), (48, 52), (40, 44)))))
		self._step_sequencer._playhead_component._triplet_notes=tuple(chain(*starmap(range, ((64, 67), (56, 59), (48, 51), (40, 43)))))
		self._step_sequencer._playhead_component._feedback_channels = [15]
		self._step_sequencer._note_editor._visible_steps_model = lambda indices: filter(lambda k: k % 4 != 3, indices)
		self.set_sequencer_matrix = self._step_sequencer.set_button_matrix
		self.set_playhead = self._step_sequencer.set_playhead
		self.set_loop_selector_matrix = self._step_sequencer.set_loop_selector_matrix 
		self.set_quantization_buttons = self._step_sequencer.set_quantization_buttons
		self.set_follow_button = self._step_sequencer.set_follow_button
		self.set_follow_button = self._step_sequencer.set_follow_button
		self.set_mute_button = self._step_sequencer.set_mute_button
		self.set_solo_button = self._step_sequencer.set_solo_button
		self.register_component(self._step_sequencer)

		self.set_split_matrix = self._parent._selected_session.set_clip_launch_buttons
	

	@listens('value')
	def _drum_offset_value(self, value):
		self._drumgroup.position = value
		self._drum_offset_component.buttons_are_pressed() and self._control_surface.show_message('New drum root is ' + str(value))
		#debug('_drum_offset_value', value)
	

	@listens('position')
	def _drumpad_position_value(self):
		self._drum_offset_component.set_index(self._drumgroup.position)
	

	def update(self):
		self._drumgroup._update_assigned_drum_pads()
		self._drumgroup._create_and_set_pad_translations()
		super(MonoDrumpadComponent, self).update()
class MonoDrumpadComponent(Component):

    _offset_settings_component_class = OffsetTaggedSetting

    def __init__(self,
                 parent,
                 control_surface,
                 skin,
                 grid_resolution,
                 parent_task_group,
                 settings=DEFAULT_INSTRUMENT_SETTINGS,
                 *a,
                 **k):
        super(MonoDrumpadComponent, self).__init__(*a, **k)
        self._settings = settings
        self._parent = parent
        self._control_surface = control_surface
        self._skin = skin
        self._grid_resolution = grid_resolution

        #self._drum_offset_component = self.register_component(self._offset_settings_component_class(attribute_tag = 'drum_offset', name = 'DrumPadOffset', parent_task_group = parent_task_group, value_dict = range(28), default_value_index = self._settings['DefaultDrumOffset'], default_channel = 0, bank_increment = 4, on_color = 'MonoInstrument.OffsetOnValue', off_color = 'MonoInstrument.OffsetOffValue'))
        self._drum_offset_component = self._offset_settings_component_class(
            parent=self,
            attribute_tag='drum_offset',
            name='DrumPadOffset',
            parent_task_group=parent_task_group,
            value_dict=list(range(28)),
            default_value_index=self._settings['DefaultDrumOffset'],
            default_channel=0,
            bank_increment=4,
            on_color='MonoInstrument.OffsetOnValue',
            off_color='MonoInstrument.OffsetOffValue')
        self._drum_offset_value.subject = self._drum_offset_component
        self.set_offset_shift_toggle = self._drum_offset_component.shift_toggle.set_control_element

        self._drumgroup = MonoDrumGroupComponent(
            translation_channel=3,
            set_pad_translations=self._control_surface.set_pad_translations,
            channel_list=self._settings['Channels'],
            settings=self._settings)
        self._drumpad_position_value.subject = self._drumgroup
        self.set_drumpad_matrix = self._drumgroup.set_matrix
        self.set_drumpad_select_matrix = self._drumgroup.set_select_matrix

        drum_clip_creator = ClipCreator()
        drum_note_editor = MonoNoteEditorComponent(
            clip_creator=drum_clip_creator, grid_resolution=grid_resolution)
        self._step_sequencer = MonoStepSeqComponent(
            parent=self,
            clip_creator=drum_clip_creator,
            skin=skin,
            grid_resolution=grid_resolution,
            name='Drum_Sequencer',
            note_editor_component=drum_note_editor,
            instrument_component=self._drumgroup)
        #self._step_sequencer._playhead_component._notes=tuple(range(32))
        #self._step_sequencer._playhead_component._triplet_notes=tuple(range(28))
        #self._step_sequencer._playhead_component._feedback_channels = [15]
        #self._step_sequencer._note_editor._visible_steps_model = lambda indices: filter(lambda k: k % 16 not in (13, 14, 15, 16), indices)
        self.set_sequencer_matrix = self._step_sequencer.set_button_matrix
        self.set_playhead = self._step_sequencer.set_playhead
        self.set_loop_selector_matrix = self._step_sequencer.set_loop_selector_matrix
        self.set_quantization_buttons = self._step_sequencer.set_quantization_buttons
        self.set_follow_button = self._step_sequencer.set_follow_button
        self.set_follow_button = self._step_sequencer.set_follow_button
        self.set_mute_button = self._step_sequencer.set_mute_button
        self.set_solo_button = self._step_sequencer.set_solo_button
        #self.register_component(self._step_sequencer)

        self.set_split_matrix = self._parent._selected_session.set_clip_launch_buttons

    @listens('value')
    def _drum_offset_value(self, value):
        self._drumgroup.position = value
        self._drum_offset_component.buttons_are_pressed(
        ) and self._control_surface.show_message('New drum root is ' +
                                                 str(value))
        #debug('_drum_offset_value', value)

    @listens('position')
    def _drumpad_position_value(self):
        self._drum_offset_component.set_index(self._drumgroup.position)

    def update(self):
        self._drumgroup._update_assigned_drum_pads()
        self._drumgroup._create_and_set_pad_translations()
        super(MonoDrumpadComponent, self).update()