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.cc127
1 files changed, 96 insertions, 31 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 1f833e8337..77b0883fc1 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -57,6 +57,7 @@
#include "ardour_ui.h"
#include "editor.h"
#include "time_axis_view.h"
+#include "route_time_axis.h"
#include "audio_time_axis.h"
#include "automation_time_axis.h"
#include "streamview.h"
@@ -1659,7 +1660,6 @@ Editor::temporal_zoom_region ()
ensure_entered_region_selected (true);
if (selection->regions.empty()) {
- info << _("cannot set loop: no region selected") << endmsg;
return;
}
@@ -3540,13 +3540,11 @@ Editor::cut_copy (CutCopyOp op)
switch (current_mouse_mode()) {
case MouseObject:
- cerr << "cutting in object mode\n";
if (!selection->regions.empty() || !selection->points.empty()) {
begin_reversible_command (opname + _(" objects"));
if (!selection->regions.empty()) {
- cerr << "have regions to cut" << endl;
cut_copy_regions (op);
if (op == Cut) {
@@ -3565,7 +3563,6 @@ Editor::cut_copy (CutCopyOp op)
commit_reversible_command ();
break; // terminate case statement here
}
- cerr << "nope, now cutting time range" << endl;
if (!selection->time.empty()) {
/* don't cause suprises */
break;
@@ -3575,9 +3572,7 @@ Editor::cut_copy (CutCopyOp op)
case MouseRange:
if (selection->time.empty()) {
nframes64_t start, end;
- cerr << "no time selection, get edit op range" << endl;
if (!get_edit_op_range (start, end)) {
- cerr << "no edit op range" << endl;
return;
}
selection->set ((TimeAxisView*) 0, start, end);
@@ -4376,6 +4371,15 @@ Editor::toggle_region_lock ()
}
void
+Editor::set_region_lock_style (Region::PositionLockStyle ps)
+{
+ for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
+ (*i)->region()->set_position_lock_style (ps);
+ }
+}
+
+
+void
Editor::toggle_region_mute ()
{
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
@@ -5013,31 +5017,70 @@ void
Editor::define_one_bar (nframes64_t start, nframes64_t end)
{
nframes64_t length = end - start;
-
+
const Meter& m (session->tempo_map().meter_at (start));
- /* region length = 1 bar */
+ /* length = 1 bar */
- /* 1 bar = how many beats per bar */
-
- double beats_per_bar = m.beats_per_bar();
-
/* now we want frames per beat.
we have frames per bar, and beats per bar, so ...
*/
- double frames_per_beat = length / beats_per_bar;
+ double frames_per_beat = length / m.beats_per_bar();
/* beats per minute = */
double beats_per_minute = (session->frame_rate() * 60.0) / frames_per_beat;
+ /* now decide whether to:
+
+ (a) set global tempo
+ (b) add a new tempo marker
+
+ */
+
const TempoSection& t (session->tempo_map().tempo_section_at (start));
+ bool do_global = false;
+
+ if ((session->tempo_map().n_tempos() == 1) && (session->tempo_map().n_meters() == 1)) {
+
+ /* only 1 tempo & 1 meter: ask if the user wants to set the tempo
+ at the start, or create a new marker
+ */
+
+ vector<string> options;
+ options.push_back (_("Set global tempo"));
+ options.push_back (_("Add new marker"));
+ options.push_back (_("Cancel"));
+ Choice c (_("Do you want to set the global tempo or add new tempo marker?"),
+ options);
+
+ switch (c.run()) {
+ case 0:
+ do_global = true;
+ break;
+ case 2:
+ return;
+
+ default:
+ do_global = false;
+ }
+
+ } else {
+
+ /* more than 1 tempo and/or meter section already, go ahead do the "usual":
+ if the marker is at the region starter, change it, otherwise add
+ a new tempo marker
+ */
+ }
+
begin_reversible_command (_("set tempo from region"));
XMLNode& before (session->tempo_map().get_state());
- if (t.frame() == start) {
+ if (do_global) {
+ session->tempo_map().change_initial_tempo (beats_per_minute, t.note_type());
+ } else if (t.frame() == start) {
session->tempo_map().change_existing_tempo_at (start, beats_per_minute, t.note_type());
} else {
session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), start);
@@ -5052,7 +5095,7 @@ Editor::define_one_bar (nframes64_t start, nframes64_t end)
void
Editor::split_region_at_transients ()
{
- vector<nframes64_t> positions;
+ AnalysisFeatureList positions;
if (!session) {
return;
@@ -5088,7 +5131,7 @@ Editor::split_region_at_transients ()
}
void
-Editor::split_region_at_points (boost::shared_ptr<Region> r, vector<nframes64_t>& positions)
+Editor::split_region_at_points (boost::shared_ptr<Region> r, AnalysisFeatureList& positions)
{
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (r);
@@ -5106,7 +5149,7 @@ Editor::split_region_at_points (boost::shared_ptr<Region> r, vector<nframes64_t>
return;
}
- vector<nframes64_t>::const_iterator x;
+ AnalysisFeatureList::const_iterator x;
nframes64_t pos = ar->position();
@@ -5163,30 +5206,52 @@ Editor::split_region_at_points (boost::shared_ptr<Region> r, vector<nframes64_t>
void
Editor::tab_to_transient (bool forward)
{
-
- vector<nframes64_t> positions;
+ AnalysisFeatureList positions;
if (!session) {
return;
}
- ExclusiveRegionSelection esr (*this, entered_regionview);
+ nframes64_t pos = session->audible_frame ();
- if (selection->regions.empty()) {
- return;
- }
-
- boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (selection->regions.front()->region());
+ if (!selection->tracks.empty()) {
- if (!ar) {
- return;
+ for (TrackSelection::iterator t = selection->tracks.begin(); t != selection->tracks.end(); ++t) {
+
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*t);
+
+ if (rtv) {
+ boost::shared_ptr<Diskstream> ds = rtv->get_diskstream();
+ if (ds) {
+ boost::shared_ptr<Playlist> pl = rtv->get_diskstream()->playlist ();
+ if (pl) {
+ nframes64_t result = pl->find_next_transient (pos, forward ? 1 : -1);
+
+ if (result >= 0) {
+ positions.push_back (result);
+ }
+ }
+ }
+ }
+ }
+
+ } else {
+
+ ExclusiveRegionSelection esr (*this, entered_regionview);
+
+ if (selection->regions.empty()) {
+ return;
+ }
+
+ for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) {
+ (*r)->region()->get_transients (positions);
+ }
}
- ar->get_transients (positions);
- nframes64_t pos = session->audible_frame ();
+ TransientDetector::cleanup_transients (positions, session->frame_rate(), 3.0);
if (forward) {
- vector<nframes64_t>::iterator x;
+ AnalysisFeatureList::iterator x;
for (x = positions.begin(); x != positions.end(); ++x) {
if ((*x) > pos) {
@@ -5199,7 +5264,7 @@ Editor::tab_to_transient (bool forward)
}
} else {
- vector<nframes64_t>::reverse_iterator x;
+ AnalysisFeatureList::reverse_iterator x;
for (x = positions.rbegin(); x != positions.rend(); ++x) {
if ((*x) < pos) {