diff options
-rw-r--r-- | abcontroller.py | 7 | ||||
-rw-r--r-- | diagram.drawio | 2 | ||||
-rw-r--r-- | midi_controller_launchpad_mini.py | 44 | ||||
-rw-r--r-- | midi_launchpad_mini_integrationtest.py | 102 | ||||
-rw-r--r-- | notifier.py | 2 | ||||
-rw-r--r-- | notifier_unittest.py | 35 | ||||
-rw-r--r-- | solo_tool.py | 18 | ||||
-rw-r--r-- | solo_tool_integrationtest.py | 48 | ||||
-rw-r--r-- | solo_tool_qt.py | 2 |
9 files changed, 228 insertions, 32 deletions
diff --git a/abcontroller.py b/abcontroller.py index 3604a85..5c9bda7 100644 --- a/abcontroller.py +++ b/abcontroller.py @@ -5,7 +5,7 @@ _AB = namedtuple("_AB", ["a", "b"]) class ABController: def __init__(self, enabled=True, callback=None): self._setPositionCallback = callback - self._limits = dict() # dictionary of all songs + 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 @@ -13,7 +13,7 @@ class ABController: def _ensureSongExists(self, path): if path not in self._limits: - self._limits[path] = list() + self._limits[path] = [] def setCurrentSong(self, path): self._ensureSongExists(path) @@ -35,7 +35,7 @@ class ABController: 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 @@ -76,4 +76,3 @@ class ABController: def clear(self): self.__init__(enabled=self._enabled, callback=self._setPositionCallback) - diff --git a/diagram.drawio b/diagram.drawio index 8950787..935a914 100644 --- a/diagram.drawio +++ b/diagram.drawio @@ -1 +1 @@ -<mxfile host="Electron" modified="2022-01-03T20:16:42.156Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/16.0.2 Chrome/96.0.4664.55 Electron/16.0.5 Safari/537.36" etag="1MdpZqlp1vzm_oapTGY9" version="16.0.2" type="device" pages="3"><diagram id="g-wcGVps3MkI6_XAwNEs" name="Core">7V1df5o8FP80XrY/C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GbDtiJnU7V0x6UgZsOxSTsp0rJj0pA7Ydx8IoOzXJURmw7zh2V25q0qNyW+PuDkGXo3IyaFDWPQNlgW2Nbw75GVDeP3KGS8q6b6QssK2RTCp3rpj0pCyw7YiYVO5cMelJWWDbETOp3Lli0pOywLZDXfkpey8x6UlZeD5pCzxD3K/1fImjla1/+vmjjHD0JC48vgaYDnE9IHH8CsDzge05ElfDngAdqZ6xuMS+abd/KYvD9Vn8XtLTk7X0rNvBpNLniklP1i2NdsmaSaXPFZOerCW2Ke2TipuY9GQtPat3MKnzuWLSk7XENmU/nRStCVGa19yuV7jl88NN4YJwYQ+ULXKylr6lPTwfWJ3P1souph8lX/TsLvE7Cc+CEWcX6Lt9ZZYQ3eOkb+iOjZZvGv05dBd80N2Vnh7dPasjtungJiY9unvWL4yY9kx6dPesYJgwmbXuikmP7p41DBWTwqArJj26e1Yx3H9d5I5MC7Ot7o7tPQILemz3LJIIvo++/Jm6ObL3KFc3RPZ69321731bZ8l0+fQ/</diagram></mxfile>
\ No newline at end of file +<mxfile host="app.diagrams.net" modified="2022-01-04T12:39:41.427Z" agent="5.0 (X11)" etag="pkS41rbGQOjqmha5821z" version="16.1.4" type="device" pages="3"><diagram id="g-wcGVps3MkI6_XAwNEs" name="Core">7V3vf5o8EP9rfNl+IPz0ZbXd1j7d1q3d1u4dSkRWJBai1f31D0hQIFdqlZ9lryQhhCR337vL3QV70nC2+ugZ8+lnYmKnhwRz1ZPOewiJMhKCn7BmHdXofRRVWJ5tska7ilv7L2aV7DlrYZvYTzWkhDjUnqcrx8R18Zim6gzPI8/pZhPipN86NyzMVdyODYev/WWbdMpqRbW/u/EJ29aUvVpHWnRjZsSN2Uz8qWGS50SVdNGThh4hNLqarYbYCRcvXpfouQ8v3N0OzMMu3ecB5XIg3uHzM937Zv0kS2Q7D08nrJel4SzYhH3iELbIbNx0HS+GRxauicP+hJ40eJ7aFN/OjXF49zkgf1A3pTMnKInBpWn4003bsGA5hu+z57YLsSk8YjqessLEdp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3LOyYMLkfXJXTHoQ96wtqJjU7Fwx6UHcs7rg/rsfd2ZamG11cwgnfHSOnCKHcM/iheD7HMvv1NUBfEBeXRHA6923Nbj3bZ2VzOXjHw==</diagram></mxfile>
\ No newline at end of file diff --git a/midi_controller_launchpad_mini.py b/midi_controller_launchpad_mini.py index cb3bc37..10013b5 100644 --- a/midi_controller_launchpad_mini.py +++ b/midi_controller_launchpad_mini.py @@ -13,9 +13,9 @@ class MidiController: MAX_PLAYBACK_RATE = 1.2 PLAYBACK_RATE_STEP = 0.1 - MIN_PLAYBACK_VOLUME = 0.125 - MAX_PLAYBACK_VOLUME = 1.0 - PLAYBACK_VOLUME_STEP = 0.125 + MIN_PLAYBACK_VOLUME = 0.5 + MAX_PLAYBACK_VOLUME = 1.2 + PLAYBACK_VOLUME_STEP = 0.1 def __init__(self, soloTool, midiWrapperOverride=None): self._soloTool = soloTool @@ -26,6 +26,8 @@ class MidiController: self._registerHandlers() self._soloTool.registerPlayingStateCallback(self._updatePlayPauseButton) + self._soloTool.registerPlaybackVolumeCallback(self._updateVolumeRow) + self._soloTool.registerPlaybackRateCallback(self._updateRateRow) def _registerHandlers(self): self._handlers = { @@ -39,12 +41,12 @@ class MidiController: } for i in range(0, 8): - volume = round(MidiController.MIN_PLAYBACK_VOLUME + i * MidiController.PLAYBACK_VOLUME_STEP, 3) - self._handlers[i] = self._createSetPlaybackVolumeCallback(volume, i) + volume = round(MidiController.MIN_PLAYBACK_VOLUME + MidiController.PLAYBACK_VOLUME_STEP * i, 1) + self._handlers[i] = self._createSetPlaybackVolumeCallback(volume) for i, button in enumerate(range(16, 24)): rate = round(MidiController.MIN_PLAYBACK_RATE + MidiController.PLAYBACK_RATE_STEP * i, 1) - self._handlers[button] = self._createSetPlaybackRateCallback(rate, i) + self._handlers[button] = self._createSetPlaybackRateCallback(rate) def connect(self): self._midiWrapper.setCallback(self._callback) @@ -73,23 +75,35 @@ class MidiController: else: self._setButtonLED(7, 0, MidiController.LED_YELLOW) - def _createSetPlaybackRateCallback(self, rate, column): + def _updateVolumeRow(self): + volume = self._soloTool.getPlaybackVolume() + t1 = int(round(volume / MidiController.PLAYBACK_VOLUME_STEP, 1)) + t2 = int(round(MidiController.MIN_PLAYBACK_VOLUME / MidiController.PLAYBACK_VOLUME_STEP, 1)) + lastColumnLit = t1 - t2 + 1 + self._lightRowUntilColumn(0, lastColumnLit, MidiController.LED_GREEN) + + def _updateRateRow(self): + rate = self._soloTool.getPlaybackRate() + t1 = int(round(rate / MidiController.PLAYBACK_RATE_STEP, 1)) + t2 = int(round(MidiController.MIN_PLAYBACK_RATE / MidiController.PLAYBACK_RATE_STEP, 1)) + lastColumnLit = t1 - t2 + 1 + self._lightRowUntilColumn(1, lastColumnLit, MidiController.LED_YELLOW) + + def _createSetPlaybackRateCallback(self, rate): def f(): self._soloTool.setPlaybackRate(rate) - self._lightRowUntilColumn(1, column, MidiController.LED_YELLOW) return f - def _createSetPlaybackVolumeCallback(self, volume, column): + def _createSetPlaybackVolumeCallback(self, volume): def f(): self._soloTool.setPlaybackVolume(volume) - self._lightRowUntilColumn(0, column, MidiController.LED_GREEN) return f def _setButtonLED(self, row, col, colour): self._midiWrapper.sendMessage(MidiController.BUTTON_MATRIX[row][col], colour, MidiController.LIGHT_CONTROL_CHANNEL) def _lightRowUntilColumn(self, row, column, litColour): - colours = [litColour] * (column + 1) + [MidiController.LED_OFF] * (7 - column) + colours = [litColour] * column + [MidiController.LED_OFF] * (8 - column) for col in range(0, 8): self._setButtonLED(row, col, colours[col]) @@ -102,16 +116,14 @@ class MidiController: self._allLEDsOff() # volume buttons - for col in range(0, 8): - self._setButtonLED(0, col, MidiController.LED_GREEN) + self._updateVolumeRow() # playback rate buttons - for col in range(0, 6): - self._setButtonLED(1, col, MidiController.LED_YELLOW) + self._updateRateRow() # playback control self._setButtonLED(6, 0, MidiController.LED_RED) - self._setButtonLED(7, 0, MidiController.LED_YELLOW) + self._updatePlayPauseButton() # AB control self._setButtonLED(6, 5, MidiController.LED_YELLOW) diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py index c10a3f5..35ac087 100644 --- a/midi_launchpad_mini_integrationtest.py +++ b/midi_launchpad_mini_integrationtest.py @@ -211,20 +211,61 @@ def test_playbackRateButtons(uut, midiWrapperMock, soloTool, playerMock): for i, colour in enumerate(playbackRateOptions[button][1]): assert midiWrapperMock.sentMessages[i] == (16 + i, colour, 0) +def test_playbackRateLeds(uut, midiWrapperMock, soloTool, playerMock): + playbackRateOptions = [ + (0.00, [LED_OFF] * 8), + (0.49, [LED_OFF] * 8), + + (0.50, [LED_YELLOW] * 1 + [LED_OFF] * 7), + (0.59, [LED_YELLOW] * 1 + [LED_OFF] * 7), + + (0.60, [LED_YELLOW] * 2 + [LED_OFF] * 6), + (0.69, [LED_YELLOW] * 2 + [LED_OFF] * 6), + + (0.70, [LED_YELLOW] * 3 + [LED_OFF] * 5), + (0.79, [LED_YELLOW] * 3 + [LED_OFF] * 5), + + (0.80, [LED_YELLOW] * 4 + [LED_OFF] * 4), + (0.89, [LED_YELLOW] * 4 + [LED_OFF] * 4), + + (0.90, [LED_YELLOW] * 5 + [LED_OFF] * 3), + (0.99, [LED_YELLOW] * 5 + [LED_OFF] * 3), + + (1.00, [LED_YELLOW] * 6 + [LED_OFF] * 2), + (1.09, [LED_YELLOW] * 6 + [LED_OFF] * 2), + + (1.10, [LED_YELLOW] * 7 + [LED_OFF] * 1), + (1.19, [LED_YELLOW] * 7 + [LED_OFF] * 1), + + (1.2, [LED_YELLOW] * 8), + (1.5, [LED_YELLOW] * 8) + ] + uut.connect() + assert playerMock.rate == 1.0 + + for t, (rate, leds) in enumerate(playbackRateOptions): + midiWrapperMock.sentMessages.clear() + + soloTool.setPlaybackRate(rate) + assert playerMock.rate == rate + + for i, colour in enumerate(leds): + assert midiWrapperMock.sentMessages[i] == (16 + i, colour, 0) + def test_playbackVolumeButtons(uut, midiWrapperMock, soloTool, playerMock): playbackVolumeOptions = { - 0 : (0.125, [LED_GREEN] * 1 + [LED_OFF] * 7), - 1 : (0.250, [LED_GREEN] * 2 + [LED_OFF] * 6), - 2 : (0.375, [LED_GREEN] * 3 + [LED_OFF] * 5), - 3 : (0.500, [LED_GREEN] * 4 + [LED_OFF] * 4), - 4 : (0.625, [LED_GREEN] * 5 + [LED_OFF] * 3), - 5 : (0.750, [LED_GREEN] * 6 + [LED_OFF] * 2), - 6 : (0.875, [LED_GREEN] * 7 + [LED_OFF] * 1), - 7 : (1.000, [LED_GREEN] * 8) + 0 : (0.5, [LED_GREEN] * 1 + [LED_OFF] * 7), + 1 : (0.6, [LED_GREEN] * 2 + [LED_OFF] * 6), + 2 : (0.7, [LED_GREEN] * 3 + [LED_OFF] * 5), + 3 : (0.8, [LED_GREEN] * 4 + [LED_OFF] * 4), + 4 : (0.9, [LED_GREEN] * 5 + [LED_OFF] * 3), + 5 : (1.0, [LED_GREEN] * 6 + [LED_OFF] * 2), + 6 : (1.1, [LED_GREEN] * 7 + [LED_OFF] * 1), + 7 : (1.2, [LED_GREEN] * 8) } uut.connect() assert playerMock.volume == 1.0 - + for t, button in enumerate(playbackVolumeOptions): midiWrapperMock.sentMessages.clear() @@ -234,6 +275,47 @@ def test_playbackVolumeButtons(uut, midiWrapperMock, soloTool, playerMock): for i, colour in enumerate(playbackVolumeOptions[button][1]): assert midiWrapperMock.sentMessages[i] == (i, colour, 0) +def test_playbackVolumeLeds(uut, midiWrapperMock, soloTool, playerMock): + playbackVolumeOptions = [ + (0.00, [LED_OFF] * 8), + (0.49, [LED_OFF] * 8), + + (0.50, [LED_GREEN] * 1 + [LED_OFF] * 7), + (0.59, [LED_GREEN] * 1 + [LED_OFF] * 7), + + (0.60, [LED_GREEN] * 2 + [LED_OFF] * 6), + (0.69, [LED_GREEN] * 2 + [LED_OFF] * 6), + + (0.70, [LED_GREEN] * 3 + [LED_OFF] * 5), + (0.79, [LED_GREEN] * 3 + [LED_OFF] * 5), + + (0.80, [LED_GREEN] * 4 + [LED_OFF] * 4), + (0.89, [LED_GREEN] * 4 + [LED_OFF] * 4), + + (0.90, [LED_GREEN] * 5 + [LED_OFF] * 3), + (0.99, [LED_GREEN] * 5 + [LED_OFF] * 3), + + (1.00, [LED_GREEN] * 6 + [LED_OFF] * 2), + (1.09, [LED_GREEN] * 6 + [LED_OFF] * 2), + + (1.10, [LED_GREEN] * 7 + [LED_OFF] * 1), + (1.19, [LED_GREEN] * 7 + [LED_OFF] * 1), + + (1.2, [LED_GREEN] * 8), + (1.5, [LED_GREEN] * 8) + ] + uut.connect() + assert playerMock.volume == 1.0 + + for t, (volume, leds) in enumerate(playbackVolumeOptions): + midiWrapperMock.sentMessages.clear() + + soloTool.setPlaybackVolume(volume) + assert playerMock.volume == volume + + for i, colour in enumerate(leds): + assert midiWrapperMock.sentMessages[i] == (i, colour, 0) + def test_unassignedButton(uut, midiWrapperMock): unassignedButton = 48 uut.connect() @@ -245,7 +327,7 @@ def test_unassignedButton(uut, midiWrapperMock): def test_initializationMessages(uut, midiWrapperMock): expectedMessages = set( [(int(i / 8) * 16 + (i % 8), LED_OFF, 0) for i in range(0, 64)] + # clear all - [(i, LED_GREEN, 0) for i in range(0, 8)] + # volume row + [(i, LED_GREEN, 0) for i in range(0, 6)] + # volume row [(i, LED_YELLOW, 0) for i in range(16, 22)] + # playback rate row [ (96, LED_RED, 0), diff --git a/notifier.py b/notifier.py index e052b5c..42ab529 100644 --- a/notifier.py +++ b/notifier.py @@ -1,6 +1,8 @@ class Notifier: PLAYING_STATE_EVENT = 0 + PLAYBACK_VOLUME_EVENT = 1 + PLAYBACK_RATE_EVENT = 2 def __init__(self, player): self._callbacks = dict() diff --git a/notifier_unittest.py b/notifier_unittest.py index b840c16..52be51e 100644 --- a/notifier_unittest.py +++ b/notifier_unittest.py @@ -30,6 +30,8 @@ def checkEvent(uut, event): def test_allEvents(uut): checkEvent(uut, Notifier.PLAYING_STATE_EVENT) + checkEvent(uut, Notifier.PLAYBACK_VOLUME_EVENT) + checkEvent(uut, Notifier.PLAYBACK_RATE_EVENT) def test_eventWithoutRegisteredCallbacks(uut): uut.notify(Notifier.PLAYING_STATE_EVENT) @@ -46,3 +48,36 @@ def test_playingStateEventWithMockPlayer(uut, mockPlayer): assert not called mockPlayer.simulatePlayingStateChanged() assert called + +def test_singleEventNotification(uut): + playingStateCalled = False + def playingStateCallback(): + nonlocal playingStateCalled + playingStateCalled = True + + volumeCalled = False + def volumeCallback(): + nonlocal volumeCalled + volumeCalled = True + + uut.registerCallback(Notifier.PLAYING_STATE_EVENT, playingStateCallback) + uut.registerCallback(Notifier.PLAYBACK_VOLUME_EVENT, volumeCallback) + + assert not playingStateCalled + assert not volumeCalled + + uut.notify(Notifier.PLAYING_STATE_EVENT) + assert playingStateCalled + assert not volumeCalled + + playingStateCalled = False + + uut.notify(Notifier.PLAYBACK_VOLUME_EVENT) + assert not playingStateCalled + assert volumeCalled + + volumeCalled = False + + uut.notify(Notifier.PLAYBACK_RATE_EVENT) + assert not playingStateCalled + assert not volumeCalled diff --git a/solo_tool.py b/solo_tool.py index f52e074..7933fce 100644 --- a/solo_tool.py +++ b/solo_tool.py @@ -92,7 +92,13 @@ class SoloTool: return self._player.isPlaying() def setPlaybackRate(self, rate): + previousRate = self._player.getPlaybackRate() self._player.setPlaybackRate(rate) + if previousRate != rate: + self._notifier.notify(Notifier.PLAYBACK_RATE_EVENT) + + def getPlaybackRate(self): + return self._player.getPlaybackRate() def setPlaybackPosition(self, position): self._player.setPlaybackPosition(position) @@ -101,8 +107,20 @@ class SoloTool: return self._player.getPlaybackPosition() def setPlaybackVolume(self, volume): + previousVolume = self._player.getPlaybackVolume() self._player.setPlaybackVolume(volume) + if previousVolume != volume: + self._notifier.notify(Notifier.PLAYBACK_VOLUME_EVENT) + + def getPlaybackVolume(self): + return self._player.getPlaybackVolume() def registerPlayingStateCallback(self, callback): self._notifier.registerCallback(Notifier.PLAYING_STATE_EVENT, callback) + def registerPlaybackVolumeCallback(self, callback): + self._notifier.registerCallback(Notifier.PLAYBACK_VOLUME_EVENT, callback) + + def registerPlaybackRateCallback(self, callback): + self._notifier.registerCallback(Notifier.PLAYBACK_RATE_EVENT, callback) + diff --git a/solo_tool_integrationtest.py b/solo_tool_integrationtest.py index 117e539..98dd31b 100644 --- a/solo_tool_integrationtest.py +++ b/solo_tool_integrationtest.py @@ -291,6 +291,12 @@ def test_getters(uut, mockPlayer): mockPlayer.position = 0.8 assert uut.getPlaybackPosition() == 0.8 + mockPlayer.volume = 0.8 + assert uut.getPlaybackVolume() == 0.8 + + mockPlayer.rate = 0.5 + assert uut.getPlaybackRate() == 0.5 + def test_setTemporaryLimits(uut, mockPlayer): song = "test.flac" abLimits = [ @@ -359,3 +365,45 @@ def test_playingStateNotification(uut, mockPlayer): called = False uut.stop() assert not called + +def test_playbackVolumeNotification(uut, mockPlayer): + song = "test.flac" + uut.addSong(song) + uut.setSong(0) + + called = False + def callback(): + nonlocal called + called = True + + uut.registerPlaybackVolumeCallback(callback) + + assert not called + + uut.setPlaybackVolume(0.0) + assert called + called = False + + uut.setPlaybackVolume(0.0) + assert not called + +def test_playbackRateNotification(uut, mockPlayer): + song = "test.flac" + uut.addSong(song) + uut.setSong(0) + + called = False + def callback(): + nonlocal called + called = True + + uut.registerPlaybackRateCallback(callback) + + assert not called + + uut.setPlaybackRate(0.5) + assert called + called = False + + uut.setPlaybackRate(0.5) + assert not called diff --git a/solo_tool_qt.py b/solo_tool_qt.py index 2ae75a5..bb4ee76 100644 --- a/solo_tool_qt.py +++ b/solo_tool_qt.py @@ -66,7 +66,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.bSlider.setMaximum(POSITION_FACTOR) self.bSlider.sliderReleased.connect(self.abSliderReleased) - self.rateSlider.setRange(int(0.5 * RATE_FACTOR), int(1.5 * RATE_FACTOR)) + self.rateSlider.setRange(int(0.5 * RATE_FACTOR), int(1.2 * RATE_FACTOR)) self.rateSlider.setSingleStep(int(0.1 * RATE_FACTOR)) self.rateSlider.setValue(int(1.0 * RATE_FACTOR)) self.rateSlider.sliderReleased.connect(self.rateSliderReleased) |