RNBO codebox~ : passing a buffer or data to a function
In RNBO codebox~, passing a buffer or data to a function as its argument causes a compile error.
For example :
const bufferSize = 1024;
@state buffer0 = new data(bufferSize);
@state buffer1 = new data(bufferSize);
process(buffer0);
process(buffer1);
function process(_buffer) {
let v = random(-1, 1);
let i = floor(random(bufferSize));
poke(_buffer, v, i);
}
What am I missing here?
Thanks in advance.
It isn't possible right now unfortunately, function arguments are pretty restrictive, we do have a ticket in to resolve this.
Here is a workaround (btw, i fixed up your 2nd random call too):
const bufferSize = 1024;
@state buffer0 = new data(bufferSize);
@state buffer1 = new data(bufferSize);
let dummy = in1;
function process(b: Index) {
let _buffer: BufferRef = b == 0 ? buffer0 : buffer1;
let v = random(-1, 1);
let i = floor(random(0, bufferSize - 1));
poke(_buffer, v, i);
}
process(0);
process(1);
Thanks a lot, Alex.
I've been using the RNBO codebox~ extensively recently and have found it incredibly powerful for creating non-standard synthesis and processing of sound. I really appreciate the efforts you and your team have put into it.
BTW, I think my workaround should work but I just tried it in a development build for our next released RNBO, not in the latest 1.3.4 release.