Mercurial > ~darius > hgwebdir.cgi > musiccutter
diff 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 |
line wrap: on
line diff
--- a/musiccutter.py Tue May 03 08:34:39 2016 +0930 +++ b/musiccutter.py Tue May 03 09:09:27 2016 +0930 @@ -72,7 +72,12 @@ ctime += ev.time if ev.type == 'note_on' or ev.type == 'note_off': - note = self.midi2note[ev.note] + if ev.note not in self.midi2note: + print 'Input MIDI number %d out of range' % (ev.note) + unplayablecount += 1 + continue + else: + note = self.midi2note[ev.note] #print ctime, ev if ev.type == 'note_on' and ev.velocity > 0: if ev.note in channels[ev.channel]: