Changed Processor interface to support out-of-place processors, for Panner.
authorDavid Robillard <d@drobilla.net>
Wed, 4 Jul 2007 22:32:28 +0000 (22:32 +0000)
committerDavid Robillard <d@drobilla.net>
Wed, 4 Jul 2007 22:32:28 +0000 (22:32 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2106 d708f5d6-7413-0410-9779-e7cbd77b26cf

16 files changed:
libs/ardour/amp.cc
libs/ardour/ardour/amp.h
libs/ardour/ardour/io_processor.h
libs/ardour/ardour/ladspa_plugin.h
libs/ardour/ardour/plugin_insert.h
libs/ardour/ardour/port_insert.h
libs/ardour/ardour/processor.h
libs/ardour/ardour/send.h
libs/ardour/audio_track.cc
libs/ardour/io.cc
libs/ardour/ladspa_plugin.cc
libs/ardour/midi_track.cc
libs/ardour/plugin_insert.cc
libs/ardour/port_insert.cc
libs/ardour/route.cc
libs/ardour/send.cc

index dde438b911fbff69c67dcfbbade61b7fcc67ec06..ae540b86e8335530cb979fdbcbed45a978901af7 100644 (file)
@@ -28,7 +28,7 @@ namespace ARDOUR {
 
 /** Apply a declicked gain to the audio buffers of @a bufs */
 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)
                return;
index e5a4c189e98700e843f0912f150bc9e5d1c7553a..cdbcacbd91916154fa1ab60678f87ccc2dc6b211 100644 (file)
@@ -29,11 +29,11 @@ class BufferSet;
 /** Applies a declick operation to all audio inputs, passing the same number of
  * audio outputs, and passing through any other types unchanged.
  *
- * FIXME: make this an insert.
+ * FIXME: make this a Processor.
  */
 class Amp {
 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);
 };
index c6224969b94b50140d47a695105463be890bbc95..409ad91b15f48778ef745256c33934b4db810efc 100644 (file)
@@ -67,7 +67,8 @@ class IOProcessor : public Processor
        
        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);
 
        sigc::signal<void,IOProcessor*,bool>     AutomationPlaybackChanged;
index a3e43f4cec7b1952799d540ca7ce5afe1e1f1dc2..4c8d9ff74172cd13fe7f1f18ae24b333395a0ca1 100644 (file)
@@ -133,7 +133,7 @@ class LadspaPlugin : public ARDOUR::Plugin
        bool                     was_activated;
 
        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 ();
 };
 
index c78a17b218fb9bbe9179614979841632f59905c7..0694fa2a683e03c22da78577b4b5616fe31634d0 100644 (file)
@@ -54,7 +54,7 @@ class PluginInsert : public Processor
        XMLNode& get_state(void);
        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 activate ();
index 619e2e5bd29a748ed6e1960e098586aeb161207e..114d196750234ea11bc7c5e7241ebca5e6bfdbb5 100644 (file)
@@ -52,7 +52,7 @@ class PortInsert : public IOProcessor
 
        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;
        
index 371572610a9c24b45837905b39001867649c247d..bf9dfe0430945a1f80c3f3e740a3181b74daf8f2 100644 (file)
@@ -72,7 +72,10 @@ class Processor : public Automatable, public Latent
        
        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 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); }
 
-       /* 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 ChanCount output_for_input_configuration (ChanCount in) const { return in; }
        virtual ChanCount output_streams() const { return _configured_input; }
index 26d0351bb236fc6450277099060e5ccf00cd8eea..018df96be4afd51cffa196a4b81661abbef8ec1a 100644 (file)
@@ -45,7 +45,7 @@ class Send : public IOProcessor
        ChanCount output_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 deactivate () {}
index 4df8ffea492b5f8c365231686e8a2b14528ad57d..ffdb47be9dab9d6a4b2285a67d06a6ea47aad652 100644 (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) {
                        switch (processor->placement()) {
                        case PreFader:
-                               processor->run (buffers, start, start+nframes, nframes, 0);
+                               processor->run_in_place (buffers, start, start+nframes, nframes, 0);
                                break;
                        case PostFader:
                                post_fader_work = true;
@@ -727,7 +727,7 @@ AudioTrack::export_stuff (BufferSet& buffers, nframes_t start, nframes_t nframes
                                case PreFader:
                                        break;
                                case PostFader:
-                                       processor->run (buffers, start, start+nframes, nframes, 0);
+                                       processor->run_in_place (buffers, start, start+nframes, nframes, 0);
                                        break;
                                }
                        }
index 057d1dcb64126c69b5f6a53c1be9fff6940c10fc..29cc94ffe70f2ba9772070503822991d9d3aa9a5 100644 (file)
@@ -254,7 +254,7 @@ IO::deliver_output (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame,
                }
 
                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
index 731b76a0bc4fe0b7f4caa481640939d69dd55b90..5ca4a250cce5211a741b7ff3c7f76668f0ed590a 100644 (file)
@@ -562,7 +562,7 @@ LadspaPlugin::connect_and_run (BufferSet& bufs, uint32_t& in_index, uint32_t& ou
                port_index++;
        }
        
-       run (nframes);
+       run_in_place (nframes);
        now = get_cycles ();
        set_cycles ((uint32_t) (now - then));
 
@@ -606,7 +606,7 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const
 }
 
 void
-LadspaPlugin::run (nframes_t nframes)
+LadspaPlugin::run_in_place (nframes_t nframes)
 {
        for (uint32_t i = 0; i < parameter_count(); ++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++;
        }
        
-       run (bufsize);
+       run_in_place (bufsize);
        deactivate ();
 }
 
index 3f7225ed21a50c371f9bee44ea72657145039e0d..00b76eb08aa136fea50cb4328e2e1960051523bc 100644 (file)
@@ -546,7 +546,7 @@ MidiTrack::process_output_buffers (BufferSet& bufs,
                Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
                if (rm.locked()) {
                        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);
                        }
                } 
        }
index 1859c5405f08d4450b49bf72dbdfb76ee56d9f9b..58009e6b5a4643ccee12e5f71df204905ca7f19c 100644 (file)
@@ -313,7 +313,7 @@ PluginInsert::silence (nframes_t nframes, nframes_t offset)
 }
        
 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()) {
 
index 06cbcecc383aa6ae98c7a76a22188c7fa942364d..e14835b0832bda0491bdbe706e06746b37082f14 100644 (file)
@@ -84,7 +84,7 @@ PortInsert::~PortInsert ()
 }
 
 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) {
                return;
index d14f1de08739ec01d58ee02f384d7b2a4adff13c..914e936d6b336445da11f7b9c2d529aa1583e90c 100644 (file)
@@ -295,17 +295,17 @@ Route::process_output_buffers (BufferSet& bufs,
           -------------------------------------------------------------------------------------------------- */
 
        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;
        } 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;
        } else {
 
                /* no global declick */
 
                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;
                }
        }
@@ -320,7 +320,7 @@ Route::process_output_buffers (BufferSet& bufs,
        }
 
        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_declick_applied = true;
        }
@@ -381,7 +381,7 @@ Route::process_output_buffers (BufferSet& bufs,
                                for (i = _processors.begin(); i != _processors.end(); ++i) {
                                        switch ((*i)->placement()) {
                                        case PreFader:
-                                               (*i)->run (bufs, start_frame, end_frame, nframes, offset);
+                                               (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
                                                break;
                                        case PostFader:
                                                post_fader_work = true;
@@ -407,7 +407,7 @@ Route::process_output_buffers (BufferSet& bufs,
        bufs.set_count(pre_fader_streams());
        
        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_declick_applied = true;
        }
@@ -417,7 +417,7 @@ Route::process_output_buffers (BufferSet& bufs,
           -------------------------------------------------------------------------------------------------- */
 
        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) {
                                
-                               Amp::run (bufs, nframes, _gain, dg, _phase_invert);
+                               Amp::run_in_place (bufs, nframes, _gain, dg, _phase_invert);
                                _gain = dg;
                                
                        } else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
@@ -551,7 +551,7 @@ Route::process_output_buffers (BufferSet& bufs,
                                        case PreFader:
                                                break;
                                        case PostFader:
-                                               (*i)->run (bufs, start_frame, end_frame, nframes, offset);
+                                               (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
                                                break;
                                        }
                                }
@@ -570,7 +570,7 @@ Route::process_output_buffers (BufferSet& bufs,
        }
 
        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_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) {
-               Amp::run (bufs, nframes, mute_gain, dmg, false);
+               Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
                mute_gain = dmg;
                mute_declick_applied = true;
        }
@@ -677,7 +677,7 @@ Route::process_output_buffers (BufferSet& bufs,
                if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
                        _meter->reset();
                } 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);
 
        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;
        }
                
index 3c22abf25ca26aa55d8e23df9dcf1f95816f55fe..5567649c9a76905f9672c421aaac074d2071d301 100644 (file)
@@ -113,7 +113,7 @@ Send::set_state(const XMLNode& node)
 }
 
 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()) {