diff options
author | David Robillard <d@drobilla.net> | 2013-01-20 04:27:12 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-20 04:27:12 +0000 |
commit | 586484abf0d7816be06879a28c29175d90f03f26 (patch) | |
tree | e80c466712d10aad11be1e3008c51d111e1a8d12 | |
parent | f85bf54e21e68aeffed002fb691f301a8a9bfd4f (diff) |
Support loading MIDI note names in NoteGroup tags as well.
git-svn-id: svn://localhost/ardour2/branches/3.0@13919 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/midi++2/midnam_patch.cc | 54 | ||||
-rw-r--r-- | patchfiles/Yamaha_EX-5.midnam | 16 |
2 files changed, 37 insertions, 33 deletions
diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index 624e1605b5..916dfe7be7 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -148,7 +148,7 @@ Note::get_state (void) } int -Note::set_state (const XMLTree&, const XMLNode& node) +Note::set_state (const XMLTree& tree, const XMLNode& node) { assert(node.name() == "Note"); @@ -160,6 +160,13 @@ Note::set_state (const XMLTree&, const XMLNode& node) _number = atoi(node.property("Number")->value().c_str()) - 1; _name = node.property("Name")->value(); + if (_number > 127) { + PBD::warning << string_compose("%1: Note number %2 (%3) out of range", + tree.filename(), (int)_number, _name) + << endmsg; + return -1; + } + return 0; } @@ -172,6 +179,22 @@ NoteNameList::get_state (void) return *node; } +static void +add_note_from_xml (NoteNameList::Notes& notes, const XMLTree& tree, const XMLNode& node) +{ + boost::shared_ptr<Note> note(new Note()); + if (!note->set_state (tree, node)) { + if (!notes[note->number()]) { + notes[note->number()] = note; + } else { + PBD::warning + << string_compose("%1: Duplicate note number %2 (%3) ignored", + tree.filename(), (int)note->number(), note->name()) + << endmsg; + } + } +} + int NoteNameList::set_state (const XMLTree& tree, const XMLNode& node) { @@ -182,22 +205,19 @@ NoteNameList::set_state (const XMLTree& tree, const XMLNode& node) for (XMLNodeList::const_iterator i = node.children().begin(); i != node.children().end(); ++i) { - if ((*i)->name() != "Note") { - continue; - } - boost::shared_ptr<Note> note(new Note()); - note->set_state (tree, *(*i)); - if (note->number() > 127) { - PBD::warning << string_compose("%1: Note number %2 (%3) out of range", - tree.filename(), (int)note->number(), note->name()) - << endmsg; - } else if (_notes[note->number()]) { - PBD::warning << - string_compose("%1: Duplicate note number %2 (%3) ignored", - tree.filename(), (int)note->number(), note->name()) - << endmsg; - } else { - _notes[note->number()] = note; + if ((*i)->name() == "Note") { + add_note_from_xml(_notes, tree, **i); + } else if ((*i)->name() == "NoteGroup") { + for (XMLNodeList::const_iterator j = (*i)->children().begin(); + j != (*i)->children().end(); ++j) { + if ((*j)->name() == "Note") { + add_note_from_xml(_notes, tree, **j); + } else { + PBD::warning << string_compose("%1: Invalid NoteGroup child %2 ignored", + tree.filename(), (*j)->name()) + << endmsg; + } + } } } diff --git a/patchfiles/Yamaha_EX-5.midnam b/patchfiles/Yamaha_EX-5.midnam index 2d177bdc99..2cac3901eb 100644 --- a/patchfiles/Yamaha_EX-5.midnam +++ b/patchfiles/Yamaha_EX-5.midnam @@ -882,8 +882,6 @@ </PatchBank> </ChannelNameSet> <NoteNameList Name="P2123 Pop Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <NoteGroup Name="Conga Hi Mute/Open"> <Note Number="62" Name="Conga Sl"/> <Note Number="63" Name="Conga H"/> @@ -961,8 +959,6 @@ <Note Number="84" Name="BellTree"/> </NoteNameList> <NoteNameList Name="P2124 Velocity Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <NoteGroup Name="Conga Hi Mute/Open"> <Note Number="62" Name="Conga Sl"/> <Note Number="63" Name="Conga H"/> @@ -1040,8 +1036,6 @@ <Note Number="84" Name="BellTree"/> </NoteNameList> <NoteNameList Name="P2125 Rock Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <NoteGroup Name="Conga Hi Mute/Open"> <Note Number="62" Name="Conga Sl"/> <Note Number="63" Name="Conga H"/> @@ -1119,8 +1113,6 @@ <Note Number="84" Name="BellTree"/> </NoteNameList> <NoteNameList Name="P2126 Jazzy Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <NoteGroup Name="Conga Hi Mute/Open"> <Note Number="62" Name="Conga Sl"/> <Note Number="63" Name="Conga H"/> @@ -1198,8 +1190,6 @@ <Note Number="84" Name="BellTree"/> </NoteNameList> <NoteNameList Name="P2127 House Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <Note Number="28" Name="Crash 1"/> <Note Number="29" Name="BassDr Hi"/> <Note Number="30" Name="Conga"/> @@ -1266,8 +1256,6 @@ <Note Number="91" Name="BdDeep"/> </NoteNameList> <NoteNameList Name="P2128 Tech Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <Note Number="28" Name="Crash"/> <Note Number="29" Name="Snare GM"/> <Note Number="30" Name="Dist Kick"/> @@ -1334,8 +1322,6 @@ <Note Number="91" Name="BD Deep"/> </NoteNameList> <NoteNameList Name="12126 Alien Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <Note Number="28" Name="Crash"/> <Note Number="29" Name="Snare GM"/> <Note Number="30" Name="Dist Kick"/> @@ -1472,8 +1458,6 @@ <Note Number="91" Name="BelAir"/> </NoteNameList> <NoteNameList Name="12128 Street Kit"> - <NoteGroup Name="HiHat"> - </NoteGroup> <Note Number="24" Name="T8Bd"/> <Note Number="25" Name="T8Snare"/> <Note Number="26" Name="SdPrmH"/> |