static IEnumerable<ChordNameMeta> EC_CalculateChordSymbols(ECToneNameEnum[] tones, bool firstOnly) { var ret = new List<ChordNameMeta>(); if (tones.IsEmpty()) { return ret; } var distinctTones = tones.Distinct().OrderBy(x => x.ToInt()).ToList(); if (distinctTones.Count() == 1) { ret.Add(new ChordNameMeta() { ToneName = ChordNameFinder.GetToneName(distinctTones.First()) }); return ret; } else if (distinctTones.Count() == 2) { distinctTones.Add(distinctTones.First()); } var n = distinctTones.Count(); if (n < 3 || n > 5) { return ret; } var ecNotes = distinctTones.Select(x => EC_NotesDir[((int)x)]).ToArray(); for (var i = 0; i < EC_Chords.Length; i++) { for (var j = 0; j < 12; j++) { var x = 0; if (n == EC_Chords[i].Notes.Length) { for (var k = 0; k < EC_Chords[i].Notes.Length; k++) { var tone = ((EC_Chords[i].Notes[k] + j - 1) % 12); for (var l = 0; l < n; l++) { if (tone == (int)tones[l]) { x++; } } } } if (x == EC_Chords[i].Notes.Length) { var chord = EC_ShowChord(EC_NotesDir[j] + EC_Chords[i].Description); if (chord != null) { ret.Add(chord); if (firstOnly) break; } } } } return ret; }
static ToneNameEnum GetToneName(ECToneNameEnum tone) { return (ToneNameEnum)((((int)tone) + 8) % 12); }
static ToneNameEnum GetToneName(ECToneNameEnum tone) { return((ToneNameEnum)((((int)tone) + 8) % 12)); }