Copy local state in AudioRegionView copy constructor. Fixes #4047.
[ardour2.git] / gtk2_ardour / strip_silence_dialog.h
blob886017ca8a855071ed4d88cd222bf8de9c98b7bb
1 /*
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"
25 #include "canvas.h"
26 #include "progress_reporter.h"
28 namespace ARDOUR {
29 class Session;
32 class RegionView;
34 /// Dialog box to set options for the `strip silence' filter
35 class StripSilenceDialog : public ArdourDialog, public ProgressReporter
37 public:
38 StripSilenceDialog (ARDOUR::Session*, std::list<RegionView*> const &);
39 ~StripSilenceDialog ();
41 double threshold () const {
42 return _threshold.get_value ();
45 void drop_rects ();
47 void silences (ARDOUR::AudioIntervalMap&);
49 ARDOUR::framecnt_t minimum_length () const;
50 ARDOUR::framecnt_t fade_length () const;
52 private:
53 void create_waves ();
54 void peaks_ready ();
55 void canvas_allocation (Gtk::Allocation &);
56 void update_silence_rects ();
57 void resize_silence_rects ();
58 void update ();
59 void update_threshold_line ();
60 void update_stats (ARDOUR::AudioIntervalResult const &);
61 void threshold_changed ();
62 void update_progress_gui (float);
63 void restart_thread ();
65 Gtk::SpinButton _threshold;
66 AudioClock _minimum_length;
67 AudioClock _fade_length;
68 Gtk::ProgressBar _progress_bar;
70 struct ViewInterval {
71 RegionView* view;
72 ARDOUR::AudioIntervalResult intervals;
74 ViewInterval (RegionView* rv) : view (rv) {}
77 std::list<ViewInterval> views;
79 PBD::ScopedConnection* _peaks_ready_connection;
81 bool _destroying;
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::Mutex _lock; ///< lock held while the thread is doing work
87 Glib::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;