summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
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