From 793495a6be9e9fffa8f7ec0e1d3ee4b055c93371 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 30 Oct 2018 17:42:19 +0100 Subject: Added dynamic midnam support. --- plugin/drumgizmo_plugin.cc | 19 +++++++++++++++++++ plugin/drumgizmo_plugin.h | 2 ++ plugin/plugingizmo | 2 +- src/audioinputenginemidi.h | 2 +- src/midimapper.cc | 5 +++++ src/midimapper.h | 2 ++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index 6e4fe3c..d8130f3 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -394,6 +394,25 @@ bool DrumGizmoPlugin::Input::isFreewheeling() const return plugin.getFreeWheel(); } +bool DrumGizmoPlugin::Input::loadMidiMap(const std::string& file, + const Instruments& i) +{ + bool result = AudioInputEngineMidi::loadMidiMap(file, i); + std::vector> midnam; + + const auto& map = mmap.getMap(); + midnam.reserve(map.size()); + for(const auto& m : map) + { + midnam.push_back(std::make_pair(m.first, m.second)); + } + + if(midnam.size() > 0) + { + plugin.setMidnamData(midnam); + } + return result; +} // // Output Engine diff --git a/plugin/drumgizmo_plugin.h b/plugin/drumgizmo_plugin.h index d864def..106614f 100644 --- a/plugin/drumgizmo_plugin.h +++ b/plugin/drumgizmo_plugin.h @@ -128,6 +128,8 @@ private: bool isFreewheeling() const override; + bool loadMidiMap(const std::string& file, const Instruments& i) override; + protected: DrumGizmoPlugin& plugin; const Instruments* instruments{nullptr}; diff --git a/plugin/plugingizmo b/plugin/plugingizmo index 7f84f53..75b1992 160000 --- a/plugin/plugingizmo +++ b/plugin/plugingizmo @@ -1 +1 @@ -Subproject commit 7f84f53bad767dfe2d1a2900b58c4dc32e9a8059 +Subproject commit 75b19928e264ed5a58077498fd61f71e99dc400d diff --git a/src/audioinputenginemidi.h b/src/audioinputenginemidi.h index 19f7da4..e02ba21 100644 --- a/src/audioinputenginemidi.h +++ b/src/audioinputenginemidi.h @@ -51,7 +51,7 @@ public: virtual void run(size_t pos, size_t len, std::vector& events) = 0; virtual void post() = 0; - bool loadMidiMap(const std::string& file, const Instruments& i); + virtual bool loadMidiMap(const std::string& file, const Instruments& i); std::string getMidimapFile() const; diff --git a/src/midimapper.cc b/src/midimapper.cc index ab3d8d7..9243ecf 100644 --- a/src/midimapper.cc +++ b/src/midimapper.cc @@ -51,3 +51,8 @@ void MidiMapper::swap(instrmap_t& instrmap, midimap_t& midimap) std::swap(this->instrmap, instrmap); std::swap(this->midimap, midimap); } + +const midimap_t& MidiMapper::getMap() +{ + return midimap; +} diff --git a/src/midimapper.h b/src/midimapper.h index fc3faec..4673e33 100644 --- a/src/midimapper.h +++ b/src/midimapper.h @@ -43,6 +43,8 @@ public: //! Set new map sets. void swap(instrmap_t& instrmap, midimap_t& midimap); + const midimap_t& getMap(); + private: instrmap_t instrmap; midimap_t midimap; -- cgit v1.2.3