DLS::File Class Reference

Parses DLS Level 1 and 2 compliant files and provides abstract access to the data. More...

#include <DLS.h>

Inheritance diagram for DLS::File:

DLS::Resource gig::File

List of all members.

Public Member Functions

 File ()
 Constructor.
 File (RIFF::File *pRIFF)
 Constructor.
SampleGetFirstSample ()
 Returns a pointer to the first Sample object of the file, NULL otherwise.
SampleGetNextSample ()
 Returns a pointer to the next Sample object of the file, NULL otherwise.
SampleAddSample ()
 Add a new sample.
void DeleteSample (Sample *pSample)
 Delete a sample.
InstrumentGetFirstInstrument ()
 Returns a pointer to the first Instrument object of the file, NULL otherwise.
InstrumentGetNextInstrument ()
 Returns a pointer to the next Instrument object of the file, NULL otherwise.
InstrumentAddInstrument ()
 Add a new instrument definition.
void DeleteInstrument (Instrument *pInstrument)
 Delete an instrument.
virtual void UpdateChunks ()
 Apply all the DLS file's current instruments, samples and settings to the respective RIFF chunks.
virtual void Save (const String &Path)
 Save changes to another file.
virtual void Save ()
 Save changes to same file.
virtual ~File ()
ResourceGetParent ()
void GenerateDLSID ()
 Generates a new DLSID for the resource.

Public Attributes

version_tpVersion
 Points to a version_t structure if the file provided a version number else is set to NULL.
uint32_t Instruments
 Reflects the number of available Instrument objects.
InfopInfo
 Points (in any case) to an Info object, providing additional, optional infos and comments.
dlsid_tpDLSID
 Points to a dlsid_t structure if the file provided a DLS ID else is NULL.

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.

Protected Attributes

RIFF::FilepRIFF
std::list< RIFF::File * > ExtensionFiles
SampleListpSamples
SampleList::iterator SamplesIterator
InstrumentListpInstruments
InstrumentList::iterator InstrumentsIterator
uint32_t WavePoolHeaderSize
uint32_t WavePoolCount
uint32_t * pWavePoolTable
uint32_t * pWavePoolTableHi
bool b64BitWavePoolOffsets
ResourcepParent
RIFF::ListpResourceList

Friends

class Region


Detailed Description

Parses DLS Level 1 and 2 compliant files and provides abstract access to the data.

Definition at line 482 of file DLS.h.


Member Typedef Documentation

typedef std::list<Instrument*> DLS::File::InstrumentList [protected]

Definition at line 503 of file DLS.h.

typedef std::list<Sample*> DLS::File::SampleList [protected]

Definition at line 502 of file DLS.h.


Constructor & Destructor Documentation

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.

Reimplemented in gig::File.

Definition at line 1193 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.

Parameters:
pRIFF - pointer to a RIFF file which is actually the DLS file to load
Exceptions:
Exception if given file is not a DLS file, expected chunks are missing

Reimplemented in gig::File.

Definition at line 1222 of file DLS.cpp.

References b64BitWavePoolOffsets, CHUNK_ID_COLH, CHUNK_ID_PTBL, CHUNK_ID_VERS, RIFF::Chunk::GetSize(), RIFF::List::GetSubChunk(), Instruments, pInstruments, pSamples, pVersion, pWavePoolTable, pWavePoolTableHi, RIFF::Chunk::Read(), RIFF::Chunk::ReadUint32(), RIFF::Chunk::SetPos(), WavePoolCount, and WavePoolHeaderSize.

DLS::File::~File (  )  [virtual]

Reimplemented in gig::File.

Definition at line 1270 of file DLS.cpp.

References ExtensionFiles, pInstruments, pSamples, pVersion, pWavePoolTable, and pWavePoolTableHi.


Member Function Documentation

void DLS::File::__ensureMandatoryChunksExist (  )  [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 1533 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(), gig::File::AddInstrument(), AddInstrument(), gig::File::AddSample(), and 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.

Returns:
pointer to new Instrument object

Reimplemented in gig::File.

Definition at line 1408 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.

Returns:
pointer to new Sample object

Reimplemented in gig::File.

Definition at line 1348 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.

Parameters:
pInstrument - instrument to delete

Definition at line 1425 of file DLS.cpp.

References pInstruments.

void DLS::File::DeleteSample ( Sample pSample  ) 

Delete a sample.

This will delete the given Sample object from the DLS file. You have to call Save() to make this persistent to the file.

Parameters:
pSample - sample to delete

Definition at line 1366 of file DLS.cpp.

References pSamples.

void DLS::Resource::GenerateDLSID (  )  [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().

Instrument * DLS::File::GetFirstInstrument (  ) 

Returns a pointer to the first Instrument object of the file, NULL otherwise.

Reimplemented in gig::File.

Definition at line 1374 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 1298 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.

Reimplemented in gig::File.

Definition at line 1381 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.

Reimplemented in gig::File.

Definition at line 1305 of file DLS.cpp.

References pSamples, and SamplesIterator.

Referenced by DLS::Region::GetSample().

Resource* DLS::Resource::GetParent (  )  [inline, inherited]

void DLS::File::LoadInstruments (  )  [protected, virtual]

void DLS::File::LoadSamples (  )  [protected, virtual]

void DLS::File::Save (  )  [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.

Exceptions:
RIFF::Exception if any kind of IO error occured
DLS::Exception if any kind of DLS specific error occured

Definition at line 1522 of file DLS.cpp.

References pRIFF, RIFF::File::Save(), and UpdateChunks().

void DLS::File::Save ( const String Path  )  [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.

Parameters:
Path - path and file name where everything should be written to

Definition at line 1507 of file DLS.cpp.

References pRIFF, RIFF::File::Save(), and UpdateChunks().

void DLS::File::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.

Exceptions:
Exception - on errors

Reimplemented from DLS::Resource.

Reimplemented in gig::File.

Definition at line 1440 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(), WavePoolCount, and WavePoolHeaderSize.

Referenced by Save().


Friends And Related Function Documentation

friend class Region [friend]

Reimplemented in gig::File.

Definition at line 520 of file DLS.h.


Member Data Documentation

Definition at line 515 of file DLS.h.

Referenced by __ensureMandatoryChunksExist(), File(), gig::File::UpdateChunks(), and UpdateChunks().

std::list<RIFF::File*> DLS::File::ExtensionFiles [protected]

Definition at line 506 of file DLS.h.

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

Reflects the number of available Instrument objects.

Definition at line 485 of file DLS.h.

Referenced by File(), gig::File::LoadInstruments(), gig::File::UpdateChunks(), and UpdateChunks().

InstrumentList::iterator DLS::File::InstrumentsIterator [protected]

Points to a dlsid_t structure if the file provided a DLS ID else is NULL.

Definition at line 342 of file DLS.h.

Referenced by DLS::Resource::GenerateDLSID(), DLS::Resource::Resource(), DLS::Resource::UpdateChunks(), and DLS::Resource::~Resource().

Info* DLS::Resource::pInfo [inherited]

Points (in any case) to an Info object, providing additional, optional infos and comments.

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

Resource* DLS::Resource::pParent [protected, inherited]

RIFF::List* DLS::Resource::pResourceList [protected, inherited]

Definition at line 349 of file DLS.h.

Referenced by DLS::Resource::Resource(), and DLS::Resource::UpdateChunks().

uint32_t* DLS::File::pWavePoolTable [protected]

uint32_t* DLS::File::pWavePoolTableHi [protected]

Definition at line 514 of file DLS.h.

Referenced by File(), gig::Region::GetSampleFromWavePool(), gig::File::LoadSamples(), and ~File().

SampleList::iterator DLS::File::SamplesIterator [protected]

uint32_t DLS::File::WavePoolCount [protected]

Definition at line 512 of file DLS.h.

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

uint32_t DLS::File::WavePoolHeaderSize [protected]

Definition at line 511 of file DLS.h.

Referenced by __ensureMandatoryChunksExist(), File(), and UpdateChunks().


The documentation for this class was generated from the following files:

doxygen