summaryrefslogtreecommitdiff
path: root/libs/ardour/slavable_automation_control.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-06-11 01:57:28 +0200
committerRobin Gareus <robin@gareus.org>2017-06-11 02:16:35 +0200
commit02b087c552b38dbbd2042ee8fb61dca4e56a1137 (patch)
treee3f842522f724931ea5dbd629dba0458f7947569 /libs/ardour/slavable_automation_control.cc
parent8b8f47430adfefc624af19f8f27585039560cc81 (diff)
Fix thinko in 9581cb26 - scratch-buffer can't be used recursively.
Diffstat (limited to 'libs/ardour/slavable_automation_control.cc')
-rw-r--r--libs/ardour/slavable_automation_control.cc43
1 files changed, 14 insertions, 29 deletions
diff --git a/libs/ardour/slavable_automation_control.cc b/libs/ardour/slavable_automation_control.cc
index 8a7a8ba00f..5ab968f69c 100644
--- a/libs/ardour/slavable_automation_control.cc
+++ b/libs/ardour/slavable_automation_control.cc
@@ -27,6 +27,7 @@
#include "evoral/Curve.hpp"
#include "ardour/audioengine.h"
+#include "ardour/runtime_functions.h"
#include "ardour/slavable_automation_control.h"
#include "ardour/session.h"
@@ -127,40 +128,24 @@ SlavableAutomationControl::get_masters_curve_locked (framepos_t, framepos_t, flo
bool
SlavableAutomationControl::masters_curve_multiply (framepos_t start, framepos_t end, float* vec, framecnt_t veclen) const
{
- bool rv = list()->curve().rt_safe_get_vector (start, end, vec, veclen);
+ gain_t* scratch = _session.scratch_automation_buffer ();
+ bool rv = list()->curve().rt_safe_get_vector (start, end, scratch, veclen);
+ if (rv) {
+ for (framecnt_t i = 0; i < veclen; ++i) {
+ vec[i] *= scratch[i];
+ }
+ } else {
+ apply_gain_to_buffer (vec, veclen, Control::get_double ());
+ }
if (_masters.empty()) {
return rv;
}
- gain_t* scratch = _session.scratch_automation_buffer ();
- for (Masters::const_iterator mr = _masters.begin(); mr != _masters.end(); ++mr) {
- boost::shared_ptr<AutomationControl> ac (mr->second.master());
- bool got_curve;
+ for (Masters::const_iterator mr = _masters.begin(); mr != _masters.end(); ++mr) {
boost::shared_ptr<SlavableAutomationControl> sc
- = boost::dynamic_pointer_cast<SlavableAutomationControl>(ac);
- if (sc) {
- got_curve = sc->get_masters_curve_locked (start, end, scratch, veclen);
- } else {
- got_curve = ac->list()->curve().rt_safe_get_vector (start, end, scratch, veclen);
- }
- if (got_curve) {
- // TODO use SSE/AVX methods, e.g. ARDOUR::apply_gain_to_buffer, mix_buffers_no_gain
- // which works as long as automation _types_ gain_t == ARDOUR::Sample type == float
- if (!rv) {
- // TODO optimize this, in case rv is false, direcly use "vec" above.
- rv = true;
- memcpy (vec, scratch, sizeof (float) * veclen);
- } else {
- for (framecnt_t i = 0; i < veclen; ++i) {
- vec[i] *= scratch[i];
- }
- }
- } else if (rv) {
- const float v = get_masters_value ();
- for (framecnt_t i = 0; i < veclen; ++i) {
- vec[i] *= v;
- }
- }
+ = boost::dynamic_pointer_cast<SlavableAutomationControl>(mr->second.master());
+ assert (sc);
+ rv |= sc->masters_curve_multiply (start, end, vec, veclen);
}
return rv;
}