Per-region MIDI CC "automation".
[ardour.git] / gtk2_ardour / editor_timefx.cc
index 8315834b932418ddd00f0e9e1d73f5ac420eb0b0..2efdc03f8fdca0c723997ea380732ed01ef2b7e8 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <cstdlib>
 
 #include <pbd/error.h>
 #include <pbd/pthread_utils.h>
+#include <pbd/memento_command.h>
+
+#include <gtkmm2ext/window_title.h>
 
 #include "editor.h"
 #include "audio_time_axis.h"
-#include "regionview.h"
+#include "audio_region_view.h"
 #include "region_selection.h"
 
 #include <ardour/session.h>
@@ -44,6 +46,7 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
+using namespace Gtkmm2ext;
 
 Editor::TimeStretchDialog::TimeStretchDialog (Editor& e)
        : ArdourDialog ("time stretch dialog"),
@@ -53,9 +56,12 @@ Editor::TimeStretchDialog::TimeStretchDialog (Editor& e)
 {
        set_modal (true);
        set_position (Gtk::WIN_POS_MOUSE);
-       set_title (_("ardour: timestretch"));
        set_name (N_("TimeStretchDialog"));
 
+       WindowTitle title(Glib::get_application_name());
+       title += _("Timestretch");
+       set_title(title.get_string());
+
        get_vbox()->set_spacing (5);
        get_vbox()->set_border_width (5);
        get_vbox()->pack_start (upper_button_box);
@@ -100,7 +106,7 @@ Editor::TimeStretchDialog::delete_timestretch_in_progress (GdkEventAny* ev)
 }
 
 int
-Editor::run_timestretch (AudioRegionSelection& regions, float fraction)
+Editor::run_timestretch (RegionSelection& regions, float fraction)
 {
        pthread_t thread;
 
@@ -157,39 +163,39 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction)
 void
 Editor::do_timestretch (TimeStretchDialog& dialog)
 {
-       AudioTrack* at;
-       Playlist* playlist;
-       AudioRegion* new_region;
-
+       Track*    t;
+       boost::shared_ptr<Playlist> playlist;
+       boost::shared_ptr<Region>   new_region;
 
-       for (AudioRegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) {
+       for (RegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) {
+               AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*i);
+               if (!arv)
+                       continue;
 
-               AudioRegion& aregion ((*i)->region);
-               TimeAxisView* tv = &(*i)->get_time_axis_view();
-               AudioTimeAxisView* atv;
-               AudioRegionSelection::iterator tmp;
+               boost::shared_ptr<AudioRegion> region (arv->audio_region());
+               TimeAxisView* tv = &(arv->get_time_axis_view());
+               RouteTimeAxisView* rtv;
+               RegionSelection::iterator tmp;
                
-               cerr << "stretch " << aregion.name() << endl;
-
                tmp = i;
                ++tmp;
 
-               if ((atv = dynamic_cast<AudioTimeAxisView*> (tv)) == 0) {
+               if ((rtv = dynamic_cast<RouteTimeAxisView*> (tv)) == 0) {
                        i = tmp;
                        continue;
                }
 
-               if ((at = dynamic_cast<AudioTrack*> (&atv->route())) == 0) {
+               if ((t = dynamic_cast<Track*> (rtv->route().get())) == 0) {
                        i = tmp;
                        continue;
                }
        
-               if ((playlist = at->diskstream().playlist()) == 0) {
+               if ((playlist = t->diskstream()->playlist()) == 0) {
                        i = tmp;
                        continue;
                }
 
-               dialog.request.region = &aregion;
+               dialog.request.region = region;
 
                if (!dialog.request.running) {
                        /* we were cancelled */
@@ -203,15 +209,17 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
                        return;
                }
 
-               session->add_undo (playlist->get_memento());
-               playlist->replace_region (aregion, *new_region, aregion.position());
-               session->add_redo_no_execute (playlist->get_memento());
+               XMLNode &before = playlist->get_state();
+               playlist->replace_region (region, new_region, region->position());
+               XMLNode &after = playlist->get_state();
+               session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
 
                i = tmp;
        }
 
        dialog.status = 0;
        dialog.request.running = false;
+       dialog.request.region.reset ();
 }
 
 void*