Hello to all,
I have a question maybe for @tedmoore or @tremblap ? but a solution from anybody is welcome too.
I 'd like to pass a buffer as argument to a SynthDef for feeding a FluidBufToKr UGen.
The documentation for the argument buffer of the FluidBufToKr stated:
" buffer Either a Buffer object or an index pointing to a buffer that this pseudo UGen will read out of…"
But I have an error message (entire message at the end of the post) when I try to pass a bufnum or even an instance of Buffer as an argument.
Here is a piece of code to illustrate the problem:
(
s.waitForBoot{ arg predicting = 0;
var xydata = FluidDataSet(s);
var paramsdata = FluidDataSet(s);
var xybuf = Buffer.alloc(s, 2);
var paramsbuf = Buffer.alloc(s, 10);
var mlp = FluidMLPRegressor(s,
[7],
activation: FluidMLPRegressor.sigmoid,
outputActivation: FluidMLPRegressor.sigmoid,
maxIter: 1000,
learnRate: 0.1,
batchSize: 1,
validation: 0
);
{
var values, xy, trig;
xy = FluidBufToKr.kr(xybuf);
trig = Mix(Changed.kr(xy));
mlp.kr(trig * predicting, xybuf, paramsbuf);
values = FluidBufToKr.kr(paramsbuf);
/*...*/
}.play;
};
)
(
s.waitForBoot{
var xydata = FluidDataSet(s);
var paramsdata = FluidDataSet(s);
var xybuf = Buffer.alloc(s, 2);
var paramsbuf = Buffer.alloc(s, 10);
var mlp = FluidMLPRegressor(s,
[7],
activation: FluidMLPRegressor.sigmoid,
outputActivation: FluidMLPRegressor.sigmoid,
maxIter: 1000,
learnRate: 0.1,
batchSize: 1,
validation: 0
);
{
SynthDef(\regressor, { arg xybuf, paramsbuf, predicting = 0;
var values, xy, trig;
xy = FluidBufToKr.kr(xybuf);
trig = Mix(Changed.kr(xy)) * predicting;
mlp.kr(trig, xybuf, paramsbuf);
values = FluidBufToKr.kr(paramsbuf);
/*...*/
}).add;
s.sync;
Synth(\regressor, [\xybuf, xybuf.bufnum, \paramsbuf, paramsbuf.bufnum, \predicting, 0]);
}.fork;
};
)
First block of code: No error message.
Second block of code: error:
ERROR: Meta_FluidBufToKr if no buffer is specified, numFrames must be a value >= 1.
PROTECTED CALL STACK:
Meta_FluidBufToKr:kr 0x614de35ba500
arg this = FluidBufToKr
arg buffer = an OutputProxy
arg startFrame = 0
arg numFrames = -1
a FunctionDef 0x614de5055098
sourceCode = "<an open Function>"
arg xybuf = an OutputProxy
arg paramsbuf = an OutputProxy
arg predicting = an OutputProxy
var values = nil
var xy = nil
var trig = nil
SynthDef:buildUgenGraph 0x614de40ac040
arg this = SynthDef:regressor
arg func = a Function
arg rates = nil
arg prependArgs = [ ]
var result = nil
var saveControlNames = nil
a FunctionDef 0x614de40aa5c0
sourceCode = "<an open Function>"
Function:prTry 0x614de23dd000
arg this = a Function
var result = nil
var thread = a Routine
var next = nil
var wasInProtectedFunc = false
CALL STACK:
Exception:reportError
arg this = <instance of Error>
Nil:handleError
arg this = nil
arg error = <instance of Error>
Thread:handleError
arg this = <instance of Thread>
arg error = <instance of Error>
Thread:handleError
arg this = <instance of Routine>
arg error = <instance of Error>
Object:throw
arg this = <instance of Error>
Function:protect
arg this = <instance of Function>
arg handler = <instance of Function>
var result = <instance of Error>
SynthDef:build
arg this = <instance of SynthDef>
arg ugenGraphFunc = <instance of Function>
arg rates = nil
arg prependArgs = nil
< FunctionDef in closed FunctionDef > (no arguments or variables)
Routine:prStart
arg this = <instance of Routine>
arg inval = 631.683702033
^^ The preceding error dump is for ERROR: Meta_FluidBufToKr if no buffer is specified, numFrames must be a value >= 1.