-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
56 lines (54 loc) · 1.37 KB
/
main.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
#include <RtMidi.h>
#include <vector>
#include <iostream>
#include <string>
#include <unistd.h>
#include <memory>
using namespace std;
int main()
{
std::vector<std::unique_ptr<RtMidiIn>> inputs;
vector<unsigned char> message;
try
{
{
RtMidiIn probe;
unsigned int nPorts = probe.getPortCount();
for (unsigned int i = 0; i < nPorts; i++)
{
string portName = probe.getPortName(i);
cout << "port\t" << i << "\t" << portName << endl;
auto input = make_unique<RtMidiIn>();
input->openPort(i);
inputs.push_back(move(input));
}
}
for (;;)
{
bool found = false;
for (auto &input : inputs)
{
input->getMessage(&message);
if (message.size() > 0)
{
cout << "message";
for (auto b : message)
{
cout << "\t" << (int)b;
}
cout << endl;
found = true;
}
}
if (!found)
{
usleep(33333);
}
}
}
catch (RtMidiError &error)
{
cout << "RtMidiError\t" << error.getMessage() << endl;
}
return 0;
}