"""Digital Partial"""
from enum import IntEnum
from typing import List
from jdxi_editor.midi.data.parameter.digital.common import DigitalCommonParam
[docs]
class DigitalPartialOffset(IntEnum):
"""Offsets for each partial's parameters"""
[docs]
class DigitalPartial(IntEnum):
"""Digital synth partial numbers and structure types"""
# Partial numbers
# Structure types
@property
[docs]
def switch_param(self) -> "DigitalCommonParam":
"""Get the switch parameter for this partial"""
if self > 3: # Structure types are > 3
raise ValueError("Structure types don't have switch parameters")
return {
self.PARTIAL_1: DigitalCommonParam.PARTIAL1_SWITCH,
self.PARTIAL_2: DigitalCommonParam.PARTIAL2_SWITCH,
self.PARTIAL_3: DigitalCommonParam.PARTIAL3_SWITCH,
}[self]
@property
[docs]
def select_param(self) -> "DigitalCommonParam":
"""Get the select parameter for this partial"""
if self > 3: # Structure types are > 3
raise ValueError("Structure types don't have select parameters")
return {
self.PARTIAL_1: DigitalCommonParam.PARTIAL1_SELECT,
self.PARTIAL_2: DigitalCommonParam.PARTIAL2_SELECT,
self.PARTIAL_3: DigitalCommonParam.PARTIAL3_SELECT,
}[self]
@property
[docs]
def is_partial(self) -> bool:
"""Returns True if this is address partial number (not address structure preset_type)"""
return 1 <= self <= 3
@property
[docs]
def is_structure(self) -> bool:
"""Returns True if this is address structure preset_type (not address partial number)"""
return self <= 0x07 and not self.is_partial
@classmethod
[docs]
def get_partials(cls) -> List["DigitalPartial"]:
"""Get list of partial numbers (not structure types)"""
return [cls.PARTIAL_1, cls.PARTIAL_2, cls.PARTIAL_3]
@classmethod
[docs]
def get_structures(cls) -> List["DigitalPartial"]:
"""Get list of structure types (not partial numbers)"""
return [
cls.SINGLE,
cls.LAYER_1_2,
cls.LAYER_2_3,
cls.LAYER_1_3,
cls.LAYER_ALL,
cls.SPLIT_1_2,
cls.SPLIT_2_3,
cls.SPLIT_1_3,
]
[docs]
DIGITAL_PARTIAL_NAMES = ["COMMON", "PARTIAL_1", "PARTIAL_2", "PARTIAL_3"]