resonance 1.0.1
Loading...
Searching...
No Matches
Synth Class Referenceabstract

Abstract base of the game's sound output. More...

#include <synth.h>

Inheritance diagram for Synth:
Collaboration diagram for Synth:

Public Member Functions

virtual ~Synth ()
virtual void LoadBankSet4 ()
 Load one of the three bank sets.
virtual void LoadBankSet5 ()
 Load one of the three bank sets.
virtual void LoadBankSet6 ()
 Load one of the three bank sets.
virtual void UnusedHook ()
 Do nothing.
virtual void UnloadBanks ()
 Release every loaded bank.
virtual void PlayMidi (unsigned char nStatus, unsigned char nData1, unsigned char nData2)=0
 Move one MIDI message to the hardware.
virtual void OnPlayStarted ()
 Respond to the start of play.
virtual void SelectBank (unsigned char nChannel, unsigned char nBank)
 Select a bank on one channel.
virtual void SetStereo (int bStereo)
 Switch between stereo and mono output.
virtual void SetRemixMode (int bRemix)
 Switch the remix mode of the sound driver.
virtual void SetPaused (int bPaused)
 Pause or resume the sound driver.
virtual void AllNotesOff ()
 Silence every channel.
virtual void AllNotesOffExceptSfxChannel ()
 Silence every channel but the sound-effect channel.
void SetChannelVolume (unsigned char nVolume)
 Set the volume of every channel.
void Setup ()
 Put every channel into its starting state.
void FadeOut (int nDurationMs)
 Fade every channel's volume to silence over a duration.
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.

Protected Member Functions

void OnStdMidi (StdMidiMsg *pMsg)
 Sends the message's three bytes through PlayMidi().
virtual void DispatchPriv (Message *pMsg)
 Act on a message.

Detailed Description

Abstract base of the game's sound output.

Its RTTI descriptor is at 0x008ef430. It has MsgSink as its one base. Its own vtable is at 0x007d2ee0 and runs seventeen entries, slots 0 through 16. Slot 9 addresses the shared pure-virtual stub at 0x005381a8, which is what makes the class abstract. Two classes implement it. Ps2HardSynth drives the hardware, and the file-local Synth::Setup::NullSynth at 0x008eecf8 supplies an empty body for slot 9 at 0x0013a478 and inherits everything else. A third file-local class, Synth::Setup::SynthFade at 0x008eebe8, derives from TimeTask rather than from this class.

The interface is a MIDI port. Slot 9 moves one three-byte MIDI message to the hardware and every other member of the class is expressed through it, which is what fixes the meaning of the whole interface. AllNotesOff() sends controller 123 on all sixteen channels, AllNotesOffExceptSfxChannel() sends the same on channels 0 through 14, SetChannelVolume() sends controller 7, and SelectBank() sends controllers 0 and 32. Channel 15 is the sound-effect channel, which the channel count of AllNotesOffExceptSfxChannel() and the separate channel-15 program selection in Ps2HardSynth's three bank loaders both attest.

The bodies of slots 4 through 8 and 10 through 14 are two-instruction bare returns in this class and are therefore its defaults rather than pure members. Slots 15 and 16 have real bodies here.

Ps2HardSynth's table has eighteen slots and adds one of its own at slot 17, which is consistent with the two implementations being siblings rather than one deriving from the other.

The verb of slots 7, 10, 12, 13, and 14 is unrecovered, and of slots 4, 5, and 6 only the shape is. No string in the image identifies any member of this class, so each of those declarations records its table index and its address rather than an invented title. They are declared because omitting a slot would shift every later index and state something false about the layout.

Globals owns the single instance, created in Globals::CreateSynth() and destroyed in Globals::Shutdown().

Constructor & Destructor Documentation

◆ ~Synth()

virtual Synth::~Synth ( )
virtual
Ghidra address:
NTSC-U/C: 0x0013a398
Ghidra address:
PAL: 0x0013ace0

Member Function Documentation

◆ LoadBankSet4()

virtual void Synth::LoadBankSet4 ( )
virtual

Load one of the three bank sets.

Table slot 4. The body here is empty. Ps2HardSynth's override at 0x003f47b8 unloads what is resident, loads the pair of bank paths the configuration reports under codes 500 and 501 at placement 0, turns the reverb off, and selects the sound-effect programs. Which of the three bank sets this is remains unrecovered, because the configuration codes are numeric and no table in the image maps a code to a name.

Ghidra address:
NTSC-U/C: 0x0013a1d0
Ghidra address:
PAL: 0x0013ab18

Reimplemented in Ps2HardSynth.

◆ LoadBankSet5()

virtual void Synth::LoadBankSet5 ( )
virtual

Load one of the three bank sets.

Table slot 5. The body here is empty. Ps2HardSynth's override at 0x003f4960 loads the pair under codes 507 and 508 at placement 1 and then resets.

Ghidra address:
NTSC-U/C: 0x0013a1d8
Ghidra address:
PAL: 0x0013ab20

Reimplemented in Ps2HardSynth.

◆ LoadBankSet6()

virtual void Synth::LoadBankSet6 ( )
virtual

Load one of the three bank sets.

Table slot 6. The body here is empty. Ps2HardSynth's override at 0x003f4af0 loads the pair under codes 504 and 505 at the rotating placement, turns the reverb on, and then resets.

Ghidra address:
NTSC-U/C: 0x0013a1e0
Ghidra address:
PAL: 0x0013ab28

Reimplemented in Ps2HardSynth.

◆ UnusedHook()

virtual void Synth::UnusedHook ( )
virtual

Do nothing.

Table slot 7. The body is empty here, no implementation overrides it, and the image never calls it. The image does not reveal its purpose.

Ghidra address:
NTSC-U/C: 0x0013a1e8
Ghidra address:
PAL: 0x0013ab30

◆ UnloadBanks()

virtual void Synth::UnloadBanks ( )
virtual

Release every loaded bank.

Table slot 8. The body here is empty. Ps2HardSynth's override at 0x003f6650 hands off to the driver routine at 0x00464660, which waits for the transfers in flight, releases the streaming voice, and clears both stored bank paths.

Ghidra address:
NTSC-U/C: 0x0013a1f0
Ghidra address:
PAL: 0x0013ab38

Reimplemented in Ps2HardSynth.

◆ PlayMidi()

virtual void Synth::PlayMidi ( unsigned char nStatus,
unsigned char nData1,
unsigned char nData2 )
pure virtual

Move one MIDI message to the hardware.

Table slot 9, and the one pure member of the class. Every other member reaches the hardware through this one. Ps2HardSynth's override at 0x003f66d8 masks each argument to a byte and hands the three to the driver at 0x00464928, which suppresses a program change or a bank select that repeats what the channel already holds and packs the rest into one word for the sound driver.

Parameters
nStatusThe status byte, a command nibble ORed with the channel.
nData1The first data byte.
nData2The second data byte.

Implemented in Ps2HardSynth.

◆ OnPlayStarted()

virtual void Synth::OnPlayStarted ( )
virtual

Respond to the start of play.

Table slot 10. The body is empty here and no implementation overrides it. GrooveWorld calls it once play starts.

Ghidra address:
NTSC-U/C: 0x0013a1f8
Ghidra address:
PAL: 0x0013ab40

◆ SelectBank()

virtual void Synth::SelectBank ( unsigned char nChannel,
unsigned char nBank )
virtual

Select a bank on one channel.

Table slot 11. The body here is empty. Ps2HardSynth's override at 0x003f65c8 sends controller 0 with value 0 and then controller 32 with the bank, which is the two halves of a MIDI bank select. That override performs no work unless the alternate bank set is resident.

Parameters
nChannelThe channel.
nBankThe bank, sent as the low half of the bank select.
Ghidra address:
NTSC-U/C: 0x0013a200
Ghidra address:
PAL: 0x0013ab48

Reimplemented in Ps2HardSynth.

◆ SetStereo()

virtual void Synth::SetStereo ( int bStereo)
virtual

Switch between stereo and mono output.

Table slot 12. The body is empty here. Ps2HardSynth's override at 0x003f6700 submits the sound driver's mono command with the argument inverted.

Parameters
bStereoNonzero for stereo output, zero for mono.
Ghidra address:
NTSC-U/C: 0x0013a208
Ghidra address:
PAL: 0x0013ab50

Reimplemented in Ps2HardSynth.

◆ SetRemixMode()

virtual void Synth::SetRemixMode ( int bRemix)
virtual

Switch the remix mode of the sound driver.

Table slot 13. The body is empty here. Ps2HardSynth's override at 0x003f6740 submits the sound driver's remix command with the argument unchanged.

Parameters
bRemixNonzero in jam mode, zero otherwise.
Ghidra address:
NTSC-U/C: 0x0013a210
Ghidra address:
PAL: 0x0013ab58

Reimplemented in Ps2HardSynth.

◆ SetPaused()

virtual void Synth::SetPaused ( int bPaused)
virtual

Pause or resume the sound driver.

Table slot 14. The body is empty here. Ps2HardSynth's override at 0x003f6720 submits the sound driver's pause command with the argument unchanged.

Parameters
bPausedNonzero to pause, zero to resume.
Ghidra address:
NTSC-U/C: 0x0013a218
Ghidra address:
PAL: 0x0013ab60

Reimplemented in Ps2HardSynth.

◆ AllNotesOff()

virtual void Synth::AllNotesOff ( )
virtual

Silence every channel.

Table slot 15. Sends controller 123 with value 0 on channels 0 through 15. Ps2HardSynth's override at 0x003f4c50 calls this body first and then resets the rest of the channel state.

Ghidra address:
NTSC-U/C: 0x0013a220
Ghidra address:
PAL: 0x0013ab68

Reimplemented in Ps2HardSynth.

◆ AllNotesOffExceptSfxChannel()

virtual void Synth::AllNotesOffExceptSfxChannel ( )
virtual

Silence every channel but the sound-effect channel.

Table slot 16. The same as AllNotesOff() over channels 0 through 14, which retains whatever is sounding on channel 15. Neither implementation overrides it.

Ghidra address:
NTSC-U/C: 0x0013a288
Ghidra address:
PAL: 0x0013abd0

◆ SetChannelVolume()

void Synth::SetChannelVolume ( unsigned char nVolume)

Set the volume of every channel.

Sends controller 7 with the given value on channels 0 through 15. The member is not virtual and occupies no table slot. Ps2HardSynth's AllNotesOff() override calls it with 100.

Parameters
nVolumeThe volume, 0 through 127.
Ghidra address:
NTSC-U/C: 0x0013a2f0
Ghidra address:
PAL: 0x0013ac38

◆ Setup()

void Synth::Setup ( )

Put every channel into its starting state.

On each of the sixteen channels, centres the pitch bend, resets every controller, silences every note, sets the channel volume to 100, and sets the expression to 127. The member is not virtual and nothing in the image calls it. It is the first routine of the unit, and the anonymous namespace of the unit takes its _GLOBAL_$N$Setup__5Synth prefix from it, which is what recovers the title.

Ghidra address:
NTSC-U/C: 0x00139fd0
Ghidra address:
PAL: 0x0013a918

◆ FadeOut()

void Synth::FadeOut ( int nDurationMs)

Fade every channel's volume to silence over a duration.

Creates a file-local SynthFade task on the watchdog time base, which samples a fade-out Source every 100 milliseconds and sends the scaled volume to all sixteen channels, then silences every note once the volume reaches zero. GrooveWorld::Exit() and MetLoadGameScreen's slot 33 are the callers. The title is inferred.

Parameters
nDurationMsThe length of the fade, in milliseconds.
Ghidra address:
NTSC-U/C: 0x0013a480
Ghidra address:
PAL: 0x0013adc8

◆ OnStdMidi()

void Synth::OnStdMidi ( StdMidiMsg * pMsg)
protected

Sends the message's three bytes through PlayMidi().

DispatchPriv() expands it inline. The address is the out-of-line copy.

Ghidra address:
NTSC-U/C: 0x0013a360
Ghidra address:
PAL: 0x0013aca8

◆ DispatchPriv()

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

Act on a message.

Table slot 3. Accepts StdMidiMsg alone and hands its three payload bytes to PlayMidi(). Neither implementation overrides it.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x0013a570
Ghidra address:
PAL: 0x0013aeb8

Implements MsgSink.


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