diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 6adbb5a1a0..637f858bab 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -334,6 +334,7 @@ + @@ -817,6 +818,7 @@ + diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 8185845844..3e409addbd 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1320,6 +1320,7 @@ private: void align_region_internal (boost::shared_ptr, ARDOUR::RegionPoint point, Temporal::timepos_t const & position); void recover_regions (ARDOUR::RegionList); void remove_selected_regions (); + void remove_regions (const RegionSelection&, bool can_ripple, bool as_part_of_other_command); void remove_clicked_region (); void show_region_properties (); void show_midi_list_editor (); @@ -1343,6 +1344,8 @@ private: void quantize_regions (const RegionSelection& rs); void legatize_region (bool shrink_only); void legatize_regions (const RegionSelection& rs, bool shrink_only); + void deinterlace_midi_regions (const RegionSelection& rs); + void deinterlace_selected_midi_regions (); void transform_region (); void transform_regions (const RegionSelection& rs); void transpose_region (); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 8105c2c06f..a9834ac0f3 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -1874,6 +1874,7 @@ Editor::register_region_actions () register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "quantize-region", _("Quantize..."), sigc::mem_fun (*this, &Editor::quantize_region)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "legatize-region", _("Legatize"), sigc::bind(sigc::mem_fun (*this, &Editor::legatize_region), false)); + register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "deinterlace-midi", _("Deinterlace Into Layers"), sigc::mem_fun (*this, &Editor::deinterlace_selected_midi_regions)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "transform-region", _("Transform..."), sigc::mem_fun (*this, &Editor::transform_region)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "remove-overlap", _("Remove Overlap"), sigc::bind(sigc::mem_fun (*this, &Editor::legatize_region), true)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "insert-patch-change", _("Insert Patch Change..."), sigc::bind (sigc::mem_fun (*this, &Editor::insert_patch_change), false)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 67289569c8..3c10edeb54 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4627,16 +4627,26 @@ Editor::recover_regions (ARDOUR::RegionList regions) } -/** Remove the selected regions */ +/** This is an editor Action, called with no arguments */ void Editor::remove_selected_regions () { RegionSelection rs = get_regions_from_selection_and_entered (); - if (!_session || rs.empty()) { + remove_regions (rs, true /*can_ripple*/, false /*as_part_of_other_command*/); +} + +/** Remove region(s) from their associated playlists */ +void +Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_part_of_other_command) +{ + if (!_session || sel.empty()) { return; } + /* make a local copy */ + RegionSelection rs = sel; + list > regions_to_remove; for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { @@ -4675,7 +4685,7 @@ Editor::remove_selected_regions () playlist->freeze (); playlist->remove_region (*rl); - if (should_ripple()) { + if (can_ripple && should_ripple()) { do_ripple (playlist, (*rl)->position(), -(*rl)->length(), boost::shared_ptr(), false); } } @@ -4690,7 +4700,7 @@ Editor::remove_selected_regions () so we need to do a recursive diff here. */ - if (!in_command) { + if (!in_command && !as_part_of_other_command) { begin_reversible_command (_("remove region")); in_command = true; } @@ -4701,7 +4711,7 @@ Editor::remove_selected_regions () _session->add_command(new StatefulDiffCommand (*pl)); } - if (in_command) { + if (in_command && !as_part_of_other_command) { commit_reversible_command (); } } @@ -5839,6 +5849,43 @@ Editor::legatize_region (bool shrink_only) } } +void +Editor::deinterlace_midi_regions (const RegionSelection& rs) +{ + begin_reversible_command (_("de-interlace midi")); + + RegionSelection rcopy = rs; + if (_session) { + + for (RegionSelection::iterator i = rcopy.begin (); i != rcopy.end(); i++) { + MidiRegionView* const mrv = dynamic_cast (*i); + if (mrv) { + XMLNode& before (mrv->region()->playlist()->get_state()); + + /* pass the regions to deinterlace_midi_region*/ + _session->deinterlace_midi_region(mrv->midi_region()); + + XMLNode& after (mrv->region()->playlist()->get_state()); + _session->add_command (new MementoCommand(*(mrv->region()->playlist()), &before, &after)); + } + } + } + + /* Remove the original region(s) safely, without rippling, as part of this command */ + remove_regions(rs, false /*can_ripple*/, true /*as_part_of_other_command*/); + + commit_reversible_command (); +} + +void +Editor::deinterlace_selected_midi_regions () +{ + if (_session) { + RegionSelection rs = get_regions_from_selection_and_entered (); + deinterlace_midi_regions(rs); + } +} + void Editor::legatize_regions (const RegionSelection& rs, bool shrink_only) { diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index f69947a23a..65695bb0b0 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -767,7 +767,7 @@ EditorSources::remove_selected_sources () } - _editor->remove_selected_regions(); // this operation is undo-able + _editor->remove_regions( _editor->get_regions_from_selection_and_entered(), false /*can_ripple*/, false /*as_part_of_other_command*/); // this operation is undo-able if (opt==2) { for (std::list >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {