public static void AddNote(NoteScore note) { if (!note.isSharp)//不加入半音阶 { notes.Add(note); } }
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.RoundedRecordedMidiNote) != 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 = CreateSentenceScore(analyzedSentence); ScoreData.SentenceToSentenceScoreMap.Add(analyzedSentence, sentenceScore); } if (IsPerfectHit(beatAnalyzedEvent)) { ScoreData.GetBeatData(analyzedNote).IfNotNull(it => it.PerfectBeats++); sentenceScore.GetBeatData(analyzedNote).IfNotNull(it => it.PerfectBeats++); } else if (IsGoodHit(beatAnalyzedEvent)) { ScoreData.GetBeatData(analyzedNote).IfNotNull(it => it.GoodBeats++); sentenceScore.GetBeatData(analyzedNote).IfNotNull(it => it.GoodBeats++); } }
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++; } }
public NoteScoreEvent(NoteScore noteScore) { NoteScore = noteScore; }