add libardour infrastructure for "fade range" edit operation

This commit is contained in:
Paul Davis 2014-07-10 08:16:55 -04:00
parent 94c8b672c4
commit 0622a0cc30
5 changed files with 43 additions and 0 deletions

View File

@ -115,6 +115,8 @@ class LIBARDOUR_API AudioRegion : public Region
XMLNode& get_basic_state ();
int set_state (const XMLNode&, int version);
void fade_range (framepos_t, framepos_t);
bool fade_in_is_default () const;
bool fade_out_is_default () const;

View File

@ -142,6 +142,7 @@ public:
void nudge_after (framepos_t start, framecnt_t distance, bool forwards);
boost::shared_ptr<Region> combine (const RegionList&);
void uncombine (boost::shared_ptr<Region>);
void fade_range (std::list<AudioRange>&);
void shuffle (boost::shared_ptr<Region>, int dir);
void ripple (framepos_t at, framecnt_t distance, RegionList *exclude);

View File

@ -224,6 +224,8 @@ class LIBARDOUR_API Region
void trim_end (framepos_t new_position);
void trim_to (framepos_t position, framecnt_t length);
virtual void fade_range (framepos_t, framepos_t) {}
void cut_front (framepos_t new_position);
void cut_end (framepos_t new_position);

View File

@ -957,6 +957,34 @@ AudioRegion::set_state (const XMLNode& node, int version)
return _set_state (node, version, what_changed, true);
}
void
AudioRegion::fade_range (framepos_t start, framepos_t end)
{
framepos_t s, e;
switch (coverage (start, end)) {
case Evoral::OverlapStart:
s = _position;
e = end;
set_fade_in (FadeConstantPower, e - s);
break;
case Evoral::OverlapEnd:
s = start;
e = _position + _length;
set_fade_out (FadeConstantPower, e - s);
break;
case Evoral::OverlapInternal:
/* needs addressing, perhaps. Difficult to do if we can't
* control one edge of the fade relative to the relevant edge
* of the region, which we cannot - fades are currently assumed
* to start/end at the start/end of the region
*/
break;
default:
return;
}
}
void
AudioRegion::set_fade_in_shape (FadeShape shape)
{

View File

@ -3123,6 +3123,16 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
thaw ();
}
void
Playlist::fade_range (list<AudioRange>& ranges)
{
for (list<AudioRange>::iterator r = ranges.begin(); r != ranges.end(); ++r) {
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
(*i)->fade_range ((*r).start, (*r).end);
}
}
}
uint32_t
Playlist::max_source_level () const
{