From 1d3834dd534323467a234fb8ad8bc37eab8ebd0e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 17 Nov 2008 00:05:49 +0000 Subject: Use LV2 MIDI event type from map instead of hardcoded. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1742 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/JackAudioDriver.cpp | 5 +---- src/engine/JackMidiDriver.cpp | 17 ++++++++++++----- src/engine/JackMidiDriver.hpp | 5 ++++- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src/engine') diff --git a/src/engine/JackAudioDriver.cpp b/src/engine/JackAudioDriver.cpp index 3f39f363..19a66281 100644 --- a/src/engine/JackAudioDriver.cpp +++ b/src/engine/JackAudioDriver.cpp @@ -171,13 +171,10 @@ JackAudioDriver::activate() exit(EXIT_FAILURE); } else { cout << "[JackAudioDriver] Activated Jack client." << endl; -/*#ifdef HAVE_LASH - _engine.lash_driver()->set_jack_client_name(jack_client_get_name(_client)); -#endif*/ } if (!_engine.midi_driver() || dynamic_cast(_engine.midi_driver())) - _engine.set_midi_driver(new JackMidiDriver(_client)); + _engine.set_midi_driver(new JackMidiDriver(_engine, _client)); } diff --git a/src/engine/JackMidiDriver.cpp b/src/engine/JackMidiDriver.cpp index ecdbd098..0101212c 100644 --- a/src/engine/JackMidiDriver.cpp +++ b/src/engine/JackMidiDriver.cpp @@ -20,6 +20,9 @@ #include #include "raul/Maid.hpp" #include "raul/midi_events.h" +#include "module/World.hpp" +#include "lv2ext/lv2_event_helpers.h" +#include "shared/LV2URIMap.hpp" #include "types.hpp" #include "JackMidiDriver.hpp" #include "JackAudioDriver.hpp" @@ -28,6 +31,7 @@ #include "EventBuffer.hpp" #include "DuplexPort.hpp" #include "ProcessContext.hpp" +#include "Engine.hpp" #include "jack_compat.h" using namespace std; @@ -89,9 +93,8 @@ JackMidiPort::pre_process(ProcessContext& context) jack_midi_event_t ev; jack_midi_event_get(&ev, jack_buffer, i); - // FIXME: type is hardcoded for now, we should get it from - // the type map instead - const bool success = patch_buf->append(ev.time, 0, 1, ev.size, ev.buffer); + const bool success = patch_buf->append(ev.time, 0, _driver->_midi_event_type, + ev.size, ev.buffer); if (!success) cerr << "WARNING: Failed to write MIDI to port buffer, event(s) lost!" << endl; } @@ -144,11 +147,15 @@ JackMidiPort::post_process(ProcessContext& context) bool JackMidiDriver::_midi_thread_exit_flag = true; -JackMidiDriver::JackMidiDriver(jack_client_t* client) - : _client(client) +JackMidiDriver::JackMidiDriver(Engine& engine, jack_client_t* client) + : _engine(engine) + , _client(client) , _is_activated(false) , _is_enabled(false) { + const Shared::LV2Features::Feature* f = engine.world()->lv2_features->feature(LV2_URI_MAP_URI); + Shared::LV2URIMap* map = (Shared::LV2URIMap*)f->controller; + _midi_event_type = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent"); } diff --git a/src/engine/JackMidiDriver.hpp b/src/engine/JackMidiDriver.hpp index 0b155450..2c78c439 100644 --- a/src/engine/JackMidiDriver.hpp +++ b/src/engine/JackMidiDriver.hpp @@ -63,7 +63,7 @@ private: class JackMidiDriver : public MidiDriver { public: - JackMidiDriver(jack_client_t* client); + JackMidiDriver(Engine& engine, jack_client_t* client); ~JackMidiDriver(); void activate(); @@ -88,6 +88,9 @@ public: jack_client_t* jack_client() { return _client; } private: + Engine& _engine; + uint32_t _midi_event_type; + Raul::List _in_ports; Raul::List _out_ports; -- cgit v1.2.1