private SentenceScore CreateSentenceScore(Sentence sentence) { SentenceScore sentenceScore = new SentenceScore(sentence); sentenceScore.TotalScoreSoFar = TotalScore; return(sentenceScore); }
private SentenceScore CreateSentenceScore(Sentence sentence, int totalScoreSoFar) { SentenceScore sentenceScore = new SentenceScore(sentence); sentenceScore.TotalScoreSoFar = totalScoreSoFar; return(sentenceScore); }
private void OnBeatAnalyzed(PlayerPitchTracker.BeatAnalyzedEvent beatAnalyzedEvent) { // Check if pitch was detected where a note is expected in the song if (beatAnalyzedEvent.PitchEvent == null || beatAnalyzedEvent.NoteAtBeat == null) { return; } if (beatAnalyzedEvent.Beat < NextBeatToScore) { return; } Note analyzedNote = beatAnalyzedEvent.NoteAtBeat; // Check if note was hit if (MidiUtils.GetRelativePitch(beatAnalyzedEvent.RoundedMidiNote) != MidiUtils.GetRelativePitch(analyzedNote.MidiNote)) { return; } // The beat was sung correctly. if (!ScoreData.NoteToNoteScoreMap.TryGetValue(analyzedNote, out NoteScore noteScore)) { noteScore = new NoteScore(analyzedNote); ScoreData.NoteToNoteScoreMap.Add(analyzedNote, noteScore); } noteScore.CorrectlySungBeats++; Sentence analyzedSentence = beatAnalyzedEvent.NoteAtBeat.Sentence; if (!ScoreData.SentenceToSentenceScoreMap.TryGetValue(analyzedSentence, out SentenceScore sentenceScore)) { sentenceScore = new SentenceScore(analyzedSentence); ScoreData.SentenceToSentenceScoreMap.Add(analyzedSentence, sentenceScore); } if (analyzedNote.IsNormal) { ScoreData.CorrectNormalNoteLengthTotal++; sentenceScore.CorrectlySungNormalBeats++; } else if (analyzedNote.IsGolden) { ScoreData.CorrectGoldenNoteLengthTotal++; sentenceScore.CorrectlySungGoldenBeats++; } }
private void OnSentenceAnalyzed(PlayerPitchTracker.SentenceAnalyzedEvent sentenceAnalyzedEvent) { if (sentenceAnalyzedEvent.Sentence.MaxBeat < NextBeatToScore) { return; } Sentence analyzedSentence = sentenceAnalyzedEvent.Sentence; int totalScorableNoteLength = analyzedSentence.Notes .Where(note => note.IsNormal || note.IsGolden) .Select(note => note.Length) .Sum(); if (totalScorableNoteLength <= 0) { return; } SentenceRating sentenceRating; if (ScoreData.SentenceToSentenceScoreMap.TryGetValue(analyzedSentence, out SentenceScore sentenceScore)) { int correctlySungNoteLength = sentenceScore.CorrectlySungNormalBeats + sentenceScore.CorrectlySungGoldenBeats; double correctNotesPercentage = (double)correctlySungNoteLength / totalScorableNoteLength; // Score for a perfect sentence if (correctNotesPercentage >= SentenceRating.Perfect.PercentageThreshold) { perfectSentenceCount++; } sentenceRating = GetSentenceRating(correctNotesPercentage); } else { sentenceScore = new SentenceScore(analyzedSentence); sentenceRating = GetSentenceRating(0); } sentenceScoreEventStream.OnNext(new SentenceScoreEvent(sentenceScore, sentenceRating)); }
public SentenceScoreEvent(SentenceScore sentenceScore, SentenceRating sentenceRating) { SentenceScore = sentenceScore; SentenceRating = sentenceRating; }