diff src/MatchMarkers.cpp @ 50:93d21c20cfbc

Added Markers and the ability to switch to these points in the file when playing
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Thu, 14 Jun 2012 20:04:49 +0100
parents
children 6f6461b0d07f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/MatchMarkers.cpp	Thu Jun 14 20:04:49 2012 +0100
@@ -0,0 +1,57 @@
+/*
+ *  MatchMarkers.cpp
+ *  MultipleAudioMathcher
+ *
+ *  Created by Andrew on 14/06/2012.
+ *  Copyright 2012 QMUL. All rights reserved.
+ *
+ */
+
+#include "MatchMarkers.h"
+
+MatchMarkers::MatchMarkers(){
+
+}
+
+
+void MatchMarkers::addMarker(const double& markerTime){
+	int i = 0;
+	while (i < markers.size() && markers[i] < markerTime){
+		i++;
+	}
+	vector<double>::iterator it;
+	it = markers.begin();
+	markers.insert(it + i, markerTime);
+
+	printf("\n");
+	for (i = 0;i< markers.size();i++)
+		printf("marker[%i] %f\n", i, markers[i]);
+	
+}
+
+
+void MatchMarkers::deleteMarker(const int& markerIndex){
+	if (markerIndex >= 0 && markerIndex < markers.size()){
+		vector<double>::iterator it;
+		it = markers.begin();
+		markers.erase(it+markerIndex);
+	}
+}
+
+void MatchMarkers::saveMarkers(){
+	std::string filePath = "../../../data/markers.txt";
+	saveMarkers(filePath);
+	
+}
+
+void MatchMarkers::saveMarkers(const std::string& filePath){
+	if (!markerOutputFile.is_open()){
+	markerOutputFile.open(filePath.c_str());
+		for (int i = 0;i < markers.size();i++){
+			markerOutputFile << markers[i] << endl;
+		}
+	markerOutputFile.close();
+	}
+	
+}
+