View Issue Details

IDProjectCategoryView StatusLast Update
0002903ardourfeaturespublic2016-09-07 01:45
Reporterdoubleg Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product VersionMixbus 1.0 
Summary0002903: Combine Punch Range + Punch In/out Enable in One Step
DescriptionBe nice if there was a way to combine defining the punch range and enabling punch in/out in one step, i.e. setting the punch range automatically enables it -- or at least have that as a user selectable option. Presently my understanding is that this must be done in 2 separate steps.
TagsNo tags attached.

Activities

nstewart

2016-08-12 18:38

reporter   ~0018356

I'm working on something similar to emulate the way my control surface's Punch In/Out works when operating in its standalone recorder mode. My current thinking about what happens when pressing the "Auto Punch In/Out" button is:

1) If there Punch In/Out are off, and no range exists, the first press Sets Punch In, and creates a range from the playhead to the end of the session.

2a) If punch in is set, and there is a range, the 2nd press sets punch out, and moves the end of the range from the end of the session to the current playhead position.

2b) If the playhead was rewound and is now ahead of the Punch In range Start, the punch in start is moved backwards to the current playhead position, and punch out is NOT set.

3) If punch in and out are both set, the range is removed, and punch in/out are both cleared.

nstewart

2016-08-13 02:00

reporter  

auto-punch.diff (3,502 bytes)   
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index d45545b..81098ac 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1451,6 +1451,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 	void set_loop_from_selection (bool play);
 	void set_punch_from_selection ();
 	void set_punch_from_region ();
+	void set_punch_range_from_playhead ();
 
 	void set_session_start_from_playhead ();
 	void set_session_end_from_playhead ();
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 79900b3..a4039e4 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -319,6 +319,7 @@ Editor::register_actions ()
 	reg_sens (editor_actions, "set-loop-from-edit-range", _("Set Loop from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false));
 	reg_sens (editor_actions, "set-punch-from-edit-range", _("Set Punch from Selection"), sigc::mem_fun(*this, &Editor::set_punch_from_selection));
 	reg_sens (editor_actions, "set-session-from-edit-range", _("Set Session Start/End from Selection"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection));
+	reg_sens (editor_actions, "set-punch-range-from-playhead", _("Set Punch Range from Playhead"), sigc::mem_fun(*this, &Editor::set_punch_range_from_playhead));
 
 	/* this is a duplicated action so that the main menu can use a different label */
 	reg_sens (editor_actions, "main-menu-play-selected-regions", _("Play Selected Regions"), sigc::mem_fun (*this, &Editor::play_selected_region));
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index c208e55..af27c1b 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2243,6 +2243,7 @@ Editor::set_session_end_from_playhead ()
 	_session->set_end_is_free (false);
 }
 
+
 void
 Editor::add_location_from_playhead_cursor ()
 {
@@ -6305,6 +6306,50 @@ Editor::set_punch_from_selection ()
 }
 
 void
+Editor::set_punch_range_from_playhead ()
+{
+	// auto punch in/out button from a single button
+	// If no punch range set - first press sets punch in.
+	// if punch in is set, the next punch sets punch out
+	// if punch out is set, it clears the punch range
+	if (_session == 0) {
+			return;
+	}
+
+	Location* tpl = transport_punch_location();
+	framepos_t now = playhead_cursor->current_frame();
+	framepos_t begin = now;
+	framepos_t end = _session->current_end_frame();
+
+	if (tpl == 0 && !_session->config.get_punch_in()) {
+		// First Press - set punch in and create range from here to eternity
+		set_punch_range (begin, end, _("Auto Punch In"));
+		_session->config.set_punch_in(true);
+	} else if (tpl && !_session->config.get_punch_out()) {
+		// Second press - update end range marker and set punch_out
+		if (now < tpl->start()) {
+			// playhead has been rewound - move start back  and pretend nothing happened
+			begin = now;
+			set_punch_range (begin, end, _("Auto Punch In/Out"));
+		} else {
+			// normal case for 2nd press - set the punch out
+			end = playhead_cursor->current_frame ();
+			set_punch_range (tpl->start(), now, _("Auto Punch In/Out"));
+			_session->config.set_punch_out(true);
+		}
+	} else 	{
+		if (tpl)
+		{
+			// third press - unset punch in/out and remove range
+			_session->config.set_punch_out(false);
+			_session->config.set_punch_in(false);
+			_session->locations()->remove(tpl);
+		}
+	}
+
+}
+
+void
 Editor::set_session_extents_from_selection ()
 {
 	if (_session == 0) {
auto-punch.diff (3,502 bytes)   

nstewart

2016-08-13 02:03

reporter   ~0018357

Here's my patch implementing a single button Auto Punch In/Out and settings the ranges. As described above (case 3):

1) If Punch In is unset, it sets Punch In, and creates a Punch range from the playhead to the end of the session.

2) If Punch In is set, but Punch Out is unset, it will set the end of the Punch range to the playhead, and set Punch Out - unless the playhead has been rewound ahead of the existing Punch-In point. In that case it will back the Punch In point up to the playhead, and leave the Punch-Out at the end of the sesion.

3) If Punch In and Punch Out are both set, pressing the button again clears both Punch In and Punch Out and removes the range.

This behavior was modeled on my Zoom R24's behavior in standalone mode. I'm not as familiar with other systems, but it seems intuitive to me.

nstewart

2016-08-16 02:42

reporter  

0001-Single-Button-Multi-press-Auto-Punch-In-Out-with-pun.patch (3,756 bytes)   
From 128ae396b04cc21ea8adb6f9ef3f5fe20ecf4974 Mon Sep 17 00:00:00 2001
From: Nathan Stewart <therealnathanstewart@gmail.com>
Date: Mon, 15 Aug 2016 22:29:27 -0400
Subject: [PATCH] Single Button, Multi-press Auto Punch In/Out with punch range
 set from the playhead

---
 gtk2_ardour/editor.h          |  1 +
 gtk2_ardour/editor_actions.cc |  1 +
 gtk2_ardour/editor_ops.cc     | 53 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 7d754ed..75ba686 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1451,6 +1451,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 	void set_loop_from_selection (bool play);
 	void set_punch_from_selection ();
 	void set_punch_from_region ();
+	void set_auto_punch_range();
 
 	void set_session_start_from_playhead ();
 	void set_session_end_from_playhead ();
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 44c66e3..660a051 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -330,6 +330,7 @@ Editor::register_actions ()
 
 	reg_sens (editor_actions, "set-playhead", _("Playhead to Mouse"), sigc::mem_fun(*this, &Editor::set_playhead_cursor));
 	reg_sens (editor_actions, "set-edit-point", _("Active Marker to Mouse"), sigc::mem_fun(*this, &Editor::set_edit_point));
+	reg_sens (editor_actions, "set-auto-punch-range", _("Set Auto Punch In/Out from Playhead"), sigc::mem_fun(*this, &Editor::set_auto_punch_range));
 
 	reg_sens (editor_actions, "duplicate-range", _("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false));
 
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index e5d7623..16cce62 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -6345,6 +6345,59 @@ Editor::set_punch_from_selection ()
 }
 
 void
+Editor::set_auto_punch_range ()
+{
+	// auto punch in/out button from a single button
+	// If Punch In is unset, set punch range from playhead to end, enable punch in
+	// If Punch In is set, the next punch sets Punch Out, unless the playhead has been
+	//   rewound beyond the Punch In marker, in which case that marker will be moved back
+	//   to the current playhead position.
+	// If punch out is set, it clears the punch range and Punch In/Out buttons
+
+	if (_session == 0) {
+		return;
+	}
+
+	Location* tpl = transport_punch_location();
+	framepos_t now = playhead_cursor->current_frame();
+	framepos_t begin = now;
+	framepos_t end = _session->current_end_frame();
+
+	if (!_session->config.get_punch_in()) {
+		// First Press - set punch in and create range from here to eternity
+		set_punch_range (begin, end, _("Auto Punch In"));
+		_session->config.set_punch_in(true);
+	} else if (tpl && !_session->config.get_punch_out()) {
+		// Second press - update end range marker and set punch_out
+		if (now < tpl->start()) {
+			// playhead has been rewound - move start back  and pretend nothing happened
+			begin = now;
+			set_punch_range (begin, end, _("Auto Punch In/Out"));
+		} else {
+			// normal case for 2nd press - set the punch out
+			end = playhead_cursor->current_frame ();
+			set_punch_range (tpl->start(), now, _("Auto Punch In/Out"));
+			_session->config.set_punch_out(true);
+		}
+	} else 	{
+		if (_session->config.get_punch_out()) {
+			_session->config.set_punch_out(false);
+		}
+
+		if (_session->config.get_punch_in()) {
+			_session->config.set_punch_in(false);
+		}
+
+		if (tpl)
+		{
+			// third press - unset punch in/out and remove range
+			_session->locations()->remove(tpl);
+		}
+	}
+
+}
+
+void
 Editor::set_session_extents_from_selection ()
 {
 	if (_session == 0) {
-- 
2.7.4

nstewart

2016-08-16 02:44

reporter   ~0018375

001-Single-Button-Multi-press-Auto-Punch-In-Out-with-pun.patch replaces earlier auto-punch.diff. Renamed methods, made logic more robust if some unexpected punch-in state is preexisting when the action is initiated.

ahellquist

2016-08-27 09:55

reporter   ~0018495

Single button punch-in would be handy indeed

paul

2016-08-27 23:58

administrator   ~0018497

applied and pushed as git commit 400f38c. Thanks!

nstewart

2016-08-28 00:50

reporter   ~0018498

Verified with 400f38c. Since I'm not the original creator of the request, I won't close it yet. Given the age of this item - I'll give it a week or so to hear back from the originator before closing. (In order to make sure that the solution to my problem is the solution he was looking for.)

nstewart

2016-09-07 01:44

reporter   ~0018559

Moving to closed w/ release of 5.3

nstewart

2016-09-07 01:45

reporter   ~0018560

Added in git 400f38c, released in 5.3

Issue History

Date Modified Username Field Change
2009-11-08 00:39 doubleg New Issue
2016-08-12 18:38 nstewart Note Added: 0018356
2016-08-13 02:00 nstewart File Added: auto-punch.diff
2016-08-13 02:03 nstewart Note Added: 0018357
2016-08-16 02:42 nstewart File Added: 0001-Single-Button-Multi-press-Auto-Punch-In-Out-with-pun.patch
2016-08-16 02:44 nstewart Note Added: 0018375
2016-08-27 09:55 ahellquist Note Added: 0018495
2016-08-27 23:58 paul Note Added: 0018497
2016-08-28 00:50 nstewart Note Added: 0018498
2016-09-07 01:44 nstewart Note Added: 0018559
2016-09-07 01:45 nstewart Note Added: 0018560
2016-09-07 01:45 nstewart Status new => closed
2016-09-07 01:45 nstewart Resolution open => fixed