This repository has been archived by the owner on Feb 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkMidi.cpp
68 lines (64 loc) · 1.64 KB
/
NetworkMidi.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
#include <iostream>
#include <cstdlib>
#include <vector>
#include <unistd.h>
#include "rtmidi-3.0.0/RtMidi.h"
#include "MidiProbe.h"
int main(){
MidiProbe probe;
bool keepAlive = true;
int status = probe.probePorts();
std::string setting = "help";
if(status != 0){
std::cout << "An error occured during port probing!\nProgram must now exit\n";
return 0;
}
while(keepAlive) {
if(setting == "output"){
std::cout << "Select Port #: ";
std::cin >> status;
std::cin.get(); //clear state for reading input
status = probe.bindOutput(status);
if(status == -1){
std::cout << "an error occured in binding port!\nProgram must now exit\n";
return 0;
}
for(int i=0; i < 16; i++){
probe.sendTestOutput();
usleep(90000);
}
}
else if(setting == "input"){
std::cout << "Select Port #: ";
std::cin >> status;
std::cin.get(); //clear state for reading input
status = probe.bindInput(status);
if(status == -1){
std::cout << "an error occured in binding port!\nProgram must now exit\n";
return 0;
}
probe.readInputs();
}
else if(setting == "help") {
std::cout << "commands: input, output, probe, help, quit\n";
}
else if(setting == "probe") {
int status = probe.probePorts();
if(status != 0){
std::cout << "an error occured during port probing!\nProgram must now exit\n";
return 0;
}
}
else if(setting == "quit"){
keepAlive = false;
break;
}
else{
std::cout << "unknown command!\n";
} std::cout << "cmd: ";
std::cin >> setting;
std::cin.get();//clear input for possible midi input
}
std::cout << "program has finished"<<std::endl;
return 0;
}