# HG changeset patch # User Daniel O'Connor # Date 1457180276 -37800 # Node ID 123b42d95ab84b83cf0a8e2d42cbfa32e6bb4aea # Parent 0773354c742882563d90c041a8a388a36f3422ef Use cm directly diff -r 0773354c7428 -r 123b42d95ab8 musiccutter.py --- a/musiccutter.py Sat Mar 05 21:59:44 2016 +1030 +++ b/musiccutter.py Sat Mar 05 22:47:56 2016 +1030 @@ -45,20 +45,22 @@ return note2slot def emitnote(svg, slot, start, notelen): - # Let us say 185 ticks for a quaver and that is 5mm long - tickscale = 185.0 / 5.0 - pitch = 5.5 - offset = 6 + # Let us say 185 ticks for a quaver and that is 0.5cm long + tickscale = 185.0 / 0.5 + pitch = 0.55 + offset = 0.60 x = start / tickscale y = offset + slot * pitch w = notelen / tickscale - h = pitch - print x, y, w, h - svg.add(svgwrite.shapes.Rect(insert = ('%.3fcm' % (x / 10, '%.3fcm' % (y / 10)), size = (w, h), stroke = 'red', stroke_width = '1px', fill = 'red')) + h = pitch / 10.0 + print 'x = %.3f y = %.3f w = %.3f h = %.3f' % (x, y, w, h) + svg.add(svgwrite.shapes.Rect(insert = ('%.3fcm' % (x), '%.3fcm' % (y)), + size = ('%.3fcm' % (w), '%.3fcm' % (h)), + stroke = 'red', stroke_width = '1px', fill = 'red')) def midi2svg(inf, outpat, pitch, midi2note, note2midi, note2slot): midi = mido.MidiFile(inf) - svg = svgwrite.Drawing(outpat % (0)) + svg = svgwrite.Drawing(outpat % (0), size = ('20.0cm', '15.5cm')) tnum = 0 for t in midi.tracks: print "Track", tnum