changeset 12:6e46ceee57a7

Use correct MIDI note generation, previous version did not agree with MUP (hmmmm).
author Daniel O'Connor <darius@dons.net.au>
date Sun, 10 Apr 2016 22:24:56 +0930
parents 9faad813e39e
children 5f4c21bb5140
files musiccutter.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/musiccutter.py	Thu Apr 07 23:35:44 2016 +0930
+++ b/musiccutter.py	Sun Apr 10 22:24:56 2016 +0930
@@ -6,6 +6,7 @@
 import mido
 import os
 import reportlab.lib.colors
+import reportlab.pdfgen.canvas
 from reportlab.lib.units import mm
 import sys
 
@@ -99,15 +100,15 @@
             pdf.drawText(tobj)
             pdf.save()
 
-    # http://www.electronics.dit.ie/staff/tscarff/Music_technology/midi/midi_note_numbers_for_octaves.htm
+    # http://newt.phys.unsw.edu.au/jw/notes.html
     @staticmethod
     def genmidi2note():
-        '''Create forward & reverse tables for midi number to note name (assuming 69 == A440)'''
+        '''Create forward & reverse tables for midi number to note name (assuming 69 = A4 = A440)'''
         names = ['C%d', 'C%d#', 'D%d', 'D%d#', 'E%d', 'F%d', 'F%d#', 'G%d', 'G%d#', 'A%d', 'A%d#', 'B%d']
         midi2note = {}
         note2midi = {}
         for midi in range(128):
-            octave = midi / len(names)
+            octave = midi / len(names) - 1
             index = midi % len(names)
             name = names[index] % (octave)
             midi2note[midi] = name