diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-03-29 11:52:25 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-03-29 11:52:25 -0400 |
commit | 86f1b8c71f7cfae210d66bb97d3c513eade0c40e (patch) | |
tree | e3d0a2033a999614bdf99ad3e42e82a22d410edc /libs/evoral/evoral/types.hpp | |
parent | f1ce235b6bc10a336822a052cee517fa923def48 (diff) |
major fixes for MIDI patch change and note undo/redo. Patch change handling was completely broken because of the use of absolute floating point comparisons for time comparison, and serialization/deserialization of patch change property changes was borked because of int/char conversions by stringstream. Note undo/redo would fail for note removal if a note had been moved and/or had its note number changed as the next operation after it was added, because time-based lookup would fail. Similar small changes made for sysex messages, which just needed the musical_time comparisons and nothing else
Diffstat (limited to 'libs/evoral/evoral/types.hpp')
-rw-r--r-- | libs/evoral/evoral/types.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp index 7bdbdc7a2e..000b79bb94 100644 --- a/libs/evoral/evoral/types.hpp +++ b/libs/evoral/evoral/types.hpp @@ -43,6 +43,33 @@ static inline bool musical_time_equal (MusicalTime a, MusicalTime b) { return fabs (a - b) <= (1.0/1920.0); } +static inline bool musical_time_less_than (MusicalTime a, MusicalTime b) { + /* acceptable tolerance is 1 tick. Nice if there was no magic number here */ + if (fabs (a - b) <= (1.0/1920.0)) { + return false; /* effectively identical */ + } else { + return a < b; + } +} + +static inline bool musical_time_greater_than (MusicalTime a, MusicalTime b) { + /* acceptable tolerance is 1 tick. Nice if there was no magic number here */ + if (fabs (a - b) <= (1.0/1920.0)) { + return false; /* effectively identical */ + } else { + return a > b; + } +} + +static inline bool musical_time_greater_or_equal_to (MusicalTime a, MusicalTime b) { + /* acceptable tolerance is 1 tick. Nice if there was no magic number here */ + if (fabs (a - b) <= (1.0/1920.0)) { + return true; /* effectively identical, note the "or_equal_to" */ + } else { + return a >= b; + } +} + /** Type of an event (opaque, mapped by application) */ typedef uint32_t EventType; |