view src/AudioEventMatcher.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 4ded82fe318d
children 4f6006cac9de
line wrap: on
line source
/*
 *  AudioEventMatcher.h
 *  MultipleAudioMathcher
 *
 *  Created by Andrew on 31/01/2012.
 *  Copyright 2012 QMUL. All rights reserved.
 *
 */



#ifndef AUDIO_EVENT_MATCHER_H
#define AUDIO_EVENT_MATCHER_H

#define NUMBER_OF_CHANNELS 3

#include "ofMain.h"
#include "ChromaOnset.h"
#include "LiveAudioInput.h"
#include "ofxWindowRegion.h"
#include "BayesianArrayStructure.h"
#include "RecordedMultitrackAudio.h"
#include "DynamicVector.h"
#include "AccompanimentSynchroniser.h"
#include "TempoFollower.h"

class AudioEventMatcher{
	
	public:
	AudioEventMatcher();
	
	void setArraySizes();
	
	void updatePosition();
	void updateBestAlignmentPosition();
	
	void draw();
	void drawBayesianDistributions();;
	void setWindowDimensions();
	
	void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
	void newKickEvent(const double& timeIn);
	void newKickEvent(const int& channel, const double& timeIn);
	void newSnareEvent(const double& timeIn);
	void newSnareEvent(const int& channel, const double& timeIn);
	
	void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
	void matchNewOnsetEvent(const int& channel, const double& timeIn);
	
	BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
	
	LiveAudioInput liveInput;//hold the new events that come in
	RecordedMultitrackAudio recordedTracks;
	
	void loadAudioFiles();
	
	void windowResized(const int& w, const int& h);
	
	ofxWindowRegion bayesTempoWindow;
	ofxWindowRegion bayesPositionWindow;
	ofxWindowRegion bayesLikelihoodWindow;

	bool checkMatch(const double& recordedPitch, const double& livePitch);
	double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
	
	void startPlaying();
	void stopPlaying();
	bool startedPlaying;
	
	bool usingRealTime;
	double recentPitch, recentTime;
	
	DynamicVector likelihoodVisualisation[NUMBER_OF_CHANNELS];
	DynamicVector recentPriors[NUMBER_OF_CHANNELS];
	//DynamicVector recentPrior;
	DynamicVector projectedPrior;
	
	double currentAlignmentPosition;
	double lastAlignmentTime;
	
	double recentEventTime[NUMBER_OF_CHANNELS];
	int startTime;
	int currentAlignmentTime;
	
	double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
	bool followingLiveInput;
	void setScreenDisplayTimes();
	
	AccompanimentSynchroniser synchroniser;
	
	//params
	double onsetLikelihoodWidth;
	double onsetLikelihoodToNoise;
	double pitchLikelihoodToNoise;//more noise
	
	double pitchOfNearestMatch;//for viz purposes
	double distanceOfNearestMatch;
	

	
	TempoFollower temporal;
};
#endif