--- libgig/trunk/src/DLS.h 2007/05/12 12:39:25 1180 +++ libgig/trunk/src/DLS.h 2011/09/19 21:41:34 2274 @@ -2,7 +2,7 @@ * * * libgig - C++ cross-platform Gigasampler format file access library * * * - * Copyright (C) 2003-2007 by Christian Schoenebeck * + * Copyright (C) 2003-2010 by Christian Schoenebeck * * * * * * This library is free software; you can redistribute it and/or modify * @@ -28,7 +28,6 @@ #if WORDS_BIGENDIAN # define RIFF_TYPE_DLS 0x444C5320 -# define LIST_TYPE_INFO 0x494E464F # define LIST_TYPE_WVPL 0x7776706C # define LIST_TYPE_DWPL 0x6477706C ///< Seen on some files instead of a wvpl list chunk. # define LIST_TYPE_WAVE 0x77617665 @@ -42,17 +41,10 @@ # define CHUNK_ID_IARL 0x4941524C # define CHUNK_ID_IART 0x49415254 # define CHUNK_ID_ICMS 0x49434D53 -# define CHUNK_ID_ICMT 0x49434D54 -# define CHUNK_ID_ICOP 0x49434F50 -# define CHUNK_ID_ICRD 0x49435244 -# define CHUNK_ID_IENG 0x49454E47 # define CHUNK_ID_IGNR 0x49474E52 # define CHUNK_ID_IKEY 0x494B4559 # define CHUNK_ID_IMED 0x494D4544 -# define CHUNK_ID_INAM 0x494E414D -# define CHUNK_ID_IPRD 0x49505244 # define CHUNK_ID_ISBJ 0x4953424A -# define CHUNK_ID_ISFT 0x49534654 # define CHUNK_ID_ISRC 0x49535243 # define CHUNK_ID_ISRF 0x49535246 # define CHUNK_ID_ITCH 0x49544348 @@ -70,7 +62,6 @@ # define CHUNK_ID_ART2 0x61727432 #else // little endian # define RIFF_TYPE_DLS 0x20534C44 -# define LIST_TYPE_INFO 0x4F464E49 # define LIST_TYPE_WVPL 0x6C707677 # define LIST_TYPE_DWPL 0x6C707764 ///< Seen on some files instead of a wvpl list chunk. # define LIST_TYPE_WAVE 0x65766177 @@ -84,17 +75,10 @@ # define CHUNK_ID_IARL 0x4C524149 # define CHUNK_ID_IART 0x54524149 # define CHUNK_ID_ICMS 0x534D4349 -# define CHUNK_ID_ICMT 0x544D4349 -# define CHUNK_ID_ICOP 0x504F4349 -# define CHUNK_ID_ICRD 0x44524349 -# define CHUNK_ID_IENG 0x474E4549 # define CHUNK_ID_IGNR 0x524E4749 # define CHUNK_ID_IKEY 0x59454B49 # define CHUNK_ID_IMED 0x44454D49 -# define CHUNK_ID_INAM 0x4D414E49 -# define CHUNK_ID_IPRD 0x44525049 # define CHUNK_ID_ISBJ 0x4A425349 -# define CHUNK_ID_ISFT 0x54465349 # define CHUNK_ID_ISRC 0x43525349 # define CHUNK_ID_ISRF 0x46525349 # define CHUNK_ID_ITCH 0x48435449 @@ -258,10 +242,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,17 +300,20 @@ 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; ///< @deprecated Not used anymore, use SetFixedStringLengths() instead. - struct FixedStringLength { + struct string_length_t { uint32_t chunkId; - int length; + int length; }; - const FixedStringLength* FixedStringLengths; ///< 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. + 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); void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault); @@ -338,8 +325,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; @@ -353,7 +341,7 @@ 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. @@ -361,6 +349,7 @@ 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; @@ -412,7 +401,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; @@ -424,6 +413,7 @@ Sample* GetSample(); void SetSample(Sample* pSample); + virtual void SetKeyRange(uint16_t Low, uint16_t High); virtual void UpdateChunks(); protected: RIFF::List* pCkRegion; @@ -450,7 +440,6 @@ Region* GetFirstRegion(); Region* GetNextRegion(); Region* AddRegion(); - void MoveRegion(Region* pSrc, Region* pDst); void DeleteRegion(Region* pRegion); virtual void UpdateChunks(); protected: @@ -468,6 +457,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. */ @@ -478,6 +470,7 @@ File(); File(RIFF::File* pRIFF); + String GetFileName(); Sample* GetFirstSample(); ///< Returns a pointer to the first Sample object of the file, NULL otherwise. Sample* GetNextSample(); ///< Returns a pointer to the next Sample object of the file, NULL otherwise. Sample* AddSample();