-
Notifications
You must be signed in to change notification settings - Fork 757
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
Create doneAction aliases in Done.sc #2616
Create doneAction aliases in Done.sc #2616
Conversation
Just for reference, and as a warning when testing: some done actions don't work as described: #2189. (edited: they don't work for EnvGen when called within a block after start). |
@telephon Thanks, didn't know that. |
Thanks for your work on this, Brian. I slightly prefer Done to DoneAction. Less typing with negligible loss in readability. After merge, would it be a good idea to start recommending these as best practice? They're so much better than the magic numbers, and we should popularize them by updating the tutorials and examples. Also, while we're at it, we should also promote Env:ar and Env:kr. |
@snappizz do you propose we fold this into the |
Advantages of DoneAction: ideological purity, slightly cleaner IDE autocompletion. Advantages of Done: less typing at no cost to clarity. Done wins in my book. |
HelpSource/Classes/DoneAction.schelp
Outdated
## freeSelfAndPrev || 3 || free both this synth and the preceding node | ||
## freeSelfAndNext || 4 || free both this synth and the following node | ||
## freeSelfAndFreeAllPrev || 5 || free this synth; if the preceding node is a group then do g_freeAll on it, else free it | ||
## freeSelfAndFreeAllNext || 6 || free this synth; if the following node is a group then do g_freeAll on it, else free it |
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.
How about freeSelfAndFreeAllInPrev
and freeSelfAndFreeAllInNext
?
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.
works for me.
Yeah, absolutely. I'll move it to I might be able to do some quick replacements on patterns like |
looks like there are about 200 instances of |
Sure thing. |
HelpSource/Classes/Buffer.schelp
Outdated
@@ -748,7 +748,7 @@ code:: | |||
s.boot; | |||
( | |||
SynthDef(\help_Buffer_copy, { arg out=0, buf; | |||
Line.ar(0, 0, dur: BufDur.kr(buf), doneAction: 2); // frees itself | |||
Line.ar(0, 0, dur: BufDur.kr(buf), doneAction: Done.freeSelf); // frees itself |
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.
Doesn't need comment
HelpSource/Classes/Event.schelp
Outdated
@@ -220,7 +220,7 @@ code:: | |||
SynthDef(\test, { | out = 0, amp = 0.01, freq = #[300,400,400], pan, gate = 1 | | |||
var audio, env; | |||
audio = Mix.ar(Pulse.ar(freq, 0.5)); // this is a mixture of three oscillators | |||
env = Linen.kr(gate, susLevel: amp , doneAction: 2); // envelope deletes the synt when done | |||
env = Linen.kr(gate, susLevel: amp , doneAction: Done.freeSelf); // envelope deletes the synt when done |
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.
Doesn't need comment
@vivid-synth Thanks for the review, I automated those replacements. Would still like more input on the incomplete tasks I've marked above:
|
HelpSource/Classes/Done.schelp
Outdated
## freeSelfAndPrev || 3 || free both this synth and the preceding node | ||
## freeSelfAndNext || 4 || free both this synth and the following node | ||
## freeSelfAndFreeAllPrev || 5 || free this synth; if the preceding node is a group then do g_freeAll on it, else free it | ||
## freeSelfAndFreeAllNext || 6 || free this synth; if the following node is a group then do g_freeAll on it, else free it |
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.
These two names still haven't been updated in the docs.
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.
Thanks, fixed.
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.
Looks good to me.
ping. Does anyone mind if I delete UGen-doneAction.schelp? I've already migrated its contents to the Done helpfile and changed all the links. |
Yes, go ahead and delete. |
I think this is ready to merge if we can get consensus. |
HelpSource/Classes/Done.schelp
Outdated
|
||
table:: | ||
## name || value || description | ||
## doNothing || 0 || do nothing when the UGen is finished |
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.
Should we add idle
?
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.
Or link to all the aliases actually?
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.
Should we add idle?
Thanks for catching that, I actually used idle
instead of doNothing
in the .sc file, maybe I should use both?
Or link to all the aliases actually?
Not sure what you mean.
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.
Whoops, I see that's the main one. Nevermind.
@snappizz I think the documentation is equally as important as the new class, so I don't mind keeping it atomic! @vivid-synth Hmm.. in all the helpfiles for UGens with doneAction arguments, the description for doneAction always points to the DoneAction class, and that seems to be enough to me. However, considering it further, unfortunately the only way to change the display of the default argument values is by editing the .sc file itself, and when I change the default value of e.g. |
You can edit |
@snappizz I think one of the whole reasons we took this route was to avoid decisions being made on the basis of a method having an argument named |
I don't see what's wrong with it. No SuperCollider user writes an argument named |
Until someone does, and then we run into something like #2614. To state it in more general terms, I want to avoid hardcoded magic words. Here are some more things to consider:
|
I'm fine with merging this and fixing docs separately. Is the issue we want to create "Allow class methods to render as default arguments"? |
Yeah, let's deal with that later. I'm sure users are smart enough to figure out that |
Ok, I think this is ready to merge. Anyone want to give a final look-over? |
Not sure about |
For the record, the reasons I chose
I'm open to reasonable alternatives, or even multiple aliases for 0 as a compromise. I'm going to poll the dev list for opinions, because once in place this is going to be a fairly difficult naming convention to change. |
I can't quite get on board with |
|
I like I would prefer |
I'm fine with Done.none or Done.idle |
+1 |
HelpSource/Classes/MIDIClient.schelp
Outdated
@@ -73,7 +73,7 @@ The number of output ports that SuperCollider created. This is mainly useful to | |||
|
|||
METHOD:: getClientID | |||
Linux only. This gets the client ID by which the MIDIClient is defined in the ALSA subsystem. It can be used to identify whether a port is belonging to this client or another one. | |||
|
|||
On non-linux systems, this posts a warning and reutrns nil. |
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.
Already reverted :)
Since |
Can you rebase? (doesn't need to be any deeper than squashing the revert) |
No longer needed since all this material has been migrated to DoneAction.schelp
OK! First time rebaseing, that was fun. |
From discussion at #2601. Very open to suggestions.
Todo:
create DoneAction.sc(migrated to Done.sc)createamend DoneAction.schelpI have no strong preferences here. Several people have tried their hand at it (including myself), and we also have the existing names from ScalaCollider, although some of those seem unhelpful to me.
Not sure about this. Some obvious possibilities are
fromValue(int)
(returns the name/description of a doneAction code) andvalues()
(returns all possible names), but these would require having an internal dictionary object. Even though it sounds redundant, I think the constants should be kept in either case so as to aid auto-complete.Actionfrom existing class documentationActionThey don't all have to, but this would be a quick way to show new users the feature.
replace instances ofTBD in another PREnvGen.xr(Env ...
with the more convenientEnv.xr