mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-30 17:03:06 +01:00
dialog for remove gaps operation
This commit is contained in:
parent
79b50aebcd
commit
bbcdd959bf
3 changed files with 82 additions and 4 deletions
|
|
@ -579,7 +579,8 @@ public:
|
|||
void split_regions_at (ARDOUR::MusicSample, RegionSelection&);
|
||||
void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
|
||||
RegionSelection get_regions_from_selection_and_mouse (samplepos_t);
|
||||
void remove_gaps ();
|
||||
void do_remove_gaps ();
|
||||
void remove_gaps (samplecnt_t threshold, samplecnt_t leave);
|
||||
|
||||
void mouse_add_new_tempo_event (samplepos_t where);
|
||||
void mouse_add_new_meter_event (samplepos_t where);
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ Editor::register_actions ()
|
|||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
ActionManager::track_selection_sensitive_actions.push_back (act);
|
||||
|
||||
act = reg_sens (editor_actions, "remove-gaps", _("Remove Gaps"), (sigc::mem_fun(*this, &Editor::remove_gaps)));
|
||||
act = reg_sens (editor_actions, "remove-gaps", _("Remove Gaps"), (sigc::mem_fun(*this, &Editor::do_remove_gaps)));
|
||||
ActionManager::track_selection_sensitive_actions.push_back (act);
|
||||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
|
||||
|
|
|
|||
|
|
@ -8924,7 +8924,84 @@ Editor::make_region_markers_global (bool as_cd_marker)
|
|||
}
|
||||
|
||||
void
|
||||
Editor::remove_gaps ()
|
||||
Editor::do_remove_gaps ()
|
||||
{
|
||||
ArdourDialog d (_("Remove Gaps"), true, false);
|
||||
|
||||
Gtk::HBox hpacker1;
|
||||
Gtk::Label label1 (_("Smallest gap size to remove (seconds):"));
|
||||
Gtk::Entry e1;
|
||||
|
||||
hpacker1.set_spacing (12);
|
||||
hpacker1.set_border_width (12);
|
||||
hpacker1.pack_start (label1, true, false);
|
||||
hpacker1.pack_start (e1, false, false);
|
||||
|
||||
Gtk::HBox hpacker2;
|
||||
Gtk::Label label2 (_("Leave a gap of(seconds):"));
|
||||
Gtk::Entry e2;
|
||||
|
||||
hpacker2.set_spacing (12);
|
||||
hpacker2.set_border_width (12);
|
||||
hpacker2.pack_start (label2, true, false);
|
||||
hpacker2.pack_start (e2, false, false);
|
||||
|
||||
d.get_vbox()->pack_start (hpacker1);
|
||||
d.get_vbox()->pack_start (hpacker2);
|
||||
d.get_vbox()->show_all ();
|
||||
|
||||
e2.set_activates_default ();
|
||||
|
||||
d.add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
d.add_button (Stock::OK, RESPONSE_OK);
|
||||
d.set_default_response (RESPONSE_OK);
|
||||
|
||||
again:
|
||||
int result = d.run ();
|
||||
|
||||
if (result != RESPONSE_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
float threshold_secs;
|
||||
|
||||
if (sscanf (e1.get_text().c_str(), "%f", &threshold_secs) != 1) {
|
||||
ArdourMessageDialog msg (_("The threshold value you entered is not a number"));
|
||||
msg.run();
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (threshold_secs <= 0) {
|
||||
ArdourMessageDialog msg (_("The threshold value must be larger than zero"));
|
||||
msg.run();
|
||||
goto again;
|
||||
}
|
||||
|
||||
samplecnt_t threshold_samples = (samplecnt_t) floor (threshold_secs * _session->sample_rate());
|
||||
|
||||
float leave_secs;
|
||||
|
||||
if (sscanf (e2.get_text().c_str(), "%f", &leave_secs) != 1) {
|
||||
ArdourMessageDialog msg (_("The leave-gap value you entered is not a number"));
|
||||
msg.run();
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (leave_secs < 0) {
|
||||
ArdourMessageDialog msg (_("The threshold value must be larger than or equal to zero"));
|
||||
msg.run ();
|
||||
goto again;
|
||||
}
|
||||
|
||||
samplecnt_t leave_samples = (samplecnt_t) floor (leave_secs * _session->sample_rate());
|
||||
|
||||
d.hide ();
|
||||
|
||||
remove_gaps (threshold_samples, leave_samples);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::remove_gaps (samplecnt_t gap_threshold, samplecnt_t leave_gap)
|
||||
{
|
||||
bool in_command = false;
|
||||
TrackViewList ts = selection->tracks.filter_to_unique_playlists ();
|
||||
|
|
@ -8963,7 +9040,7 @@ Editor::remove_gaps ()
|
|||
in_command = true;
|
||||
}
|
||||
|
||||
(*i)->remove_gaps (24000, 4410);
|
||||
(*i)->remove_gaps (gap_threshold, leave_gap);
|
||||
|
||||
vector<Command*> cmds;
|
||||
(*i)->rdiff (cmds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue