Update region peak amplitude when the region is trimmed (#3931).
git-svn-id: svn://localhost/ardour2/branches/3.0@9276 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b850f58467
commit
02cfe41bff
|
@ -53,8 +53,8 @@ _peak_amplitude_thread (void* arg)
|
|||
AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion> r)
|
||||
: RegionEditor (s, r)
|
||||
, _audio_region (r)
|
||||
, gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
|
||||
, _peak_amplitude_found (false)
|
||||
, gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
|
||||
, _peak_channel (false)
|
||||
{
|
||||
|
||||
Gtk::HBox* b = Gtk::manage (new Gtk::HBox);
|
||||
|
@ -91,6 +91,7 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion>
|
|||
|
||||
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);
|
||||
_peak_channel.deliver ('c');
|
||||
}
|
||||
|
||||
AudioRegionEditor::~AudioRegionEditor ()
|
||||
|
@ -109,6 +110,11 @@ AudioRegionEditor::region_changed (const PBD::PropertyChange& what_changed)
|
|||
if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
|
||||
gain_changed ();
|
||||
}
|
||||
|
||||
if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::length)) {
|
||||
/* ask the peak thread to run again */
|
||||
_peak_channel.deliver ('c');
|
||||
}
|
||||
}
|
||||
void
|
||||
AudioRegionEditor::gain_changed ()
|
||||
|
@ -131,7 +137,14 @@ AudioRegionEditor::gain_adjustment_changed ()
|
|||
void
|
||||
AudioRegionEditor::peak_amplitude_thread ()
|
||||
{
|
||||
PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */
|
||||
while (1) {
|
||||
/* await instructions to run */
|
||||
char msg;
|
||||
_peak_channel.receive (msg);
|
||||
|
||||
/* compute peak amplitude and signal the fact */
|
||||
PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <libgnomecanvas/libgnomecanvas.h>
|
||||
|
||||
#include "pbd/signals.h"
|
||||
#include "pbd/crossthread.h"
|
||||
|
||||
#include "audio_clock.h"
|
||||
#include "ardour_dialog.h"
|
||||
|
@ -73,11 +74,11 @@ class AudioRegionEditor : public RegionEditor
|
|||
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;
|
||||
CrossThreadChannel _peak_channel;
|
||||
};
|
||||
|
||||
#endif /* __gtk_ardour_audio_region_edit_h__ */
|
||||
|
|
|
@ -50,6 +50,7 @@ Port::Port (string const & name, Flags flags, jack_client_t* jack_client)
|
|||
, _jack_client (jack_client)
|
||||
, _jack_port (0)
|
||||
, _last_read_index (0)
|
||||
, xthread (true)
|
||||
, output_fifo (512)
|
||||
, input_fifo (1024)
|
||||
, _flags (flags)
|
||||
|
@ -64,6 +65,7 @@ Port::Port (const XMLNode& node, jack_client_t* jack_client)
|
|||
, _jack_client (jack_client)
|
||||
, _jack_port (0)
|
||||
, _last_read_index (0)
|
||||
, xthread (true)
|
||||
, output_fifo (512)
|
||||
, input_fifo (1024)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,8 @@ BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
|
|||
BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type();
|
||||
|
||||
BaseUI::BaseUI (const string& str)
|
||||
: run_loop_thread (0)
|
||||
: request_channel (true)
|
||||
, run_loop_thread (0)
|
||||
, _name (str)
|
||||
{
|
||||
base_ui_instance = this;
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace std;
|
|||
using namespace PBD;
|
||||
using namespace Glib;
|
||||
|
||||
CrossThreadChannel::CrossThreadChannel ()
|
||||
CrossThreadChannel::CrossThreadChannel (bool non_blocking)
|
||||
{
|
||||
_ios = 0;
|
||||
fds[0] = -1;
|
||||
|
@ -41,14 +41,16 @@ CrossThreadChannel::CrossThreadChannel ()
|
|||
return;
|
||||
}
|
||||
|
||||
if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
|
||||
error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
|
||||
error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
|
||||
return;
|
||||
if (non_blocking) {
|
||||
if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
|
||||
error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
|
||||
error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
class CrossThreadChannel {
|
||||
public:
|
||||
CrossThreadChannel();
|
||||
CrossThreadChannel(bool);
|
||||
~CrossThreadChannel();
|
||||
|
||||
void wakeup();
|
||||
|
|
Loading…
Reference in New Issue
Block a user