summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorHans Baier <hansfbaier@googlemail.com>2008-12-06 04:38:44 +0000
committerHans Baier <hansfbaier@googlemail.com>2008-12-06 04:38:44 +0000
commitfc73f748b545ab95ad4ed4fadcbf8948ff8fd455 (patch)
treea3d066e95ed38b627759285c5452ef891cee2851 /libs
parent110170db95aa455794cc8d8ca8ed53b8a31119a5 (diff)
* completed MIDI::Name::MasterDeviceNames and implemented its set_state-Method
git-svn-id: svn://localhost/ardour2/branches/3.0@4293 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/midi++2/midi++/midnam_patch.h44
-rw-r--r--libs/midi++2/midnam_patch.cc75
2 files changed, 108 insertions, 11 deletions
diff --git a/libs/midi++2/midi++/midnam_patch.h b/libs/midi++2/midi++/midnam_patch.h
index 18100cf9be..17d3b17f90 100644
--- a/libs/midi++2/midi++/midnam_patch.h
+++ b/libs/midi++2/midi++/midnam_patch.h
@@ -6,7 +6,7 @@
#include "pbd/xml++.h"
#include <string>
-#include <list>
+#include <vector>
#include <set>
namespace MIDI
@@ -18,7 +18,7 @@ namespace Name
class Patch : public PBD::Stateful
{
public:
- typedef std::list<Evoral::Event> PatchMidiCommands;
+ typedef std::vector<Evoral::Event> PatchMidiCommands;
Patch() {};
Patch(string a_number, string a_name) : _number(a_number), _name(a_name) {};
@@ -44,7 +44,7 @@ private:
class PatchBank : public PBD::Stateful
{
public:
- typedef std::list<Patch> PatchNameList;
+ typedef std::vector<Patch> PatchNameList;
PatchBank() {};
virtual ~PatchBank() {};
@@ -67,7 +67,7 @@ class ChannelNameSet : public PBD::Stateful
{
public:
typedef std::set<uint8_t> AvailableForChannels;
- typedef std::list<PatchBank> PatchBanks;
+ typedef std::vector<PatchBank> PatchBanks;
ChannelNameSet() {};
virtual ~ChannelNameSet() {};
@@ -109,6 +109,27 @@ private:
string _name;
};
+class NoteNameList : public PBD::Stateful
+{
+public:
+ typedef std::vector<Note> Notes;
+ NoteNameList() {};
+ NoteNameList(string a_name) : _name(a_name) {};
+ ~NoteNameList() {};
+
+ const string& name() const { return _name; }
+ void set_name(const string a_name) { _name = a_name; }
+
+ const Notes& notes() const { return _notes; }
+
+ XMLNode& get_state (void);
+ int set_state (const XMLNode& a_node);
+
+private:
+ string _name;
+ Notes _notes;
+};
+
class CustomDeviceMode : public PBD::Stateful
{
public:
@@ -132,8 +153,11 @@ private:
class MasterDeviceNames : public PBD::Stateful
{
public:
- typedef std::list<ChannelNameSet> ChannelNameSets;
- typedef std::list<std::string> Models;
+ typedef std::vector<std::string> Models;
+ typedef std::vector<CustomDeviceMode> CustomDeviceModes;
+ typedef std::vector<ChannelNameSet> ChannelNameSets;
+ typedef std::vector<NoteNameList> NoteNameLists;
+
MasterDeviceNames() {};
virtual ~MasterDeviceNames() {};
@@ -148,9 +172,11 @@ public:
int set_state (const XMLNode& a_node);
private:
- string _manufacturer;
- Models _models;
- ChannelNameSets _channel_name_sets;
+ string _manufacturer;
+ Models _models;
+ CustomDeviceModes _custom_device_modes;
+ ChannelNameSets _channel_name_sets;
+ NoteNameLists _note_name_lists;
};
class MIDINameDocument : public PBD::Stateful
diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc
index dbde6e240c..b9cacdcd96 100644
--- a/libs/midi++2/midnam_patch.cc
+++ b/libs/midi++2/midnam_patch.cc
@@ -42,7 +42,7 @@ Patch::set_state (const XMLNode& node)
XMLNode&
Note::get_state (void)
{
- XMLNode* node = new XMLNode("Patch");
+ XMLNode* node = new XMLNode("Note");
node->add_property("Number", _number);
node->add_property("Name", _name);
@@ -52,7 +52,7 @@ Note::get_state (void)
int
Note::set_state (const XMLNode& node)
{
- assert(node.name() == "Patch");
+ assert(node.name() == "Note");
_number = node.property("Number")->value();
_name = node.property("Name")->value();
@@ -60,6 +60,33 @@ Note::set_state (const XMLNode& node)
}
XMLNode&
+NoteNameList::get_state (void)
+{
+ XMLNode* node = new XMLNode("NoteNameList");
+ node->add_property("Name", _name);
+
+ return *node;
+}
+
+int
+NoteNameList::set_state (const XMLNode& node)
+{
+ assert(node.name() == "NoteNameList");
+ _name = node.property("Name")->value();
+
+ boost::shared_ptr<XMLSharedNodeList> notes =
+ node.find("//Note");
+ for (XMLSharedNodeList::const_iterator i = notes->begin(); i != notes->end(); ++i) {
+ Note note;
+ note.set_state(*(*i));
+ _notes.push_back(note);
+ }
+
+ return 0;
+}
+
+
+XMLNode&
PatchBank::get_state (void)
{
XMLNode* node = new XMLNode("PatchBank");
@@ -188,6 +215,50 @@ CustomDeviceMode::get_state(void)
int
MasterDeviceNames::set_state(const XMLNode& a_node)
{
+ // Manufacturer
+ boost::shared_ptr<XMLSharedNodeList> manufacturer = a_node.find("//Manufacturer");
+ assert(manufacturer->size() == 1);
+ _manufacturer = manufacturer->front()->content();
+
+ // Models
+ boost::shared_ptr<XMLSharedNodeList> models = a_node.find("//Model");
+ assert(models->size() >= 1);
+ for (XMLSharedNodeList::iterator i = models->begin();
+ i != models->end();
+ ++i) {
+ _models.push_back((*i)->content());
+ }
+
+ // CustomDeviceModes
+ boost::shared_ptr<XMLSharedNodeList> custom_device_modes = a_node.find("//CustomDeviceMode");
+ for (XMLSharedNodeList::iterator i = custom_device_modes->begin();
+ i != custom_device_modes->end();
+ ++i) {
+ CustomDeviceMode custom_device_mode;
+ custom_device_mode.set_state(*(*i));
+ _custom_device_modes.push_back(custom_device_mode);
+ }
+
+ // ChannelNameSets
+ boost::shared_ptr<XMLSharedNodeList> channel_name_sets = a_node.find("//ChannelNameSet");
+ for (XMLSharedNodeList::iterator i = channel_name_sets->begin();
+ i != channel_name_sets->end();
+ ++i) {
+ ChannelNameSet channel_name_set;
+ channel_name_set.set_state(*(*i));
+ _channel_name_sets.push_back(channel_name_set);
+ }
+
+ // NoteNameLists
+ boost::shared_ptr<XMLSharedNodeList> note_name_lists = a_node.find("//NoteNameList");
+ for (XMLSharedNodeList::iterator i = note_name_lists->begin();
+ i != note_name_lists->end();
+ ++i) {
+ NoteNameList note_name_list;
+ note_name_list.set_state(*(*i));
+ _note_name_lists.push_back(note_name_list);
+ }
+
return 0;
}