Populate strips output menus with a more user-friendly heuristic
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Tue, 22 Aug 2017 14:04:16 +0000 (16:04 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Wed, 23 Aug 2017 21:31:10 +0000 (23:31 +0200)
Ensure the master bus is the first proposed bundle if it is present.
Also propose internal route inputs before physical outs or other
software via JACK.

Last, but not least, add to the menu not only exactly matching bundles,
but also bundles that have the same number of channels than the route
output when considering only the DataType we think the user wants to
use. This covers both the case of a MIDI+STEREO instrument track
connecting to master, and the case of a STEREO track connecting to a
MIDI+STEREO vocoder track.

gtk2_ardour/mixer_strip.cc

index f4592370008d5d42d9342b081e40897faa2146d0..dc8813dbd7ee8bb01a0931bbbd933eef795184f7 100644 (file)
@@ -904,27 +904,37 @@ MixerStrip::output_press (GdkEventButton *ev)
 
                boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
 
-               /* give user bundles first chance at being in the menu */
+               /* guess the user-intended main type of the route output */
+               DataType intended_type = guess_main_type(false);
+
+               /* try adding the master bus first */
+               boost::shared_ptr<Route> master = _session->master_out();
+               if (master) {
+                       maybe_add_bundle_to_output_menu (master->input()->bundle(), current, intended_type);
+               }
 
+               /* then other routes inputs */
+               boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
+               RouteList copy = *routes;
+               copy.sort (RouteCompareByName ());
+               for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
+                       maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current, intended_type);
+               }
+
+               /* then try adding user bundles, often labeled/grouped physical inputs */
                for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
                        if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
-                               maybe_add_bundle_to_output_menu (*i, current);
+                               maybe_add_bundle_to_output_menu (*i, current, intended_type);
                        }
                }
 
+               /* then all other bundles, including physical outs or other sofware */
                for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
                        if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
-                               maybe_add_bundle_to_output_menu (*i, current);
+                               maybe_add_bundle_to_output_menu (*i, current, intended_type);
                        }
                }
 
-               boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
-               RouteList copy = *routes;
-               copy.sort (RouteCompareByName ());
-               for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
-                       maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
-               }
-
                if (citems.size() == n_with_separator) {
                        /* no routes added; remove the separator */
                        citems.pop_back ();