00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __CL_Track__
00023 #define __CL_Track__
00024
00025 #include "CL_API.h"
00026 #include <UT/UT_PtrArray.h>
00027 #include <UT/UT_FloatArray.h>
00028 #include <UT/UT_String.h>
00029
00030 class UT_IStream;
00031 class CL_Clip;
00032 class CL_Track;
00033 class CL_SubRange;
00034
00035 typedef UT_PtrArray<CL_Track *> CL_TrackList;
00036 typedef UT_PtrArray<const CL_Track *> CL_TrackListC;
00037
00038
00039
00040
00041
00042 typedef enum {
00043 CL_TRACK_HOLD,
00044 CL_TRACK_SLOPE,
00045 CL_TRACK_CYCLE,
00046 CL_TRACK_MIRROR,
00047 CL_TRACK_DEFAULT,
00048 CL_TRACK_CYCLE_STEP
00049 } CL_TrackOutside;
00050
00051 enum CL_TrackLimitMethod
00052 {
00053 CL_TRACK_LIMIT_OFF,
00054 CL_TRACK_LIMIT_CLAMP,
00055 CL_TRACK_LIMIT_LOOP,
00056 CL_TRACK_LIMIT_ZIGZAG
00057 };
00058
00059 enum CL_QuantizeValueMethod
00060 {
00061 CL_QUANTIZE_VALUE_OFF,
00062 CL_QUANTIZE_VALUE_CEILING,
00063 CL_QUANTIZE_VALUE_FLOOR,
00064 CL_QUANTIZE_VALUE_ROUND
00065 };
00066
00067 enum CL_TrackResampleMethod
00068 {
00069 CL_TRACK_INTERP_NONE,
00070 CL_TRACK_INTERP_LINEAR,
00071 CL_TRACK_INTERP_CUBIC,
00072 CL_TRACK_INTERP_EDGE_PRESERVE
00073 };
00074
00075
00076 class CL_API CL_Track {
00077
00078 public:
00079
00080 CL_Track(CL_Clip &dad, const CL_Track &from);
00081 CL_Track(CL_Clip &dad, const char *name);
00082 ~CL_Track();
00083
00084
00085 CL_Track &operator= (const CL_Track &from);
00086
00087 void init(CL_Clip &dad, const char *name);
00088
00089 float *getData()
00090 { return myData.array(); }
00091
00092 const float *getData() const
00093 { return myData.getRawArray(); }
00094
00095 int getTrackLength() const
00096 { return myData.entries(); }
00097
00098 const UT_String &getName() const
00099 { return myName; }
00100
00101
00102
00103
00104 void setName(const char *);
00105
00106
00107
00108
00109
00110
00111
00112 unsigned short getNameHash() const
00113 {
00114 return myNameHash;
00115 }
00116
00117 unsigned short getNameBaseLength() const
00118 { return myNameBaseLength; }
00119
00120 unsigned short getNameBaseHash() const
00121 { return myNameBaseHash; }
00122
00123 int getNameNumber() const
00124 {
00125 if (myNameNumberDirty)
00126 ((CL_Track *)this)->calcNameNumber();
00127 return myNameNumber;
00128 }
00129
00130 static void getNameComposition(const char *name,
00131 unsigned short &base_length,
00132 unsigned short &base_hash);
00133
00134
00135 const char *info(float t, const char *prefix = 0,
00136 const char *suffix = 0) const;
00137
00138 int isTimeDependent() const;
00139
00140 int isWithinRange(float low,float hi,int completely=1) const;
00141
00142
00143
00144
00145 void setLeft(CL_TrackOutside type);
00146 void setRight(CL_TrackOutside type);
00147 void setDefault(float value);
00148
00149 CL_Clip *getClip(void)
00150 { return myParent; }
00151
00152 const CL_Clip *getClip(void) const
00153 { return myParent; }
00154
00155
00156 const char *getLeft(void) const;
00157 const char *getRight(void) const;
00158
00159 int64 getMemoryUsage(void) const;
00160
00161 void getExtendCond(CL_TrackOutside &left,
00162 CL_TrackOutside &right) const;
00163 float getDefault() const
00164 { return myDefault; }
00165
00166 void dupAttributes(const CL_Track *,
00167 int data_too=0, int name_too=0);
00168
00169
00170
00171 void reverse();
00172 void constant(float value=0);
00173 void cycle(int howmany);
00174
00175 int convolve(const CL_Track &t1, const CL_Track &t2,
00176 int add = 0);
00177
00178 int convolveCenter(float *data2, int n2, int passes = 1);
00179 int convolveCenterDirect(float *data2, int n2, int passes);
00180 int convolveCenterFFT(float *data2,int n2,int passes);
00181
00182 int copyStamp(const CL_Track &t1, float toffset, int clr);
00183
00184 int getThresholdTimes(float thresh,
00185 UT_FloatArray &toffsets,
00186 UT_FloatArray &values) const;
00187
00188 void despike(float tol, float effect=1.0f, int maxwidth=1);
00189
00190 void blend(float start, const float *values, int len,
00191 float base, const CL_SubRange *effect,
00192 float cycle);
00193
00194 void blend(float start, const float *values, int len,
00195 float base, const CL_Track *effect_track,
00196 float cycle);
00197
00198 void limitValues(float max, float min,
00199 CL_TrackLimitMethod method,
00200 int start, int end);
00201
00202 static float limitValue(float max, float min,
00203 CL_TrackLimitMethod method, float v);
00204
00205
00206
00207 int resample(const float *values, int num,
00208 CL_TrackResampleMethod method,
00209 int constant_area, int iscycle = 0,
00210 float cycle = 0);
00211
00212
00213
00214 int resample(float *data, int size, int start, int end,
00215 CL_TrackResampleMethod method,
00216 int constant_area,
00217 int iscycle = 0,
00218 float cycle = 0) const;
00219
00220 void quantizeValue(float max, float min,
00221 CL_QuantizeValueMethod method,
00222 float step, float offset,
00223 int clamp, int start, int end);
00224
00225 void normalize();
00226 void absolute();
00227 void smoothRotate(float delta = 180.0f);
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 void filterFrequency(int filter_size,
00238 float freqstep,
00239 float overlap,
00240 float discard,
00241 float *filter,
00242 float *phase_filter = 0,
00243 void (*filter_design)(void *,int,float,float *,float *,int,int)=0,
00244 void *node = 0,
00245 int doblend = 1);
00246
00247
00248 void pitchShift(float shift,int chunk,
00249 const CL_Track *animate=0,
00250 float (*callback)(void *,int,int)=0,
00251 void *node=0);
00252
00253
00254 void fastConvolve(int chunk,float *data);
00255
00256
00257
00258
00259
00260
00261 void aliasTrack(CL_Track &track);
00262 void unalias();
00263 bool isAliased() const { return myPrevDataAlias != 0; }
00264
00265
00266 void swapData(CL_Track &track);
00267
00268 private:
00269
00270
00271
00272 void evaluate(float start_index, float stop_index,
00273 float *data, int size) const;
00274
00275
00276
00277 float evaluateSingle(float index) const;
00278
00279
00280
00281
00282 void evaluatePortion(float i0, float i1,
00283 float start_index, float
00284 stop_index, float *data, int size,
00285 float *fix, int portion) const;
00286
00287 void evaluateCenter(float start_index, float stop_index,
00288 float *data, int size) const;
00289
00290 void evaluateLeftSlope(float start_index, float stop_index,
00291 float *data, int size) const;
00292 void evaluateRightSlope(float start_index, float stop_index,
00293 float *data, int size) const;
00294
00295 void evaluateLeftHold(float *data, int size) const;
00296 void evaluateRightHold(float *data, int size) const;
00297
00298 void evaluateDefault(float *data, int size) const;
00299 void evaluateCycle(float start_index, float stop_index,
00300 float *data, int size) const;
00301 void evaluateMirror(float start_index, float stop_index,
00302 float *data, int size) const;
00303 void evaluateCycleStep(float start_index, float stop_index,
00304 float *data, int size) const;
00305
00306 void updateName();
00307
00308
00309
00310
00311
00312 class CL_API BinaryIO
00313 {
00314 public:
00315 BinaryIO() : myTaintVersion(0), myOffset(0), myDoubleFlag(false) {}
00316
00317 int myTaintVersion;
00318 int myOffset;
00319 bool myDoubleFlag;
00320 };
00321
00322 int save(ostream &os, bool binary,
00323 BinaryIO *binary_options) const;
00324 bool load(UT_IStream &is, BinaryIO *binary_options,
00325 const char *path = 0);
00326
00327 void setDefaults();
00328 void calcNameNumber();
00329
00330 UT_String myName;
00331 UT_FloatArray myData;
00332 CL_Clip *myParent;
00333
00334 unsigned short myNameBaseLength;
00335 unsigned short myNameNumber;
00336 unsigned short myNameBaseHash;
00337
00338 unsigned short myNameHash;
00339 char myNameNumberDirty;
00340
00341
00342 CL_TrackOutside myLeft;
00343 CL_TrackOutside myRight;
00344 float myDefault;
00345 float *myPrevDataAlias;
00346
00347 friend class CL_Clip;
00348 friend class CL_AsciiClipReader;
00349 friend class CL_AsciiClipWriter;
00350 friend class CL_BinaryClipReader;
00351 friend class CL_BinaryClipWriter;
00352 };
00353
00354
00355 #endif