Mercurial > ~darius > hgwebdir.cgi > musiccutter
diff musiccutter.py @ 20:9bb72ae63651
- Make various things optional.
- Fix card size typo.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Tue, 26 Apr 2016 21:35:54 +0930 |
parents | ffaf97818ce3 |
children | c710c4c3f44f |
line wrap: on
line diff
--- a/musiccutter.py Tue Apr 26 18:10:18 2016 +0930 +++ b/musiccutter.py Tue Apr 26 21:35:54 2016 +0930 @@ -18,12 +18,12 @@ filename = 'test.midi' # Card layout from http://www.orgues-de-barbarie.com/wp-content/uploads/2014/09/format-cartons.pdf # Notes are read from right to left - m = Midi2PDF('notes', 130, 155, 5.5, 3.0, 6.0, 0, False, False, 10, 'Helvetica', 12) + m = Midi2PDF('notes', 120, 155, 5.5, 3.0, 6.0, 50, False, False, False, False, 10, 'Helvetica', 12) base, ext = os.path.splitext(filename) m.processMidi(filename, base + '-%02d.pdf') class Midi2PDF(object): - def __init__(self, notefile, pagewidth, pageheight, pitch, slotsize, offset, leadin, timemarks, drawrect, timescale, fontname, fontsize): + def __init__(self, notefile, pagewidth, pageheight, pitch, slotsize, offset, leadin, timemarks, drawrect, notenames, notelines, timescale, fontname, fontsize): self.midi2note, self.note2midi = Midi2PDF.genmidi2note() self.note2slot, self.slot2note = Midi2PDF.loadnote2slot(notefile, self.note2midi) self.pagewidth = pagewidth # Dimensions are in millimetres @@ -34,6 +34,8 @@ self.leadin = leadin # Extra at the start self.timemarks = timemarks # Draw vertical time lines self.drawrect = drawrect # Draw rectangle around each page + self.notenames = notenames # Draw note names on the right edge + self.notelines = notelines # Draw line rulers self.timescale = timescale # Width per second self.fontname = fontname self.fontsize = fontsize # Points @@ -124,11 +126,12 @@ # Draw lines per note for slot in sorted(self.slot2note.keys()): ofs = (self.offset + slot * self.pitch) * mm - pdf.line(0, ofs, self.pagewidth * mm, ofs) + if self.notelines: + pdf.line(0, ofs, self.pagewidth * mm, ofs) # Note name - Midi2PDF.textHelper(pdf, (self.pagewidth - 10) * mm, ofs + 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, self.slot2note[slot]) - pdf.restoreState() - pdf.save() + if self.notenames: + Midi2PDF.textHelper(pdf, (self.pagewidth - 10) * mm, ofs + 1 * mm, ENGRAVE_COLOUR, False, self.fontname, self.fontsize, self.slot2note[slot]) + pdf.save() # http://newt.phys.unsw.edu.au/jw/notes.html @staticmethod