Skip to content

bufferSetn not working as expected #115

@relativeflux

Description

@relativeflux

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions