45 void *
operator new(
size_t nSize) {
46 return PoolMemAlloc(
static_cast<int>(nSize),
"SynthPs2", 0);
54 void operator delete(
void *pBlock) {
129 unsigned char nByte1,
130 unsigned char nByte2,
131 int nByte3)
override;
252 int LoadBank(
unsigned short nSlot,
const String &file,
bool bSkipPending)
override;
421 kCommandTerminate = 101,
422 kCommandSetBankLayout = 102,
423 kCommandSetBankLoaded = 103,
424 kCommandUnloadBank = 104,
425 kCommandTransferSamples = 105,
426 kCommandLoadBankHeader = 106,
427 kCommandLoadPrograms = 107,
428 kCommandLoadSampleDescs = 108,
429 kCommandLoadSamples = 109,
430 kCommandQueueEvents = 110,
431 kCommandConcatenation = 113,
433 kCommandSurround = 115,
434 kCommandResetSpu = 116,
459 kLoadSampleDescs = 5,
462 kFindSampleDescs = 8,
463 kTransferAudioData = 9,
471 struct BankDataCommand {
477 union CommandBuffer {
478 BankDataCommand mLastHeader;
492 struct SoftFxParams {
497 SoftFxTap mTaps[kNumTaps];
507 int ReadStreamStatus();
515 static void ClearStreamStatus();
526 void SendCommand(
int nCommand,
const void *pData,
int nSize);
544 void UpdateVolumes();
562 bool IsSoftFxRpcBusy();
571 bool IsTransferDone();
579 void SetTransferPending();
596 void SetCoreFxPending();
615 int SendBankLoaded(
unsigned short nSlot);
625 int SendUnloadBank(
unsigned short nSlot);
636 int StartBankLoad(
unsigned short nSlot,
const String &file);
649 int SendBankData(
const std::vector<unsigned char> &data,
int nBank,
int nCommand,
int nOffset);
660 int SendBankHeader(
const std::vector<unsigned char> &data,
int nBank);
671 int SendPrograms(
const std::vector<unsigned char> &data,
int nBank);
682 int SendSampleDescs(
const std::vector<unsigned char> &data,
int nBank);
693 int SendSamples(
const std::vector<unsigned char> &data,
int nBank);
705 int SendSampleData(
const std::vector<unsigned char> &data,
int nOffset,
int nBank) {
706 SetTransferPending();
707 (void)SendBankData(data, nBank, kCommandTransferSamples, nOffset);
726 void AdjustDelays(
int nBias);
745 void SendSoftFxEnable(
int nEnable);
755 int SendPartition(
const std::vector<int> &blocks);
782 void SendMessageList(
const std::vector<unsigned int> &messages);
791 void SetSweepFromController(
unsigned char nValue);
800 void SetLevelFromController(
unsigned char nValue);
810 bool HasPendingLoad(
unsigned short nSlot);
812 std::vector<bool> mBankLoaded;
813 std::list<std::unique_ptr<QueuedJob>> mJobs;
815 std::vector<unsigned char> mChunk;
816 std::unique_ptr<BankFileIO> mBankFile;
818 std::vector<unsigned int> mMidiQueue;
824 std::unique_ptr<BufStream> mCommands;
825 std::unique_ptr<BufStream> mSoftFxCommands;
826 alignas(64) CommandBuffer mCommandBuffer;
827 CommandBuffer mSoftFxBuffer;
828 StreamPlayer *mStream;
831 float mSoftFxModulation;
833 SoftFxFilter mFilter;
834 Lfo mTapOscillators[kNumTaps];
835 std::vector<OnePoleFilter> mChannelVolumes;
838 int mAudioDataOffset;
839 std::vector<unsigned char> mAudioData;
Reader of a bank file and the audio data file beside it.
Definition bankfileio.h:36
Stream of sound data read from a file and handed to the sound output a run at a time.
Definition streamplayer.h:13
Growable text buffer that is also a PrnStream.
Definition string.h:19
static constexpr int kNumBankSlots
The number of bank slots of the synthesiser module.
Definition synthps2.h:31
int GetStreamStatus() override
Report the room the software effect has for stream data.
int IsBankPresent(unsigned short nSlot) override
Report whether a slot has a bank or a load into it is waiting.
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.
bool IsBankLoaded(unsigned short nSlot) override
Report whether a slot has a bank and no load into it is waiting.
int EnableSoftFx() override
Queue a job that turns the software effects on.
~SynthPS2() override
Release the command buffers.
void SetSoftFxModulation(float fValue) override
Set the second control of the software effect.
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 DisableSoftFx() override
Queue a job that turns the software effects off.
int GetBankBlockCount(const String &file) override
Report the size of the audio data file of a bank in 64-byte blocks, rounded up.
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.
SynthPS2()
Build the output with every bank slot empty and the command buffers ready.
int SendPackedMessage(unsigned int nPacked) override
Send one packed message.
void SetSoftFxInput(int nInput) override
Choose the mixer input of the sound processor that the software effect captures.
float GetLag() override
Report the lag of the output.
void SetSoftFxFilter(const SoftFxFilter &filter) override
Select the software effect and record its settings.
int Partition(const std::vector< int > &blocks) override
Queue the division of the sound memory among the bank slots.
int Terminate() override
Stop the synthesiser module.
int GetStreamFormat(int *pnRate, int *pnBlock) override
Report the format of the stream data.
void SetMono(bool bMono) override
Choose mono output for the synthesiser and the stream.
void ResetSpu() override
Queue a reset of the sound processor.
void SetBusToCoreFx(int nOn) override
Set whether the voices feed the hardware effects.
void SetSurround(bool bSurround) override
Choose whether the synthesiser may invert a channel for surround decoders.
int UnloadBank(unsigned short nSlot) override
Empty a slot, or cancel the load into it.
void SetOutputLevel(float fLevel) override
Set the volume of the input the software effect captures.
float GetOutputLevel() override
Report the level SetOutputLevel() set.
void SetStream(StreamPlayer *pStream) override
Set the stream the output plays, and end the stream the software effect played.
int LoadBank(unsigned short nSlot, const String &file, bool bSkipPending) override
Queue the load of a bank file into a slot.
void SetSoftFxSweep(float fPosition) override
Set the position of the sweep of a sweeping software filter.
static constexpr int kNumChannels
The number of MIDI channels, each with a smoothed volume.
Definition synthps2.h:34
void QueueCallback(Callback pfnCallback, int nArg) override
Queue a job that calls a routine once the jobs before it have run.
static constexpr int kCommandBufferSize
The size of each command buffer in bytes.
Definition synthps2.h:37
int Init() override
Read the lag, bind to the IOP modules, and start them.
StreamPlayer * GetStream() override
Report the stream SetStream() set.
Definition synthps2.h:159
int SendMessage(unsigned char nByte0, unsigned char nByte1, unsigned char nByte2, int nByte3) override
Send one message, or act on it at once.
void SetLag(float fLag) override
Set the lag of the output.
The MIDI synthesiser that drives the SPU2 voices.
Definition synth.h:19
void(* Callback)(int nArg)
Routine a queued callback job calls with its argument.
Definition synth.h:439
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
SoftFxCommand
RPC function numbers.
Definition softfx.h:14
@ kSoftFxCommandStart
Definition softfx.h:17
@ kSoftFxCommandRouteVoices
Definition softfx.h:25
@ kSoftFxCommandConcatenation
Definition softfx.h:23
@ kSoftFxCommandSetVolume
Definition softfx.h:26
@ kSoftFxCommandStreamData
Definition softfx.h:20
@ kSoftFxCommandSetParams
Definition softfx.h:22
@ kSoftFxCommandInit
Definition softfx.h:15
@ kSoftFxCommandRouteInput
Definition softfx.h:24
@ kSoftFxCommandSetEffect
Definition softfx.h:21
@ kSoftFxCommandSetMonoStream
Definition softfx.h:27
@ kSoftFxCommandStop
Definition softfx.h:18
Settings of the software effect, read from the filter entry of the first effect bus.
Definition softfxfilter.h:9
static constexpr int kNumTaps
The number of delay taps of a kTypeChorus effect.
Definition softfxfilter.h:26