Enum Class TimeSignature

java.lang.Object
java.lang.Enum<TimeSignature>
org.jjazz.harmony.api.TimeSignature
All Implemented Interfaces:
Serializable, Comparable<TimeSignature>, Constable

public enum TimeSignature extends Enum<TimeSignature>
The time signature of a bar, e.g. C or 4/4, 6/8 etc...
  • Enum Constant Details

  • Field Details

    • SYSTEM_END_BEAT

      public static final float SYSTEM_END_BEAT
      Special position for a beat : ensure it's ALWAYS the last position for any bar
      See Also:
    • SWING_WALTZ_HALF_BAR

      public static final float SWING_WALTZ_HALF_BAR
      The half bar position for a ternary 3/4 bar, 5/3=1.6666...
      See Also:
  • Method Details

    • values

      public static TimeSignature[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TimeSignature valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • parse

      public static TimeSignature parse(String s) throws ParseException
      Get the TimeSignature object represented by a string representation as the one returned by toString(), e.g. "3/4".
      Parameters:
      s - The string representation
      Returns:
      TimeSignature Null if no valid time signature could be constructed.
      Throws:
      ParseException - If syntax error encountered in the string.
    • get

      public static TimeSignature get(int up, int low)
      Get the TimeSignature objects represented by a string representation, e.g. "3/4".
      Parameters:
      up - The uppser value of the TimSignature, e.g. "3" for "3/4"
      low - The lower value of the TimSignature, e.g. "4" for "3/4"
      Returns:
      TimeSignature Null if no valid time signature could be constructed.
    • getUpper

      public int getUpper()
    • getLower

      public int getLower()
    • getNaturalBeat

      public int getNaturalBeat()
      The "natural" beat unit expressed in terms of the lower value. Examples : 4/4=>1, 12/8=>3
      Returns:
    • getHalfBarBeat

      public float getHalfBarBeat(boolean swing)
      Calculate the most appropriate "half of the bar" position in terms of logical beats.

      It is used for instance to know where to put the 2nd chord for a 2 chords bar.

      - For even bars (e.g. 4/4) : half, e.g. beat 2(start at 0)
      - For 3/4 : 1.5 or 5/3
      - Other odd bars : ceil(half), e.g. beat 3 (start at 0) for a 5/4 bar.

      Parameters:
      swing - If true half-bar for a 3/4 waltz is SWING_WALTZ_HALF_BAR=5/3=1.666...
      Returns:
    • getNbNaturalBeats

      public float getNbNaturalBeats()
      How many "logical" beats there is in a bar.

      E.g. 4 for 4/4, 7 for 7/4, 4 for 12/8, 3.5 for 7/8.

      Returns:
    • checkBeat

      public boolean checkBeat(float beat)
      Tell whether it's a valid beat for that time signature.
      Parameters:
      beat -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Enum<TimeSignature>
      Returns:
      e.g "3/4" or "6/8"
    • getNextTimeSignature

      public TimeSignature getNextTimeSignature()
      The next TimeSignature if increased of 1 unit. For instance 4/4 => 5/4.
      Returns:
    • getPreviousTimeSignature

      public TimeSignature getPreviousTimeSignature()
      The previous TimeSignature if decreased by 1 unit.

      For instance 4/4 => 3/4

      Returns: