Use PBD::copy_file in Session::create() to copy the template file.
[ardour.git] / libs / ardour / ardour / crossfade.h
index ded41bbfdadcd596ca9f4707fe3aba441e3c0b7b..7346e645fb136e8fbf795258ab2ec597eebe6ff3 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_overlap_h__
@@ -24,6 +23,7 @@
 #include <vector>
 #include <algorithm>
 #include <boost/shared_ptr.hpp>
+#include <boost/enable_shared_from_this.hpp>
 
 #include <sigc++/signal.h>
 
@@ -33,7 +33,6 @@
 #include <ardour/ardour.h>
 #include <ardour/curve.h>
 #include <ardour/audioregion.h>
-#include <ardour/state_manager.h>
 #include <ardour/crossfade_compare.h>
 
 namespace ARDOUR {
@@ -41,19 +40,7 @@ namespace ARDOUR {
 class AudioRegion;
 class Playlist;
 
-struct CrossfadeState : public StateManager::State {
-    CrossfadeState (std::string reason) : StateManager::State (reason) {}
-
-    UndoAction fade_in_memento;
-    UndoAction fade_out_memento;
-    jack_nframes_t position;
-    jack_nframes_t length;
-    AnchorPoint    anchor_point;
-    bool           follow_overlap;
-    bool           active;
-};
-
-class Crossfade : public PBD::StatefulDestructible, public StateManager
+class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_from_this<ARDOUR::Crossfade>
 {
   public:
 
@@ -65,8 +52,8 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
        /* constructor for "fixed" xfades at each end of an internal overlap */
 
        Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out,
-                  jack_nframes_t position,
-                  jack_nframes_t initial_length,
+                  nframes_t position,
+                  nframes_t initial_length,
                   AnchorPoint);
 
        /* constructor for xfade between two regions that are overlapped in any way
@@ -77,12 +64,13 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
 
 
        /* 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 (const Crossfade &, boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>);
        
        /* the usual XML constructor */
 
-       Crossfade (const ARDOUR::Playlist&, XMLNode&);
+       Crossfade (const Playlist&, XMLNode&);
        virtual ~Crossfade();
 
        bool operator== (const ARDOUR::Crossfade&);
@@ -93,11 +81,11 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
        boost::shared_ptr<ARDOUR::AudioRegion> in() const { return _in; }
        boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
        
-       jack_nframes_t read_at (Sample *buf, Sample *mixdown_buffer, 
-                               float *gain_buffer, jack_nframes_t position, jack_nframes_t cnt, 
+       nframes_t read_at (Sample *buf, Sample *mixdown_buffer, 
+                               float *gain_buffer, nframes_t position, nframes_t cnt, 
                                uint32_t chan_n,
-                               jack_nframes_t read_frames = 0,
-                               jack_nframes_t skip_frames = 0);
+                               nframes_t read_frames = 0,
+                               nframes_t skip_frames = 0);
        
        bool refresh ();
 
@@ -117,21 +105,22 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
                return (_in == a && _out == b) || (_in == b && _out == a);
        }
 
-       jack_nframes_t length() const { return _length; }
-       jack_nframes_t overlap_length() const;
-       jack_nframes_t position() const { return _position; }
+       nframes_t length() const { return _length; }
+       nframes_t overlap_length() const;
+       nframes_t position() const { return _position; }
+
+       void invalidate();
 
-       sigc::signal<void,Crossfade*> Invalidated;
+       sigc::signal<void,boost::shared_ptr<Crossfade> > Invalidated;
+       sigc::signal<void,Change>     StateChanged;
 
-       bool covers (jack_nframes_t frame) const {
+       bool covers (nframes_t frame) const {
                return _position <= frame && frame < _position + _length;
        }
 
-       OverlapType coverage (jack_nframes_t start, jack_nframes_t end) const;
+       OverlapType coverage (nframes_t start, nframes_t end) const;
 
-       UndoAction get_memento() const; 
-
-       static void set_buffer_size (jack_nframes_t);
+       static void set_buffer_size (nframes_t);
 
        bool active () const { return _active; }
        void set_active (bool yn);
@@ -143,44 +132,40 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
        Curve& fade_in() { return _fade_in; } 
        Curve& fade_out() { return _fade_out; }
 
-       jack_nframes_t set_length (jack_nframes_t);
+       nframes_t set_length (nframes_t);
        
-       static jack_nframes_t short_xfade_length() { return _short_xfade_length; }
-       static void set_short_xfade_length (jack_nframes_t n);
+       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;
 
   private:
        friend struct CrossfadeComparePtr;
        friend class AudioPlaylist;
 
-       static jack_nframes_t _short_xfade_length;
+       static nframes_t _short_xfade_length;
 
        boost::shared_ptr<ARDOUR::AudioRegion> _in;
        boost::shared_ptr<ARDOUR::AudioRegion> _out;
        bool                 _active;
        bool                 _in_update;
        OverlapType           overlap_type;
-       jack_nframes_t       _length;
-       jack_nframes_t       _position;
+       nframes_t       _length;
+       nframes_t       _position;
        AnchorPoint          _anchor_point;
        bool                 _follow_overlap;
        bool                 _fixed;
+       int32_t               layer_relation;
        Curve _fade_in;
        Curve _fade_out;
 
        static Sample* crossfade_buffer_out;
        static Sample* crossfade_buffer_in;
 
-       void initialize (bool savestate=true);
+       void initialize ();
        int  compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
-       bool update (bool force);
-
-       StateManager::State* state_factory (std::string why) const;
-       Change restore_state (StateManager::State&);
-
-       void member_changed (ARDOUR::Change);
-
+       bool update ();
 };