libgig  3.3.0.svn4
gig::Instrument Class Reference

Provides all neccessary information for the synthesis of an Instrument. More...

#include <gig.h>

Inheritance diagram for gig::Instrument:
DLS::Instrument DLS::Resource DLS::Articulator

Public Member Functions

RegionGetFirstRegion ()
 Returns the first Region of the instrument. More...
 
RegionGetNextRegion ()
 Returns the next Region of the instrument. More...
 
RegionAddRegion ()
 
void DeleteRegion (Region *pRegion)
 
virtual void UpdateChunks ()
 Apply Instrument with all its Regions to the respective RIFF chunks. More...
 
virtual void CopyAssign (const Instrument *orig)
 Make a (semi) deep copy of the Instrument object given by orig and assign it to this object. More...
 
RegionGetRegion (unsigned int Key)
 Returns the appropriate Region for a triggered note. More...
 
MidiRuleGetMidiRule (int i)
 Returns a MIDI rule of the instrument. More...
 

Public Attributes

int32_t Attenuation
 in dB More...
 
uint16_t EffectSend
 
int16_t FineTune
 in cents More...
 
uint16_t PitchbendRange
 Number of semitones pitchbend controller can pitch (default is 2). More...
 
bool PianoReleaseMode
 
range_t DimensionKeyRange
 0-127 (where 0 means C1 and 127 means G9) More...
 

Protected Types

typedef std::list< Region * > RegionList
 
typedef std::list< Articulation * > ArticulationList
 

Protected Member Functions

 Instrument (File *pFile, RIFF::List *insList, progress_t *pProgress=NULL)
 
 ~Instrument ()
 Destructor. More...
 
void UpdateRegionKeyTable ()
 
void DeleteRegion (Region *pRegion)
 
virtual void CopyAssign (const Instrument *orig)
 Make a (semi) deep copy of the Instrument object given by orig and assign it to this object. 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...
 
virtual void CopyAssign (const Articulator *orig)
 Not yet implemented in this version, since the .gig format does not need to copy DLS articulators and so far nobody used pure DLS instrument AFAIK. More...
 
void CopyAssignCore (const Instrument *orig)
 
virtual void LoadRegions ()
 
ResourceGetParent ()
 
void GenerateDLSID ()
 Generates a new DLSID for the resource. More...
 
Articulation * GetFirstArticulation ()
 
Articulation * GetNextArticulation ()
 
void LoadArticulations ()
 

Protected Attributes

RegionRegionKeyTable [128]
 fast lookup for the corresponding Region of a MIDI key More...
 
bool IsDrum
 Indicates if the Instrument is a drum type, as they differ in the synthesis model of DLS from melodic instruments. More...
 
uint16_t MIDIBank
 Reflects combination of MIDIBankCoarse and MIDIBankFine (bank 1 - bank 16384). Do not change this value, it will not be saved! Change MIDIBankCoarse and MIDIBankFine instead (we might change that in future). More...
 
uint8_t MIDIBankCoarse
 Reflects the MIDI Bank number for MIDI Control Change 0 (bank 1 - 128). More...
 
uint8_t MIDIBankFine
 Reflects the MIDI Bank number for MIDI Control Change 32 (bank 1 - 128). More...
 
uint32_t MIDIProgram
 Specifies the MIDI Program Change Number this Instrument should be assigned to. More...
 
uint32_t Regions
 Reflects the number of Region defintions this Instrument has. More...
 
RIFF::ListpCkInstrument
 
RegionListpRegions
 
RegionList::iterator RegionsIterator
 
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
 
RIFF::ListpParentList
 
ArticulationListpArticulations
 
ArticulationList::iterator ArticulationsIterator
 

Friends

class File
 
class Region
 

Detailed Description

Provides all neccessary information for the synthesis of an Instrument.

Definition at line 669 of file gig.h.

Member Typedef Documentation

typedef std::list<Articulation*> DLS::Articulator::ArticulationList
protectedinherited

Definition at line 275 of file DLS.h.

typedef std::list<Region*> DLS::Instrument::RegionList
protectedinherited

Definition at line 452 of file DLS.h.

Constructor & Destructor Documentation

gig::Instrument::~Instrument ( )
protectedvirtual

Destructor.

Removes RIFF chunks associated with this Instrument and frees all memory occupied by this instrument.

Reimplemented from DLS::Instrument.

Definition at line 3108 of file gig.cpp.

Member Function Documentation

void DLS::Articulator::CopyAssign ( const Articulator orig)
virtualinherited

Not yet implemented in this version, since the .gig format does not need to copy DLS articulators and so far nobody used pure DLS instrument AFAIK.

Definition at line 236 of file DLS.cpp.

Referenced by DLS::Region::CopyAssign(), and DLS::Instrument::CopyAssignCore().

void DLS::Resource::CopyAssign ( const Resource orig)
virtualinherited

Make a deep copy of the Resource object given by orig and assign it to this object.

Parameters
orig- original Resource object to be copied from

Definition at line 534 of file DLS.cpp.

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

Referenced by DLS::Region::CopyAssign(), and DLS::Instrument::CopyAssignCore().

void DLS::Instrument::CopyAssign ( const Instrument orig)
virtualinherited

Make a (semi) deep copy of the Instrument object given by orig and assign it to this object.

Note that all sample pointers referenced by orig are simply copied as memory address. Thus the respective samples are shared, not duplicated!

Parameters
orig- original Instrument object to be copied from

Definition at line 1305 of file DLS.cpp.

References DLS::Instrument::AddRegion(), DLS::Region::CopyAssign(), DLS::Instrument::CopyAssignCore(), DLS::Instrument::DeleteRegion(), DLS::Instrument::GetFirstRegion(), DLS::Instrument::pRegions, and DLS::Instrument::Regions.

void gig::Instrument::CopyAssign ( const Instrument orig)
virtual

Make a (semi) deep copy of the Instrument object given by orig and assign it to this object.

Note that all sample pointers referenced by orig are simply copied as memory address. Thus the respective samples are shared, not duplicated!

Parameters
orig- original Instrument object to be copied from

Definition at line 3250 of file gig.cpp.

References AddRegion(), Attenuation, gig::Region::CopyAssign(), DLS::Instrument::CopyAssignCore(), DeleteRegion(), DimensionKeyRange, EffectSend, FineTune, GetFirstRegion(), PianoReleaseMode, PitchbendRange, DLS::Instrument::pRegions, DLS::Instrument::Regions, and UpdateRegionKeyTable().

Referenced by gig::File::AddDuplicateInstrument().

void DLS::Instrument::DeleteRegion ( Region pRegion)
inherited

Definition at line 1221 of file DLS.cpp.

References DLS::Instrument::pRegions, and DLS::Instrument::Regions.

Referenced by DLS::Instrument::CopyAssign(), and DeleteRegion().

void gig::Instrument::DeleteRegion ( Region pRegion)

Definition at line 3220 of file gig.cpp.

References DLS::Instrument::DeleteRegion(), DLS::Instrument::pRegions, and UpdateRegionKeyTable().

Referenced by CopyAssign().

void DLS::Resource::GenerateDLSID ( )
inherited

Generates a new DLSID for the resource.

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

Articulation * DLS::Articulator::GetFirstArticulation ( )
inherited
Region * gig::Instrument::GetFirstRegion ( )

Returns the first Region of the instrument.

You have to call this method once before you use GetNextRegion().

Returns
pointer address to first region or NULL if there is none
See Also
GetNextRegion()

Definition at line 3186 of file gig.cpp.

References DLS::Instrument::pRegions, and DLS::Instrument::RegionsIterator.

Referenced by CopyAssign().

MidiRule * gig::Instrument::GetMidiRule ( int  i)

Returns a MIDI rule of the instrument.

The list of MIDI rules, at least in gig v3, always contains at most two rules. The second rule can only be the DEF filter (which currently isn't supported by libgig).

Parameters
i- MIDI rule number
Returns
pointer address to MIDI rule number i or NULL if there is none

Definition at line 3237 of file gig.cpp.

Articulation * DLS::Articulator::GetNextArticulation ( )
inherited
Region * gig::Instrument::GetNextRegion ( )

Returns the next Region of the instrument.

You have to call GetFirstRegion() once before you can use this method. By calling this method multiple times it iterates through the available Regions.

Returns
pointer address to the next region or NULL if end reached
See Also
GetFirstRegion()

Definition at line 3200 of file gig.cpp.

References DLS::Instrument::pRegions, and DLS::Instrument::RegionsIterator.

Region * gig::Instrument::GetRegion ( unsigned int  Key)

Returns the appropriate Region for a triggered note.

Parameters
KeyMIDI Key number of triggered note / key (0 - 127)
Returns
pointer adress to the appropriate Region or NULL if there there is no Region defined for the given Key

Definition at line 3168 of file gig.cpp.

References DLS::Instrument::pRegions, and RegionKeyTable.

void gig::Instrument::UpdateChunks ( )
virtual

Apply Instrument with all its Regions to the respective RIFF chunks.

You have to call File::Save() to make changes persistent.

Usually there is absolutely no need to call this method explicitly. It will be called automatically when File::Save() was called.

Exceptions
gig::Exceptionif samples cannot be dereferenced

Reimplemented from DLS::Instrument.

Definition at line 3124 of file gig.cpp.

References RIFF::List::AddSubChunk(), RIFF::List::AddSubList(), Attenuation, CHUNK_ID_3EWG, DimensionKeyRange, EffectSend, FineTune, DLS::Resource::GetParent(), RIFF::List::GetSubChunk(), RIFF::List::GetSubList(), gig::range_t::high, LIST_TYPE_LART, RIFF::Chunk::LoadChunkData(), gig::range_t::low, DLS::version_t::major, DLS::Instrument::pCkInstrument, PianoReleaseMode, PitchbendRange, DLS::Instrument::pRegions, DLS::File::pVersion, and DLS::Instrument::UpdateChunks().

void gig::Instrument::UpdateRegionKeyTable ( )
protected

Friends And Related Function Documentation

friend class File
friend

Definition at line 708 of file gig.h.

friend class Region
friend

Definition at line 709 of file gig.h.

Referenced by AddRegion(), and Instrument().

Member Data Documentation

ArticulationList::iterator DLS::Articulator::ArticulationsIterator
protectedinherited
int32_t gig::Instrument::Attenuation

in dB

Definition at line 682 of file gig.h.

Referenced by CopyAssign(), Instrument(), and UpdateChunks().

range_t gig::Instrument::DimensionKeyRange

0-127 (where 0 means C1 and 127 means G9)

Definition at line 687 of file gig.h.

Referenced by CopyAssign(), Instrument(), and UpdateChunks().

uint16_t gig::Instrument::EffectSend

Definition at line 683 of file gig.h.

Referenced by CopyAssign(), Instrument(), and UpdateChunks().

int16_t gig::Instrument::FineTune

in cents

Definition at line 684 of file gig.h.

Referenced by CopyAssign(), Instrument(), and UpdateChunks().

bool DLS::Instrument::IsDrum
inherited

Indicates if the Instrument is a drum type, as they differ in the synthesis model of DLS from melodic instruments.

Definition at line 438 of file DLS.h.

Referenced by DLS::Instrument::CopyAssignCore(), DLS::Instrument::Instrument(), and DLS::Instrument::UpdateChunks().

uint16_t DLS::Instrument::MIDIBank
inherited

Reflects combination of MIDIBankCoarse and MIDIBankFine (bank 1 - bank 16384). Do not change this value, it will not be saved! Change MIDIBankCoarse and MIDIBankFine instead (we might change that in future).

Definition at line 439 of file DLS.h.

Referenced by DLS::Instrument::CopyAssignCore(), DLS::Instrument::Instrument(), and DLS::Instrument::UpdateChunks().

uint8_t DLS::Instrument::MIDIBankCoarse
inherited

Reflects the MIDI Bank number for MIDI Control Change 0 (bank 1 - 128).

Definition at line 440 of file DLS.h.

Referenced by DLS::Instrument::CopyAssignCore(), DLS::Instrument::Instrument(), and DLS::Instrument::UpdateChunks().

uint8_t DLS::Instrument::MIDIBankFine
inherited

Reflects the MIDI Bank number for MIDI Control Change 32 (bank 1 - 128).

Definition at line 441 of file DLS.h.

Referenced by DLS::Instrument::CopyAssignCore(), DLS::Instrument::Instrument(), and DLS::Instrument::UpdateChunks().

uint32_t DLS::Instrument::MIDIProgram
inherited

Specifies the MIDI Program Change Number this Instrument should be assigned to.

Definition at line 442 of file DLS.h.

Referenced by DLS::Instrument::CopyAssignCore(), DLS::Instrument::Instrument(), and DLS::Instrument::UpdateChunks().

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 328 of file DLS.h.

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

bool gig::Instrument::PianoReleaseMode

Definition at line 686 of file gig.h.

Referenced by CopyAssign(), Instrument(), and UpdateChunks().

Info* DLS::Resource::pInfo
inherited

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

Definition at line 327 of file DLS.h.

Referenced by gig::File::AddInstrument(), DLS::Resource::CopyAssign(), gig::File::File(), Instrument(), DLS::Resource::Resource(), gig::Sample::Sample(), DLS::Resource::UpdateChunks(), and DLS::Resource::~Resource().

uint16_t gig::Instrument::PitchbendRange

Number of semitones pitchbend controller can pitch (default is 2).

Definition at line 685 of file gig.h.

Referenced by CopyAssign(), Instrument(), and UpdateChunks().

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

Definition at line 336 of file DLS.h.

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

Region* gig::Instrument::RegionKeyTable[128]
protected

fast lookup for the corresponding Region of a MIDI key

Definition at line 703 of file gig.h.

Referenced by GetRegion(), Instrument(), and UpdateRegionKeyTable().

uint32_t DLS::Instrument::Regions
inherited
RegionList::iterator DLS::Instrument::RegionsIterator
protectedinherited

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