aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool
diff options
context:
space:
mode:
Diffstat (limited to 'solo-tool-project/src/solo_tool')
-rw-r--r--solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py6
-rw-r--r--solo-tool-project/src/solo_tool/playlist.py14
-rw-r--r--solo-tool-project/src/solo_tool/solo_tool.py15
-rw-r--r--solo-tool-project/src/solo_tool/solo_tool_controller.py22
4 files changed, 28 insertions, 29 deletions
diff --git a/solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py b/solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py
index fb6e385..4fde8fc 100644
--- a/solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py
+++ b/solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py
@@ -1,4 +1,5 @@
from .midi_wrapper_mido import MidiWrapper
+from .solo_tool_controller import SoloToolController
class MidiController:
DEVICE_NAME = "Launchpad Mini MIDI 1"
@@ -19,6 +20,7 @@ class MidiController:
def __init__(self, soloTool, midiWrapperOverride=None):
self._soloTool = soloTool
+ self._soloToolController = SoloToolController(soloTool)
if midiWrapperOverride is not None:
self._midiWrapper = midiWrapperOverride
else:
@@ -43,14 +45,14 @@ class MidiController:
119 : self._soloTool.nextStoredAbLimits,
116 : self._setALimit,
117 : self._setBLimit,
- 48 : self._soloTool.previousSong,
+ 48 : self._soloToolController.previousSong,
49 : self._createSeekHandler(-0.25),
50 : self._createSeekHandler(-0.05),
51 : self._createSeekHandler(-0.01),
52 : self._createSeekHandler(0.01),
53 : self._createSeekHandler(0.05),
54 : self._createSeekHandler(0.25),
- 55 : self._soloTool.nextSong,
+ 55 : self._soloToolController.nextSong,
}
for i in range(0, 8):
diff --git a/solo-tool-project/src/solo_tool/playlist.py b/solo-tool-project/src/solo_tool/playlist.py
index bbfd8f5..988cc04 100644
--- a/solo-tool-project/src/solo_tool/playlist.py
+++ b/solo-tool-project/src/solo_tool/playlist.py
@@ -24,17 +24,3 @@ class Playlist:
def clear(self):
self.__init__(self._setSongCallback)
-
- def nextSong(self):
- if self._currentSong is None:
- nextSong = 0
- else:
- nextSong = self._currentSong + 1
- self.setCurrentSong(nextSong)
-
- def previousSong(self):
- if self._currentSong is None:
- prevSong = 0
- else:
- prevSong = self._currentSong - 1
- self.setCurrentSong(prevSong)
diff --git a/solo-tool-project/src/solo_tool/solo_tool.py b/solo-tool-project/src/solo_tool/solo_tool.py
index 211babf..38e3d11 100644
--- a/solo-tool-project/src/solo_tool/solo_tool.py
+++ b/solo-tool-project/src/solo_tool/solo_tool.py
@@ -36,19 +36,8 @@ class SoloTool:
if previous != new:
self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new)
- def nextSong(self):
- previous = self._playlist.getCurrentSongIndex()
- self._playlist.nextSong()
- new = self._playlist.getCurrentSongIndex()
- if previous != new:
- self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new)
-
- def previousSong(self):
- previous = self._playlist.getCurrentSongIndex()
- self._playlist.previousSong()
- new = self._playlist.getCurrentSongIndex()
- if previous != new:
- self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new)
+ def getCurrentSong(self):
+ return self._playlist.getCurrentSongIndex()
def getSongs(self):
return self._playlist.getSongs()
diff --git a/solo-tool-project/src/solo_tool/solo_tool_controller.py b/solo-tool-project/src/solo_tool/solo_tool_controller.py
new file mode 100644
index 0000000..d283725
--- /dev/null
+++ b/solo-tool-project/src/solo_tool/solo_tool_controller.py
@@ -0,0 +1,22 @@
+import os
+
+from solo_tool.solo_tool import SoloTool
+
+class SoloToolController:
+ def __init__(self, soloTool: SoloTool):
+ self._soloTool = soloTool
+
+ def nextSong(self):
+ current = self._soloTool.getCurrentSong()
+ if current is None:
+ self._soloTool.setSong(0)
+ else:
+ self._soloTool.setSong(current + 1)
+
+ def previousSong(self):
+ current = self._soloTool.getCurrentSong()
+ if current is None:
+ self._soloTool.setSong(0)
+ else:
+ self._soloTool.setSong(current - 1)
+