From 813d802443679a6f937a13680bc0ec3fb11a96b6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 26 Apr 2013 15:18:22 +0200 Subject: Add MidimapLoadStatus Message. --- src/audioinputenginemidi.cc | 26 +++++++++++++++++++++++--- src/audioinputenginemidi.h | 6 +++++- src/drumgizmo.cc | 12 +++++++++--- src/message.h | 7 +++++++ 4 files changed, 44 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/audioinputenginemidi.cc b/src/audioinputenginemidi.cc index 00aa518..44e8606 100644 --- a/src/audioinputenginemidi.cc +++ b/src/audioinputenginemidi.cc @@ -30,13 +30,25 @@ #include -void AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) +AudioInputEngineMidi::AudioInputEngineMidi() { + is_valid = false; +} + +bool AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) +{ + file = ""; + is_valid = false; + DEBUG(mmap, "loadMidiMap(%s, i.size() == %d)\n", f.c_str(), instruments.size()); - if(f == "") return; + + if(f == "") return false; + MidiMapParser p(f); - if(p.parse()) {/*return false;*/} + if(p.parse()) { + return false; + } mmap.clear(); mmap.midimap = p.midimap; @@ -46,6 +58,9 @@ void AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) } file = f; + is_valid = true; + + return true; } std::string AudioInputEngineMidi::midimapFile() @@ -53,6 +68,11 @@ std::string AudioInputEngineMidi::midimapFile() return file; } +bool AudioInputEngineMidi::isValid() +{ + return is_valid; +} + #ifdef TEST_AUDIOINPUTENGINEMIDI //Additional dependency files //deps: diff --git a/src/audioinputenginemidi.h b/src/audioinputenginemidi.h index 0f63f8a..b01fef0 100644 --- a/src/audioinputenginemidi.h +++ b/src/audioinputenginemidi.h @@ -36,6 +36,7 @@ class AudioInputEngineMidi : public AudioInputEngine { public: + AudioInputEngineMidi(); virtual ~AudioInputEngineMidi() {} bool isMidiEngine() { return true; } @@ -51,13 +52,16 @@ public: virtual event_t *run(size_t pos, size_t len, size_t *nevents) = 0; virtual void post() = 0; - void loadMidiMap(std::string file, Instruments &i); + bool loadMidiMap(std::string file, Instruments &i); std::string midimapFile(); + bool isValid(); + protected: MidiMapper mmap; std::string file; + bool is_valid; }; #endif/*__DRUMGIZMO_AUDIOINPUTENGINEMIDI_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 8ba45f5..943e852 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -201,22 +201,28 @@ void DrumGizmo::handleEngineEvents() { AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie; LoadMidimapMessage *m = (LoadMidimapMessage*)msg; - aim->loadMidiMap(m->midimapfile, kit.instruments); + bool ret = aim->loadMidiMap(m->midimapfile, kit.instruments); + + LoadStatusMessageMidimap *ls = new LoadStatusMessageMidimap(); + ls->success = ret; + sendGUIMessage(ls); } break; case Message::EngineSettingsMessage: { DEBUG(msg, "got EngineSettingsMessage message."); - + bool mmap_loaded = false; std::string mmapfile; if(ie->isMidiEngine()) { AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie; mmapfile = aim->midimapFile(); + mmap_loaded = aim->isValid(); + } EngineSettingsMessage *msg = new EngineSettingsMessage(); msg->midimapfile = mmapfile; - msg->midimap_loaded = true; + msg->midimap_loaded = mmap_loaded; msg->drumkitfile = drumkitfile(); msg->drumkit_loaded = true; msg->enable_velocity_modifier = Conf::enable_velocity_modifier; diff --git a/src/message.h b/src/message.h index 9bf2f12..4ce65ef 100644 --- a/src/message.h +++ b/src/message.h @@ -32,6 +32,7 @@ public: typedef enum { // Engine -> GUI Messages: LoadStatus, // Signal GUI the current load status. + LoadStatusMidimap, // Signal GUI the current load status of the midimap. // GUI -> Engine, Engine -> Engine Messages: LoadDrumKit, // Signal engine to load drumkit. @@ -52,6 +53,12 @@ public: std::string current_file; }; +class LoadStatusMessageMidimap : public Message { +public: + type_t type() { return Message::LoadStatusMidimap; } + bool success; +}; + class LoadDrumKitMessage : public Message { public: type_t type() { return Message::LoadDrumKit; } -- cgit v1.2.3