summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-09-27 06:51:23 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-09-27 06:51:23 +0000
commita09bc7ef137dd4851d4276a4ebd1cda4172a98f8 (patch)
tree94b7675aeee611660f8f7daadb5ea9e185b84303 /libs
parent4d594d08e9d4f2725b298fafb7d93ee5af572edf (diff)
robustify MidiModel::unmarshal_note()
git-svn-id: svn://localhost/ardour2/branches/3.0@3813 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/midi_model.cc58
1 files changed, 43 insertions, 15 deletions
diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc
index 18b37689bd..1f23ee9561 100644
--- a/libs/ardour/midi_model.cc
+++ b/libs/ardour/midi_model.cc
@@ -24,6 +24,7 @@
#include <algorithm>
#include <stdexcept>
#include <stdint.h>
+#include <pbd/error.h>
#include <pbd/enumwriter.h>
#include <midi++/events.h>
@@ -34,7 +35,7 @@
using namespace std;
using namespace ARDOUR;
-
+using namespace PBD;
MidiModel::MidiModel(MidiSource *s, size_t size)
: AutomatableSequence(s->session(), size)
@@ -184,24 +185,51 @@ MidiModel::DeltaCommand::marshal_note(const boost::shared_ptr<Evoral::Note> note
boost::shared_ptr<Evoral::Note> MidiModel::DeltaCommand::unmarshal_note(XMLNode *xml_note)
{
unsigned int note;
- istringstream note_str(xml_note->property("note")->value());
- note_str >> note;
-
+ XMLProperty* prop;
unsigned int channel;
- istringstream channel_str(xml_note->property("channel")->value());
- channel_str >> channel;
-
unsigned int time;
- istringstream time_str(xml_note->property("time")->value());
- time_str >> time;
-
unsigned int length;
- istringstream length_str(xml_note->property("length")->value());
- length_str >> length;
-
unsigned int velocity;
- istringstream velocity_str(xml_note->property("velocity")->value());
- velocity_str >> velocity;
+
+ if ((prop = xml_note->property("note")) != 0) {
+ istringstream note_str(prop->value());
+ note_str >> note;
+ } else {
+ warning << "note information missing note value" << endmsg;
+ note = 127;
+ }
+
+ if ((prop = xml_note->property("channel")) != 0) {
+ istringstream channel_str(prop->value());
+ channel_str >> channel;
+ } else {
+ warning << "note information missing channel" << endmsg;
+ channel = 0;
+ }
+
+ if ((prop = xml_note->property("time")) != 0) {
+ istringstream time_str(prop->value());
+ time_str >> time;
+ } else {
+ warning << "note information missing time" << endmsg;
+ time = 0;
+ }
+
+ if ((prop = xml_note->property("length")) != 0) {
+ istringstream length_str(prop->value());
+ length_str >> length;
+ } else {
+ warning << "note information missing length" << endmsg;
+ note = 1;
+ }
+
+ if ((prop = xml_note->property("velocity")) != 0) {
+ istringstream velocity_str(prop->value());
+ velocity_str >> velocity;
+ } else {
+ warning << "note information missing velocity" << endmsg;
+ velocity = 127;
+ }
boost::shared_ptr<Evoral::Note> note_ptr(new Evoral::Note(channel, time, length, note, velocity));
return note_ptr;