8 """returns (type, index, value)""" 9 midi_command = message[0][0]
10 midi_param1 = message[0][1]
11 midi_param2 = message[0][2]
12 timestamp = message[1]
13 command_type = MIDICommand.detect(midi_command)
14 midi_channel = MIDICommand.getChannel(midi_command)
15 if command_type == MIDICommand.NOTE_OFF:
16 return (MIDICommand.NOTE_ON, midi_param1, 0)
17 elif command_type == MIDICommand.NOTE_ON:
18 return (MIDICommand.NOTE_ON, midi_param1, midi_param2 / 127.0)
19 elif command_type == MIDICommand.AFTERTOUCH:
20 return (MIDICommand.AFTERTOUCH, midi_param1, midi_param2 / 127.0)
21 elif command_type == MIDICommand.CONTINUOUS_CONTROLLER:
22 return (MIDICommand.CONTINUOUS_CONTROLLER, midi_param1, midi_param2 / 127.0)
23 elif command_type == MIDICommand.PATCH_CHANGE:
24 return (MIDICommand.PATCH_CHANGE, midi_param1, midi_param2 / 127.0)
25 elif command_type == MIDICommand.CHANNEL_PRESSURE:
26 return (MIDICommand.CHANNEL_PRESSURE, midi_channel, midi_param1)
27 elif command_type == MIDICommand.PITCH_BEND:
28 return (MIDICommand.PITCH_BEND, midi_channel, midi_param1 / 127.0)
30 raise MIDIException(
"unknown command type: " + MIDICommand.toStr(command_type))
36 CONTINUOUS_CONTROLLER = 0xB0
38 CHANNEL_PRESSURE = 0xD0
57 return (ref >> 4) == (val >> 4)
70 return "ContinuousController" 74 return "Channel Pressure" 78 return "Non Musical Command" 89 devices = pygame.midi.get_count()
90 for i
in range(devices):
91 info = pygame.midi.get_device_info(i)
92 if info[1] == device_name
and info[2] == input_output:
94 return pygame.midi.Input(i)
96 return pygame.midi.Output(i)
97 raise MIDIException(
"Cannot find the device: %s" % (device_name))
def openMIDIByName(device_name, input_output)
def openMIDIInputByName(device_name)
def openMIDIOutputByName(device_name)
def checkUpperByte(cls, ref, val)
int CONTINUOUS_CONTROLLER