diff options
author | David Robillard <d@drobilla.net> | 2013-01-16 08:24:31 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-16 08:24:31 +0000 |
commit | e092fe33afc5cfd566e156f0d565cb1d0c1194f2 (patch) | |
tree | 167ab7737a1d946adc8a1de722dd68b86b9c4d4d /libs/midi++2 | |
parent | 65da5a7cc2c68475019b457f1ea3e60d5b37ceb4 (diff) |
Preliminary support for named MIDI controllers via midname files.
Add midnam file for Moog Minitaur controller names.
git-svn-id: svn://localhost/ardour2/branches/3.0@13852 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/midi++2')
-rw-r--r-- | libs/midi++2/midi++/midnam_patch.h | 57 | ||||
-rw-r--r-- | libs/midi++2/midnam_patch.cc | 62 |
2 files changed, 114 insertions, 5 deletions
diff --git a/libs/midi++2/midi++/midnam_patch.h b/libs/midi++2/midi++/midnam_patch.h index 63d12d322d..20e1b95714 100644 --- a/libs/midi++2/midi++/midnam_patch.h +++ b/libs/midi++2/midi++/midnam_patch.h @@ -255,6 +255,57 @@ private: Notes _notes; }; +class Control +{ +public: + Control() {} + Control(const std::string& type, + const std::string& number, + const std::string& name) + : _type(type) + , _number(number) + , _name(name) + {} + + const std::string& type() const { return _type; } + const std::string& number() const { return _number; } + const std::string& name() const { return _name; } + + void set_type(const std::string& type) { _type = type; } + void set_number(const std::string& number) { _number = number; } + void set_name(const std::string& name) { _name = name; } + + XMLNode& get_state(void); + int set_state(const XMLTree&, const XMLNode&); + +private: + std::string _type; + std::string _number; + std::string _name; +}; + +class ControlNameList +{ +public: + typedef std::list< boost::shared_ptr<Control> > Controls; + + ControlNameList() {} + ControlNameList(const std::string& name) : _name(name) {} + + const std::string& name() const { return _name; } + + void set_name(const std::string name) { _name = name; } + + const Controls& controls() const { return _controls; } + + XMLNode& get_state(void); + int set_state(const XMLTree&, const XMLNode&); + +private: + std::string _name; + Controls _controls; +}; + class CustomDeviceMode { public: @@ -291,6 +342,7 @@ public: /// maps name to ChannelNameSet typedef std::map<std::string, boost::shared_ptr<ChannelNameSet> > ChannelNameSets; typedef std::list<boost::shared_ptr<NoteNameList> > NoteNameLists; + typedef std::list<boost::shared_ptr<ControlNameList> > ControlNameLists; typedef std::map<std::string, PatchBank::PatchNameList> PatchNameLists; MasterDeviceNames() {}; @@ -301,7 +353,9 @@ public: const Models& models() const { return _models; } void set_models(const Models some_models) { _models = some_models; } - + + const ControlNameLists& controls() const { return _control_name_lists; } + const CustomDeviceModeNames& custom_device_mode_names() const { return _custom_device_mode_names; } boost::shared_ptr<CustomDeviceMode> custom_device_mode_by_name(std::string mode_name); @@ -319,6 +373,7 @@ private: ChannelNameSets _channel_name_sets; NoteNameLists _note_name_lists; PatchNameLists _patch_name_lists; + ControlNameLists _control_name_lists; }; class MIDINameDocument diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index f48ae7b6e2..1608b418b0 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -129,7 +129,6 @@ Patch::set_state (const XMLTree&, const XMLNode& node) _id.program_number = PBD::atoi(program_change); } - return 0; } @@ -143,7 +142,6 @@ Note::get_state (void) return *node; } - int Note::set_state (const XMLTree&, const XMLNode& node) { @@ -179,6 +177,52 @@ NoteNameList::set_state (const XMLTree& tree, const XMLNode& node) return 0; } +XMLNode& +Control::get_state (void) +{ + XMLNode* node = new XMLNode("Control"); + node->add_property("Type", _type); + node->add_property("Number", _number); + node->add_property("Name", _name); + + return *node; +} + +int +Control::set_state (const XMLTree&, const XMLNode& node) +{ + assert(node.name() == "Control"); + _type = node.property("Type")->value(); + _number = node.property("Number")->value(); + _name = node.property("Name")->value(); + + return 0; +} + +XMLNode& +ControlNameList::get_state (void) +{ + XMLNode* node = new XMLNode("ControlNameList"); + node->add_property("Name", _name); + + return *node; +} + +int +ControlNameList::set_state (const XMLTree& tree, const XMLNode& node) +{ + assert(node.name() == "ControlNameList"); + _name = node.property("Name")->value(); + + for (XMLNodeList::const_iterator i = node.children().begin(); + i != node.children().end(); ++i) { + boost::shared_ptr<Control> control(new Control()); + control->set_state (tree, *(*i)); + _controls.push_back(control); + } + + return 0; +} XMLNode& PatchBank::get_state (void) @@ -427,7 +471,7 @@ MasterDeviceNames::find_patch(std::string mode, uint8_t channel, PatchPrimaryKey } int -MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode& a_node) +MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode&) { // Manufacturer boost::shared_ptr<XMLSharedNodeList> manufacturer = tree.find("//Manufacturer"); @@ -479,6 +523,16 @@ MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode& a_node) _note_name_lists.push_back(note_name_list); } + // ControlNameLists + boost::shared_ptr<XMLSharedNodeList> control_name_lists = tree.find("//ControlNameList"); + for (XMLSharedNodeList::iterator i = control_name_lists->begin(); + i != control_name_lists->end(); + ++i) { + boost::shared_ptr<ControlNameList> control_name_list(new ControlNameList()); + control_name_list->set_state (tree, *(*i)); + _control_name_lists.push_back(control_name_list); + } + // global/post-facto PatchNameLists boost::shared_ptr<XMLSharedNodeList> patch_name_lists = tree.find("/child::MIDINameDocument/child::MasterDeviceNames/child::PatchNameList"); for (XMLSharedNodeList::iterator i = patch_name_lists->begin(); @@ -544,7 +598,7 @@ MIDINameDocument::MIDINameDocument (const string& filename) } int -MIDINameDocument::set_state (const XMLTree& tree, const XMLNode& a_node) +MIDINameDocument::set_state (const XMLTree& tree, const XMLNode&) { // Author |