summaryrefslogtreecommitdiff
path: root/drumgizmo/input/ossmidi.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-04-08 17:42:00 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2019-04-08 18:08:43 +0200
commit723343269d161b2bba7aee4597357ffc32f26f04 (patch)
tree65b25278bcf029ce5f34420a0caaee634b0c9c04 /drumgizmo/input/ossmidi.cc
parent10d483417fa70bb4c357d598f3bdfcf4f0b75f21 (diff)
Move midi note process to one common place in AudioInputEngineMidi::processNote and use it in the four input engines (plugin, midifile, ossmidi and jackmidi)
Diffstat (limited to 'drumgizmo/input/ossmidi.cc')
-rw-r--r--drumgizmo/input/ossmidi.cc25
1 files changed, 6 insertions, 19 deletions
diff --git a/drumgizmo/input/ossmidi.cc b/drumgizmo/input/ossmidi.cc
index 325a83d..7c7757e 100644
--- a/drumgizmo/input/ossmidi.cc
+++ b/drumgizmo/input/ossmidi.cc
@@ -32,10 +32,6 @@
#include <iostream>
-static int const NOTE_ON = 0x90;
-static int const NOTE_MASK = 0xF0;
-
-
OSSInputEngine::OSSInputEngine()
: AudioInputEngineMidi{}
, dev{"/dev/midi"}
@@ -100,21 +96,12 @@ void OSSInputEngine::run(size_t pos, size_t len, std::vector<event_t>& events)
unsigned char buf[128];
if ((l = read (fd, buf, sizeof (buf))) != -1)
{
- int masked_note = buf[0] & NOTE_MASK;
- if (masked_note == NOTE_ON) {
- int note = buf[1];
- int velocity = buf[2];
- event_t event;
- event.instrument = mmap.lookup(note);
- if(event.instrument != -1)
- {
- event.velocity = velocity / 127.0;
- event.type = 0;
- event.offset = 0;
- events.push_back(event);
- }
- }
- } else if (errno != EAGAIN) {
+ processNote(buf, l,
+ 0, // No time information available? play as soon as possible
+ events);
+ }
+ else if (errno != EAGAIN)
+ {
std::cerr << "Error code: " << errno << std::endl;
std::cerr << std::strerror(errno) << std::endl;
}