midi_verbose.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 
4 import pygame
5 import pygame.midi
6 import sys
7 import time
8 import roslib
9 roslib.load_manifest('jsk_teleop_joy')
10 from jsk_teleop_joy.midi_util import MIDICommand, MIDIParse
11 
12 def checkUpperByte(ref, val):
13  return ((ref | val) >> 4 == (ref >> 4))
14 
15 def main():
16  pygame.midi.init()
17  controller = pygame.midi.Input(int(sys.argv[1]))
18  while True:
19  while controller.poll():
20  data = controller.read(1)
21  for elem_set in data:
22  midi_command = elem_set[0][0]
23  print(elem_set[0], end=' ')
24  print("(0x%X, 0x%X, 0x%X)" % (midi_command, elem_set[0][1], elem_set[0][2]), end=' ')
25  print(MIDICommand.toStr(MIDICommand.detect(midi_command)))
26  print(MIDIParse(elem_set))
27  time.sleep(0.1)
28 
29 if __name__ == "__main__":
30  main()
def MIDIParse(message)
Definition: midi_util.py:7
def checkUpperByte(ref, val)
Definition: midi_verbose.py:12


jsk_teleop_joy
Author(s): Ryohei Ueda
autogenerated on Sun May 28 2023 03:03:37