HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CL_Track.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CL_Track.h ( Clip Library, C++)
7  *
8  * COMMENTS:
9  * A set of raw data
10  *
11  */
12 
13 
14 #ifndef __CL_Track__
15 #define __CL_Track__
16 
17 #include "CL_API.h"
18 #include <UT/UT_ValArray.h>
19 #include <UT/UT_FloatArray.h>
20 #include <UT/UT_String.h>
21 #include <UT/UT_StringHolder.h>
22 #include <SYS/SYS_Types.h>
23 
24 class UT_IStream;
25 class UT_OStream;
26 class CL_Clip;
27 class CL_Track;
29 
32 
33 //
34 // how to evaluate the track outside its defined range
35 //
36 
37 typedef enum {
38  CL_TRACK_HOLD, // Track is start/end value before/after
39  CL_TRACK_SLOPE, // Track extends at start/end slope
40  CL_TRACK_CYCLE, // Track wraps to defined range (repeat)
41  CL_TRACK_MIRROR, // Track wraps+reflects to defined range
42  CL_TRACK_DEFAULT, // Track is default value beyond defined range
43  CL_TRACK_CYCLE_STEP // Track is cycled and advanced
45 
47 {
52 };
53 
55 {
60 };
61 
63 {
68 };
69 
70 
72 
73 public:
74 
75  CL_Track(CL_Clip &dad, const CL_Track &from);
76  CL_Track(CL_Clip &dad, const char *name);
77  ~CL_Track();
78 
79 
80  CL_Track &operator= (const CL_Track &from);
81 
82  void init(CL_Clip &dad, const char *name);
83 
85  { return myData.array(); }
86 
87  const fpreal *getData() const
88  { return myData.getRawArray(); }
89 
90  int getTrackLength() const
91  { return myData.entries(); }
92 
93  const UT_String &getName() const
94  { return myName; }
95 
96  const UT_StringHolder &getNameRef() const
97  { return myNameRef; }
98 
99 
100  //
101  // Warning this method must be used with extreme caution
102  void setName(const char *);
103 
104  // These methods are used for special cases, to access tracks more quickly.
105  // Normally a symboltable in CL_Clip is used to track access by name.
106  unsigned short getNameHash() const
107  { return myNameHash; }
108 
109  unsigned short getNameBaseLength() const
110  { return myNameBaseLength; }
111 
112  unsigned short getNameBaseHash() const
113  { return myNameBaseHash; }
114 
115  int getNameNumber() const
116  {
117  if (myNameNumberDirty)
118  ((CL_Track *)this)->calcNameNumber();
119  return myNameNumber;
120  }
121 
122  static void getNameComposition(const char *name,
123  unsigned short &base_length,
124  unsigned short &base_hash);
125 
126 
127  const char *info(fpreal t, const char *prefix = 0,
128  const char *suffix = 0) const;
129 
130  int isTimeDependent() const;
131 
132  int isWithinRange(fpreal low,fpreal hi,int completely=1) const;
133 
134  // these methods define the evaluation of the array outside
135  // its defined interval
136 
137  void setLeft(CL_TrackOutside type);
138  void setRight(CL_TrackOutside type);
139  void setDefault(fpreal value);
140 
142  { return myParent; }
143 
144  const CL_Clip *getClip(void) const
145  { return myParent; }
146 
147 
148  const char *getLeft(void) const;
149  const char *getRight(void) const;
150 
151  int64 getMemoryUsage(bool inclusive) const;
152 
153  void getExtendCond(CL_TrackOutside &left,
154  CL_TrackOutside &right) const;
156  { return myDefault; }
157 
158  void dupAttributes(const CL_Track *,
159  int data_too=0, int name_too=0);
160 
161  // data methods
162 
163  void reverse();
164  void constant(fpreal value=0);
165  void cycle(int howmany);
166 
167  int convolve(const CL_Track &t1, const CL_Track &t2,
168  int add = 0);
169 
170  int convolveCenter(fpreal *data2, int n2, int passes = 1);
171  int convolveCenterDirect(fpreal *data2, int n2, int passes);
172  int convolveCenterFFT(fpreal *data2,int n2,int passes);
173 
174  int copyStamp(const CL_Track &t1, fpreal toffset, int clr);
175 
176  int getThresholdTimes(fpreal thresh,
177  UT_FprealArray &toffsets,
178  UT_FprealArray &values) const;
179 
180  void despike(fpreal tol, fpreal effect=1.0, int maxwidth=1);
181 
182  void blend(fpreal start, const fpreal *values, int len,
183  fpreal base, const CL_SubRange *effect,
184  fpreal cycle);
185 
186  void blend(fpreal start, const fpreal *values, int len,
187  fpreal base, const CL_Track *effect_track,
188  fpreal cycle);
189 
190  void limitValues(fpreal max, fpreal min,
192  int start, int end);
193 
194  static fpreal limitValue(fpreal max, fpreal min,
196 
197  // Resample from the given source into ourselves
198 
199  int resample(const fpreal *values, int num,
201  int constant_area, int iscycle = 0,
202  fpreal cycle = 0);
203 
204  // Resample from ourselves into the given destination
205 
206  int resample(fpreal *data, int size, int start, int end,
208  int constant_area,
209  int iscycle = 0,
210  fpreal cycle = 0) const;
211 
212  void quantizeValue(fpreal max, fpreal min,
214  fpreal step, fpreal offset,
215  int clamp, int start, int end);
216 
217  void normalize();
218  void absolute();
219  void smoothRotate(fpreal delta = 180.0);
220 
221 
222  // Filter size must be a power of 2, and the filter itself should be
223  // in the form of a DFT filter
224  // the callback function takes parms 'node' 'size', 'freq step'
225  // 'mag filter' 'phase filter'
226  // 'index' and 'chunk' -- mag & phase filter are the arrays to be filted
227  // by the callback function. Called before filtering each chunk, if
228  // not null.
229  void filterFrequency(int filter_size,
230  fpreal freqstep,
231  fpreal overlap,
232  fpreal discard,
233  fpreal *filter,
234  fpreal *phase_filter = 0,
235  void (*filter_design)(void *,int,fpreal,fpreal *,fpreal *,int,int)=0,
236  void *node = 0,
237  int doblend = 1);
238 
239 
240  void pitchShift(fpreal shift,int chunk,
241  const CL_Track *animate=0,
242  fpreal (*callback)(void *,int,int)=0,
243  void *node=0);
244 
245  // This actually is a DFT followed by a multipy, and an IDFT
246  void fastConvolve(int chunk,fpreal *data);
247 
248 
249  // This method allows this track to assume the same data array as 'track'.
250  // They will share the same buffer until unalias() is called. aliasTrack()
251  // may be called multiple times before unalias() is called. Both tracks
252  // must have the same number of samples.
253  void aliasTrack(CL_Track &track);
254  void unalias();
255  bool isAliased() const { return myPrevDataAlias != 0; }
256 
257  // swaps data with 'track'.
258  void swapData(CL_Track &track);
259 
260  int getIndex() const;
261 
262 private:
263 
264  // should only be called by CL_Clip
265 
266  void evaluate(fpreal start_index, fpreal stop_index,
267  fpreal *data, int size) const;
268 
269 
270  // this single version is much less efficient than the range methods
271  fpreal evaluateSingle(fpreal index) const;
272 
273  // optimizied evaluations which work on a range
274  // entire range is evaluated with a particular extend condition
275 
276  void evaluatePortion(fpreal i0, fpreal i1,
277  fpreal start_index, fpreal
278  stop_index, fpreal *data, int size,
279  fpreal *fix, int portion) const;
280 
281  void evaluateCenter(fpreal start_index, fpreal stop_index,
282  fpreal *data, int size) const;
283 
284  void evaluateLeftSlope(fpreal start_index, fpreal stop_index,
285  fpreal *data, int size) const;
286  void evaluateRightSlope(fpreal start_index, fpreal stop_index,
287  fpreal *data, int size) const;
288 
289  void evaluateLeftHold(fpreal *data, int size) const;
290  void evaluateRightHold(fpreal *data, int size) const;
291 
292  void evaluateDefault(fpreal *data, int size) const;
293  void evaluateCycle(fpreal start_index, fpreal stop_index,
294  fpreal *data, int size) const;
295  void evaluateMirror(fpreal start_index, fpreal stop_index,
296  fpreal *data, int size) const;
297  void evaluateCycleStep(fpreal start_index, fpreal stop_index,
298  fpreal *data, int size) const;
299 
300  void updateName();
301 
302 
303  //
304  // I/O methods
305  //
306  class CL_API BinaryIO
307  {
308  public:
309  BinaryIO() : myTaintVersion(0), myOffset(0), myDoubleFlag(false) {}
310 
311  int myTaintVersion;
312  int myOffset;
313  bool myDoubleFlag;
314  };
315 
316  int save(UT_OStream &os, BinaryIO *binary_options) const;
317  bool load(UT_IStream &is, BinaryIO *binary_options,
318  const char *path = 0);
319 
320  void setDefaults();
321  void calcNameNumber();
322  void setIndex(int);
323 
324  UT_String myName;
325  UT_StringHolder myNameRef;
326  UT_FprealArray myData;
327  CL_Clip *myParent;
328 
329  unsigned short myNameBaseLength;
330  unsigned short myNameNumber;
331  unsigned short myNameBaseHash;
332 
333  unsigned short myNameHash;
334  char myNameNumberDirty;
335 
336 
337  CL_TrackOutside myLeft; // eval method outside range
338  CL_TrackOutside myRight; // eval method outside range
339  fpreal myDefault; // used in CL_TRACK_DEFAULT
340  fpreal *myPrevDataAlias; // used by alias/unalias.
341 
342  int myIndex; // track index in the clip array.
343 
344  friend class CL_Clip;
345  friend class CL_AsciiClipReader;
346  friend class CL_AsciiClipWriter;
347  friend class CL_BinaryClipReader;
348  friend class CL_BinaryClipWriter;
349 };
350 
351 
352 #endif
UT_ValArray< const CL_Track * > CL_TrackListC
Definition: CL_Track.h:31
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128
GLint left
Definition: glcorearb.h:2004
CL_Clip * getClip(void)
Definition: CL_Track.h:141
const GLdouble * v
Definition: glcorearb.h:836
GLuint start
Definition: glcorearb.h:474
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
GLsizeiptr size
Definition: glcorearb.h:663
int getNameNumber() const
Definition: CL_Track.h:115
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:132
unsigned short getNameBaseLength() const
Definition: CL_Track.h:109
#define CL_API
Definition: CL_API.h:10
long long int64
Definition: SYS_Types.h:106
bool isAliased() const
Definition: CL_Track.h:255
CL_TrackLimitMethod
Definition: CL_Track.h:46
unsigned short getNameHash() const
Definition: CL_Track.h:106
CL_QuantizeValueMethod
Definition: CL_Track.h:54
GLuint GLuint end
Definition: glcorearb.h:474
int method
Definition: png.h:1924
const UT_StringHolder & getNameRef() const
Definition: CL_Track.h:96
GLintptr offset
Definition: glcorearb.h:664
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
GridType::Ptr normalize(const GridType &grid, bool threaded, InterruptT *interrupt)
Normalize the vectors of the given vector-valued grid.
unsigned short getNameBaseHash() const
Definition: CL_Track.h:112
const CL_Clip * getClip(void) const
Definition: CL_Track.h:144
CL_TrackOutside
Definition: CL_Track.h:37
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:269
CL_TrackResampleMethod
Definition: CL_Track.h:62
int getTrackLength() const
Definition: CL_Track.h:90
fpreal getDefault() const
Definition: CL_Track.h:155
const fpreal * getData() const
Definition: CL_Track.h:87
GLuint index
Definition: glcorearb.h:785
const UT_String & getName() const
Definition: CL_Track.h:93
fpreal * getData()
Definition: CL_Track.h:84
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
png_infop png_uint_32 int num
Definition: png.h:2158
png_infop int chunk
Definition: png.h:2576
UT_ValArray< CL_Track * > CL_TrackList
Definition: CL_Track.h:28
GLenum clamp
Definition: glcorearb.h:1233
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296