summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-10-05 21:24:01 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-10-05 21:24:01 +0200
commit6509ebfaea12f690af459ddc85416786e475684b (patch)
treec447f95f089222e7bd59a507a32098ec0c3d4861 /src
parent38ca16084eaed14e155c3f096d6eb6e38778e9a4 (diff)
Make channel maps work.
Diffstat (limited to 'src')
-rw-r--r--src/drumkitparser.cc65
-rw-r--r--src/drumkitparser.h4
2 files changed, 37 insertions, 32 deletions
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index 1c16574..53b0a6d 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -85,8 +85,31 @@ void DrumKitParser::startTag(std::string name,
printf("Missing file in instrument tag.\n");
return;
}
+
+ instr_name = attr["name"];
+ instr_file = attr["file"];
+ }
+
+ if(name == "channelmap") {
+ if(attr.find("in") == attr.end()) {
+ printf("Missing 'in' in channelmap tag.\n");
+ return;
+ }
+
+ if(attr.find("out") == attr.end()) {
+ printf("Missing 'out' in channelmap tag.\n");
+ return;
+ }
+
+ channelmap[attr["in"]] = attr["out"];
+ }
+}
+
+void DrumKitParser::endTag(std::string name)
+{
+ if(name == "instrument") {
Instrument i;
- InstrumentParser parser(path + "/" + attr["file"], i);
+ InstrumentParser parser(path + "/" + instr_file, i);
parser.parse();
kit.instruments.push_back(i);//[attr["name"]] = i;
@@ -95,49 +118,27 @@ void DrumKitParser::startTag(std::string name,
while(ic != parser.channellist.end()) {
InstrumentChannel *c = *ic;
+ std::string cname = c->name;
+ if(channelmap.find(cname) != channelmap.end()) cname = channelmap[cname];
+
for(size_t cnt = 0; cnt < kit.channels.size(); cnt++) {
- if(kit.channels[cnt].name == c->name) c->num = kit.channels[cnt].num;
+ if(kit.channels[cnt].name == cname) c->num = kit.channels[cnt].num;
}
if(c->num == NO_CHANNEL) {
printf("Missing channel '%s' in instrument '%s'\n",
c->name.c_str(), i.name().c_str());
} else {
- printf("Assigned channel '%s' to number %d in instrument '%s'\n",
- c->name.c_str(), c->num, i.name().c_str());
+ /*
+ printf("Assigned channel '%s' to number %d in instrument '%s'\n",
+ c->name.c_str(), c->num, i.name().c_str());
+ */
}
ic++;
}
- //instr = &kit.instruments[attr["name"]];
- }
- /*
- if(name == "channelmap") {
- if(instr == NULL) {
- printf("Missing instrument.\n");
- return;
- }
-
- if(attr.find("in") == attr.end()) {
- printf("Missing 'in' in channelmap tag.\n");
- return;
- }
-
- if(attr.find("out") == attr.end()) {
- printf("Missing 'out' in channelmap tag.\n");
- return;
- }
- instr->channelmap[attr["in"]] = attr["out"];
- }
- */
-}
+ channelmap.clear();
-void DrumKitParser::endTag(std::string name)
-{
- /*
- if(name == "instrument") {
- instr = NULL;
}
- */
}
int DrumKitParser::readData(char *data, size_t size)
diff --git a/src/drumkitparser.h b/src/drumkitparser.h
index f585043..f02eece 100644
--- a/src/drumkitparser.h
+++ b/src/drumkitparser.h
@@ -47,6 +47,10 @@ private:
DrumKit &kit;
// Instrument *instr;
std::string path;
+
+ std::map<std::string, std::string> channelmap;
+ std::string instr_file;
+ std::string instr_name;
};
#endif/*__DRUMGIZMO_DRUMKITPARSER_H__*/