andrew@0
|
1 /*
|
andrew@0
|
2 * DynamicVector.h
|
andrew@0
|
3 * midiCannamReader
|
andrew@0
|
4 *
|
andrew@0
|
5 * Created by Andrew on 18/07/2011.
|
andrew@0
|
6 * Copyright 2011 QMUL. All rights reserved.
|
andrew@0
|
7 *
|
andrew@0
|
8 */
|
andrew@0
|
9
|
andrew@0
|
10 //OPTIMIZE CONSTRAINED VECTOR
|
andrew@0
|
11
|
andrew@0
|
12 #include "stdlib.h"
|
andrew@0
|
13 #include "ofMain.h"
|
andrew@0
|
14 #include "ofxWindowRegion.h"
|
andrew@0
|
15
|
andrew@0
|
16 #ifndef _DYNAMIC_VECTOR
|
andrew@0
|
17 #define _DYNAMIC_VECTOR
|
andrew@0
|
18 #define GAUSSIAN_LOOKUP_LENGTH 1000000
|
andrew@0
|
19
|
andrew@0
|
20 class DynamicVector{
|
andrew@0
|
21 public:
|
andrew@0
|
22 DynamicVector();
|
andrew@0
|
23
|
andrew@0
|
24 void createVector(int len);
|
andrew@0
|
25 void renormalise();
|
andrew@0
|
26 void translateDistribution(int translationIndex);
|
andrew@0
|
27 typedef std::vector<double> DoubleVector;
|
andrew@0
|
28 DoubleVector array;
|
andrew@0
|
29 double getMaximum();
|
andrew@4
|
30 int getMAPestimate();
|
andrew@0
|
31 double getIntegratedEstimate();
|
andrew@0
|
32 double getLookupIndex(const int& i, const double& mean, const double& StdDev);
|
andrew@0
|
33 void addGaussianShapeByLookupTable(double& mean, double& StdDev, double factor);
|
andrew@0
|
34 double gaussianLookupTable[GAUSSIAN_LOOKUP_LENGTH];
|
andrew@0
|
35 double gaussianLookupMean, gaussianLookupStdDev;
|
andrew@0
|
36 double integratedEstimate;
|
andrew@0
|
37 void updateIntegratedEstimate();
|
andrew@0
|
38 void updateLimitedIntegratedEstimate();
|
andrew@0
|
39
|
andrew@0
|
40 void drawVector(const int& minIndex, const int& maxIndex);
|
andrew@0
|
41 void drawVector(const int& minIndex, const int& maxIndex, ofxWindowRegion window);
|
andrew@0
|
42
|
andrew@0
|
43 void drawConstrainedVector(const int& minIndex, const int& maxIndex, const int& minScreenIndex, const int& maxScreenIndex);
|
andrew@6
|
44 void drawConstrainedVector(const int& minIndex, const int& maxIndex, const int& minScreenIndex, const int& maxScreenIndex, const ofxWindowRegion& window);
|
andrew@0
|
45
|
andrew@0
|
46 void addConstant(const double& value);
|
andrew@0
|
47 void addGaussianShape(const double& mean, const double& stddev, double factor);
|
andrew@2
|
48
|
andrew@2
|
49 void addGaussianShapeFromRealTime(const double& actualTime, const double& StdDev, double factor);
|
andrew@2
|
50
|
andrew@2
|
51
|
andrew@15
|
52
|
andrew@0
|
53 void addTriangularShape(double mean, double width, double factor);
|
andrew@0
|
54 void addToIndex(const int& index, const double& constant);
|
andrew@0
|
55
|
andrew@0
|
56 void doProduct(DynamicVector& arrayOne, DynamicVector& arrayTwo);
|
andrew@0
|
57
|
andrew@0
|
58 double getIndexInRealTerms(const int& index);
|
andrew@0
|
59 double getRealTermsAsIndex(double value);
|
andrew@0
|
60 double getValueAtMillis(const double& millis);
|
andrew@15
|
61 double millisToVectorUnits(const double& millis);
|
andrew@0
|
62
|
andrew@0
|
63 void printArray();
|
andrew@0
|
64 void zero();
|
andrew@0
|
65
|
andrew@0
|
66 void copyFromDynamicVector(const DynamicVector& dynamicVec);
|
andrew@0
|
67
|
andrew@0
|
68 //variables
|
andrew@0
|
69 int length, arraySize;
|
andrew@0
|
70 double maximumValue;
|
andrew@0
|
71 int MAPestimate;
|
andrew@0
|
72
|
andrew@0
|
73 double offset;
|
andrew@0
|
74 double scalar;//each array point is this much of the quantity
|
andrew@0
|
75 //i.e. array[index] contributes to (offset + scalar*index) in real terms
|
andrew@0
|
76
|
andrew@0
|
77 };
|
andrew@0
|
78
|
andrew@0
|
79 #endif
|