aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool/abcontroller.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-02-22 22:59:52 +0100
committerEddy Pedroni <epedroni@pm.me>2025-02-22 22:59:52 +0100
commitbef8eee0f63cc5ccb963be9467381e4e605e7f53 (patch)
treea7d07ef9689a608c572216b3e54569014752f0e6 /solo-tool-project/src/solo_tool/abcontroller.py
parent2bcd98fd69b3b4c36b0f6c985a2ea214b1d0ad60 (diff)
Remove AB concept, introduce key points, refactor SoloTool to use properties
Diffstat (limited to 'solo-tool-project/src/solo_tool/abcontroller.py')
-rw-r--r--solo-tool-project/src/solo_tool/abcontroller.py82
1 files changed, 0 insertions, 82 deletions
diff --git a/solo-tool-project/src/solo_tool/abcontroller.py b/solo-tool-project/src/solo_tool/abcontroller.py
deleted file mode 100644
index cec9fb2..0000000
--- a/solo-tool-project/src/solo_tool/abcontroller.py
+++ /dev/null
@@ -1,82 +0,0 @@
-from collections import namedtuple
-
-_AB = namedtuple("_AB", ["a", "b"])
-
-class ABController:
- def __init__(self, enabled=True, callback=None):
- self._setPositionCallback = callback
- self._limits = {} # dictionary of all songs
- self._songLimits = None # list of limits for selected song
- self._currentLimits = _AB(0.0, 0.0) # a/b positions of active limit
- self._loadedIndex = None
- self._enabled = enabled
-
- def _ensureSongExists(self, path):
- if path not in self._limits:
- self._limits[path] = []
-
- def setCurrentSong(self, path):
- self._ensureSongExists(path)
- self._songLimits = self._limits[path]
- self._loadedIndex = None
-
- def storeLimits(self, aLimit, bLimit, song=None):
- if song is not None:
- self._ensureSongExists(song)
- songLimits = self._limits[song]
- else:
- songLimits = self._songLimits
-
- if songLimits is None:
- return
-
- ab = _AB(aLimit, bLimit)
- songLimits.append(ab)
-
- def loadLimits(self, index):
- if not self._songLimits:
- return
-
- if index >= 0 and index < len(self._songLimits):
- self._currentLimits = self._songLimits[index]
- self._loadedIndex = index
-
- def nextStoredAbLimits(self):
- if self._loadedIndex is None:
- nextIndex = 0
- else:
- nextIndex = self._loadedIndex + 1
- self.loadLimits(nextIndex)
-
- def previousStoredAbLimits(self):
- if self._loadedIndex is None:
- previousIndex = 0
- else:
- previousIndex = self._loadedIndex - 1
- self.loadLimits(previousIndex)
-
- def setLimits(self, aLimit, bLimit):
- self._currentLimits = _AB(aLimit, bLimit)
- self._loadedIndex = None
-
- def positionChanged(self, position):
- if position > self._currentLimits.b and self._setPositionCallback and self._enabled:
- self._setPositionCallback(self._currentLimits.a)
-
- def setEnable(self, enable):
- self._enabled = enable
-
- def isEnabled(self):
- return self._enabled
-
- def getStoredLimits(self, song):
- return self._limits.get(song)
-
- def getCurrentLimits(self):
- return self._currentLimits
-
- def getLoadedIndex(self):
- return self._loadedIndex
-
- def clear(self):
- self.__init__(enabled=self._enabled, callback=self._setPositionCallback)