Source code for jdxi_editor.midi.data.digital.partial

"""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] PARTIAL_1 = 0x20
[docs] PARTIAL_2 = 0x21
[docs] PARTIAL_3 = 0x22
[docs] class DigitalPartial(IntEnum): """Digital synth partial numbers and structure types""" # Partial numbers
[docs] PARTIAL_1 = 1
[docs] PARTIAL_2 = 2
[docs] PARTIAL_3 = 3
# Structure types
[docs] SINGLE = 0x00
[docs] LAYER_1_2 = 0x01
[docs] LAYER_2_3 = 0x02
[docs] LAYER_1_3 = 0x03
[docs] LAYER_ALL = 0x04
[docs] SPLIT_1_2 = 0x05
[docs] SPLIT_2_3 = 0x06
[docs] SPLIT_1_3 = 0x07
@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"]