libgig
3.3.0.svn3
|
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... | |
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 () |
Apply all the DLS file's current instruments, samples and settings to the respective RIFF chunks. More... | |
virtual void | Save (const String &Path) |
Save changes to another file. More... | |
virtual void | Save () |
Save changes to same file. More... | |
virtual | ~File () |
Resource * | GetParent () |
void | GenerateDLSID () |
Generates a new DLSID for the resource. 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 () |
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 1195 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 1224 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 1272 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 1568 of file DLS.cpp.
References RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), b64BitWavePoolOffsets, CHUNK_ID_PTBL, RIFF::List::GetSubChunk(), RIFF::List::GetSubList(), LIST_TYPE_LINS, LIST_TYPE_WVPL, pRIFF, and WavePoolHeaderSize.
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 1410 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 1350 of file DLS.cpp.
References __ensureMandatoryChunksExist(), RIFF::List::AddSubList(), RIFF::List::GetSubList(), LIST_TYPE_WAVE, LIST_TYPE_WVPL, LoadSamples(), pRIFF, and pSamples.
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 1427 of file DLS.cpp.
References pInstruments.
void DLS::File::DeleteSample | ( | Sample * | pSample | ) |
|
inherited |
Generates a new DLSID for the resource.
Definition at line 450 of file DLS.cpp.
References DLS::dlsid_t::abData, DLS::Resource::pDLSID, DLS::dlsid_t::ulData1, DLS::dlsid_t::usData2, and DLS::dlsid_t::usData3.
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 1447 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 1464 of file DLS.cpp.
References RIFF::File::GetFileName(), and pRIFF.
Instrument * DLS::File::GetFirstInstrument | ( | ) |
Returns a pointer to the first Instrument object of the file, NULL otherwise.
Definition at line 1376 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 1300 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 1383 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 1307 of file DLS.cpp.
References pSamples, and SamplesIterator.
Referenced by DLS::Region::GetSample().
|
inlineinherited |
Definition at line 328 of file DLS.h.
References DLS::Resource::pParent.
Referenced by gig::Region::AddDimension(), DLS::Region::GetSample(), gig::Region::GetSampleFromWavePool(), gig::Region::Region(), DLS::Region::SetKeyRange(), gig::Region::SetKeyRange(), DLS::Region::UpdateChunks(), gig::DimensionRegion::UpdateChunks(), gig::Region::UpdateChunks(), gig::Instrument::UpdateChunks(), and gig::Sample::Write().
|
protectedvirtual |
Reimplemented in gig::File.
Definition at line 1389 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 1313 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 |
Definition at line 1542 of file DLS.cpp.
References pRIFF, RIFF::File::Save(), and UpdateChunks().
|
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.
RIFF::Exception | if any kind of IO error occured |
DLS::Exception | if any kind of DLS specific error occured |
Definition at line 1557 of file DLS.cpp.
References pRIFF, RIFF::File::Save(), and UpdateChunks().
|
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.
Exception | - on errors |
Reimplemented from DLS::Resource.
Reimplemented in gig::File.
Definition at line 1475 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().
|
protected |
Definition at line 501 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), UpdateChunks(), and gig::File::UpdateChunks().
|
protected |
Definition at line 492 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 469 of file DLS.h.
Referenced by File(), gig::File::LoadInstruments(), UpdateChunks(), and gig::File::UpdateChunks().
|
protected |
Definition at line 496 of file DLS.h.
Referenced by GetFirstInstrument(), gig::File::GetFirstInstrument(), gig::File::GetInstrument(), GetNextInstrument(), and gig::File::GetNextInstrument().
|
inherited |
Points to a dlsid_t structure if the file provided a DLS ID else is NULL.
Definition at line 326 of file DLS.h.
Referenced by DLS::Resource::GenerateDLSID(), DLS::Resource::Resource(), DLS::Resource::UpdateChunks(), and DLS::Resource::~Resource().
|
inherited |
Points (in any case) to an Info object, providing additional, optional infos and comments.
Definition at line 325 of file DLS.h.
Referenced by gig::File::AddInstrument(), gig::File::File(), gig::Instrument::Instrument(), DLS::Resource::Resource(), gig::Sample::Sample(), DLS::Resource::UpdateChunks(), and DLS::Resource::~Resource().
|
protected |
Definition at line 495 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(), UpdateChunks(), and ~File().
|
protectedinherited |
Definition at line 332 of file DLS.h.
Referenced by DLS::Resource::GetParent(), DLS::Resource::Resource(), gig::Sample::UpdateChunks(), DLS::Instrument::~Instrument(), DLS::Region::~Region(), and DLS::Sample::~Sample().
|
protectedinherited |
Definition at line 333 of file DLS.h.
Referenced by DLS::Resource::Resource(), and DLS::Resource::UpdateChunks().
|
protected |
Definition at line 491 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), AddInstrument(), gig::File::AddInstrument(), AddSample(), gig::File::AddSample(), File(), gig::File::File(), GetFileName(), gig::File::LoadGroups(), LoadInstruments(), gig::File::LoadInstruments(), LoadSamples(), gig::File::LoadSamples(), Save(), gig::File::SetSampleChecksum(), UpdateChunks(), gig::Group::UpdateChunks(), and gig::File::UpdateChunks().
|
protected |
Definition at line 493 of file DLS.h.
Referenced by AddSample(), gig::File::AddSample(), DeleteSample(), gig::File::DeleteSample(), File(), GetFirstSample(), gig::File::GetFirstSample(), GetNextSample(), gig::File::GetNextSample(), 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 468 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::Group::UpdateChunks(), gig::File::UpdateChunks(), and ~File().
|
protected |
Definition at line 499 of file DLS.h.
Referenced by File(), DLS::Region::GetSample(), gig::Region::GetSampleFromWavePool(), gig::Region::Region(), and ~File().
|
protected |
Definition at line 500 of file DLS.h.
Referenced by File(), gig::Region::GetSampleFromWavePool(), gig::File::LoadSamples(), and ~File().
|
protected |
Definition at line 494 of file DLS.h.
Referenced by gig::File::DeleteSample(), GetFirstSample(), gig::File::GetFirstSample(), GetNextSample(), and gig::File::GetNextSample().
|
protected |
Definition at line 498 of file DLS.h.
Referenced by File(), gig::File::LoadSamples(), and UpdateChunks().
|
protected |
Definition at line 497 of file DLS.h.
Referenced by __ensureMandatoryChunksExist(), File(), and UpdateChunks().