Jamoma API  0.6.0.a19
TTMatrixStencil.h
1 /*
2  * Jamoma MatrixProcessingLib: Stencil
3  * Copyright © 2011, Timothy Place
4  *
5  * License: This code is licensed under the terms of the "New BSD License"
6  * http://creativecommons.org/licenses/BSD/
7  */
8 
9 #ifndef __TTMATRIXSTENCIL_H__
10 #define __TTMATRIXSTENCIL_H__
11 
12 #include "TTMatrixProcessingLib.h"
13 
14 
15 /****************************************************************************************************/
16 // Class Specifications
17 
18 /**
19  This class performs operations on a stencil from a matrix.
20  In the initial implementation, we have limited ourselves to 5-point stencil as described @ http://en.wikipedia.org/wiki/Five-point_stencil
21  and we limit the operations to be performed to simple averaging and the first derivitave.
22 
23  With the averaging case, and the middle point omitted, the result is thus similar to the operation of the jit.avg4 object in Jitter.
24  */
27 
28  TTSymbol mMode; // what kind of calculation to perform on the stencil: average, firstDerivative
29  TTSymbol mEdges; // what to do at the edges: none, clip, fold, or wrap
30  TTSymbol mStencilType; // currently only 5-point stencil...
31  std::vector<TTUInt32> mStepSize; // step size for each dimension
32 
33 
34  // Attribute Accessors
35  TTErr getStepSize(TTValue& returnedStepSize);
36  TTErr setStepSize(const TTValue& newStepSize);
37 
38 
39  // Matrix calculation methods pass arrays of inputs and outputs.
40 
41  /** Calculate matrix output using an average of the stencil. */
42  TTErr matrixCalculateAverage(TTMatrixArray& inputMatrices, TTMatrixArray& outputMatrices);
43 
44  /** Calculate matrix output using the first derivative of the stencil. */
45  TTErr matrixCalculateFirstDerivative(TTMatrixArray& inputMatrices, TTMatrixArray& outputMatrices);
46 
47 
48  template<typename T>
49  TTErr doCalculateAverage2D_zeroedEdges(TTMatrixBasePtr inMatrix, TTMatrixBasePtr outMatrix);
50 
51  template<typename T>
52  TTErr doCalculateAverage2D_clippedEdges(TTMatrixBasePtr inMatrix, TTMatrixBasePtr outMatrix);
53 
54  template<typename T>
55  TTErr doCalculateFirstDerivative(TTMatrixBasePtr inMatrix, TTMatrixBasePtr outMatrix);
56 
57  /** Unit Tests */
58  virtual TTErr test(TTValue& returnedTestInfo);
59 };
60 
61 
62 #endif // __TTMATRIXSTENCIL_H__
This class performs operations on a stencil from a matrix.
TTDataObjectBase is the base class for all data generating and processing objects.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
2-dimensional matrix of compound values with N elements each.
Definition: TTMatrixBase.h:41
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
An array of TTMatrix instance pointers.
Definition: TTMatrixArray.h:25
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34