## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+# Each status byte has 3 string names, each shorter than the previous
status_bytes = {
# Channel voice messages
- 0x80: 'note off',
- 0x90: 'note on', # However, velocity = 0 means "note off".
- 0xa0: 'polyphonic key pressure / aftertouch',
- 0xb0: 'control change',
- 0xc0: 'program change',
- 0xd0: 'channel pressure / aftertouch',
- 0xe0: 'pitch bend change',
+ 0x80: ['note off', 'note off', 'N off'],
+ 0x90: ['note on', 'note on', 'N on'], # However, velocity = 0 means "note off".
+ 0xa0: ['polyphonic key pressure / aftertouch', 'key pressure', 'KP' ],
+ 0xb0: ['control change', 'ctl chg', 'CC'],
+ 0xc0: ['program change', 'prgm chg', 'PC'],
+ 0xd0: ['channel pressure / aftertouch', 'channel pressure', 'CP'],
+ 0xe0: ['pitch bend change', 'pitch bend', 'PB'],
# Channel mode messages
# 0xb0: 'select channel mode', # Note: Same as 'control change'.
# System exclusive messages
- 0xf0: 'system exclusive (SysEx)',
+ 0xf0: ['system exclusive', 'SysEx', 'SE'],
# System common messages
- 0xf1: 'MIDI time code quarter frame',
- 0xf2: 'song position pointer',
- 0xf3: 'song select',
- 0xf4: 'undefined 0xf4',
- 0xf5: 'undefined 0xf5',
- 0xf6: 'tune request',
- 0xf7: 'end of system exclusive (EOX)',
+ 0xf1: ['MIDI time code quarter frame', 'MIDI time code', 'MIDI time'],
+ 0xf2: ['song position pointer', 'song position', 'position'],
+ 0xf3: ['song select', 'song select', 'song select'],
+ 0xf4: ['undefined 0xf4', 'undef 0xf4', 'undef'],
+ 0xf5: ['undefined 0xf5', 'undef 0xf5', 'undef'],
+ 0xf6: ['tune request', 'tune request', 'tune request'],
+ 0xf7: ['end of system exclusive (EOX)', 'end of SysEx', 'EOX'],
# System real time messages
- 0xf8: 'timing clock',
- 0xf9: 'undefined 0xf9',
- 0xfa: 'start',
- 0xfb: 'continue',
- 0xfc: 'stop',
- 0xfd: 'undefined 0xfd',
- 0xfe: 'active sensing',
- 0xff: 'system reset',
+ 0xf8: ['timing clock', 'timing clock', 'timing clock'],
+ 0xf9: ['undefined 0xf9', 'undef 0xf9', 'undef'],
+ 0xfa: ['start', 'start', 'start'],
+ 0xfb: ['continue', 'continue', 'continue'],
+ 0xfc: ['stop', 'stop', 'stop'],
+ 0xfd: ['undefined 0xfd', 'undef 0xfd', 'undef'],
+ 0xfe: ['active sensing', 'active sensing', 'sensing'],
+ 0xff: ['system reset', 'reset', 'reset'],
}
# Universal system exclusive (SysEx) messages, non-realtime (0x7e)
}
control_functions = {
- 0x00: 'bank select MSB',
- 0x01: 'modulation wheel/lever MSB',
- 0x02: 'breath controller MSB',
+ 0x00: ['bank select MSB', 'bank MSB', 'bank-M'],
+ 0x01: ['modulation wheel/lever MSB', 'modulation MSB', 'mod-M'],
+ 0x02: ['breath controller MSB', 'breath MSB', 'breath-M'],
# 0x03: undefined MSB
- 0x04: 'foot controller MSB',
- 0x05: 'portamento time MSB',
- 0x06: 'data entry MSB',
- 0x07: 'channel volume MSB (formerly main volume)',
- 0x08: 'balance MSB',
+ 0x04: ['foot controller MSB', 'foot MSB', 'foot-M'],
+ 0x05: ['portamento time MSB', 'portamento MSB', 'porta.-M'],
+ 0x06: ['data entry MSB', 'data entry MSB', 'data-M'],
+ 0x07: ['channel volume MSB (formerly main volume)', 'channel volume MSB', 'ch vol-M'],
+ 0x08: ['balance MSB', 'bal MSB', 'bal-M'],
# 0x09: undefined MSB
- 0x0a: 'pan MSB',
- 0x0b: 'expression controller MSB',
- 0x0c: 'effect control 1 MSB',
- 0x0d: 'effect control 2 MSB',
+ 0x0a: ['pan MSB', 'pan MSB', 'pan-M'],
+ 0x0b: ['expression controller MSB', 'expression MSB', 'expr-M'],
+ 0x0c: ['effect control 1 MSB', 'effect 1 MSB', 'effect-1-M'],
+ 0x0d: ['effect control 2 MSB', 'effect 2 MSB', 'effect-2-M'],
# 0x0e-0x0f: undefined MSB
- 0x10: 'general purpose controller 1 MSB',
- 0x11: 'general purpose controller 2 MSB',
- 0x12: 'general purpose controller 3 MSB',
- 0x13: 'general purpose controller 4 MSB',
+ 0x10: ['general purpose controller 1 MSB', 'GP controller 1 MSB', 'GPC-1-M'],
+ 0x11: ['general purpose controller 2 MSB', 'GP controller 2 MSB', 'GPC-2-M'],
+ 0x12: ['general purpose controller 3 MSB', 'GP controller 3 MSB', 'GPC-3-M'],
+ 0x13: ['general purpose controller 4 MSB', 'GP controller 4 MSB', 'GPC-4-M'],
# 0x14-0x1f: undefined MSB
- 0x20: 'bank select LSB',
- 0x21: 'modulation wheel/lever LSB',
- 0x22: 'breath controller LSB',
+ 0x20: ['bank select LSB', 'bank LSB', 'bank-L'],
+ 0x21: ['modulation wheel/lever LSB', 'modulation LSB', 'mod-L'],
+ 0x22: ['breath controller LSB', 'breath LSB', 'breath-L'],
# 0x23: undefined LSB
- 0x24: 'foot controller LSB',
- 0x25: 'portamento time LSB',
- 0x26: 'data entry LSB',
- 0x27: 'channel volume LSB (formerly main volume)',
- 0x28: 'balance LSB',
+ 0x24: ['foot controller LSB', 'foot LSB', 'foot-L'],
+ 0x25: ['portamento time LSB', 'portamento LSB', 'porta.-L'],
+ 0x26: ['data entry LSB', 'data entry LSB', 'data-L'],
+ 0x27: ['channel volume LSB (formerly main volume)', 'channel volume LSB', 'ch vol-L'],
+ 0x28: ['balance LSB', 'bal LSB', 'bal-L'],
# 0x29: undefined LSB
- 0x2a: 'pan LSB',
- 0x2b: 'expression controller LSB',
- 0x2c: 'effect control 1 LSB',
- 0x2d: 'effect control 2 LSB',
+ 0x2a: ['pan LSB', 'pan LSB', 'pan-L'],
+ 0x2b: ['expression controller LSB', 'expression LSB', 'expr-L'],
+ 0x2c: ['effect control 1 LSB', 'effect 1 LSB', 'effect-1-L'],
+ 0x2d: ['effect control 2 LSB', 'effect 2 LSB', 'effect-2-L'],
# 0x2e-0x2f: undefined LSB
- 0x30: 'general purpose controller 1 LSB',
- 0x31: 'general purpose controller 2 LSB',
- 0x32: 'general purpose controller 3 LSB',
- 0x33: 'general purpose controller 4 LSB',
+ 0x30: ['general purpose controller 1 LSB', 'GP controller 1 LSB', 'GPC-1-L'],
+ 0x31: ['general purpose controller 2 LSB', 'GP controller 2 LSB', 'GPC-2-L'],
+ 0x32: ['general purpose controller 3 LSB', 'GP controller 3 LSB', 'GPC-3-L'],
+ 0x33: ['general purpose controller 4 LSB', 'GP controller 4 LSB', 'GPC-4-L'],
# 0x34-0x3f: undefined LSB
- 0x40: 'damper pedal (sustain)',
- 0x41: 'portamento on/off',
- 0x42: 'sostenuto',
- 0x43: 'soft pedal',
- 0x44: 'legato footswitch', # vv: 00-3f = normal, 40-7f = legato
- 0x45: 'hold 2',
- 0x46: 'sound controller 1 (default: sound variation)',
- 0x47: 'sound controller 2 (default: timbre / harmonic intensity)',
- 0x48: 'sound controller 3 (default: release time)',
- 0x49: 'sound controller 4 (default: attack time)',
- 0x4a: 'sound controller 5 (default: brightness)',
- 0x4b: 'sound controller 6 (GM2 default: decay time)',
- 0x4c: 'sound controller 7 (GM2 default: vibrato rate)',
- 0x4d: 'sound controller 8 (GM2 default: vibrato depth)',
- 0x4e: 'sound controller 9 (GM2 default: vibrato delay)',
- 0x4f: 'sound controller 10',
- 0x50: 'general purpose controller 5',
- 0x51: 'general purpose controller 6',
- 0x52: 'general purpose controller 7',
- 0x53: 'general purpose controller 8',
- 0x54: 'portamento control',
+ 0x40: ['damper pedal (sustain)', 'sustain', 'sust.'],
+ 0x41: ['portamento on/off', 'porta. on/off', 'porta. on/off'],
+ 0x42: ['sostenuto', 'sostenuto', 'sostenuto'],
+ 0x43: ['soft pedal', 'soft pedal', 'soft pedal'],
+ 0x44: ['legato footswitch', 'legato switch', 'legato?'], # vv: 00-3f = normal, 40-7f = legato
+ 0x45: ['hold 2', 'hold 2', 'hold 2'],
+ 0x46: ['sound controller 1 (default: sound variation)', 'sound controller 1', 'snd cntlr 1'],
+ 0x47: ['sound controller 2 (default: timbre / harmonic intensity)', 'sound controller 2', 'snd cntlr 2'],
+ 0x48: ['sound controller 3 (default: release time)', 'sound controller 3', 'snd cntlr 3'],
+ 0x49: ['sound controller 4 (default: attack time)', 'sound controller 4', 'snd cntlr 4'],
+ 0x4a: ['sound controller 5 (default: brightness)', 'sound controller 5', 'snd cntlr 5'],
+ 0x4b: ['sound controller 6 (GM2 default: decay time)', 'sound controller 6', 'snd cntlr 6'],
+ 0x4c: ['sound controller 7 (GM2 default: vibrato rate)', 'sound controller 7', 'snd cntlr 7'],
+ 0x4d: ['sound controller 8 (GM2 default: vibrato depth)', 'sound controller 8', 'snd cntlr 8'],
+ 0x4e: ['sound controller 9 (GM2 default: vibrato delay)', 'sound controller 9', 'snd cntlr 9'],
+ 0x4f: ['sound controller 10', 'sound controller 10', 'snd cntlr 10'],
+ 0x50: ['general purpose controller 5', 'GP controller 5', 'GPC-5'],
+ 0x51: ['general purpose controller 6', 'GP controller 6', 'GPC-6'],
+ 0x52: ['general purpose controller 7', 'GP controller 7', 'GPC-7'],
+ 0x53: ['general purpose controller 8', 'GP controller 8', 'GPC-8'],
+ 0x54: ['portamento control', 'portamento ctl', 'porta. ctl'],
# 0x55-0x5a: undefined
- 0x5b: 'effects 1 depth (formerly external effects depth)',
- 0x5c: 'effects 2 depth (formerly tremolo depth)',
- 0x5d: 'effects 3 depth (formerly chorus depth)',
- 0x5e: 'effects 4 depth (formerly celeste/detune depth)',
- 0x5f: 'effects 5 depth (formerly phaser depth)',
- 0x60: 'data increment',
- 0x61: 'data decrement',
- 0x62: 'Non-Registered Parameter Number LSB',
- 0x63: 'Non-Registered Parameter Number MSB',
- 0x64: 'Registered Parameter Number LSB',
- 0x65: 'Registered Parameter Number MSB',
+ 0x5b: ['effects 1 depth (formerly external effects depth)', 'effects 1 depth', 'effects 1 depth'],
+ 0x5c: ['effects 2 depth (formerly tremolo depth)', 'effects 2 depth', 'effects 2 depth'],
+ 0x5d: ['effects 3 depth (formerly chorus depth)', 'effects 3 depth', 'effects 3 depth'],
+ 0x5e: ['effects 4 depth (formerly celeste/detune depth)', 'effects 4 depth', 'effects 4 depth'],
+ 0x5f: ['effects 5 depth (formerly phaser depth)', 'effects 5 depth', 'effects 5 depth'],
+ 0x60: ['data increment', 'data inc', 'data++'],
+ 0x61: ['data decrement', 'data dec', 'data--'],
+ 0x62: ['Non-Registered Parameter Number LSB', 'NRPN LSB', 'NRPN-L'],
+ 0x63: ['Non-Registered Parameter Number MSB', 'NRPN MSB', 'NRPN-M'],
+ 0x64: ['Registered Parameter Number LSB', 'RPN LSB', 'RPN-L'],
+ 0x65: ['Registered Parameter Number MSB', 'RPN MSB', 'RPN-M'],
# 0x66-0x77: undefined
# 0x78-0x7f: reserved for channel mode messages
- 0x78: 'all sound off',
- 0x79: 'reset all controllers',
- 0x7a: 'local control',
- 0x7b: 'all notes off',
- 0x7c: 'omni mode off', # all notes off
- 0x7d: 'omni mode on', # all notes off
- 0x7e: 'mono mode on', # mono mode on, all notes off
- 0x7f: 'poly mode on', # mono mode off, all notes off
+ 0x78: ['all sound off', 'all snd off', 'snd off'],
+ 0x79: ['reset all controllers', 'reset all cntlrs', 'reset cntlrs'],
+ 0x7a: ['local control', 'local cntl', 'local ctl'],
+ 0x7b: ['all notes off', 'notes off', 'notes off'],
+ 0x7c: ['omni mode off', 'omni off', 'omni off'], # all notes off
+ 0x7d: ['omni mode on', 'omni on', 'omni on'], # all notes off
+ 0x7e: ['mono mode on', 'mono on', 'mono'], # mono mode on, all notes off
+ 0x7f: ['poly mode on', 'poly on', 'poly'], # mono mode off, all notes off
}
gm_instruments = {
128: 'GS CM-64/CM-32 Kit',
}
+# Each quarter frame type has 2 string names, each shorter than the previous
quarter_frame_type = {
- 0: 'frame count LS nibble',
- 1: 'frame count MS nibble',
- 2: 'seconds count LS nibble',
- 3: 'seconds count MS nibble',
- 4: 'minutes count LS nibble',
- 5: 'minutes count MS nibble',
- 6: 'hours count LS nibble',
- 7: 'hours count MS nibble and SMPTE type',
+ 0: ['frame count LS nibble', 'frame LSN'],
+ 1: ['frame count MS nibble', 'frame MSN'],
+ 2: ['seconds LS nibble', 'sec LSN'],
+ 3: ['seconds MS nibble', 'sec MSN'],
+ 4: ['minutes LS nibble', 'min LSN'],
+ 5: ['minutes MS nibble', 'min MSN'],
+ 6: ['hours LS nibble', 'hrs LSN'],
+ 7: ['hours MS nibble and SMPTE type', 'hrs MSN'],
}
smpte_type = {
- 0: '24 frames/second',
- 1: '25 frames/second',
- 2: '30 frames/second (drop-frame)',
- 3: '30 frames/second (non-drop)',
+ 0: '24 fps',
+ 1: '25 fps',
+ 2: '30 fps (drop-frame)',
+ 3: '30 fps (non-drop)',
}
chromatic_notes = {
msg, chan, note, velocity = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[1], c[2]
note_name = self.get_note_name(chan, note)
self.putx([0, ['Channel %d: %s (note = %d \'%s\', velocity = %d)' % \
- (chan, status_bytes[msg], note, note_name, velocity)]])
+ (chan, status_bytes[msg][0], note, note_name, velocity),
+ 'ch %d: %s %d, velocity = %d' % \
+ (chan, status_bytes[msg][1], note, velocity),
+ '%d: %s %d, vel %d' % \
+ (chan, status_bytes[msg][2], note, velocity)]])
self.cmd, self.state = [], 'IDLE'
def handle_channel_msg_0x90(self):
return
self.es_block = self.es
msg, chan, note, velocity = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[1], c[2]
- s = 'note off' if (velocity == 0) else status_bytes[msg]
+ s = status_bytes[0x80] if (velocity == 0) else status_bytes[msg]
note_name = self.get_note_name(chan, note)
self.putx([0, ['Channel %d: %s (note = %d \'%s\', velocity = %d)' % \
- (chan, s, note, note_name, velocity)]])
+ (chan, s[0], note, note_name, velocity),
+ 'ch %d: %s %d, velocity = %d' % \
+ (chan, s[1], note, velocity),
+ '%d: %s %d, vel %d' % \
+ (chan, s[2], note, velocity)]])
self.cmd, self.state = [], 'IDLE'
def handle_channel_msg_0xa0(self):
self.es_block = self.es
msg, chan, note, pressure = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[1], c[2]
note_name = self.get_note_name(chan, note)
- self.putx([0, ['Channel %d: %s (note = %d \'%s\', pressure = %d)' % \
- (chan, status_bytes[msg], note, note_name, pressure)]])
+ self.putx([0, ['Channel %d: %s of %d for note = %d \'%s\'' % \
+ (chan, status_bytes[msg][0], pressure, note, note_name),
+ 'ch %d: %s %d for note %d' % \
+ (chan, status_bytes[msg][1], pressure, note),
+ '%d: %s %d, N %d' % \
+ (chan, status_bytes[msg][2], pressure, note)]])
self.cmd, self.state = [], 'IDLE'
def handle_controller_0x44(self):
# Legato footswitch: Bn 44 vv
# n = channel, vv = value (<= 0x3f: normal, > 0x3f: legato)
- chan, vv = (self.cmd[0] & 0x0f) + 1, self.cmd[2]
- t = 'normal' if vv <= 0x3f else 'legato'
- self.putx([0, ['Channel %d: control function \'%s\' = %s' % \
- (chan, control_functions[0x44], t)]])
+ c = self.cmd
+ msg, chan, vv = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[2]
+ t = ('normal', 'no') if vv <= 0x3f else ('legato', 'yes')
+ self.putx([0, ['Channel %d: %s \'%s\' = %s' % \
+ (chan, status_bytes[msg][0],
+ control_functions[0x44][0], t[0]),
+ 'ch %d: %s \'%s\' = %s' % \
+ (chan, status_bytes[msg][1],
+ control_functions[0x44][1], t[0]),
+ '%d: %s \'%s\' = %s' % \
+ (chan, status_bytes[msg][2],
+ control_functions[0x44][2], t[1])]])
def handle_controller_0x54(self):
# Portamento control (PTC): Bn 54 kk
# n = channel, kk = source note for pitch reference
- chan, kk = (self.cmd[0] & 0x0f) + 1, self.cmd[2]
+ c = self.cmd
+ msg, chan, kk = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[2]
kk_name = self.get_note_name(chan, kk)
- self.putx([0, ['Channel %d: control function \'%s\' (source note ' \
- '= %d / %s)' % \
- (chan, control_functions[0x54], kk, kk_name)]])
+ self.putx([0, ['Channel %d: %s \'%s\' (source note = %d / %s)' % \
+ (chan, status_bytes[msg][0],
+ control_functions[0x54][0], kk, kk_name),
+ 'ch %d: %s \'%s\' (source note = %d)' % \
+ (chan, status_bytes[msg][1],
+ control_functions[0x54][1], kk),
+ '%d: %s \'%s\' (src N %d)' % \
+ (chan, status_bytes[msg][2],
+ control_functions[0x54][2], kk)]])
def handle_controller_generic(self):
c = self.cmd
- chan, fn, param = (c[0] & 0x0f) + 1, c[1], c[2]
+ msg, chan, fn, param = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[1], c[2]
default_name = 'undefined'
ctrl_fn = control_functions.get(fn, default_name)
if ctrl_fn == default_name:
- ctrl_fn = '%s 0x%02x' % (default_name, fn)
- self.putx([0, ['Channel %d: control change to function \'%s\' ' \
- '(param = 0x%02x)' % (chan, ctrl_fn, param)]])
+ ctrl_fn = ('undefined 0x%02x' % fn, 'undef 0x%02x' % fn, '0x%02x' % fn)
+ self.putx([0, ['Channel %d: %s \'%s\' (param = 0x%02x)' % \
+ (chan, status_bytes[msg][0], ctrl_fn[0], param),
+ 'ch %d: %s \'%s\' (param = 0x%02x)' % \
+ (chan, status_bytes[msg][1], ctrl_fn[1], param),
+ '%d: %s \'%s\' is 0x%02x' % \
+ (chan, status_bytes[msg][2], ctrl_fn[2], param)]])
def handle_channel_mode(self):
# Channel Mode: Bn mm vv
# n = channel, mm = mode number (120 - 127), vv = value
c = self.cmd
- chan, mm, vv = (c[0] & 0x0f) + 1, c[1], c[2]
- mode_fn = control_functions.get(mm, 'undefined')
+ msg, chan, mm, vv = c[0] & 0xf0, (c[0] & 0x0f) + 1, c[1], c[2]
+ mode_fn = control_functions.get(mm, ('undefined', 'undef', 'undef'))
# Decode the value based on the mode number.
- vv_string = ''
+ vv_string = ('', '')
if mm == 122: # mode = local control?
if vv == 0:
- vv_string = 'off'
+ vv_string = ('off', 'off')
elif vv == 127: # mode = poly mode on?
- vv_string = 'on'
+ vv_string = ('on', 'on')
else:
- vv_string = '(non-standard param value of 0x%02x)' % vv
+ vv_string = ('(non-standard param value of 0x%02x)' % vv,
+ '0x%02x' % vv)
elif mm == 126: # mode = mono mode on?
if vv != 0:
- vv_string = '(%d channels)' % vv
+ vv_string = ('(%d channels)' % vv, '(%d ch)' % vv)
else:
- vv_string = '(channels \'basic\' through 16)'
+ vv_string = ('(channels \'basic\' through 16)',
+ '(ch \'basic\' thru 16)')
elif vv != 0: # All other channel mode messages expect vv == 0.
- vv_string = '(non-standard param value of 0x%02x)' % vv
- self.putx([0, ['Channel %d: mode message \'%s\' %s' % \
- (chan, mode_fn, vv_string)]])
+ vv_string = ('(non-standard param value of 0x%02x)' % vv,
+ '0x%02x' % vv)
+ self.putx([0, ['Channel %d: %s \'%s\' %s' % \
+ (chan, status_bytes[msg][0], mode_fn[0], vv_string[0]),
+ 'ch %d: %s \'%s\' %s' % \
+ (chan, status_bytes[msg][1], mode_fn[1], vv_string[1]),
+ '%d: %s \'%s\' %s' % \
+ (chan, status_bytes[msg][2], mode_fn[2], vv_string[1])]])
self.cmd, self.state = [], 'IDLE'
def handle_channel_msg_0xb0(self):
change_type = 'drum kit'
name = drum_kit.get(pp, 'undefined')
self.putx([0, ['Channel %d: %s to %s %d (assuming %s)' % \
- (chan, status_bytes[msg], change_type, pp, name)]])
+ (chan, status_bytes[msg][0], change_type, pp, name),
+ 'ch %d: %s to %s %d' % \
+ (chan, status_bytes[msg][1], change_type, pp),
+ '%d: %s %d' % \
+ (chan, status_bytes[msg][2], pp)]])
self.cmd, self.state = [], 'IDLE'
def handle_channel_msg_0xd0(self):
if len(c) < 2:
return
self.es_block = self.es
- msg, chan, vv = self.cmd[0] & 0xf0, (self.cmd[0] & 0x0f) + 1, self.cmd[1]
- self.putx([0, ['Channel %d: %s %d' % (chan, status_bytes[msg], vv)]])
+ msg, chan, vv = self.cmd[0] & 0xf0, (self.cmd[0] & 0x0f) + 1, \
+ self.cmd[1]
+ self.putx([0, ['Channel %d: %s %d' % (chan, status_bytes[msg][0], vv),
+ 'ch %d: %s %d' % (chan, status_bytes[msg][1], vv),
+ '%d: %s %d' % (chan, status_bytes[msg][2], vv)]])
self.cmd, self.state = [], 'IDLE'
def handle_channel_msg_0xe0(self):
self.cmd[1], self.cmd[2]
decimal = (mm << 7) + ll
self.putx([0, ['Channel %d: %s 0x%02x 0x%02x (%d)' % \
- (chan, status_bytes[msg], ll, mm, decimal)]])
+ (chan, status_bytes[msg][0], ll, mm, decimal),
+ 'ch %d: %s 0x%02x 0x%02x (%d)' % \
+ (chan, status_bytes[msg][1], ll, mm, decimal),
+ '%d: %s (%d)' % \
+ (chan, status_bytes[msg][2], decimal)]])
self.cmd, self.state = [], 'IDLE'
def handle_channel_msg_generic(self):
# to isolate the data.
msg, eox = self.cmd.pop(0), self.cmd.pop()
if len(self.cmd) < 1:
- self.putx([0, ['SysEx: truncated manufacturer code (<1 bytes)']])
+ self.putx([0, ['%s: truncated manufacturer code (<1 bytes)' % \
+ status_bytes[msg][0],
+ '%s: truncated manufacturer (<1 bytes)' % \
+ status_bytes[msg][1],
+ '%s: trunc. manu.' % status_bytes[msg][2]]])
self.cmd, self.state = [], 'IDLE'
return
# Extract the manufacturer name (or SysEx realtime or non-realtime).
manu = (m1,)
if m1 == 0x00: # If byte == 0, then 2 more manufacturer bytes follow.
if len(self.cmd) < 2:
- self.putx([0, ['SysEx: truncated manufacturer code (<3 bytes)']])
+ self.putx([0, ['%s: truncated manufacturer code (<3 bytes)' % \
+ status_bytes[msg][0],
+ '%s: truncated manufacturer (<3 bytes)' % \
+ status_bytes[msg][1],
+ '%s: trunc. manu.' % status_bytes[msg][2]]])
self.cmd, self.state = [], 'IDLE'
return
manu = (m1, self.cmd.pop(0), self.cmd.pop(0))
manu_name = sysex_manufacturer_ids.get(manu, default_name)
if manu_name == default_name:
if len(manu) == 3:
- manu_name = '%s (0x%02x 0x%02x 0x%02x)' % \
- (default_name, manu[0], manu[1], manu[2])
+ manu_name = ('%s (0x%02x 0x%02x 0x%02x)' % \
+ (default_name, manu[0], manu[1], manu[2]),
+ default_name)
else:
- manu_name = '%s (0x%02x)' % (default_name, manu[0])
- # Extract the payload.
+ manu_name = ('%s (0x%02x)' % (default_name, manu[0]),
+ default_name)
+ else:
+ manu_name = (manu_name, manu_name)
+ # Extract the payload, display in 1 of 2 formats
# TODO: Write methods to decode SysEx realtime & non-realtime payloads.
- payload = ''
+ payload0 = ''
+ payload1 = ''
while len(self.cmd) > 0:
- payload += '0x%02x ' % (self.cmd.pop(0))
- if payload == '':
- payload = '<empty>'
- self.putx([0, ['SysEx: for \'%s\' with payload %s' % \
- (manu_name, payload)]])
+ byte = self.cmd.pop(0)
+ payload0 += '0x%02x ' % (byte)
+ payload1 += '%02x ' % (byte)
+ if payload0 == '':
+ payload0 = '<empty>'
+ payload1 = '<>'
+ payload = (payload0, payload1)
+ self.putx([0, ['%s: for \'%s\' with payload %s' % \
+ (status_bytes[msg][0], manu_name[0], payload[0]),
+ '%s: \'%s\', payload %s' % \
+ (status_bytes[msg][1], manu_name[1], payload[1]),
+ '%s: \'%s\', payload %s' % \
+ (status_bytes[msg][2], manu_name[1], payload[1])]])
self.cmd, self.state = [], 'IDLE'
def handle_syscommon_midi_time_code_quarter_frame_msg(self, newbyte):
return
msg = self.cmd[0]
nn, dd = (self.cmd[1] & 0x70) >> 4, self.cmd[1] & 0x0f
- group = 'System Common'
+ group = ('System Common', 'SysCom', 'SC')
self.es_block = self.es
if nn != 7: # If message type does not contain SMPTE type.
self.putx([0, ['%s: %s of %s, value 0x%01x' % \
- (group, status_bytes[msg], quarter_frame_type[nn], dd)]])
+ (group[0], status_bytes[msg][0],
+ quarter_frame_type[nn][0], dd),
+ '%s: %s of %s, value 0x%01x' % \
+ (group[1], status_bytes[msg][1],
+ quarter_frame_type[nn][1], dd),
+ '%s: %s of %s, value 0x%01x' % \
+ (group[2], status_bytes[msg][2],
+ quarter_frame_type[nn][1], dd)]])
self.cmd, self.state = [], 'IDLE'
return
tt = (dd & 0x6) >> 1
self.putx([0, ['%s: %s of %s, value 0x%01x for %s' % \
- (group, status_bytes[msg], quarter_frame_type[nn], \
- dd, smpte_type[tt])]])
+ (group[0], status_bytes[msg][0], \
+ quarter_frame_type[nn][0], dd, smpte_type[tt]),
+ '%s: %s of %s, value 0x%01x for %s' % \
+ (group[1], status_bytes[msg][1], \
+ quarter_frame_type[nn][1], dd, smpte_type[tt]),
+ '%s: %s of %s, value 0x%01x for %s' % \
+ (group[2], status_bytes[msg][2], \
+ quarter_frame_type[nn][1], dd, smpte_type[tt])]])
self.cmd, self.state = [], 'IDLE'
def handle_syscommon_msg(self, newbyte):
self.cmd.append(newbyte)
msg = self.cmd[0]
c = self.cmd
- group = 'System Common'
+ group = ('System Common', 'SysCom', 'SC')
if msg == 0xf1:
# MIDI time code quarter frame
self.handle_syscommon_midi_time_code_quarter_frame_msg(newbyte)
decimal = (mm << 7) + ll
self.es_block = self.es
self.putx([0, ['%s: %s 0x%02x 0x%02x (%d)' % \
- (group, status_bytes[msg], ll, mm, decimal)]])
+ (group[0], status_bytes[msg][0], ll, mm, decimal),
+ '%s: %s 0x%02x 0x%02x (%d)' % \
+ (group[1], status_bytes[msg][1], ll, mm, decimal),
+ '%s: %s (%d)' % \
+ (group[2], status_bytes[msg][2], decimal)]])
elif msg == 0xf3:
# Song select: F3 ss
# ss = song selection number
return
ss = self.cmd[1]
self.es_block = self.es
- self.putx([0, ['%s: %s number %d' % (group, status_bytes[msg], ss)]])
+ self.putx([0, ['%s: %s number %d' % \
+ (group[0], status_bytes[msg][0], ss),
+ '%s: %s number %d' % \
+ (group[1], status_bytes[msg][1], ss),
+ '%s: %s # %d' % \
+ (group[2], status_bytes[msg][2], ss)]])
elif msg == 0xf4 or msg == 0xf5 or msg == 0xf6:
# Undefined 0xf4, Undefined 0xf5, and Tune Request (respectively).
# All are only 1 byte long with no data bytes.
self.es_block = self.es
- self.putx([0, ['%s: %s' % (group, status_bytes[msg])]])
+ self.putx([0, ['%s: %s' % (group[0], status_bytes[msg][0]),
+ '%s: %s' % (group[1], status_bytes[msg][1]),
+ '%s: %s' % (group[2], status_bytes[msg][2])]])
self.cmd, self.state = [], 'IDLE'
def handle_sysrealtime_msg(self, newbyte):
# System realtime message: 0b11111ttt (t = message type)
self.es_block = self.es
- self.putx([0, ['System realtime message: %s' % status_bytes[newbyte]]])
+ group = ('System Realtime', 'SysReal', 'SR')
+ self.putx([0, ['%s: %s' % (group[0], status_bytes[newbyte][0]),
+ '%s: %s' % (group[1], status_bytes[newbyte][1]),
+ '%s: %s' % (group[2], status_bytes[newbyte][2])]])
self.cmd, self.state = [], 'IDLE'
def decode(self, ss, es, data):