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.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
A property change event is fired when session is no more up-to-date with its underlying data.static final String
A property change event is fired when the loop count has changed.static final String
A property change event is fired when one or more tracks muted status have changed.static final String
A property change event is fired when the state has changed.static final String
A property change event is fired when the playback reference tempo has changed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
close()
Put session in the CLOSED state and release used resources, so that session can be disposed.void
generate
(boolean silent) Create the sequence and the related data.The bar range corresponding to the sequence.getFreshCopy
(SongContext sgContext) Get a copy of this session in the NEW state for the specified context.int
The sequencer loop count (see Java Sequencer setLoopCount()).long
The tick position of the end of the loop.long
The tick position of the start of the loop.The Midi sequence.getState()
Get the state of this session.int
getTempo()
Get the tempo in BPM.long
getTick
(int barIndex) Get the start tick position corresponding to the specified bar.Get the mute status of each track id.boolean
isDirty()
Return true if the sequence is not up-to-date with its underlying data.void
-
Field Details
-
PROP_STATE
A property change event is fired when the state has changed.- See Also:
-
PROP_DIRTY
A property change event is fired when session is no more up-to-date with its underlying data.- See Also:
-
PROP_TEMPO
A property change event is fired when the playback reference tempo has changed.- See Also:
-
PROP_MUTED_TRACKS
A property change event is fired when one or more tracks muted status have changed.- See Also:
-
PROP_LOOP_COUNT
A property change event is fired when the loop count has changed.- See Also:
-
-
Method Details
-
generate
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
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
PlaybackSession.State 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
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
-
removePropertyChangeListener
-