libgig  3.3.0
gig::File Class Reference

Parses Gigasampler files and provides abstract access to the data. More...

#include <gig.h>

Inheritance diagram for gig::File:
DLS::File DLS::Resource

Public Member Functions

 File ()
 
 File (RIFF::File *pRIFF)
 
SampleGetFirstSample (progress_t *pProgress=NULL)
 Returns a pointer to the first Sample object of the file, NULL otherwise. More...
 
SampleGetNextSample ()
 Returns a pointer to the next Sample object of the file, NULL otherwise. More...
 
SampleAddSample ()
 Add a new sample. More...
 
void DeleteSample (Sample *pSample)
 Delete a sample. More...
 
InstrumentGetFirstInstrument ()
 Returns a pointer to the first Instrument object of the file, NULL otherwise. More...
 
InstrumentGetNextInstrument ()
 Returns a pointer to the next Instrument object of the file, NULL otherwise. More...
 
InstrumentGetInstrument (uint index, progress_t *pProgress=NULL)
 Returns the instrument with the given index. More...
 
InstrumentAddInstrument ()
 Add a new instrument definition. More...
 
void DeleteInstrument (Instrument *pInstrument)
 Delete an instrument. More...
 
GroupGetFirstGroup ()
 Returns a pointer to the first Group object of the file, NULL otherwise. More...
 
GroupGetNextGroup ()
 Returns a pointer to the next Group object of the file, NULL otherwise. More...
 
GroupGetGroup (uint index)
 Returns the group with the given index. More...
 
GroupAddGroup ()
 
void DeleteGroup (Group *pGroup)
 Delete a group and its samples. More...
 
void DeleteGroupOnly (Group *pGroup)
 Delete a group. More...
 
void SetAutoLoad (bool b)
 Enable / disable automatic loading. More...
 
bool GetAutoLoad ()
 Returns whether automatic loading is enabled. More...
 
virtual ~File ()
 
virtual void UpdateChunks ()
 Apply all the gig file's current instruments, samples, groups and settings to the respective RIFF chunks. More...
 

Static Public Attributes

static const DLS::version_t VERSION_2
 Reflects Gigasampler file format version 2.0 (1998-06-28). More...
 
static const DLS::version_t VERSION_3
 Reflects Gigasampler file format version 3.0 (2003-03-31). More...
 

Protected Types

typedef std::list< Sample * > SampleList
 
typedef std::list< Instrument * > InstrumentList
 

Protected Member Functions

virtual void LoadSamples ()
 
virtual void LoadInstruments ()
 
virtual void LoadGroups ()
 
virtual void LoadSamples (progress_t *pProgress)
 
virtual void LoadInstruments (progress_t *pProgress)
 
void SetSampleChecksum (Sample *pSample, uint32_t crc)
 Updates the 3crc chunk with the checksum of a sample. More...
 
SampleGetFirstSample ()
 Returns a pointer to the first Sample object of the file, NULL otherwise. More...
 
void DeleteSample (Sample *pSample)
 Delete a sample. More...
 
void DeleteInstrument (Instrument *pInstrument)
 Delete an instrument. More...
 
virtual void Save (const String &Path)
 Save changes to another file. More...
 
virtual void Save ()
 Save changes to same file. More...
 
void __ensureMandatoryChunksExist ()
 Checks if all (for DLS) mandatory chunks exist, if not they will be created. More...
 
ResourceGetParent ()
 
void GenerateDLSID ()
 Generates a new DLSID for the resource. More...
 

Protected 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...
 
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
 
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...
 
ResourcepParent
 
RIFF::ListpResourceList
 

Friends

class Region
 
class Sample
 
class Group
 

Detailed Description

Parses Gigasampler files and provides abstract access to the data.

Definition at line 747 of file gig.h.

Member Typedef Documentation

typedef std::list<Instrument*> DLS::File::InstrumentList
protectedinherited

Definition at line 503 of file DLS.h.

typedef std::list<Sample*> DLS::File::SampleList
protectedinherited

Definition at line 502 of file DLS.h.

Constructor & Destructor Documentation

gig::File::File ( RIFF::File pRIFF)

Definition at line 3342 of file gig.cpp.

References DLS::Resource::pInfo, and DLS::Info::SetFixedStringLengths().

gig::File::~File ( )
virtual

Reimplemented from DLS::File.

Definition at line 3348 of file gig.cpp.

Member Function Documentation

void DLS::File::__ensureMandatoryChunksExist ( )
protectedinherited

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(), DLS::File::b64BitWavePoolOffsets, CHUNK_ID_PTBL, RIFF::List::GetSubChunk(), RIFF::List::GetSubList(), LIST_TYPE_LINS, LIST_TYPE_WVPL, DLS::File::pRIFF, and DLS::File::WavePoolHeaderSize.

Referenced by AddGroup(), DLS::File::AddInstrument(), AddInstrument(), DLS::File::AddSample(), and AddSample().

Group * gig::File::AddGroup ( )

Definition at line 3671 of file gig.cpp.

References DLS::File::__ensureMandatoryChunksExist(), Group, and LoadGroups().

Instrument * gig::File::AddInstrument ( )

Add a new instrument definition.

This will create a new Instrument object for the gig file. You have to call Save() to make this persistent to the file.

Returns
pointer to new Instrument object

Definition at line 3548 of file gig.cpp.

References DLS::File::__ensureMandatoryChunksExist(), RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), CHUNK_ID_DLID, CHUNK_ID_INSH, DLS::Resource::GenerateDLSID(), RIFF::List::GetSubList(), LIST_TYPE_INFO, LIST_TYPE_INS, LIST_TYPE_LINS, LoadInstruments(), DLS::Resource::pInfo, DLS::File::pInstruments, DLS::File::pRIFF, and DLS::Info::Software.

Sample * gig::File::AddSample ( )

Add a new sample.

This will create a new Sample object for the gig file. You have to call Save() to make this persistent to the file.

Returns
pointer to new Sample object

Definition at line 3380 of file gig.cpp.

References DLS::File::__ensureMandatoryChunksExist(), RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), CHUNK_ID_FMT, RIFF::List::GetSubList(), LIST_TYPE_INFO, LIST_TYPE_WAVE, LIST_TYPE_WVPL, LoadSamples(), DLS::File::pRIFF, DLS::File::pSamples, and Sample.

void gig::File::DeleteGroup ( Group pGroup)

Delete a group and its samples.

This will delete the given Group object and all the samples that belong to this group from the gig file. You have to call Save() to make this persistent to the file.

Parameters
pGroup- group to delete
Exceptions
gig::Exceptionif given group could not be found

Definition at line 3689 of file gig.cpp.

References DeleteSample(), gig::Group::GetFirstSample(), gig::Group::GetNextSample(), and LoadGroups().

void gig::File::DeleteGroupOnly ( Group pGroup)

Delete a group.

This will delete the given Group object from the gig file. All the samples that belong to this group will not be deleted, but instead be moved to another group. You have to call Save() to make this persistent to the file.

Parameters
pGroup- group to delete
Exceptions
gig::Exceptionif given group could not be found

Definition at line 3713 of file gig.cpp.

References LoadGroups(), and gig::Group::MoveAll().

void DLS::File::DeleteInstrument ( Instrument pInstrument)
inherited

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

void gig::File::DeleteInstrument ( Instrument pInstrument)

Delete an instrument.

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

Parameters
pInstrument- instrument to delete
Exceptions
gig::Exceptionif given instrument could not be found

Definition at line 3578 of file gig.cpp.

References DLS::File::pInstruments.

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

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

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

Delete a sample.

This will delete the given Sample object from the gig file. Any references to this sample from Regions and DimensionRegions will be removed. You have to call Save() to make this persistent to the file.

Parameters
pSample- sample to delete
Exceptions
gig::Exceptionif given sample could not be found

Definition at line 3405 of file gig.cpp.

References GetFirstInstrument(), GetNextInstrument(), gig::DimensionRegion::pSample, DLS::File::pSamples, and DLS::File::SamplesIterator.

Referenced by DeleteGroup().

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 AddInstrument(), and File().

bool gig::File::GetAutoLoad ( )

Returns whether automatic loading is enabled.

See also
SetAutoLoad()

Definition at line 3950 of file gig.cpp.

Referenced by GetInstrument(), gig::Instrument::Instrument(), and gig::Region::Region().

Group * gig::File::GetFirstGroup ( )

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

Definition at line 3642 of file gig.cpp.

References LoadGroups().

Referenced by gig::Group::MoveAll().

Instrument * gig::File::GetFirstInstrument ( )

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

Definition at line 3491 of file gig.cpp.

References DLS::File::InstrumentsIterator, LoadInstruments(), and DLS::File::pInstruments.

Referenced by DeleteSample(), and UpdateChunks().

Sample * DLS::File::GetFirstSample ( )
inherited

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

Definition at line 1298 of file DLS.cpp.

References DLS::File::LoadSamples(), DLS::File::pSamples, and DLS::File::SamplesIterator.

Referenced by GetInstrument(), DLS::Region::GetSample(), and UpdateChunks().

Sample * gig::File::GetFirstSample ( progress_t pProgress = NULL)

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

Definition at line 3360 of file gig.cpp.

References LoadSamples(), DLS::File::pSamples, and DLS::File::SamplesIterator.

Referenced by gig::Group::GetFirstSample(), and gig::Region::GetSampleFromWavePool().

Group * gig::File::GetGroup ( uint  index)

Returns the group with the given index.

Parameters
index- number of the sought group (0..n)
Returns
sought group or NULL if there's no such group

Definition at line 3661 of file gig.cpp.

References LoadGroups().

Referenced by gig::Sample::Sample().

Instrument * gig::File::GetInstrument ( uint  index,
progress_t pProgress = NULL 
)

Returns the instrument with the given index.

Parameters
index- number of the sought instrument (0..n)
pProgress- optional: callback function for progress notification
Returns
sought instrument or NULL if there's no such instrument

Definition at line 3511 of file gig.cpp.

References gig::progress_t::__range_max, gig::progress_t::__range_min, gig::progress_t::callback, GetAutoLoad(), DLS::File::GetFirstSample(), DLS::File::InstrumentsIterator, LoadInstruments(), and DLS::File::pInstruments.

Group * gig::File::GetNextGroup ( )

Returns a pointer to the next Group object of the file, NULL otherwise.

Definition at line 3649 of file gig.cpp.

Referenced by gig::Group::MoveAll().

Instrument * gig::File::GetNextInstrument ( )

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

Definition at line 3498 of file gig.cpp.

References DLS::File::InstrumentsIterator, and DLS::File::pInstruments.

Referenced by DeleteSample(), and UpdateChunks().

Sample * gig::File::GetNextSample ( )

Returns a pointer to the next Sample object of the file, NULL otherwise.

Definition at line 3367 of file gig.cpp.

References DLS::File::pSamples, and DLS::File::SamplesIterator.

Referenced by gig::Group::GetFirstSample(), gig::Group::GetNextSample(), gig::Region::GetSampleFromWavePool(), and UpdateChunks().

void gig::File::LoadInstruments ( )
protectedvirtual

Reimplemented from DLS::File.

Definition at line 3586 of file gig.cpp.

Referenced by AddInstrument(), GetFirstInstrument(), and GetInstrument().

void gig::File::LoadSamples ( )
protectedvirtual

Reimplemented from DLS::File.

Definition at line 3431 of file gig.cpp.

Referenced by AddSample(), and GetFirstSample().

void DLS::File::Save ( const String Path)
virtualinherited

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 DLS::File::pRIFF, RIFF::File::Save(), and DLS::File::UpdateChunks().

void DLS::File::Save ( )
virtualinherited

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::Exceptionif any kind of IO error occured
DLS::Exceptionif any kind of DLS specific error occured

Definition at line 1522 of file DLS.cpp.

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

void gig::File::SetAutoLoad ( bool  b)

Enable / disable automatic loading.

By default this properyt is enabled and all informations are loaded automatically. However loading all Regions, DimensionRegions and especially samples might take a long time for large .gig files, and sometimes one might only be interested in retrieving very superficial informations like the amount of instruments and their names. In this case one might disable automatic loading to avoid very slow response times.

CAUTION: by disabling this property many pointers (i.e. sample references) and informations will have invalid or even undefined data! This feature is currently only intended for retrieving very superficial informations in a very fast way. Don't use it to retrieve details like synthesis informations or even to modify .gig files!

Definition at line 3942 of file gig.cpp.

void gig::File::SetSampleChecksum ( Sample pSample,
uint32_t  crc 
)
protected

Updates the 3crc chunk with the checksum of a sample.

The update is done directly to disk, as this method is called after File::Save()

Definition at line 3619 of file gig.cpp.

References CHUNK_ID_3CRC, RIFF::List::GetSubChunk(), DLS::File::pRIFF, DLS::File::pSamples, RIFF::Chunk::SetPos(), and RIFF::Chunk::WriteUint32().

Referenced by gig::Sample::Write().

void gig::File::UpdateChunks ( )
virtual

Friends And Related Function Documentation

friend class Group
friend

Definition at line 796 of file gig.h.

Referenced by AddGroup(), and LoadGroups().

friend class Region
friend

Definition at line 794 of file gig.h.

friend class Sample
friend

Definition at line 795 of file gig.h.

Referenced by AddSample(), and LoadSamples().

Member Data Documentation

bool DLS::File::b64BitWavePoolOffsets
protectedinherited
std::list<RIFF::File*> DLS::File::ExtensionFiles
protectedinherited

Definition at line 506 of file DLS.h.

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

uint32_t DLS::File::Instruments
inherited

Reflects the number of available Instrument objects.

Definition at line 485 of file DLS.h.

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

InstrumentList::iterator DLS::File::InstrumentsIterator
protectedinherited
dlsid_t* DLS::Resource::pDLSID
inherited

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 AddInstrument(), File(), gig::Instrument::Instrument(), DLS::Resource::Resource(), gig::Sample::Sample(), DLS::Resource::UpdateChunks(), and DLS::Resource::~Resource().

RIFF::List* DLS::Resource::pResourceList
protectedinherited

Definition at line 349 of file DLS.h.

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

version_t* DLS::File::pVersion
inherited
uint32_t* DLS::File::pWavePoolTable
protectedinherited
uint32_t* DLS::File::pWavePoolTableHi
protectedinherited
SampleList::iterator DLS::File::SamplesIterator
protectedinherited
const DLS::version_t gig::File::VERSION_2
static
Initial value:
= {
0, 2, 19980628 & 0xffff, 19980628 >> 16
}

Reflects Gigasampler file format version 2.0 (1998-06-28).

Definition at line 749 of file gig.h.

const DLS::version_t gig::File::VERSION_3
static
Initial value:
= {
0, 3, 20030331 & 0xffff, 20030331 >> 16
}

Reflects Gigasampler file format version 3.0 (2003-03-31).

Definition at line 750 of file gig.h.

Referenced by File().

uint32_t DLS::File::WavePoolCount
protectedinherited

Definition at line 512 of file DLS.h.

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

uint32_t DLS::File::WavePoolHeaderSize
protectedinherited

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