wavelength 1.0.0
Loading...
Searching...
No Matches
SynthPS2 Class Reference

Sound output of the console, a client of the synth and softfx IOP modules. More...

#include <synthps2.h>

Inheritance diagram for SynthPS2:
Collaboration diagram for SynthPS2:

Public Member Functions

void * operator new (size_t nSize)
 Allocate the object from the pool heaps under the tag "SynthPs2".
void operator delete (void *pBlock)
 Return the object to the pool heaps.
 SynthPS2 ()
 Build the output with every bank slot empty and the command buffers ready.
 ~SynthPS2 () override
 Release the command buffers.
int Init () override
 Read the lag, bind to the IOP modules, and start them.
int Terminate () override
 Stop the synthesiser module.
void ResetSpu () override
 Queue a reset of the sound processor.
int SendPackedMessage (unsigned int nPacked) override
 Send one packed message.
int SendMessage (unsigned char nByte0, unsigned char nByte1, unsigned char nByte2, int nByte3) override
 Send one message, or act on it at once.
void UpdateTime () override
 Read the system clock and shorten the delays of the queued messages by the time passed.
int Poll () override
 Run the frame's work and send the command buffers to the IOP modules.
StreamPlayer * GetStream () override
 Report the stream SetStream() set.
void SetStream (StreamPlayer *pStream) override
 Set the stream the output plays, and end the stream the software effect played.
void SendStreamData (const void *pData, int nSize) override
 Queue a run of stream data for the software effect and clear the room it reported.
int GetStreamStatus () override
 Report the room the software effect has for stream data.
int GetStreamFormat (int *pnRate, int *pnBlock) override
 Report the format of the stream data.
int Partition (const std::vector< int > &blocks) override
 Queue the division of the sound memory among the bank slots.
int GetBankBlockCount (const String &file) override
 Report the size of the audio data file of a bank in 64-byte blocks, rounded up.
bool IsBankLoaded (unsigned short nSlot) override
 Report whether a slot has a bank and no load into it is waiting.
int IsBankPresent (unsigned short nSlot) override
 Report whether a slot has a bank or a load into it is waiting.
int LoadBank (unsigned short nSlot, const String &file, bool bSkipPending) override
 Queue the load of a bank file into a slot.
int UnloadBank (unsigned short nSlot) override
 Empty a slot, or cancel the load into it.
void SetSurround (bool bSurround) override
 Choose whether the synthesiser may invert a channel for surround decoders.
void SetMono (bool bMono) override
 Choose mono output for the synthesiser and the stream.
void SetLag (float fLag) override
 Set the lag of the output.
float GetLag () override
 Report the lag of the output.
void SetSoftFxSweep (float fPosition) override
 Set the position of the sweep of a sweeping software filter.
void SetSoftFxModulation (float fValue) override
 Set the second control of the software effect.
void SetSoftFxFilter (const SoftFxFilter &filter) override
 Select the software effect and record its settings.
int EnableSoftFx () override
 Queue a job that turns the software effects on.
int DisableSoftFx () override
 Queue a job that turns the software effects off.
void SetOutputLevel (float fLevel) override
 Set the volume of the input the software effect captures.
float GetOutputLevel () override
 Report the level SetOutputLevel() set.
void SetSoftFxInput (int nInput) override
 Choose the mixer input of the sound processor that the software effect captures.
void SetBusToCoreFx (int nOn) override
 Set whether the voices feed the hardware effects.
void SetBusToSoftFx (int nOn) override
 Do nothing.
void SendMessages (const std::vector< unsigned int > &messages) override
 Queue a job that sends packed messages to set up the hardware effects.
void QueueCallback (Callback pfnCallback, int nArg) override
 Queue a job that calls a routine once the jobs before it have run.
Public Member Functions inherited from Synth
virtual ~Synth ()
 Vtable slot 4.
virtual int Unsupported ()
 Vtable slot 7.
virtual void VirtualSlot35 ()
 Vtable slot 35.

Static Public Attributes

static constexpr int kNumBankSlots = 7
 The number of bank slots of the synthesiser module.
static constexpr int kNumChannels = 16
 The number of MIDI channels, each with a smoothed volume.
static constexpr int kCommandBufferSize = 0x10000
 The size of each command buffer in bytes.
Static Public Attributes inherited from Synth
static constexpr int kNumChannels = 16
static constexpr int kNumCores = 2
static constexpr int kVoicesPerCore = 24
static constexpr int kMaxRetiredVoices = 50
static void * sNotifyAddress
static int sNotifyPending
static void * sEffectNotifyAddress
static int sEffectNotifyPending
static int sEffectThreadId
static unsigned char sInitFlag
static Channel sChannels [kNumChannels]

Additional Inherited Members

Public Types inherited from Synth
typedef void(* Callback) (int nArg)
 Routine a queued callback job calls with its argument.
Static Public Member Functions inherited from Synth
static void TickThread ()
 The tick thread.
static int ProcessMidiMessage (unsigned char status, unsigned char data1, unsigned char data2)
 Act on one MIDI channel message.
static void ProcessDueEvents ()
 Act on every queued MIDI message that is due, as one batch of key changes.
static int QueueTimedEvents (const MidiEvent *events, unsigned int count)
 Queue MIDI messages stamped with delays from now.
static int ProcessMidiStream (const unsigned char *data, unsigned int size)
 Act on a MIDI byte stream with running status.
static void SetMono (bool mono)
 Select mono output.
static void SetSurround (bool enabled)
 Allow or forbid the surround inversion of the descriptors that request it.
static void ResetAllControllers (unsigned char channel)
 Restore a channel's controllers to their defaults, except its monophonic switch.
static void Init ()
 Reset the banks, channels, and voices, then the SPU2.
static void ResetSpu ()
 Initialise the SPU2: the mixer, the reverb areas and settings, and the voice mix.
static int CombinePan (unsigned char channelPan, unsigned char programPan, unsigned char samplePan)
 Combine three pan offsets around the centre, clamped to zero to 127.
static bool ChannelHasProgram (unsigned char channel)
 Report whether a channel has a program it can play.
static void NoteOn (unsigned char note, unsigned char velocity, unsigned char channel)
 Start a note on every descriptor of the channel's program whose key range covers it.
static void NoteOff (unsigned char note, unsigned char channel)
 Stop the oldest sounding instance of a note.
static void SelectProgram (unsigned short channel, unsigned short program)
 Point a channel at the program of its bank with a program number.
static void ProgramChange (unsigned char channel, unsigned short program)
 Act on a program change unless the channel already plays that program number.
static void BankSelect (unsigned char channel, unsigned short bank)
 Point a channel at a loaded bank, retaining its program number.
static void UpdateChannelVolume (unsigned char channel)
 Rewrite the volume registers of a channel's sounding voices.
static void SetPan (unsigned char channel, unsigned char pan)
 Set a channel's pan.
static void SetVolume (unsigned char channel, unsigned char volume)
 Set a channel's volume.
static void SetExpression (unsigned char channel, unsigned char expression)
 Set a channel's expression.
static void SetPitchBend (unsigned char channel, signed char semitones, signed char cents)
 Set a channel's pitch bend.
static int LoadBankHeader (const unsigned char *data, unsigned short bank)
 Load a bank's header.
static int LoadPrograms (const unsigned char *data, short size, unsigned short bank)
 Load a bank's programs, each record preceded by a size word.
static int LoadSampleDescs (const unsigned char *data, short size, unsigned short bank)
 Load a bank's sample descriptors, each record preceded by a size word.
static int LoadSamples (const unsigned char *data, short size, unsigned short bank)
 Load a bank's samples, each record preceded by a size word.
static int TransferDone (int channel, void *data)
 Notify the EE at the next tick that a waveform transfer ended.
static int EffectsApplied ()
 Notify the EE at the next tick that a reverb update ended, when the EE requested it.
static int TransferSampleData (unsigned char *data, int size, unsigned int offset, unsigned short bank)
 Start a waveform transfer into a bank's SPU2 area.
static int SetBankSpuLayout (const unsigned char *data)
 Place the banks' SPU2 areas one after another.
static int SetBankLoaded (unsigned short bank)
 Mark a bank loaded.
static int UnloadBank (unsigned short bank)
 Silence a bank's voices, detach its channels, and empty it.
static void SetPriority (unsigned char channel, unsigned char priority)
 Set a channel's voice priority.
static void SetDetune (unsigned char channel, unsigned char detune)
 Set a channel's detune switch.
static void SetStereo (unsigned char channel, unsigned char stereo)
 Set a channel's stereo switch.
static void SetMonophonic (unsigned char channel, unsigned char monophonic)
 Set a channel's monophonic switch.
static void SetControllerEnable (unsigned char channel, unsigned char controller, unsigned char value)
 Switch the live update of one controller on or off for a channel.
static void SetTranspose (unsigned char channel, signed char semitones)
 Set a channel's transposition.
static void SetBusMode (unsigned char channel, unsigned char busMode)
 Set a channel's dry and reverb mix for later notes.
static void SetBus (unsigned char channel, unsigned char bus)
 Set a channel's preferred core for later notes.
static void AllNotesOff (unsigned char channel)
 Release a channel's notes and forget every retired voice.
static void EffectThread ()
 The reverb thread.
static void SetEffectParam (unsigned char channel, unsigned char value, unsigned char param)
 Set one reverb setting of a core from a controller.
static void CommitKeys ()
 Key off and then key on every voice the current batch collected.
static void ClearKeyMasks ()
 Start a batch of key changes.
static void Create ()
 Build TheSynth and initialise it.
static void Destroy ()
 Terminate TheSynth, destroy it, and clear the pointer.

Detailed Description

Sound output of the console, a client of the synth and softfx IOP modules.

The RTTI includes the class name and records Synth as the base. The object is 0x20180 bytes and is 64-byte aligned. Each frame, Poll() runs the queued jobs, advances the bank load, and sends the commands collected in the two command buffers to the modules, each buffer as one concatenated remote call. The synthesiser module plays the MIDI messages and the banks, and the software effect module runs the software filters and plays the stream of a StreamPlayer.

Constructor & Destructor Documentation

◆ SynthPS2()

SynthPS2::SynthPS2 ( )

Build the output with every bank slot empty and the command buffers ready.

The smoothing of the channel volumes is the volume_smoothing entry of the synth section.

Ghidra address:
NTSC-U/C: 0x0024bdc0
Ghidra address:
PAL: 0x00254800

◆ ~SynthPS2()

SynthPS2::~SynthPS2 ( )
override

Release the command buffers.

The queued jobs are not deleted.

Ghidra address:
NTSC-U/C: 0x0024ce18
Ghidra address:
PAL: 0x00255858

Member Function Documentation

◆ operator new()

void * SynthPS2::operator new ( size_t nSize)
inline

Allocate the object from the pool heaps under the tag "SynthPs2".

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.

◆ operator delete()

void SynthPS2::operator delete ( void * pBlock)
inline

Return the object to the pool heaps.

Parameters
pBlockThe block.

◆ Init()

int SynthPS2::Init ( )
overridevirtual

Read the lag, bind to the IOP modules, and start them.

Returns
0.
Ghidra address:
NTSC-U/C: 0x0024d2e0
Ghidra address:
PAL: 0x00255d10

Implements Synth.

◆ Terminate()

int SynthPS2::Terminate ( )
overridevirtual

Stop the synthesiser module.

Returns
0.
Ghidra address:
NTSC-U/C: 0x0024d1b0
Ghidra address:
PAL: 0x00255bf0

Implements Synth.

◆ ResetSpu()

void SynthPS2::ResetSpu ( )
overridevirtual

Queue a reset of the sound processor.

Ghidra address:
NTSC-U/C: 0x00250ea8
Ghidra address:
PAL: 0x00259858

Reimplemented from Synth.

◆ SendPackedMessage()

int SynthPS2::SendPackedMessage ( unsigned int nPacked)
overridevirtual

Send one packed message.

Parameters
nPackedThe four message bytes, lowest first.
Returns
0.
Ghidra address:
NTSC-U/C: 0x0024ecf8
Ghidra address:
PAL: 0x00257708

Implements Synth.

◆ SendMessage()

int SynthPS2::SendMessage ( unsigned char nByte0,
unsigned char nByte1,
unsigned char nByte2,
int nByte3 )
overridevirtual

Send one message, or act on it at once.

Control changes 12, 15, and 17 set the sweep of the software filter, the output level, and the target volume of the channel. Every other message joins the MIDI queue with its delay clamped to a byte.

Parameters
nByte0The status byte.
nByte1The first data byte.
nByte2The second data byte.
nByte3The delay in milliseconds.
Returns
0.
Ghidra address:
NTSC-U/C: 0x0024ea68
Ghidra address:
PAL: 0x00257478

Implements Synth.

◆ UpdateTime()

void SynthPS2::UpdateTime ( )
overridevirtual

Read the system clock and shorten the delays of the queued messages by the time passed.

Ghidra address:
NTSC-U/C: 0x0024ed58
Ghidra address:
PAL: 0x00257768

Implements Synth.

◆ Poll()

int SynthPS2::Poll ( )
overridevirtual

Run the frame's work and send the command buffers to the IOP modules.

A module still busy with the previous frame's call is skipped.

Returns
0.
Ghidra address:
NTSC-U/C: 0x0024ee10
Ghidra address:
PAL: 0x00257820

Implements Synth.

◆ GetStream()

StreamPlayer * SynthPS2::GetStream ( )
inlineoverridevirtual

Report the stream SetStream() set.

Returns
The stream, or null.
Ghidra address:
NTSC-U/C: 0x00396a18
Ghidra address:
PAL: 0x00405100

Reimplemented from Synth.

◆ SetStream()

void SynthPS2::SetStream ( StreamPlayer * pStream)
overridevirtual

Set the stream the output plays, and end the stream the software effect played.

Parameters
pStreamThe stream, or null.
Ghidra address:
NTSC-U/C: 0x0024faa0
Ghidra address:
PAL: 0x00258490

Reimplemented from Synth.

◆ SendStreamData()

void SynthPS2::SendStreamData ( const void * pData,
int nSize )
overridevirtual

Queue a run of stream data for the software effect and clear the room it reported.

Parameters
pDataThe data.
nSizeThe size of the data in bytes. 0 ends the stream.
Ghidra address:
NTSC-U/C: 0x0024fae0
Ghidra address:
PAL: 0x002584d0

Reimplemented from Synth.

◆ GetStreamStatus()

int SynthPS2::GetStreamStatus ( )
overridevirtual

Report the room the software effect has for stream data.

Returns
The room in bytes.
Ghidra address:
NTSC-U/C: 0x00250d98
Ghidra address:
PAL: 0x00259748

Reimplemented from Synth.

◆ GetStreamFormat()

int SynthPS2::GetStreamFormat ( int * pnRate,
int * pnBlock )
overridevirtual

Report the format of the stream data.

Parameters
pnRateReceives 28351.
pnBlockReceives 64.
Returns
0.
Ghidra address:
NTSC-U/C: 0x0024f968
Ghidra address:
PAL: 0x00258358

Implements Synth.

◆ Partition()

int SynthPS2::Partition ( const std::vector< int > & blocks)
overridevirtual

Queue the division of the sound memory among the bank slots.

Parameters
blocksThe size of each bank slot in 64-byte blocks.
Returns
0.
Ghidra address:
NTSC-U/C: 0x0024f9b8
Ghidra address:
PAL: 0x002583a8

Implements Synth.

◆ GetBankBlockCount()

int SynthPS2::GetBankBlockCount ( const String & file)
overridevirtual

Report the size of the audio data file of a bank in 64-byte blocks, rounded up.

Parameters
fileThe bank file.
Returns
The number of blocks.
Ghidra address:
NTSC-U/C: 0x0024e4f8
Ghidra address:
PAL: 0x00256f28

Implements Synth.

◆ IsBankLoaded()

bool SynthPS2::IsBankLoaded ( unsigned short nSlot)
overridevirtual

Report whether a slot has a bank and no load into it is waiting.

Parameters
nSlotThe bank slot.
Returns
Whether the bank is loaded.
Ghidra address:
NTSC-U/C: 0x0024cfd0
Ghidra address:
PAL: 0x00255a10

Implements Synth.

◆ IsBankPresent()

int SynthPS2::IsBankPresent ( unsigned short nSlot)
overridevirtual

Report whether a slot has a bank or a load into it is waiting.

Parameters
nSlotThe bank slot.
Returns
1 when the slot has a bank or a pending load, otherwise 0.
Ghidra address:
NTSC-U/C: 0x0024d0b8
Ghidra address:
PAL: 0x00255af8

Reimplemented from Synth.

◆ LoadBank()

int SynthPS2::LoadBank ( unsigned short nSlot,
const String & file,
bool bSkipPending )
overridevirtual

Queue the load of a bank file into a slot.

Parameters
nSlotThe bank slot.
fileThe bank file.
bSkipPendingDo nothing when a load into the slot is already waiting.
Returns
0.
Ghidra address:
NTSC-U/C: 0x0024e750
Ghidra address:
PAL: 0x00257180

Implements Synth.

◆ UnloadBank()

int SynthPS2::UnloadBank ( unsigned short nSlot)
overridevirtual

Empty a slot, or cancel the load into it.

A load that is under way is aborted and the slot emptied after it. A load still waiting is taken off the queue, and the job is not deleted.

Parameters
nSlotThe bank slot.
Returns
0.
Ghidra address:
NTSC-U/C: 0x0024e0b0
Ghidra address:
PAL: 0x00256ae0

Implements Synth.

◆ SetSurround()

void SynthPS2::SetSurround ( bool bSurround)
overridevirtual

Choose whether the synthesiser may invert a channel for surround decoders.

Parameters
bSurroundWhether the inversion is allowed.
Ghidra address:
NTSC-U/C: 0x00250db8
Ghidra address:
PAL: 0x00259768

Reimplemented from Synth.

◆ SetMono()

void SynthPS2::SetMono ( bool bMono)
overridevirtual

Choose mono output for the synthesiser and the stream.

Parameters
bMonoWhether the output is mono.
Ghidra address:
NTSC-U/C: 0x00250df0
Ghidra address:
PAL: 0x002597a0

Reimplemented from Synth.

◆ SetLag()

void SynthPS2::SetLag ( float fLag)
overridevirtual

Set the lag of the output.

Parameters
fLagThe lag in milliseconds.
Ghidra address:
NTSC-U/C: 0x0024d2d0
Ghidra address:
PAL: 0x00255d00

Reimplemented from Synth.

◆ GetLag()

float SynthPS2::GetLag ( )
overridevirtual

Report the lag of the output.

Returns
The lag in milliseconds.
Ghidra address:
NTSC-U/C: 0x0024d2d8
Ghidra address:
PAL: 0x00255d08

Reimplemented from Synth.

◆ SetSoftFxSweep()

void SynthPS2::SetSoftFxSweep ( float fPosition)
overridevirtual

Set the position of the sweep of a sweeping software filter.

Another filter type is reported and the position is not changed.

Parameters
fPositionThe position, from -1 to 1.
Ghidra address:
NTSC-U/C: 0x0024fbe8
Ghidra address:
PAL: 0x002585c8

Reimplemented from Synth.

◆ SetSoftFxModulation()

void SynthPS2::SetSoftFxModulation ( float fValue)
overridevirtual

Set the second control of the software effect.

Parameters
fValueThe value, from -1 to 1.
Ghidra address:
NTSC-U/C: 0x0024fbd8
Ghidra address:
PAL: 0x002585b8

Reimplemented from Synth.

◆ SetSoftFxFilter()

void SynthPS2::SetSoftFxFilter ( const SoftFxFilter & filter)
overridevirtual

Select the software effect and record its settings.

The output level returns to full. A sweeping filter starts its sweep at the ratio of its initial frequency to its ceiling, and a chorus restarts the oscillators of its taps.

Parameters
filterThe settings.
Ghidra address:
NTSC-U/C: 0x0024fc58
Ghidra address:
PAL: 0x00258638

Reimplemented from Synth.

◆ EnableSoftFx()

int SynthPS2::EnableSoftFx ( )
overridevirtual

Queue a job that turns the software effects on.

Returns
0.
Ghidra address:
NTSC-U/C: 0x0024f630
Ghidra address:
PAL: 0x00258020

Implements Synth.

◆ DisableSoftFx()

int SynthPS2::DisableSoftFx ( )
overridevirtual

Queue a job that turns the software effects off.

Returns
0.
Ghidra address:
NTSC-U/C: 0x0024f8a0
Ghidra address:
PAL: 0x00258290

Implements Synth.

◆ SetOutputLevel()

void SynthPS2::SetOutputLevel ( float fLevel)
overridevirtual

Set the volume of the input the software effect captures.

Parameters
fLevelThe level, 1 for full.
Ghidra address:
NTSC-U/C: 0x00250c10
Ghidra address:
PAL: 0x002595c0

Reimplemented from Synth.

◆ GetOutputLevel()

float SynthPS2::GetOutputLevel ( )
overridevirtual

Report the level SetOutputLevel() set.

Returns
The level, 1 for full.
Ghidra address:
NTSC-U/C: 0x00250cb0
Ghidra address:
PAL: 0x00259660

Reimplemented from Synth.

◆ SetSoftFxInput()

void SynthPS2::SetSoftFxInput ( int nInput)
overridevirtual

Choose the mixer input of the sound processor that the software effect captures.

Parameters
nInputThe input pair, 0 to 2.
Ghidra address:
NTSC-U/C: 0x002508f0
Ghidra address:
PAL: 0x002592a0

Reimplemented from Synth.

◆ SetBusToCoreFx()

void SynthPS2::SetBusToCoreFx ( int nOn)
overridevirtual

Set whether the voices feed the hardware effects.

Parameters
nOnWhether the voices feed the hardware effects.
Ghidra address:
NTSC-U/C: 0x00250970
Ghidra address:
PAL: 0x00259320

Reimplemented from Synth.

◆ SetBusToSoftFx()

void SynthPS2::SetBusToSoftFx ( int nOn)
overridevirtual

Do nothing.

Parameters
nOnUnused.
Ghidra address:
NTSC-U/C: 0x002509f0
Ghidra address:
PAL: 0x002593a0

Reimplemented from Synth.

◆ SendMessages()

void SynthPS2::SendMessages ( const std::vector< unsigned int > & messages)
overridevirtual

Queue a job that sends packed messages to set up the hardware effects.

Parameters
messagesThe messages.
Ghidra address:
NTSC-U/C: 0x002509f8
Ghidra address:
PAL: 0x002593a8

Reimplemented from Synth.

◆ QueueCallback()

void SynthPS2::QueueCallback ( Callback pfnCallback,
int nArg )
overridevirtual

Queue a job that calls a routine once the jobs before it have run.

Parameters
pfnCallbackThe routine.
nArgThe argument passed to the routine.
Ghidra address:
NTSC-U/C: 0x0024f700
Ghidra address:
PAL: 0x002580f0

Reimplemented from Synth.

Member Data Documentation

◆ kNumBankSlots

int SynthPS2::kNumBankSlots = 7
staticconstexpr

The number of bank slots of the synthesiser module.

◆ kNumChannels

int SynthPS2::kNumChannels = 16
staticconstexpr

The number of MIDI channels, each with a smoothed volume.

◆ kCommandBufferSize

int SynthPS2::kCommandBufferSize = 0x10000
staticconstexpr

The size of each command buffer in bytes.


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