supercolliderjs icon indicating copy to clipboard operation
supercolliderjs copied to clipboard

bufferSetn not working as expected

Open relativeflux opened this issue 3 years ago • 0 comments

I am attempting to use bufferSetn to set samples into a pre-allocated buffer, but it's not working for me. I allocate the buffer like this:

await server.buffer(10);

Then I try to set it like this:

const payload = [
  -0.000732421875,
  0.00103759765625,
  -0.000823974609375,
  0.00103759765625,
  -0.00103759765625,
  0.000732421875,
  -0.000732421875,
  0.000823974609375,
  -0.000732421875,
  0.000823974609375
];

sc.server.msg.bufferSetn(0, 0, payload);

But when I subsequently use bufferGetn to interrogate the buffer contents it shows it to be still empty:

console.log(await server.callAndResponse(sc.server.msg.bufferGetn(0, 0, 10)));

Using readBuffer works fine, in that case bufferGetn shows me that the contents of the buffer have been set (readBuffer allocates it's own buffer, though).

What am I doing wrong? Is this the expected result?

relativeflux avatar Jan 22 '22 12:01 relativeflux