Fix a few return types.
[ardour.git] / libs / ardour / ardour / crossfade.h
index 9ba3689e823f1fb545d8b46ebd5aa2c205eb9d79..1c7075eb7dfc690d765ae82a9e42c5197944824d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000 Paul Davis 
+    Copyright (C) 2000 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include <algorithm>
 #include <boost/shared_ptr.hpp>
 
-#include <sigc++/signal.h>
 
-#include <pbd/undo.h>
-#include <pbd/statefuldestructible.h> 
+#include "pbd/undo.h"
+#include "pbd/statefuldestructible.h"
 
-#include <ardour/ardour.h>
-#include <ardour/curve.h>
-#include <ardour/audioregion.h>
-#include <ardour/crossfade_compare.h>
+#include "ardour/ardour.h"
+#include "ardour/audioregion.h"
+#include "evoral/Curve.hpp"
 
 namespace ARDOUR {
+       namespace Properties {
+               /* "active" is defined elsewhere but we use it with crossfade also */
+               extern PBD::PropertyDescriptor<bool> active;
+               extern PBD::PropertyDescriptor<bool> follow_overlap;
+       }
+
+enum AnchorPoint {
+       StartOfIn,
+       EndOfIn,
+       EndOfOut
+};
 
-class AudioRegion;
 class Playlist;
 
 class Crossfade : public ARDOUR::AudioRegion
@@ -44,48 +52,45 @@ class Crossfade : public ARDOUR::AudioRegion
   public:
 
        class NoCrossfadeHere: std::exception {
-         public:
+       public:
                virtual const char *what() const throw() { return "no crossfade should be constructed here"; }
        };
-       
+
        /* constructor for "fixed" xfades at each end of an internal overlap */
 
        Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out,
-                  nframes_t position,
-                  nframes_t initial_length,
+                  framecnt_t initial_length,
                   AnchorPoint);
 
        /* constructor for xfade between two regions that are overlapped in any way
           except the "internal" case.
        */
-       
+
        Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out, CrossfadeModel, bool active);
 
 
        /* copy constructor to copy a crossfade with new regions. used (for example)
-          when a playlist copy is made 
+          when a playlist copy is made
        */
        Crossfade (boost::shared_ptr<Crossfade>, boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>);
-       
+
        /* the usual XML constructor */
 
-       Crossfade (const Playlist&, XMLNode&);
+       Crossfade (const Playlist&, XMLNode const &);
        virtual ~Crossfade();
 
-       bool operator== (const ARDOUR::Crossfade&);
+       static void make_property_quarks ();
 
        XMLNode& get_state (void);
-       int set_state (const XMLNode&);
+       int set_state (const XMLNode&, int version);
 
        boost::shared_ptr<ARDOUR::AudioRegion> in() const { return _in; }
        boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
-       
-       nframes_t read_at (Sample *buf, Sample *mixdown_buffer, 
-                               float *gain_buffer, nframes_t position, nframes_t cnt, 
-                               uint32_t chan_n,
-                               nframes_t read_frames = 0,
-                               nframes_t skip_frames = 0) const;
-       
+
+       framecnt_t read_at (Sample *buf, Sample *mixdown_buffer,
+                           float *gain_buffer, framepos_t position, framecnt_t cnt,
+                           uint32_t chan_n) const;
+
        bool refresh ();
 
        uint32_t upper_layer () const {
@@ -104,20 +109,13 @@ class Crossfade : public ARDOUR::AudioRegion
                return (_in == a && _out == b) || (_in == b && _out == a);
        }
 
-       nframes_t overlap_length() const;
-
-       void invalidate();
+       framecnt_t overlap_length() const;
 
-       sigc::signal<void,boost::shared_ptr<Region> > Invalidated;
-       sigc::signal<void,Change>     StateChanged;
-
-       bool covers (nframes_t frame) const {
-               return _position <= frame && frame < _position + _length;
-       }
+       PBD::Signal1<void,boost::shared_ptr<Region> > Invalidated;
 
-       OverlapType coverage (nframes_t start, nframes_t end) const;
+       OverlapType coverage (framepos_t start, framepos_t end) const;
 
-       static void set_buffer_size (nframes_t);
+       static void set_buffer_size (framecnt_t);
 
        bool active () const { return _active; }
        void set_active (bool yn);
@@ -126,35 +124,35 @@ class Crossfade : public ARDOUR::AudioRegion
        bool can_follow_overlap() const;
        void set_follow_overlap (bool yn);
 
-       AutomationList& fade_in() { return _fade_in; } 
+       AutomationList& fade_in() { return _fade_in; }
        AutomationList& fade_out() { return _fade_out; }
 
-       nframes_t set_length (nframes_t);
+       framecnt_t set_xfade_length (framecnt_t);
 
        bool is_dependent() const { return true; }
-       bool depends_on (boost::shared_ptr<Region> other) const { 
-               return other == _in || other == _out; 
+       bool depends_on (boost::shared_ptr<Region> other) const {
+               return other == _in || other == _out;
        }
-       
-       static nframes_t short_xfade_length() { return _short_xfade_length; }
-       static void set_short_xfade_length (nframes_t n);
 
-       static Change ActiveChanged;
-       static Change FollowOverlapChanged;
+       static framecnt_t short_xfade_length() { return _short_xfade_length; }
+       static void set_short_xfade_length (framecnt_t n);
+
+       /** emitted when the actual fade curves change, as opposed to one of the Stateful properties */
+       PBD::Signal0<void> FadesChanged;
 
   private:
        friend struct CrossfadeComparePtr;
        friend class AudioPlaylist;
 
-       static nframes_t _short_xfade_length;
+       static framecnt_t _short_xfade_length;
 
        boost::shared_ptr<ARDOUR::AudioRegion> _in;
        boost::shared_ptr<ARDOUR::AudioRegion> _out;
-       bool                 _active;
+       PBD::Property<bool>  _active;
+       PBD::Property<bool>  _follow_overlap;
        bool                 _in_update;
        OverlapType           overlap_type;
        AnchorPoint          _anchor_point;
-       bool                 _follow_overlap;
        bool                 _fixed;
        int32_t               layer_relation;
 
@@ -166,14 +164,17 @@ class Crossfade : public ARDOUR::AudioRegion
        static Sample* crossfade_buffer_in;
 
        void initialize ();
+       void register_properties ();
        int  compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
        bool update ();
 
+       bool operator== (const ARDOUR::Crossfade&);
+
   protected:
-       nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const;      
+       framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int) const;
 };
 
 
 } // namespace ARDOUR
 
-#endif /* __ardour_overlap_h__ */      
+#endif /* __ardour_overlap_h__ */