comparison musiccutter.py @ 3:49a33c431b45

Accept filename for test function
author Daniel O'Connor <darius@dons.net.au>
date Mon, 07 Mar 2016 14:46:37 +1030
parents b1aac55d2864
children 9f4fa5f231e6
comparison
equal deleted inserted replaced
2:b1aac55d2864 3:49a33c431b45
3 import exceptions 3 import exceptions
4 import mido 4 import mido
5 import svgwrite 5 import svgwrite
6 import sys 6 import sys
7 7
8 def test(): 8 def test(filename = None):
9 # http://www.orgues-de-barbarie.com/wp-content/uploads/2014/09/format-cartons.pdf 9 # http://www.orgues-de-barbarie.com/wp-content/uploads/2014/09/format-cartons.pdf
10 conf = { 'notefile' : 'notes', 'pitch' : 5.5 , 'pagewidth' : 20, 'pageheight' : 15.5 } 10 conf = { 'notefile' : 'notes', 'pitch' : 5.5 , 'pagewidth' : 20, 'pageheight' : 15.5 }
11 midi2note, note2midi = genmidi2note() 11 midi2note, note2midi = genmidi2note()
12 note2slot = loadnote2slot(conf['notefile'], note2midi) 12 note2slot = loadnote2slot(conf['notefile'], note2midi)
13 midi2svg('test.midi', 'test%d.svg', conf['pitch'], midi2note, note2midi, note2slot, conf['pagewidth'], conf['pageheight']) 13 if filename == None:
14 filename = 'test.midi'
15 midi2svg(filename, 'test%d.svg', conf['pitch'], midi2note, note2midi, note2slot, conf['pagewidth'], conf['pageheight'])
14 16
15 # http://www.electronics.dit.ie/staff/tscarff/Music_technology/midi/midi_note_numbers_for_octaves.htm 17 # http://www.electronics.dit.ie/staff/tscarff/Music_technology/midi/midi_note_numbers_for_octaves.htm
16 def genmidi2note(): 18 def genmidi2note():
17 '''Create forward & reverse tables for midi number to note name (assuming 69 == A440)''' 19 '''Create forward & reverse tables for midi number to note name (assuming 69 == A440)'''
18 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'] 20 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']