summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_ops.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r--gtk2_ardour/editor_ops.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index a81a6e6965..33a0e6920c 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -49,6 +49,7 @@
#include <ardour/region_factory.h>
#include <ardour/playlist_factory.h>
#include <ardour/reverse.h>
+#include <ardour/dB.h>
#include <ardour/quantize.h>
#include "ardour_ui.h"
@@ -66,6 +67,7 @@
#include "gtk-custom-hruler.h"
#include "gui_thread.h"
#include "keyboard.h"
+#include "utils.h"
#include "i18n.h"
@@ -4119,6 +4121,8 @@ Editor::denormalize_region ()
return;
}
+ ExclusiveRegionSelection (*this, entered_regionview);
+
if (selection->regions.empty()) {
return;
}
@@ -4137,6 +4141,62 @@ Editor::denormalize_region ()
commit_reversible_command ();
}
+void
+Editor::adjust_region_scale_amplitude (bool up)
+{
+ if (!session) {
+ return;
+ }
+
+ ExclusiveRegionSelection (*this, entered_regionview);
+
+ if (selection->regions.empty()) {
+ return;
+ }
+
+ begin_reversible_command ("denormalize");
+
+ for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) {
+ AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
+ if (!arv)
+ continue;
+ XMLNode &before = arv->region()->get_state();
+
+ double fraction = gain_to_slider_position (arv->audio_region()->scale_amplitude ());
+
+ cerr << "slider pos for " << arv->audio_region()->scale_amplitude ()
+ << " = " << fraction
+ << endl;
+
+ if (up) {
+ fraction += 0.05;
+ fraction = min (fraction, 1.0);
+ } else {
+ fraction -= 0.05;
+ fraction = max (fraction, 0.0);
+ }
+
+ if (!up && fraction <= 0) {
+ continue;
+ }
+
+ if (up && fraction >= 1.0) {
+ continue;
+ }
+
+ fraction = slider_position_to_gain (fraction);
+ fraction = coefficient_to_dB (fraction);
+ fraction = dB_to_coefficient (fraction);
+
+ cerr << "set scale amp for " << arv->audio_region()->name() << " to " << fraction << endl;
+
+ arv->audio_region()->set_scale_amplitude (fraction);
+ session->add_command (new MementoCommand<Region>(*(arv->region().get()), &before, &arv->region()->get_state()));
+ }
+
+ commit_reversible_command ();
+}
+
void
Editor::reverse_region ()