Make time stretch respect edit groups (#4615).
authorCarl Hetherington <carl@carlh.net>
Tue, 24 Jan 2012 17:04:15 +0000 (17:04 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 24 Jan 2012 17:04:15 +0000 (17:04 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11334 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_timefx.cc
gtk2_ardour/time_fx_dialog.cc
gtk2_ardour/time_fx_dialog.h
libs/ardour/ardour/pitch.h
libs/ardour/rb_effect.cc
libs/ardour/st_pitch.cc
libs/ardour/st_stretch.cc

index 5201d3346df98d3bae2661067ea0a1b6b9f79439..dd4249f59756f6936e6f9b540a6bf520b13a8d50 100644 (file)
@@ -3292,7 +3292,9 @@ TimeFXDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
        RegionSelection rs;
        rs.add (_primary);
 
-       if (_editor->time_stretch (rs, percentage) == -1) {
+       RegionSelection all = _editor->get_equivalent_regions (rs, ARDOUR::Properties::edit.property_id);
+
+       if (_editor->time_stretch (all, percentage) == -1) {
                error << _("An error occurred while executing time stretch operation") << endmsg;
        }
 }
index 1c4162eda2c9e4735dc7d63f6970e05f1a95b922..830d8999a445b4cb67b496b7176f88385bcc054d 100644 (file)
@@ -107,8 +107,6 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
 
        current_timefx = new TimeFXDialog (*this, pitching);
 
-       current_timefx->progress_bar.set_fraction (0.0f);
-
        switch (current_timefx->run ()) {
        case RESPONSE_ACCEPT:
                break;
@@ -234,7 +232,6 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
        current_timefx->request.quick_seek = current_timefx->quick_button.get_active();
        current_timefx->request.antialias = !current_timefx->antialias_button.get_active();
 #endif
-       current_timefx->request.progress = 0.0f;
        current_timefx->request.done = false;
        current_timefx->request.cancel = false;
 
@@ -256,14 +253,10 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
 
        pthread_detach (current_timefx->request.thread);
 
-       sigc::connection c = Glib::signal_timeout().connect (sigc::mem_fun (current_timefx, &TimeFXDialog::update_progress), 100);
-
        while (!current_timefx->request.done && !current_timefx->request.cancel) {
                gtk_main_iteration ();
        }
 
-       c.disconnect ();
-
        current_timefx->hide ();
        return current_timefx->status;
 }
@@ -276,6 +269,8 @@ Editor::do_timefx (TimeFXDialog& dialog)
        boost::shared_ptr<Region>   new_region;
        bool in_command = false;
 
+       uint32_t const N = dialog.regions.size ();
+
        for (RegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) {
                AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*i);
 
@@ -324,7 +319,9 @@ Editor::do_timefx (TimeFXDialog& dialog)
 #endif
                }
 
-               if (fx->run (region)) {
+               current_timefx->descend (1.0 / N);
+
+               if (fx->run (region, current_timefx)) {
                        dialog.status = -1;
                        dialog.request.done = true;
                        delete fx;
@@ -344,6 +341,8 @@ Editor::do_timefx (TimeFXDialog& dialog)
                        _session->add_command (new StatefulDiffCommand (playlist));
                }
 
+               current_timefx->ascend ();
+
                i = tmp;
                delete fx;
        }
index de5786c98221876db7cf823a1c3864814b35b4a6..97e661df84d61fa6f57a47a3828c45cd16f866d8 100644 (file)
@@ -186,11 +186,10 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch)
        show_all_children ();
 }
 
-gint
-TimeFXDialog::update_progress ()
+void
+TimeFXDialog::update_progress_gui (float p)
 {
-       progress_bar.set_fraction (request.progress);
-       return !request.done;
+       progress_bar.set_fraction (p);
 }
 
 void
index aee9d40b161fc7c01ee6096427dce4d7f32be8db..20b0538a7fa6dd9ca1972816aaf3340fa21f4fa4 100644 (file)
 
 #include "ardour_dialog.h"
 #include "region_selection.h"
+#include "progress_reporter.h"
 
 class Editor;
 
-struct TimeFXDialog : public ArdourDialog {
+class TimeFXDialog : public ArdourDialog, public ProgressReporter
+{
+public:
     ARDOUR::TimeFXRequest request;
     Editor&               editor;
     bool                  pitching;
@@ -58,11 +61,14 @@ struct TimeFXDialog : public ArdourDialog {
 
     TimeFXDialog (Editor& e, bool for_pitch);
 
-    gint update_progress ();
     sigc::connection first_cancel;
     sigc::connection first_delete;
     void cancel_in_progress ();
     gint delete_in_progress (GdkEventAny*);
+
+private:
+       
+    void update_progress_gui (float);
 };
 
 #endif /* __ardour_time_fx_dialog_h__ */
index 8c7718f685eeabe6d5d0833b7b260756dccbcbc5..3bb179127e20e10c05326a3085f11aaf30b7a021 100644 (file)
@@ -53,7 +53,7 @@ class Pitch : public Filter {
        Pitch (ARDOUR::Session&, TimeFXRequest&);
        ~Pitch () {}
 
-       int run (boost::shared_ptr<ARDOUR::Region>);
+       int run (boost::shared_ptr<ARDOUR::Region>, Progress *);
 
   private:
        TimeFXRequest& tsr;
index e90149926c86bbdd0f69aad65ea93b9670af00c0..d928377e2523aa38758d190941a128937a0f7021 100644 (file)
@@ -29,6 +29,7 @@
 #include "ardour/audiofilesource.h"
 #include "ardour/session.h"
 #include "ardour/audioregion.h"
+#include "ardour/progress.h"
 
 #include "i18n.h"
 
@@ -52,7 +53,7 @@ RBEffect::RBEffect (Session& s, TimeFXRequest& req)
        , tsr (req)
 
 {
-       tsr.progress = 0.0f;
+
 }
 
 RBEffect::~RBEffect ()
@@ -60,7 +61,7 @@ RBEffect::~RBEffect ()
 }
 
 int
-RBEffect::run (boost::shared_ptr<Region> r, Progress*)
+RBEffect::run (boost::shared_ptr<Region> r, Progress* progress)
 {
        boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (r);
 
@@ -160,7 +161,7 @@ RBEffect::run (boost::shared_ptr<Region> r, Progress*)
                (session.frame_rate(), channels,
                 (RubberBandStretcher::Options) tsr.opts, stretch, shift);
 
-       tsr.progress = 0.0f;
+       progress->set_progress (0);
        tsr.done = false;
 
        stretcher.setExpectedInputDuration(read_duration);
@@ -238,7 +239,7 @@ RBEffect::run (boost::shared_ptr<Region> r, Progress*)
                        pos += this_read;
                        done += this_read;
 
-                       tsr.progress = ((float) done / read_duration) * 0.25;
+                       progress->set_progress (((float) done / read_duration) * 0.25);
 
                        stretcher.study(buffers, this_read, pos == read_duration);
                }
@@ -279,7 +280,7 @@ RBEffect::run (boost::shared_ptr<Region> r, Progress*)
                        pos += this_read;
                        done += this_read;
 
-                       tsr.progress = 0.25 + ((float) done / read_duration) * 0.75;
+                       progress->set_progress (0.25 + ((float) done / read_duration) * 0.75);
 
                        stretcher.process(buffers, this_read, pos == read_duration);
 
index 307a41cbf7933ba440e35e1dda6432a0152f0a36..8e65ea2b5639016e54b74932fbd81b938095659d 100644 (file)
@@ -39,13 +39,12 @@ Pitch::Pitch (Session& s, TimeFXRequest& req)
        , tsr (req)
 
 {
-       tsr.progress = 0.0f;
+
 }
 
 int
 Pitch::run (boost::shared_ptr<Region> region)
 {
-       tsr.progress = 1.0f;
        tsr.done = true;
 
        return 1;
index 3660ff34d385431923e5932b8f472958242b63ab..d8009c1218113929651bbab065c144cd6830c1f6 100644 (file)
@@ -56,7 +56,6 @@ STStretch::STStretch (Session& s, TimeFXRequest& req)
        st.setSetting(SETTING_USE_QUICKSEEK, tsr.quick_seek);
        st.setSetting(SETTING_USE_AA_FILTER, tsr.antialias);
 
-       tsr.progress = 0.0f;
 }
 
 STStretch::~STStretch ()
@@ -64,7 +63,7 @@ STStretch::~STStretch ()
 }
 
 int
-STStretch::run (boost::shared_ptr<Region> a_region)
+STStretch::run (boost::shared_ptr<Region> a_region, Progress* progress)
 {
        SourceList nsrcs;
        framecnt_t total_frames;
@@ -77,7 +76,7 @@ STStretch::run (boost::shared_ptr<Region> a_region)
        string new_name;
        string::size_type at;
 
-       tsr.progress = 0.0f;
+       progress->set_progress (0);
        tsr.done = false;
 
        boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(a_region);
@@ -131,7 +130,7 @@ STStretch::run (boost::shared_ptr<Region> a_region)
                                pos += this_read;
                                done += this_read;
 
-                               tsr.progress = (float) done / total_frames;
+                               progress->set_progress ((float) done / total_frames);
 
                                st.putSamples (buffer, this_read);