view src/LiveAudioInput.cpp @ 40:0d66ecd1f4d3

added output file writing to export alignment data
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 25 Apr 2012 00:24:20 +0100
parents 9806a4f22fd0
children
line wrap: on
line source
/*
 *  LiveAudioInput.cpp
 *  MultipleAudioMathcher
 *
 *  Created by Andrew on 30/01/2012.
 *  Copyright 2012 QMUL. All rights reserved.
 *
 */

#include "LiveAudioInput.h"

//Keeping track of incoming events
//more useful as data than anything else. But in fact, not particularly useful it seems at present


const double hopsize = 512;//check to see it agrees with ofxAubioOnsetDetector

LiveAudioInput::LiveAudioInput(){
	numberOfEvents = 0;
	
}

void LiveAudioInput::addPitchEvent(const double& pitch, const double& time){

	AudioEvent e;
	e.millisTime = time;
	e.frameTime = millisToFrames(time);
	e.pitch = pitch;
	liveEvents.push_back(e);
	//printf("live input pitch %f time %f ms == %f frames\n", pitch, time, e.frameTime);
	numberOfEvents++;
	
}


double LiveAudioInput::framesToMillis(const double& frameCount){
	return ((frameCount*hopsize*1000.0)/44100.0);
}


double LiveAudioInput::millisToFrames(const double& millis){
	return ((millis*44100.0)/(hopsize*1000.0));
}



/*
 //any point in this??
 void LiveAudioInput::addChromaEvent(const double& time){
 
 AudioEvent e;
 e.millisTime = time;
 e.frameTime = millisToFrames(time);
 
 liveEvents.push_back(e);
 //printf("live input pitch %f time %f ms == %f frames\n", pitch, time, e.frameTime);
 numberOfEvents++;
 
 }
 */