first vaguely working version using PresentationInfo
[ardour.git] / libs / ardour / ardour / track.h
index 5e05ec373c67173771dea9d10955c2633749b3c7..d57e0a2b5a9b33e1f69b3297a3db8b0ad065bca8 100644 (file)
@@ -22,6 +22,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include "ardour/interthread_info.h"
+#include "ardour/recordable.h"
 #include "ardour/route.h"
 #include "ardour/public_diskstream.h"
 
@@ -34,11 +35,17 @@ class Source;
 class Region;
 class Diskstream;
 class IO;
-
-class LIBARDOUR_API Track : public Route, public PublicDiskstream
+class MonitorControl;
+
+/** A track is an route (bus) with a recordable diskstream and
+ * related objects relevant to tracking, playback and editing.
+ *
+ * Specifically a track has regions and playlist objects.
+ */
+class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskstream
 {
   public:
-       Track (Session&, std::string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
+       Track (Session&, std::string name, PresentationInfo::Flag f = PresentationInfo::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
        virtual ~Track ();
 
        int init ();
@@ -51,13 +58,11 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
        virtual bool can_use_mode (TrackMode /*m*/, bool& /*bounce_required*/) { return false; }
        PBD::Signal0<void> TrackModeChanged;
 
-       virtual void set_monitoring (MonitorChoice);
-       MonitorChoice monitoring_choice() const { return _monitoring; }
-        MonitorState monitoring_state () const;
-       PBD::Signal0<void> MonitoringChanged;
+       boost::shared_ptr<MonitorControl> monitoring_control() const { return _monitoring_control; }
 
+       MonitorState monitoring_state () const;
        MeterState metering_state () const;
-       
+
        virtual int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
                             bool state_changing);
 
@@ -90,11 +95,32 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
        virtual void freeze_me (InterThreadInfo&) = 0;
        virtual void unfreeze () = 0;
 
-       /** @return true if the track can be bounced, or false otherwise.
+       /** Test if the track can be bounced with the given settings.
+        * If sends/inserts/returns are present in the signal path or the given track
+        * has no audio outputs bouncing is not possible.
+        *
+        * @param endpoint the processor to tap the signal off (or nil for the top)
+        * @param include_endpoint include the given processor in the bounced audio.
+        * @return true if the track can be bounced, or false otherwise.
         */
        virtual bool bounceable (boost::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
-       virtual boost::shared_ptr<Region> bounce (InterThreadInfo&) = 0;
-       virtual boost::shared_ptr<Region> bounce_range (framepos_t start, framepos_t end, InterThreadInfo&, 
+
+       /** bounce track from session start to session end to new region
+        *
+        * @param itt asynchronous progress report and cancel
+        * @return a new audio region (or nil in case of error)
+        */
+       virtual boost::shared_ptr<Region> bounce (InterThreadInfo& itt) = 0;
+
+       /** Bounce the given range to a new audio region.
+        * @param start start time (in samples)
+        * @param end end time (in samples)
+        * @param itt asynchronous progress report and cancel
+        * @param endpoint the processor to tap the signal off (or nil for the top)
+        * @param include_endpoint include the given processor in the bounced audio.
+        * @return a new audio region (or nil in case of error)
+        */
+       virtual boost::shared_ptr<Region> bounce_range (framepos_t start, framepos_t end, InterThreadInfo& itt,
                                                        boost::shared_ptr<Processor> endpoint, bool include_endpoint) = 0;
        virtual int export_stuff (BufferSet& bufs, framepos_t start_frame, framecnt_t nframes,
                                  boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
@@ -104,11 +130,12 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
        virtual int set_state (const XMLNode&, int version);
        static void zero_diskstream_id_in_xml (XMLNode&);
 
-       boost::shared_ptr<AutomationControl> rec_enable_control() { return _rec_enable_control; }
+       boost::shared_ptr<AutomationControl> rec_enable_control() const { return _record_enable_control; }
+       boost::shared_ptr<AutomationControl> rec_safe_control() const { return _record_safe_control; }
 
-       bool record_enabled() const;
-       void set_record_enabled (bool yn, void *src);
-       void prep_record_enabled (bool yn, void *src);
+       int prep_record_enabled (bool);
+       bool can_be_record_enabled ();
+       bool can_be_record_safe ();
 
        bool using_diskstream_id (PBD::ID) const;
 
@@ -164,7 +191,6 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
        PBD::Signal0<void> FreezeChange;
        /* Emitted when our diskstream is set to use a different playlist */
        PBD::Signal0<void> PlaylistChanged;
-       PBD::Signal0<void> RecordEnableChanged;
        PBD::Signal0<void> SpeedChanged;
        PBD::Signal0<void> AlignmentStyleChanged;
 
@@ -175,7 +201,7 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
        MeterPoint    _saved_meter_point;
        TrackMode     _mode;
        bool          _needs_butler;
-       MonitorChoice _monitoring;
+       boost::shared_ptr<MonitorControl> _monitoring_control;
 
        //private: (FIXME)
        struct FreezeRecordProcessorInfo {
@@ -200,15 +226,6 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
                FreezeState                        state;
        };
 
-       struct RecEnableControl : public AutomationControl {
-               RecEnableControl (boost::shared_ptr<Track> t);
-
-               void set_value (double);
-               double get_value (void) const;
-
-               boost::weak_ptr<Track> track;
-       };
-
        virtual void set_state_part_two () = 0;
 
        FreezeRecord          _freeze_record;
@@ -217,16 +234,20 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
 
        void maybe_declick (BufferSet&, framecnt_t, int);
 
-       boost::shared_ptr<RecEnableControl> _rec_enable_control;
-       
+       boost::shared_ptr<AutomationControl> _record_enable_control;
+       boost::shared_ptr<AutomationControl> _record_safe_control;
+
+       virtual void record_enable_changed (bool, PBD::Controllable::GroupControlDisposition);
+       virtual void record_safe_changed (bool, PBD::Controllable::GroupControlDisposition);
+
        framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&);
+       virtual void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
 
 private:
 
        virtual boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &) = 0;
-       
+
        void diskstream_playlist_changed ();
-       void diskstream_record_enable_changed ();
        void diskstream_speed_changed ();
        void diskstream_alignment_style_changed ();
        void parameter_changed (std::string const & p);