Advertisement
cymplecy

Untitled

Dec 18th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import sys, pygame, pygame.midi
  2.  
  3. # set up pygame
  4. pygame.init()
  5. pygame.midi.init()
  6.  
  7. # list all midi devices
  8. for x in range( 0, pygame.midi.get_count() ):
  9.     print pygame.midi.get_device_info(x)
  10.  
  11. # open a specific midi device
  12. inp = pygame.midi.Input(3)
  13.  
  14. # run the event loop
  15. while True:
  16.     if inp.poll():
  17.         # no way to find number of messages in queue
  18.         # so we just specify a high max value
  19.         mdatain = inp.read(1000)[0][0]
  20.         if mdatain[0] <> 248:
  21.             print mdatain
  22.  
  23.     # wait 10ms - this is arbitrary, but wait(0) still resulted
  24.     # in 100% cpu utilization
  25.     pygame.time.wait(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement