from picomidi.sysex.parameter.address import AddressParameter
[docs]
class SystemCommonParam(AddressParameter):
"""System Common parameters"""
[docs]
MASTER_TUNE = (0x00, -100.0, 100.0) # Master Tune (24-2024: -100.0 to +100.0 cents)
[docs]
MASTER_KEY_SHIFT = (0x04, -24, 24) # Master Key Shift (40-88: -24 to +24 semitones)
[docs]
MASTER_LEVEL = (0x05, 0, 127) # Master Level (0-127)
# Reserved space (0x06-0x10)
[docs]
PROGRAM_CTRL_CH = (0x11, 0, 16) # Program Control Channel (0-16: 1-16, OFF)
# Reserved space (0x12-0x28)
[docs]
RX_PROGRAM_CHANGE = (0x29, 0, 1) # Receive Program Change (0: OFF, 1: ON)
[docs]
RX_BANK_SELECT = (0x2A, 0, 1) # Receive Bank Select (0: OFF, 1: ON)
@staticmethod
[docs]
def get_display_value(param: int, value: int) -> str:
"""Convert raw value to display value"""
if param == SystemCommonParam.MASTER_TUNE: # Master Tune
cents = (value - 1024) / 10 # Convert 24-2024 to -100.0/+100.0
return f"{cents:+.1f} cents"
elif param == SystemCommonParam.MASTER_KEY_SHIFT: # Master Key Shift
semitones = value - 64 # Convert 40-88 to -24/+24
return f"{semitones:+d} st"
elif param == SystemCommonParam.PROGRAM_CTRL_CH: # Program Control Channel
return "OFF" if value == 0 else str(value)
elif param in (
SystemCommonParam.RX_PROGRAM_CHANGE,
SystemCommonParam.RX_BANK_SELECT,
): # Switches
return "ON" if value else "OFF"
return str(value)
[docs]
def get_nibbled_byte_size(self) -> int:
"""Get the nibbled byte size of the parameter"""
if self.max_value - self.min_value <= 255:
return 1
else:
return 4 # I don't know of any 2 byte parameters