Mercurial > hg > multitrack-audio-matcher
comparison 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 |
comparison
equal
deleted
inserted
replaced
49:8df911733fdc | 50:93d21c20cfbc |
---|---|
1 /* | |
2 * MatchMarkers.cpp | |
3 * MultipleAudioMathcher | |
4 * | |
5 * Created by Andrew on 14/06/2012. | |
6 * Copyright 2012 QMUL. All rights reserved. | |
7 * | |
8 */ | |
9 | |
10 #include "MatchMarkers.h" | |
11 | |
12 MatchMarkers::MatchMarkers(){ | |
13 | |
14 } | |
15 | |
16 | |
17 void MatchMarkers::addMarker(const double& markerTime){ | |
18 int i = 0; | |
19 while (i < markers.size() && markers[i] < markerTime){ | |
20 i++; | |
21 } | |
22 vector<double>::iterator it; | |
23 it = markers.begin(); | |
24 markers.insert(it + i, markerTime); | |
25 | |
26 printf("\n"); | |
27 for (i = 0;i< markers.size();i++) | |
28 printf("marker[%i] %f\n", i, markers[i]); | |
29 | |
30 } | |
31 | |
32 | |
33 void MatchMarkers::deleteMarker(const int& markerIndex){ | |
34 if (markerIndex >= 0 && markerIndex < markers.size()){ | |
35 vector<double>::iterator it; | |
36 it = markers.begin(); | |
37 markers.erase(it+markerIndex); | |
38 } | |
39 } | |
40 | |
41 void MatchMarkers::saveMarkers(){ | |
42 std::string filePath = "../../../data/markers.txt"; | |
43 saveMarkers(filePath); | |
44 | |
45 } | |
46 | |
47 void MatchMarkers::saveMarkers(const std::string& filePath){ | |
48 if (!markerOutputFile.is_open()){ | |
49 markerOutputFile.open(filePath.c_str()); | |
50 for (int i = 0;i < markers.size();i++){ | |
51 markerOutputFile << markers[i] << endl; | |
52 } | |
53 markerOutputFile.close(); | |
54 } | |
55 | |
56 } | |
57 |