Conversation
also improve param metadata passing for DynGenTranspiler
src/Classes/DynGen.sc
Outdated
| inputs = inputs.asArray; | ||
| params = params.asArray; | ||
|
|
||
| if((params.size==1).and(params[0]==\all), { |
There was a problem hiding this comment.
If the second operand of and is an expression, it should be in a function. This way it is only evaluated if the first operand is true (= short circuiting):
if ((params.size == 1) and: { params[0] == \all }) { ... }Note that the function will be inlined.
src/HelpSource/Classes/DynGen.schelp
Outdated
| If a parameter is not found in the DynGen code, you get a warning in the console. | ||
| It is not discarded, though, you can still use it when you update the code. | ||
|
|
||
| If CODE::params:: is set to CODE::\all::, it will expose all parameters of the script with as LINK::Classes/NamedControl:: with its associated LINK::Classes/ControlSpec:: using LINK::Classes/DynGenDef#-allParams::. |
There was a problem hiding this comment.
all parameters of the script with as
all parameters of the script as
src/Classes/DynGen.sc
Outdated
| ]; | ||
| } | ||
|
|
||
| allParams { |
There was a problem hiding this comment.
Hmmm... I would expect this method to just return an Array of all parameter names or something. I definitely wouldn't expect it to have side effects (= creating NamedControls) for the containing Synth.
Maybe something like paramControls or makeControls could be clearer?
src/Classes/DynGen.sc
Outdated
|
|
||
| allParams { | ||
| var allParams = []; | ||
| DynGenDef.prExtractParameters(code).do({|param| |
There was a problem hiding this comment.
This calls prExtractParameters everytime you create a new DynGen, although the parameters only change when the code changes. For this reason, wouldn't it make more sense to just call prRegisterParams in the code_ setter method (instead of in the send method)?
I guess we only want the parameters that are currently in the code. But this could be easily solved by keeping another array, e.g. prCurrentParams, that only contains the current parameters. We probably need this anyway when we expose the current parameters (and their specs) to the user.
also rename allParams method to privet prMakeControls method
| code_ {|newCode| | ||
| code = newCode; | ||
| prCurrentParams = DynGenDef.prExtractParameters(code); | ||
| this.prRegisterParams; |
There was a problem hiding this comment.
prRegisterParams calls prExtractParameters again!
Just remove the call to prExtractParameters here and modify prRegisterParams to store the extracted parameters in prCurrentParams.
Improves passing metadata to params within transpiler
Also allows to pass
\allas param value inDynGen, which creates a named control for every param present in the code (w/ associated control spec/init value when using the transpiler). This allows to writeThis also works w/o the transpiler as seen in the test
testPlainDynGenParamExtract.