2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/spinbutton.h>
21 #include <glibmm/thread.h>
23 #include "ardour/types.h"
24 #include "ardour_dialog.h"
26 #include "progress_reporter.h"
35 /// Dialog box to set options for the `strip silence' filter
36 class StripSilenceDialog
: public ArdourDialog
, public ProgressReporter
39 StripSilenceDialog (ARDOUR::Session
*, std::list
<RegionView
*> const &);
40 ~StripSilenceDialog ();
42 double threshold () const {
43 return _threshold
.get_value ();
48 void silences (ARDOUR::AudioIntervalMap
&);
50 ARDOUR::framecnt_t
minimum_length () const;
51 ARDOUR::framecnt_t
fade_length () const;
56 void canvas_allocation (Gtk::Allocation
&);
57 void update_silence_rects ();
58 void resize_silence_rects ();
60 void update_threshold_line ();
61 void update_stats (ARDOUR::AudioIntervalResult
const &);
62 void threshold_changed ();
63 void update_progress_gui (float);
64 void restart_thread ();
66 Gtk::SpinButton _threshold
;
67 AudioClock
* _minimum_length
;
68 AudioClock
* _fade_length
;
69 Gtk::ProgressBar _progress_bar
;
73 ARDOUR::AudioIntervalResult intervals
;
75 ViewInterval (RegionView
* rv
) : view (rv
) {}
78 std::list
<ViewInterval
> views
;
80 PBD::ScopedConnection
* _peaks_ready_connection
;
84 pthread_t _thread
; ///< thread to compute silence in the background
85 static void * _detection_thread_work (void *);
86 void * detection_thread_work ();
87 Glib::Mutex _lock
; ///< lock held while the thread is doing work
88 Glib::Cond _run_cond
; ///< condition to wake the thread
89 bool _thread_should_finish
; ///< true if the thread should terminate
90 PBD::Signal0
<void> Completed
; ///< emitted when a silence detection has completed
91 PBD::ScopedConnection _completed_connection
;
92 ARDOUR::InterThreadInfo _interthread_info
;