Class ChordSequence

All Implemented Interfaces:
Serializable, Cloneable, Comparable<ChordSequence>, Iterable<CLI_ChordSymbol>, Collection<CLI_ChordSymbol>, NavigableSet<CLI_ChordSymbol>, Set<CLI_ChordSymbol>, SortedSet<CLI_ChordSymbol>
Direct Known Subclasses:
SimpleChordSequence, SongChordSequence

public class ChordSequence extends TreeSet<CLI_ChordSymbol> implements Comparable<ChordSequence>, Cloneable
A convenience class to analyze and manipulate a suite of chord symbols extracted from a ChordLeadSheet, possibly with different TimeSignatures.

See Also:
  • Constructor Details

    • ChordSequence

      public ChordSequence(IntRange barRange)
      Construct a chord sequence for the specified bar range.
      Parameters:
      barRange -
  • Method Details

    • clone

      public ChordSequence clone()
      Overrides:
      clone in class TreeSet<CLI_ChordSymbol>
      Returns:
      A shallow copy (CLI_ChordSymbols are not cloned).
    • getRootAscIntervals

      public List<Integer> getRootAscIntervals()
      The relative root ascending intervals of N chord symbols of this chord sequence.

      Example: if chords=[Em,D7,F/A] then returned list is [10;3].

      Returns:
      A list with N-1 values in the range [0;11].
    • getBarRange

      public final IntRange getBarRange()
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<CLI_ChordSymbol>
      Specified by:
      hashCode in interface Set<CLI_ChordSymbol>
      Overrides:
      hashCode in class AbstractSet<CLI_ChordSymbol>
    • 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 AbstractSet<CLI_ChordSymbol>
    • getChordSymbol

      public CLI_ChordSymbol getChordSymbol(Position pos)
      Get the CLI_ChordSymbol from this ChordSequence which is active at the specified position.
      Parameters:
      pos -
      Returns:
      Can be null
    • subSequence

      public ChordSequence subSequence(IntRange subRange, boolean addInitChordSymbol)
      A new sub-sequence from this sequence.
      Parameters:
      subRange - The range of the sub-sequence.
      addInitChordSymbol - If true, try to add an init chordsymbol if the resulting subsequence does not have one: reuse the last chord symbol before subRange.from if any
      Returns:
    • getFirstAfter

      public CLI_ChordSymbol getFirstAfter(Position posFrom, boolean inclusive, Predicate<CLI_ChordSymbol> tester)
      Get the first matching chord symbol whose position is after (or equal, if inclusive is true) posFrom.
      Parameters:
      posFrom -
      inclusive -
      tester -
      Returns:
    • getLastBefore

      public CLI_ChordSymbol getLastBefore(Position posTo, boolean inclusive, Predicate<CLI_ChordSymbol> tester)
      Get the last matching chord symbol whose position is before (or equal, if inclusive is true) posTo.
      Parameters:
      posTo -
      inclusive -
      tester -
      Returns:
    • hasChordAtBeginning

      public final boolean hasChordAtBeginning()
      Returns:
      True if there is a chord on bar=startBar, beat=0.
    • compareTo

      public int compareTo(ChordSequence cSeq)
      Comparison is only based on startBar.
      Specified by:
      compareTo in interface Comparable<ChordSequence>
      Parameters:
      cSeq -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection<CLI_ChordSymbol>