Give group and meter point buttons controllable visibility.
[ardour.git] / gtk2_ardour / editor_timefx.cc
index 88889a4745272b2e96ff55b46605cb31c7e3aafd..1c4162eda2c9e4735dc7d63f6970e05f1a95b922 100644 (file)
@@ -20,6 +20,7 @@
 #include <iostream>
 #include <cstdlib>
 #include <cmath>
+#include <ctime>
 
 #include <string>
 
@@ -73,15 +74,14 @@ Editor::time_stretch (RegionSelection& regions, float fraction)
                if (!rtv)
                        return -1;
 
-               boost::shared_ptr<Playlist> playlist
-                       = rtv->track()->playlist();
+               boost::shared_ptr<Playlist> playlist = rtv->track()->playlist();
 
-           ARDOUR::TimeFXRequest request;
+               ARDOUR::TimeFXRequest request;
                request.time_fraction = fraction;
                MidiStretch stretch(*_session, request);
                begin_reversible_command ("midi stretch");
                stretch.run(regions.front()->region());
-                playlist->clear_history ();
+                playlist->clear_changes ();
                playlist->replace_region (regions.front()->region(), stretch.results[0],
                                regions.front()->region()->position());
                _session->add_command (new StatefulDiffCommand (playlist));
@@ -97,7 +97,9 @@ Editor::pitch_shift (RegionSelection& regions, float fraction)
        return time_fx (regions, fraction, true);
 }
 
-/** @return -1 in case of error, 1 if operation was cancelled by the user, 0 if everything went ok */
+/** @param val Percentage to time stretch by; ignored if pitch-shifting.
+ *  @param pitching true to pitch shift, false to time stretch.
+ *  @return -1 in case of error, 1 if operation was cancelled by the user, 0 if everything went ok */
 int
 Editor::time_fx (RegionSelection& regions, float val, bool pitching)
 {
@@ -177,22 +179,22 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
                        break;
                }
        }
-       
+
        switch (rb_current_opt) {
                case 0:
-                       transients = NoTransients; peaklock = false; longwin = true; shortwin = false; 
+                       transients = NoTransients; peaklock = false; longwin = true; shortwin = false;
                        break;
                case 1:
-                       transients = NoTransients; peaklock = false; longwin = false; shortwin = false; 
+                       transients = NoTransients; peaklock = false; longwin = false; shortwin = false;
                        break;
                case 2:
-                       transients = NoTransients; peaklock = true; longwin = false; shortwin = false; 
+                       transients = NoTransients; peaklock = true; longwin = false; shortwin = false;
                        break;
                case 3:
-                       transients = BandLimitedTransients; peaklock = true; longwin = false; shortwin = false; 
+                       transients = BandLimitedTransients; peaklock = true; longwin = false; shortwin = false;
                        break;
                case 5:
-                       transients = Transients; peaklock = false; longwin = false; shortwin = true; 
+                       transients = Transients; peaklock = false; longwin = false; shortwin = true;
                        break;
                case 6:
                        transients = NoTransients;
@@ -203,8 +205,8 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
                        // peaklock = false;
                        break;
                default:
-                       /* default/4 */ 
-                       transients = Transients; peaklock = true; longwin = false; shortwin = false; 
+                       /* default/4 */
+                       transients = Transients; peaklock = true; longwin = false; shortwin = false;
                        break;
        };
 
@@ -337,7 +339,7 @@ Editor::do_timefx (TimeFXDialog& dialog)
                                in_command = true;
                        }
 
-                        playlist->clear_history ();
+                        playlist->clear_changes ();
                        playlist->replace_region (region, new_region, region->position());
                        _session->add_command (new StatefulDiffCommand (playlist));
                }
@@ -365,6 +367,14 @@ Editor::timefx_thread (void *arg)
 
        tsd->editor.do_timefx (*tsd);
 
+        /* GACK! HACK! sleep for a bit so that our request buffer for the GUI
+           event loop doesn't die before any changes we made are processed
+           by the GUI ...
+        */
+
+        struct timespec t = { 2, 0 };
+        nanosleep (&t, 0);
+
        return 0;
 }