Creating a modular system

Joosterhuis's icon

Hi, I'm a beginner learning max for a uni project. I imagine there's a lot of writing out there about what I'm describing but I'm having trouble finding any of it.

Let's say I have a synth and the signal flow is source -> distortion -> filter -> chorus. Each of these modules is contained within its own subpatch. How would I implement a system to:

a) re-route the order of the modules (eg. source -> filter -> chorus -> distortion)
b) add in or remove extra copies of each module if desired? (eg. source -> filter -> distortion -> chorus -> distortion -> filter)

This seems like the kind of thing that's either incredibly simple or really really complicated.

Thanks!

TFL's icon

Maybe have a look at the [matrix~] object to route/mix signals as you want, and the [matrixctrl] object to get an UI to control [matrix~]'s behavior.

You have a pretty good example of what you want to achieve in the M4L/RNBO Pedalboard patch in the RNBO Guitar Pedals package. There might be some non RNBO examples in the wild, for sure!

Sébastien Gay's icon

This is both "incredibly simple", because it is only a mater of connecting virtual cables, and it is after all one of the reasons why MAX/MSP exists .....

.... and quite complex, depending on the level of "automation" you need, if you don't want to simply dis-connect/re-connect these cables with a mouse only (as suggested by TFL).

Source Audio's icon

You could use matrix~ object for routing .
adding or removing modules …
depends a bit, personally I would create all needed modules anyway and route or mute them for live situation, to keep switching between configurations smooth and noisefree

Joosterhuis's icon

@Sebastian

Of course you are right! I was overcomplicating this for myself by thinking in terms of creating a separate GUI (which is part of the product we're developing for the course) but of course max has its own GUI which is already perfect for this exact situation!

Joosterhuis's icon

In terms of adding or removing modules is it possible to create a menu of all possible subpatches to add into the routing? Part of the project ethos is giving users the freedom to add as many or as few modules as they need, which means having all needed modules already created at the start is not really an option.

TFL's icon

Yes, given that all of your modules are individual .maxpat files, you can put them in the same folder, and use [folder] to fill a [umenu] with all patcher files from that folder. Then use scripting (sending script messages to thispatcher, see my first post on this thread) to create new objects when the user select one of the modules from the umenu.
This is one possible approach among many.

Roman Thilenius's icon

the pcontrol object allows you to load a patcher file from disk into a [p ]