add currentSettingsAsCompileString#33
add currentSettingsAsCompileString#33LFSaw wants to merge 2 commits intosupercollider-quarks:mainfrom
Conversation
There was a problem hiding this comment.
I wonder if this whole thing of using a = is so practical (in general and also here). We could also:
- return
.set(...)for anonymous proxies, or - pass in a default name that is added
Is it useful to pass in the environment?
In the case where envir is nil, the envir.use is redundant:
envir = envir ? currentEnvironment;
nameStr = envir.use { this.asCompileString };
So if you have a use case, that would be good.
|
Thanks for looking into this! my usecase is as above. That said, I am happy to streamline the function, however, I also have to say that I do not fully understand the inner workings of NodeProxy enough to see what the envir is used for in this case, so I do not understand why it might need to be passed in here. |
|
maybe @adcxyz wants to add his ideas? |
|
Yes nodeProxy.asCode is too monolithic. The main thing that is needed across its parts is accessStr, then currentSettingsAsCompileString (or maybe settingsCS ?) could be |
|
Teaching classes, I again and again stumble over the demand to quickly and programmatically access the current state of an My original test case (above) is pretty much summing up what I'd love to have... An intermediate step would be to be able to save presets and recall, manipulate programmatically, or I know that there is |
|
I am very much in favour of bringing source code and object as close together as possible. Sorry for having left this lying around. I was unsure if I should really keep this "a = " in the standard library. We have three cases:
It would be good to resolve these more clearly. But for now, we can go along the lines of what is there, we can refactor later. |
telephon
left a comment
There was a problem hiding this comment.
just a few minor things.
| @@ -0,0 +1,18 @@ | |||
| + NodeProxy { | |||
| accessStr { | envir | | |||
There was a problem hiding this comment.
Calling it accessString reads better, and we know that it is not a stream.
| @@ -0,0 +1,18 @@ | |||
| + NodeProxy { | |||
| accessStr { | envir | | |||
| var accessStr = "a", nameStr, isAnon; | |||
| isAnon = nameStr.beginsWith("a = "); | ||
| if (isAnon.not) { accessStr = nameStr }; | ||
|
|
||
| ^accessStr; |
There was a problem hiding this comment.
you can drop the semicolon if you like.
| ^accessStr; | ||
| } | ||
|
|
||
| currentSettingsAsCompileString { |
There was a problem hiding this comment.
settingsAsCompileString would be better. Settings are always current, just like any object.
There was a problem hiding this comment.
For consistency, I would propose settingsAsCode.
on N/P/Tdefs, asCompileString only posts the access string,
while asCode fully reconstructs the object.
Also for consistency, PatternProxy should have a settingsAsCode method.
And all asCode and settingsAsCode methods should allow passing in an accessString
that overrides the auto-generated (or guessed) ones, since users might know better.
I can try that here, or in a different PR.
2c, adc
There was a problem hiding this comment.
will do!
Until this is finalized, you could do:
Ndef(\x, { LFSaw.ar(\freq.kr) }).set(\freq, 123);
Ndef(\x).nodeMap.asCode(Ndef(\x), true);
There was a problem hiding this comment.
hello, so wow; I was not aware of ProxyNodeMap:asCode, somehow...
so would
+ NodeProxy {
settingsAsCode{|namestring, dropOut = true|
namestring = namestring ?? {this.asCompileString};
^this.nodeMap.asCode(namestring, dropOut);
}
do the trick?
I often find myself in the situation that I'd like to save only the specific settings for a NodeProxy.
This method (extracted from
NodeProxy:asCode, src) returns the current settings as acompileString, ready to be used further.I am unsure about the (quite clunky) name, feedback welcome.
Here is a testcase: