diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-10 16:19:13 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-10 16:19:13 +0000 |
commit | 1c167454eb2d498ed0ed453136ad3042aee0b556 (patch) | |
tree | 56b889a392cd0f9295359116d03c973a91ef881a /libs/ardour/crossfade.cc | |
parent | c9fd6da8b184831565fc74dd6a828596f5d77840 (diff) |
fix xfade logic and use shared_ptr for xfades
git-svn-id: svn://localhost/ardour2/trunk@1297 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/crossfade.cc')
-rw-r--r-- | libs/ardour/crossfade.cc | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index 9e36702705..d2d04f8dc7 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -20,6 +20,8 @@ #include <sigc++/bind.h> +#include <pbd/stacktrace.h> + #include <ardour/types.h> #include <ardour/crossfade.h> #include <ardour/crossfade_compare.h> @@ -80,6 +82,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio { _in = in; _out = out; + _length = length; _position = position; _anchor_point = ap; @@ -199,7 +202,8 @@ Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr<AudioRegion> newi Crossfade::~Crossfade () { - Invalidated (this); + cerr << "Crossfade deleted\n"; + notify_callbacks (); } void @@ -256,6 +260,8 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg /* first check for matching ends */ if (top->first_frame() == bottom->first_frame()) { + + cerr << "same start\n"; /* Both regions start at the same point */ @@ -297,6 +303,8 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg } else if (top->last_frame() == bottom->last_frame()) { + cerr << "same end\n"; + /* Both regions end at the same point */ if (top->first_frame() > bottom->first_frame()) { @@ -335,17 +343,21 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg OverlapType ot = top->coverage (bottom->first_frame(), bottom->last_frame()); + cerr << "ot = " << ot << endl; + switch (ot) { case OverlapNone: /* should be NOTREACHED as a precondition of creating a new crossfade, but we need to handle it here. */ + cerr << "no sir\n"; throw NoCrossfadeHere(); break; case OverlapInternal: case OverlapExternal: /* should be NOTREACHED because of tests above */ + cerr << "nu-uh\n"; throw NoCrossfadeHere(); break; @@ -357,15 +369,16 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg _in = bottom; _out = top; - _position = bottom->first_frame(); _anchor_point = StartOfIn; if (model == FullCrossfade) { + _position = bottom->first_frame(); // "{" _length = _out->first_frame() + _out->length() - _in->first_frame(); /* leave active alone */ _follow_overlap = true; } else { _length = min (short_xfade_length, top->length()); + _position = top->last_frame() - _length; // "]" - length _active = true; _follow_overlap = false; @@ -499,7 +512,13 @@ Crossfade::refresh () /* crossfades must be between non-muted regions */ if (_out->muted() || _in->muted()) { - Invalidated (this); + Invalidated (shared_from_this()); + return false; + } + + if (_in->layer() < _out->layer()) { + cerr << "layer change, invalidated\n"; + Invalidated (shared_from_this()); return false; } @@ -508,11 +527,11 @@ Crossfade::refresh () OverlapType ot; ot = _in->coverage (_out->first_frame(), _out->last_frame()); - + switch (ot) { case OverlapNone: case OverlapInternal: - Invalidated (this); + Invalidated (shared_from_this()); return false; default: @@ -522,7 +541,7 @@ Crossfade::refresh () /* overlap type must not have altered */ if (ot != overlap_type) { - Invalidated (this); + Invalidated (shared_from_this()); return false; } @@ -543,7 +562,7 @@ Crossfade::update (bool force) } if (newlen == 0) { - Invalidated (this); + Invalidated (shared_from_this()); return false; } @@ -563,7 +582,13 @@ Crossfade::update (bool force) switch (_anchor_point) { case StartOfIn: if (_position != _in->first_frame()) { - _position = _in->first_frame(); + if (_length > _short_xfade_length) { + /* assume FullCrossfade */ + _position = _in->first_frame(); + } else { + /* assume short xfade */ + _position = _out->last_frame() - _length; + } } break; @@ -865,5 +890,5 @@ Crossfade::set_short_xfade_length (nframes_t n) void Crossfade::invalidate () { - Invalidated (this); /* EMIT SIGNAL */ + Invalidated (shared_from_this()); /* EMIT SIGNAL */ } |