Exemplo n.º 1
0
        /// <summary>
        /// Converts an list of notes from its string representation.
        /// </summary>
        /// <param name="s">The <see cref="string"/> (e.g. "C D E F").</param>
        /// <param name="separators">The <see cref="IEnumerable{Char}"/> (Optional, ' ' separator is used by default)</param>\
        /// <returns>The <see cref="NotesList"/>.</returns>
        /// <exception cref="System.FormatException">Throw if the format is incorrect,</exception>
        public static NotesList Parse(
            string s,
            IEnumerable <char> separators = null)
        {
            separators = separators ?? new[] { ' ' };
            var notes  = s.Split(separators.ToArray()).Select(Note.Parse);
            var result = new NotesList(notes);

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets notes from a list of absolute semitones.
        /// </summary>
        /// <param name="semitones">Thje <see cref="AbsoluteSemitoneList"/>.</param>
        /// <returns></returns>
        public NotesList GetNotes(AbsoluteSemitoneList semitones)
        {
            var noteBySemitone = semitones.IsMinor ? _flatNotes : _sharpNotes;
            var notes          = new List <Note>();

            foreach (var semitone in semitones)
            {
                var note = noteBySemitone[semitone];
                notes.Add(note);
            }
            var result = new NotesList(notes);

            return(result);
        }