jdxi_editor.ui.sequencer.button.manager
Sequencer Button Manager Module
Manages sequencer button state, styling, and synchronization with pattern measures. Handles button clicks, note assignment, and UI updates.
Classes
Button attribute names. |
|
Represents the state of a sequencer button. |
|
Manages sequencer button state and synchronization. |
Module Contents
- class jdxi_editor.ui.sequencer.button.manager.ButtonState(is_checked: bool = False, note: int | None = None, velocity: int = 100, duration_ms: float = 120.0, *, note_spec: picomidi.ui.widget.button.note.NoteButtonEvent | None = None)[source]
Represents the state of a sequencer button.
- class jdxi_editor.ui.sequencer.button.manager.SequencerButtonManager(midi_converter: jdxi_editor.midi.conversion.note.MidiNoteConverter | None = None, scope: str = 'SequencerButtonManager')[source]
Manages sequencer button state and synchronization.
Handles: - Button click events and state updates - Note assignment from combo box selectors - Button styling and highlighting - Synchronization with measure data - Tooltip updates
- set_buttons(buttons: List[List]) → None[source]
Set the button grid.
- Parameters:
buttons – 2D list of buttons (4 rows x 16+ columns)
- set_channel_map(channel_map: Dict[int, PySide6.QtWidgets.QComboBox]) → None[source]
Set the row-to-selector mapping.
- Parameters:
channel_map – Dictionary mapping row (0-3) to QComboBox
- set_style_generator(generator: Callable[[bool, bool, bool], str]) → None[source]
Set the style generator callback.
Called with (is_checked, is_current, is_selected_bar) returns stylesheet.
- Parameters:
generator – Callback function
- handle_button_click(button, checked: bool, measures: List | None = None) → None[source]
Handle a button click event.
Updates button state, measure data, and UI.
- Parameters:
button – SequencerButton that was clicked
checked – New checked state
measures – List of PatternMeasure objects (optional)
- sync_sequencer_with_measure(bar_index: int, measures: List) → None[source]
Synchronize sequencer buttons with a measure’s data.
Copies note data from the measure to the main sequencer buttons.
- Parameters:
bar_index – Index of the bar to sync from
measures – List of PatternMeasure objects
- highlight_current_step(step: int) → None[source]
Highlight the current playback step.
Updates button styles to show which step is currently playing.
- Parameters:
step – Current step in bar (0-15)
- highlight_bar(bar_index: int) → None[source]
Highlight all buttons in the current bar display.
- Parameters:
bar_index – Index of bar being displayed
- reset_button(button) → None[source]
Reset a button to its default state.
Clears note data and unchecks the button.
- Parameters:
button – SequencerButton to reset
- clear_row(row: int) → None[source]
Clear all buttons in a specific row.
- Parameters:
row – Row index (0-3)
- get_button_state(row: int, col: int) → ButtonState | None[source]
Get the current state of a button.
- Parameters:
row – Row index
col – Column index
- Returns:
ButtonState or None if button doesn’t exist
- get_row_state(row: int) → List[ButtonState | None][source]
Get the state of all buttons in a row.
- Parameters:
row – Row index (0-3)
- Returns:
List of ButtonState objects
- set_button_note(row: int, col: int, note: int, velocity: int = 100, duration_ms: float = 120.0) → bool[source]
Set a button’s note data programmatically.
- Parameters:
row – Row index
col – Column index
note – MIDI note number
velocity – Note velocity
duration_ms – Note duration
- Returns:
True if successful
- set_button_checked(row: int, col: int, checked: bool) → bool[source]
Set a button’s checked state programmatically.
- Parameters:
row – Row index
col – Column index
checked – New checked state
- Returns:
True if successful
- _store_note_in_measures(button, checked: bool, measures: List) → None[source]
Store button state in the corresponding measure.
- Parameters:
button – SequencerButton
checked – Whether button is checked
measures – List of PatternMeasure objects
- _update_button_style(button, is_current: bool | None = None, is_selected_bar: bool = True) → None[source]
Update button visual style.
- Parameters:
button – Button to style
is_current – Whether button is current step (optional)
is_selected_bar – Whether button is in selected bar
- _update_button_tooltip(button) → None[source]
Update button tooltip to show note name.
- Parameters:
button – SequencerButton
- _update_button_state_silent(button, checked: bool) → None[source]
Update button checked state without signals.
- Parameters:
button – Button to update
checked – New checked state
- _get_button_state(button) → ButtonState[source]
Extract button state.
- Parameters:
button – SequencerButton
- Returns:
ButtonState object
- _sync_button_note_spec(button) → None[source]
Sync the button’s note_spec from attributes.
- Parameters:
button – SequencerButton
- _create_note_spec(note, duration_ms, velocity)[source]
Create a note specification object.
- Parameters:
note – MIDI note number
duration_ms – Duration in milliseconds
velocity – Velocity (0-127)
- Returns:
NoteButtonSpec
- _note_name_to_midi(note_name: str) → int | None[source]
Convert note name to MIDI number.
- Parameters:
note_name – Note name (e.g., ‘C4’)
- Returns:
MIDI note number or None
- _midi_to_note_name(midi_note: int, drums: bool = False) → str[source]
Convert MIDI number to note name.
- Parameters:
midi_note – MIDI note number
drums – Whether to use drum names
- Returns:
Note name (e.g., ‘C4’)
- _basic_note_name_to_midi(note_name: str) → int | None[source]
Basic note name to MIDI conversion (fallback).
- Parameters:
note_name – Note name
- Returns:
MIDI note or None
- set_midi_converter(converter: jdxi_editor.midi.conversion.note.MidiNoteConverter) → None[source]
Set the MIDI converter.
- Parameters:
converter – MidiNoteConverter instance
- set_defaults(velocity: int = 100, duration_ms: float = 120.0) → None[source]
Set default velocity and duration.
- Parameters:
velocity – Default velocity
duration_ms – Default duration
- highlight_measure(measure_index: int) → None[source]
Highlight the current measure/bar in the sequencer display.
Updates button styles to show the selected measure and the current step. Equivalent to highlight_bar; “measure” and “bar” are interchangeable.
- Parameters:
measure_index – Index of the measure being displayed