diff options
author | David Robillard <d@drobilla.net> | 2014-12-06 13:37:08 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-06 13:40:35 -0500 |
commit | 4650912ae36ef79fd342a6e183e0bc205d3326c2 (patch) | |
tree | 3af63c1b0dc9dfdbb16441e35b7c0a966c254d3f /libs/evoral | |
parent | 96a9292a407dd90b85ed6bebae932c096b357ce8 (diff) |
Adapt range when copying between automation types.
For things like copying from pitch bender to a CC.
Also things like fader to pan, but that seems a bit funny. The conversion
probably needs to be a bit smarter here, perhaps taking the normal into
consideration...
Diffstat (limited to 'libs/evoral')
-rw-r--r-- | libs/evoral/evoral/Parameter.hpp | 4 | ||||
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/libs/evoral/evoral/Parameter.hpp b/libs/evoral/evoral/Parameter.hpp index c870fa8e99..1412699b4d 100644 --- a/libs/evoral/evoral/Parameter.hpp +++ b/libs/evoral/evoral/Parameter.hpp @@ -57,6 +57,10 @@ public: return (_type == id._type && _channel == id._channel && _id == id._id ); } + inline bool operator!=(const Parameter& id) const { + return !operator==(id); + } + /** Strict weak ordering * See: http://www.sgi.com/tech/stl/StrictWeakOrdering.html * Sort Parameters first according to type then to channel and lastly to ID. diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 61bac6148e..70500ba8de 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -1599,7 +1599,16 @@ ControlList::paste (const ControlList& alist, double pos, float /*times*/) where = upper_bound (_events.begin(), _events.end(), &cp, time_comparator); for (const_iterator i = alist.begin();i != alist.end(); ++i) { - _events.insert (where, new ControlEvent( (*i)->when+pos,( *i)->value)); + double value = (*i)->value; + if (alist.parameter() != parameter()) { + const ParameterDescriptor& src_desc = alist.descriptor(); + + value -= src_desc.lower; // translate to 0-relative + value /= (src_desc.upper - src_desc.lower); // normalize range + value *= (_desc.upper - _desc.lower); // scale to our range + value += _desc.lower; // translate to our offset + } + _events.insert (where, new ControlEvent((*i)->when + pos, value)); end = (*i)->when + pos; } |