Class BeatIterator

java.lang.Object
org.jjazz.song.api.BeatIterator
All Implemented Interfaces:
Iterator<Position>

public class BeatIterator extends Object implements Iterator<Position>
A beat Iterator within a Song.

  • Constructor Details

    • BeatIterator

      public BeatIterator(Song song)
      Create a beat iterator for the specified song.

      NOTE: modifying the song while using this iterator will produce unknown results.

      Parameters:
      song -
    • BeatIterator

      public BeatIterator(Song song, Position pos)
      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

      public BeatIterator(Song song, IntRange barRange)
      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

      public BeatIterator(Song song, IntRange barRange, Position pos)
      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

      public Song getSong()
    • peek

      public Position 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.
      Specified by:
      hasNext in interface Iterator<Position>
      Returns:
    • next

      public Position next() throws NoSuchElementException
      Advance the song position to the next integer beat.
      Specified by:
      next in interface Iterator<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

      public Position nextBar() throws NoSuchElementException
      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

      public Position nextHalfBar(boolean swing) throws NoSuchElementException
      Advance the song position to the next half bar (beat=0 or half-bar).
      Parameters:
      swing -
      Returns:
      Throws:
      NoSuchElementException
    • getTimeSignature

      public TimeSignature getTimeSignature()
      The time signature corresponding to the current position.
      Returns:
      Can be null if outside the song