public static IEnumerable <Note> AddRhythm(this IEnumerable <Pitch> pitches, string durations) { var units = new Queue <RhythmicUnit>(RhythmicUnit.Parse(durations, " ")); if (pitches.Count() != units.Count) { throw new Exception("Durations must have the same count as pitches."); } return(pitches.Select(p => new Note(p, units.Dequeue().Duration)).ToArray()); }
public static IEnumerable <Note> AddRhythm(this IEnumerable <Pitch> pitches, params int[] durations) { if (pitches.Count() != durations.Length) { throw new Exception("Durations must have the same count as pitches."); } var units = new Queue <RhythmicUnit>(RhythmicUnit.Parse(durations)); return(pitches.Select(p => new Note(p, units.Dequeue().Duration)).ToArray()); }