Add region peak amplitude to region editor.
git-svn-id: svn://localhost/ardour2/branches/3.0@7937 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
e88f7f6b55
commit
db5c8c9791
@ -17,8 +17,11 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "pbd/memento_command.h"
|
#include "pbd/memento_command.h"
|
||||||
#include "pbd/stateful_diff_command.h"
|
#include "pbd/stateful_diff_command.h"
|
||||||
|
#include "pbd/pthread_utils.h"
|
||||||
|
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "ardour/audioregion.h"
|
#include "ardour/audioregion.h"
|
||||||
@ -41,28 +44,63 @@ using namespace PBD;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Gtkmm2ext;
|
using namespace Gtkmm2ext;
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_peak_amplitude_thread (void* arg)
|
||||||
|
{
|
||||||
|
SessionEvent::create_per_thread_pool ("peak amplitude events", 64);
|
||||||
|
static_cast<AudioRegionEditor*>(arg)->peak_amplitude_thread ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion> r)
|
AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion> r)
|
||||||
: RegionEditor (s, r)
|
: RegionEditor (s, r)
|
||||||
, _audio_region (r)
|
, _audio_region (r)
|
||||||
, gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
|
, gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
|
||||||
|
, _peak_amplitude_found (false)
|
||||||
{
|
{
|
||||||
gain_label.set_alignment (1, 0.5);
|
|
||||||
|
|
||||||
Gtk::HBox* gb = Gtk::manage (new Gtk::HBox);
|
Gtk::HBox* b = Gtk::manage (new Gtk::HBox);
|
||||||
gb->set_spacing (6);
|
b->set_spacing (6);
|
||||||
gb->pack_start (gain_entry);
|
b->pack_start (gain_entry);
|
||||||
gb->pack_start (*Gtk::manage (new Gtk::Label (_("dB"))), false, false);
|
b->pack_start (*Gtk::manage (new Gtk::Label (_("dB"))), false, false);
|
||||||
|
|
||||||
gain_label.set_name ("AudioRegionEditorLabel");
|
gain_label.set_name ("AudioRegionEditorLabel");
|
||||||
gain_label.set_text (_("Region gain:"));
|
gain_label.set_text (_("Region gain:"));
|
||||||
|
gain_label.set_alignment (1, 0.5);
|
||||||
gain_entry.configure (gain_adjustment, 0.0, 1);
|
gain_entry.configure (gain_adjustment, 0.0, 1);
|
||||||
_table.attach (gain_label, 0, 1, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
_table.attach (gain_label, 0, 1, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
||||||
_table.attach (*gb, 1, 2, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
_table.attach (*b, 1, 2, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
||||||
|
++_table_row;
|
||||||
|
|
||||||
|
b = Gtk::manage (new Gtk::HBox);
|
||||||
|
b->set_spacing (6);
|
||||||
|
b->pack_start (_peak_amplitude);
|
||||||
|
b->pack_start (*Gtk::manage (new Gtk::Label (_("dBFS"))), false, false);
|
||||||
|
|
||||||
|
_peak_amplitude_label.set_name ("AudioRegionEditorLabel");
|
||||||
|
_peak_amplitude_label.set_text (_("Peak amplitude:"));
|
||||||
|
_peak_amplitude_label.set_alignment (1, 0.5);
|
||||||
|
_table.attach (_peak_amplitude_label, 0, 1, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
||||||
|
_table.attach (*b, 1, 2, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
||||||
|
++_table_row;
|
||||||
|
|
||||||
gain_changed ();
|
gain_changed ();
|
||||||
|
|
||||||
gain_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed));
|
gain_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed));
|
||||||
|
|
||||||
|
_peak_amplitude.property_editable() = false;
|
||||||
|
_peak_amplitude.set_text (_("Calculating..."));
|
||||||
|
|
||||||
|
PeakAmplitudeFound.connect (_peak_amplitude_connection, invalidator (*this), boost::bind (&AudioRegionEditor::peak_amplitude_found, this, _1), gui_context ());
|
||||||
|
pthread_create_and_store (X_("peak-amplitude"), &_peak_amplitude_thread_handle, _peak_amplitude_thread, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioRegionEditor::~AudioRegionEditor ()
|
||||||
|
{
|
||||||
|
pthread_cancel_one (_peak_amplitude_thread_handle);
|
||||||
|
void* v;
|
||||||
|
int const r = pthread_join (_peak_amplitude_thread_handle, &v);
|
||||||
|
assert (r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -91,3 +129,16 @@ AudioRegionEditor::gain_adjustment_changed ()
|
|||||||
_audio_region->set_scale_amplitude (gain);
|
_audio_region->set_scale_amplitude (gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioRegionEditor::peak_amplitude_thread ()
|
||||||
|
{
|
||||||
|
PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioRegionEditor::peak_amplitude_found (double p)
|
||||||
|
{
|
||||||
|
_peak_amplitude.set_text (boost::lexical_cast<string> (p));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ class AudioRegionEditor : public RegionEditor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioRegionEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::AudioRegion>);
|
AudioRegionEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::AudioRegion>);
|
||||||
|
~AudioRegionEditor ();
|
||||||
|
|
||||||
|
void peak_amplitude_thread ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -66,6 +69,15 @@ class AudioRegionEditor : public RegionEditor
|
|||||||
Gtk::Label gain_label;
|
Gtk::Label gain_label;
|
||||||
Gtk::Adjustment gain_adjustment;
|
Gtk::Adjustment gain_adjustment;
|
||||||
Gtk::SpinButton gain_entry;
|
Gtk::SpinButton gain_entry;
|
||||||
|
|
||||||
|
Gtk::Label _peak_amplitude_label;
|
||||||
|
Gtk::Entry _peak_amplitude;
|
||||||
|
|
||||||
|
bool _peak_amplitude_found;
|
||||||
|
pthread_t _peak_amplitude_thread_handle;
|
||||||
|
void peak_amplitude_found (double);
|
||||||
|
PBD::Signal1<void, double> PeakAmplitudeFound;
|
||||||
|
PBD::ScopedConnection _peak_amplitude_connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __gtk_ardour_audio_region_edit_h__ */
|
#endif /* __gtk_ardour_audio_region_edit_h__ */
|
||||||
|
@ -44,7 +44,7 @@ using namespace Gtkmm2ext;
|
|||||||
|
|
||||||
RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r)
|
RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r)
|
||||||
: ArdourDialog (_("Region")),
|
: ArdourDialog (_("Region")),
|
||||||
_table (8, 2),
|
_table (9, 2),
|
||||||
_table_row (0),
|
_table_row (0),
|
||||||
_region (r),
|
_region (r),
|
||||||
name_label (_("Name:")),
|
name_label (_("Name:")),
|
||||||
@ -88,7 +88,12 @@ RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r)
|
|||||||
start_label.set_name ("RegionEditorLabel");
|
start_label.set_name ("RegionEditorLabel");
|
||||||
start_label.set_text (_("File start:"));
|
start_label.set_text (_("File start:"));
|
||||||
_sources_label.set_name ("RegionEditorLabel");
|
_sources_label.set_name ("RegionEditorLabel");
|
||||||
|
|
||||||
|
if (region->n_channels() > 1) {
|
||||||
_sources_label.set_text (_("Sources:"));
|
_sources_label.set_text (_("Sources:"));
|
||||||
|
} else {
|
||||||
|
_sources_label.set_text (_("Source:"));
|
||||||
|
}
|
||||||
|
|
||||||
_table.set_col_spacings (12);
|
_table.set_col_spacings (12);
|
||||||
_table.set_row_spacings (6);
|
_table.set_row_spacings (6);
|
||||||
|
@ -52,6 +52,7 @@ class RegionEditor : public ArdourDialog
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RegionEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Region>);
|
RegionEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Region>);
|
||||||
|
virtual ~RegionEditor () {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void region_changed (const PBD::PropertyChange&);
|
virtual void region_changed (const PBD::PropertyChange&);
|
||||||
|
@ -83,7 +83,7 @@ class AudioRegion : public Region
|
|||||||
gain_t scale_amplitude() const { return _scale_amplitude; }
|
gain_t scale_amplitude() const { return _scale_amplitude; }
|
||||||
|
|
||||||
void normalize (float, float target_in_dB = 0.0f);
|
void normalize (float, float target_in_dB = 0.0f);
|
||||||
double maximum_amplitude (Progress *) const;
|
double maximum_amplitude (Progress* p = 0) const;
|
||||||
|
|
||||||
bool envelope_active () const { return _envelope_active; }
|
bool envelope_active () const { return _envelope_active; }
|
||||||
bool fade_in_active () const { return _fade_in_active; }
|
bool fade_in_active () const { return _fade_in_active; }
|
||||||
|
@ -1174,11 +1174,13 @@ AudioRegion::maximum_amplitude (Progress* p) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
fpos += to_read;
|
fpos += to_read;
|
||||||
|
if (p) {
|
||||||
p->set_progress (float (fpos - _start) / _length);
|
p->set_progress (float (fpos - _start) / _length);
|
||||||
if (p->cancelled ()) {
|
if (p->cancelled ()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return maxamp;
|
return maxamp;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user