Last active
October 2, 2019 18:20
-
-
Save pedrolcl/61e85d6712bf37fab038e4cfb04b1c84 to your computer and use it in GitHub Desktop.
StackOverflow question: https://stackoverflow.com/questions/58191627
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame.midi | |
import time | |
pygame.midi.init() | |
#list all midi devices | |
for x in range( 0, pygame.midi.get_count() ): | |
print(x,"=",pygame.midi.get_device_info(x)) | |
player = pygame.midi.Output(2) | |
player.set_instrument(0) | |
player.note_on(60, 127) | |
print("PLAYING") | |
time.sleep(1) | |
player.note_off(60, 127) | |
print("STOPPED") | |
del player | |
pygame.midi.quit() |
$ python3 testpygame.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
0 = (b'CoreMIDI', b'VMPK Output', 1, 0, 0)
1 = (b'CoreMIDI', b'VMPK Input', 0, 1, 0)
2 = (b'CoreMIDI', b'SimpleSynth virtual input', 0, 1, 0)
PLAYING
STOPPED
Output in Linux:
0 = (b'ALSA', b'Midi Through Port-0', 0, 1, 0)
1 = (b'ALSA', b'Midi Through Port-0', 1, 0, 0)
2 = (b'ALSA', b'UM-2 MIDI 1', 0, 1, 0) <-- here is my synth
3 = (b'ALSA', b'UM-2 MIDI 1', 1, 0, 0)
4 = (b'ALSA', b'UM-2 MIDI 2', 0, 1, 0)
5 = (b'ALSA', b'UM-2 MIDI 2', 1, 0, 0)
PLAYING
STOPPED
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C:\tmp>python3 testpygame.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
0 = (b'MMSystem', b'Microsoft MIDI Mapper', 0, 1, 0)
1 = (b'MMSystem', b'VirtualMIDISynth #1', 0, 1, 0)
2 = (b'MMSystem', b'Microsoft GS Wavetable Synth', 0, 1, 0)
PLAYING
STOPPED