resonance 1.0.1
Loading...
Searching...
No Matches
Scratcher Class Reference

Pitcher that drives the scratch track. More...

#include <scratcher.h>

Inheritance diagram for Scratcher:
Collaboration diagram for Scratcher:

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ Scratcher()

Scratcher::Scratcher ( PhraseMgr * pPhraseMgr,
Quantizer * pQuantizer,
Sch::TickClock * pClock,
const TrackData * pTrackData )

Construct a scratcher for one track.

Parameters
pPhraseMgrThe phrase manager for the track.
pQuantizerThe quantiser for the track.
pClockThe clock the producer schedules against.
pTrackDataThe track description.
Ghidra address:
NTSC-U/C: 0x001cf988
Ghidra address:
PAL: 0x001d5840

◆ ~Scratcher()

virtual Scratcher::~Scratcher ( )
virtual
Ghidra address:
NTSC-U/C: 0x001d1bf0
Ghidra address:
PAL: 0x001d7aa8

Member Function Documentation

◆ Tick()

virtual int Scratcher::Tick ( int nElapsedTicks)
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.

Parameters
nElapsedTicksTicks since the epoch.
Returns
1 always.
Ghidra address:
NTSC-U/C: 0x001d1d68
Ghidra address:
PAL: 0x001d7c20

Implements TickTask.

◆ PostNowBarMsg()

void Scratcher::PostNowBarMsg ( AxisRegisterMsg * pMsg)
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.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x001cfd20
Ghidra address:
PAL: 0x001d5bd8

◆ EraseGemRange()

void Scratcher::EraseGemRange ( EraseMsg * pMsg)
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.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x001d0038
Ghidra address:
PAL: 0x001d5ef0

◆ OnTrackSelect()

void Scratcher::OnTrackSelect ( TrackSelectMsg * pMsg)
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.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x001d0248
Ghidra address:
PAL: 0x001d6100

◆ OnPitchRiff()

void Scratcher::OnPitchRiff ( int nGem,
int nStep,
int nTick )
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.

Parameters
nGemThe gem, a PitchRiffMsg's first word.
nStepThe pitch step, zero from a PitchRiffMsg and -3 to 3 from PostNowBarMsg().
nTickThe song position.
Ghidra address:
NTSC-U/C: 0x001d0358
Ghidra address:
PAL: 0x001d6210

◆ SendSeekerMsg()

void Scratcher::SendSeekerMsg ( int nBar) const
protected

Turn mPlayer's seeker off, unless mPlayer is the stand-in.

Parameters
nBarNot read.
Ghidra address:
NTSC-U/C: 0x001d08e0
Ghidra address:
PAL: 0x001d6798

◆ DispatchPriv()

virtual void Scratcher::DispatchPriv ( Message * pMsg)
protectedvirtual

Act on a message.

Primary table slot 3.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x001d0980
Ghidra address:
PAL: 0x001d6838

Implements MsgSink.


The documentation for this class was generated from the following file: