From 94e7b3f13f4247613609d53c95d0ba59a1eee9d1 Mon Sep 17 00:00:00 2001 From: pin Date: Tue, 27 Sep 2011 11:47:20 +0000 Subject: [PATCH] =?utf8?q?Ajout=20de=20la=20propri=C3=A9t=C3=A9=20=C2=AB?= =?utf8?q?=20duration=20=C2=BB=20sur=20l'objet=20musicxml.Part.=20Modifica?= =?utf8?q?tion=20dans=20le=20code=20d'analyse=20pour=20prendre=20en=20char?= =?utf8?q?ge=20cette=20propri=C3=A9t=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@394 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/loganalyse.py | 5 +---- src/minwii/musicxml.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/minwii/loganalyse.py b/src/minwii/loganalyse.py index f3e5e32..61b0382 100755 --- a/src/minwii/loganalyse.py +++ b/src/minwii/loganalyse.py @@ -139,10 +139,7 @@ class LogFileAnalyser(LogFileReader) : songFile = self.getSongFile() song = musicXml2Song(songFile) - duration = 0 - for note, verseIndex in song.iterNotes() : - duration = duration + note.duration - duration = duration * song.quarterNoteDuration # en milisecondes + duration = song.duration return self._toTimeDelta(duration) @statsresults diff --git a/src/minwii/musicxml.py b/src/minwii/musicxml.py index 7468eca..54d859f 100755 --- a/src/minwii/musicxml.py +++ b/src/minwii/musicxml.py @@ -176,6 +176,17 @@ class Part(object) : histogram[interval] = 1 previousNote = note return histogram + + @property + def duration(self) : + 'Durée de référence du morceau en milisecondes' + it = self.iterNotes() + duration = 0 + for note, verseIndex in it : + duration = duration + note.duration + duration = duration * self.quarterNoteDuration # en milisecondes + return duration + def pprint(self) : for note, verseIndex in self.iterNotes(indefinitely=False) : @@ -423,6 +434,7 @@ def main() : printNotes=options.printNotes) from pprint import pprint pprint(song.intervalsHistogram) + print song.duration if __name__ == '__main__' : -- 2.20.1