else :
for note in verse :
yield note, 0
else :
for note in verse :
yield note, 0
+
+ @property
+ def intervalsHistogram(self) :
+ histogram = {}
+ it = self.iterNotes()
+ previousNote = it.next()[0]
+ for note, _ in it :
+ interval = note.midi - previousNote.midi
+ if histogram.has_key(interval) :
+ histogram[interval] += 1
+ else :
+ histogram[interval] = 1
+ previousNote = note
+ return histogram
def pprint(self) :
for note, verseIndex in self.iterNotes(indefinitely=False) :
def pprint(self) :
for note, verseIndex in self.iterNotes(indefinitely=False) :
doc = d.documentElement
# TODO conversion préalable score-timewise -> score-partwise
doc = d.documentElement
# TODO conversion préalable score-timewise -> score-partwise
- assert doc.nodeName == u'score-partwise'
+ if doc.nodeName != u'score-partwise' :
+ raise ValueError('not a musicxml file')
parts = doc.getElementsByTagName('part')
leadPart = parts[partIndex]
parts = doc.getElementsByTagName('part')
leadPart = parts[partIndex]
if len(args) != 1 :
raise SystemExit(op.format_help())
if len(args) != 1 :
raise SystemExit(op.format_help())
+ song = musicXml2Song(args[0],
partIndex=options.partIndex,
autoDetectChorus=options.autoDetectChorus,
printNotes=options.printNotes)
partIndex=options.partIndex,
autoDetectChorus=options.autoDetectChorus,
printNotes=options.printNotes)
+ from pprint import pprint
+ pprint(song.intervalsHistogram)
if __name__ == '__main__' :
if __name__ == '__main__' :