From 704637a070dfbf0880d228228a0ef183e982f81e Mon Sep 17 00:00:00 2001 From: pin Date: Thu, 8 Jul 2010 16:51:11 +0000 Subject: [PATCH 1/1] =?utf8?q?Impl=C3=A9mentation=20de=20la=20m=C3=A9thode?= =?utf8?q?=20de=20comptage=20des=20fautes.?= 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@281 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/loganalyse.py | 73 +++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/src/minwii/loganalyse.py b/src/minwii/loganalyse.py index 551af7f..952c3a7 100755 --- a/src/minwii/loganalyse.py +++ b/src/minwii/loganalyse.py @@ -16,15 +16,15 @@ DEFAULT_STATS = ('geometricmean', 'mean', 'median', 'medianscore', - 'mode', + #'mode', 'moment', 'variation', 'skew', 'kurtosis', - 'itemfreq', - 'histogram', - 'cumfreq', - 'relfreq', + #'itemfreq', + #'histogram', + #'cumfreq', + #'relfreq', ) def statsresults(m) : @@ -41,10 +41,28 @@ class LogFileAnalyser(LogFileReader) : POSSIBLE_ANALYSES = {'BEGINNER' : ('songDuration', 'playingDuration', 'noteEndNoteOnLatency', - 'noteOnCount')} + 'realisationRate') + ,'EASY' : ('songDuration', + 'playingDuration', + 'noteEndNoteOnLatency', + 'realisationRate', + 'missCount') + ,'NORMAL' : ('songDuration', + 'playingDuration', + 'realisationRate', + 'missCount') + ,'ADVANCED' : ('songDuration', + 'playingDuration', + 'realisationRate', + 'missCount') + ,'EXPERT' : ('songDuration', + 'playingDuration', + 'realisationRate', + 'missCount') + } def analyse(self) : - mode = self.getMode() + self.mode = mode = self.getMode() print 'Mode :', mode results = {} @@ -100,9 +118,48 @@ class LogFileAnalyser(LogFileReader) : cpt = cpt + 1 return cpt - + + def realisationRate(self) : + """ taux de réalisation en nombre de note + peut être supérieur à 100 % car la chanson + boucle à l'infini. + """ + songFile = self.getSongFile() + song = musicXml2Song(songFile) + songNoteCpt = 0 + for note, verseIndex in song.iterNotes() : + songNoteCpt = songNoteCpt + 1 + return int(round(self.noteOnCount() / float(songNoteCpt) * 100, 0)) + def missCount(self) : + eIter = self.getEventsIterator() + miss = 0 + if self.mode in ('EASY', 'NORMAL') : + catchColUp = False + for ticks, eventName, message in eIter : + if eventName == 'COLDOWN' : + colState = message.split(None, 2)[1] + colState = colState == 'True' + if colState : + catchColUp = False + continue + else : + catchColUp = True + elif eventName == 'NOTEON' : + catchColUp = False + elif eventName == 'COLUP' and catchColUp : + miss = miss + 1 + else : + for ticks, eventName, message in eIter : + if eventName == 'COLDOWN' : + colState = message.split(None, 2)[1] + colState = colState == 'True' + if not colState : + miss = miss + 1 + + return miss + -- 2.20.1