add libardour infrastructure for "fade range" edit operation
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 10 Jul 2014 12:16:55 +0000 (08:16 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 10 Jul 2014 12:16:55 +0000 (08:16 -0400)
libs/ardour/ardour/audioregion.h
libs/ardour/ardour/playlist.h
libs/ardour/ardour/region.h
libs/ardour/audioregion.cc
libs/ardour/playlist.cc

index b3bed8d5fd226f6b134edf618df4c92982069b1d..8e510b3e43cd25d41f2ec1f269c7427d634ba959 100644 (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;
 
index ababa600631d19f14e324b1e892d5dd8acb4ffa1..0cb68cd80511339e185c5742f68ba0e6aa65cf11 100644 (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);
index a66047a02a1a2d026df9b515f0c977a3f980e6af..a77d92fd9e7329068af645f9f8a54a1964329ff0 100644 (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);
 
index 2eb09ae192c1aa4c933083500101e8e51f874b49..630819d7c11cd10f5faad768036d6f1db65c5f81 100644 (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)
 {
index 266535da20ff15535007980bcc49a423068b2f5c..4214e9031d1db571dd01df7c6247db4302aca03f 100644 (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
 {