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 Summary
ConstructorsConstructorDescriptionChordSequence(IntRange barRange) Construct a chord sequence for the specified bar range. -
Method Summary
Modifier and TypeMethodDescriptionclone()intcompareTo(ChordSequence cSeq) Comparison is only based on startBar.booleanfinal IntRangegetChordSymbol(Position pos) Get the CLI_ChordSymbol from this ChordSequence which is active at the specified position.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.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.The relative root ascending intervals of N chord symbols of this chord sequence.final booleaninthashCode()subSequence(IntRange subRange, boolean addInitChordSymbol) A new sub-sequence from this sequence.toString()Methods inherited from class java.util.TreeSet
add, addAll, ceiling, clear, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, spliterator, subSet, subSet, tailSet, tailSetMethods inherited from class java.util.AbstractSet
removeAllMethods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArrayMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
ChordSequence
Construct a chord sequence for the specified bar range.- Parameters:
barRange-
-
-
Method Details
-
clone
- Overrides:
clonein classTreeSet<CLI_ChordSymbol>- Returns:
- A shallow copy (CLI_ChordSymbols are not cloned).
-
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
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<CLI_ChordSymbol>- Specified by:
hashCodein interfaceSet<CLI_ChordSymbol>- Overrides:
hashCodein classAbstractSet<CLI_ChordSymbol>
-
equals
- Specified by:
equalsin interfaceCollection<CLI_ChordSymbol>- Specified by:
equalsin interfaceSet<CLI_ChordSymbol>- Overrides:
equalsin classAbstractSet<CLI_ChordSymbol>
-
getChordSymbol
Get the CLI_ChordSymbol from this ChordSequence which is active at the specified position.- Parameters:
pos-- Returns:
- Can be null
-
subSequence
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
Comparison is only based on startBar.- Specified by:
compareToin interfaceComparable<ChordSequence>- Parameters:
cSeq-- Returns:
-
toString
- Overrides:
toStringin classAbstractCollection<CLI_ChordSymbol>
-