This object holds the state of how the currently-in-memory Music sheet should be performed over time. More...
#include <PlaybackState.h>
Public Member Functions | |
PlaybackState () | |
Constructor. More... | |
~PlaybackState () | |
Destructor. More... | |
virtual void | SetToDefaultState () |
Sets this object to its just-constructed state. More... | |
virtual status_t | SetFromArchive (const ConstMessageRef &archive) |
Replaces this sheet's current contents with the contents from (archive) More... | |
virtual status_t | SaveToArchive (const MessageRef &archive) const |
Saves this sheet's current contents into (archive) More... | |
virtual uint32 | GetCurrentChecksum () const |
Just calls CalculateChecksum(), since this database is very small and thus CalculateChecksum() is still cheap. More... | |
virtual uint32 | CalculateChecksum () const |
Calculates and returns a checksum for this object. More... | |
virtual ConstMessageRef | SeniorUpdate (const ConstMessageRef &seniorDoMsg) |
Updates our state as specified in the (seniorDoMsg). More... | |
virtual status_t | JuniorUpdate (const ConstMessageRef &juniorDoMsg) |
Updates our state as specified in the (juniorDoMsg). More... | |
uint64 | GetNetworkStartTimeMicros () const |
Returns the time corresponding to the triggering of playback of the first note in the MusicSheet (or MUSCLE_TIME_NEVER if we shouldn't play) More... | |
uint64 | GetMicrosPerChord () const |
Returns the number of microseconds to be allotted to each chord in the MusicSheet. More... | |
uint32 | GetPausedIndex () const |
If we're paused, returns the index of the chord that the playhead is currently paused at (or MUSCLE_NO_LIMIT if we aren't paused) More... | |
void | SetNetworkStartTimeMicros (uint64 networkStartTimeMicros) |
Sets the time corresponding to the triggering of playback of the first note in the MusicSheet (or MUSCLE_TIME_NEVER if we shouldn't play) More... | |
void | SetMicrosPerChord (uint64 microsPerChord, uint64 optNetworkNow=MUSCLE_TIME_NEVER) |
Sets the number of microseconds to be allotted to each chord in the MusicSheet. More... | |
void | SetPausedIndex (bool pausedIndex) |
Sets returns the index of the chord that the playhead is currently paused at (or MUSCLE_NO_LIMIT if we don't want to be paused) More... | |
bool | IsPaused () const |
Convenience method – returns true iff we are currently paused. More... | |
void | SetLoop (bool loop) |
Set true if the music playback should loop; false if it should play through just once. More... | |
bool | IsLoop () const |
Returns true iff we should loop playback indefinitely (false means we should play only once) More... | |
void | StartPlayback (uint64 networkNow) |
Convenience method – starts playback at the current seek position, if we're not already playing. More... | |
void | PausePlayback (uint64 networkNow) |
Convenience method – pauses playback at the current seek position, if we're not already paused. More... | |
void | SeekTo (uint64 networkNow, uint32 whichChord) |
Convenience method – seeks the current playback position to the specified chord. More... | |
uint32 | GetChordIndexForNetworkTimeStamp (uint64 networkTimeStamp, uint32 optLoopLengthChords) const |
Convenience method: Given a network time stamp, returns the chord-index that corresponds to that time. More... | |
uint64 | GetNetworkTimeToPlayChord (uint32 chordIndex) const |
Convenience method: Given a chord index, returns the network-time at which that chord should be played. More... | |
int64 | GetPlaybackPositionForNetworkTimeMicroseconds (uint64 networkTimestamp) const |
Convenience method: Given a network-timestamp, returns the corresponding offset from the top of the song (may be negative!) More... | |
virtual String | ToString () const |
Returns a string representation of this object, for debugging purposes. More... | |
ZGDatabasePeerSession * | GetDatabasePeerSession () |
Returns a pointer to the ZGDatabasePeerSession object that created us, or NULL if this object was not created by a ZGDatabasePeerSession. More... | |
const ZGDatabasePeerSession * | GetDatabasePeerSession () const |
As above, but returns a const/read-only pointer. More... | |
Protected Member Functions | |
ChoirSession * | GetChoirSession () |
Returns a pointer to the ChoirSession object that created this object. More... | |
const ChoirSession * | GetChoirSession () const |
Returns a read-only pointer to the ChoirSession object that created this object. More... | |
ConstMessageRef | SendFullStateToGUI (bool allowReviewTrigger) |
Saves the state of this object into a Message and sends that Message to the GUI thread. More... | |
void | SendMessageToGUI (const ConstMessageRef &msg, bool allowReviewTrigger) |
Sends the specified Message to the GUI thread. More... | |
void | SetReviewResults (uint64 allNotesUsedChord) |
Convenience method; calls SetReviewResults(allNotesUsedChord) on our ChoirSession object. More... | |
const IDatabaseObject * | GetDatabaseObject (uint32 whichDatabase) const |
Returns a read-only pointer to the specified IDatabaseObject held by our ZGDatabasePeerSession, or NULL if we don't have a ZGDatabasePeerSession or if the specified database doesn't exist. More... | |
bool | IsPeerOnline (const ZGPeerID &pid) const |
Returns true iff the peer with the specified ID is currently on line. More... | |
const Hashtable< ZGPeerID, ConstMessageRef > & | GetOnlinePeers () const |
Returns a table of the currently online peers (and their attributes), or an empty table if we have no ZGDatabasePeerSession. More... | |
virtual uint64 | GetNetworkTime64 () const |
Returns the current network time, or 0 if we have no ZGDatabasePeerSession. More... | |
virtual uint64 | GetRunTime64ForNetworkTime64 (uint64 networkTime64TimeStamp) const |
Returns the local time corresponding to a given network time, or 0 if we have no ZGDatabasePeerSession. More... | |
virtual uint64 | GetNetworkTime64ForRunTime64 (uint64 runTime64TimeStamp) const |
Returns the network time corresponding to a given local time, or 0 if we have no ZGDatabasePeerSession. More... | |
virtual int64 | GetToNetworkTimeOffset () const |
Returns the number of microseconds that should be added to a GetRunTime64() value to turn it into a GetNetworkTime64() value, or subtracted to do the inverse operation. More... | |
This object holds the state of how the currently-in-memory Music sheet should be performed over time.
Definition at line 9 of file PlaybackState.h.
PlaybackState | ( | ) |
Constructor.
~PlaybackState | ( | ) |
Destructor.
|
virtual |
Calculates and returns a checksum for this object.
Implements IDatabaseObject.
Referenced by PlaybackState::GetCurrentChecksum().
|
protectedinherited |
Returns a pointer to the ChoirSession object that created this object.
|
protectedinherited |
Returns a read-only pointer to the ChoirSession object that created this object.
uint32 GetChordIndexForNetworkTimeStamp | ( | uint64 | networkTimeStamp, |
uint32 | optLoopLengthChords | ||
) | const |
Convenience method: Given a network time stamp, returns the chord-index that corresponds to that time.
networkTimeStamp | time-stamp to return a chord-index for |
optLoopLengthChords | if valid, we'll use this loop-length in our calculation. If 0 or MUSCLE_TIME_NEVER, we won't. |
|
inlinevirtual |
Just calls CalculateChecksum(), since this database is very small and thus CalculateChecksum() is still cheap.
Implements IDatabaseObject.
Definition at line 28 of file PlaybackState.h.
References PlaybackState::CalculateChecksum().
|
protectedinherited |
Returns a read-only pointer to the specified IDatabaseObject held by our ZGDatabasePeerSession, or NULL if we don't have a ZGDatabasePeerSession or if the specified database doesn't exist.
whichDatabase | index of the database object we want to access |
|
inlineinherited |
Returns a pointer to the ZGDatabasePeerSession object that created us, or NULL if this object was not created by a ZGDatabasePeerSession.
(Note that this pointer is not set until after our constructor returns, this method will always return NULL if called from a constructor)
Definition at line 85 of file IDatabaseObject.h.
|
inlineinherited |
As above, but returns a const/read-only pointer.
Definition at line 88 of file IDatabaseObject.h.
|
inline |
Returns the number of microseconds to be allotted to each chord in the MusicSheet.
Definition at line 49 of file PlaybackState.h.
|
inline |
Returns the time corresponding to the triggering of playback of the first note in the MusicSheet (or MUSCLE_TIME_NEVER if we shouldn't play)
Definition at line 46 of file PlaybackState.h.
|
protectedvirtualinherited |
Returns the current network time, or 0 if we have no ZGDatabasePeerSession.
Implements INetworkTimeProvider.
|
protectedvirtualinherited |
Returns the network time corresponding to a given local time, or 0 if we have no ZGDatabasePeerSession.
runTime64TimeStamp | a local-clock time, in microseconds |
Implements INetworkTimeProvider.
uint64 GetNetworkTimeToPlayChord | ( | uint32 | chordIndex | ) | const |
Convenience method: Given a chord index, returns the network-time at which that chord should be played.
|
protectedinherited |
Returns a table of the currently online peers (and their attributes), or an empty table if we have no ZGDatabasePeerSession.
|
inline |
If we're paused, returns the index of the chord that the playhead is currently paused at (or MUSCLE_NO_LIMIT if we aren't paused)
Definition at line 52 of file PlaybackState.h.
int64 GetPlaybackPositionForNetworkTimeMicroseconds | ( | uint64 | networkTimestamp | ) | const |
Convenience method: Given a network-timestamp, returns the corresponding offset from the top of the song (may be negative!)
|
protectedvirtualinherited |
Returns the local time corresponding to a given network time, or 0 if we have no ZGDatabasePeerSession.
networkTime64TimeStamp | a network-clock time, in microseconds |
Implements INetworkTimeProvider.
|
protectedvirtualinherited |
Returns the number of microseconds that should be added to a GetRunTime64() value to turn it into a GetNetworkTime64() value, or subtracted to do the inverse operation.
Note that this value will vary from one moment to the next!
Implements INetworkTimeProvider.
|
inline |
Returns true iff we should loop playback indefinitely (false means we should play only once)
Definition at line 74 of file PlaybackState.h.
|
inline |
Convenience method – returns true iff we are currently paused.
Definition at line 68 of file PlaybackState.h.
|
protectedinherited |
Returns true iff the peer with the specified ID is currently on line.
pid | The ID of the peer we are interested in. If we have no ZGDatabasePeerSession then this will always return false. |
|
virtual |
Updates our state as specified in the (juniorDoMsg).
Will only be called on the instance running on the senior peer.
juniorDoMsg | A Message containing instructions for how to update our state on a junior peer. |
Implements IDatabaseObject.
void PausePlayback | ( | uint64 | networkNow | ) |
Convenience method – pauses playback at the current seek position, if we're not already paused.
networkNow | The current network time (used to calculate the network-start-time-micros value) |
|
virtual |
Saves this sheet's current contents into (archive)
Implements IDatabaseObject.
void SeekTo | ( | uint64 | networkNow, |
uint32 | whichChord | ||
) |
Convenience method – seeks the current playback position to the specified chord.
networkNow | The current network time (used to calculate the network-start-time-micros value) |
whichChord | The chord to seek to (0 == start of song, 1 == second chord, etc) |
|
protectedinherited |
Saves the state of this object into a Message and sends that Message to the GUI thread.
allowReviewTrigger | if true, this method may also trigger a review of the current bell-assignments to see if they need updating. |
|
protectedinherited |
Sends the specified Message to the GUI thread.
msg | The Message to send to the GUI thread. |
allowReviewTrigger | if true, this method may also trigger a review of the current bell-assignments to see if they need updating. |
|
virtual |
Updates our state as specified in the (seniorDoMsg).
Will only be called on the instance running on the senior peer.
seniorDoMsg | A Message containing instructions for how to update our state on the senior peer. |
Implements IDatabaseObject.
|
virtual |
Replaces this sheet's current contents with the contents from (archive)
Implements IDatabaseObject.
|
inline |
Set true if the music playback should loop; false if it should play through just once.
Definition at line 71 of file PlaybackState.h.
void SetMicrosPerChord | ( | uint64 | microsPerChord, |
uint64 | optNetworkNow = MUSCLE_TIME_NEVER |
||
) |
Sets the number of microseconds to be allotted to each chord in the MusicSheet.
microsPerChord | the new microseconds-per-chord value to use (smaller == faster playback) |
optNetworkNow | If specified, and the state is currently set to "playing", we'll use this information to try to keep the current-playback-point roughly constant despite the change in tempo. |
|
inline |
Sets the time corresponding to the triggering of playback of the first note in the MusicSheet (or MUSCLE_TIME_NEVER if we shouldn't play)
Definition at line 55 of file PlaybackState.h.
|
inline |
Sets returns the index of the chord that the playhead is currently paused at (or MUSCLE_NO_LIMIT if we don't want to be paused)
Definition at line 65 of file PlaybackState.h.
|
protectedinherited |
Convenience method; calls SetReviewResults(allNotesUsedChord) on our ChoirSession object.
allNotesUsedChord | a bit-chord of CHOIR_NOTE_* values indicating which notes are present in our current song. |
|
virtual |
Sets this object to its just-constructed state.
Implements IDatabaseObject.
void StartPlayback | ( | uint64 | networkNow | ) |
Convenience method – starts playback at the current seek position, if we're not already playing.
networkNow | The current network time (used to calculate the network-start-time-micros value) |
|
virtual |
Returns a string representation of this object, for debugging purposes.
Implements IDatabaseObject.