Mercurial > ~darius > hgwebdir.cgi > musiccutter
comparison musiccutter.py @ 39:86622ba474e4
add some comments
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 23 May 2016 22:38:27 +0930 |
parents | 9e8ed92b477c |
children | 5c47f9361d93 |
comparison
equal
deleted
inserted
replaced
38:9e8ed92b477c | 39:86622ba474e4 |
---|---|
102 print 'Duplicate note_on message at %.1f sec channel %d note %d' % (ctime, ev.channel, ev.note) | 102 print 'Duplicate note_on message at %.1f sec channel %d note %d' % (ctime, ev.channel, ev.note) |
103 else: | 103 else: |
104 channels[ev.channel][ev.note] = ctime | 104 channels[ev.channel][ev.note] = ctime |
105 elif ev.type == 'note_off' or (ev.type == 'note_on' and ev.velocity == 0): | 105 elif ev.type == 'note_off' or (ev.type == 'note_on' and ev.velocity == 0): |
106 if ev.note not in channels[ev.channel]: | 106 if ev.note not in channels[ev.channel]: |
107 # These can be rests (iWriteMusic) | |
107 print 'note_off with no corresponding note_on at %.1f sec for channel %d note %d' % (ctime, ev.channel, ev.note) | 108 print 'note_off with no corresponding note_on at %.1f sec for channel %d note %d' % (ctime, ev.channel, ev.note) |
108 continue | 109 continue |
109 else: | 110 else: |
110 orignote = ev.note | 111 orignote = ev.note |
111 start = channels[ev.channel][orignote] | 112 start = channels[ev.channel][orignote] |
131 print 'Unplayable count:', stats.unplayablecount | 132 print 'Unplayable count:', stats.unplayablecount |
132 if self.trytranspose: | 133 if self.trytranspose: |
133 print 'Transpose down:', stats.transposedowncount | 134 print 'Transpose down:', stats.transposedowncount |
134 print 'Transpose up:', stats.transposeupcount | 135 print 'Transpose up:', stats.transposeupcount |
135 | 136 |
137 # Do per-page things | |
136 for pindx in range(npages): | 138 for pindx in range(npages): |
137 pdf = pdfs[pindx / self.pagesperpdf] # PDF for this page | 139 pdf = pdfs[pindx / self.pagesperpdf] # PDF for this page |
138 # Offset into PDF where the page starts | 140 # Offset into PDF where the page starts |
139 pageofs = self.pagewidth * (self.pagesperpdf - (pindx % self.pagesperpdf) - 1) | 141 pageofs = self.pagewidth * (self.pagesperpdf - (pindx % self.pagesperpdf) - 1) |
140 # Add title and page number | 142 # Add title and page number |
183 if notename in self.note2slot: | 185 if notename in self.note2slot: |
184 slot = self.note2slot[notename] | 186 slot = self.note2slot[notename] |
185 | 187 |
186 return slot | 188 return slot |
187 | 189 |
190 # Check if the organ can play the note | |
188 def transposenote(self, evw, amount): | 191 def transposenote(self, evw, amount): |
189 evw.ev.note += amount | 192 evw.ev.note += amount |
190 evw.notename = self.midi2note[evw.ev.note] | 193 evw.notename = self.midi2note[evw.ev.note] |
191 evw.slot = self.note2slot[evw.notename] | 194 evw.slot = self.note2slot[evw.notename] |
192 | 195 |
196 # Work out which slot to use for the note, transpose if desired | |
193 def getslotfornote(self, evw, stats, ctime): | 197 def getslotfornote(self, evw, stats, ctime): |
194 evw.slot = None | 198 evw.slot = None |
195 evw.notename = None | 199 evw.notename = None |
196 | 200 |
197 # First off, is the note in our midi table? | 201 # First off, is the note in our midi table? |