summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-09-16 18:32:28 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-09-16 18:38:44 -0400
commit96cc1dbe80f0378ca010c1c5ac37913958193360 (patch)
treefc89043007be602c33bf8752bc5461dc73d23349
parent202b9cc82a6d602ec842b60d609ebdcfe6bac16d (diff)
Revert "add an Amp to Delivery, remove it from Send, make use of this in various ::run() methods"
This reverts commit 601a34521c2ce1d0167ed2f3c66f2fa6eeeb6b8e.
-rw-r--r--libs/ardour/amp.cc12
-rw-r--r--libs/ardour/ardour/delivery.h5
-rw-r--r--libs/ardour/ardour/send.h2
-rw-r--r--libs/ardour/delivery.cc83
-rw-r--r--libs/ardour/internal_send.cc25
-rw-r--r--libs/ardour/send.cc3
6 files changed, 45 insertions, 85 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc
index b7e639b9f5..880fe2575e 100644
--- a/libs/ardour/amp.cc
+++ b/libs/ardour/amp.cc
@@ -133,19 +133,9 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/,
_current_gain = Amp::apply_gain (bufs, _session.nominal_frame_rate(), nframes, _current_gain, dg, _midi_amp);
- } else if (_current_gain == GAIN_COEFF_ZERO) {
-
- /* gain has not changed, and is zero. small
- * optimization here.
- */
-
- bufs.silence (nframes, 0);
-
} else if (_current_gain != GAIN_COEFF_UNITY) {
- /* gain has not changed, but its non-unity and
- * isn't zero, so we have to do something
- */
+ /* gain has not changed, but its non-unity */
if (_midi_amp) {
/* don't Trim midi velocity -- only relevant for Midi on Audio tracks */
diff --git a/libs/ardour/ardour/delivery.h b/libs/ardour/ardour/delivery.h
index 1b8ff3f87a..e19eef719f 100644
--- a/libs/ardour/ardour/delivery.h
+++ b/libs/ardour/ardour/delivery.h
@@ -34,7 +34,6 @@ class MuteMaster;
class PannerShell;
class Panner;
class Pannable;
-class Amp;
class LIBARDOUR_API Delivery : public IOProcessor
{
@@ -68,8 +67,6 @@ public:
bool set_name (const std::string& name);
std::string display_name() const;
- boost::shared_ptr<Amp> amp() const { return _amp; }
-
Role role() const { return _role; }
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (ChanCount in, ChanCount out);
@@ -109,8 +106,8 @@ public:
protected:
Role _role;
BufferSet* _output_buffers;
+ gain_t _current_gain;
boost::shared_ptr<PannerShell> _panshell;
- boost::shared_ptr<Amp> _amp;
gain_t target_gain ();
diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h
index df9afad55c..17343bff96 100644
--- a/libs/ardour/ardour/send.h
+++ b/libs/ardour/ardour/send.h
@@ -43,6 +43,7 @@ class LIBARDOUR_API Send : public Delivery
bool display_to_user() const;
+ boost::shared_ptr<Amp> amp() const { return _amp; }
boost::shared_ptr<PeakMeter> meter() const { return _meter; }
bool metering() const { return _metering; }
@@ -77,6 +78,7 @@ class LIBARDOUR_API Send : public Delivery
protected:
bool _metering;
+ boost::shared_ptr<Amp> _amp;
boost::shared_ptr<PeakMeter> _meter;
boost::shared_ptr<DelayLine> _delayline;
diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc
index 5a4fbd3e1d..1b8a8c5948 100644
--- a/libs/ardour/delivery.cc
+++ b/libs/ardour/delivery.cc
@@ -52,7 +52,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pann
: IOProcessor(s, boost::shared_ptr<IO>(), (role_requires_output_ports (r) ? io : boost::shared_ptr<IO>()), name)
, _role (r)
, _output_buffers (new BufferSet())
- , _amp (new Amp (s))
+ , _current_gain (GAIN_COEFF_UNITY)
, _no_outs_cuz_we_no_monitor (false)
, _mute_master (mm)
, _no_panner_reset (false)
@@ -68,8 +68,6 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pann
if (_output) {
_output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2));
}
-
- _amp->activate ();
}
/* deliver to a new IO object */
@@ -78,7 +76,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr<Pannable> pannable, boost::sha
: IOProcessor(s, false, (role_requires_output_ports (r) ? true : false), name, "", DataType::AUDIO, (r == Send))
, _role (r)
, _output_buffers (new BufferSet())
- , _amp (new Amp (s))
+ , _current_gain (GAIN_COEFF_UNITY)
, _no_outs_cuz_we_no_monitor (false)
, _mute_master (mm)
, _no_panner_reset (false)
@@ -94,17 +92,16 @@ Delivery::Delivery (Session& s, boost::shared_ptr<Pannable> pannable, boost::sha
if (_output) {
_output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2));
}
-
- _amp->activate ();
}
+
Delivery::~Delivery()
{
- DEBUG_TRACE (DEBUG::Destruction, string_compose ("delivery %1 destructor\n", _name));
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("delivery %1 destructor\n", _name));
/* this object should vanish from any signal callback lists
that it is on before we get any further. The full qualification
- of the method name is not necessary, but is here to make it
+ of the method name is not necessary, but is here to make it
clear that this call is about signals, not data flow connections.
*/
@@ -238,7 +235,6 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf
PortSet& ports (_output->ports());
gain_t tgain;
- bool need_amp = true;
if (_output->n_ports ().get (_output->default_type()) == 0) {
goto out;
@@ -263,59 +259,28 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf
tgain = target_gain ();
- if (tgain < GAIN_COEFF_SMALL && _amp->gain() < GAIN_COEFF_SMALL) {
-
- /* special case (but very common) fast path:
- *
- * if we are supposed to be silent, and we were already silent,
- * then short-circuit the computation in Amp and just put silence into
- * our output(s)
- */
-
- _output->silence (nframes);
-
- if (!result_required) {
- /* if !result_required, then the buffers won't actually
- * be used. This means we don't actually need to silence
- * them, because we've already filled the output ports
- * with silence.
- *
- * but we just noted that result_required is true,
- * and so we do need to run the amp to ensure
- * that the buffers are silenced.
- */
- need_amp = false;
- }
- }
-
- if (need_amp) {
-
- bufs.set_count (output_buffers().count ());
+ if (tgain != _current_gain) {
+ /* target gain has changed */
- if (_role != Main) {
+ _current_gain = Amp::apply_gain (bufs, _session.nominal_frame_rate(), nframes, _current_gain, tgain);
- /* inserts, external and internal sends have
- * automatable gain and the Amp::run() method has
- * already been executed by the time we get here.
- *
- * XXX we do not expose the automatable gain for
- * Inserts as of September 2015.
- */
+ } else if (tgain < GAIN_COEFF_SMALL) {
- } else {
-
- /* main outs have no automatable gain, the amp is just
- * used for ramping gain changes caused by monitoring
- * state changes.
- */
-
- _amp->set_gain (tgain, this);
- _amp->run (bufs, 0, 0, nframes, false);
+ /* we were quiet last time, and we're still supposed to be quiet.
+ Silence the outputs, and make sure the buffers are quiet too,
+ */
+ _output->silence (nframes);
+ if (result_required) {
+ bufs.set_count (output_buffers().count ());
+ Amp::apply_simple_gain (bufs, nframes, GAIN_COEFF_ZERO);
}
-
- } else {
goto out;
+
+ } else if (tgain != GAIN_COEFF_UNITY) {
+
+ /* target gain has not changed, but is not unity */
+ Amp::apply_simple_gain (bufs, nframes, tgain);
}
// Speed quietning
@@ -429,7 +394,7 @@ Delivery::pan_outs () const
{
if (_output) {
return _output->n_ports().n_audio();
- }
+ }
return _configured_output.n_audio();
}
@@ -497,7 +462,7 @@ Delivery::flush_buffers (framecnt_t nframes)
if (!_output) {
return;
}
-
+
PortSet& ports (_output->ports());
for (PortSet::iterator i = ports.begin(); i != ports.end(); ++i) {
@@ -548,7 +513,7 @@ Delivery::target_gain ()
we're not monitoring, then be quiet.
*/
- if (_role == Main && _session.config.get_use_monitor_fades() && _no_outs_cuz_we_no_monitor) {
+ if (_no_outs_cuz_we_no_monitor) {
return GAIN_COEFF_ZERO;
}
diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc
index fe57176ac7..e8e560c7c0 100644
--- a/libs/ardour/internal_send.cc
+++ b/libs/ardour/internal_send.cc
@@ -148,10 +148,10 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
} else {
if (role() == Listen) {
/* We're going to the monitor bus, so discard MIDI data */
-
+
uint32_t const bufs_audio = bufs.count().get (DataType::AUDIO);
uint32_t const mixbufs_audio = mixbufs.count().get (DataType::AUDIO);
-
+
/* monitor-section has same number of channels as master-bus (on creation).
*
* There is no clear answer what should happen when trying to PFL or AFL
@@ -190,21 +190,26 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
gain_t tgain = target_gain ();
- _amp->set_gain (tgain, this);
+ if (tgain != _current_gain) {
+
+ /* target gain has changed */
+
+ _current_gain = Amp::apply_gain (mixbufs, _session.nominal_frame_rate(), nframes, _current_gain, tgain);
+
+ } else if (tgain == GAIN_COEFF_ZERO) {
- if (tgain == GAIN_COEFF_ZERO && _amp->gain() == GAIN_COEFF_ZERO) {
/* we were quiet last time, and we're still supposed to be quiet.
- */
+ */
_meter->reset ();
Amp::apply_simple_gain (mixbufs, nframes, GAIN_COEFF_ZERO);
goto out;
- }
+ } else if (tgain != GAIN_COEFF_UNITY) {
- /* These two calls will either set up gain automation or mark
- the amp as ready to use a simple scalar gain.
- */
+ /* target gain has not changed, but is not zero or unity */
+ Amp::apply_simple_gain (mixbufs, nframes, tgain);
+ }
_amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
_amp->setup_gain_automation (start_frame, end_frame, nframes);
@@ -395,4 +400,4 @@ InternalSend::cycle_start (pframes_t /*nframes*/)
for (BufferSet::audio_iterator b = mixbufs.audio_begin(); b != mixbufs.audio_end(); ++b) {
b->prepare ();
}
-}
+}
diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc
index 2167c4319c..9d5fd619c3 100644
--- a/libs/ardour/send.cc
+++ b/libs/ardour/send.cc
@@ -86,6 +86,7 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
//boost_debug_shared_ptr_mark_interesting (this, "send");
+ _amp.reset (new Amp (_session));
_meter.reset (new PeakMeter (_session, name()));
_delayline.reset (new DelayLine (_session, name()));
@@ -173,7 +174,7 @@ Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframe
sendbufs.read_from (bufs, nframes);
assert(sendbufs.count() == bufs.count());
- /* automatable gain control */
+ /* gain control */
_amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
_amp->setup_gain_automation (start_frame, end_frame, nframes);