Add progress bar to strip silence dialogue. Fixes #3103.
git-svn-id: svn://localhost/ardour2/branches/3.0@7809 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
a212e7eec9
commit
a2885a430b
|
@ -127,6 +127,7 @@ class EditorLocations;
|
|||
class EditorSnapshots;
|
||||
class EditorSummary;
|
||||
class RegionLayeringOrderEditor;
|
||||
class ProgressReporter;
|
||||
|
||||
/* <CMT Additions> */
|
||||
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);
|
||||
|
|
|
@ -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> 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 ();
|
||||
|
|
|
@ -53,6 +53,7 @@ StripSilenceDialog* StripSilenceDialog::current = 0;
|
|||
/** Construct Strip silence dialog box */
|
||||
StripSilenceDialog::StripSilenceDialog (Session* s, list<boost::shared_ptr<ARDOUR::AudioRegion> > 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, list<boost::shared_ptr<ARDOU
|
|||
|
||||
get_vbox()->pack_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);
|
||||
}
|
||||
|
|
|
@ -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<boost::shared_ptr<ARDOUR::AudioRegion> > 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<std::pair<ARDOUR::frameoffset_t,ARDOUR::framecnt_t> > SilenceResult;
|
||||
|
||||
struct Wave {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -28,13 +28,14 @@ namespace ARDOUR {
|
|||
|
||||
class Region;
|
||||
class Session;
|
||||
class Progress;
|
||||
|
||||
class Filter {
|
||||
|
||||
public:
|
||||
virtual ~Filter() {}
|
||||
|
||||
virtual int run (boost::shared_ptr<ARDOUR::Region>) = 0;
|
||||
virtual int run (boost::shared_ptr<ARDOUR::Region>, Progress* progress = 0) = 0;
|
||||
std::vector<boost::shared_ptr<ARDOUR::Region> > results;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -29,7 +29,7 @@ class MidiStretch : public Filter {
|
|||
MidiStretch (ARDOUR::Session&, TimeFXRequest&);
|
||||
~MidiStretch ();
|
||||
|
||||
int run (boost::shared_ptr<ARDOUR::Region>);
|
||||
int run (boost::shared_ptr<ARDOUR::Region>, Progress* progress = 0);
|
||||
|
||||
private:
|
||||
TimeFXRequest& _request;
|
||||
|
|
|
@ -31,7 +31,7 @@ class RBEffect : public Filter {
|
|||
RBEffect (ARDOUR::Session&, TimeFXRequest&);
|
||||
~RBEffect ();
|
||||
|
||||
int run (boost::shared_ptr<ARDOUR::Region>);
|
||||
int run (boost::shared_ptr<ARDOUR::Region>, Progress* progress = 0);
|
||||
|
||||
private:
|
||||
TimeFXRequest& tsr;
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Reverse : public Filter {
|
|||
Reverse (ARDOUR::Session&);
|
||||
~Reverse ();
|
||||
|
||||
int run (boost::shared_ptr<ARDOUR::Region>);
|
||||
int run (boost::shared_ptr<ARDOUR::Region>, Progress *);
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
|
|
@ -27,7 +27,7 @@ class StripSilence : public Filter {
|
|||
public:
|
||||
StripSilence (Session &, double, nframes_t, nframes_t);
|
||||
|
||||
int run (boost::shared_ptr<ARDOUR::Region>);
|
||||
int run (boost::shared_ptr<ARDOUR::Region>, Progress* progress = 0);
|
||||
|
||||
private:
|
||||
double _threshold; ///< silence threshold, in dBFS
|
||||
|
|
|
@ -42,7 +42,7 @@ MidiStretch::~MidiStretch ()
|
|||
}
|
||||
|
||||
int
|
||||
MidiStretch::run (boost::shared_ptr<Region> r)
|
||||
MidiStretch::run (boost::shared_ptr<Region> r, Progress* progress)
|
||||
{
|
||||
SourceList nsrcs;
|
||||
char suffix[32];
|
||||
|
|
|
@ -60,7 +60,7 @@ RBEffect::~RBEffect ()
|
|||
}
|
||||
|
||||
int
|
||||
RBEffect::run (boost::shared_ptr<Region> r)
|
||||
RBEffect::run (boost::shared_ptr<Region> r, Progress* progress)
|
||||
{
|
||||
boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (r);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ Reverse::~Reverse ()
|
|||
}
|
||||
|
||||
int
|
||||
Reverse::run (boost::shared_ptr<Region> r)
|
||||
Reverse::run (boost::shared_ptr<Region> r, Progress* progress)
|
||||
{
|
||||
SourceList nsrcs;
|
||||
SourceList::iterator si;
|
||||
|
|
|
@ -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<Region> r)
|
||||
StripSilence::run (boost::shared_ptr<Region> r, Progress* progress)
|
||||
{
|
||||
results.clear ();
|
||||
|
||||
|
@ -88,6 +89,9 @@ StripSilence::run (boost::shared_ptr<Region> 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<Region> r)
|
|||
++s;
|
||||
end = s->first;
|
||||
in_silence = !in_silence;
|
||||
|
||||
if (progress) {
|
||||
progress->set_progress (float (n) / N);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -148,6 +148,7 @@ libardour_sources = [
|
|||
'port_set.cc',
|
||||
'process_thread.cc',
|
||||
'processor.cc',
|
||||
'progress.cc',
|
||||
'quantize.cc',
|
||||
'rc_configuration.cc',
|
||||
'recent_sessions.cc',
|
||||
|
|
Loading…
Reference in New Issue
Block a user