/// <summary> /// Converts a string representation of a list of relative semitones into a relative semitones list. /// </summary> /// <param name="s">The <see cref="string"/> represention of the semitone relative distances.</param> /// <param name="separators">The <see cref="IEnumerable{Char}"/> (Optional, '-' separator is used by default)</param>\ /// <returns>The <see cref="RelativeSemitoneList"/>.</returns> /// <exception cref="System.FormatException">Throw if the format is incorrect,</exception> public static RelativeSemitoneList Parse( string s, IEnumerable <char> separators = null) { separators = separators ?? new[] { '-' }; var semitones = s.Split(separators.ToArray()).Select(ParseSelector); var result = new RelativeSemitoneList(semitones); return(result); }
/// <summary> /// Gets the <see cref="RelativeSemitoneList" />. /// </summary> /// <returns>The <see cref="RelativeSemitoneList"/>.</returns> public RelativeSemitoneList ToRelative() { var relativeSemitones = new List <Semitone>(); for (var i = 1; i < Count; i++) { var relativeSemitone = AbsoluteSemitones[i] - AbsoluteSemitones[i - 1]; relativeSemitones.Add(relativeSemitone); } var result = new RelativeSemitoneList(relativeSemitones); return(result); }