view src/TempoFollower.h @ 19:1a62561bd72d

Added in tempo follower class that models the tempo of played events
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Thu, 09 Feb 2012 18:09:34 +0000
parents
children 4f6006cac9de
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 3

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

class TempoFollower{
	
public:
	TempoFollower();

	DynamicVector tempoPrior;
	DynamicVector tempoPosterior;
	DynamicVector tempoLikelihood;
	int tempoArraySize;
	int minimumTempoInterval, maximumTempoInterval;
	
	double playingTempo;
	
	void reset();
	
	//TEMPO STUFF
	
	typedef std::vector<double> DoubleVector;
	typedef std::vector<DoubleVector> DoubleMatrix;
	typedef std::vector<DoubleMatrix> DoubleCube;
	DoubleCube tempoIntervals;//channel, event index, vector of interval times
	
	
	typedef std::vector<int> IntVector;
	typedef std::vector<IntVector> IntMatrix;
	IntMatrix eventTimes;
	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);
	
};
#endif