Remove unused Session::butler_mixdown_buffer and Session::butler_gain_buffer.
[ardour.git] / libs / ardour / ardour / session.h
index 344b79bcd1a80985e3059f25e53f5a3b6848bbac..0e543462aef36b4b1992e351e1fb85ef28a0e6ad 100644 (file)
 
 #include "ardour/ardour.h"
 #include "ardour/chan_count.h"
-#include "ardour/configuration.h"
+#include "ardour/rc_configuration.h"
+#include "ardour/session_configuration.h"
 #include "ardour/location.h"
 #include "ardour/smpte.h"
+#include "ardour/interpolation.h"
 
 class XMLTree;
 class XMLNode;
@@ -176,7 +178,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
                std::list<AudioRange> audio_range;
                std::list<MusicRange> music_range;
-               
+
                boost::shared_ptr<Region> region;
 
                Event(Type t, Action a, nframes_t when, nframes_t where, double spd, bool yn = false)
@@ -204,11 +206,11 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
                        return e1->before (*e2);
                }
 
-               void *operator new (size_t ignored) {
+               void *operator new (size_t) {
                        return pool.alloc ();
                }
 
-               void operator delete(void *ptr, size_t size) {
+               void operator delete (void *ptr, size_t /*size*/) {
                        pool.release (ptr);
                }
 
@@ -221,15 +223,15 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        /* creating from an XML file */
 
        Session (AudioEngine&,
-                       const std::string& fullpath,
-                       const std::string& snapshot_name,
-                       std::string mix_template = "");
+                       const std::string& fullpath,
+                       const std::string& snapshot_name,
+                       std::string mix_template = "");
 
        /* creating a new Session */
 
        Session (AudioEngine&,
-                       std::string fullpath,
-                       std::string snapshot_name,
+                       std::string fullpath,
+                       std::string snapshot_name,
                        AutoConnectOption input_auto_connect,
                        AutoConnectOption output_auto_connect,
                        uint32_t control_out_channels,
@@ -247,6 +249,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        void set_snap_name ();
 
+       bool writable() const { return _writable; }
        void set_dirty ();
        void set_clean ();
        bool dirty() const { return _state_of_the_state & Dirty; }
@@ -302,7 +305,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        typedef std::list<boost::shared_ptr<Diskstream> > DiskstreamList;
 
-       int load_routes (const XMLNode&);
+       int load_routes (const XMLNode&, int);
        boost::shared_ptr<RouteList> get_routes() const {
                return routes.reader ();
        }
@@ -316,10 +319,10 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        }
 
        struct RoutePublicOrderSorter {
-           bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b);
+               bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b);
        };
-       
-       void sync_order_keys (const char* base);
+
+       void sync_order_keys (std::string const &);
 
        template<class T> void foreach_route (T *obj, void (T::*func)(Route&));
        template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
@@ -375,6 +378,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        sigc::signal<void> Located;
 
        sigc::signal<void,RouteList&> RouteAdded;
+       sigc::signal<void> RouteGroupChanged;
 
        void request_roll_at_and_return (nframes_t start, nframes_t return_to);
        void request_bounded_roll (nframes_t start, nframes_t end);
@@ -388,7 +392,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        void goto_end ()   { request_locate (end_location->start(), false);}
        void goto_start () { request_locate (start_location->start(), false); }
        void set_session_start (nframes_t start) { start_location->set_start(start); }
-       void set_session_end (nframes_t end) { end_location->set_start(end); _end_location_is_free = false; }
+       void set_session_end (nframes_t end) { end_location->set_start(end); config.set_end_marker_is_free (false); }
        void use_rf_shuttle_speed ();
        void allow_auto_play (bool yn);
        void request_transport_speed (double speed);
@@ -415,7 +419,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        double frames_per_smpte_frame() const { return _frames_per_smpte_frame; }
        nframes_t smpte_frames_per_hour() const { return _smpte_frames_per_hour; }
 
-       MIDI::byte get_mtc_smpte_bits() const { 
+       MIDI::byte get_mtc_smpte_bits() const {
                return mtc_smpte_bits;   /* encoding of SMTPE type for MTC */
        }
 
@@ -464,7 +468,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        static std::vector<std::string*>* possible_states (std::string path);
 
        XMLNode& get_state();
-       int      set_state(const XMLNode& node); // not idempotent
+       int      set_state(const XMLNode& node, int version); // not idempotent
        XMLNode& get_template();
 
        /// The instant xml file is written to the session directory
@@ -483,28 +487,16 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        StateOfTheState state_of_the_state() const { return _state_of_the_state; }
 
-       RouteGroup* add_edit_group (std::string);
-       RouteGroup* add_mix_group (std::string);
-
-       void remove_edit_group (RouteGroup&);
-       void remove_mix_group (RouteGroup&);
-
-       RouteGroup *mix_group_by_name (std::string);
-       RouteGroup *edit_group_by_name (std::string);
+       void add_route_group (RouteGroup *);
+       void remove_route_group (RouteGroup&);
 
-       sigc::signal<void,RouteGroup*> edit_group_added;
-       sigc::signal<void,RouteGroup*> mix_group_added;
-       sigc::signal<void>             edit_group_removed;
-       sigc::signal<void>             mix_group_removed;
+       RouteGroup *route_group_by_name (std::string);
 
-       void foreach_edit_group (sigc::slot<void,RouteGroup*> sl) {
-               for (std::list<RouteGroup *>::iterator i = edit_groups.begin(); i != edit_groups.end(); i++) {
-                       sl (*i);
-               }
-       }
+       sigc::signal<void,RouteGroup*> route_group_added;
+       sigc::signal<void>             route_group_removed;
 
-       void foreach_mix_group (sigc::slot<void,RouteGroup*> sl) {
-               for (std::list<RouteGroup *>::iterator i = mix_groups.begin(); i != mix_groups.end(); i++) {
+       void foreach_route_group (sigc::slot<void,RouteGroup*> sl) {
+               for (std::list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); i++) {
                        sl (*i);
                }
        }
@@ -512,12 +504,14 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        /* fundamental operations. duh. */
 
        std::list<boost::shared_ptr<AudioTrack> > new_audio_track (
-                       int input_channels, int output_channels, TrackMode mode = Normal, uint32_t how_many = 1);
-       
-       RouteList new_audio_route (int input_channels, int output_channels, uint32_t how_many);
+               int input_channels, int output_channels, TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1
+               );
+
+       RouteList new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many);
 
        std::list<boost::shared_ptr<MidiTrack> > new_midi_track (
-                       TrackMode mode = Normal, uint32_t how_many = 1);
+               TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1
+               );
 
        void   remove_route (boost::shared_ptr<Route>);
        void   resort_routes ();
@@ -549,7 +543,6 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
                pullup_Minus4Minus1
        };
 
-       int  set_smpte_format (SmpteFormat);
        void sync_time_vars();
 
        void bbt_time (nframes_t when, BBT_Time&);
@@ -589,7 +582,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        /// signals the current transport position in frames, bbt and smpte time (in that order)
        sigc::signal<void, const nframes_t&, const BBT_Time&, const SMPTE::Time&> tick;
-       
+
        /* region info  */
 
        void add_regions (std::vector<boost::shared_ptr<Region> >&);
@@ -635,7 +628,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        boost::shared_ptr<ExportHandler> get_export_handler ();
        boost::shared_ptr<ExportStatus> get_export_status ();
 
-       int  start_audio_export (nframes_t position, bool realtime);    
+       int  start_audio_export (nframes_t position, bool realtime);
 
        sigc::signal<int, nframes_t> ProcessExport;
        sigc::signal<void> ExportReadFinished;
@@ -724,16 +717,18 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        /* flattening stuff */
 
        boost::shared_ptr<Region> write_one_track (AudioTrack&, nframes_t start, nframes_t end,
-                                                  bool overwrite, std::vector<boost::shared_ptr<Source> >&, InterThreadInfo& wot,
-                                                  bool enable_processing = true);
+                       bool overwrite, std::vector<boost::shared_ptr<Source> >&, InterThreadInfo& wot,
+                       bool enable_processing = true);
        int freeze (InterThreadInfo&);
 
        /* session-wide solo/mute/rec-enable */
 
-       bool soloing() const { return currently_soloing; }
+       bool soloing() const { return _non_soloed_outs_muted; }
+       bool listening() const { return _listen_cnt > 0; }
 
        void set_all_solo (bool);
        void set_all_mute (bool);
+       void set_all_listen (bool);
 
        sigc::signal<void,bool> SoloActive;
        sigc::signal<void> SoloChanged;
@@ -743,14 +738,14 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        /* control/master out */
 
-       boost::shared_ptr<IO> control_out() const { return _control_out; }
-       boost::shared_ptr<IO> master_out() const { return _master_out; }
-
-       /* insert/send management */
+       boost::shared_ptr<Route> control_out() const { return _control_out; }
+       boost::shared_ptr<Route> master_out() const { return _master_out; }
 
-       uint32_t n_port_inserts() const { return _port_inserts.size(); }
-       uint32_t n_plugin_inserts() const { return _plugin_inserts.size(); }
-       uint32_t n_sends() const { return _sends.size(); }
+       void globally_add_internal_sends (boost::shared_ptr<Route> dest, Placement p);
+       void globally_set_send_gains_from_track (boost::shared_ptr<Route> dest);
+       void globally_set_send_gains_to_zero (boost::shared_ptr<Route> dest);
+       void globally_set_send_gains_to_unity (boost::shared_ptr<Route> dest);
+       void add_internal_sends (boost::shared_ptr<Route> dest, Placement p, boost::shared_ptr<RouteList> senders);
 
        static void set_disable_all_loaded_plugins (bool yn) {
                _disable_all_loaded_plugins = yn;
@@ -851,22 +846,21 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        class GlobalRouteStateCommand : public Command
        {
-         public:
+       public:
                GlobalRouteStateCommand (Session&, void*);
                GlobalRouteStateCommand (Session&, const XMLNode& node);
-               int set_state (const XMLNode&);
+               int set_state (const XMLNode&, int version);
                XMLNode& get_state ();
 
-         protected:
+       protected:
                GlobalRouteBooleanState before, after;
                Session& sess;
                void* src;
-
        };
 
        class GlobalSoloStateCommand : public GlobalRouteStateCommand
        {
-         public:
+       public:
                GlobalSoloStateCommand (Session &, void *src);
                GlobalSoloStateCommand (Session&, const XMLNode&);
                void operator()(); //redo
@@ -877,7 +871,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        class GlobalMuteStateCommand : public GlobalRouteStateCommand
        {
-         public:
+       public:
                GlobalMuteStateCommand(Session &, void *src);
                GlobalMuteStateCommand (Session&, const XMLNode&);
                void operator()(); // redo
@@ -888,7 +882,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        class GlobalRecordEnableStateCommand : public GlobalRouteStateCommand
        {
-         public:
+       public:
                GlobalRecordEnableStateCommand(Session &, void *src);
                GlobalRecordEnableStateCommand (Session&, const XMLNode&);
                void operator()(); // redo
@@ -899,16 +893,16 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        class GlobalMeteringStateCommand : public Command
        {
-         public:
+       public:
                GlobalMeteringStateCommand(Session &, void *src);
                GlobalMeteringStateCommand (Session&, const XMLNode&);
                void operator()();
                void undo();
                XMLNode &get_state();
-               int set_state (const XMLNode&);
+               int set_state (const XMLNode&, int version);
                void mark();
 
-         protected:
+       protected:
                Session& sess;
                void* src;
                GlobalRouteMeterState before;
@@ -944,7 +938,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        gain_t* gain_automation_buffer () const { return _gain_automation_buffer; }
        pan_t** pan_automation_buffer () const  { return _pan_automation_buffer; }
-       
+
        void ensure_buffer_set (BufferSet& buffers, const ChanCount& howmany);
 
        /* VST support */
@@ -967,6 +961,12 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        SessionMetadata & metadata () { return *_metadata; }
 
+       SessionConfiguration config;
+
+       bool exporting () const {
+               return _exporting;
+       }
+
   protected:
        friend class AudioEngine;
        void set_block_size (nframes_t nframes);
@@ -1018,12 +1018,13 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        Location*                start_location;
        Slave*                  _slave;
        bool                    _silent;
-       volatile double         _transport_speed;
-       double                  _last_transport_speed;
-                                // varispeed playback
-       uint64_t                 phi;        // fixed point transport speed
-       uint64_t                 target_phi; // fixed point target transport speed
-       uint64_t                 phase;      // fixed point phase 
+
+    // varispeed playback
+       volatile double             _transport_speed;
+       double                      _last_transport_speed;
+       double                      _target_transport_speed;
+       CubicInterpolation          interpolation;
+
        bool                     auto_play_legal;
        nframes_t               _last_slave_transport_frame;
        nframes_t                maximum_output_latency;
@@ -1038,10 +1039,12 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        bool                    _have_captured;
        float                   _meter_hold;
        float                   _meter_falloff;
-       bool                    _end_location_is_free;
+       bool                    _non_soloed_outs_muted;
+       uint32_t                _listen_cnt;
+       bool                    _writable;
 
        void set_worst_io_latencies ();
-       void set_worst_io_latencies_x (IOChange asifwecare, void *ignored) {
+       void set_worst_io_latencies_x (IOChange, void *) {
                set_worst_io_latencies ();
        }
 
@@ -1081,10 +1084,10 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        void reset_slave_state ();
        bool follow_slave (nframes_t);
        void calculate_moving_average_of_slave_delta(int dir, nframes_t this_delta);
-       void track_slave_state(float slave_speed, nframes_t slave_transport_frame, 
-                              nframes_t this_delta, bool starting);
+       void track_slave_state(float slave_speed, nframes_t slave_transport_frame,
+                              nframes_t this_delta, bool starting);
        void follow_slave_silently(nframes_t nframes, float slave_speed);
-       
+
        void set_slave_source (SlaveSource);
 
        SlaveSource post_export_slave;
@@ -1092,14 +1095,14 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        bool _exporting;
        bool _exporting_realtime;
-       
+
        boost::shared_ptr<ExportHandler> export_handler;
        boost::shared_ptr<ExportStatus>  export_status;
 
        int  pre_export ();
        int  stop_audio_export ();
        void finalize_audio_export ();
-       
+
        sigc::connection export_freewheel_connection;
 
        void prepare_diskstreams ();
@@ -1111,7 +1114,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
                if (actively_recording()) {
                        return true;
                } else {
-                       if (Config->get_auto_input()) {
+                       if (config.get_auto_input()) {
                                return false;
                        } else {
                                return true;
@@ -1131,8 +1134,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        }
 
        bool maybe_stop (nframes_t limit) {
-               if (   (_transport_speed > 0.0f && _transport_frame >= limit)
-                   || (_transport_speed < 0.0f && _transport_frame == 0)    ) {
+               if ( (_transport_speed > 0.0f && _transport_frame >= limit)
+                               || (_transport_speed < 0.0f && _transport_frame == 0) ) {
                        stop_transport ();
                        return true;
                }
@@ -1167,15 +1170,13 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        std::string _current_snapshot_name;
 
-       XMLTree* state_tree;
-       bool     state_was_pending;
+       XMLTree*         state_tree;
+       bool             state_was_pending;
        StateOfTheState _state_of_the_state;
 
        void     auto_save();
        int      load_options (const XMLNode&);
-       XMLNode& get_options () const;
        int      load_state (std::string snapshot_name);
-       bool     save_config_options_predicate (ConfigVariableBase::Owner owner) const;
 
        nframes_t _last_roll_location;
        nframes_t _last_record_location;
@@ -1186,8 +1187,6 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        bool              pending_abort;
        bool              pending_auto_loop;
 
-       Sample*           butler_mixdown_buffer;
-       float*            butler_gain_buffer;
        pthread_t         butler_thread;
        Glib::Mutex       butler_request_lock;
        Glib::Cond        butler_paused;
@@ -1438,13 +1437,9 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        /* edit/mix groups */
 
-       int load_route_groups (const XMLNode&, bool is_edit);
-       int load_edit_groups (const XMLNode&);
-       int load_mix_groups (const XMLNode&);
+       int load_route_groups (const XMLNode&, int);
 
-
-       std::list<RouteGroup *> edit_groups;
-       std::list<RouteGroup *> mix_groups;
+       std::list<RouteGroup *> _route_groups;
 
        /* disk-streams */
 
@@ -1461,20 +1456,19 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        void add_routes (RouteList&, bool save);
        uint32_t destructive_index;
 
-       boost::shared_ptr<Route> XMLRouteFactory (const XMLNode&);
+       boost::shared_ptr<Route> XMLRouteFactory (const XMLNode&, int);
 
        /* mixer stuff */
 
-       bool       solo_update_disabled;
-       bool       currently_soloing;
+       bool solo_update_disabled;
 
+       void route_listen_changed (void *src, boost::weak_ptr<Route>);
        void route_mute_changed (void *src);
        void route_solo_changed (void *src, boost::weak_ptr<Route>);
-       void catch_up_on_solo ();
-       void catch_up_on_solo_mute_override ();
-       void update_route_solo_state ();
-       void modify_solo_mute (bool, bool);
-       void strip_portname_for_solo (std::string& portname);
+       void update_route_solo_state (boost::shared_ptr<RouteList> r = boost::shared_ptr<RouteList>());
+
+       void listen_position_changed ();
+       void solo_control_mode_changed ();
 
        /* REGION MANAGEMENT */
 
@@ -1491,6 +1485,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        int load_regions (const XMLNode& node);
 
+       void route_group_changed ();
+
        /* SOURCES */
 
        mutable Glib::Mutex source_lock;
@@ -1559,16 +1555,9 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
 
        /* INSERT AND SEND MANAGEMENT */
 
-       std::list<PortInsert *>              _port_inserts;
-       std::list<PluginInsert *>            _plugin_inserts;
-       std::list<Send *>                    _sends;
-       std::list<Return *>                  _returns;
        boost::dynamic_bitset<uint32_t> send_bitset;
        boost::dynamic_bitset<uint32_t> return_bitset;
        boost::dynamic_bitset<uint32_t> insert_bitset;
-       uint32_t                        send_cnt;
-       uint32_t                        insert_cnt;
-
 
        void add_processor (Processor *);
        void remove_processor (Processor *);
@@ -1644,15 +1633,15 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
                Click (nframes_t s, nframes_t d, const Sample *b)
                        : start (s), duration (d), data (b) { offset = 0; }
 
-               void *operator new(size_t ignored) {
+               void *operator new (size_t) {
                        return pool.alloc ();
                };
 
-               void operator delete(void *ptr, size_t size) {
+               void operator delete(void *ptr, size_t /*size*/) {
                        pool.release (ptr);
                }
 
-         private:
+       private:
                static Pool pool;
        };
 
@@ -1689,8 +1678,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        /* main outs */
        uint32_t main_outs;
 
-       boost::shared_ptr<IO> _master_out;
-       boost::shared_ptr<IO> _control_out;
+       boost::shared_ptr<Route> _master_out;
+       boost::shared_ptr<Route> _control_out;
 
        gain_t* _gain_automation_buffer;
        pan_t** _pan_automation_buffer;
@@ -1722,9 +1711,6 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        int find_all_sources (std::string path, std::set<std::string>& result);
        int find_all_sources_across_snapshots (std::set<std::string>& result, bool exclude_this_snapshot);
 
-       LayerModel layer_model;
-       CrossfadeModel xfade_model;
-
        typedef std::set<boost::shared_ptr<PBD::Controllable> > Controllables;
        Glib::Mutex controllables_lock;
        Controllables controllables;
@@ -1733,7 +1719,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        bool first_file_data_format_reset;
        bool first_file_header_format_reset;
 
-       void config_changed (const char*);
+       void config_changed (std::string, bool);
 
        XMLNode& get_control_protocol_state ();
 
@@ -1741,7 +1727,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        void sync_order_keys ();
 
        static bool _disable_all_loaded_plugins;
-       
+
        SessionMetadata * _metadata;
 
        mutable bool have_looped; ///< Used in ::audible_frame(*)