|
resonance 1.0.1
|
Pausable view of scheduler time, together with the tempo that maps it to a song position. More...
#include <tickclock.h>


Public Member Functions | |
| TickClock (Scheduler *pWatchdog, TempoMap *pTempoMap) | |
| Start a clock against a scheduler, with a tempo map of its own or a shared one. | |
| ~TickClock () | |
| Give back the reference to the tempo map. | |
| void | SetTempoMap (TempoMap *pTempoMap) |
| Share a different tempo map, giving back the reference to the current one. | |
| int | SongTick () |
| Report the song position the clock has arrived at. | |
| void | SetSongTick (Sch::Tick tick) |
| Move the clock to a song position. | |
| void | PostAt (Command *pCommand, Time tick) |
| Queue a command at an absolute scheduler time, discarding the handle. | |
| void | PostAtSongTick (Command *pCommand, long long nTick, CmdID &id, int nUnused=0) |
| Queue a command at a song position, under a handle the caller retains. | |
| void | PostAtSongTick (Command *pCommand, long long nTick) |
| Queue a command at a song position, discarding the handle. | |
| Public Member Functions inherited from Sch::TimeClock | |
| TimeClock (Scheduler *pWatchdog) | |
| void | SetOrigin (long long nNanoseconds) |
| Fix the origin of the time base. | |
| long long | Now () |
| Report the current time. | |
| void | Pause () |
| Stop the time base at its current reading. | |
| void | Resume () |
| Restart the time base from the reading Pause() stopped it at. | |
| void | Post (Sch::Command *pCommand, Sch::Time tick, CmdID &id, int bRecordable, int bDelta) |
| Queue a command, choosing between the absolute and the delta path. | |
| void | Withdraw (const CmdID &id) |
| Withdraw the first wrapper queued under a handle. | |
| void | PostIn (Sch::Command *pCommand, Sch::Time tick, CmdID &id, int bRecordable) |
| Queue a command a distance from now, under a handle the caller retains. | |
| void | PostIn (Sch::Command *pCommand, Sch::Time tick) |
| Queue a command a distance from now, discarding the handle. | |
Public Attributes | |
| TempoMap * | mTempoMap |
| Map between song position and scheduler time. | |
| Public Attributes inherited from Sch::TimeClock | |
| long long | mNegatedOrigin |
| The origin, negated, in nanoseconds. | |
| long long | mPausedNs |
| The reading Now() reports while no origin is set, in nanoseconds. | |
| int | mHasOrigin |
| Non-zero while the time base runs against the scheduler. | |
| Scheduler * | mWatchdog |
| The scheduler whose current time the readings follow. | |
Pausable view of scheduler time, together with the tempo that maps it to a song position.
The class is not polymorphic and does not emit RTTI. Its name comes from the one recorded signature that mentions it. Catcher's constructor takes a Sch::TickClock *. That signature identifies this class rather than its base, because Catcher's handler at 0x001ac760 calls SongTick(), and SongTick() reads mTempoMap.
An instance is 0x1c bytes. The base subobject occupies +0x00 through +0x17 and this class adds one pointer at +0x18, which the constructor at 0x004a79f8 is the last write of and which the destructor at 0x004a7aa8 releases.
The base is the 0x18-byte class that Globals::InitServices() instantiates directly at 0x00117118, with its own constructor at 0x004a7780 and its own destructor at 0x004a7798 that releases no tempo map. Two measurements prove the base and derived classes are distinct. The two destructors differ in behaviour, and a class has exactly one destructor. Start(), Resume(), Pause(), and Now() exist as single bodies that both the Globals object and GrooveWorld's object are passed to, and none of the four touches +0x18.
Every post below wraps the command in a Sch::TimedCommand, hands the wrapper to one of the scheduler's two queueing paths, and then gives back its reference. The queue is then the only owner. The member titles are inferred from those bodies. The script command clock at 0x00150d88 supplies the words tempo, tick, and song_bar, the source of the name SongTick(). The bare name Tick would hide the type Sch::Tick inside this class.
Start a clock against a scheduler, with a tempo map of its own or a shared one.
A null tempo map produces a private one at the default tempo of 500000 microseconds per quarter note. A tempo map the caller supplies is shared, and its reference count is incremented directly at 0x004a7a28.
| pWatchdog | The scheduler this clock posts to. |
| pTempoMap | The tempo map to share, or null for a private one. |
| Sch::TickClock::~TickClock | ( | ) |
Give back the reference to the tempo map.
| void Sch::TickClock::SetTempoMap | ( | TempoMap * | pTempoMap | ) |
Share a different tempo map, giving back the reference to the current one.
The new map's reference count is incremented before the old map is released, and a null map is stored without a reference. GrooveWorld::FinishLoad() is the recovered caller, with the tempo map a converted level reports.
| pTempoMap | The tempo map to share, or null. |
| int Sch::TickClock::SongTick | ( | ) |
Report the song position the clock has arrived at.
The body divides the current time, biased by TempoMap::mCeilingBias, by TempoMap::mNanosecondsPerTick, which rounds up to the next whole MIDI tick. The result is then wrapped in a Sch::Tick, whose constructor runs the discarded Sch::Tick::IsInRange() check at 0x00100ab8.
| void Sch::TickClock::SetSongTick | ( | Sch::Tick | tick | ) |
Move the clock to a song position.
The body converts the position to scheduler time through mTempoMap and stores it as the paused reading, but only when it differs from the current reading. The store happens even while the clock runs, when Now() does not report the paused reading.
The position is a Sch::Tick passed by value in one register. Both callers, GrooveWorld's PrepareLevel() at 0x0018ddd8 and StopLevel() at 0x0018ed6c, construct it through Sch::Tick(int) immediately before the call.
| tick | The song position. |
Queue a command at an absolute scheduler time, discarding the handle.
| pCommand | The command to run. |
| tick | The scheduler time to run it at, in this clock's frame. |
| void Sch::TickClock::PostAtSongTick | ( | Command * | pCommand, |
| long long | nTick, | ||
| CmdID & | id, | ||
| int | nUnused = 0 ) |
Queue a command at a song position, under a handle the caller retains.
| pCommand | The command to run. |
| nTick | The song position, in MIDI ticks at 480 per quarter note. Callers widen a 32-bit position into the 64-bit register, and the body multiplies the full width through its 64-bit helper at 0x00600270. |
| id | The handle to queue under. |
| nUnused | All 17 call sites pass 0 as the fifth argument, and the body never reads it. The type and the meaning are not recoverable. |
| void Sch::TickClock::PostAtSongTick | ( | Command * | pCommand, |
| long long | nTick ) |
Queue a command at a song position, discarding the handle.
| pCommand | The command to run. |
| nTick | The song position, in MIDI ticks at 480 per quarter note. |
| TempoMap* Sch::TickClock::mTempoMap |
Map between song position and scheduler time.
Public because the clock tempo script command reads it directly at 0x001511ec, the undeclared Globals accessor at 0x00118ce8 reads it inline, and the image has no out-of-line accessor.
+0x18