jdxi_editor.ui.editors.midi_player.editor
MIDI Player for JDXI Editor
Attributes
Classes
Midi File Attributes |
|
Midi File Editor |
Module Contents
- 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.SynthEditorMidi File Editor
- preset_helper: jdxi_editor.ui.preset.helper.JDXiPresetHelper = 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]
- classification_group: jdxi_editor.ui.widgets.classification_group.ClassificationGroup[source]
- mute_channels_group: jdxi_editor.ui.widgets.mute_channels_group.MuteChannelsGroup[source]
- _apply_midi_player_style() None[source]
Override global editor QSS with player-scoped tokens (less idle red).
- 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_tracks(drum_indices: list[int])[source]
Classify non-drum tracks into Bass, Keys/Guitars, Strings.
- _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).
- _build_classification_message(updated: dict[str, list[str]]) str[source]
build classification message
- 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.
- _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
- _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:
- _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_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_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_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.
- _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_track(track_index: int) None[source]
Trim Track… (track menu): remove the track’s notes outside a range.
- _on_transport_loop_changed() None[source]
Show loop on/off and the A–B range on the button, label and ruler.
- on_send_clock_toggled(checked: bool) None[source]
Send MIDI Clock / Start / Stop / Song Position to the JD-Xi.
- static _dropped_midi_path(event: PySide6.QtGui.QDragEnterEvent | PySide6.QtGui.QDropEvent) str | None[source]
First local .mid/.midi file in a drag, if any.
- _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.
- _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.