libgig
4.0.0
|
Parses DLS Level 1 and 2 compliant files and provides abstract access to the data. More...
#include <DLS.h>
Public Member Functions | |
File () | |
Constructor. More... | |
File (RIFF::File *pRIFF) | |
Constructor. More... | |
String | GetFileName () |
File name of this DLS file. More... | |
void | SetFileName (const String &name) |
You may call this method store a future file name, so you don't have to to pass it to the Save() call later on. More... | |
Sample * | GetFirstSample () |
Returns a pointer to the first Sample object of the file, NULL otherwise. More... | |
Sample * | GetNextSample () |
Returns a pointer to the next Sample object of the file, NULL otherwise. More... | |
Sample * | AddSample () |
Add a new sample. More... | |
void | DeleteSample (Sample *pSample) |
Delete a sample. More... | |
Instrument * | GetFirstInstrument () |
Returns a pointer to the first Instrument object of the file, NULL otherwise. More... | |
Instrument * | GetNextInstrument () |
Returns a pointer to the next Instrument object of the file, NULL otherwise. More... | |
Instrument * | AddInstrument () |
Add a new instrument definition. More... | |
void | DeleteInstrument (Instrument *pInstrument) |
Delete an instrument. More... | |
RIFF::File * | GetExtensionFile (int index) |
Returns extension file of given index. More... | |
virtual void | UpdateChunks (progress_t *pProgress) |
Apply all the DLS file's current instruments, samples and settings to the respective RIFF chunks. More... | |
virtual void | Save (const String &Path, progress_t *pProgress=NULL) |
Save changes to another file. More... | |
virtual void | Save (progress_t *pProgress=NULL) |
Save changes to same file. More... | |
virtual | ~File () |
Resource * | GetParent () |
const Resource * | GetParent () const |
void | GenerateDLSID () |
Generates a new DLSID for the resource. More... | |
virtual void | CopyAssign (const Resource *orig) |
Make a deep copy of the Resource object given by orig and assign it to this object. More... | |
Public Attributes | |
version_t * | pVersion |
Points to a version_t structure if the file provided a version number else is set to NULL. More... | |
uint32_t | Instruments |
Reflects the number of available Instrument objects. More... | |
Info * | pInfo |
Points (in any case) to an Info object, providing additional, optional infos and comments. More... | |
dlsid_t * | pDLSID |
Points to a dlsid_t structure if the file provided a DLS ID else is NULL. More... | |
Protected Types | |
typedef std::list< Sample * > | SampleList |
typedef std::list< Instrument * > | InstrumentList |
Protected Member Functions | |
virtual void | LoadSamples () |
virtual void | LoadInstruments () |
virtual void | UpdateFileOffsets () |
Updates all file offsets stored all over the file. More... | |
void | __ensureMandatoryChunksExist () |
Checks if all (for DLS) mandatory chunks exist, if not they will be created. More... | |
Protected Attributes | |
RIFF::File * | pRIFF |
std::list< RIFF::File * > | ExtensionFiles |
SampleList * | pSamples |
SampleList::iterator | SamplesIterator |
InstrumentList * | pInstruments |
InstrumentList::iterator | InstrumentsIterator |
uint32_t | WavePoolHeaderSize |
uint32_t | WavePoolCount |
uint32_t * | pWavePoolTable |
uint32_t * | pWavePoolTableHi |
bool | b64BitWavePoolOffsets |
Resource * | pParent |
RIFF::List * | pResourceList |
Friends | |
class | Region |
Parses DLS Level 1 and 2 compliant files and provides abstract access to the data.
|
protected |
|
protected |
DLS::File::File | ( | ) |
Constructor.
Default constructor, use this to create an empty DLS file. You have to add samples, instruments and finally call Save() to actually write a DLS file.
Definition at line 1406 of file DLS.cpp.
References b64BitWavePoolOffsets, DLS::version_t::build, RIFF::endian_little, Instruments, DLS::version_t::major, DLS::version_t::minor, pInstruments, pRIFF, pSamples, pVersion, pWavePoolTable, pWavePoolTableHi, DLS::version_t::release, RIFF::File::SetByteOrder(), WavePoolCount, and WavePoolHeaderSize.
DLS::File::File | ( | RIFF::File * | pRIFF | ) |
Constructor.
Load an existing DLS file.
Definition at line 1435 of file DLS.cpp.
References b64BitWavePoolOffsets, CHUNK_ID_COLH, CHUNK_ID_PTBL, CHUNK_ID_VERS, RIFF::Chunk::GetSize(), RIFF::List::GetSubChunk(), Instruments, pInstruments, pRIFF, pSamples, pVersion, pWavePoolTable, pWavePoolTableHi, RIFF::Chunk::Read(), RIFF::Chunk::ReadUint32(), RIFF::Chunk::SetPos(), WavePoolCount, and WavePoolHeaderSize.
|
virtual |
Reimplemented in gig::File.
Definition at line 1483 of file DLS.cpp.
References ExtensionFiles, pInstruments, pSamples, pVersion, pWavePoolTable, and pWavePoolTableHi.
|
protected |
Checks if all (for DLS) mandatory chunks exist, if not they will be created.
Note that those chunks will not be made persistent until Save() was called.
Definition at line 1855 of file DLS.cpp.
References RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), b64BitWavePoolOffsets, CHUNK_ID_PTBL, RIFF::Chunk::GetFilePos(), RIFF::Chunk::GetPos(), RIFF::Chunk::GetSize(), RIFF::List::GetSubChunk(), RIFF::List::GetSubList(), LIST_HEADER_SIZE, LIST_TYPE_LINS, LIST_TYPE_WVPL, pRIFF, pSamples, pWavePoolTable, pWavePoolTableHi, RIFF::Chunk::SetPos(), WavePoolCount, WavePoolHeaderSize, and RIFF::Chunk::WriteUint32().
Referenced by gig::File::AddGroup(), AddInstrument(), gig::File::AddInstrument(), AddSample(), and gig::File::AddSample().
Instrument * DLS::File::AddInstrument | ( | ) |
Add a new instrument definition.
This will create a new Instrument object for the DLS file. You have to call Save() to make this persistent to the file.
Definition at line 1621 of file DLS.cpp.
References __ensureMandatoryChunksExist(), RIFF::List::AddSubList(), RIFF::List::GetSubList(), LIST_TYPE_INS, LIST_TYPE_LINS, LoadInstruments(), pInstruments, and pRIFF.
Sample * DLS::File::AddSample | ( | ) |
Add a new sample.
This will create a new Sample object for the DLS file. You have to call Save() to make this persistent to the file.
Definition at line 1561 of file DLS.cpp.
References __ensureMandatoryChunksExist(), RIFF::List::AddSubList(), RIFF::List::GetSubList(), LIST_TYPE_WAVE, LIST_TYPE_WVPL, LoadSamples(), pRIFF, and pSamples.
|
virtualinherited |
Make a deep copy of the Resource object given by orig and assign it to this object.
orig | - original Resource object to be copied from |
Definition at line 542 of file DLS.cpp.
References DLS::Resource::pInfo.
Referenced by DLS::Region::CopyAssign(), DLS::Sample::CopyAssignCore(), and DLS::Instrument::CopyAssignCore().
void DLS::File::DeleteInstrument | ( | Instrument * | pInstrument | ) |
Delete an instrument.
This will delete the given Instrument object from the DLS file. You have to call Save() to make this persistent to the file.
pInstrument | - instrument to delete |
Definition at line 1638 of file DLS.cpp.
References pInstruments.
void DLS::File::DeleteSample | ( | Sample * | pSample | ) |
|
inherited |
Generates a new DLSID for the resource.
Definition at line 495 of file DLS.cpp.
Referenced by gig::File::AddInstrument(), and gig::File::File().
RIFF::File * DLS::File::GetExtensionFile | ( | int | index | ) |
Returns extension file of given index.
Extension files are used sometimes to circumvent the 2 GB file size limit of the RIFF format and of certain operating systems in general. In this case, instead of just using one file, the content is spread among several files with similar file name scheme. This is especially used by some GigaStudio sound libraries.
index | - index of extension file |
Definition at line 1658 of file DLS.cpp.
References ExtensionFiles.
String DLS::File::GetFileName | ( | ) |
This method returns the file name as it was provided when loading the respective DLS file. However in case the File object associates an empty, that is new DLS file, which was not yet saved to disk, this method will return an empty string.
Definition at line 1675 of file DLS.cpp.
References RIFF::File::GetFileName(), and pRIFF.
Referenced by gig::File::AddContentOf().
Instrument * DLS::File::GetFirstInstrument | ( | ) |
Returns a pointer to the first Instrument object of the file, NULL otherwise.
Definition at line 1587 of file DLS.cpp.
References InstrumentsIterator, LoadInstruments(), and pInstruments.
Sample * DLS::File::GetFirstSample | ( | ) |
Returns a pointer to the first Sample object of the file, NULL otherwise.
Definition at line 1511 of file DLS.cpp.
References LoadSamples(), pSamples, and SamplesIterator.
Referenced by gig::File::GetInstrument(), DLS::Region::GetSample(), and gig::File::UpdateChunks().
Instrument * DLS::File::GetNextInstrument | ( | ) |
Returns a pointer to the next Instrument object of the file, NULL otherwise.
Definition at line 1594 of file DLS.cpp.
References InstrumentsIterator, and pInstruments.
Sample * DLS::File::GetNextSample | ( | ) |
Returns a pointer to the next Sample object of the file, NULL otherwise.
Definition at line 1518 of file DLS.cpp.
References pSamples, and SamplesIterator.
Referenced by DLS::Region::GetSample().
|
inlineinherited |
Definition at line 350 of file DLS.h.
Referenced by gig::Region::AddDimension(), DLS::Region::CopyAssign(), gig::DimensionRegion::CopyAssign(), gig::Region::DeleteDimensionZone(), DLS::Region::GetSample(), gig::Region::GetSampleFromWavePool(), gig::Instrument::LoadScripts(), gig::Instrument::MoveTo(), gig::Region::Region(), DLS::Region::SetKeyRange(), gig::Region::SetKeyRange(), gig::Region::SplitDimensionZone(), DLS::Region::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Region::UpdateChunks(), gig::Instrument::UpdateChunks(), and gig::Sample::Write().
|
inlineinherited |
|
protectedvirtual |
Reimplemented in gig::File.
Definition at line 1600 of file DLS.cpp.
References RIFF::List::GetFirstSubList(), RIFF::List::GetListType(), RIFF::List::GetNextSubList(), RIFF::List::GetSubList(), LIST_TYPE_INS, LIST_TYPE_LINS, pInstruments, and pRIFF.
Referenced by AddInstrument(), and GetFirstInstrument().
|
protectedvirtual |
Reimplemented in gig::File.
Definition at line 1524 of file DLS.cpp.
References RIFF::Chunk::GetFilePos(), RIFF::List::GetFirstSubList(), RIFF::List::GetListType(), RIFF::List::GetNextSubList(), RIFF::List::GetSubList(), LIST_TYPE_DWPL, LIST_TYPE_WAVE, LIST_TYPE_WVPL, pRIFF, and pSamples.
Referenced by AddSample(), and GetFirstSample().
|
virtual |
Save changes to another file.
Make all changes 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 Save() (without path argument) in that case instead! Ignoring this might result in a corrupted file!
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 1787 of file DLS.cpp.
References pRIFF, RIFF::File::Save(), UpdateChunks(), and UpdateFileOffsets().
Referenced by gig::File::AddContentOf().
|
virtual |
Save changes to same file.
Make all changes persistent by writing them to the actual (same) file. The file might temporarily grow to a higher size than it will have at the end of the saving process.
pProgress | - optional: callback function for progress notification |
RIFF::Exception | if any kind of IO error occurred |
DLS::Exception | if any kind of DLS specific error occurred |
Definition at line 1817 of file DLS.cpp.
References pRIFF, RIFF::File::Save(), UpdateChunks(), and UpdateFileOffsets().
void DLS::File::SetFileName | ( | const String & | name | ) |
You may call this method store a future file name, so you don't have to to pass it to the Save() call later on.
Definition at line 1683 of file DLS.cpp.
References pRIFF, and RIFF::File::SetFileName().
|
virtual |
Apply all the DLS file's current instruments, samples and settings to the respective RIFF chunks.
You have to call Save() to make changes persistent.
pProgress | - callback function for progress notification |
Exception | - on errors |
Reimplemented from DLS::Resource.
Reimplemented in gig::File.
Definition at line 1695 of file DLS.cpp.
References RIFF::List::AddSubChunk(), b64BitWavePoolOffsets, DLS::version_t::build, CHUNK_ID_COLH, CHUNK_ID_PTBL, CHUNK_ID_VERS, RIFF::List::GetSubChunk(), Instruments, RIFF::Chunk::LoadChunkData(), DLS::version_t::major, DLS::version_t::minor, pInstruments, pRIFF, pSamples, pVersion, DLS::version_t::release, RIFF::Chunk::Resize(), DLS::Resource::UpdateChunks(), WavePoolCount, and WavePoolHeaderSize.
Referenced by Save(), and gig::File::UpdateChunks().
|
protectedvirtual |
Updates all file offsets stored all over the file.
This virtual method is called whenever the overall file layout has been changed (i.e. file or individual RIFF chunks have been resized). It is then the responsibility of this method to update all file offsets stored in the file format. For example samples are referenced by instruments by file offsets. The gig format also stores references to instrument scripts as file offsets, and thus it overrides this method to update those file offsets as well.
Reimplemented in gig::File.
Definition at line 1846 of file DLS.cpp.
Referenced by Save(), and gig::File::UpdateFileOffsets().
|
protected |
Definition at line 532 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), UpdateChunks(), and gig::File::UpdateChunks().
|
protected |
Definition at line 523 of file DLS.h.
Referenced by GetExtensionFile(), gig::File::LoadSamples(), and ~File().
uint32_t DLS::File::Instruments |
Reflects the number of available Instrument objects.
Definition at line 499 of file DLS.h.
Referenced by File(), gig::File::LoadInstruments(), UpdateChunks(), and gig::File::UpdateChunks().
|
protected |
Definition at line 527 of file DLS.h.
Referenced by GetFirstInstrument(), gig::File::GetFirstInstrument(), gig::File::GetInstrument(), GetNextInstrument(), and gig::File::GetNextInstrument().
|
inherited |
|
inherited |
Points (in any case) to an Info object, providing additional, optional infos and comments.
Definition at line 347 of file DLS.h.
Referenced by gig::File::AddInstrument(), DLS::Resource::CopyAssign(), gig::File::File(), gig::Instrument::Instrument(), and gig::Sample::Sample().
|
protected |
Definition at line 526 of file DLS.h.
Referenced by AddInstrument(), gig::File::AddInstrument(), DeleteInstrument(), gig::File::DeleteInstrument(), File(), GetFirstInstrument(), gig::File::GetFirstInstrument(), gig::File::GetInstrument(), GetNextInstrument(), gig::File::GetNextInstrument(), LoadInstruments(), gig::File::LoadInstruments(), gig::Instrument::MoveTo(), UpdateChunks(), and ~File().
|
protectedinherited |
Definition at line 356 of file DLS.h.
Referenced by gig::Sample::UpdateChunks(), DLS::Instrument::~Instrument(), DLS::Region::~Region(), and DLS::Sample::~Sample().
|
protectedinherited |
|
protected |
Definition at line 522 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), gig::File::AddContentOf(), AddInstrument(), gig::File::AddInstrument(), AddSample(), gig::File::AddSample(), File(), gig::File::File(), GetFileName(), gig::File::LoadGroups(), LoadInstruments(), gig::File::LoadInstruments(), LoadSamples(), gig::File::LoadSamples(), gig::File::LoadScriptGroups(), gig::Instrument::MoveTo(), Save(), SetFileName(), gig::File::SetSampleChecksum(), UpdateChunks(), and gig::File::UpdateChunks().
|
protected |
Definition at line 524 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), AddSample(), gig::File::AddSample(), DeleteSample(), gig::File::DeleteSample(), File(), GetFirstSample(), gig::File::GetFirstSample(), GetNextSample(), gig::File::GetNextSample(), gig::File::GetSample(), LoadSamples(), gig::File::LoadSamples(), gig::File::SetSampleChecksum(), DLS::Region::UpdateChunks(), UpdateChunks(), gig::Region::UpdateChunks(), gig::File::UpdateChunks(), and ~File().
version_t* DLS::File::pVersion |
Points to a version_t structure if the file provided a version number else is set to NULL.
Definition at line 498 of file DLS.h.
Referenced by gig::Region::AddDimension(), File(), gig::File::File(), gig::File::LoadGroups(), gig::Region::Region(), gig::DimensionRegion::UpdateChunks(), UpdateChunks(), gig::Region::UpdateChunks(), gig::Instrument::UpdateChunks(), gig::File::UpdateChunks(), and ~File().
|
protected |
Definition at line 530 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), DLS::Region::GetSample(), gig::Region::GetSampleFromWavePool(), gig::Region::Region(), and ~File().
|
protected |
Definition at line 531 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), gig::Region::GetSampleFromWavePool(), gig::File::LoadSamples(), and ~File().
|
protected |
Definition at line 525 of file DLS.h.
Referenced by gig::File::DeleteSample(), GetFirstSample(), gig::File::GetFirstSample(), GetNextSample(), and gig::File::GetNextSample().
|
protected |
Definition at line 529 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), gig::Region::GetSampleFromWavePool(), gig::File::LoadSamples(), and UpdateChunks().
|
protected |
Definition at line 528 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), and UpdateChunks().