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
This commit is contained in:
parent
f85bf54e21
commit
586484abf0
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"/>
|
||||
|
|
Loading…
Reference in New Issue
Block a user