Add settings retention to StripSilenceDialog
authorNikolaus Gullotta <nik@harrisonconsoles.com>
Fri, 30 Aug 2019 17:40:28 +0000 (12:40 -0500)
committerNikolaus Gullotta <nik@harrisonconsoles.com>
Fri, 30 Aug 2019 17:40:28 +0000 (12:40 -0500)
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()

gtk2_ardour/editor_ops.cc
gtk2_ardour/strip_silence_dialog.cc
gtk2_ardour/strip_silence_dialog.h

index 99e7d1133ab3a2b45ba68feddf70fdc8f3033abf..0b9c7a33de688f45db8debf564ff451551eb740e 100644 (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());
        }
 }
 
index 50115af6d541e18d928d7e5f9d9909afc77a2324..6aeec29cd9441949b544057b3d282645bc52ddfe 100644 (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 &)
+{
+}
\ No newline at end of file
index 51bec028f541aad81c302af43c64a3013a791966..bc90ce321e5bea120b62e9819dd31bbdf815d0c4 100644 (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;
 };