Update recorded MIDI regions as notes arrive. Fixes one cause of infinite note-lengt...
[ardour.git] / libs / ardour / ardour / region.h
index a30bb8660c7296f8e2b32b0ba601a136fde33625..ef86dce4b2c3984d6d9923920f07042c4e107c10 100644 (file)
 #include "ardour/ardour.h"
 #include "ardour/data_type.h"
 #include "ardour/automatable.h"
+#include "ardour/movable.h"
 #include "ardour/readable.h"
 #include "ardour/session_object.h"
+#include "ardour/trimmable.h"
 
 class XMLNode;
 
@@ -52,6 +54,7 @@ namespace Properties {
        extern PBD::PropertyDescriptor<bool> right_of_split;
        extern PBD::PropertyDescriptor<bool> hidden;
        extern PBD::PropertyDescriptor<bool> position_locked;
+       extern PBD::PropertyDescriptor<bool> valid_transients;
        extern PBD::PropertyDescriptor<framepos_t> start;
        extern PBD::PropertyDescriptor<framecnt_t> length;
        extern PBD::PropertyDescriptor<framepos_t> position;
@@ -61,11 +64,13 @@ namespace Properties {
        extern PBD::PropertyDescriptor<framecnt_t> ancestral_length;
        extern PBD::PropertyDescriptor<float> stretch;
        extern PBD::PropertyDescriptor<float> shift;
+       extern PBD::PropertyDescriptor<PositionLockStyle> position_lock_style;
 };
 
 class Playlist;
 class Filter;
 class ExportSpecification;
+class Progress;        
 
 enum RegionEditState {
        EditChangesNothing = 0,
@@ -78,27 +83,24 @@ class Region
        : public SessionObject
        , public boost::enable_shared_from_this<Region>
        , public Readable
+        , public Trimmable
+        , public Movable
 {
   public:
        typedef std::vector<boost::shared_ptr<Source> > SourceList;
 
        static void make_property_quarks ();
        
-       enum PositionLockStyle {
-               AudioTime,
-               MusicTime
-       };
-
        static PBD::Signal2<void,boost::shared_ptr<ARDOUR::Region>, const PBD::PropertyChange&> RegionPropertyChanged;
 
-        PBD::PropertyList* property_factory (const XMLNode&) const;
-
        virtual ~Region();
        
        /** Note: changing the name of a Region does not constitute an edit */
        bool set_name (const std::string& str);
 
        const DataType& data_type() const { return _type; }
+       
+       AnalysisFeatureList transients () { return _transients; };
 
        /** How the region parameters play together:
         *   
@@ -106,8 +108,8 @@ class Region
         * START:    first frame of the region within its source(s)
         * LENGTH:   number of frames the region represents
         */
-       sframes_t  position () const { return _position; }
-       sframes_t  start ()    const { return _start; }
+       framepos_t  position () const { return _position; }
+       framepos_t  start ()    const { return _start; }
        framecnt_t length()    const { return _length; }
        layer_t    layer ()    const { return _layer; }
 
@@ -115,15 +117,15 @@ class Region
 
        /* these two are valid ONLY during a StateChanged signal handler */
 
-       sframes_t  last_position() const { return _last_position; }
+       framepos_t  last_position() const { return _last_position; }
        framecnt_t last_length() const { return _last_length; }
 
-       sframes_t ancestral_start () const { return _ancestral_start; }
+       framepos_t ancestral_start () const { return _ancestral_start; }
        framecnt_t ancestral_length () const { return _ancestral_length; }
        float stretch() const { return _stretch; }
        float shift() const { return _shift; }
 
-       void set_ancestral_data (nframes64_t start, nframes64_t length, float stretch, float shift);
+       void set_ancestral_data (framepos_t start, framepos_t length, float stretch, float shift);
 
        frameoffset_t sync_offset(int& dir) const;
        framepos_t sync_position() const;
@@ -141,6 +143,7 @@ class Region
        bool opaque ()    const  { return _opaque; }
        bool locked()     const  { return _locked; }
        bool position_locked() const { return _position_locked; }
+       bool valid_transients() const { return _valid_transients; }
        bool automatic()  const  { return _automatic; }
        bool whole_file() const  { return _whole_file; }
        bool captured()   const  { return !(_import || _external); }
@@ -148,8 +151,10 @@ class Region
        bool sync_marked() const { return _sync_marked; }
        bool external() const    { return _external; }
        bool import() const      { return _import; }
+        
+        Trimmable::CanTrim can_trim() const;
 
-       PositionLockStyle positional_lock_style() const { return _positional_lock_style; }
+       PositionLockStyle position_lock_style() const { return _position_lock_style; }
        void set_position_lock_style (PositionLockStyle ps);
        void recompute_position_from_lock_style ();
 
@@ -207,7 +212,7 @@ class Region
        void set_locked (bool yn);
        void set_position_locked (bool yn);
 
-       int apply (Filter&);
+       int apply (Filter &, Progress* progress = 0);
 
        virtual uint64_t read_data_count() const { return _read_data_count; }
 
@@ -236,7 +241,7 @@ class Region
        /* serialization */
 
        XMLNode&         get_state ();
-       virtual XMLNode& state (bool);
+       virtual XMLNode& state ();
        virtual int      set_state (const XMLNode&, int version);
 
        virtual boost::shared_ptr<Region> get_parent() const;
@@ -249,12 +254,35 @@ class Region
 
        virtual int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&) = 0;
 
+       virtual void add_transient (framepos_t) {
+               // no transients, but its OK
+       }
+
+       virtual int update_transient (framepos_t /* old_position */, framepos_t /* new_position */) {
+               // no transients, but its OK
+               return 0;
+       }
+
+       virtual void remove_transient (framepos_t /* where */) {
+               // no transients, but its OK
+       }
+
+       virtual int set_transients (AnalysisFeatureList&) {
+               // no transients, but its OK
+               return 0;
+       }
+
        virtual int get_transients (AnalysisFeatureList&, bool force_new = false) {
                (void) force_new;
                // no transients, but its OK
                return 0;
        }
 
+       virtual int adjust_transients (framepos_t /*delta*/) {
+               // no transients, but its OK
+               return 0;
+       }
+
        virtual int separate_by_channel (ARDOUR::Session&,
                        std::vector< boost::shared_ptr<Region> >&) const {
                return 0;
@@ -321,23 +349,25 @@ class Region
        PBD::Property<bool>        _right_of_split;
        PBD::Property<bool>        _hidden;
        PBD::Property<bool>        _position_locked;
+       PBD::Property<bool>        _valid_transients;
        PBD::Property<framepos_t>  _start;
        PBD::Property<framecnt_t>  _length;
        PBD::Property<framepos_t>  _position;
+       /** Sync position relative to the start of our file */
        PBD::Property<framepos_t>  _sync_position;
        PBD::Property<layer_t>     _layer;
        PBD::Property<framepos_t>  _ancestral_start;
        PBD::Property<framecnt_t>  _ancestral_length;
        PBD::Property<float>       _stretch;
        PBD::Property<float>       _shift;
+       PBD::EnumProperty<PositionLockStyle> _position_lock_style;
 
        framecnt_t              _last_length;
        framepos_t              _last_position;
-       PositionLockStyle       _positional_lock_style;
        mutable RegionEditState _first_edit;
        BBT_Time                _bbt_time;
        AnalysisFeatureList     _transients;
-       bool                    _valid_transients;
+       
        mutable uint64_t        _read_data_count;  ///< modified in read()
        uint64_t                _last_layer_op;  ///< timestamp
        SourceList              _sources;
@@ -353,7 +383,7 @@ class Region
 
        void register_properties ();
 
-private:
+protected:
        void use_sources (SourceList const &);
 };