Good workflow for calling functions in extension class

Hi!

Im looking for a good workflow for calling functions in an extension class?

Say I got the following scenario:
I got a costum parameter for controlling the amplitude of a Noise chop. Say I also for some reason want to multiply the amplitude with the current framecount. To achieve this I am calling the NoiseAmp function in the Extension class from a chopexecute that gets executed when I change the costum Noise Amplitude parameter.

I this a good work flow or any other suggestions? For example is it possible calling the extension directly from the costum parameter without doing a chopexecute on value changes in the parameter chop? That would indeed be handy.

Or for exemple (I guess not possible) but execute my extension class directly when a parameter is changed in desired chop.

Just looking for a good workflow when working with extensions …

Thanks
extension.toe (5 KB)

In the situation you’re describing, I think you are better off putting an expression in the parameter you are controlling. The expression in the parameter can call a complex function in the extension class, if necessary.

This allows you to skip the relatively slow process of using execute DATs.

Thanks for your reply!

Can you please provide an example or update my example on how to do that? How do I call the function in my extensionclass with the provided value from my custom parameter without the chopexecute?

I think Ivan means that in your noise CHOP’s Amplitude par you’d use:

parent().NoiseAmp(parent().par.Noiseamplitude)

To make this work, however, you’ll need to change your method to return a value rather than set a value:

def NoiseAmp(self, val):
	ampValue = me.time.frame * val * 0.01
	#op('noise1').par.amp = ampValue

	return ampValue

I don’t think this totally works the way you might be expecting as the expression is being evaluated every frame, and a as a consequence the ampValue is always changing (this is because you’re using me.time.frame in your extension).

Other ways to handle this would be to use a Parameter execute DAT rather than a CHOP.

You could also create another custom parameter that’s write only - then rather than changing the Amplitude par of your noise CHOP you’d change your write-only value which you could then export or reference in your operator.

These days my personal preference is avoid writing directly to a parameter with a value if at all possible. If you can write to an export table, to a custom parameter, to a constant CHOP… write to anything but your ops pars. It’s often quite difficult to track down what’s changing a parameter - so let’s say you decide you want to put an expression in a par instead, but as soon as your method runs it will change the parameter back to a static value. You can spend a lot of time chasing your tail on this one if you’re not careful. At least if it’s written to another intermediary you can work around it in a pinch, or better track when it’s being changed.

Here’s an example with what I think Ivan has described, along with some other options:
ext_examples.toe (5.61 KB)

Thanks a lot! I wasnt aware of the parameter execute! Seems like a good solution to me! Thanks for your help!