-
Notifications
You must be signed in to change notification settings - Fork 2
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 poll-like that
to Ugens
#6
Comments
Since from one UGen/SynthDef you can make many Units/Synths this is a little tricky from an administrative point of view. But there is an example of how this could work in the |
Thanks for the hint, I wrote a first draft today which finally allows to use sclang code/callbacks on the server side in an easy manner :)
+ UGen {
that { | callback, trigger |
var oscAddress = "/that/ugen/%".format(UniqueID.next);
callback = callback ? {};
trigger = trigger ? Impulse.kr(10.0);
SendReply.perform(
UGen.methodSelectorForRate(trigger.rate),
trigger, // trig
oscAddress, // cmdName
this, // values
);
OSCdef(key: oscAddress, func: { |msg|
var nodeId, replyId, values;
#nodeId, replyId ... values = msg[1..];
callback.(values, nodeId);
}, path: oscAddress).fix;
}
}
UsageNdefs(
Ndef(\foo, {
var sigA = SinOsc.ar(0.1).that({|r, nodeId| ["foo", r, nodeId].postln});
var sigB = LFSaw.ar(0.1).that({|r, nodeId| ["bar", r, nodeId].postln});
[sigA, sigB];
}).play;
) prints
Updating the callback is possible by re-evaluating the Ndef. SynthDefs(
SynthDef(\foobar, {|out|
var sig = (SinOsc.ar(\freq.kr(2.0))).that({|r, n| [n, r].postln});
sig * EnvGen.kr(Env.perc, doneAction: Done.freeSelf);
Out.ar(out, sig);
}).add;
)
(
{
a = Synth(\foobar);
2.0.wait;
b = Synth(\foobar);
}.fork;
) prints
Do you think this should be included to the lib? |
Is it possible to use
SinOsc.ar(200).that(....)
on any Ugen within a SynthDef? I really enjoy using LFO values in visualisations etc. viaThat.identity
but having this directly available would be great as in such a case I would not have to create multiple sub-busses/Ndefs.Could this be implemented by wrapping the Ugen with a
SendReply
which is setup according to the That specification?A first sketch could look like
SinOsc.ar.that(callback: {|r| myVisualOSC.sendMsg("/foo", r)}, trigger: {|in| in>0.5})
.The text was updated successfully, but these errors were encountered: