view src/BeatWriter.cpp @ 8:184a7c232049 tip

changed files since updating computer
author Venetian
date Thu, 14 Aug 2014 17:53:57 +0100
parents 7ec1ed0b2eb0
children
line wrap: on
line source
/*
 *  BeatWriter.cpp
 *  BTrack
 *
 *  Created by Andrew on 31/10/2013.
 *  Copyright 2013 QMUL. All rights reserved.
 *
 */

#include "BeatWriter.h"

/*
 *  BeatWriter.cpp
 *  MultipleAudioMathcher
 *
 *  Created by Andrew on 25/04/2012.
 *  Copyright 2012 QMUL. All rights reserved.
 *
 */

#include "BeatWriter.h"

BeatWriter::BeatWriter(){
	filepath = "output.txt";
	//openFile();
}

BeatWriter::~BeatWriter(){
	closeFile();
}

void BeatWriter::writeBeatTime(const double& beatTime){
	
	if (outputFile.is_open()){
		outputFile << beatTime << endl;
	} else{
		printf("trying to write value but file closed\n");
	}
}

void BeatWriter::openFile(std::string pathname){
	//	closeFile();
	filepath = pathname;
	printf("Writer: opening file '%s'\n", pathname.c_str());
	//filepath = "/Users/andrew/Ride_SM58#08.aif.txt";
	openFile();
}

void BeatWriter::openFile(){
	if (!outputFile.is_open()){
		outputFile.open(filepath.c_str());
		printf("opening file %s\n", filepath.c_str());
	}else{
		printf("file already open! %s\n", filepath.c_str());
	}
}

void BeatWriter::closeFile(){
	if (outputFile.is_open()){
		outputFile.close();
		printf("closing file '%s'\n", filepath.c_str());
	}else {
		printf("Writer: file is not open to be closed\n");
	}
}