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
Fields inherited from interface org.jjazz.musiccontrol.api.playbacksession.ControlTrackProvider
ENABLED_STATE
Fields inherited from interface org.jjazz.musiccontrol.api.playbacksession.PlaybackSession
PROP_DIRTY, PROP_LOOP_COUNT, PROP_MUTED_TRACKS, PROP_STATE, PROP_TEMPO
-
Constructor Summary
ConstructorDescriptionBaseSongSession
(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 TypeMethodDescriptionvoid
void
close()
Put session in the CLOSED state and release used resources, so that session can be disposed.void
generate
(boolean silent) Generate the sequence for the SongContext.The bar range corresponding to the sequence.int
Get 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.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.int
Get 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.int
getTempo()
Get the tempo in BPM.long
getTick
(int barIndex) Get the start tick position corresponding to the specified bar.The mute status of all tracks.boolean
boolean
boolean
isDirty()
We don't listen to any change on the underlying context data: always return false.boolean
boolean
boolean
void
void
toString()
-
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:PlaybackSession
Get a copy of this session in the NEW state for the specified context.- Specified by:
getFreshCopy
in interfacePlaybackSession
- Parameters:
sgContext
- If null use a copy of this session'SongContext- Returns:
-
isUseActiveSongBackgroundMusicBuilder
public boolean isUseActiveSongBackgroundMusicBuilder() -
getState
Description copied from interface:PlaybackSession
Get the state of this session.- Specified by:
getState
in 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:
generate
in interfacePlaybackSession
- Parameters:
silent
-- Throws:
MusicGenerationException
IllegalStateException
- 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:
isDirty
in interfacePlaybackSession
- Returns:
- See Also:
-
getTempo
public int getTempo()Description copied from interface:PlaybackSession
Get the tempo in BPM.- Specified by:
getTempo
in interfacePlaybackSession
- Returns:
- -1 if no meaningful value can be returned.
- See Also:
-
getSequence
Description copied from interface:PlaybackSession
The Midi sequence.- Specified by:
getSequence
in interfacePlaybackSession
- Returns:
- Can be null if no meaningful value can be returned.
-
getLoopStartTick
public long getLoopStartTick()Description copied from interface:PlaybackSession
The tick position of the start of the loop.- Specified by:
getLoopStartTick
in interfacePlaybackSession
- Returns:
- -1 if no meaningful value can be returned.
-
getLoopEndTick
public long getLoopEndTick()Description copied from interface:PlaybackSession
The tick position of the end of the loop.- Specified by:
getLoopEndTick
in 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:PlaybackSession
The sequencer loop count (see Java Sequencer setLoopCount()).- Specified by:
getLoopCount
in 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:PlaybackSession
Get the start tick position corresponding to the specified bar.- Specified by:
getTick
in interfacePlaybackSession
- Returns:
- -1 if no meaningful value can be returned.
-
getBarRange
Description copied from interface:PlaybackSession
The bar range corresponding to the sequence.- Specified by:
getBarRange
in 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:
getTracksMuteStatus
in interfacePlaybackSession
- Returns:
- See Also:
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListener
in interfacePlaybackSession
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in interfacePlaybackSession
-
close
public void close()Description copied from interface:PlaybackSession
Put session in the CLOSED state and release used resources, so that session can be disposed.- Specified by:
close
in 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:
getSongContext
in interfaceSongContextProvider
-
getControlTrack
Description copied from interface:ControlTrackProvider
get the control track.- Specified by:
getControlTrack
in interfaceControlTrackProvider
- Returns:
- Null if no contral track available.
-
getEndOfPlaybackAction
Description copied from interface:EndOfPlaybackActionProvider
An action to be executed when music playback is stopped or paused (because user stopped it or end of sequence is reached).- Specified by:
getEndOfPlaybackAction
in interfaceEndOfPlaybackActionProvider
- Returns:
- Can be null
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
toString
-