Class SizedPhrase

java.lang.Object
org.jjazz.phrase.api.Phrase
org.jjazz.phrase.api.SizedPhrase
All Implemented Interfaces:
Serializable, Iterable<NoteEvent>, Collection<NoteEvent>, NavigableSet<NoteEvent>, Set<NoteEvent>, SortedSet<NoteEvent>

public class SizedPhrase extends Phrase
A Phrase which has a size (beat range) and a time signature.

Added NoteEvents must be fully contained in the beat range, otherwise an IllegalArgumentException is thrown.

See Also:
  • Constructor Details

    • SizedPhrase

      public SizedPhrase(int channel, FloatRange beatRange, TimeSignature ts, boolean isDrums)
      Create a sized phrase with no notes.
      Parameters:
      channel -
      beatRange -
      ts -
      isDrums -
    • SizedPhrase

      public SizedPhrase(SizedPhrase sp)
  • Method Details

    • canAddNote

      public boolean canAddNote(NoteEvent ne)
      Overridden to check NoteEvent is within the beat range (including the upper bound).

      Parameters:
      ne -
      Returns:
    • clone

      public SizedPhrase clone()
      Description copied from class: Phrase
      A deep clone: returned phrase contains clones of the original NoteEvents.
      Overrides:
      clone in class Phrase
      Returns:
    • getBeatRange

      public FloatRange getBeatRange()
      Get the beat range corresponding to this phrase.

      Overrides Phrase.getBeatRange() because the beat range is fixed for a SizedPhrase.

      Overrides:
      getBeatRange in class Phrase
      Returns:
    • getTimeSignature

      public TimeSignature getTimeSignature()
      Returns:
      The timeSignature used in this phrase.
    • getSizeInBars

      public int getSizeInBars()
    • shiftAllEvents

      public void shiftAllEvents(float shiftInBeats)
      Shift the associated BeatRange and all events.
      Overrides:
      shiftAllEvents in class Phrase
      Parameters:
      shiftInBeats -
    • saveAsString

      public static String saveAsString(SizedPhrase sp)
      Save the specified SizedPhrase as a string.

      Example "[8|12.0|16.0|4/4|NoteEventStr0|NoteEventStr1]" means a melodic Phrase for channel 8, beatRange=12-16, in 4/4, with 2 NoteEvents.
      Example "[drums_9|12.0|16.0|4/4|NoteEventStr0|NoteEventStr1]" means a drums Phrase for channel 9.

      Parameters:
      sp -
      Returns:
      See Also:
    • loadAsString

      public static SizedPhrase loadAsString(String s) throws ParseException
      Create a SizedPhrase from the specified string.

      Parameters:
      s -
      Returns:
      Throws:
      ParseException - If s is not a valid string.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Phrase