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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from class org.jjazz.musiccontrol.api.playbacksession.BaseSongSession
PLAYBACK_SETTINGS_LOOP_COUNTFields 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_TEMPOFields inherited from interface org.jjazz.musiccontrol.api.playbacksession.UpdatableSongSession.UpdateProvider
PROP_UPDATE_AVAILABLE, PROP_UPDATE_PROVISION_ENABLED -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Put session in the CLOSED state and release used resources, so that session can be disposed.voidgenerate(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.intWait time after having generated an update.intWait time before starting the music generation to provide an update.static UpdateProviderSongSessiongetSession(SongContext sgContext) Same as getSession(sgContext, true, true, true, true, true, PLAYBACK_SETTINGS_LOOP_COUNT, null);static UpdateProviderSongSessiongetSession(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.booleanTrue if updates are authorized/blocked depending on the PlaybackSettings auto update value.booleanCheck if this UpdateProvider can still provide updates.voidvoidsetPostUpdateSleepTimeMs(int postUpdateSleepTimeMs) Calls to this method are ignored if state is not NEW.voidsetPreUpdateBufferTimeMs(int preUpdateBufferTimeMs) Calls to this method are ignored if state is not NEW.voidThe 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:PlaybackSessionGet a copy of this session in the NEW state for the specified context.- Specified by:
getFreshCopyin interfacePlaybackSession- Overrides:
getFreshCopyin 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:
generatein interfacePlaybackSession- Overrides:
generatein classBaseSongSession- Parameters:
silent-- Throws:
MusicGenerationException
-
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- Overrides:
closein 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:
propertyChangein interfacePropertyChangeListener- Overrides:
propertyChangein classBaseSongSession
-
getLastUpdate
Description copied from interface:UpdatableSongSession.UpdateProviderGet the last available update after the PROP_UPDATE_AVAILABLE property change event was fired.- Specified by:
getLastUpdatein interfaceUpdatableSongSession.UpdateProvider- Returns:
- Can be null if PROP_UPDATE_AVAILABLE change event was never fired.
-
isUpdateProvisionEnabled
public boolean isUpdateProvisionEnabled()Description copied from interface:UpdatableSongSession.UpdateProviderCheck if this UpdateProvider can still provide updates.- Specified by:
isUpdateProvisionEnabledin 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:ControlTrackProviderget the control track.- Specified by:
getControlTrackin interfaceControlTrackProvider- Overrides:
getControlTrackin classBaseSongSession- Returns:
- Null if no contral track available.
-