Skip to content

Commit

Permalink
Instrument controller issues fixed.
Browse files Browse the repository at this point in the history
Button lights fixed.
Every mode have it's own octave set.
Instrument channel error its fixed.
Horizontal/vertical options enabled when it's possible.
  • Loading branch information
poltow committed Dec 8, 2016
1 parent 321f9f7 commit 3da4d0f
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 58 deletions.
43 changes: 29 additions & 14 deletions InstrumentControllerComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ def __init__(self, matrix, side_buttons, top_buttons, control_surface):
self._octave_up_button = None
self._octave_down_button = None
self._scales_toggle_button = None
self.set_scales_toggle_button(side_buttons[0])
self.set_octave_up_button(side_buttons[2])
self.set_octave_down_button(side_buttons[3])
self.set_scales_toggle_button(side_buttons[0])#Enable scale selecting mode
self.set_octave_up_button(side_buttons[2])#Shift octave up
self.set_octave_down_button(side_buttons[3])#Shift octave down

self._track_controller = self.register_component(TrackControllerComponent(control_surface = control_surface, implicit_arm = True))
self._track_controller.set_enabled(False)

#Clip navigation buttons
self._track_controller.set_prev_scene_button(top_buttons[0])
self._track_controller.set_next_scene_button(top_buttons[1])
self._track_controller.set_prev_track_button(top_buttons[2])
self._track_controller.set_next_track_button(top_buttons[3])

#Clip edition buttons
self._track_controller.set_undo_button(side_buttons[1])
self._track_controller.set_stop_button(side_buttons[4])
self._track_controller.set_play_button(side_buttons[5])
Expand Down Expand Up @@ -86,6 +90,7 @@ def _set_feedback_velocity(self):
def _on_session_record_changed(self):
self._set_feedback_velocity()

# Refresh button and its listener
def set_scales_toggle_button(self, button):
assert isinstance(button, (ButtonElement, type(None)))
if (self._scales_toggle_button != None):
Expand All @@ -95,6 +100,7 @@ def set_scales_toggle_button(self, button):
self._scales_toggle_button.add_value_listener(self._scales_toggle, identify_sender=True)
self._scales_toggle_button.turn_off()

# Refresh button and its listener
def set_octave_up_button(self, button=None):
assert isinstance(button, (ButtonElement, type(None)))
if (self._octave_up_button != None):
Expand All @@ -104,6 +110,7 @@ def set_octave_up_button(self, button=None):
self._octave_up_button.add_value_listener(self._scroll_octave_up, identify_sender=True)
self._octave_up_button.turn_off()

# Refresh button and its listener
def set_octave_down_button(self, button=None):
assert isinstance(button, (ButtonElement, type(None)))
if (self._octave_down_button != None):
Expand All @@ -113,6 +120,7 @@ def set_octave_down_button(self, button=None):
self._octave_down_button.add_value_listener(self._scroll_octave_down, identify_sender=True)
self._octave_down_button.turn_off()

#Enables scale selection mode
def _scales_toggle(self, value, sender):
if self.is_enabled():
if (value is not 0):
Expand All @@ -132,28 +140,30 @@ def _scales_toggle(self, value, sender):
self._osd.mode = self._osd_mode_backup
self.update()

def _can_scroll_octave_up(self):
return self._scales._octave < 10

def _can_scroll_octave_down(self):
return self._scales._octave > -2

# Transposes key one octave up
def _scroll_octave_up(self, value, sender):
if self.is_enabled():
if ((not sender.is_momentary()) or (value is not 0)):
if self._can_scroll_octave_up():
self._scales._octave += 1
self.update()

def _can_scroll_octave_up(self):
return self._scales._octave < 10

# Transposes key one octave down
def _scroll_octave_down(self, value, sender):
if self.is_enabled():
if ((not sender.is_momentary()) or (value is not 0)):
if self._can_scroll_octave_down():
self._scales._octave -= 1
self.update()

def _can_scroll_octave_down(self):
return self._scales._octave > -2


#Handles scale setting and configuration
def _matrix_value_quickscale(self, value, x, y, is_momentary): # matrix buttons listener for advanced mode
if self.is_enabled() and not self._scales.is_enabled() and self._scales.is_quick_scale:
keys = ["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]
Expand Down Expand Up @@ -254,6 +264,7 @@ def _matrix_value_quickscale(self, value, x, y, is_momentary): # matrix buttons
self._scales.update_object_name(self._track_controller.selected_clip)
self._control_surface.show_message("mode : "+str(self._scales._modus_names[self._scales._modus]))
self.update()


def update(self):
if self.is_enabled():
Expand Down Expand Up @@ -319,6 +330,7 @@ def _update_OSD(self):
self._osd.info[1] = " "
self._osd.update()

# Refresh matrix and its listener
def set_matrix(self, matrix):
self._matrix = matrix
if matrix:
Expand All @@ -331,6 +343,7 @@ def set_matrix(self, matrix):
self._matrix.add_value_listener(self._matrix_value_quickscale)
self._update_matrix()

#Listener, setup drumrack scale mode and load the selected scale for Track/Cip (Disabled)
def on_selected_track_changed(self):
if self._track_controller._implicit_arm:
self._get_drumrack_device()
Expand All @@ -357,6 +370,7 @@ def on_selected_scene_changed(self):

self.update()

#Set the drum rack instrument to _drum_group_device variable, if it exists
def _get_drumrack_device(self):
if self._track_controller.selected_track != None:
track = self._track_controller.selected_track
Expand All @@ -372,6 +386,7 @@ def _get_drumrack_device(self):
else:
self._drum_group_device = None

#Return the drum device inside the track devices or inside the track chain or None if device is not a Drum
def find_drum_group_device(self, track):
device = find_if(lambda d: d.type == Live.Device.DeviceType.instrument, track.devices)
if device:
Expand All @@ -383,7 +398,6 @@ def find_drum_group_device(self, track):
return None

def _update_matrix(self):

if not self.is_enabled() or not self._matrix or self._scales.is_enabled():
self._control_surface.release_controlled_track()
# self._control_surface.set_feedback_channels([])
Expand All @@ -396,14 +410,14 @@ def _update_matrix(self):
for i in range(128):
note_channel[i] = self.base_channel

# select drumrack device
# Validate if device is drumrack (assign _drum_group_device)
self._get_drumrack_device()

if self._scales.is_drumrack and not self._scales.is_diatonic and not self._scales.is_chromatic:
if self._drum_group_device != None:
self._scales._is_drumrack = True
self._scales.set_drumrack(True)
else:
self._scales._is_drumrack = False
self._scales.set_drumrack(False)

for button, (x, y) in self._matrix.iterbuttons():
button.use_default_message()
Expand Down Expand Up @@ -547,7 +561,8 @@ def _update_matrix(self):
# comment the line above and use the one below if you want instrument controller to use one channel instead of 3
# button.set_channel(note_channel[0])
button.set_identifier(note_info.index)
note_channel[note_info.index] = note_channel[note_info.index] + 1
if(note_channel[note_info.index]<15):
note_channel[note_info.index] = note_channel[note_info.index] + 1
else:
button.set_channel(non_feedback_channel)
button.set_identifier(a)
Expand Down
10 changes: 5 additions & 5 deletions MainSelectorComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def __init__(self, matrix, top_buttons, side_buttons, config_button, osd, contro
self._sub_modes._mixer.set_osd(self._osd)
self._sub_modes.set_update_callback(self._update_control_channels)

#User2 stepSequencer (Drum)
#User2 stepSequencer (Drum & Melodic)
self._stepseq = StepSequencerComponent(self._matrix, self._side_buttons, self._nav_buttons, self._control_surface)
self._stepseq.set_osd(self._osd)

#User2 stepSequencer (Melodic)
#User2 stepSequencer (Retro style)
self._stepseq2 = StepSequencerComponent2(self._matrix, self._side_buttons, self._nav_buttons, self._control_surface)
self._stepseq2.set_osd(self._osd)

Expand Down Expand Up @@ -271,7 +271,7 @@ def _setup_sub_mode(self, mode):
self._setup_instrument_controller(as_active)
self._mode_index = 4
elif mode == "melodic stepseq":
self._control_surface.show_message("MELODIC SEQUENCER MODE")
self._control_surface.show_message("RETRO SEQUENCER MODE")
self._setup_session(not as_active, not as_enabled)
self._setup_instrument_controller(not as_active)
self._setup_device_controller(not as_active)
Expand All @@ -295,7 +295,7 @@ def _setup_sub_mode(self, mode):
self._osd.mode = "User 1"
self._osd.update()
elif mode == "drum stepseq":
self._control_surface.show_message("DRUM SEQUENCER MODE")
self._control_surface.show_message("DRUM/MELODIC SEQUENCER MODE")
self._setup_session(not as_active, not as_enabled)
self._setup_instrument_controller(not as_active)
self._setup_device_controller(not as_active)
Expand Down Expand Up @@ -376,7 +376,7 @@ def _setup_session(self, as_active, as_navigation_enabled):
self._session.set_stop_all_clips_button(None)

if as_active:# zoom
self._zooming.set_zoom_button(self._modes_buttons[0])# Set Session button as zoom button, wrong behavior???
self._zooming.set_zoom_button(self._modes_buttons[0])# Set Session button as zoom shift button
self._zooming.set_button_matrix(self._matrix)
self._zooming.set_scene_bank_buttons(self._side_buttons)
self._zooming.set_nav_buttons(self._nav_buttons[0], self._nav_buttons[1], self._nav_buttons[2], self._nav_buttons[3])
Expand Down
Loading

0 comments on commit 3da4d0f

Please sign in to comment.