jdxi_editor.ui.widgets.midi.time_ruler

TimeRulerWidget

Time axis above the track viewer. Shows the playback position, the loop range and program-change markers, and is the place to seek (click/drag) and to move or delete program changes (drag/right-click a marker handle).

Attributes

HANDLE_WIDTH

HANDLE_HEIGHT

HANDLE_HIT_SLOP

RULER_MIN_HEIGHT

MIN_LABEL_SPACING

MIN_BEAT_SPACING

MARKER_GROUP_PX

MAX_GRID_BARS

Classes

BarLine

A bar on the ruler: where it starts, its number, and the time signature

RulerMarker

A marker on the ruler. Markers with a key can be dragged and deleted.

TimeRulerWidget

TimeRulerWidget

Functions

_conductor(midi_file) → tuple[list, list, int]

Tempo changes [(tick, µs per beat)], time signatures [(tick, num, den)] and

bar_grid(midi_file) → tuple[list[BarLine], list[float]]

The bars and beats of midi_file, in seconds, following its time

_signature_before(bars, line) → Optional[tuple[int, int]]

Module Contents

jdxi_editor.ui.widgets.midi.time_ruler.HANDLE_WIDTH = 10[source]
jdxi_editor.ui.widgets.midi.time_ruler.HANDLE_HEIGHT = 14[source]
jdxi_editor.ui.widgets.midi.time_ruler.HANDLE_HIT_SLOP = 4[source]
jdxi_editor.ui.widgets.midi.time_ruler.RULER_MIN_HEIGHT = 34[source]
jdxi_editor.ui.widgets.midi.time_ruler.MIN_LABEL_SPACING = 28[source]
jdxi_editor.ui.widgets.midi.time_ruler.MIN_BEAT_SPACING = 6[source]
jdxi_editor.ui.widgets.midi.time_ruler.MARKER_GROUP_PX = 6[source]
jdxi_editor.ui.widgets.midi.time_ruler.MAX_GRID_BARS = 2000[source]
class jdxi_editor.ui.widgets.midi.time_ruler.BarLine[source]

A bar on the ruler: where it starts, its number, and the time signature when one starts there (None otherwise).

seconds: float[source]
bar: int[source]
signature: tuple[int, int] | None = None[source]
jdxi_editor.ui.widgets.midi.time_ruler._conductor(midi_file: mido.MidiFile) → tuple[list, list, int][source]

Tempo changes [(tick, µs per beat)], time signatures [(tick, num, den)] and the last tick of midi_file, from all its tracks (as the playback engine reads them: one entry per tick, the last one wins).

jdxi_editor.ui.widgets.midi.time_ruler.bar_grid(midi_file: mido.MidiFile) → tuple[list[BarLine], list[float]][source]

The bars and beats of midi_file, in seconds, following its time signatures and tempo changes.

Bars are counted as the playback engine counts them (bar_beat_at_tick, the position shown in the player and «Snap to bars»): at a change of time signature a new bar starts, and an unfinished bar before it still counts. Returns ([], []) when the file has more than MAX_GRID_BARS bars.

jdxi_editor.ui.widgets.midi.time_ruler._signature_before(bars: list[BarLine], line: BarLine) → tuple[int, int] | None[source]
class jdxi_editor.ui.widgets.midi.time_ruler.RulerMarker[source]

A marker on the ruler. Markers with a key can be dragged and deleted.

seconds: float[source]
label: str | None = None[source]
color: PySide6.QtGui.QColor | None = None[source]
key: Any = None[source]
class jdxi_editor.ui.widgets.midi.time_ruler.TimeRulerWidget(midi_file: mido.MidiFile = None, parent: PySide6.QtWidgets.QWidget = None)[source]

Bases: PySide6.QtWidgets.QWidget

TimeRulerWidget

Signals:

seek_requested(float): user clicked/dragged to a time (seconds) marker_moved(object, float): marker key dragged to a new time marker_delete_requested(object): delete the marker with key marker_edit_requested(object): edit the marker with key (double-click)

seek_requested[source]
marker_moved[source]
marker_delete_requested[source]
marker_edit_requested[source]
midi_file_cached_total_length = None[source]
midi_file = None[source]
_markers: list[RulerMarker] = [][source]
_playhead_seconds: float | None = None[source]
_loop_range: tuple[float, float] | None = None[source]
_loop_marks: tuple[float | None, float | None] = (None, None)[source]
_loop_enabled = False[source]
_dragging_marker: RulerMarker | None = None[source]
_drag_seconds: float | None = None[source]
_scrubbing = False[source]
_grid: tuple[list[BarLine], list[float]] | None = None[source]
set_midi_file(midi_file: mido.MidiFile, length: float | None = None) → None[source]
grid() → tuple[list[BarLine], list[float]][source]

The file’s bars and beats (see bar_grid), worked out once per file.

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

Show the playback position (None hides it).

set_loop_region(loop_range: tuple[float, float] | None, enabled: bool) → None[source]

Show the A–B range (None = whole file) and whether looping is on.

set_loop_marks(a: float | None, b: float | None) → None[source]

The A and B points as they are set: one shows at once, before the other makes the range (A alone used to show nothing).

add_marker(seconds: float, color: PySide6.QtGui.QColor | None = None, label: str | None = None, key: Any = None) → None[source]

Add a time marker in seconds and repaint. Markers with a key are draggable.

set_markers(markers: list[RulerMarker]) → None[source]

Replace all markers.

clear_markers() → None[source]

Clear all time markers and repaint.

_x_for(seconds: float) → int[source]
_seconds_for(x: float) → float[source]
_marker_at(pos: PySide6.QtCore.QPoint) → RulerMarker | None[source]

Draggable marker whose handle is under pos.

mousePressEvent(event: PySide6.QtGui.QMouseEvent) → None[source]
mouseMoveEvent(event: PySide6.QtGui.QMouseEvent) → None[source]
mouseDoubleClickEvent(event: PySide6.QtGui.QMouseEvent) → None[source]
mouseReleaseEvent(event: PySide6.QtGui.QMouseEvent) → None[source]
_show_marker_menu(marker: RulerMarker, global_pos: PySide6.QtCore.QPoint) → None[source]
paintEvent(event: PySide6.QtGui.QPaintEvent) → None[source]
_paint_bar_beat_grid(painter: PySide6.QtGui.QPainter, width: int, height: int, duration: float) → None[source]

Bars (numbered) and beats, with the file’s time signatures and tempo changes; the time signature where it starts (when not 4/4 throughout). Seconds when the file has no usable bars.

static _label_interval(bar_px: float, painter: PySide6.QtGui.QPainter, bar_count: float) → int[source]

Number every 1, 2, 4, 8… bars so labels are MIN_LABEL_SPACING apart.

_paint_loop_region(painter: PySide6.QtGui.QPainter, height: int) → None[source]
_marker_groups() → list[list[RulerMarker]][source]

Markers drawn within MARKER_GROUP_PX of each other, left to right.

_paint_markers(painter: PySide6.QtGui.QPainter, height: int) → None[source]

One flag per group; a label only where it fits before the next one.

_markers_near(pos: PySide6.QtCore.QPoint) → list[RulerMarker][source]

Markers in the group under pos (for the tooltip).

_paint_marker(painter: PySide6.QtGui.QPainter, marker: RulerMarker, height: int, label: bool = True) → None[source]
_paint_playhead(painter: PySide6.QtGui.QPainter, height: int) → None[source]