def handle_edit_action(self, index, scale=None):
     if not self.__shift_down:
         return
     if index == 0:
         if self.song().can_undo == 1:
             self.song().undo()
             self.canonical_parent.show_message(str('UNDO'))
     else:
         if index == 1:
             if self.song().can_redo == 1:
                 self.song().redo()
                 self.canonical_parent.show_message(str('REDO'))
         else:
             if index == 2 or index == 3:
                 clip = self.song().view.detail_clip
                 if clip:
                     clip.quantize(QUANT_CONST[self.__quantize_setting],
                                   index == 2 and 1.0 or 0.5)
                     self.canonical_parent.show_message(
                         'Quantize Clip ' + clip.name + ' by ' +
                         QUANT_STRING[self.__quantize_setting])
             else:
                 clip = self.song().view.detail_clip
                 if clip and clip.is_midi_clip:
                     track = clip.canonical_parent.canonical_parent
                     drum_device = find_drum_device(track)
                     if not drum_device:
                         self.__transpose_clip(clip, TRANSPOSE[index],
                                               scale)
 def enter_step_mode(self, show_info=True, block_clip_creation=False):
     clip = self.song().view.detail_clip
     if not clip and not block_clip_creation:
         clip = self.create_clip_on_track()
     if not clip or not clip.is_midi_clip:
         return
     selected_track = self.song().view.selected_track
     if not selected_track or not selected_track.has_midi_input:
         return
     self.ensure_reset_note_repeat_mode()
     self._light_button(2)
     selected_track = clip.canonical_parent.canonical_parent
     drum_device = find_drum_device(selected_track)
     if drum_device:
         show_info and self._show_msg_callback('Drum Step Mode')
         with self.rebuild():
             if self._mode != self._drum_step_mode:
                 self._mode.exit()
                 self._mode = self._drum_step_mode
             self._light_button(2)
             self._mode.enter()
             self._drum_step_mode.register_page_handler()
             self._defer_action = lambda : self._drum_step_mode.arm_to_clip()
     else:
         show_info and self._show_msg_callback('Step Mode')
         with self.rebuild():
             if self._mode != self._step_mode:
                 self._mode.exit()
                 self._mode = self._step_mode
             self._light_button(2)
             self._mode.enter()
             self._step_mode.register_page_handler()
     self._mode_group = MG_STEP
Beispiel #3
0
 def fitting_mode(self, track):
     if not track:
         return self
     drum_device = find_drum_device(track)
     if drum_device == None and self._alternate_mode != None:
         return self._alternate_mode
     return self
Beispiel #4
0
 def assign_track_device(self):
     if self.device and self.device.view:
         self._on_scroll_index_changed.subject = None
         self._on_selected_drum_pad_changed.subject = None
         self._on_name_changed.subject = None
     self.track = self.song().view.selected_track
     self.device = find_drum_device(self.track)
     if self.device:
         self._on_scroll_index_changed.subject = self.device.view
         self._on_selected_drum_pad_changed.subject = self.device.view
         self._on_name_changed.subject = self.device
     self.assign_pads()
     return
 def __handle_possible_instrument_change(self):
     drum_device = find_drum_device(self.song().view.selected_track)
     if drum_device:
         if self._mode == self._pad_mode:
             self.enter_pad_mode()
         elif self._mode == self._step_mode:
             self.enter_step_mode(False, True)
     else:
         if self._mode == self._drum_pad_mode:
             self.enter_pad_mode()
         else:
             if self._mode == self._drum_step_mode:
                 self.enter_step_mode(False, True)
 def enter_pad_mode(self, show_info=True, check_drum_device=0):
     if show_info:
         self._show_msg_callback('PAD Mode')
     selected_track = self.song().view.selected_track
     if not selected_track or not selected_track.has_midi_input:
         return
     drum_device = find_drum_device(selected_track)
     if drum_device:
         with self.rebuild():
             self._mode.exit()
             self._mode.spec_unbind()
             self._mode = self._drum_pad_mode
             self._light_button(1)
             self._mode.enter()
     else:
         with self.rebuild():
             self._mode.exit()
             self._mode.spec_unbind()
             self._mode = self._pad_mode
             self._light_button(1)
             self._mode.enter()
     self._mode_group = MG_PAD