Class TimeSig

The TimeSig class defines how beats are counted together into bars of music. The TimeSig also defines how much swing should be applied when counting beats.

Hierarchy

  • TimeSig

Constructors

  • Parameters

    • divisions: (number | { count: number; swing: number })[]

      The divisions parameter accepts an array of numbers that define how to group note lengths (as defined by the denominator) together into beats. The sum of divisions equals the value of the top number in the time signature. See the divisions property for more information.

      Individual items within the divisions array can also be swapped out for {count: number, swing: number} objects in order to define swing values for specific beats within a bar. Not all metronomes support this behaviour though.

    • denominator: number

      The denominator represents the bottom number in a time signature.

    • swing: number = 0.5

      The swing parameter defines how long the first half of each beat lasts compared to the second half. The default value for this is 0.5, meaning that there's no swing, and both halfs of the beat are evenly divided. The valid values for this range from 0 to 1, where 1 means that the first half of the beat takes up the entire beat length, and 0 means that the second half of the beat takes up the entire beat length. See the swing property for more information.

    Returns TimeSig

Properties

denominator: number = 4

The denominator represents the bottom number in a time signature.

As far as I can tell, 'denominator' isn't the proper name for this, but there also doesn't seem to be a well agreed upon actual proper name for it, so denominator is what we're going with.

divisions: TimeSigDivision[] = []

The divisions property contains an array of TimeSigDivision objects that define how to group note lengths (as defined by the denominator) together into beats. The sum of division counts equals the value of the top number in the time signature.

The easiest way to explain is with a few examples:

The standard definition of the 4/4 time signature is denominator = 4, and divisions = [1, 1, 1, 1]. Denominator = 4 means that we're counting in quarter notes, and the array of 4 1's means that we count that we have 4 beats per bar, one per quarter note.

We could also define 4/4 as denominator = 4, and divisions = [1.5, 1.5, 1]. This means that there's 3 beats per bar, but the first 2 are equal to a dotted quarter note in length, while the last is a quarter note.

If working in 7/8, then denominator = 8, and we might have divisions = [2, 2, 3]. The 8 for denominator means we're counting in eighth notes. The divisions array means that we have 3 beats per bar, the first 2 are each 2 eighth notes long, and the 3rd is 3 eighth notes long.

swing: number = 0

The swing property defines how long the first half of each beat lasts compared to the second half. The default value for this is 0.5, meaning that there's no swing, and both halfs of the beat are evenly divided. The valid values for this range from 0 to 1, where 1 means that the first half of the beat takes up the entire beat length, and 0 means that the second half of the beat takes up the entire beat length.

A swing value of 2/3 would give you your classic jazz swing, where the first half of the beat lasts twice as long as the second half. A 0.75 value would be a far stronger swing, with the first half of each beat lasting 3 times as long as the second half.

A swing value < 0.5 is far more rare, but works along the same principle as positive values, just in the other direction

Accessors

  • get beatsPerBar(): number
  • Returns the value of divisions.length

    Returns number

  • get quarterNotesPerBar(): number
  • Returns the number of quarter notes that one bar would contain under this time signature.

    Returns number

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

Methods

  • The applySwing method accepts a number representing a position within a bar, and returns the swung value of it. For example, if swing = 0.75, then applySwing(3.5) = 3.75

    Returns

    Parameters

    • position: number

      The position to apply swing to.

    • swing: number = null

      Optional parameter, if not provided, then the TimeSig's swing value will be used.

    Returns number

  • Takes in a bar beat position and returns how many quarter notes into the bar that is

    Parameters

    • beat: number

    Returns number

  • Takes in a quarter note position within a bar and returns the corresponding bar beat position.

    Parameters

    • quarterNote: number

    Returns number

  • A static method to easily define common time.

    TimeSig.commonTime(); is the same as new TimeSig([1, 1, 1, 1], 4);

    Returns

    Parameters

    • swing: number = 0.5

      Optional parameter, 0.5 if not used. Defines the swing to be used in the new TimeSig object.

    Returns TimeSig

Generated using TypeDoc