From 94537a47a1c53fd97f3010c9cc17b49b441bb37a Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Sun, 23 Nov 2008 19:42:09 +0000 Subject: [PATCH] * Added support for ChannelNameSetAssignments (midnam_patch.(cc|h) git-svn-id: svn://localhost/ardour2/branches/3.0@4238 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/midi++2/midi++/midnam_patch.h | 44 ++++++++++++++++++++++++++++ libs/midi++2/midnam_patch.cc | 47 ++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/libs/midi++2/midi++/midnam_patch.h b/libs/midi++2/midi++/midnam_patch.h index d4f8dbf466..775f46ec75 100644 --- a/libs/midi++2/midi++/midnam_patch.h +++ b/libs/midi++2/midi++/midnam_patch.h @@ -88,6 +88,50 @@ private: PatchBanks _patch_banks; }; +class CustomDeviceMode : public PBD::Stateful +{ +public: + CustomDeviceMode() {}; + virtual ~CustomDeviceMode() {}; + + const string& name() const { return _name; } + void set_name(const string a_name) { _name = a_name; } + + + XMLNode& get_state (void); + int set_state (const XMLNode& a_node); + +private: + /// array index = channel number + /// string contents = name of channel name set + string _name; + string _channel_name_set_assignments[16]; +}; + +class MasterDeviceNames : public PBD::Stateful +{ +public: + typedef std::list ChannelNameSets; + typedef std::list Models; + + MasterDeviceNames() {}; + virtual ~MasterDeviceNames() {}; + + const string& manufacturer() const { return _manufacturer; } + void set_manufacturer(const string a_manufacturer) { _manufacturer = a_manufacturer; } + + const Models& models() const { return _models; } + void set_models(const Models some_models) { _models = some_models; } + + XMLNode& get_state (void); + int set_state (const XMLNode& a_node); + +private: + string _manufacturer; + Models _models; + ChannelNameSets _channel_name_sets; +}; + class MIDINameDocument : public PBD::Stateful { public: diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index d08911966b..624701bcde 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -131,6 +131,53 @@ ChannelNameSet::set_state (const XMLNode& node) return 0; } +int +CustomDeviceMode::set_state(const XMLNode& a_node) +{ + assert(a_node.name() == "CustomDeviceNode"); + boost::shared_ptr channel_name_set_assignments = + a_node.find("//ChannelNameSetAssign"); + for(XMLSharedNodeList::const_iterator i = channel_name_set_assignments->begin(); + i != channel_name_set_assignments->end(); + ++i) { + int channel = atoi((*i)->property("Channel")->value().c_str()); + string name_set = (*i)->property("NameSet")->value(); + assert( 1 <= channel && channel <= 16 ); + _channel_name_set_assignments[channel -1] = name_set; + } + return 0; +} + +XMLNode& +CustomDeviceMode::get_state(void) +{ + XMLNode* custom_device_mode = new XMLNode("CustomDeviceMode"); + custom_device_mode->add_property("Name", _name); + XMLNode* channel_name_set_assignments = + custom_device_mode->add_child("ChannelNameSetAssignments"); + for (int i = 0; i < 15 && !_channel_name_set_assignments[i].empty(); i++) { + XMLNode* channel_name_set_assign = + channel_name_set_assignments->add_child("ChannelNameSetAssign"); + channel_name_set_assign->add_property("Channel", i + 1); + channel_name_set_assign->add_property("NameSet", _channel_name_set_assignments[i]); + } + + return *custom_device_mode; +} + +int +MasterDeviceNames::set_state(const XMLNode& a_node) +{ + return 0; +} + +XMLNode& +MasterDeviceNames::get_state(void) +{ + static XMLNode nothing(""); + return nothing; +} + int MIDINameDocument::set_state(const XMLNode& a_node) {