HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CHOP_Realtime.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: CHOP Library (C++)
7  *
8  * COMMENTS: All realtime Channel Filters should derive from this class.
9  *
10  */
11 
12 #ifndef __CHOP_Realtime_h__
13 #define __CHOP_Realtime_h__
14 
15 #include "CHOP_API.h"
16 #include "CHOP_Node.h"
17 #include <CL/CL_SaveVersion.h>
18 
19 #define REALTIME_MODE_TRIM 0
20 #define REALTIME_MODE_ACCUM 1
21 #define REALTIME_MODE_CONTINUOUS 2
22 #define REALTIME_MODE_CURRENT_FRAME 3
23 #define REALTIME_MODE_FRAME_ONE 4
24 
25 #define REALTIME_INPUT_INTEREST_NONE (-1)
26 #define REALTIME_INPUT_INTEREST_ALL (-2)
27 
28 #define DEF_REALTIME_SETTLING_TIME 3
29 
30 class UT_OStream;
31 class CL_Filter;
32 class chop_RealtimeData;
33 
34 // Base Class for realtime Data blocks
36 {
37 public:
38  ut_RealtimeData(const char *name, int input = -1);
39  virtual ~ut_RealtimeData();
40 
41  const UT_String & tag() { return myTag; }
42  int inputNum() { return myInputNum; }
43  void setInput(int n) { myInputNum = n; }
44 
45  virtual bool loadStates(UT_IStream &is, int version);
46  virtual bool saveStates(UT_OStream &os);
47 
48 private:
49  UT_String myTag;
50  int myInputNum;
51 };
52 
53 // class for filtering data blocks (para eq, band eq, filter, etc).
55 {
56 public:
57  ut_FilterData(const char *name, int filter_size, int overlap);
58  virtual ~ut_FilterData();
59 
60  virtual bool loadStates(UT_IStream &is, int version);
61  virtual bool saveStates(UT_OStream &os);
62 
64 };
65 
67 {
68 protected:
69 
70  CHOP_Realtime(OP_Network *parent,
71  const char *name,
72  OP_Operator *entry);
73  virtual ~CHOP_Realtime();
74 
75  virtual OP_ERROR cookMySlice(OP_Context &, int start, int end) =0;
76  virtual const char *getTimeSliceExtension() = 0;
77  virtual int getSaveVersion()
78  { return CL_SAVE_VERSION; }
79 
80 
81  // called when the realtime button is turned on or off.
82  virtual void realtimeInit(fpreal t);
83  virtual void realtimeCleanup();
84 
85  // these methods are called when the framebar is started or stopped.
86  virtual void realtimeStart(fpreal t);
87  virtual void realtimeStop();
88 
89  // this method returns a newly allocated ut_RealtimeData block.
90  // override this if you have subclassed ut_RealtimeData.
91  // One data block per channel.
92  virtual ut_RealtimeData * newRealtimeDataBlock(const char *name,
93  const CL_Track *track,
94  fpreal t);
95 
96  // overridden from CHOP_Node.
97  virtual int usesRealtime() { return 1; }
98  virtual int isRealtimeCook() { return REALTIME(); }
99  virtual int isRealtimeActive(OP_Context &) { return 1; }
100 
101  // normally all realtime chops are time dependent
102  virtual int isTimeDependent();
103  virtual int isSteady() const;
104  virtual int getSettlingTime() const
105  { return DEF_REALTIME_SETTLING_TIME; }
106  virtual int allowDoubleCooking() const { return 0; }
107 
108  int isFirstRealtimeCook() const;
109  void setFirstRealtimeCook(bool first);
110 
111  // if true, this will trim out only the current slice.
112  virtual int realtimeMode() { return REALTIME_MODE_TRIM; }
113 
114  // if true, the realtime CHOP will change the start/end of the CHOP.
115  // otherwise, it leaves it alone.
116  virtual int adjustClip() { return 1; }
117 
118  // do not override this method.
119  virtual OP_ERROR doCookRealtime(OP_Context &context);
120 
121  // which input's channels are our names & number of channels dependent on
122  // (-1 for none)
123  virtual int getInputInterest() { return 0; } // first input
124 
125  // override if you need the slice to end at a time other than the
126  // current frame (+/- adjustment).
127  virtual fpreal getRealtimeFrameAdjustment(fpreal ) { return 0.0; }
128 
129  // override if the sample rate is set by the chop, and not the input.
131 
132  // returns true if a range has been modified, plus that range.
133  virtual int getModifiedRange(int &first,int &last,int clear=1);
134 
135  // returns true if wraparound occured before this cook.
136  int isWraparound() const;
137 
138  int getNumDataBlocks() const;
140  ut_RealtimeData * getDataBlock(const char *tag);
141 
142  void getFrameRange(int &start, int &end);
143  unsigned int getAbsoluteFrame();
144 
145  // input channel name & data cache management for straight through
146  // filters.
147  virtual void cacheChannelData(fpreal t);
148  virtual void resetDataCache();
149 
150  void setPreviousCookTime(fpreal t);
151 
152  void getCurrentRange(int &start, int &end) const;
153  void setCurrentRange(int start, int end);
154 
155  // for classes that manage their own data blocks; use with caution.
156  ut_RealtimeData *addDataBlock(const char *name,
157  const CL_Track *track =0,
158  fpreal t = 0.0);
159  ut_RealtimeData *insertDataBlock(int index,
160  const char *name,
161  const CL_Track *track =0,
162  fpreal t = 0.0);
163  void removeDataBlock(const char *name);
164  void removeDataBlock(int index);
165 
166  void updateDataBlocks();
167 
168  void copyRealtimeInput(const CL_Clip *clip,
169  int start, int end);
170 
171  virtual OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags,
172  const char *pathPrefix,
173  const UT_String &name_override = UT_String());
174 
175  virtual bool load(UT_IStream &is, const char *extension,
176  const char *path);
177 
178  virtual OP_ERROR saveStates(UT_OStream &os);
179  virtual bool loadStates(UT_IStream &is, int version);
180 
181  // Allow the Reset At First Frame playbar button to clear all data in
182  // doRealtimeCook()
184  { return isRealtimeActive(ctx); }
185 
186 protected:
187 
188  chop_RealtimeData *newRealtimeBlock();
189 
190  chop_RealtimeData *myRealtimeData;
191 
192 private:
193  void getParentTimeSlice(int &start,int &end);
194 
195 public:
196  chop_RealtimeData *getRealtimeData() { return myRealtimeData; }
197  void setRealtimeData(chop_RealtimeData *d)
198  { myRealtimeData = d; }
199  static void deleteRealtimeData(chop_RealtimeData *data);
200 
201 };
202 
203 #endif
chop_RealtimeData * getRealtimeData()
GLint first
Definition: glcorearb.h:404
#define DEF_REALTIME_SETTLING_TIME
Definition: CHOP_Realtime.h:28
#define REALTIME_MODE_TRIM
Definition: CHOP_Realtime.h:19
virtual int allowDoubleCooking() const
#define CHOP_API
Definition: CHOP_API.h:10
virtual bool saveStates(UT_OStream &os)
virtual int getModifiedRange(int &first, int &last, int clear=1)
GLuint start
Definition: glcorearb.h:474
virtual void realtimeInit(fpreal t)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
UT_ErrorSeverity
Definition: UT_Error.h:25
GLbitfield flags
Definition: glcorearb.h:1595
bool isTimeDependent(OP_Context &context)
OP_DataBlockPtr getDataBlock(const char *key) const
CL_Filter * myFilter
Definition: CHOP_Realtime.h:63
virtual bool load(UT_IStream &is, const char *extension, const char *path=0)
chop_RealtimeData * myRealtimeData
int REALTIME() const
Definition: CHOP_Node.h:554
virtual void realtimeCleanup()
GLdouble n
Definition: glcorearb.h:2007
virtual bool allowResetAtFirstFrame(OP_Context &ctx)
GLuint GLuint end
Definition: glcorearb.h:474
void setInput(int n)
Definition: CHOP_Realtime.h:43
virtual int isRealtimeCook()
Definition: CHOP_Realtime.h:98
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual OP_ERROR doCookRealtime(OP_Context &context)
virtual int isRealtimeActive(OP_Context &)
Definition: CHOP_Realtime.h:99
const UT_String & tag()
Definition: CHOP_Realtime.h:41
double fpreal
Definition: SYS_Types.h:269
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
fpreal getSampleRate()
virtual int getSaveVersion()
Definition: CHOP_Realtime.h:77
virtual int usesRealtime()
Definition: CHOP_Realtime.h:97
virtual OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *pathPrefix, const UT_String &name_override=UT_String())
virtual int realtimeMode()
GLuint index
Definition: glcorearb.h:785
virtual int getInputInterest()
virtual fpreal getRealtimeSampleRate()
virtual bool loadStates(UT_IStream &is, int version)
#define CL_SAVE_VERSION
void setRealtimeData(chop_RealtimeData *d)
virtual int getSettlingTime() const
virtual fpreal getRealtimeFrameAdjustment(fpreal)
virtual int adjustClip()