Interface SongContext

All Known Subinterfaces:
SongPartContext

public interface SongContext
A Song music generation context.

Associates a Song, a MidiMix and a bar range within that song.

  • Method Details

    • getMidiMix

      MidiMix getMidiMix()
      Music should be produced for this MidiMix.
      Returns:
    • getSong

      Song getSong()
      Music should be produced for this song.
      Returns:
    • getBarRange

      IntRange getBarRange()
      Music should be produced for the song's bar range.

      Returns:
    • getLoopRestartBar

      int getLoopRestartBar()
      The bar to restart from after last bar was played, when playback is in loop mode.
      Returns:
      A value within getBarRange(). By default returns getBarRange().from.
    • getDeepCopy

      SongContext getDeepCopy(boolean disableInternalUpdates)
      Deep copy the Song and the MidiMix.
      Parameters:
      disableInternalUpdates - If true the returned Song instance will have internal consistency updates disabled, e.g. changing a section in the ChordLeadSheet won't impact the SongStructure. The returned MidiMix instance will also not be associated to the Song copy. For special purposes only, this can lead to inconsistent states.
      Returns:
    • clone

      SongContext clone()
      Shallow cloning which reuses the same song and midi mix.
      Returns:
    • getBeatRange

      default FloatRange getBeatRange()
      The beat range within the song for which music should be produced.

      The range can start/end anywhere in the song (including in the middle of a song part). If getBarRange().from > 0 then toBeatRange().from is also > 0.

      Returns:
    • getSongParts

      default List<SongPart> getSongParts()
      Get all the song parts contained in this context bar range.

      Returns:
      Can be empty.
      See Also:
    • getTickRange

      default LongRange getTickRange()
      The tick range corresponding to getBarRange() or getBeatRange().

      The range can start/end anywhere in the song (including in the middle of a song part). If toBeatRange().from > 0 then getTickRange().from is also > 0.

      Returns:
    • getSptBarRange

      default IntRange getSptBarRange(SongPart spt)
      Get the intersection between the song part bar range and this SongContext bar range.

      Parameters:
      spt -
      Returns:
      Can be the EMPTY_RANGE if spt is not part of this context.
    • getSptBeatRange

      default FloatRange getSptBeatRange(SongPart spt)
      Get the intersection between the song part beat range and this SongContext beat range.

      Parameters:
      spt -
      Returns:
    • getSptTickRange

      default LongRange getSptTickRange(SongPart spt)
      Get the range of ticks of spt belonging to this context.
      Parameters:
      spt -
      Returns:
    • getMergedBarRanges

      default <E> List<IntRange> getMergedBarRanges(Rhythm r, RhythmParameter<E> rp, E rpValue)
      Get the bar ranges in this context whose SongParts use rpValue.

      Adjacent BarRanges are merged in the returned list.

      Type Parameters:
      E -
      Parameters:
      r -
      rp - A RhythmParameter from r
      rpValue - A value for rp
      Returns:
      Can be empty
    • getUniqueRhythms

      default List<Rhythm> getUniqueRhythms()
      Get the list of unique rhythms used in this context.
      Returns:
    • getUniqueRhythmVoices

      default List<RhythmVoice> getUniqueRhythmVoices()
      Get the list of unique rhythm voices used in this context.
      Returns:
    • getUniqueSections

      default List<CLI_Section> getUniqueSections()
      Get the unique parent sections used by the context song parts.
      Returns:
      An ordered list by position
    • isInRange

      default boolean isInRange(SongPart spt)
      Check if the specified spt has at least one bar in the range of this context.
      Parameters:
      spt -
      Returns:
    • toClsPosition

      default Position toClsPosition(long relativeTick)
      Converts a tick position relative to this context into a ChordLeadSheet Position.
      Parameters:
      relativeTick -
      Returns:
      Null if tick is out of the bounds of this context.
    • toRelativeTick

      default long toRelativeTick(Position pos)
      Compute the tick relative to this context for the given absolute position expressed in bar/beat.

      Parameters:
      pos -
      Returns:
      -1 if pos is outside this context range. Returns 0 for the first bar/beat of the context range.
    • toPosition

      default Position toPosition(long relativeTick)
      Converts a tick position relative to this context into an absolute SongStructure Position.
      Parameters:
      relativeTick - 0 for the start of this context bar range.
      Returns:
      Null if tick is out of the bounds of this context.
    • toPositionInBeats

      default float toPositionInBeats(long relativeTick)
      Converts a tick position relative to this context into an absolute SongStructure position in beats.
      Parameters:
      relativeTick - 0 for the start of this context bar range.
      Returns:
      -1 if tick is out of the bounds of this context.