-
Notifications
You must be signed in to change notification settings - Fork 1
/
CHOP_CPlusPlusBase.h
373 lines (279 loc) · 10.1 KB
/
CHOP_CPlusPlusBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/* Shared Use License: This file is owned by Derivative Inc. (Derivative) and
* can only be used, and/or modified for use, in conjunction with
* Derivative's TouchDesigner software, and only if you are a licensee who has
* accepted Derivative's TouchDesigner license or assignment agreement (which
* also govern the use of this file). You may share a modified version of this
* file with another authorized licensee of Derivative's TouchDesigner software.
* Otherwise, no redistribution or sharing of this file, with or without
* modification, is permitted.
*/
/*
* Produced by:
*
* Derivative Inc
* 401 Richmond Street West, Unit 386
* Toronto, Ontario
* Canada M5V 3A8
* 416-591-3555
*
* NAME: CHOP_CPlusPlusBase.h
*
*
* Do not edit this file directly!
* Make a subclass of CHOP_CPlusPlusBase instead, and add your own
* data/functions.
* Derivative Developers:: Make sure the virtual function order
* stays the same, otherwise changes won't be backwards compatible
*/
#ifndef __CHOP_CPlusPlusBase__
#define __CHOP_CPlusPlusBase__
#include "CPlusPlus_Common.h"
#define CHOP_CPLUSPLUS_API_VERSION 6
class CHOP_CPlusPlusBase;
// These are the definitions for the C-functions that are used to
// load the library and create instances of the object you define
typedef int32_t (__cdecl *GETCHOPAPIVERSION)(void);
typedef CHOP_CPlusPlusBase* (__cdecl *CREATECHOPINSTANCE)(const OP_NodeInfo*);
typedef void (__cdecl *DESTROYCHOPINSTANCE)(CHOP_CPlusPlusBase*);
class CHOP_GeneralInfo
{
public:
// Set this to true if you want the CHOP to cook every frame, even
// if none of it's inputs/parameters are changing
// DEFAULT: false
bool cookEveryFrame;
// Set this to true if you want the CHOP to cook every frame, but only
// if someone asks for it to cook. So if nobody is using the output from
// the CHOP, it won't cook. This is difereent from 'cookEveryFrame'
// since that will cause it to cook every frame no matter what.
bool cookEveryFrameIfAsked;
// Set this to true if you will be outputting a timeslice
// Outputting a timeslice means the number of samples in the CHOP will
// be determined by the number of frames that have elapsed since the last
// time TouchDesigner cooked (it will be more than one in cases where it's
// running slower than the target cook rate), the playbar framerate and
// the sample rate of the CHOP.
// For example if you are outputting the CHOP 120hz sample rate,
// TouchDesigner is running at 60 hz cookrate, and you missed a frame last cook
// then on this cook the number of sampels of the output of this CHOP will
// be 4 samples. I.e (120 / 60) * number of playbar frames to output.
// If this isn't set then you specify the number of sample in the CHOP using
// the getOutputInfo() function
// DEFAULT: false
bool timeslice;
// If you are returning 'false' from getOutputInfo, this index will
// specify the CHOP input whos attribues you will match
// (channel names, length, sample rate etc.)
// DEFAULT : 0
int32_t inputMatchIndex;
private:
int32_t reserved[20];
};
class CHOP_OutputInfo
{
public:
// The number of channels you want to output
int32_t numChannels;
// If you arn't outputting a timeslice, specify the number of samples here
int32_t numSamples;
// if you arn't outputting a timeslice, specify the start index
// of the channels here. This is the 'Start' you see when you
// middle click on a CHOP
uint32_t startIndex;
// Specify the sample rate of the channel data
// DEFAULT : whatever the timeline FPS is ($FPS)
float sampleRate;
// This is provided for you incase you want to use data from the
// your inputs/parameters to decide what you will be outputting from
// the CHOP, you shouldn't change anything in this structure
OP_Inputs* opInputs;
private:
int32_t reserved[20];
};
class CHOP_Output
{
public:
CHOP_Output(int32_t nc, int32_t l, float s, uint32_t st):
numChannels(nc),
numSamples(l),
sampleRate(s),
startIndex(st)
{
}
// Info about what you are expected to output
const int32_t numChannels;
const int32_t numSamples;
const float sampleRate;
const uint32_t startIndex;
// This is an array of const char* that tells you the channel names
// of the channels you are providing values for. It's 'numChannels' long.
// E.g names[3] is the name of the 4th channel
const char** names;
// This is an array of float arrays, the length of the array is
// 'numChannels', while the length of each of the arrays each entry
// points to is 'numSamples'.
// For example channels[1][10] will point to the 11th sample in the 2nd
// channel
float** channels;
private:
int32_t reserved[20];
};
/***** FUNCTION CALL ORDER DURING INITIALIZATION ******/
/*
When the TOP loads the dll the functions will be called in this order
setupParameters(OP_ParameterManager* m);
*/
/***** FUNCTION CALL ORDER DURING A COOK ******/
/*
When the CHOP cooks the functions will be called in this order
getGeneralInfo()
getOutputInfo()
if getOutputInfo() returns true
{
getChannelName() once for each channel needed
}
execute()
getNumInfoCHOPChans()
for the number of chans returned getNumInfoCHOPChans()
{
getInfoCHOPChan()
}
getInfoDATSize()
for the number of rows/cols returned by getInfoDATSize()
{
getInfoDATEntries()
}
getInfoPopupString()
getWarningString()
getErrorString()
*/
/*** DO NOT EDIT THIS CLASS, MAKE A SUBCLASS OF IT INSTEAD ***/
class CHOP_CPlusPlusBase
{
protected:
CHOP_CPlusPlusBase()
{
}
public:
virtual ~CHOP_CPlusPlusBase()
{
}
// BEGIN PUBLIC INTERFACE
// Some general settings can be assigned here (if you ovierride it)
virtual void getGeneralInfo(CHOP_GeneralInfo*)
{
}
// This function is called so the class can tell the CHOP how many
// channels it wants to output, how many samples etc.
// Return true if you specify the output here
// Return false if you want the output to be set by matching
// the channel names, numSamples, sample rate etc. of one of your inputs
// The input that is used is chosen by setting the 'inputMatchIndex'
// memeber in getGeneralInfo()
// The CHOP_OutputFormat class is pre-filled with what the CHOP would
// output if you return false, so you can just tweak a few settings
// and return true if you want
virtual bool getOutputInfo(CHOP_OutputInfo*)
{
return false;
}
// This function will be called after getOutputInfo() asking for
// the channel names. It will get called once for each channel name
// you need to specify. If you returned 'false' from getOutputInfo()
// it won't be called.
virtual const char* getChannelName(int32_t index, void* reserved)
{
return "chan1";
}
// In this function you do whatever you want to fill the framebuffer
//
// See the OP_Inputs class definition for more details on it's
// contents
virtual void execute(const CHOP_Output*,
OP_Inputs* ,
void* reserved) = 0;
// Override these methods if you want to output values to the Info CHOP/DAT
// returning 0 means you dont plan to output any Info CHOP channels
virtual int32_t getNumInfoCHOPChans()
{
return 0;
}
// Specify the name and value for CHOP 'index',
// by assigning something to 'name' and 'value' members of the
// CHOP_InfoCHOPChan class pointer that is passed (it points
// to a valid instance of the class already.
// the 'name' pointer will initially point to nullptr
// you must allocate memory or assign a constant string
// to it.
virtual void getInfoCHOPChan(int32_t index,
OP_InfoCHOPChan* chan)
{
}
// Return false if you arn't returning data for an Info DAT
// Return true if you are.
// Set the members of the CHOP_InfoDATSize class to specify
// the dimensions of the Info DAT
virtual bool getInfoDATSize(OP_InfoDATSize* infoSize)
{
return false;
}
// You are asked to assign values to the Info DAT 1 row or column at a time
// The 'byColumn' variable in 'getInfoDATSize' is how you specify
// if it is by column or by row.
// 'index' is the row/column index
// 'nEntries' is the number of entries in the row/column
virtual void getInfoDATEntries(int32_t index,
int32_t nEntries,
OP_InfoDATEntries* entries)
{
}
// You can use this function to put the node into a warning state
// with the returned string as the message.
// Return nullptr if you don't want it to be in a warning state.
virtual const char* getWarningString()
{
return nullptr;
}
// You can use this function to put the node into a error state
// with the returned string as the message.
// Return nullptr if you don't want it to be in a error state.
virtual const char* getErrorString()
{
return nullptr;
}
// Use this function to return some text that will show up in the
// info popup (when you middle click on a node)
// Return nullptr if you don't want to return anything.
virtual const char* getInfoPopupString()
{
return nullptr;
}
// Override these methods if you want to define specfic parameters
virtual void setupParameters(OP_ParameterManager* manager)
{
}
// This is called whenever a pulse parameter is pressed
virtual void pulsePressed(const char* name)
{
}
// END PUBLIC INTERFACE
private:
// Reserved for future features
virtual int32_t reservedFunc6() { return 0; }
virtual int32_t reservedFunc7() { return 0; }
virtual int32_t reservedFunc8() { return 0; }
virtual int32_t reservedFunc9() { return 0; }
virtual int32_t reservedFunc10() { return 0; }
virtual int32_t reservedFunc11() { return 0; }
virtual int32_t reservedFunc12() { return 0; }
virtual int32_t reservedFunc13() { return 0; }
virtual int32_t reservedFunc14() { return 0; }
virtual int32_t reservedFunc15() { return 0; }
virtual int32_t reservedFunc16() { return 0; }
virtual int32_t reservedFunc17() { return 0; }
virtual int32_t reservedFunc18() { return 0; }
virtual int32_t reservedFunc19() { return 0; }
virtual int32_t reservedFunc20() { return 0; }
int32_t reserved[400];
};
#endif