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
ConstructorDescriptionChordSequence
(IntRange barRange) Construct a chord sequence for the specified bar range. -
Method Summary
Modifier and TypeMethodDescriptionclone()
int
compareTo
(ChordSequence cSeq) Comparison is only based on startBar.boolean
final IntRange
getChordSymbol
(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 boolean
int
hashCode()
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, tailSet
Methods inherited from class java.util.AbstractSet
removeAll
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray
Methods 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:
clone
in 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:
hashCode
in interfaceCollection<CLI_ChordSymbol>
- Specified by:
hashCode
in interfaceSet<CLI_ChordSymbol>
- Overrides:
hashCode
in classAbstractSet<CLI_ChordSymbol>
-
equals
- Specified by:
equals
in interfaceCollection<CLI_ChordSymbol>
- Specified by:
equals
in interfaceSet<CLI_ChordSymbol>
- Overrides:
equals
in 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:
compareTo
in interfaceComparable<ChordSequence>
- Parameters:
cSeq
-- Returns:
-
toString
- Overrides:
toString
in classAbstractCollection<CLI_ChordSymbol>
-