Source code for jdxi_editor.ui.editors.program.track

"""Mixer Track"""

from dataclasses import dataclass
from enum import Enum
from typing import Callable, Optional

from PySide6.QtWidgets import QLabel, QWidget

from jdxi_editor.core.synth.type import JDXiSynth
from jdxi_editor.midi.data.address.address import JDXiSysExAddress
from jdxi_editor.ui.editors.program.channel_strip import ChannelStrip
from picomidi.sysex.parameter.address import AddressParameter


[docs] class MixerTrackEntity(Enum): """Actual Mixer Tracks"""
[docs] MASTER = "MASTER"
[docs] DIGITAL1 = "DIGITAL1"
[docs] DIGITAL2 = "DIGITAL2"
[docs] DRUMS = "DRUMS"
[docs] ANALOG = "ANALOG"
@classmethod
[docs] def from_synth(cls, synth: str) -> "MixerTrackEntity": mapping = { JDXiSynth.DIGITAL_SYNTH_1: cls.DIGITAL1, JDXiSynth.DIGITAL_SYNTH_2: cls.DIGITAL2, JDXiSynth.DRUM_KIT: cls.DRUMS, JDXiSynth.ANALOG_SYNTH: cls.ANALOG, } try: return mapping[synth] except KeyError: raise ValueError(f"Unsupported synth type: {synth!r}")
@dataclass
[docs] class MixerTrack: """Mixer Track"""
[docs] entity: MixerTrackEntity
[docs] slider: QWidget | None
[docs] value_label: QLabel | None
[docs] icon: QLabel | None
[docs] label: QLabel | None
[docs] param: Optional[AddressParameter] = None
[docs] address: Optional[JDXiSysExAddress] = None
[docs] send_midi_callback: Optional[Callable] = None
[docs] analog: bool = False
[docs] def build_strip(self) -> ChannelStrip: """Build Channel Strip""" return ChannelStrip( self.entity.name, self.slider, self.value_label, self.icon, param=self.param, address=self.address, send_midi_callback=self.send_midi_callback, )
[docs] def set_name(self, text: str): if self.label: self.label.setText(text)