summaryrefslogtreecommitdiff
path: root/src/audioinputenginemidi.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-05-01 21:36:04 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-05-08 12:16:21 +0200
commit42953944da1261584d56405128c6eb3c0e9e7da0 (patch)
tree1f150ce606457a0bea5647374e0719ecd9646f01 /src/audioinputenginemidi.cc
parentf8feb953c6d86bee12747679e5e4dac7795a65d0 (diff)
The last loader thread stuff.
Diffstat (limited to 'src/audioinputenginemidi.cc')
-rw-r--r--src/audioinputenginemidi.cc88
1 files changed, 49 insertions, 39 deletions
diff --git a/src/audioinputenginemidi.cc b/src/audioinputenginemidi.cc
index ea632fe..3ac2a96 100644
--- a/src/audioinputenginemidi.cc
+++ b/src/audioinputenginemidi.cc
@@ -33,55 +33,65 @@
#include <hugin.hpp>
AudioInputEngineMidi::AudioInputEngineMidi()
- : refs(REFSFILE)
+ : refs(REFSFILE)
{
- is_valid = false;
+ is_valid = false;
}
-bool AudioInputEngineMidi::loadMidiMap(const std::string& file, const Instruments& instruments)
+bool AudioInputEngineMidi::loadMidiMap(const std::string& file,
+ const Instruments& instruments)
{
- std::string f = file;
-
- if(refs.load()) {
- if(file.size() > 1 && file[0] == '@') {
- f = refs.getValue(file.substr(1));
- }
- } else {
- ERR(drumkitparser, "Error reading refs.conf");
- }
-
- midimap = "";
- is_valid = false;
-
- DEBUG(mmap, "loadMidiMap(%s, i.size() == %d)\n", f.c_str(),
- (int)instruments.size());
-
- if(f == "") return false;
-
- MidiMapParser p;
- if(p.parseFile(f)) {
- return false;
- }
-
- mmap.clear();
- mmap.midimap = p.midimap;
-
- for(size_t i = 0; i < instruments.size(); i++) {
- mmap.instrmap[instruments[i]->getName()] = i;
- }
-
- midimap = file;
- is_valid = true;
-
- return true;
+ std::string f = file;
+
+ if(refs.load())
+ {
+ if(file.size() > 1 && file[0] == '@')
+ {
+ f = refs.getValue(file.substr(1));
+ }
+ }
+ else
+ {
+ ERR(drumkitparser, "Error reading refs.conf");
+ }
+
+ midimap = "";
+ is_valid = false;
+
+ DEBUG(mmap, "loadMidiMap(%s, i.size() == %d)\n", f.c_str(),
+ (int)instruments.size());
+
+ if(f == "")
+ {
+ return false;
+ }
+
+ MidiMapParser midimap_parser;
+ if(midimap_parser.parseFile(f))
+ {
+ return false;
+ }
+
+ instrmap_t instrmap;
+ for(size_t i = 0; i < instruments.size(); i++)
+ {
+ instrmap[instruments[i]->getName()] = i;
+ }
+
+ mmap.swap(instrmap, midimap_parser.midimap);
+
+ midimap = file;
+ is_valid = true;
+
+ return true;
}
std::string AudioInputEngineMidi::getMidimapFile() const
{
- return midimap;
+ return midimap;
}
bool AudioInputEngineMidi::isValid() const
{
- return is_valid;
+ return is_valid;
}