Use ProgressReporter class for normalization. Report progress for individual regions. Fix crash on normalising a single region (#3510).
git-svn-id: svn://localhost/ardour2/branches/3.0@7924 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
8f448a78cd
commit
935aeb55dd
@ -4509,12 +4509,14 @@ Editor::normalize_region ()
|
||||
set_canvas_cursor (wait_cursor);
|
||||
gdk_flush ();
|
||||
|
||||
/* XXX: this should really count only audio regions */
|
||||
|
||||
int tasks = rs.size ();
|
||||
if (!dialog.normalize_individually()) {
|
||||
tasks *= 2;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
int n = 1;
|
||||
|
||||
double maxamp = 0;
|
||||
if (!dialog.normalize_individually()) {
|
||||
@ -4523,8 +4525,12 @@ Editor::normalize_region ()
|
||||
if (!arv) {
|
||||
continue;
|
||||
}
|
||||
maxamp = max (maxamp, arv->audio_region()->maximum_amplitude ());
|
||||
dialog.set_progress (double (n) / tasks);
|
||||
|
||||
dialog.descend (1.0 / tasks);
|
||||
maxamp = max (maxamp, arv->audio_region()->maximum_amplitude (&dialog));
|
||||
dialog.ascend ();
|
||||
|
||||
dialog.set_progress (float (n) / tasks);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
@ -4536,12 +4542,17 @@ Editor::normalize_region ()
|
||||
}
|
||||
arv->region()->clear_changes ();
|
||||
|
||||
double const amp = dialog.normalize_individually () ? arv->audio_region()->maximum_amplitude () : maxamp;
|
||||
|
||||
double amp = maxamp;
|
||||
if (dialog.normalize_individually()) {
|
||||
dialog.descend (1.0 / tasks);
|
||||
amp = arv->audio_region()->maximum_amplitude (&dialog);
|
||||
dialog.ascend ();
|
||||
}
|
||||
|
||||
arv->audio_region()->normalize (amp, dialog.target ());
|
||||
_session->add_command (new StatefulDiffCommand (arv->region()));
|
||||
|
||||
dialog.set_progress (double (n) / tasks);
|
||||
dialog.set_progress (float (n) / tasks);
|
||||
++n;
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,11 @@ NormalizeDialog::NormalizeDialog (bool more_than_one)
|
||||
vbox->pack_start (*b);
|
||||
|
||||
get_vbox()->pack_start (*vbox);
|
||||
|
||||
_progress_bar = manage (new ProgressBar);
|
||||
get_vbox()->pack_start (*_progress_bar);
|
||||
}
|
||||
|
||||
_progress_bar = manage (new ProgressBar);
|
||||
get_vbox()->pack_start (*_progress_bar);
|
||||
|
||||
show_all ();
|
||||
|
||||
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
@ -71,7 +71,7 @@ bool
|
||||
NormalizeDialog::normalize_individually () const
|
||||
{
|
||||
if (_normalize_individually == 0) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return _normalize_individually->get_active ();
|
||||
@ -84,11 +84,7 @@ NormalizeDialog::target () const
|
||||
}
|
||||
|
||||
void
|
||||
NormalizeDialog::set_progress (double p)
|
||||
NormalizeDialog::update_progress_gui (float p)
|
||||
{
|
||||
_progress_bar->set_fraction (p);
|
||||
|
||||
while (gtk_events_pending()) {
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "ardour_dialog.h"
|
||||
#include "progress_reporter.h"
|
||||
|
||||
namespace Gtk {
|
||||
class RadioButton;
|
||||
@ -25,16 +26,17 @@ namespace Gtk {
|
||||
class ProgressBar;
|
||||
}
|
||||
|
||||
class NormalizeDialog : public ArdourDialog
|
||||
class NormalizeDialog : public ArdourDialog, public ProgressReporter
|
||||
{
|
||||
public:
|
||||
NormalizeDialog (bool);
|
||||
|
||||
bool normalize_individually () const;
|
||||
double target () const;
|
||||
void set_progress (double);
|
||||
|
||||
private:
|
||||
void update_progress_gui (float);
|
||||
|
||||
Gtk::RadioButton* _normalize_individually;
|
||||
Gtk::SpinButton* _spin;
|
||||
Gtk::ProgressBar* _progress_bar;
|
||||
|
@ -17,6 +17,9 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __ardour_progress_reporter_h__
|
||||
#define __ardour_progress_reporter_h__
|
||||
|
||||
#include "ardour/progress.h"
|
||||
|
||||
/** A parent class for classes which can report progress on something */
|
||||
@ -34,3 +37,5 @@ private:
|
||||
*/
|
||||
virtual void update_progress_gui (float p) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -83,7 +83,7 @@ class AudioRegion : public Region
|
||||
gain_t scale_amplitude() const { return _scale_amplitude; }
|
||||
|
||||
void normalize (float, float target_in_dB = 0.0f);
|
||||
double maximum_amplitude () const;
|
||||
double maximum_amplitude (Progress *) const;
|
||||
|
||||
bool envelope_active () const { return _envelope_active; }
|
||||
bool fade_in_active () const { return _fade_in_active; }
|
||||
|
@ -17,6 +17,9 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __ardour_progress_h__
|
||||
#define __ardour_progress_h__
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace ARDOUR {
|
||||
@ -49,3 +52,5 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "ardour/region_factory.h"
|
||||
#include "ardour/runtime_functions.h"
|
||||
#include "ardour/transient_detector.h"
|
||||
#include "ardour/progress.h"
|
||||
|
||||
#include "i18n.h"
|
||||
#include <locale.h>
|
||||
@ -1144,7 +1145,7 @@ AudioRegion::set_scale_amplitude (gain_t g)
|
||||
|
||||
/** @return the maximum (linear) amplitude of the region */
|
||||
double
|
||||
AudioRegion::maximum_amplitude () const
|
||||
AudioRegion::maximum_amplitude (Progress* p) const
|
||||
{
|
||||
framepos_t fpos = _start;
|
||||
framepos_t const fend = _start + _length;
|
||||
@ -1171,6 +1172,7 @@ AudioRegion::maximum_amplitude () const
|
||||
}
|
||||
|
||||
fpos += to_read;
|
||||
p->set_progress (float (fpos - _start) / _length);
|
||||
}
|
||||
|
||||
return maxamp;
|
||||
|
Loading…
Reference in New Issue
Block a user