Executing js before Max connects inlets, outlets
I wrote a custom dsp module, where the number of audio channels (means inlets, processing, parameter handling, outlets) is dynamically generated by a javascript. I call this module via bpatcher.
The problem
When I connect my module to other files, the next time, when I start my patcher, I get the error:
bpatcher: patchcord inlet out of range: deleting patchcord
This means the js code in my dynamic object is created after the wiring is done by Max.
The question
Is it possible to execute the javascript code before wiring is done (eg. before loadbang, etc. ) ?
As far as I know there is no alternative to PureData's [initbang] object in Max, that "gets executed just after the rest of the abstraction is built and _before_ the parent of the abstraction is finished".
Maybe you could connect the lines using scripting with the thispatcher object.
That could be a feature request for cycling74 to build a functionality like initbang in Pd.
I found a workaround for presering the connections to my dynamic channel module.
In the original file, I create a max. number of inlets, outlets which I intend to use. All of them get their unique scripting name.
My javascript connects these in/outlets with my dsp processing and afterwards removes the inlets/outlets, which are not necessary.
It works. But a feature like initbang in Pd would be more elegant.
@hardcoder
Nice hack! :) I think I will this in my patches sometime.