Add reset region gain action for selected regions
authorTim Mayberry <mojofunk@gmail.com>
Sat, 4 Mar 2017 05:20:56 +0000 (15:20 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Sat, 4 Mar 2017 05:26:00 +0000 (15:26 +1000)
gtk2_ardour/ardour.menus.in
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc

index a2921c286ecd2e89f1ca7829149731ac6e343adb..2c88709e1db288d5dbd3cf82dc0e76465c987e3f 100644 (file)
         <menuitem action='normalize-region'/>
         <menuitem action='boost-region-gain'/>
         <menuitem action='cut-region-gain'/>
+        <menuitem action='reset-region-gain'/>
         <menuitem action='reset-region-gain-envelopes'/>
         <menuitem action='toggle-region-gain-envelope-active'/>
       </menu>
       <menuitem action='normalize-region'/>
       <menuitem action='boost-region-gain'/>
       <menuitem action='cut-region-gain'/>
+      <menuitem action='reset-region-gain'/>
       <menuitem action='reset-region-gain-envelopes'/>
       <menuitem action='toggle-region-gain-envelope-active'/>
     </menu>
index 88318c4f69d647ea7a09977126f1b921abcc1720..ec781e2df602bd578153c8347b144eccfb653e7e 100644 (file)
@@ -1267,6 +1267,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void normalize_region ();
        void reset_region_scale_amplitude ();
        void adjust_region_gain (bool up);
+       void reset_region_gain ();
        void quantize_region ();
        void quantize_regions (const RegionSelection& rs);
        void legatize_region (bool shrink_only);
index aa82ff39b32af16d75934b07512c673eb04eb4f8..67786e01dbec148a068cf37b68a306f0d607c436 100644 (file)
@@ -1799,6 +1799,9 @@ Editor::register_region_actions ()
        /* Cut selected region gain */
        register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "cut-region-gain", _("Cut Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), false));
 
+       /* Reset selected region gain */
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "reset-region-gain", _("Reset Gain"), sigc::mem_fun(*this, &Editor::reset_region_gain));
+
        /* Open the pitch shift dialogue for any selected audio regions */
        register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "pitch-shift-region", _("Pitch Shift..."), sigc::mem_fun (*this, &Editor::pitch_shift_region));
 
index 581326e278278ba60a08f5740bf88d43415a1e33..2b8a5fd018d0ddeac39d5abc9fd0cee4098e1ca1 100644 (file)
@@ -5217,6 +5217,38 @@ Editor::adjust_region_gain (bool up)
        }
 }
 
+void
+Editor::reset_region_gain ()
+{
+       RegionSelection rs = get_regions_from_selection_and_entered ();
+
+       if (!_session || rs.empty()) {
+               return;
+       }
+
+       bool in_command = false;
+
+       for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) {
+               AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
+               if (!arv) {
+                       continue;
+               }
+
+               arv->region()->clear_changes ();
+
+               arv->audio_region()->set_scale_amplitude (1.0f);
+
+               if (!in_command) {
+                               begin_reversible_command ("reset region gain");
+                               in_command = true;
+               }
+               _session->add_command (new StatefulDiffCommand (arv->region()));
+       }
+
+       if (in_command) {
+               commit_reversible_command ();
+       }
+}
 
 void
 Editor::reverse_region ()