midi_verbose.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import pygame
00003 import pygame.midi
00004 import sys
00005 import time
00006 import roslib
00007 roslib.load_manifest('jsk_teleop_joy')
00008 from jsk_teleop_joy.midi_util import MIDICommand, MIDIParse
00009 
00010 def checkUpperByte(ref, val):
00011   return ((ref | val) >> 4 == (ref >> 4))
00012 
00013 def main():
00014   pygame.midi.init()
00015   controller = pygame.midi.Input(int(sys.argv[1]))
00016   while True:
00017     while controller.poll():
00018       data = controller.read(1)
00019       for elem_set in data:
00020         midi_command = elem_set[0][0]
00021         print elem_set[0],
00022         print "(0x%X, 0x%X, 0x%X)" % (midi_command, elem_set[0][1], elem_set[0][2]),
00023         print MIDICommand.toStr(MIDICommand.detect(midi_command))
00024         print MIDIParse(elem_set)
00025     time.sleep(0.1)
00026   
00027 if __name__ == "__main__":
00028   main()


jsk_teleop_joy
Author(s): Ryohei Ueda
autogenerated on Fri Apr 19 2019 03:45:43