How to check when all expanders are loaded on init?

Hi folkssss,

another question for you :slight_smile:

Is there a way to check when all expanders are loaded on init of a Patch?

In fact, I’ve noticed that sometimes the onExpanderChange method:

void onExpanderChange(const ExpanderChangeEvent &e) override

is called when my Module’s process() has been runs N times. So in fact this won’t work as “is module loaded?” check:

void process(const ProcessArgs &args) override {
	if (!mLoaded) {
		mLoaded = true;

because related expanders can connect later. Would be important to me discriminate when all is loaded vs somethings related is not yet active.

How do you usually check for expanders loads?

I don’t know what your definition of “loaded” is. From Rack’s point of view, your module is fully loaded and running when it calls process.

There is no event for when Rack finishes loading all the modules in a patch.

Other modules can be added and removed at any time, so there is no moment when you can say that ‘all the expanders that might be added have been added’. You may have no expanders ever in the lifetime of your module. So, you simply have to deal with the presence or absence of an expander at any time your process is called.

What is it that you’re trying to do?

1 Like

The problem I’m challenge is:

  1. when I first time link a module and expand it, I do some specific tasks
  2. than I save the patch, and store some data on JSON (such the linked module id)
  3. when I reload the patch, the expander call back will be called at some time, but now I want to avoid to redo the task done at point 1 (since its not a user/native linking, but a restoring scenario)

Having the value of linked module id at point 2 is not enough: can’t evaluate if its a preset loading or whole patch loading (context could be different).

So I’m looking for somethings that can flag as a loading patch.

Do you see the use case?

I do and I have no idea.

Good luck.

1 Like

I have no idea, not even sure I understand the question … but maybe this can be used ? (sourcecode on github).

Module: Bogaudio Manual

“MANUAL may be set to output a trigger pulse (the high output voltage for 10ms) on patch load (akin to a Max/Msp loadbang). This is off by default; enable clicking “Trigger on load” on the module’s context (right-click) menu. The pulse is emitted 100ms after the patch starts processing samples.”

1 Like

If the expander and the host communicate with each other using some kind of messaging protocol (as most do) then the main module can just send a message “who is there”, and look for a returned message that says “I am”.

Of course you need to make all that yourself, or “borrow” it from some other module.

1 Like

It seems 100ms from the process() Module starting, without any further check.

Could be a workaround, but a bit weak :slight_smile:

Indeed, but I’m looking forward for a general solution, not specific only for my own modules.

ok, but there isn’t a general solution.

Now I know: thanks to all.

I’ll write a request to the support!

1 Like

Please keep us informed.

We’ve an idea for Surge that a solution for this would help with.


yeah and i can’t figure out a way to do it reliably either