xref: /haiku/src/tests/kits/midi/test1.cpp (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
1 #include <MidiStore.h>
2 #include <MidiText.h>
3 #include <Entry.h>
4 #include <iostream.h>
5 
6 int main(int argc, char * argv[]) {
7 	if(argc < 2) {
8 		cerr << "Must supply a filename (*.mid)!" << endl;
9 		return 1;
10 	}
11 	BMidiText * text = new BMidiText();
12 	BMidiStore * store = new BMidiStore();
13 	BEntry entry(argv[1],true);
14 	if(!entry.Exists()) {
15 		cerr << "File does not exist." << endl;
16 		return 2;
17 	}
18 	entry_ref e_ref;
19 	entry.GetRef(&e_ref);
20 	store->Import(&e_ref);
21 	store->Connect(text);
22 	uint32 start_time = B_NOW;
23 	store->Start();
24 	while(store->IsRunning()) {
25 		snooze(100000);
26 	}
27 	store->Stop();
28 	uint32 stop_time = B_NOW;
29 	cout << "Start Time: " << dec << start_time << "ms" << endl;
30 	cout << "Stop Time: " << dec << stop_time << "ms" << endl;
31 	cout << "Total time: " << dec << stop_time - start_time << "ms" << endl;
32 
33 	store->Disconnect(text);
34 	delete store;
35 	delete text;
36 	return 0;
37 }
38