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>
|
2012-07-25 13:48:55 -04:00
|
|
|
#include <glibmm/threads.h>
|
2010-03-03 18:38:42 -05:00
|
|
|
|
|
|
|
#include "ardour/types.h"
|
2009-04-29 13:05:42 -04:00
|
|
|
#include "ardour_dialog.h"
|
2010-09-19 20:58:25 -04:00
|
|
|
#include "progress_reporter.h"
|
2009-04-30 13:07:57 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
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
|
|
|
|
2011-06-02 13:50:37 -04:00
|
|
|
class AudioClock;
|
2010-12-08 16:02:37 -05:00
|
|
|
class RegionView;
|
|
|
|
|
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-12-08 16:02:37 -05:00
|
|
|
StripSilenceDialog (ARDOUR::Session*, std::list<RegionView*> 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-12-09 11:31:05 -05:00
|
|
|
void drop_rects ();
|
|
|
|
|
2010-12-09 13:17:36 -05:00
|
|
|
void silences (ARDOUR::AudioIntervalMap&);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
ARDOUR::framecnt_t minimum_length () const;
|
|
|
|
ARDOUR::framecnt_t fade_length () const;
|
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 ();
|
2010-11-22 12:15:32 -05:00
|
|
|
void update ();
|
2010-04-30 10:50:25 -04:00
|
|
|
void update_threshold_line ();
|
2010-12-08 16:02:37 -05:00
|
|
|
void update_stats (ARDOUR::AudioIntervalResult const &);
|
2010-04-30 10:50:25 -04:00
|
|
|
void threshold_changed ();
|
2010-09-19 20:58:25 -04:00
|
|
|
void update_progress_gui (float);
|
2010-11-22 12:15:32 -05:00
|
|
|
void restart_thread ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
Gtk::SpinButton _threshold;
|
2011-06-02 13:50:37 -04:00
|
|
|
AudioClock* _minimum_length;
|
|
|
|
AudioClock* _fade_length;
|
2010-09-19 20:58:25 -04:00
|
|
|
Gtk::ProgressBar _progress_bar;
|
2009-04-30 13:07:57 -04:00
|
|
|
|
2010-12-08 16:02:37 -05:00
|
|
|
struct ViewInterval {
|
|
|
|
RegionView* view;
|
|
|
|
ARDOUR::AudioIntervalResult intervals;
|
|
|
|
|
|
|
|
ViewInterval (RegionView* rv) : view (rv) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::list<ViewInterval> views;
|
2010-03-04 21:09:37 -05:00
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
PBD::ScopedConnection* _peaks_ready_connection;
|
2010-03-04 21:09:37 -05:00
|
|
|
|
2010-11-22 20:00:37 -05:00
|
|
|
bool _destroying;
|
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
pthread_t _thread; ///< thread to compute silence in the background
|
|
|
|
static void * _detection_thread_work (void *);
|
|
|
|
void * detection_thread_work ();
|
2012-07-25 13:48:55 -04:00
|
|
|
Glib::Threads::Mutex _lock; ///< lock held while the thread is doing work
|
|
|
|
Glib::Threads::Cond _run_cond; ///< condition to wake the thread
|
2010-11-22 12:15:32 -05:00
|
|
|
bool _thread_should_finish; ///< true if the thread should terminate
|
|
|
|
PBD::Signal0<void> Completed; ///< emitted when a silence detection has completed
|
|
|
|
PBD::ScopedConnection _completed_connection;
|
|
|
|
ARDOUR::InterThreadInfo _interthread_info;
|
2009-04-29 13:05:42 -04:00
|
|
|
};
|