Mercurial > hg > midi-score-follower
comparison hackday/DynamicBayesianArray.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 * DynamicBayesianArray.h | |
3 * midiCannamReader | |
4 * | |
5 * Created by Andrew on 17/07/2011. | |
6 * Copyright 2011 QMUL. All rights reserved. | |
7 * | |
8 */ | |
9 | |
10 /* | |
11 * DynamicBayesianArray.cpp | |
12 * bayesianTest5 | |
13 * | |
14 * Created by Andrew Robertson on 08/05/2010. | |
15 * Copyright 2010 __MyCompanyName__. All rights reserved. | |
16 * | |
17 */ | |
18 | |
19 /* | |
20 * DynamicBayesianArray.h | |
21 * bayesianTest5 | |
22 * | |
23 * Created by Andrew Robertson on 08/05/2010. | |
24 * Copyright 2010 __MyCompanyName__. All rights reserved. | |
25 * | |
26 */ | |
27 | |
28 #include "ofMain.h" | |
29 | |
30 #include "DynamicVector.h" | |
31 | |
32 #ifndef _DYNAMIC_BAYESIAN_ARRAY | |
33 #define _DYNAMIC_BAYESIAN_ARRAY | |
34 | |
35 #define ARRAY_SIZE 240 | |
36 | |
37 | |
38 class DynamicBayesianArray{ | |
39 | |
40 public: | |
41 | |
42 DynamicBayesianArray(); | |
43 void initialiseArray(); | |
44 | |
45 // void setGaussianLikelihoodForBeats(float mean, float StdDev); | |
46 void setGaussianLikelihood(float mean, float StdDev); | |
47 void setGaussianPrior(float mean, float StdDev); | |
48 void setGaussianPosterior(float mean, float StdDev); | |
49 | |
50 void calculatePosterior(); | |
51 void renormalisePosterior(); | |
52 void resetMaximumPosterior();//resets the max index | |
53 void decayPosteriorWithGaussianNoise(); | |
54 void translateDistribution(int translationIndex); | |
55 void setDecayNoiseGaussian(float mean, float StdDev); | |
56 double calculateStandardDeviation(); | |
57 | |
58 int arraySize; | |
59 | |
60 | |
61 float getMaximum(float *ptr, int length); | |
62 void renormaliseArray(float *ptr, int length); | |
63 void resetPrior(); | |
64 void decayPosterior(); | |
65 float* getMaximumEstimate(float *ptr, int length); | |
66 double getMaximumIndex();//return the index where the probability is maximal | |
67 double getIntegratedEstimateIndex(); | |
68 | |
69 // void drawArray(const int& minIndex, const int& maxIndex); | |
70 void drawFloatArray(float* arrayToDraw, const int& minIndex, const int& maxIndex); | |
71 void drawDoubleArray(double* arrayToDraw, const int& minIndex, const int& maxIndex); | |
72 | |
73 | |
74 typedef std::vector<double> DoubleVector; | |
75 // typedef std::vector<IntVector> DoubleMatrix; | |
76 | |
77 | |
78 // DynamicVector prior; | |
79 // DynamicVector posterior; | |
80 // DynamicVector likelihood; | |
81 | |
82 DynamicVector testVector; | |
83 // DynamicVector prior; | |
84 | |
85 float prior [ARRAY_SIZE]; | |
86 float posterior [ARRAY_SIZE]; | |
87 float likelihood [ARRAY_SIZE]; | |
88 float tempPosteriorArray[ARRAY_SIZE]; | |
89 | |
90 float decayNoiseArray[ARRAY_SIZE]; | |
91 float decayNoiseStdDev, decayNoiseAmount; | |
92 | |
93 float likelihoodMean, likelihoodStdDev, likelihoodNoise; | |
94 float maximumTest, posteriorDecayRate, maximumValue; | |
95 float eighthNoteProportion, earlySixteenthNoteProportion, lateSixteenthNoteProportion ; | |
96 float maximumEstimate, maximumIndex, integratedEstimate; | |
97 double standardDeviation; | |
98 | |
99 private: | |
100 }; | |
101 | |
102 #endif | |
103 | |
104 | |
105 |