X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fcrossfade.h;h=1c7075eb7dfc690d765ae82a9e42c5197944824d;hb=184c7cedf9974ecce3445b2686a1ebb32703694c;hp=aea7b31852fb7c76821c5b6e49c865ea0601ca8e;hpb=30c08ba655330232767554c48bda1975bfb5628c;p=ardour.git diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index aea7b31852..1c7075eb7d 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -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 @@ -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__ @@ -23,80 +22,75 @@ #include #include +#include -#include -#include +#include "pbd/undo.h" +#include "pbd/statefuldestructible.h" -#include -#include -#include -#include -#include +#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 active; + extern PBD::PropertyDescriptor follow_overlap; + } -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; +enum AnchorPoint { + StartOfIn, + EndOfIn, + EndOfOut }; -class Crossfade : public Stateful, public StateManager +class Playlist; + +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 (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out, - jack_nframes_t position, - jack_nframes_t initial_length, + Crossfade (boost::shared_ptr in, boost::shared_ptr out, + framecnt_t initial_length, AnchorPoint); /* constructor for xfade between two regions that are overlapped in any way except the "internal" case. */ - - Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out, CrossfadeModel, bool active); + + Crossfade (boost::shared_ptr in, boost::shared_ptr out, CrossfadeModel, bool active); /* copy constructor to copy a crossfade with new regions. used (for example) - when a playlist copy is made */ - Crossfade (const Crossfade &, ARDOUR::AudioRegion *, ARDOUR::AudioRegion *); - + when a playlist copy is made + */ + Crossfade (boost::shared_ptr, boost::shared_ptr, boost::shared_ptr); + /* the usual XML constructor */ - Crossfade (const ARDOUR::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&); - - ARDOUR::AudioRegion& in() const { return *_in; } - 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, - uint32_t chan_n, - jack_nframes_t read_frames = 0, - jack_nframes_t skip_frames = 0); - + int set_state (const XMLNode&, int version); + + boost::shared_ptr in() const { return _in; } + boost::shared_ptr out() const { return _out; } + + 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 { @@ -107,30 +101,21 @@ class Crossfade : public Stateful, public StateManager return std::min (_in->layer(), _out->layer()); } - bool involves (ARDOUR::AudioRegion& region) const { - return _in == ®ion || _out == ®ion; + bool involves (boost::shared_ptr region) const { + return _in == region || _out == region; } - bool involves (ARDOUR::AudioRegion& a, ARDOUR::AudioRegion& b) const { - return (_in == &a && _out == &b) || (_in == &b && _out == &a); + bool involves (boost::shared_ptr a, boost::shared_ptr b) const { + 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; } - - sigc::signal Invalidated; - sigc::signal GoingAway; + framecnt_t overlap_length() const; - bool covers (jack_nframes_t frame) const { - return _position <= frame && frame < _position + _length; - } - - OverlapType coverage (jack_nframes_t start, jack_nframes_t end) const; + PBD::Signal1 > Invalidated; - UndoAction get_memento() const; + OverlapType coverage (framepos_t start, framepos_t end) const; - static void set_buffer_size (jack_nframes_t); + static void set_buffer_size (framecnt_t); bool active () const { return _active; } void set_active (bool yn); @@ -139,50 +124,57 @@ class Crossfade : public Stateful, public StateManager bool can_follow_overlap() const; void set_follow_overlap (bool yn); - Curve& fade_in() { return _fade_in; } - Curve& fade_out() { return _fade_out; } + AutomationList& fade_in() { return _fade_in; } + AutomationList& fade_out() { return _fade_out; } + + framecnt_t set_xfade_length (framecnt_t); - jack_nframes_t set_length (jack_nframes_t); - - static jack_nframes_t short_xfade_length() { return _short_xfade_length; } - static void set_short_xfade_length (jack_nframes_t n); + bool is_dependent() const { return true; } + bool depends_on (boost::shared_ptr other) const { + return other == _in || other == _out; + } + + static framecnt_t short_xfade_length() { return _short_xfade_length; } + static void set_short_xfade_length (framecnt_t n); - static Change ActiveChanged; + /** emitted when the actual fade curves change, as opposed to one of the Stateful properties */ + PBD::Signal0 FadesChanged; private: friend struct CrossfadeComparePtr; friend class AudioPlaylist; - static jack_nframes_t _short_xfade_length; + static framecnt_t _short_xfade_length; - ARDOUR::AudioRegion* _in; - ARDOUR::AudioRegion* _out; - bool _active; + boost::shared_ptr _in; + boost::shared_ptr _out; + PBD::Property _active; + PBD::Property _follow_overlap; bool _in_update; OverlapType overlap_type; - jack_nframes_t _length; - jack_nframes_t _position; AnchorPoint _anchor_point; - bool _follow_overlap; bool _fixed; - Curve _fade_in; - Curve _fade_out; + int32_t layer_relation; + + + mutable AutomationList _fade_in; + mutable AutomationList _fade_out; static Sample* crossfade_buffer_out; static Sample* crossfade_buffer_in; - void initialize (bool savestate=true); - int compute (ARDOUR::AudioRegion&, ARDOUR::AudioRegion&, CrossfadeModel); - bool update (bool force); - - StateManager::State* state_factory (std::string why) const; - Change restore_state (StateManager::State&); + void initialize (); + void register_properties (); + int compute (boost::shared_ptr, boost::shared_ptr, CrossfadeModel); + bool update (); - void member_changed (ARDOUR::Change); + bool operator== (const ARDOUR::Crossfade&); + protected: + framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int) const; }; } // namespace ARDOUR -#endif /* __ardour_overlap_h__ */ +#endif /* __ardour_overlap_h__ */