Fix the horrible mess that was anything related to sources and paths.
[ardour.git] / libs / ardour / ardour / region.h
index 76b41a04cbb8f4fb9a29f2c61322a4657b368214..b55d77f4990ffed8e129d62f0c77fc197cf5747d 100644 (file)
@@ -29,6 +29,8 @@
 #include <ardour/ardour.h>
 #include <ardour/data_type.h>
 #include <ardour/automatable.h>
+#include <ardour/readable.h>
+#include <ardour/session_object.h>
 
 class XMLNode;
 
@@ -36,6 +38,7 @@ namespace ARDOUR {
 
 class Playlist;
 class Filter;
+class ExportSpecification;
 
 enum RegionEditState {
        EditChangesNothing = 0,
@@ -43,7 +46,10 @@ enum RegionEditState {
        EditChangesID      = 2
 };
 
-class Region : public Automatable, public boost::enable_shared_from_this<Region>
+class Region
+               : public SessionObject
+               , public boost::enable_shared_from_this<Region>
+               , public Readable
 {
   public:
        typedef std::vector<boost::shared_ptr<Source> > SourceList;
@@ -72,6 +78,11 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
                range_guarantoor = USHRT_MAX
        };
 
+       enum PositionLockStyle {
+               AudioTime,
+               MusicTime
+       };
+
        static const Flag DefaultFlags = Flag (Opaque|DefaultFadeIn|DefaultFadeOut|FadeIn|FadeOut);
 
        static Change FadeChanged;
@@ -83,6 +94,7 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        static Change HiddenChanged;
 
        sigc::signal<void,Change> StateChanged;
+       static sigc::signal<void,boost::shared_ptr<ARDOUR::Region> > RegionPropertyChanged;
 
        virtual ~Region();
 
@@ -91,6 +103,16 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
 
        const DataType& data_type() const { return _type; }
 
+       /**
+        * Thats how the region parameters play together:
+        * <PRE>
+        * |------------------------------------------------------------------- track
+        *                    |..........[------------------].....| region
+        * |-----------------------------| _position
+        *                               |------------------| _length
+        *                    |----------| _start
+        * </PRE>
+        */
        nframes_t position () const { return _position; }
        nframes_t start ()    const { return _start; }
        nframes_t length()    const { return _length; }
@@ -110,8 +132,9 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
 
        nframes_t sync_offset(int& dir) const;
        nframes_t sync_position() const;
+       nframes_t sync_point () const;
 
-       nframes_t adjust_to_sync (nframes_t);
+       nframes_t adjust_to_sync (nframes_t) const;
        
        /* first_frame() is an alias; last_frame() just hides some math */
 
@@ -129,6 +152,10 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        bool captured()   const { return !(_flags & (Region::Flag (Region::Import|Region::External))); }
        bool can_move()   const { return !(_flags & (Locked|PositionLocked)); }
 
+       PositionLockStyle positional_lock_style() const { return _positional_lock_style; }
+       void set_position_lock_style (PositionLockStyle ps);
+       void recompute_position_from_lock_style ();
+
        virtual bool should_save_state () const { return !(_flags & DoNotSaveState); };
 
        void freeze ();
@@ -155,6 +182,7 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        void set_position (nframes_t, void *src);
        void set_position_on_top (nframes_t, void *src);
        void special_set_position (nframes_t);
+       void update_position_after_tempo_map_change ();
        void nudge_position (nframes64_t, void *src);
 
        bool at_natural_position () const;
@@ -195,7 +223,15 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        const SourceList& master_sources() const { return _master_sources; }
 
        std::vector<string> master_source_names();
-       void set_master_sources (SourceList&);
+       void set_master_sources (const SourceList&);
+       
+       /* automation */
+       
+       virtual boost::shared_ptr<Evoral::Control>
+       control(const Evoral::Parameter& id, bool create=false) = 0;
+
+       virtual boost::shared_ptr<const Evoral::Control>
+       control(const Evoral::Parameter& id) const = 0;
        
        /* serialization */
        
@@ -212,29 +248,45 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        virtual bool is_dependent() const { return false; }
        virtual bool depends_on (boost::shared_ptr<Region> other) const { return false; }
 
+       virtual int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&) = 0;
+
+       virtual int get_transients (AnalysisFeatureList&, bool force_new = false) { 
+               // no transients, but its OK
+               return 0;
+       }
+       
+       virtual int separate_by_channel (ARDOUR::Session&,
+                       std::vector< boost::shared_ptr<Region> >&) const {
+               return 0;
+       }
+
+       void invalidate_transients ();  
+
   protected:
        friend class RegionFactory;
 
        Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length, 
                const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
-       Region (SourceList& srcs, nframes_t start, nframes_t length, 
+       Region (const SourceList& srcs, nframes_t start, nframes_t length, 
                const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
        
        Region (boost::shared_ptr<const Region>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Flag flags = DefaultFlags);
+       Region (boost::shared_ptr<const Region>, nframes_t length, const string& name, layer_t = 0, Flag flags = DefaultFlags);
        Region (boost::shared_ptr<const Region>);
        Region (boost::shared_ptr<Source> src, const XMLNode&);
-       Region (SourceList& srcs, const XMLNode&);
-
-       /* this one is for derived types of derived types */
+       Region (const SourceList& srcs, const XMLNode&);
 
        Region (Session& s, nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags);
 
   protected:
+       void copy_stuff (boost::shared_ptr<const Region>, nframes_t start, nframes_t length, const string& name, layer_t, Flag flags);
+
        XMLNode& get_short_state (); /* used only by Session */
 
        void send_change (Change);
 
        void trim_to_internal (nframes_t position, nframes_t length, void *src);
+       void set_position_internal (nframes_t pos, bool allow_bbt_recompute);
 
        bool copied() const { return _flags & Copied; }
        void maybe_uncopy ();
@@ -255,6 +307,7 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        nframes_t               _last_length;
        nframes_t               _position;
        nframes_t               _last_position;
+       PositionLockStyle       _positional_lock_style;
        nframes_t               _sync_position;
        layer_t                 _layer;
        mutable RegionEditState _first_edit;
@@ -263,6 +316,9 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
        nframes64_t             _ancestral_length;
        float                   _stretch;
        float                   _shift;
+       BBT_Time                _bbt_time;
+       AnalysisFeatureList     _transients;
+       bool                    _valid_transients;
        mutable uint32_t        _read_data_count;  ///< modified in read()
        Change                  _pending_changed;
        uint64_t                _last_layer_op;  ///< timestamp