--- libgig/trunk/src/DLS.h 2011/09/19 21:41:34 2274 +++ libgig/trunk/src/DLS.h 2014/05/13 11:17:24 2547 @@ -2,7 +2,7 @@ * * * libgig - C++ cross-platform Gigasampler format file access library * * * - * Copyright (C) 2003-2010 by Christian Schoenebeck * + * Copyright (C) 2003-2014 by Christian Schoenebeck * * * * * * This library is free software; you can redistribute it and/or modify * @@ -204,6 +204,25 @@ struct range_t { uint16_t low; ///< Low value of range. uint16_t high; ///< High value of range. + + inline bool operator< (const range_t& other) const { + if (low < other.low) return true; + if (low > other.low) return false; + return high < other.high; + } + + inline bool operator== (const range_t& other) const { + return low == other.low && high == other.high; + } + + inline bool overlaps(uint16_t scalar) const { + return low <= scalar && scalar <= high; + } + + inline bool overlaps(const range_t& other) const { + return overlaps(other.low) || overlaps(other.high) || + other.overlaps(low) || other.overlaps(high); + } }; /** Defines Sample Loop Points. */ @@ -270,6 +289,7 @@ Articulation* GetFirstArticulation(); Articulation* GetNextArticulation(); virtual void UpdateChunks(); + virtual void CopyAssign(const Articulator* orig); protected: typedef std::list ArticulationList; RIFF::List* pParentList; @@ -311,6 +331,7 @@ void SetFixedStringLengths(const string_length_t* lengths); virtual ~Info(); virtual void UpdateChunks(); + virtual void CopyAssign(const Info* orig); private: 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. @@ -326,8 +347,10 @@ dlsid_t* pDLSID; ///< Points to a dlsid_t structure if the file provided a DLS ID else is NULL. Resource* GetParent() { return pParent; } + const Resource* GetParent() const { return pParent; } virtual void UpdateChunks(); void GenerateDLSID(); + virtual void CopyAssign(const Resource* orig); protected: Resource* pParent; RIFF::List* pResourceList; @@ -351,6 +374,7 @@ void DeleteSampleLoop(sample_loop_t* pLoopDef); virtual void SetGain(int32_t gain); virtual void UpdateChunks(); + virtual void CopyAssign(const Sampler* orig); protected: RIFF::List* pParentList; uint32_t uiHeaderSize; @@ -380,12 +404,13 @@ void* LoadSampleData(); void ReleaseSampleData(); - unsigned long GetSize(); + unsigned long GetSize() const; void Resize(int iNewSize); unsigned long SetPos(unsigned long SampleCount, RIFF::stream_whence_t Whence = RIFF::stream_start); unsigned long Read(void* pBuffer, unsigned long SampleCount); unsigned long Write(void* pBuffer, unsigned long SampleCount); virtual void UpdateChunks(); + virtual void CopyAssign(const Sample* orig); protected: RIFF::List* pWaveList; RIFF::Chunk* pCkData; @@ -394,6 +419,7 @@ Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset); virtual ~Sample(); + void CopyAssignCore(const Sample* orig); friend class File; friend class Region; // Region has to compare the wave pool offset to get its sample }; @@ -415,6 +441,7 @@ void SetSample(Sample* pSample); virtual void SetKeyRange(uint16_t Low, uint16_t High); virtual void UpdateChunks(); + virtual void CopyAssign(const Region* orig); protected: RIFF::List* pCkRegion; uint32_t WavePoolTableIndex; // index in the wave pool table to the sample wave this region is linked to @@ -442,6 +469,7 @@ Region* AddRegion(); void DeleteRegion(Region* pRegion); virtual void UpdateChunks(); + virtual void CopyAssign(const Instrument* orig); protected: typedef std::list RegionList; struct midi_locale_t { @@ -454,6 +482,7 @@ RegionList::iterator RegionsIterator; Instrument(File* pFile, RIFF::List* insList); + void CopyAssignCore(const Instrument* orig); virtual void LoadRegions(); virtual ~Instrument(); friend class File; @@ -471,6 +500,7 @@ File(); File(RIFF::File* pRIFF); String GetFileName(); + void SetFileName(const String& name); 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(); @@ -479,6 +509,7 @@ Instrument* GetNextInstrument(); ///< Returns a pointer to the next Instrument object of the file, NULL otherwise. Instrument* AddInstrument(); void DeleteInstrument(Instrument* pInstrument); + RIFF::File* GetExtensionFile(int index); virtual void UpdateChunks(); virtual void Save(const String& Path); virtual void Save();