summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Bisballe Jensen <larsbisballe@gmail.com>2014-10-21 11:04:49 +0200
committerLars Bisballe Jensen <larsbisballe@gmail.com>2014-10-21 11:04:49 +0200
commit98a89a73d7834e83f09f1619d16a58f3ecf2d850 (patch)
tree2d1a78c1163219af8f53c9f8d0a181b372303951
parentc7af1c332447e5fb25f37d4738458a5d7106a6fc (diff)
Added metadata strings to classes and began work on xml parser for drumkits
-rw-r--r--src/audioinputenginemidi.cc2
-rw-r--r--src/channel.cc8
-rw-r--r--src/channel.h4
-rw-r--r--src/drumkit.cc20
-rw-r--r--src/drumkit.h8
-rw-r--r--src/drumkitparser.cc23
-rw-r--r--src/drumkitparser.h6
-rw-r--r--src/instrument.cc4
-rw-r--r--src/instrument.h6
-rw-r--r--src/instrumentparser.cc4
10 files changed, 69 insertions, 16 deletions
diff --git a/src/audioinputenginemidi.cc b/src/audioinputenginemidi.cc
index 82cafbf..a719582 100644
--- a/src/audioinputenginemidi.cc
+++ b/src/audioinputenginemidi.cc
@@ -54,7 +54,7 @@ bool AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments)
mmap.midimap = p.midimap;
for(size_t i = 0; i < instruments.size(); i++) {
- mmap.instrmap[instruments[i]->name()] = i;
+ mmap.instrmap[instruments[i]->id()] = i;
}
file = f;
diff --git a/src/channel.cc b/src/channel.cc
index 941847a..f3490b7 100644
--- a/src/channel.cc
+++ b/src/channel.cc
@@ -26,9 +26,9 @@
*/
#include "channel.h"
-Channel::Channel(std::string name)
+Channel::Channel(std::string id)
{
- this->name = name;
+ this->id = id;
num = NO_CHANNEL;
}
@@ -41,11 +41,11 @@ Channel::Channel(std::string name)
TEST_BEGIN;
Channel c1;
-TEST_EQUAL_STR(c1.name, "", "Empty name?");
+TEST_EQUAL_STR(c1.id, "", "Empty id?");
TEST_EQUAL_INT(c1.num, NO_CHANNEL, "No physical channel assigned?");
Channel c2("ch2");
-TEST_EQUAL_STR(c2.name, "ch2", "Nonempty name?");
+TEST_EQUAL_STR(c2.id, "ch2", "Nonempty id?");
TEST_EQUAL_INT(c2.num, NO_CHANNEL, "No physical channel assigned?");
Channels channels;
diff --git a/src/channel.h b/src/channel.h
index 2484d92..b473a97 100644
--- a/src/channel.h
+++ b/src/channel.h
@@ -37,9 +37,11 @@
class Channel {
public:
- Channel(std::string name = "");
+ Channel(std::string id = "");
+ std::string id;
std::string name;
+ std::string microphone;
channel_t num;
};
diff --git a/src/drumkit.cc b/src/drumkit.cc
index c2aa221..76342d5 100644
--- a/src/drumkit.cc
+++ b/src/drumkit.cc
@@ -72,6 +72,26 @@ std::string DrumKit::description()
return _description;
}
+std::string DrumKit::notes()
+{
+ return _notes;
+}
+
+std::string DrumKit::author()
+{
+ return _author;
+}
+
+std::string DrumKit::email()
+{
+ return _email;
+}
+
+std::string DrumKit::website()
+{
+ return _website;
+}
+
#ifdef TEST_DRUMKIT
//Additional dependency files
//deps:
diff --git a/src/drumkit.h b/src/drumkit.h
index 82fe69b..f72ff50 100644
--- a/src/drumkit.h
+++ b/src/drumkit.h
@@ -45,6 +45,10 @@ public:
std::string name();
std::string description();
+ std::string notes();
+ std::string author();
+ std::string email();
+ std::string website();
Instruments instruments;
Channels channels;
@@ -60,6 +64,10 @@ private:
std::string _name;
std::string _description;
+ std::string _notes;
+ std::string _author;
+ std::string _email;
+ std::string _website;
VersionStr _version;
};
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index 1b7ecaf..2af022a 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -36,6 +36,10 @@
DrumKitParser::DrumKitParser(const std::string &kitfile, DrumKit &k)
: kit(k)
{
+ in_metadata = false;
+ in_channel = false;
+ in_instrument = false;
+
// instr = NULL;
path = getPath(kitfile);
@@ -54,15 +58,17 @@ DrumKitParser::~DrumKitParser()
}
void DrumKitParser::startTag(std::string name,
- std::map<std::string, std::string> attr)
+ std::map<std::string, std::string> attr,
+ std::string &data)
{
if(name == "drumkit") {
+ /*
if(attr.find("name") != attr.end())
kit._name = attr["name"];
if(attr.find("description") != attr.end())
kit._description = attr["description"];
-
+ */
if(attr.find("version") != attr.end()) {
try {
kit._version = VersionStr(attr["version"]);
@@ -76,6 +82,19 @@ void DrumKitParser::startTag(std::string name,
}
}
+ if(name == "metadata") {
+ in_metadata = true;
+ }
+
+ if(in_metadata) {
+ if(name == "name") {
+ if(data != "") {
+ kit._name = data;
+ printf("TEST!\n");
+ }
+ }
+ }
+
if(name == "channels") {}
if(name == "channel") {
diff --git a/src/drumkitparser.h b/src/drumkitparser.h
index 907b09d..7b34b44 100644
--- a/src/drumkitparser.h
+++ b/src/drumkitparser.h
@@ -36,7 +36,8 @@ public:
~DrumKitParser();
void startTag(std::string name,
- std::map< std::string, std::string> attributes);
+ std::map< std::string, std::string> attributes,
+ std::string &data);
void endTag(std::string name);
protected:
@@ -52,6 +53,9 @@ private:
std::string instr_file;
std::string instr_name;
std::string instr_group;
+ bool in_metadata;
+ bool in_channel;
+ bool in_instrument;
};
#endif/*__DRUMGIZMO_DRUMKITPARSER_H__*/
diff --git a/src/instrument.cc b/src/instrument.cc
index d0b25aa..a49b286 100644
--- a/src/instrument.cc
+++ b/src/instrument.cc
@@ -121,9 +121,9 @@ void Instrument::finalise()
}
}
-std::string Instrument::name()
+std::string Instrument::id()
{
- return _name;
+ return _id;
}
std::string Instrument::description()
diff --git a/src/instrument.h b/src/instrument.h
index 416b6c2..d66d60d 100644
--- a/src/instrument.h
+++ b/src/instrument.h
@@ -45,7 +45,7 @@ public:
Sample *sample(level_t level, size_t pos);
- std::string name();
+ std::string id();
std::string description();
std::string group();
@@ -60,9 +60,9 @@ public:
private:
void *magic;
- std::string _group;
- std::string _name;
+ std::string _id;
std::string _description;
+ std::string _group;
VersionStr version;
diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc
index 0889d74..8d097e9 100644
--- a/src/instrumentparser.cc
+++ b/src/instrumentparser.cc
@@ -52,8 +52,8 @@ void InstrumentParser::startTag(std::string name,
std::map<std::string, std::string> attr)
{
if(name == "instrument") {
- if(attr.find("name") != attr.end())
- instrument._name = attr["name"];
+ if(attr.find("id") != attr.end())
+ instrument._id = attr["id"];
if(attr.find("description") != attr.end())
instrument._description = attr["description"];