annotate bayesianArraySrc/BayesianArrayStructure.h @ 56:4394c9490716 tip

minor changes
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 24 Dec 2012 18:58:39 +0000
parents 5274e3b5479d
children
rev   line source
andrew@0 1 /*
andrew@0 2 * BayesianArrayStructure.h
andrew@0 3 * midiCannamReader
andrew@0 4 *
andrew@0 5 * Created by Andrew on 17/07/2011.
andrew@0 6 * Copyright 2011 QMUL. All rights reserved.
andrew@0 7 *
andrew@0 8 */
andrew@0 9 #ifndef BAYESIAN_ARRAY_STRUCTURE
andrew@0 10 #define BAYESIAN_ARRAY_STRUCTURE
andrew@0 11
andrew@0 12
andrew@0 13 #include "ofMain.h"
andrew@0 14 //#include "DynamicBayesianArray.h"
andrew@0 15 #include "DynamicVector.h"
andrew@0 16
andrew@0 17 class BayesianArrayStructure {
andrew@0 18
andrew@0 19 public:
andrew@0 20 // BayesianArrayStructure();
andrew@0 21 BayesianArrayStructure();
andrew@0 22 BayesianArrayStructure(int length);
andrew@0 23
andrew@0 24 void calculatePosterior();
andrew@0 25 void drawArrays();
andrew@0 26 void drawArraysRelativeToTimeframe(const double& startTimeMillis, const double& endTimeMillis);
andrew@0 27
andrew@0 28 void drawTempoArrays();
andrew@0 29
andrew@0 30 void resetSize(int length);
andrew@0 31 void resetArrays();
andrew@0 32 void simpleExample();
andrew@0 33 void setStartPlaying();
andrew@0 34 void zeroArrays();
andrew@0 35
andrew@0 36 double screenWidth;
andrew@0 37
andrew@0 38 void copyPriorToPosterior();
andrew@0 39 // DynamicBayesianArray bayesArray;
andrew@0 40
andrew@0 41 double lastEventTime;
andrew@0 42 double likelihoodNoise;
andrew@0 43 double speedLikelihoodNoise;
andrew@0 44
andrew@0 45 //DynamicVector tmpPrior;
andrew@0 46 DynamicVector tmpPosteriorForStorage;
andrew@0 47 DynamicVector prior;
andrew@0 48 DynamicVector posterior;
andrew@0 49 DynamicVector likelihood;
andrew@0 50
andrew@0 51 DynamicVector relativeSpeedPrior;
andrew@0 52 DynamicVector relativeSpeedLikelihood;
andrew@0 53 DynamicVector relativeSpeedPosterior;
andrew@0 54 DynamicVector acceleration;
andrew@0 55
andrew@0 56 double tmpBestEstimate;
andrew@4 57
andrew@4 58 // void updateTmpBestEstimate(const double& timeDifference);
andrew@0 59
andrew@0 60 int updateCounter;
andrew@0 61
andrew@0 62 void setPositionDistributionScalar(double f);
andrew@0 63
andrew@0 64 void resetSpeedToOne();
andrew@0 65 void addGaussianNoiseToSpeedPosterior(const double& std_dev);
andrew@0 66 void addTriangularNoiseToSpeedPosterior(const double& std_dev);
andrew@0 67
andrew@0 68 double bestEstimate;
andrew@0 69 void updateBestEstimate(const double& timeDifference);
andrew@0 70 double lastBestEstimateUpdateTime;
andrew@0 71 double speedEstimate, speedEstimateIndex;
andrew@4 72 double getSpeedEstimateIndex();
andrew@0 73
andrew@0 74 double speedDecayWidth, speedDecayAmount;
andrew@0 75 void decaySpeedDistribution(double timeDifference);
andrew@0 76
andrew@0 77 void resetSpeedSize(int length);
andrew@0 78 void setRelativeSpeedScalar(double f);
andrew@0 79 void setSpeedPrior(double f);
andrew@0 80 void calculateNewPriorOffset(const double& timeDifference);
andrew@0 81 void setNewDistributionOffsets(const double& newOffset);
andrew@0 82
andrew@0 83 void setLikelihoodToConstant();
andrew@0 84 void updateTempoLikelihood(const double& speedRatio, const double& matchFactor);
andrew@0 85 void updateTempoDistribution();
andrew@0 86
andrew@0 87 void calculateTempoUpdate();
andrew@0 88
andrew@6 89 void updateBayesianDistributions(const double& newEventTime);
andrew@0 90 void crossUpdateArrays(DynamicVector& position, DynamicVector& speed, double timeDifference);
andrew@0 91 void complexCrossUpdate(const double& timeDifferenceInPositionVectorUnits);
andrew@0 92 void translateByMaximumSpeed(const double& timeDifferenceInPositionVectorUnits);
andrew@0 93 double crossUpdateTimeThreshold;//time after which we do complex update of multiple speeds
andrew@0 94
andrew@0 95 double speedPriorValue;
andrew@0 96 int priorWidth;
andrew@0 97 bool* realTimeMode;
andrew@0 98 bool usingIntegratedTempoEstimate;
andrew@0 99 double relativeSpeedLikelihoodStdDev;
andrew@6 100
andrew@11 101 void projectDistribution(const double& newEventTime, const double& newAlignmentPosition, DynamicVector& projectedPrior);
andrew@11 102 void complexCrossUpdateProjection(DynamicVector& projectedPrior, const double& timeDifferenceInPositionVectorUnits);
andrew@11 103 void translatePosteriorByMaximumSpeed(DynamicVector& translatedPosterior, const double& timeDifferenceInPositionVectorUnits);
andrew@11 104
andrew@6 105 void printPostOffset();
andrew@42 106 int startingWindowWidth, matchWindowWidth;
andrew@7 107 bool updatingSpeedDistribution;//false for testing
andrew@0 108
andrew@53 109 void zeroDistributionAtPosition(DynamicVector& distribution, const double& position);
andrew@0 110 };
andrew@0 111 #endif