Table of Contents

Struct TimeSignature

Namespace
Celeritas.Core
Assembly
Celeritas.dll

Time signature / meter.

public readonly struct TimeSignature : IEquatable<TimeSignature>
Implements
Inherited Members

Remarks

Both parts must be positive. BeatUnit is a denominator: at zero, BeatDuration and MeasureDuration are undefined, and the meter still prints and compares as if it were a real one ("4/0"). Note this only covers explicit construction — default(TimeSignature) bypasses these initializers and is 0/0, as it is for every C# struct. Whether a denominator is writable to a MIDI file is a stricter question, and belongs to the export path rather than here: MIDI stores log2 of the denominator, so it can only encode powers of two, while a meter like 4/3 is representable in this type and meaningful on paper.

Constructors

TimeSignature(int, int)

Time signature / meter.

public TimeSignature(int beatsPerMeasure, int beatUnit)

Parameters

beatsPerMeasure int

Beats per measure (numerator); must be positive.

beatUnit int

Beat unit note value (denominator: 4 = quarter, 8 = eighth); must be positive.

Remarks

Both parts must be positive. BeatUnit is a denominator: at zero, BeatDuration and MeasureDuration are undefined, and the meter still prints and compares as if it were a real one ("4/0"). Note this only covers explicit construction — default(TimeSignature) bypasses these initializers and is 0/0, as it is for every C# struct. Whether a denominator is writable to a MIDI file is a stricter question, and belongs to the export path rather than here: MIDI stores log2 of the denominator, so it can only encode powers of two, while a meter like 4/3 is representable in this type and meaningful on paper.

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Properties

BeatDuration

Duration of one beat as a Rational.

public Rational BeatDuration { get; }

Property Value

Rational

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

BeatUnit

Beat unit as note value (4 = quarter, 8 = eighth, etc).

public int BeatUnit { get; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

BeatsPerMeasure

Beats per measure (numerator).

public int BeatsPerMeasure { get; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Common

Common time, 4/4.

public static TimeSignature Common { get; }

Property Value

TimeSignature

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Compound12

Compound quadruple, 12/8.

public static TimeSignature Compound12 { get; }

Property Value

TimeSignature

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Compound6

Compound duple, 6/8.

public static TimeSignature Compound6 { get; }

Property Value

TimeSignature

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Compound9

Compound triple, 9/8.

public static TimeSignature Compound9 { get; }

Property Value

TimeSignature

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

CutTime

Cut time, 2/2.

public static TimeSignature CutTime { get; }

Property Value

TimeSignature

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

IsCompound

Is this a compound meter (beats subdivide into 3)?

public bool IsCompound { get; }

Property Value

bool

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

IsSimple

Is this a simple meter (beats subdivide into 2)?

public bool IsSimple { get; }

Property Value

bool

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

MeasureDuration

Duration of one measure.

public Rational MeasureDuration { get; }

Property Value

Rational

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

StrongBeats

Number of strong beats per measure.

public int StrongBeats { get; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Waltz

Waltz meter, 3/4.

public static TimeSignature Waltz { get; }

Property Value

TimeSignature

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Methods

Equals(TimeSignature)

Indicates whether this meter equals other (same numerator and denominator).

public bool Equals(TimeSignature other)

Parameters

other TimeSignature

Returns

bool

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Equals(object?)

Indicates whether obj is an equal TimeSignature.

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

GetHashCode()

Returns a hash code combining numerator and denominator.

public override int GetHashCode()

Returns

int

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

ToString()

Returns the meter as "beats/unit" (e.g. "4/4").

public override string ToString()

Returns

string

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

Operators

operator ==(TimeSignature, TimeSignature)

Indicates whether two time signatures are equal.

public static bool operator ==(TimeSignature left, TimeSignature right)

Parameters

left TimeSignature
right TimeSignature

Returns

bool

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.

operator !=(TimeSignature, TimeSignature)

Indicates whether two time signatures differ.

public static bool operator !=(TimeSignature left, TimeSignature right)

Parameters

left TimeSignature
right TimeSignature

Returns

bool

Exceptions

ArgumentOutOfRangeException

beatsPerMeasure or beatUnit is not positive.