summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/midi_model.h
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-09-06 18:11:55 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-09-06 18:11:55 +0000
commit837bfc9af44c5b6c1eeb14e7af8d9ec62c59aac6 (patch)
treecb1fc5bf4f58290efd82e95274d33f67e828b0e5 /libs/ardour/ardour/midi_model.h
parentc3c5c9a559f0dcf63a901f0f99f579fedf64984d (diff)
the start (only the start) of MIDI diff commands
git-svn-id: svn://localhost/ardour2/branches/3.0@5637 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/midi_model.h')
-rw-r--r--libs/ardour/ardour/midi_model.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h
index 967372fa9a..46d4cf794c 100644
--- a/libs/ardour/ardour/midi_model.h
+++ b/libs/ardour/ardour/midi_model.h
@@ -89,10 +89,62 @@ public:
NoteList _removed_notes;
};
+
+ /** Change note properties.
+ * More efficient than DeltaCommand and has the important property that
+ * it leaves the objects in the MidiModel (Notes) the same, thus
+ * enabling selection and other state to persist across command
+ * do/undo/redo.
+ */
+ class DiffCommand : public Command {
+ public:
+ enum Property {
+ NoteNumber,
+ Velocity,
+ StartTime,
+ Length,
+ Channel
+ };
+
+ DiffCommand (boost::shared_ptr<MidiModel> m, const std::string& name);
+ DiffCommand (boost::shared_ptr<MidiModel> m, const XMLNode& node);
+
+ const std::string& name() const { return _name; }
+
+ void operator()();
+ void undo();
+
+ int set_state (const XMLNode&);
+ XMLNode& get_state ();
+
+ void change (const boost::shared_ptr<Evoral::Note<TimeType> > note,
+ Property prop, uint8_t new_value);
+
+ private:
+ boost::shared_ptr<MidiModel> _model;
+ const std::string _name;
+
+ struct NotePropertyChange {
+ DiffCommand::Property property;
+ boost::shared_ptr<Evoral::Note<TimeType> > note;
+ uint8_t old_value;
+ uint8_t new_value;
+ };
+
+ typedef std::list<NotePropertyChange> ChangeList;
+ ChangeList _changes;
+
+ XMLNode &marshal_change(const NotePropertyChange&);
+ NotePropertyChange unmarshal_change(XMLNode *xml_note);
+ };
+
MidiModel::DeltaCommand* new_delta_command(const std::string name="midi edit");
+ MidiModel::DiffCommand* new_diff_command(const std::string name="midi edit");
void apply_command(Session& session, Command* cmd);
void apply_command_as_subcommand(Session& session, Command* cmd);
+
+
bool write_to(boost::shared_ptr<MidiSource> source);
// MidiModel doesn't use the normal AutomationList serialisation code
@@ -104,6 +156,8 @@ public:
const MidiSource* midi_source() const { return _midi_source; }
void set_midi_source(MidiSource* source) { _midi_source = source; }
+
+ boost::shared_ptr<Evoral::Note<TimeType> > find_note (boost::shared_ptr<Evoral::Note<TimeType> >);
private:
friend class DeltaCommand;