-
Notifications
You must be signed in to change notification settings - Fork 8
/
musedata2hum.cpp
52 lines (44 loc) · 1.18 KB
/
musedata2hum.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
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Wed Sep 25 19:35:54 PDT 2019
// Last Modified: Mon Feb 21 18:31:59 PST 2022
// Filename: cli/musedata2hum.cpp
// URL: https://github.com/craigsapp/musedata2hum/blob/master/src/musedata2hum.cpp
// Syntax: C++11
// vim: ts=3 noexpandtab
//
// Description: Command-line interface for converting MusicXML files into
// Humdrum files.
//
#include "humlib.h"
#include <iostream>
using namespace std;
using namespace hum;
int main(int argc, char** argv) {
hum::Tool_musedata2hum converter;
if (!converter.process(argc, argv)) {
converter.getError(cerr);
return -1;
}
MuseDataSet infile;
string filename;
if (converter.getArgCount() == 0) {
filename = "<STDIN>";
infile.read(cin);
} else {
filename = converter.getArg(1);
infile.readFile(filename);
}
int partcount = infile.getFileCount();
if (partcount == 0) {
cerr << "Error: no parts found in file" << endl;
return 1;
}
stringstream out;
bool status = converter.convert(out, infile);
if (!status) {
cerr << "Error converting file: " << filename << endl;
}
cout << out.str();
return 0;
}