diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2016-08-28 13:57:05 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2017-04-19 09:36:52 +1000 |
commit | 30bea965796868bfd69f3dfecd3f0fa07a6fc4dd (patch) | |
tree | 4d7798b4191ec46dec05074e1189b404d09774ef /libs/ardour/midi_scene_change.cc | |
parent | adc4bfd5dbfb4c5c6de4ce0f791f2fb4cd603d8a (diff) |
Use XMLNode::get/set_property in ARDOUR::MIDISceneChange class
Diffstat (limited to 'libs/ardour/midi_scene_change.cc')
-rw-r--r-- | libs/ardour/midi_scene_change.cc | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/libs/ardour/midi_scene_change.cc b/libs/ardour/midi_scene_change.cc index 969dadbf75..75fcf32d91 100644 --- a/libs/ardour/midi_scene_change.cc +++ b/libs/ardour/midi_scene_change.cc @@ -19,6 +19,7 @@ #include "pbd/error.h" #include "pbd/compose.h" +#include "pbd/types_convert.h" #include "ardour/midi_port.h" #include "ardour/midi_scene_change.h" @@ -98,20 +99,14 @@ MIDISceneChange::get_program_message (uint8_t* buf, size_t size) const XMLNode& MIDISceneChange::get_state () { - char buf[32]; XMLNode* node = new XMLNode (SceneChange::xml_node_name); - node->add_property (X_("type"), X_("MIDI")); - snprintf (buf, sizeof (buf), "%d", (int) _program); - node->add_property (X_("id"), id().to_s()); - snprintf (buf, sizeof (buf), "%d", (int) _program); - node->add_property (X_("program"), buf); - snprintf (buf, sizeof (buf), "%d", (int) _bank); - node->add_property (X_("bank"), buf); - snprintf (buf, sizeof (buf), "%d", (int) _channel); - node->add_property (X_("channel"), buf); - snprintf (buf, sizeof (buf), "%u", _color); - node->add_property (X_("color"), buf); + node->set_property (X_("type"), X_("MIDI")); + node->set_property (X_("id"), id()); + node->set_property (X_("program"), _program); + node->set_property (X_("bank"), _bank); + node->set_property (X_("channel"), _channel); + node->set_property (X_("color"), _color); return *node; } @@ -123,26 +118,12 @@ MIDISceneChange::set_state (const XMLNode& node, int /* version-ignored */) return -1; } - XMLProperty const * prop; - - if ((prop = node.property (X_("program"))) == 0) { - return -1; - } - _program = atoi (prop->value()); - - if ((prop = node.property (X_("bank"))) == 0) { - return -1; - } - _bank = atoi (prop->value()); - - if ((prop = node.property (X_("channel"))) == 0) { + if (!node.get_property (X_("program"), _program) || !node.get_property (X_("bank"), _bank) || + !node.get_property (X_("channel"), _channel)) { return -1; } - _channel = atoi (prop->value()); - if ((prop = node.property (X_("color"))) != 0) { - _color = atoi (prop->value()); - } else { + if (!node.get_property (X_("color"), _color)) { _color = out_of_bound_color; } |