jdxi_editor.midi.conversion.note
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
Classes
Convert between MIDI note numbers, note names, and combo box indices. |
Functions
|
Return drum index for JD-Xi drum name, or None if not found. |
Module Contents
- jdxi_editor.midi.conversion.note._JDXI_DRUM_NAMES = ['BD1', 'RIM', 'BD2', 'CLAP', 'BD3', 'SD1', 'CHH', 'SD2', 'PHH', 'SD3', 'OHH', 'SD4', 'TOM1',...[source]
- jdxi_editor.midi.conversion.note._jdxi_drum_index(note_name: str) int | None[source]
Return drum index for JD-Xi drum name, or None if not found.
- class jdxi_editor.midi.conversion.note.MidiNoteConverter(drum_options: List[str] | None = None)[source]
Convert between MIDI note numbers, note names, and combo box indices.
- SEMITONE_TO_NOTE: List[str] = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'][source]
- note_name_to_midi(note_name: str) int[source]
Convert note name (e.g., ‘C4’) or drum name (e.g., ‘CLAP’) to MIDI note number.
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)
- Parameters:
note_name – Note name in format “NOTE[OCTAVE]” or drum name from drum_options
- Returns:
MIDI note number (0-127)
- Raises:
ValueError – If note name is invalid
- midi_to_note_name(midi_note: int, drums: bool = False) str[source]
Convert MIDI note number to note name or drum name.
Examples
60 -> ‘C4’ (without drums=True) 69 -> ‘A4’ 36 -> ‘Kick’ (with drums=True, if drum_options set)
- Parameters:
midi_note – MIDI note number (0-127)
drums – If True, return drum name from drum_options (if available)
- Returns:
Note name (e.g., ‘C4’) or drum name (e.g., ‘Kick’) or fallback string
- _midi_to_drum_name(midi_note: int) str[source]
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.
- Parameters:
midi_note – MIDI note number
- Returns:
Drum name or fallback string
- midi_note_to_combo_index(row: int, midi_note: int, row_options: List[str] | None = None) int | None[source]
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.
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)
- Parameters:
row – Sequencer row index (0-3)
midi_note – MIDI note number to convert
row_options – List of note/drum options for the row (e.g., [‘C4’, ‘C#4’, …])
- Returns:
Index in row_options, or None if not found or invalid
- get_note_range_for_row(row: int) range[source]
Get the valid MIDI note range for a specific sequencer row.
- Parameters:
row – Sequencer row index (0-3)
- Returns:
Range object with valid MIDI notes for this row
- is_note_in_row_range(row: int, midi_note: int) bool[source]
Check if a MIDI note is in the valid range for a specific row.
- Parameters:
row – Sequencer row index (0-3)
midi_note – MIDI note number to check
- Returns:
True if note is in valid range for this row