jdxi_editor.ui.editors.midi_player.editor

MIDI Player for JDXI Editor

Attributes

QApplication

QObject

Signal

Slot

Classes

MidiFileAttrs

Midi File Attributes

MidiFilePlayer

Midi File Editor

Module Contents

jdxi_editor.ui.editors.midi_player.editor.QApplication = None[source]
jdxi_editor.ui.editors.midi_player.editor.QObject = None[source]
jdxi_editor.ui.editors.midi_player.editor.Signal = None[source]
jdxi_editor.ui.editors.midi_player.editor.Slot = None[source]
class jdxi_editor.ui.editors.midi_player.editor.MidiFileAttrs[source]

Midi File Attributes

TICKS_PER_BEAT = 'ticks_per_beat'[source]
class jdxi_editor.ui.editors.midi_player.editor.MidiFilePlayer(midi_helper: jdxi_editor.midi.io.helper.MidiIOHelper | None = None, parent: jdxi_editor.ui.common.QWidget = None, preset_helper: jdxi_editor.ui.preset.helper.JDXiPresetHelper = None)[source]

Bases: jdxi_editor.ui.editors.synth.editor.SynthEditor

Midi File Editor

BUFFER_WINDOW_SECONDS = 30.0[source]
midi_helper = None[source]
tick_duration = None[source]
specs: dict | None = None[source]
_last_position_label: PySide6.QtWidgets.QLabel | None = None[source]
parent: jdxi_editor.ui.common.QWidget = None[source]
preset_helper: jdxi_editor.ui.preset.helper.JDXiPresetHelper = None[source]
midi_state: jdxi_editor.midi.playback.state.MidiPlaybackState[source]
_midi_file_path: str | None = None[source]
on_midi_file_saved: Callable[[str], None] | None = None[source]
midi_analyzer: jdxi_editor.ui.editors.midi_player.midi_analyzer.MidiAnalyzer[source]
midi_total_ticks: int | None = None[source]
midi_port[source]
transport_controller[source]
playback_engine: picomidi.playback.engine.PlaybackEngine[source]
current_tempo_bpm = None[source]
_upper_display_text: str | None = None[source]
midi_preferred_channels[source]
usb_recorder[source]
automation[source]
ui[source]
transport: jdxi_editor.ui.widgets.transport.transport.TransportWidget[source]
playback_options[source]
_loop_points: tuple[float | None, float | None] = (None, None)[source]
_loading_file = False[source]
_preset_names: dict[tuple[int, int, int], str] | None = None[source]
midi_file_group: jdxi_editor.ui.widgets.midi_file_group.MidiFileGroup[source]
event_suppression_group: jdxi_editor.ui.widgets.event_suppression_group.EventSuppressionGroup[source]
_fit_applied = False[source]
classification_group: jdxi_editor.ui.widgets.classification_group.ClassificationGroup[source]
mute_channels_group: jdxi_editor.ui.widgets.mute_channels_group.MuteChannelsGroup[source]
midi_file[source]
transport_input[source]
ui_init()[source]

Initialize the UI for the MidiPlayer.

_apply_midi_player_style() → None[source]

Override global editor QSS with player-scoped tokens (less idle red).

_add_base_widget_to_editor()[source]

Add base widget to editor’s layout

_build_left_panel() → jdxi_editor.ui.common.QVBoxLayout[source]

Build left panel

_build_right_panel()[source]

Build right panel

detect_and_assign_drum_tracks() → None[source]

Detect drum tracks in the loaded MIDI file and assign Channel 10 (1-based) to them.

This analyzes all tracks using heuristics and automatically sets the channel spinboxes for tracks identified as drum tracks.

fit_tracks_to_jdxi() → None[source]

Propose a JD-Xi part for every track with notes, to check and apply.

_apply_part_sounds(sounds: dict[int, tuple[int, int]]) → None[source]

Give the parts their sounds (Fit to the JD-Xi): on each part’s channel the file’s program changes and bank selects go, and the part’s main track starts with the chosen JD-Xi preset; sent to the JD-Xi too.

Parameters:

sounds – part channel (1-based) -> (preset number, main track index)

_refresh_fit_summary() → None[source]

What the JD-Xi plays of the file, in the Fit to the JD-Xi group.

classify_and_assign_tracks() → None[source]

classify and assign tracks

_validate_midi_loaded() → bool[source]

validate that a MIDI file is loaded

_detect_drum_tracks() → list[int][source]

Return track indices identified as drum tracks.

_classify_tracks(drum_indices: list[int])[source]

Classify non-drum tracks into Bass, Keys/Guitars, Strings.

_apply_channel_assignments(classifications) → dict[str, list[str]][source]

apply channel assignments

_handle_unclassified_tracks(classifications, updated: dict[str, list[str]])[source]

Handle unclassified

_has_classified_tracks(updated_tracks: dict) → bool[source]

Return True if at least one track was classified (excluding unclassified).

_show_no_tracks_message() → None[source]

Show the no-tracks-classified message box.

_build_classification_message(updated: dict[str, list[str]]) → str[source]

build classification message

_show_info_message(title: str, message: str) → None[source]

show info dialog

_show_warning(title: str, message: str) → None[source]

show warning

_handle_classification_error(ex: Exception) → None[source]

handle classification error

init_automation_usb_grid() → PySide6.QtWidgets.QGridLayout[source]

Create a grid layout containing Automation, USB Port, and USB File controls.

insert_program_change_current_position() → None[source]

Insert Bank Select (CC#0, CC#32) and Program Change at the current slider time.

_snap_to_bar(seconds: float) → float[source]

Nearest bar line to seconds when Snap to bar is on.

_on_track_viewer_file_changed(midi_file: mido.MidiFile) → None[source]

Keep playback and saving on the file the track viewer shows.

Track edits (channels, names, presets, reorder, clone, delete, program changes) produce or modify the viewer’s file; adopt it so it is heard and saved, keeping the playback position.

_preset_name(msb: int, lsb: int, program: int) → str | None[source]

JD-Xi preset name for a bank select + program change, if known.

_refresh_program_change_markers() → None[source]

Show every program change in the file as a draggable ruler marker.

_move_program_change(key: tuple[int, int, int], seconds: float) → None[source]

Move a program change (and its bank select) to seconds.

static _bank_program_messages(channel: int, bank_msb: int, bank_lsb: int, program: int) → list[mido.Message][source]

CC#0, CC#32 and Program Change (JD-Xi wire values) at time 0.

static _program_change_at(track: mido.MidiTrack, abs_tick: int, channel: int) → tuple[int, int, int] | None[source]

(bank MSB, bank LSB, program) of the program change at abs_tick, if any.

_ask_program_change(channel: int, bank_msb: int, bank_lsb: int, program: int) → jdxi_editor.ui.dialogs.program_change.ProgramChangeSelection | None[source]

Show the Program Change dialog; the chosen values, or None if cancelled.

_edit_program_change(key: tuple[int, int, int]) → None[source]

Double-clicked PC flag: choose a new preset/channel and write it back in place.

_delete_program_change(key: tuple[int, int, int]) → None[source]

Delete a program change (and its bank select).

static _remove_program_change(track: mido.MidiTrack, abs_tick: int, channel: int) → list[mido.Message][source]

Remove the program change at abs_tick on channel, plus the bank select (CC#0/CC#32) directly before it, keeping other timing intact.

Returns:

The removed messages (time=0), in order; empty if not found

_build_message(message_type: str, channel: int, value: int = None, program: int = None) → mido.Message[source]

Build message

_find_track_for_channel(channel: int) → int[source]
_insert_messages_at_abs_tick(track: mido.MidiTrack, abs_tick_target: int, new_msgs: list[mido.Message]) → None[source]

Insert a list of messages at a given absolute tick, preserving delta times.

_toggle_channel_mute(channel: int, is_muted: bool, btn) → None[source]

Toggle mute state for a specific MIDI channel. Updates both the track viewer and the player’s muted channels state.

Parameters:
  • channel – int MIDI channel (1-16)

  • is_muted – bool is the channel muted?

_toggle_channel_solo(channel: int, is_solo: bool) → None[source]

Solo or un-solo a MIDI channel (1-16): with any channel soloed only the soloed ones play.

_sync_mute_buttons_from_track_viewer() → None[source]

Sync mute channel buttons in the USB file controls with the track viewer’s state. Called when MIDI file is loaded or track viewer’s mute state changes.

apply_channel_presets() → None[source]

Send live MIDI Program Changes to the synth and insert presets into the MIDI file. Ch 1→Picked Bass, Ch 2→Piano, Ch 3→JP8 Strings.

_create_transport_control(spec: picomidi.ui.widget.transport.spec.TransportSpec, layout: PySide6.QtWidgets.QHBoxLayout, button_group: PySide6.QtWidgets.QButtonGroup | None) → None[source]

Create a transport button + label row

on_suppress_program_changes_toggled(state: PySide6.QtCore.Qt.CheckState) → None[source]

on_suppress_program_changes_toggled

Parameters:

state – Qt.CheckState

Returns:

None

on_block_foreign_program_changes_toggled(state: PySide6.QtCore.Qt.CheckState) → None[source]

Block the file’s program changes that do not choose a JD-Xi sound (General MIDI ones).

on_suppress_control_changes_toggled(state: PySide6.QtCore.Qt.CheckState)[source]

on_suppress_control_changes_toggled

Parameters:

state – Qt.CheckState

Returns:

_midi_file_dialog_path() → str[source]

Last loaded/saved MIDI path for file dialog defaults.

_remember_midi_file_path(file_path: str) → None[source]

Store MIDI path for subsequent load/save dialogs.

_reload_saved_midi_file(file_path: str) → None[source]

Reload a saved MIDI file from disk so the UI matches persisted state.

_after_midi_file_saved(file_path: str) → None[source]

Invoke post-save callback; default reloads the file into the UI.

_save_midi_to_path(file_path: str) → bool[source]

Write the current MIDI file to file_path and update UI state.

midi_save_file() → None[source]

Save the current MIDI file to its existing path, or prompt if none is set.

midi_save_file_as() → None[source]

Save the current MIDI file via a file dialog.

midi_load_file() → None[source]

Load a MIDI file and initialize parameters

midi_load_file_from_path(file_path: str, *, title_prefix: str = 'Loaded', notify_pattern_sequencer: bool = True, update_recent_files: bool = True, remember_path: bool = True) → bool[source]

Load a MIDI file from a given path and initialize parameters.

Parameters:
  • file_path – Path to the MIDI file

  • title_prefix – Prefix for the file title display (e.g. Loaded/Saved)

  • notify_pattern_sequencer – Push load to Pattern Sequencer when True

  • update_recent_files – Add path to recent-files menu when True

  • remember_path – Use this path for later Save / file dialogs when True (False for temporary files, e.g. extracted from a bundle)

Returns:

True if the file was loaded

calculate_tick_duration()[source]

calculate_tick_duration

Returns:

Calculate the duration of a single MIDI tick in seconds.

calculate_duration() → None[source]

calculate_duration

Returns:

None

Accurate Total Duration Calculation

midi_channel_select() → None[source]

Select a suitable MIDI channel for playback from the file.

midi_extract_events() → None[source]

midi_extract_events

Returns:

None

Extract events from the MIDI file and store them in the midi_state.

detect_initial_tempo() → dict[int, int][source]

Detect initial tempo from the file and set midi_state.tempo_initial.

Returns:

dict[track_number, tempo_usec] for tracks that have set_tempo

ui_display_set_tempo_usecs(tempo_usecs: int) → None[source]

ui_display_set_tempo_usecs

Parameters:

tempo_usecs – int tempo in microseconds

Returns:

None

Set the tempo in the UI and log it.

set_display_tempo_bpm(tempo_bpm: float) → None[source]

set_display_tempo_bpm

Parameters:

tempo_bpm – float tempo in BPM

Returns:

None

Set the tempo in the UI and log it. Also pushes tempo to Pattern Sequencer so both editors stay in sync when using the same playback pipeline.

update_upper_display_with_tempo_and_bar() → None[source]

Update the upper digital with tempo, plus the bar number while playing or paused.

turn_off_effects() → None[source]

Turn off all effects (Effect 1, Effect 2, Delay, Reverb) when starting playback. This prevents distortion and other effects from being accidentally enabled.

midi_playback_start()[source]

Play from the current position, or resume if paused.

midi_playback_toggle() → None[source]

Space: pause if playing, otherwise play (or resume).

midi_playback_rewind() → None[source]

Home: go back to the start, keeping play/pause/stop state.

midi_playback_panic(*_args) → None[source]

Silence the instrument without changing the transport state.

midi_loop_toggled(checked: bool = False) → None[source]

Loop button: loop the A–B range, or the whole song.

midi_loop_toggle_shortcut() → None[source]

L: toggle looping.

midi_loop_set_a(*_args) → None[source]

Set the loop start at the playback position.

midi_loop_set_b(*_args) → None[source]

Set the loop end at the playback position.

_set_loop_point(which: int) → None[source]
_ask_trim_range(title: str, description: str) → tuple[int, int] | None[source]

Ask for the range to keep, starting from the A–B range (else the whole file); (start, end) in ticks, or None if cancelled.

midi_trim_file(*_args) → None[source]

Trim button: keep only part of the file, moved to the start.

midi_trim_track(track_index: int) → None[source]

Trim Track… (track menu): remove the track’s notes outside a range.

midi_loop_clear(*_args) → None[source]

Forget the A–B range so Loop repeats the whole song.

_on_transport_loop_changed() → None[source]

Show loop on/off and the A–B range on the button, label and ruler.

on_playback_speed_changed(percent: int) → None[source]

Speed spin box (percent of the file’s tempo).

on_send_clock_toggled(checked: bool) → None[source]

Send MIDI Clock / Start / Stop / Song Position to the JD-Xi.

_init_shortcuts() → None[source]

Space = play/pause, Home = back to start, L = loop on/off.

static _dropped_midi_path(event: PySide6.QtGui.QDragEnterEvent | PySide6.QtGui.QDropEvent) → str | None[source]

First local .mid/.midi file in a drag, if any.

dragEnterEvent(event: PySide6.QtGui.QDragEnterEvent) → None[source]
dropEvent(event: PySide6.QtGui.QDropEvent) → None[source]
_sync_transport_settings() → None[source]

Push mute, track velocity and event-suppression settings to the transport (applies live).

_on_transport_state_changed(state: picomidi.playback.engine.TransportState) → None[source]

Reflect the transport state in the buttons and digital display.

_on_transport_position_changed(seconds: float) → None[source]

Move the slider and position label to the playback position.

_on_transport_tempo_changed(tempo_us: int) → None[source]

Show the tempo in effect at the playback position.

is_track_muted(track_index: int) → bool[source]

is_track_muted

Parameters:

track_index – Index of the track to check.

Returns:

True if the track is muted, otherwise False.

Check if the track is muted.

is_channel_muted(channel_index: int) → bool[source]

is_channel_muted

Parameters:

channel_index – Index of the track to check.

Returns:

True if the channel is muted, otherwise False.

Check if the channel is muted.

get_muted_tracks()[source]

get_muted_tracks

Returns:

None

Get the muted tracks from the MIDI track viewer.

get_muted_channels()[source]

get_muted_channels

Returns:

the channels (1-16) that do not play: muted, or silenced by another channel’s solo

on_tempo_usecs_changed(tempo: int)[source]

on_tempo_usecs_changed

Parameters:

tempo – int

Returns:

None

on_tempo_bpm_changed(bpm: float)[source]

on_tempo_bpm_changed

Parameters:

bpm – float

Returns:

None

midi_scrub_position()[source]

Seek to the slider position, keeping the current play/pause/stop state.

is_midi_ready() → bool[source]

Checks if a MIDI file is loaded into the transport.

midi_playback_stop()[source]

Stop playback, silence the instrument and rewind to the beginning.

_connect_transport_input() → None[source]

Listen to MiniLab (etc.) note pads via the instrument’s controller input.

_toggle_usb_recording() → None[source]

Record pad: start or stop USB capture when save-recording is enabled.

closeEvent(event: PySide6.QtGui.QCloseEvent) → None[source]

Ensure the playback thread is stopped before widget destruction.

ui_position_slider_reset() → None[source]

position_slider_reset

Returns:

None

Reset the position slider and label to initial state.

midi_file_position_label_update_time(time_seconds: float | None = None) → None[source]

midi_file_position_label_update_time

Parameters:

time_seconds – float, optional

Returns:

None

current_bar_beat() → tuple[int, int][source]

Current (bar, beat), 1-based, at the playback position, following the file’s tempo map and time signatures.

ui_position_label_set_time(elapsed_time: float | None = None) → None[source]

Update the position label with formatted elapsed time and total duration. Caps elapsed_time to total duration to prevent overflow digital. Also updates the bar number in the DigitalTitle upper digital.

update_position_text(elapsed_str: str, total_str: str, remaining_str: str | None = None)[source]

update position text

midi_playback_pause_toggle()[source]

midi_playback_pause_toggle

Returns:

None

Pause if playing, resume if paused; does nothing when stopped.

_get_pattern_sequencer_editor()[source]

Return the Pattern Sequencer editor instance if available, else None.

_push_tempo_to_pattern_sequencer(tempo_bpm: float) → None[source]

Push current display tempo to Pattern Sequencer so it stays in sync with playback pipeline.

_notify_pattern_sequencer_file_loaded() → None[source]

Notify Pattern Sequencer that a MIDI file has been loaded.

_build_specs() → dict[str, Any][source]

build specs for the Midi file player

_build_button_specs() → dict[str, picoui.specs.widgets.ButtonSpec][source]
_build_message_box_specs() → dict[str, picoui.specs.widgets.MessageBoxSpec][source]

Assemble all static message box specs for the MIDI player.

_build_checkbox_specs() → dict[str, picoui.specs.widgets.CheckBoxSpec][source]

build check box specs (event suppression moved to EventSuppressionGroup)