jdxi_editor.midi.conversion.note ================================ .. py:module:: jdxi_editor.midi.conversion.note .. autoapi-nested-parse:: MIDI Note Conversion Utilities Provides utilities for converting between MIDI note numbers, note names (e.g., 'C4'), and combo box indices for different instrument types. Attributes ---------- .. autoapisummary:: jdxi_editor.midi.conversion.note._JDXI_DRUM_NAMES jdxi_editor.midi.conversion.note.converter Classes ------- .. autoapisummary:: jdxi_editor.midi.conversion.note.MidiNoteConverter Functions --------- .. autoapisummary:: jdxi_editor.midi.conversion.note._jdxi_drum_index Module Contents --------------- .. py:data:: _JDXI_DRUM_NAMES :value: ['BD1', 'RIM', 'BD2', 'CLAP', 'BD3', 'SD1', 'CHH', 'SD2', 'PHH', 'SD3', 'OHH', 'SD4', 'TOM1',... .. py:function:: _jdxi_drum_index(note_name: str) -> Optional[int] Return drum index for JD-Xi drum name, or None if not found. .. py:class:: MidiNoteConverter(drum_options: Optional[List[str]] = None) Convert between MIDI note numbers, note names, and combo box indices. .. py:attribute:: NOTE_TO_SEMITONE :type: Dict[str, int] .. py:attribute:: SEMITONE_TO_NOTE :type: List[str] :value: ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] .. py:attribute:: NOTE_RANGES :type: Dict[int, range] .. py:attribute:: drum_options :value: [] .. py:method:: note_name_to_midi(note_name: str) -> int Convert note name (e.g., 'C4') or drum name (e.g., 'CLAP') to MIDI note number. .. rubric:: Examples 'C4' -> 60 (Middle C) 'A4' -> 69 'C#4' -> 61 'CLAP' -> 39 (if CLAP is at index 3 in drum_options; drums map to 36-59) :param note_name: Note name in format "NOTE[OCTAVE]" or drum name from drum_options :return: MIDI note number (0-127) :raises ValueError: If note name is invalid .. py:method:: midi_to_note_name(midi_note: int, drums: bool = False) -> str Convert MIDI note number to note name or drum name. .. rubric:: Examples 60 -> 'C4' (without drums=True) 69 -> 'A4' 36 -> 'Kick' (with drums=True, if drum_options set) :param midi_note: MIDI note number (0-127) :param drums: If True, return drum name from drum_options (if available) :return: Note name (e.g., 'C4') or drum name (e.g., 'Kick') or fallback string .. py:method:: _midi_to_drum_name(midi_note: int) -> str Convert MIDI note number to drum kit name. Drum notes are typically in range 36-60 (C2-C3). Maps to indices 0-24 in the drum_options list. :param midi_note: MIDI note number :return: Drum name or fallback string .. py:method:: midi_note_to_combo_index(row: int, midi_note: int, row_options: Optional[List[str]] = None) -> Optional[int] Convert a MIDI note number to the corresponding combo box index for a specific row. This is useful for determining which item in a combo box corresponds to a MIDI note. .. rubric:: Examples Row 0 (Digital Synth 1), MIDI note 60 (C4) -> index 0 (first item in options) Row 3 (Drums), MIDI note 36 (C2) -> index 0 (first drum in options) :param row: Sequencer row index (0-3) :param midi_note: MIDI note number to convert :param row_options: List of note/drum options for the row (e.g., ['C4', 'C#4', ...]) :return: Index in row_options, or None if not found or invalid .. py:method:: get_note_range_for_row(row: int) -> range Get the valid MIDI note range for a specific sequencer row. :param row: Sequencer row index (0-3) :return: Range object with valid MIDI notes for this row .. py:method:: is_note_in_row_range(row: int, midi_note: int) -> bool Check if a MIDI note is in the valid range for a specific row. :param row: Sequencer row index (0-3) :param midi_note: MIDI note number to check :return: True if note is in valid range for this row .. py:method:: get_all_notes_for_row(row: int) -> List[str] Get all valid note names for a specific row. Useful for populating combo boxes. :param row: Sequencer row index (0-3) :return: List of note names (e.g., ['C4', 'C#4', 'D4', ...]) .. py:method:: update_drum_options(drum_options: List[str]) -> None Update the drum kit options. Call this when the drum kit selection changes. :param drum_options: List of drum kit note names .. py:data:: converter