[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] midi events



Hi,

If I look at https://github.com/pygame/pygame/blob/main/examples/midi.py I see the following:

if e.type in [pygame.midi.MIDIIN]:

I tried that in a tiny test program, but that never gets triggered.
pygame.event.get() does work, so something is received.

My test-code is:

#! /usr/bin/python3

import pygame
import pygame.midi
import time

pygame.init()
pygame.midi.init()
midi_in = pygame.midi.Input(pygame.midi.get_default_input_id())

pygame.fastevent.init()

while True:
    for event in pygame.fastevent.get():
        if event.type == pygame.QUIT:
            sys.exit(0)

        if event.type in [pygame.midi.MIDIIN]:
            print(event)

    time.sleep(0.001)

pygame.quit()


I would like to receive it as an event, as that way I can do get() with a timeout instead of get() & sleep(); the timeout variant would reduce the latency that is introduced by the sleep.


regards