2009-04-29 13:05:42 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2009 Paul Davis
|
2009-04-29 13:05:42 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtkmm/spinbutton.h>
|
2010-03-03 18:38:42 -05:00
|
|
|
#include <glibmm/thread.h>
|
|
|
|
|
|
|
|
#include "ardour/types.h"
|
2009-04-29 13:05:42 -04:00
|
|
|
#include "ardour_dialog.h"
|
2009-04-30 13:07:57 -04:00
|
|
|
#include "canvas.h"
|
2010-09-19 20:58:25 -04:00
|
|
|
#include "progress_reporter.h"
|
2009-04-30 13:07:57 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
|
|
|
class AudioRegion;
|
2010-03-04 21:09:37 -05:00
|
|
|
class Session;
|
2009-04-30 13:07:57 -04:00
|
|
|
}
|
2009-04-29 13:05:42 -04:00
|
|
|
|
|
|
|
/// Dialog box to set options for the `strip silence' filter
|
2010-09-19 20:58:25 -04:00
|
|
|
class StripSilenceDialog : public ArdourDialog, public ProgressReporter
|
2009-04-29 13:05:42 -04:00
|
|
|
{
|
|
|
|
public:
|
2010-03-04 21:09:37 -05:00
|
|
|
StripSilenceDialog (ARDOUR::Session*, std::list<boost::shared_ptr<ARDOUR::AudioRegion> > const &);
|
2009-04-30 13:07:57 -04:00
|
|
|
~StripSilenceDialog ();
|
2009-04-29 13:05:42 -04:00
|
|
|
|
|
|
|
double threshold () const {
|
|
|
|
return _threshold.get_value ();
|
|
|
|
}
|
|
|
|
|
2010-03-04 21:09:37 -05:00
|
|
|
nframes_t minimum_length () const;
|
|
|
|
nframes_t fade_length () const;
|
|
|
|
static void stop_thread ();
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
private:
|
2009-04-30 13:07:57 -04:00
|
|
|
void create_waves ();
|
|
|
|
void peaks_ready ();
|
|
|
|
void canvas_allocation (Gtk::Allocation &);
|
|
|
|
void update_silence_rects ();
|
2010-04-30 10:50:25 -04:00
|
|
|
void resize_silence_rects ();
|
|
|
|
void update_threshold_line ();
|
|
|
|
void threshold_changed ();
|
2010-09-19 20:58:25 -04:00
|
|
|
void update_progress_gui (float);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
Gtk::SpinButton _threshold;
|
2010-03-04 21:09:37 -05:00
|
|
|
AudioClock _minimum_length;
|
|
|
|
AudioClock _fade_length;
|
2010-03-03 18:38:42 -05:00
|
|
|
Gtk::Label _segment_count_label;
|
2010-04-30 10:50:25 -04:00
|
|
|
Gtk::Label _shortest_silence_label;
|
|
|
|
Gtk::Label _shortest_audible_label;
|
2010-09-19 20:58:25 -04:00
|
|
|
Gtk::ProgressBar _progress_bar;
|
2010-03-04 21:09:37 -05:00
|
|
|
typedef std::list<std::pair<ARDOUR::frameoffset_t,ARDOUR::framecnt_t> > SilenceResult;
|
2009-04-30 13:07:57 -04:00
|
|
|
|
|
|
|
struct Wave {
|
2010-03-03 18:38:42 -05:00
|
|
|
boost::shared_ptr<ARDOUR::AudioRegion> region;
|
|
|
|
ArdourCanvas::WaveView* view;
|
|
|
|
std::list<ArdourCanvas::SimpleRect*> silence_rects;
|
2010-04-30 10:50:25 -04:00
|
|
|
ArdourCanvas::SimpleLine* threshold_line;
|
2010-03-03 18:38:42 -05:00
|
|
|
double samples_per_unit;
|
2010-03-04 21:09:37 -05:00
|
|
|
SilenceResult silence;
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
Wave (ArdourCanvas::Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
|
|
|
|
~Wave ();
|
2009-04-30 13:07:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
ArdourCanvas::Canvas* _canvas;
|
2010-04-30 10:50:25 -04:00
|
|
|
std::list<Wave*> _waves;
|
2009-04-30 13:07:57 -04:00
|
|
|
int _wave_width;
|
|
|
|
int _wave_height;
|
2010-03-03 18:38:42 -05:00
|
|
|
bool restart_queued;
|
|
|
|
|
2010-03-04 21:09:37 -05:00
|
|
|
static ARDOUR::InterThreadInfo itt;
|
|
|
|
static bool thread_should_exit;
|
|
|
|
static Glib::Cond *thread_run;
|
|
|
|
static Glib::Cond *thread_waiting;
|
|
|
|
static Glib::StaticMutex run_lock;
|
|
|
|
static StripSilenceDialog* current;
|
|
|
|
|
|
|
|
ARDOUR::framecnt_t max_audible;
|
|
|
|
ARDOUR::framecnt_t min_audible;
|
|
|
|
ARDOUR::framecnt_t max_silence;
|
|
|
|
ARDOUR::framecnt_t min_silence;
|
2009-04-30 13:07:57 -04:00
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
PBD::ScopedConnection* _peaks_ready_connection;
|
2010-03-03 18:38:42 -05:00
|
|
|
|
|
|
|
static bool _detection_done (void*);
|
|
|
|
static void* _detection_thread_work (void*);
|
|
|
|
|
|
|
|
bool detection_done ();
|
|
|
|
void* detection_thread_work ();
|
|
|
|
bool start_silence_detection ();
|
|
|
|
void maybe_start_silence_detection ();
|
2010-03-04 21:09:37 -05:00
|
|
|
|
|
|
|
void update_stats (const SilenceResult&);
|
2009-04-29 13:05:42 -04:00
|
|
|
};
|