--- libgig/trunk/src/gig.h 2007/05/26 13:59:40 1207 +++ libgig/trunk/src/gig.h 2007/11/25 17:29:37 1524 @@ -323,35 +323,6 @@ progress_t(); }; - /** @brief CRC-32 checksum implementation - * - * This class is used to calculate checksums of the sample data in - * a gig file. The checksums are stored in the 3crc chunk of the - * gig file and automatically updated when a sample is written - * with Sample::Write(). - */ - class CRC { - private: - uint32_t value; - static const uint32_t* table; - static uint32_t* initTable(); - public: - CRC() { - reset(); - } - void reset() { - value = 0xffffffff; - } - void update(unsigned char* buf, int len) { - for (int i = 0 ; i < len ; i++) { - value = table[(value ^ buf[i]) & 0xff] ^ (value >> 8); - } - } - uint32_t getValue() { - return value ^ 0xffffffff; - } - }; - // just symbol prototyping class File; class Instrument; @@ -425,23 +396,23 @@ // Filter bool VCFEnabled; ///< If filter should be used. vcf_type_t VCFType; ///< Defines the general filter characteristic (lowpass, highpass, bandpass, etc.). - vcf_cutoff_ctrl_t VCFCutoffController; ///< Specifies which external controller has influence on the filter cutoff frequency. + vcf_cutoff_ctrl_t VCFCutoffController; ///< Specifies which external controller has influence on the filter cutoff frequency. @deprecated Don't alter directly, use SetVCFCutoffController() instead! bool VCFCutoffControllerInvert; ///< Inverts values coming from the defined cutoff controller uint8_t VCFCutoff; ///< Max. cutoff frequency. - curve_type_t VCFVelocityCurve; ///< Defines a transformation curve for the incoming velocity values, affecting the VCF. - uint8_t VCFVelocityScale; ///< (0-127) Amount velocity controls VCF cutoff frequency (only if no other VCF cutoff controller is defined, otherwise this is the minimum cutoff). - uint8_t VCFVelocityDynamicRange; ///< 0x04 = lowest, 0x00 = highest + curve_type_t VCFVelocityCurve; ///< Defines a transformation curve for the incoming velocity values, affecting the VCF. @deprecated Don't alter directly, use SetVCFVelocityCurve() instead! + uint8_t VCFVelocityScale; ///< (0-127) Amount velocity controls VCF cutoff frequency (only if no other VCF cutoff controller is defined, otherwise this is the minimum cutoff). @deprecated Don't alter directly, use SetVCFVelocityScale() instead! + uint8_t VCFVelocityDynamicRange; ///< 0x04 = lowest, 0x00 = highest . @deprecated Don't alter directly, use SetVCFVelocityDynamicRange() instead! uint8_t VCFResonance; ///< Firm internal filter resonance weight. bool VCFResonanceDynamic; ///< If true: Increases the resonance Q according to changes of controllers that actually control the VCF cutoff frequency (EG2, ext. VCF MIDI controller). vcf_res_ctrl_t VCFResonanceController; ///< Specifies which external controller has influence on the filter resonance Q. bool VCFKeyboardTracking; ///< If true: VCF cutoff frequence will be dependend to the note key position relative to the defined breakpoint value. uint8_t VCFKeyboardTrackingBreakpoint; ///< See VCFKeyboardTracking (0 - 127). // Key Velocity Transformations - curve_type_t VelocityResponseCurve; ///< Defines a transformation curve to the incoming velocity values affecting amplitude (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead). - uint8_t VelocityResponseDepth; ///< Dynamic range of velocity affecting amplitude (0 - 4) (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead). - uint8_t VelocityResponseCurveScaling; ///< 0 - 127 (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead) - curve_type_t ReleaseVelocityResponseCurve; ///< Defines a transformation curve to the incoming release veloctiy values affecting envelope times. - uint8_t ReleaseVelocityResponseDepth; ///< Dynamic range of release velocity affecting envelope time (0 - 4). + curve_type_t VelocityResponseCurve; ///< Defines a transformation curve to the incoming velocity values affecting amplitude (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead). @deprecated Don't alter directly, use SetVelocityResponseCurve() instead! + uint8_t VelocityResponseDepth; ///< Dynamic range of velocity affecting amplitude (0 - 4) (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead). @deprecated Don't alter directly, use SetVelocityResponseDepth() instead! + uint8_t VelocityResponseCurveScaling; ///< 0 - 127 (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead). @deprecated Don't alter directly, use SetVelocityResponseCurveScaling() instead! + curve_type_t ReleaseVelocityResponseCurve; ///< Defines a transformation curve to the incoming release veloctiy values affecting envelope times. @deprecated Don't alter directly, use SetReleaseVelocityResponseCurve() instead! + uint8_t ReleaseVelocityResponseDepth; ///< Dynamic range of release velocity affecting envelope time (0 - 4). @deprecated Don't alter directly, use SetReleaseVelocityResponseDepth() instead! uint8_t ReleaseTriggerDecay; ///< 0 - 8 // Mix / Layer crossfade_t Crossfade; @@ -470,14 +441,26 @@ double GetVelocityAttenuation(uint8_t MIDIKeyVelocity); double GetVelocityRelease(uint8_t MIDIKeyVelocity); double GetVelocityCutoff(uint8_t MIDIKeyVelocity); + void SetVelocityResponseCurve(curve_type_t curve); + void SetVelocityResponseDepth(uint8_t depth); + void SetVelocityResponseCurveScaling(uint8_t scaling); + void SetReleaseVelocityResponseCurve(curve_type_t curve); + void SetReleaseVelocityResponseDepth(uint8_t depth); + void SetVCFCutoffController(vcf_cutoff_ctrl_t controller); + void SetVCFVelocityCurve(curve_type_t curve); + void SetVCFVelocityDynamicRange(uint8_t range); + void SetVCFVelocityScale(uint8_t scaling); + Region* GetParent() const; // derived methods DLS::Sampler::AddSampleLoop; DLS::Sampler::DeleteSampleLoop; // overridden methods + virtual void SetGain(int32_t gain); virtual void UpdateChunks(); protected: uint8_t* VelocityTable; ///< For velocity dimensions with custom defined zone ranges only: used for fast converting from velocity MIDI value to dimension bit number. - DimensionRegion(RIFF::List* _3ewl); + DimensionRegion(Region* pParent, RIFF::List* _3ewl); + DimensionRegion(RIFF::List* _3ewl, const DimensionRegion& src); ~DimensionRegion(); friend class Region; private: @@ -516,9 +499,12 @@ double* pVelocityAttenuationTable; ///< Points to the velocity table corresponding to the velocity parameters of this DimensionRegion. double* pVelocityReleaseTable; ///< Points to the velocity table corresponding to the release velocity parameters of this DimensionRegion double* pVelocityCutoffTable; ///< Points to the velocity table corresponding to the filter velocity parameters of this DimensionRegion + Region* pRegion; leverage_ctrl_t DecodeLeverageController(_lev_ctrl_t EncodedController); _lev_ctrl_t EncodeLeverageController(leverage_ctrl_t DecodedController); + double* GetReleaseVelocityTable(curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth); + double* GetCutoffVelocityTable(curve_type_t vcfVelocityCurve, uint8_t vcfVelocityDynamicRange, uint8_t vcfVelocityScale, vcf_cutoff_ctrl_t vcfCutoffController); double* GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling); double* CreateVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling); }; @@ -592,7 +578,7 @@ unsigned long FileNo; ///< File number (> 0 when sample is stored in an extension file, 0 when it's in the gig) RIFF::Chunk* pCk3gix; RIFF::Chunk* pCkSmpl; - CRC crc; ///< CRC-32 checksum of the raw sample data + uint32_t crc; ///< CRC-32 checksum of the raw sample data Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset, unsigned long fileNo = 0); ~Sample(); @@ -635,11 +621,14 @@ DimensionRegion* pDimensionRegions[256]; ///< Pointer array to the 32 (gig2) or 256 (gig3) possible dimension regions (reflects NULL for dimension regions not in use). Avoid to access the array directly and better use GetDimensionRegionByValue() instead, but of course in some cases it makes sense to use the array (e.g. iterating through all DimensionRegions). Use AddDimension() and DeleteDimension() to create a new dimension or delete an existing one (which will create or delete the respective dimension region(s) automatically). unsigned int Layers; ///< Amount of defined layers (1 - 32). A value of 1 actually means no layering, a value > 1 means there is Layer dimension. The same information can of course also be obtained by accessing pDimensionDefinitions. Do not alter this value! + // own methods DimensionRegion* GetDimensionRegionByValue(const uint DimValues[8]); DimensionRegion* GetDimensionRegionByBit(const uint8_t DimBits[8]); Sample* GetSample(); void AddDimension(dimension_def_t* pDimDef); void DeleteDimension(dimension_def_t* pDimDef); + // overridden methods + virtual void SetKeyRange(uint16_t Low, uint16_t High); virtual void UpdateChunks(); protected: Region(Instrument* pInstrument, RIFF::List* rgnList); @@ -674,8 +663,6 @@ // derived methods from DLS::Resource DLS::Resource::GetParent; - // derived methods from DLS::Instrument - DLS::Instrument::MoveRegion; // overridden methods Region* GetFirstRegion(); Region* GetNextRegion(); @@ -691,6 +678,7 @@ ~Instrument(); void UpdateRegionKeyTable(); friend class File; + friend class Region; // so Region can call UpdateRegionKeyTable() }; /** @brief Group of Gigasampler objects @@ -761,6 +749,8 @@ Group* AddGroup(); void DeleteGroup(Group* pGroup); void DeleteGroupOnly(Group* pGroup); + void SetAutoLoad(bool b); + bool GetAutoLoad(); virtual ~File(); virtual void UpdateChunks(); protected: @@ -776,9 +766,9 @@ friend class Sample; friend class Group; // so Group can access protected member pRIFF private: - static const DLS::Info::FixedStringLength FixedStringLengths[]; std::list* pGroups; std::list::iterator GroupsIterator; + bool bAutoLoad; }; /**