comparison musiccutter.py @ 29:767ba8ec90e6

Don't crap out if the input midi note is out of range
author Daniel O'Connor <darius@dons.net.au>
date Tue, 03 May 2016 09:09:27 +0930
parents 657bc32a0dfd
children f46cc9401e79
comparison
equal deleted inserted replaced
28:657bc32a0dfd 29:767ba8ec90e6
70 if ev.type == 'text' and ctime == 0: 70 if ev.type == 'text' and ctime == 0:
71 title = ev.text 71 title = ev.text
72 72
73 ctime += ev.time 73 ctime += ev.time
74 if ev.type == 'note_on' or ev.type == 'note_off': 74 if ev.type == 'note_on' or ev.type == 'note_off':
75 note = self.midi2note[ev.note] 75 if ev.note not in self.midi2note:
76 print 'Input MIDI number %d out of range' % (ev.note)
77 unplayablecount += 1
78 continue
79 else:
80 note = self.midi2note[ev.note]
76 #print ctime, ev 81 #print ctime, ev
77 if ev.type == 'note_on' and ev.velocity > 0: 82 if ev.type == 'note_on' and ev.velocity > 0:
78 if ev.note in channels[ev.channel]: 83 if ev.note in channels[ev.channel]:
79 print 'Duplicate note_on message %d (%s)' % (ev.note, note) 84 print 'Duplicate note_on message %d (%s)' % (ev.note, note)
80 else: 85 else: