#include "transform_dialog.h"
#include "ui_config.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
void
Editor::undo (uint32_t n)
{
+ if (_session && _session->actively_recording()) {
+ /* no undo allowed while recording. Session will check also,
+ but we don't even want to get to that.
+ */
+ return;
+ }
+
if (_drags->active ()) {
_drags->abort ();
}
void
Editor::redo (uint32_t n)
{
+ if (_session && _session->actively_recording()) {
+ /* no redo allowed while recording. Session will check also,
+ but we don't even want to get to that.
+ */
+ return;
+ }
+
if (_drags->active ()) {
_drags->abort ();
}
if (_session) {
- _session->redo (n);
+ _session->redo (n);
if (_session->redo_depth() == 0) {
redo_action->set_sensitive(false);
}
} else {
loc->set_end (max_framepos);
}
+ if (loc->is_session_range()) {
+ _session->set_end_is_free (false);
+ }
}
if (!in_command) {
begin_reversible_command (_("nudge location forward"));
} else {
loc->set_end (loc->length());
}
+ if (loc->is_session_range()) {
+ _session->set_end_is_free (false);
+ }
}
if (!in_command) {
begin_reversible_command (_("nudge location forward"));
commit_reversible_command ();
}
+
+ _session->set_end_is_free (false);
+}
+
+
+void
+Editor::toggle_location_at_playhead_cursor ()
+{
+ if (!do_remove_location_at_playhead_cursor())
+ {
+ add_location_from_playhead_cursor();
+ }
}
void
add_location_mark (_session->audible_frame());
}
-void
-Editor::remove_location_at_playhead_cursor ()
+bool
+Editor::do_remove_location_at_playhead_cursor ()
{
+ bool removed = false;
if (_session) {
//set up for undo
XMLNode &before = _session->locations()->get_state();
- bool removed = false;
//find location(s) at this time
Locations::LocationList locs;
commit_reversible_command ();
}
}
+ return removed;
+}
+
+void
+Editor::remove_location_at_playhead_cursor ()
+{
+ do_remove_location_at_playhead_cursor ();
}
/** Add a range marker around each selected region */
}
}
+
struct AutomationRecord {
AutomationRecord () : state (0) , line(NULL) {}
AutomationRecord (XMLNode* s, const AutomationLine* l) : state (s) , line (l) {}
const AutomationLine* line; ///< line this came from
boost::shared_ptr<Evoral::ControlList> copy; ///< copied events for the cut buffer
};
-
+struct PointsSelectionPositionSorter {
+ bool operator() (ControlPoint* a, ControlPoint* b) {
+ return (*(a->model()))->when < (*(b->model()))->when;
+ }
+};
/** Cut, copy or clear selected automation points.
* @param op Operation (Cut, Copy or Clear)
*/
typedef std::map<boost::shared_ptr<AutomationList>, AutomationRecord> Lists;
Lists lists;
+ /* user could select points in any order */
+ selection->points.sort(PointsSelectionPositionSorter ());
+
/* Go through all selected points, making an AutomationRecord for each distinct AutomationList */
- for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) {
- const AutomationLine& line = (*i)->line();
+ for (PointSelection::iterator sel_point = selection->points.begin(); sel_point != selection->points.end(); ++sel_point) {
+ const AutomationLine& line = (*sel_point)->line();
const boost::shared_ptr<AutomationList> al = line.the_list();
if (lists.find (al) == lists.end ()) {
/* We haven't seen this list yet, so make a record for it. This includes
/* Add all selected points to the relevant copy ControlLists */
framepos_t start = std::numeric_limits<framepos_t>::max();
- for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) {
- boost::shared_ptr<AutomationList> al = (*i)->line().the_list();
- AutomationList::const_iterator j = (*i)->model();
+ for (PointSelection::iterator sel_point = selection->points.begin(); sel_point != selection->points.end(); ++sel_point) {
+ boost::shared_ptr<AutomationList> al = (*sel_point)->line().the_list();
+ AutomationList::const_iterator ctrl_evt = (*sel_point)->model ();
- lists[al].copy->fast_simple_add ((*j)->when, (*j)->value);
+ lists[al].copy->fast_simple_add ((*ctrl_evt)->when, (*ctrl_evt)->value);
if (midi) {
/* Update earliest MIDI start time in beats */
- earliest = std::min(earliest, Evoral::Beats((*j)->when));
+ earliest = std::min(earliest, Evoral::Beats((*ctrl_evt)->when));
} else {
/* Update earliest session start time in frames */
- start = std::min(start, (*i)->line().session_position(j));
+ start = std::min(start, (*sel_point)->line().session_position(ctrl_evt));
}
}
start time, so relative ordering between points is preserved
when copying from several lists and the paste starts at the
earliest copied piece of data. */
- for (AutomationList::iterator j = i->second.copy->begin(); j != i->second.copy->end(); ++j) {
- (*j)->when -= line_offset;
+ boost::shared_ptr<Evoral::ControlList> &al_cpy = i->second.copy;
+ for (AutomationList::iterator ctrl_evt = al_cpy->begin(); ctrl_evt != al_cpy->end(); ++ctrl_evt) {
+ (*ctrl_evt)->when -= line_offset;
}
/* And add it to the cut buffer */
- cut_buffer->add (i->second.copy);
+ cut_buffer->add (al_cpy);
}
}
}
/* Remove each selected point from its AutomationList */
- for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) {
- boost::shared_ptr<AutomationList> al = (*i)->line().the_list();
- al->erase ((*i)->model ());
+ for (PointSelection::iterator sel_point = selection->points.begin(); sel_point != selection->points.end(); ++sel_point) {
+ AutomationLine& line = (*sel_point)->line ();
+ boost::shared_ptr<AutomationList> al = line.the_list();
+
+ bool erase = true;
+
+ if (dynamic_cast<AudioRegionGainLine*> (&line)) {
+ /* removing of first and last gain point in region gain lines is prohibited*/
+ if (line.is_last_point (*(*sel_point)) || line.is_first_point (*(*sel_point))) {
+ erase = false;
+ }
+ }
+
+ if(erase) {
+ al->erase ((*sel_point)->model ());
+ }
}
/* Thaw the lists and add undo records for them */
obtain the maximum amplitude of them all.
*/
list<double> max_amps;
+ list<double> rms_vals;
double max_amp = 0;
+ double max_rms = 0;
+ bool use_rms = dialog.constrain_rms ();
+
for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) {
AudioRegionView const * arv = dynamic_cast<AudioRegionView const *> (*i);
- if (arv) {
- dialog.descend (1.0 / regions);
- double const a = arv->audio_region()->maximum_amplitude (&dialog);
-
- if (a == -1) {
- /* the user cancelled the operation */
- return;
- }
+ if (!arv) {
+ continue;
+ }
+ dialog.descend (1.0 / regions);
+ double const a = arv->audio_region()->maximum_amplitude (&dialog);
+ if (use_rms) {
+ double r = arv->audio_region()->rms (&dialog);
+ max_rms = max (max_rms, r);
+ rms_vals.push_back (r);
+ }
- max_amps.push_back (a);
- max_amp = max (max_amp, a);
- dialog.ascend ();
+ if (a == -1) {
+ /* the user cancelled the operation */
+ return;
}
+
+ max_amps.push_back (a);
+ max_amp = max (max_amp, a);
+ dialog.ascend ();
}
list<double>::const_iterator a = max_amps.begin ();
+ list<double>::const_iterator l = rms_vals.begin ();
bool in_command = false;
for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) {
arv->region()->clear_changes ();
- double const amp = dialog.normalize_individually() ? *a : max_amp;
+ double amp = dialog.normalize_individually() ? *a : max_amp;
+ double target = dialog.target_peak (); // dB
+
+ if (use_rms) {
+ double const amp_rms = dialog.normalize_individually() ? *l : max_rms;
+ const double t_rms = dialog.target_rms ();
+ const gain_t c_peak = dB_to_coefficient (target);
+ const gain_t c_rms = dB_to_coefficient (t_rms);
+ if ((amp_rms / c_rms) > (amp / c_peak)) {
+ amp = amp_rms;
+ target = t_rms;
+ }
+ }
- arv->audio_region()->normalize (amp, dialog.target ());
+ arv->audio_region()->normalize (amp, target);
if (!in_command) {
begin_reversible_command (_("normalize"));
_session->add_command (new StatefulDiffCommand (arv->region()));
++a;
+ ++l;
}
if (in_command) {
vector<Evoral::Sequence<Evoral::Beats>::Notes> v;
v.push_back (selected);
- framepos_t pos_frames = mrv.midi_region()->position() - mrv.midi_region()->start();
- Evoral::Beats pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames);
+ Evoral::Beats pos_beats = Evoral::Beats (mrv.midi_region()->beat()) - mrv.midi_region()->start_beats();
return op (mrv.midi_region()->model(), pos_beats, v);
}
Location* loc;
if ((loc = _session->locations()->session_range_location()) == 0) {
- _session->set_session_extents ( start, end ); // this will create a new session range; no need for UNDO
+ _session->set_session_extents (start, end); // this will create a new session range; no need for UNDO
} else {
XMLNode &before = loc->get_state();
- _session->set_session_extents ( start, end );
+ _session->set_session_extents (start, end);
XMLNode &after = loc->get_state();
commit_reversible_command ();
}
+
+ _session->set_end_is_free (false);
}
void
{
Timers::TimerSuspender t;
label->set_text (string_compose ("Copying %1, %2 of %3", name, n, total));
- Gtkmm2ext::UI::instance()->flush_pending ();
+ Gtkmm2ext::UI::instance()->flush_pending (1);
}
void
*/
Timers::TimerSuspender t;
- Gtkmm2ext::UI::instance()->flush_pending ();
+ Gtkmm2ext::UI::instance()->flush_pending (3);
cerr << " Do it\n";