public MusicNote(Note note, int octave = 4, RhythmicUnit rhythmicUnit = RhythmicUnit.Whole, int dotCount = 0) { _note = note; _octave = octave; _rhythmicUnit = rhythmicUnit; _dotCount = dotCount; }
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()); }
/// <summary> /// Creates a Note or a Rest from RhythmicUnit. /// </summary> /// <param name="unit"></param> /// <returns></returns> public static NoteOrRest FromRhythmicUnit(RhythmicUnit unit) { return(unit.IsRest ? (NoteOrRest) new Rest(unit.Duration) : new Note(unit.Duration)); }
private static double CalculateDurationInBeats(RhythmicUnit rhythmicUnit, int dotCount) { return((2 * (1 / (double)rhythmicUnit)) - ((1 / (double)rhythmicUnit) / System.Math.Pow(2, dotCount))); }