Add GUI action to record with preroll
authorRobin Gareus <robin@gareus.org>
Wed, 18 Jan 2017 14:16:05 +0000 (15:16 +0100)
committerRobin Gareus <robin@gareus.org>
Wed, 18 Jan 2017 14:16:05 +0000 (15:16 +0100)
gtk2_ardour/ardour.menus.in
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc
gtk2_ardour/public_editor.h

index 7d18d17d11e154d9f9459dab0e1aca580a0e0d10..b579e7d2a16a69dbdf8c8349accf96b375b8ccba 100644 (file)
@@ -74,6 +74,7 @@
       <menuitem action='record-roll'/>
       <menuitem action='ToggleRollForgetCapture'/>
       <menuitem action='Record'/>
+      <menuitem action='RecordPreroll'/>
 #if 0
       <menuitem action='toggle-skip-playback'/>
 #endif
index 46510112b7a3a43a9f2ffe94b13639d59e2eec18..d9ea44c3256821b4cf83f7c54dca3c7936be6c32 100644 (file)
@@ -2449,6 +2449,15 @@ ARDOUR_UI::transport_play_preroll ()
        editor->play_with_preroll ();
 }
 
+void
+ARDOUR_UI::transport_rec_preroll ()
+{
+       if (!_session) {
+               return;
+       }
+       editor->rec_with_preroll ();
+}
+
 void
 ARDOUR_UI::transport_rewind (int option)
 {
index 5686d8c978a7fd8659ee156f3a3feca3f592c9da..f69a4a3dd633bf62368408af56640aff24515635 100644 (file)
@@ -677,6 +677,7 @@ private:
        void transport_roll ();
        void transport_play_selection();
        void transport_play_preroll();
+       void transport_rec_preroll();
        void transport_forward (int option);
        void transport_rewind (int option);
        void transport_loop ();
index 2c21de607405a4572b17a077a4f04058bda58720..1cdbcb51c7218d12f1817e8cf865fc74fb1b4323 100644 (file)
@@ -408,6 +408,10 @@ ARDOUR_UI::install_actions ()
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::transport_sensitive_actions.push_back (act);
 
+       act = global_actions.register_action (transport_actions, X_("RecordPreroll"), _("Record w/Preroll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_rec_preroll));
+       ActionManager::session_sensitive_actions.push_back (act);
+       ActionManager::write_sensitive_actions.push_back (act);
+
        act = global_actions.register_action (transport_actions, X_("Record"), _("Enable Record"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), false));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::write_sensitive_actions.push_back (act);
index dfe25420f68895c7802aefe958302e5c19f15f97..d34a40cda86cb134dd2cc5eaa319f52198e4ddf8 100644 (file)
@@ -264,6 +264,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        framepos_t get_preroll ();
        void maybe_locate_with_edit_preroll (framepos_t);
        void play_with_preroll ();
+       void rec_with_preroll ();
        void select_all_in_track (Selection::Operation op);
        void select_all_objects (Selection::Operation op);
        void invert_selection_in_track ();
index 633a6989d86b6e1b59d33673ee55875ea5feb7bc..95be0ed972d58544ff50e194aef7db0797cebed5 100644 (file)
@@ -2665,6 +2665,20 @@ Editor::play_with_preroll ()
        }
 }
 
+void
+Editor::rec_with_preroll ()
+{
+       framepos_t preroll = get_preroll();
+       framepos_t ph = playhead_cursor->current_frame ();
+       framepos_t start = std::max ((framepos_t)0, ph - preroll);
+
+       _session->request_preroll_record (ph);
+       _session->maybe_enable_record ();
+       _session->request_locate (start, true);
+       _session->set_requested_return_frame (ph);
+}
+
+
 void
 Editor::play_location (Location& location)
 {
index 4220ddbb72b5bbb060d24d74bbf63926516f7ead..cdae2480ec2518a9f7db3a2beab2f3e8079b0c09 100644 (file)
@@ -211,6 +211,7 @@ class PublicEditor : public Gtkmm2ext::Tabbable {
        virtual bool extend_selection_to_track (TimeAxisView&) = 0;
        virtual void play_selection () = 0;
        virtual void play_with_preroll () = 0;
+       virtual void rec_with_preroll () = 0;
        virtual void maybe_locate_with_edit_preroll (framepos_t location) = 0;
        virtual void goto_nth_marker (int nth) = 0;
        virtual void trigger_script (int nth) = 0;