andrew@2: /* andrew@2: * BeatWriter.cpp andrew@2: * BTrack andrew@2: * andrew@2: * Created by Andrew on 31/10/2013. andrew@2: * Copyright 2013 QMUL. All rights reserved. andrew@2: * andrew@2: */ andrew@2: andrew@2: #include "BeatWriter.h" andrew@2: andrew@2: /* andrew@2: * BeatWriter.cpp andrew@2: * MultipleAudioMathcher andrew@2: * andrew@2: * Created by Andrew on 25/04/2012. andrew@2: * Copyright 2012 QMUL. All rights reserved. andrew@2: * andrew@2: */ andrew@2: andrew@2: #include "BeatWriter.h" andrew@2: andrew@2: BeatWriter::BeatWriter(){ andrew@2: filepath = "output.txt"; andrew@2: //openFile(); andrew@2: } andrew@2: andrew@2: BeatWriter::~BeatWriter(){ andrew@2: closeFile(); andrew@2: } andrew@2: andrew@2: void BeatWriter::writeBeatTime(const double& beatTime){ andrew@2: andrew@2: if (outputFile.is_open()){ andrew@2: outputFile << beatTime << endl; andrew@2: } else{ andrew@2: printf("trying to write value but file closed\n"); andrew@2: } andrew@2: } andrew@2: andrew@2: void BeatWriter::openFile(std::string pathname){ andrew@2: // closeFile(); andrew@2: filepath = pathname; andrew@2: printf("Writer: opening file '%s'\n", pathname.c_str()); andrew@2: //filepath = "/Users/andrew/Ride_SM58#08.aif.txt"; andrew@2: openFile(); andrew@2: } andrew@2: andrew@2: void BeatWriter::openFile(){ andrew@2: if (!outputFile.is_open()){ andrew@2: outputFile.open(filepath.c_str()); Venetian@8: printf("opening file %s\n", filepath.c_str()); andrew@2: }else{ andrew@2: printf("file already open! %s\n", filepath.c_str()); andrew@2: } andrew@2: } andrew@2: andrew@2: void BeatWriter::closeFile(){ andrew@2: if (outputFile.is_open()){ andrew@2: outputFile.close(); andrew@2: printf("closing file '%s'\n", filepath.c_str()); andrew@2: }else { andrew@2: printf("Writer: file is not open to be closed\n"); andrew@2: } andrew@2: }