view src/TempoFollower.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 93d21c20cfbc
children
line wrap: on
line source
/*
 *  TempoFollower.h
 *  MultipleAudioMathcher
 *
 *  Created by Andrew on 09/02/2012.
 *  Copyright 2012 QMUL. All rights reserved.
 *
 */

#ifndef TEMPO_FOLLOWER_H
#define TEMPO_FOLLOWER_H

#define NUMBER_OF_CHANNELS 4

#include "ofMain.h"
#include "DynamicVector.h"
#include "ofxWindowRegion.h"
#include "ofxAubioOnsetDetection.h"

typedef std::vector<double> DoubleVector;
typedef std::vector<DoubleVector> DoubleMatrix;
typedef std::vector<DoubleMatrix> DoubleCube;


typedef std::vector<int> IntVector;
typedef std::vector<IntVector> IntMatrix;
typedef std::vector<IntMatrix> IntCube;

/*
 struct RecordedTempoData {
	DoubleCube recordedIntervals;
	IntCube recordedDivisions;
	IntMatrix recordedTimes;
	DoubleMatrix recordedTempo;
};
*/

class TempoFollower{
	
public:
	TempoFollower();

	DynamicVector tempoPrior;
	DynamicVector tempoPosterior;
	DynamicVector tempoLikelihood;
	int tempoArraySize;
	int minimumTempoInterval, maximumTempoInterval;
	
	double playingTempo;
	void zero();
	void reset();
	
	//TEMPO STUFF
	

	DoubleCube tempoIntervals;//channel, event index, vector of interval times

	IntCube divisions;
	
	IntMatrix eventTimes;
	DoubleMatrix tempo;
	
	DoubleVector globalTempo;
	IntVector globalTempoTimes;
	
	
	void setUpEventTimeMatrix();
	void printEventTimes();
	
	void updateTempo(const int& channel, const int& timeIn);
	bool testTempoInterval(const int& channel, const double& testTempoInterval, DoubleVector& d);
	void updateTempoDistribution(const DoubleVector& d);
	void calculatePosterior();
	void drawTempoArray(ofxWindowRegion& window);
	
	double intervalsToTest[4];
	
	double tempoLikelihoodStdDev;
	
	void printTempoTimes();//prints global tempo - the playing tempo sequence
	bool printOutput;
	
};
#endif