|
resonance 1.0.1
|
Pitcher that drives the scratch track. More...
#include <scratcher.h>


Public Member Functions | |
| Scratcher (PhraseMgr *pPhraseMgr, Quantizer *pQuantizer, Sch::TickClock *pClock, const TrackData *pTrackData) | |
| Construct a scratcher for one track. | |
| virtual | ~Scratcher () |
| virtual int | Tick (int nElapsedTicks) |
| Advance to the bar the elapsed tick count falls in. | |
| Public Member Functions inherited from Pitcher | |
| Pitcher (Sch::TickClock *pClock) | |
| Construct the three bases, the TickTask one to run every bar. | |
| virtual | ~Pitcher () |
| Inline. | |
| Public Member Functions inherited from MsgSink | |
| void * | operator new (size_t nSize) |
| Allocate a sink from the tagged heap under the tag "MsgSink". | |
| void | operator delete (void *pBlock) |
| Release a sink to the tagged heap. | |
| virtual | ~MsgSink () |
| virtual void | Dispatch (Message *pMsg) |
| Accept a message. | |
| Public Member Functions inherited from MsgSource | |
| virtual | ~MsgSource () |
| virtual void | AddSink (MsgSink *pSink) |
| Register a sink, ignoring a sink that is already registered. | |
| virtual void | RemoveSink (MsgSink *pSink) |
| Unregister the first occurrence of a sink. | |
| void | Send (Message *pMsg) const |
| Deliver a message to every registered sink, in registration order. | |
| void | ClearSinks () |
| Unregister every sink. | |
| Public Member Functions inherited from TickTask | |
| TickTask (Sch::TickClock *pClock, int nPeriod, int bAligned) | |
| virtual | ~TickTask () |
| Withdraw the queued command. | |
| virtual void | Print (std::ostream &stream) |
| Write the task to a diagnostic stream. | |
| void | Start (int nEpochOffset) |
| Post the task on its clock. | |
| void | Run () |
| Run Tick() for the run now due and post the next one. | |
| void | Stop () |
| Withdraw the queued command and forget its handle. | |
| Public Member Functions inherited from Attachment | |
| Attachment () | |
| virtual | ~Attachment () |
| int | Release () |
| Give back one reference and destroy the object once the last one is gone. | |
| virtual void | Destroy () |
| Destroy the object. | |
Protected Member Functions | |
| void | PostNowBarMsg (AxisRegisterMsg *pMsg) |
| Turn an axis reading for this track and player into scratches. | |
| void | EraseGemRange (EraseMsg *pMsg) |
| Erase a player's phrases at an EraseMsg's position for this track. | |
| void | OnTrackSelect (TrackSelectMsg *pMsg) |
| Install the player a TrackSelectMsg for this track selects. | |
| void | OnPitchRiff (int nGem, int nStep, int nTick) |
| Play a gem at a pitch step. | |
| void | SendSeekerMsg (int nBar) const |
| Turn mPlayer's seeker off, unless mPlayer is the stand-in. | |
| virtual void | DispatchPriv (Message *pMsg) |
| Act on a message. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from Attachment | |
| static void | ReleaseIfSet (Attachment *pAttachment) |
| Give back one reference to an object that may be null. | |
| Public Attributes inherited from MsgSource | |
| int | mGraphBuilt |
| A word no member of this class reads. | |
| Public Attributes inherited from Attachment | |
| int | mRefs |
| Static Public Attributes inherited from Pitcher | |
| static constexpr int | kBarPeriod = 1920 |
| The TickTask period, one bar of 1920 ticks. | |
Pitcher that drives the scratch track.
Its RTTI descriptor is at 0x00901fe0. It has Pitcher as its one base. Its three tables are at 0x007e57b8, 0x007e5790, and 0x007e5760, and it overrides exactly the two slots Pitcher declares pure. PitchingSTG's tagged allocation measures the object at 0x90 bytes, and PitchingSTG builds one of these when the track's kind word is 3 and a NotePitcher when it is 2.
Tick() is what fixes mBarDivisor. It divides the elapsed tick count by that member, sends the result through SendSeekerMsg(), and then, while mSwitchesBanks is set, tests the track description against the same bar and dispatches a slot on the synthesiser that Globals::GetSynth() returns.
The constructor fixes the member map. It copies the bar length from the phrase manager's +0x34 into mBarDivisor and the track's identity and MIDI channel out of the track description, starts both player references at the stand-in player, and sizes mReadings to three zeroed elements.
| Scratcher::Scratcher | ( | PhraseMgr * | pPhraseMgr, |
| Quantizer * | pQuantizer, | ||
| Sch::TickClock * | pClock, | ||
| const TrackData * | pTrackData ) |
Construct a scratcher for one track.
| pPhraseMgr | The phrase manager for the track. |
| pQuantizer | The quantiser for the track. |
| pClock | The clock the producer schedules against. |
| pTrackData | The track description. |
|
virtual |
|
virtual |
Advance to the bar the elapsed tick count falls in.
Divides the elapsed count by mBarDivisor and sends that bar through SendSeekerMsg(). While mSwitchesBanks is set and the bar starts a step, it then selects the synthesiser bank of that step for the channel in mChannel, as AxePhraseMaker::OnPeriod() does.
| nElapsedTicks | Ticks since the epoch. |
Implements TickTask.
|
protected |
Turn an axis reading for this track and player into scratches.
The routine sends a NowBarMsg at lane one minus the value, then tracks the reading's movement against the ring of past readings in mReadings and replays the last gem through OnPitchRiff() at a step of up to 3 in either direction.
| pMsg | The message. |
|
protected |
Erase a player's phrases at an EraseMsg's position for this track.
The bar, or with the message's last word set every bar of its step, is cleared wherever it belongs to the message's player, and clearing the message's bar also sends an AllNotesOffMsg. When anything was cleared, SND_ERASE_SECTION or SND_ERASE plays, a ShowEraseEffectMsg identifying mPlayer goes out, and SendSeekerMsg() runs for the bar.
| pMsg | The message. |
|
protected |
Install the player a TrackSelectMsg for this track selects.
A real new player first gets a NowBarMsg at lane 0.5. A message with a zero second word installs the player, and a real player then has SendSeekerMsg() run for the message's bar.
| pMsg | The message. |
|
protected |
Play a gem at a pitch step.
The routine checks the bar, sends the riff transposed by nStep, records the gem, and announces it with several messages, among them a DurGemMsg and a PitchMsg.
| nGem | The gem, a PitchRiffMsg's first word. |
| nStep | The pitch step, zero from a PitchRiffMsg and -3 to 3 from PostNowBarMsg(). |
| nTick | The song position. |
|
protected |
Turn mPlayer's seeker off, unless mPlayer is the stand-in.
| nBar | Not read. |
|
protectedvirtual |
Act on a message.
Primary table slot 3.
| pMsg | The message. |
Implements MsgSink.