diff options
author | David Robillard <d@drobilla.net> | 2014-12-17 19:43:09 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-17 19:43:09 -0500 |
commit | d2cafbe95a5784b7c306c24b0008379a41a909f7 (patch) | |
tree | 03216b0bd933f4d774634a7f8e14965fcf79c990 /libs/midi++2/midnam_patch.cc | |
parent | 6e912a0aa31313636e2957ec0aa97d4103ee117f (diff) |
Remove some aborts that don't really need to be.
Enforce PatchPrimaryKey sanity at the type level rather than attempting to
check for it everywhere.
Remove dead file.
Diffstat (limited to 'libs/midi++2/midnam_patch.cc')
-rw-r--r-- | libs/midi++2/midnam_patch.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index 77e13f29e1..e69842e6cd 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -58,7 +58,8 @@ static int initialize_primary_key_from_commands ( const XMLTree& tree, PatchPrimaryKey& id, const XMLNode* node) { - id.bank_number = 0; + uint16_t bank = 0; + uint8_t program = 0; const XMLNodeList events = node->children(); for (XMLNodeList::const_iterator i = events.begin(); i != events.end(); ++i) { @@ -69,18 +70,19 @@ initialize_primary_key_from_commands ( const string& value = node->property("Value")->value(); if (control == "0") { - id.bank_number |= string_to_int(tree, value) << 7; + bank |= string_to_int(tree, value) << 7; } else if (control == "32") { - id.bank_number |= string_to_int(tree, value); + bank |= string_to_int(tree, value); } } else if (node->name() == "ProgramChange") { const string& number = node->property("Number")->value(); assert(number != ""); - id.program_number = string_to_int(tree, number); + program = string_to_int(tree, number); } } + id = PatchPrimaryKey(program, bank); return 0; } @@ -91,7 +93,7 @@ Patch::get_state (void) /* XXX this is totally wrong */ - node->add_property("Number", string_compose ("%1", _id.program_number)); + node->add_property("Number", string_compose ("%1", _id.program())); node->add_property("Name", _name); /* @@ -120,7 +122,7 @@ Patch::set_state (const XMLTree& tree, const XMLNode& node) const XMLProperty* program_change = node.property("ProgramChange"); if (program_change) { - _id.program_number = string_to_int(tree, program_change->value()); + _id = PatchPrimaryKey(string_to_int(tree, program_change->value()), _id.bank()); } const XMLProperty* name = node.property("Name"); @@ -426,7 +428,7 @@ PatchBank::set_state (const XMLTree& tree, const XMLNode& node) if (initialize_primary_key_from_commands (tree, id, commands)) { return -1; } - _number = id.bank_number; + _number = id.bank(); } XMLNode* patch_name_list = node.child("PatchNameList"); |