API / MusicTheory
TimeSignature record
Represents a musical time signature (meter).
Constructors
TimeSignature(int numerator, int denominator)Initializes a new instance of the
TimeSignature class.numerator- The numerator (beats per measure).
denominator- The denominator (note value that gets the beat).
Throws ArgumentException Thrown when values are invalid.
TimeSignature(int numerator, int denominator, IReadOnlyList<int> beatGroups)Initializes a time signature with an explicit additive grouping, such as 7/8 as 3+2+2.
numerator- The numerator (beats per measure).
denominator- The denominator (note value that gets the beat).
beatGroups- The length of each beat group in denominator units; they must sum to
numerator.
Throws ArgumentException Thrown when values are invalid, or the groups are empty, not positive, or do not sum to the numerator.
Properties
int Numerator { get; }Gets the numerator (top number) of the time signature.
int Denominator { get; }Gets the denominator (bottom number) of the time signature.
bool IsSimple { get; }Gets whether this is a simple time signature.
bool IsCompound { get; }Gets whether this is a compound time signature.
bool IsComplex { get; }Gets whether this is a complex (odd/irregular) time signature.
static TimeSignature CommonTime { get; }Common time (4/4).
static TimeSignature CutTime { get; }Cut time (2/2).
IReadOnlyList<Rational> BeatGroups { get; }Gets the length of each beat group of the bar in whole notes. Without an explicit grouping the default follows the meter: one group per beat in simple time, threes in compound time, a single group for 3/8 and 3/16, and twos then a final three for odd numerators over 8 or 16 (5/8 is 2+3, 7/8 is 2+2+3), as music21 beams them.
Rational MeasureLength { get; }Gets the duration of one measure in whole notes, exactly.
Methods
bool Equals(TimeSignature? other)int GetBeatsPerMeasure()Gets the number of beats per measure.
Returns The number of beats.
(int, int) GetBeatUnit()Gets the beat unit (what note value gets the beat).
Returns A tuple of (numerator, denominator) representing the beat unit.
string? GetCommonName()Gets the common name for this time signature.
Returns The common name or null if none exists.
int GetHashCode()string GetSymbol()Gets the symbol representation of the time signature.
Returns The symbol (C for common time, ¢ for cut time, or fraction).
string ToString()Returns a string representation of the time signature.
Returns A string in the format "numerator/denominator".