meet rhythm ferret: cute, furry and always on time (ardour build now requires fftw3...
[ardour.git] / libs / ardour / ardour / session.h
index 92687c7dc0428fe2f443d3c4779869d4f21e1497..acb9f5f53f3e7227a266cbd850cd8d8a8565605c 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #ifndef __ardour_session_h__
@@ -126,6 +125,7 @@ class Session : public PBD::StatefulDestructible
                    SetDiskstreamSpeed,
                    Locate,
                    LocateRoll,
+                   LocateRollLocate,
                    SetLoop,
                    PunchIn,
                    PunchOut,
@@ -165,7 +165,7 @@ class Session : public PBD::StatefulDestructible
                        SlaveSource slave;
            };
 
-           boost::shared_ptr<Region>   region;
+           boost::shared_ptr<Region>     region;
 
            list<AudioRange>     audio_range;
            list<MusicRange>     music_range;
@@ -211,9 +211,9 @@ class Session : public PBD::StatefulDestructible
        /* creating from an XML file */
 
        Session (AudioEngine&,
-                string fullpath,
-                string snapshot_name,
-                string* mix_template = 0);
+                const string& fullpath,
+                const string& snapshot_name,
+                string mix_template = "");
 
        /* creating a new Session */
 
@@ -237,6 +237,7 @@ class Session : public PBD::StatefulDestructible
        string name() const { return _name; }
        string snap_name() const { return _current_snapshot_name; }
        string raid_path () const;
+       string export_dir () const;
 
        void set_snap_name ();
 
@@ -251,8 +252,11 @@ class Session : public PBD::StatefulDestructible
        std::string peak_dir () const;
        std::string dead_sound_dir () const;
        std::string automation_dir () const;
+       std::string analysis_dir() const;
+       
+       int ensure_subdirs ();
 
-       string peak_path_from_audio_path (string) const;
+       Glib::ustring peak_path (Glib::ustring) const;
 
        static string suffixed_search_path (std::string suffix, bool data);
        static string control_protocol_path ();
@@ -323,6 +327,8 @@ class Session : public PBD::StatefulDestructible
        void disable_record (bool rt_context, bool force = false);
        void step_back_from_record ();
        
+       void maybe_write_autosave ();
+
        /* Proxy signal for region hidden changes */
 
        sigc::signal<void,boost::shared_ptr<Region> > RegionHiddenChange;
@@ -333,7 +339,7 @@ class Session : public PBD::StatefulDestructible
        
        /* Record status signals */
 
-        sigc::signal<void> RecordStateChanged;
+       sigc::signal<void> RecordStateChanged;
 
        /* Transport mechanism signals */
 
@@ -341,10 +347,11 @@ class Session : public PBD::StatefulDestructible
        sigc::signal<void,nframes_t> PositionChanged; /* sent after any non-sequential motion */
        sigc::signal<void> DurationChanged;
        sigc::signal<void> HaltOnXrun;
+       sigc::signal<void> TransportLooped;
 
        sigc::signal<void,RouteList&> RouteAdded;
 
-       void request_roll ();
+       void request_roll_at_and_return (nframes_t start, nframes_t return_to);
        void request_bounded_roll (nframes_t start, nframes_t end);
        void request_stop (bool abort = false);
        void request_locate (nframes_t frame, bool with_roll = false);
@@ -358,6 +365,7 @@ class Session : public PBD::StatefulDestructible
        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 use_rf_shuttle_speed ();
+       void allow_auto_play (bool yn);
        void request_transport_speed (float speed);
        void request_overwrite_buffer (Diskstream*);
        void request_diskstream_speed (Diskstream&, float speed);
@@ -410,6 +418,9 @@ class Session : public PBD::StatefulDestructible
        int save_template (string template_name);
         int save_history (string snapshot_name = "");
         int restore_history (string snapshot_name);
+       void remove_state (string snapshot_name);
+       void rename_state (string old_name, string new_name);
+       void remove_pending_capture_state ();
 
        static int rename_template (string old_name, string new_name);
 
@@ -475,6 +486,8 @@ class Session : public PBD::StatefulDestructible
        void   resort_routes ();
        void   resort_routes_using (boost::shared_ptr<RouteList>);
 
+       void    set_remote_control_ids();
+
        AudioEngine &engine() { return _engine; };
 
        int32_t  max_level;
@@ -484,6 +497,7 @@ class Session : public PBD::StatefulDestructible
 
        nframes_t transport_frame () const {return _transport_frame; }
        nframes_t audible_frame () const;
+       nframes64_t requested_return_frame() const { return _requested_return_frame; }
 
        enum PullupFormat {
                pullup_Plus4Plus1,
@@ -528,6 +542,9 @@ class Session : public PBD::StatefulDestructible
        bool        transport_stopped() const { return _transport_speed == 0.0f; }
        bool        transport_rolling() const { return _transport_speed != 0.0f; }
 
+       void set_silent (bool yn);
+       bool silent () { return _silent; }
+
        int jack_slave_sync (nframes_t);
 
        TempoMap& tempo_map() { return *_tempo_map; }
@@ -554,17 +571,17 @@ class Session : public PBD::StatefulDestructible
            string doing_what;
            
            /* control info */
-           bool multichan;
            bool sample_convert;
+           SrcQuality quality;
            volatile bool freeze;
            std::vector<Glib::ustring> paths;
            
            /* result */
-           std::vector<boost::shared_ptr<AudioRegion> > new_regions;
+           SourceList sources;
            
        };
 
-       int import_audiofile (import_status&);
+       void import_audiofiles (import_status&);
        bool sample_rate_convert (import_status&, string infile, string& outfile);
        string build_tmp_convert_name (string file);
 
@@ -573,13 +590,14 @@ class Session : public PBD::StatefulDestructible
 
        int start_audio_export (ARDOUR::AudioExportSpecification&);
        int stop_audio_export (ARDOUR::AudioExportSpecification&);
-       
+       void finalize_audio_export ();
+
        void add_source (boost::shared_ptr<Source>);
        void remove_source (boost::weak_ptr<Source>);
 
        struct cleanup_report {
            vector<string> paths;
-           int32_t space;
+           int64_t space;
        };
 
        int  cleanup_sources (cleanup_report&);
@@ -606,6 +624,7 @@ class Session : public PBD::StatefulDestructible
        boost::shared_ptr<AudioFileSource> create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive);
 
        boost::shared_ptr<Source> source_by_id (const PBD::ID&);
+       boost::shared_ptr<Source> source_by_path_and_channel (const Glib::ustring&, uint16_t);
 
        /* playlist management */
 
@@ -663,6 +682,7 @@ class Session : public PBD::StatefulDestructible
        void set_all_mute (bool);
 
        sigc::signal<void,bool> SoloActive;
+       sigc::signal<void> SoloChanged;
        
        void record_disenable_all ();
        void record_enable_all ();
@@ -678,6 +698,13 @@ class Session : public PBD::StatefulDestructible
        uint32_t n_plugin_inserts() const { return _plugin_inserts.size(); }
        uint32_t n_sends() const { return _sends.size(); }
 
+       static void set_disable_all_loaded_plugins (bool yn) { 
+               _disable_all_loaded_plugins = yn;
+       }
+       static bool get_disable_all_loaded_plugins() { 
+               return _disable_all_loaded_plugins;
+       }
+
        uint32_t next_send_id();
        uint32_t next_insert_id();
        void mark_send_id (uint32_t);
@@ -720,6 +747,9 @@ class Session : public PBD::StatefulDestructible
 
        void deliver_midi (MIDI::Port*, MIDI::byte*, int32_t size);
 
+       void set_mmc_receive_device_id (uint32_t id);
+       void set_mmc_send_device_id (uint32_t id);
+       
        /* Scrubbing */
 
        void start_scrub (nframes_t where);
@@ -830,21 +860,6 @@ class Session : public PBD::StatefulDestructible
 
        boost::shared_ptr<IO>  click_io() { return _click_io; }
                
-       /* tempo FX */
-
-       struct TimeStretchRequest {
-           boost::shared_ptr<ARDOUR::AudioRegion> region;
-           float                fraction; /* session: read ; GUI: write */
-           float                progress; /* session: write ; GUI: read */
-           bool                 running;  /* read/write */
-           bool                 quick_seek; /* GUI: write */
-           bool                 antialias;  /* GUI: write */
-
-           TimeStretchRequest () {} 
-       };
-
-       boost::shared_ptr<AudioRegion> tempoize_region (TimeStretchRequest&);
-
        /* disk, buffer loads */
 
        uint32_t playback_load ();
@@ -900,12 +915,14 @@ class Session : public PBD::StatefulDestructible
                                  void* ptr,
                                  float opt);
 
-       typedef float (*compute_peak_t)                         (Sample *, nframes_t, float);
+       typedef float (*compute_peak_t)                 (Sample *, nframes_t, float);
+       typedef void  (*find_peaks_t)                   (Sample *, nframes_t, float *, float*);
        typedef void  (*apply_gain_to_buffer_t)         (Sample *, nframes_t, float);
        typedef void  (*mix_buffers_with_gain_t)        (Sample *, Sample *, nframes_t, float);
        typedef void  (*mix_buffers_no_gain_t)          (Sample *, Sample *, nframes_t);
 
-       static compute_peak_t                   compute_peak;
+       static compute_peak_t           compute_peak;
+       static find_peaks_t             find_peaks;
        static apply_gain_to_buffer_t   apply_gain_to_buffer;
        static mix_buffers_with_gain_t  mix_buffers_with_gain;
        static mix_buffers_no_gain_t    mix_buffers_no_gain;
@@ -935,7 +952,7 @@ class Session : public PBD::StatefulDestructible
        void update_latency_compensation (bool, bool);
        
   private:
-       int  create (bool& new_session, string* mix_template, nframes_t initial_length);
+       int  create (bool& new_session, const string& mix_template, nframes_t initial_length);
        void destroy ();
 
        nframes_t compute_initial_length ();
@@ -959,32 +976,35 @@ class Session : public PBD::StatefulDestructible
 
        typedef void (Session::*process_function_type)(nframes_t);
 
-       AudioEngine            &_engine;
-       mutable gint            processing_prohibited;
+       AudioEngine&            _engine;
+       mutable gint             processing_prohibited;
        process_function_type    process_function;
        process_function_type    last_process_function;
        bool                     waiting_for_sync_offset;
-       nframes_t          _base_frame_rate;
-       nframes_t          _current_frame_rate;  //this includes video pullup offset
+       nframes_t               _base_frame_rate;
+       nframes_t               _current_frame_rate;  //this includes video pullup offset
        int                      transport_sub_state;
-       mutable gint           _record_status;
-       nframes_t          _transport_frame;
+       mutable gint            _record_status;
+       volatile nframes_t      _transport_frame;
        Location*                end_location;
        Location*                start_location;
-       Slave                  *_slave;
+       Slave*                  _slave;
+       bool                    _silent;
        volatile float          _transport_speed;
        volatile float          _desired_transport_speed;
        float                   _last_transport_speed;
-       nframes_t          _last_slave_transport_frame;
-       nframes_t           maximum_output_latency;
-       nframes_t           last_stop_frame;
+       bool                     auto_play_legal;
+       nframes_t               _last_slave_transport_frame;
+       nframes_t                maximum_output_latency;
+       nframes_t                last_stop_frame;
+       volatile nframes64_t    _requested_return_frame;
        vector<Sample *>        _passthru_buffers;
        vector<Sample *>        _silent_buffers;
        vector<Sample *>        _send_buffers;
-       nframes_t           current_block_size;
-       nframes_t          _worst_output_latency;
-       nframes_t          _worst_input_latency;
-       nframes_t          _worst_track_latency;
+       nframes_t                current_block_size;
+       nframes_t               _worst_output_latency;
+       nframes_t               _worst_input_latency;
+       nframes_t               _worst_track_latency;
        bool                    _have_captured;
        float                   _meter_hold;
        float                   _meter_falloff;
@@ -1263,8 +1283,7 @@ class Session : public PBD::StatefulDestructible
        void mmc_record_pause (MIDI::MachineControl &);
        void mmc_record_strobe (MIDI::MachineControl &);
        void mmc_record_exit (MIDI::MachineControl &);
-       void mmc_track_record_status (MIDI::MachineControl &, 
-                                     uint32_t track, bool enabled);
+       void mmc_track_record_status (MIDI::MachineControl &, uint32_t track, bool enabled);
        void mmc_fast_forward (MIDI::MachineControl &);
        void mmc_rewind (MIDI::MachineControl &);
        void mmc_locate (MIDI::MachineControl &, const MIDI::byte *);
@@ -1425,7 +1444,7 @@ class Session : public PBD::StatefulDestructible
 
        SerializedRCUManager<RouteList>  routes;
 
-       void   add_routes (RouteList&, bool save = true);
+       void   add_routes (RouteList&, bool save);
        uint32_t destructive_index;
 
        int load_routes (const XMLNode&);
@@ -1483,7 +1502,7 @@ class Session : public PBD::StatefulDestructible
        boost::shared_ptr<Playlist> XMLPlaylistFactory (const XMLNode&);
 
        void playlist_length_changed ();
-       void diskstream_playlist_changed (boost::shared_ptr<Diskstream>);
+       void diskstream_playlist_changed (boost::weak_ptr<Diskstream>);
 
        /* NAMED SELECTIONS */
 
@@ -1561,7 +1580,9 @@ class Session : public PBD::StatefulDestructible
        static const char* dead_sound_dir_name;
        static const char* interchange_dir_name;
        static const char* peak_dir_name;
-
+       static const char* export_dir_name;
+       
+       string old_sound_dir (bool with_path = true) const;
        string discover_best_sound_dir (bool destructive = false);
        int ensure_sound_dir (string, string&);
        void refresh_disk_space ();
@@ -1595,6 +1616,7 @@ class Session : public PBD::StatefulDestructible
 
        void jack_timebase_callback (jack_transport_state_t, nframes_t, jack_position_t*, int);
        int  jack_sync_callback (jack_transport_state_t, jack_position_t*);
+       void reset_jack_connection (jack_client_t* jack);
        void record_enable_change_all (bool yn);
 
        XMLNode& state(bool);
@@ -1676,10 +1698,8 @@ class Session : public PBD::StatefulDestructible
           based on max (requested,available)
        */
 
-       uint32_t n_physical_outputs;
-       uint32_t n_physical_inputs;
-
-       void remove_pending_capture_state ();
+       uint32_t n_physical_audio_outputs;
+       uint32_t n_physical_audio_inputs;
 
        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);
@@ -1699,6 +1719,10 @@ class Session : public PBD::StatefulDestructible
 
        XMLNode& get_control_protocol_state ();
        
+       void set_history_depth (uint32_t depth);
+       void sync_order_keys ();
+
+       static bool _disable_all_loaded_plugins;
 };
 
 } // namespace ARDOUR