2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /* Note: public Editor methods are documented in public_editor.h */
30 #include "pbd/error.h"
31 #include "pbd/basename.h"
32 #include "pbd/pthread_utils.h"
33 #include "pbd/memento_command.h"
34 #include "pbd/whitespace.h"
35 #include "pbd/stateful_diff_command.h"
37 #include <gtkmm2ext/utils.h>
38 #include <gtkmm2ext/choice.h>
39 #include <gtkmm2ext/popup.h>
41 #include "ardour/audioengine.h"
42 #include "ardour/session.h"
43 #include "ardour/audioplaylist.h"
44 #include "ardour/audioregion.h"
45 #include "ardour/audio_diskstream.h"
46 #include "ardour/utils.h"
47 #include "ardour/location.h"
48 #include "ardour/audio_track.h"
49 #include "ardour/audioplaylist.h"
50 #include "ardour/region_factory.h"
51 #include "ardour/playlist_factory.h"
52 #include "ardour/reverse.h"
53 #include "ardour/transient_detector.h"
54 #include "ardour/dB.h"
55 #include "ardour/quantize.h"
56 #include "ardour/strip_silence.h"
57 #include "ardour/route_group.h"
58 #include "ardour/operations.h"
60 #include "ardour_ui.h"
63 #include "time_axis_view.h"
64 #include "route_time_axis.h"
65 #include "audio_time_axis.h"
66 #include "automation_time_axis.h"
67 #include "streamview.h"
68 #include "audio_streamview.h"
69 #include "audio_region_view.h"
70 #include "midi_region_view.h"
71 #include "rgb_macros.h"
72 #include "selection_templates.h"
73 #include "selection.h"
75 #include "gtk-custom-hruler.h"
76 #include "gui_thread.h"
79 #include "editor_drag.h"
80 #include "strip_silence_dialog.h"
81 #include "editor_routes.h"
82 #include "editor_regions.h"
83 #include "quantize_dialog.h"
84 #include "interthread_progress_window.h"
85 #include "insert_time_dialog.h"
86 #include "normalize_dialog.h"
87 #include "editor_cursors.h"
88 #include "mouse_cursors.h"
89 #include "patch_change_dialog.h"
94 using namespace ARDOUR
;
97 using namespace Gtkmm2ext
;
98 using namespace Editing
;
99 using Gtkmm2ext::Keyboard
;
101 /***********************************************************************
103 ***********************************************************************/
106 Editor::undo (uint32_t n
)
114 Editor::redo (uint32_t n
)
122 Editor::split_regions_at (framepos_t where
, RegionSelection
& regions
)
126 list
<boost::shared_ptr
<Playlist
> > used_playlists
;
128 if (regions
.empty()) {
132 begin_reversible_command (_("split"));
134 // if splitting a single region, and snap-to is using
135 // region boundaries, don't pay attention to them
137 if (regions
.size() == 1) {
138 switch (_snap_type
) {
139 case SnapToRegionStart
:
140 case SnapToRegionSync
:
141 case SnapToRegionEnd
:
150 EditorFreeze(); /* Emit Signal */
153 for (RegionSelection::iterator a
= regions
.begin(); a
!= regions
.end(); ) {
155 RegionSelection::iterator tmp
;
157 /* XXX this test needs to be more complicated, to make sure we really
158 have something to split.
161 if (!(*a
)->region()->covers (where
)) {
169 boost::shared_ptr
<Playlist
> pl
= (*a
)->region()->playlist();
177 /* we haven't seen this playlist before */
179 /* remember used playlists so we can thaw them later */
180 used_playlists
.push_back(pl
);
185 pl
->clear_changes ();
186 pl
->split_region ((*a
)->region(), where
);
187 _session
->add_command (new StatefulDiffCommand (pl
));
193 while (used_playlists
.size() > 0) {
194 list
<boost::shared_ptr
<Playlist
> >::iterator i
= used_playlists
.begin();
196 used_playlists
.pop_front();
199 commit_reversible_command ();
202 EditorThaw(); /* Emit Signal */
206 boost::shared_ptr
<Region
>
207 Editor::select_region_for_operation (int /*dir*/, TimeAxisView
**tv
)
210 boost::shared_ptr
<Region
> region
;
211 framepos_t start
= 0;
213 if (selection
->time
.start () == selection
->time
.end_frame ()) {
215 /* no current selection-> is there a selected regionview? */
217 if (selection
->regions
.empty()) {
223 if (!selection
->regions
.empty()) {
225 rv
= *(selection
->regions
.begin());
226 (*tv
) = &rv
->get_time_axis_view();
227 region
= rv
->region();
229 } else if (!selection
->tracks
.empty()) {
231 (*tv
) = selection
->tracks
.front();
233 RouteTimeAxisView
* rtv
;
235 if ((rtv
= dynamic_cast<RouteTimeAxisView
*> (*tv
)) != 0) {
236 boost::shared_ptr
<Playlist
> pl
;
238 if ((pl
= rtv
->playlist()) == 0) {
242 region
= pl
->top_region_at (start
);
250 Editor::extend_selection_to_end_of_region (bool next
)
253 boost::shared_ptr
<Region
> region
;
256 if ((region
= select_region_for_operation (next
? 1 : 0, &tv
)) == 0) {
260 if (region
&& selection
->time
.start () == selection
->time
.end_frame ()) {
261 start
= region
->position();
263 start
= selection
->time
.start ();
266 begin_reversible_command (_("extend selection"));
267 selection
->set (start
, region
->position() + region
->length());
268 commit_reversible_command ();
272 Editor::extend_selection_to_start_of_region (bool previous
)
275 boost::shared_ptr
<Region
> region
;
278 if ((region
= select_region_for_operation (previous
? -1 : 0, &tv
)) == 0) {
282 if (region
&& selection
->time
.start () == selection
->time
.end_frame ()) {
283 end
= region
->position() + region
->length();
285 end
= selection
->time
.end_frame ();
288 /* Try to leave the selection with the same route if possible */
290 begin_reversible_command (_("extend selection"));
291 selection
->set (region
->position(), end
);
292 commit_reversible_command ();
296 Editor::nudge_forward_release (GdkEventButton
* ev
)
298 if (ev
->state
& Keyboard::PrimaryModifier
) {
299 nudge_forward (false, true);
301 nudge_forward (false, false);
307 Editor::nudge_backward_release (GdkEventButton
* ev
)
309 if (ev
->state
& Keyboard::PrimaryModifier
) {
310 nudge_backward (false, true);
312 nudge_backward (false, false);
319 Editor::nudge_forward (bool next
, bool force_playhead
)
322 framepos_t next_distance
;
328 RegionSelection rs
= get_regions_from_selection_and_entered ();
330 if (!force_playhead
&& !rs
.empty()) {
332 begin_reversible_command (_("nudge regions forward"));
334 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
335 boost::shared_ptr
<Region
> r ((*i
)->region());
337 distance
= get_nudge_distance (r
->position(), next_distance
);
340 distance
= next_distance
;
344 r
->set_position (r
->position() + distance
, this);
345 _session
->add_command (new StatefulDiffCommand (r
));
348 commit_reversible_command ();
351 } else if (!force_playhead
&& !selection
->markers
.empty()) {
355 begin_reversible_command (_("nudge location forward"));
357 for (MarkerSelection::iterator i
= selection
->markers
.begin(); i
!= selection
->markers
.end(); ++i
) {
359 Location
* loc
= find_location_from_marker ((*i
), is_start
);
363 XMLNode
& before (loc
->get_state());
366 distance
= get_nudge_distance (loc
->start(), next_distance
);
368 distance
= next_distance
;
370 if (max_framepos
- distance
> loc
->start() + loc
->length()) {
371 loc
->set_start (loc
->start() + distance
);
373 loc
->set_start (max_framepos
- loc
->length());
376 distance
= get_nudge_distance (loc
->end(), next_distance
);
378 distance
= next_distance
;
380 if (max_framepos
- distance
> loc
->end()) {
381 loc
->set_end (loc
->end() + distance
);
383 loc
->set_end (max_framepos
);
386 XMLNode
& after (loc
->get_state());
387 _session
->add_command (new MementoCommand
<Location
>(*loc
, &before
, &after
));
391 commit_reversible_command ();
394 distance
= get_nudge_distance (playhead_cursor
->current_frame
, next_distance
);
395 _session
->request_locate (playhead_cursor
->current_frame
+ distance
);
400 Editor::nudge_backward (bool next
, bool force_playhead
)
403 framepos_t next_distance
;
409 RegionSelection rs
= get_regions_from_selection_and_entered ();
411 if (!force_playhead
&& !rs
.empty()) {
413 begin_reversible_command (_("nudge regions backward"));
415 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
416 boost::shared_ptr
<Region
> r ((*i
)->region());
418 distance
= get_nudge_distance (r
->position(), next_distance
);
421 distance
= next_distance
;
426 if (r
->position() > distance
) {
427 r
->set_position (r
->position() - distance
, this);
429 r
->set_position (0, this);
431 _session
->add_command (new StatefulDiffCommand (r
));
434 commit_reversible_command ();
436 } else if (!force_playhead
&& !selection
->markers
.empty()) {
440 begin_reversible_command (_("nudge location forward"));
442 for (MarkerSelection::iterator i
= selection
->markers
.begin(); i
!= selection
->markers
.end(); ++i
) {
444 Location
* loc
= find_location_from_marker ((*i
), is_start
);
448 XMLNode
& before (loc
->get_state());
451 distance
= get_nudge_distance (loc
->start(), next_distance
);
453 distance
= next_distance
;
455 if (distance
< loc
->start()) {
456 loc
->set_start (loc
->start() - distance
);
461 distance
= get_nudge_distance (loc
->end(), next_distance
);
464 distance
= next_distance
;
467 if (distance
< loc
->end() - loc
->length()) {
468 loc
->set_end (loc
->end() - distance
);
470 loc
->set_end (loc
->length());
474 XMLNode
& after (loc
->get_state());
475 _session
->add_command (new MementoCommand
<Location
>(*loc
, &before
, &after
));
479 commit_reversible_command ();
483 distance
= get_nudge_distance (playhead_cursor
->current_frame
, next_distance
);
485 if (playhead_cursor
->current_frame
> distance
) {
486 _session
->request_locate (playhead_cursor
->current_frame
- distance
);
488 _session
->goto_start();
494 Editor::nudge_forward_capture_offset ()
496 RegionSelection rs
= get_regions_from_selection_and_entered ();
498 if (!_session
|| rs
.empty()) {
502 begin_reversible_command (_("nudge forward"));
504 framepos_t
const distance
= _session
->worst_output_latency();
506 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
507 boost::shared_ptr
<Region
> r ((*i
)->region());
510 r
->set_position (r
->position() + distance
, this);
511 _session
->add_command(new StatefulDiffCommand (r
));
514 commit_reversible_command ();
518 Editor::nudge_backward_capture_offset ()
520 RegionSelection rs
= get_regions_from_selection_and_entered ();
522 if (!_session
|| rs
.empty()) {
526 begin_reversible_command (_("nudge forward"));
528 framepos_t
const distance
= _session
->worst_output_latency();
530 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
531 boost::shared_ptr
<Region
> r ((*i
)->region());
535 if (r
->position() > distance
) {
536 r
->set_position (r
->position() - distance
, this);
538 r
->set_position (0, this);
540 _session
->add_command(new StatefulDiffCommand (r
));
543 commit_reversible_command ();
549 Editor::move_to_start ()
551 _session
->goto_start ();
555 Editor::move_to_end ()
558 _session
->request_locate (_session
->current_end_frame());
562 Editor::build_region_boundary_cache ()
565 vector
<RegionPoint
> interesting_points
;
566 boost::shared_ptr
<Region
> r
;
567 TrackViewList tracks
;
570 region_boundary_cache
.clear ();
576 switch (_snap_type
) {
577 case SnapToRegionStart
:
578 interesting_points
.push_back (Start
);
580 case SnapToRegionEnd
:
581 interesting_points
.push_back (End
);
583 case SnapToRegionSync
:
584 interesting_points
.push_back (SyncPoint
);
586 case SnapToRegionBoundary
:
587 interesting_points
.push_back (Start
);
588 interesting_points
.push_back (End
);
591 fatal
<< string_compose (_("build_region_boundary_cache called with snap_type = %1"), _snap_type
) << endmsg
;
596 TimeAxisView
*ontrack
= 0;
599 if (!selection
->tracks
.empty()) {
600 tlist
= selection
->tracks
;
605 while (pos
< _session
->current_end_frame() && !at_end
) {
608 framepos_t lpos
= max_framepos
;
610 for (vector
<RegionPoint
>::iterator p
= interesting_points
.begin(); p
!= interesting_points
.end(); ++p
) {
612 if ((r
= find_next_region (pos
, *p
, 1, tlist
, &ontrack
)) == 0) {
613 if (*p
== interesting_points
.back()) {
616 /* move to next point type */
622 rpos
= r
->first_frame();
626 rpos
= r
->last_frame();
630 rpos
= r
->sync_position ();
638 RouteTimeAxisView
*rtav
;
640 if (ontrack
!= 0 && (rtav
= dynamic_cast<RouteTimeAxisView
*>(ontrack
)) != 0 ) {
641 if (rtav
->track() != 0) {
642 speed
= rtav
->track()->speed();
646 rpos
= track_frame_to_session_frame (rpos
, speed
);
652 /* prevent duplicates, but we don't use set<> because we want to be able
656 vector
<framepos_t
>::iterator ri
;
658 for (ri
= region_boundary_cache
.begin(); ri
!= region_boundary_cache
.end(); ++ri
) {
664 if (ri
== region_boundary_cache
.end()) {
665 region_boundary_cache
.push_back (rpos
);
672 /* finally sort to be sure that the order is correct */
674 sort (region_boundary_cache
.begin(), region_boundary_cache
.end());
677 boost::shared_ptr
<Region
>
678 Editor::find_next_region (framepos_t frame
, RegionPoint point
, int32_t dir
, TrackViewList
& tracks
, TimeAxisView
**ontrack
)
680 TrackViewList::iterator i
;
681 framepos_t closest
= max_framepos
;
682 boost::shared_ptr
<Region
> ret
;
686 framepos_t track_frame
;
687 RouteTimeAxisView
*rtav
;
689 for (i
= tracks
.begin(); i
!= tracks
.end(); ++i
) {
692 boost::shared_ptr
<Region
> r
;
695 if ( (rtav
= dynamic_cast<RouteTimeAxisView
*>(*i
)) != 0 ) {
696 if (rtav
->track()!=0)
697 track_speed
= rtav
->track()->speed();
700 track_frame
= session_frame_to_track_frame(frame
, track_speed
);
702 if ((r
= (*i
)->find_next_region (track_frame
, point
, dir
)) == 0) {
708 rpos
= r
->first_frame ();
712 rpos
= r
->last_frame ();
716 rpos
= r
->sync_position ();
720 // rpos is a "track frame", converting it to "_session frame"
721 rpos
= track_frame_to_session_frame(rpos
, track_speed
);
724 distance
= rpos
- frame
;
726 distance
= frame
- rpos
;
729 if (distance
< closest
) {
741 Editor::find_next_region_boundary (framepos_t pos
, int32_t dir
, const TrackViewList
& tracks
)
743 framecnt_t distance
= max_framepos
;
744 framepos_t current_nearest
= -1;
746 for (TrackViewList::const_iterator i
= tracks
.begin(); i
!= tracks
.end(); ++i
) {
747 framepos_t contender
;
750 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (*i
);
756 if ((contender
= rtv
->find_next_region_boundary (pos
, dir
)) < 0) {
760 d
= ::llabs (pos
- contender
);
763 current_nearest
= contender
;
768 return current_nearest
;
772 Editor::get_region_boundary (framepos_t pos
, int32_t dir
, bool with_selection
, bool only_onscreen
)
777 if (with_selection
&& Config
->get_region_boundaries_from_selected_tracks()) {
779 if (!selection
->tracks
.empty()) {
781 target
= find_next_region_boundary (pos
, dir
, selection
->tracks
);
785 if (only_onscreen
|| Config
->get_region_boundaries_from_onscreen_tracks()) {
786 get_onscreen_tracks (tvl
);
787 target
= find_next_region_boundary (pos
, dir
, tvl
);
789 target
= find_next_region_boundary (pos
, dir
, track_views
);
795 if (only_onscreen
|| Config
->get_region_boundaries_from_onscreen_tracks()) {
796 get_onscreen_tracks (tvl
);
797 target
= find_next_region_boundary (pos
, dir
, tvl
);
799 target
= find_next_region_boundary (pos
, dir
, track_views
);
807 Editor::cursor_to_region_boundary (bool with_selection
, int32_t dir
)
809 framepos_t pos
= playhead_cursor
->current_frame
;
816 // so we don't find the current region again..
817 if (dir
> 0 || pos
> 0) {
821 if ((target
= get_region_boundary (pos
, dir
, with_selection
, false)) < 0) {
825 _session
->request_locate (target
);
829 Editor::cursor_to_next_region_boundary (bool with_selection
)
831 cursor_to_region_boundary (with_selection
, 1);
835 Editor::cursor_to_previous_region_boundary (bool with_selection
)
837 cursor_to_region_boundary (with_selection
, -1);
841 Editor::cursor_to_region_point (EditorCursor
* cursor
, RegionPoint point
, int32_t dir
)
843 boost::shared_ptr
<Region
> r
;
844 framepos_t pos
= cursor
->current_frame
;
850 TimeAxisView
*ontrack
= 0;
852 // so we don't find the current region again..
856 if (!selection
->tracks
.empty()) {
858 r
= find_next_region (pos
, point
, dir
, selection
->tracks
, &ontrack
);
860 } else if (clicked_axisview
) {
863 t
.push_back (clicked_axisview
);
865 r
= find_next_region (pos
, point
, dir
, t
, &ontrack
);
869 r
= find_next_region (pos
, point
, dir
, track_views
, &ontrack
);
878 pos
= r
->first_frame ();
882 pos
= r
->last_frame ();
886 pos
= r
->sync_position ();
891 RouteTimeAxisView
*rtav
;
893 if ( ontrack
!= 0 && (rtav
= dynamic_cast<RouteTimeAxisView
*>(ontrack
)) != 0 ) {
894 if (rtav
->track() != 0) {
895 speed
= rtav
->track()->speed();
899 pos
= track_frame_to_session_frame(pos
, speed
);
901 if (cursor
== playhead_cursor
) {
902 _session
->request_locate (pos
);
904 cursor
->set_position (pos
);
909 Editor::cursor_to_next_region_point (EditorCursor
* cursor
, RegionPoint point
)
911 cursor_to_region_point (cursor
, point
, 1);
915 Editor::cursor_to_previous_region_point (EditorCursor
* cursor
, RegionPoint point
)
917 cursor_to_region_point (cursor
, point
, -1);
921 Editor::cursor_to_selection_start (EditorCursor
*cursor
)
925 switch (mouse_mode
) {
927 if (!selection
->regions
.empty()) {
928 pos
= selection
->regions
.start();
933 if (!selection
->time
.empty()) {
934 pos
= selection
->time
.start ();
942 if (cursor
== playhead_cursor
) {
943 _session
->request_locate (pos
);
945 cursor
->set_position (pos
);
950 Editor::cursor_to_selection_end (EditorCursor
*cursor
)
954 switch (mouse_mode
) {
956 if (!selection
->regions
.empty()) {
957 pos
= selection
->regions
.end_frame();
962 if (!selection
->time
.empty()) {
963 pos
= selection
->time
.end_frame ();
971 if (cursor
== playhead_cursor
) {
972 _session
->request_locate (pos
);
974 cursor
->set_position (pos
);
979 Editor::selected_marker_to_region_boundary (bool with_selection
, int32_t dir
)
989 if (selection
->markers
.empty()) {
993 if (!mouse_frame (mouse
, ignored
)) {
997 add_location_mark (mouse
);
1000 if ((loc
= find_location_from_marker (selection
->markers
.front(), ignored
)) == 0) {
1004 framepos_t pos
= loc
->start();
1006 // so we don't find the current region again..
1007 if (dir
> 0 || pos
> 0) {
1011 if ((target
= get_region_boundary (pos
, dir
, with_selection
, false)) < 0) {
1015 loc
->move_to (target
);
1019 Editor::selected_marker_to_next_region_boundary (bool with_selection
)
1021 selected_marker_to_region_boundary (with_selection
, 1);
1025 Editor::selected_marker_to_previous_region_boundary (bool with_selection
)
1027 selected_marker_to_region_boundary (with_selection
, -1);
1031 Editor::selected_marker_to_region_point (RegionPoint point
, int32_t dir
)
1033 boost::shared_ptr
<Region
> r
;
1038 if (!_session
|| selection
->markers
.empty()) {
1042 if ((loc
= find_location_from_marker (selection
->markers
.front(), ignored
)) == 0) {
1046 TimeAxisView
*ontrack
= 0;
1050 // so we don't find the current region again..
1054 if (!selection
->tracks
.empty()) {
1056 r
= find_next_region (pos
, point
, dir
, selection
->tracks
, &ontrack
);
1060 r
= find_next_region (pos
, point
, dir
, track_views
, &ontrack
);
1069 pos
= r
->first_frame ();
1073 pos
= r
->last_frame ();
1077 pos
= r
->adjust_to_sync (r
->first_frame());
1082 RouteTimeAxisView
*rtav
;
1084 if (ontrack
!= 0 && (rtav
= dynamic_cast<RouteTimeAxisView
*>(ontrack
)) != 0) {
1085 if (rtav
->track() != 0) {
1086 speed
= rtav
->track()->speed();
1090 pos
= track_frame_to_session_frame(pos
, speed
);
1096 Editor::selected_marker_to_next_region_point (RegionPoint point
)
1098 selected_marker_to_region_point (point
, 1);
1102 Editor::selected_marker_to_previous_region_point (RegionPoint point
)
1104 selected_marker_to_region_point (point
, -1);
1108 Editor::selected_marker_to_selection_start ()
1114 if (!_session
|| selection
->markers
.empty()) {
1118 if ((loc
= find_location_from_marker (selection
->markers
.front(), ignored
)) == 0) {
1122 switch (mouse_mode
) {
1124 if (!selection
->regions
.empty()) {
1125 pos
= selection
->regions
.start();
1130 if (!selection
->time
.empty()) {
1131 pos
= selection
->time
.start ();
1143 Editor::selected_marker_to_selection_end ()
1149 if (!_session
|| selection
->markers
.empty()) {
1153 if ((loc
= find_location_from_marker (selection
->markers
.front(), ignored
)) == 0) {
1157 switch (mouse_mode
) {
1159 if (!selection
->regions
.empty()) {
1160 pos
= selection
->regions
.end_frame();
1165 if (!selection
->time
.empty()) {
1166 pos
= selection
->time
.end_frame ();
1178 Editor::scroll_playhead (bool forward
)
1180 framepos_t pos
= playhead_cursor
->current_frame
;
1181 framecnt_t delta
= (framecnt_t
) floor (current_page_frames() / 0.8);
1184 if (pos
== max_framepos
) {
1188 if (pos
< max_framepos
- delta
) {
1207 _session
->request_locate (pos
);
1211 Editor::cursor_align (bool playhead_to_edit
)
1217 if (playhead_to_edit
) {
1219 if (selection
->markers
.empty()) {
1223 _session
->request_locate (selection
->markers
.front()->position(), _session
->transport_rolling());
1226 /* move selected markers to playhead */
1228 for (MarkerSelection::iterator i
= selection
->markers
.begin(); i
!= selection
->markers
.end(); ++i
) {
1231 Location
* loc
= find_location_from_marker (*i
, ignored
);
1233 if (loc
->is_mark()) {
1234 loc
->set_start (playhead_cursor
->current_frame
);
1236 loc
->set (playhead_cursor
->current_frame
,
1237 playhead_cursor
->current_frame
+ loc
->length());
1244 Editor::scroll_backward (float pages
)
1246 framepos_t
const one_page
= (framepos_t
) rint (_canvas_width
* frames_per_unit
);
1247 framepos_t
const cnt
= (framepos_t
) floor (pages
* one_page
);
1250 if (leftmost_frame
< cnt
) {
1253 frame
= leftmost_frame
- cnt
;
1256 reset_x_origin (frame
);
1260 Editor::scroll_forward (float pages
)
1262 framepos_t
const one_page
= (framepos_t
) rint (_canvas_width
* frames_per_unit
);
1263 framepos_t
const cnt
= (framepos_t
) floor (pages
* one_page
);
1266 if (max_framepos
- cnt
< leftmost_frame
) {
1267 frame
= max_framepos
- cnt
;
1269 frame
= leftmost_frame
+ cnt
;
1272 reset_x_origin (frame
);
1276 Editor::scroll_tracks_down ()
1278 double vert_value
= vertical_adjustment
.get_value() + vertical_adjustment
.get_page_size();
1279 if (vert_value
> vertical_adjustment
.get_upper() - _canvas_height
) {
1280 vert_value
= vertical_adjustment
.get_upper() - _canvas_height
;
1283 vertical_adjustment
.set_value (vert_value
);
1287 Editor::scroll_tracks_up ()
1289 vertical_adjustment
.set_value (vertical_adjustment
.get_value() - vertical_adjustment
.get_page_size());
1293 Editor::scroll_tracks_down_line ()
1295 double vert_value
= vertical_adjustment
.get_value() + 60;
1297 if (vert_value
> vertical_adjustment
.get_upper() - _canvas_height
) {
1298 vert_value
= vertical_adjustment
.get_upper() - _canvas_height
;
1301 vertical_adjustment
.set_value (vert_value
);
1305 Editor::scroll_tracks_up_line ()
1307 reset_y_origin (vertical_adjustment
.get_value() - 60);
1313 Editor::tav_zoom_step (bool coarser
)
1315 ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step
, coarser
)
1317 _routes
->suspend_redisplay ();
1319 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
1320 TimeAxisView
*tv
= (static_cast<TimeAxisView
*>(*i
));
1321 tv
->step_height (coarser
);
1324 _routes
->resume_redisplay ();
1328 Editor::temporal_zoom_step (bool coarser
)
1330 ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step
, coarser
)
1334 nfpu
= frames_per_unit
;
1339 nfpu
= max(1.0,(nfpu
/1.61803399));
1342 temporal_zoom (nfpu
);
1346 Editor::temporal_zoom (gdouble fpu
)
1348 if (!_session
) return;
1350 framepos_t current_page
= current_page_frames();
1351 framepos_t current_leftmost
= leftmost_frame
;
1352 framepos_t current_rightmost
;
1353 framepos_t current_center
;
1354 framepos_t new_page_size
;
1355 framepos_t half_page_size
;
1356 framepos_t leftmost_after_zoom
= 0;
1358 bool in_track_canvas
;
1362 /* XXX this limit is also in ::set_frames_per_unit() */
1364 if (frames_per_unit
<= 1.0 && fpu
<= frames_per_unit
) {
1370 new_page_size
= (framepos_t
) floor (_canvas_width
* nfpu
);
1371 half_page_size
= new_page_size
/ 2;
1373 switch (zoom_focus
) {
1375 leftmost_after_zoom
= current_leftmost
;
1378 case ZoomFocusRight
:
1379 current_rightmost
= leftmost_frame
+ current_page
;
1380 if (current_rightmost
< new_page_size
) {
1381 leftmost_after_zoom
= 0;
1383 leftmost_after_zoom
= current_rightmost
- new_page_size
;
1387 case ZoomFocusCenter
:
1388 current_center
= current_leftmost
+ (current_page
/2);
1389 if (current_center
< half_page_size
) {
1390 leftmost_after_zoom
= 0;
1392 leftmost_after_zoom
= current_center
- half_page_size
;
1396 case ZoomFocusPlayhead
:
1397 /* centre playhead */
1398 l
= playhead_cursor
->current_frame
- (new_page_size
* 0.5);
1401 leftmost_after_zoom
= 0;
1402 } else if (l
> max_framepos
) {
1403 leftmost_after_zoom
= max_framepos
- new_page_size
;
1405 leftmost_after_zoom
= (framepos_t
) l
;
1409 case ZoomFocusMouse
:
1410 /* try to keep the mouse over the same point in the display */
1412 if (!mouse_frame (where
, in_track_canvas
)) {
1413 /* use playhead instead */
1414 where
= playhead_cursor
->current_frame
;
1416 if (where
< half_page_size
) {
1417 leftmost_after_zoom
= 0;
1419 leftmost_after_zoom
= where
- half_page_size
;
1424 l
= - ((new_page_size
* ((where
- current_leftmost
)/(double)current_page
)) - where
);
1427 leftmost_after_zoom
= 0;
1428 } else if (l
> max_framepos
) {
1429 leftmost_after_zoom
= max_framepos
- new_page_size
;
1431 leftmost_after_zoom
= (framepos_t
) l
;
1438 /* try to keep the edit point in the same place */
1439 where
= get_preferred_edit_position ();
1443 double l
= - ((new_page_size
* ((where
- current_leftmost
)/(double)current_page
)) - where
);
1446 leftmost_after_zoom
= 0;
1447 } else if (l
> max_framepos
) {
1448 leftmost_after_zoom
= max_framepos
- new_page_size
;
1450 leftmost_after_zoom
= (framepos_t
) l
;
1454 /* edit point not defined */
1461 // leftmost_after_zoom = min (leftmost_after_zoom, _session->current_end_frame());
1463 reposition_and_zoom (leftmost_after_zoom
, nfpu
);
1467 Editor::temporal_zoom_region (bool both_axes
)
1469 framepos_t start
= max_framepos
;
1471 set
<TimeAxisView
*> tracks
;
1473 RegionSelection rs
= get_regions_from_selection_and_entered ();
1479 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
1481 if ((*i
)->region()->position() < start
) {
1482 start
= (*i
)->region()->position();
1485 if ((*i
)->region()->last_frame() + 1 > end
) {
1486 end
= (*i
)->region()->last_frame() + 1;
1489 tracks
.insert (&((*i
)->get_time_axis_view()));
1492 /* now comes an "interesting" hack ... make sure we leave a little space
1493 at each end of the editor so that the zoom doesn't fit the region
1494 precisely to the screen.
1497 GdkScreen
* screen
= gdk_screen_get_default ();
1498 gint pixwidth
= gdk_screen_get_width (screen
);
1499 gint mmwidth
= gdk_screen_get_width_mm (screen
);
1500 double pix_per_mm
= (double) pixwidth
/ (double) mmwidth
;
1501 double one_centimeter_in_pixels
= pix_per_mm
* 10.0;
1503 if ((start
== 0 && end
== 0) || end
< start
) {
1507 framepos_t range
= end
- start
;
1508 double new_fpu
= (double)range
/ (double)_canvas_width
;
1509 framepos_t extra_samples
= (framepos_t
) floor (one_centimeter_in_pixels
* new_fpu
);
1511 if (start
> extra_samples
) {
1512 start
-= extra_samples
;
1517 if (max_framepos
- extra_samples
> end
) {
1518 end
+= extra_samples
;
1524 /* save visual state with track states included, and prevent
1525 set_frames_per_unit() from doing it again.
1527 undo_visual_stack
.push_back (current_visual_state(true));
1528 no_save_visual
= true;
1531 temporal_zoom_by_frame (start
, end
, "zoom to region");
1534 uint32_t per_track_height
= (uint32_t) floor ((_canvas_height
- canvas_timebars_vsize
- 10.0) / tracks
.size());
1536 /* set visible track heights appropriately */
1538 for (set
<TimeAxisView
*>::iterator t
= tracks
.begin(); t
!= tracks
.end(); ++t
) {
1539 (*t
)->set_height (per_track_height
);
1542 /* hide irrelevant tracks */
1544 _routes
->suspend_redisplay ();
1546 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
1547 if (find (tracks
.begin(), tracks
.end(), (*i
)) == tracks
.end()) {
1548 hide_track_in_display (*i
);
1552 _routes
->resume_redisplay ();
1554 vertical_adjustment
.set_value (0.0);
1555 no_save_visual
= false;
1558 redo_visual_stack
.push_back (current_visual_state());
1562 Editor::zoom_to_region (bool both_axes
)
1564 temporal_zoom_region (both_axes
);
1568 Editor::temporal_zoom_selection ()
1570 if (!selection
) return;
1572 if (selection
->time
.empty()) {
1576 framepos_t start
= selection
->time
[clicked_selection
].start
;
1577 framepos_t end
= selection
->time
[clicked_selection
].end
;
1579 temporal_zoom_by_frame (start
, end
, "zoom to selection");
1583 Editor::temporal_zoom_session ()
1585 ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_session
)
1588 framecnt_t
const l
= _session
->current_end_frame() - _session
->current_start_frame();
1589 double s
= _session
->current_start_frame() - l
* 0.01;
1593 framecnt_t
const e
= _session
->current_end_frame() + l
* 0.01;
1594 temporal_zoom_by_frame (framecnt_t (s
), e
, "zoom to _session");
1599 Editor::temporal_zoom_by_frame (framepos_t start
, framepos_t end
, const string
& /*op*/)
1601 if (!_session
) return;
1603 if ((start
== 0 && end
== 0) || end
< start
) {
1607 framepos_t range
= end
- start
;
1609 double new_fpu
= (double)range
/ (double)_canvas_width
;
1611 framepos_t new_page
= (framepos_t
) floor (_canvas_width
* new_fpu
);
1612 framepos_t middle
= (framepos_t
) floor( (double)start
+ ((double)range
/ 2.0f
));
1613 framepos_t new_leftmost
= (framepos_t
) floor( (double)middle
- ((double)new_page
/2.0f
));
1615 if (new_leftmost
> middle
) {
1619 reposition_and_zoom (new_leftmost
, new_fpu
);
1623 Editor::temporal_zoom_to_frame (bool coarser
, framepos_t frame
)
1628 double range_before
= frame
- leftmost_frame
;
1631 new_fpu
= frames_per_unit
;
1634 new_fpu
*= 1.61803399;
1635 range_before
*= 1.61803399;
1637 new_fpu
= max(1.0,(new_fpu
/1.61803399));
1638 range_before
/= 1.61803399;
1641 if (new_fpu
== frames_per_unit
) {
1645 framepos_t new_leftmost
= frame
- (framepos_t
)range_before
;
1647 if (new_leftmost
> frame
) {
1651 if (new_leftmost
< 0) {
1655 reposition_and_zoom (new_leftmost
, new_fpu
);
1660 Editor::choose_new_marker_name(string
&name
) {
1662 if (!Config
->get_name_new_markers()) {
1663 /* don't prompt user for a new name */
1667 ArdourPrompter
dialog (true);
1669 dialog
.set_prompt (_("New Name:"));
1671 dialog
.set_title (_("New Location Marker"));
1673 dialog
.set_name ("MarkNameWindow");
1674 dialog
.set_size_request (250, -1);
1675 dialog
.set_position (Gtk::WIN_POS_MOUSE
);
1677 dialog
.add_button (Stock::OK
, RESPONSE_ACCEPT
);
1678 dialog
.set_initial_text (name
);
1682 switch (dialog
.run ()) {
1683 case RESPONSE_ACCEPT
:
1689 dialog
.get_result(name
);
1696 Editor::add_location_from_selection ()
1700 if (selection
->time
.empty()) {
1704 if (_session
== 0 || clicked_axisview
== 0) {
1708 framepos_t start
= selection
->time
[clicked_selection
].start
;
1709 framepos_t end
= selection
->time
[clicked_selection
].end
;
1711 _session
->locations()->next_available_name(rangename
,"selection");
1712 Location
*location
= new Location (*_session
, start
, end
, rangename
, Location::IsRangeMarker
);
1714 _session
->begin_reversible_command (_("add marker"));
1715 XMLNode
&before
= _session
->locations()->get_state();
1716 _session
->locations()->add (location
, true);
1717 XMLNode
&after
= _session
->locations()->get_state();
1718 _session
->add_command(new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1719 _session
->commit_reversible_command ();
1723 Editor::add_location_mark (framepos_t where
)
1727 select_new_marker
= true;
1729 _session
->locations()->next_available_name(markername
,"mark");
1730 if (!choose_new_marker_name(markername
)) {
1733 Location
*location
= new Location (*_session
, where
, where
, markername
, Location::IsMark
);
1734 _session
->begin_reversible_command (_("add marker"));
1735 XMLNode
&before
= _session
->locations()->get_state();
1736 _session
->locations()->add (location
, true);
1737 XMLNode
&after
= _session
->locations()->get_state();
1738 _session
->add_command(new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1739 _session
->commit_reversible_command ();
1743 Editor::add_location_from_playhead_cursor ()
1745 add_location_mark (_session
->audible_frame());
1748 /** Add a range marker around each selected region */
1750 Editor::add_locations_from_region ()
1752 RegionSelection rs
= get_regions_from_selection_and_entered ();
1758 _session
->begin_reversible_command (selection
->regions
.size () > 1 ? _("add markers") : _("add marker"));
1759 XMLNode
&before
= _session
->locations()->get_state();
1761 for (RegionSelection::iterator i
= rs
.begin (); i
!= rs
.end (); ++i
) {
1763 boost::shared_ptr
<Region
> region
= (*i
)->region ();
1765 Location
*location
= new Location (*_session
, region
->position(), region
->last_frame(), region
->name(), Location::IsRangeMarker
);
1767 _session
->locations()->add (location
, true);
1770 XMLNode
&after
= _session
->locations()->get_state();
1771 _session
->add_command (new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1772 _session
->commit_reversible_command ();
1775 /** Add a single range marker around all selected regions */
1777 Editor::add_location_from_region ()
1779 RegionSelection rs
= get_regions_from_selection_and_entered ();
1785 _session
->begin_reversible_command (_("add marker"));
1786 XMLNode
&before
= _session
->locations()->get_state();
1790 if (rs
.size() > 1) {
1791 _session
->locations()->next_available_name(markername
, "regions");
1793 RegionView
* rv
= *(rs
.begin());
1794 boost::shared_ptr
<Region
> region
= rv
->region();
1795 markername
= region
->name();
1798 if (!choose_new_marker_name(markername
)) {
1802 // single range spanning all selected
1803 Location
*location
= new Location (*_session
, selection
->regions
.start(), selection
->regions
.end_frame(), markername
, Location::IsRangeMarker
);
1804 _session
->locations()->add (location
, true);
1806 XMLNode
&after
= _session
->locations()->get_state();
1807 _session
->add_command (new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1808 _session
->commit_reversible_command ();
1814 Editor::jump_forward_to_mark ()
1820 Location
*location
= _session
->locations()->first_location_after (playhead_cursor
->current_frame
);
1823 _session
->request_locate (location
->start(), _session
->transport_rolling());
1825 _session
->request_locate (_session
->current_end_frame());
1830 Editor::jump_backward_to_mark ()
1836 Location
*location
= _session
->locations()->first_location_before (playhead_cursor
->current_frame
);
1839 _session
->request_locate (location
->start(), _session
->transport_rolling());
1841 _session
->goto_start ();
1848 framepos_t
const pos
= _session
->audible_frame ();
1851 _session
->locations()->next_available_name (markername
, "mark");
1853 if (!choose_new_marker_name (markername
)) {
1857 _session
->locations()->add (new Location (*_session
, pos
, 0, markername
, Location::IsMark
), true);
1861 Editor::clear_markers ()
1864 _session
->begin_reversible_command (_("clear markers"));
1865 XMLNode
&before
= _session
->locations()->get_state();
1866 _session
->locations()->clear_markers ();
1867 XMLNode
&after
= _session
->locations()->get_state();
1868 _session
->add_command(new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1869 _session
->commit_reversible_command ();
1874 Editor::clear_ranges ()
1877 _session
->begin_reversible_command (_("clear ranges"));
1878 XMLNode
&before
= _session
->locations()->get_state();
1880 Location
* looploc
= _session
->locations()->auto_loop_location();
1881 Location
* punchloc
= _session
->locations()->auto_punch_location();
1883 _session
->locations()->clear_ranges ();
1885 if (looploc
) _session
->locations()->add (looploc
);
1886 if (punchloc
) _session
->locations()->add (punchloc
);
1888 XMLNode
&after
= _session
->locations()->get_state();
1889 _session
->add_command(new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1890 _session
->commit_reversible_command ();
1895 Editor::clear_locations ()
1897 _session
->begin_reversible_command (_("clear locations"));
1898 XMLNode
&before
= _session
->locations()->get_state();
1899 _session
->locations()->clear ();
1900 XMLNode
&after
= _session
->locations()->get_state();
1901 _session
->add_command(new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
1902 _session
->commit_reversible_command ();
1903 _session
->locations()->clear ();
1907 Editor::unhide_markers ()
1909 for (LocationMarkerMap::iterator i
= location_markers
.begin(); i
!= location_markers
.end(); ++i
) {
1910 Location
*l
= (*i
).first
;
1911 if (l
->is_hidden() && l
->is_mark()) {
1912 l
->set_hidden(false, this);
1918 Editor::unhide_ranges ()
1920 for (LocationMarkerMap::iterator i
= location_markers
.begin(); i
!= location_markers
.end(); ++i
) {
1921 Location
*l
= (*i
).first
;
1922 if (l
->is_hidden() && l
->is_range_marker()) {
1923 l
->set_hidden(false, this);
1928 /* INSERT/REPLACE */
1931 Editor::insert_region_list_drag (boost::shared_ptr
<Region
> region
, int x
, int y
)
1936 RouteTimeAxisView
*rtv
= 0;
1937 boost::shared_ptr
<Playlist
> playlist
;
1939 track_canvas
->window_to_world (x
, y
, wx
, wy
);
1942 event
.type
= GDK_BUTTON_RELEASE
;
1943 event
.button
.x
= wx
;
1944 event
.button
.y
= wy
;
1946 where
= event_frame (&event
, &cx
, &cy
);
1948 if (where
< leftmost_frame
|| where
> leftmost_frame
+ current_page_frames()) {
1949 /* clearly outside canvas area */
1953 std::pair
<TimeAxisView
*, int> tv
= trackview_by_y_position (cy
);
1954 if (tv
.first
== 0) {
1958 if ((rtv
= dynamic_cast<RouteTimeAxisView
*> (tv
.first
)) == 0) {
1962 if ((playlist
= rtv
->playlist()) == 0) {
1968 begin_reversible_command (_("insert dragged region"));
1969 playlist
->clear_changes ();
1970 playlist
->add_region (RegionFactory::create (region
, true), where
, 1.0);
1971 _session
->add_command(new StatefulDiffCommand (playlist
));
1972 commit_reversible_command ();
1976 Editor::insert_route_list_drag (boost::shared_ptr
<Route
> route
, int x
, int y
)
1981 RouteTimeAxisView
*dest_rtv
= 0;
1982 RouteTimeAxisView
*source_rtv
= 0;
1984 track_canvas
->window_to_world (x
, y
, wx
, wy
);
1985 wx
+= horizontal_position ();
1986 wy
+= vertical_adjustment
.get_value();
1989 event
.type
= GDK_BUTTON_RELEASE
;
1990 event
.button
.x
= wx
;
1991 event
.button
.y
= wy
;
1993 where
= event_frame (&event
, &cx
, &cy
);
1995 std::pair
<TimeAxisView
*, int> const tv
= trackview_by_y_position (cy
);
1996 if (tv
.first
== 0) {
2000 if ((dest_rtv
= dynamic_cast<RouteTimeAxisView
*> (tv
.first
)) == 0) {
2004 /* use this drag source to add underlay to a track. But we really don't care
2005 about the Route, only the view of the route, so find it first */
2006 for(TrackViewList::iterator it
= track_views
.begin(); it
!= track_views
.end(); ++it
) {
2007 if((source_rtv
= dynamic_cast<RouteTimeAxisView
*>(*it
)) == 0) {
2011 if(source_rtv
->route() == route
&& source_rtv
!= dest_rtv
) {
2012 dest_rtv
->add_underlay(source_rtv
->view());
2019 Editor::insert_region_list_selection (float times
)
2021 RouteTimeAxisView
*tv
= 0;
2022 boost::shared_ptr
<Playlist
> playlist
;
2024 if (clicked_routeview
!= 0) {
2025 tv
= clicked_routeview
;
2026 } else if (!selection
->tracks
.empty()) {
2027 if ((tv
= dynamic_cast<RouteTimeAxisView
*>(selection
->tracks
.front())) == 0) {
2030 } else if (entered_track
!= 0) {
2031 if ((tv
= dynamic_cast<RouteTimeAxisView
*>(entered_track
)) == 0) {
2038 if ((playlist
= tv
->playlist()) == 0) {
2042 boost::shared_ptr
<Region
> region
= _regions
->get_single_selection ();
2047 begin_reversible_command (_("insert region"));
2048 playlist
->clear_changes ();
2049 playlist
->add_region ((RegionFactory::create (region
, true)), get_preferred_edit_position(), times
);
2050 _session
->add_command(new StatefulDiffCommand (playlist
));
2051 commit_reversible_command ();
2054 /* BUILT-IN EFFECTS */
2057 Editor::reverse_selection ()
2062 /* GAIN ENVELOPE EDITING */
2065 Editor::edit_envelope ()
2072 Editor::transition_to_rolling (bool fwd
)
2078 if (_session
->config
.get_external_sync()) {
2079 switch (_session
->config
.get_sync_source()) {
2083 /* transport controlled by the master */
2088 if (_session
->is_auditioning()) {
2089 _session
->cancel_audition ();
2093 _session
->request_transport_speed (fwd
? 1.0f
: -1.0f
);
2097 Editor::play_from_start ()
2099 _session
->request_locate (_session
->current_start_frame(), true);
2103 Editor::play_from_edit_point ()
2105 _session
->request_locate (get_preferred_edit_position(), true);
2109 Editor::play_from_edit_point_and_return ()
2111 framepos_t start_frame
;
2112 framepos_t return_frame
;
2114 start_frame
= get_preferred_edit_position (true);
2116 if (_session
->transport_rolling()) {
2117 _session
->request_locate (start_frame
, false);
2121 /* don't reset the return frame if its already set */
2123 if ((return_frame
= _session
->requested_return_frame()) < 0) {
2124 return_frame
= _session
->audible_frame();
2127 if (start_frame
>= 0) {
2128 _session
->request_roll_at_and_return (start_frame
, return_frame
);
2133 Editor::play_selection ()
2135 if (selection
->time
.empty()) {
2139 _session
->request_play_range (&selection
->time
, true);
2143 Editor::play_location (Location
& location
)
2145 if (location
.start() <= location
.end()) {
2149 _session
->request_bounded_roll (location
.start(), location
.end());
2153 Editor::loop_location (Location
& location
)
2155 if (location
.start() <= location
.end()) {
2161 if ((tll
= transport_loop_location()) != 0) {
2162 tll
->set (location
.start(), location
.end());
2164 // enable looping, reposition and start rolling
2165 _session
->request_play_loop (true);
2166 _session
->request_locate (tll
->start(), true);
2171 Editor::raise_region ()
2173 selection
->foreach_region (&Region::raise
);
2177 Editor::raise_region_to_top ()
2179 selection
->foreach_region (&Region::raise_to_top
);
2183 Editor::lower_region ()
2185 selection
->foreach_region (&Region::lower
);
2189 Editor::lower_region_to_bottom ()
2191 selection
->foreach_region (&Region::lower_to_bottom
);
2194 /** Show the region editor for the selected regions */
2196 Editor::show_region_properties ()
2198 selection
->foreach_regionview (&RegionView::show_region_editor
);
2201 /** Show the midi list editor for the selected MIDI regions */
2203 Editor::show_midi_list_editor ()
2205 selection
->foreach_midi_regionview (&MidiRegionView::show_list_editor
);
2209 Editor::rename_region ()
2211 RegionSelection rs
= get_regions_from_selection_and_entered ();
2217 ArdourDialog
d (*this, _("Rename Region"), true, false);
2219 Label
label (_("New name:"));
2222 hbox
.set_spacing (6);
2223 hbox
.pack_start (label
, false, false);
2224 hbox
.pack_start (entry
, true, true);
2226 d
.get_vbox()->set_border_width (12);
2227 d
.get_vbox()->pack_start (hbox
, false, false);
2229 d
.add_button(Gtk::Stock::CANCEL
, Gtk::RESPONSE_CANCEL
);
2230 d
.add_button(Gtk::Stock::OK
, Gtk::RESPONSE_OK
);
2232 d
.set_size_request (300, -1);
2233 d
.set_position (Gtk::WIN_POS_MOUSE
);
2235 entry
.set_text (selection
->regions
.front()->region()->name());
2236 entry
.select_region (0, -1);
2238 entry
.signal_activate().connect (sigc::bind (sigc::mem_fun (d
, &Dialog::response
), RESPONSE_OK
));
2244 int const ret
= d
.run();
2248 if (ret
!= RESPONSE_OK
) {
2252 std::string str
= entry
.get_text();
2253 strip_whitespace_edges (str
);
2255 rs
.front()->region()->set_name (str
);
2256 _regions
->redisplay ();
2261 Editor::audition_playlist_region_via_route (boost::shared_ptr
<Region
> region
, Route
& route
)
2263 if (_session
->is_auditioning()) {
2264 _session
->cancel_audition ();
2267 // note: some potential for creativity here, because region doesn't
2268 // have to belong to the playlist that Route is handling
2270 // bool was_soloed = route.soloed();
2272 route
.set_solo (true, this);
2274 _session
->request_bounded_roll (region
->position(), region
->position() + region
->length());
2276 /* XXX how to unset the solo state ? */
2279 /** Start an audition of the first selected region */
2281 Editor::play_edit_range ()
2283 framepos_t start
, end
;
2285 if (get_edit_op_range (start
, end
)) {
2286 _session
->request_bounded_roll (start
, end
);
2291 Editor::play_selected_region ()
2293 framepos_t start
= max_framepos
;
2296 RegionSelection rs
= get_regions_from_selection_and_entered ();
2302 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2303 if ((*i
)->region()->position() < start
) {
2304 start
= (*i
)->region()->position();
2306 if ((*i
)->region()->last_frame() + 1 > end
) {
2307 end
= (*i
)->region()->last_frame() + 1;
2311 _session
->request_bounded_roll (start
, end
);
2315 Editor::audition_playlist_region_standalone (boost::shared_ptr
<Region
> region
)
2317 _session
->audition_region (region
);
2321 Editor::region_from_selection ()
2323 if (clicked_axisview
== 0) {
2327 if (selection
->time
.empty()) {
2331 framepos_t start
= selection
->time
[clicked_selection
].start
;
2332 framepos_t end
= selection
->time
[clicked_selection
].end
;
2334 TrackViewList tracks
= get_tracks_for_range_action ();
2336 framepos_t selection_cnt
= end
- start
+ 1;
2338 for (TrackSelection::iterator i
= tracks
.begin(); i
!= tracks
.end(); ++i
) {
2339 boost::shared_ptr
<Region
> current
;
2340 boost::shared_ptr
<Playlist
> pl
;
2341 framepos_t internal_start
;
2344 if ((pl
= (*i
)->playlist()) == 0) {
2348 if ((current
= pl
->top_region_at (start
)) == 0) {
2352 internal_start
= start
- current
->position();
2353 RegionFactory::region_name (new_name
, current
->name(), true);
2357 plist
.add (ARDOUR::Properties::start
, current
->start() + internal_start
);
2358 plist
.add (ARDOUR::Properties::length
, selection_cnt
);
2359 plist
.add (ARDOUR::Properties::name
, new_name
);
2360 plist
.add (ARDOUR::Properties::layer
, 0);
2362 boost::shared_ptr
<Region
> region (RegionFactory::create (current
, plist
));
2367 Editor::create_region_from_selection (vector
<boost::shared_ptr
<Region
> >& new_regions
)
2369 if (selection
->time
.empty() || selection
->tracks
.empty()) {
2373 framepos_t start
= selection
->time
[clicked_selection
].start
;
2374 framepos_t end
= selection
->time
[clicked_selection
].end
;
2376 sort_track_selection ();
2378 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
2379 boost::shared_ptr
<Region
> current
;
2380 boost::shared_ptr
<Playlist
> playlist
;
2381 framepos_t internal_start
;
2384 if ((playlist
= (*i
)->playlist()) == 0) {
2388 if ((current
= playlist
->top_region_at(start
)) == 0) {
2392 internal_start
= start
- current
->position();
2393 RegionFactory::region_name (new_name
, current
->name(), true);
2397 plist
.add (ARDOUR::Properties::start
, current
->start() + internal_start
);
2398 plist
.add (ARDOUR::Properties::length
, end
- start
+ 1);
2399 plist
.add (ARDOUR::Properties::name
, new_name
);
2401 new_regions
.push_back (RegionFactory::create (current
, plist
));
2406 Editor::split_multichannel_region ()
2408 RegionSelection rs
= get_regions_from_selection_and_entered ();
2414 vector
< boost::shared_ptr
<Region
> > v
;
2416 for (list
<RegionView
*>::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
2417 (*x
)->region()->separate_by_channel (*_session
, v
);
2422 Editor::new_region_from_selection ()
2424 region_from_selection ();
2425 cancel_selection ();
2429 add_if_covered (RegionView
* rv
, const AudioRange
* ar
, RegionSelection
* rs
)
2431 switch (rv
->region()->coverage (ar
->start
, ar
->end
- 1)) {
2440 * - selected tracks, or if there are none...
2441 * - tracks containing selected regions, or if there are none...
2446 Editor::get_tracks_for_range_action () const
2450 if (selection
->tracks
.empty()) {
2452 /* use tracks with selected regions */
2454 RegionSelection rs
= selection
->regions
;
2456 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2457 TimeAxisView
* tv
= &(*i
)->get_time_axis_view();
2459 if (!t
.contains (tv
)) {
2465 /* no regions and no tracks: use all tracks */
2471 t
= selection
->tracks
;
2478 Editor::separate_regions_between (const TimeSelection
& ts
)
2480 bool in_command
= false;
2481 boost::shared_ptr
<Playlist
> playlist
;
2482 RegionSelection new_selection
;
2484 TrackViewList tmptracks
= get_tracks_for_range_action ();
2485 sort_track_selection (&tmptracks
);
2487 for (TrackSelection::iterator i
= tmptracks
.begin(); i
!= tmptracks
.end(); ++i
) {
2489 RouteTimeAxisView
* rtv
;
2491 if ((rtv
= dynamic_cast<RouteTimeAxisView
*> ((*i
))) != 0) {
2493 if (rtv
->is_track()) {
2495 /* no edits to destructive tracks */
2497 if (rtv
->track()->destructive()) {
2501 if ((playlist
= rtv
->playlist()) != 0) {
2503 playlist
->clear_changes ();
2505 /* XXX need to consider musical time selections here at some point */
2507 double speed
= rtv
->track()->speed();
2510 for (list
<AudioRange
>::const_iterator t
= ts
.begin(); t
!= ts
.end(); ++t
) {
2512 sigc::connection c
= rtv
->view()->RegionViewAdded
.connect (
2513 sigc::mem_fun(*this, &Editor::collect_new_region_view
));
2515 latest_regionviews
.clear ();
2517 playlist
->partition ((framepos_t
)((*t
).start
* speed
),
2518 (framepos_t
)((*t
).end
* speed
), false);
2522 if (!latest_regionviews
.empty()) {
2524 rtv
->view()->foreach_regionview (sigc::bind (
2525 sigc::ptr_fun (add_if_covered
),
2526 &(*t
), &new_selection
));
2529 begin_reversible_command (_("separate"));
2533 /* pick up changes to existing regions */
2535 vector
<Command
*> cmds
;
2536 playlist
->rdiff (cmds
);
2537 _session
->add_commands (cmds
);
2539 /* pick up changes to the playlist itself (adds/removes)
2542 _session
->add_command(new StatefulDiffCommand (playlist
));
2551 selection
->set (new_selection
);
2552 set_mouse_mode (MouseObject
);
2554 commit_reversible_command ();
2558 struct PlaylistState
{
2559 boost::shared_ptr
<Playlist
> playlist
;
2563 /** Take tracks from get_tracks_for_range_action and cut any regions
2564 * on those tracks so that the tracks are empty over the time
2568 Editor::separate_region_from_selection ()
2570 /* preferentially use *all* ranges in the time selection if we're in range mode
2571 to allow discontiguous operation, since get_edit_op_range() currently
2572 returns a single range.
2575 if (mouse_mode
== MouseRange
&& !selection
->time
.empty()) {
2577 separate_regions_between (selection
->time
);
2584 if (get_edit_op_range (start
, end
)) {
2586 AudioRange
ar (start
, end
, 1);
2590 separate_regions_between (ts
);
2596 Editor::separate_region_from_punch ()
2598 Location
* loc
= _session
->locations()->auto_punch_location();
2600 separate_regions_using_location (*loc
);
2605 Editor::separate_region_from_loop ()
2607 Location
* loc
= _session
->locations()->auto_loop_location();
2609 separate_regions_using_location (*loc
);
2614 Editor::separate_regions_using_location (Location
& loc
)
2616 if (loc
.is_mark()) {
2620 AudioRange
ar (loc
.start(), loc
.end(), 1);
2625 separate_regions_between (ts
);
2628 /** Separate regions under the selected region */
2630 Editor::separate_under_selected_regions ()
2632 vector
<PlaylistState
> playlists
;
2636 rs
= get_regions_from_selection_and_entered();
2638 if (!_session
|| rs
.empty()) {
2642 begin_reversible_command (_("separate region under"));
2644 list
<boost::shared_ptr
<Region
> > regions_to_remove
;
2646 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2647 // we can't just remove the region(s) in this loop because
2648 // this removes them from the RegionSelection, and they thus
2649 // disappear from underneath the iterator, and the ++i above
2650 // SEGVs in a puzzling fashion.
2652 // so, first iterate over the regions to be removed from rs and
2653 // add them to the regions_to_remove list, and then
2654 // iterate over the list to actually remove them.
2656 regions_to_remove
.push_back ((*i
)->region());
2659 for (list
<boost::shared_ptr
<Region
> >::iterator rl
= regions_to_remove
.begin(); rl
!= regions_to_remove
.end(); ++rl
) {
2661 boost::shared_ptr
<Playlist
> playlist
= (*rl
)->playlist();
2664 // is this check necessary?
2668 vector
<PlaylistState
>::iterator i
;
2670 //only take state if this is a new playlist.
2671 for (i
= playlists
.begin(); i
!= playlists
.end(); ++i
) {
2672 if ((*i
).playlist
== playlist
) {
2677 if (i
== playlists
.end()) {
2679 PlaylistState before
;
2680 before
.playlist
= playlist
;
2681 before
.before
= &playlist
->get_state();
2683 playlist
->freeze ();
2684 playlists
.push_back(before
);
2687 //Partition on the region bounds
2688 playlist
->partition ((*rl
)->first_frame() - 1, (*rl
)->last_frame() + 1, true);
2690 //Re-add region that was just removed due to the partition operation
2691 playlist
->add_region( (*rl
), (*rl
)->first_frame() );
2694 vector
<PlaylistState
>::iterator pl
;
2696 for (pl
= playlists
.begin(); pl
!= playlists
.end(); ++pl
) {
2697 (*pl
).playlist
->thaw ();
2698 _session
->add_command(new MementoCommand
<Playlist
>(*(*pl
).playlist
, (*pl
).before
, &(*pl
).playlist
->get_state()));
2701 commit_reversible_command ();
2705 Editor::crop_region_to_selection ()
2707 if (!selection
->time
.empty()) {
2709 crop_region_to (selection
->time
.start(), selection
->time
.end_frame());
2716 if (get_edit_op_range (start
, end
)) {
2717 crop_region_to (start
, end
);
2724 Editor::crop_region_to (framepos_t start
, framepos_t end
)
2726 vector
<boost::shared_ptr
<Playlist
> > playlists
;
2727 boost::shared_ptr
<Playlist
> playlist
;
2730 if (selection
->tracks
.empty()) {
2733 sort_track_selection ();
2734 ts
= &selection
->tracks
;
2737 for (TrackSelection::iterator i
= ts
->begin(); i
!= ts
->end(); ++i
) {
2739 RouteTimeAxisView
* rtv
;
2741 if ((rtv
= dynamic_cast<RouteTimeAxisView
*> ((*i
))) != 0) {
2743 boost::shared_ptr
<Track
> t
= rtv
->track();
2745 if (t
!= 0 && ! t
->destructive()) {
2747 if ((playlist
= rtv
->playlist()) != 0) {
2748 playlists
.push_back (playlist
);
2754 if (playlists
.empty()) {
2758 framepos_t the_start
;
2762 begin_reversible_command (_("trim to selection"));
2764 for (vector
<boost::shared_ptr
<Playlist
> >::iterator i
= playlists
.begin(); i
!= playlists
.end(); ++i
) {
2766 boost::shared_ptr
<Region
> region
;
2770 if ((region
= (*i
)->top_region_at(the_start
)) == 0) {
2774 /* now adjust lengths to that we do the right thing
2775 if the selection extends beyond the region
2778 the_start
= max (the_start
, (framepos_t
) region
->position());
2779 if (max_framepos
- the_start
< region
->length()) {
2780 the_end
= the_start
+ region
->length() - 1;
2782 the_end
= max_framepos
;
2784 the_end
= min (end
, the_end
);
2785 cnt
= the_end
- the_start
+ 1;
2787 region
->clear_changes ();
2788 region
->trim_to (the_start
, cnt
, this);
2789 _session
->add_command (new StatefulDiffCommand (region
));
2792 commit_reversible_command ();
2796 Editor::region_fill_track ()
2798 RegionSelection rs
= get_regions_from_selection_and_entered ();
2800 if (!_session
|| rs
.empty()) {
2804 framepos_t
const end
= _session
->current_end_frame ();
2806 begin_reversible_command (Operations::region_fill
);
2808 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2810 boost::shared_ptr
<Region
> region ((*i
)->region());
2812 boost::shared_ptr
<Playlist
> pl
= region
->playlist();
2814 if (end
<= region
->last_frame()) {
2818 double times
= (double) (end
- region
->last_frame()) / (double) region
->length();
2824 pl
->clear_changes ();
2825 pl
->add_region (RegionFactory::create (region
, true), region
->last_frame(), times
);
2826 _session
->add_command (new StatefulDiffCommand (pl
));
2829 commit_reversible_command ();
2833 Editor::region_fill_selection ()
2835 if (clicked_routeview
== 0 || !clicked_routeview
->is_audio_track()) {
2839 if (selection
->time
.empty()) {
2843 boost::shared_ptr
<Region
> region
= _regions
->get_single_selection ();
2848 framepos_t start
= selection
->time
[clicked_selection
].start
;
2849 framepos_t end
= selection
->time
[clicked_selection
].end
;
2851 boost::shared_ptr
<Playlist
> playlist
;
2853 if (selection
->tracks
.empty()) {
2857 framepos_t selection_length
= end
- start
;
2858 float times
= (float)selection_length
/ region
->length();
2860 begin_reversible_command (Operations::fill_selection
);
2862 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
2864 if ((playlist
= (*i
)->playlist()) == 0) {
2868 playlist
->clear_changes ();
2869 playlist
->add_region (RegionFactory::create (region
, true), start
, times
);
2870 _session
->add_command (new StatefulDiffCommand (playlist
));
2873 commit_reversible_command ();
2877 Editor::set_region_sync_position ()
2879 set_sync_point (get_preferred_edit_position (), get_regions_from_selection_and_edit_point ());
2883 Editor::set_sync_point (framepos_t where
, const RegionSelection
& rs
)
2885 bool in_command
= false;
2887 for (RegionSelection::const_iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
2889 if (!(*r
)->region()->covers (where
)) {
2893 boost::shared_ptr
<Region
> region ((*r
)->region());
2896 begin_reversible_command (_("set sync point"));
2900 region
->clear_changes ();
2901 region
->set_sync_position (where
);
2902 _session
->add_command(new StatefulDiffCommand (region
));
2906 commit_reversible_command ();
2910 /** Remove the sync positions of the selection */
2912 Editor::remove_region_sync ()
2914 RegionSelection rs
= get_regions_from_selection_and_entered ();
2920 begin_reversible_command (_("remove region sync"));
2922 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2924 (*i
)->region()->clear_changes ();
2925 (*i
)->region()->clear_sync_position ();
2926 _session
->add_command(new StatefulDiffCommand ((*i
)->region()));
2929 commit_reversible_command ();
2933 Editor::naturalize_region ()
2935 RegionSelection rs
= get_regions_from_selection_and_entered ();
2941 if (rs
.size() > 1) {
2942 begin_reversible_command (_("move regions to original position"));
2944 begin_reversible_command (_("move region to original position"));
2947 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2948 (*i
)->region()->clear_changes ();
2949 (*i
)->region()->move_to_natural_position (this);
2950 _session
->add_command (new StatefulDiffCommand ((*i
)->region()));
2953 commit_reversible_command ();
2957 Editor::align_regions (RegionPoint what
)
2959 RegionSelection
const rs
= get_regions_from_selection_and_edit_point ();
2965 begin_reversible_command (_("align selection"));
2967 framepos_t
const position
= get_preferred_edit_position ();
2969 for (RegionSelection::const_iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
2970 align_region_internal ((*i
)->region(), what
, position
);
2973 commit_reversible_command ();
2976 struct RegionSortByTime
{
2977 bool operator() (const RegionView
* a
, const RegionView
* b
) {
2978 return a
->region()->position() < b
->region()->position();
2983 Editor::align_regions_relative (RegionPoint point
)
2985 RegionSelection
const rs
= get_regions_from_selection_and_edit_point ();
2991 framepos_t
const position
= get_preferred_edit_position ();
2993 framepos_t distance
= 0;
2997 list
<RegionView
*> sorted
;
2998 rs
.by_position (sorted
);
3000 boost::shared_ptr
<Region
> r ((*sorted
.begin())->region());
3005 if (position
> r
->position()) {
3006 distance
= position
- r
->position();
3008 distance
= r
->position() - position
;
3014 if (position
> r
->last_frame()) {
3015 distance
= position
- r
->last_frame();
3016 pos
= r
->position() + distance
;
3018 distance
= r
->last_frame() - position
;
3019 pos
= r
->position() - distance
;
3025 pos
= r
->adjust_to_sync (position
);
3026 if (pos
> r
->position()) {
3027 distance
= pos
- r
->position();
3029 distance
= r
->position() - pos
;
3035 if (pos
== r
->position()) {
3039 begin_reversible_command (_("align selection (relative)"));
3041 /* move first one specially */
3043 r
->clear_changes ();
3044 r
->set_position (pos
, this);
3045 _session
->add_command(new StatefulDiffCommand (r
));
3047 /* move rest by the same amount */
3051 for (list
<RegionView
*>::iterator i
= sorted
.begin(); i
!= sorted
.end(); ++i
) {
3053 boost::shared_ptr
<Region
> region ((*i
)->region());
3055 region
->clear_changes ();
3058 region
->set_position (region
->position() + distance
, this);
3060 region
->set_position (region
->position() - distance
, this);
3063 _session
->add_command(new StatefulDiffCommand (region
));
3067 commit_reversible_command ();
3071 Editor::align_region (boost::shared_ptr
<Region
> region
, RegionPoint point
, framepos_t position
)
3073 begin_reversible_command (_("align region"));
3074 align_region_internal (region
, point
, position
);
3075 commit_reversible_command ();
3079 Editor::align_region_internal (boost::shared_ptr
<Region
> region
, RegionPoint point
, framepos_t position
)
3081 region
->clear_changes ();
3085 region
->set_position (region
->adjust_to_sync (position
), this);
3089 if (position
> region
->length()) {
3090 region
->set_position (position
- region
->length(), this);
3095 region
->set_position (position
, this);
3099 _session
->add_command(new StatefulDiffCommand (region
));
3103 Editor::trim_region_front ()
3109 Editor::trim_region_back ()
3111 trim_region (false);
3115 Editor::trim_region (bool front
)
3117 framepos_t where
= get_preferred_edit_position();
3118 RegionSelection rs
= get_regions_from_selection_and_edit_point ();
3120 cerr
<< "trim regions\n";
3123 cerr
<< " no regions\n";
3127 cerr
<< "where = " << where
<< endl
;
3129 begin_reversible_command (front
? _("trim front") : _("trim back"));
3131 for (list
<RegionView
*>::const_iterator i
= rs
.by_layer().begin(); i
!= rs
.by_layer().end(); ++i
) {
3132 if (!(*i
)->region()->locked()) {
3134 (*i
)->region()->clear_changes ();
3137 (*i
)->region()->trim_front (where
, this);
3139 (*i
)->region()->trim_end (where
, this);
3142 _session
->add_command (new StatefulDiffCommand ((*i
)->region()));
3146 commit_reversible_command ();
3149 /** Trim the end of the selected regions to the position of the edit cursor */
3151 Editor::trim_region_to_loop ()
3153 Location
* loc
= _session
->locations()->auto_loop_location();
3157 trim_region_to_location (*loc
, _("trim to loop"));
3161 Editor::trim_region_to_punch ()
3163 Location
* loc
= _session
->locations()->auto_punch_location();
3167 trim_region_to_location (*loc
, _("trim to punch"));
3171 Editor::trim_region_to_location (const Location
& loc
, const char* str
)
3173 RegionSelection rs
= get_regions_from_selection_and_entered ();
3175 begin_reversible_command (str
);
3177 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
3178 RegionView
* rv
= (*x
);
3180 /* require region to span proposed trim */
3181 switch (rv
->region()->coverage (loc
.start(), loc
.end())) {
3182 case OverlapInternal
:
3188 RouteTimeAxisView
* tav
= dynamic_cast<RouteTimeAxisView
*> (&rv
->get_time_axis_view());
3197 if (tav
->track() != 0) {
3198 speed
= tav
->track()->speed();
3201 start
= session_frame_to_track_frame (loc
.start(), speed
);
3202 end
= session_frame_to_track_frame (loc
.end(), speed
);
3204 rv
->region()->clear_changes ();
3205 rv
->region()->trim_to (start
, (end
- start
), this);
3206 _session
->add_command(new StatefulDiffCommand (rv
->region()));
3209 commit_reversible_command ();
3213 Editor::trim_region_to_previous_region_end ()
3215 return trim_to_region(false);
3219 Editor::trim_region_to_next_region_start ()
3221 return trim_to_region(true);
3225 Editor::trim_to_region(bool forward
)
3227 RegionSelection rs
= get_regions_from_selection_and_entered ();
3229 begin_reversible_command (_("trim to region"));
3231 boost::shared_ptr
<Region
> next_region
;
3233 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
3235 AudioRegionView
* arv
= dynamic_cast<AudioRegionView
*> (*x
);
3241 AudioTimeAxisView
* atav
= dynamic_cast<AudioTimeAxisView
*> (&arv
->get_time_axis_view());
3249 if (atav
->track() != 0) {
3250 speed
= atav
->track()->speed();
3254 boost::shared_ptr
<Region
> region
= arv
->region();
3255 boost::shared_ptr
<Playlist
> playlist (region
->playlist());
3257 region
->clear_changes ();
3261 next_region
= playlist
->find_next_region (region
->first_frame(), Start
, 1);
3267 region
->trim_end((framepos_t
) ( (next_region
->first_frame() - 1) * speed
), this);
3268 arv
->region_changed (PropertyChange (ARDOUR::Properties::length
));
3272 next_region
= playlist
->find_next_region (region
->first_frame(), Start
, 0);
3278 region
->trim_front((framepos_t
) ((next_region
->last_frame() + 1) * speed
), this);
3280 arv
->region_changed (ARDOUR::bounds_change
);
3283 _session
->add_command(new StatefulDiffCommand (region
));
3286 commit_reversible_command ();
3290 Editor::unfreeze_route ()
3292 if (clicked_routeview
== 0 || !clicked_routeview
->is_track()) {
3296 clicked_routeview
->track()->unfreeze ();
3300 Editor::_freeze_thread (void* arg
)
3302 SessionEvent::create_per_thread_pool ("freeze events", 64);
3304 return static_cast<Editor
*>(arg
)->freeze_thread ();
3308 Editor::freeze_thread ()
3310 clicked_routeview
->audio_track()->freeze_me (*current_interthread_info
);
3311 current_interthread_info
->done
= true;
3316 Editor::freeze_route ()
3318 if (clicked_routeview
== 0 || !clicked_routeview
->is_audio_track()) {
3322 if (!clicked_routeview
->track()->bounceable()) {
3323 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (clicked_routeview
);
3324 if (rtv
&& !rtv
->track()->bounceable()) {
3326 _("This route cannot be frozen because it has more outputs than inputs. "
3327 "You can fix this by increasing the number of inputs.")
3329 d
.set_title (_("Cannot freeze"));
3335 InterThreadInfo itt
;
3336 current_interthread_info
= &itt
;
3338 InterthreadProgressWindow
ipw (current_interthread_info
, _("Freeze"), _("Cancel Freeze"));
3340 pthread_create_and_store (X_("freezer"), &itt
.thread
, _freeze_thread
, this);
3342 set_canvas_cursor (_cursors
->wait
);
3344 while (!itt
.done
&& !itt
.cancel
) {
3345 gtk_main_iteration ();
3348 current_interthread_info
= 0;
3349 set_canvas_cursor (current_canvas_cursor
);
3353 Editor::bounce_range_selection (bool replace
, bool enable_processing
)
3355 if (selection
->time
.empty()) {
3359 TrackSelection views
= selection
->tracks
;
3361 for (TrackViewList::iterator i
= views
.begin(); i
!= views
.end(); ++i
) {
3362 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (*i
);
3363 if (rtv
&& !rtv
->track()->bounceable()) {
3365 _("One or more selected tracks cannot be bounced because it has more outputs than inputs. "
3366 "You can fix this by increasing the number of inputs on that track.")
3368 d
.set_title (_("Cannot bounce"));
3374 framepos_t start
= selection
->time
[clicked_selection
].start
;
3375 framepos_t end
= selection
->time
[clicked_selection
].end
;
3376 framepos_t cnt
= end
- start
+ 1;
3378 begin_reversible_command (_("bounce range"));
3380 for (TrackViewList::iterator i
= views
.begin(); i
!= views
.end(); ++i
) {
3382 RouteTimeAxisView
* rtv
;
3384 if ((rtv
= dynamic_cast<RouteTimeAxisView
*> (*i
)) == 0) {
3388 boost::shared_ptr
<Playlist
> playlist
;
3390 if ((playlist
= rtv
->playlist()) == 0) {
3394 InterThreadInfo itt
;
3396 playlist
->clear_changes ();
3397 playlist
->clear_owned_changes ();
3399 boost::shared_ptr
<Region
> r
= rtv
->track()->bounce_range (start
, start
+cnt
, itt
, enable_processing
);
3402 list
<AudioRange
> ranges
;
3403 ranges
.push_back (AudioRange (start
, start
+cnt
, 0));
3404 playlist
->cut (ranges
); // discard result
3405 playlist
->add_region (r
, start
);
3408 vector
<Command
*> cmds
;
3409 playlist
->rdiff (cmds
);
3410 _session
->add_commands (cmds
);
3412 _session
->add_command (new StatefulDiffCommand (playlist
));
3415 commit_reversible_command ();
3418 /** Cut selected regions, automation points or a time range */
3425 /** Copy selected regions, automation points or a time range */
3433 /** @return true if a Cut, Copy or Clear is possible */
3435 Editor::can_cut_copy () const
3437 switch (current_mouse_mode()) {
3440 if (!selection
->regions
.empty() || !selection
->points
.empty()) {
3446 if (!selection
->time
.empty()) {
3459 /** Cut, copy or clear selected regions, automation points or a time range.
3460 * @param op Operation (Cut, Copy or Clear)
3463 Editor::cut_copy (CutCopyOp op
)
3465 /* only cancel selection if cut/copy is successful.*/
3477 opname
= _("clear");
3481 /* if we're deleting something, and the mouse is still pressed,
3482 the thing we started a drag for will be gone when we release
3483 the mouse button(s). avoid this. see part 2 at the end of
3487 if (op
== Cut
|| op
== Clear
) {
3488 if (_drags
->active ()) {
3493 cut_buffer
->clear ();
3495 if (entered_marker
) {
3497 /* cut/delete op while pointing at a marker */
3500 Location
* loc
= find_location_from_marker (entered_marker
, ignored
);
3502 if (_session
&& loc
) {
3503 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker
), loc
));
3510 if (internal_editing()) {
3512 switch (current_mouse_mode()) {
3525 /* we only want to cut regions if some are selected */
3527 if (!selection
->regions
.empty()) {
3528 rs
= selection
->regions
;
3531 switch (current_mouse_mode()) {
3533 if (!rs
.empty() || !selection
->points
.empty()) {
3535 begin_reversible_command (opname
+ _(" objects"));
3538 cut_copy_regions (op
, rs
);
3541 selection
->clear_regions ();
3545 if (!selection
->points
.empty()) {
3546 cut_copy_points (op
);
3549 selection
->clear_points ();
3553 commit_reversible_command ();
3554 break; // terminate case statement here
3556 if (!selection
->time
.empty()) {
3557 /* don't cause suprises */
3560 // fall thru if there was nothing selected
3563 if (selection
->time
.empty()) {
3564 framepos_t start
, end
;
3565 if (!get_edit_op_range (start
, end
)) {
3568 selection
->set (start
, end
);
3571 begin_reversible_command (opname
+ _(" range"));
3572 cut_copy_ranges (op
);
3573 commit_reversible_command ();
3576 selection
->clear_time ();
3586 if (op
== Cut
|| op
== Clear
) {
3591 /** Cut, copy or clear selected automation points.
3592 * @param op Operation (Cut, Copy or Clear)
3595 Editor::cut_copy_points (CutCopyOp op
)
3597 for (PointSelection::iterator i
= selection
->points
.begin(); i
!= selection
->points
.end(); ++i
) {
3599 AutomationTimeAxisView
* atv
= dynamic_cast<AutomationTimeAxisView
*>((*i
).track
);
3602 atv
->cut_copy_clear_objects (selection
->points
, op
);
3607 /** Cut, copy or clear selected automation points.
3608 * @param op Operation (Cut, Copy or Clear)
3611 Editor::cut_copy_midi (CutCopyOp op
)
3613 for (MidiRegionSelection::iterator i
= selection
->midi_regions
.begin(); i
!= selection
->midi_regions
.end(); ++i
) {
3614 MidiRegionView
* mrv
= *i
;
3615 mrv
->cut_copy_clear (op
);
3621 struct lt_playlist
{
3622 bool operator () (const PlaylistState
& a
, const PlaylistState
& b
) {
3623 return a
.playlist
< b
.playlist
;
3627 struct PlaylistMapping
{
3629 boost::shared_ptr
<Playlist
> pl
;
3631 PlaylistMapping (TimeAxisView
* tvp
) : tv (tvp
) {}
3634 /** Remove `clicked_regionview' */
3636 Editor::remove_clicked_region ()
3638 if (clicked_routeview
== 0 || clicked_regionview
== 0) {
3642 boost::shared_ptr
<Playlist
> playlist
= clicked_routeview
->playlist();
3644 begin_reversible_command (_("remove region"));
3645 playlist
->clear_changes ();
3646 playlist
->remove_region (clicked_regionview
->region());
3647 _session
->add_command(new StatefulDiffCommand (playlist
));
3648 commit_reversible_command ();
3652 /** Remove the selected regions */
3654 Editor::remove_selected_regions ()
3656 RegionSelection rs
= get_regions_from_selection_and_entered ();
3658 if (!_session
|| rs
.empty()) {
3662 begin_reversible_command (_("remove region"));
3664 list
<boost::shared_ptr
<Region
> > regions_to_remove
;
3666 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
3667 // we can't just remove the region(s) in this loop because
3668 // this removes them from the RegionSelection, and they thus
3669 // disappear from underneath the iterator, and the ++i above
3670 // SEGVs in a puzzling fashion.
3672 // so, first iterate over the regions to be removed from rs and
3673 // add them to the regions_to_remove list, and then
3674 // iterate over the list to actually remove them.
3676 regions_to_remove
.push_back ((*i
)->region());
3679 vector
<boost::shared_ptr
<Playlist
> > playlists
;
3681 for (list
<boost::shared_ptr
<Region
> >::iterator rl
= regions_to_remove
.begin(); rl
!= regions_to_remove
.end(); ++rl
) {
3683 boost::shared_ptr
<Playlist
> playlist
= (*rl
)->playlist();
3686 // is this check necessary?
3690 vector
<boost::shared_ptr
<Playlist
> >::iterator i
;
3692 //only prep history if this is a new playlist.
3693 for (i
= playlists
.begin(); i
!= playlists
.end(); ++i
) {
3694 if ((*i
) == playlist
) {
3699 if (i
== playlists
.end()) {
3701 playlist
->clear_changes ();
3702 playlist
->freeze ();
3704 playlists
.push_back (playlist
);
3707 playlist
->remove_region (*rl
);
3710 vector
<boost::shared_ptr
<Playlist
> >::iterator pl
;
3712 for (pl
= playlists
.begin(); pl
!= playlists
.end(); ++pl
) {
3714 _session
->add_command(new StatefulDiffCommand (*pl
));
3717 commit_reversible_command ();
3720 /** Cut, copy or clear selected regions.
3721 * @param op Operation (Cut, Copy or Clear)
3724 Editor::cut_copy_regions (CutCopyOp op
, RegionSelection
& rs
)
3726 /* we can't use a std::map here because the ordering is important, and we can't trivially sort
3727 a map when we want ordered access to both elements. i think.
3730 vector
<PlaylistMapping
> pmap
;
3732 framepos_t first_position
= max_framepos
;
3734 typedef set
<boost::shared_ptr
<Playlist
> > FreezeList
;
3735 FreezeList freezelist
;
3737 /* get ordering correct before we cut/copy */
3739 rs
.sort_by_position_and_track ();
3741 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
3743 first_position
= min ((framepos_t
) (*x
)->region()->position(), first_position
);
3745 if (op
== Cut
|| op
== Clear
) {
3746 boost::shared_ptr
<Playlist
> pl
= (*x
)->region()->playlist();
3749 FreezeList::iterator fl
;
3751 //only take state if this is a new playlist.
3752 for (fl
= freezelist
.begin(); fl
!= freezelist
.end(); ++fl
) {
3758 if (fl
== freezelist
.end()) {
3759 pl
->clear_changes();
3761 freezelist
.insert (pl
);
3766 TimeAxisView
* tv
= &(*x
)->get_time_axis_view();
3767 vector
<PlaylistMapping
>::iterator z
;
3769 for (z
= pmap
.begin(); z
!= pmap
.end(); ++z
) {
3770 if ((*z
).tv
== tv
) {
3775 if (z
== pmap
.end()) {
3776 pmap
.push_back (PlaylistMapping (tv
));
3780 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ) {
3782 boost::shared_ptr
<Playlist
> pl
= (*x
)->region()->playlist();
3785 /* region not yet associated with a playlist (e.g. unfinished
3792 TimeAxisView
& tv
= (*x
)->get_time_axis_view();
3793 boost::shared_ptr
<Playlist
> npl
;
3794 RegionSelection::iterator tmp
;
3799 vector
<PlaylistMapping
>::iterator z
;
3801 for (z
= pmap
.begin(); z
!= pmap
.end(); ++z
) {
3802 if ((*z
).tv
== &tv
) {
3807 assert (z
!= pmap
.end());
3810 npl
= PlaylistFactory::create (pl
->data_type(), *_session
, "cutlist", true);
3817 boost::shared_ptr
<Region
> r
= (*x
)->region();
3818 boost::shared_ptr
<Region
> _xx
;
3824 _xx
= RegionFactory::create (r
);
3825 npl
->add_region (_xx
, r
->position() - first_position
);
3826 pl
->remove_region (r
);
3830 /* copy region before adding, so we're not putting same object into two different playlists */
3831 npl
->add_region (RegionFactory::create (r
), r
->position() - first_position
);
3835 pl
->remove_region (r
);
3842 list
<boost::shared_ptr
<Playlist
> > foo
;
3844 /* the pmap is in the same order as the tracks in which selected regions occured */
3846 for (vector
<PlaylistMapping
>::iterator i
= pmap
.begin(); i
!= pmap
.end(); ++i
) {
3849 foo
.push_back ((*i
).pl
);
3854 cut_buffer
->set (foo
);
3858 _last_cut_copy_source_track
= 0;
3860 _last_cut_copy_source_track
= pmap
.front().tv
;
3863 for (FreezeList::iterator pl
= freezelist
.begin(); pl
!= freezelist
.end(); ++pl
) {
3865 _session
->add_command (new StatefulDiffCommand (*pl
));
3870 Editor::cut_copy_ranges (CutCopyOp op
)
3873 TrackViewList entered
;
3875 if (selection
->tracks
.empty()) {
3876 if (!entered_track
) {
3879 entered
.push_back (entered_track
);
3882 ts
= &selection
->tracks
;
3885 for (TrackSelection::iterator i
= ts
->begin(); i
!= ts
->end(); ++i
) {
3886 (*i
)->cut_copy_clear (*selection
, op
);
3891 Editor::paste (float times
)
3893 DEBUG_TRACE (DEBUG::CutNPaste
, "paste to preferred edit pos\n");
3894 paste_internal (get_preferred_edit_position(), times
);
3898 Editor::mouse_paste ()
3903 if (!mouse_frame (where
, ignored
)) {
3908 paste_internal (where
, 1);
3912 Editor::paste_internal (framepos_t position
, float times
)
3914 DEBUG_TRACE (DEBUG::CutNPaste
, string_compose ("apparent paste position is %1\n", position
));
3916 if (internal_editing()) {
3917 if (cut_buffer
->midi_notes
.empty()) {
3921 if (cut_buffer
->empty()) {
3926 if (position
== max_framepos
) {
3927 position
= get_preferred_edit_position();
3928 DEBUG_TRACE (DEBUG::CutNPaste
, string_compose ("preferred edit position is %1\n", position
));
3932 TrackViewList::iterator i
;
3935 /* get everything in the correct order */
3937 if (!selection
->tracks
.empty()) {
3938 /* there are some selected tracks, so paste to them */
3939 sort_track_selection ();
3940 ts
= selection
->tracks
;
3941 } else if (_last_cut_copy_source_track
) {
3942 /* otherwise paste to the track that the cut/copy came from;
3943 see discussion in mants #3333.
3945 ts
.push_back (_last_cut_copy_source_track
);
3948 if (internal_editing ()) {
3950 /* undo/redo is handled by individual tracks/regions */
3952 for (nth
= 0, i
= ts
.begin(); i
!= ts
.end(); ++i
, ++nth
) {
3955 RegionSelection::iterator r
;
3956 MidiNoteSelection::iterator cb
;
3958 get_regions_at (rs
, position
, ts
);
3960 for (cb
= cut_buffer
->midi_notes
.begin(), r
= rs
.begin();
3961 cb
!= cut_buffer
->midi_notes
.end() && r
!= rs
.end(); ++r
) {
3962 MidiRegionView
* mrv
= dynamic_cast<MidiRegionView
*> (*r
);
3964 mrv
->paste (position
, times
, **cb
);
3972 /* we do redo (do you do voodoo?) */
3974 begin_reversible_command (Operations::paste
);
3976 for (nth
= 0, i
= ts
.begin(); i
!= ts
.end(); ++i
, ++nth
) {
3977 (*i
)->paste (position
, times
, *cut_buffer
, nth
);
3980 commit_reversible_command ();
3985 Editor::duplicate_some_regions (RegionSelection
& regions
, float times
)
3987 boost::shared_ptr
<Playlist
> playlist
;
3988 RegionSelection sel
= regions
; // clear (below) may clear the argument list if its the current region selection
3989 RegionSelection foo
;
3991 framepos_t
const start_frame
= regions
.start ();
3992 framepos_t
const end_frame
= regions
.end_frame ();
3994 begin_reversible_command (Operations::duplicate_region
);
3996 selection
->clear_regions ();
3998 for (RegionSelection::iterator i
= sel
.begin(); i
!= sel
.end(); ++i
) {
4000 boost::shared_ptr
<Region
> r ((*i
)->region());
4002 TimeAxisView
& tv
= (*i
)->get_time_axis_view();
4003 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (&tv
);
4004 latest_regionviews
.clear ();
4005 sigc::connection c
= rtv
->view()->RegionViewAdded
.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view
));
4007 playlist
= (*i
)->region()->playlist();
4008 playlist
->clear_changes ();
4009 playlist
->duplicate (r
, end_frame
+ (r
->first_frame() - start_frame
), times
);
4010 _session
->add_command(new StatefulDiffCommand (playlist
));
4014 foo
.insert (foo
.end(), latest_regionviews
.begin(), latest_regionviews
.end());
4017 commit_reversible_command ();
4020 selection
->set (foo
);
4025 Editor::duplicate_selection (float times
)
4027 if (selection
->time
.empty() || selection
->tracks
.empty()) {
4031 boost::shared_ptr
<Playlist
> playlist
;
4032 vector
<boost::shared_ptr
<Region
> > new_regions
;
4033 vector
<boost::shared_ptr
<Region
> >::iterator ri
;
4035 create_region_from_selection (new_regions
);
4037 if (new_regions
.empty()) {
4041 begin_reversible_command (_("duplicate selection"));
4043 ri
= new_regions
.begin();
4045 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
4046 if ((playlist
= (*i
)->playlist()) == 0) {
4049 playlist
->clear_changes ();
4050 playlist
->duplicate (*ri
, selection
->time
[clicked_selection
].end
, times
);
4051 _session
->add_command (new StatefulDiffCommand (playlist
));
4054 if (ri
== new_regions
.end()) {
4059 commit_reversible_command ();
4063 Editor::reset_point_selection ()
4065 /* reset all selected points to the relevant default value */
4067 for (PointSelection::iterator i
= selection
->points
.begin(); i
!= selection
->points
.end(); ++i
) {
4069 AutomationTimeAxisView
* atv
= dynamic_cast<AutomationTimeAxisView
*>((*i
).track
);
4072 atv
->reset_objects (selection
->points
);
4078 Editor::center_playhead ()
4080 float page
= _canvas_width
* frames_per_unit
;
4081 center_screen_internal (playhead_cursor
->current_frame
, page
);
4085 Editor::center_edit_point ()
4087 float page
= _canvas_width
* frames_per_unit
;
4088 center_screen_internal (get_preferred_edit_position(), page
);
4091 /** Caller must begin and commit a reversible command */
4093 Editor::clear_playlist (boost::shared_ptr
<Playlist
> playlist
)
4095 playlist
->clear_changes ();
4097 _session
->add_command (new StatefulDiffCommand (playlist
));
4101 Editor::nudge_track (bool use_edit
, bool forwards
)
4103 boost::shared_ptr
<Playlist
> playlist
;
4104 framepos_t distance
;
4105 framepos_t next_distance
;
4109 start
= get_preferred_edit_position();
4114 if ((distance
= get_nudge_distance (start
, next_distance
)) == 0) {
4118 if (selection
->tracks
.empty()) {
4122 begin_reversible_command (_("nudge track"));
4124 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
4126 if ((playlist
= (*i
)->playlist()) == 0) {
4130 playlist
->clear_changes ();
4131 playlist
->clear_owned_changes ();
4133 playlist
->nudge_after (start
, distance
, forwards
);
4135 vector
<Command
*> cmds
;
4137 playlist
->rdiff (cmds
);
4138 _session
->add_commands (cmds
);
4140 _session
->add_command (new StatefulDiffCommand (playlist
));
4143 commit_reversible_command ();
4147 Editor::remove_last_capture ()
4149 vector
<string
> choices
;
4156 if (Config
->get_verify_remove_last_capture()) {
4157 prompt
= _("Do you really want to destroy the last capture?"
4158 "\n(This is destructive and cannot be undone)");
4160 choices
.push_back (_("No, do nothing."));
4161 choices
.push_back (_("Yes, destroy it."));
4163 Gtkmm2ext::Choice
prompter (_("Destroy last capture"), prompt
, choices
);
4165 if (prompter
.run () == 1) {
4166 _session
->remove_last_capture ();
4167 _regions
->redisplay ();
4171 _session
->remove_last_capture();
4172 _regions
->redisplay ();
4177 Editor::normalize_region ()
4183 RegionSelection rs
= get_regions_from_selection_and_entered ();
4189 NormalizeDialog
dialog (rs
.size() > 1);
4191 if (dialog
.run () == RESPONSE_CANCEL
) {
4195 set_canvas_cursor (_cursors
->wait
);
4198 /* XXX: should really only count audio regions here */
4199 int const regions
= rs
.size ();
4201 /* Make a list of the selected audio regions' maximum amplitudes, and also
4202 obtain the maximum amplitude of them all.
4204 list
<double> max_amps
;
4206 for (RegionSelection::const_iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4207 AudioRegionView
const * arv
= dynamic_cast<AudioRegionView
const *> (*i
);
4209 dialog
.descend (1.0 / regions
);
4210 double const a
= arv
->audio_region()->maximum_amplitude (&dialog
);
4213 /* the user cancelled the operation */
4214 set_canvas_cursor (current_canvas_cursor
);
4218 max_amps
.push_back (a
);
4219 max_amp
= max (max_amp
, a
);
4224 begin_reversible_command (_("normalize"));
4226 list
<double>::const_iterator a
= max_amps
.begin ();
4228 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
4229 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*> (*r
);
4234 arv
->region()->clear_changes ();
4236 double const amp
= dialog
.normalize_individually() ? *a
: max_amp
;
4238 arv
->audio_region()->normalize (amp
, dialog
.target ());
4239 _session
->add_command (new StatefulDiffCommand (arv
->region()));
4244 commit_reversible_command ();
4245 set_canvas_cursor (current_canvas_cursor
);
4250 Editor::reset_region_scale_amplitude ()
4256 RegionSelection rs
= get_regions_from_selection_and_entered ();
4262 begin_reversible_command ("reset gain");
4264 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
4265 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*>(*r
);
4268 arv
->region()->clear_changes ();
4269 arv
->audio_region()->set_scale_amplitude (1.0f
);
4270 _session
->add_command (new StatefulDiffCommand (arv
->region()));
4273 commit_reversible_command ();
4277 Editor::adjust_region_gain (bool up
)
4279 RegionSelection rs
= get_regions_from_selection_and_entered ();
4281 if (!_session
|| rs
.empty()) {
4285 begin_reversible_command ("adjust region gain");
4287 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
4288 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*>(*r
);
4293 arv
->region()->clear_changes ();
4295 double dB
= accurate_coefficient_to_dB (arv
->audio_region()->scale_amplitude ());
4303 arv
->audio_region()->set_scale_amplitude (dB_to_coefficient (dB
));
4304 _session
->add_command (new StatefulDiffCommand (arv
->region()));
4307 commit_reversible_command ();
4312 Editor::reverse_region ()
4318 Reverse
rev (*_session
);
4319 apply_filter (rev
, _("reverse regions"));
4323 Editor::strip_region_silence ()
4329 RegionSelection rs
= get_regions_from_selection_and_entered ();
4335 std::list
<RegionView
*> audio_only
;
4337 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4338 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*> (*i
);
4340 audio_only
.push_back (arv
);
4344 StripSilenceDialog
d (_session
, audio_only
);
4345 int const r
= d
.run ();
4349 if (r
== Gtk::RESPONSE_OK
) {
4350 ARDOUR::AudioIntervalMap silences
;
4351 d
.silences (silences
);
4352 StripSilence
s (*_session
, silences
, d
.fade_length());
4353 apply_filter (s
, _("strip silence"), &d
);
4358 Editor::apply_midi_note_edit_op_to_region (MidiOperator
& op
, MidiRegionView
& mrv
)
4360 Evoral::Sequence
<Evoral::MusicalTime
>::Notes selected
;
4361 mrv
.selection_as_notelist (selected
, true);
4363 vector
<Evoral::Sequence
<Evoral::MusicalTime
>::Notes
> v
;
4364 v
.push_back (selected
);
4366 return op (mrv
.midi_region()->model(), v
);
4370 Editor::apply_midi_note_edit_op (MidiOperator
& op
)
4374 RegionSelection rs
= get_regions_from_selection_and_entered ();
4380 begin_reversible_command (op
.name ());
4382 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ) {
4383 RegionSelection::iterator tmp
= r
;
4386 MidiRegionView
* const mrv
= dynamic_cast<MidiRegionView
*> (*r
);
4389 cmd
= apply_midi_note_edit_op_to_region (op
, *mrv
);
4392 _session
->add_command (cmd
);
4399 commit_reversible_command ();
4403 Editor::fork_region ()
4405 RegionSelection rs
= get_regions_from_selection_and_entered ();
4411 begin_reversible_command (_("Fork Region(s)"));
4413 set_canvas_cursor (_cursors
->wait
);
4416 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ) {
4417 RegionSelection::iterator tmp
= r
;
4420 MidiRegionView
* const mrv
= dynamic_cast<MidiRegionView
*>(*r
);
4423 boost::shared_ptr
<Playlist
> playlist
= mrv
->region()->playlist();
4424 boost::shared_ptr
<MidiRegion
> newregion
= mrv
->midi_region()->clone ();
4426 playlist
->clear_changes ();
4427 playlist
->replace_region (mrv
->region(), newregion
, mrv
->region()->position());
4428 _session
->add_command(new StatefulDiffCommand (playlist
));
4434 commit_reversible_command ();
4436 set_canvas_cursor (current_canvas_cursor
);
4440 Editor::quantize_region ()
4442 int selected_midi_region_cnt
= 0;
4448 RegionSelection rs
= get_regions_from_selection_and_entered ();
4454 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
4455 MidiRegionView
* const mrv
= dynamic_cast<MidiRegionView
*> (*r
);
4457 selected_midi_region_cnt
++;
4461 if (selected_midi_region_cnt
== 0) {
4465 QuantizeDialog
* qd
= new QuantizeDialog (*this);
4468 const int r
= qd
->run ();
4471 if (r
== Gtk::RESPONSE_OK
) {
4472 Quantize
quant (*_session
, Plain
,
4473 qd
->snap_start(), qd
->snap_end(),
4474 qd
->start_grid_size(), qd
->end_grid_size(),
4475 qd
->strength(), qd
->swing(), qd
->threshold());
4477 apply_midi_note_edit_op (quant
);
4482 Editor::insert_patch_change ()
4484 RegionSelection rs
= get_regions_from_selection_and_entered ();
4489 framepos_t
const p
= get_preferred_edit_position (false);
4491 Evoral::PatchChange
<Evoral::MusicalTime
> empty (0, 0, 0, 0);
4492 PatchChangeDialog
d (0, _session
, empty
, Gtk::Stock::ADD
);
4494 if (d
.run() == RESPONSE_CANCEL
) {
4498 for (RegionSelection::iterator i
= rs
.begin (); i
!= rs
.end(); ++i
) {
4499 MidiRegionView
* const mrv
= dynamic_cast<MidiRegionView
*> (*i
);
4501 if (p
>= mrv
->region()->first_frame() && p
<= mrv
->region()->last_frame()) {
4502 mrv
->add_patch_change (p
- mrv
->region()->position(), d
.patch ());
4509 Editor::apply_filter (Filter
& filter
, string command
, ProgressReporter
* progress
)
4511 RegionSelection rs
= get_regions_from_selection_and_entered ();
4517 begin_reversible_command (command
);
4519 set_canvas_cursor (_cursors
->wait
);
4523 int const N
= rs
.size ();
4525 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ) {
4526 RegionSelection::iterator tmp
= r
;
4529 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*>(*r
);
4531 boost::shared_ptr
<Playlist
> playlist
= arv
->region()->playlist();
4534 progress
->descend (1.0 / N
);
4537 if (arv
->audio_region()->apply (filter
, progress
) == 0) {
4539 playlist
->clear_changes ();
4541 if (filter
.results
.empty ()) {
4543 /* no regions returned; remove the old one */
4544 playlist
->remove_region (arv
->region ());
4548 std::vector
<boost::shared_ptr
<Region
> >::iterator res
= filter
.results
.begin ();
4550 /* first region replaces the old one */
4551 playlist
->replace_region (arv
->region(), *res
, (*res
)->position());
4555 while (res
!= filter
.results
.end()) {
4556 playlist
->add_region (*res
, (*res
)->position());
4562 _session
->add_command(new StatefulDiffCommand (playlist
));
4568 progress
->ascend ();
4576 commit_reversible_command ();
4579 set_canvas_cursor (current_canvas_cursor
);
4583 Editor::external_edit_region ()
4589 Editor::reset_region_gain_envelopes ()
4591 RegionSelection rs
= get_regions_from_selection_and_entered ();
4593 if (!_session
|| rs
.empty()) {
4597 _session
->begin_reversible_command (_("reset region gain"));
4599 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4600 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*>(*i
);
4602 boost::shared_ptr
<AutomationList
> alist (arv
->audio_region()->envelope());
4603 XMLNode
& before (alist
->get_state());
4605 arv
->audio_region()->set_default_envelope ();
4606 _session
->add_command (new MementoCommand
<AutomationList
>(*arv
->audio_region()->envelope().get(), &before
, &alist
->get_state()));
4610 _session
->commit_reversible_command ();
4614 Editor::toggle_gain_envelope_visibility ()
4616 if (_ignore_region_action
) {
4620 RegionSelection rs
= get_regions_from_selection_and_entered ();
4622 if (!_session
|| rs
.empty()) {
4626 _session
->begin_reversible_command (_("region gain envelope visible"));
4628 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4629 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*>(*i
);
4631 arv
->region()->clear_changes ();
4632 arv
->set_envelope_visible (!arv
->envelope_visible());
4633 _session
->add_command (new StatefulDiffCommand (arv
->region()));
4637 _session
->commit_reversible_command ();
4641 Editor::toggle_gain_envelope_active ()
4643 if (_ignore_region_action
) {
4647 RegionSelection rs
= get_regions_from_selection_and_entered ();
4649 if (!_session
|| rs
.empty()) {
4653 _session
->begin_reversible_command (_("region gain envelope active"));
4655 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4656 AudioRegionView
* const arv
= dynamic_cast<AudioRegionView
*>(*i
);
4658 arv
->region()->clear_changes ();
4659 arv
->audio_region()->set_envelope_active (!arv
->audio_region()->envelope_active());
4660 _session
->add_command (new StatefulDiffCommand (arv
->region()));
4664 _session
->commit_reversible_command ();
4668 Editor::toggle_region_lock ()
4670 if (_ignore_region_action
) {
4674 RegionSelection rs
= get_regions_from_selection_and_entered ();
4676 if (!_session
|| rs
.empty()) {
4680 _session
->begin_reversible_command (_("toggle region lock"));
4682 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4683 (*i
)->region()->clear_changes ();
4684 (*i
)->region()->set_locked (!(*i
)->region()->locked());
4685 _session
->add_command (new StatefulDiffCommand ((*i
)->region()));
4688 _session
->commit_reversible_command ();
4692 Editor::toggle_region_lock_style ()
4694 if (_ignore_region_action
) {
4698 RegionSelection rs
= get_regions_from_selection_and_entered ();
4700 if (!_session
|| rs
.empty()) {
4704 _session
->begin_reversible_command (_("region lock style"));
4706 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4707 (*i
)->region()->clear_changes ();
4708 PositionLockStyle
const ns
= (*i
)->region()->position_lock_style() == AudioTime
? MusicTime
: AudioTime
;
4709 (*i
)->region()->set_position_lock_style (ns
);
4710 _session
->add_command (new StatefulDiffCommand ((*i
)->region()));
4713 _session
->commit_reversible_command ();
4717 Editor::toggle_opaque_region ()
4719 if (_ignore_region_action
) {
4723 RegionSelection rs
= get_regions_from_selection_and_entered ();
4725 if (!_session
|| rs
.empty()) {
4729 _session
->begin_reversible_command (_("change region opacity"));
4731 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4732 (*i
)->region()->clear_changes ();
4733 (*i
)->region()->set_opaque (!(*i
)->region()->opaque());
4734 _session
->add_command (new StatefulDiffCommand ((*i
)->region()));
4737 _session
->commit_reversible_command ();
4741 Editor::toggle_record_enable ()
4743 bool new_state
= false;
4745 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
4746 RouteTimeAxisView
*rtav
= dynamic_cast<RouteTimeAxisView
*>(*i
);
4749 if (!rtav
->is_track())
4753 new_state
= !rtav
->track()->record_enabled();
4757 rtav
->track()->set_record_enabled (new_state
, this);
4763 Editor::set_fade_length (bool in
)
4765 RegionSelection rs
= get_regions_from_selection_and_entered ();
4771 /* we need a region to measure the offset from the start */
4773 RegionView
* rv
= rs
.front ();
4775 framepos_t pos
= get_preferred_edit_position();
4779 if (pos
> rv
->region()->last_frame() || pos
< rv
->region()->first_frame()) {
4780 /* edit point is outside the relevant region */
4785 if (pos
<= rv
->region()->position()) {
4789 len
= pos
- rv
->region()->position();
4790 cmd
= _("set fade in length");
4792 if (pos
>= rv
->region()->last_frame()) {
4796 len
= rv
->region()->last_frame() - pos
;
4797 cmd
= _("set fade out length");
4800 begin_reversible_command (cmd
);
4802 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
4803 AudioRegionView
* tmp
= dynamic_cast<AudioRegionView
*> (*x
);
4809 boost::shared_ptr
<AutomationList
> alist
;
4811 alist
= tmp
->audio_region()->fade_in();
4813 alist
= tmp
->audio_region()->fade_out();
4816 XMLNode
&before
= alist
->get_state();
4819 tmp
->audio_region()->set_fade_in_length (len
);
4820 tmp
->audio_region()->set_fade_in_active (true);
4822 tmp
->audio_region()->set_fade_out_length (len
);
4823 tmp
->audio_region()->set_fade_out_active (true);
4826 XMLNode
&after
= alist
->get_state();
4827 _session
->add_command(new MementoCommand
<AutomationList
>(*alist
, &before
, &after
));
4830 commit_reversible_command ();
4834 Editor::set_fade_in_shape (FadeShape shape
)
4836 RegionSelection rs
= get_regions_from_selection_and_entered ();
4842 begin_reversible_command (_("set fade in shape"));
4844 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
4845 AudioRegionView
* tmp
= dynamic_cast<AudioRegionView
*> (*x
);
4851 boost::shared_ptr
<AutomationList
> alist
= tmp
->audio_region()->fade_in();
4852 XMLNode
&before
= alist
->get_state();
4854 tmp
->audio_region()->set_fade_in_shape (shape
);
4856 XMLNode
&after
= alist
->get_state();
4857 _session
->add_command(new MementoCommand
<AutomationList
>(*alist
.get(), &before
, &after
));
4860 commit_reversible_command ();
4865 Editor::set_fade_out_shape (FadeShape shape
)
4867 RegionSelection rs
= get_regions_from_selection_and_entered ();
4873 begin_reversible_command (_("set fade out shape"));
4875 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
4876 AudioRegionView
* tmp
= dynamic_cast<AudioRegionView
*> (*x
);
4882 boost::shared_ptr
<AutomationList
> alist
= tmp
->audio_region()->fade_out();
4883 XMLNode
&before
= alist
->get_state();
4885 tmp
->audio_region()->set_fade_out_shape (shape
);
4887 XMLNode
&after
= alist
->get_state();
4888 _session
->add_command(new MementoCommand
<AutomationList
>(*alist
.get(), &before
, &after
));
4891 commit_reversible_command ();
4895 Editor::set_fade_in_active (bool yn
)
4897 RegionSelection rs
= get_regions_from_selection_and_entered ();
4903 begin_reversible_command (_("set fade in active"));
4905 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
4906 AudioRegionView
* tmp
= dynamic_cast<AudioRegionView
*> (*x
);
4913 boost::shared_ptr
<AudioRegion
> ar (tmp
->audio_region());
4915 ar
->clear_changes ();
4916 ar
->set_fade_in_active (yn
);
4917 _session
->add_command (new StatefulDiffCommand (ar
));
4920 commit_reversible_command ();
4924 Editor::set_fade_out_active (bool yn
)
4926 RegionSelection rs
= get_regions_from_selection_and_entered ();
4932 begin_reversible_command (_("set fade out active"));
4934 for (RegionSelection::iterator x
= rs
.begin(); x
!= rs
.end(); ++x
) {
4935 AudioRegionView
* tmp
= dynamic_cast<AudioRegionView
*> (*x
);
4941 boost::shared_ptr
<AudioRegion
> ar (tmp
->audio_region());
4943 ar
->clear_changes ();
4944 ar
->set_fade_out_active (yn
);
4945 _session
->add_command(new StatefulDiffCommand (ar
));
4948 commit_reversible_command ();
4952 Editor::toggle_region_fades (int dir
)
4954 boost::shared_ptr
<AudioRegion
> ar
;
4957 RegionSelection rs
= get_regions_from_selection_and_entered ();
4963 RegionSelection::iterator i
;
4964 for (i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4965 if ((ar
= boost::dynamic_pointer_cast
<AudioRegion
>((*i
)->region())) != 0) {
4967 yn
= ar
->fade_out_active ();
4969 yn
= ar
->fade_in_active ();
4975 if (i
== rs
.end()) {
4979 /* XXX should this undo-able? */
4981 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
4982 if ((ar
= boost::dynamic_pointer_cast
<AudioRegion
>((*i
)->region())) == 0) {
4985 if (dir
== 1 || dir
== 0) {
4986 ar
->set_fade_in_active (!yn
);
4989 if (dir
== -1 || dir
== 0) {
4990 ar
->set_fade_out_active (!yn
);
4996 /** Update region fade visibility after its configuration has been changed */
4998 Editor::update_region_fade_visibility ()
5000 bool _fade_visibility
= _session
->config
.get_show_region_fades ();
5002 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
5003 AudioTimeAxisView
* v
= dynamic_cast<AudioTimeAxisView
*>(*i
);
5005 if (_fade_visibility
) {
5006 v
->audio_view()->show_all_fades ();
5008 v
->audio_view()->hide_all_fades ();
5014 /** Update crossfade visibility after its configuration has been changed */
5016 Editor::update_xfade_visibility ()
5018 _xfade_visibility
= _session
->config
.get_xfades_visible ();
5020 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
5021 AudioTimeAxisView
* v
= dynamic_cast<AudioTimeAxisView
*>(*i
);
5023 if (_xfade_visibility
) {
5024 v
->show_all_xfades ();
5026 v
->hide_all_xfades ();
5033 Editor::set_edit_point ()
5038 if (!mouse_frame (where
, ignored
)) {
5044 if (selection
->markers
.empty()) {
5046 mouse_add_new_marker (where
);
5051 Location
* loc
= find_location_from_marker (selection
->markers
.front(), ignored
);
5054 loc
->move_to (where
);
5060 Editor::set_playhead_cursor ()
5062 if (entered_marker
) {
5063 _session
->request_locate (entered_marker
->position(), _session
->transport_rolling());
5068 if (!mouse_frame (where
, ignored
)) {
5075 _session
->request_locate (where
, _session
->transport_rolling());
5081 Editor::split_region ()
5083 if (((mouse_mode
== MouseRange
) ||
5084 (mouse_mode
!= MouseObject
&& _join_object_range_state
== JOIN_OBJECT_RANGE_RANGE
)) &&
5085 !selection
->time
.empty()) {
5086 separate_regions_between (selection
->time
);
5090 RegionSelection rs
= get_regions_from_selection_and_edit_point ();
5092 framepos_t where
= get_preferred_edit_position ();
5098 split_regions_at (where
, rs
);
5102 Editor::ensure_entered_track_selected (bool op_really_wants_one_track_if_none_are_selected
)
5104 if (entered_track
&& mouse_mode
== MouseObject
) {
5105 if (!selection
->tracks
.empty()) {
5106 if (!selection
->selected (entered_track
)) {
5107 selection
->add (entered_track
);
5110 /* there is no selection, but this operation requires/prefers selected objects */
5112 if (op_really_wants_one_track_if_none_are_selected
) {
5113 selection
->set (entered_track
);
5119 struct EditorOrderRouteSorter
{
5120 bool operator() (boost::shared_ptr
<Route
> a
, boost::shared_ptr
<Route
> b
) {
5121 /* use of ">" forces the correct sort order */
5122 return a
->order_key ("editor") < b
->order_key ("editor");
5127 Editor::select_next_route()
5129 if (selection
->tracks
.empty()) {
5130 selection
->set (track_views
.front());
5134 TimeAxisView
* current
= selection
->tracks
.front();
5138 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
5139 if (*i
== current
) {
5141 if (i
!= track_views
.end()) {
5144 current
= (*(track_views
.begin()));
5145 //selection->set (*(track_views.begin()));
5150 rui
= dynamic_cast<RouteUI
*>(current
);
5151 } while ( current
->hidden() || (rui
!= NULL
&& !rui
->route()->active()));
5153 selection
->set(current
);
5155 ensure_track_visible(current
);
5159 Editor::select_prev_route()
5161 if (selection
->tracks
.empty()) {
5162 selection
->set (track_views
.front());
5166 TimeAxisView
* current
= selection
->tracks
.front();
5170 for (TrackViewList::reverse_iterator i
= track_views
.rbegin(); i
!= track_views
.rend(); ++i
) {
5171 if (*i
== current
) {
5173 if (i
!= track_views
.rend()) {
5176 current
= *(track_views
.rbegin());
5181 rui
= dynamic_cast<RouteUI
*>(current
);
5182 } while ( current
->hidden() || (rui
!= NULL
&& !rui
->route()->active()));
5184 selection
->set (current
);
5186 ensure_track_visible(current
);
5190 Editor::ensure_track_visible(TimeAxisView
*track
)
5192 if (track
->hidden())
5195 double const current_view_min_y
= vertical_adjustment
.get_value();
5196 double const current_view_max_y
= vertical_adjustment
.get_value() + vertical_adjustment
.get_page_size() - canvas_timebars_vsize
;
5198 double const track_min_y
= track
->y_position ();
5199 double const track_max_y
= track
->y_position () + track
->effective_height ();
5201 if (track_min_y
>= current_view_min_y
&&
5202 track_max_y
<= current_view_max_y
) {
5208 if (track_min_y
< current_view_min_y
) {
5209 // Track is above the current view
5210 new_value
= track_min_y
;
5212 // Track is below the current view
5213 new_value
= track
->y_position () + track
->effective_height() + canvas_timebars_vsize
- vertical_adjustment
.get_page_size();
5216 vertical_adjustment
.set_value(new_value
);
5220 Editor::set_loop_from_selection (bool play
)
5222 if (_session
== 0 || selection
->time
.empty()) {
5226 framepos_t start
= selection
->time
[clicked_selection
].start
;
5227 framepos_t end
= selection
->time
[clicked_selection
].end
;
5229 set_loop_range (start
, end
, _("set loop range from selection"));
5232 _session
->request_play_loop (true);
5233 _session
->request_locate (start
, true);
5238 Editor::set_loop_from_edit_range (bool play
)
5240 if (_session
== 0) {
5247 if (!get_edit_op_range (start
, end
)) {
5251 set_loop_range (start
, end
, _("set loop range from edit range"));
5254 _session
->request_play_loop (true);
5255 _session
->request_locate (start
, true);
5260 Editor::set_loop_from_region (bool play
)
5262 framepos_t start
= max_framepos
;
5265 RegionSelection rs
= get_regions_from_selection_and_entered ();
5271 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
5272 if ((*i
)->region()->position() < start
) {
5273 start
= (*i
)->region()->position();
5275 if ((*i
)->region()->last_frame() + 1 > end
) {
5276 end
= (*i
)->region()->last_frame() + 1;
5280 set_loop_range (start
, end
, _("set loop range from region"));
5283 _session
->request_play_loop (true);
5284 _session
->request_locate (start
, true);
5289 Editor::set_punch_from_selection ()
5291 if (_session
== 0 || selection
->time
.empty()) {
5295 framepos_t start
= selection
->time
[clicked_selection
].start
;
5296 framepos_t end
= selection
->time
[clicked_selection
].end
;
5298 set_punch_range (start
, end
, _("set punch range from selection"));
5302 Editor::set_punch_from_edit_range ()
5304 if (_session
== 0) {
5311 if (!get_edit_op_range (start
, end
)) {
5315 set_punch_range (start
, end
, _("set punch range from edit range"));
5319 Editor::set_punch_from_region ()
5321 framepos_t start
= max_framepos
;
5324 RegionSelection rs
= get_regions_from_selection_and_entered ();
5330 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
5331 if ((*i
)->region()->position() < start
) {
5332 start
= (*i
)->region()->position();
5334 if ((*i
)->region()->last_frame() + 1 > end
) {
5335 end
= (*i
)->region()->last_frame() + 1;
5339 set_punch_range (start
, end
, _("set punch range from region"));
5343 Editor::pitch_shift_region ()
5345 RegionSelection rs
= get_regions_from_selection_and_entered ();
5351 pitch_shift (rs
, 1.2);
5355 Editor::set_tempo_from_region ()
5357 RegionSelection rs
= get_regions_from_selection_and_entered ();
5359 if (!_session
|| rs
.empty()) {
5363 RegionView
* rv
= rs
.front();
5365 define_one_bar (rv
->region()->position(), rv
->region()->last_frame() + 1);
5369 Editor::use_range_as_bar ()
5371 framepos_t start
, end
;
5372 if (get_edit_op_range (start
, end
)) {
5373 define_one_bar (start
, end
);
5378 Editor::define_one_bar (framepos_t start
, framepos_t end
)
5380 framepos_t length
= end
- start
;
5382 const Meter
& m (_session
->tempo_map().meter_at (start
));
5384 /* length = 1 bar */
5386 /* now we want frames per beat.
5387 we have frames per bar, and beats per bar, so ...
5390 double frames_per_beat
= length
/ m
.beats_per_bar();
5392 /* beats per minute = */
5394 double beats_per_minute
= (_session
->frame_rate() * 60.0) / frames_per_beat
;
5396 /* now decide whether to:
5398 (a) set global tempo
5399 (b) add a new tempo marker
5403 const TempoSection
& t (_session
->tempo_map().tempo_section_at (start
));
5405 bool do_global
= false;
5407 if ((_session
->tempo_map().n_tempos() == 1) && (_session
->tempo_map().n_meters() == 1)) {
5409 /* only 1 tempo & 1 meter: ask if the user wants to set the tempo
5410 at the start, or create a new marker
5413 vector
<string
> options
;
5414 options
.push_back (_("Cancel"));
5415 options
.push_back (_("Add new marker"));
5416 options
.push_back (_("Set global tempo"));
5419 _("Define one bar"),
5420 _("Do you want to set the global tempo or add a new tempo marker?"),
5424 c
.set_default_response (2);
5440 /* more than 1 tempo and/or meter section already, go ahead do the "usual":
5441 if the marker is at the region starter, change it, otherwise add
5446 begin_reversible_command (_("set tempo from region"));
5447 XMLNode
& before (_session
->tempo_map().get_state());
5450 _session
->tempo_map().change_initial_tempo (beats_per_minute
, t
.note_type());
5451 } else if (t
.frame() == start
) {
5452 _session
->tempo_map().change_existing_tempo_at (start
, beats_per_minute
, t
.note_type());
5454 _session
->tempo_map().add_tempo (Tempo (beats_per_minute
, t
.note_type()), start
);
5457 XMLNode
& after (_session
->tempo_map().get_state());
5459 _session
->add_command (new MementoCommand
<TempoMap
>(_session
->tempo_map(), &before
, &after
));
5460 commit_reversible_command ();
5464 Editor::split_region_at_transients ()
5466 AnalysisFeatureList positions
;
5468 RegionSelection rs
= get_regions_from_selection_and_entered ();
5470 if (!_session
|| rs
.empty()) {
5474 _session
->begin_reversible_command (_("split regions"));
5476 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ) {
5478 RegionSelection::iterator tmp
;
5483 boost::shared_ptr
<AudioRegion
> ar
= boost::dynamic_pointer_cast
<AudioRegion
> ((*i
)->region());
5485 if (ar
&& (ar
->get_transients (positions
) == 0)) {
5486 split_region_at_points ((*i
)->region(), positions
, true);
5493 _session
->commit_reversible_command ();
5498 Editor::split_region_at_points (boost::shared_ptr
<Region
> r
, AnalysisFeatureList
& positions
, bool can_ferret
, bool select_new
)
5500 bool use_rhythmic_rodent
= false;
5502 boost::shared_ptr
<Playlist
> pl
= r
->playlist();
5504 list
<boost::shared_ptr
<Region
> > new_regions
;
5510 if (positions
.empty()) {
5515 if (positions
.size() > 20 && can_ferret
) {
5516 std::string msgstr
= string_compose (_("You are about to split\n%1\ninto %2 pieces.\nThis could take a long time."), r
->name(), positions
.size() + 1);
5517 MessageDialog
msg (msgstr
,
5520 Gtk::BUTTONS_OK_CANCEL
);
5523 msg
.add_button (_("Call for the Ferret!"), RESPONSE_APPLY
);
5524 msg
.set_secondary_text (_("Press OK to continue with this split operation\nor ask the Ferret dialog to tune the analysis"));
5526 msg
.set_secondary_text (_("Press OK to continue with this split operation"));
5529 msg
.set_title (_("Excessive split?"));
5532 int response
= msg
.run();
5538 case RESPONSE_APPLY
:
5539 use_rhythmic_rodent
= true;
5546 if (use_rhythmic_rodent
) {
5547 show_rhythm_ferret ();
5551 AnalysisFeatureList::const_iterator x
;
5553 pl
->clear_changes ();
5555 x
= positions
.begin();
5557 if (x
== positions
.end()) {
5562 pl
->remove_region (r
);
5566 while (x
!= positions
.end()) {
5568 /* deal with positons that are out of scope of present region bounds */
5569 if (*x
<= 0 || *x
> r
->length()) {
5574 /* file start = original start + how far we from the initial position ?
5577 framepos_t file_start
= r
->start() + pos
;
5579 /* length = next position - current position
5582 framepos_t len
= (*x
) - pos
;
5584 /* XXX we do we really want to allow even single-sample regions?
5585 shouldn't we have some kind of lower limit on region size?
5594 if (RegionFactory::region_name (new_name
, r
->name())) {
5598 /* do NOT announce new regions 1 by one, just wait till they are all done */
5602 plist
.add (ARDOUR::Properties::start
, file_start
);
5603 plist
.add (ARDOUR::Properties::length
, len
);
5604 plist
.add (ARDOUR::Properties::name
, new_name
);
5605 plist
.add (ARDOUR::Properties::layer
, 0);
5607 boost::shared_ptr
<Region
> nr
= RegionFactory::create (r
->sources(), plist
, false);
5609 pl
->add_region (nr
, r
->position() + pos
);
5612 new_regions
.push_front(nr
);
5621 RegionFactory::region_name (new_name
, r
->name());
5623 /* Add the final region */
5626 plist
.add (ARDOUR::Properties::start
, r
->start() + pos
);
5627 plist
.add (ARDOUR::Properties::length
, r
->last_frame() - (r
->position() + pos
) + 1);
5628 plist
.add (ARDOUR::Properties::name
, new_name
);
5629 plist
.add (ARDOUR::Properties::layer
, 0);
5631 boost::shared_ptr
<Region
> nr
= RegionFactory::create (r
->sources(), plist
, false);
5632 pl
->add_region (nr
, r
->position() + pos
);
5635 new_regions
.push_front(nr
);
5640 _session
->add_command (new StatefulDiffCommand (pl
));
5644 for (list
<boost::shared_ptr
<Region
> >::iterator i
= new_regions
.begin(); i
!= new_regions
.end(); ++i
){
5645 set_selected_regionview_from_region_list ((*i
), Selection::Add
);
5651 Editor::place_transient()
5657 RegionSelection rs
= get_regions_from_selection_and_edit_point ();
5663 framepos_t where
= get_preferred_edit_position();
5665 _session
->begin_reversible_command (_("place transient"));
5667 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
5668 framepos_t position
= (*r
)->region()->position();
5669 (*r
)->region()->add_transient(where
- position
);
5672 _session
->commit_reversible_command ();
5676 Editor::remove_transient(ArdourCanvas::Item
* item
)
5682 ArdourCanvas::Line
* _line
= reinterpret_cast<ArdourCanvas::Line
*> (item
);
5685 AudioRegionView
* _arv
= reinterpret_cast<AudioRegionView
*> (item
->get_data ("regionview"));
5686 _arv
->remove_transient (*(float*) _line
->get_data ("position"));
5690 Editor::snap_regions_to_grid ()
5692 list
<boost::shared_ptr
<Playlist
> > used_playlists
;
5694 RegionSelection rs
= get_regions_from_selection_and_entered ();
5696 if (!_session
|| rs
.empty()) {
5700 _session
->begin_reversible_command (_("snap regions to grid"));
5702 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
5704 boost::shared_ptr
<Playlist
> pl
= (*r
)->region()->playlist();
5706 if (!pl
->frozen()) {
5707 /* we haven't seen this playlist before */
5709 /* remember used playlists so we can thaw them later */
5710 used_playlists
.push_back(pl
);
5714 framepos_t start_frame
= (*r
)->region()->first_frame ();
5715 snap_to (start_frame
);
5716 (*r
)->region()->set_position (start_frame
, this);
5719 while (used_playlists
.size() > 0) {
5720 list
<boost::shared_ptr
<Playlist
> >::iterator i
= used_playlists
.begin();
5722 used_playlists
.pop_front();
5725 _session
->commit_reversible_command ();
5729 Editor::close_region_gaps ()
5731 list
<boost::shared_ptr
<Playlist
> > used_playlists
;
5733 RegionSelection rs
= get_regions_from_selection_and_entered ();
5735 if (!_session
|| rs
.empty()) {
5739 Dialog
dialog (_("Close Region Gaps"));
5742 table
.set_spacings (12);
5743 table
.set_border_width (12);
5744 Label
* l
= manage (new Label (_("Crossfade length")));
5745 l
->set_alignment (0, 0.5);
5746 table
.attach (*l
, 0, 1, 0, 1);
5748 SpinButton
spin_crossfade (1, 0);
5749 spin_crossfade
.set_range (0, 15);
5750 spin_crossfade
.set_increments (1, 1);
5751 spin_crossfade
.set_value (5);
5752 table
.attach (spin_crossfade
, 1, 2, 0, 1);
5754 table
.attach (*manage (new Label (_("ms"))), 2, 3, 0, 1);
5756 l
= manage (new Label (_("Pull-back length")));
5757 l
->set_alignment (0, 0.5);
5758 table
.attach (*l
, 0, 1, 1, 2);
5760 SpinButton
spin_pullback (1, 0);
5761 spin_pullback
.set_range (0, 100);
5762 spin_pullback
.set_increments (1, 1);
5763 spin_pullback
.set_value(30);
5764 table
.attach (spin_pullback
, 1, 2, 1, 2);
5766 table
.attach (*manage (new Label (_("ms"))), 2, 3, 1, 2);
5768 dialog
.get_vbox()->pack_start (table
);
5769 dialog
.add_button (Stock::CANCEL
, RESPONSE_CANCEL
);
5770 dialog
.add_button (_("Ok"), RESPONSE_ACCEPT
);
5773 if (dialog
.run () == RESPONSE_CANCEL
) {
5777 framepos_t crossfade_len
= spin_crossfade
.get_value();
5778 framepos_t pull_back_frames
= spin_pullback
.get_value();
5780 crossfade_len
= lrintf (crossfade_len
* _session
->frame_rate()/1000);
5781 pull_back_frames
= lrintf (pull_back_frames
* _session
->frame_rate()/1000);
5783 /* Iterate over the region list and make adjacent regions overlap by crossfade_len_ms */
5785 _session
->begin_reversible_command (_("close region gaps"));
5788 boost::shared_ptr
<Region
> last_region
;
5790 rs
.sort_by_position_and_track();
5792 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
5794 boost::shared_ptr
<Playlist
> pl
= (*r
)->region()->playlist();
5796 if (!pl
->frozen()) {
5797 /* we haven't seen this playlist before */
5799 /* remember used playlists so we can thaw them later */
5800 used_playlists
.push_back(pl
);
5804 framepos_t position
= (*r
)->region()->position();
5806 if (idx
== 0 || position
< last_region
->position()){
5807 last_region
= (*r
)->region();
5812 (*r
)->region()->trim_front( (position
- pull_back_frames
), this );
5813 last_region
->trim_end( (position
- pull_back_frames
+ crossfade_len
), this );
5815 last_region
= (*r
)->region();
5820 while (used_playlists
.size() > 0) {
5821 list
<boost::shared_ptr
<Playlist
> >::iterator i
= used_playlists
.begin();
5823 used_playlists
.pop_front();
5826 _session
->commit_reversible_command ();
5830 Editor::tab_to_transient (bool forward
)
5832 AnalysisFeatureList positions
;
5834 RegionSelection rs
= get_regions_from_selection_and_entered ();
5840 framepos_t pos
= _session
->audible_frame ();
5842 if (!selection
->tracks
.empty()) {
5844 for (TrackSelection::iterator t
= selection
->tracks
.begin(); t
!= selection
->tracks
.end(); ++t
) {
5846 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (*t
);
5849 boost::shared_ptr
<Track
> tr
= rtv
->track();
5851 boost::shared_ptr
<Playlist
> pl
= tr
->playlist ();
5853 framepos_t result
= pl
->find_next_transient (pos
, forward
? 1 : -1);
5856 positions
.push_back (result
);
5869 for (RegionSelection::iterator r
= rs
.begin(); r
!= rs
.end(); ++r
) {
5870 (*r
)->region()->get_transients (positions
);
5874 TransientDetector::cleanup_transients (positions
, _session
->frame_rate(), 3.0);
5877 AnalysisFeatureList::iterator x
;
5879 for (x
= positions
.begin(); x
!= positions
.end(); ++x
) {
5885 if (x
!= positions
.end ()) {
5886 _session
->request_locate (*x
);
5890 AnalysisFeatureList::reverse_iterator x
;
5892 for (x
= positions
.rbegin(); x
!= positions
.rend(); ++x
) {
5898 if (x
!= positions
.rend ()) {
5899 _session
->request_locate (*x
);
5905 Editor::playhead_forward_to_grid ()
5907 if (!_session
) return;
5908 framepos_t pos
= playhead_cursor
->current_frame
;
5909 if (pos
< max_framepos
- 1) {
5911 snap_to_internal (pos
, 1, false);
5912 _session
->request_locate (pos
);
5918 Editor::playhead_backward_to_grid ()
5920 if (!_session
) return;
5921 framepos_t pos
= playhead_cursor
->current_frame
;
5924 snap_to_internal (pos
, -1, false);
5925 _session
->request_locate (pos
);
5930 Editor::set_track_height (Height h
)
5932 TrackSelection
& ts (selection
->tracks
);
5934 for (TrackSelection::iterator x
= ts
.begin(); x
!= ts
.end(); ++x
) {
5935 (*x
)->set_height_enum (h
);
5940 Editor::toggle_tracks_active ()
5942 TrackSelection
& ts (selection
->tracks
);
5944 bool target
= false;
5950 for (TrackSelection::iterator x
= ts
.begin(); x
!= ts
.end(); ++x
) {
5951 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*>(*x
);
5955 target
= !rtv
->_route
->active();
5958 rtv
->_route
->set_active (target
, this);
5964 Editor::remove_tracks ()
5966 TrackSelection
& ts (selection
->tracks
);
5972 vector
<string
> choices
;
5976 const char* trackstr
;
5978 vector
<boost::shared_ptr
<Route
> > routes
;
5979 bool special_bus
= false;
5981 for (TrackSelection::iterator x
= ts
.begin(); x
!= ts
.end(); ++x
) {
5982 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (*x
);
5984 if (rtv
->is_track()) {
5990 routes
.push_back (rtv
->_route
);
5992 if (rtv
->route()->is_master() || rtv
->route()->is_monitor()) {
5997 if (special_bus
&& !Config
->get_allow_special_bus_removal()) {
5998 MessageDialog
msg (_("That would be bad news ...."),
6002 msg
.set_secondary_text (string_compose (_(
6003 "Removing the master or monitor bus is such a bad idea\n\
6004 that %1 is not going to allow it.\n\
6006 If you really want to do this sort of thing\n\
6007 edit your ardour.rc file to set the\n\
6008 \"allow-special-bus-removal\" option to be \"yes\""), PROGRAM_NAME
));
6015 if (ntracks
+ nbusses
== 0) {
6020 trackstr
= _("tracks");
6022 trackstr
= _("track");
6026 busstr
= _("busses");
6033 prompt
= string_compose (_("Do you really want to remove %1 %2 and %3 %4?\n"
6034 "(You may also lose the playlists associated with the %2)\n\n"
6035 "This action cannot be undone, and the session file will be overwritten!"),
6036 ntracks
, trackstr
, nbusses
, busstr
);
6038 prompt
= string_compose (_("Do you really want to remove %1 %2?\n"
6039 "(You may also lose the playlists associated with the %2)\n\n"
6040 "This action cannot be undone, and the session file will be overwritten!"),
6043 } else if (nbusses
) {
6044 prompt
= string_compose (_("Do you really want to remove %1 %2?\n\n"
6045 "This action cannot be undon, and the session file will be overwritten"),
6049 choices
.push_back (_("No, do nothing."));
6050 if (ntracks
+ nbusses
> 1) {
6051 choices
.push_back (_("Yes, remove them."));
6053 choices
.push_back (_("Yes, remove it."));
6058 title
= string_compose (_("Remove %1"), trackstr
);
6060 title
= string_compose (_("Remove %1"), busstr
);
6063 Choice
prompter (title
, prompt
, choices
);
6065 if (prompter
.run () != 1) {
6069 for (vector
<boost::shared_ptr
<Route
> >::iterator x
= routes
.begin(); x
!= routes
.end(); ++x
) {
6070 _session
->remove_route (*x
);
6075 Editor::do_insert_time ()
6077 if (selection
->tracks
.empty()) {
6081 InsertTimeDialog
d (*this);
6082 int response
= d
.run ();
6084 if (response
!= RESPONSE_OK
) {
6088 if (d
.distance() == 0) {
6092 InsertTimeOption opt
= d
.intersected_region_action ();
6095 get_preferred_edit_position(),
6100 d
.move_glued_markers(),
6101 d
.move_locked_markers(),
6107 Editor::insert_time (framepos_t pos
, framecnt_t frames
, InsertTimeOption opt
,
6108 bool ignore_music_glue
, bool markers_too
, bool glued_markers_too
, bool locked_markers_too
, bool tempo_too
)
6110 bool commit
= false;
6112 if (Config
->get_edit_mode() == Lock
) {
6116 begin_reversible_command (_("insert time"));
6118 for (TrackSelection::iterator x
= selection
->tracks
.begin(); x
!= selection
->tracks
.end(); ++x
) {
6120 boost::shared_ptr
<Playlist
> pl
= (*x
)->playlist();
6124 pl
->clear_changes ();
6125 pl
->clear_owned_changes ();
6127 if (opt
== SplitIntersected
) {
6131 pl
->shift (pos
, frames
, (opt
== MoveIntersected
), ignore_music_glue
);
6133 vector
<Command
*> cmds
;
6135 _session
->add_commands (cmds
);
6137 _session
->add_command (new StatefulDiffCommand (pl
));
6142 RouteTimeAxisView
* rtav
= dynamic_cast<RouteTimeAxisView
*> (*x
);
6144 rtav
->route ()->shift (pos
, frames
);
6152 XMLNode
& before (_session
->locations()->get_state());
6153 Locations::LocationList
copy (_session
->locations()->list());
6155 for (Locations::LocationList::iterator i
= copy
.begin(); i
!= copy
.end(); ++i
) {
6157 Locations::LocationList::const_iterator tmp
;
6159 bool const was_locked
= (*i
)->locked ();
6160 if (locked_markers_too
) {
6164 if ((*i
)->position_lock_style() == AudioTime
|| glued_markers_too
) {
6166 if ((*i
)->start() >= pos
) {
6167 (*i
)->set_start ((*i
)->start() + frames
);
6168 if (!(*i
)->is_mark()) {
6169 (*i
)->set_end ((*i
)->end() + frames
);
6182 XMLNode
& after (_session
->locations()->get_state());
6183 _session
->add_command (new MementoCommand
<Locations
>(*_session
->locations(), &before
, &after
));
6188 _session
->tempo_map().insert_time (pos
, frames
);
6192 commit_reversible_command ();
6197 Editor::fit_selected_tracks ()
6199 if (!selection
->tracks
.empty()) {
6200 fit_tracks (selection
->tracks
);
6204 /* no selected tracks - use tracks with selected regions */
6206 if (!selection
->regions
.empty()) {
6207 for (RegionSelection::iterator r
= selection
->regions
.begin(); r
!= selection
->regions
.end(); ++r
) {
6208 tvl
.push_back (&(*r
)->get_time_axis_view ());
6214 } else if (internal_editing()) {
6215 /* no selected tracks, or regions, but in internal edit mode, so follow the mouse and use
6218 if (entered_track
) {
6219 tvl
.push_back (entered_track
);
6227 Editor::fit_tracks (TrackViewList
& tracks
)
6229 if (tracks
.empty()) {
6233 uint32_t child_heights
= 0;
6234 int visible_tracks
= 0;
6236 for (TrackSelection::iterator t
= tracks
.begin(); t
!= tracks
.end(); ++t
) {
6238 if (!(*t
)->marked_for_display()) {
6242 child_heights
+= (*t
)->effective_height() - (*t
)->current_height();
6246 uint32_t h
= (uint32_t) floor ((_canvas_height
- child_heights
- canvas_timebars_vsize
) / visible_tracks
);
6247 double first_y_pos
= DBL_MAX
;
6249 if (h
< TimeAxisView::preset_height (HeightSmall
)) {
6250 MessageDialog
msg (*this, _("There are too many tracks to fit in the current window"));
6251 /* too small to be displayed */
6255 undo_visual_stack
.push_back (current_visual_state());
6257 /* build a list of all tracks, including children */
6260 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
6262 TimeAxisView::Children c
= (*i
)->get_child_list ();
6263 for (TimeAxisView::Children::iterator j
= c
.begin(); j
!= c
.end(); ++j
) {
6264 all
.push_back (j
->get());
6268 /* operate on all tracks, hide unselected ones that are in the middle of selected ones */
6270 bool prev_was_selected
= false;
6271 bool is_selected
= tracks
.contains (all
.front());
6272 bool next_is_selected
;
6274 for (TrackViewList::iterator t
= all
.begin(); t
!= all
.end(); ++t
) {
6276 TrackViewList::iterator next
;
6281 if (next
!= all
.end()) {
6282 next_is_selected
= tracks
.contains (*next
);
6284 next_is_selected
= false;
6287 if ((*t
)->marked_for_display ()) {
6289 (*t
)->set_height (h
);
6290 first_y_pos
= std::min ((*t
)->y_position (), first_y_pos
);
6292 if (prev_was_selected
&& next_is_selected
) {
6293 hide_track_in_display (*t
);
6298 prev_was_selected
= is_selected
;
6299 is_selected
= next_is_selected
;
6303 set the controls_layout height now, because waiting for its size
6304 request signal handler will cause the vertical adjustment setting to fail
6307 controls_layout
.property_height () = full_canvas_height
- canvas_timebars_vsize
;
6308 vertical_adjustment
.set_value (first_y_pos
);
6310 redo_visual_stack
.push_back (current_visual_state());
6314 Editor::save_visual_state (uint32_t n
)
6316 while (visual_states
.size() <= n
) {
6317 visual_states
.push_back (0);
6320 delete visual_states
[n
];
6322 visual_states
[n
] = current_visual_state (true);
6327 Editor::goto_visual_state (uint32_t n
)
6329 if (visual_states
.size() <= n
) {
6333 if (visual_states
[n
] == 0) {
6337 use_visual_state (*visual_states
[n
]);
6341 Editor::start_visual_state_op (uint32_t n
)
6343 if (visual_state_op_connection
.empty()) {
6344 visual_state_op_connection
= Glib::signal_timeout().connect (sigc::bind (sigc::mem_fun (*this, &Editor::end_visual_state_op
), n
), 1000);
6349 Editor::cancel_visual_state_op (uint32_t n
)
6351 if (!visual_state_op_connection
.empty()) {
6352 visual_state_op_connection
.disconnect();
6353 goto_visual_state (n
);
6355 //we land here if called from the menu OR if end_visual_state_op has been called
6356 //so check if we are already in visual state n
6357 // XXX not yet checking it at all, but redoing does not hurt
6358 goto_visual_state (n
);
6363 Editor::end_visual_state_op (uint32_t n
)
6365 visual_state_op_connection
.disconnect();
6366 save_visual_state (n
);
6368 PopUp
* pup
= new PopUp (WIN_POS_MOUSE
, 1000, true);
6370 snprintf (buf
, sizeof (buf
), _("Saved view %u"), n
+1);
6371 pup
->set_text (buf
);
6374 return false; // do not call again
6378 Editor::toggle_region_mute ()
6380 if (_ignore_region_action
) {
6384 RegionSelection rs
= get_regions_from_selection_and_entered ();
6390 if (rs
.size() > 1) {
6391 begin_reversible_command (_("mute regions"));
6393 begin_reversible_command (_("mute region"));
6396 for (RegionSelection::iterator i
= rs
.begin(); i
!= rs
.end(); ++i
) {
6398 (*i
)->region()->playlist()->clear_changes ();
6399 (*i
)->region()->set_muted (!(*i
)->region()->muted ());
6400 _session
->add_command (new StatefulDiffCommand ((*i
)->region()->playlist()));
6404 commit_reversible_command ();