summaryrefslogtreecommitdiff
path: root/src/drumkitparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/drumkitparser.cc')
-rw-r--r--src/drumkitparser.cc45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index 3ba69c8..048a05b 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -34,9 +34,10 @@
#include "path.h"
#include "drumgizmo.h"
-DrumKitParser::DrumKitParser(DrumKit& kit)
- : kit(kit)
- , refs(REFSFILE)
+DrumKitParser::DrumKitParser(Settings& settings, DrumKit& k)
+ : kit(k)
+ , refs(REFSFILE)
+ , settings(settings)
{
}
@@ -46,9 +47,9 @@ int DrumKitParser::parseFile(const std::string& filename)
if(refs.load())
{
- if(filename.size() > 1 && filename[0] == '@')
+ if((filename.size() > 1) && (filename[0] == '@'))
{
- edited_filename = refs.getValue(filename.substr(1));
+ edited_filename = refs.getValue(filename.substr(1));
}
}
else
@@ -57,9 +58,10 @@ int DrumKitParser::parseFile(const std::string& filename)
}
path = getPath(edited_filename);
- auto result = SAXParser::parseFile(filename);
+ auto result = SAXParser::parseFile(edited_filename);
- if (result == 0) {
+ if(result == 0)
+ {
kit._file = edited_filename;
}
@@ -101,7 +103,7 @@ void DrumKitParser::startTag(const std::string& name, const attr_t& attr)
{
ERR(kitparser, "Error parsing version number: %s, using 1.0\n", err);
kit._version = VersionStr(1,0,0);
- }
+ }
}
else
{
@@ -112,7 +114,7 @@ void DrumKitParser::startTag(const std::string& name, const attr_t& attr)
if(name == "channels")
{
-
+
}
if(name == "channel")
@@ -140,6 +142,7 @@ void DrumKitParser::startTag(const std::string& name, const attr_t& attr)
ERR(kitparser, "Missing name in instrument tag.\n");
return;
}
+
if(attr.find("file") == attr.end())
{
ERR(kitparser, "Missing file in instrument tag.\n");
@@ -180,12 +183,14 @@ void DrumKitParser::endTag(const std::string& name)
{
if(name == "instrument")
{
- Instrument* i = new Instrument();
- i->setGroup(instr_group);
- // Instrument &i = kit.instruments[kit.instruments.size() - 1];
- InstrumentParser parser(*i);
+ Instrument* instrument = new Instrument(settings);
+ instrument->setGroup(instr_group);
+
+ InstrumentParser parser(*instrument);
parser.parseFile(path + "/" + instr_file);
- kit.instruments.push_back(i);
+
+ // Transfer ownership to the DrumKit object.
+ kit.instruments.push_back(instrument);
// Assign kit channel numbers to instruments channels.
std::vector<InstrumentChannel*>::iterator ic = parser.channellist.begin();
@@ -206,16 +211,18 @@ void DrumKitParser::endTag(const std::string& name)
c->num = kit.channels[cnt].num;
}
}
+
if(c->num == NO_CHANNEL)
{
ERR(kitparser, "Missing channel '%s' in instrument '%s'\n",
- c->name.c_str(), i->getName().c_str());
+ c->name.c_str(), instrument->getName().c_str());
}
- else {
+ else
+ {
/*
- DEBUG(kitparser, "Assigned channel '%s' to number %d in instrument '%s'\n",
- c->name.c_str(), c->num, i.name().c_str());
- */
+ DEBUG(kitparser, "Assigned channel '%s' to number %d in instrument '%s'\n",
+ c->name.c_str(), c->num, i.name().c_str());
+ */
}
ic++;
}