annotate 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
rev   line source
andrew@2 1 /*
andrew@2 2 * BeatWriter.cpp
andrew@2 3 * BTrack
andrew@2 4 *
andrew@2 5 * Created by Andrew on 31/10/2013.
andrew@2 6 * Copyright 2013 QMUL. All rights reserved.
andrew@2 7 *
andrew@2 8 */
andrew@2 9
andrew@2 10 #include "BeatWriter.h"
andrew@2 11
andrew@2 12 /*
andrew@2 13 * BeatWriter.cpp
andrew@2 14 * MultipleAudioMathcher
andrew@2 15 *
andrew@2 16 * Created by Andrew on 25/04/2012.
andrew@2 17 * Copyright 2012 QMUL. All rights reserved.
andrew@2 18 *
andrew@2 19 */
andrew@2 20
andrew@2 21 #include "BeatWriter.h"
andrew@2 22
andrew@2 23 BeatWriter::BeatWriter(){
andrew@2 24 filepath = "output.txt";
andrew@2 25 //openFile();
andrew@2 26 }
andrew@2 27
andrew@2 28 BeatWriter::~BeatWriter(){
andrew@2 29 closeFile();
andrew@2 30 }
andrew@2 31
andrew@2 32 void BeatWriter::writeBeatTime(const double& beatTime){
andrew@2 33
andrew@2 34 if (outputFile.is_open()){
andrew@2 35 outputFile << beatTime << endl;
andrew@2 36 } else{
andrew@2 37 printf("trying to write value but file closed\n");
andrew@2 38 }
andrew@2 39 }
andrew@2 40
andrew@2 41 void BeatWriter::openFile(std::string pathname){
andrew@2 42 // closeFile();
andrew@2 43 filepath = pathname;
andrew@2 44 printf("Writer: opening file '%s'\n", pathname.c_str());
andrew@2 45 //filepath = "/Users/andrew/Ride_SM58#08.aif.txt";
andrew@2 46 openFile();
andrew@2 47 }
andrew@2 48
andrew@2 49 void BeatWriter::openFile(){
andrew@2 50 if (!outputFile.is_open()){
andrew@2 51 outputFile.open(filepath.c_str());
Venetian@8 52 printf("opening file %s\n", filepath.c_str());
andrew@2 53 }else{
andrew@2 54 printf("file already open! %s\n", filepath.c_str());
andrew@2 55 }
andrew@2 56 }
andrew@2 57
andrew@2 58 void BeatWriter::closeFile(){
andrew@2 59 if (outputFile.is_open()){
andrew@2 60 outputFile.close();
andrew@2 61 printf("closing file '%s'\n", filepath.c_str());
andrew@2 62 }else {
andrew@2 63 printf("Writer: file is not open to be closed\n");
andrew@2 64 }
andrew@2 65 }