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
class library: plot relative to target synth #3088
Changes from 2 commits
22b12ca
c86f706
c070baa
7a61b64
b65aa0b
22247f2
2d5f1e8
471f411
24cf38f
52c7ff5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,6 +425,9 @@ A zoom value for the scope's X axis. Larger values show more. The default is 1. | |
|
||
method::plot | ||
|
||
note::See link::Reference/plot:: for a general reference on plotting:: | ||
|
||
|
||
Calculates duration in seconds worth of the output of this function asynchronously, and plots it in a GUI window. Unlike play and scope it will not work with explicit Out Ugens, so your function should return a UGen or an Array of them. The plot will be calculated in realtime. | ||
|
||
code:: | ||
|
@@ -434,19 +437,26 @@ code:: | |
:: | ||
|
||
|
||
|
||
argument::duration | ||
The duration of the function to plot in seconds. The default is 0.01. | ||
argument::server | ||
The Server on which to calculate the plot. This must be running on your local machine, but does not need to be the internal server. If nil the default server will be used. | ||
argument::target | ||
The target node on which to calculate the plot. See link::Reference/asTarget::. If it is a link::Classes/Server::, it must be running on your local machine, but does not need to be the internal server (see link::Classes/Buffer#-loadToFloatArray:: for details). | ||
code:: | ||
( | ||
var synth = { Out.ar(99, SinOsc.ar([300, 700])) }.play; | ||
{ In.ar(99, 2) }.plot(0.02, synth); | ||
) | ||
:: | ||
|
||
argument::bounds | ||
An instance of Rect or Point indicating the bounds of the plot window. | ||
argument::minval | ||
the minimum value in the plot. Defaults to -1.0. | ||
argument::maxval | ||
the maximum value in the plot. Defaults to 1.0. | ||
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. | ||
If set to code::true::, for multichannel signals use separate value display ranges. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are these specified? |
||
|
||
|
||
method::asBuffer | ||
|
@@ -455,8 +465,8 @@ Calculates duration in seconds worth of the output of this function asynchronous | |
argument::duration | ||
The duration of the function to plot in seconds. The default is 0.01. | ||
|
||
argument::server | ||
The server on which the function is calculated. The default is code::Server.default::. | ||
argument::target | ||
The synth or group after which the synth runs (see link::Reference/asTarget::). The default is the default group of code::Server.default::. | ||
|
||
argument::action | ||
A function that is called when the buffer is filled. It is passed the buffer as argument. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,9 +263,11 @@ Function : AbstractFunction { | |
^{ |... args| envir.use({ this.valueArray(args) }) } | ||
} | ||
|
||
asBuffer { |duration = 0.01, server, action, fadeTime = (0)| | ||
var buffer, def, synth, name, numChannels, rate; | ||
server = server ? Server.default; | ||
asBuffer { |duration = 0.01, target, action, fadeTime = (0)| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also breaking change |
||
var buffer, def, synth, name, numChannels, rate, server; | ||
target = target.asTarget; | ||
server = target.server; | ||
|
||
|
||
name = this.hash.asString; | ||
def = SynthDef(name, { |bufnum| | ||
|
@@ -301,7 +303,7 @@ Function : AbstractFunction { | |
server.sync; | ||
def.send(server); | ||
server.sync; | ||
synth = Synth(name, [\bufnum, buffer], server); | ||
synth = Synth(name, [\bufnum, buffer], target, \addAfter); | ||
OSCFunc({ | ||
action.value(buffer); | ||
server.sendMsg("/d_free", name); | ||
|
@@ -311,8 +313,8 @@ Function : AbstractFunction { | |
^buffer | ||
} | ||
|
||
loadToFloatArray { |duration = 0.01, server, action| | ||
this.asBuffer(duration, server, { |buffer| | ||
loadToFloatArray { |duration = 0.01, target, action| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, breaking change |
||
this.asBuffer(duration, target, { |buffer| | ||
buffer.loadToFloatArray(action: { |array| | ||
action.value(array, buffer); | ||
buffer.free | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -769,14 +769,13 @@ Plotter { | |
|
||
|
||
+ Function { | ||
plot { |duration = 0.01, server, bounds, minval, maxval, separately = false| | ||
|
||
plot { |duration = 0.01, target, bounds, minval, maxval, separately = false| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changing function parameter names is a breaking change... |
||
var name = this.asCompileString, plotter; | ||
if(name.size > 50 or: { name.includes(Char.nl) }) { name = "function plot" }; | ||
plotter = Plotter(name, bounds); | ||
plotter.value = [0.0]; | ||
|
||
this.loadToFloatArray(duration, server, { |array, buf| | ||
this.loadToFloatArray(duration, target, { |array, buf| | ||
var numChan = buf.numChannels; | ||
{ | ||
plotter.setValue( | ||
|
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.
Does the implementation really require a local server? Why? getToFloatArray should work or?
Also, it would be useful to explain what's happening (addAfter) with target and why. With Function:plot presumably target only matters if you are reading from a bus. I find 'on which to calculate the plot' a bit enigmatic for newbies.
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.
It uses
loadToFloatArray
, presumably for speed. In general, the class library seems to avoidgetToFloatArray
; I'm not sure why.For the default 100ms plot duration, get... rather than load... will not be any slower -- might even be faster. For longer plots, load... is much faster.
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 think getToFloatArray was added later, and everyone, including me, is copying the old one.
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.
IAC plotting on remote servers seems desirable.
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.
Also, I think the
getToFloatArray
looks more complicated and insecure with thewait
andtimeout
arguments. Also the argument namesindex
andcount
don't match the ones ofloadToFloatArray
.That might be the reason. Maybe we need the same thing as we have for SynthDef, something that tries to send first and if that fails, tries to load? All packed under a clean interface.