forked from SirDifferential/instrument_controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputReader.cpp
More file actions
56 lines (47 loc) · 1.29 KB
/
inputReader.cpp
File metadata and controls
56 lines (47 loc) · 1.29 KB
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
#include "inputReader.hpp"
#include "manager.hpp"
#include "inputmanager.hpp"
#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>
#include <string>
int InputReader::init()
{
fprintf(stderr, "Initting SFD\n");
device_name = "/dev/snd/midiC1D0";
sequencer_file_descriptor = open(device_name.c_str(), O_RDONLY);
if (sequencer_file_descriptor == -1)
{
fprintf(stderr, "!!!! Error opening sequencer file descriptor !!!!\n");
return 11;
}
fcntl(sequencer_file_descriptor, F_SETFL, O_NONBLOCK);
fprintf(stderr, "\n****************************************\n");
fprintf(stderr, "* InputReader started successfully!!!! *\n");
fprintf(stderr, "****************************************\n\n");
return 0;
}
int InputReader::readInput()
{
status = read(sequencer_file_descriptor, &input_bytes, sizeof(input_bytes));
if (status < 0)
{
//fprintf(stderr, "Error reading input\n");
//fprintf(stderr, device_name.c_str());
return -12;
}
if (input_bytes[0] && (input_bytes[0] == 144 ))
{
// fprintf(stderr, "MIDI Event: %d %d %d %d\n", input_bytes[0], input_bytes[1], input_bytes[2], input_bytes[4]);
manager.getInputMgr()->handleSynthEvents(input_bytes);
}
return 0;
}
InputReader::InputReader()
{
fprintf(stderr, "InputReader warming up\n");
init();
}
InputReader::~InputReader()
{
}