Пример #1
0
        public static int GetMostCommonNote(Phrase phrase)
        {
            var notes = phrase.Elements
                        .GroupBy(x => NoteHelper.RemoveOctave(x.Note),
                                 x => x.Duration,
                                 (key, values) => new { Note = key, Duration = values.Sum() })
                        .OrderByDescending(x => x.Duration)
                        .ToList();

            return(notes.FirstOrDefault()?.Note ?? 0);
        }
Пример #2
0
 private static bool ScaleContainsNote(Scale scale, int note)
 {
     return(scale.Notes.Contains(NoteHelper.RemoveOctave(note)));
 }