comparison musiccutter.py @ 26:f492b70f5e49

Fix notename/line drawing. Remove superfluous state save call.
author Daniel O'Connor <darius@dons.net.au>
date Sat, 30 Apr 2016 16:57:02 +0930
parents ce367392806c
children 87cf66e04ef9
comparison
equal deleted inserted replaced
25:ce367392806c 26:f492b70f5e49
100 for pindx in range(len(pdfs)): 100 for pindx in range(len(pdfs)):
101 pdf = pdfs[pindx] 101 pdf = pdfs[pindx]
102 # Add title and page number 102 # Add title and page number
103 Midi2PDF.textHelper(pdf, 0 * mm, 1 * mm, ENGRAVE_COLOUR, True, self.fontname, self.fontsize, '%s (%d / %d)' % (title, pindx + 1, npages)) 103 Midi2PDF.textHelper(pdf, 0 * mm, 1 * mm, ENGRAVE_COLOUR, True, self.fontname, self.fontsize, '%s (%d / %d)' % (title, pindx + 1, npages))
104 104
105 pdf.saveState() # Not really necessary since everything after this is done hairline
106 pdf.setLineWidth(0) 105 pdf.setLineWidth(0)
107 106
108 # Draw time marks 107 # Draw time marks
109 if self.timemarks: 108 if self.timemarks:
110 tstart = self.leadin / self.timescale 109 tstart = self.leadin / self.timescale
122 if self.drawrect: 121 if self.drawrect:
123 pdf.rect(0, 0, self.pagewidth * mm, self.pageheight * mm, fill = False, stroke = True) 122 pdf.rect(0, 0, self.pagewidth * mm, self.pageheight * mm, fill = False, stroke = True)
124 123
125 # Draw lines per note 124 # Draw lines per note
126 for slot in sorted(self.slot2note.keys()): 125 for slot in sorted(self.slot2note.keys()):
127 ofs = (self.heel - self.slotsize / 2 + slot * self.pitch) * mm 126 ofs = self.pageheight - (self.heel + slot * self.pitch) - self.slotsize / 2
128 if self.notelines: 127 if self.notelines:
129 pdf.line(0, ofs, self.pagewidth * mm, ofs) 128 pdf.line(0, ofs * mm, self.pagewidth * mm, ofs * mm)
130 # Note name 129 # Note name
131 if self.notenames: 130 if self.notenames:
132 Midi2PDF.textHelper(pdf, (self.pagewidth - 10) * mm, ofs + 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, self.slot2note[slot]) 131 Midi2PDF.textHelper(pdf, (self.pagewidth - 10) * mm, (ofs + 0.5) * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, self.slot2note[slot])
133 132
134 # Save PDF 133 # Save PDF
135 pdf.save() 134 pdf.save()
136 135
137 # http://newt.phys.unsw.edu.au/jw/notes.html 136 # http://newt.phys.unsw.edu.au/jw/notes.html
138 @staticmethod 137 @staticmethod
139 def genmidi2note(offset): 138 def genmidi2note(offset):
140 '''Create forward & reverse tables for midi number to note name (assuming 69 = A4 = A440) 139 '''Create forward & reverse tables for midi number to note name (assuming 69 = A4 = A440)