Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, pygame, pygame.midi
- # set up pygame
- pygame.init()
- pygame.midi.init()
- # list all midi devices
- for x in range( 0, pygame.midi.get_count() ):
- print pygame.midi.get_device_info(x)
- # open a specific midi device
- inp = pygame.midi.Input(3)
- # run the event loop
- while True:
- if inp.poll():
- # no way to find number of messages in queue
- # so we just specify a high max value
- mdatain = inp.read(1000)[0][0]
- if mdatain[0] <> 248:
- print mdatain
- # wait 10ms - this is arbitrary, but wait(0) still resulted
- # in 100% cpu utilization
- pygame.time.wait(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement