X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_ops.cc;h=1b5067e2ac1d1ccdd684a745f414f9940140b1ec;hb=f19c01bbb42f4e80769adb8e3e1015724fe9d6c6;hp=467b8539f9139695af59d761f5df67a33ebba394;hpb=f2058a3f8739c6a7e9f7408f31d3b94ddb50673f;p=ardour.git diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 467b8539f9..1b5067e2ac 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -27,34 +27,33 @@ #include #include -#include -#include -#include -#include -#include +#include "pbd/error.h" +#include "pbd/basename.h" +#include "pbd/pthread_utils.h" +#include "pbd/memento_command.h" +#include "pbd/whitespace.h" #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ardour/audioengine.h" +#include "ardour/session.h" +#include "ardour/audioplaylist.h" +#include "ardour/audioregion.h" +#include "ardour/audio_diskstream.h" +#include "ardour/utils.h" +#include "ardour/location.h" +#include "ardour/named_selection.h" +#include "ardour/audio_track.h" +#include "ardour/audioplaylist.h" +#include "ardour/region_factory.h" +#include "ardour/playlist_factory.h" +#include "ardour/reverse.h" +#include "ardour/transient_detector.h" +#include "ardour/dB.h" +#include "ardour/quantize.h" #include "ardour_ui.h" #include "editor.h" @@ -174,26 +173,26 @@ Editor::split_regions_at (nframes64_t where, RegionSelection& regions) } AudioRegionView* const arv = dynamic_cast(*a); - if (arv) { _new_regionviews_show_envelope = arv->envelope_visible(); } if (pl) { - XMLNode &before = pl->get_state(); + XMLNode &before = pl->get_state(); pl->split_region ((*a)->region(), where); - XMLNode &after = pl->get_state(); - session->add_command(new MementoCommand(*pl, &before, &after)); + XMLNode &after = pl->get_state(); + session->add_command(new MementoCommand(*pl, &before, &after)); } a = tmp; } - while (used_playlists.size() > 0) { + while (used_playlists.size() > 0) { list >::iterator i = used_playlists.begin(); (*i)->thaw(); used_playlists.pop_front(); } + commit_reversible_command (); _new_regionviews_show_envelope = false; } @@ -711,7 +710,8 @@ Editor::build_region_boundary_cache () break; case SyncPoint: - rpos = r->adjust_to_sync (r->first_frame()); + rpos = r->sync_position (); + //r->adjust_to_sync (r->first_frame()); break; default: @@ -797,7 +797,8 @@ Editor::find_next_region (nframes64_t frame, RegionPoint point, int32_t dir, Tra break; case SyncPoint: - rpos = r->adjust_to_sync (r->first_frame()); + rpos = r->sync_position (); + // r->adjust_to_sync (r->first_frame()); break; } @@ -827,6 +828,7 @@ Editor::find_next_region_boundary (nframes64_t pos, int32_t dir, const TrackView nframes64_t distance = max_frames; nframes64_t current_nearest = -1; + for (TrackViewList::const_iterator i = tracks.begin(); i != tracks.end(); ++i) { nframes64_t contender; nframes64_t d; @@ -852,10 +854,45 @@ Editor::find_next_region_boundary (nframes64_t pos, int32_t dir, const TrackView return current_nearest; } +nframes64_t +Editor::get_region_boundary (nframes64_t pos, int32_t dir, bool with_selection, bool only_onscreen) +{ + nframes64_t target; + TrackViewList tvl; + + if (with_selection && Config->get_region_boundaries_from_selected_tracks()) { + + if (!selection->tracks.empty()) { + + target = find_next_region_boundary (pos, dir, selection->tracks); + + } else { + + if (only_onscreen || Config->get_region_boundaries_from_onscreen_tracks()) { + get_onscreen_tracks (tvl); + target = find_next_region_boundary (pos, dir, tvl); + } else { + target = find_next_region_boundary (pos, dir, track_views); + } + } + + } else { + + if (only_onscreen || Config->get_region_boundaries_from_onscreen_tracks()) { + get_onscreen_tracks (tvl); + target = find_next_region_boundary (pos, dir, tvl); + } else { + target = find_next_region_boundary (pos, dir, track_views); + } + } + + return target; +} + void -Editor::cursor_to_region_boundary (Cursor* cursor, int32_t dir) +Editor::cursor_to_region_boundary (bool with_selection, int32_t dir) { - nframes64_t pos = cursor->current_frame; + nframes64_t pos = playhead_cursor->current_frame; nframes64_t target; if (!session) { @@ -867,37 +904,24 @@ Editor::cursor_to_region_boundary (Cursor* cursor, int32_t dir) pos += dir; } - if (!selection->tracks.empty()) { - - target = find_next_region_boundary (pos, dir, selection->tracks); - - } else { - - target = find_next_region_boundary (pos, dir, track_views); - } - - if (target < 0) { + if ((target = get_region_boundary (pos, dir, with_selection, false)) < 0) { return; } - if (cursor == playhead_cursor) { - session->request_locate (target); - } else { - cursor->set_position (target); - } + session->request_locate (target); } void -Editor::cursor_to_next_region_boundary (Cursor* cursor) +Editor::cursor_to_next_region_boundary (bool with_selection) { - cursor_to_region_boundary (cursor, 1); + cursor_to_region_boundary (with_selection, 1); } void -Editor::cursor_to_previous_region_boundary (Cursor* cursor) +Editor::cursor_to_previous_region_boundary (bool with_selection) { - cursor_to_region_boundary (cursor, -1); + cursor_to_region_boundary (with_selection, -1); } void @@ -946,7 +970,8 @@ Editor::cursor_to_region_point (Cursor* cursor, RegionPoint point, int32_t dir) break; case SyncPoint: - pos = r->adjust_to_sync (r->first_frame()); + pos = r->sync_position (); + // r->adjust_to_sync (r->first_frame()); break; } @@ -1045,7 +1070,7 @@ Editor::cursor_to_selection_end (Cursor *cursor) } void -Editor::selected_marker_to_region_boundary (int32_t dir) +Editor::selected_marker_to_region_boundary (bool with_selection, int32_t dir) { nframes64_t target; Location* loc; @@ -1077,16 +1102,7 @@ Editor::selected_marker_to_region_boundary (int32_t dir) pos += dir; } - if (!selection->tracks.empty()) { - - target = find_next_region_boundary (pos, dir, selection->tracks); - - } else { - - target = find_next_region_boundary (pos, dir, track_views); - } - - if (target < 0) { + if ((target = get_region_boundary (pos, dir, with_selection, false)) < 0) { return; } @@ -1094,15 +1110,15 @@ Editor::selected_marker_to_region_boundary (int32_t dir) } void -Editor::selected_marker_to_next_region_boundary () +Editor::selected_marker_to_next_region_boundary (bool with_selection) { - selected_marker_to_region_boundary (1); + selected_marker_to_region_boundary (with_selection, 1); } void -Editor::selected_marker_to_previous_region_boundary () +Editor::selected_marker_to_previous_region_boundary (bool with_selection) { - selected_marker_to_region_boundary (-1); + selected_marker_to_region_boundary (with_selection, -1); } void @@ -1157,11 +1173,11 @@ Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir) } float speed = 1.0f; - AudioTimeAxisView *atav; + RouteTimeAxisView *rtav; - if ( ontrack != 0 && (atav = dynamic_cast(ontrack)) != 0 ) { - if (atav->get_diskstream() != 0) { - speed = atav->get_diskstream()->speed(); + if (ontrack != 0 && (rtav = dynamic_cast(ontrack)) != 0) { + if (rtav->get_diskstream() != 0) { + speed = rtav->get_diskstream()->speed(); } } @@ -2761,10 +2777,8 @@ Editor::region_from_selection () nframes64_t selection_cnt = end - start + 1; for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { - boost::shared_ptr current; - boost::shared_ptr current_r; + boost::shared_ptr current; boost::shared_ptr pl; - nframes64_t internal_start; string new_name; @@ -2772,17 +2786,14 @@ Editor::region_from_selection () continue; } - if ((current_r = pl->top_region_at (start)) == 0) { + if ((current = pl->top_region_at (start)) == 0) { continue; } - current = boost::dynamic_pointer_cast (current_r); - assert(current); // FIXME - if (current != 0) { - internal_start = start - current->position(); - session->region_name (new_name, current->name(), true); - boost::shared_ptr region (RegionFactory::create (current, internal_start, selection_cnt, new_name)); - } + internal_start = start - current->position(); + session->region_name (new_name, current->name(), true); + boost::shared_ptr region (RegionFactory::create (current, + internal_start, selection_cnt, new_name)); } } @@ -2799,9 +2810,7 @@ Editor::create_region_from_selection (vector >& new_re sort_track_selection (); for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { - - boost::shared_ptr current; - boost::shared_ptr current_r; + boost::shared_ptr current; boost::shared_ptr playlist; nframes64_t internal_start; string new_name; @@ -2810,18 +2819,15 @@ Editor::create_region_from_selection (vector >& new_re continue; } - if ((current_r = playlist->top_region_at(start)) == 0) { + if ((current = playlist->top_region_at(start)) == 0) { continue; } - if ((current = boost::dynamic_pointer_cast(current_r)) == 0) { - continue; - } - internal_start = start - current->position(); session->region_name (new_name, current->name(), true); - new_regions.push_back (boost::dynamic_pointer_cast (RegionFactory::create (current, internal_start, end - start + 1, new_name))); + new_regions.push_back (RegionFactory::create (current, + internal_start, end - start + 1, new_name)); } } @@ -2836,17 +2842,10 @@ Editor::split_multichannel_region () return; } - vector > v; + vector< boost::shared_ptr > v; for (list::iterator x = rs.begin(); x != rs.end(); ++x) { - - AudioRegionView* arv = dynamic_cast(*x); - - if (!arv || arv->audio_region()->n_channels() < 2) { - continue; - } - - (arv)->audio_region()->separate_by_channel (*session, v); + (*x)->region()->separate_by_channel (*session, v); } } @@ -2905,9 +2904,6 @@ Editor::separate_regions_between (const TimeSelection& ts) sort_track_selection (&tmptracks); - - - for (TrackSelection::iterator i = tmptracks.begin(); i != tmptracks.end(); ++i) { RouteTimeAxisView* rtv; @@ -2937,10 +2933,12 @@ Editor::separate_regions_between (const TimeSelection& ts) for (list::const_iterator t = ts.begin(); t != ts.end(); ++t) { - sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view)); + sigc::connection c = rtv->view()->RegionViewAdded.connect ( + mem_fun(*this, &Editor::collect_new_region_view)); latest_regionviews.clear (); - playlist->partition ((nframes64_t)((*t).start * speed), (nframes64_t)((*t).end * speed), true); + playlist->partition ((nframes64_t)((*t).start * speed), + (nframes64_t)((*t).end * speed), true); c.disconnect (); @@ -2948,15 +2946,17 @@ Editor::separate_regions_between (const TimeSelection& ts) got_some = true; - rtv->view()->foreach_regionview (bind (sigc::ptr_fun (add_if_covered), &(*t), &new_selection)); + rtv->view()->foreach_regionview (bind ( + sigc::ptr_fun (add_if_covered), + &(*t), &new_selection)); if (!in_command) { begin_reversible_command (_("separate")); in_command = true; } - session->add_command(new MementoCommand(*playlist, before, &playlist->get_state())); - + session->add_command(new MementoCommand( + *playlist, before, &playlist->get_state())); } } @@ -3506,24 +3506,18 @@ Editor::trim_region_to_location (const Location& loc, const char* str) begin_reversible_command (str); for (RegionSelection::iterator x = rs.begin(); x != rs.end(); ++x) { - AudioRegionView* arv = dynamic_cast (*x); - - if (!arv) { - continue; - } + RegionView* rv = (*x); /* require region to span proposed trim */ - - switch (arv->region()->coverage (loc.start(), loc.end())) { + switch (rv->region()->coverage (loc.start(), loc.end())) { case OverlapInternal: break; default: continue; } - AudioTimeAxisView* atav = dynamic_cast (&arv->get_time_axis_view()); - - if (!atav) { + RouteTimeAxisView* tav = dynamic_cast (&rv->get_time_axis_view()); + if (!tav) { return; } @@ -3531,17 +3525,18 @@ Editor::trim_region_to_location (const Location& loc, const char* str) nframes64_t start; nframes64_t end; - if (atav->get_diskstream() != 0) { - speed = atav->get_diskstream()->speed(); + if (tav->get_diskstream() != 0) { + speed = tav->get_diskstream()->speed(); } start = session_frame_to_track_frame (loc.start(), speed); end = session_frame_to_track_frame (loc.end(), speed); - XMLNode &before = arv->region()->playlist()->get_state(); - arv->region()->trim_to (start, (end - start), this); - XMLNode &after = arv->region()->playlist()->get_state(); - session->add_command(new MementoCommand(*(arv->region()->playlist()), &before, &after)); + XMLNode &before = rv->region()->playlist()->get_state(); + rv->region()->trim_to (start, (end - start), this); + XMLNode &after = rv->region()->playlist()->get_state(); + session->add_command(new MementoCommand( + *(rv->region()->playlist()), &before, &after)); } commit_reversible_command (); @@ -3559,34 +3554,29 @@ Editor::trim_region_to_edit_point () begin_reversible_command (_("trim region start to edit point")); for (RegionSelection::iterator x = rs.begin(); x != rs.end(); ++x) { - AudioRegionView* arv = dynamic_cast (*x); - - if (!arv) { - continue; - } + RegionView* rv = (*x); /* require region to cover trim */ - - if (!arv->region()->covers (where)) { + if (!rv->region()->covers (where)) { continue; } - AudioTimeAxisView* atav = dynamic_cast (&arv->get_time_axis_view()); - - if (!atav) { + RouteTimeAxisView* tav = dynamic_cast (&rv->get_time_axis_view()); + if (!tav) { return; } float speed = 1.0; - if (atav->get_diskstream() != 0) { - speed = atav->get_diskstream()->speed(); + if (tav->get_diskstream() != 0) { + speed = tav->get_diskstream()->speed(); } - XMLNode &before = arv->region()->playlist()->get_state(); - arv->region()->trim_end( session_frame_to_track_frame(where, speed), this); - XMLNode &after = arv->region()->playlist()->get_state(); - session->add_command(new MementoCommand(*(arv->region()->playlist()), &before, &after)); + XMLNode &before = rv->region()->playlist()->get_state(); + rv->region()->trim_end( session_frame_to_track_frame(where, speed), this); + XMLNode &after = rv->region()->playlist()->get_state(); + session->add_command(new MementoCommand( + *(rv->region()->playlist()), &before, &after)); } commit_reversible_command (); @@ -3604,34 +3594,29 @@ Editor::trim_region_from_edit_point () begin_reversible_command (_("trim region end to edit point")); for (RegionSelection::iterator x = rs.begin(); x != rs.end(); ++x) { - AudioRegionView* arv = dynamic_cast (*x); - - if (!arv) { - continue; - } + RegionView* rv = (*x); /* require region to cover trim */ - - if (!arv->region()->covers (where)) { + if (!rv->region()->covers (where)) { continue; } - AudioTimeAxisView* atav = dynamic_cast (&arv->get_time_axis_view()); - - if (!atav) { + RouteTimeAxisView* tav = dynamic_cast (&rv->get_time_axis_view()); + if (!tav) { return; } float speed = 1.0; - if (atav->get_diskstream() != 0) { - speed = atav->get_diskstream()->speed(); + if (tav->get_diskstream() != 0) { + speed = tav->get_diskstream()->speed(); } - XMLNode &before = arv->region()->playlist()->get_state(); - arv->region()->trim_front ( session_frame_to_track_frame(where, speed), this); - XMLNode &after = arv->region()->playlist()->get_state(); - session->add_command(new MementoCommand(*(arv->region()->playlist()), &before, &after)); + XMLNode &before = rv->region()->playlist()->get_state(); + rv->region()->trim_front ( session_frame_to_track_frame(where, speed), this); + XMLNode &after = rv->region()->playlist()->get_state(); + session->add_command(new MementoCommand( + *(rv->region()->playlist()), &before, &after)); } commit_reversible_command (); @@ -3640,11 +3625,11 @@ Editor::trim_region_from_edit_point () void Editor::unfreeze_route () { - if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) { + if (clicked_routeview == 0 || !clicked_routeview->is_track()) { return; } - clicked_routeview->audio_track()->unfreeze (); + clicked_routeview->track()->unfreeze (); } void* @@ -3658,13 +3643,14 @@ void* Editor::freeze_thread () { clicked_routeview->audio_track()->freeze (*current_interthread_info); + current_interthread_info->done = true; return 0; } gint Editor::freeze_progress_timeout (void *arg) { - interthread_progress_bar.set_fraction (current_interthread_info->progress/100); + interthread_progress_bar.set_fraction (current_interthread_info->progress); return !(current_interthread_info->done || current_interthread_info->cancel); } @@ -3702,7 +3688,7 @@ Editor::freeze_route () pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 500000); - pthread_create (&itt.thread, &attr, _freeze_thread, this); + pthread_create_and_store (X_("freezer"), &itt.thread, &attr, _freeze_thread, this); pthread_attr_destroy(&attr); @@ -3719,7 +3705,7 @@ Editor::freeze_route () } void -Editor::bounce_range_selection (bool replace) +Editor::bounce_range_selection (bool replace, bool enable_processing) { if (selection->time.empty()) { return; @@ -3754,7 +3740,7 @@ Editor::bounce_range_selection (bool replace) itt.progress = false; XMLNode &before = playlist->get_state(); - boost::shared_ptr r = rtv->track()->bounce_range (start, start+cnt, itt); + boost::shared_ptr r = rtv->track()->bounce_range (start, start+cnt, itt, enable_processing); if (replace) { list ranges; @@ -5898,37 +5884,6 @@ Editor::set_track_height (uint32_t h) } } -void -Editor::set_track_height_largest () -{ - set_track_height (TimeAxisView::hLargest); -} -void -Editor::set_track_height_large () -{ - set_track_height (TimeAxisView::hLarge); -} -void -Editor::set_track_height_larger () -{ - set_track_height (TimeAxisView::hLarger); -} -void -Editor::set_track_height_normal () -{ - set_track_height (TimeAxisView::hNormal); -} -void -Editor::set_track_height_smaller () -{ - set_track_height (TimeAxisView::hSmaller); -} -void -Editor::set_track_height_small () -{ - set_track_height (TimeAxisView::hSmall); -} - void Editor::toggle_tracks_active () {