Every once in a while, I come to having to program an external which ends up having some specific variables, which I'd prefer being set "internally" instead of exposing them through outlets, mostly to reduce clutter. And unfortunately, that is usually not easily visible in https://github.com/pure-data/externals-howto ...

So, I'm not really sure if the below is the "correct" thing - I just managed to patch it together by reading from the PD source.

You can find the code in:

The help patch looks like this:


Basically, this is a copy of [send], which when banged, triggers r AHA and r EHE - even if there aren't corresponding send objects. It turns out, there must be a pd_bind in order for this to work, and for a long time I thought the object argument there is the sender object - but actually it seems to be the receiving object reference. So this objects includes an additional "dummy" receiver class, a copy of [receive], which is there simply to initialize this binding, once this is done, other normal [receive] objects begin reacting on messages too.

Now I noticed I don't actually have the code for setting [value] variables there, but it is easier - you simply declare a symbol, and then you call PD functions on it:

  t_symbol* s_mysimbol;
  x->s_mysimbol    = gensym("myvar");
  // initialize/instantiate the [value] variables (reading is with value_getfloat)
  // note - via value_get, these will also gain non-null ->s_thing property
  value_setfloat(x->s_mysimbol, 42);