Package org.jjazz.song.api
Class BeatIterator
java.lang.Object
org.jjazz.song.api.BeatIterator
A beat Iterator within a Song.
-
Constructor Summary
ConstructorDescriptionBeatIterator
(Song song) Create a beat iterator for the specified song.BeatIterator
(Song song, Position pos) Construct an iterator for the specified song, starting at specified position.BeatIterator
(Song song, IntRange barRange) Construct an iterator for the specified bar range within a song.BeatIterator
(Song song, IntRange barRange, Position pos) Construct an iterator for the specified bar range within a song, starting at pos. -
Method Summary
Modifier and TypeMethodDescriptiongetSong()
The time signature corresponding to the current position.boolean
hasNext()
True if next integer beat position is not in the song.boolean
True if there is a next bar in the song.boolean
hasNextHalfBar
(boolean swing) True if there is a next half bar in the song.next()
Advance the song position to the next integer beat.nextBar()
Advance the song position to the next bar (with beat 0).nextHalfBar
(boolean swing) Advance the song position to the next half bar (beat=0 or half-bar).peek()
Get the next position without advancing the iterator.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
BeatIterator
Create a beat iterator for the specified song.NOTE: modifying the song while using this iterator will produce unknown results.
- Parameters:
song
-
-
BeatIterator
Construct an iterator for the specified song, starting at specified position.NOTE: modifying the song while using this iterator will produce unknown results.
- Parameters:
song
-pos
- Must be a position within the song.
-
BeatIterator
Construct an iterator for the specified bar range within a song.NOTE: modifying the song while using this iterator will produce unknown results.
- Parameters:
song
-barRange
- A bar range within the song.
-
BeatIterator
Construct an iterator for the specified bar range within a song, starting at pos.NOTE: modifying the song while using this iterator will produce unknown results.
- Parameters:
song
-pos
- must be within the bar range.barRange
- A bar range within the song.
-
-
Method Details
-
getSong
-
peek
Get the next position without advancing the iterator.NOTE: Position might be out of the song.
- Returns:
-
hasNext
public boolean hasNext()True if next integer beat position is not in the song. -
next
Advance the song position to the next integer beat.- Specified by:
next
in interfaceIterator<Position>
- Returns:
- A position with an integer beat (e.g.bar=2 beat=3.0)
- Throws:
NoSuchElementException
-
hasNextBar
public boolean hasNextBar()True if there is a next bar in the song.- Returns:
-
nextBar
Advance the song position to the next bar (with beat 0).- Returns:
- A position with beat=0
- Throws:
NoSuchElementException
-
hasNextHalfBar
public boolean hasNextHalfBar(boolean swing) True if there is a next half bar in the song.- Parameters:
swing
-- Returns:
-
nextHalfBar
Advance the song position to the next half bar (beat=0 or half-bar).- Parameters:
swing
-- Returns:
- Throws:
NoSuchElementException
-
getTimeSignature
The time signature corresponding to the current position.- Returns:
- Can be null if outside the song
-