diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-05-20 22:38:12 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-05-20 22:38:12 +0000 |
commit | a196405da9fab534b5ece4d165e871d02d671b36 (patch) | |
tree | 17cf937e579046c2fb84c30db5c09bb87def6451 /libs/evoral | |
parent | e58f6752af39d5aa032b45eca1c8f392fd874b16 (diff) |
various minor MIDI fixes: prevent duplicate note entry with mouse, show note info more often with verbose cursor, fix some crashes from click+move on notes ... lots more where this comes from
git-svn-id: svn://localhost/ardour2/branches/3.0@7128 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/evoral')
-rw-r--r-- | libs/evoral/evoral/Sequence.hpp | 3 | ||||
-rw-r--r-- | libs/evoral/src/Sequence.cpp | 28 |
2 files changed, 29 insertions, 2 deletions
diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index 3aafb15312..038cf2c344 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -202,7 +202,8 @@ public: bool edited() const { return _edited; } void set_edited(bool yn) { _edited = yn; } - void add_note_unlocked(const boost::shared_ptr< Note<Time> > note); + bool contains (const boost::shared_ptr< Note<Time> > ev) const; + bool add_note_unlocked(const boost::shared_ptr< Note<Time> > note); void remove_note_unlocked(const boost::shared_ptr< const Note<Time> > note); uint8_t lowest_note() const { return _lowest_note; } diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index 281aec514b..523643665f 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -730,12 +730,38 @@ Sequence<Time>::append_sysex_unlocked(const MIDIEvent<Time>& ev) } template<typename Time> -void +bool +Sequence<Time>::contains(const boost::shared_ptr< Note<Time> > note) const +{ + ReadLock lock (read_lock()); + + for (typename Sequence<Time>::Notes::const_iterator i = note_lower_bound(note->time()); + i != _notes.end() && (*i)->time() == note->time(); ++i) { + if (*i == note) { + cerr << "Existing note matches: " << *i << endl; + return true; + } + } + cerr << "No matching note for " << note << endl; + return false; +} + +template<typename Time> +bool Sequence<Time>::add_note_unlocked(const boost::shared_ptr< Note<Time> > note) { DUMP(format("%1% add note %2% @ %3%\n") % this % (int)note->note() % note->time()); + + for (typename Sequence<Time>::Notes::iterator i = note_lower_bound(note->time()); + i != _notes.end() && (*i)->time() == note->time(); ++i) { + if (*i == note) { + return false; + } + } + _edited = true; _notes.insert(note); + return true; } template<typename Time> |