Confusion about onAdd() and onReset()

I’m trying to make a module start up in a known state when it is first added to the rack. But I can’t figure out how to do this properly. Here’s what I’ve tried:

  • onReset() - only seems to get called when a manual Initialize is called
  • onAdd() - seems likely, but this is called on every module even ones that were already in a rack when restarting
  • using configParam() to set default values - the defaults do not seem to have any effect when adding a new module

I can’t seem to find a way to reset the settings for a module only when it’s added new to a rack, but not affect existing instances of the same module in the rack when it is started from an existing patch.

Must be called manually, I have it at the end of my constructors.

Never used this one.

Technically Rack is empty on restart and all modules are added according to autosave.vcv.

Not sure what you mean by that. If you keep the default values the call won’t have any effect on a parameter. Besides that, it is not used to set values of parameters.

If I understand you correctly it seems the easiest would be calling onReset() on the end of your module constructor.

Okay thanks! Calling onReset() at the end of the constructor seems to work.