diff options
author | Hans Baier <hansfbaier@googlemail.com> | 2008-04-11 15:49:52 +0000 |
---|---|---|
committer | Hans Baier <hansfbaier@googlemail.com> | 2008-04-11 15:49:52 +0000 |
commit | aae8262a363b3d7b85b5baa3b2d0ffb07e604b73 (patch) | |
tree | f482717d2f895f3d9fb3b3f7faa5a4648c3b58d0 /libs/ardour/ardour | |
parent | cb413146428ce5db5e281d70f2b3b7df27c1aaab (diff) |
* persistent undo for MIDI edits works now
* fixed bug: dragging of notes beyond left region bounds made it disappear (unsigned int wrap around)
git-svn-id: svn://localhost/ardour2/branches/3.0@3249 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/midi_model.h | 15 | ||||
-rw-r--r-- | libs/ardour/ardour/note.h | 12 |
2 files changed, 18 insertions, 9 deletions
diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 3ba0fc1279..b6cdac1864 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -55,7 +55,7 @@ typedef std::pair<boost::shared_ptr<const AutomationList>, std::pair<double,doub */ class MidiModel : public boost::noncopyable, public Automatable { public: - MidiModel(MidiSource& s, size_t size=0); + MidiModel(MidiSource *s, size_t size=0); // This is crap. void write_lock(); @@ -108,9 +108,8 @@ public: class DeltaCommand : public Command { public: - DeltaCommand (MidiModel& m, const std::string& name) - : Command(name), _model(m), _name(name) {} - DeltaCommand (MidiModel&, const XMLNode& node); + DeltaCommand (boost::shared_ptr<MidiModel> m, const std::string& name); + DeltaCommand (boost::shared_ptr<MidiModel>, const XMLNode& node); const std::string& name() const { return _name; } @@ -127,7 +126,7 @@ public: XMLNode &marshal_note(const boost::shared_ptr<Note> note); boost::shared_ptr<Note> unmarshal_note(XMLNode *xml_note); - MidiModel& _model; + boost::shared_ptr<MidiModel> _model; const std::string _name; typedef std::list< boost::shared_ptr<Note> > NoteList; @@ -189,7 +188,8 @@ public: const_iterator begin() const { return const_iterator(*this, 0); } const const_iterator& end() const { return _end_iter; } - const MidiSource& midi_source() const { return _midi_source; } + const MidiSource *midi_source() const { return _midi_source; } + void set_midi_source(MidiSource *source) { _midi_source = source; } private: friend class DeltaCommand; @@ -227,7 +227,8 @@ private: LaterNoteEndComparator> ActiveNotes; - MidiSource& _midi_source; + // We cannot use a boost::shared_ptr here to avoid a retain cycle + MidiSource *_midi_source; }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/note.h b/libs/ardour/ardour/note.h index a53b134be8..713d732113 100644 --- a/libs/ardour/ardour/note.h +++ b/libs/ardour/ardour/note.h @@ -40,14 +40,22 @@ public: const Note& operator=(const Note& copy); inline bool operator==(const Note& other) - { return time() == other.time() && note() == other.note() && duration() == other.duration(); } + { return time() == other.time() && + note() == other.note() && + duration() == other.duration() && + velocity() == other.velocity() && + channel() == other.channel(); + } inline double time() const { return _on_event.time(); } inline double end_time() const { return _off_event.time(); } inline uint8_t note() const { return _on_event.note(); } inline uint8_t velocity() const { return _on_event.velocity(); } inline double duration() const { return _off_event.time() - _on_event.time(); } - inline uint8_t channel() const { return _on_event.channel(); } + inline uint8_t channel() const { + assert(_on_event.channel() == _off_event.channel()); + return _on_event.channel(); + } inline void set_time(double t) { _off_event.time() = t + duration(); _on_event.time() = t; } inline void set_note(uint8_t n) { _on_event.buffer()[1] = n; _off_event.buffer()[1] = n; } |