Programmatically add wires between moduels

Is there, or will there ever be a way to programmatically add wires between different modules?

I am thinking about the possibility of using a lauchepad pro as a sort of mod matrix. Although that would require some other functionality as well,

Yes, you can add wires prgrammatically. I wouldn’t suggest it though. The way to go would be using something like Mutes or a matrix mixer to switch connections on or off.

CableWidget* cw = new CableWidget;
cw->color = color::fromHexString(colorStr);

for (PortWidget *port : outputModule->outputs) {
  if (port->portId == outputId) {
    cw->setOutput(port);
    break;
  }
}
for (PortWidget *port : inputModule->inputs) {
  if (port->portId == inputId) {
    cw->setInput(port);
    break;
  }
}
if (cw->isComplete()) {
  APP->scene->rack->addCable(cw);
}
1 Like

Is there a matrix switcher module with something like 16x16 connections?

No

EDIT : I was wrong… see Computerscare’s post below :+1: RolyPouter oh yeah…

There used to be a “cat simulator” that would randomly disconnect your wires.

1 Like

Oh how was it called ?

Jeremy W … 0cat

And this

1 Like

Computerscare Modules Roly Pouter is a 16x16 router which is basically a matrix switcher. It is polyphonic, so you need to use merge/split modules to use the individual channels.

1 Like

Thanks for the suggestion! I already started working on my own module, though.

1 Like

Could someone explain the usage of the colon operator in this context for me? I understand when it’s used for a bit-field inside a struct for instance, but here it’s a struct being instantiated (PortWidget), how come you add a colon with what i assume is a pointer to an int after…?

That’s a “range-based for loop”. It’s a shorthand for using an iterator to iterate over a collection.

Thanks, very interesting, hadn’t encountered that before… Ah, i see it is a C++11 addition. I have the C++ Language 4th Edition by Stroustrup on my desk (all 1300 pages of it). Yet to really dig in. There’s a lot of useful little tricks like that it seems.

So, if i’m reading this right, it’s grabbing an array of inputs/outputs and iteratively assigning the elements to a pointer which can be used in the loop statement?

Don’t get to deep into the stroustroup. Most of if will never be usefull for the things you need for VCVRack. Rather read on modern OO paradigms and language features.

Read the loop

for (PortWidget *port : inputModule->inputs)

as: for every port in the inputs array do the floowing … or in short: for every input port do …

1 Like

Yes, that’s right.

Thanks, i bought the book on a whim to use as a reference because i don’t like to rely on the internet for everything. Writing Lua scripts was my entry into coding, so am pretty au fait with OOP basics. Will look more into the modern practices. I can understand most of the source of VCV, and once i have a dev environment set up i’m sure it will all come together. I just don’t know all the expressions, so this sneaky colon thing threw me a bit!

Just an FYI: This is definitely part of the unstable API, so this may break in any update, even a revision release.

Yeah understand. The Stroustrup is a treasure trove, albeit I never used it when I’ve been programming C++ 15 years ago.

@cupcake2001 How are you getting along with this? I’d quite like to have a similar thing.

1 Like