Cache Modulator/Component Object #482
dnaldoog
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
|
It's like you said, another way of doing things, but the fact that you don't have to close Ctrlr each time you add a modulator to the init file is very convenient. Nice method :) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
EDIT Update: 12/23/2025
In CtrlrX and Ctrlr every time you call
panel:getModulatorByName("lfofDelay")(for example) orpanel:getComponent("mycontrol")Ctrlr(X) needs to loop through every modulator on your panel looking for that modulator. If you have a lot of modulators, this is inefficient.panel:getModulatorByName():- If your modulator is 200th in a panel, then this function will run 200 times before returning.It is better to cache or memoize those calls into a lua table:
_m["lfodelay"]→ Lua detects the key doesn't exist → triggers __index → calls the expensivepanel:getModulatorByName("lfodelay")→ stores the result in the table → returns it_m["lfodelay"]→ Lua finds the key in the table → returns it directly (no __index, no C++ function call)_mforgetModulator()and_cforgetComponent()are entirely optional and can be changed to any legal variable/table name.mtin your panel and paste this code:Now just call
_m.lfoDelay:getModulatorValue()_m("mod name with space or illegal character"):getModulatorValue()_c.myComp:setProperty("componentVisibilty",0,true)Example: Memoise panel
Beta Was this translation helpful? Give feedback.
All reactions