2009-04-29 13:05:42 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2009-04-29 13:05:42 -04:00
|
|
|
|
|
|
|
#include <gtkmm/spinbutton.h>
|
2012-07-25 13:48:55 -04:00
|
|
|
#include <glibmm/threads.h>
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2019-08-30 13:40:28 -04:00
|
|
|
#include <pbd/xml++.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 {
|
2015-09-19 14:31:32 -04: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:
|
2015-09-19 14:31:32 -04: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 ();
|
|
|
|
}
|
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
void drop_rects ();
|
2010-12-09 11:31:05 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
void silences (ARDOUR::AudioIntervalMap&);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
ARDOUR::samplecnt_t minimum_length () const;
|
|
|
|
ARDOUR::samplecnt_t fade_length () const;
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2017-04-20 13:03:52 -04:00
|
|
|
void on_response (int response_id) {
|
|
|
|
Gtk::Dialog::on_response (response_id);
|
|
|
|
}
|
|
|
|
|
2022-04-06 23:56:45 -04:00
|
|
|
XMLNode& get_state () const;
|
2019-08-30 13:40:28 -04:00
|
|
|
void set_state (const XMLNode &);
|
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
private:
|
2009-04-30 13:07:57 -04:00
|
|
|
void create_waves ();
|
|
|
|
void canvas_allocation (Gtk::Allocation &);
|
|
|
|
void update_silence_rects ();
|
2015-09-19 14:31:32 -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 ();
|
2019-08-30 15:44:50 -04:00
|
|
|
void finished(int);
|
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;
|
2015-09-19 14:31:32 -04:00
|
|
|
AudioClock* _fade_length;
|
2010-09-19 20:58:25 -04:00
|
|
|
Gtk::ProgressBar _progress_bar;
|
2009-04-30 13:07:57 -04:00
|
|
|
|
2015-09-19 14:28:56 -04:00
|
|
|
Gtk::Button* cancel_button;
|
|
|
|
Gtk::Button* apply_button;
|
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
struct ViewInterval {
|
|
|
|
RegionView* view;
|
|
|
|
ARDOUR::AudioIntervalResult intervals;
|
2010-12-08 16:02:37 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
ViewInterval (RegionView* rv) : view (rv) {}
|
|
|
|
};
|
2010-12-08 16:02:37 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
std::list<ViewInterval> views;
|
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;
|
2015-10-16 08:53:21 -04:00
|
|
|
|
|
|
|
sigc::connection progress_idle_connection;
|
|
|
|
bool idle_update_progress(); ///< GUI-thread progress updates of background silence computation
|
|
|
|
int analysis_progress_cur;
|
|
|
|
int analysis_progress_max;
|
2019-08-30 13:40:28 -04:00
|
|
|
|
|
|
|
int _threshold_value;
|
|
|
|
ARDOUR::samplecnt_t _minimum_length_value;
|
|
|
|
ARDOUR::samplecnt_t _fade_length_value;
|
2009-04-29 13:05:42 -04:00
|
|
|
};
|