public void CalculateBaseScores() { NotesInLevel2Beats.ComputeScores(true); _noteSum = NOTES_IN_LEVEL_2 * NotesInLevel2Beats.TotalNoteWeight + NOTES_IN_LEVEL_1 * NotesInLevel1Beats.TotalNoteWeight + NOTES_IN_LEVEL_0 * NotesInLevel0Beats.TotalNoteWeight; for (var chord = 0; chord < 24; chord++) { BaseScores[chord] = BaseScore(new Key(chord), chord); } }
private void AddNotesToSegments() { var current = 0; var notes = _midi.EventsOfType <NoteOn>().Where(n => !n.IsPercussion && n.Volume > 0).OrderBy(n => n.AbsoluteRealTime); foreach (var note in notes) { // while the segment does not contain this note while (_segments[current].Beat.AbsoluteRealTime + _segments[current].Beat.Length <= note.AbsoluteRealTime) { current++; } for (var span = current; span < _segments.Length && _segments[span].Beat.AbsoluteRealTime < note.End; span++) { _segments[span].AddNote(note); } } var notesInLevel0 = new NotesInSegment(TimeSpan.Zero, TimeSpan.Zero, _lowestPitch); var notesInLevel1 = new NotesInSegment(TimeSpan.Zero, TimeSpan.Zero, _lowestPitch); foreach (var segment in _segments) { if (segment.Beat.Level == 1 || segment.Beat.Level == 0) { notesInLevel1.ComputeScores(true); notesInLevel1 = new NotesInSegment(segment.Beat.AbsoluteRealTime, TimeSpan.Zero, _lowestPitch); } if (segment.Beat.Level == 0) { notesInLevel0.ComputeScores(false); notesInLevel0 = new NotesInSegment(segment.Beat.AbsoluteRealTime, TimeSpan.Zero, _lowestPitch); } segment.NotesInLevel0Beats = notesInLevel0; segment.NotesInLevel1Beats = notesInLevel1; notesInLevel0.Join(segment.NotesInLevel2Beats); notesInLevel1.Join(segment.NotesInLevel2Beats); } notesInLevel0.ComputeScores(false); notesInLevel1.ComputeScores(true); }