-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add currentSettingsAsCompileString #33
base: main
Are you sure you want to change the base?
add currentSettingsAsCompileString #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few minor things.
@@ -0,0 +1,18 @@ | |||
+ NodeProxy { | |||
accessStr { | envir | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not "a ="
?
isAnon = nameStr.beginsWith("a = "); | ||
if (isAnon.not) { accessStr = nameStr }; | ||
|
||
^accessStr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can drop the semicolon if you like.
^accessStr; | ||
} | ||
|
||
currentSettingsAsCompileString { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settingsAsCompileString would be better. Settings are always current, just like any object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: