from collections.abc import Generator, Iterable, Sequence from typing import Never, Self, SupportsIndex, overload, override from ..messages import BaseMessage class MidiTrack(list[BaseMessage]): @property def name(self) -> str: """Name of the track. This will return the name from the first `track_name` meta message in the track, or `''` if there is no such message. Setting this property will update the name field of the first `track_name` message in the track. If no such message is found, one will be added to the beginning of the track with a delta time of 0.""" @name.setter def name(self, name: str) -> None: ... @override def copy(self) -> Self: ... @overload def __getitem__(self, index_or_slice: SupportsIndex) -> BaseMessage: ... @overload def __getitem__(self, index_or_slice: slice[int, int, int]) -> Self: ... @override def __add__(self, other: Sequence[BaseMessage]) -> Self: ... # pyright: ignore[reportIncompatibleMethodOverride] @override def __mul__(self, other: SupportsIndex) -> Self: ... def fix_end_of_track(messages: Iterable[BaseMessage], skip_checks: bool = False) -> Generator[BaseMessage, Never]: """Remove all end_of_track messages and add one at the end. This is used by `merge_tracks()` and `MidiFile.save()`.""" def merge_tracks(tracks: Iterable[MidiTrack], skip_checks: bool = False) -> MidiTrack: """Returns a MidiTrack object with all messages from all tracks. The messages are returned in playback order with delta times as if they were all in one track. Pass `skip_checks=True` to skip validation of messages before merging. This should ONLY be used when the messages in tracks have already been validated by mido.checks. """