Class RP_SYS_CustomPhraseValue

java.lang.Object
org.jjazz.rhythm.api.rhythmparameters.RP_SYS_CustomPhraseValue
All Implemented Interfaces:
PropertyChangeListener, EventListener, MutableRpValue

public class RP_SYS_CustomPhraseValue extends Object implements MutableRpValue, PropertyChangeListener
A RhythmParameter to replace one or more RhythmVoice phrases by custom phrases.

All custom phrases start at beat 0. This is a mutable class which fires a ChangeEvent when a phrase is added/removed, or when an added phrase content is modified.

  • Constructor Details

    • RP_SYS_CustomPhraseValue

      public RP_SYS_CustomPhraseValue(Rhythm r)
    • RP_SYS_CustomPhraseValue

      public RP_SYS_CustomPhraseValue(RP_SYS_CustomPhraseValue value)
      Create a deep copy of the specified value.
      Parameters:
      value -
  • Method Details

    • set

      public void set(RP_SYS_CustomPhraseValue value)
      Set the customized phrases from the specified value (phrases are directly reused, not cloned).
      Parameters:
      value - Must share the same rhythm
    • getRhythmParameter

      public RP_SYS_CustomPhrase getRhythmParameter()
    • setCustomizedPhrase

      public void setCustomizedPhrase(RhythmVoice rv, Phrase p)
      Set the customized phrase for the specified RhythmVoice.
      Parameters:
      rv - Must belong to the rhythm
      p - Can't be null. Phrase starts at beat 0.
    • removeCustomizedPhrase

      public Phrase removeCustomizedPhrase(RhythmVoice rv)
      Remove the customized phrase for the specified RhythmVoice.
      Parameters:
      rv -
      Returns:
      The removed phrase, or null
    • getRhythm

      public Rhythm getRhythm()
      Get the Rhythm which uses this RhythmParameter instance.
      Returns:
    • getCustomizedPhrase

      public Phrase getCustomizedPhrase(RhythmVoice rv)
      Get the custom phrase for the specified RhythmVoice.
      Parameters:
      rv -
      Returns:
      Null if no customized phrase for rv. Phrase starts at beat 0.
    • getCustomizedRhythmVoices

      public Set<RhythmVoice> getCustomizedRhythmVoices()
      Get the RhythmVoices for which there is a custom phrase.
      Returns:
      Empty set if no custom phrase.
    • toDescriptionString

      public String toDescriptionString()
      The list of RhythmVoice names sorted by preferred channel.
      Returns:
    • saveAsString

      public static String saveAsString(RP_SYS_CustomPhraseValue v)
      Save the specified object state as a string.

      Example "Bass%[PhraseString]&Piano%[PhraseString]" means 2 RhythmVoices/Phrases. "" means no custom phrase.

      Parameters:
      v -
      Returns:
      See Also:
      • loadFromString()
    • loadFromString

      public static RP_SYS_CustomPhraseValue loadFromString(Rhythm r, String s) throws ParseException
      Create an object from a string.
      Parameters:
      r -
      s -
      Returns:
      Throws:
      ParseException - If s is invalid
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addChangeListener

      public void addChangeListener(ChangeListener listener)
      Description copied from interface: MutableRpValue
      Be notified of value mutations (state changes).

      Note that listeners won't be notified if a new RhythmParameter value instance is replaced by another one. Use SongStructure RpChangedEvent to get all types of RP value changes.

      Specified by:
      addChangeListener in interface MutableRpValue
    • removeChangeListener

      public void removeChangeListener(ChangeListener listener)
      Specified by:
      removeChangeListener in interface MutableRpValue
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener