summaryrefslogtreecommitdiff
path: root/gtk2_ardour/mixer_strip.cc
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-07-07 19:17:16 +0200
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-07-09 21:08:16 +0200
commit9389ee1e964cc8c7b01cea02a6f9621b680eb447 (patch)
treecb9cb2e1d752fc43d15367ef6d7f0042cd847ed4 /gtk2_ardour/mixer_strip.cc
parent35b4cb91d21f8e45e49d2e629f6df818cb9742c6 (diff)
Better heuristics for guessing the primary type of an input or output
In order to choose which port name to display (if any) in the button, MixerStrip::update_io_button() first chose a primary type for the input or output. It was AUDIO in all cases, except if the route was a MidiTrack where the primary type was MIDI. In the latter case, it enabled the following code of update_io_button() to show the MIDI sources feeding the MidiTrack rather than showing an unhelpful dash. But this simple heuristic has several shortcommings: - Going further, tracks and busses will probably loose strong types so the approach is not future-proof; - It doesn't take midi busses into account, yet there is no reason for them to be handled differently than midi tracks; - It falls short when the midi track contains a synthesiser and is meant to output audio. Improve the heuristics by choosing the data type as follows: A) If there are connected audio ports, consider audio as primary type. B) Else, if there are connected midi ports, consider midi as primary type. C) If there are audio ports, consider audio as primary type. D) Else, if there are midi ports, consider midi as primary type. These new heuristics give the same results for audio tracks and busses (whose audio inputs have not been removed), and the same result for the input of midi tracks (again, provided the inputs have not been tampered with). It improves the situation for inputs of midi busses, and output of midi tracks and busses, especially when synthesisers are in use.
Diffstat (limited to 'gtk2_ardour/mixer_strip.cc')
-rw-r--r--gtk2_ardour/mixer_strip.cc61
1 files changed, 52 insertions, 9 deletions
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc
index f8386e7706..eaf3aeb096 100644
--- a/gtk2_ardour/mixer_strip.cc
+++ b/gtk2_ardour/mixer_strip.cc
@@ -1235,24 +1235,67 @@ MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width widt
ostringstream tooltip;
char * tooltip_cstr;
- //to avoid confusion, the button caption should only show connections that match the datatype of the track
+ /* To avoid confusion, the button caption only shows connections that match the expected datatype
+ *
+ * First of all, if the user made only connections to a given type, we should use that one since
+ * it is very probably what the user expects. If there are several connections types, then show
+ * audio ones as primary, which matches expectations for both audio tracks with midi control and
+ * synthesisers. This first heuristic can be expressed with these two rules:
+ * A) If there are connected audio ports, consider audio as primary type.
+ * B) Else, if there are connected midi ports, consider midi as primary type.
+ *
+ * If there are no connected ports, then we choose the primary type based on the type of existing
+ * but unconnected ports. Again:
+ * C) If there are audio ports, consider audio as primary type.
+ * D) Else, if there are midi ports, consider midi as primary type. */
+
DataType dt = DataType::AUDIO;
- if ( boost::dynamic_pointer_cast<MidiTrack>(route) != 0 ) {
- dt = DataType::MIDI;
- // avoid further confusion with Midi-tracks that have a synth.
- // Audio-ports may be connected, but button says "Disconnected"
- tooltip << _("MIDI ");
- }
+ bool match = false;
if (for_input) {
io = route->input();
- tooltip << string_compose (_("<b>INPUT</b> to %1"), Gtkmm2ext::markup_escape_text (route->name()));
} else {
io = route->output();
- tooltip << string_compose (_("<b>OUTPUT</b> from %1"), Gtkmm2ext::markup_escape_text (route->name()));
}
io_count = io->n_ports().n_total();
+ for (io_index = 0; io_index < io_count; ++io_index) {
+ port = io->nth (io_index);
+ if (port->connected()) {
+ match = true;
+ if (port->type() == DataType::AUDIO) {
+ /* Rule A) applies no matter the remaining ports */
+ dt = DataType::AUDIO;
+ break;
+ }
+ if (port->type() == DataType::MIDI) {
+ /* Rule B) is a good candidate... */
+ dt = DataType::MIDI;
+ /* ...but continue the loop to check remaining ports for rule A) */
+ }
+ }
+ }
+
+ if (!match) {
+ /* Neither rule A) nor rule B) matched */
+ if ( io->n_ports().n_audio() > 0 ) {
+ /* Rule C */
+ dt = DataType::AUDIO;
+ } else if ( io->n_ports().n_midi() > 0 ) {
+ /* Rule D */
+ dt = DataType::MIDI;
+ }
+ }
+
+ if ( dt == DataType::MIDI ) {
+ tooltip << _("MIDI ");
+ }
+
+ if (for_input) {
+ tooltip << string_compose (_("<b>INPUT</b> to %1"), Gtkmm2ext::markup_escape_text (route->name()));
+ } else {
+ tooltip << string_compose (_("<b>OUTPUT</b> from %1"), Gtkmm2ext::markup_escape_text (route->name()));
+ }
for (io_index = 0; io_index < io_count; ++io_index) {
port = io->nth (io_index);