comparison hackday/BayesianArrayStructure.h @ 28:49a5b023df1e

Hackday files comitted - version as demo'd at London hackday
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 05 Dec 2011 07:00:47 +0000
parents
children
comparison
equal deleted inserted replaced
27:fa1890efa044 28:49a5b023df1e
1 /*
2 * BayesianArrayStructure.h
3 * midiCannamReader
4 *
5 * Created by Andrew on 17/07/2011.
6 * Copyright 2011 QMUL. All rights reserved.
7 *
8 */
9 #ifndef BAYESIAN_ARRAY_STRUCTURE
10 #define BAYESIAN_ARRAY_STRUCTURE
11
12
13 #include "ofMain.h"
14 //#include "DynamicBayesianArray.h"
15 #include "DynamicVector.h"
16
17 class BayesianArrayStructure {
18
19 public:
20 // BayesianArrayStructure();
21 BayesianArrayStructure();
22 BayesianArrayStructure(int length);
23
24 void calculatePosterior();
25 void drawArrays();
26 void drawArraysRelativeToTimeframe(const double& startTimeMillis, const double& endTimeMillis);
27
28 void drawTempoArrays();
29
30 void resetSize(int length);
31 void resetArrays();
32 void simpleExample();
33 void setStartPlaying();
34 void zeroArrays();
35
36 double screenWidth;
37
38 void copyPriorToPosterior();
39 // DynamicBayesianArray bayesArray;
40
41 double lastEventTime;
42 double likelihoodNoise;
43 double speedLikelihoodNoise;
44
45 //DynamicVector tmpPrior;
46 DynamicVector tmpPosteriorForStorage;
47 DynamicVector prior;
48 DynamicVector posterior;
49 DynamicVector likelihood;
50
51 DynamicVector relativeSpeedPrior;
52 DynamicVector relativeSpeedLikelihood;
53 DynamicVector relativeSpeedPosterior;
54 DynamicVector acceleration;
55
56 double tmpBestEstimate;
57 void updateTmpBestEstimate(const double& timeDifference);
58
59 int updateCounter;
60
61 void setPositionDistributionScalar(double f);
62
63 void resetSpeedToOne();
64 void addGaussianNoiseToSpeedPosterior(const double& std_dev);
65 void addTriangularNoiseToSpeedPosterior(const double& std_dev);
66
67 double bestEstimate;
68 void updateBestEstimate(const double& timeDifference);
69 double lastBestEstimateUpdateTime;
70 double speedEstimate;
71
72 double speedDecayWidth, speedDecayAmount;
73 void decaySpeedDistribution(double timeDifference);
74
75 void resetSpeedSize(int length);
76 void setRelativeSpeedScalar(double f);
77 void setSpeedPrior(double f);
78 void calculateNewPriorOffset(const double& timeDifference);
79 void setNewDistributionOffsets(const double& newOffset);
80
81 void setLikelihoodToConstant();
82 void updateTempoLikelihood(const double& speedRatio, const double& matchFactor);
83 void updateTempoDistribution();
84
85 void calculateTempoUpdate();
86
87 void crossUpdateArrays(DynamicVector& position, DynamicVector& speed, double timeDifference);
88 void complexCrossUpdate(const double& timeDifferenceInPositionVectorUnits);
89 void translateByMaximumSpeed(const double& timeDifferenceInPositionVectorUnits);
90 double crossUpdateTimeThreshold;//time after which we do complex update of multiple speeds
91
92 double speedPriorValue;
93 int priorWidth;
94 bool* realTimeMode;
95 bool usingIntegratedTempoEstimate;
96 double relativeSpeedLikelihoodStdDev;
97
98 };
99 #endif