+ def noteOnCount(self) :
+ "retourne le nombre d'événements NOTEON"
+
+ eIter = self.getEventsIterator()
+ cpt = 0
+
+ for ticks, eventName, message in eIter :
+ if eventName == 'NOTEON' :
+ cpt = cpt + 1
+
+ return cpt
+
+ def realisationRate(self) :
+ 'Taux de réalisation'
+ #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 round(self.noteOnCount() / float(songNoteCpt) * 100, 1)
+
+ def missCount(self) :
+ "Nombre d'erreurs"
+ 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
+
+ @timebased
+ def getMissPerTimeFrame(self, timeFrame=10000) :
+ "Nombre d'erreurs en fonction du temps"
+ eIter = self.getEventsIterator()
+ firstTicks = self.getFirstEventTicks()
+ frames = [0]
+
+ if self.mode in ('EASY', 'NORMAL') :
+ catchColUp = False
+ for ticks, eventName, message in eIter :
+ if ticks - firstTicks > timeFrame :
+ firstTicks = ticks
+ frames.append(0)
+
+ 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 :
+ frames[-1] = frames[-1] + 1
+ else :
+ for ticks, eventName, message in eIter :
+ if ticks - firstTicks > timeFrame :
+ firstTicks = ticks
+ frames.append(0)
+
+ if eventName == 'COLDOWN' :
+ colState = message.split(None, 2)[1]
+ colState = colState == 'True'
+ if not colState :
+ frames[-1] = frames[-1] + 1
+
+ return frames
+