--- libgig/trunk/src/gig.h 2004/04/27 09:06:07 55 +++ libgig/trunk/src/gig.h 2005/01/29 14:25:35 353 @@ -63,10 +63,6 @@ #define GIG_EG_CTR_ATTACK_INFLUENCE_EXTRACT(x) ((x >> 1) & 0x03) #define GIG_EG_CTR_DECAY_INFLUENCE_EXTRACT(x) ((x >> 3) & 0x03) #define GIG_EG_CTR_RELEASE_INFLUENCE_EXTRACT(x) ((x >> 5) & 0x03) -//TODO: the transformation functions are not very accurate compared to the original ones -#define GIG_VELOCITY_TRANSFORM_NONLINEAR(x,dynamic,scale) ((1.0-1.0/pow(x,1.0/(129.0-x))) * (1.0+scale/20.0) + (5.0-dynamic)*pow(x/300.0* (1.0+2.0*scale/128.0),2)) -#define GIG_VELOCITY_TRANSFORM_LINEAR(x,dynamic,scale) ((1.0+scale*3.0/128.0)/110.0*x+(5.0-dynamic)/5.0+(5.0-dynamic)*scale) -#define GIG_VELOCITY_TRANSFORM_SPECIAL(x,dynamic,scale) ((1.0+9.0*scale/129.0)*(1.0-1.0/pow(x,1.0/(129.0-x))+pow(3.0*x/pow(129,2),2)+pow((5.0-dynamic)*x/500.0,2))) /** Gigasampler specific classes and definitions */ namespace gig { @@ -223,7 +219,7 @@ dimension_velocity = 0x82, ///< Key Velocity (this is the only dimension where the ranges can exactly be defined). dimension_channelaftertouch = 0x83, ///< Channel Key Pressure dimension_releasetrigger = 0x84, ///< Special dimension for triggering samples on releasing a key. - dimension_keyboard = 0x85, ///< Key Position + dimension_keyboard = 0x85, ///< Dimension for keyswitching dimension_modwheel = 0x01, ///< Modulation Wheel (MIDI Controller 1) dimension_breath = 0x02, ///< Breath Controller (Coarse, MIDI Controller 2) dimension_foot = 0x04, ///< Foot Pedal (Coarse, MIDI Controller 4) @@ -278,18 +274,24 @@ vcf_type_bandreject = 0x03 } vcf_type_t; - /** Defines the envelope of a crossfade. */ + /** + * Defines the envelope of a crossfade. + * + * Note: The default value for crossfade points is 0,0,0,0. Layers with + * such a default value should be treated as if they would not have a + * crossfade. + */ struct crossfade_t { #if WORDS_BIGENDIAN - uint8_t in_start; ///< Start position of fade in. - uint8_t in_end; ///< End position of fade in. - uint8_t out_start; ///< Start position of fade out. - uint8_t out_end; ///< End postition of fade out. - #else // little endian uint8_t out_end; ///< End postition of fade out. uint8_t out_start; ///< Start position of fade out. uint8_t in_end; ///< End position of fade in. uint8_t in_start; ///< Start position of fade in. + #else // little endian + uint8_t in_start; ///< Start position of fade in. + uint8_t in_end; ///< End position of fade in. + uint8_t out_start; ///< Start position of fade out. + uint8_t out_end; ///< End postition of fade out. #endif // WORDS_BIGENDIAN }; @@ -304,6 +306,7 @@ class File; class Instrument; class Sample; + class Region; /** Encapsulates articulation information of a dimension region. * @@ -382,9 +385,9 @@ 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. - uint8_t VelocityResponseDepth; ///< Dynamic range of velocity affecting amplitude (0 - 4). - uint8_t VelocityResponseCurveScaling; ///< 0 - 127 + 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). uint8_t ReleaseTriggerDecay; ///< 0 - 8 @@ -450,6 +453,7 @@ double* pVelocityAttenuationTable; ///< Points to the velocity table corresponding to the velocity parameters of this DimensionRegion. leverage_ctrl_t DecodeLeverageController(_lev_ctrl_t EncodedController); + double* CreateVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling); }; /** Encapsulates sample waves used for playback. */ @@ -567,12 +571,13 @@ class Region : public DLS::Region { public: unsigned int Dimensions; ///< Number of defined dimensions. - dimension_def_t pDimensionDefinitions[5]; ///< Defines the five possible dimensions (the dimension's controller and number of bits/splits). + dimension_def_t pDimensionDefinitions[8]; ///< Defines the five (gig2) or eight (gig3) possible dimensions (the dimension's controller and number of bits/splits). uint32_t DimensionRegions; ///< Total number of DimensionRegions this Region contains. - DimensionRegion* pDimensionRegions[32]; ///< Pointer array to the 32 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). + 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). + 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. - DimensionRegion* GetDimensionRegionByValue(uint Dim4Val, uint Dim3Val, uint Dim2Val, uint Dim1Val, uint Dim0Val); - DimensionRegion* GetDimensionRegionByBit(uint8_t Dim4Bit, uint8_t Dim3Bit, uint8_t Dim2Bit, uint8_t Dim1Bit, uint8_t Dim0Bit); + DimensionRegion* GetDimensionRegionByValue(const uint DimValues[8]); + DimensionRegion* GetDimensionRegionByBit(const uint8_t DimBits[8]); Sample* GetSample(); protected: uint8_t VelocityTable[128]; ///< For velocity dimensions with custom defined zone ranges only: used for fast converting from velocity MIDI value to dimension bit number. @@ -643,7 +648,7 @@ Instrument* GetFirstInstrument(); ///< Returns a pointer to the first Instrument object of the file, NULL otherwise. Instrument* GetNextInstrument(); ///< Returns a pointer to the next Instrument object of the file, NULL otherwise. Instrument* GetInstrument(uint index); - ~File() {}; + ~File(); protected: typedef std::list SampleList; typedef std::list InstrumentList;