Add settings retention to StripSilenceDialog

StripSilenceDialog will now retain its threshold, minimum length, and
fade length values from run to run.

This is done via Session::add_extra_xml() and recalled during the
construction of StripSilenceDialog via Session::extra_xml()
This commit is contained in:
Nikolaus Gullotta 2019-08-30 12:40:28 -05:00
parent dab29eb8ad
commit d5988b232c
3 changed files with 39 additions and 3 deletions

View File

@ -5522,6 +5522,7 @@ Editor::strip_region_silence ()
StripSilence s (*_session, silences, d.fade_length());
apply_filter (s, _("strip silence"), &d);
_session->add_extra_xml(d.get_state());
}
}

View File

@ -51,6 +51,9 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
, _destroying (false)
, analysis_progress_cur (0)
, analysis_progress_max (0)
, _threshold_value (-60)
, _minimum_length_value (1000)
, _fade_length_value (64)
{
set_session (s);
@ -63,6 +66,14 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
Gtk::Table* table = Gtk::manage (new Gtk::Table (3, 3));
table->set_spacings (6);
//get the last used settings for this
XMLNode* node = _session->extra_xml(X_("StripSilence"));
if (node) {
node->get_property(X_("threshold"), _threshold_value);
node->get_property(X_("min-length"), _minimum_length_value);
node->get_property(X_("fade-length"), _fade_length_value);
}
int n = 0;
table->attach (*Gtk::manage (new Gtk::Label (_("Threshold"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
@ -73,7 +84,7 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
_threshold.set_digits (1);
_threshold.set_increments (1, 10);
_threshold.set_range (-120, 0);
_threshold.set_value (-60);
_threshold.set_value (_threshold_value);
_threshold.set_activates_default ();
table->attach (*Gtk::manage (new Gtk::Label (_("Minimum length"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
@ -82,7 +93,7 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
_minimum_length->set_session (s);
_minimum_length->set_mode (AudioClock::Samples);
_minimum_length->set (1000, true);
_minimum_length->set (_minimum_length_value, true);
table->attach (*Gtk::manage (new Gtk::Label (_("Fade length"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
table->attach (*_fade_length, 1, 2, n, n + 1, Gtk::FILL);
@ -90,7 +101,7 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
_fade_length->set_session (s);
_fade_length->set_mode (AudioClock::Samples);
_fade_length->set (64, true);
_fade_length->set (_fade_length_value, true);
hbox->pack_start (*table);
@ -339,3 +350,18 @@ StripSilenceDialog::update_progress_gui (float p)
{
_progress_bar.set_fraction (p);
}
XMLNode&
StripSilenceDialog::get_state ()
{
XMLNode* node = new XMLNode(X_("StripSilence"));
node->set_property(X_("threshold"), threshold());
node->set_property(X_("min-length"), minimum_length());
node->set_property(X_("fade-length"), fade_length());
return *node;
}
void
StripSilenceDialog::set_state (const XMLNode &)
{
}

View File

@ -22,6 +22,8 @@
#include <gtkmm/spinbutton.h>
#include <glibmm/threads.h>
#include <pbd/xml++.h>
#include "ardour/types.h"
#include "ardour_dialog.h"
#include "progress_reporter.h"
@ -55,6 +57,9 @@ public:
Gtk::Dialog::on_response (response_id);
}
XMLNode& get_state ();
void set_state (const XMLNode &);
private:
void create_waves ();
void canvas_allocation (Gtk::Allocation &);
@ -100,4 +105,8 @@ private:
bool idle_update_progress(); ///< GUI-thread progress updates of background silence computation
int analysis_progress_cur;
int analysis_progress_max;
int _threshold_value;
ARDOUR::samplecnt_t _minimum_length_value;
ARDOUR::samplecnt_t _fade_length_value;
};