Welcome @heretogo , thanks for your question!
Do you mean you’d like to have the function return as if it were a synchronous function in the main thread? I don’t think it can be done without running the whole thing in a Routine
or similar, because the processing and buffer fetching from the server are both asynchronous, so you need to make things block.
(
~getFrequencies = {|in|
var out;
var cond = Condition.new;
var outBuf = Buffer.new;
FluidBufPitch.process(s, in, features: outBuf,
action:{outBuf.loadToFloatArray(
action: {|x|
out = x.reshape((x.size()/2).asInteger, 2);
cond.unhang;
}
)
}
);
cond.hang;
out
};
fork{
b = Buffer.read(s, File.realpath(FluidBufPitch.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-ASWINE-ScratchySynth-M.wav");
s.sync;
~getFrequencies.value(b).postln;
}
)