From a2885a430bbb69a72f901d227cacce979f121020 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 Sep 2010 00:58:25 +0000 Subject: Add progress bar to strip silence dialogue. Fixes #3103. git-svn-id: svn://localhost/ardour2/branches/3.0@7809 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 3 ++- gtk2_ardour/editor_ops.cc | 21 +++++++++++++++++---- gtk2_ardour/strip_silence_dialog.cc | 9 +++++++++ gtk2_ardour/strip_silence_dialog.h | 5 ++++- gtk2_ardour/wscript | 1 + libs/ardour/ardour/filter.h | 3 ++- libs/ardour/ardour/midi_stretch.h | 2 +- libs/ardour/ardour/rb_effect.h | 2 +- libs/ardour/ardour/region.h | 3 ++- libs/ardour/ardour/reverse.h | 2 +- libs/ardour/ardour/strip_silence.h | 2 +- libs/ardour/midi_stretch.cc | 2 +- libs/ardour/rb_effect.cc | 2 +- libs/ardour/region.cc | 4 ++-- libs/ardour/reverse.cc | 2 +- libs/ardour/strip_silence.cc | 11 ++++++++++- libs/ardour/wscript | 1 + 17 files changed, 57 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 9063599e23..9e5e065ecd 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -127,6 +127,7 @@ class EditorLocations; class EditorSnapshots; class EditorSummary; class RegionLayeringOrderEditor; +class ProgressReporter; /* */ class ImageFrameView; @@ -1910,7 +1911,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* audio filters */ - void apply_filter (ARDOUR::Filter&, std::string cmd); + void apply_filter (ARDOUR::Filter&, std::string cmd, ProgressReporter* progress = 0); Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv); void apply_midi_note_edit_op (ARDOUR::MidiOperator& op); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 10d8410dad..426e42ced2 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4740,7 +4740,7 @@ Editor::strip_region_silence () if (r == Gtk::RESPONSE_OK) { StripSilence s (*_session, d.threshold (), d.minimum_length (), d.fade_length ()); - apply_filter (s, _("strip silence")); + apply_filter (s, _("strip silence"), &d); } } @@ -4855,7 +4855,7 @@ Editor::quantize_region () } void -Editor::apply_filter (Filter& filter, string command) +Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress) { RegionSelection rs; @@ -4870,6 +4870,9 @@ Editor::apply_filter (Filter& filter, string command) track_canvas->get_window()->set_cursor (*wait_cursor); gdk_flush (); + int n = 0; + int const N = rs.size (); + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ) { RegionSelection::iterator tmp = r; ++tmp; @@ -4878,10 +4881,14 @@ Editor::apply_filter (Filter& filter, string command) if (arv) { boost::shared_ptr playlist = arv->region()->playlist(); - if (arv->audio_region()->apply (filter) == 0) { + if (progress) { + progress->descend (1.0 / N); + } + + if (arv->audio_region()->apply (filter, progress) == 0) { playlist->clear_changes (); - + if (filter.results.empty ()) { /* no regions returned; remove the old one */ @@ -4907,9 +4914,15 @@ Editor::apply_filter (Filter& filter, string command) } else { goto out; } + + if (progress) { + progress->ascend (); + progress->set_progress (float (n + 1) / N); + } } r = tmp; + ++n; } commit_reversible_command (); diff --git a/gtk2_ardour/strip_silence_dialog.cc b/gtk2_ardour/strip_silence_dialog.cc index 936c071290..d0f806e71a 100644 --- a/gtk2_ardour/strip_silence_dialog.cc +++ b/gtk2_ardour/strip_silence_dialog.cc @@ -53,6 +53,7 @@ StripSilenceDialog* StripSilenceDialog::current = 0; /** Construct Strip silence dialog box */ StripSilenceDialog::StripSilenceDialog (Session* s, list > const & regions) : ArdourDialog (_("Strip Silence")) + , ProgressReporter () , _minimum_length (X_("silence duration"), true, "SilenceDurationClock", true, false, true, false) , _fade_length (X_("silence duration"), true, "SilenceDurationClock", true, false, true, false) , _wave_width (640) @@ -143,6 +144,8 @@ StripSilenceDialog::StripSilenceDialog (Session* s, listpack_start (*_canvas, true, true); + get_vbox()->pack_start (_progress_bar, true, true); + show_all (); _threshold.get_adjustment()->signal_value_changed().connect (sigc::mem_fun (*this, &StripSilenceDialog::threshold_changed)); @@ -560,3 +563,9 @@ StripSilenceDialog::Wave::~Wave () delete *i; } } + +void +StripSilenceDialog::update_progress_gui (float p) +{ + _progress_bar.set_fraction (p); +} diff --git a/gtk2_ardour/strip_silence_dialog.h b/gtk2_ardour/strip_silence_dialog.h index 1e8b140358..3b800eb115 100644 --- a/gtk2_ardour/strip_silence_dialog.h +++ b/gtk2_ardour/strip_silence_dialog.h @@ -23,6 +23,7 @@ #include "ardour/types.h" #include "ardour_dialog.h" #include "canvas.h" +#include "progress_reporter.h" namespace ARDOUR { class AudioRegion; @@ -30,7 +31,7 @@ namespace ARDOUR { } /// Dialog box to set options for the `strip silence' filter -class StripSilenceDialog : public ArdourDialog +class StripSilenceDialog : public ArdourDialog, public ProgressReporter { public: StripSilenceDialog (ARDOUR::Session*, std::list > const &); @@ -52,6 +53,7 @@ private: void resize_silence_rects (); void update_threshold_line (); void threshold_changed (); + void update_progress_gui (float); Gtk::SpinButton _threshold; AudioClock _minimum_length; @@ -59,6 +61,7 @@ private: Gtk::Label _segment_count_label; Gtk::Label _shortest_silence_label; Gtk::Label _shortest_audible_label; + Gtk::ProgressBar _progress_bar; typedef std::list > SilenceResult; struct Wave { diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index bd5ef56690..2f003a615c 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -167,6 +167,7 @@ gtk2_ardour_sources = [ 'port_matrix_labels.cc', 'port_matrix_row_labels.cc', 'processor_box.cc', + 'progress_reporter.cc', 'prompter.cc', 'public_editor.cc', 'quantize_dialog.cc', diff --git a/libs/ardour/ardour/filter.h b/libs/ardour/ardour/filter.h index 697e19539e..9d69a513ac 100644 --- a/libs/ardour/ardour/filter.h +++ b/libs/ardour/ardour/filter.h @@ -28,13 +28,14 @@ namespace ARDOUR { class Region; class Session; +class Progress; class Filter { public: virtual ~Filter() {} - virtual int run (boost::shared_ptr) = 0; + virtual int run (boost::shared_ptr, Progress* progress = 0) = 0; std::vector > results; protected: diff --git a/libs/ardour/ardour/midi_stretch.h b/libs/ardour/ardour/midi_stretch.h index 9dbfbca2bd..90c75bbc18 100644 --- a/libs/ardour/ardour/midi_stretch.h +++ b/libs/ardour/ardour/midi_stretch.h @@ -29,7 +29,7 @@ class MidiStretch : public Filter { MidiStretch (ARDOUR::Session&, TimeFXRequest&); ~MidiStretch (); - int run (boost::shared_ptr); + int run (boost::shared_ptr, Progress* progress = 0); private: TimeFXRequest& _request; diff --git a/libs/ardour/ardour/rb_effect.h b/libs/ardour/ardour/rb_effect.h index e4b1c00034..84c9bce53c 100644 --- a/libs/ardour/ardour/rb_effect.h +++ b/libs/ardour/ardour/rb_effect.h @@ -31,7 +31,7 @@ class RBEffect : public Filter { RBEffect (ARDOUR::Session&, TimeFXRequest&); ~RBEffect (); - int run (boost::shared_ptr); + int run (boost::shared_ptr, Progress* progress = 0); private: TimeFXRequest& tsr; diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index b78699d906..0ae325d124 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -68,6 +68,7 @@ namespace Properties { class Playlist; class Filter; class ExportSpecification; +class Progress; enum RegionEditState { EditChangesNothing = 0, @@ -205,7 +206,7 @@ class Region void set_locked (bool yn); void set_position_locked (bool yn); - int apply (Filter&); + int apply (Filter &, Progress* progress = 0); virtual uint64_t read_data_count() const { return _read_data_count; } diff --git a/libs/ardour/ardour/reverse.h b/libs/ardour/ardour/reverse.h index 0831e8184b..edc72ce707 100644 --- a/libs/ardour/ardour/reverse.h +++ b/libs/ardour/ardour/reverse.h @@ -29,7 +29,7 @@ class Reverse : public Filter { Reverse (ARDOUR::Session&); ~Reverse (); - int run (boost::shared_ptr); + int run (boost::shared_ptr, Progress *); }; } /* namespace */ diff --git a/libs/ardour/ardour/strip_silence.h b/libs/ardour/ardour/strip_silence.h index 217f6b3d8a..e77aa7111c 100644 --- a/libs/ardour/ardour/strip_silence.h +++ b/libs/ardour/ardour/strip_silence.h @@ -27,7 +27,7 @@ class StripSilence : public Filter { public: StripSilence (Session &, double, nframes_t, nframes_t); - int run (boost::shared_ptr); + int run (boost::shared_ptr, Progress* progress = 0); private: double _threshold; ///< silence threshold, in dBFS diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index dedae6acb1..ee1ccc31ae 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -42,7 +42,7 @@ MidiStretch::~MidiStretch () } int -MidiStretch::run (boost::shared_ptr r) +MidiStretch::run (boost::shared_ptr r, Progress* progress) { SourceList nsrcs; char suffix[32]; diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 60764c1220..32a2d056d6 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -60,7 +60,7 @@ RBEffect::~RBEffect () } int -RBEffect::run (boost::shared_ptr r) +RBEffect::run (boost::shared_ptr r, Progress* progress) { boost::shared_ptr region = boost::dynamic_pointer_cast (r); diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 07d27faee9..98f48ab80a 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1535,9 +1535,9 @@ Region::get_parent() const } int -Region::apply (Filter& filter) +Region::apply (Filter& filter, Progress* progress) { - return filter.run (shared_from_this()); + return filter.run (shared_from_this(), progress); } diff --git a/libs/ardour/reverse.cc b/libs/ardour/reverse.cc index 10fce58442..675ccb4c52 100644 --- a/libs/ardour/reverse.cc +++ b/libs/ardour/reverse.cc @@ -42,7 +42,7 @@ Reverse::~Reverse () } int -Reverse::run (boost::shared_ptr r) +Reverse::run (boost::shared_ptr r, Progress* progress) { SourceList nsrcs; SourceList::iterator si; diff --git a/libs/ardour/strip_silence.cc b/libs/ardour/strip_silence.cc index a7d7ab073f..a7308b06ab 100644 --- a/libs/ardour/strip_silence.cc +++ b/libs/ardour/strip_silence.cc @@ -24,6 +24,7 @@ #include "ardour/region_factory.h" #include "ardour/session.h" #include "ardour/dB.h" +#include "ardour/progress.h" using namespace ARDOUR; @@ -41,7 +42,7 @@ StripSilence::StripSilence (Session & s, double threshold, nframes_t minimum_len } int -StripSilence::run (boost::shared_ptr r) +StripSilence::run (boost::shared_ptr r, Progress* progress) { results.clear (); @@ -88,6 +89,9 @@ StripSilence::run (boost::shared_ptr r) in_silence = false; } + int n = 0; + int const N = silence.size (); + while (s != silence.end()) { framecnt_t interval_duration; @@ -119,6 +123,11 @@ StripSilence::run (boost::shared_ptr r) ++s; end = s->first; in_silence = !in_silence; + + if (progress) { + progress->set_progress (float (n) / N); + } + ++n; } return 0; diff --git a/libs/ardour/wscript b/libs/ardour/wscript index a7bc811999..a2c4898053 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -148,6 +148,7 @@ libardour_sources = [ 'port_set.cc', 'process_thread.cc', 'processor.cc', + 'progress.cc', 'quantize.cc', 'rc_configuration.cc', 'recent_sessions.cc', -- cgit v1.2.3