jdxi_editor.ui.widgets.midi.track_viewer

Midi Track Viewer

Classes

_TrackList

The list behind the lanes. A punched-card skin paints it in wood.

MidiTrackViewer

MidiTrackViewer

Module Contents

class jdxi_editor.ui.widgets.midi.track_viewer._TrackList[source]

Bases: jdxi_editor.ui.common.QWidget

The list behind the lanes. A punched-card skin paints it in wood.

paintEvent(_event: PySide6.QtGui.QPaintEvent) → None[source]
class jdxi_editor.ui.widgets.midi.track_viewer.MidiTrackViewer(parent: jdxi_editor.ui.common.QWidget = None)[source]

Bases: jdxi_editor.ui.common.QWidget

MidiTrackViewer

mute_changed[source]
track_velocity_changed[source]
file_changed[source]
trim_track_requested[source]
midi_file = None[source]
event_index = None[source]
ruler[source]
midi_track_widgets[source]
muted_tracks: set[int][source]
solo_track: int | None = None[source]
_pre_solo_muted_tracks: set[int] | None = None[source]
track_mute_buttons: dict[int, PySide6.QtWidgets.QPushButton][source]
track_solo_buttons: dict[int, PySide6.QtWidgets.QPushButton][source]
track_velocity_scales: dict[int, float][source]
track_velocity_sliders: dict[int, jdxi_editor.ui.widgets.midi.slider.track_velocity.TrackVelocitySlider][source]
_draggable_rows[source]
_selected_track_index: int | None = None[source]
muted_channels: set[int][source]
soloed_channels: set[int][source]
_track_name_edits: dict[int, PySide6.QtWidgets.QLineEdit][source]
track_channel_spins: dict[int, jdxi_editor.ui.widgets.midi.spin_box.spin_box.MidiSpinBox][source]
_track_part_labels: dict[int, PySide6.QtWidgets.QLabel][source]
_track_icon_labels: dict[int, PySide6.QtWidgets.QLabel][source]
_track_number_labels: dict[int, PySide6.QtWidgets.QLabel][source]
_pending_channels: dict[int, int][source]
_channel_edit_timer[source]
scroll_content[source]
_ruler_layout[source]
_ruler_spacer[source]
mute_buttons[source]
scroll_area[source]
track_zoom_slider[source]
apply_skin() → None[source]

Show the wood behind the cards when this skin punches them.

Returns:

None

_header_text_colors() → tuple[source]

Text and caption colours of the track headers. On the skin’s own backing (walnut, or brushed metal) they are that skin’s lettering, so a pale caption does not vanish on silver; otherwise the player’s.

Returns:

(text, secondary) colours

_style_track_headers() → None[source]

Colour the track numbers, names and captions for the backing.

paintEvent(_event: PySide6.QtGui.QPaintEvent) → None[source]

The wood continues under the zoom control, around the list.

clear()[source]

Clear the MIDI track view and reset state.

_clear_layout(layout: PySide6.QtWidgets.QLayout)[source]

_clear_layout

Parameters:

layout

Returns:

Recursively clear a layout and its children.

clear_old()[source]

Clear the MIDI track view and reset state.

fit_tracks_to_view() → None[source]

Scale the timeline so the full MIDI file fits the visible viewer width.

_align_ruler_to_tracks() → None[source]

Line the ruler up exactly with the track timelines below it.

set_playhead(seconds: float | None) → None[source]

Show the playback position on the ruler and every track (None hides it).

resizeEvent(event: PySide6.QtCore.QEvent) → None[source]
update_track_zoom(width: int)[source]

update_track_zoom

Parameters:

width – int slider value (1–100) used to set content width

Returns:

None

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

Toggle mute state for a specific MIDI channel.

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

  • is_muted – bool is the channel muted?

Returns:

None

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

Solo a MIDI channel: while one or more channels are soloed only those play. The channels’ own mutes stay as they were.

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

  • is_solo – bool is the channel soloed?

get_silenced_channels() → set[int][source]

The channels that do not play (1-16): the muted ones and, with a solo, the others.

_notify_channel_mutes() → None[source]

Grey the silenced channels’ notes in the lanes and tell the player.

select_track(track_index: int) → None[source]

Highlight the chosen track row and its note events.

update_muted_channels(muted_channels: set[int]) → None[source]

Called when the global mute state is updated.

_apply_muted_tracks_to_widgets() → None[source]

Push the current muted-tracks set to all track row widgets.

_sync_track_mute_solo_buttons() → None[source]

Keep per-track mute/solo buttons aligned with internal state.

_clear_solo(*, restore_pre_solo: bool = True) → None[source]

Exit solo mode and optionally restore pre-solo mute state.

toggle_track_solo(track_index: int, is_solo: bool) → None[source]

Solo a track: mute all other tracks and unmute the soloed track.

Parameters:
  • track_index – Index of the track to solo

  • is_solo – Whether solo is active for this track

toggle_track_mute(track: int, is_muted: bool) → None[source]

Toggle mute state for a specific MIDI track.

Parameters:
  • track – int track index (0-based)

  • is_muted – bool is the track muted?

Returns:

None

set_track_velocity_scale(track: int, scale: float) → None[source]

Scale a track’s note velocities during playback.

Parameters:
  • track – int track index (0-based)

  • scale – float factor, 1.0 = velocities as in the file

get_track_velocity_scales() → dict[int, float][source]
update_muted_tracks(muted_tracks: set[int]) → None[source]

Called when the global mute state is updated.

delete_track(track_index: int) → None[source]

Ask user to confirm and delete a specific MIDI track and its widget.

Parameters:

track_index – int

Returns:

None

clone_track(track_index: int) → None[source]

Insert a copy of a track directly below it.

Parameters:

track_index – int

Returns:

None

_replace_tracks(tracks: list[mido.MidiTrack], index_map: dict[int, int]) → None[source]

Show a new file made of tracks, keeping per-track mutes and velocity.

Parameters:
  • tracks – Tracks for the new file, in order

  • index_map – New track index -> index the track had before

_show_track_menu(track_index: int, global_pos: PySide6.QtCore.QPoint) → None[source]

Right-click menu for a track row.

CHANNEL_EDIT_DELAY_MS = 300[source]
_track_part(first_channel: int, has_channel: bool)[source]

Part label and icon pixmap for a track on first_channel (1-16).

_on_channel_edited(track_index: int, display_channel: int) → None[source]
flush_pending_edits() → None[source]

Apply channel edits still waiting for the merge delay.

_on_name_edited(track_index: int, text: str) → None[source]
set_track_channels(channels: dict[int, int]) → None[source]

Move tracks to new channels (0-15), in place.

Only the changed rows are refreshed (lane, icon, part label); the headers are not rebuilt, so the selector being edited keeps focus.

rename_track(track_index: int, new_name: str) → None[source]

Rename a track in place.

replace_track(track_index: int, track: mido.MidiTrack) → None[source]

Show track in place of track track_index (an edit of that track).

_update_tracks_in_place(changed: dict[int, mido.MidiTrack]) → None[source]

New file with changed tracks replaced; refresh only those rows.

change_track_name(track_index: int, new_name: str) → None[source]

Change the name of a specific MIDI track.

Parameters:
  • track_index – int

  • new_name – str

Returns:

None

set_track_name(track, new_name)[source]
change_track_channel(track_index: int, new_channel: int) → None[source]

Change the MIDI channel of a specific track.

Parameters:
  • track_index – int

  • new_channel – int

Returns:

None

make_apply_name(track_name: str, text_edit: PySide6.QtWidgets.QLineEdit) → callable[source]

Create a slot for applying changes to the track channel.

Parameters:
  • track_name – str Track name to modify

  • text_edit – QLineEdit for selecting the name

Returns:

callable function to apply changes

set_midi_file(midi_file: mido.MidiFile, keep_track_state: bool = False) → None[source]

Set the MIDI file for the widget and create channel controls.

Parameters:
  • midi_file

  • keep_track_state – keep track mutes, solo and velocity scales (an edit of the same tracks, in the same order); a new file starts unmuted at 100 %

Returns:

None

get_track_controls_width() → int[source]

Returns the estimated total width of all controls to the left of the MidiTrackWidget.

clear_layout(layout: PySide6.QtWidgets.QLayout) → None[source]
refresh_track_list()[source]

refresh_track_list

Returns:

_CHANNEL_PRESET_MAP[source]
apply_channel_presets() → None[source]

Insert Bank Select and Program Change at the start of each track based on channel.

get_muted_channels()[source]
get_muted_tracks()[source]
move_track(from_index: int, to_index: int) → None[source]

Move a track from one position to another in the MIDI file.

Parameters:
  • from_index – Source track index

  • to_index – Target track index