libgig
4.3.0
|
#include <RIFF.h>
Public Member Functions | |
File (uint32_t FileType) | |
Create new RIFF file. More... | |
File (const String &path) | |
Load existing RIFF file. More... | |
File (const String &path, uint32_t FileType, endian_t Endian, layout_t layout, offset_size_t fileOffsetSize=offset_size_auto) | |
Load existing RIFF-like file. More... | |
stream_mode_t | GetMode () const |
bool | SetMode (stream_mode_t NewMode) |
Change file access mode. More... | |
void | SetByteOrder (endian_t Endian) |
Set the byte order to be used when saving. More... | |
String | GetFileName () const |
void | SetFileName (const String &path) |
bool | IsNew () const |
Returns true if this file has been created new from scratch and has not been stored to disk yet. | |
layout_t | GetLayout () const |
file_offset_t | GetCurrentFileSize () const |
Returns the current size of this file (in bytes) as it is currently yet stored on disk. More... | |
file_offset_t | GetRequiredFileSize () |
Returns the required size (in bytes) for this RIFF File to be saved to disk. More... | |
file_offset_t | GetRequiredFileSize (offset_size_t fileOffsetSize) |
Returns the rquired size (in bytes) for this RIFF file to be saved to disk, assuming the passed fileOffsestSize would be used for the Save() operation. More... | |
int | GetFileOffsetSize () const |
Returns the current size (in bytes) of file offsets stored in the headers of all chunks of this file. More... | |
int | GetRequiredFileOffsetSize () |
Returns the required size (in bytes) of file offsets stored in the headers of all chunks of this file if the current RIFF tree would be saved to disk by calling Save(). More... | |
virtual void | Save (progress_t *pProgress=NULL) |
Save changes to same file. More... | |
virtual void | Save (const String &path, progress_t *pProgress=NULL) |
Save changes to another file. More... | |
String | GetListTypeString () const |
Returns string representation of the lists's id. | |
uint32_t | GetListType () const |
Returns unsigned integer representation of the list's ID. | |
Chunk * | GetSubChunk (uint32_t ChunkID) |
Returns subchunk with chunk ID ChunkID within this chunk list. More... | |
List * | GetSubList (uint32_t ListType) |
Returns sublist chunk with list type ListType within this chunk list. More... | |
Chunk * | GetFirstSubChunk () |
Returns the first subchunk within the list (which may be an ordinary chunk as well as a list chunk). More... | |
Chunk * | GetNextSubChunk () |
Returns the next subchunk within the list (which may be an ordinary chunk as well as a list chunk). More... | |
List * | GetFirstSubList () |
Returns the first sublist within the list (that is a subchunk with chunk ID "LIST"). More... | |
List * | GetNextSubList () |
Returns the next sublist (that is a subchunk with chunk ID "LIST") within the list. More... | |
size_t | CountSubChunks () |
Returns number of subchunks within the list (including list chunks). | |
size_t | CountSubChunks (uint32_t ChunkID) |
Returns number of subchunks within the list with chunk ID ChunkId. | |
size_t | CountSubLists () |
Returns number of sublists within the list. | |
size_t | CountSubLists (uint32_t ListType) |
Returns number of sublists within the list with list type ListType | |
Chunk * | AddSubChunk (uint32_t uiChunkID, file_offset_t ullBodySize) |
Creates a new sub chunk. More... | |
List * | AddSubList (uint32_t uiListType) |
Creates a new list sub chunk. More... | |
void | DeleteSubChunk (Chunk *pSubChunk) |
Removes a sub chunk. More... | |
void | MoveSubChunk (Chunk *pSrc, Chunk *pDst) |
Moves a sub chunk witin this list. More... | |
void | MoveSubChunk (Chunk *pSrc, List *pNewParent) |
Moves a sub chunk from this list to another list. More... | |
String | GetChunkIDString () const |
Returns the String representation of the chunk's ID (e.g. More... | |
uint32_t | GetChunkID () const |
Chunk ID in unsigned integer representation. | |
File * | GetFile () const |
Returns pointer to the chunk's File object. | |
List * | GetParent () const |
Returns pointer to the chunk's parent list chunk. | |
file_offset_t | GetSize () const |
Chunk size in bytes (without header, thus the chunk data body) | |
file_offset_t | GetNewSize () const |
New chunk size if it was modified with Resize(), otherwise value returned will be equal to GetSize(). | |
file_offset_t | GetPos () const |
Position within the chunk data body (starting with 0). | |
file_offset_t | GetFilePos () const |
Current, actual offset in file of current chunk data body read/write position. | |
file_offset_t | SetPos (file_offset_t Where, stream_whence_t Whence=stream_start) |
Sets the position within the chunk body, thus within the data portion of the chunk (in bytes). More... | |
file_offset_t | RemainingBytes () const |
Returns the number of bytes left to read in the chunk body. More... | |
stream_state_t | GetState () const |
Returns the current state of the chunk object. More... | |
file_offset_t | Read (void *pData, file_offset_t WordCount, file_offset_t WordSize) |
Reads WordCount number of data words with given WordSize and copies it into a buffer pointed by pData. More... | |
file_offset_t | ReadInt8 (int8_t *pData, file_offset_t WordCount=1) |
Reads WordCount number of 8 Bit signed integer words and copies it into the buffer pointed by pData. More... | |
int8_t | ReadInt8 () |
Reads one 8 Bit signed integer word and increments the position within the chunk. More... | |
file_offset_t | ReadUint8 (uint8_t *pData, file_offset_t WordCount=1) |
Reads WordCount number of 8 Bit unsigned integer words and copies it into the buffer pointed by pData. More... | |
uint8_t | ReadUint8 () |
Reads one 8 Bit unsigned integer word and increments the position within the chunk. More... | |
file_offset_t | ReadInt16 (int16_t *pData, file_offset_t WordCount=1) |
Reads WordCount number of 16 Bit signed integer words and copies it into the buffer pointed by pData. More... | |
int16_t | ReadInt16 () |
Reads one 16 Bit signed integer word and increments the position within the chunk. More... | |
file_offset_t | ReadUint16 (uint16_t *pData, file_offset_t WordCount=1) |
Reads WordCount number of 16 Bit unsigned integer words and copies it into the buffer pointed by pData. More... | |
uint16_t | ReadUint16 () |
Reads one 16 Bit unsigned integer word and increments the position within the chunk. More... | |
file_offset_t | ReadInt32 (int32_t *pData, file_offset_t WordCount=1) |
Reads WordCount number of 32 Bit signed integer words and copies it into the buffer pointed by pData. More... | |
int32_t | ReadInt32 () |
Reads one 32 Bit signed integer word and increments the position within the chunk. More... | |
file_offset_t | ReadUint32 (uint32_t *pData, file_offset_t WordCount=1) |
Reads WordCount number of 32 Bit unsigned integer words and copies it into the buffer pointed by pData. More... | |
uint32_t | ReadUint32 () |
Reads one 32 Bit unsigned integer word and increments the position within the chunk. More... | |
void | ReadString (String &s, int size) |
Reads a null-padded string of size characters and copies it into the string s. More... | |
file_offset_t | Write (void *pData, file_offset_t WordCount, file_offset_t WordSize) |
Writes WordCount number of data words with given WordSize from the buffer pointed by pData. More... | |
file_offset_t | WriteInt8 (int8_t *pData, file_offset_t 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. More... | |
file_offset_t | WriteUint8 (uint8_t *pData, file_offset_t 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. More... | |
file_offset_t | WriteInt16 (int16_t *pData, file_offset_t 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. More... | |
file_offset_t | WriteUint16 (uint16_t *pData, file_offset_t 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. More... | |
file_offset_t | WriteInt32 (int32_t *pData, file_offset_t 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. More... | |
file_offset_t | WriteUint32 (uint32_t *pData, file_offset_t 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. More... | |
void * | LoadChunkData () |
Load chunk body into RAM. More... | |
void | ReleaseChunkData () |
Free loaded chunk body from RAM. More... | |
void | Resize (file_offset_t NewSize) |
Resize chunk. More... | |
Protected Types | |
typedef std::map< uint32_t, RIFF::Chunk * > | ChunkMap |
typedef std::list< Chunk * > | ChunkList |
typedef std::set< Chunk * > | ChunkSet |
Protected Member Functions | |
void | ReadHeader (file_offset_t filePos) |
void | WriteHeader (file_offset_t filePos) |
void | LoadSubChunks (progress_t *pProgress=NULL) |
void | LoadSubChunksRecursively (progress_t *pProgress=NULL) |
virtual file_offset_t | RequiredPhysicalSize (int fileOffsetSize) |
Returns the actual total size in bytes (including List chunk header and all subchunks) of this List Chunk if being stored to a file. More... | |
virtual file_offset_t | WriteChunk (file_offset_t ullWritePos, file_offset_t ullCurrentDataOffset, progress_t *pProgress=NULL) |
Write list chunk persistently e.g. More... | |
virtual void | __resetPos () |
Sets List Chunk's read/write position to zero and causes all sub chunks to do the same. | |
void | DeleteChunkList () |
file_offset_t | ReadSceptical (void *pData, file_offset_t WordCount, file_offset_t WordSize) |
Just an internal wrapper for the main Read() method with additional Exception throwing on errors. | |
Static Protected Member Functions | |
static String | convertToString (uint32_t word) |
Protected Attributes | |
int | hFileRead |
handle / descriptor for reading from file | |
int | hFileWrite |
handle / descriptor for writing to (some) file | |
String | Filename |
bool | bEndianNative |
bool | bIsNewFile |
layout_t | Layout |
An ordinary RIFF file is always set to layout_standard. | |
offset_size_t | FileOffsetPreference |
int | FileOffsetSize |
Size of file offsets (in bytes) when this file was opened (or saved the last time). | |
uint32_t | ListType |
ChunkList * | pSubChunks |
ChunkMap * | pSubChunksMap |
ChunkList::iterator | ChunksIterator |
ChunkList::iterator | ListIterator |
uint32_t | ChunkID |
file_offset_t | ullCurrentChunkSize |
file_offset_t | ullNewChunkSize |
List * | pParent |
File * | pFile |
file_offset_t | ullStartPos |
file_offset_t | ullPos |
uint8_t * | pChunkData |
file_offset_t | ullChunkDataSize |
Handles arbitrary RIFF files and provides together with its base classes convenient methods to walk through, read and modify the file's RIFF tree.
RIFF::File::File | ( | uint32_t | FileType | ) |
Create new RIFF file.
Use this constructor if you want to create a new RIFF file completely "from scratch". Note: there must be no empty chunks or empty list chunks when trying to make the new RIFF file persistent with Save()!
Note: by default, the RIFF file will be saved in native endian format; that is, as a RIFF file on little-endian machines and as a RIFX file on big-endian. To change this behaviour, call SetByteOrder() before calling Save().
FileType | - four-byte identifier of the RIFF file type |
Definition at line 1624 of file RIFF.cpp.
References FileOffsetSize, hFileRead, and hFileWrite.
RIFF::File::File | ( | const String & | path | ) |
Load existing RIFF file.
Loads an existing RIFF file with all its chunks.
path | - path and file name of the RIFF file to open |
RIFF::Exception | if error occurred while trying to load the given RIFF file |
Definition at line 1648 of file RIFF.cpp.
References FileOffsetSize.
RIFF::File::File | ( | const String & | path, |
uint32_t | FileType, | ||
endian_t | Endian, | ||
layout_t | layout, | ||
offset_size_t | fileOffsetSize = offset_size_auto |
||
) |
Load existing RIFF-like file.
Loads an existing file, which is not a "real" RIFF file, but similar to an ordinary RIFF file.
A "real" RIFF file contains at top level a List chunk either with chunk ID "RIFF" or "RIFX". The simple constructor above expects this to be case, and if it finds the toplevel List chunk to have another chunk ID than one of those two expected ones, it would throw an Exception and would refuse to load the file accordingly.
Since there are however a lot of file formats which use the same simple principles of the RIFF format, with another toplevel List chunk ID though, you can use this alternative constructor here to be able to load and handle those files in the same way as you would do with "real" RIFF files.
path | - path and file name of the RIFF-alike file to be opened |
FileType | - expected toplevel List chunk ID (this is the very first chunk found in the file) |
Endian | - whether the file uses little endian or big endian layout |
layout | - general file structure type |
fileOffsetSize | - (optional) preference how to deal with large files |
RIFF::Exception | if error occurred while trying to load the given RIFF-alike file |
Definition at line 1695 of file RIFF.cpp.
References FileOffsetSize, RIFF::offset_size_64bit, and SetByteOrder().
|
inherited |
Creates a new sub chunk.
Creates and adds a new sub chunk to this list chunk. Note that the chunk's body size given by ullBodySize must be greater than zero. You have to call File::Save() to make this change persistent to the actual file and before performing any data write operations on the new chunk!
uiChunkID | - chunk ID of the new chunk |
ullBodySize | - size of the new chunk's body, that is its actual data size (without header) |
RIFF::Exception | if ullBodySize equals zero |
Definition at line 1310 of file RIFF.cpp.
References FileOffsetSize, and RIFF::Chunk::Resize().
Referenced by DLS::File::__ensureMandatoryChunksExist(), gig::File::AddInstrument(), gig::File::AddSample(), gig::File::RebuildSampleChecksumTable(), DLS::Sample::Resize(), DLS::Resource::UpdateChunks(), DLS::Sampler::UpdateChunks(), DLS::Sample::UpdateChunks(), DLS::Region::UpdateChunks(), DLS::Instrument::UpdateChunks(), DLS::File::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Sample::UpdateChunks(), gig::Region::UpdateChunks(), gig::Script::UpdateChunks(), gig::Instrument::UpdateChunks(), and gig::File::UpdateChunks().
|
inherited |
Creates a new list sub chunk.
Creates and adds a new list sub chunk to this list chunk. Note that you have to add sub chunks / sub list chunks to the new created chunk before trying to make this change persisten to the actual file with File::Save()!
uiListType | - list ID of the new list chunk |
Definition at line 1380 of file RIFF.cpp.
References FileOffsetSize.
Referenced by DLS::File::__ensureMandatoryChunksExist(), gig::Region::AddDimension(), DLS::File::AddInstrument(), gig::File::AddInstrument(), DLS::File::AddSample(), gig::File::AddSample(), gig::Region::DeleteDimensionZone(), gig::Region::SplitDimensionZone(), DLS::Info::UpdateChunks(), gig::Region::UpdateChunks(), gig::ScriptGroup::UpdateChunks(), gig::Instrument::UpdateChunks(), gig::Group::UpdateChunks(), and gig::File::UpdateChunks().
|
inherited |
Removes a sub chunk.
Removes the sub chunk given by pSubChunk from this list and frees it completely from RAM. The given chunk can either be a normal sub chunk or a list sub chunk. In case the given chunk is a list chunk, all its subchunks (if any) will be removed recursively as well. You should call File::Save() to make this change persistent at any time.
pSubChunk | - sub chunk or sub list chunk to be removed |
Definition at line 1399 of file RIFF.cpp.
References RIFF::Chunk::GetChunkID().
Referenced by DLS::Sample::DeleteChunks(), DLS::Region::DeleteChunks(), DLS::Instrument::DeleteChunks(), gig::Group::DeleteChunks(), gig::Region::DeleteDimension(), gig::ScriptGroup::DeleteScript(), gig::File::DeleteScriptGroup(), DLS::File::UpdateChunks(), gig::Sample::UpdateChunks(), gig::Region::UpdateChunks(), gig::Instrument::UpdateChunks(), and gig::File::UpdateChunks().
|
inherited |
file_offset_t RIFF::File::GetCurrentFileSize | ( | ) | const |
Returns the current size of this file (in bytes) as it is currently yet stored on disk.
If this file does not yet exist on disk (i.e. when this RIFF File has just been created from scratch and Save() has not been called yet) then this method returns 0.
Definition at line 2192 of file RIFF.cpp.
References hFileRead.
Referenced by GetRequiredFileOffsetSize(), and Save().
int RIFF::File::GetFileOffsetSize | ( | ) | const |
Returns the current size (in bytes) of file offsets stored in the headers of all chunks of this file.
Most RIFF files are using 32 bit file offsets internally, which limits them to a maximum file size of less than 4 GB though. In contrast to the common standard, this RIFF File class implementation supports handling of RIFF files equal or larger than 4 GB. In such cases 64 bit file offsets have to be used in all headers of all RIFF Chunks when being stored to a physical file. libgig by default automatically selects the correct file offset size for you. You may however also force one particular file offset size by supplying the respective option to the RIFF::File constructor.
This method can be used to check which RIFF file offset size is currently being used for this RIFF File.
Definition at line 2285 of file RIFF.cpp.
References FileOffsetSize.
Referenced by DLS::Sample::Sample().
|
inherited |
Returns the first subchunk within the list (which may be an ordinary chunk as well as a list chunk).
You have to call this method before you can call GetNextSubChunk(). Recall it when you want to start from the beginning of the list again.
Definition at line 1173 of file RIFF.cpp.
Referenced by gig::Group::UpdateChunks(), and gig::File::UpdateChunks().
|
inherited |
Returns the first sublist within the list (that is a subchunk with chunk ID "LIST").
You have to call this method before you can call GetNextSubList(). Recall it when you want to start from the beginning of the list again.
|
inherited |
Returns the next subchunk within the list (which may be an ordinary chunk as well as a list chunk).
You have to call GetFirstSubChunk() before you can use this method!
Definition at line 1190 of file RIFF.cpp.
Referenced by gig::Group::UpdateChunks(), and gig::File::UpdateChunks().
|
inherited |
Returns the next sublist (that is a subchunk with chunk ID "LIST") within the list.
You have to call GetFirstSubList() before you can use this method!
int RIFF::File::GetRequiredFileOffsetSize | ( | ) |
Returns the required size (in bytes) of file offsets stored in the headers of all chunks of this file if the current RIFF tree would be saved to disk by calling Save().
See GetFileOffsetSize() for mor details about RIFF file offsets.
Definition at line 2299 of file RIFF.cpp.
References GetCurrentFileSize().
file_offset_t RIFF::File::GetRequiredFileSize | ( | ) |
Returns the required size (in bytes) for this RIFF File to be saved to disk.
The precise size of the final file on disk depends on the RIFF file offset size actually used internally in all headers of the RIFF chunks. By default libgig handles the required file offset size automatically for you; that means it is using 32 bit offsets for files smaller than 4 GB and 64 bit offsets for files equal or larger than 4 GB. You may however also override this default behavior by passing the respective option to the RIFF File constructor to force one particular offset size. In the latter case this method will return the file size for the requested forced file offset size that will be used when calling Save() later on.
You may also use the overridden method below to get the file size for an arbitrary other file offset size instead.
Definition at line 2221 of file RIFF.cpp.
Referenced by GetRequiredFileSize(), Save(), and DLS::File::UpdateChunks().
file_offset_t RIFF::File::GetRequiredFileSize | ( | offset_size_t | fileOffsetSize | ) |
Returns the rquired size (in bytes) for this RIFF file to be saved to disk, assuming the passed fileOffsestSize would be used for the Save() operation.
This overridden method essentialy behaves like the above method, with the difference that you must provide a specific RIFF fileOffsetSize for calculating the theoretical final file size.
Definition at line 2236 of file RIFF.cpp.
References FileOffsetSize, GetRequiredFileSize(), RIFF::offset_size_32bit, RIFF::offset_size_64bit, RIFF::offset_size_auto, and RIFF::List::RequiredPhysicalSize().
|
inherited |
Returns the current state of the chunk object.
Following values are possible:
Definition at line 343 of file RIFF.cpp.
References hFileRead.
|
inherited |
Returns subchunk with chunk ID ChunkID within this chunk list.
Use this method if you expect only one subchunk of that type in the list. It there are more than one, it's undetermined which one of them will be returned! If there are no subchunks with that desired chunk ID, NULL will be returned.
ChunkID | - chunk ID of the sought subchunk |
Definition at line 1128 of file RIFF.cpp.
Referenced by DLS::File::__ensureMandatoryChunksExist(), DLS::File::File(), Korg::KSFSample::GetPos(), DLS::Instrument::Instrument(), Korg::KSFSample::Read(), gig::File::RebuildSampleChecksumTable(), DLS::Sample::Resize(), DLS::Resource::Resource(), DLS::Sample::Sample(), gig::Sample::Sample(), Korg::KSFSample::SetPos(), gig::File::SetSampleChecksum(), DLS::Resource::UpdateChunks(), DLS::Sampler::UpdateChunks(), DLS::Sample::UpdateChunks(), DLS::Region::UpdateChunks(), DLS::Instrument::UpdateChunks(), DLS::File::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Sample::UpdateChunks(), gig::Region::UpdateChunks(), gig::Instrument::UpdateChunks(), gig::Group::UpdateChunks(), gig::File::UpdateChunks(), and gig::File::VerifySampleChecksumTable().
|
inherited |
Returns sublist chunk with list type ListType within this chunk list.
Use this method if you expect only one sublist chunk of that type in the list. If there are more than one, it's undetermined which one of them will be returned! If there are no sublists with that desired list type, NULL will be returned.
ListType | - list type of the sought sublist |
Definition at line 1147 of file RIFF.cpp.
References RIFF::List::GetListType().
Referenced by DLS::File::__ensureMandatoryChunksExist(), gig::Region::AddDimension(), DLS::File::AddInstrument(), gig::File::AddInstrument(), DLS::File::AddSample(), gig::File::AddSample(), gig::Region::DeleteDimension(), gig::Region::DeleteDimensionZone(), DLS::Info::Info(), gig::Instrument::MoveTo(), gig::Region::SplitDimensionZone(), DLS::Info::UpdateChunks(), gig::Region::UpdateChunks(), gig::ScriptGroup::UpdateChunks(), gig::Instrument::UpdateChunks(), gig::Group::UpdateChunks(), and gig::File::UpdateChunks().
|
inherited |
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.
Exception | if data buffer could not be enlarged |
Definition at line 865 of file RIFF.cpp.
References RIFF::Chunk::GetSize(), and hFileRead.
Referenced by DLS::Sample::LoadSampleData(), gig::File::RebuildSampleChecksumTable(), DLS::Articulation::UpdateChunks(), DLS::Resource::UpdateChunks(), DLS::Sampler::UpdateChunks(), DLS::Sample::UpdateChunks(), DLS::Region::UpdateChunks(), DLS::Instrument::UpdateChunks(), DLS::File::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Sample::UpdateChunks(), gig::Region::UpdateChunks(), gig::Script::UpdateChunks(), gig::Instrument::UpdateChunks(), gig::File::UpdateChunks(), gig::File::VerifySampleChecksumTable(), and RIFF::Chunk::WriteChunk().
Moves a sub chunk witin this list.
Moves a sub chunk from one position in this list to another position in the same list. The pSrc chunk is placed before the pDst chunk.
pSrc | - sub chunk to be moved |
pDst | - the position to move to. pSrc will be placed before pDst. If pDst is 0, pSrc will be placed last in list. |
Definition at line 1332 of file RIFF.cpp.
Referenced by gig::Region::AddDimension(), gig::Instrument::MoveTo(), gig::File::RebuildSampleChecksumTable(), gig::Script::SetGroup(), gig::DimensionRegion::UpdateChunks(), gig::Region::UpdateChunks(), gig::Group::UpdateChunks(), and gig::File::UpdateChunks().
Moves a sub chunk from this list to another list.
Moves a sub chunk from this list list to the end of another list.
pSrc | - sub chunk to be moved |
pDst | - destination list where the chunk shall be moved to |
Definition at line 1347 of file RIFF.cpp.
References RIFF::Chunk::GetChunkID().
|
inherited |
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 374 of file RIFF.cpp.
References hFileRead, and RIFF::Chunk::SetPos().
Referenced by DLS::Articulation::Articulation(), DLS::File::File(), DLS::Instrument::Instrument(), DLS::Sample::Read(), gig::Sample::Read(), Korg::KSFSample::Read(), RIFF::Chunk::ReadSceptical(), DLS::Resource::Resource(), gig::Sample::Sample(), and DLS::File::UpdateChunks().
|
inherited |
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 occurred |
Definition at line 784 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred or less than WordCount integers could be read! |
Definition at line 591 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
Referenced by gig::Sample::Sample().
|
inherited |
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 occurred |
Definition at line 818 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred or less than WordCount integers could be read! |
Definition at line 665 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
Referenced by gig::Sample::Sample().
|
inherited |
Reads one 8 Bit signed integer word and increments the position within the chunk.
RIFF::Exception | if an error occurred |
Definition at line 751 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred or less than WordCount integers could be read! |
Definition at line 517 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
Reads a null-padded string of size characters and copies it into the string s.
The position within the chunk will automatically be incremented.
s | destination string |
size | number of characters to read |
RIFF::Exception | if an error occurred or less than size characters could be read! |
Definition at line 719 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred |
Definition at line 801 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred or less than WordCount integers could be read! |
Definition at line 628 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
Referenced by DLS::Sample::Sample().
|
inherited |
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 occurred |
Definition at line 835 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred or less than WordCount integers could be read! |
Definition at line 702 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
Referenced by DLS::Articulation::Articulation(), DLS::File::File(), DLS::Instrument::Instrument(), and DLS::Sample::Sample().
|
inherited |
Reads one 8 Bit unsigned integer word and increments the position within the chunk.
RIFF::Exception | if an error occurred |
Definition at line 767 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 occurred or less than WordCount integers could be read! |
Definition at line 554 of file RIFF.cpp.
References RIFF::Chunk::ReadSceptical().
|
inherited |
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 911 of file RIFF.cpp.
Referenced by DLS::Sample::ReleaseSampleData(), and DLS::Sample::~Sample().
|
inherited |
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 312 of file RIFF.cpp.
Referenced by gig::Sample::Read().
|
protectedvirtualinherited |
Returns the actual total size in bytes (including List chunk header and all subchunks) of this List Chunk if being stored to a file.
fileOffsetSize | - RIFF file offset size (in bytes) assumed when being saved to a file |
Reimplemented from RIFF::Chunk.
Definition at line 1424 of file RIFF.cpp.
Referenced by GetRequiredFileSize().
|
inherited |
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!
NewSize | - new chunk body size in bytes (must be greater than zero) |
RIFF::Exception | if NewSize is less than 1 or unrealistic large |
Definition at line 936 of file RIFF.cpp.
Referenced by RIFF::List::AddSubChunk(), gig::File::RebuildSampleChecksumTable(), DLS::Sample::Resize(), DLS::Articulation::UpdateChunks(), DLS::Sampler::UpdateChunks(), DLS::File::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Script::UpdateChunks(), gig::Instrument::UpdateChunks(), and gig::File::UpdateChunks().
|
virtual |
Save changes to another file.
Make all changes of all chunks persistent by writing them to another file. Caution: this method is optimized for writing to another file, do not use it to save the changes to the same file! Use File::Save() in that case instead! Ignoring this might result in a corrupted file, especially in case chunks were resized!
After calling this method, this File object will be associated with the new file (given by path) afterwards.
path | - path and file name where everything should be written to |
pProgress | - optional: callback function for progress notification |
Definition at line 2051 of file RIFF.cpp.
References FileOffsetSize, GetRequiredFileSize(), hFileRead, hFileWrite, Layout, RIFF::layout_flat, SetMode(), and RIFF::List::WriteChunk().
|
virtual |
Save changes to same file.
Make all changes of all chunks persistent by writing them to the actual (same) file.
pProgress | - optional: callback function for progress notification |
RIFF::Exception | if there is an empty chunk or empty list chunk or any kind of IO error occurred |
Definition at line 1927 of file RIFF.cpp.
References FileOffsetSize, GetCurrentFileSize(), GetRequiredFileSize(), hFileRead, hFileWrite, Layout, RIFF::layout_flat, SetMode(), and RIFF::List::WriteChunk().
Referenced by DLS::File::Save().
void RIFF::File::SetByteOrder | ( | endian_t | Endian | ) |
Set the byte order to be used when saving.
Set the byte order to be used in the file. A value of endian_little will create a RIFF file, endian_big a RIFX file and endian_native will create a RIFF file on little-endian machines and RIFX on big-endian machines.
Endian | - endianess to use when file is saved. |
Definition at line 1910 of file RIFF.cpp.
Referenced by DLS::File::File(), and File().
bool RIFF::File::SetMode | ( | stream_mode_t | NewMode | ) |
Change file access mode.
Changes files access mode either to read-only mode or to read/write mode.
NewMode | - new file access mode |
RIFF::Exception | if new file access mode is unknown |
Definition at line 1803 of file RIFF.cpp.
References RIFF::List::__resetPos(), hFileRead, and hFileWrite.
Referenced by gig::File::RebuildSampleChecksumTable(), and Save().
|
inherited |
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.
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 280 of file RIFF.cpp.
Referenced by DLS::Articulation::Articulation(), DLS::Sample::CopyAssign(), DLS::File::File(), DLS::Instrument::Instrument(), gig::Sample::Read(), RIFF::Chunk::Read(), DLS::Resource::Resource(), DLS::Sample::Sample(), gig::Sample::Sample(), DLS::Sample::SetPos(), gig::Sample::SetPos(), Korg::KSFSample::SetPos(), gig::File::SetSampleChecksum(), and RIFF::Chunk::Write().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of data words to write |
WordSize | size of each data word to write |
RIFF::Exception | if write operation would exceed current chunk size or any IO error occurred |
Definition at line 444 of file RIFF.cpp.
References hFileWrite, and RIFF::Chunk::SetPos().
Referenced by DLS::Sample::Write(), gig::Sample::Write(), RIFF::Chunk::WriteInt16(), RIFF::Chunk::WriteInt32(), RIFF::Chunk::WriteInt8(), RIFF::Chunk::WriteUint16(), RIFF::Chunk::WriteUint32(), and RIFF::Chunk::WriteUint8().
|
protectedvirtualinherited |
Write list chunk persistently e.g.
to disk.
Stores the list chunk persistently to its actual "physical" file. All subchunks (including sub list chunks) will be stored recursively as well.
ullWritePos | - position within the "physical" file where this list chunk should be written to |
ullCurrentDataOffset | - offset of current (old) data within the file |
pProgress | - optional: callback function for progress notification |
Reimplemented from RIFF::Chunk.
Definition at line 1553 of file RIFF.cpp.
References FileOffsetSize.
Referenced by Save().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of 16 Bit signed integers to write |
RIFF::Exception | if an IO error occurred |
Definition at line 612 of file RIFF.cpp.
References RIFF::Chunk::Write().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of 32 Bit signed integers to write |
RIFF::Exception | if an IO error occurred |
Definition at line 686 of file RIFF.cpp.
References RIFF::Chunk::Write().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of 8 Bit signed integers to write |
RIFF::Exception | if an IO error occurred |
Definition at line 538 of file RIFF.cpp.
References RIFF::Chunk::Write().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of 16 Bit unsigned integers to write |
RIFF::Exception | if an IO error occurred |
Definition at line 649 of file RIFF.cpp.
References RIFF::Chunk::Write().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of 32 Bit unsigned integers to write |
RIFF::Exception | if an IO error occurred |
Definition at line 740 of file RIFF.cpp.
References RIFF::Chunk::Write().
Referenced by gig::File::SetSampleChecksum().
|
inherited |
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.
pData | source buffer (containing the data) |
WordCount | number of 8 Bit unsigned integers to write |
RIFF::Exception | if an IO error occurred |
Definition at line 575 of file RIFF.cpp.
References RIFF::Chunk::Write().