Class SimpleChordSequence
java.lang.Object
java.util.AbstractCollection<CLI_ChordSymbol>
java.util.AbstractSet<CLI_ChordSymbol>
java.util.TreeSet<CLI_ChordSymbol>
org.jjazz.rhythmmusicgeneration.api.ChordSequence
org.jjazz.rhythmmusicgeneration.api.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>
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 Summary
ConstructorsConstructorDescriptionSimpleChordSequence(ChordSequence cSeq, float startBeatPosition, TimeSignature ts) Construct a SimpleChordSequence from a standard ChordSequence.SimpleChordSequence(IntRange barRange, float startBeatPosition, TimeSignature ts) Create an empty SimpleChordSequence. -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanThe beat range of this SimpleChordSequence.getBeatRange(CLI_ChordSymbol cliCs) The beat range of a ChordSymbol of this SimpleChordSequencefloatgetShifted(int barOffset) Get a copy of this SimpleChordSequence shifted by barOffset.floatThe start position in beats of the chord sequence.inthashCode()booleanisMatchingInBarBeatPositions(boolean acceptEmptyBars, FloatRange... inBarBeatRanges) For each bar, check if each chord position is in the corresponding in-bar beat range (excluding the upper bound).static SimpleChordSequenceof(ChordLeadSheet cls, CLI_Section section) Create a SimpleChordSequence starting at beat 0 from a section of ChordLeadSheet.voidsetStartBeatPosition(float startBeatPosition) Set the start position in beats of the chord sequence.subSequence(IntRange subRange, boolean addInitChordSymbol) Overridden to return a SimpleChordSequence with the appropriate startBeatPosition.toPosition(float posInBeats) Convert the specified position in beats into a Position.floatConvert the specified position into an absolute position in natural beats.Methods inherited from class org.jjazz.rhythmmusicgeneration.api.ChordSequence
compareTo, getBarRange, getChordSymbol, getFirstAfter, getLastBefore, getRootAscIntervals, hasChordAtBeginning, removeRedundantStandardChords, toStringMethods inherited from class java.util.TreeSet
add, addAll, addFirst, addLast, 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, toArrayMethods inherited from interface java.util.NavigableSet
removeFirst, removeLast, reversed
-
Constructor Details
-
SimpleChordSequence
Create an empty SimpleChordSequence.- Parameters:
barRange-startBeatPosition- The beat start position of the created SimpleChordSequencets-
-
SimpleChordSequence
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 SimpleChordSequencets-
-
-
Method Details
-
clone
- Overrides:
clonein classChordSequence- Returns:
- A shallow copy (CLI_ChordSymbols are not cloned).
-
deepClone
- Returns:
- A deep copy with each CLI_ChordSymbol cloned.
-
of
Create a SimpleChordSequence starting at beat 0 from a section of ChordLeadSheet.- Parameters:
cls-section-- Returns:
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<CLI_ChordSymbol>- Specified by:
hashCodein interfaceSet<CLI_ChordSymbol>- Overrides:
hashCodein classChordSequence
-
equals
- Specified by:
equalsin interfaceCollection<CLI_ChordSymbol>- Specified by:
equalsin interfaceSet<CLI_ChordSymbol>- Overrides:
equalsin classChordSequence
-
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
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
-
getBeatRange
-
getPositionInBeats
-
getBeatRange
The beat range of a ChordSymbol of this SimpleChordSequence- Parameters:
cliCs- Must belong to this SimpleChordSequence- Returns:
-
toPositionInBeats
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
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
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 ignoredinBarBeatRanges- Can not be empty. Each beat range must have an exclusive upper bound.- Returns:
- See Also:
-
subSequence
Overridden to return a SimpleChordSequence with the appropriate startBeatPosition.- Overrides:
subSequencein classChordSequence- Parameters:
subRange-addInitChordSymbol-- Returns:
-