Skip to content

Add asInteger to numFrames & numChannels of Buffer.alloc & Buffer.getToFloatArray - #7472

Open
prko wants to merge 2 commits into
supercollider:developfrom
prko:topic/add_asInteger_to_numFrames_&numChannels_of_Buffer.alloc_&.getToFloatArray
Open

prko wants to merge 2 commits into
supercollider:developfrom
prko:topic/add_asInteger_to_numFrames_&numChannels_of_Buffer.alloc_&.getToFloatArray

Conversation

@prko

@prko prko commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

fixes #7462

Purpose and Motivation

This PR resolves the error triggered by evaluating the following example code from #7462:

b = Buffer.alloc(s, 6890.625, 10);

// actually, you don't need any data
a = { RecordBuf.ar(Array.fill(10, { WhiteNoise.ar }), b, loop: 0, doneAction: 2); Silent.ar(1) }.play;

b.getToFloatArray(wait: -1, timeout: 10, action: { |data| data.postln });

However, if this example code is not expected to throw an error without truncating 6890.625, then I have misunderstood the issue, and this PR should probably be closed.

As far as I understand it, there are two possible ways to address the issue:

  1. Add .asInteger to var count in the getToFloatArray method.
    At the moment, the implementation applies .asInteger to (numFrames * numChannels), which may lead to an incorrect calculation.

  2. Add .asInteger to numFrames and numChannels in Buffer.alloc.
    The documentation says that numFrames and numChannels are truncated, but the corresponding method does not currently do this. This commit would make the implementation consistent with the documentation.

I put the second approach in a separate PR (#7471), but my impression is that it is better left as a draft for now. That is why I opened this new PR instead.

Types of changes

  • Bug fix

To-do list

  • Code is tested
  • All tests are passing
  • This PR is ready for review

@prko prko changed the title Topic/add as integer to num frames &num channels of buffer.alloc &.get to float array Add asInteger to numFrames & numChannels of Buffer.alloc & Buffer.getToFloatArray Apr 26, 2026
@prko

prko commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

I would appreciate feedback on whether this PR could be merged after making the necessary changes, or if it should be closed due to a misunderstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fractional numFrames causes Buffer:getToFloatArray to fail

1 participant