2009-04-29 13:05:42 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2015-2019 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
|
|
|
|
2010-03-03 18:38:42 -05:00
|
|
|
#include <iostream>
|
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
#include <gtkmm/table.h>
|
|
|
|
#include <gtkmm/label.h>
|
2017-07-16 22:55:52 -04:00
|
|
|
#include <gtkmm/progressbar.h>
|
2009-04-29 13:05:42 -04:00
|
|
|
#include <gtkmm/stock.h>
|
2009-12-21 13:23:07 -05:00
|
|
|
|
2020-03-29 08:56:50 -04:00
|
|
|
#include "pbd/pthread_utils.h"
|
|
|
|
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/audioregion.h"
|
2009-04-30 13:07:57 -04:00
|
|
|
#include "ardour/dB.h"
|
2016-09-25 16:02:16 -04:00
|
|
|
#include "ardour/logmeter.h"
|
2009-04-30 13:07:57 -04:00
|
|
|
#include "ardour_ui.h"
|
2010-03-04 21:05:20 -05:00
|
|
|
|
2011-06-02 13:50:37 -04:00
|
|
|
#include "audio_clock.h"
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "gui_thread.h"
|
2009-04-29 13:05:42 -04:00
|
|
|
#include "strip_silence_dialog.h"
|
2010-12-08 16:02:37 -05:00
|
|
|
#include "region_view.h"
|
2009-04-30 13:07:57 -04:00
|
|
|
#include "rgb_macros.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2009-04-29 13:05:42 -04:00
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
using namespace ARDOUR;
|
2010-03-03 18:38:42 -05:00
|
|
|
using namespace std;
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
/** Construct Strip silence dialog box */
|
2010-12-08 16:02:37 -05:00
|
|
|
StripSilenceDialog::StripSilenceDialog (Session* s, list<RegionView*> const & v)
|
2010-03-03 18:38:42 -05:00
|
|
|
: ArdourDialog (_("Strip Silence"))
|
2010-09-19 20:58:25 -04:00
|
|
|
, ProgressReporter ()
|
2015-09-19 14:31:32 -04:00
|
|
|
, _minimum_length (new AudioClock (X_("silence duration"), true, "", true, false, true, false))
|
|
|
|
, _fade_length (new AudioClock (X_("silence duration"), true, "", true, false, true, false))
|
2010-11-22 20:00:37 -05:00
|
|
|
, _destroying (false)
|
2015-10-16 08:53:21 -04:00
|
|
|
, analysis_progress_cur (0)
|
|
|
|
, analysis_progress_max (0)
|
2019-08-30 13:40:28 -04:00
|
|
|
, _threshold_value (-60)
|
|
|
|
, _minimum_length_value (1000)
|
|
|
|
, _fade_length_value (64)
|
2009-04-29 13:05:42 -04:00
|
|
|
{
|
2015-09-19 14:31:32 -04:00
|
|
|
set_session (s);
|
2010-03-04 21:05:20 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
for (list<RegionView*>::const_iterator r = v.begin(); r != v.end(); ++r) {
|
|
|
|
views.push_back (ViewInterval (*r));
|
|
|
|
}
|
2010-12-08 16:02:37 -05:00
|
|
|
|
2009-04-30 13:07:57 -04:00
|
|
|
Gtk::HBox* hbox = Gtk::manage (new Gtk::HBox);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
Gtk::Table* table = Gtk::manage (new Gtk::Table (3, 3));
|
|
|
|
table->set_spacings (6);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-30 13:40:28 -04:00
|
|
|
//get the last used settings for this
|
|
|
|
XMLNode* node = _session->extra_xml(X_("StripSilence"));
|
|
|
|
if (node) {
|
|
|
|
node->get_property(X_("threshold"), _threshold_value);
|
|
|
|
node->get_property(X_("min-length"), _minimum_length_value);
|
|
|
|
node->get_property(X_("fade-length"), _fade_length_value);
|
|
|
|
}
|
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
int n = 0;
|
2009-04-29 13:05:42 -04:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
table->attach (*Gtk::manage (new Gtk::Label (_("Threshold"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
|
|
|
|
table->attach (_threshold, 1, 2, n, n + 1, Gtk::FILL);
|
2016-07-24 14:30:08 -04:00
|
|
|
table->attach (*Gtk::manage (new Gtk::Label (_("dBFS"))), 2, 3, n, n + 1, Gtk::FILL);
|
2010-04-30 10:50:25 -04:00
|
|
|
++n;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
_threshold.set_digits (1);
|
|
|
|
_threshold.set_increments (1, 10);
|
|
|
|
_threshold.set_range (-120, 0);
|
2019-08-30 13:40:28 -04:00
|
|
|
_threshold.set_value (_threshold_value);
|
2011-11-14 08:44:05 -05:00
|
|
|
_threshold.set_activates_default ();
|
2010-03-04 21:05:20 -05:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
table->attach (*Gtk::manage (new Gtk::Label (_("Minimum length"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
|
2011-06-02 13:50:37 -04:00
|
|
|
table->attach (*_minimum_length, 1, 2, n, n + 1, Gtk::FILL);
|
2010-04-30 10:50:25 -04:00
|
|
|
++n;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
_minimum_length->set_session (s);
|
2017-09-18 12:39:17 -04:00
|
|
|
_minimum_length->set_mode (AudioClock::Samples);
|
2020-10-05 00:52:17 -04:00
|
|
|
_minimum_length->set_duration (timecnt_t (_minimum_length_value), true);
|
2009-04-29 13:05:42 -04:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
table->attach (*Gtk::manage (new Gtk::Label (_("Fade length"), 1, 0.5)), 0, 1, n, n + 1, Gtk::FILL);
|
2015-09-19 14:31:32 -04:00
|
|
|
table->attach (*_fade_length, 1, 2, n, n + 1, Gtk::FILL);
|
2010-04-30 10:50:25 -04:00
|
|
|
++n;
|
2010-03-04 21:05:20 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
_fade_length->set_session (s);
|
2017-09-18 12:39:17 -04:00
|
|
|
_fade_length->set_mode (AudioClock::Samples);
|
2020-10-05 00:52:17 -04:00
|
|
|
_fade_length->set_duration (timecnt_t (_fade_length_value), true);
|
2009-04-30 13:07:57 -04:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
hbox->pack_start (*table);
|
|
|
|
|
2010-03-03 18:38:42 -05:00
|
|
|
get_vbox()->pack_start (*hbox, false, false);
|
2009-04-29 13:05:42 -04:00
|
|
|
|
2015-09-19 14:28:56 -04:00
|
|
|
cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
|
|
|
apply_button = add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_OK);
|
2011-11-14 08:44:05 -05:00
|
|
|
set_default_response (Gtk::RESPONSE_OK);
|
2009-04-29 13:05:42 -04:00
|
|
|
|
2010-12-09 11:31:05 -05:00
|
|
|
get_vbox()->pack_start (_progress_bar, true, true, 12);
|
2010-09-19 20:58:25 -04:00
|
|
|
|
2009-04-29 13:05:42 -04:00
|
|
|
show_all ();
|
2009-04-30 13:07:57 -04:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
_threshold.get_adjustment()->signal_value_changed().connect (sigc::mem_fun (*this, &StripSilenceDialog::threshold_changed));
|
|
|
|
_minimum_length->ValueChanged.connect (sigc::mem_fun (*this, &StripSilenceDialog::restart_thread));
|
2015-09-19 19:28:37 -04:00
|
|
|
_fade_length->ValueChanged.connect (sigc::mem_fun (*this, &StripSilenceDialog::restart_thread));
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2009-04-30 13:07:57 -04:00
|
|
|
update_silence_rects ();
|
2010-04-30 10:50:25 -04:00
|
|
|
update_threshold_line ();
|
|
|
|
|
2015-10-15 18:13:02 -04:00
|
|
|
_progress_bar.set_text (_("Analyzing"));
|
2015-10-16 08:53:21 -04:00
|
|
|
update_progress_gui (0);
|
2015-10-15 18:13:02 -04:00
|
|
|
apply_button->set_sensitive (false);
|
2015-10-16 08:53:21 -04:00
|
|
|
progress_idle_connection = Glib::signal_idle().connect (sigc::mem_fun (*this, &StripSilenceDialog::idle_update_progress));
|
2015-10-15 18:13:02 -04:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Create a thread which runs while the dialogue is open to compute the silence regions */
|
2015-09-19 12:29:51 -04:00
|
|
|
Completed.connect (_completed_connection, invalidator(*this), boost::bind (&StripSilenceDialog::update, this), gui_context ());
|
2010-11-22 12:15:32 -05:00
|
|
|
_thread_should_finish = false;
|
|
|
|
pthread_create (&_thread, 0, StripSilenceDialog::_detection_thread_work, this);
|
2019-08-30 15:44:50 -04:00
|
|
|
|
|
|
|
signal_response().connect(sigc::mem_fun (*this, &StripSilenceDialog::finished));
|
2009-04-30 13:07:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StripSilenceDialog::~StripSilenceDialog ()
|
|
|
|
{
|
2010-11-22 20:00:37 -05:00
|
|
|
_destroying = true;
|
2015-10-16 08:53:21 -04:00
|
|
|
progress_idle_connection.disconnect();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Terminate our thread */
|
|
|
|
_interthread_info.cancel = true;
|
2015-10-16 08:53:21 -04:00
|
|
|
_lock.lock ();
|
2010-11-22 12:15:32 -05:00
|
|
|
_thread_should_finish = true;
|
|
|
|
_lock.unlock ();
|
2010-11-22 20:00:37 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
_run_cond.signal ();
|
|
|
|
pthread_join (_thread, 0);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-06-02 13:50:37 -04:00
|
|
|
delete _minimum_length;
|
|
|
|
delete _fade_length;
|
2010-12-09 11:31:05 -05:00
|
|
|
}
|
|
|
|
|
2015-10-16 08:53:21 -04:00
|
|
|
bool
|
|
|
|
StripSilenceDialog::idle_update_progress()
|
|
|
|
{
|
|
|
|
if (analysis_progress_max > 0) {
|
|
|
|
// AudioRegion::find_silence() has
|
|
|
|
// itt.progress = (end - pos) / length
|
|
|
|
// not sure if that's intentional, but let's use (1. - val)
|
|
|
|
float rp = std::min(1.f, std::max (0.f, (1.f - _interthread_info.progress)));
|
|
|
|
float p = analysis_progress_cur / (float) analysis_progress_max
|
|
|
|
+ rp / (float) analysis_progress_max;
|
|
|
|
update_progress_gui (p);
|
|
|
|
}
|
|
|
|
return !_destroying;
|
|
|
|
}
|
|
|
|
|
2010-12-09 13:17:36 -05:00
|
|
|
void
|
|
|
|
StripSilenceDialog::silences (AudioIntervalMap& m)
|
2010-12-09 11:31:05 -05:00
|
|
|
{
|
2015-09-19 14:31:32 -04:00
|
|
|
for (list<ViewInterval>::iterator v = views.begin(); v != views.end(); ++v) {
|
2023-02-16 18:33:28 -05:00
|
|
|
pair<std::shared_ptr<Region>,AudioIntervalResult> newpair (v->view->region(), v->intervals);
|
2015-09-19 14:31:32 -04:00
|
|
|
m.insert (newpair);
|
|
|
|
}
|
2010-12-09 11:31:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StripSilenceDialog::drop_rects ()
|
|
|
|
{
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
// called by parent when starting to progress (dialog::run returned),
|
|
|
|
// but before the dialog is destroyed.
|
2015-09-19 14:28:56 -04:00
|
|
|
|
2015-10-15 18:13:02 -04:00
|
|
|
_interthread_info.cancel = true;
|
|
|
|
|
2015-10-16 08:53:21 -04:00
|
|
|
/* Block until the thread is idle */
|
|
|
|
_lock.lock ();
|
|
|
|
_lock.unlock ();
|
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
for (list<ViewInterval>::iterator v = views.begin(); v != views.end(); ++v) {
|
2019-04-08 18:31:29 -04:00
|
|
|
v->view->drop_silent_frames ();
|
2015-09-19 14:31:32 -04:00
|
|
|
}
|
2015-09-19 14:28:56 -04:00
|
|
|
|
|
|
|
cancel_button->set_sensitive (false);
|
|
|
|
apply_button->set_sensitive (false);
|
2009-04-30 13:07:57 -04:00
|
|
|
}
|
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
void
|
|
|
|
StripSilenceDialog::update_threshold_line ()
|
|
|
|
{
|
2010-12-08 16:02:37 -05:00
|
|
|
#if 0
|
2010-04-30 10:50:25 -04:00
|
|
|
int n = 0;
|
2010-11-22 12:15:32 -05:00
|
|
|
|
|
|
|
/* Don't need to lock here as we're not reading the _waves silence details */
|
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
for (list<Wave*>::iterator i = _waves.begin(); i != _waves.end(); ++i) {
|
|
|
|
(*i)->threshold_line->property_x1() = 0;
|
|
|
|
(*i)->threshold_line->property_x2() = _wave_width;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-04-30 10:50:25 -04:00
|
|
|
double const y = alt_log_meter (_threshold.get_value());
|
|
|
|
|
|
|
|
(*i)->threshold_line->property_y1() = (n + 1 - y) * _wave_height;
|
|
|
|
(*i)->threshold_line->property_y2() = (n + 1 - y) * _wave_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
++n;
|
2010-12-08 16:02:37 -05:00
|
|
|
#endif
|
2010-04-30 10:50:25 -04:00
|
|
|
}
|
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
void
|
|
|
|
StripSilenceDialog::update ()
|
|
|
|
{
|
|
|
|
update_threshold_line ();
|
2010-12-08 16:02:37 -05:00
|
|
|
update_silence_rects ();
|
2015-10-15 18:13:02 -04:00
|
|
|
_progress_bar.set_text ("");
|
2015-10-16 08:53:21 -04:00
|
|
|
update_progress_gui (0);
|
2015-10-15 18:13:02 -04:00
|
|
|
apply_button->set_sensitive(true);
|
2010-11-22 12:15:32 -05:00
|
|
|
}
|
|
|
|
|
2009-04-30 13:07:57 -04:00
|
|
|
void
|
|
|
|
StripSilenceDialog::update_silence_rects ()
|
|
|
|
{
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Lock so that we don't contend with the detection thread for access to the silence regions */
|
2012-07-25 13:48:55 -04:00
|
|
|
Glib::Threads::Mutex::Lock lm (_lock);
|
2015-09-19 14:31:32 -04:00
|
|
|
double const y = _threshold.get_value();
|
2010-12-09 13:17:36 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
for (list<ViewInterval>::iterator v = views.begin(); v != views.end(); ++v) {
|
2019-04-08 18:31:29 -04:00
|
|
|
v->view->set_silent_frames (v->intervals, y);
|
2009-04-30 13:07:57 -04:00
|
|
|
}
|
2010-03-03 18:38:42 -05:00
|
|
|
}
|
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
void *
|
2010-03-03 18:38:42 -05:00
|
|
|
StripSilenceDialog::_detection_thread_work (void* arg)
|
|
|
|
{
|
2010-11-22 12:15:32 -05:00
|
|
|
StripSilenceDialog* d = reinterpret_cast<StripSilenceDialog*> (arg);
|
2020-03-29 08:56:50 -04:00
|
|
|
pthread_set_name ("SilenceDetect");
|
2010-11-22 12:15:32 -05:00
|
|
|
return d->detection_thread_work ();
|
2010-03-03 18:38:42 -05:00
|
|
|
}
|
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/** Body of our silence detection thread */
|
|
|
|
void *
|
2010-03-03 18:38:42 -05:00
|
|
|
StripSilenceDialog::detection_thread_work ()
|
|
|
|
{
|
2015-12-28 10:14:17 -05:00
|
|
|
/* Do not register with all UIs, but do register with the GUI,
|
|
|
|
because we will need to queue some GUI (only) requests
|
|
|
|
*/
|
|
|
|
ARDOUR_UI::instance()->register_thread (pthread_self(), "silence", 32);
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Hold this lock when we are doing work */
|
|
|
|
_lock.lock ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
while (1) {
|
2015-10-16 08:53:21 -04:00
|
|
|
analysis_progress_cur = 0;
|
|
|
|
analysis_progress_max = views.size();
|
2010-12-08 16:02:37 -05:00
|
|
|
for (list<ViewInterval>::iterator i = views.begin(); i != views.end(); ++i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<AudioRegion> ar = std::dynamic_pointer_cast<AudioRegion> ((*i).view->region());
|
2010-12-08 16:02:37 -05:00
|
|
|
|
2015-09-19 14:31:32 -04:00
|
|
|
if (ar) {
|
2015-09-19 19:28:37 -04:00
|
|
|
i->intervals = ar->find_silence (dB_to_coefficient (threshold ()), minimum_length (), fade_length(), _interthread_info);
|
2015-09-19 14:31:32 -04:00
|
|
|
}
|
2010-12-08 16:02:37 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
if (_interthread_info.cancel) {
|
|
|
|
break;
|
|
|
|
}
|
2015-10-16 08:53:21 -04:00
|
|
|
++analysis_progress_cur;
|
|
|
|
_interthread_info.progress = 1.0;
|
|
|
|
ARDOUR::GUIIdle ();
|
2010-11-22 12:15:32 -05:00
|
|
|
}
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2015-10-16 08:53:21 -04:00
|
|
|
analysis_progress_max = 0;
|
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
if (!_interthread_info.cancel) {
|
|
|
|
Completed (); /* EMIT SIGNAL */
|
|
|
|
}
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Our work is done; sleep until there is more to do.
|
|
|
|
* The lock is released while we are waiting.
|
|
|
|
*/
|
|
|
|
_run_cond.wait (_lock);
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
if (_thread_should_finish) {
|
|
|
|
_lock.unlock ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
return 0;
|
2010-04-30 10:50:25 -04:00
|
|
|
}
|
|
|
|
|
2010-03-03 18:38:42 -05:00
|
|
|
void
|
2010-11-22 12:15:32 -05:00
|
|
|
StripSilenceDialog::restart_thread ()
|
2010-03-03 18:38:42 -05:00
|
|
|
{
|
2010-11-22 20:00:37 -05:00
|
|
|
if (_destroying) {
|
|
|
|
/* I don't know how this happens, but it seems to be possible for this
|
|
|
|
method to be called after our destructor has finished executing.
|
|
|
|
If this happens, bad things follow; _lock cannot be locked and
|
|
|
|
Ardour hangs. So if we are destroying, just bail early.
|
2015-09-19 14:31:32 -04:00
|
|
|
*/
|
2010-11-22 20:00:37 -05:00
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-10-15 18:13:02 -04:00
|
|
|
_progress_bar.set_text (_("Analyzing"));
|
2015-10-16 08:53:21 -04:00
|
|
|
update_progress_gui (0);
|
2015-10-15 18:13:02 -04:00
|
|
|
apply_button->set_sensitive (false);
|
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Cancel any current run */
|
|
|
|
_interthread_info.cancel = true;
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* Block until the thread waits() */
|
|
|
|
_lock.lock ();
|
|
|
|
/* Reset the flag */
|
|
|
|
_interthread_info.cancel = false;
|
|
|
|
_lock.unlock ();
|
2010-03-03 18:38:42 -05:00
|
|
|
|
2010-11-22 12:15:32 -05:00
|
|
|
/* And re-awake the thread */
|
|
|
|
_run_cond.signal ();
|
2010-03-03 18:38:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-22 12:15:32 -05:00
|
|
|
StripSilenceDialog::threshold_changed ()
|
2010-03-03 18:38:42 -05:00
|
|
|
{
|
2010-11-22 12:15:32 -05:00
|
|
|
update_threshold_line ();
|
|
|
|
restart_thread ();
|
2009-04-29 13:05:42 -04:00
|
|
|
}
|
2010-03-04 21:05:20 -05:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplecnt_t
|
2010-03-04 21:05:20 -05:00
|
|
|
StripSilenceDialog::minimum_length () const
|
|
|
|
{
|
2020-11-30 12:59:17 -05:00
|
|
|
return std::max((samplecnt_t)1, _minimum_length->current_duration (views.front().view->region()->position()).samples());
|
2010-03-04 21:05:20 -05:00
|
|
|
}
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplecnt_t
|
2010-03-04 21:05:20 -05:00
|
|
|
StripSilenceDialog::fade_length () const
|
|
|
|
{
|
2020-11-30 12:59:17 -05:00
|
|
|
return std::max((samplecnt_t)0, _fade_length->current_duration (views.front().view->region()->position()).samples());
|
2010-04-30 10:50:25 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-19 20:58:25 -04:00
|
|
|
void
|
|
|
|
StripSilenceDialog::update_progress_gui (float p)
|
|
|
|
{
|
|
|
|
_progress_bar.set_fraction (p);
|
|
|
|
}
|
2019-08-30 13:40:28 -04:00
|
|
|
|
|
|
|
XMLNode&
|
2022-04-06 23:56:45 -04:00
|
|
|
StripSilenceDialog::get_state () const
|
2019-08-30 13:40:28 -04:00
|
|
|
{
|
|
|
|
XMLNode* node = new XMLNode(X_("StripSilence"));
|
|
|
|
node->set_property(X_("threshold"), threshold());
|
|
|
|
node->set_property(X_("min-length"), minimum_length());
|
|
|
|
node->set_property(X_("fade-length"), fade_length());
|
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StripSilenceDialog::set_state (const XMLNode &)
|
|
|
|
{
|
2019-08-30 15:44:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StripSilenceDialog::finished(int response)
|
|
|
|
{
|
|
|
|
if(response == Gtk::RESPONSE_OK) {
|
|
|
|
_session->add_extra_xml(get_state());
|
|
|
|
}
|
2020-03-29 08:56:50 -04:00
|
|
|
}
|