Interface PlaybackSession

All Known Implementing Classes:
BaseSongSession, StaticSongSession, UpdatableSongSession, UpdatableSongSessionOnePlay, UpdateProviderSongSession

public interface PlaybackSession
A PlaybackSession contains the data needed by the MusicController to play music and provide related services (firing beat or chord symbol events, managing tempo changes, ...).

Implementations may also implement additional session capabilities such as SongContextProvider, ChordSymbolProvider, etc.

  • Field Details

    • PROP_STATE

      static final String PROP_STATE
      A property change event is fired when the state has changed.
      See Also:
    • PROP_DIRTY

      static final String PROP_DIRTY
      A property change event is fired when session is no more up-to-date with its underlying data.
      See Also:
    • PROP_TEMPO

      static final String PROP_TEMPO
      A property change event is fired when the playback reference tempo has changed.
      See Also:
    • PROP_MUTED_TRACKS

      static final String PROP_MUTED_TRACKS
      A property change event is fired when one or more tracks muted status have changed.
      See Also:
    • PROP_LOOP_COUNT

      static final String PROP_LOOP_COUNT
      A property change event is fired when the loop count has changed.
      See Also:
  • Method Details

    • generate

      void generate(boolean silent) throws MusicGenerationException
      Create the sequence and the related data.

      If generation is successful the method changes the state from NEW to GENERATED.

      Parameters:
      silent - If false a modal progress bar is shown why generating the music.
      Throws:
      MusicGenerationException
      IllegalStateException - If State is not NEW.
    • getFreshCopy

      PlaybackSession getFreshCopy(SongContext sgContext)
      Get a copy of this session in the NEW state for the specified context.
      Parameters:
      sgContext - If null use a copy of this session'SongContext
      Returns:
    • getSequence

      Sequence getSequence()
      The Midi sequence.
      Returns:
      Can be null if no meaningful value can be returned.
    • isDirty

      boolean isDirty()
      Return true if the sequence is not up-to-date with its underlying data.

      If playback is stopped a new session should be created.

      Returns:
      See Also:
    • getState

      Get the state of this session.
      Returns:
      See Also:
    • getTempo

      int getTempo()
      Get the tempo in BPM.
      Returns:
      -1 if no meaningful value can be returned.
      See Also:
    • getTracksMuteStatus

      HashMap<Integer,Boolean> getTracksMuteStatus()
      Get the mute status of each track id.

      Note that track 0 (e.g. mandatory track for sequence name, tempo and time signature changes, etc.) is not included.

      Returns:
      Key=track id, Value=true if track is muted. Can be null if no meaningful value can be returned.
      See Also:
    • getLoopEndTick

      long getLoopEndTick()
      The tick position of the end of the loop.

      Returns:
      -1 if no meaningful value can be returned (loop will be at the end of sequence)
    • getLoopStartTick

      long getLoopStartTick()
      The tick position of the start of the loop.

      Returns:
      -1 if no meaningful value can be returned.
    • getLoopCount

      int getLoopCount()
      The sequencer loop count (see Java Sequencer setLoopCount()).
      Returns:
      0 means sequence is played only once, 1 means sequence is played twice, etc. -1 means loop forever.
    • getBarRange

      IntRange getBarRange()
      The bar range corresponding to the sequence.
      Returns:
      Null if no meaningful value can be returned.
    • getTick

      long getTick(int barIndex)
      Get the start tick position corresponding to the specified bar.
      Parameters:
      barIndex -
      Returns:
      -1 if no meaningful value can be returned.
    • close

      void close()
      Put session in the CLOSED state and release used resources, so that session can be disposed.
      See Also:
    • addPropertyChangeListener

      void addPropertyChangeListener(PropertyChangeListener l)
    • removePropertyChangeListener

      void removePropertyChangeListener(PropertyChangeListener l)