Skip to content

Commit

Permalink
1. (mostly) fixed index problem when (un)folding group tracks and the…
Browse files Browse the repository at this point in the history
…n changing tracks, by utilizing all 3 visible_tracks_listener types. It is important to distinguish between "track_change" (change the currently selected track) and "tracks_change" (change of the AMOUNT of (visible) tracks, meaning adding, deleting or (un)folding group tracks (which makes them (in)visible.

2. more clean-up of (unused) code (old log statements, imports)
  • Loading branch information
markusschloesser committed Feb 12, 2023
1 parent 1c42d6c commit 2d25744
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion wip/MackieC4/Encoders.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# was Python bytecode 2.5 (62131)
# Embedded file name: /Applications/Live 8.2.1 OS X/Live.app/Contents/App-Resources/MIDI Remote Scripts/MackieC4/Encoders.py
# Compiled at: 2011-01-13 21:07:51
# Decompiled by https://python-decompiler.com

from __future__ import absolute_import, print_function, unicode_literals # MS
from . MackieC4Component import *

Expand Down
24 changes: 8 additions & 16 deletions wip/MackieC4/MackieC4.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# was Python bytecode 2.5 (62131)
# Embedded file name: /Applications/Live 8.2.1 OS X/Live.app/Contents/App-Resources/MIDI Remote Scripts/MackieC4/MackieC4.py
# Compiled at: 2011-01-22 04:38:37
# Decompiled by https://python-decompiler.com

"""
# Copyright (C) 2007 Nathan Ramella (nar@remix.net)
# MS: not sure this applies anymore ;-)
Expand All @@ -23,7 +22,7 @@
from __future__ import absolute_import, print_function, unicode_literals
import sys
import Live
from ableton.v2.base import liveobj_valid, clamp, listens
from ableton.v2.base import liveobj_valid, clamp
from .TimeDisplay import TimeDisplay
from . import song_util
import logging
Expand Down Expand Up @@ -62,9 +61,6 @@ class MackieC4(object):
dlisten = {}
'''dlisten is "Device Listener'''

# clisten = {}
# '''clisten is "Clip" Listener'''

slisten = {}
'''slisten is "Slot Listener'''

Expand Down Expand Up @@ -110,7 +106,6 @@ def __init__(self, c_instance):
tracks = self.song().visible_tracks + self.song().return_tracks
index = 0

# if the selected Live track is in view (on computer screen?)
# assign track to the local index of the matching selected track in Live
for track in tracks:
if track == self.song().view.selected_track:
Expand All @@ -120,8 +115,8 @@ def __init__(self, c_instance):
self.track_count = len(tracks)

# if refresh_state is not already listening for visible tracks view changes
if self.song().visible_tracks_has_listener(self.refresh_state) != 1:
self.song().add_visible_tracks_listener(self.refresh_state)
if self.song().visible_tracks_has_listener(self.tracks_change) != 1:
self.song().add_visible_tracks_listener(self.tracks_change)

# To display song position pointer or beats on display
self.__time_display = TimeDisplay(self)
Expand Down Expand Up @@ -170,7 +165,7 @@ def send_midi(self, midi_event_bytes):
def build_midi_map(self, midi_map_handle):
"""Live -> Script Build DeviceParameter mappings, that are processed in Audio time, or forward MIDI messages
explicitly to our receive_midi_functions. Which means that when you are not forwarding MIDI, nor mapping parameters, you will
never get any MIDI messages at all. """
never get any MIDI messages at all. """

# build the relationships between info in Live and each __encoder, this is the MAPPING part (Parameters handled by Live directly)
for s in self.__encoders:
Expand Down Expand Up @@ -382,7 +377,8 @@ def disconnect(self):
self.rem_tracks_listener()
self.rem_device_listeners()
self.rem_transport_listener()
self.song().remove_visible_tracks_listener(self.refresh_state)
if self.song().visible_tracks_has_listener(self.tracks_change):
self.song().remove_visible_tracks_listener(self.tracks_change)
for c in self.__components:
c.destroy()

Expand Down Expand Up @@ -432,7 +428,6 @@ def track_change(self):
# figure out if a track was added, deleted, or just changed
# then delegate to appropriate encoder controller methods
selected_track = self.song().view.selected_track
# self.log_message("selected track {0}".format(selected_track.name))
tracks = self.song().visible_tracks + self.song().return_tracks # not counting Master Track?
# track might have been deleted, added, or just changed (always one at a time?)
if not len(tracks) in range(self.track_count - 1, self.track_count + 2): # include + 1 in range
Expand All @@ -445,7 +440,6 @@ def track_change(self):
found = 0
selected_index = 0
for track in tracks:

if track == selected_track:
selected_index = index
found = 1
Expand All @@ -460,8 +454,6 @@ def track_change(self):
# signal that something bad happened - selected track
selected_index = 555

# self.log_message("C4/track_change found selected index {0}".format(selected_index))

if selected_index != self.track_index:
# self.log_message("C4/track_change setting self.track_index {0} to selected index {1}".format(self.track_index, selected_index))
self.track_index = selected_index
Expand All @@ -472,7 +464,7 @@ def track_change(self):
elif self.track_count < len(tracks):
self.__encoder_controller.track_added(selected_index)
self.track_count += 1
self.return_resetter = 1
self.tracks_change()
else:
self.__encoder_controller.track_changed(selected_index)

Expand Down
5 changes: 2 additions & 3 deletions wip/MackieC4/MackieC4Component.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# was originally Python bytecode 2.5 (62131)
# Embedded file name: /Applications/Live 8.2.1 OS X/Live.app/Contents/App-Resources/MIDI Remote Scripts/MackieC4/MackieC4Component.py
# was originally Python bytecode 2.5
# Compiled at: 2011-01-12 12:23:43
# Decompiled by https://python-decompiler.com

from __future__ import absolute_import, print_function, unicode_literals
import sys
if sys.version_info[0] >= 3: # Live 11
Expand Down
5 changes: 1 addition & 4 deletions wip/MackieC4/TimeDisplay.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# decompyle3 version 3.9.0
# Python bytecode version base 3.7.0 (3394)
# Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:01:55) [MSC v.1900 32 bit (Intel)]
# Embedded file name: ..\..\..\output\Live\win_64_static\Release\python-bundle\MIDI Remote Scripts\MackieControl\TimeDisplay.py
# Compiled at: 2022-04-21 16:02:21
# Size of source mod 2**32: 4062 bytes

from __future__ import absolute_import, print_function, unicode_literals
from .MackieC4Component import *
if sys.version_info[0] >= 3: # Live 11
Expand Down

0 comments on commit 2d25744

Please sign in to comment.