summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/midi_model.h
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-12-09 21:34:46 +0000
committerCarl Hetherington <carl@carlh.net>2010-12-09 21:34:46 +0000
commit5c23faaa0d86b2d1b18d4f03565bad55c410fb7a (patch)
tree673cafb6a98854a4683110e4e89449103403e3cf /libs/ardour/ardour/midi_model.h
parent7d4e03e28e58a9315f163738f35559f57b099d37 (diff)
Allow trim of midi regions to before the start of the source (better, this time). Fixes #3156.
git-svn-id: svn://localhost/ardour2/branches/3.0@8229 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/midi_model.h')
-rw-r--r--libs/ardour/ardour/midi_model.h56
1 files changed, 37 insertions, 19 deletions
diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h
index 27ffa4d8a2..69dc452b62 100644
--- a/libs/ardour/ardour/midi_model.h
+++ b/libs/ardour/ardour/midi_model.h
@@ -58,6 +58,31 @@ public:
class DiffCommand : public Command {
public:
+
+ DiffCommand (boost::shared_ptr<MidiModel> m, const std::string& name);
+
+ const std::string& name () const { return _name; }
+
+ virtual void operator() () = 0;
+ virtual void undo () = 0;
+
+ virtual int set_state (const XMLNode&, int version) = 0;
+ virtual XMLNode & get_state () = 0;
+
+ boost::shared_ptr<MidiModel> model() const { return _model; }
+
+ protected:
+ boost::shared_ptr<MidiModel> _model;
+ const std::string _name;
+
+ };
+
+ class NoteDiffCommand : public DiffCommand {
+ public:
+
+ NoteDiffCommand (boost::shared_ptr<MidiModel> m, const std::string& name) : DiffCommand (m, name) {}
+ NoteDiffCommand (boost::shared_ptr<MidiModel> m, const XMLNode& node);
+
enum Property {
NoteNumber,
Velocity,
@@ -66,17 +91,12 @@ public:
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();
+ void operator() ();
+ void undo ();
int set_state (const XMLNode&, int version);
- XMLNode& get_state ();
-
+ XMLNode & get_state ();
+
void add (const NotePtr note);
void remove (const NotePtr note);
void side_effect_remove (const NotePtr note);
@@ -88,15 +108,11 @@ public:
return !_added_notes.empty() || !_removed_notes.empty();
}
- DiffCommand& operator+= (const DiffCommand& other);
- boost::shared_ptr<MidiModel> model() const { return _model; }
-
+ NoteDiffCommand& operator+= (const NoteDiffCommand& other);
+
private:
- boost::shared_ptr<MidiModel> _model;
- const std::string _name;
-
struct NoteChange {
- DiffCommand::Property property;
+ NoteDiffCommand::Property property;
NotePtr note;
union {
uint8_t old_value;
@@ -124,9 +140,9 @@ public:
NotePtr unmarshal_note(XMLNode *xml_note);
};
- 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);
+ MidiModel::NoteDiffCommand* new_note_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 sync_to_source ();
bool write_to(boost::shared_ptr<MidiSource> source);
@@ -151,6 +167,8 @@ public:
boost::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
+ void insert_silence_at_start (TimeType);
+
protected:
int resolve_overlaps_unlocked (const NotePtr, void* arg = 0);