/// <summary> /// Returns collection of names of the current <see cref="Chord"/>. /// </summary> /// <returns>Collection of names of the current <see cref="Chord"/>.</returns> public IReadOnlyCollection <string> GetNames() { if (_chordNames != null) { return(_chordNames); } var names = ChordsNamesTable.GetChordNames(NotesNames.ToArray()); return(_chordNames = new ReadOnlyCollection <string>(names)); }
internal static ParsingResult TryParse(string input, out Chord chord) { chord = null; if (string.IsNullOrWhiteSpace(input)) return ParsingResult.EmptyInputString; var match = ParsingUtilities.Match(input, Patterns, ignoreCase: false); if (match == null) return ParsingResult.NotMatched; var rootNoteNameGroup = match.Groups[RootNoteNameGroupName]; NoteName rootNoteName; var rootNoteNameParsingResult = NoteNameParser.TryParse(rootNoteNameGroup.Value, out rootNoteName); if (rootNoteNameParsingResult.Status != ParsingStatus.Parsed) return rootNoteNameParsingResult; // NoteName? bassNoteName = null; var bassNoteNameGroup = match.Groups[BassNoteNameGroupName]; if (bassNoteNameGroup.Success) { NoteName actualBassNoteName; var bassNoteNameParsingResult = NoteNameParser.TryParse(bassNoteNameGroup.Value, out actualBassNoteName); if (bassNoteNameParsingResult.Status != ParsingStatus.Parsed) return bassNoteNameParsingResult; bassNoteName = actualBassNoteName; } var notesNames = ChordsNamesTable.GetChordNotesNames(rootNoteName, match.Groups[ChordCharacteristicsGroupName].Value, bassNoteName); if (!notesNames.Any()) return ParsingResult.Error(ChordCharacteristicIsUnknown); chord = new Chord(notesNames); return ParsingResult.Parsed; }