[pygame] Pygame Read MIDI Input

Skip to first unread message


Nov 20, 2020, 9:38:38 AM11/20/20
to pygame...@seul.org
MidiInput.py <http://pygame-users.25799.x6.nabble.com/file/t497/MidiInput.py>


Some info in advance so you can not say I did not do research:

I have been googling for quite a while now without success. Code that worked
for other people did not let me read any input Midi data. I also wrote a
question on Stackoverflow which has not been answered.
So I hope that maybe you users in this forum specifically for pygame may
have suggestions.


My goal is to simply read the Midi data from a USB Midi interface. However,
'pygame.midi.Input.poll' always returns 'False'.
I tried two different USB Midi interfaces that do work in my audio software.
Also, I tried every input device ID that was available.

My code is attached as a .py to this email.
I would be super happy for suggestions!
Feel free to ask if you need further clarifications.

Thanks in advance,

Sent from: http://pygame-users.25799.x6.nabble.com/

René Dudfield

Nov 20, 2020, 9:41:13 AM11/20/20
to pygame...@seul.org

- what OS are you using?
- What does this list?
python -m pygame.examples.midi --list

- With the input id from the list, does this work for you?
python -m pygame.examples.midi --input 1



Nov 20, 2020, 9:59:58 AM11/20/20
to pygame...@seul.org
Thanks for your quick answer!

- OS: Windows 10
- 'python -m pygame.examples.midi --list' lists the following:
0: interface :b'MMSystem':, name :b'Microsoft MIDI Mapper':, opened :0:
1: interface :b'MMSystem':, name :b'External':, opened :0: (input)
2: interface :b'MMSystem':, name :b'Eleven Rack':, opened :0: (input)
3: interface :b'MMSystem':, name :b'Maschine Mikro MK2 In':, opened :0:
4: interface :b'MMSystem':, name :b'TASCAM US-122 MKII MIDI':, opened :0:
5: interface :b'MMSystem':, name :b'Microsoft GS Wavetable Synth':, opened
:0: (output)
6: interface :b'MMSystem':, name :b'External':, opened :0: (output)
7: interface :b'MMSystem':, name :b'Eleven Rack':, opened :0: (output)
8: interface :b'MMSystem':, name :b'Maschine Mikro MK2 Out':, opened :0:
9: interface :b'MMSystem':, name :b'TASCAM US-122 MKII MIDI':, opened :0:

- 'python -m pygame.examples.midi --input 4'
It actually works for both USB Midi interfaces now!

Can you tell me where these example files are located so I can check what I
did wrong?

René Dudfield

Nov 20, 2020, 10:24:50 AM11/20/20
to pygame...@seul.org

import pygame.examples.midi


Nov 20, 2020, 10:55:58 AM11/20/20
to pygame...@seul.org
Thanks a lot! To understand fully what is happening I will have to learn
about pygame events. But I have the Midi data available now and can just use
it for further processing.

Again, thanks for the quick and to the point help.
Reply all
Reply to author
0 new messages