forked from t3kt/DistThresholdCHOP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHOP_CPlusPlusBase.h
524 lines (387 loc) · 12.2 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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
/*
* 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 <windows.h>
#include <cstdio>
#define DLLEXPORT __declspec (dllexport)
#define CHOP_CPLUSPLUS_API_VERSION 1
class CHOP_CPlusPlusBase;
class CHOP_NodeInfo;
// These are the definitions for the C-functions that are used to
// load the library and create instances of the object you define
typedef int (__cdecl *GETCHOPAPIVERSION)(void);
typedef CHOP_CPlusPlusBase* (__cdecl *CREATECHOPINSTANCE)(const CHOP_NodeInfo*);
typedef void (__cdecl *DESTROYCHOPINSTANCE)(CHOP_CPlusPlusBase*);
// These classes are used to pass data to/from the functions you will define
class CHOP_NodeInfo
{
public:
// The full path to the node
const char* nodeFullPath;
// A unique ID representing the node, no two nodes will ever
// have the same ID in a single Touch instance.
unsigned int uniqueNodeId;
// This is the handle to the main TouchDesigner window.
// It's possible this will be 0 the first few times the node cooks,
// incase it cooks while Touch is still loading up
HWND mainWindowHandle;
private:
int reserved[19];
};
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 length of the CHOP will be determined
// by the number of frames that have elapsed since the last time Touch
// 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,
// Touch is running at 60 hz cookrate, and you missed a frame last cook
// then on this cook the length of the output of this CHOP will be
// 4 samples. ((120 / 60) * number of playbar frames to output)
// If this isn't set then you specify the length of 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
int inputMatchIndex;
private:
int reserved[20];
};
class CHOP_FloatInput
{
public:
const char* name;
int inputNumber;
// Will contain the 4 floats in the parameter.
float values[4];
private:
int reserved[20];
};
class CHOP_StringInput
{
public:
const char* name;
int inputNumber;
const char* value;
private:
int reserved[20];
};
class CHOP_CHOPInput
{
public:
const char* nodeFullPath;
int inputNumber;
int numChannels;
int length;
float sampleRate;
unsigned int startIndex;
// This is an array of const char* which tells you the names of the
// channels. The length of the array is 'numChannels' long.
// For example names[1] is the name of the 2nd channel
const char** names;
// This is an array of float arrays. The array is 'numChannels' long
// while each individual array within the array is 'length' long
// e.g: channels[1][10] will refer to the 11th sample in the 2nd channel
const float** channels;
private:
int reserved[20];
};
class CHOP_DATInput
{
public:
const char* nodeFullPath;
int inputNumber;
int numRows;
int numCols;
bool isTable;
// data, referenced by [row][col], which will be a const char* for the
// contents of the cell
// E.g data[1][1] will be the contents of the cell located at (1, 1)
const char*** data;
private:
int reserved[20];
};
class CHOP_InputArrays
{
public:
int numFloatInputs;
// floatInputs is an array of CHOP_FloatInputs objects, 'numFloatInputs' long
// e.g floatInputs[0].name
const CHOP_FloatInput* floatInputs;
// The rest of these are similar to the floatInputs description
int numCHOPInputs;
const CHOP_CHOPInput* CHOPInputs;
int numStringInputs;
const CHOP_StringInput* stringInputs;
int numDATInputs;
const CHOP_DATInput* DATInputs;
private:
#ifdef _WIN64
int reserved[95];
#else
int reserved[98];
#endif
};
class CHOP_OutputInfo
{
public:
// The number of channels you want to output
int numChannels;
// If you arn't outputting a timeslice, specify the length of the channels
// here
int length;
// 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
unsigned int 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
const CHOP_InputArrays *inputArrays;
private:
int reserved[20];
};
class CHOP_InfoCHOPChan
{
public:
char* name;
float value;
private:
int reserved[10];
};
class CHOP_InfoDATSize
{
public:
// Set this to the size you want the table to be
int rows;
int cols;
// Set this to true if you want to return DAT entries on a column
// by column basis.
// Otherwise set to false, and you'll be expected to set them on
// a row by row basis.
bool byColumn;
private:
int reserved[10];
};
class CHOP_InfoDATEntries
{
public:
// This is an array of char* pointers which you are expected to assign
// The start off as NULL, you need to allocate or assign constant/statis
// strings to them
// e.g values[1] = "myColumnName";
char** values;
private:
int reserved[10];
};
class CHOP_Output
{
public:
CHOP_Output(int nc, int l, float s, unsigned int st):
numChannels(nc),
length(l),
sampleRate(s),
startIndex(st)
{
}
// Info about what you are expected to output
const int numChannels;
const int length;
const float sampleRate;
const unsigned int 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 'length'.
// For example channels[1][10] will point to the 11th sample in the 2nd
// channel
float** channels;
private:
int reserved[20];
};
/***** 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, their length etc.
// Return true if you specify the output here
// Return false if you want the output to be set by matching
// the channel names, length, 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(int index, void* reserved)
{
return "chan1";
}
// In this function you do whatever you want to fill the framebuffer
//
// See the CHOP_InputArrays class definition for more details on it's
// contents
virtual void execute(const CHOP_Output*,
const CHOP_InputArrays*,
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 int 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 NULL
// you must allocate memory or assign a constant string
// to it.
virtual void getInfoCHOPChan(int index,
CHOP_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(CHOP_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(int index,
int nEntries,
CHOP_InfoDATEntries *entries)
{
}
// You can use this function to put the node into a warning state
// with the returned string as the message.
// Return NULL if you don't want it to be in a warning state.
virtual const char* getWarningString()
{
return NULL;
}
// You can use this function to put the node into a error state
// with the returned string as the message.
// Return NULL if you don't want it to be in a error state.
virtual const char* getErrorString()
{
return NULL;
}
// Use this function to return some text that will show up in the
// info popup (when you middle click on a node)
// Return NULL if you don't want to return anything.
virtual const char* getInfoPopupString()
{
return NULL;
}
// END PUBLIC INTERFACE
private:
// Reserved for future features
virtual int reservedFunc4() { return 0; }
virtual int reservedFunc5() { return 0; }
virtual int reservedFunc6() { return 0; }
virtual int reservedFunc7() { return 0; }
virtual int reservedFunc8() { return 0; }
virtual int reservedFunc9() { return 0; }
virtual int reservedFunc10() { return 0; }
virtual int reservedFunc11() { return 0; }
virtual int reservedFunc12() { return 0; }
virtual int reservedFunc13() { return 0; }
virtual int reservedFunc14() { return 0; }
virtual int reservedFunc15() { return 0; }
virtual int reservedFunc16() { return 0; }
virtual int reservedFunc17() { return 0; }
virtual int reservedFunc18() { return 0; }
virtual int reservedFunc19() { return 0; }
virtual int reservedFunc20() { return 0; }
int reserved[400];
};
#endif