-
Notifications
You must be signed in to change notification settings - Fork 4
/
mcu_device_track_fader.py
26 lines (21 loc) · 1.12 KB
/
mcu_device_track_fader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import device
import midi
import mcu_device_fader_conversion
class McuDeviceTrackFader:
""" Class for controlling a single fader on the Xtouch in MCU mode (Hardware abstraction) """
def __init__(self, productId: int, index: int, isMain: bool, baseMidiValue: int):
self.__productId = productId
self.__index = index
self.__isMain = isMain
self.__baseMidiValue = baseMidiValue
def SetLevelFromFlsFader(self, flFaderValue: int, skipIsAssignedCheck: bool = False):
""" Sets the value of the fader on the Xtouch using a FL Studio Fader value """
paramValue = mcu_device_fader_conversion.FlFaderToMcuFader(flFaderValue)
self.SetLevel(paramValue, skipIsAssignedCheck)
def SetLevel(self, value: int, skipIsAssignedCheck: bool = False):
""" Sets the value of the fader on the Xtouch (0 to 16380) """
if skipIsAssignedCheck or device.isAssigned():
data1 = value
data2 = data1 & 127
data1 = data1 >> 7
device.midiOutNewMsg(midi.MIDI_PITCHBEND + self.__index + (data2 << 8) + (data1 << 16), self.__baseMidiValue + 5)