Skip to content
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

Refactor Function plot and loadToFloatArray #3047

Merged

Conversation

telephon
Copy link
Member

Fixes #2996.

telephon added 3 commits June 26, 2017 18:08
This allows us to load a function into an array, too. Also the code is
cleaned up now.
After this refactoring, you can now just get a buffer from a function
directly.
@telephon telephon requested a review from LFSaw July 17, 2017 14:22
telephon added 2 commits July 17, 2017 18:45
Just a convenience, but will prove very useful.
Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much! lgtm except for a few small things

@@ -448,6 +448,32 @@ argument:: separately
For multi channel signals, set whether to use separate value display ranges or not.
a window to place the plot in. If nil, one will be created for you.


method::asBuffer
Calculates duration in seconds worth of the output of this function, and returns it in a link::Classes/Buffer:: of the number of channels. This method immediately returns a buffer, which takes code::duration:: seconds to become filled with data. Then the action function is called.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably better to say "which is filled asynchronously" - it may take slightly longer than the duration of the buffer for the data to move around.

A function that is called when the buffer is filled. It is passed the buffer as argument.

argument::fadeTime
A fade in and out time in seconds. (Only) when given, an envelope is applied to the signal to avoid clicks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering about the functionality of this... what if we make the default value 0, and then check if fadeTime is == 0? IIRC EnvGen still does a single control period of interpolation if a segment time is 0, so it would be good to catch this case, I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!

inEnvir { |envir|
envir ?? { envir = currentEnvironment };
^{ |... args| envir.use({ this.valueArray(args) }) }
}

loadToFloatArray { arg duration = 0.01, server, action;
var buffer, def, synth, name, numChannels, val, rate;
asBuffer { |duration = 0.01, server, action, fadeTime|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my note above about using fadeTime = 0


^buffer


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please remove the extra whitespace here?

loadToFloatArray { arg duration = 0.01, server, action;
var buffer, def, synth, name, numChannels, val, rate;
asBuffer { |duration = 0.01, server, action, fadeTime|
var buffer, def, synth, name, numChannels, rate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks!

@mossheim mossheim merged commit a6af626 into supercollider:master Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants