Mercurial > hg > precise-onset-detection
view src/BeatWriter.cpp @ 2:7ec1ed0b2eb0
Added offline precise onset detection, outputting precise locations in seconds to text file
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Mon, 30 Dec 2013 14:08:42 +0000 |
parents | |
children | 184a7c232049 |
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"); } }