RIFF::Chunk Class Reference

Ordinary RIFF Chunk. More...

#include <RIFF.h>

Inheritance diagram for RIFF::Chunk:

RIFF::List RIFF::File List of all members.

Public Member Functions

 Chunk (File *pFile, unsigned long StartPos, List *Parent)
String GetChunkIDString ()
 Returns the String representation of the chunk's ID (e.g.
uint32_t GetChunkID ()
 Chunk ID in unsigned integer representation.
ListGetParent ()
 Returns pointer to the chunk's parent list chunk.
unsigned long GetSize ()
 Chunk size in bytes (without header, thus the chunk data body).
unsigned long GetNewSize ()
 New chunk size if it was modified with Resize().
unsigned long GetPos ()
 Position within the chunk data body.
unsigned long GetFilePos ()
 Current, actual offset in file.
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.
unsigned long Write (void *pData, unsigned long WordCount, unsigned long WordSize)
 Writes WordCount number of data words with given WordSize from the buffer pointed by pData.
unsigned long WriteInt8 (int8_t *pData, unsigned long WordCount=1)
 Writes WordCount number of 8 Bit signed integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.
unsigned long WriteUint8 (uint8_t *pData, unsigned long WordCount=1)
 Writes WordCount number of 8 Bit unsigned integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.
unsigned long WriteInt16 (int16_t *pData, unsigned long WordCount=1)
 Writes WordCount number of 16 Bit signed integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.
unsigned long WriteUint16 (uint16_t *pData, unsigned long WordCount=1)
 Writes WordCount number of 16 Bit unsigned integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.
unsigned long WriteInt32 (int32_t *pData, unsigned long WordCount=1)
 Writes WordCount number of 32 Bit signed integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.
unsigned long WriteUint32 (uint32_t *pData, unsigned long WordCount=1)
 Writes WordCount number of 32 Bit unsigned integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.
void * LoadChunkData ()
 Load chunk body into RAM.
void ReleaseChunkData ()
 Free loaded chunk body from RAM.
void Resize (int iNewSize)
 Resize chunk.
virtual ~Chunk ()

Protected Member Functions

 Chunk (File *pFile)
 Chunk (File *pFile, List *pParent, uint32_t uiChunkID, uint uiBodySize)
void ReadHeader (unsigned long fPos)
void WriteHeader (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)
virtual unsigned long WriteChunk (unsigned long ulWritePos, unsigned long ulCurrentDataOffset)
 Write chunk persistently e.g.
virtual void __resetPos ()
 Sets Chunk's read/write position to zero.

Protected Attributes

uint32_t ChunkID
uint32_t CurrentChunkSize
uint32_t NewChunkSize
ListpParent
FilepFile
unsigned long ulStartPos
unsigned long ulPos
uint8_t * pChunkData
unsigned long ulChunkDataSize

Friends

class List

Detailed Description

Ordinary RIFF Chunk.

Provides convenient methods to access data of ordinary RIFF chunks in general.

Definition at line 177 of file RIFF.h.


Constructor & Destructor Documentation

RIFF::Chunk::Chunk ( File pFile,
unsigned long  StartPos,
List Parent 
)

Definition at line 70 of file RIFF.cpp.

References CHUNK_HEADER_SIZE, CurrentChunkSize, NewChunkSize, pChunkData, pFile, pParent, ReadHeader(), ulChunkDataSize, ulPos, and ulStartPos.

Referenced by RIFF::List::AddSubChunk().

RIFF::Chunk::~Chunk (  )  [virtual]

Definition at line 97 of file RIFF.cpp.

References pChunkData, pFile, and RIFF::File::UnlogResized().

RIFF::Chunk::Chunk ( File pFile  )  [protected]

Definition at line 56 of file RIFF.cpp.

References CHUNK_ID_RIFF, ChunkID, CurrentChunkSize, NewChunkSize, pChunkData, pFile, pParent, ulChunkDataSize, and ulPos.

RIFF::Chunk::Chunk ( File pFile,
List pParent,
uint32_t  uiChunkID,
uint  uiBodySize 
) [protected]

Definition at line 85 of file RIFF.cpp.

References ChunkID, CurrentChunkSize, NewChunkSize, pChunkData, pFile, pParent, ulChunkDataSize, ulPos, and ulStartPos.


Member Function Documentation

String RIFF::Chunk::GetChunkIDString (  ) 

Returns the String representation of the chunk's ID (e.g.

"RIFF", "LIST").

Definition at line 183 of file RIFF.cpp.

References ChunkID, and convertToString().

uint32_t RIFF::Chunk::GetChunkID (  )  [inline]

Chunk ID in unsigned integer representation.

Definition at line 181 of file RIFF.h.

References ChunkID.

Referenced by DLS::Articulation::Articulation(), RIFF::List::DeleteSubChunk(), DLS::Articulator::LoadArticulations(), gig::File::LoadGroups(), and sf2::VerifySize().

List* RIFF::Chunk::GetParent (  )  [inline]

Returns pointer to the chunk's parent list chunk.

Definition at line 182 of file RIFF.h.

References pParent.

Referenced by gig::Group::~Group(), DLS::Instrument::~Instrument(), DLS::Region::~Region(), and DLS::Sample::~Sample().

unsigned long RIFF::Chunk::GetSize (  )  [inline]

Chunk size in bytes (without header, thus the chunk data body).

Definition at line 183 of file RIFF.h.

References CurrentChunkSize.

Referenced by sf2::File::File(), DLS::File::File(), DLS::Sample::GetSize(), gig::Instrument::Instrument(), LoadChunkData(), RIFF::List::LoadSubChunks(), sf2::Sample::Sample(), DLS::Sample::Sample(), RIFF::File::Save(), gig::File::UpdateChunks(), DLS::Region::UpdateChunks(), DLS::Sampler::UpdateChunks(), sf2::VerifySize(), and gig::Sample::Write().

unsigned long RIFF::Chunk::GetNewSize (  )  [inline]

New chunk size if it was modified with Resize().

Definition at line 184 of file RIFF.h.

References NewChunkSize.

Referenced by gig::DimensionRegion::UpdateChunks().

unsigned long RIFF::Chunk::GetPos (  )  [inline]

Position within the chunk data body.

Definition at line 185 of file RIFF.h.

References ulPos.

Referenced by sf2::Sample::GetPos(), gig::Sample::GetPos(), RIFF::List::LoadSubChunks(), sf2::Sample::Read(), and gig::Sample::Write().

unsigned long RIFF::Chunk::GetFilePos (  )  [inline]

Current, actual offset in file.

Definition at line 186 of file RIFF.h.

References ulPos, and ulStartPos.

Referenced by gig::File::LoadSamples(), and DLS::File::LoadSamples().

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).

Caution: the position will be reset to zero whenever File::Save() was called.

Parameters:
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 199 of file RIFF.cpp.

References CurrentChunkSize, RIFF::stream_backward, RIFF::stream_curpos, RIFF::stream_end, RIFF::stream_start, and ulPos.

Referenced by DLS::Articulation::Articulation(), DLS::File::File(), gig::Instrument::Instrument(), RIFF::List::LoadSubChunks(), gig::MidiRuleCtrlTrigger::MidiRuleCtrlTrigger(), Read(), gig::Sample::Read(), gig::Region::Region(), gig::Sample::Sample(), DLS::Sampler::Sampler(), sf2::Sample::SetPos(), gig::Sample::SetPos(), DLS::Sample::SetPos(), and gig::File::SetSampleChecksum().

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.

Returns:
number of bytes left to read

Definition at line 231 of file RIFF.cpp.

References CurrentChunkSize, and ulPos.

Referenced by gig::DimensionRegion::DimensionRegion(), RIFF::List::LoadSubChunks(), gig::Sample::Read(), and DLS::Region::Region().

stream_state_t RIFF::Chunk::GetState (  ) 

Returns the current state of the chunk object.

Following values are possible:

Definition at line 249 of file RIFF.cpp.

References CurrentChunkSize, RIFF::File::hFileRead, pFile, RIFF::stream_closed, RIFF::stream_end_reached, RIFF::stream_ready, and ulPos.

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.

Parameters:
pData destination buffer
WordCount number of data words to read
WordSize size of each data word to read
Returns:
number of successfully read data words or 0 if end of file reached or error occured

Definition at line 280 of file RIFF.cpp.

References RIFF::File::bEndianNative, CurrentChunkSize, RIFF::File::hFileRead, pFile, SetPos(), RIFF::stream_curpos, swapBytes(), swapBytes_16(), swapBytes_32(), ulPos, and ulStartPos.

Referenced by DLS::Articulation::Articulation(), gig::DimensionRegion::DimensionRegion(), DLS::File::File(), DLS::Instrument::Instrument(), RIFF::List::LoadSubChunks(), sf2::Sample::Read(), gig::Sample::Read(), DLS::Sample::Read(), ReadSceptical(), DLS::Region::Region(), DLS::Resource::Resource(), gig::Sample::Sample(), and DLS::Sampler::Sampler().

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.

Parameters:
pData destination buffer
WordCount number of 8 Bit signed integers to read
Returns:
number of read integers
Exceptions:
RIFF::Exception if an error occured or less than WordCount integers could be read!

Definition at line 405 of file RIFF.cpp.

References ReadSceptical().

Referenced by gig::DimensionRegion::DimensionRegion(), sf2::LoadString(), and sf2::Sample::Sample().

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.

Parameters:
pData destination buffer
WordCount number of 8 Bit unsigned integers to read
Returns:
number of read integers
Exceptions:
RIFF::Exception if an error occured or less than WordCount integers could be read!

Definition at line 442 of file RIFF.cpp.

References ReadSceptical().

Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), gig::MidiRuleCtrlTrigger::MidiRuleCtrlTrigger(), and gig::Region::Region().

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.

Parameters:
pData destination buffer
WordCount number of 16 Bit signed integers to read
Returns:
number of read integers
Exceptions:
RIFF::Exception if an error occured or less than WordCount integers could be read!

Definition at line 479 of file RIFF.cpp.

References ReadSceptical().

Referenced by gig::DimensionRegion::DimensionRegion(), sf2::File::File(), sf2::Instrument::Instrument(), gig::Instrument::Instrument(), sf2::Preset::Preset(), sf2::Sample::Sample(), gig::Sample::Sample(), and DLS::Sampler::Sampler().

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.

Parameters:
pData destination buffer
WordCount number of 8 Bit unsigned integers to read
Returns:
number of read integers
Exceptions:
RIFF::Exception if an error occured or less than WordCount integers could be read!

Definition at line 516 of file RIFF.cpp.

References ReadSceptical().

Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), DLS::Region::Region(), DLS::Sample::Sample(), and DLS::Sampler::Sampler().

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.

Parameters:
pData destination buffer
WordCount number of 32 Bit signed integers to read
Returns:
number of read integers
Exceptions:
RIFF::Exception if an error occured or less than WordCount integers could be read!

Definition at line 553 of file RIFF.cpp.

References ReadSceptical().

Referenced by gig::DimensionRegion::DimensionRegion(), gig::Instrument::Instrument(), sf2::Preset::Preset(), sf2::Sample::Sample(), gig::Sample::Sample(), and DLS::Sampler::Sampler().

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.

Parameters:
pData destination buffer
WordCount number of 32 Bit unsigned integers to read
Returns:
number of read integers
Exceptions:
RIFF::Exception if an error occured or less than WordCount integers could be read!

Definition at line 590 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().

int8_t RIFF::Chunk::ReadInt8 (  ) 

Reads one 8 Bit signed integer word and increments the position within the chunk.

Returns:
read integer word
Exceptions:
RIFF::Exception if an error occured

Definition at line 622 of file RIFF.cpp.

References ReadSceptical().

uint8_t RIFF::Chunk::ReadUint8 (  ) 

Reads one 8 Bit unsigned integer word and increments the position within the chunk.

Returns:
read integer word
Exceptions:
RIFF::Exception if an error occured

Definition at line 638 of file RIFF.cpp.

References ReadSceptical().

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.

Returns:
read integer word
Exceptions:
RIFF::Exception if an error occured

Definition at line 655 of file RIFF.cpp.

References ReadSceptical().

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.

Returns:
read integer word
Exceptions:
RIFF::Exception if an error occured

Definition at line 672 of file RIFF.cpp.

References ReadSceptical().

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.

Returns:
read integer word
Exceptions:
RIFF::Exception if an error occured

Definition at line 689 of file RIFF.cpp.

References ReadSceptical().

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.

Returns:
read integer word
Exceptions:
RIFF::Exception if an error occured

Definition at line 706 of file RIFF.cpp.

References ReadSceptical().

unsigned long RIFF::Chunk::Write ( void *  pData,
unsigned long  WordCount,
unsigned long  WordSize 
)

Writes WordCount number of data words with given WordSize from the buffer pointed by pData.

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.

Parameters:
pData source buffer (containing the data)
WordCount number of data words to write
WordSize size of each data word to write
Returns:
number of successfully written data words
Exceptions:
RIFF::Exception if write operation would exceed current chunk size or any IO error occured
See also:
Resize()

Definition at line 338 of file RIFF.cpp.

References RIFF::File::bEndianNative, CurrentChunkSize, RIFF::File::hFileWrite, RIFF::File::Mode, pFile, RIFF::stream_mode_read_write, swapBytes(), swapBytes_16(), swapBytes_32(), ulPos, and ulStartPos.

Referenced by gig::Sample::Write(), DLS::Sample::Write(), WriteInt16(), WriteInt32(), WriteInt8(), WriteUint16(), WriteUint32(), and WriteUint8().

unsigned long RIFF::Chunk::WriteInt8 ( int8_t *  pData,
unsigned long  WordCount = 1 
)

Writes WordCount number of 8 Bit signed integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.

The position within the chunk will automatically be incremented. Note: you cannot write beyond the boundaries of the chunk, to append data to the chunk call Resize() before.

Parameters:
pData source buffer (containing the data)
WordCount number of 8 Bit signed integers to write
Returns:
number of written integers
Exceptions:
RIFF::Exception if an IO error occured
See also:
Resize()

Definition at line 426 of file RIFF.cpp.

References Write().

unsigned long RIFF::Chunk::WriteUint8 ( uint8_t *  pData,
unsigned long  WordCount = 1 
)

Writes WordCount number of 8 Bit unsigned integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.

The position within the chunk will automatically be incremented. Note: you cannot write beyond the boundaries of the chunk, to append data to the chunk call Resize() before.

Parameters:
pData source buffer (containing the data)
WordCount number of 8 Bit unsigned integers to write
Returns:
number of written integers
Exceptions:
RIFF::Exception if an IO error occured
See also:
Resize()

Definition at line 463 of file RIFF.cpp.

References Write().

unsigned long RIFF::Chunk::WriteInt16 ( int16_t *  pData,
unsigned long  WordCount = 1 
)

Writes WordCount number of 16 Bit signed integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.

The position within the chunk will automatically be incremented. Note: you cannot write beyond the boundaries of the chunk, to append data to the chunk call Resize() before.

Parameters:
pData source buffer (containing the data)
WordCount number of 16 Bit signed integers to write
Returns:
number of written integers
Exceptions:
RIFF::Exception if an IO error occured
See also:
Resize()

Definition at line 500 of file RIFF.cpp.

References Write().

unsigned long RIFF::Chunk::WriteUint16 ( uint16_t *  pData,
unsigned long  WordCount = 1 
)

Writes WordCount number of 16 Bit unsigned integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.

The position within the chunk will automatically be incremented. Note: you cannot write beyond the boundaries of the chunk, to append data to the chunk call Resize() before.

Parameters:
pData source buffer (containing the data)
WordCount number of 16 Bit unsigned integers to write
Returns:
number of written integers
Exceptions:
RIFF::Exception if an IO error occured
See also:
Resize()

Definition at line 537 of file RIFF.cpp.

References Write().

unsigned long RIFF::Chunk::WriteInt32 ( int32_t *  pData,
unsigned long  WordCount = 1 
)

Writes WordCount number of 32 Bit signed integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.

The position within the chunk will automatically be incremented. Note: you cannot write beyond the boundaries of the chunk, to append data to the chunk call Resize() before.

Parameters:
pData source buffer (containing the data)
WordCount number of 32 Bit signed integers to write
Returns:
number of written integers
Exceptions:
RIFF::Exception if an IO error occured
See also:
Resize()

Definition at line 574 of file RIFF.cpp.

References Write().

unsigned long RIFF::Chunk::WriteUint32 ( uint32_t *  pData,
unsigned long  WordCount = 1 
)

Writes WordCount number of 32 Bit unsigned integer words from the buffer pointed by pData to the chunk's body, directly to the actual "physical" file.

The position within the chunk will automatically be incremented. Note: you cannot write beyond the boundaries of the chunk, to append data to the chunk call Resize() before.

Parameters:
pData source buffer (containing the data)
WordCount number of 32 Bit unsigned integers to write
Returns:
number of written integers
Exceptions:
RIFF::Exception if an IO error occured
See also:
Resize()

Definition at line 611 of file RIFF.cpp.

References Write().

Referenced by gig::File::SetSampleChecksum().

void * RIFF::Chunk::LoadChunkData (  ) 

Load chunk body into RAM.

Loads the whole chunk body into memory. You can modify the data in RAM and save the data by calling File::Save() afterwards.

Caution: the buffer pointer will be invalidated once File::Save() was called. You have to call LoadChunkData() again to get a new, valid pointer whenever File::Save() was called.

You can call LoadChunkData() again if you previously scheduled to enlarge this chunk with a Resize() call. In that case the buffer will be enlarged to the new, scheduled chunk size and you can already place the new chunk data to the buffer and finally call File::Save() to enlarge the chunk physically and write the new data in one rush. This approach is definitely recommended if you have to enlarge and write new data to a lot of chunks.

Returns:
a pointer to the data in RAM on success, NULL otherwise
Exceptions:
Exception if data buffer could not be enlarged
See also:
ReleaseChunkData()

Definition at line 736 of file RIFF.cpp.

References CurrentChunkSize, RIFF::File::Filename, GetSize(), RIFF::File::hFileRead, NewChunkSize, pChunkData, pFile, ulChunkDataSize, and ulStartPos.

Referenced by gig::File::LoadGroups(), DLS::Sample::LoadSampleData(), gig::File::UpdateChunks(), gig::Instrument::UpdateChunks(), gig::Region::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Sample::UpdateChunks(), DLS::File::UpdateChunks(), DLS::Instrument::UpdateChunks(), DLS::Region::UpdateChunks(), DLS::Sample::UpdateChunks(), DLS::Sampler::UpdateChunks(), DLS::Resource::UpdateChunks(), DLS::Articulation::UpdateChunks(), and WriteChunk().

void RIFF::Chunk::ReleaseChunkData (  ) 

Free loaded chunk body from RAM.

Frees loaded chunk body data from memory (RAM). You should call File::Save() before calling this method if you modified the data to make the changes persistent.

Definition at line 780 of file RIFF.cpp.

References pChunkData.

Referenced by DLS::Sample::ReleaseSampleData().

void RIFF::Chunk::Resize ( int  iNewSize  ) 

Resize chunk.

Resizes this chunk's body, that is the actual size of data possible to be written to this chunk. This call will return immediately and just schedule the resize operation. You should call File::Save() to actually perform the resize operation(s) "physically" to the file. As this can take a while on large files, it is recommended to call Resize() first on all chunks which have to be resized and finally to call File::Save() to perform all those resize operations in one rush.

Caution: You cannot directly write to enlarged chunks before calling File::Save() as this might exceed the current chunk's body boundary!

Parameters:
iNewSize - new chunk body size in bytes (must be greater than zero)
Exceptions:
RIFF::Exception if iNewSize is less than 1
See also:
File::Save()

Definition at line 805 of file RIFF.cpp.

References RIFF::File::LogAsResized(), NewChunkSize, and pFile.

Referenced by RIFF::List::AddSubChunk(), DLS::Sample::Resize(), gig::File::UpdateChunks(), DLS::File::UpdateChunks(), DLS::Sampler::UpdateChunks(), and DLS::Articulation::UpdateChunks().

void RIFF::Chunk::ReadHeader ( unsigned long  fPos  )  [protected]

Reimplemented in RIFF::List.

Definition at line 102 of file RIFF.cpp.

References RIFF::File::bEndianNative, CHUNK_ID_RIFF, CHUNK_ID_RIFX, ChunkID, convertToString(), CurrentChunkSize, RIFF::File::hFileRead, NewChunkSize, pFile, and swapBytes_32().

Referenced by Chunk(), and RIFF::List::ReadHeader().

void RIFF::Chunk::WriteHeader ( unsigned long  fPos  )  [protected]

Reimplemented in RIFF::List.

Definition at line 145 of file RIFF.cpp.

References RIFF::File::bEndianNative, CHUNK_ID_RIFF, CHUNK_ID_RIFX, ChunkID, RIFF::File::hFileWrite, NewChunkSize, pFile, and swapBytes_32().

Referenced by WriteChunk(), and RIFF::List::WriteHeader().

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 388 of file RIFF.cpp.

References Read().

Referenced by ReadInt16(), ReadInt32(), ReadInt8(), ReadUint16(), ReadUint32(), and ReadUint8().

void RIFF::Chunk::swapBytes_16 ( void *  Word  )  [inline, protected]

Definition at line 230 of file RIFF.h.

Referenced by Read(), and Write().

void RIFF::Chunk::swapBytes_32 ( void *  Word  )  [inline, protected]

Definition at line 235 of file RIFF.h.

Referenced by Read(), ReadHeader(), Write(), and WriteHeader().

void RIFF::Chunk::swapBytes ( void *  Word,
unsigned long  WordSize 
) [inline, protected]

Definition at line 243 of file RIFF.h.

Referenced by Read(), and Write().

String RIFF::Chunk::convertToString ( uint32_t  word  )  [inline, protected]

Definition at line 252 of file RIFF.h.

Referenced by GetChunkIDString(), RIFF::List::GetListTypeString(), RIFF::List::LoadSubChunks(), RIFF::List::ReadHeader(), and ReadHeader().

unsigned long RIFF::Chunk::WriteChunk ( unsigned long  ulWritePos,
unsigned long  ulCurrentDataOffset 
) [protected, virtual]

Write chunk persistently e.g.

to disk.

Stores the chunk persistently to its actual "physical" file.

Parameters:
ulWritePos - position within the "physical" file where this chunk should be written to
ulCurrentDataOffset - offset of current (old) data within the file
Returns:
new write position in the "physical" file, that is ulWritePos incremented by this chunk's new size (including its header size of course)

Reimplemented in RIFF::List.

Definition at line 825 of file RIFF.cpp.

References CHUNK_HEADER_SIZE, CurrentChunkSize, RIFF::File::hFileRead, RIFF::File::hFileWrite, LoadChunkData(), RIFF::File::Mode, NewChunkSize, pChunkData, pFile, RIFF::stream_mode_read_write, ulPos, ulStartPos, and WriteHeader().

void RIFF::Chunk::__resetPos (  )  [protected, virtual]

Sets Chunk's read/write position to zero.

Reimplemented in RIFF::List.

Definition at line 915 of file RIFF.cpp.

References ulPos.

Referenced by RIFF::List::__resetPos().


Friends And Related Function Documentation

friend class List [friend]

Reimplemented in RIFF::File.

Definition at line 264 of file RIFF.h.


Member Data Documentation

uint32_t RIFF::Chunk::ChunkID [protected]

Definition at line 215 of file RIFF.h.

Referenced by Chunk(), RIFF::File::File(), GetChunkID(), GetChunkIDString(), ReadHeader(), and WriteHeader().

uint32_t RIFF::Chunk::CurrentChunkSize [protected]

Definition at line 216 of file RIFF.h.

Referenced by Chunk(), GetSize(), GetState(), LoadChunkData(), Read(), RIFF::List::ReadHeader(), ReadHeader(), RemainingBytes(), SetPos(), Write(), RIFF::List::WriteChunk(), and WriteChunk().

uint32_t RIFF::Chunk::NewChunkSize [protected]

Definition at line 217 of file RIFF.h.

Referenced by RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), Chunk(), GetNewSize(), LoadChunkData(), RIFF::List::ReadHeader(), ReadHeader(), Resize(), RIFF::List::WriteChunk(), WriteChunk(), RIFF::List::WriteHeader(), and WriteHeader().

List* RIFF::Chunk::pParent [protected]

Definition at line 218 of file RIFF.h.

Referenced by Chunk(), and GetParent().

File* RIFF::Chunk::pFile [protected]

Definition at line 219 of file RIFF.h.

Referenced by RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), Chunk(), GetState(), LoadChunkData(), RIFF::List::LoadSubChunks(), Read(), RIFF::List::ReadHeader(), ReadHeader(), Resize(), Write(), RIFF::List::WriteChunk(), WriteChunk(), RIFF::List::WriteHeader(), WriteHeader(), and ~Chunk().

unsigned long RIFF::Chunk::ulStartPos [protected]

Definition at line 220 of file RIFF.h.

Referenced by Chunk(), RIFF::File::File(), GetFilePos(), RIFF::List::List(), LoadChunkData(), RIFF::List::LoadSubChunks(), Read(), Write(), RIFF::List::WriteChunk(), and WriteChunk().

unsigned long RIFF::Chunk::ulPos [protected]

Definition at line 221 of file RIFF.h.

Referenced by __resetPos(), Chunk(), GetFilePos(), GetPos(), GetState(), RIFF::List::LoadSubChunks(), Read(), RemainingBytes(), RIFF::File::Save(), SetPos(), Write(), and WriteChunk().

uint8_t* RIFF::Chunk::pChunkData [protected]

Definition at line 222 of file RIFF.h.

Referenced by Chunk(), LoadChunkData(), ReleaseChunkData(), WriteChunk(), and ~Chunk().

unsigned long RIFF::Chunk::ulChunkDataSize [protected]

Definition at line 223 of file RIFF.h.

Referenced by Chunk(), and LoadChunkData().


The documentation for this class was generated from the following files:
Generated on Sun May 1 03:22:47 2011 for libgig by  doxygen 1.5.2