summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-02 16:40:24 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-02 16:40:24 +0000
commit95f1c2369ae46e79dbba7a03b283cb6d7f725aee (patch)
treeb9823e13887d7455da783e2d54aab3c8a16fbb3f /libs
parentd7b46c17ce1e7511d3e5dc264e789f4e865da4d8 (diff)
provide new cut_{front,end} region methods whose semantics for audio fade in/out are subtly different than trim_{front,end}
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5999 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/region.h3
-rw-r--r--libs/ardour/audioregion.cc19
-rw-r--r--libs/ardour/playlist.cc8
-rw-r--r--libs/ardour/region.cc55
4 files changed, 74 insertions, 11 deletions
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index bffd13ae1d..57691574cc 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -169,6 +169,9 @@ class Region : public PBD::StatefulDestructible, public Readable, public boost::
void trim_front (nframes_t new_position, void *src);
void trim_end (nframes_t new_position, void *src);
void trim_to (nframes_t position, nframes_t length, void *src);
+
+ void cut_front (nframes_t new_position, void *src);
+ void cut_end (nframes_t new_position, void *src);
void set_layer (layer_t l); /* ONLY Playlist can call this */
void raise ();
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 6163897b20..ad7a295907 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -181,7 +181,6 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t
_fade_in_disabled = 0;
_fade_out_disabled = 0;
-
if (_flags & LeftOfSplit) {
if (_fade_in.back()->when >= _length) {
set_default_fade_in ();
@@ -1141,15 +1140,18 @@ AudioRegion::recompute_at_end ()
_envelope.set_max_xval (_length);
_envelope.thaw ();
+ if (_flags & LeftOfSplit) {
+ set_default_fade_out ();
+ _flags = Flag (_flags & ~Region::LeftOfSplit);
+ } else if (_fade_out.back()->when > _length) {
+ _fade_out.extend_to (_length);
+ send_change (FadeOutChanged);
+ }
+
if (_fade_in.back()->when > _length) {
_fade_in.extend_to (_length);
send_change (FadeInChanged);
}
-
- if (_fade_out.back()->when > _length) {
- _fade_out.extend_to (_length);
- send_change (FadeOutChanged);
- }
}
void
@@ -1159,7 +1161,10 @@ AudioRegion::recompute_at_start ()
_envelope.truncate_start (_length);
- if (_fade_in.back()->when > _length) {
+ if (_flags & RightOfSplit) {
+ set_default_fade_in ();
+ _flags = Flag (_flags & ~Region::RightOfSplit);
+ } else if (_fade_in.back()->when > _length) {
_fade_in.extend_to (_length);
send_change (FadeInChanged);
}
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 44e28d37ed..9cc23b52b6 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -791,11 +791,11 @@ Playlist::partition_internal (nframes_t start, nframes_t end, bool cutting, Regi
new_regions.push_back (region);
/* "front" ***** */
-
+
current->freeze ();
thawlist.push_back (current);
- current->trim_end (pos2, this);
-
+ current->cut_end (pos2, this);
+
} else if (overlap == OverlapEnd) {
/*
@@ -823,7 +823,7 @@ Playlist::partition_internal (nframes_t start, nframes_t end, bool cutting, Regi
current->freeze ();
thawlist.push_back (current);
- current->trim_end (pos2, this);
+ current->cut_end (pos2, this);
} else if (overlap == OverlapStart) {
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 6a40a56127..cec56e2150 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -638,6 +638,45 @@ Region::trim_front (nframes_t new_position, void *src)
}
void
+Region::cut_front (nframes_t new_position, void *src)
+{
+ if (_flags & Locked) {
+ return;
+ }
+
+ nframes_t end = last_frame();
+ nframes_t source_zero;
+
+ if (_position > _start) {
+ source_zero = _position - _start;
+ } else {
+ source_zero = 0; // its actually negative, but this will work for us
+ }
+
+ if (new_position < end) { /* can't trim it zero or negative length */
+
+ nframes_t newlen;
+
+ /* can't trim it back passed where source position zero is located */
+
+ new_position = max (new_position, source_zero);
+
+
+ if (new_position > _position) {
+ newlen = _length - (new_position - _position);
+ } else {
+ newlen = _length + (_position - new_position);
+ }
+
+ trim_to_internal (new_position, newlen, src);
+ _flags = Flag (_flags | RightOfSplit); /* force reset of fade in */
+ if (!_frozen) {
+ recompute_at_start ();
+ }
+ }
+}
+
+void
Region::trim_end (nframes_t new_endpoint, void *src)
{
if (_flags & Locked) {
@@ -653,6 +692,22 @@ Region::trim_end (nframes_t new_endpoint, void *src)
}
void
+Region::cut_end (nframes_t new_endpoint, void *src)
+{
+ if (_flags & Locked) {
+ return;
+ }
+
+ if (new_endpoint > _position) {
+ trim_to_internal (_position, new_endpoint - _position +1, this);
+ _flags = Flag (_flags | LeftOfSplit); /* force reset of fade out */
+ if (!_frozen) {
+ recompute_at_end ();
+ }
+ }
+}
+
+void
Region::trim_to (nframes_t position, nframes_t length, void *src)
{
if (_flags & Locked) {