#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"
#include "editing.h"
#include "gtk-custom-hruler.h"
#include "gui_thread.h"
+#include "keyboard.h"
+#include "utils.h"
#include "i18n.h"
commit_reversible_command ();
}
+bool
+Editor::nudge_forward_release (GdkEventButton* ev)
+{
+ if (ev->state & Keyboard::PrimaryModifier) {
+ nudge_forward (false, true);
+ } else {
+ nudge_forward (false, false);
+ }
+ return false;
+}
+
+bool
+Editor::nudge_backward_release (GdkEventButton* ev)
+{
+ if (ev->state & Keyboard::PrimaryModifier) {
+ nudge_backward (false, true);
+ } else {
+ nudge_backward (false, false);
+ }
+ return false;
+}
+
void
-Editor::nudge_forward (bool next)
+Editor::nudge_forward (bool next, bool force_playhead)
{
nframes_t distance;
nframes_t next_distance;
if (!session) return;
- if (!selection->regions.empty()) {
+ if (!force_playhead && !selection->regions.empty()) {
begin_reversible_command (_("nudge regions forward"));
commit_reversible_command ();
- } else if (!selection->markers.empty()) {
+ } else if (!force_playhead && !selection->markers.empty()) {
bool is_start;
Location* loc = find_location_from_marker (selection->markers.front(), is_start);
}
void
-Editor::nudge_backward (bool next)
+Editor::nudge_backward (bool next, bool force_playhead)
{
nframes_t distance;
nframes_t next_distance;
if (!session) return;
- if (!selection->regions.empty()) {
+ if (!force_playhead && !selection->regions.empty()) {
begin_reversible_command (_("nudge regions backward"));
commit_reversible_command ();
- } else if (!selection->markers.empty()) {
+ } else if (!force_playhead && !selection->markers.empty()) {
bool is_start;
Location* loc = find_location_from_marker (selection->markers.front(), is_start);
double nfpu;
double l;
+ /* XXX this limit is also in ::set_frames_per_unit() */
+
+ if (frames_per_unit <= 2.0 && fpu <= frames_per_unit) {
+ return;
+ }
+
nfpu = fpu;
new_page_size = (nframes_t) floor (canvas_width * nfpu);
where = playhead_cursor->current_frame;
l = - ((new_page_size * ((where - current_leftmost)/(double)current_page)) - where);
-
+
if (l < 0) {
leftmost_after_zoom = 0;
} else if (l > max_frames) {
return;
}
+ ExclusiveRegionSelection (*this, entered_regionview);
+
if (selection->regions.empty()) {
return;
}
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 ()