summaryrefslogtreecommitdiff
path: root/gtk2_ardour/audio_region_editor.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-10-23 23:21:55 +0000
committerCarl Hetherington <carl@carlh.net>2009-10-23 23:21:55 +0000
commit002ff65d0f75431bb42cc29836d6237ba1b7d704 (patch)
treead9a6fa8053e48d96b31ee2f2046921c8359b2bb /gtk2_ardour/audio_region_editor.cc
parenta6b735abdbcfc375db314e7f3a4ffb9cee503a48 (diff)
Patch from colinf to show region gain in the region editor (mantis 2879)
git-svn-id: svn://localhost/ardour2/branches/3.0@5899 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/audio_region_editor.cc')
-rw-r--r--gtk2_ardour/audio_region_editor.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc
index 62fd14b16d..cee59ec647 100644
--- a/gtk2_ardour/audio_region_editor.cc
+++ b/gtk2_ardour/audio_region_editor.cc
@@ -22,6 +22,7 @@
#include "ardour/audioregion.h"
#include "ardour/playlist.h"
#include "ardour/utils.h"
+#include "ardour/dB.h"
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/stop_signal.h>
#include <cmath>
@@ -53,7 +54,8 @@ AudioRegionEditor::AudioRegionEditor (Session& s, boost::shared_ptr<AudioRegion>
sync_offset_relative_clock (X_("regionsyncoffsetrelative"), true, X_("AudioRegionEditorClock"), true),
sync_offset_absolute_clock (X_("regionsyncoffsetabsolute"), true, X_("AudioRegionEditorClock"), true),
/* XXX cannot file start yet */
- start_clock (X_("regionstart"), true, X_("AudioRegionEditorClock"), false)
+ start_clock (X_("regionstart"), true, X_("AudioRegionEditorClock"), false),
+ gain_adjustment(accurate_coefficient_to_dB(_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
{
position_clock.set_session (&_session);
@@ -125,6 +127,13 @@ AudioRegionEditor::AudioRegionEditor (Session& s, boost::shared_ptr<AudioRegion>
time_table.attach (start_label, 0, 1, 5, 6, Gtk::FILL, Gtk::FILL);
time_table.attach (start_clock, 1, 2, 5, 6, Gtk::FILL, Gtk::FILL);
+ gain_label.set_name ("AudioRegionEditorLabel");
+ gain_label.set_text (_("Scale amplitude:"));
+ gain_label.set_alignment (1, 0.5);
+ gain_entry.configure (gain_adjustment, 0.0, 1);
+ time_table.attach (gain_label, 0, 1, 6, 7, Gtk::FILL, Gtk::FILL);
+ time_table.attach (gain_entry, 1, 2, 6, 7, Gtk::FILL, Gtk::FILL);
+
lower_hbox.pack_start (time_table, true, true);
lower_hbox.pack_start (sep1, false, false);
lower_hbox.pack_start (sep2, false, false);
@@ -144,6 +153,7 @@ AudioRegionEditor::AudioRegionEditor (Session& s, boost::shared_ptr<AudioRegion>
name_changed ();
bounds_changed (Change (StartChanged|LengthChanged|PositionChanged|StartChanged|Region::SyncOffsetChanged));
+ gain_changed ();
_region->StateChanged.connect (mem_fun(*this, &AudioRegionEditor::region_changed));
@@ -166,6 +176,10 @@ AudioRegionEditor::region_changed (Change what_changed)
if (what_changed & Change (BoundsChanged|StartChanged|Region::SyncOffsetChanged)) {
bounds_changed (what_changed);
}
+
+ if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
+ gain_changed ();
+ }
}
gint
@@ -211,6 +225,7 @@ AudioRegionEditor::connect_editor_events ()
length_clock.ValueChanged.connect (mem_fun(*this, &AudioRegionEditor::length_clock_changed));
sync_offset_absolute_clock.ValueChanged.connect (mem_fun (*this, &AudioRegionEditor::sync_offset_absolute_clock_changed));
sync_offset_relative_clock.ValueChanged.connect (mem_fun (*this, &AudioRegionEditor::sync_offset_relative_clock_changed));
+ gain_adjustment.signal_value_changed().connect (mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed));
audition_button.signal_toggled().connect (mem_fun(*this, &AudioRegionEditor::audition_button_toggled));
_session.AuditionActive.connect (mem_fun(*this, &AudioRegionEditor::audition_state_changed));
@@ -274,6 +289,24 @@ AudioRegionEditor::length_clock_changed ()
}
void
+AudioRegionEditor::gain_changed ()
+{
+ float const region_gain_dB = accurate_coefficient_to_dB (_region->scale_amplitude());
+ if (region_gain_dB != gain_adjustment.get_value()) {
+ gain_adjustment.set_value(region_gain_dB);
+ }
+}
+
+void
+AudioRegionEditor::gain_adjustment_changed ()
+{
+ float const gain = dB_to_coefficient (gain_adjustment.get_value());
+ if (_region->scale_amplitude() != gain) {
+ _region->set_scale_amplitude (gain);
+ }
+}
+
+void
AudioRegionEditor::audition_button_toggled ()
{
if (audition_button.get_active()) {