From dd78cce7b7e1a7704c054f67ea38d846fdafd9b6 Mon Sep 17 00:00:00 2001 From: GZharun Date: Tue, 2 Dec 2014 16:57:40 +0200 Subject: [PATCH] [Summary] Reworked master track behavior according to PRD --- gtk2_ardour/actions.cc | 1 + gtk2_ardour/actions.h | 1 + gtk2_ardour/compact_meter_strip.cc | 2 +- gtk2_ardour/editor.cc | 10 ++--- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_actions.cc | 1 + gtk2_ardour/editor_routes.cc | 35 +++------------ gtk2_ardour/editor_selection.cc | 57 ++++++++---------------- gtk2_ardour/route_time_axis.cc | 7 +-- libs/ardour/session.cc | 70 ++++++++++-------------------- 10 files changed, 56 insertions(+), 130 deletions(-) diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc index bd9ef3c51d..d0af5ef40a 100644 --- a/gtk2_ardour/actions.cc +++ b/gtk2_ardour/actions.cc @@ -50,6 +50,7 @@ vector > ActionManager::write_sensitive_actions; vector > ActionManager::region_list_selection_sensitive_actions; vector > ActionManager::plugin_selection_sensitive_actions; vector > ActionManager::track_selection_sensitive_actions; +vector > ActionManager::actions_forbiden_for_master_track; vector > ActionManager::point_selection_sensitive_actions; vector > ActionManager::time_selection_sensitive_actions; vector > ActionManager::line_selection_sensitive_actions; diff --git a/gtk2_ardour/actions.h b/gtk2_ardour/actions.h index 50f9c20b82..19abc268c2 100644 --- a/gtk2_ardour/actions.h +++ b/gtk2_ardour/actions.h @@ -38,6 +38,7 @@ namespace ActionManager { extern std::vector > plugin_selection_sensitive_actions; extern std::vector > track_selection_sensitive_actions; + extern std::vector > actions_forbiden_for_master_track; extern std::vector > point_selection_sensitive_actions; extern std::vector > time_selection_sensitive_actions; extern std::vector > line_selection_sensitive_actions; diff --git a/gtk2_ardour/compact_meter_strip.cc b/gtk2_ardour/compact_meter_strip.cc index a8f61a4f89..67f1e42643 100644 --- a/gtk2_ardour/compact_meter_strip.cc +++ b/gtk2_ardour/compact_meter_strip.cc @@ -133,7 +133,7 @@ CompactMeterStrip::update_tooltip () boost::shared_ptr t; t = boost::dynamic_pointer_cast( _route ); - if( t!=NULL && t->is_master_track () ) + if( t != NULL && t->is_master_track () ) { this->set_tooltip_text (_route->name () + "\n" + record_status); } else diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 12b279216a..47dac6c197 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -5069,13 +5069,9 @@ Editor::add_routes (RouteList& routes) throw unknown_type(); } - if (rtv->is_master_track() ) { - new_views.push_front (rtv); - track_views.push_front (rtv); - } else { - new_views.push_back (rtv); - track_views.push_back (rtv); - } + + new_views.push_back (rtv); + track_views.push_back (rtv); rtv->effective_gain_display (); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 41ee9a00d6..3bdb9fbb13 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1725,7 +1725,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void time_selection_changed (); void update_time_selection_display (); void track_selection_changed (); - bool non_master_track_selected (); + bool track_selected (); void output_connection_mode_changed (); void region_selection_changed (); sigc::connection editor_regions_selection_changed_connection; diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 3fc8de7027..521f1de524 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -279,6 +279,7 @@ Editor::register_actions () act = reg_sens (editor_actions, "DeleteSelectedTracks", _("Delete Selected"), sigc::mem_fun(ARDOUR_UI::instance(), &ARDOUR_UI::delete_selected_tracks)); ActionManager::track_selection_sensitive_actions.push_back (act); + ActionManager::actions_forbiden_for_master_track.push_back (act); act = reg_sens (editor_actions, "move-selected-tracks-up", _("Move Up"), sigc::bind (sigc::mem_fun(*_routes, &EditorRoutes::move_selected_tracks), true)); ActionManager::track_selection_sensitive_actions.push_back (act); act = reg_sens (editor_actions, "move-selected-tracks-down", _("Move Down"), sigc::bind (sigc::mem_fun(*_routes, &EditorRoutes::move_selected_tracks), false)); diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index 61054d0bfd..14db14b094 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -29,7 +29,6 @@ #include "ardour/debug.h" #include "ardour/route.h" -#include "ardour/audio_track.h" #include "ardour/midi_track.h" #include "ardour/session.h" @@ -1474,17 +1473,7 @@ EditorRoutes::move_selected_tracks (bool up) ++leading; while (leading != view_routes.end()) { - - //skip master track if it's in scope - bool master_track_in_scope = false; - AudioTrack* atr_l = dynamic_cast(leading->second.get() ); - AudioTrack* atr_t = dynamic_cast(trailing->second.get() ); - - if ((atr_l && atr_l->is_master_track() ) || (atr_t && atr_t->is_master_track() ) ) { - master_track_in_scope = true; - } - - if (_editor->selection->selected (leading->first) && !master_track_in_scope ) { + if (_editor->selection->selected (leading->first)) { view_routes.insert (trailing, ViewRoute (leading->first, leading->second)); leading = view_routes.erase (leading); } else { @@ -1509,16 +1498,7 @@ EditorRoutes::move_selected_tracks (bool up) while (1) { - //skip master track if it's in scope - bool master_track_in_scope = false; - AudioTrack* atr_l = dynamic_cast(leading->second.get() ); - AudioTrack* atr_t = dynamic_cast(trailing->second.get() ); - - if ((atr_l && atr_l->is_master_track() ) || (atr_t && atr_t->is_master_track() ) ) { - master_track_in_scope = true; - } - - if (_editor->selection->selected (leading->first) && !master_track_in_scope ) { + if (_editor->selection->selected (leading->first)) { list::iterator tmp; /* need to insert *after* trailing, not *before* it, @@ -1610,18 +1590,13 @@ EditorRoutes::move_selected_tracks_relatively (const PBD::ID& source_track_id, c // selected tracks: add to the move list but if it's not a target if (selection.selected(tv) && - route->id() != target_track_id && - !rtv->is_master_track() ) { + route->id() != target_track_id ) { routes_to_move.push_back(route); continue; } - // master track should always be the first - if (rtv->is_master_track() ) { - routes.push_front(route); - } else { - routes.push_back (route); - } + // other tracks + routes.push_back (route); } RouteList::iterator insert_position; diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 97d1856912..12c62eec4d 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -944,24 +944,11 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* /*ev*/, StreamView* Otherwise return false */ bool -Editor::non_master_track_selected () +Editor::track_selected () { - if( selection->tracks.empty() ) - return false; - - if( selection->tracks.size() >=2 ) + if( !selection->tracks.empty() ) return true; - TimeAxisView* tv = selection->tracks.front(); - RouteTimeAxisView* rtv = dynamic_cast (tv); - if (rtv) { - AudioTrack* atr = dynamic_cast (rtv->route().get() ); - if (atr && _session && atr->is_master_track() ) - return false; - else - return true; - } - return false; } @@ -970,26 +957,6 @@ Editor::track_selection_changed () { if (!selection->tracks.empty() ) { set_selected_mixer_strip (*(selection->tracks.front())); - // the commented out implementation shows master bus in the inspector - // when master track is selected. Requirements chenged for this case - /* - bool master_bus_set = false; - TimeAxisView* tv = selection->tracks.front(); - RouteTimeAxisView* rtv = dynamic_cast (tv); - if (rtv) { - AudioTrack* atr = dynamic_cast (rtv->route().get() ); - if (atr && _session && atr->is_master_track() ) { - TimeAxisView* master_bus_tv = axis_view_from_route (_session->master_out() ); - if (master_bus_tv) { - set_selected_mixer_strip (*master_bus_tv); - master_bus_set = true; - } - } - } - - if (!master_bus_set) { - set_selected_mixer_strip(*tv); - }*/ } else { @@ -1024,6 +991,7 @@ Editor::track_selection_changed () } } + bool master_track_selected = false; RouteNotificationListPtr routes (new RouteNotificationList); for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { @@ -1048,14 +1016,27 @@ Editor::track_selection_changed () RouteTimeAxisView* rtav = dynamic_cast (*i); if (rtav) { routes->push_back (rtav->route()); + + boost::shared_ptr atr = boost::dynamic_pointer_cast (rtav->route()); + if (atr && atr->is_master_track() ) { + master_track_selected = true; + } } } } - ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, non_master_track_selected()); - + // check if we should enable track selectin sensitive actions + ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, track_selected() ); + + // check if we should disable actions forbiden when only master track is selected + if( master_track_selected && + track_selected() && + selection->tracks.size() < 2 ) { + + ActionManager::set_sensitive (ActionManager::actions_forbiden_for_master_track, false); + } + /* notify control protocols */ - ControlProtocol::TrackSelectionChanged (routes); } diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 8589f04d5e..e88bfbeb71 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -172,12 +172,7 @@ RouteTimeAxisView::set_route (boost::shared_ptr rt) track()->PlaylistChanged.connect (*this, invalidator (*this), ui_bind(&RouteTimeAxisView::update_playlist_tip, this), gui_context()); } - if (is_master_track() ) { - // do not display number for master track - _number_is_hidden = true; - } else { - enable_header_dnd (); - } + enable_header_dnd (); playlist_button.set_visible(is_track() && track()->mode() == ARDOUR::Normal); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 5096bdcee1..77a9c96214 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -384,11 +384,6 @@ Session::Session (AudioEngine &eng, _engine.reset_timebase (); EngineStateController::instance()->set_session(this); - - // Waves Tracks: always create master track - if ( ARDOUR::Profile->get_trx () ) { - create_master_track(); - } /* Waves Tracks: fill session with tracks basing on the amount of inputs. * each available input must have corresponding track when session starts. @@ -431,6 +426,11 @@ Session::Session (AudioEngine &eng, } } + // Waves Tracks: always create master track at the end + if ( ARDOUR::Profile->get_trx () ) { + create_master_track(); + } + _is_new = false; SessionLoaded(); @@ -2326,35 +2326,28 @@ Session::reconnect_existing_routes (bool withLock, bool reconnect_master, bool r continue; } - if (*rIter == _master_track && !reconnect_master ) { - continue; - } - if (reconnectIputs) { (*rIter)->input()->disconnect (this); //GZ: check this; could be heavy - if (*rIter != _master_track) { // do not connect master to phys inputs ever - for (uint32_t route_input_n = 0; route_input_n < (*rIter)->n_inputs().get(DataType::AUDIO); ++route_input_n) { + for (uint32_t route_input_n = 0; route_input_n < (*rIter)->n_inputs().get(DataType::AUDIO); ++route_input_n) { + + if (Config->get_input_auto_connect() & AutoConnectPhysical) { - if (Config->get_input_auto_connect() & AutoConnectPhysical) { - - if ( input_n == physinputs.size() ) { - break; - } - - string port = physinputs[input_n]; - - if (port.empty() ) { - error << "Physical Input number "<< input_n << " is unavailable and cannot be connected" << endmsg; - } - - //GZ: check this; could be heavy - (*rIter)->input()->connect ((*rIter)->input()->ports().port(DataType::AUDIO, route_input_n), port, this); - ++input_n; + if ( input_n == physinputs.size() ) { + break; } + + string port = physinputs[input_n]; + + if (port.empty() ) { + error << "Physical Input number "<< input_n << " is unavailable and cannot be connected" << endmsg; + } + + //GZ: check this; could be heavy + (*rIter)->input()->connect ((*rIter)->input()->ports().port(DataType::AUDIO, route_input_n), port, this); + ++input_n; } } - } if (reconnectOutputs) { @@ -2385,16 +2378,10 @@ Session::reconnect_existing_routes (bool withLock, bool reconnect_master, bool r error << error << "Master bus is not available" << endmsg; break; } - - if (!_master_track) { - error << error << "Master track is not available" << endmsg; - break; - } } for (uint32_t route_output_n = 0; route_output_n < (*rIter)->n_outputs().get(DataType::AUDIO); ++route_output_n) { - if ((Config->get_output_auto_connect() & AutoConnectPhysical) && - *rIter != _master_track ) { + if ((Config->get_output_auto_connect() & AutoConnectPhysical) ) { if ( output_n == physoutputs.size() ) { break; @@ -2427,17 +2414,6 @@ Session::reconnect_existing_routes (bool withLock, bool reconnect_master, bool r //GZ: check this; could be heavy (*rIter)->output()->connect ((*rIter)->output()->ports().port(DataType::AUDIO, route_output_n), port, this); - // connect to master track - if (*rIter != _master_track) { // do not connect Master Track to itself - port = _master_track->input()->ports().port(DataType::AUDIO, route_output_n)->name(); - - if (port.empty() ) { - error << "MasterTrack Input number "<< route_output_n << " is unavailable and cannot be connected" << endmsg; - } - - //GZ: check this; could be heavy - (*rIter)->output()->connect ((*rIter)->output()->ports().port(DataType::AUDIO, route_output_n), port, this); - } } } } @@ -2678,8 +2654,8 @@ Session::create_master_track () return true; } + // master track I/O is stereo uint32_t input_channels = _master_out->n_inputs().get(DataType::AUDIO); - // use the same amount of autputs because master track will be connected to master bus uint32_t output_channels = input_channels; std::string track_name = "Master Track"; @@ -2688,7 +2664,7 @@ Session::create_master_track () boost::shared_ptr track; try { - track.reset (new AudioTrack (*this, track_name, Route::MasterTrack, Normal)); + track.reset (new AudioTrack (*this, track_name, Route::MasterTrack, Normal) ); if (track->init ()) { return false;