Record Class RhythmFeatures

java.lang.Object
java.lang.Record
org.jjazz.rhythm.api.RhythmFeatures
All Implemented Interfaces:
Serializable

public record RhythmFeatures(Genre genre, Division division, TempoRange tempoRange) extends Record implements Serializable
Rhythm general features.
See Also:
  • Constructor Details

    • RhythmFeatures

      public RhythmFeatures()
      Construct an object with all default values.

      Values are set to UNKNOWN, except for TempoRange which is set to TempoRange.ALL_TEMPO.

    • RhythmFeatures

      public RhythmFeatures(Genre genre, Division division, TempoRange tempoRange)
      Creates an instance of a RhythmFeatures record class.
      Parameters:
      genre - the value for the genre record component
      division - the value for the division record component
      tempoRange - the value for the tempoRange record component
  • Method Details

    • getMatchingScore

      public int getMatchingScore(RhythmFeatures rf)
      Compute a matching score between this object and rf.

      Score calculation on each variable:
      - Add 100 points if genre values are defined and match
      - Add 30 points division values are defined and match
      - Add up to 30 points depending how TempoRange values match

      Parameters:
      rf -
      Returns:
      The matching score
    • guessFeatures

      public static RhythmFeatures guessFeatures(String text, int tempo)
      Try to guess features from a text (for example a style name).

      Use defaultValues to set some values in the returned RhythmFeatures object.

      Parameters:
      text - eg "Bossa Nova"
      tempo - Ignored if negative
      Returns:
      If no match, all features will be UNKNOWN and TempoRange.ALL_TEMPO for the TempoRange
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • genre

      public Genre genre()
      Returns the value of the genre record component.
      Returns:
      the value of the genre record component
    • division

      public Division division()
      Returns the value of the division record component.
      Returns:
      the value of the division record component
    • tempoRange

      public TempoRange tempoRange()
      Returns the value of the tempoRange record component.
      Returns:
      the value of the tempoRange record component