add headamp class

This commit is contained in:
onyx-and-iris 2025-01-03 10:19:06 +00:00
parent 6bdd4a0040
commit f26de42b89
7 changed files with 80 additions and 2 deletions

View File

@ -9,7 +9,7 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
## [Unreleased]
- [ ]
- [x] Add preamp class to all kinds for enabling phantom power and setting preamp gain.
## [2.3.2] - 2024-02-16

View File

@ -0,0 +1,18 @@
import logging
import xair_api
logging.basicConfig(level=logging.DEBUG)
def main():
with xair_api.connect("XR18", ip="mixer.local") as mixer:
mixer.headamp[8].phantom = True
for i in range(-12, -6):
mixer.headamp[8].gain = i
print(mixer.headamp[8].gain)
input("Press Enter to continue...")
if __name__ == "__main__":
main()

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "xair-api"
version = "2.3.2"
version = "2.3.3a0"
description = "Remote control Behringer X-Air | Midas MR mixers through OSC"
authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT"

View File

@ -1,4 +1,5 @@
from .bus import Bus as IBus
from .headamp import HeadAmp as IHeadAmp
from .lr import LR as ILR
from .rtn import AuxRtn as IAuxRtn
from .rtn import FxRtn as IFxRtn
@ -38,3 +39,9 @@ class Matrix(ILR):
@property
def address(self) -> str:
return f"/mtx/{str(self.index).zfill(2)}"
class HeadAmp(IHeadAmp):
@property
def address(self):
return f"/headamp/{str(self.index).zfill(3)}"

49
xair_api/headamp.py Normal file
View File

@ -0,0 +1,49 @@
import abc
import logging
from . import util
logger = logging.getLogger(__name__)
class IHeadAmp(abc.ABC):
"""Abstract Base Class for headamps"""
def __init__(self, remote, index: int):
self._remote = remote
self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str):
return self._remote.query(f"{self.address}/{param}")
def setter(self, param: str, val: int):
self._remote.send(f"{self.address}/{param}", val)
@abc.abstractmethod
def address(self):
pass
class HeadAmp(IHeadAmp):
"""Concrete class for headamps"""
@property
def address(self):
return f"/headamp/{str(self.index).zfill(2)}"
@property
def gain(self):
return round(util.lin_get(-12, 60, self.getter("gain")[0]), 1)
@gain.setter
def gain(self, val):
self.setter("gain", util.lin_set(-12, 60, val))
@property
def phantom(self):
return self.getter("phantom")[0] == 1
@phantom.setter
def phantom(self, val):
self.setter("phantom", 1 if val else 0)

View File

@ -16,6 +16,7 @@ class X32KindMap(KindMap):
num_fx: int = 8
num_auxrtn: int = 8
num_matrix: int = 6
num_headamp: int = 127
@dataclass

View File

@ -20,6 +20,7 @@ from .config import Config
from .dca import DCA
from .errors import XAirRemoteConnectionTimeoutError, XAirRemoteError
from .fx import FX, FXSend
from .headamp import HeadAmp
from .kinds import KindMap
from .lr import LR
from .rtn import AuxRtn, FxRtn
@ -134,6 +135,7 @@ def _make_remote(kind: KindMap) -> XAirRemote:
self.fxreturn = tuple(adapter.FxRtn.make(self, i) for i in range(kind.num_fx))
self.auxin = tuple(adapter.AuxRtn.make(self, i) for i in range(kind.num_auxrtn))
self.config = Config.make(self)
self.headamp = tuple(adapter.HeadAmp(self, i) for i in range(kind.num_headamp))
def init_xair(self, *args, **kwargs):
defaultkwargs = {
@ -154,6 +156,7 @@ def _make_remote(kind: KindMap) -> XAirRemote:
self.fxreturn = tuple(FxRtn.make(self, i) for i in range(kind.num_fx))
self.auxreturn = AuxRtn.make(self)
self.config = Config.make(self)
self.headamp = tuple(HeadAmp(self, i) for i in range(kind.num_strip))
if kind.id_ == "X32":
return type(