72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
# DMP 128 COMMAND SET
|
|
#
|
|
# inputs 0 - 11
|
|
# outputs 0 - ?
|
|
|
|
from enum import *
|
|
from dataclasses import dataclass
|
|
|
|
|
|
class ActionType(str, Enum):
|
|
Gain = 'G'
|
|
Mute = 'M'
|
|
|
|
|
|
class IOType(int, Enum):
|
|
Input: int = 40000
|
|
Output: int = 60000
|
|
|
|
|
|
# IMPORTANT: for proper functionality, matrix *MUST* be set to verbose mode = 3
|
|
|
|
|
|
@dataclass
|
|
class EAMValue:
|
|
act: ActionType
|
|
io: IOType
|
|
id: int
|
|
val: str
|
|
|
|
def __init__(self, act, io, id, val):
|
|
self.act, self.io, self.id, self.val = act, io, id, val
|
|
|
|
|
|
def field_to_eam_telnet_code(field: EAMValue) -> str:
|
|
_io = str(field.io + field.id)
|
|
# cursed conversion to extron speak, this is how it was in the documentation
|
|
_val = str(int(float(field.val) * 10) + 2048) if field.act == ActionType.Gain else \
|
|
(1 if field.val == "ON" else 0)
|
|
return f"\e{field.act}{_io}*{_val}AU\r\n"
|
|
|
|
|
|
def eam_telnet_code_to_field(code: str) -> EAMValue:
|
|
if code.startswith("E"):
|
|
return None # TODO error handling
|
|
# code.strip().removeprefix("Ds")
|
|
code = code[2:].strip()
|
|
action = ActionType(code[0]) # always the case allegedly
|
|
_temp = code[1:].split("*", 2)
|
|
_line = int(_temp[0])
|
|
value = int(_temp[1])
|
|
line_id = _line % 100
|
|
io_type = IOType(_line - line_id)
|
|
value = str((value - 2048) / 10) if action == ActionType.Gain else ('ON' if value == 1 else 'OFF')
|
|
# print(action.name + "\n" + io_type.name + "\n" + str(line_id) + "\n" + str(value) + \
|
|
# (" dB" if action == ActionType.Gain else ""))
|
|
return EAMValue(action, io_type, line_id, value)
|
|
|
|
|
|
# TODO limits on values
|
|
|
|
|
|
# 00 naglavni 01 rocni1 02 rocni02 03 kravatniidk 04 / 05 / 06 hdmiL 97 hdmiR 08 vga1L 09 vga1R
|
|
|
|
# TODO have person input dict with labels, also maybe "available" inputs
|
|
|
|
"""
|
|
Mic/line input gain controls (A) -18.0 dB to +80 dB, (1868 to 2848 ) in 0.1 dB increments.
|
|
Input pre-mixer gains (B) -100.0 dB to +12.0 dB, (1048 to 2168) in 0.1 dB increments.
|
|
Virtual returns, pre-mixer gains (C) -100.0 dB to +12.0 dB, (1048 to 2168) in 0.1 dB increments.
|
|
Output trim control (post-mixer trim) (D) -12.0 dB to +12.0 dB, (1928 to 2168) in 0.1 dB increments.
|
|
Output volume controls (E) -100.0 dB to +0.0 dB, (1048 to 2048 ) in 0.1 dB increments
|
|
"""
|