Use a C++ bool constant
[ardour.git] / gtk2_ardour / strip_silence_dialog.h
1 /*
2     Copyright (C) 2009 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include <gtkmm/spinbutton.h>
21 #include <glibmm/threads.h>
22
23 #include "ardour/types.h"
24 #include "ardour_dialog.h"
25 #include "progress_reporter.h"
26
27 namespace ARDOUR {
28         class Session;
29 }
30
31 class AudioClock;
32 class RegionView;
33
34 /// Dialog box to set options for the `strip silence' filter
35 class StripSilenceDialog : public ArdourDialog, public ProgressReporter
36 {
37 public:
38         StripSilenceDialog (ARDOUR::Session*, std::list<RegionView*> const &);
39         ~StripSilenceDialog ();
40
41         double threshold () const {
42                 return _threshold.get_value ();
43         }
44
45         void drop_rects ();
46
47         void silences (ARDOUR::AudioIntervalMap&);
48
49         ARDOUR::framecnt_t minimum_length () const;
50         ARDOUR::framecnt_t fade_length () const;
51
52 private:
53         void create_waves ();
54         void canvas_allocation (Gtk::Allocation &);
55         void update_silence_rects ();
56         void resize_silence_rects ();
57         void update ();
58         void update_threshold_line ();
59         void update_stats (ARDOUR::AudioIntervalResult const &);
60         void threshold_changed ();
61         void update_progress_gui (float);
62         void restart_thread ();
63
64         Gtk::SpinButton _threshold;
65         AudioClock*      _minimum_length;
66         AudioClock*      _fade_length;
67         Gtk::ProgressBar _progress_bar;
68
69         Gtk::Button* cancel_button;
70         Gtk::Button* apply_button;
71
72         struct ViewInterval {
73                 RegionView* view;
74                 ARDOUR::AudioIntervalResult intervals;
75
76                 ViewInterval (RegionView* rv) : view (rv) {}
77         };
78
79         std::list<ViewInterval> views;
80
81         bool _destroying;
82
83         pthread_t _thread; ///< thread to compute silence in the background
84         static void * _detection_thread_work (void *);
85         void * detection_thread_work ();
86         Glib::Threads::Mutex _lock; ///< lock held while the thread is doing work
87         Glib::Threads::Cond  _run_cond; ///< condition to wake the thread
88         bool _thread_should_finish; ///< true if the thread should terminate
89         PBD::Signal0<void> Completed; ///< emitted when a silence detection has completed
90         PBD::ScopedConnection _completed_connection;
91         ARDOUR::InterThreadInfo _interthread_info;
92
93         sigc::connection progress_idle_connection;
94         bool idle_update_progress(); ///< GUI-thread progress updates of background silence computation
95         int analysis_progress_cur;
96         int analysis_progress_max;
97 };