Possible to save patch cord connections when using pattrstorage and/or scripting?

mbira's icon

I build a modular synth in Max and so each module is it's own subpatch that is loaded in a bpatcher.

Modules (bpatchers) are connected to each other with patch cords (like in a real modular).

I'm now wanting to create presets that have patch cords going to different places.

I'm using autopattr inside each module and I have a pattrstorage at the top level and so I'm able to save the presets of all the knobs within each module. But I'm not able to save the state of the patch cord connections.

I started looking in to using matrix or crosspatch but I think those solutions will become way too unmanageable.

I see that you can use the 'script' message to create connections.

So is there any way to create all my patch cord connections and save all those patch cord connections in a way that can be recalled?

Sébastien Gay's icon

Using [coll], maybe ?

Max Patch
Copy patch and select New From Clipboard in Max.

(Edited)

mbira's icon

Hmm. I'm still brand new to coll, so I'm probably misunderstanding. From what I can tell, this is allowing me to make connections with the radio button triggering the script. But what I want to be able to do is manually make my connections and then save those connections (maybe in a column in coll?) and then make a different manual connection and save that in a different column and then be able to toggle between them. Does that make sense? I'm guessing your soultion does that, but i'm just not understanding.

Sébastien Gay's icon
I'm guessing your solution does that, but i'm just not understanding.

No it doesn't. It assumes you have pre-defined every possible connections and call them on request.

By "manually" , I understand that you want to connect 2 objects with the mouse and then save the newly made connection "on the fly". That would imply that the information "inlet x of object A is connected to outlet y object B" is available somewhere. This I don't know.

Using Snapshots, may be an appropriate workaround ?

mbira's icon

That would imply that the information "inlet x of object A is connected to outlet y object B" is available somewhere.

Yes. My hope is that I can perhaps I can do something like give every inlet and outlet a scripting name and then Save the connection state somehow to then be recalled later.

Roman Thilenius's icon

you could give any inlet and outlet of a patcher a unique ID...

happy inlet & happy outlet


...and combine that ID with the instance number of the patcher or bpatcher (not shown here)

then you run a global [qmetro 1234] somewhere which continuously triggers all the "outlets" in order to make them announce their idendity to all "inlets" connected to them and store all this info in a [coll] or [text] in order to script-create that whole patch next time.

two patches equipped with happy inlets/outlets and how they communicate with each other


mbira's icon

you could give any inlet and outlet of a patcher a unique ID and combine that with the instance number of the patcher or bpatcher.

But I'm not sure how to translate that to being able to save that "outlet x is connected to inlet y".

Roman Thilenius's icon

you can store that info in any format you wish. all we need to know is "object name, object instance number, inlet number of this object" - and the same for the outlets.

every connection will be saved as one pair of these informations:

"myoscillator no_03 out_2 myfilter no_02 in_1"

the translation to the actual scripting commands can be done later, while you actually want to reassemble things.

be warned that it can get complicated to assign unique instance numbers to abstractions or bpatchers. the only half working solution i´ve found is that at runtime you start counting 1,2,3 for the first 3 oscillator bpatchers - and in case you remove the 2nd oscillator only #1 and #3 shall be left.

when you later use scripting to recreate what you got, you have to process the list of patches and connections alphabetically (as you can not do it from right to left as numbering will then follow right to left then instead of how it was before)

the system will cause a minor overhead as eveything else which goes throught the happy inlets has to cross some additional inlet objects as wel as 2 route objects.

Source Audio's icon

Are your modules fixed in the patch, I mean they don't get inserted or removed

on the fly ?

mbira's icon

Are your modules fixed in the patch, I mean they don't get inserted or removed on the fly ?

In an ideal world, I'd be able to add and remove modules on the fly, but that's outside the scope of this specific question, so I'm happy to keep a set number of modules. Still hoping to be able to save the different patch cords that have been manually connected in different ways, but I still don't understand how to do that.

mbira's icon

every connection will be saved as one pair of these informations:

I don't understand how this would work when I manually connect patch cords in different ways and then want to save those connections.

Source Audio's icon

When you recall a preset, you also need to disconnect

existing connections, not only connect .

For example if

A -> B & C and C -> D

switch to

A -> C and B -> E

main question for me would be :

do you get audio interrupts, hickups and other unpleasant effects

when connecting/disconnecting that modules manually ?

Would make no difference to simply save entire patches and keep them as presets.

Load whichever you need.

like that guitar amp, stomp, pomp multieffects where one creates chains ....

mbira's icon

Like a real modular, I have an attenuator at the end, so I’d be sure to automate setting that to 0 any time I change presets.

sure, I could just save a whole bunch of different patches. I’m trying to learn max better and was hoping with scripting combined with autopattr and pattrstorage I may be able to save patch cord connections on the fly.

Wil's icon
like that guitar amp, stomp, pomp multieffects where one creates chains ....

after reworking Rnbo-Pedalboardi in RNBO Guitar Pedal Package (which works like a charm)

re-order effectx chain

completely different effexts chain (same external)


why not apply same same logic to [matrix]?

only need [live.numbox] to eliminate stack overflow

I can't even begin to calculate how many possible orders you have here (with dual matrixes):


change preset to get

A -> B & C and C -> D

switch to

A -> C and B -> E

Max Patch
Copy patch and select New From Clipboard in Max.

//

I have no idea - this Max thing is weird

mbira's icon

The main difference is the sheer number of connections. As an example, just an single oscillator module has modulation inputs for wave type, octave, semitone, fine tuning, pwm, portamento. It also has basic midi in and audio out. So each module is the equivalent to one of those stomp box chains.

So matrix or even crosspatch immediately become too unwieldy.

Source Audio's icon

I would also go with matrix or router

but here scripting and maybe a bit of

visual effect when making connections

was the goal.

I don’t really see how shoud that work

efficiently, but I am not really qualified

to judge because new max versions

and all that new stuff that comes with it

are out of ny focus, because of Mac OS

Wil's icon

So you want to script instead?

sheer number of connections

why not [join] -> [to symbol] -> [single patch chord to anywhere] -> [unpack destination]

only need one connection

Max Patch
Copy patch and select New From Clipboard in Max.

mbira's icon

The issue I’m trying to get at is that I see how I can write a script to make connections. That’s easy.

I am wondering if there is a way to make multiple manual connections and then save those.

the solutions here that I see seem to be offering different ways of sending a hard-coded connection between places. But if I dynamically what to change where a patch cord goes then I somehow need a way to store the info of where the patch cord went.

What I’m trying to say is that I understand how to dynamically store info that module_1 out 1 is connected

And module_2 in is connected.

but I don’t see a way to store that the patch cord knows that those two modules (of dozens of connections) know that they are connected to each other.

Wil's icon
scripting and maybe a bit of visual effect when making connections

haha - I would be 'cute' to have VCV rack visual s

when connect

mbira's icon

Maybe one idea could be to send/receive to a big-ass hidden matrix whenever a connection is made. I was stuck on thinking that the user would have to use the matrix directly, but I can see how it could be hidden. Hmm…

….oh, or you could prepend an id# to a message out and then whichever connection receives it could read that.

Wil's icon

send / receive is only for demonstration about packing controls

that dual matrix I sent has at least 100 to 150 varialtions

your sample has 6 controls - to one connction

that's 600 - 900 controls

if you are trying to script

big ass connections

good luck!

maybe time to rethink and simplify

//

personally - I only have 10 fingers (8 + 2)

Wil's icon

ok - follow up

//

helpful thought

what if you had on "ONE" controller that controlled 1000 different "whatevers"

switch - gate - route - matrix

Max Patch
Copy patch and select New From Clipboard in Max.

Wil's icon
and all that new stuff that comes with it
are out of ny focus, because of Mac OS

SOURCE AUDIO - those delays are basic - can be done in basic Max

only difference is RNBO external mc.

and how they can be targeted

Basic