View Issue Details

IDCategoryLast Update
0006818features2016-03-16 01:39
ReporterHouston4444Assigned To 
Reproducibilityhave not tried 
Status newResolutionopen 
PlatformGNU/linuxOSkubuntuOS Version15.10
Product Version4.7 
Fixed in Version 
Summary0006818: wish: close gaps (or conform regions) could have an option 'prevent double attack'
DescriptionUsing rhythm ferret (for example for a drum), after split regions, snap regions and conform regions, user have to move some fades because some attacks are present on two following regions. The second one is the good one, the first is at the end of the region from previous attack.

An easy solution (I guess) would be to set an option in close gabs/conform regions dialog called for example 'prevent double attack'. With this option, when two consecutives regions do not overlap, the left one isn't extended, and the right one is starting at the end of the left one, less the crossfade's lenght.

Steps To Reproduceright click on a region, go to edit/rhythm ferret
Analyze
split regions
re-select regions
snap regions
conform regions

Listen these regions.
TagsNo tags attached.

Users sponsoring this issue
Sponsors List Total Sponsorship = US$ 50

2016-03-12 13:07: Houston4444 (US$ 50)
Users sponsoring this issue (Total Sponsorship = US$ 50)

Activities

Houston4444

2016-03-15 22:53

reporter   ~0018070

I modify the function close_region_gaps in /ardour/gtk2_ardour/editor_ops in source code to get what I wanted (close_gaps.txt in attachment).
It works very well.
I ensure that it's much much better for all automatic snap to grid. Whit it user don't need to modify attack becoming two following times (it doesn't appends anymore), and pullback can be set very short (just duration of pre-attack), that's why I set it to 10ms as default, more than enought for allmost drums.

First I was asking about an option in close gaps dialog to do that, but I wonder if users would need original behaviour. What do you think about ?

There's still something weird with crossfades (not very strong, just not logic). In Dialog box user set crossfade duration, but in fact, this setting affects the duration of regions recovery, crossfade duration is in all cases the default one. Would it be better to superimpose two crossfades, or one crossfade and one region without crossfade, or something else ?

Please Test !

Houston4444

2016-03-15 22:53

reporter  

close_gaps.txt (3,219 bytes)
void
Editor::close_region_gaps ()
{
	list <boost::shared_ptr<Playlist > > used_playlists;

	RegionSelection rs = get_regions_from_selection_and_entered ();

	if (!_session || rs.empty()) {
		return;
	}

	Dialog dialog (_("Close Region Gaps"));

	Table table (2, 3);
	table.set_spacings (12);
	table.set_border_width (12);
	Label* l = manage (left_aligned_label (_("Crossfade length")));
	table.attach (*l, 0, 1, 0, 1);

	SpinButton spin_crossfade (1, 0);
	spin_crossfade.set_range (0, 15);
	spin_crossfade.set_increments (1, 1);
	spin_crossfade.set_value (5);
	table.attach (spin_crossfade, 1, 2, 0, 1);

	table.attach (*manage (new Label (_("ms"))), 2, 3, 0, 1);

	l = manage (left_aligned_label (_("Pull-back length")));
	table.attach (*l, 0, 1, 1, 2);

	SpinButton spin_pullback (1, 0);
	spin_pullback.set_range (0, 100);
	spin_pullback.set_increments (1, 1);
	spin_pullback.set_value(10);
	table.attach (spin_pullback, 1, 2, 1, 2);

	table.attach (*manage (new Label (_("ms"))), 2, 3, 1, 2);

	dialog.get_vbox()->pack_start (table);
	dialog.add_button (Stock::CANCEL, RESPONSE_CANCEL);
	dialog.add_button (_("Ok"), RESPONSE_ACCEPT);
	dialog.show_all ();

	if (dialog.run () == RESPONSE_CANCEL) {
		return;
	}

	framepos_t crossfade_len = spin_crossfade.get_value();
	framepos_t pull_back_frames = spin_pullback.get_value();

	crossfade_len = lrintf (crossfade_len * _session->frame_rate()/1000);
	pull_back_frames = lrintf (pull_back_frames * _session->frame_rate()/1000);

	/* Iterate over the region list and make adjacent regions overlap by crossfade_len_ms */

	begin_reversible_command (_("close region gaps"));

	int idx = 0;
	boost::shared_ptr<Region> last_region;

	rs.sort_by_position_and_track();
	
	for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) {

		boost::shared_ptr<Playlist> pl = (*r)->region()->playlist();

		if (!pl->frozen()) {
			/* we haven't seen this playlist before */

			/* remember used playlists so we can thaw them later */
			used_playlists.push_back(pl);
			pl->freeze();
		}

		framepos_t position = (*r)->region()->position();
                

		if (idx == 0 || position < last_region->position()){
			last_region = (*r)->region();
			idx++;
			continue;
		}
                
                framepos_t last_region_position = last_region->position();
                framecnt_t last_region_length = last_region->length();
                framepos_t last_region_end = (last_region_position + last_region_length);
                
                if ((last_region_end - pull_back_frames) > (position - crossfade_len)){
                    (*r)->region()->trim_front( (position - pull_back_frames));
                    last_region->trim_end( (position - pull_back_frames + crossfade_len));
                } else {
                    (*r)->region()->trim_front( (last_region_end - pull_back_frames - crossfade_len));
                    last_region->trim_end( (last_region_end - pull_back_frames));
                }
		last_region = (*r)->region();

		idx++;
	}

	while (used_playlists.size() > 0) {
		list <boost::shared_ptr<Playlist > >::iterator i = used_playlists.begin();
		(*i)->thaw();
		used_playlists.pop_front();
	}

	commit_reversible_command ();
}
 
close_gaps.txt (3,219 bytes)

Houston4444

2016-03-15 22:54

reporter  

editor_ops.cc (182,265 bytes)

x42

2016-03-16 01:38

administrator  

close_gaps_6818.diff (1,328 bytes)
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 12a7f2a..68d07d3 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -6873,7 +6873,7 @@ Editor::close_region_gaps ()
 	SpinButton spin_pullback (1, 0);
 	spin_pullback.set_range (0, 100);
 	spin_pullback.set_increments (1, 1);
-	spin_pullback.set_value(30);
+	spin_pullback.set_value(10);
 	table.attach (spin_pullback, 1, 2, 1, 2);
 
 	table.attach (*manage (new Label (_("ms"))), 2, 3, 1, 2);
@@ -6922,9 +6922,17 @@ Editor::close_region_gaps ()
 			continue;
 		}
 
-		(*r)->region()->trim_front( (position - pull_back_frames));
-		last_region->trim_end( (position - pull_back_frames + crossfade_len));
+		framepos_t last_region_position = last_region->position();
+		framecnt_t last_region_length = last_region->length();
+		framepos_t last_region_end = (last_region_position + last_region_length);
 
+		if ((last_region_end - pull_back_frames) > (position - crossfade_len)){
+			(*r)->region()->trim_front( (position - pull_back_frames));
+			last_region->trim_end( (position - pull_back_frames + crossfade_len));
+		} else {
+			(*r)->region()->trim_front( (last_region_end - pull_back_frames - crossfade_len));
+			last_region->trim_end( (last_region_end - pull_back_frames));
+		}
 		last_region = (*r)->region();
 
 		idx++;
close_gaps_6818.diff (1,328 bytes)

x42

2016-03-16 01:39

administrator   ~0018071

reformatted as patch (with whitespace/indent fixes): close_gaps_6818.diff

Issue History

Date Modified Username Field Change
2016-03-12 12:55 Houston4444 New Issue
2016-03-12 13:07 Houston4444 Sponsorship Added Houston4444: US$ 50
2016-03-12 13:07 Houston4444 Sponsorship Total 0 => 50
2016-03-15 22:53 Houston4444 Note Added: 0018070
2016-03-15 22:53 Houston4444 File Added: close_gaps.txt
2016-03-15 22:54 Houston4444 File Added: editor_ops.cc
2016-03-16 01:38 x42 File Added: close_gaps_6818.diff
2016-03-16 01:39 x42 Note Added: 0018071