Class BaseSongSession
- All Implemented Interfaces:
PropertyChangeListener,EventListener,ControlTrackProvider,EndOfPlaybackActionProvider,PlaybackSession,SongContextProvider
- Direct Known Subclasses:
StaticSongSession,UpdateProviderSongSession
Music generation uses the SongSequenceBuilder (and optionnaly ActiveSongBackgroundMusicBuilder) then adds control/click/precount tracks, taking into account drums rerouting.
Once generated the session listens to the following changes:
- Song tempo, song closing
- MidiMix channel mute changes
- PlaybackSettings Click and Loop changes
The session never makes the session dirty. Use the provided subclasses for more advanced behaviors, e.g. update the dirty state, etc.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jjazz.musiccontrol.api.playbacksession.PlaybackSession
PlaybackSession.State -
Field Summary
FieldsFields inherited from interface org.jjazz.musiccontrol.api.playbacksession.ControlTrackProvider
ENABLED_STATEFields inherited from interface org.jjazz.musiccontrol.api.playbacksession.PlaybackSession
PROP_DIRTY, PROP_LOOP_COUNT, PROP_MUTED_TRACKS, PROP_STATE, PROP_TEMPO -
Constructor Summary
ConstructorsConstructorDescriptionBaseSongSession(SongContext sgContext, boolean enablePlaybackTransposition, boolean enableClickTrack, boolean enablePrecountTrack, boolean enableControlTrack, int loopCount, ActionListener endOfPlaybackAction, boolean useActiveSongBackgroundMusicBuilder) Create a session with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()Put session in the CLOSED state and release used resources, so that session can be disposed.voidgenerate(boolean silent) Generate the sequence for the SongContext.The bar range corresponding to the sequence.intGet the click sequence track number.get the control track.An action to be executed when music playback is stopped or paused (because user stopped it or end of sequence is reached).getFreshCopy(SongContext sgContext) Get a copy of this session in the NEW state for the specified context.intThe sequencer loop count (see Java Sequencer setLoopCount()).longThe tick position of the end of the loop.longThe tick position of the start of the loop.intGet the precount sequence track number.A map giving the resulting Phrase for each RhythmVoice, in the current context.A map providing the track id (index) corresponding to each used RhythmVoice in the given context.The Midi sequence.getState()Get the state of this session.intgetTempo()Get the tempo in BPM.longgetTick(int barIndex) Get the start tick position corresponding to the specified bar.The mute status of all tracks.booleanbooleanbooleanisDirty()We don't listen to any change on the underlying context data: always return false.booleanbooleanbooleanvoidvoidtoString()
-
Field Details
-
PLAYBACK_SETTINGS_LOOP_COUNT
public static final int PLAYBACK_SETTINGS_LOOP_COUNT- See Also:
-
-
Constructor Details
-
BaseSongSession
public BaseSongSession(SongContext sgContext, boolean enablePlaybackTransposition, boolean enableClickTrack, boolean enablePrecountTrack, boolean enableControlTrack, int loopCount, ActionListener endOfPlaybackAction, boolean useActiveSongBackgroundMusicBuilder) Create a session with the specified parameters.- Parameters:
sgContext-enablePlaybackTransposition-enableClickTrack-enablePrecountTrack-enableControlTrack-loopCount-endOfPlaybackAction-useActiveSongBackgroundMusicBuilder- If true use ActiveSongBackgroundMusicBuilder when possible to speed up music generation
-
-
Method Details
-
getFreshCopy
Description copied from interface:PlaybackSessionGet a copy of this session in the NEW state for the specified context.- Specified by:
getFreshCopyin interfacePlaybackSession- Parameters:
sgContext- If null use a copy of this session'SongContext- Returns:
-
isUseActiveSongBackgroundMusicBuilder
public boolean isUseActiveSongBackgroundMusicBuilder() -
getState
Description copied from interface:PlaybackSessionGet the state of this session.- Specified by:
getStatein interfacePlaybackSession- Returns:
- See Also:
-
generate
Generate the sequence for the SongContext.When all parameters are enabled, sequence will contain:
- track 0: song name, tempo and tempo factor changes (seeSongSequenceBuilder)
- track 1-N: the song tracks, one per RhythmVoice(seeSongSequenceBuilder)
- track N+1: control track with beat events + chord symbol markers
- track N+2: click track
- track N+3: precount-click trackManage the drums rerouting.
- Specified by:
generatein interfacePlaybackSession- Parameters:
silent-- Throws:
MusicGenerationExceptionIllegalStateException- If state is not NEW
-
isDirty
public boolean isDirty()We don't listen to any change on the underlying context data: always return false.- Specified by:
isDirtyin interfacePlaybackSession- Returns:
- See Also:
-
getTempo
public int getTempo()Description copied from interface:PlaybackSessionGet the tempo in BPM.- Specified by:
getTempoin interfacePlaybackSession- Returns:
- -1 if no meaningful value can be returned.
- See Also:
-
getSequence
Description copied from interface:PlaybackSessionThe Midi sequence.- Specified by:
getSequencein interfacePlaybackSession- Returns:
- Can be null if no meaningful value can be returned.
-
getLoopStartTick
public long getLoopStartTick()Description copied from interface:PlaybackSessionThe tick position of the start of the loop.- Specified by:
getLoopStartTickin interfacePlaybackSession- Returns:
- -1 if no meaningful value can be returned.
-
getLoopEndTick
public long getLoopEndTick()Description copied from interface:PlaybackSessionThe tick position of the end of the loop.- Specified by:
getLoopEndTickin interfacePlaybackSession- Returns:
- -1 if no meaningful value can be returned (loop will be at the end of sequence)
-
getLoopCount
public int getLoopCount()Description copied from interface:PlaybackSessionThe sequencer loop count (see Java Sequencer setLoopCount()).- Specified by:
getLoopCountin interfacePlaybackSession- Returns:
- 0 means sequence is played only once, 1 means sequence is played twice, etc. -1 means loop forever.
-
getTick
public long getTick(int barIndex) Description copied from interface:PlaybackSessionGet the start tick position corresponding to the specified bar.- Specified by:
getTickin interfacePlaybackSession- Returns:
- -1 if no meaningful value can be returned.
-
getBarRange
Description copied from interface:PlaybackSessionThe bar range corresponding to the sequence.- Specified by:
getBarRangein interfacePlaybackSession- Returns:
- Null if no meaningful value can be returned.
-
getTracksMuteStatus
The mute status of all tracks.This includes the click/precount/control tracks when enabled.
- Specified by:
getTracksMuteStatusin interfacePlaybackSession- Returns:
- See Also:
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListenerin interfacePlaybackSession
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListenerin interfacePlaybackSession
-
close
public void close()Description copied from interface:PlaybackSessionPut session in the CLOSED state and release used resources, so that session can be disposed.- Specified by:
closein interfacePlaybackSession- See Also:
-
getRvTrackIdMap
A map providing the track id (index) corresponding to each used RhythmVoice in the given context.If a song uses rhythms R1 and R2 and context is only on R2 bars, then the map only contains R2 rhythm voices and track id.
- Returns:
- Null if no meaningful value can be returned.
-
getRvPhraseMap
A map giving the resulting Phrase for each RhythmVoice, in the current context.- Returns:
- Null if no meaningful value can be returned.
-
getClickTrackId
public int getClickTrackId()Get the click sequence track number.- Returns:
- -1 if no click track
-
getPrecountTrackId
public int getPrecountTrackId()Get the precount sequence track number.- Returns:
- -1 if no precount track
-
isPlaybackTranspositionEnabled
public boolean isPlaybackTranspositionEnabled() -
isClickTrackIncluded
public boolean isClickTrackIncluded() -
isPrecountTrackIncluded
public boolean isPrecountTrackIncluded() -
isControlTrackIncluded
public boolean isControlTrackIncluded() -
getSongContext
- Specified by:
getSongContextin interfaceSongContextProvider
-
getControlTrack
Description copied from interface:ControlTrackProviderget the control track.- Specified by:
getControlTrackin interfaceControlTrackProvider- Returns:
- Null if no contral track available.
-
getEndOfPlaybackAction
Description copied from interface:EndOfPlaybackActionProviderAn action to be executed when music playback is stopped or paused (because user stopped it or end of sequence is reached).- Specified by:
getEndOfPlaybackActionin interfaceEndOfPlaybackActionProvider- Returns:
- Can be null
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
toString
-