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

Reader of a bank file and the audio data file beside it. More...

#include <bankfileio.h>

Public Types

enum  IODirection { kRead = 0 , kWrite = 1 , kRead = 0 , kWrite = 1 }
 Directions of a BankFileIO. More...
enum  ChunkType {
  kBankChunk = 0 , kInstrumentChunk = 1 , kSampleDescriptionChunk = 2 , kSampleChunk = 3 ,
  kSampleFilenameChunk = 4 , kBankNameChunk = 5 , kInstrumentNameChunk = 6 , kSampleDescriptionNameChunk = 7 ,
  kSampleNameChunk = 8 , kBankChunk = 0 , kInstrumentChunk = 1 , kSampleDescriptionChunk = 2 ,
  kSampleChunk = 3 , kSampleFilenameChunk = 4 , kBankNameChunk = 5 , kInstrumentNameChunk = 6 ,
  kSampleDescriptionNameChunk = 7 , kSampleNameChunk = 8
}
 Chunks of a bank file. More...
enum  IODirection { kRead = 0 , kWrite = 1 , kRead = 0 , kWrite = 1 }
 Directions of a BankFileIO. More...
enum  ChunkType {
  kBankChunk = 0 , kInstrumentChunk = 1 , kSampleDescriptionChunk = 2 , kSampleChunk = 3 ,
  kSampleFilenameChunk = 4 , kBankNameChunk = 5 , kInstrumentNameChunk = 6 , kSampleDescriptionNameChunk = 7 ,
  kSampleNameChunk = 8 , kBankChunk = 0 , kInstrumentChunk = 1 , kSampleDescriptionChunk = 2 ,
  kSampleChunk = 3 , kSampleFilenameChunk = 4 , kBankNameChunk = 5 , kInstrumentNameChunk = 6 ,
  kSampleDescriptionNameChunk = 7 , kSampleNameChunk = 8
}
 Chunks of a bank file. More...

Public Member Functions

 BankFileIO (const String &filename, int nIODirection)
 Open a bank file for reading or writing.
 ~BankFileIO ()
 Close every file.
bool operator! () const
 Report whether the bank file failed to open.
const char * GetChunkTag (int nChunkType)
 Report the identifier of a chunk.
void OpenAudioData (int nBufferSize)
 Start reading the audio data file.
bool GetAudioData (std::vector< unsigned char > &audioData, int *pnPosition, int *pnGotData)
 Poll the reading of the audio data file.
void FindChunk (int nChunkType)
 Start looking for a chunk from the start of the bank file.
bool ReadChunk (std::vector< unsigned char > &data)
 Continue reading the bank file.
 BankFileIO (const String &filename, int ioDirection)
 Open a bank file for reading or writing.
 ~BankFileIO ()
 Close every file.
bool operator! () const
 Report whether the bank file failed to open.
void PackChunkHeader (const char *header, std::vector< unsigned char > &data)
 Copy a chunk header into eight bytes.
void UnpackChunkHeader (char *header, std::vector< unsigned char > &data)
 Copy eight bytes into a chunk header.
void BeginAudioDataOutput ()
 Create the audio data file for writing.
void WriteAudioData (std::vector< unsigned char > &data)
 Append bytes to the audio data file.
void EndAudioDataOutput ()
 Close the audio data file.
BinStream * BeginChunk (int chunkType)
 Start writing a chunk.
const char * GetChunkTag (int chunkType)
 Report the identifier of a chunk.
void EndChunk (BinStream *stream)
 Complete the header of the chunk BeginChunk() started.
void OpenAudioData (int bufferSize)
 Start reading the audio data file.
bool GetAudioData (std::vector< unsigned char > &oAudioData, int *position, bool *gotData)
 Poll the reading of the audio data file.
void FindChunk (int chunkType)
 Start looking for a chunk from the start of the bank file.
bool ReadChunk (std::vector< unsigned char > &data)
 Continue reading the bank file.

Static Public Member Functions

static String AudioDataFilename (const String &bankFileName)
 Derive the path of the audio data file from the path of a bank file.
static String AudioDataFilename (const String &iBankFileName)
 Derive the path of the audio data file from the path of a bank file.

Detailed Description

Reader of a bank file and the audio data file beside it.

Reader and writer of a bank file and the audio data file beside it.

The class has no RTTI, and its name comes from the synthesiser editor that shares the source. The object is 0x44 bytes. A bank file is a run of chunks, each an identifier of four characters, a size word, and the data. The reader finds a chunk with asynchronous reads that the caller polls. The writer's routines are absent from the game.

The class has no RTTI, and its name comes from its source file. The object is 0x44 bytes. A bank file is a run of chunks, each an identifier of four characters, a size word, and the data. The writer produces chunks through a FileStream. The reader finds a chunk with asynchronous reads that the caller polls.

Member Enumeration Documentation

◆ IODirection [1/2]

Directions of a BankFileIO.

Enumerator
kRead 

Read an existing bank.

kWrite 

Write a bank.

kRead 

Read an existing bank.

kWrite 

Write a bank.

◆ ChunkType [1/2]

Chunks of a bank file.

Enumerator
kBankChunk 

The bank header, BANK.

kInstrumentChunk 

The instruments, INST.

kSampleDescriptionChunk 

The sample descriptions, SDES.

kSampleChunk 

The samples, SAMP.

kSampleFilenameChunk 

The WAV file of each sample, SAFN.

kBankNameChunk 

The bank name, BKNM.

kInstrumentNameChunk 

The instrument names, INNM.

kSampleDescriptionNameChunk 

The sample description names, SDNM.

kSampleNameChunk 

The sample names, SANM.

kBankChunk 

The bank header, BANK.

kInstrumentChunk 

The instruments, INST.

kSampleDescriptionChunk 

The sample descriptions, SDES.

kSampleChunk 

The samples, SAMP.

kSampleFilenameChunk 

The WAV file of each sample, SAFN.

kBankNameChunk 

The bank name, BKNM.

kInstrumentNameChunk 

The instrument names, INNM.

kSampleDescriptionNameChunk 

The sample description names, SDNM.

kSampleNameChunk 

The sample names, SANM.

◆ IODirection [2/2]

Directions of a BankFileIO.

Enumerator
kRead 

Read an existing bank.

kWrite 

Write a bank.

kRead 

Read an existing bank.

kWrite 

Write a bank.

◆ ChunkType [2/2]

Chunks of a bank file.

Enumerator
kBankChunk 

The bank header, BANK.

kInstrumentChunk 

The instruments, INST.

kSampleDescriptionChunk 

The sample descriptions, SDES.

kSampleChunk 

The samples, SAMP.

kSampleFilenameChunk 

The WAV file of each sample, SAFN.

kBankNameChunk 

The bank name, BKNM.

kInstrumentNameChunk 

The instrument names, INNM.

kSampleDescriptionNameChunk 

The sample description names, SDNM.

kSampleNameChunk 

The sample names, SANM.

kBankChunk 

The bank header, BANK.

kInstrumentChunk 

The instruments, INST.

kSampleDescriptionChunk 

The sample descriptions, SDES.

kSampleChunk 

The samples, SAMP.

kSampleFilenameChunk 

The WAV file of each sample, SAFN.

kBankNameChunk 

The bank name, BKNM.

kInstrumentNameChunk 

The instrument names, INNM.

kSampleDescriptionNameChunk 

The sample description names, SDNM.

kSampleNameChunk 

The sample names, SANM.

Constructor & Destructor Documentation

◆ BankFileIO() [1/2]

BankFileIO::BankFileIO ( const String & filename,
int nIODirection )

Open a bank file for reading or writing.

Parameters
filenameThe path of the bank file.
nIODirectionThe direction, an IODirection.
Ghidra address:
NTSC-U/C: 0x00250fb0
Ghidra address:
PAL: 0x00259960

◆ ~BankFileIO() [1/2]

BankFileIO::~BankFileIO ( )

Close every file.

Ghidra address:
NTSC-U/C: 0x00251080
Ghidra address:
PAL: 0x00259a30

◆ BankFileIO() [2/2]

BankFileIO::BankFileIO ( const String & filename,
int ioDirection )

Open a bank file for reading or writing.

Parameters
filenameThe path of the bank file.
ioDirectionThe direction, an IODirection.
Ghidra address:
0x1002bce8

◆ ~BankFileIO() [2/2]

BankFileIO::~BankFileIO ( )

Close every file.

Ghidra address:
0x1002be22

Member Function Documentation

◆ operator!() [1/2]

bool BankFileIO::operator! ( ) const

Report whether the bank file failed to open.

Returns
Whether no bank file is open.
Ghidra address:
NTSC-U/C: 0x00251120
Ghidra address:
PAL: 0x00259ad0

◆ AudioDataFilename() [1/2]

String BankFileIO::AudioDataFilename ( const String & bankFileName)
static

Derive the path of the audio data file from the path of a bank file.

Parameters
bankFileNameThe path of the bank file.
Returns
The path with the bank extension replaced.
Ghidra address:
NTSC-U/C: 0x00251148
Ghidra address:
PAL: 0x00259af8

◆ GetChunkTag() [1/2]

const char * BankFileIO::GetChunkTag ( int nChunkType)

Report the identifier of a chunk.

Parameters
nChunkTypeThe chunk, a ChunkType.
Returns
The four characters of the identifier, without a terminator, or null for an unknown chunk.
Ghidra address:
NTSC-U/C: 0x002511c0
Ghidra address:
PAL: 0x00259b78

◆ OpenAudioData() [1/2]

void BankFileIO::OpenAudioData ( int nBufferSize)

Start reading the audio data file.

Parameters
nBufferSizeThe size of each read buffer in bytes.
Ghidra address:
NTSC-U/C: 0x00251260
Ghidra address:
PAL: 0x00259c18

◆ GetAudioData() [1/2]

bool BankFileIO::GetAudioData ( std::vector< unsigned char > & audioData,
int * pnPosition,
int * pnGotData )

Poll the reading of the audio data file.

Parameters
audioDataReceives the data of a completed read, padded with zeros to a multiple of 64 bytes.
pnPositionReceives the offset of the data in the file.
pnGotDataReceives 1 when a read completed, otherwise 0.
Returns
Whether more data is to come.
Ghidra address:
NTSC-U/C: 0x002512c0
Ghidra address:
PAL: 0x00259c78

◆ FindChunk() [1/2]

void BankFileIO::FindChunk ( int nChunkType)

Start looking for a chunk from the start of the bank file.

Parameters
nChunkTypeThe chunk, a ChunkType.
Ghidra address:
NTSC-U/C: 0x002513f8
Ghidra address:
PAL: 0x00259db0

◆ ReadChunk() [1/2]

bool BankFileIO::ReadChunk ( std::vector< unsigned char > & data)

Continue reading the bank file.

Call it until it returns false.

Parameters
dataReceives the data of the chunk FindChunk() requested.
Returns
Whether the read is still in progress.
Ghidra address:
NTSC-U/C: 0x00251670
Ghidra address:
PAL: 0x0025a018

◆ operator!() [2/2]

bool BankFileIO::operator! ( ) const

Report whether the bank file failed to open.

Returns
Whether no bank file is open.
Ghidra address:
0x1002bf05

◆ PackChunkHeader()

void BankFileIO::PackChunkHeader ( const char * header,
std::vector< unsigned char > & data )

Copy a chunk header into eight bytes.

No routine calls it.

Parameters
headerThe header, the identifier and then the size word.
dataReceives the bytes.
Ghidra address:
0x1002bf37

◆ UnpackChunkHeader()

void BankFileIO::UnpackChunkHeader ( char * header,
std::vector< unsigned char > & data )

Copy eight bytes into a chunk header.

No routine calls it.

Parameters
headerReceives the identifier and then the size word.
dataThe bytes.
Ghidra address:
0x1002bfa5

◆ AudioDataFilename() [2/2]

String BankFileIO::AudioDataFilename ( const String & iBankFileName)
static

Derive the path of the audio data file from the path of a bank file.

Parameters
iBankFileNameThe path of the bank file.
Returns
The path with the bank extension replaced.
Ghidra address:
0x1002c009

◆ BeginAudioDataOutput()

void BankFileIO::BeginAudioDataOutput ( )

Create the audio data file for writing.

Ghidra address:
0x1002c0ce

◆ WriteAudioData()

void BankFileIO::WriteAudioData ( std::vector< unsigned char > & data)

Append bytes to the audio data file.

Parameters
dataThe bytes.
Ghidra address:
0x1002c1d5

◆ EndAudioDataOutput()

void BankFileIO::EndAudioDataOutput ( )

Close the audio data file.

Ghidra address:
0x1002c23d

◆ BeginChunk()

BinStream * BankFileIO::BeginChunk ( int chunkType)

Start writing a chunk.

EndChunk() completes its header.

Parameters
chunkTypeThe chunk, a ChunkType.
Returns
The stream of the bank file, positioned after the chunk header.
Ghidra address:
0x1002c281

◆ GetChunkTag() [2/2]

const char * BankFileIO::GetChunkTag ( int chunkType)

Report the identifier of a chunk.

Parameters
chunkTypeThe chunk, a ChunkType.
Returns
The four characters of the identifier, without a terminator.
Ghidra address:
0x1002c397

◆ EndChunk()

void BankFileIO::EndChunk ( BinStream * stream)

Complete the header of the chunk BeginChunk() started.

Parameters
streamThe stream BeginChunk() returned.
Ghidra address:
0x1002c465

◆ OpenAudioData() [2/2]

void BankFileIO::OpenAudioData ( int bufferSize)

Start reading the audio data file.

No routine calls it.

Parameters
bufferSizeThe size of each read buffer in bytes.
Ghidra address:
0x1002c508

◆ GetAudioData() [2/2]

bool BankFileIO::GetAudioData ( std::vector< unsigned char > & oAudioData,
int * position,
bool * gotData )

Poll the reading of the audio data file.

No routine calls it.

Parameters
oAudioDataReceives the data of a completed read, padded with zeros to a multiple of 64 bytes. The capacity must already fit it.
positionReceives the offset of the data in the file.
gotDataReceives whether a read completed.
Returns
Whether more data is to come.
Ghidra address:
0x1002c5cd

◆ FindChunk() [2/2]

void BankFileIO::FindChunk ( int chunkType)

Start looking for a chunk from the start of the bank file.

Parameters
chunkTypeThe chunk, a ChunkType.
Ghidra address:
0x1002c7b7

◆ ReadChunk() [2/2]

bool BankFileIO::ReadChunk ( std::vector< unsigned char > & data)

Continue reading the bank file.

Call it until it returns false.

Parameters
dataReceives the data of the chunk FindChunk() requested.
Returns
Whether the read is still in progress.
Ghidra address:
0x1002cb34

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