comparison musiccutter.py @ 25:ce367392806c

comment tweaks
author Daniel O'Connor <darius@dons.net.au>
date Sat, 30 Apr 2016 16:37:23 +0930
parents 71b78f06ff03
children f492b70f5e49
comparison
equal deleted inserted replaced
24:71b78f06ff03 25:ce367392806c
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 this is last thing we do 105 pdf.saveState() # Not really necessary since everything after this is done hairline
106 pdf.setLineWidth(0) 106 pdf.setLineWidth(0)
107 107
108 # Draw time marks 108 # Draw time marks
109 if self.timemarks: 109 if self.timemarks:
110 tstart = self.leadin / self.timescale 110 tstart = self.leadin / self.timescale
116 for s in range(tstart, tend, 5): 116 for s in range(tstart, tend, 5):
117 x = self.pagewidth - (float(s * self.timescale + self.leadin) % self.pagewidth) 117 x = self.pagewidth - (float(s * self.timescale + self.leadin) % self.pagewidth)
118 pdf.line(x * mm, self.heel, x * mm, self.pageheight * mm) 118 pdf.line(x * mm, self.heel, x * mm, self.pageheight * mm)
119 Midi2PDF.textHelper(pdf, x * mm, 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, str(s) + 's') 119 Midi2PDF.textHelper(pdf, x * mm, 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, str(s) + 's')
120 120
121 # Draw rectangle around page 121 # Draw rectangle around page (upper and right hand ends don't seem to render though)
122 if self.drawrect: 122 if self.drawrect:
123 pdf.rect(0, 0, self.pagewidth * mm, self.pageheight * mm, fill = False, stroke = True) 123 pdf.rect(0, 0, self.pagewidth * mm, self.pageheight * mm, fill = False, stroke = True)
124 124
125 # Draw lines per note 125 # Draw lines per note
126 for slot in sorted(self.slot2note.keys()): 126 for slot in sorted(self.slot2note.keys()):
128 if self.notelines: 128 if self.notelines:
129 pdf.line(0, ofs, self.pagewidth * mm, ofs) 129 pdf.line(0, ofs, self.pagewidth * mm, ofs)
130 # Note name 130 # Note name
131 if self.notenames: 131 if self.notenames:
132 Midi2PDF.textHelper(pdf, (self.pagewidth - 10) * mm, ofs + 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, self.slot2note[slot]) 132 Midi2PDF.textHelper(pdf, (self.pagewidth - 10) * mm, ofs + 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, self.slot2note[slot])
133
134 # Save PDF
133 pdf.save() 135 pdf.save()
134 136
135 # http://newt.phys.unsw.edu.au/jw/notes.html 137 # http://newt.phys.unsw.edu.au/jw/notes.html
136 @staticmethod 138 @staticmethod
137 def genmidi2note(offset): 139 def genmidi2note(offset):