Skip to content

How to set the speed of mid.play() #374

Answered by rdoursenaud
yk0n9 asked this question in Q&A
Discussion options

You must be logged in to vote

The play method from the mido.MidiFile class is pretty straightforward:

def play(self, meta_messages=False):
    """Play back all tracks.

    The generator will sleep between each message by
    default. Messages are yielded with correct timing. The time
    attribute is set to the number of seconds slept since the
    previous message.

    By default you will only get normal MIDI messages. Pass
    meta_messages=True if you also want meta messages.

    You will receive copies of the original messages, so you can
    safely modify them without ruining the tracks.
    """
    start_time = time.time()
    input_time = 0.0

    for msg in self:
        input_time += msg.time

        play…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yk0n9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants