aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project
diff options
context:
space:
mode:
Diffstat (limited to 'solo-tool-project')
-rw-r--r--solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py23
-rw-r--r--solo-tool-project/test/midi_launchpad_mini_integrationtest.py58
2 files changed, 71 insertions, 10 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 ee77d21..fb6e385 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
@@ -44,7 +44,13 @@ class MidiController:
116 : self._setALimit,
117 : self._setBLimit,
48 : self._soloTool.previousSong,
- 55 : self._soloTool.nextSong
+ 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,
}
for i in range(0, 8):
@@ -75,7 +81,14 @@ class MidiController:
self._soloTool.pause()
else:
self._soloTool.play()
-
+
+ def _createSeekHandler(self, delta):
+ def f():
+ newPosition = self._soloTool.getPlaybackPosition() + delta
+ newPosition = min(1.0, max(0.0, newPosition))
+ self._soloTool.setPlaybackPosition(newPosition)
+ return f
+
def _setALimit(self):
self._aLimit = self._soloTool.getPlaybackPosition()
self._soloTool.setAbLimits(self._aLimit, self._bLimit)
@@ -159,5 +172,11 @@ class MidiController:
# Song control
self._setButtonLED(3, 0, MidiController.LED_RED)
+ self._setButtonLED(3, 1, MidiController.LED_RED)
+ self._setButtonLED(3, 2, MidiController.LED_RED)
+ self._setButtonLED(3, 3, MidiController.LED_RED)
+ self._setButtonLED(3, 4, MidiController.LED_GREEN)
+ self._setButtonLED(3, 5, MidiController.LED_GREEN)
+ self._setButtonLED(3, 6, MidiController.LED_GREEN)
self._setButtonLED(3, 7, MidiController.LED_GREEN)
diff --git a/solo-tool-project/test/midi_launchpad_mini_integrationtest.py b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
index e7c1315..8fd09bb 100644
--- a/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
+++ b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
@@ -1,4 +1,5 @@
import pytest
+from mido import Message
from solo_tool.midi_controller_launchpad_mini import MidiController
from solo_tool.solo_tool import SoloTool
@@ -10,12 +11,12 @@ LED_GREEN = 124
LED_OFF = 0
nextSongButton = 55
-plus1MinuteButton = 54
-plus30SecondsButton = 53
-plus5SecondsButton = 52
-minus5SecondsButton = 51
-minus30SecondsButton = 50
-minus1MinuteButton = 49
+fwd25PcButton = 54
+fwd5PcButton = 53
+fwd1PcButton = 52
+rwd1PcButton = 51
+rwd5PcButton = 50
+rwd25PcButton = 49
previousSongButton = 48
playPauseButton = 112
@@ -46,7 +47,6 @@ class MidiWrapperMock:
def simulateInput(self, note, velocity=127, channel=0):
if self.callback is not None:
- from mido import Message
msg = Message("note_on", note=note, velocity=velocity, channel=channel)
self.callback(msg)
@@ -365,7 +365,13 @@ def test_connectDisconnect(uut, midiWrapperMock):
(setAButton, LED_YELLOW, 0),
(setBButton, LED_YELLOW, 0),
(previousSongButton, LED_RED, 0),
- (nextSongButton, LED_GREEN, 0)
+ (rwd1PcButton, LED_RED, 0),
+ (rwd5PcButton, LED_RED, 0),
+ (rwd25PcButton, LED_RED, 0),
+ (nextSongButton, LED_GREEN, 0),
+ (fwd1PcButton, LED_GREEN, 0),
+ (fwd5PcButton, LED_GREEN, 0),
+ (fwd25PcButton, LED_GREEN, 0),
])
teardownMessages = [(int(i / 8) * 16 + (i % 8), LED_OFF, 0) for i in range(0, 64)] # clear all
@@ -436,3 +442,39 @@ def test_setAbButtons(uut, midiWrapperMock, soloTool, playerMock):
midiWrapperMock.simulateInput(nextLimitButton)
checkLimit(abLimits[0], abLimits[1])
+def test_seekButtons(uut, midiWrapperMock, soloTool, playerMock):
+ song = "test.flac"
+ soloTool.addSong(song)
+ soloTool.setSong(0)
+
+ uut.connect()
+
+ assert playerMock.position == 0.0
+
+ midiWrapperMock.simulateInput(fwd25PcButton)
+ assert playerMock.position == 0.25
+
+ midiWrapperMock.simulateInput(fwd5PcButton)
+ assert playerMock.position == 0.30
+
+ midiWrapperMock.simulateInput(fwd1PcButton)
+ assert playerMock.position == 0.31
+
+ midiWrapperMock.simulateInput(fwd25PcButton)
+ midiWrapperMock.simulateInput(fwd25PcButton)
+ midiWrapperMock.simulateInput(fwd25PcButton)
+ assert playerMock.position == 1.0
+
+ midiWrapperMock.simulateInput(rwd25PcButton)
+ assert playerMock.position == 0.75
+
+ midiWrapperMock.simulateInput(rwd5PcButton)
+ assert playerMock.position == 0.70
+
+ midiWrapperMock.simulateInput(rwd1PcButton)
+ assert playerMock.position == 0.69
+
+ midiWrapperMock.simulateInput(rwd25PcButton)
+ midiWrapperMock.simulateInput(rwd25PcButton)
+ midiWrapperMock.simulateInput(rwd25PcButton)
+ assert playerMock.position == 0.0