--- libgig/trunk/src/DLS.h 2007/03/18 07:13:06 1102 +++ libgig/trunk/src/DLS.h 2008/03/06 20:42:22 1713 @@ -224,10 +224,10 @@ /** Defines Sample Loop Points. */ struct sample_loop_t { - uint32_t Size; - uint32_t LoopType; - uint32_t LoopStart; - uint32_t LoopLength; + uint32_t Size; ///< For internal usage only: usually reflects exactly @c sizeof(sample_loop_t), otherwise if the value is larger then the DLS format was extended! + uint32_t LoopType; ///< Defines how the waveform samples will be looped (appropriate loop types for the gig format are defined by gig::loop_type_t). + uint32_t LoopStart; ///< The start value specifies the offset (in sample points) in the waveform data of the first sample point to be played in the loop. + uint32_t LoopLength; ///< Length of the looping area (in sample points). }; // just symbol prototyping @@ -258,10 +258,10 @@ uint16_t transform; uint32_t scale; }; - Connection() {}; + Connection() {} void Init(conn_block_t* Header); conn_block_t ToConnBlock(); - virtual ~Connection() {}; + virtual ~Connection() {} friend class Articulation; }; @@ -316,16 +316,23 @@ String SourceForm; ///< . Identifies the original form of the material that was digitized, such as record, sampling CD, TV sound track. This is not neccessarily the same as Medium. String Commissioned; ///< . Lists the name of the person or organization that commissioned the subject of the file, e.g., Pope Julian II. String Subject; ///< . Describes the contents of the file. - bool UseFixedLengthStrings; ///< Set this to true if the info strings should be stored with a fixed length format. This is used for gig files, not for ordinary DLS files. + bool UseFixedLengthStrings; ///< @deprecated Not used anymore, use SetFixedStringLengths() instead. + + struct string_length_t { + uint32_t chunkId; + int length; + }; Info(RIFF::List* list); + void SetFixedStringLengths(const string_length_t* lengths); virtual ~Info(); virtual void UpdateChunks(); private: - RIFF::List* pResourceListChunk; + RIFF::List* pResourceListChunk; + const string_length_t* pFixedStringLengths; ///< List of IDs and string lengths for strings that should be stored in a fixed length format. This is used for gig files, not for ordinary DLS files. static void LoadString(uint32_t ChunkID, RIFF::List* lstINFO, String& s); - static void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault, bool bUseFixedLengthStrings, int size); + void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault); }; /** Abstract base class which encapsulates data structures which all DLS resources are able to provide. */ @@ -334,8 +341,9 @@ Info* pInfo; ///< Points (in any case) to an Info object, providing additional, optional infos and comments. dlsid_t* pDLSID; ///< Points to a dlsid_t structure if the file provided a DLS ID else is NULL. - Resource* GetParent() { return pParent; }; + Resource* GetParent() { return pParent; } virtual void UpdateChunks(); + void GenerateDLSID(); protected: Resource* pParent; RIFF::List* pResourceList; @@ -349,12 +357,15 @@ public: uint8_t UnityNote; int16_t FineTune; - int32_t Gain; + int32_t Gain; ///< @deprecated Don't alter directly, use SetGain() instead! bool NoSampleDepthTruncation; bool NoSampleCompression; uint32_t SampleLoops; ///< Reflects the number of sample loops. sample_loop_t* pSampleLoops; ///< Points to the beginning of a sample loop array, or is NULL if there are no loops defined. + void AddSampleLoop(sample_loop_t* pLoopDef); + void DeleteSampleLoop(sample_loop_t* pLoopDef); + virtual void SetGain(int32_t gain); virtual void UpdateChunks(); protected: RIFF::List* pParentList; @@ -406,7 +417,7 @@ /** Defines Region information of an Instrument. */ class Region : public Resource, public Articulator, public Sampler { public: - range_t KeyRange; + range_t KeyRange; ///< @deprecated Only read, don't write! Use SetKeyRange() instead. range_t VelocityRange; uint16_t KeyGroup; uint16_t Layer; @@ -418,6 +429,7 @@ Sample* GetSample(); void SetSample(Sample* pSample); + virtual void SetKeyRange(uint16_t Low, uint16_t High); virtual void UpdateChunks(); protected: RIFF::List* pCkRegion; @@ -444,7 +456,6 @@ Region* GetFirstRegion(); Region* GetNextRegion(); Region* AddRegion(); - void MoveRegion(Region* pSrc, Region* pDst); void DeleteRegion(Region* pRegion); virtual void UpdateChunks(); protected: @@ -462,6 +473,9 @@ virtual void LoadRegions(); virtual ~Instrument(); friend class File; + friend class Region; + private: + void MoveRegion(Region* pSrc, Region* pDst); }; /** Parses DLS Level 1 and 2 compliant files and provides abstract access to the data. */