API / MusicTheory
Measure record
A time signature and the events of one voice inside one bar.
Constructors
Measure(TimeSignature timeSignature, IReadOnlyList<RhythmEvent> events, Rational? capacity = null)Creates a measure and checks that its events fit.
timeSignature- The bar's time signature.
events- The events, in order.
capacity- A smaller capacity for a pickup bar; defaults to the full bar.
Throws ArgumentException The capacity is not in (0, bar length], or the events overflow it.
Properties
TimeSignature TimeSignature { get; }The bar's time signature.
IReadOnlyList<RhythmEvent> Events { get; }The events, in order.
Rational Capacity { get; }The whole-note length the bar can hold.
Rational Filled { get; }The summed value of the events, in whole notes.
Rational Remaining { get; }Room left in the bar.
bool IsComplete { get; }True when the bar is exactly full.
IReadOnlyList<Rational> Onsets { get; }The offset of each event from the barline, in whole notes.
Methods
bool Equals(Measure? other)Two measures are equal when they have the same time signature, capacity and events.
int GetHashCode()static IReadOnlyList<Measure> Split(TimeSignature timeSignature, IEnumerable<RhythmEvent> events, Rational? pickup = null)Bars an event stream. An event that crosses a barline is cut there into notatable parts, tied when pitched.
timeSignature- The time signature of every bar.
events- The events, in order.
pickup- The first bar's capacity, for an anacrusis.
Returns The measures; apart from a pickup bar at the start, only the last may be incomplete.
Throws ArgumentException A tuplet event crosses a barline.
Throws ArgumentOutOfRangeException The pickup is not in (0, bar length].