summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-05-28 21:36:38 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-05-28 21:36:38 +0000
commit60ec5dd33946d0500ae00730caa672bb45292a0b (patch)
treeea4c3577e47b25cee02991afa17ad7cf845eae38 /libs/evoral
parent8932625869f181bc16833c9e9d253970656c180d (diff)
provide a generalized Sequence::get_notes()-by-predicate method, and prototypes for 2 future methods
git-svn-id: svn://localhost/ardour2/branches/3.0@7191 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/evoral')
-rw-r--r--libs/evoral/evoral/Sequence.hpp18
-rw-r--r--libs/evoral/src/Sequence.cpp67
2 files changed, 85 insertions, 0 deletions
diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp
index 038cf2c344..36f4138abd 100644
--- a/libs/evoral/evoral/Sequence.hpp
+++ b/libs/evoral/evoral/Sequence.hpp
@@ -137,6 +137,24 @@ public:
inline Notes& notes() { return _notes; }
inline const Notes& notes() const { return _notes; }
+ enum NoteOperator {
+ PitchEqual,
+ PitchLessThan,
+ PitchLessThanOrEqual,
+ PitchGreater,
+ PitchGreaterThanOrEqual,
+ VelocityEqual,
+ VelocityLessThan,
+ VelocityLessThanOrEqual,
+ VelocityGreater,
+ VelocityGreaterThanOrEqual,
+ };
+
+ void get_notes (Notes&, NoteOperator, uint8_t val, int chan_mask = 0) const;
+
+ void remove_overlapping_notes ();
+ void remove_duplicate_notes ();
+
void set_notes (const Sequence<Time>::Notes& n);
typedef std::vector< boost::shared_ptr< Event<Time> > > SysExes;
diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp
index 523643665f..2dadbeb64d 100644
--- a/libs/evoral/src/Sequence.cpp
+++ b/libs/evoral/src/Sequence.cpp
@@ -797,6 +797,73 @@ Sequence<Time>::note_lower_bound (Time t) const
return i;
}
+template<typename Time>
+void
+Sequence<Time>::get_notes (Notes& n, NoteOperator op, uint8_t val, int chan_mask) const
+{
+ ReadLock lock (read_lock());
+
+ for (typename Notes::const_iterator i = _notes.begin(); i != _notes.end(); ++i) {
+
+ if (chan_mask != 0 && !((1<<(*i)->channel()) & chan_mask)) {
+ continue;
+ }
+
+ switch (op) {
+ case PitchEqual:
+ if ((*i)->note() == val) {
+ n.insert (*i);
+ }
+ break;
+ case PitchLessThan:
+ if ((*i)->note() < val) {
+ n.insert (*i);
+ }
+ break;
+ case PitchLessThanOrEqual:
+ if ((*i)->note() <= val) {
+ n.insert (*i);
+ }
+ break;
+ case PitchGreater:
+ if ((*i)->note() > val) {
+ n.insert (*i);
+ }
+ break;
+ case PitchGreaterThanOrEqual:
+ if ((*i)->note() >= val) {
+ n.insert (*i);
+ }
+ break;
+ case VelocityEqual:
+ if ((*i)->velocity() == val) {
+ n.insert (*i);
+ }
+ break;
+ case VelocityLessThan:
+ if ((*i)->velocity() < val) {
+ n.insert (*i);
+ }
+ break;
+ case VelocityLessThanOrEqual:
+ if ((*i)->velocity() <= val) {
+ n.insert (*i);
+ }
+ break;
+ case VelocityGreater:
+ if ((*i)->velocity() > val) {
+ n.insert (*i);
+ }
+ break;
+ case VelocityGreaterThanOrEqual:
+ if ((*i)->velocity() >= val) {
+ n.insert (*i);
+ }
+ break;
+ }
+ }
+}
+
template class Sequence<Evoral::MusicalTime>;
} // namespace Evoral