Interface RhythmParameter<E>

Type Parameters:
E - The type of value of this RhythmParameter. E.toString() should return a short (max ~30 characters) user-readable string. Prefer an immutable class, but if value class is mutable, it must implement the MutableRpValue interface.
All Known Implementing Classes:
RP_Integer, RP_State, RP_STD_Feel, RP_STD_Fill, RP_STD_Intensity, RP_STD_Variation, RP_StringSet, RP_SYS_CustomPhrase, RP_SYS_DrumsTransform, RP_SYS_Marker, RP_SYS_Mute, RP_SYS_TempoFactor

public interface RhythmParameter<E>
Define a parameter that influences the way a Rhythm generates music.

A RhythmParameter implementation can have additional capabilities by implementing additional interfaces, such as RpEnumerable, RpCustomEditorProvider, RpViewerRendererFactory, etc.

  • Method Details

    • findFirstCompatibleRp

      static RhythmParameter<?> findFirstCompatibleRp(List<? extends RhythmParameter<?>> rps, RhythmParameter<?> rp)
      Return the first RhythmParameter in rps compatible with rp.
      Parameters:
      rps -
      rp -
      Returns:
      Null if no compatible RhythmParameter found
    • getId

      String getId()
      Returns:
      A unique identifier. Usually the english name.
    • getDisplayName

      String getDisplayName()
      Returns:
      The localized display name of the rhythm parameter.
    • getDescription

      String getDescription()
      The description of this rhythm parameter.
      Returns:
    • getDisplayValue

      String getDisplayValue(E value)
      Get a short String representation of the value.
      Parameters:
      value -
      Returns:
      Can be an empty String.
    • getValueDescription

      String getValueDescription(E value)
      Provide an optional description or help text associated to the specified value.
      Parameters:
      value -
      Returns:
      Can be null.
    • getDefaultValue

      E getDefaultValue()
      Returns:
      Object The default value.
    • saveAsString

      String saveAsString(E value)
      Try to convert the specified RhythmParameter value to a string.
      Parameters:
      value -
      Returns:
      Can be null if value is invalid or RhytmParameter does not have this capability.
      See Also:
    • loadFromString

      E loadFromString(String s)
      Try to convert the specified string to a RhythmParameter value.
      Parameters:
      s - A string produced by valueToString().
      Returns:
      Can be null if conversion failed.
      See Also:
    • isValidValue

      boolean isValidValue(E value)
      Parameters:
      value -
      Returns:
      True is value is valid.
    • cloneValue

      default E cloneValue(E value)
      Clone the specified value.

      The default implementation just return value, which is fine is E is an immutable class. If E is mutable, this method must be overridden.

      Parameters:
      value -
      Returns:
      A copy of the specified value.
    • isCompatibleWith

      boolean isCompatibleWith(RhythmParameter<?> rp)
      Indicate if rp is compatible with this RhythmParameter.

      NOTE: if rp1 is compatible with rp2, then rp2 must be compatible with rp1 as well.

      Parameters:
      rp -
      Returns:
      True if a rp's value can be converted to a value for this RhythmParameter.
    • convertValue

      <T> E convertValue(RhythmParameter<T> rp, T rpValue)
      Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.
      Type Parameters:
      T - A RhythmParameter value
      Parameters:
      rp - A compatible RhythmParameter
      rpValue - The value to convert
      Returns:
      The rpValue converted for this RhythmParameter. Can't be null.
      Throws:
      IllegalArgumentException - If rp is not a compatible with this RhythmParameter.
    • isPrimary

      default boolean isPrimary()
      Indicate if this RhythmParameter is a primary parameter for its rhythm.

      This information is made available mainly for the user interface, e.g. to select which RhythmParameters to show first.

      Default implementation returns true.

      Returns: