Class UpdateProviderSongSession
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,ControlTrackProvider
,EndOfPlaybackActionProvider
,PlaybackSession
,SongContextProvider
,UpdatableSongSession.UpdateProvider
The session provides on-the-fly UpdatableSongSession.Updates for:
- chord symbol changes (add/remove/change/moveAll)
- rhythm parameter value changes
- existing user phrase content changes (but not for add/remove user phrase events)
- PlaybackSettings playback transposition changes
- MidiMix instrument transposition/velocity changes, plus drum keymap and drum rerouting changes
If change can't be handled as an update (eg a song part tempo factor change or a click setting), session is marked dirty (ie needs regeneration). If session is dirty, editors can still show the playback point using the control track but the "dirty" changes are not heard.
A more serious change like a structural change of the song context will make the session dirty, plus it disables the control track and any future update. So editors should stop showing the playback point, and any further change will not be heard (until a new session is generated).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jjazz.musiccontrol.api.playbacksession.PlaybackSession
PlaybackSession.State
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from class org.jjazz.musiccontrol.api.playbacksession.BaseSongSession
PLAYBACK_SETTINGS_LOOP_COUNT
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
Fields inherited from interface org.jjazz.musiccontrol.api.playbacksession.UpdatableSongSession.UpdateProvider
PROP_UPDATE_AVAILABLE, PROP_UPDATE_PROVISION_ENABLED
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Put session in the CLOSED state and release used resources, so that session can be disposed.void
generate
(boolean silent) Generate the initial music then listen for song changes to be ready to generate updates.get the control track.getFreshCopy
(SongContext sgContext) Get a copy of this session in the NEW state for the specified context.Get the last available update after the PROP_UPDATE_AVAILABLE property change event was fired.int
Wait time after having generated an update.int
Wait time before starting the music generation to provide an update.static UpdateProviderSongSession
getSession
(SongContext sgContext) Same as getSession(sgContext, true, true, true, true, true, PLAYBACK_SETTINGS_LOOP_COUNT, null);static UpdateProviderSongSession
getSession
(SongContext sgContext, boolean enablePlaybackTransposition, boolean includeClickTrack, boolean includePrecountTrack, boolean includeControlTrack, boolean enableUpdateControl, int loopCount, ActionListener endOfPlaybackAction) Create or reuse a session for the specified parameters.boolean
True if updates are authorized/blocked depending on the PlaybackSettings auto update value.boolean
Check if this UpdateProvider can still provide updates.void
void
setPostUpdateSleepTimeMs
(int postUpdateSleepTimeMs) Calls to this method are ignored if state is not NEW.void
setPreUpdateBufferTimeMs
(int preUpdateBufferTimeMs) Calls to this method are ignored if state is not NEW.void
The handler for exception during music generation due to user error.Methods inherited from class org.jjazz.musiccontrol.api.playbacksession.BaseSongSession
addPropertyChangeListener, getBarRange, getClickTrackId, getEndOfPlaybackAction, getLoopCount, getLoopEndTick, getLoopStartTick, getPrecountTrackId, getRvPhraseMap, getRvTrackIdMap, getSequence, getSongContext, getState, getTempo, getTick, getTracksMuteStatus, isClickTrackIncluded, isControlTrackIncluded, isDirty, isPlaybackTranspositionEnabled, isPrecountTrackIncluded, isUseActiveSongBackgroundMusicBuilder, removePropertyChangeListener, toString
-
Field Details
-
DEFAULT_PRE_UPDATE_BUFFER_TIME_MS
public static final int DEFAULT_PRE_UPDATE_BUFFER_TIME_MS- See Also:
-
DEFAULT_POST_UPDATE_SLEEP_TIME_MS
public static final int DEFAULT_POST_UPDATE_SLEEP_TIME_MS- See Also:
-
-
Method Details
-
getSession
public static UpdateProviderSongSession getSession(SongContext sgContext, boolean enablePlaybackTransposition, boolean includeClickTrack, boolean includePrecountTrack, boolean includeControlTrack, boolean enableUpdateControl, int loopCount, ActionListener endOfPlaybackAction) Create or reuse a session for the specified parameters.Sessions are cached: if a non-dirty session in the NEW or GENERATED state already exists for the same parameters then return it, otherwise a new session is created.
- Parameters:
sgContext
-enablePlaybackTransposition
- If true apply the playback transpositionincludeClickTrack
- If true add the click track, and its muted/unmuted state will depend on the PlaybackSettingsincludePrecountTrack
- If true add the precount track, and loopStartTick will depend on the PlaybackSettingsincludeControlTrack
- if true add a control track (beat positions + chord symbol markers)enableUpdateControl
- If true updates are authorized depending on the PlaybackSettings AutoUpdateEnabled value.loopCount
- See Sequencer.setLoopCount(). Use PLAYBACK_SETTINGS_LOOP_COUNT to rely on the PlaybackSettings instance value.endOfPlaybackAction
- Action executed when playback is stopped. Can be null.- Returns:
- A session in the NEW or GENERATED state.
-
getSession
Same as getSession(sgContext, true, true, true, true, true, PLAYBACK_SETTINGS_LOOP_COUNT, null);- Parameters:
sgContext
-- Returns:
- A targetSession in the NEW or GENERATED state.
-
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
- Overrides:
getFreshCopy
in classBaseSongSession
- Parameters:
sgContext
- If null use a copy of this session'SongContext- Returns:
-
generate
Generate the initial music then listen for song changes to be ready to generate updates.- Specified by:
generate
in interfacePlaybackSession
- Overrides:
generate
in classBaseSongSession
- Parameters:
silent
-- Throws:
MusicGenerationException
-
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
- Overrides:
close
in classBaseSongSession
- See Also:
-
isUpdateControlEnabled
public boolean isUpdateControlEnabled()True if updates are authorized/blocked depending on the PlaybackSettings auto update value.- Returns:
-
getPreUpdateBufferTimeMs
public int getPreUpdateBufferTimeMs()Wait time before starting the music generation to provide an update.- Returns:
- See Also:
-
setPreUpdateBufferTimeMs
public void setPreUpdateBufferTimeMs(int preUpdateBufferTimeMs) Calls to this method are ignored if state is not NEW.- Parameters:
preUpdateBufferTimeMs
-
-
getPostUpdateSleepTimeMs
public int getPostUpdateSleepTimeMs()Wait time after having generated an update.- Returns:
- See Also:
-
setPostUpdateSleepTimeMs
public void setPostUpdateSleepTimeMs(int postUpdateSleepTimeMs) Calls to this method are ignored if state is not NEW.- Parameters:
postUpdateSleepTimeMs
-
-
setUserErrorExceptionHandler
The handler for exception during music generation due to user error.By default the handler displays the exception error message using StatusDisplayer.
- Parameters:
handler
- If null errors will be ignored
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
- Overrides:
propertyChange
in classBaseSongSession
-
getLastUpdate
Description copied from interface:UpdatableSongSession.UpdateProvider
Get the last available update after the PROP_UPDATE_AVAILABLE property change event was fired.- Specified by:
getLastUpdate
in interfaceUpdatableSongSession.UpdateProvider
- Returns:
- Can be null if PROP_UPDATE_AVAILABLE change event was never fired.
-
isUpdateProvisionEnabled
public boolean isUpdateProvisionEnabled()Description copied from interface:UpdatableSongSession.UpdateProvider
Check if this UpdateProvider can still provide updates.- Specified by:
isUpdateProvisionEnabled
in interfaceUpdatableSongSession.UpdateProvider
- Returns:
- True upon this object's creation, but might become false if UpdateProvider is "too" dirty and not able anymore to provide updates.
- See Also:
-
getControlTrack
Description copied from interface:ControlTrackProvider
get the control track.- Specified by:
getControlTrack
in interfaceControlTrackProvider
- Overrides:
getControlTrack
in classBaseSongSession
- Returns:
- Null if no contral track available.
-