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

An instrument bank: its header, programs, sample descriptors, and samples, and where its waveforms sit in SPU2 memory. More...

#include <bank.h>

Collaboration diagram for Bank:

Public Member Functions

 Bank ()
 Construct an empty, unloaded bank.
void Init ()
 Reset the header, forget every program, descriptor, and sample, and mark the bank unloaded.
void SetProgram (BankProgram *program, int index)
 Store a program and point it at its run of descriptors.
void SetSampleDesc (BankSampleDesc *sampleDesc, int index)
 Store a descriptor and link it to its sample.
bool SetSample (Sample *sample, int index)
 Store a sample.
BankProgram * GetProgram (int index)
 Look up a program by slot.
BankSampleDesc * GetSampleDesc (BankProgram *program, int index)
 Look up one descriptor of a program's run.
void Clear ()
 Return every program, descriptor, and sample to the pools, then Init().
 Bank ()
 Create a bank header and reset it.
void Init ()
 Reset every field to its default.
int FromStream (const unsigned char *data)
 Read the header from its stream form.
int ToStream (unsigned char *data) const
 Write the header in its stream form, as version 1.

Static Public Member Functions

static void NewProgram (BankProgram **program)
 Take a program from the pool and Init() it.
static void NewSampleDesc (BankSampleDesc **sampleDesc)
 Take a descriptor from the pool and Init() it.
static void NewSample (Sample **sample)
 Take a sample from the pool and Init() it.
static int Find (unsigned short id)
 Find the loaded bank with an identifier.
static void InitPools ()
 Allocate the shared pools.
static int ReleasePools ()
 Release the shared pools.
static int StreamSize ()
 Report the size of the stream form.

Public Attributes

unsigned char mLoaded
BankHeader mHeader
BankProgram * mPrograms [kMaxPrograms]
BankSampleDesc * mSampleDescs [kMaxSampleDescs]
Sample * mSamples [kMaxSamples]
unsigned int mSpuAddress
unsigned int mSpuSize
unsigned short mId
unsigned char mVolume
unsigned short mNumInstruments

Static Public Attributes

static constexpr int kMaxBanks = 7
static constexpr int kMaxPrograms = 100
static constexpr int kMaxSampleDescs = 700
static constexpr int kMaxSamples = 700
static Bank sBanks [kMaxBanks]

Detailed Description

An instrument bank: its header, programs, sample descriptors, and samples, and where its waveforms sit in SPU2 memory.

Header of a bank, shared with the synthesiser on the IOP.

The class has no RTTI, and its name is inferred from its role. The EE loads a bank piece by piece over RPC into one of kMaxBanks slots. Programs, descriptors, and samples come from pools every bank shares.

The class has no RTTI, and its name is inferred from its source file. The record is 6 bytes, laid out as the bank header of the IOP synthesiser. Its stream form is a version word followed by the fields, 9 bytes in all.

Constructor & Destructor Documentation

◆ Bank() [1/2]

Bank::Bank ( )
inline

Construct an empty, unloaded bank.

◆ Bank() [2/2]

Bank::Bank ( )

Create a bank header and reset it.

Ghidra address:
0x1002baa0

Member Function Documentation

◆ Init() [1/2]

void Bank::Init ( )

Reset the header, forget every program, descriptor, and sample, and mark the bank unloaded.

The SPU2 area is retained.

Ghidra address:
NTSC-U/C: 0x00001efc
Ghidra address:
PAL: 0x00001efc

◆ SetProgram()

void Bank::SetProgram ( BankProgram * program,
int index )

Store a program and point it at its run of descriptors.

The run starts after the descriptors of every program before index. Those programs must already be stored.

Parameters
programThe program.
indexIts slot.
Ghidra address:
NTSC-U/C: 0x00001f94
Ghidra address:
PAL: 0x00001f94

◆ SetSampleDesc()

void Bank::SetSampleDesc ( BankSampleDesc * sampleDesc,
int index )

Store a descriptor and link it to its sample.

The sample must already be stored.

Parameters
sampleDescThe descriptor.
indexIts slot.
Ghidra address:
NTSC-U/C: 0x00001ff0
Ghidra address:
PAL: 0x00001ff0

◆ SetSample()

bool Bank::SetSample ( Sample * sample,
int index )

Store a sample.

Parameters
sampleThe sample.
indexIts slot.
Returns
True.
Ghidra address:
NTSC-U/C: 0x0000201c
Ghidra address:
PAL: 0x0000201c

◆ GetProgram()

BankProgram * Bank::GetProgram ( int index)

Look up a program by slot.

Parameters
indexThe slot.
Returns
The program, or null when index is not below the header's program count.
Ghidra address:
NTSC-U/C: 0x00002030
Ghidra address:
PAL: 0x00002030

◆ GetSampleDesc()

BankSampleDesc * Bank::GetSampleDesc ( BankProgram * program,
int index )

Look up one descriptor of a program's run.

Parameters
programThe program.
indexPosition in the program's run.
Returns
The descriptor.
Ghidra address:
NTSC-U/C: 0x000020a0
Ghidra address:
PAL: 0x000020a0

◆ Clear()

void Bank::Clear ( )

Return every program, descriptor, and sample to the pools, then Init().

Ghidra address:
NTSC-U/C: 0x00002530
Ghidra address:
PAL: 0x00002530

◆ NewProgram()

void Bank::NewProgram ( BankProgram ** program)
static

Take a program from the pool and Init() it.

Parameters
programReceives the program.
Ghidra address:
NTSC-U/C: 0x00002698
Ghidra address:
PAL: 0x00002698

◆ NewSampleDesc()

void Bank::NewSampleDesc ( BankSampleDesc ** sampleDesc)
static

Take a descriptor from the pool and Init() it.

Parameters
sampleDescReceives the descriptor.
Ghidra address:
NTSC-U/C: 0x000026d0
Ghidra address:
PAL: 0x000026d0

◆ NewSample()

void Bank::NewSample ( Sample ** sample)
static

Take a sample from the pool and Init() it.

Parameters
sampleReceives the sample.
Ghidra address:
NTSC-U/C: 0x00002708
Ghidra address:
PAL: 0x00002708

◆ Find()

int Bank::Find ( unsigned short id)
static

Find the loaded bank with an identifier.

Parameters
idThe identifier.
Returns
The bank's slot, or -1 when no loaded bank has it.
Ghidra address:
NTSC-U/C: 0x00002740
Ghidra address:
PAL: 0x00002740

◆ InitPools()

void Bank::InitPools ( )
static

Allocate the shared pools.

Ghidra address:
NTSC-U/C: 0x000027b4
Ghidra address:
PAL: 0x000027b4

◆ ReleasePools()

int Bank::ReleasePools ( )
static

Release the shared pools.

Returns
Zero.
Ghidra address:
NTSC-U/C: 0x00002c00
Ghidra address:
PAL: 0x00002c00

◆ Init() [2/2]

void Bank::Init ( )

Reset every field to its default.

Ghidra address:
0x1002baba

◆ FromStream()

int Bank::FromStream ( const unsigned char * data)

Read the header from its stream form.

Only version 1 is accepted.

Parameters
dataThe stream form.
Returns
The number of bytes read.
Ghidra address:
0x1002bad7

◆ ToStream()

int Bank::ToStream ( unsigned char * data) const

Write the header in its stream form, as version 1.

Parameters
dataReceives StreamSize() bytes.
Returns
The number of bytes written.
Ghidra address:
0x1002bbaa

◆ StreamSize()

int Bank::StreamSize ( )
static

Report the size of the stream form.

Returns
The size in bytes.
Ghidra address:
0x1002bc49

Member Data Documentation

◆ kMaxBanks

int Bank::kMaxBanks = 7
staticconstexpr

Bank slots.

◆ kMaxPrograms

int Bank::kMaxPrograms = 100
staticconstexpr

Programs per bank, and in the shared pool.

◆ kMaxSampleDescs

int Bank::kMaxSampleDescs = 700
staticconstexpr

Descriptors per bank and in the pool.

◆ kMaxSamples

int Bank::kMaxSamples = 700
staticconstexpr

Samples per bank and in the pool.

◆ mLoaded

unsigned char Bank::mLoaded

One once the EE marks the bank loaded.

◆ mHeader

BankHeader Bank::mHeader

The bank's identity and mix settings.

◆ mPrograms

BankProgram* Bank::mPrograms[kMaxPrograms]

Programs by slot.

◆ mSampleDescs

BankSampleDesc* Bank::mSampleDescs[kMaxSampleDescs]

Descriptors, in program order.

◆ mSamples

Sample* Bank::mSamples[kMaxSamples]

Samples by index.

◆ mSpuAddress

unsigned int Bank::mSpuAddress

Start of the bank's SPU2 area.

◆ mSpuSize

unsigned int Bank::mSpuSize

Size of the bank's SPU2 area in bytes.

◆ sBanks

Bank Bank::sBanks[kMaxBanks]
static

The bank slots.

◆ mId

unsigned short Bank::mId

Bank identifier a bank select requests.

◆ mVolume

unsigned char Bank::mVolume

Bank volume, an index into the volume curve.

◆ mNumInstruments

unsigned short Bank::mNumInstruments

Instruments the bank defines.


The documentation for this class was generated from the following files:
  • src/iop/synth_s/bank.h
  • tools/synthedit/synth/common/Bank.h