Class SimpleChordSequence

All Implemented Interfaces:
Serializable, Cloneable, Comparable<ChordSequence>, Iterable<CLI_ChordSymbol>, Collection<CLI_ChordSymbol>, NavigableSet<CLI_ChordSymbol>, SequencedCollection<CLI_ChordSymbol>, SequencedSet<CLI_ChordSymbol>, Set<CLI_ChordSymbol>, SortedSet<CLI_ChordSymbol>

public class SimpleChordSequence extends ChordSequence
A ChordSequence which has only one TimeSignature and a start position in beats.

User is responsible to ensure CLI_ChordSymbols are added in the right position order, in the startBar/nbBars range, and are compatible with the TimeSignature.

See Also:
  • Constructor Details

    • SimpleChordSequence

      public SimpleChordSequence(IntRange barRange, float startBeatPosition, TimeSignature ts)
      Create an empty SimpleChordSequence.
      Parameters:
      barRange -
      startBeatPosition - The beat start position of the created SimpleChordSequence
      ts -
    • SimpleChordSequence

      public SimpleChordSequence(ChordSequence cSeq, float startBeatPosition, TimeSignature ts)
      Construct a SimpleChordSequence from a standard ChordSequence.
      Parameters:
      cSeq - All ChordSymbols are checked to be compatible with the specified TimeSignature.
      startBeatPosition - The beat start position of the created SimpleChordSequence
      ts -
  • Method Details

    • clone

      public SimpleChordSequence clone()
      Overrides:
      clone in class ChordSequence
      Returns:
      A shallow copy (CLI_ChordSymbols are not cloned).
    • deepClone

      public SimpleChordSequence deepClone()
      Returns:
      A deep copy with each CLI_ChordSymbol cloned.
    • of

      public static SimpleChordSequence of(ChordLeadSheet cls, CLI_Section section)
      Create a SimpleChordSequence starting at beat 0 from a section of ChordLeadSheet.
      Parameters:
      cls -
      section -
      Returns:
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<CLI_ChordSymbol>
      Specified by:
      hashCode in interface Set<CLI_ChordSymbol>
      Overrides:
      hashCode in class ChordSequence
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<CLI_ChordSymbol>
      Specified by:
      equals in interface Set<CLI_ChordSymbol>
      Overrides:
      equals in class ChordSequence
    • getStartBeatPosition

      public float getStartBeatPosition()
      The start position in beats of the chord sequence.
      Returns:
      A value >= 0
    • setStartBeatPosition

      public void setStartBeatPosition(float startBeatPosition)
      Set the start position in beats of the chord sequence.
      Parameters:
      startBeatPosition - Must be >= 0
    • getShifted

      public SimpleChordSequence getShifted(int barOffset)
      Get a copy of this SimpleChordSequence shifted by barOffset.
      Parameters:
      barOffset - Must be >= -getBarRange().from
      Returns:
      An instance with a start beat position set to 0
    • getTimeSignature

      public TimeSignature getTimeSignature()
    • getBeatRange

      public FloatRange getBeatRange()
      The beat range of this SimpleChordSequence.
      Returns:
      See Also:
    • getPositionInBeats

      public float getPositionInBeats(CLI_ChordSymbol cliCs)
    • getBeatRange

      public FloatRange getBeatRange(CLI_ChordSymbol cliCs)
      The beat range of a ChordSymbol of this SimpleChordSequence
      Parameters:
      cliCs - Must belong to this SimpleChordSequence
      Returns:
    • toPositionInBeats

      public float toPositionInBeats(Position pos)
      Convert the specified position into an absolute position in natural beats.
      Parameters:
      pos -
      Returns:
      If pos is beyond the end of this ChordSequence, then returned value will also be beyond this ChordSequence.
      See Also:
    • toPosition

      public Position toPosition(float posInBeats)
      Convert the specified position in beats into a Position.
      Parameters:
      posInBeats -
      Returns:
      If posInBeats is beyond the end of this ChordSequence, then returned value will also be beyond this ChordSequence.
      Throws:
      IllegalArgumentException - If posInBeats is < than getStartBeatPosition()
    • isMatchingInBarBeatPositions

      public boolean isMatchingInBarBeatPositions(boolean acceptEmptyBars, FloatRange... inBarBeatRanges)
      For each bar, check if each chord position is in the corresponding in-bar beat range (excluding the upper bound).

      For example in 4/4, in order to check there are 2 chords at start and middle of each bar, use:
      isMatchingInBarBeatPositions(true, new FloatRange(0, 0.01f), new FloatRange(2f, 2.01f))

      Parameters:
      acceptEmptyBars - If true, bars with no chords are ignored
      inBarBeatRanges - Can not be empty. Each beat range must have an exclusive upper bound.
      Returns:
      See Also:
    • subSequence

      public SimpleChordSequence subSequence(IntRange subRange, boolean addInitChordSymbol)
      Overridden to return a SimpleChordSequence with the appropriate startBeatPosition.
      Overrides:
      subSequence in class ChordSequence
      Parameters:
      subRange -
      addInitChordSymbol -
      Returns: