Various updates and fixes for Latency Compensation
[ardour.git] / libs / ardour / ardour / route.h
index 6c5726339389e3c6591cd19ad9331d6d3a4e741c..1ecf36d445d9fbb7e5123c47e1a9d5eb222857e0 100644 (file)
@@ -28,7 +28,6 @@
 
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
 
 #include <glibmm/threads.h>
 #include "pbd/fastlog.h"
 #include "ardour/slavable.h"
 
 class RoutePinWindowProxy;
+class PatchChangeGridDialog;
 
 namespace ARDOUR {
 
 class Amp;
 class DelayLine;
 class Delivery;
+class DiskReader;
+class DiskWriter;
 class IOProcessor;
 class Panner;
 class PannerShell;
@@ -89,9 +91,7 @@ class LIBARDOUR_API Route : public Stripable,
                             public Soloable,
                             public Muteable,
                             public Monitorable,
-                            public Automatable,
-                            public RouteGroupMember,
-                            public boost::enable_shared_from_this<Route>
+                            public RouteGroupMember
 {
 public:
 
@@ -102,6 +102,13 @@ public:
 
        virtual int init ();
 
+       DataType data_type () const {
+               /* XXX ultimately nice to do away with this concept, but it is
+                  quite useful for coders and for users too.
+               */
+               return _default_type;
+       }
+
        boost::shared_ptr<IO> input() const { return _input; }
        boost::shared_ptr<IO> output() const { return _output; }
        IOVector all_inputs () const;
@@ -126,26 +133,26 @@ public:
 
        /* these are the core of the API of a Route. see the protected sections as well */
 
-       virtual int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
+       virtual int roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample,
                          int declick, bool& need_butler);
 
-       virtual int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
+       virtual int no_roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample,
                             bool state_changing);
 
-       virtual int silent_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
+       virtual int silent_roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample,
                                 bool& need_butler);
 
        virtual bool can_record() { return false; }
 
-       virtual void nonrealtime_handle_transport_stopped (bool abort, bool did_locate, bool flush_processors);
+       virtual void non_realtime_transport_stop (samplepos_t now, bool flush);
        virtual void realtime_handle_transport_stopped () {}
        virtual void realtime_locate () {}
-       virtual void non_realtime_locate (framepos_t);
+       virtual void non_realtime_locate (samplepos_t);
        virtual void set_pending_declick (int);
 
        /* end of vfunc-based API */
 
-       void shift (framepos_t, framecnt_t);
+       void shift (samplepos_t, samplecnt_t);
 
        void set_trim (gain_t val, PBD::Controllable::GroupControlDisposition);
 
@@ -181,6 +188,9 @@ public:
        void         set_meter_type (MeterType t) { _meter_type = t; }
        MeterType    meter_type() const { return _meter_type; }
 
+       void set_disk_io_point (DiskIOPoint);
+       DiskIOPoint disk_io_point() const { return _disk_io_point; }
+
        /* Processors */
 
        boost::shared_ptr<Amp> amp() const  { return _amp; }
@@ -223,6 +233,11 @@ public:
        RoutePinWindowProxy * pinmgr_proxy () const { return _pinmgr_proxy; }
        void set_pingmgr_proxy (RoutePinWindowProxy* wp) { _pinmgr_proxy = wp ; }
 
+       PatchChangeGridDialog* patch_selector_dialog () const { return _patch_selector_dialog; }
+       void set_patch_selector_dialog  (PatchChangeGridDialog* d) { _patch_selector_dialog = d; }
+
+       boost::shared_ptr<AutomationControl> automation_control_recurse (PBD::ID const & id) const;
+
        /* special processors */
 
        boost::shared_ptr<InternalSend>     monitor_send() const { return _monitor_send; }
@@ -279,6 +294,7 @@ public:
        void ab_plugins (bool forward);
        void clear_processors (Placement);
        void all_visible_processors_active (bool);
+       void move_instrument_down (bool postfader = false);
 
        bool strict_io () const { return _strict_io; }
        bool set_strict_io (bool);
@@ -320,15 +336,15 @@ public:
         */
        bool remove_sidechain (boost::shared_ptr<Processor> proc) { return add_remove_sidechain (proc, false); }
 
-       framecnt_t set_private_port_latencies (bool playback) const;
-       void       set_public_port_latencies (framecnt_t, bool playback) const;
+       samplecnt_t set_private_port_latencies (bool playback) const;
+       void       set_public_port_latencies (samplecnt_t, bool playback) const;
 
-       framecnt_t   update_signal_latency();
-       virtual void set_latency_compensation (framecnt_t);
+       samplecnt_t   update_signal_latency (bool set_initial_delay = false);
+       virtual void set_latency_compensation (samplecnt_t);
 
-       void set_user_latency (framecnt_t);
-       framecnt_t initial_delay() const { return _initial_delay; }
-       framecnt_t signal_latency() const { return _signal_latency; }
+       void set_user_latency (samplecnt_t);
+       samplecnt_t initial_delay() const  { return _initial_delay; }
+       samplecnt_t signal_latency() const { return _signal_latency; }
 
        PBD::Signal0<void>       active_changed;
        PBD::Signal0<void>       denormal_protection_changed;
@@ -359,6 +375,7 @@ public:
 
        /** the processors have changed; the parameter indicates what changed */
        PBD::Signal1<void,RouteProcessorChange> processors_changed;
+       PBD::Signal0<void> fan_out; // used to signal the GUI to fan-out (track-creation)
        PBD::Signal1<void,void*> record_enable_changed;
        PBD::Signal0<void> processor_latency_changed;
        /** the metering point has changed */
@@ -376,9 +393,12 @@ public:
        virtual XMLNode& get_template();
 
        XMLNode& get_processor_state ();
-       virtual void set_processor_state (const XMLNode&);
+       void set_processor_state (const XMLNode&);
+       virtual bool set_processor_state (XMLNode const & node, XMLProperty const* prop, ProcessorList& new_order, bool& must_configure);
+
+       boost::weak_ptr<Route> weakroute ();
 
-       int save_as_template (const std::string& path, const std::string& name);
+       int save_as_template (const std::string& path, const std::string& name, const std::string& description );
 
        PBD::Signal1<void,void*> SelectedChanged;
 
@@ -501,12 +521,17 @@ public:
         */
        uint32_t eq_band_cnt () const;
        std::string eq_band_name (uint32_t) const;
+       boost::shared_ptr<AutomationControl> eq_enable_controllable () const;
        boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const;
        boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const;
        boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const;
        boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const;
-       boost::shared_ptr<AutomationControl> eq_enable_controllable () const;
-       boost::shared_ptr<AutomationControl> eq_hpf_controllable () const;
+
+       //additional HP/LP filters
+       boost::shared_ptr<AutomationControl> filter_freq_controllable (bool hpf) const;
+       boost::shared_ptr<AutomationControl> filter_slope_controllable (bool) const;
+       boost::shared_ptr<AutomationControl> filter_enable_controllable (bool) const;
+
 
        /* "well-known" controls for a compressor in this route. Any or all may
         * be null.
@@ -516,7 +541,7 @@ public:
        boost::shared_ptr<AutomationControl> comp_speed_controllable () const;
        boost::shared_ptr<AutomationControl> comp_mode_controllable () const;
        boost::shared_ptr<AutomationControl> comp_makeup_controllable () const;
-       boost::shared_ptr<AutomationControl> comp_redux_controllable () const;
+       boost::shared_ptr<ReadOnlyControl>   comp_redux_controllable () const;
 
        /* @param mode must be supplied by the comp_mode_controllable(). All other values
         * result in undefined behaviour
@@ -557,11 +582,13 @@ public:
        /* can only be executed by a route for which is_monitor() is true
         *       (i.e. the monitor out)
         */
-       void monitor_run (framepos_t start_frame, framepos_t end_frame,
+       void monitor_run (samplepos_t start_sample, samplepos_t end_sample,
                        pframes_t nframes, int declick);
 
-        bool slaved_to (boost::shared_ptr<VCA>) const;
-        bool slaved () const;
+       bool slaved_to (boost::shared_ptr<VCA>) const;
+       bool slaved () const;
+
+       virtual void use_captured_sources (SourceList& srcs, CaptureInfos const &) {}
 
   protected:
         friend class Session;
@@ -572,41 +599,37 @@ public:
        void curve_reallocate ();
        virtual void set_block_size (pframes_t nframes);
 
-  protected:
-        virtual framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&) { return nframes; }
+       virtual samplecnt_t check_initial_delay (samplecnt_t nframes, samplepos_t&) { return nframes; }
 
        void fill_buffers_with_input (BufferSet& bufs, boost::shared_ptr<IO> io, pframes_t nframes);
 
-       void passthru (BufferSet&, framepos_t start_frame, framepos_t end_frame,
-                       pframes_t nframes, int declick);
+       void passthru (BufferSet&, samplepos_t start_sample, samplepos_t end_sample, pframes_t nframes, int declick);
 
-       virtual void write_out_of_band_data (BufferSet& /* bufs */, framepos_t /* start_frame */, framepos_t /* end_frame */,
-                                            framecnt_t /* nframes */) {}
+       virtual void write_out_of_band_data (BufferSet& /* bufs */, samplepos_t /* start_sample */, samplepos_t /* end_sample */,
+                                            samplecnt_t /* nframes */) {}
 
        virtual void process_output_buffers (BufferSet& bufs,
-                                            framepos_t start_frame, framepos_t end_frame,
+                                            samplepos_t start_sample, samplepos_t end_sample,
                                             pframes_t nframes, int declick,
                                             bool gain_automation_ok);
 
-       void flush_processor_buffers_locked (framecnt_t nframes);
+       void flush_processor_buffers_locked (samplecnt_t nframes);
 
        virtual void bounce_process (BufferSet& bufs,
-                                    framepos_t start_frame, framecnt_t nframes,
+                                    samplepos_t start_sample, samplecnt_t nframes,
                                                                                                                         boost::shared_ptr<Processor> endpoint, bool include_endpoint,
                                     bool for_export, bool for_freeze);
 
-       framecnt_t   bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) const;
+       samplecnt_t   bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) const;
        ChanCount    bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) const;
 
        boost::shared_ptr<IO> _input;
        boost::shared_ptr<IO> _output;
 
        bool           _active;
-       framecnt_t     _signal_latency;
-       framecnt_t     _signal_latency_at_amp_position;
-       framecnt_t     _signal_latency_at_trim_position;
-       framecnt_t     _initial_delay;
-       framecnt_t     _roll_delay;
+       samplecnt_t     _signal_latency;
+       samplecnt_t     _initial_delay;
+       samplecnt_t     _roll_delay;
 
        ProcessorList  _processors;
        mutable Glib::Threads::RWLock   _processor_lock;
@@ -615,6 +638,10 @@ public:
        boost::shared_ptr<InternalReturn> _intreturn;
        boost::shared_ptr<MonitorProcessor> _monitor_control;
        boost::shared_ptr<Pannable> _pannable;
+       boost::shared_ptr<DiskReader> _disk_reader;
+       boost::shared_ptr<DiskWriter> _disk_writer;
+
+       DiskIOPoint    _disk_io_point;
 
        enum {
                EmitNone = 0x00,
@@ -653,16 +680,15 @@ public:
 
        virtual ChanCount input_streams () const;
 
-protected:
        virtual XMLNode& state(bool);
 
        int configure_processors (ProcessorStreams*);
 
-       void passthru_silence (framepos_t start_frame, framepos_t end_frame,
+       void passthru_silence (samplepos_t start_sample, samplepos_t end_sample,
                               pframes_t nframes, int declick);
 
-       void silence (framecnt_t);
-       void silence_unlocked (framecnt_t);
+       void silence (samplecnt_t);
+       void silence_unlocked (samplecnt_t);
 
        ChanCount processor_max_streams;
        ChanCount processor_out_streams;
@@ -670,7 +696,7 @@ protected:
        uint32_t pans_required() const;
        ChanCount n_process_buffers ();
 
-       virtual void maybe_declick (BufferSet&, framecnt_t, int);
+       virtual void maybe_declick (BufferSet&, samplecnt_t, int);
 
        boost::shared_ptr<GainControl> _gain_control;
        boost::shared_ptr<Amp>       _amp;
@@ -681,7 +707,9 @@ protected:
 
        boost::shared_ptr<Processor> the_instrument_unlocked() const;
 
-  private:
+       SlavableControlList slavables () const;
+
+private:
        int64_t _track_number;
 
        int set_state_2X (const XMLNode&, int);
@@ -716,9 +744,10 @@ protected:
        void set_self_solo (bool yn);
 
        void set_processor_positions ();
-       framecnt_t update_port_latencies (PortSet& ports, PortSet& feeders, bool playback, framecnt_t) const;
+       samplecnt_t update_port_latencies (PortSet& ports, PortSet& feeders, bool playback, samplecnt_t) const;
 
        void setup_invisible_processors ();
+
        void unpan ();
 
        void set_plugin_state_dir (boost::weak_ptr<Processor>, const std::string&);
@@ -766,10 +795,11 @@ protected:
        */
        boost::weak_ptr<Processor> _processor_after_last_custom_meter;
        RoutePinWindowProxy *_pinmgr_proxy;
+       PatchChangeGridDialog* _patch_selector_dialog;
 
        void reset_instrument_info ();
 
-        void solo_control_changed (bool self, PBD::Controllable::GroupControlDisposition);
+       void solo_control_changed (bool self, PBD::Controllable::GroupControlDisposition);
 };
 
 } // namespace ARDOUR