In that example, the midi events are converted to Pygame events and posted
to the Pygame event queue here:
https://github.com/pygame/pygame/blob/main/examples/midi.py#L74

On Mon, Jul 26, 2021, 04:02 Folkert van Heusden <m...@vanheusden.com> wrote:

> 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
>

Reply via email to