aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2021-11-21 18:03:11 +0100
committerEddy Pedroni <eddy@0xf7.com>2021-11-21 18:03:11 +0100
commit96fa61ed7a0f3e08b40f528e272fd73a7dbc9cf4 (patch)
tree99a912c7fbee863bc33a314b68b96038f7da02bd /solo-tool.py
parentfa5b0f760892bcbc2548ec0e516a716bd854ceef (diff)
Fixed some bugs, added some midi buttons
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([])