implement parametric eq

This commit is contained in:
onyx-and-iris 2026-01-18 14:42:07 +00:00
parent 45ffed9f63
commit d439da725c
3 changed files with 189 additions and 10 deletions

View File

@ -15,12 +15,15 @@ class SingletonType(type):
return cls._instances[cls] return cls._instances[cls]
@dataclass @dataclass(frozen=True)
class KindMapClass(metaclass=SingletonType): class KindMapClass(metaclass=SingletonType):
name: str name: str
ins: tuple ins: tuple
outs: tuple outs: tuple
vban: tuple vban: tuple
strip_channels: int
bus_channels: int
cells: int
@property @property
def phys_in(self): def phys_in(self):
@ -58,28 +61,37 @@ class KindMapClass(metaclass=SingletonType):
return self.name.capitalize() return self.name.capitalize()
@dataclass @dataclass(frozen=True)
class BasicMap(KindMapClass): class BasicMap(KindMapClass):
name: str name: str
ins: tuple = (2, 1) ins: tuple = (2, 1)
outs: tuple = (1, 1) outs: tuple = (1, 1)
vban: tuple = (4, 4, 1, 1) vban: tuple = (4, 4, 1, 1)
strip_channels: int = 0
bus_channels: int = 0
cells: int = 0
@dataclass @dataclass(frozen=True)
class BananaMap(KindMapClass): class BananaMap(KindMapClass):
name: str name: str
ins: tuple = (3, 2) ins: tuple = (3, 2)
outs: tuple = (3, 2) outs: tuple = (3, 2)
vban: tuple = (8, 8, 1, 1) vban: tuple = (8, 8, 1, 1)
strip_channels: int = 0
bus_channels: int = 8
cells: int = 6
@dataclass @dataclass(frozen=True)
class PotatoMap(KindMapClass): class PotatoMap(KindMapClass):
name: str name: str
ins: tuple = (5, 3) ins: tuple = (5, 3)
outs: tuple = (5, 3) outs: tuple = (5, 3)
vban: tuple = (8, 8, 1, 1) vban: tuple = (8, 8, 1, 1)
strip_channels: int = 2
bus_channels: int = 8
cells: int = 6
def kind_factory(kind_id): def kind_factory(kind_id):

View File

@ -1,3 +1,4 @@
import struct
from dataclasses import dataclass from dataclasses import dataclass
from typing import NamedTuple from typing import NamedTuple
@ -240,11 +241,11 @@ class EqGains(NamedTuple):
class ParametricEQSettings(NamedTuple): class ParametricEQSettings(NamedTuple):
eq_on: bool on: bool
eq_type: int type: int
eq_gain: float gain: float
eq_freq: float freq: float
eq_q: float q: float
class Sends(NamedTuple): class Sends(NamedTuple):
@ -437,6 +438,19 @@ class VbanVMParamStrip:
] ]
) )
@property
def parametric_eq_settings(self) -> tuple[ParametricEQSettings, ...]:
return tuple(
ParametricEQSettings(
on=bool(int.from_bytes(self._PEQ_eqOn[i : i + 1], 'little')),
type=int.from_bytes(self._PEQ_eqtype[i : i + 1], 'little'),
freq=struct.unpack('<f', self._PEQ_eqfreq[i * 4 : (i + 1) * 4])[0],
gain=struct.unpack('<f', self._PEQ_eqgain[i * 4 : (i + 1) * 4])[0],
q=struct.unpack('<f', self._PEQ_eqq[i * 4 : (i + 1) * 4])[0],
)
for i in range(6)
)
@property @property
def sends(self) -> Sends: def sends(self) -> Sends:
return Sends( return Sends(

View File

@ -68,7 +68,7 @@ class PhysicalStrip(Strip):
'comp': StripComp(remote, index), 'comp': StripComp(remote, index),
'gate': StripGate(remote, index), 'gate': StripGate(remote, index),
'denoiser': StripDenoiser(remote, index), 'denoiser': StripDenoiser(remote, index),
'eq': StripEQ(remote, index), 'eq': StripEQ.make(remote, index),
}, },
) )
@ -247,6 +247,25 @@ class StripDenoiser(IRemote):
class StripEQ(IRemote): class StripEQ(IRemote):
@classmethod
def make(cls, remote, i):
"""
Factory method for Strip EQ.
Returns a StripEQ class.
"""
STRIPEQ_cls = type(
'StripEQ',
(cls,),
{
'channel': tuple(
StripEQCh.make(remote, i, j)
for j in range(remote.kind.strip_channels)
)
},
)
return STRIPEQ_cls(remote, i)
@property @property
def identifier(self) -> str: def identifier(self) -> str:
return f'strip[{self.index}].eq' return f'strip[{self.index}].eq'
@ -268,6 +287,140 @@ class StripEQ(IRemote):
self.setter('ab', 1 if val else 0) self.setter('ab', 1 if val else 0)
class StripEQCh(IRemote):
@classmethod
def make(cls, remote, i, j):
"""
Factory method for Strip EQ channel.
Returns a StripEQCh class.
"""
StripEQCh_cls = type(
'StripEQCh',
(cls,),
{
'cell': tuple(
StripEQChCell(remote, i, j, k) for k in range(remote.kind.cells)
)
},
)
return StripEQCh_cls(remote, i, j)
def __init__(self, remote, i, j):
super().__init__(remote, i)
self.channel_index = j
@property
def identifier(self) -> str:
return f'Strip[{self.index}].eq.channel[{self.channel_index}]'
class StripEQChCell(IRemote):
def __init__(self, remote, i, j, k):
super().__init__(remote, i)
self.channel_index = j
self.cell_index = k
@property
def identifier(self) -> str:
return f'Strip[{self.index}].eq.channel[{self.channel_index}].cell[{self.cell_index}]'
@property
def on(self) -> bool:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return False
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq_settings[self.cell_index]
.on
)
@on.setter
def on(self, val: bool):
self.setter('on', 1 if val else 0)
@property
def type(self) -> int:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq_settings[self.cell_index]
.type
)
@type.setter
def type(self, val: int):
self.setter('type', val)
@property
def f(self) -> float:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0.0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq_settings[self.cell_index]
.freq
)
@f.setter
def f(self, val: float):
self.setter('f', val)
@property
def gain(self) -> float:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0.0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq_settings[self.cell_index]
.gain
)
@gain.setter
def gain(self, val: float):
self.setter('gain', val)
@property
def q(self) -> float:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0.0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq_settings[self.cell_index]
.q
)
@q.setter
def q(self, val: float):
self.setter('q', val)
class VirtualStrip(Strip): class VirtualStrip(Strip):
@classmethod @classmethod
def make(cls, remote, i, is_phys): def make(cls, remote, i, is_phys):