Package org.jjazz.harmony.api
Enum Class TimeSignature
- All Implemented Interfaces:
Serializable
,Comparable<TimeSignature>
,Constable
The time signature of a bar, e.g. C or 4/4, 6/8 etc...
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescription -
Field Summary
Modifier and TypeFieldDescriptionstatic final float
The half bar position for a ternary 3/4 bar, 5/3=1.6666...static final float
Special position for a beat : ensure it's ALWAYS the last position for any bar -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkBeat
(float beat) Tell whether it's a valid beat for that time signature.static TimeSignature
get
(int up, int low) Get the TimeSignature objects represented by a string representation, e.g. "3/4".float
getHalfBarBeat
(boolean swing) Calculate the most appropriate "half of the bar" position in terms of logical beats.int
getLower()
int
The "natural" beat unit expressed in terms of the lower value.float
How many "logical" beats there is in a bar.The next TimeSignature if increased of 1 unit.The previous TimeSignature if decreased by 1 unit.int
getUpper()
static TimeSignature
Get the TimeSignature object represented by a string representation as the one returned by toString(), e.g. "3/4".toString()
static TimeSignature
Returns the enum constant of this class with the specified name.static TimeSignature[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Enum Constant Details
-
TWO_FOUR
-
THREE_FOUR
-
FOUR_FOUR
-
FIVE_FOUR
-
SIX_FOUR
-
SEVEN_FOUR
-
SIX_EIGHT
-
TWELVE_EIGHT
-
-
Field Details
-
SYSTEM_END_BEAT
public static final float SYSTEM_END_BEATSpecial 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_BARThe half bar position for a ternary 3/4 bar, 5/3=1.6666...- See Also:
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
parse
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
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
- Overrides:
toString
in classEnum<TimeSignature>
- Returns:
- e.g "3/4" or "6/8"
-
getNextTimeSignature
The next TimeSignature if increased of 1 unit. For instance 4/4 => 5/4.- Returns:
-
getPreviousTimeSignature
The previous TimeSignature if decreased by 1 unit.For instance 4/4 => 3/4
- Returns:
-