Display names of ports connected to in UI
This is a discussion continued from following issue.
I'd like to have audioPortChanged() for UI class. Arguments are same as Plugin::initAudioPort().
virtual void audioPortChanged(bool input, uint32_t index, const AudioPort &port);
AudioPort needs to have a collection of connected port. I named it as link, but probably there's a better name.
struct AudioPort {
std::vector<AudioPort> link;
};
It's better to have a guarantee that last connected port will be added to the last of link. So link acts like a stack of connection.
In my use case, AudioPort in link only need to have valid name. It might be better to have separated class like AudioPortLink for link, rather than using AudioPort.
With audioPortChanged() and AudioPort.link, I can write something like following in UI class.
void audioPortChanged(bool input, uint32_t index, const AudioPort &port) override {
if (input) return;
// Display last connected port name.
if (port.link.size() > 0)
someLabels[index].setText(port.link.back().name);
else
someLabels[index].setText("No Conection");
updateUI();
}
Thinking about this more; depending on the case, it might be wise to display either the connected "PluginName", or "PortName" like with the example screenshot above, or both as say "PluginName/PortName" like with the screenshot below.
The 'Control of Kick' CV_Gate16 below, ignoring the intermediary Control-CV plugins that have their control parameter exposed as an input CV, so as to distinguish what is what, is connected to the plugins/ports:
- Gain Env/Gain
- Gain Env/Decay 1
- Gain Env/Curve1
- Freq Env/Decay 1
- Freq Env/Gain
- Freq Env/Curve1
- */Exp FM Gain
- */Semitone
- Saw/Edge
- Pulse/PW
- Pulse/Edge
The two * go out to multiple plugins though with the same port name, so in such a case, IDK, maybe * as a wildcard? For port name, if it varies, maybe plugins could offer a UI option to cycle between the different options or a generic *?
