From 1b00c3dceb27892b008c9fcfede1d521e2456da1 Mon Sep 17 00:00:00 2001 From: Harpo Date: Sat, 1 Oct 2022 17:30:37 -0700 Subject: [PATCH 1/4] Base Command8 config: fader, pan, mutes --- ludwig/boards/__init__.py | 1 + ludwig/boards/command8.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 ludwig/boards/command8.py diff --git a/ludwig/boards/__init__.py b/ludwig/boards/__init__.py index 42e2a95..654a304 100644 --- a/ludwig/boards/__init__.py +++ b/ludwig/boards/__init__.py @@ -1,3 +1,4 @@ from .qu24 import Qu24 from .gld import Gld from .xair import XAir +from .command8 import Command8 diff --git a/ludwig/boards/command8.py b/ludwig/boards/command8.py new file mode 100644 index 0000000..1e0f8eb --- /dev/null +++ b/ludwig/boards/command8.py @@ -0,0 +1,28 @@ +from ludwig import mixer, Mixer, Midi +from rtmidi.midiconstants import NOTE_ON, CONTROL_CHANGE +from ludwig.types import uint1, uint2, uint3, uint4, uint5, uint7, uint8 + + +class Command8(Midi, Mixer): + """Focusrite Command8 mixing station""" + + @mixer + def fader(self, channel: uint4, volume: uint7): + """Fade the channel""" + self.send([CONTROL_CHANGE | channel, 7, volume]) + + @mixer + def pan(self, channel: uint4, pan: uint7): + """Pan the channel""" + self.send([CONTROL_CHANGE | channel, 10, pan]) + + @mixer + def mute(self, channel: uint4): + """Mute the channel""" + self.send([CONTROL_CHANGE | channel, 14, 127]) + + @mixer + def unmute(self, channel: uint4): + """Unmute the channel""" + self.send([CONTROL_CHANGE | channel, 14, 0]) + From 99e4c78d98106d6bbbdf7d94e8ea807f1d7ab0dc Mon Sep 17 00:00:00 2001 From: Harpo Date: Sat, 1 Oct 2022 17:31:01 -0700 Subject: [PATCH 2/4] Enable hook access for midi devices --- ludwig/midi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ludwig/midi.py b/ludwig/midi.py index 941df32..62ecf2e 100644 --- a/ludwig/midi.py +++ b/ludwig/midi.py @@ -8,6 +8,7 @@ class Midi: def __init__( self, *args, + hook, port: str, client_name: str = 'midi', channel: uint4 = 0, @@ -24,7 +25,7 @@ def __init__( send(message): send a MIDI message of bytes (sent as integers) nrpm(message): send a MIDI NRPN (Non-Registered Parameter Number) """ - + self.hook = hook self.port = port self.client_name = client_name self.channel = channel From b8860269aec6822694407e1a810f8d44dca2951d Mon Sep 17 00:00:00 2001 From: Harpo Date: Sat, 1 Oct 2022 17:34:17 -0700 Subject: [PATCH 3/4] Enable fader hook: Working fader control!!! --- ludwig/boards/command8.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ludwig/boards/command8.py b/ludwig/boards/command8.py index 1e0f8eb..1a26c13 100644 --- a/ludwig/boards/command8.py +++ b/ludwig/boards/command8.py @@ -26,3 +26,13 @@ def unmute(self, channel: uint4): """Unmute the channel""" self.send([CONTROL_CHANGE | channel, 14, 0]) + def __call__(self, event, data=None): + message, deltatime = event + print('Command8!', message, deltatime) + if message[0] & 0xF0 == CONTROL_CHANGE: + print( + f'found control change message {message[0]} on channel {message[0] & 0x0F}' + ) + if message[1] == 7: + print(f'fader channel {message[0] & 0x0F } at {message[2]}') + self.hook.fader(channel=message[0] & 0x0F, volume=message[2]) From 6698ee92180a188874d62c45d2e1f40b7f476ffd Mon Sep 17 00:00:00 2001 From: Harpo Date: Sat, 1 Oct 2022 17:37:01 -0700 Subject: [PATCH 4/4] Enable pan and mute functionality!! --- ludwig/boards/command8.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ludwig/boards/command8.py b/ludwig/boards/command8.py index 1a26c13..2e4b588 100644 --- a/ludwig/boards/command8.py +++ b/ludwig/boards/command8.py @@ -36,3 +36,14 @@ def __call__(self, event, data=None): if message[1] == 7: print(f'fader channel {message[0] & 0x0F } at {message[2]}') self.hook.fader(channel=message[0] & 0x0F, volume=message[2]) + elif message[1] == 10: + print(f'pan channel {message[0] & 0x0F } at {message[2]}') + self.hook.pan(channel=message[0] & 0x0F, pan=message[2]) + elif message[1] == 14: + print( + f'{"un" if message[2] == 0 else ""}mute channel {message[0] & 0x0F }' + ) + if message[2]: + self.hook.mute(channel=message[0] & 0x0F) + else: + self.hook.unmute(channel=message[0] & 0x0F)