summaryrefslogtreecommitdiff
path: root/drumgizmo/input/jackmidi.cc
diff options
context:
space:
mode:
authorChristian Glöckner <cgloeckner@freenet.de>2016-01-25 16:20:30 +0100
committerAndré Nusser <andre.nusser@googlemail.com>2016-02-09 09:03:17 +0100
commitc9edca027eb2d2e257ff4a13fc257385d7c64d39 (patch)
treef2f003225fc5177fa45bb61e8058aa5acb3be798 /drumgizmo/input/jackmidi.cc
parentd3554736c13531898fb720b34772a595620e661a (diff)
Base Midi-Engines on Midi-Engine Base Class (+ Minor Renaming)
Diffstat (limited to 'drumgizmo/input/jackmidi.cc')
-rw-r--r--drumgizmo/input/jackmidi.cc50
1 files changed, 18 insertions, 32 deletions
diff --git a/drumgizmo/input/jackmidi.cc b/drumgizmo/input/jackmidi.cc
index 386adac..4aebf69 100644
--- a/drumgizmo/input/jackmidi.cc
+++ b/drumgizmo/input/jackmidi.cc
@@ -33,12 +33,10 @@
static int const NOTE_ON = 0x90;
JackMidiInputEngine::JackMidiInputEngine(JackClient &client)
- : AudioInputEngine{}
+ : AudioInputEngineMidi{}
, JackProcess{}
, client(client)
, port{nullptr}
- , midimap{}
- , midi_mapper{}
, pos{0u}
, list{nullptr}
, listsize{0u}
@@ -46,30 +44,18 @@ JackMidiInputEngine::JackMidiInputEngine(JackClient &client)
client.add(*this);
}
-JackMidiInputEngine::~JackMidiInputEngine() { client.remove(*this); }
-
-bool JackMidiInputEngine::isMidiEngine() { return true; }
+JackMidiInputEngine::~JackMidiInputEngine()
+{
+ client.remove(*this);
+}
-bool JackMidiInputEngine::init(Instruments &instruments)
+bool JackMidiInputEngine::init(Instruments& instruments)
{
- if (midimap == "")
- {
- std::cerr << "[JackMidiInputEngine] Missing midimap filename\n";
- return false;
- }
- MidiMapParser p{midimap};
- if (p.parse())
- {
- std::cerr << "[JackmidiInputEngine] Failed to parse midimap '" << midimap
+ if (!loadMidiMap(midimap, instruments)) {
+ std::cerr << "[MidifileInputEngine] Failed to parse midimap '" << midimap
<< "'\n";
return false;
}
- midi_mapper.midimap = p.midimap;
- for (auto i = 0u; i < instruments.size(); ++i)
- {
- auto name = instruments[i]->name();
- midi_mapper.instrmap[name] = i;
- }
port = std::make_unique<JackPort>(client, "drumgizmo_midiin",
JACK_DEFAULT_MIDI_TYPE, JackPortIsInput);
return true;
@@ -95,9 +81,13 @@ bool JackMidiInputEngine::start()
return true;
}
-void JackMidiInputEngine::stop() {}
+void JackMidiInputEngine::stop()
+{
+}
-void JackMidiInputEngine::pre() {}
+void JackMidiInputEngine::pre()
+{
+}
event_t *JackMidiInputEngine::run(size_t pos, size_t len, size_t *nevents)
{
@@ -109,7 +99,9 @@ event_t *JackMidiInputEngine::run(size_t pos, size_t len, size_t *nevents)
return l;
}
-void JackMidiInputEngine::post() {}
+void JackMidiInputEngine::post()
+{
+}
void JackMidiInputEngine::process(jack_nframes_t num_frames)
{
@@ -132,7 +124,7 @@ void JackMidiInputEngine::process(jack_nframes_t num_frames)
int key = event.buffer[1];
int velocity = event.buffer[2];
printf("Event key:%d vel:%d\n", key, velocity);
- int k = midi_mapper.lookup(key);
+ int k = mmap.lookup(key);
if (k != -1 && velocity)
{
list[listsize].type = TYPE_ONSET;
@@ -145,9 +137,3 @@ void JackMidiInputEngine::process(jack_nframes_t num_frames)
jack_midi_clear_buffer(buffer);
pos += num_frames;
}
-
-/*
- DrumKit* kit;
- size_t pos;
- EventQueue *eventqueue;
-*/