-
Notifications
You must be signed in to change notification settings - Fork 8
/
musetime.cpp
77 lines (62 loc) · 1.82 KB
/
musetime.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Wed May 29 18:46:42 PDT 2024
// Last Modified: Wed May 29 18:46:46 PDT 2024
// Filename: cli/musetime.cpp
// URL: https://github.com/craigsapp/musetime/blob/master/src/musetime.cpp
// Syntax: C++11
// vim: ts=3 noexpandtab
//
// Description: Command-line interface for converting MusicXML files into
// Humdrum files.
//
#include "MuseDataSet.h"
#include "MuseData.h"
#include "Options.h"
#include <iostream>
using namespace std;
using namespace hum;
void processData(MuseDataSet& mds);
void processData(MuseData& md);
Options options;
bool floatQ = false;
int main(int argc, char** argv) {
options.define("f|float=b", "Display quarter-note time as floating-point numbers");
options.process(argc, argv);
floatQ = options.getBoolean("float");
MuseDataSet mds;
int output = 1;
if (options.getArgCount() == 0) {
mds.readString(cin);
} else {
for (int i=0; i<options.getArgCount(); i++) {
MuseData* md;
md = new MuseData;
output &= md->readFile(options.getArg(i+1));
mds.appendPart(md);
}
}
processData(mds);
return !output;
}
//////////////////////////////
//
// processData -- List QStamp for each line.
//
void processData(MuseDataSet& mds) {
for (int i=0; i<mds.getFileCount(); i++) {
cout << "###########################################################" << endl;
processData(mds[i]);
}
cout << "###########################################################" << endl;
}
// Print MuseData part contents with a quarter-note timestamp before each line.
void processData(MuseData& md) {
for (int i=0; i<md.getLineCount(); i++) {
if (floatQ) {
cout << md[i].getQStamp().getFloat() << "\t" << md[i] << endl;
} else {
cout << md[i].getQStamp() << "\t" << md[i] << endl;
}
}
}