aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool.py
diff options
context:
space:
mode:
Diffstat (limited to 'solo-tool.py')
-rw-r--r--solo-tool.py48
1 files changed, 42 insertions, 6 deletions
diff --git a/solo-tool.py b/solo-tool.py
index 26ddca2..788f58f 100644
--- a/solo-tool.py
+++ b/solo-tool.py
@@ -86,6 +86,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.saveSessionButton.pressed.connect(self.saveSession)
self.loadSessionButton.pressed.connect(self.loadSession)
+ self.abRepeatButton.clicked.connect(self.abRepeatToggleClick)
+
self.initMidiButton.pressed.connect(self.initMidi)
self.midiEnabled = False
@@ -125,6 +127,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
else:
self.player.play()
+ if self.midiEnabled:
+ midi.button_on(midi.lp_key[0][1], (midi.GREEN if self.player.state() == QMediaPlayer.PlayingState else midi.RED))
+
def updateDuration(self, duration):
self.songSlider.setMaximum(duration)
self.aSlider.setMaximum(duration)
@@ -159,6 +164,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
import json
with open(path, "r") as f:
session = json.load(f)
+ self.reset()
for song in session:
self.addSong(song)
@@ -174,18 +180,48 @@ class MainWindow(QMainWindow, Ui_MainWindow):
with open(path, "w") as f:
json.dump(self.internalState, f)
+ def abRepeatToggleClick(self):
+ midi.button_on(midi.lp_key[1][1], (midi.GREEN if self.abRepeatButton.isChecked() else midi.RED))
+
def initMidi(self):
- midi.midi_init()
+ if self.midiEnabled:
+ return
+
+ try:
+ midi.midi_init()
+ except e:
+ print(e)
+ return
+
self.midiEnabled = True
# play pause
- midi.button_on(midi.lp_key[0][0], (midi.GREEN if self.player.state() == QMediaPlayer.PlayingState else midi.RED))
- def midiPlayPause():
- midi.button_on(midi.lp_key[0][0], (midi.RED if self.player.state() == QMediaPlayer.PlayingState else midi.GREEN))
- self.playPauseButton.click()
+ midi.button_on(midi.lp_key[0][1], (midi.GREEN if self.player.state() == QMediaPlayer.PlayingState else midi.RED))
+ midi.on_press(midi.lp_key[0][1], self.playPauseButton.click)
+
+ # next song
+ midi.button_on(midi.lp_key[0][2], midi.YELLOW)
+ midi.on_press(midi.lp_key[0][2], self.playlist.next)
- midi.on_press(midi.lp_key[0][0], midiPlayPause)
+ # previous song
+ midi.button_on(midi.lp_key[0][0], midi.YELLOW)
+ midi.on_press(midi.lp_key[0][0], self.playlist.previous)
+ # a/b repeat
+ midi.button_on(midi.lp_key[1][1], (midi.GREEN if self.abRepeatButton.isChecked() else midi.RED))
+ midi.on_press(midi.lp_key[1][1], self.abRepeatButton.click)
+
+ # next ab
+ # TODO continue here
+ midi.button_on(midi.lp_key[1][2], midi.YELLOW)
+ #midi.on_press(midi.lp_key[1][2], nextAb)
+
+
+ def reset(self):
+ self.playlist.clear()
+ self.playlistModel.layoutChanged.emit()
+ self.abListModel.abList.clear()
+ self.abListModel.layoutChanged.emit()
if __name__ == '__main__':
app = QApplication([])