#include <RIFF.h>
Inheritance diagram for RIFF::Chunk:
Public Member Functions | |
Chunk (int hFile, unsigned long StartPos, bool EndianNative, List *Parent) | |
String | GetChunkIDString () |
Returns the String representation of the chunk's ID (e.g. | |
uint32_t | GetChunkID () |
List * | GetParent () |
Chunk ID in unsigned integer representation. | |
unsigned long | GetSize () |
Returns pointer to the chunk's parent list chunk. | |
unsigned long | GetPos () |
Chunk size in bytes (without header, thus the chunk data body). | |
unsigned long | GetFilePos () |
Position within the chunk data body. | |
unsigned long | SetPos (unsigned long Where, stream_whence_t Whence=stream_start) |
Sets the position within the chunk body, thus within the data portion of the chunk (in bytes). | |
unsigned long | RemainingBytes () |
Returns the number of bytes left to read in the chunk body. | |
stream_state_t | GetState () |
Returns the current state of the chunk object. | |
unsigned long | Read (void *pData, unsigned long WordCount, unsigned long WordSize) |
Reads WordCount number of data words with given WordSize and copies it into a buffer pointed by pData. | |
unsigned long | ReadInt8 (int8_t *pData, unsigned long WordCount=1) |
Reads WordCount number of 8 Bit signed integer words and copies it into the buffer pointed by pData. | |
unsigned long | ReadUint8 (uint8_t *pData, unsigned long WordCount=1) |
Reads WordCount number of 8 Bit unsigned integer words and copies it into the buffer pointed by pData. | |
unsigned long | ReadInt16 (int16_t *pData, unsigned long WordCount=1) |
Reads WordCount number of 16 Bit signed integer words and copies it into the buffer pointed by pData. | |
unsigned long | ReadUint16 (uint16_t *pData, unsigned long WordCount=1) |
Reads WordCount number of 16 Bit unsigned integer words and copies it into the buffer pointed by pData. | |
unsigned long | ReadInt32 (int32_t *pData, unsigned long WordCount=1) |
Reads WordCount number of 32 Bit signed integer words and copies it into the buffer pointed by pData. | |
unsigned long | ReadUint32 (uint32_t *pData, unsigned long WordCount=1) |
Reads WordCount number of 32 Bit unsigned integer words and copies it into the buffer pointed by pData. | |
int8_t | ReadInt8 () |
Reads one 8 Bit signed integer word and increments the position within the chunk. | |
uint8_t | ReadUint8 () |
Reads one 8 Bit unsigned integer word and increments the position within the chunk. | |
int16_t | ReadInt16 () |
Reads one 16 Bit signed integer word and increments the position within the chunk. | |
uint16_t | ReadUint16 () |
Reads one 16 Bit unsigned integer word and increments the position within the chunk. | |
int32_t | ReadInt32 () |
Reads one 32 Bit signed integer word and increments the position within the chunk. | |
uint32_t | ReadUint32 () |
Reads one 32 Bit unsigned integer word and increments the position within the chunk. | |
void * | LoadChunkData () |
Load the whole chunk body in memory (on success returns a pointer to the data in RAM, else NULL). | |
void | ReleaseChunkData () |
Free loaded chunk body data from memory (RAM). | |
virtual | ~Chunk () |
Protected Member Functions | |
Chunk () | |
void | ReadHeader (unsigned long fPos) |
unsigned long | ReadSceptical (void *pData, unsigned long WordCount, unsigned long WordSize) |
Just an internal wrapper for the main Read() method with additional Exception throwing on errors. | |
void | swapBytes_16 (void *Word) |
void | swapBytes_32 (void *Word) |
void | swapBytes (void *Word, unsigned long WordSize) |
String | convertToString (uint32_t word) |
Protected Attributes | |
uint32_t | ChunkID |
uint32_t | ChunkSize |
List * | pParent |
int | hFile |
unsigned long | ulStartPos |
unsigned long | ulPos |
bool | bEndianNative |
uint8_t * | pChunkData |
Definition at line 94 of file RIFF.h.
RIFF::Chunk::Chunk | ( | int | hFile, | |
unsigned long | StartPos, | |||
bool | EndianNative, | |||
List * | Parent | |||
) |
Definition at line 41 of file RIFF.cpp.
References bEndianNative, Chunk(), CHUNK_HEADER_SIZE, hFile, pChunkData, pParent, ReadHeader(), ulPos, and ulStartPos.
RIFF::Chunk::~Chunk | ( | ) | [virtual] |
RIFF::Chunk::Chunk | ( | ) | [protected] |
String RIFF::Chunk::convertToString | ( | uint32_t | word | ) | [inline, protected] |
Definition at line 165 of file RIFF.h.
Referenced by GetChunkIDString(), RIFF::List::GetListTypeString(), RIFF::List::LoadSubChunks(), RIFF::List::ReadHeader(), and ReadHeader().
uint32_t RIFF::Chunk::GetChunkID | ( | ) | [inline] |
String RIFF::Chunk::GetChunkIDString | ( | ) |
Returns the String representation of the chunk's ID (e.g.
"RIFF", "LIST").
Definition at line 100 of file RIFF.cpp.
References ChunkID, and convertToString().
Referenced by PrintChunkList().
unsigned long RIFF::Chunk::GetFilePos | ( | ) | [inline] |
Position within the chunk data body.
Definition at line 106 of file RIFF.h.
References ulPos, and ulStartPos.
Referenced by gig::File::LoadSamples(), and DLS::File::LoadSamples().
List* RIFF::Chunk::GetParent | ( | ) | [inline] |
Chunk ID in unsigned integer representation.
Definition at line 103 of file RIFF.h.
References pParent.
Referenced by PrintChunkList().
unsigned long RIFF::Chunk::GetPos | ( | ) | [inline] |
Chunk size in bytes (without header, thus the chunk data body).
Definition at line 105 of file RIFF.h.
References ulPos.
Referenced by gig::Sample::GetPos(), and RIFF::List::LoadSubChunks().
unsigned long RIFF::Chunk::GetSize | ( | ) | [inline] |
Returns pointer to the chunk's parent list chunk.
Definition at line 104 of file RIFF.h.
References ChunkSize.
Referenced by DLS::File::File(), LoadChunkData(), RIFF::List::LoadSubChunks(), main(), PrintChunkList(), and DLS::Sample::Sample().
stream_state_t RIFF::Chunk::GetState | ( | ) |
Returns the current state of the chunk object.
Following values are possible:
Definition at line 163 of file RIFF.cpp.
References ChunkSize, RIFF::stream_closed, RIFF::stream_end_reached, RIFF::stream_ready, and ulPos.
void * RIFF::Chunk::LoadChunkData | ( | ) |
Load the whole chunk body in memory (on success returns a pointer to the data in RAM, else NULL).
Definition at line 446 of file RIFF.cpp.
References GetSize(), pChunkData, and ulStartPos.
Referenced by DLS::Sample::LoadSampleData().
unsigned long RIFF::Chunk::Read | ( | void * | pData, | |
unsigned long | WordCount, | |||
unsigned long | WordSize | |||
) |
Reads WordCount number of data words with given WordSize and copies it into a buffer pointed by pData.
The buffer has to be allocated and be sure to provide the correct WordSize, as this will be important and taken into account for eventual endian correction (swapping of bytes due to different native byte order of a system). The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of data words to read | |
WordSize | size of each data word to read |
Definition at line 191 of file RIFF.cpp.
References bEndianNative, ChunkSize, SetPos(), RIFF::stream_curpos, swapBytes(), swapBytes_16(), swapBytes_32(), ulPos, and ulStartPos.
Referenced by DLS::Articulation::Articulation(), DLS::File::File(), DLS::Instrument::Instrument(), RIFF::List::LoadSubChunks(), gig::Sample::Read(), DLS::Sample::Read(), ReadSceptical(), DLS::Region::Region(), DLS::Resource::Resource(), gig::Sample::Sample(), and DLS::Sampler::Sampler().
void RIFF::Chunk::ReadHeader | ( | unsigned long | fPos | ) | [protected] |
Reimplemented in RIFF::List.
Definition at line 61 of file RIFF.cpp.
References bEndianNative, CHUNK_ID_RIFF, CHUNK_ID_RIFX, ChunkID, ChunkSize, convertToString(), and swapBytes_32().
Referenced by Chunk(), and RIFF::List::ReadHeader().
int16_t RIFF::Chunk::ReadInt16 | ( | ) |
Reads one 16 Bit signed integer word and increments the position within the chunk.
Endian correction will automatically be done if needed.
RIFF::Exception | if an error occured |
Definition at line 386 of file RIFF.cpp.
References ReadSceptical().
unsigned long RIFF::Chunk::ReadInt16 | ( | int16_t * | pData, | |
unsigned long | WordCount = 1 | |||
) |
Reads WordCount number of 16 Bit signed integer words and copies it into the buffer pointed by pData.
The buffer has to be allocated. Endian correction will automatically be done if needed. The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of 16 Bit signed integers to read |
RIFF::Exception | if an error occured or less than WordCount integers could be read! |
Definition at line 282 of file RIFF.cpp.
References ReadSceptical().
Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), gig::Sample::Sample(), and DLS::Sampler::Sampler().
int32_t RIFF::Chunk::ReadInt32 | ( | ) |
Reads one 32 Bit signed integer word and increments the position within the chunk.
Endian correction will automatically be done if needed.
RIFF::Exception | if an error occured |
Definition at line 420 of file RIFF.cpp.
References ReadSceptical().
unsigned long RIFF::Chunk::ReadInt32 | ( | int32_t * | pData, | |
unsigned long | WordCount = 1 | |||
) |
Reads WordCount number of 32 Bit signed integer words and copies it into the buffer pointed by pData.
The buffer has to be allocated. Endian correction will automatically be done if needed. The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of 32 Bit signed integers to read |
RIFF::Exception | if an error occured or less than WordCount integers could be read! |
Definition at line 320 of file RIFF.cpp.
References ReadSceptical().
Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), gig::Sample::Sample(), and DLS::Sampler::Sampler().
int8_t RIFF::Chunk::ReadInt8 | ( | ) |
Reads one 8 Bit signed integer word and increments the position within the chunk.
RIFF::Exception | if an error occured |
Definition at line 353 of file RIFF.cpp.
References ReadSceptical().
unsigned long RIFF::Chunk::ReadInt8 | ( | int8_t * | pData, | |
unsigned long | WordCount = 1 | |||
) |
Reads WordCount number of 8 Bit signed integer words and copies it into the buffer pointed by pData.
The buffer has to be allocated. The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of 8 Bit signed integers to read |
RIFF::Exception | if an error occured or less than WordCount integers could be read! |
Definition at line 244 of file RIFF.cpp.
References ReadSceptical().
Referenced by gig::DimensionRegion::DimensionRegion().
unsigned long RIFF::Chunk::ReadSceptical | ( | void * | pData, | |
unsigned long | WordCount, | |||
unsigned long | WordSize | |||
) | [protected] |
Just an internal wrapper for the main Read() method with additional Exception throwing on errors.
Definition at line 227 of file RIFF.cpp.
References Read().
Referenced by ReadInt16(), ReadInt32(), ReadInt8(), ReadUint16(), ReadUint32(), and ReadUint8().
uint16_t RIFF::Chunk::ReadUint16 | ( | ) |
Reads one 16 Bit unsigned integer word and increments the position within the chunk.
Endian correction will automatically be done if needed.
RIFF::Exception | if an error occured |
Definition at line 403 of file RIFF.cpp.
References ReadSceptical().
unsigned long RIFF::Chunk::ReadUint16 | ( | uint16_t * | pData, | |
unsigned long | WordCount = 1 | |||
) |
Reads WordCount number of 16 Bit unsigned integer words and copies it into the buffer pointed by pData.
The buffer has to be allocated. Endian correction will automatically be done if needed. The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of 8 Bit unsigned integers to read |
RIFF::Exception | if an error occured or less than WordCount integers could be read! |
Definition at line 301 of file RIFF.cpp.
References ReadSceptical().
Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), DLS::Region::Region(), DLS::Sample::Sample(), and DLS::Sampler::Sampler().
uint32_t RIFF::Chunk::ReadUint32 | ( | ) |
Reads one 32 Bit unsigned integer word and increments the position within the chunk.
Endian correction will automatically be done if needed.
RIFF::Exception | if an error occured |
Definition at line 437 of file RIFF.cpp.
References ReadSceptical().
unsigned long RIFF::Chunk::ReadUint32 | ( | uint32_t * | pData, | |
unsigned long | WordCount = 1 | |||
) |
Reads WordCount number of 32 Bit unsigned integer words and copies it into the buffer pointed by pData.
The buffer has to be allocated. Endian correction will automatically be done if needed. The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of 32 Bit unsigned integers to read |
RIFF::Exception | if an error occured or less than WordCount integers could be read! |
Definition at line 339 of file RIFF.cpp.
References ReadSceptical().
Referenced by DLS::Articulation::Articulation(), DLS::File::File(), DLS::Instrument::Instrument(), gig::Region::Region(), DLS::Region::Region(), DLS::Sample::Sample(), and DLS::Sampler::Sampler().
uint8_t RIFF::Chunk::ReadUint8 | ( | ) |
Reads one 8 Bit unsigned integer word and increments the position within the chunk.
RIFF::Exception | if an error occured |
Definition at line 369 of file RIFF.cpp.
References ReadSceptical().
unsigned long RIFF::Chunk::ReadUint8 | ( | uint8_t * | pData, | |
unsigned long | WordCount = 1 | |||
) |
Reads WordCount number of 8 Bit unsigned integer words and copies it into the buffer pointed by pData.
The buffer has to be allocated. The position within the chunk will automatically be incremented.
pData | destination buffer | |
WordCount | number of 8 Bit unsigned integers to read |
RIFF::Exception | if an error occured or less than WordCount integers could be read! |
Definition at line 263 of file RIFF.cpp.
References ReadSceptical().
Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), and gig::Region::Region().
void RIFF::Chunk::ReleaseChunkData | ( | ) |
Free loaded chunk body data from memory (RAM).
Definition at line 467 of file RIFF.cpp.
References pChunkData.
Referenced by DLS::Sample::ReleaseSampleData().
unsigned long RIFF::Chunk::RemainingBytes | ( | ) |
Returns the number of bytes left to read in the chunk body.
When reading data from the chunk using the Read*() Methods, the position within the chunk data (that is the chunk body) will be incremented by the number of read bytes and RemainingBytes() returns how much data is left to read from the current position to the end of the chunk data.
Definition at line 145 of file RIFF.cpp.
References ChunkSize, and ulPos.
Referenced by RIFF::List::LoadSubChunks(), gig::Sample::Read(), and DLS::Region::Region().
unsigned long RIFF::Chunk::SetPos | ( | unsigned long | Where, | |
stream_whence_t | Whence = stream_start | |||
) |
Sets the position within the chunk body, thus within the data portion of the chunk (in bytes).
Where | - position offset (in bytes) | |
Whence | - optional: defines to what Where relates to, if omitted Where relates to beginning of the chunk data |
Definition at line 113 of file RIFF.cpp.
References ChunkSize, RIFF::stream_backward, RIFF::stream_curpos, RIFF::stream_end, RIFF::stream_start, and ulPos.
Referenced by DLS::Articulation::Articulation(), DLS::File::File(), RIFF::List::LoadSubChunks(), Read(), gig::Sample::Read(), gig::Region::Region(), gig::Sample::Sample(), DLS::Sampler::Sampler(), gig::Sample::SetPos(), and DLS::Sample::SetPos().
void RIFF::Chunk::swapBytes | ( | void * | Word, | |
unsigned long | WordSize | |||
) | [inline, protected] |
void RIFF::Chunk::swapBytes_16 | ( | void * | Word | ) | [inline, protected] |
void RIFF::Chunk::swapBytes_32 | ( | void * | Word | ) | [inline, protected] |
bool RIFF::Chunk::bEndianNative [protected] |
Definition at line 137 of file RIFF.h.
Referenced by Chunk(), RIFF::File::File(), RIFF::List::LoadSubChunks(), Read(), RIFF::List::ReadHeader(), and ReadHeader().
uint32_t RIFF::Chunk::ChunkID [protected] |
Definition at line 127 of file RIFF.h.
Referenced by RIFF::File::File(), GetChunkID(), GetChunkIDString(), and ReadHeader().
uint32_t RIFF::Chunk::ChunkSize [protected] |
Definition at line 128 of file RIFF.h.
Referenced by GetSize(), GetState(), Read(), RIFF::List::ReadHeader(), ReadHeader(), RemainingBytes(), and SetPos().
int RIFF::Chunk::hFile [protected] |
uint8_t* RIFF::Chunk::pChunkData [protected] |
Definition at line 138 of file RIFF.h.
Referenced by Chunk(), LoadChunkData(), ReleaseChunkData(), and ~Chunk().
List* RIFF::Chunk::pParent [protected] |
unsigned long RIFF::Chunk::ulPos [protected] |
Definition at line 136 of file RIFF.h.
Referenced by Chunk(), GetFilePos(), GetPos(), GetState(), RIFF::List::LoadSubChunks(), Read(), RemainingBytes(), and SetPos().
unsigned long RIFF::Chunk::ulStartPos [protected] |
Definition at line 135 of file RIFF.h.
Referenced by Chunk(), RIFF::File::File(), GetFilePos(), LoadChunkData(), RIFF::List::LoadSubChunks(), and Read().