diff options
author | Carl Hetherington <carl@carlh.net> | 2011-04-04 12:21:26 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-04-04 12:21:26 +0000 |
commit | 02cfe41bff57712e59f7169037d694a3dd6a1420 (patch) | |
tree | 02d58170bfc5567caff21b8a6b08e66cd9f790dc /gtk2_ardour/audio_region_editor.cc | |
parent | b850f5846799ce416b3203a4ee585f5d925ef066 (diff) |
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
Diffstat (limited to 'gtk2_ardour/audio_region_editor.cc')
-rw-r--r-- | gtk2_ardour/audio_region_editor.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index e47f145c7e..806659b52c 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -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 |