Changed Processor interface to support out-of-place processors, for Panner.

git-svn-id: svn://localhost/ardour2/trunk@2106 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2007-07-04 22:32:28 +00:00
parent 2177f00841
commit a1052b0eca
16 changed files with 45 additions and 33 deletions

View file

@ -28,7 +28,7 @@ namespace ARDOUR {
/** Apply a declicked gain to the audio buffers of @a bufs */ /** Apply a declicked gain to the audio buffers of @a bufs */
void void
Amp::run (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t target, bool invert_polarity) Amp::run_in_place (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t target, bool invert_polarity)
{ {
if (nframes == 0) if (nframes == 0)
return; return;

View file

@ -29,11 +29,11 @@ class BufferSet;
/** Applies a declick operation to all audio inputs, passing the same number of /** Applies a declick operation to all audio inputs, passing the same number of
* audio outputs, and passing through any other types unchanged. * audio outputs, and passing through any other types unchanged.
* *
* FIXME: make this an insert. * FIXME: make this a Processor.
*/ */
class Amp { class Amp {
public: public:
static void run (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t target, bool invert_polarity); static void run_in_place (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t target, bool invert_polarity);
static void apply_simple_gain(BufferSet& bufs, nframes_t nframes, gain_t target); static void apply_simple_gain(BufferSet& bufs, nframes_t nframes, gain_t target);
}; };

View file

@ -67,7 +67,8 @@ class IOProcessor : public Processor
virtual void automation_snapshot (nframes_t now) { _io->automation_snapshot(now); } virtual void automation_snapshot (nframes_t now) { _io->automation_snapshot(now); }
virtual void run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) = 0; virtual void run_in_place (BufferSet& in, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) = 0;
void silence (nframes_t nframes, nframes_t offset); void silence (nframes_t nframes, nframes_t offset);
sigc::signal<void,IOProcessor*,bool> AutomationPlaybackChanged; sigc::signal<void,IOProcessor*,bool> AutomationPlaybackChanged;

View file

@ -133,7 +133,7 @@ class LadspaPlugin : public ARDOUR::Plugin
bool was_activated; bool was_activated;
void init (void *mod, uint32_t index, nframes_t rate); void init (void *mod, uint32_t index, nframes_t rate);
void run (nframes_t nsamples); void run_in_place (nframes_t nsamples);
void latency_compute_run (); void latency_compute_run ();
}; };

View file

@ -54,7 +54,7 @@ class PluginInsert : public Processor
XMLNode& get_state(void); XMLNode& get_state(void);
int set_state(const XMLNode&); int set_state(const XMLNode&);
void run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset); void run_in_place (BufferSet& in, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset);
void silence (nframes_t nframes, nframes_t offset); void silence (nframes_t nframes, nframes_t offset);
void activate (); void activate ();

View file

@ -52,7 +52,7 @@ class PortInsert : public IOProcessor
void init (); void init ();
void run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset); void run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset);
nframes_t signal_latency() const; nframes_t signal_latency() const;

View file

@ -72,7 +72,10 @@ class Processor : public Automatable, public Latent
virtual void set_block_size (nframes_t nframes) {} virtual void set_block_size (nframes_t nframes) {}
virtual void run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) = 0; virtual void run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { assert(is_in_place()); }
virtual void run_out_of_place (BufferSet& input, BufferSet& output, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { assert(is_out_of_place()); }
virtual void silence (nframes_t nframes, nframes_t offset) {} virtual void silence (nframes_t nframes, nframes_t offset) {}
virtual void activate () { _active = true; ActiveChanged.emit(); } virtual void activate () { _active = true; ActiveChanged.emit(); }
@ -80,7 +83,15 @@ class Processor : public Automatable, public Latent
virtual bool configure_io (ChanCount in, ChanCount out) { _configured_input = in; return (_configured = true); } virtual bool configure_io (ChanCount in, ChanCount out) { _configured_input = in; return (_configured = true); }
/* Derived classes should override these, or processor appears as a pass-through */ /* Derived classes should override these, or processor appears as an in-place pass-through */
/** In-place processors implement run_in_place and modify thee input buffer parameter */
virtual bool is_in_place () const { return true; }
/* Out-Of-Place processors implement run_out_of_place, don't modify the input parameter
* and write to their output parameter */
virtual bool is_out_of_place () const { return false; }
virtual bool can_support_input_configuration (ChanCount in) const { return true; } virtual bool can_support_input_configuration (ChanCount in) const { return true; }
virtual ChanCount output_for_input_configuration (ChanCount in) const { return in; } virtual ChanCount output_for_input_configuration (ChanCount in) const { return in; }
virtual ChanCount output_streams() const { return _configured_input; } virtual ChanCount output_streams() const { return _configured_input; }

View file

@ -45,7 +45,7 @@ class Send : public IOProcessor
ChanCount output_streams() const; ChanCount output_streams() const;
ChanCount input_streams () const; ChanCount input_streams () const;
void run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset); void run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset);
void activate() {} void activate() {}
void deactivate () {} void deactivate () {}

View file

@ -687,7 +687,7 @@ AudioTrack::export_stuff (BufferSet& buffers, nframes_t start, nframes_t nframes
if ((processor = boost::dynamic_pointer_cast<Processor>(*i)) != 0) { if ((processor = boost::dynamic_pointer_cast<Processor>(*i)) != 0) {
switch (processor->placement()) { switch (processor->placement()) {
case PreFader: case PreFader:
processor->run (buffers, start, start+nframes, nframes, 0); processor->run_in_place (buffers, start, start+nframes, nframes, 0);
break; break;
case PostFader: case PostFader:
post_fader_work = true; post_fader_work = true;
@ -727,7 +727,7 @@ AudioTrack::export_stuff (BufferSet& buffers, nframes_t start, nframes_t nframes
case PreFader: case PreFader:
break; break;
case PostFader: case PostFader:
processor->run (buffers, start, start+nframes, nframes, 0); processor->run_in_place (buffers, start, start+nframes, nframes, 0);
break; break;
} }
} }

View file

@ -254,7 +254,7 @@ IO::deliver_output (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame,
} }
if (dg != _gain || dg != 1.0) if (dg != _gain || dg != 1.0)
Amp::run(bufs, nframes, _gain, dg, _phase_invert); Amp::run_in_place(bufs, nframes, _gain, dg, _phase_invert);
} }
// Use the panner to distribute audio to output port buffers // Use the panner to distribute audio to output port buffers

View file

@ -562,7 +562,7 @@ LadspaPlugin::connect_and_run (BufferSet& bufs, uint32_t& in_index, uint32_t& ou
port_index++; port_index++;
} }
run (nframes); run_in_place (nframes);
now = get_cycles (); now = get_cycles ();
set_cycles ((uint32_t) (now - then)); set_cycles ((uint32_t) (now - then));
@ -606,7 +606,7 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const
} }
void void
LadspaPlugin::run (nframes_t nframes) LadspaPlugin::run_in_place (nframes_t nframes)
{ {
for (uint32_t i = 0; i < parameter_count(); ++i) { for (uint32_t i = 0; i < parameter_count(); ++i) {
if (LADSPA_IS_PORT_INPUT(port_descriptor (i)) && LADSPA_IS_PORT_CONTROL(port_descriptor (i))) { if (LADSPA_IS_PORT_INPUT(port_descriptor (i)) && LADSPA_IS_PORT_CONTROL(port_descriptor (i))) {
@ -656,7 +656,7 @@ LadspaPlugin::latency_compute_run ()
port_index++; port_index++;
} }
run (bufsize); run_in_place (bufsize);
deactivate (); deactivate ();
} }

View file

@ -546,7 +546,7 @@ MidiTrack::process_output_buffers (BufferSet& bufs,
Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK); Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
if (rm.locked()) { if (rm.locked()) {
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
(*i)->run (bufs, start_frame, end_frame, nframes, offset); (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
} }
} }
} }

View file

@ -313,7 +313,7 @@ PluginInsert::silence (nframes_t nframes, nframes_t offset)
} }
void void
PluginInsert::run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) PluginInsert::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
{ {
if (active()) { if (active()) {

View file

@ -84,7 +84,7 @@ PortInsert::~PortInsert ()
} }
void void
PortInsert::run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) PortInsert::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
{ {
if (_io->n_outputs().n_total() == 0) { if (_io->n_outputs().n_total() == 0) {
return; return;

View file

@ -295,17 +295,17 @@ Route::process_output_buffers (BufferSet& bufs,
-------------------------------------------------------------------------------------------------- */ -------------------------------------------------------------------------------------------------- */
if (declick > 0) { if (declick > 0) {
Amp::run (bufs, nframes, 0.0, 1.0, false); Amp::run_in_place (bufs, nframes, 0.0, 1.0, false);
_pending_declick = 0; _pending_declick = 0;
} else if (declick < 0) { } else if (declick < 0) {
Amp::run (bufs, nframes, 1.0, 0.0, false); Amp::run_in_place (bufs, nframes, 1.0, 0.0, false);
_pending_declick = 0; _pending_declick = 0;
} else { } else {
/* no global declick */ /* no global declick */
if (solo_gain != dsg) { if (solo_gain != dsg) {
Amp::run (bufs, nframes, solo_gain, dsg, false); Amp::run_in_place (bufs, nframes, solo_gain, dsg, false);
solo_gain = dsg; solo_gain = dsg;
} }
} }
@ -320,7 +320,7 @@ Route::process_output_buffers (BufferSet& bufs,
} }
if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) { if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
Amp::run (bufs, nframes, mute_gain, dmg, false); Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg; mute_gain = dmg;
mute_declick_applied = true; mute_declick_applied = true;
} }
@ -381,7 +381,7 @@ Route::process_output_buffers (BufferSet& bufs,
for (i = _processors.begin(); i != _processors.end(); ++i) { for (i = _processors.begin(); i != _processors.end(); ++i) {
switch ((*i)->placement()) { switch ((*i)->placement()) {
case PreFader: case PreFader:
(*i)->run (bufs, start_frame, end_frame, nframes, offset); (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
break; break;
case PostFader: case PostFader:
post_fader_work = true; post_fader_work = true;
@ -407,7 +407,7 @@ Route::process_output_buffers (BufferSet& bufs,
bufs.set_count(pre_fader_streams()); bufs.set_count(pre_fader_streams());
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) { if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
Amp::run (bufs, nframes, mute_gain, dmg, false); Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg; mute_gain = dmg;
mute_declick_applied = true; mute_declick_applied = true;
} }
@ -417,7 +417,7 @@ Route::process_output_buffers (BufferSet& bufs,
-------------------------------------------------------------------------------------------------- */ -------------------------------------------------------------------------------------------------- */
if (meter && (_meter_point == MeterPreFader)) { if (meter && (_meter_point == MeterPreFader)) {
_meter->run(bufs, start_frame, end_frame, nframes, offset); _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
} }
@ -498,7 +498,7 @@ Route::process_output_buffers (BufferSet& bufs,
if (_gain != dg) { if (_gain != dg) {
Amp::run (bufs, nframes, _gain, dg, _phase_invert); Amp::run_in_place (bufs, nframes, _gain, dg, _phase_invert);
_gain = dg; _gain = dg;
} else if (_gain != 0 && (_phase_invert || _gain != 1.0)) { } else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
@ -551,7 +551,7 @@ Route::process_output_buffers (BufferSet& bufs,
case PreFader: case PreFader:
break; break;
case PostFader: case PostFader:
(*i)->run (bufs, start_frame, end_frame, nframes, offset); (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
break; break;
} }
} }
@ -570,7 +570,7 @@ Route::process_output_buffers (BufferSet& bufs,
} }
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) { if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
Amp::run (bufs, nframes, mute_gain, dmg, false); Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg; mute_gain = dmg;
mute_declick_applied = true; mute_declick_applied = true;
} }
@ -615,7 +615,7 @@ Route::process_output_buffers (BufferSet& bufs,
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) { if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
Amp::run (bufs, nframes, mute_gain, dmg, false); Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg; mute_gain = dmg;
mute_declick_applied = true; mute_declick_applied = true;
} }
@ -677,7 +677,7 @@ Route::process_output_buffers (BufferSet& bufs,
if ((_gain == 0 && !apply_gain_automation) || dmg == 0) { if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
_meter->reset(); _meter->reset();
} else { } else {
_meter->run(output_buffers(), start_frame, end_frame, nframes, offset); _meter->run_in_place(output_buffers(), start_frame, end_frame, nframes, offset);
} }
} }
} }
@ -698,7 +698,7 @@ Route::passthru (nframes_t start_frame, nframes_t end_frame, nframes_t nframes,
collect_input (bufs, nframes, offset); collect_input (bufs, nframes, offset);
if (meter_first) { if (meter_first) {
_meter->run(bufs, start_frame, end_frame, nframes, offset); _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
meter_first = false; meter_first = false;
} }

View file

@ -113,7 +113,7 @@ Send::set_state(const XMLNode& node)
} }
void void
Send::run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) Send::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
{ {
if (active()) { if (active()) {