question on connectedTo()

There is a simple way to check if a cable is connected.

But is there a way to figure out where it goes? :thinking:

There are many modules that traverse cables to find the modules that they’re connected to.

I don’t find a connectedTo() in the VCV Rack API (use the search box on the Rack API site), so I assume you’re asking how one would implement it.

Note sure if there’s a more direct way to get the cable on an input or output, but you can at least do this:

  • Call APP->engine->getCableIds to get the ids of all the cables.
  • For each, call APP->engine->getCable(cable->id) to get the cable.
  • Check the cable’s inputModule or outputModule to see if it’s your module id.
  • If it is your module, you can, check the cable’s inputId and outputId to see the input id or output id of the corresponding module the cable is connected to.
2 Likes

Paul is exactly right

https://github.com/baconpaul/BaconPlugs/blob/d2962bebfe25aeb10348734f68b9635b877b10e2/src/LintBuddy.cpp#L294 here’s an example where lintbuddy uses this to probe modules it connects to for instance

3 Likes