Skip to content

Commit

Permalink
remove remainings of scale saving. add option to autoscroll in step s…
Browse files Browse the repository at this point in the history
…equencer fixes #71
  • Loading branch information
Henri DAVID authored and hdavid committed Sep 26, 2023
1 parent 65f4ae1 commit b8b5b94
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 67 deletions.
36 changes: 1 addition & 35 deletions InstrumentControllerComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ def set_enabled(self, enabled):
self._track_controller.set_enabled(enabled)

if enabled:
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "track":
self._scales.from_object(self._track_controller.selected_track)
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
self._scales.from_object(self._track_controller.selected_clip)
self._update_OSD()
self.on_selected_track_changed()

Expand Down Expand Up @@ -219,11 +215,6 @@ def _scales_toggle(self, value, sender):
else:
self._scales_toggle_button.turn_off()
self._scales.set_enabled(False)
#TODO: save scale setting in track or clip. detect if changed
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "track":
self._scales.update_object_name(self._track_controller.selected_track)
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
self._scales.update_object_name(self._track_controller.selected_clip)
self._osd.mode = self._osd_mode_backup
if(not self._scales.is_quick_scale):
self._note_repeat.set_enabled(False)
Expand Down Expand Up @@ -350,22 +341,13 @@ def _matrix_value_quickscale(self, value, x, y, is_momentary): # matrix buttons
if root != -1:
self._scales.set_modus(selected_modus, False)
self._scales.set_key(root, False)
# TODO: save scale in clip or track name
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "track":
self._scales.update_object_name(self._track_controller.selected_track)
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
self._scales.update_object_name(self._track_controller.selected_clip)
self.update()

elif self._quick_scale_root==1:
if(y == 0):
if x < 7 and self._quick_scales[x] != -1:
self._scales.set_modus(self._quick_scales[x])
#TODO: save scale in clip or track name
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "track":
self._scales.update_object_name(self._track_controller.selected_track)
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
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()
if x == 7:
Expand All @@ -374,11 +356,6 @@ def _matrix_value_quickscale(self, value, x, y, is_momentary): # matrix buttons
if(y == 1):
if x < 8 and self._quick_scales[x + 7] != -1:
self._scales.set_modus(self._quick_scales[x + 7])
#TODO: save scale in clip or track name
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "track":
self._scales.update_object_name(self._track_controller.selected_track)
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
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()
else:
Expand Down Expand Up @@ -506,22 +483,11 @@ def on_selected_track_changed(self):
else:
self._scales.set_drumrack(False)

#load scale settings from track
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "track":
self._scales.from_object(self._track_controller.selected_track)
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
self._scales.from_object(self._track_controller.selected_clip)
# must be delayed.... self._scales.update_object_name(track)
self._note_repeat.set_enabled(False)
self.update()

def on_selected_scene_changed(self):
if self._track_controller._implicit_arm:
#load scale settings from track
if Settings.INSTRUMENT__SAVE_SCALE != None and Settings.INSTRUMENT__SAVE_SCALE == "clip":
self._scales.from_object(self._track_controller.selected_clip)
# must be delayed.... self._scales.update_object_name(track)

if self._track_controller._implicit_arm:
self.update()

#Set the drum rack instrument to _drum_group_device variable, if it exists
Expand Down
6 changes: 4 additions & 2 deletions LoopSelectorComponent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time


from _Framework.ButtonElement import ButtonElement
from _Framework.ControlSurfaceComponent import ControlSurfaceComponent

Expand Down Expand Up @@ -60,8 +59,11 @@ def _mode(self):
def set_note_cache(self, note_cache):
self._note_cache = note_cache

def set_playhead(self, playhead):
def set_playhead(self, playhead, updateBlock=False):
self._playhead = playhead
if updateBlock and self._playhead is not None:
self._block = int(self._playhead / self._blocksize / self._quantization)
self._step_sequencer.set_page(self._block)
self.update()

@property
Expand Down
12 changes: 4 additions & 8 deletions Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class Settings():
#STEPSEQ__LINK_WITH_SESSION = True
STEPSEQ__LINK_WITH_SESSION = False

# Should the step sequencer scroll automatically to the currently playing page
STEP_SEQ_AUTO_SCROLL = True

# configure what user modes buttons do.
# the 3 first value configure the 3 sub modes of button user mode 1,
# and following ones are for user mode 2 button
Expand All @@ -26,14 +29,7 @@ class Settings():
#,"user 2"
]

# allow sep seq and instrument modes to save their scale settings.
# as live does not offer any api we are stuck with using the track or clip name...
# possible values : "clip" to save in clip, set, None, (case matter)
# Experimental
#STEPSEQ__SAVE_SCALE = "clip"
#INSTRUMENT__SAVE_SCALE = "clip"
STEPSEQ__SAVE_SCALE = None
INSTRUMENT__SAVE_SCALE = None


#device control stepless fader velocity thresholds
#if velocity is above threshold, the parameter will be changed instantly
Expand Down
24 changes: 3 additions & 21 deletions StepSequencerComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,6 @@ def set_enabled(self, enabled):
if(self._drum_group_device): #Select the note
self._note_selector.set_selected_note(self.index_of(self._drum_group_device.drum_pads,self._drum_group_device.view.selected_drum_pad)) #FIX set view again

#load scale settings from clip
if Settings.STEPSEQ__SAVE_SCALE != None and Settings.STEPSEQ__SAVE_SCALE == "clip": #????
self._scale_selector.from_object(self._clip)
self._note_selector.set_scale(self._scale_selector.notes, self._scale_selector._key)
self._note_selector.set_selected_note(self._scale_selector._octave * 12 + self._scale_selector._key)

self._track_controller.set_enabled(enabled)
self._note_editor.set_enabled(enabled)
# update clip notes as they might have changed while we were sleeping
Expand Down Expand Up @@ -538,17 +532,8 @@ def on_clip_slot_changed(self, scheduled=False):
self._clip.remove_loop_start_listener(self._on_loop_changed)
if self._clip.loop_end_has_listener(self._on_loop_changed):
self._clip.remove_loop_end_listener(self._on_loop_changed)

#load scale settings from clip
if Settings.STEPSEQ__SAVE_SCALE != None and Settings.STEPSEQ__SAVE_SCALE == "clip":
self._scale_selector.from_object(self._clip_slot.clip)
#must set clip to None otherwise it trigger a clip note update which we dont want.
self._clip = None
self._note_editor._clip = None
self._note_selector.set_scale(self._scale_selector.notes, self._scale_selector._key)
#self._control_surface.schedule_message(1, self._note_selector.set_selected_note,(self._scale_selector,self._scale_selector._octave * 12 + self._scale_selector._key))
self._note_selector.set_selected_note(self._scale_selector._octave * 12 + self._scale_selector._key)



# link new clip
self._clip_slot.clip.add_notes_listener(self._on_notes_changed)
self._clip_slot.clip.add_playing_status_listener(self._on_playing_status_changed)
Expand Down Expand Up @@ -625,7 +610,7 @@ def _on_playing_position_changed(self): # playing position changed listener
self._playhead = self._clip.playing_position
else:
self._playhead = None
self._loop_selector.set_playhead(self._playhead)
self._loop_selector.set_playhead(self._playhead, Settings.STEPSEQ__AUTO_SCROLL)
self._note_selector.set_playhead(self._playhead)
self._note_editor.set_playhead(self._playhead)
self.updateQuantizationButton()
Expand Down Expand Up @@ -700,9 +685,6 @@ def _scale_selector_button_value(self, value):
self._note_selector.set_scale(self._scale_selector.notes, self._scale_selector._key)
self._note_selector.set_selected_note(self._scale_selector._octave * 12 + self._scale_selector._key)
self._scale_updated()
#update clip name
if Settings.STEPSEQ__SAVE_SCALE != None and Settings.STEPSEQ__SAVE_SCALE == "clip":
self._scale_selector.update_object_name(self._clip)
self.set_mode(self._mode_backup)


Expand Down
2 changes: 1 addition & 1 deletion TrackControllerComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def disconnect(self):
self.set_prev_track_button(None)
self.set_next_track_button(None)
self.set_mute_button(None)
self.set_play_stop_button(None)
self.set_start_stop_button(None)
self.set_session_record_button(None)
self.set_solo_button(None)
self.set_arm_button(None)
Expand Down

0 comments on commit b8b5b94

Please sign in to comment.