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"
32 /// Dialog box to set options for the `strip silence' filter
33 class StripSilenceDialog : public ArdourDialog
36 StripSilenceDialog (ARDOUR::Session*, std::list<boost::shared_ptr<ARDOUR::AudioRegion> > const &);
37 ~StripSilenceDialog ();
39 double threshold () const {
40 return _threshold.get_value ();
43 nframes_t minimum_length () const;
44 nframes_t fade_length () const;
45 static void stop_thread ();
50 void canvas_allocation (Gtk::Allocation &);
51 void update_silence_rects ();
52 void redraw_silence_rects ();
54 Gtk::SpinButton _threshold;
55 AudioClock _minimum_length;
56 AudioClock _fade_length;
57 Gtk::Label _segment_count_label;
58 typedef std::list<std::pair<ARDOUR::frameoffset_t,ARDOUR::framecnt_t> > SilenceResult;
61 boost::shared_ptr<ARDOUR::AudioRegion> region;
62 ArdourCanvas::WaveView* view;
63 std::list<ArdourCanvas::SimpleRect*> silence_rects;
64 double samples_per_unit;
65 SilenceResult silence;
67 Wave() : view (0), samples_per_unit (1) { }
70 ArdourCanvas::Canvas* _canvas;
71 std::list<Wave> _waves;
76 static ARDOUR::InterThreadInfo itt;
77 static bool thread_should_exit;
78 static Glib::Cond *thread_run;
79 static Glib::Cond *thread_waiting;
80 static Glib::StaticMutex run_lock;
81 static StripSilenceDialog* current;
83 ARDOUR::framecnt_t max_audible;
84 ARDOUR::framecnt_t min_audible;
85 ARDOUR::framecnt_t max_silence;
86 ARDOUR::framecnt_t min_silence;
88 PBD::ScopedConnection _peaks_ready_connection;
90 static bool _detection_done (void*);
91 static void* _detection_thread_work (void*);
93 bool detection_done ();
94 void* detection_thread_work ();
95 bool start_silence_detection ();
96 void maybe_start_silence_detection ();
98 void update_stats (const SilenceResult&);