|
wavelength 1.0.0
|
The MIDI synthesiser that drives the SPU2 voices. More...
#include <synth.h>


Public Types | |
| typedef void(* | Callback) (int nArg) |
| Routine a queued callback job calls with its argument. | |
Public Member Functions | |
| virtual int | Init ()=0 |
| Vtable slot 1. | |
| virtual int | Terminate ()=0 |
| Vtable slot 2. | |
| virtual void | ResetSpu () |
| Vtable slot 3. | |
| virtual | ~Synth () |
| Vtable slot 4. | |
| virtual int | SendPackedMessage (unsigned int nPacked)=0 |
| Vtable slot 5. | |
| virtual int | SendMessage (unsigned char nByte0, unsigned char nByte1, unsigned char nByte2, int nByte3)=0 |
| Vtable slot 6. | |
| virtual int | Unsupported () |
| Vtable slot 7. | |
| virtual void | UpdateTime ()=0 |
| Vtable slot 8. | |
| virtual int | Poll ()=0 |
| Vtable slot 9. | |
| virtual StreamPlayer * | GetStream () |
| Vtable slot 10. | |
| virtual void | SetStream (StreamPlayer *pStream) |
| Vtable slot 11. | |
| virtual void | SendStreamData (const void *pData, int nSize) |
| Vtable slot 12. | |
| virtual int | GetStreamStatus () |
| Vtable slot 13. | |
| virtual int | GetStreamFormat (int *pnRate, int *pnBlock)=0 |
| Vtable slot 14, pure in this class. | |
| virtual int | Partition (const std::vector< int > &blocks)=0 |
| Vtable slot 15. | |
| virtual int | GetBankBlockCount (const String &file)=0 |
| Vtable slot 16. | |
| virtual bool | IsBankLoaded (unsigned short nSlot)=0 |
| Vtable slot 17. | |
| virtual int | IsBankPresent (unsigned short nSlot) |
| Vtable slot 18. | |
| virtual int | LoadBank (unsigned short nSlot, const String &file, bool bSkipPending)=0 |
| Vtable slot 19. | |
| virtual int | UnloadBank (unsigned short nSlot)=0 |
| Vtable slot 20. | |
| virtual void | SetSurround (bool bSurround) |
| Vtable slot 21. | |
| virtual void | SetMono (bool bMono) |
| Vtable slot 22. | |
| virtual void | SetLag (float fLag) |
| Vtable slot 23. | |
| virtual float | GetLag () |
| Vtable slot 24. | |
| virtual void | SetSoftFxSweep (float fPosition) |
| Vtable slot 25. | |
| virtual void | SetSoftFxModulation (float fValue) |
| Vtable slot 26. | |
| virtual void | SetSoftFxFilter (const SoftFxFilter &filter) |
| Vtable slot 27. | |
| virtual int | EnableSoftFx ()=0 |
| Vtable slot 28. | |
| virtual int | DisableSoftFx ()=0 |
| Vtable slot 29. | |
| virtual void | SetOutputLevel (float fLevel) |
| Vtable slot 30. | |
| virtual float | GetOutputLevel () |
| Vtable slot 31. | |
| virtual void | SetSoftFxInput (int nInput) |
| Vtable slot 32. | |
| virtual void | SetBusToCoreFx (int nOn) |
| Vtable slot 33. | |
| virtual void | SetBusToSoftFx (int nOn) |
| Vtable slot 34. | |
| virtual void | VirtualSlot35 () |
| Vtable slot 35. | |
| virtual void | SendMessages (const std::vector< unsigned int > &messages) |
| Vtable slot 36. | |
| virtual void | QueueCallback (Callback pfnCallback, int nArg) |
| Vtable slot 37. | |
Static Public Member Functions | |
| 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. | |
Static Public Attributes | |
| 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] |
The MIDI synthesiser that drives the SPU2 voices.
Abstract base of the game's sound output.
The class has no RTTI, and its name is inferred from the module's name. Every member is static, and the module has one synthesiser. The EE sends MIDI over RPC to play at once or stamped with a delay. The tick thread runs every six milliseconds and plays delayed MIDI when it falls due. Notes key on and off in batches. A pass over incoming MIDI collects the key masks, and CommitKeys() writes them together.
The RTTI includes the class name and records no base. The vptr sits at offset 0. Two classes implement it. SynthPS2 drives the sound hardware through the synth and softfx IOP modules, and SynthNull supplies empty bodies. Create() builds one of the two as TheSynth.
The vtable has 38 slots, declared in order.
| typedef void(* Synth::Callback) (int nArg) |
Routine a queued callback job calls with its argument.
|
virtual |
Vtable slot 4.
Release the sound output.
|
static |
The tick thread.
It sleeps until the timer wakes it, then advances the voices and the queued MIDI and posts pending notifications to the EE.
|
static |
Act on one MIDI channel message.
System messages are ignored.
| status | Status byte. |
| data1 | First data byte. |
| data2 | Second data byte. |
|
static |
Act on every queued MIDI message that is due, as one batch of key changes.
|
static |
Queue MIDI messages stamped with delays from now.
| events | The messages, whose fourth byte is the delay in milliseconds. |
| count | Number of messages. |
|
static |
Act on a MIDI byte stream with running status.
The stream ends at its size or at a system message. A note-on of velocity zero is treated as a note-off.
| data | The stream. |
| size | Its size in bytes. |
|
static |
Select mono output.
Mono output centres every later note.
| mono | True for mono. |
|
static |
Allow or forbid the surround inversion of the descriptors that request it.
| enabled | True to allow it. |
|
static |
Restore a channel's controllers to their defaults, except its monophonic switch.
| channel | The channel. |
|
static |
Reset the banks, channels, and voices, then the SPU2.
|
static |
Initialise the SPU2: the mixer, the reverb areas and settings, and the voice mix.
|
static |
|
static |
Report whether a channel has a program it can play.
| channel | The channel. |
|
static |
Start a note on every descriptor of the channel's program whose key range covers it.
| note | Note number. |
| velocity | Velocity; zero stops the note instead. |
| channel | The channel. |
|
static |
Stop the oldest sounding instance of a note.
| note | Note number. |
| channel | The channel. |
|
static |
Point a channel at the program of its bank with a program number.
| channel | The channel. |
| program | Program number; no match clears the channel's program. |
|
static |
Act on a program change unless the channel already plays that program number.
| channel | The channel. |
| program | Program number. |
|
static |
Point a channel at a loaded bank, retaining its program number.
| channel | The channel. |
| bank | Bank identifier. |
|
static |
Rewrite the volume registers of a channel's sounding voices.
| channel | The channel. |
|
static |
Set a channel's pan.
| channel | The channel. |
| pan | Pan, where 64 is the centre. |
|
static |
Set a channel's volume.
| channel | The channel. |
| volume | Volume. |
|
static |
Set a channel's expression.
| channel | The channel. |
| expression | Expression. |
|
static |
Set a channel's pitch bend.
| channel | The channel. |
| semitones | Whole semitones. |
| cents | Remaining cents. |
|
static |
Load a bank's header.
| data | The record's size word followed by the record. |
| bank | Bank slot. |
|
static |
Load a bank's programs, each record preceded by a size word.
| data | The records. |
| size | Bytes of records. |
| bank | Bank slot. |
|
static |
Load a bank's sample descriptors, each record preceded by a size word.
The samples must be loaded first.
| data | The records. |
| size | Bytes of records. |
| bank | Bank slot. |
|
static |
Load a bank's samples, each record preceded by a size word.
| data | The records. |
| size | Bytes of records. |
| bank | Bank slot. |
|
static |
Notify the EE at the next tick that a waveform transfer ended.
| channel | Transfer channel. |
| data | Unused. |
|
static |
Notify the EE at the next tick that a reverb update ended, when the EE requested it.
|
static |
Start a waveform transfer into a bank's SPU2 area.
| data | The waveform data. |
| size | Bytes to transfer. |
| offset | Destination offset in the bank's area. |
| bank | Bank slot. |
|
static |
Place the banks' SPU2 areas one after another.
| data | One size word per bank slot, in 64-byte units, or negative to retain the slot's size. |
|
static |
|
static |
Silence a bank's voices, detach its channels, and empty it.
| bank | Bank slot. |
|
static |
Set a channel's voice priority.
| channel | The channel. |
| priority | Priority. |
|
static |
Set a channel's detune switch.
| channel | The channel. |
| detune | Nonzero to detune later notes with vibrato. |
|
static |
Set a channel's stereo switch.
| channel | The channel. |
| stereo | Nonzero to play later notes as hard-panned pairs. |
|
static |
Set a channel's monophonic switch.
| channel | The channel. |
| monophonic | Nonzero to silence the channel before each later note. |
|
static |
Switch the live update of one controller on or off for a channel.
| channel | The channel. |
| controller | 10, 224 (pitch bend), 7, 17, or 91 (transposition). |
| value | At least 64 to switch the update on. |
|
static |
Set a channel's transposition.
| channel | The channel. |
| semitones | Transposition in semitones. |
|
static |
Set a channel's dry and reverb mix for later notes.
| channel | The channel. |
| busMode | A mix mode, or Channel::kBusModeFromSampleDesc. |
|
static |
Set a channel's preferred core for later notes.
| channel | The channel. |
| bus | Zero for either core, one for core 0, two for core 1. |
|
static |
Release a channel's notes and forget every retired voice.
| channel | The channel. |
|
static |
The reverb thread.
It sleeps until CommitEffects() wakes it, then applies the reverb settings.
|
static |
Set one reverb setting of a core from a controller.
| channel | 1 for core 0 or 2 for core 1; other channels are ignored. |
| value | Controller value. |
| param | 0 for the mode, 1 and 2 for the left and right depth, 3 for the delay, and 4 for the feedback. |
|
static |
Key off and then key on every voice the current batch collected.
A core whose key-on and key-off masks overlap drops its whole key-off mask.
|
static |
Start a batch of key changes.
|
static |
|
static |
Terminate TheSynth, destroy it, and clear the pointer.
|
pure virtual |
|
pure virtual |
|
virtual |
Vtable slot 3.
Initialise the sound processor again.
The base body is empty.
Reimplemented in SynthPS2.
|
pure virtual |
Vtable slot 5.
Send one packed message.
SynthPS2 splits the word into its four bytes, lowest first, and passes them to SendMessage().
| nPacked | The four message bytes. |
|
pure virtual |
|
virtual |
Vtable slot 7.
Report an unsupported request.
The base body passes "talk to denny" to the empty diagnostic routine at 0x00333d50. The PAL body only returns.
|
pure virtual |
|
pure virtual |
|
virtual |
Vtable slot 10.
Report the stream SetStream() set.
The base body returns null. The name is inferred.
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 11.
Set the stream the output plays, or none.
The base body is empty. The name is inferred.
| pStream | The stream, or null. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 12.
Append a run of stream data to the stream the software effect plays.
The base body is empty. An empty run ends the stream. The name is inferred.
| pData | The data. |
| nSize | The size of the data in bytes. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 13.
Report the room the software effect has for stream data.
The base body returns 0. The name is inferred.
Reimplemented in SynthPS2.
|
pure virtual |
|
pure virtual |
Vtable slot 15.
Queue the division of the sound memory among the bank slots.
The member is pure in this class. SynthPS2 copies the sizes into a queued job and returns 0. The name is inferred.
| blocks | The size of each bank slot in 64-byte blocks, indexed by slot. A negative size leaves the slot as it is. |
|
pure virtual |
|
pure virtual |
|
virtual |
Vtable slot 18.
Report whether a slot has a bank or a bank waiting to load.
The base body returns 1. The name is inferred.
| nSlot | The bank slot. |
Reimplemented in SynthPS2.
|
pure virtual |
|
pure virtual |
|
virtual |
Vtable slot 21.
Choose whether the output may invert a channel for surround decoders.
The base body is empty. The name is inferred.
| bSurround | Whether the inversion is allowed. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 22.
Choose mono output.
The base body is empty. The name is inferred.
| bMono | Whether the output is mono. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 23.
Set the lag of the output, the value of the lag_ms entry of the synth section.
The base body is empty. The name is inferred.
| fLag | The lag in milliseconds. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 24.
Report the lag slot 23 set.
The base body returns 0. The name is inferred.
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 25.
Set the position of the sweep of a sweeping software filter.
The base body is empty. SynthPS2 records the position for the filter types that sweep and reports any other type. The name is inferred.
| fPosition | The position, 1 for the top of the sweep. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 26.
Set the second control of the software effect.
The base body is empty. AxeVoice passes the vertical position of the stick. The name is inferred.
| fValue | The value, from -1 to 1. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 27.
Send the settings of the software effect.
The base body is empty. The name is inferred.
| filter | The settings. |
Reimplemented in SynthPS2.
|
pure virtual |
|
pure virtual |
|
virtual |
Vtable slot 30.
Set the output level that slot 31 reports.
The base body is empty. SynthPS2 scales the level by 16383 and sends it to the software effect. The name is inferred.
| fLevel | The level, 1 for full. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 31.
Report the output level.
The base body returns 1. The name is inferred.
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 32.
Choose the mixer input of the sound processor that the software effect captures.
The base body is empty. The metagame passes 1 before it plays the intro movie. The name is inferred.
| nInput | The input pair, 0 to 2. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 33.
Set whether the effect buses feed the hardware effects.
The base body is empty. The name is inferred.
| nOn | Whether the buses feed the hardware effects. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 34.
Set whether the effect buses feed the software effect.
The base body is empty, and SynthPS2 overrides it with an empty body. The name is inferred.
| nOn | Whether the buses feed the software effect. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 35.
The base body is empty, and the purpose is not yet recovered.
|
virtual |
Vtable slot 36.
Queue a job that sends packed messages.
The base body is empty. The name is inferred.
| messages | The messages, each packed as SendPackedMessage() takes it. |
Reimplemented in SynthPS2.
|
virtual |
Vtable slot 37.
Queue a job that calls a routine once the jobs before it have run.
The base body is empty. The name is inferred.
| pfnCallback | The routine. |
| nArg | The argument passed to the routine. |
Reimplemented in SynthPS2.
|
staticconstexpr |
MIDI channels.
|
staticconstexpr |
SPU2 cores.
|
staticconstexpr |
Voices of each core.
|
staticconstexpr |
Retired voice records.
|
static |
EE address a transfer notification goes to.
|
static |
Nonzero while a transfer notification waits.
|
static |
EE address a reverb notification goes to.
|
static |
Nonzero while a reverb notification waits.
|
static |
The reverb thread.
|
static |
Flag the EE sends at initialisation; unused.
|
static |
The MIDI channels.